Skip to content

Commit 7b6ebf6

Browse files
authored
Remove NumericDoubleValues class (#137884)
With the addition of DenseDoubleValues, this class is just an empty extension of lucene's DoubleValues and can be safely removed.
1 parent edddc82 commit 7b6ebf6

File tree

39 files changed

+116
-206
lines changed

39 files changed

+116
-206
lines changed

modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/ArrayValuesSource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
package org.elasticsearch.aggregations.metric;
1010

1111
import org.apache.lucene.index.LeafReaderContext;
12-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
12+
import org.apache.lucene.search.DoubleValues;
1313
import org.elasticsearch.search.MultiValueMode;
1414
import org.elasticsearch.search.aggregations.support.ValuesSource;
1515

@@ -34,7 +34,7 @@ public NumericArrayValuesSource(Map<String, ValuesSource.Numeric> valuesSources,
3434
}
3535
}
3636

37-
public NumericDoubleValues getField(final int ordinal, LeafReaderContext ctx) throws IOException {
37+
public DoubleValues getField(final int ordinal, LeafReaderContext ctx) throws IOException {
3838
if (ordinal > names.length) {
3939
throw new IndexOutOfBoundsException("ValuesSource array index " + ordinal + " out of bounds");
4040
}

modules/aggregations/src/main/java/org/elasticsearch/aggregations/metric/MatrixStatsAggregator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
*/
99
package org.elasticsearch.aggregations.metric;
1010

11+
import org.apache.lucene.search.DoubleValues;
1112
import org.apache.lucene.search.ScoreMode;
1213
import org.elasticsearch.common.util.ObjectArray;
1314
import org.elasticsearch.core.Releasables;
14-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
1515
import org.elasticsearch.search.MultiValueMode;
1616
import org.elasticsearch.search.aggregations.AggregationExecutionContext;
1717
import org.elasticsearch.search.aggregations.Aggregator;
@@ -62,7 +62,7 @@ public LeafBucketCollector getLeafCollector(AggregationExecutionContext aggCtx,
6262
if (valuesSources == null) {
6363
return LeafBucketCollector.NO_OP_COLLECTOR;
6464
}
65-
final NumericDoubleValues[] values = new NumericDoubleValues[valuesSources.fieldNames().length];
65+
final DoubleValues[] values = new DoubleValues[valuesSources.fieldNames().length];
6666
for (int i = 0; i < values.length; ++i) {
6767
values[i] = valuesSources.getField(i, aggCtx.getLeafReaderContext());
6868
}
@@ -93,7 +93,7 @@ public void collect(int doc, long bucket) throws IOException {
9393
private boolean includeDocument(int doc) throws IOException {
9494
// loop over fields
9595
for (int i = 0; i < fieldVals.length; ++i) {
96-
final NumericDoubleValues doubleValues = values[i];
96+
final DoubleValues doubleValues = values[i];
9797
if (doubleValues.advanceExact(doc)) {
9898
final double value = doubleValues.doubleValue();
9999
if (value == Double.NEGATIVE_INFINITY) {

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateMethodValueSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.apache.lucene.search.DoubleValues;
1414
import org.elasticsearch.index.fielddata.IndexFieldData;
1515
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
16-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
1716
import org.elasticsearch.search.MultiValueMode;
1817

1918
import java.io.IOException;
@@ -41,7 +40,7 @@ class DateMethodValueSource extends FieldDataValueSource {
4140
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
4241
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
4342
final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT);
44-
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
43+
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
4544
return new DoubleValues() {
4645
@Override
4746
public double doubleValue() throws IOException {

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/DateObjectValueSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import org.apache.lucene.search.DoubleValues;
1414
import org.elasticsearch.index.fielddata.IndexFieldData;
1515
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
16-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
1716
import org.elasticsearch.search.MultiValueMode;
1817

1918
import java.io.IOException;
@@ -46,7 +45,7 @@ class DateObjectValueSource extends FieldDataValueSource {
4645
@Override
4746
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
4847
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
49-
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
48+
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
5049
return new DoubleValues() {
5150
@Override
5251
public double doubleValue() throws IOException {

modules/lang-expression/src/main/java/org/elasticsearch/script/expression/FieldDataValueSource.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.apache.lucene.search.DoubleValues;
1515
import org.elasticsearch.index.fielddata.IndexFieldData;
1616
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
17-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
1817
import org.elasticsearch.search.MultiValueMode;
1918

2019
import java.io.IOException;
@@ -54,7 +53,7 @@ public int hashCode() {
5453
@Override
5554
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
5655
LeafNumericFieldData leafData = (LeafNumericFieldData) fieldData.load(leaf);
57-
NumericDoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
56+
DoubleValues docValues = multiValueMode.select(leafData.getDoubleValues());
5857
return new DoubleValues() {
5958
@Override
6059
public double doubleValue() throws IOException {

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/extras/ScaledFloatFieldMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.index.mapper.extras;
1111

1212
import org.apache.lucene.index.LeafReaderContext;
13+
import org.apache.lucene.search.DoubleValues;
1314
import org.apache.lucene.search.LongValues;
1415
import org.apache.lucene.search.Query;
1516
import org.elasticsearch.common.Explicit;
@@ -25,7 +26,6 @@
2526
import org.elasticsearch.index.fielddata.IndexFieldData;
2627
import org.elasticsearch.index.fielddata.IndexNumericFieldData;
2728
import org.elasticsearch.index.fielddata.LeafNumericFieldData;
28-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
2929
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
3030
import org.elasticsearch.index.fielddata.SortedNumericLongValues;
3131
import org.elasticsearch.index.fielddata.SourceValueFetcherSortedDoubleIndexFieldData;
@@ -836,7 +836,7 @@ public SortedNumericDoubleValues getDoubleValues() {
836836
final SortedNumericLongValues values = scaledFieldData.getLongValues();
837837
final LongValues singleValues = SortedNumericLongValues.unwrapSingleton(values);
838838
if (singleValues != null) {
839-
return FieldData.singleton(new NumericDoubleValues() {
839+
return FieldData.singleton(new DoubleValues() {
840840
@Override
841841
public boolean advanceExact(int doc) throws IOException {
842842
return singleValues.advanceExact(doc);

server/src/main/java/org/elasticsearch/common/geo/GeoUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.elasticsearch.common.geo;
1111

1212
import org.apache.lucene.geo.GeoEncodingUtils;
13+
import org.apache.lucene.search.DoubleValues;
1314
import org.apache.lucene.util.SloppyMath;
1415
import org.elasticsearch.ElasticsearchParseException;
1516
import org.elasticsearch.common.unit.DistanceUnit;
@@ -18,7 +19,6 @@
1819
import org.elasticsearch.index.fielddata.FieldData;
1920
import org.elasticsearch.index.fielddata.GeoPointValues;
2021
import org.elasticsearch.index.fielddata.MultiGeoPointValues;
21-
import org.elasticsearch.index.fielddata.NumericDoubleValues;
2222
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
2323
import org.elasticsearch.index.fielddata.SortingNumericDoubleValues;
2424
import org.elasticsearch.xcontent.NamedXContentRegistry;
@@ -525,7 +525,7 @@ public static SortedNumericDoubleValues distanceValues(
525525
) {
526526
final GeoPointValues singleValues = FieldData.unwrapSingleton(geoPointValues);
527527
if (singleValues != null && fromPoints.length == 1) {
528-
return FieldData.singleton(new NumericDoubleValues() {
528+
return FieldData.singleton(new DoubleValues() {
529529

530530
@Override
531531
public boolean advanceExact(int doc) throws IOException {

server/src/main/java/org/elasticsearch/index/fielddata/FieldData.java

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.lucene.index.SortedDocValues;
1616
import org.apache.lucene.index.SortedNumericDocValues;
1717
import org.apache.lucene.index.SortedSetDocValues;
18+
import org.apache.lucene.search.DoubleValues;
1819
import org.apache.lucene.search.LongValues;
1920
import org.apache.lucene.util.BytesRef;
2021
import org.apache.lucene.util.BytesRefBuilder;
@@ -37,29 +38,11 @@ public static SortedBinaryDocValues emptySortedBinary() {
3738
return singleton(DocValues.emptyBinary());
3839
}
3940

40-
/**
41-
* Return a {@link NumericDoubleValues} that doesn't contain any value.
42-
*/
43-
public static NumericDoubleValues emptyNumericDouble() {
44-
return new NumericDoubleValues() {
45-
@Override
46-
public boolean advanceExact(int doc) {
47-
return false;
48-
}
49-
50-
@Override
51-
public double doubleValue() {
52-
throw new UnsupportedOperationException();
53-
}
54-
55-
};
56-
}
57-
5841
/**
5942
* Return a {@link SortedNumericDoubleValues} that doesn't contain any value.
6043
*/
6144
public static SortedNumericDoubleValues emptySortedNumericDoubles() {
62-
return singleton(emptyNumericDouble());
45+
return singleton(DoubleValues.EMPTY);
6346
}
6447

6548
/**
@@ -132,7 +115,7 @@ public boolean advanceExact(int doc) throws IOException {
132115
* {@link org.apache.lucene.util.NumericUtils#doubleToSortableLong(double)}.
133116
*/
134117
public static SortedNumericLongValues toSortableLongBits(SortedNumericDoubleValues values) {
135-
final NumericDoubleValues singleton = unwrapSingleton(values);
118+
final DoubleValues singleton = unwrapSingleton(values);
136119
if (singleton != null) {
137120
final LongValues longBits;
138121
if (singleton instanceof SortableLongBitsToNumericDoubleValues) {
@@ -158,7 +141,7 @@ public static SortedNumericLongValues toSortableLongBits(SortedNumericDoubleValu
158141
public static SortedNumericDoubleValues sortableLongBitsToDoubles(SortedNumericLongValues values) {
159142
final LongValues singleton = SortedNumericLongValues.unwrapSingleton(values);
160143
if (singleton != null) {
161-
final NumericDoubleValues doubles;
144+
final DoubleValues doubles;
162145
if (singleton instanceof SortableLongBitsNumericDocValues) {
163146
doubles = ((SortableLongBitsNumericDocValues) singleton).getDoubleValues();
164147
} else {
@@ -190,7 +173,7 @@ public static SortedNumericDoubleValues castToDouble(final SortedNumericLongValu
190173
* Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs.
191174
*/
192175
public static SortedNumericLongValues castToLong(final SortedNumericDoubleValues values) {
193-
final NumericDoubleValues singleton = unwrapSingleton(values);
176+
final DoubleValues singleton = unwrapSingleton(values);
194177
if (singleton != null) {
195178
return SortedNumericLongValues.singleton(new LongCastedValues(singleton));
196179
} else {
@@ -199,9 +182,9 @@ public static SortedNumericLongValues castToLong(final SortedNumericDoubleValues
199182
}
200183

201184
/**
202-
* Returns a multi-valued view over the provided {@link NumericDoubleValues}.
185+
* Returns a multi-valued view over the provided {@link DoubleValues}.
203186
*/
204-
public static SortedNumericDoubleValues singleton(NumericDoubleValues values) {
187+
public static SortedNumericDoubleValues singleton(DoubleValues values) {
205188
return new SingletonSortedNumericDoubleValues(values);
206189
}
207190

@@ -210,7 +193,7 @@ public static SortedNumericDoubleValues singleton(NumericDoubleValues values) {
210193
* if it was previously wrapped with {@link DocValues#singleton(NumericDocValues)},
211194
* or null.
212195
*/
213-
public static NumericDoubleValues unwrapSingleton(SortedNumericDoubleValues values) {
196+
public static DoubleValues unwrapSingleton(SortedNumericDoubleValues values) {
214197
if (values instanceof SingletonSortedNumericDoubleValues) {
215198
return ((SingletonSortedNumericDoubleValues) values).getNumericDoubleValues();
216199
}
@@ -297,7 +280,7 @@ public CharSequence get() throws IOException {
297280
*/
298281
public static SortedBinaryDocValues toString(final SortedNumericDoubleValues values) {
299282
{
300-
final NumericDoubleValues singleton = FieldData.unwrapSingleton(values);
283+
final DoubleValues singleton = FieldData.unwrapSingleton(values);
301284
if (singleton != null) {
302285
return FieldData.singleton(toString(singleton));
303286
}
@@ -322,7 +305,7 @@ public void get(List<CharSequence> list) throws IOException {
322305
* typically used for scripts or for the `map` execution mode of terms aggs.
323306
* NOTE: this is very slow!
324307
*/
325-
public static BinaryDocValues toString(final NumericDoubleValues values) {
308+
public static BinaryDocValues toString(final DoubleValues values) {
326309
return toString(new ToStringValue() {
327310
@Override
328311
public boolean advanceExact(int doc) throws IOException {
@@ -505,7 +488,7 @@ private interface ToStringValue {
505488

506489
}
507490

508-
private static class DoubleCastedValues extends NumericDoubleValues {
491+
private static class DoubleCastedValues extends DoubleValues {
509492

510493
private final LongValues values;
511494

@@ -552,9 +535,9 @@ public int docValueCount() {
552535

553536
private static class LongCastedValues extends LongValues {
554537

555-
private final NumericDoubleValues values;
538+
private final DoubleValues values;
556539

557-
LongCastedValues(NumericDoubleValues values) {
540+
LongCastedValues(DoubleValues values) {
558541
this.values = values;
559542
}
560543

@@ -636,11 +619,11 @@ public long longValue() {
636619
}
637620

638621
/**
639-
* Return a {@link NumericDoubleValues} instance that has a value for every
622+
* Return a {@link DoubleValues} instance that has a value for every
640623
* document, returns the same value as {@code values} if there is a value
641624
* for the current document and {@code missing} otherwise.
642625
*/
643-
public static DenseDoubleValues replaceMissing(NumericDoubleValues values, double missing) {
626+
public static DenseDoubleValues replaceMissing(DoubleValues values, double missing) {
644627
return new DenseDoubleValues() {
645628

646629
private double value;

server/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java

Lines changed: 0 additions & 73 deletions
This file was deleted.

server/src/main/java/org/elasticsearch/index/fielddata/SingletonSortedNumericDoubleValues.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99

1010
package org.elasticsearch.index.fielddata;
1111

12+
import org.apache.lucene.search.DoubleValues;
13+
1214
import java.io.IOException;
1315

1416
/**
@@ -18,14 +20,14 @@
1820
* that works for single or multi-valued types.
1921
*/
2022
final class SingletonSortedNumericDoubleValues extends SortedNumericDoubleValues {
21-
private final NumericDoubleValues in;
23+
private final DoubleValues in;
2224

23-
SingletonSortedNumericDoubleValues(NumericDoubleValues in) {
25+
SingletonSortedNumericDoubleValues(DoubleValues in) {
2426
this.in = in;
2527
}
2628

27-
/** Return the wrapped {@link NumericDoubleValues} */
28-
public NumericDoubleValues getNumericDoubleValues() {
29+
/** Return the wrapped {@link DoubleValues} */
30+
public DoubleValues getNumericDoubleValues() {
2931
return in;
3032
}
3133

0 commit comments

Comments
 (0)