Simplify generics (by Ignacio)

Co-authored-by: Ignacio Vera <ivera@apache.org>
This commit is contained in:
Craig Taverner 2022-08-29 12:05:37 +02:00
parent cd5a740a2e
commit 050df953df
21 changed files with 64 additions and 80 deletions

View file

@ -11,8 +11,8 @@ package org.elasticsearch.script.expression;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DoubleValues; import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.LeafPointFieldData; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
import java.io.IOException; import java.io.IOException;
@ -27,8 +27,8 @@ final class GeoEmptyValueSource extends FieldDataBasedDoubleValuesSource {
@Override @Override
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) { public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
LeafPointFieldData<?> leafData = (LeafPointFieldData<?>) fieldData.load(leaf); LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
final MultiPointValues<?> values = leafData.getPointValues(); final MultiGeoPointValues values = leafData.getPointValues(); // shade
return new DoubleValues() { return new DoubleValues() {
@Override @Override
public double doubleValue() { public double doubleValue() {

View file

@ -10,10 +10,9 @@ package org.elasticsearch.script.expression;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DoubleValues; import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.plain.AbstractLeafGeoPointFieldData; import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
import java.io.IOException; import java.io.IOException;
@ -28,8 +27,8 @@ final class GeoLatitudeValueSource extends FieldDataBasedDoubleValuesSource {
@Override @Override
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) { public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
AbstractLeafGeoPointFieldData leafData = (AbstractLeafGeoPointFieldData) fieldData.load(leaf); LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
final MultiPointValues<GeoPoint> values = leafData.getPointValues(); final MultiGeoPointValues values = leafData.getPointValues();
return new DoubleValues() { return new DoubleValues() {
@Override @Override
public double doubleValue() throws IOException { public double doubleValue() throws IOException {

View file

@ -10,10 +10,9 @@ package org.elasticsearch.script.expression;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.search.DoubleValues; import org.apache.lucene.search.DoubleValues;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.plain.AbstractLeafGeoPointFieldData; import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
import java.io.IOException; import java.io.IOException;
@ -28,8 +27,8 @@ final class GeoLongitudeValueSource extends FieldDataBasedDoubleValuesSource {
@Override @Override
public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) { public DoubleValues getValues(LeafReaderContext leaf, DoubleValues scores) {
AbstractLeafGeoPointFieldData leafData = (AbstractLeafGeoPointFieldData) fieldData.load(leaf); LeafGeoPointFieldData leafData = (LeafGeoPointFieldData) fieldData.load(leaf);
final MultiPointValues<GeoPoint> values = leafData.getPointValues(); final MultiGeoPointValues values = leafData.getPointValues();
return new DoubleValues() { return new DoubleValues() {
@Override @Override
public double doubleValue() throws IOException { public double doubleValue() throws IOException {

View file

@ -15,7 +15,7 @@ import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.common.xcontent.support.XContentMapValues;
import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.GeoPointValues; import org.elasticsearch.index.fielddata.GeoPointValues;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.NumericDoubleValues; import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.SortingNumericDoubleValues; import org.elasticsearch.index.fielddata.SortingNumericDoubleValues;
@ -522,10 +522,10 @@ public class GeoUtils {
public static SortedNumericDoubleValues distanceValues( public static SortedNumericDoubleValues distanceValues(
final GeoDistance distance, final GeoDistance distance,
final DistanceUnit unit, final DistanceUnit unit,
final MultiPointValues<GeoPoint> geoPointValues, final MultiGeoPointValues geoPointValues,
final GeoPoint... fromPoints final GeoPoint... fromPoints
) { ) {
final GeoPointValues singleValues = (GeoPointValues) FieldData.unwrapSingleton(geoPointValues); final GeoPointValues singleValues = FieldData.unwrapSingleton(geoPointValues);
if (singleValues != null && fromPoints.length == 1) { if (singleValues != null && fromPoints.length == 1) {
return FieldData.singleton(new NumericDoubleValues() { return FieldData.singleton(new NumericDoubleValues() {

View file

@ -217,7 +217,7 @@ public enum FieldData {
* Returns a single-valued view of the {@link MultiGeoPointValues}, * Returns a single-valued view of the {@link MultiGeoPointValues},
* if the wrapped {@link SortedNumericDocValues} is a singleton. * if the wrapped {@link SortedNumericDocValues} is a singleton.
*/ */
public static PointValues<?> unwrapSingleton(MultiPointValues<? extends ElasticPoint> values) { public static GeoPointValues unwrapSingleton(MultiGeoPointValues values) {
return values.getPointValues(); return values.getPointValues();
} }

View file

@ -11,9 +11,8 @@ package org.elasticsearch.index.fielddata;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.search.SortField; import org.apache.lucene.search.SortField;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.index.fielddata.plain.AbstractLeafGeoPointFieldData; import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.script.GeoPointFieldScript; import org.elasticsearch.script.GeoPointFieldScript;
import org.elasticsearch.script.field.ToScriptFieldFactory; import org.elasticsearch.script.field.ToScriptFieldFactory;
@ -24,16 +23,16 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.BucketedSort;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
public class GeoPointScriptFieldData implements IndexGeoPointFieldData { public final class GeoPointScriptFieldData implements IndexGeoPointFieldData {
public static class Builder implements IndexFieldData.Builder { public static class Builder implements IndexFieldData.Builder {
private final String name; private final String name;
private final GeoPointFieldScript.LeafFactory leafFactory; private final GeoPointFieldScript.LeafFactory leafFactory;
private final ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory; private final ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory;
public Builder( public Builder(
String name, String name,
GeoPointFieldScript.LeafFactory leafFactory, GeoPointFieldScript.LeafFactory leafFactory,
ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory
) { ) {
this.name = name; this.name = name;
this.leafFactory = leafFactory; this.leafFactory = leafFactory;
@ -48,12 +47,12 @@ public class GeoPointScriptFieldData implements IndexGeoPointFieldData {
private final GeoPointFieldScript.LeafFactory leafFactory; private final GeoPointFieldScript.LeafFactory leafFactory;
private final String name; private final String name;
private final ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory; private final ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory;
private GeoPointScriptFieldData( private GeoPointScriptFieldData(
String fieldName, String fieldName,
GeoPointFieldScript.LeafFactory leafFactory, GeoPointFieldScript.LeafFactory leafFactory,
ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory
) { ) {
this.name = fieldName; this.name = fieldName;
this.leafFactory = leafFactory; this.leafFactory = leafFactory;
@ -90,9 +89,9 @@ public class GeoPointScriptFieldData implements IndexGeoPointFieldData {
} }
@Override @Override
public LeafPointFieldData<GeoPoint> load(LeafReaderContext context) { public LeafPointFieldData<MultiGeoPointValues> load(LeafReaderContext context) {
GeoPointFieldScript script = leafFactory.newInstance(context); GeoPointFieldScript script = leafFactory.newInstance(context);
return new AbstractLeafGeoPointFieldData(toScriptFieldFactory) { return new LeafGeoPointFieldData(toScriptFieldFactory) {
@Override @Override
public SortedNumericDocValues getSortedNumericDocValues() { public SortedNumericDocValues getSortedNumericDocValues() {
return new GeoPointScriptDocValues(script); return new GeoPointScriptDocValues(script);
@ -111,7 +110,7 @@ public class GeoPointScriptFieldData implements IndexGeoPointFieldData {
} }
@Override @Override
public LeafPointFieldData<GeoPoint> loadDirect(LeafReaderContext context) { public LeafPointFieldData<MultiGeoPointValues> loadDirect(LeafReaderContext context) {
return load(context); return load(context);
} }
} }

View file

@ -8,9 +8,7 @@
package org.elasticsearch.index.fielddata; package org.elasticsearch.index.fielddata;
import org.elasticsearch.common.geo.GeoPoint;
/** /**
* Specialization of {@link IndexFieldData} for geo points. * Specialization of {@link IndexFieldData} for geo points.
*/ */
public interface IndexGeoPointFieldData extends IndexPointFieldData<GeoPoint> {} public interface IndexGeoPointFieldData extends IndexPointFieldData<MultiGeoPointValues> {}

View file

@ -8,9 +8,7 @@
package org.elasticsearch.index.fielddata; package org.elasticsearch.index.fielddata;
import org.elasticsearch.common.geo.ElasticPoint;
/** /**
* Specialization of {@link IndexFieldData} for geo points and points. * Specialization of {@link IndexFieldData} for geo points and points.
*/ */
public interface IndexPointFieldData<T extends ElasticPoint> extends IndexFieldData<LeafPointFieldData<T>> {} public interface IndexPointFieldData<T extends MultiPointValues<?>> extends IndexFieldData<LeafPointFieldData<T>> {}

View file

@ -8,17 +8,16 @@
package org.elasticsearch.index.fielddata; package org.elasticsearch.index.fielddata;
import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.index.SortedNumericDocValues;
import org.elasticsearch.common.geo.ElasticPoint;
/** /**
* {@link LeafFieldData} specialization for geo points and points. * {@link LeafFieldData} specialization for geo points and points.
*/ */
public abstract class LeafPointFieldData<T extends ElasticPoint> implements LeafFieldData { public abstract class LeafPointFieldData<T extends MultiPointValues<?>> implements LeafFieldData {
/** /**
* Return geo-point or point values. * Return geo-point or point values.
*/ */
public abstract MultiPointValues<T> getPointValues(); public abstract T getPointValues();
/** /**
* Return the internal representation of geo_point or point doc values as a {@link SortedNumericDocValues}. * Return the internal representation of geo_point or point doc values as a {@link SortedNumericDocValues}.

View file

@ -8,7 +8,6 @@
package org.elasticsearch.index.fielddata.plain; package org.elasticsearch.index.fielddata.plain;
import org.apache.lucene.search.SortField; import org.apache.lucene.search.SortField;
import org.elasticsearch.common.geo.ElasticPoint;
import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.BigArrays;
import org.elasticsearch.core.Nullable; import org.elasticsearch.core.Nullable;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
@ -21,16 +20,16 @@ import org.elasticsearch.search.aggregations.support.ValuesSourceType;
import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.BucketedSort;
import org.elasticsearch.search.sort.SortOrder; import org.elasticsearch.search.sort.SortOrder;
public abstract class AbstractPointIndexFieldData<T extends ElasticPoint> implements IndexPointFieldData<T> { abstract class AbstractPointIndexFieldData<T extends MultiPointValues<?>> implements IndexPointFieldData<T> {
protected final String fieldName; protected final String fieldName;
protected final ValuesSourceType valuesSourceType; protected final ValuesSourceType valuesSourceType;
protected final ToScriptFieldFactory<MultiPointValues<T>> toScriptFieldFactory; protected final ToScriptFieldFactory<T> toScriptFieldFactory;
protected AbstractPointIndexFieldData( protected AbstractPointIndexFieldData(
String fieldName, String fieldName,
ValuesSourceType valuesSourceType, ValuesSourceType valuesSourceType,
ToScriptFieldFactory<MultiPointValues<T>> toScriptFieldFactory ToScriptFieldFactory<T> toScriptFieldFactory
) { ) {
this.fieldName = fieldName; this.fieldName = fieldName;
this.valuesSourceType = valuesSourceType; this.valuesSourceType = valuesSourceType;

View file

@ -11,19 +11,18 @@ import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.SortedNumericDocValues; import org.apache.lucene.index.SortedNumericDocValues;
import org.apache.lucene.util.Accountable; import org.apache.lucene.util.Accountable;
import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.MultiPointValues;
import org.elasticsearch.script.field.ToScriptFieldFactory; import org.elasticsearch.script.field.ToScriptFieldFactory;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
final class LatLonPointDVLeafFieldData extends AbstractLeafGeoPointFieldData { final class LatLonPointDVLeafFieldData extends LeafGeoPointFieldData {
private final LeafReader reader; private final LeafReader reader;
private final String fieldName; private final String fieldName;
LatLonPointDVLeafFieldData(LeafReader reader, String fieldName, ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory) { LatLonPointDVLeafFieldData(LeafReader reader, String fieldName, ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory) {
super(toScriptFieldFactory); super(toScriptFieldFactory);
this.reader = reader; this.reader = reader;
this.fieldName = fieldName; this.fieldName = fieldName;

View file

@ -13,27 +13,26 @@ import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo; import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReader; import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexFieldDataCache;
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
import org.elasticsearch.index.fielddata.LeafPointFieldData; import org.elasticsearch.index.fielddata.LeafPointFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.indices.breaker.CircuitBreakerService;
import org.elasticsearch.script.field.ToScriptFieldFactory; import org.elasticsearch.script.field.ToScriptFieldFactory;
import org.elasticsearch.search.aggregations.support.ValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType;
public class LatLonPointIndexFieldData extends AbstractPointIndexFieldData<GeoPoint> implements IndexGeoPointFieldData { public final class LatLonPointIndexFieldData extends AbstractPointIndexFieldData<MultiGeoPointValues> implements IndexGeoPointFieldData {
public LatLonPointIndexFieldData( public LatLonPointIndexFieldData(
String fieldName, String fieldName,
ValuesSourceType valuesSourceType, ValuesSourceType valuesSourceType,
ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory
) { ) {
super(fieldName, valuesSourceType, toScriptFieldFactory); super(fieldName, valuesSourceType, toScriptFieldFactory);
} }
@Override @Override
public LeafPointFieldData<GeoPoint> load(LeafReaderContext context) { public LeafPointFieldData<MultiGeoPointValues> load(LeafReaderContext context) {
LeafReader reader = context.reader(); LeafReader reader = context.reader();
FieldInfo info = reader.getFieldInfos().fieldInfo(fieldName); FieldInfo info = reader.getFieldInfos().fieldInfo(fieldName);
if (info != null) { if (info != null) {
@ -43,7 +42,7 @@ public class LatLonPointIndexFieldData extends AbstractPointIndexFieldData<GeoPo
} }
@Override @Override
public LeafPointFieldData<GeoPoint> loadDirect(LeafReaderContext context) throws Exception { public LeafPointFieldData<MultiGeoPointValues> loadDirect(LeafReaderContext context) throws Exception {
return load(context); return load(context);
} }
@ -67,13 +66,9 @@ public class LatLonPointIndexFieldData extends AbstractPointIndexFieldData<GeoPo
public static class Builder implements IndexFieldData.Builder { public static class Builder implements IndexFieldData.Builder {
private final String name; private final String name;
private final ValuesSourceType valuesSourceType; private final ValuesSourceType valuesSourceType;
private final ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory; private final ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory;
public Builder( public Builder(String name, ValuesSourceType valuesSourceType, ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory) {
String name,
ValuesSourceType valuesSourceType,
ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory
) {
this.name = name; this.name = name;
this.valuesSourceType = valuesSourceType; this.valuesSourceType = valuesSourceType;
this.toScriptFieldFactory = toScriptFieldFactory; this.toScriptFieldFactory = toScriptFieldFactory;

View file

@ -7,20 +7,18 @@
*/ */
package org.elasticsearch.index.fielddata.plain; package org.elasticsearch.index.fielddata.plain;
import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.LeafPointFieldData; import org.elasticsearch.index.fielddata.LeafPointFieldData;
import org.elasticsearch.index.fielddata.MultiGeoPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.MultiPointValues;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
import org.elasticsearch.script.field.DocValuesScriptFieldFactory; import org.elasticsearch.script.field.DocValuesScriptFieldFactory;
import org.elasticsearch.script.field.ToScriptFieldFactory; import org.elasticsearch.script.field.ToScriptFieldFactory;
public abstract class AbstractLeafGeoPointFieldData extends LeafPointFieldData<GeoPoint> { public abstract class LeafGeoPointFieldData extends LeafPointFieldData<MultiGeoPointValues> {
protected final ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory; protected final ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory;
public AbstractLeafGeoPointFieldData(ToScriptFieldFactory<MultiPointValues<GeoPoint>> toScriptFieldFactory) { public LeafGeoPointFieldData(ToScriptFieldFactory<MultiGeoPointValues> toScriptFieldFactory) {
this.toScriptFieldFactory = toScriptFieldFactory; this.toScriptFieldFactory = toScriptFieldFactory;
} }

View file

@ -28,7 +28,7 @@ import org.elasticsearch.core.TimeValue;
import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.NumericDoubleValues; import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.SortingNumericDoubleValues; import org.elasticsearch.index.fielddata.SortingNumericDoubleValues;
@ -382,7 +382,7 @@ public abstract class DecayFunctionBuilder<DFB extends DecayFunctionBuilder<DFB>
@Override @Override
protected NumericDoubleValues distance(LeafReaderContext context) { protected NumericDoubleValues distance(LeafReaderContext context) {
final MultiPointValues<GeoPoint> geoPointValues = fieldData.load(context).getPointValues(); final MultiGeoPointValues geoPointValues = fieldData.load(context).getPointValues();
return FieldData.replaceMissing(mode.select(new SortingNumericDoubleValues() { return FieldData.replaceMissing(mode.select(new SortingNumericDoubleValues() {
@Override @Override
public boolean advanceExact(int docId) throws IOException { public boolean advanceExact(int docId) throws IOException {
@ -413,7 +413,7 @@ public abstract class DecayFunctionBuilder<DFB extends DecayFunctionBuilder<DFB>
protected String getDistanceString(LeafReaderContext ctx, int docId) throws IOException { protected String getDistanceString(LeafReaderContext ctx, int docId) throws IOException {
StringBuilder values = new StringBuilder(mode.name()); StringBuilder values = new StringBuilder(mode.name());
values.append(" of: ["); values.append(" of: [");
final MultiPointValues<GeoPoint> geoPointValues = fieldData.load(ctx).getPointValues(); final MultiGeoPointValues geoPointValues = fieldData.load(ctx).getPointValues();
if (geoPointValues.advanceExact(docId)) { if (geoPointValues.advanceExact(docId)) {
final int num = geoPointValues.docValueCount(); final int num = geoPointValues.docValueCount();
for (int i = 0; i < num; i++) { for (int i = 0; i < num; i++) {

View file

@ -11,14 +11,14 @@ package org.elasticsearch.script.field;
import org.elasticsearch.common.geo.GeoBoundingBox; import org.elasticsearch.common.geo.GeoBoundingBox;
import org.elasticsearch.common.geo.GeoPoint; import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.geo.GeoUtils;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.ScriptDocValues;
public class GeoPointDocValuesField extends PointDocValuesField<GeoPoint> { public class GeoPointDocValuesField extends PointDocValuesField<GeoPoint> {
// maintain bwc by making centroid and bounding box available to ScriptDocValues.GeoPoints // maintain bwc by making centroid and bounding box available to ScriptDocValues.GeoPoints
private ScriptDocValues.GeoPoints geoPoints = null; private ScriptDocValues.GeoPoints geoPoints = null;
public GeoPointDocValuesField(MultiPointValues<GeoPoint> input, String name) { public GeoPointDocValuesField(MultiGeoPointValues input, String name) {
super(input, name, GeoPoint::new, new GeoBoundingBox(new GeoPoint(), new GeoPoint()), new GeoPoint[0]); super(input, name, GeoPoint::new, new GeoBoundingBox(new GeoPoint(), new GeoPoint()), new GeoPoint[0]);
} }

View file

@ -53,7 +53,7 @@ public abstract class CellIdSource extends ValuesSource.Numeric {
@Override @Override
public final SortedNumericDocValues longValues(LeafReaderContext ctx) { public final SortedNumericDocValues longValues(LeafReaderContext ctx) {
final MultiGeoPointValues multiGeoPointValues = valuesSource.geoPointValues(ctx); final MultiGeoPointValues multiGeoPointValues = valuesSource.geoPointValues(ctx);
final GeoPointValues values = (GeoPointValues) org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(multiGeoPointValues); final GeoPointValues values = org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(multiGeoPointValues);
if (geoBoundingBox.isUnbounded()) { if (geoBoundingBox.isUnbounded()) {
return values == null ? unboundedCellMultiValues(multiGeoPointValues) : DocValues.singleton(unboundedCellSingleValue(values)); return values == null ? unboundedCellMultiValues(multiGeoPointValues) : DocValues.singleton(unboundedCellSingleValue(values));
} else { } else {

View file

@ -24,9 +24,9 @@ import org.elasticsearch.common.util.CollectionUtils;
import org.elasticsearch.index.fielddata.AbstractSortingNumericDocValues; import org.elasticsearch.index.fielddata.AbstractSortingNumericDocValues;
import org.elasticsearch.index.fielddata.DocValueBits; import org.elasticsearch.index.fielddata.DocValueBits;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
import org.elasticsearch.index.fielddata.IndexNumericFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData;
import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData;
import org.elasticsearch.index.fielddata.IndexPointFieldData;
import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData;
import org.elasticsearch.index.fielddata.MultiGeoPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.index.fielddata.SortedBinaryDocValues;
@ -744,9 +744,9 @@ public abstract class ValuesSource {
public static class Fielddata extends GeoPoint { public static class Fielddata extends GeoPoint {
protected final IndexPointFieldData<org.elasticsearch.common.geo.GeoPoint> indexFieldData; protected final IndexGeoPointFieldData indexFieldData;
public Fielddata(IndexPointFieldData<org.elasticsearch.common.geo.GeoPoint> indexFieldData) { public Fielddata(IndexGeoPointFieldData indexFieldData) {
this.indexFieldData = indexFieldData; this.indexFieldData = indexFieldData;
} }

View file

@ -33,7 +33,7 @@ import org.elasticsearch.index.fielddata.FieldData;
import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData;
import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested;
import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.NumericDoubleValues; import org.elasticsearch.index.fielddata.NumericDoubleValues;
import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues;
import org.elasticsearch.index.fielddata.plain.LatLonPointIndexFieldData; import org.elasticsearch.index.fielddata.plain.LatLonPointIndexFieldData;
@ -642,7 +642,7 @@ public class GeoDistanceSortBuilder extends SortBuilder<GeoDistanceSortBuilder>
} }
private NumericDoubleValues getNumericDoubleValues(LeafReaderContext context) throws IOException { private NumericDoubleValues getNumericDoubleValues(LeafReaderContext context) throws IOException {
final MultiPointValues<GeoPoint> geoPointValues = geoIndexFieldData.load(context).getPointValues(); final MultiGeoPointValues geoPointValues = geoIndexFieldData.load(context).getPointValues();
final SortedNumericDoubleValues distanceValues = GeoUtils.distanceValues(geoDistance, unit, geoPointValues, localPoints); final SortedNumericDoubleValues distanceValues = GeoUtils.distanceValues(geoDistance, unit, geoPointValues, localPoints);
if (nested == null) { if (nested == null) {
return FieldData.replaceMissing(sortMode.select(distanceValues), Double.POSITIVE_INFINITY); return FieldData.replaceMissing(sortMode.select(distanceValues), Double.POSITIVE_INFINITY);

View file

@ -12,7 +12,7 @@ import org.apache.lucene.document.Field;
import org.apache.lucene.document.StringField; import org.apache.lucene.document.StringField;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.elasticsearch.index.fielddata.plain.AbstractLeafGeoPointFieldData; import org.elasticsearch.index.fielddata.plain.LeafGeoPointFieldData;
import java.util.List; import java.util.List;
@ -149,7 +149,7 @@ public class GeoFieldDataTests extends AbstractGeoFieldDataTestCase {
LeafFieldData fieldData = indexFieldData.load(readerContext); LeafFieldData fieldData = indexFieldData.load(readerContext);
assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed())); assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));
MultiGeoPointValues fieldValues = ((AbstractLeafGeoPointFieldData) fieldData).getPointValues(); MultiGeoPointValues fieldValues = ((LeafGeoPointFieldData) fieldData).getPointValues();
assertValues(fieldValues, 0); assertValues(fieldValues, 0);
assertValues(fieldValues, 1); assertValues(fieldValues, 1);
assertValues(fieldValues, 2); assertValues(fieldValues, 2);
@ -165,7 +165,7 @@ public class GeoFieldDataTests extends AbstractGeoFieldDataTestCase {
LeafFieldData fieldData = indexFieldData.load(readerContext); LeafFieldData fieldData = indexFieldData.load(readerContext);
assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed())); assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));
MultiGeoPointValues fieldValues = ((AbstractLeafGeoPointFieldData) fieldData).getPointValues(); MultiGeoPointValues fieldValues = ((LeafGeoPointFieldData) fieldData).getPointValues();
assertValues(fieldValues, 0); assertValues(fieldValues, 0);
assertMissing(fieldValues, 1); assertMissing(fieldValues, 1);
assertValues(fieldValues, 2); assertValues(fieldValues, 2);
@ -181,7 +181,7 @@ public class GeoFieldDataTests extends AbstractGeoFieldDataTestCase {
LeafFieldData fieldData = indexFieldData.load(readerContext); LeafFieldData fieldData = indexFieldData.load(readerContext);
assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed())); assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));
MultiGeoPointValues fieldValues = ((AbstractLeafGeoPointFieldData) fieldData).getPointValues(); MultiGeoPointValues fieldValues = ((LeafGeoPointFieldData) fieldData).getPointValues();
assertValues(fieldValues, 0); assertValues(fieldValues, 0);
assertValues(fieldValues, 1); assertValues(fieldValues, 1);
assertValues(fieldValues, 2); assertValues(fieldValues, 2);
@ -197,7 +197,7 @@ public class GeoFieldDataTests extends AbstractGeoFieldDataTestCase {
LeafFieldData fieldData = indexFieldData.load(readerContext); LeafFieldData fieldData = indexFieldData.load(readerContext);
assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed())); assertThat(fieldData.ramBytesUsed(), greaterThanOrEqualTo(minRamBytesUsed()));
MultiGeoPointValues fieldValues = ((AbstractLeafGeoPointFieldData) fieldData).getPointValues(); MultiGeoPointValues fieldValues = ((LeafGeoPointFieldData) fieldData).getPointValues();
assertValues(fieldValues, 0); assertValues(fieldValues, 0);
assertMissing(fieldValues, 1); assertMissing(fieldValues, 1);

View file

@ -26,7 +26,7 @@ import org.elasticsearch.common.geo.GeoPoint;
import org.elasticsearch.common.lucene.search.function.ScriptScoreQuery; import org.elasticsearch.common.lucene.search.function.ScriptScoreQuery;
import org.elasticsearch.geo.GeometryTestUtils; import org.elasticsearch.geo.GeometryTestUtils;
import org.elasticsearch.index.fielddata.GeoPointScriptFieldData; import org.elasticsearch.index.fielddata.GeoPointScriptFieldData;
import org.elasticsearch.index.fielddata.MultiPointValues; import org.elasticsearch.index.fielddata.MultiGeoPointValues;
import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.ScriptDocValues;
import org.elasticsearch.index.query.SearchExecutionContext; import org.elasticsearch.index.query.SearchExecutionContext;
import org.elasticsearch.script.DocReader; import org.elasticsearch.script.DocReader;
@ -74,7 +74,7 @@ public class GeoPointScriptFieldTypeTests extends AbstractNonTextScriptFieldType
@Override @Override
public LeafCollector getLeafCollector(LeafReaderContext context) { public LeafCollector getLeafCollector(LeafReaderContext context) {
MultiPointValues<GeoPoint> dv = ifd.load(context).getPointValues(); MultiGeoPointValues dv = ifd.load(context).getPointValues();
return new LeafCollector() { return new LeafCollector() {
@Override @Override
public void setScorer(Scorable scorer) {} public void setScorer(Scorable scorer) {}

View file

@ -42,6 +42,7 @@ public class GeoHexAggregatorTests extends GeoGridAggregatorTestCase<InternalGeo
@Override @Override
protected List<ValuesSourceType> getSupportedValuesSourceTypes() { protected List<ValuesSourceType> getSupportedValuesSourceTypes() {
// TODO: why is shape here already, it is not supported yet
return List.of(GeoShapeValuesSourceType.instance(), CoreValuesSourceType.GEOPOINT); return List.of(GeoShapeValuesSourceType.instance(), CoreValuesSourceType.GEOPOINT);
} }