Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
package org.elasticsearch.aggregations.metric;

import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.search.aggregations.support.ValuesSource;

Expand All @@ -34,7 +34,7 @@ public NumericArrayValuesSource(Map<String, ValuesSource.Numeric> valuesSources,
}
}

public NumericDoubleValues getField(final int ordinal, LeafReaderContext ctx) throws IOException {
public DoubleValues getField(final int ordinal, LeafReaderContext ctx) throws IOException {
if (ordinal > names.length) {
throw new IndexOutOfBoundsException("ValuesSource array index " + ordinal + " out of bounds");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
*/
package org.elasticsearch.aggregations.metric;

import org.apache.lucene.search.DoubleValues;
import org.apache.lucene.search.ScoreMode;
import org.elasticsearch.common.util.ObjectArray;
import org.elasticsearch.core.Releasables;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.search.MultiValueMode;
import org.elasticsearch.search.aggregations.AggregationExecutionContext;
import org.elasticsearch.search.aggregations.Aggregator;
Expand Down Expand Up @@ -62,7 +62,7 @@ public LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCtx,
if (valuesSources == null) {
return LeafBucketCollector.NO_OP_COLLECTOR;
}
final NumericDoubleValues[] values = new NumericDoubleValues[valuesSources.fieldNames().length];
final DoubleValues[] values = new DoubleValues[valuesSources.fieldNames().length];
for (int i = 0; i < values.length; ++i) {
values[i] = valuesSources.getField(i, aggCtx.getLeafReaderContext());
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public void collect(int doc, long bucket) throws IOException {
private boolean includeDocument(int doc) throws IOException {
// loop over fields
for (int i = 0; i < fieldVals.length; ++i) {
final NumericDoubleValues doubleValues = values[i];
final DoubleValues doubleValues = values[i];
if (doubleValues.advanceExact(doc)) {
final double value = doubleValues.doubleValue();
if (value == Double.NEGATIVE_INFINITY) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.search.MultiValueMode;

import java.io.IOException;
Expand Down Expand Up @@ -41,7 +40,7 @@ class DateMethodValueSource extends FieldDataValueSource {
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
return new DoubleValues() {
@Override
public double doubleValue() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.search.MultiValueMode;

import java.io.IOException;
Expand Down Expand Up @@ -46,7 +45,7 @@ class DateObjectValueSource extends FieldDataValueSource {
@Override
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
return new DoubleValues() {
@Override
public double doubleValue() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.search.MultiValueMode;

import java.io.IOException;
Expand Down Expand Up @@ -54,7 +53,7 @@ public int hashCode() {
@Override
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
return new DoubleValues() {
@Override
public double doubleValue() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.elasticsearch.index.mapper.extras;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DoubleValues;
import org.apache.lucene.search.LongValues;
import org.apache.lucene.search.Query;
import org.elasticsearch.common.Explicit;
Expand All @@ -25,7 +26,6 @@
import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericLongValues;
import org.elasticsearch.index.fielddata.SourceValueFetcherSortedDoubleIndexFieldData;
Expand Down Expand Up @@ -836,7 +836,7 @@ public SortedNumericDoubleValues getDoubleValues() {
final SortedNumericLongValues values = scaledFieldData.getLongValues();
final LongValues singleValues = SortedNumericLongValues.unwrapSingleton(values);
if (singleValues != null) {
return FieldData.singleton(new NumericDoubleValues() {
return FieldData.singleton(new DoubleValues() {
@Override
public boolean advanceExact(int doc) throws IOException {
return singleValues.advanceExact(doc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
package org.elasticsearch.common.geo;

import org.apache.lucene.geo.GeoEncodingUtils;
import org.apache.lucene.search.DoubleValues;
import org.apache.lucene.util.SloppyMath;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.common.unit.DistanceUnit;
Expand All @@ -18,7 +19,6 @@
import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.GeoPointValues;
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.SortingNumericDoubleValues;
import org.elasticsearch.xcontent.NamedXContentRegistry;
Expand Down Expand Up @@ -525,7 +525,7 @@ public static SortedNumericDoubleValues distanceValues(
) {
final GeoPointValues singleValues = FieldData.unwrapSingleton(geoPointValues);
if (singleValues != null && fromPoints.length == 1) {
return FieldData.singleton(new NumericDoubleValues() {
return FieldData.singleton(new DoubleValues() {

@Override
public boolean advanceExact(int doc) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.lucene.index.SortedDocValues;
import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.index.SortedSetDocValues;
import org.apache.lucene.search.DoubleValues;
import org.apache.lucene.search.LongValues;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
Expand All @@ -37,29 +38,11 @@ public static SortedBinaryDocValues emptySortedBinary() {
return singleton(DocValues.emptyBinary());
}

/**
* Return a {@link NumericDoubleValues} that doesn't contain any value.
*/
public static NumericDoubleValues emptyNumericDouble() {
return new NumericDoubleValues() {
@Override
public boolean advanceExact(int doc) {
return false;
}

@Override
public double doubleValue() {
throw new UnsupportedOperationException();
}

};
}

/**
* Return a {@link SortedNumericDoubleValues} that doesn't contain any value.
*/
public static SortedNumericDoubleValues emptySortedNumericDoubles() {
return singleton(emptyNumericDouble());
return singleton(DoubleValues.EMPTY);
}

/**
Expand Down Expand Up @@ -132,7 +115,7 @@ public boolean advanceExact(int doc) throws IOException {
* {@link org.apache.lucene.util.NumericUtils#doubleToSortableLong(double)}.
*/
public static SortedNumericLongValues toSortableLongBits(SortedNumericDoubleValues values) {
final NumericDoubleValues singleton = unwrapSingleton(values);
final DoubleValues singleton = unwrapSingleton(values);
if (singleton != null) {
final LongValues longBits;
if (singleton instanceof SortableLongBitsToNumericDoubleValues) {
Expand All @@ -158,7 +141,7 @@ public static SortedNumericLongValues toSortableLongBits(SortedNumericDoubleValu
public static SortedNumericDoubleValues sortableLongBitsToDoubles(SortedNumericLongValues values) {
final LongValues singleton = SortedNumericLongValues.unwrapSingleton(values);
if (singleton != null) {
final NumericDoubleValues doubles;
final DoubleValues doubles;
if (singleton instanceof SortableLongBitsNumericDocValues) {
doubles = ((SortableLongBitsNumericDocValues) singleton).getDoubleValues();
} else {
Expand Down Expand Up @@ -190,7 +173,7 @@ public static SortedNumericDoubleValues castToDouble(final SortedNumericLongValu
* Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs.
*/
public static SortedNumericLongValues castToLong(final SortedNumericDoubleValues values) {
final NumericDoubleValues singleton = unwrapSingleton(values);
final DoubleValues singleton = unwrapSingleton(values);
if (singleton != null) {
return SortedNumericLongValues.singleton(new LongCastedValues(singleton));
} else {
Expand All @@ -199,9 +182,9 @@ public static SortedNumericLongValues castToLong(final SortedNumericDoubleValues
}

/**
* Returns a multi-valued view over the provided {@link NumericDoubleValues}.
* Returns a multi-valued view over the provided {@link DoubleValues}.
*/
public static SortedNumericDoubleValues singleton(NumericDoubleValues values) {
public static SortedNumericDoubleValues singleton(DoubleValues values) {
return new SingletonSortedNumericDoubleValues(values);
}

Expand All @@ -210,7 +193,7 @@ public static SortedNumericDoubleValues singleton(NumericDoubleValues values) {
* if it was previously wrapped with {@link DocValues#singleton(NumericDocValues)},
* or null.
*/
public static NumericDoubleValues unwrapSingleton(SortedNumericDoubleValues values) {
public static DoubleValues unwrapSingleton(SortedNumericDoubleValues values) {
if (values instanceof SingletonSortedNumericDoubleValues) {
return ((SingletonSortedNumericDoubleValues) values).getNumericDoubleValues();
}
Expand Down Expand Up @@ -297,7 +280,7 @@ public CharSequence get() throws IOException {
*/
public static SortedBinaryDocValues toString(final SortedNumericDoubleValues values) {
{
final NumericDoubleValues singleton = FieldData.unwrapSingleton(values);
final DoubleValues singleton = FieldData.unwrapSingleton(values);
if (singleton != null) {
return FieldData.singleton(toString(singleton));
}
Expand All @@ -322,7 +305,7 @@ public void get(List<CharSequence> list) throws IOException {
* typically used for scripts or for the `map` execution mode of terms aggs.
* NOTE: this is very slow!
*/
public static BinaryDocValues toString(final NumericDoubleValues values) {
public static BinaryDocValues toString(final DoubleValues values) {
return toString(new ToStringValue() {
@Override
public boolean advanceExact(int doc) throws IOException {
Expand Down Expand Up @@ -505,7 +488,7 @@ private interface ToStringValue {

}

private static class DoubleCastedValues extends NumericDoubleValues {
private static class DoubleCastedValues extends DoubleValues {

private final LongValues values;

Expand Down Expand Up @@ -552,9 +535,9 @@ public int docValueCount() {

private static class LongCastedValues extends LongValues {

private final NumericDoubleValues values;
private final DoubleValues values;

LongCastedValues(NumericDoubleValues values) {
LongCastedValues(DoubleValues values) {
this.values = values;
}

Expand Down Expand Up @@ -636,11 +619,11 @@ public long longValue() {
}

/**
* Return a {@link NumericDoubleValues} instance that has a value for every
* Return a {@link DoubleValues} instance that has a value for every
* document, returns the same value as {@code values} if there is a value
* for the current document and {@code missing} otherwise.
*/
public static DenseDoubleValues replaceMissing(NumericDoubleValues values, double missing) {
public static DenseDoubleValues replaceMissing(DoubleValues values, double missing) {
return new DenseDoubleValues() {

private double value;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

package org.elasticsearch.index.fielddata;

import org.apache.lucene.search.DoubleValues;

import java.io.IOException;

/**
Expand All @@ -18,14 +20,14 @@
* that works for single or multi-valued types.
*/
final class SingletonSortedNumericDoubleValues extends SortedNumericDoubleValues {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be renamed? And same question for the other files that still have "NumericDoubleValues" in their name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, there are a few more classes here that can be renamed. I'll do them as follow-ups, given that eg SortedNumericDoubleValues is used in a lot of places so would make this a very noisy commit.

private final NumericDoubleValues in;
private final DoubleValues in;

SingletonSortedNumericDoubleValues(NumericDoubleValues in) {
SingletonSortedNumericDoubleValues(DoubleValues in) {
this.in = in;
}

/** Return the wrapped {@link NumericDoubleValues} */
public NumericDoubleValues getNumericDoubleValues() {
/** Return the wrapped {@link DoubleValues} */
public DoubleValues getNumericDoubleValues() {
return in;
}

Expand Down
Loading