From b718193a0136bc9ac063c27132bf52b2c47385ee Mon Sep 17 00:00:00 2001 From: Mark Tozzi Date: Thu, 14 May 2020 12:42:37 -0400 Subject: [PATCH] Clean up DocValuesIndexFieldData (#56372) (#56684) --- .../index/mapper/ScaledFloatFieldMapper.java | 7 +- .../join/mapper/MetaJoinFieldMapper.java | 4 +- .../join/mapper/ParentIdFieldMapper.java | 4 +- .../join/mapper/ParentJoinFieldMapper.java | 4 +- .../join/query/HasChildQueryBuilder.java | 8 +- .../join/query/HasParentQueryBuilder.java | 4 +- .../percolator/QueryBuilderStoreTests.java | 4 +- .../ICUCollationKeywordFieldMapper.java | 5 +- .../mapper/murmur3/Murmur3FieldMapper.java | 4 +- .../fielddata/IndexHistogramFieldData.java | 23 +++- .../LongValuesComparatorSource.java | 6 +- ...=> AbstractLatLonPointIndexFieldData.java} | 37 ++++-- ...eldData.java => BinaryIndexFieldData.java} | 43 ++++++- ...ta.java => BytesBinaryIndexFieldData.java} | 27 ++++- .../plain/DocValuesIndexFieldData.java | 109 ------------------ .../fielddata/plain/LeafLongFieldData.java | 4 +- ....java => SortedNumericIndexFieldData.java} | 59 ++++++++-- ....java => SortedSetBytesLeafFieldData.java} | 4 +- ...a => SortedSetOrdinalsIndexFieldData.java} | 67 +++++++++-- .../index/mapper/BinaryFieldMapper.java | 4 +- .../index/mapper/BooleanFieldMapper.java | 4 +- .../index/mapper/DateFieldMapper.java | 4 +- .../index/mapper/GeoPointFieldMapper.java | 4 +- .../index/mapper/IpFieldMapper.java | 4 +- .../index/mapper/KeywordFieldMapper.java | 4 +- .../index/mapper/NumberFieldMapper.java | 4 +- .../index/mapper/RangeFieldMapper.java | 4 +- .../index/mapper/SeqNoFieldMapper.java | 4 +- .../fetch/subphase/FetchDocValuesPhase.java | 4 +- .../search/sort/FieldSortBuilder.java | 6 +- .../search/sort/GeoDistanceSortBuilder.java | 4 +- .../index/fielddata/FieldDataCacheTests.java | 14 +-- .../fielddata/IndexFieldDataServiceTests.java | 12 +- .../plain/HalfFloatFielddataTests.java | 4 +- .../index/mapper/DateFieldTypeTests.java | 4 +- .../sampler/DiversifiedSamplerTests.java | 4 +- .../mapper/FlatObjectFieldMapper.java | 7 +- ...ldDataCacheWithFieldSubsetReaderTests.java | 14 +-- ...=> AbstractLatLonShapeIndexFieldData.java} | 32 +++-- .../GeoShapeWithDocValuesFieldMapper.java | 4 +- .../mapper/DenseVectorFieldMapper.java | 4 +- .../mapper/SparseVectorFieldMapper.java | 4 +- ...eldData.java => VectorIndexFieldData.java} | 28 ++++- .../wildcard/mapper/WildcardFieldMapper.java | 8 +- 44 files changed, 363 insertions(+), 249 deletions(-) rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{AbstractLatLonPointDVIndexFieldData.java => AbstractLatLonPointIndexFieldData.java} (84%) rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{BinaryDVIndexFieldData.java => BinaryIndexFieldData.java} (65%) rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{BytesBinaryDVIndexFieldData.java => BytesBinaryIndexFieldData.java} (83%) delete mode 100644 server/src/main/java/org/elasticsearch/index/fielddata/plain/DocValuesIndexFieldData.java rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{SortedNumericDVIndexFieldData.java => SortedNumericIndexFieldData.java} (92%) rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{SortedSetDVBytesLeafFieldData.java => SortedSetBytesLeafFieldData.java} (91%) rename server/src/main/java/org/elasticsearch/index/fielddata/plain/{SortedSetDVOrdinalsIndexFieldData.java => SortedSetOrdinalsIndexFieldData.java} (77%) rename x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/{AbstractLatLonShapeDVIndexFieldData.java => AbstractLatLonShapeIndexFieldData.java} (82%) rename x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/{VectorDVIndexFieldData.java => VectorIndexFieldData.java} (80%) diff --git a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java index 69ecc1f1f47..273f35c8abf 100644 --- a/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java +++ b/modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java @@ -54,7 +54,7 @@ import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.SortedBinaryDocValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; import org.elasticsearch.index.fielddata.fieldcomparator.DoubleValuesComparatorSource; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.mapper.NumberFieldMapper.Defaults; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -289,8 +289,9 @@ public class ScaledFloatFieldMapper extends FieldMapper { @Override public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - final IndexNumericFieldData scaledValues = (IndexNumericFieldData) new DocValuesIndexFieldData.Builder() - .numericType(IndexNumericFieldData.NumericType.LONG) + final IndexNumericFieldData scaledValues = new SortedNumericIndexFieldData.Builder( + IndexNumericFieldData.NumericType.LONG + ) .build(indexSettings, fieldType, cache, breakerService, mapperService); return new ScaledFloatIndexFieldData(scaledValues, scalingFactor); } diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java index 72f483d3085..f6f789197ac 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/MetaJoinFieldMapper.java @@ -24,7 +24,7 @@ import org.apache.lucene.search.Query; import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.ParseContext; @@ -92,7 +92,7 @@ public class MetaJoinFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder(); + return new SortedSetOrdinalsIndexFieldData.Builder(); } @Override diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java index fd0856c2266..67e112a2203 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentIdFieldMapper.java @@ -33,7 +33,7 @@ import org.apache.lucene.util.BytesRef; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; @@ -115,7 +115,7 @@ public final class ParentIdFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder(); + return new SortedSetOrdinalsIndexFieldData.Builder(); } @Override diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java index af1e6a733a1..a2f4c4f04a8 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java @@ -32,7 +32,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; @@ -225,7 +225,7 @@ public final class ParentJoinFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder(); + return new SortedSetOrdinalsIndexFieldData.Builder(); } @Override diff --git a/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java b/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java index 9c05891d4af..4effaaa8a1f 100644 --- a/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java +++ b/modules/parent-join/src/main/java/org/elasticsearch/join/query/HasChildQueryBuilder.java @@ -38,7 +38,7 @@ import org.apache.logging.log4j.LogManager; import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; -import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.query.AbstractQueryBuilder; import org.elasticsearch.index.query.InnerHitBuilder; @@ -325,7 +325,7 @@ public class HasChildQueryBuilder extends AbstractQueryBuilder { final String fieldName = (String) invocation.getArguments()[0]; KeywordFieldMapper.KeywordFieldType ft = new KeywordFieldMapper.KeywordFieldType(); diff --git a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java index d8364fdf82f..5903323fa3c 100644 --- a/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java +++ b/plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java @@ -23,6 +23,7 @@ import com.ibm.icu.text.Collator; import com.ibm.icu.text.RawCollationKey; import com.ibm.icu.text.RuleBasedCollator; import com.ibm.icu.util.ULocale; + import org.apache.lucene.document.Field; import org.apache.lucene.document.SortedSetDocValuesField; import org.apache.lucene.index.IndexOptions; @@ -42,7 +43,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.analysis.IndexableBinaryStringTools; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; @@ -137,7 +138,7 @@ public class ICUCollationKeywordFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder(); + return new SortedSetOrdinalsIndexFieldData.Builder(); } @Override diff --git a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java index 75f45cffbfb..3516519fb55 100644 --- a/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java +++ b/plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.hash.MurmurHash3; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.Mapper; @@ -121,7 +121,7 @@ public class Murmur3FieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder().numericType(NumericType.LONG); + return new SortedNumericIndexFieldData.Builder(NumericType.LONG); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/IndexHistogramFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/IndexHistogramFieldData.java index a944e44cd9f..dd0b2817365 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/IndexHistogramFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/IndexHistogramFieldData.java @@ -21,14 +21,31 @@ package org.elasticsearch.index.fielddata; import org.elasticsearch.index.Index; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; /** * Specialization of {@link IndexFieldData} for histograms. */ -public abstract class IndexHistogramFieldData extends DocValuesIndexFieldData implements IndexFieldData { +public abstract class IndexHistogramFieldData implements IndexFieldData { + protected final Index index; + protected final String fieldName; public IndexHistogramFieldData(Index index, String fieldName) { - super(index, fieldName); + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java index 56b0cc5fde8..33e1ab33736 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/fieldcomparator/LongValuesComparatorSource.java @@ -31,7 +31,7 @@ import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.fielddata.FieldData; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData; -import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.sort.BucketedSort; @@ -69,8 +69,8 @@ public class LongValuesComparatorSource extends IndexFieldData.XFieldComparatorS private SortedNumericDocValues loadDocValues(LeafReaderContext context) { final LeafNumericFieldData data = indexFieldData.load(context); SortedNumericDocValues values; - if (data instanceof SortedNumericDVIndexFieldData.NanoSecondFieldData) { - values = ((SortedNumericDVIndexFieldData.NanoSecondFieldData) data).getLongValuesAsNanos(); + if (data instanceof SortedNumericIndexFieldData.NanoSecondFieldData) { + values = ((SortedNumericIndexFieldData.NanoSecondFieldData) data).getLongValuesAsNanos(); } else { values = data.getLongValues(); } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointDVIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java similarity index 84% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointDVIndexFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java index 5cbd20029d4..a8eaef2c57d 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointDVIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/AbstractLatLonPointIndexFieldData.java @@ -28,11 +28,11 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.fielddata.LeafGeoPointFieldData; import org.elasticsearch.index.fielddata.IndexFieldData; +import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; -import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; +import org.elasticsearch.index.fielddata.LeafGeoPointFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -41,10 +41,29 @@ import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.SortOrder; -public abstract class AbstractLatLonPointDVIndexFieldData extends DocValuesIndexFieldData - implements IndexGeoPointFieldData { - AbstractLatLonPointDVIndexFieldData(Index index, String fieldName) { - super(index, fieldName); +public abstract class AbstractLatLonPointIndexFieldData implements IndexGeoPointFieldData { + + protected final Index index; + protected final String fieldName; + + AbstractLatLonPointIndexFieldData(Index index, String fieldName) { + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } @Override @@ -59,8 +78,8 @@ public abstract class AbstractLatLonPointDVIndexFieldData extends DocValuesIndex throw new IllegalArgumentException("can't sort on geo_point field without using specific sorting feature, like geo_distance"); } - public static class LatLonPointDVIndexFieldData extends AbstractLatLonPointDVIndexFieldData { - public LatLonPointDVIndexFieldData(Index index, String fieldName) { + public static class LatLonPointIndexFieldData extends AbstractLatLonPointIndexFieldData { + public LatLonPointIndexFieldData(Index index, String fieldName) { super(index, fieldName); } @@ -96,7 +115,7 @@ public abstract class AbstractLatLonPointDVIndexFieldData extends DocValuesIndex public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // ignore breaker - return new LatLonPointDVIndexFieldData(indexSettings.getIndex(), fieldType.name()); + return new LatLonPointIndexFieldData(indexSettings.getIndex(), fieldType.name()); } } } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java similarity index 65% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java index 26732b01d30..aeff6800d37 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryIndexFieldData.java @@ -24,18 +24,55 @@ import org.apache.lucene.search.SortField; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; +import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.SortOrder; -public class BinaryDVIndexFieldData extends DocValuesIndexFieldData implements IndexFieldData { +public class BinaryIndexFieldData implements IndexFieldData { - public BinaryDVIndexFieldData(Index index, String fieldName) { - super(index, fieldName); + public static class Builder implements IndexFieldData.Builder { + @Override + public BinaryIndexFieldData build( + IndexSettings indexSettings, + MappedFieldType fieldType, + IndexFieldDataCache cache, + CircuitBreakerService breakerService, + MapperService mapperService + ) { + final String fieldName = fieldType.name(); + return new BinaryIndexFieldData(indexSettings.getIndex(), fieldName); + } + } + protected final Index index; + protected final String fieldName; + + public BinaryIndexFieldData(Index index, String fieldName) { + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } @Override diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java similarity index 83% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java index 2cdb75f82eb..428f75d397f 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryDVIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/BytesBinaryIndexFieldData.java @@ -39,10 +39,29 @@ import org.elasticsearch.search.sort.SortOrder; import java.io.IOException; -public class BytesBinaryDVIndexFieldData extends DocValuesIndexFieldData implements IndexFieldData { +public class BytesBinaryIndexFieldData implements IndexFieldData { - public BytesBinaryDVIndexFieldData(Index index, String fieldName) { - super(index, fieldName); + protected final Index index; + protected final String fieldName; + + public BytesBinaryIndexFieldData(Index index, String fieldName) { + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } @Override @@ -77,7 +96,7 @@ public class BytesBinaryDVIndexFieldData extends DocValuesIndexFieldData impleme CircuitBreakerService breakerService, MapperService mapperService) { // Ignore breaker final String fieldName = fieldType.name(); - return new BytesBinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); + return new BytesBinaryIndexFieldData(indexSettings.getIndex(), fieldName); } } diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/DocValuesIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/DocValuesIndexFieldData.java deleted file mode 100644 index 8e33d2deec6..00000000000 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/DocValuesIndexFieldData.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Licensed to Elasticsearch under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -package org.elasticsearch.index.fielddata.plain; - -import org.apache.lucene.index.IndexReader; -import org.apache.lucene.index.SortedSetDocValues; -import org.elasticsearch.index.Index; -import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType; -import org.elasticsearch.index.fielddata.ScriptDocValues; -import org.elasticsearch.index.mapper.IdFieldMapper; -import org.elasticsearch.index.mapper.MappedFieldType; -import org.elasticsearch.index.mapper.MapperService; -import org.elasticsearch.index.mapper.RangeType; -import org.elasticsearch.indices.breaker.CircuitBreakerService; - -import java.util.Set; -import java.util.function.Function; - -import static java.util.Collections.unmodifiableSet; -import static org.elasticsearch.common.util.set.Sets.newHashSet; - -/** {@link IndexFieldData} impl based on Lucene's doc values. Caching is done on the Lucene side. */ -public abstract class DocValuesIndexFieldData { - - protected final Index index; - protected final String fieldName; - - public DocValuesIndexFieldData(Index index, String fieldName) { - super(); - this.index = index; - this.fieldName = fieldName; - } - - public final String getFieldName() { - return fieldName; - } - - public final void clear() { - // can't do - } - - public final void clear(IndexReader reader) { - // can't do - } - - public final Index index() { - return index; - } - - public static class Builder implements IndexFieldData.Builder { - private static final Set BINARY_INDEX_FIELD_NAMES = unmodifiableSet(newHashSet(IdFieldMapper.NAME)); - - private NumericType numericType; - private Function> scriptFunction = AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION; - private RangeType rangeType; - - public Builder numericType(NumericType type) { - this.numericType = type; - return this; - } - - public Builder scriptFunction(Function> scriptFunction) { - this.scriptFunction = scriptFunction; - return this; - } - - public Builder setRangeType(RangeType rangeType) { - this.rangeType = rangeType; - return this; - } - - @Override - public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, - CircuitBreakerService breakerService, MapperService mapperService) { - // Ignore Circuit Breaker - final String fieldName = fieldType.name(); - if (BINARY_INDEX_FIELD_NAMES.contains(fieldName) || rangeType != null) { - assert numericType == null; - return new BinaryDVIndexFieldData(indexSettings.getIndex(), fieldName); - } else if (numericType != null) { - return new SortedNumericDVIndexFieldData(indexSettings.getIndex(), fieldName, numericType); - } else { - return new SortedSetDVOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); - } - } - - } - -} diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java index 1f519257fdd..cf46d513402 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/LeafLongFieldData.java @@ -54,8 +54,8 @@ abstract class LeafLongFieldData implements LeafNumericFieldData { case DATE: return new ScriptDocValues.Dates(getLongValues(), false); case DATE_NANOSECONDS: - assert this instanceof SortedNumericDVIndexFieldData.NanoSecondFieldData; - return new ScriptDocValues.Dates(((SortedNumericDVIndexFieldData.NanoSecondFieldData) this).getLongValuesAsNanos(), true); + assert this instanceof SortedNumericIndexFieldData.NanoSecondFieldData; + return new ScriptDocValues.Dates(((SortedNumericIndexFieldData.NanoSecondFieldData) this).getLongValuesAsNanos(), true); case BOOLEAN: return new ScriptDocValues.Booleans(getLongValues()); default: diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericDVIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java similarity index 92% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericDVIndexFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java index f159288dec8..ed252e44114 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericDVIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedNumericIndexFieldData.java @@ -35,16 +35,22 @@ import org.elasticsearch.common.Nullable; import org.elasticsearch.common.time.DateUtils; import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.index.Index; +import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.AbstractSortedNumericDocValues; -import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.fielddata.FieldData; +import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; +import org.elasticsearch.index.fielddata.IndexFieldDataCache; 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.fieldcomparator.DoubleValuesComparatorSource; import org.elasticsearch.index.fielddata.fieldcomparator.FloatValuesComparatorSource; import org.elasticsearch.index.fielddata.fieldcomparator.LongValuesComparatorSource; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.MapperService; +import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.sort.BucketedSort; @@ -53,21 +59,58 @@ import org.elasticsearch.search.sort.SortOrder; import java.io.IOException; import java.util.Collection; import java.util.Collections; +import java.util.Objects; import java.util.function.LongUnaryOperator; /** * FieldData backed by {@link LeafReader#getSortedNumericDocValues(String)} * @see DocValuesType#SORTED_NUMERIC */ -public class SortedNumericDVIndexFieldData extends DocValuesIndexFieldData implements IndexNumericFieldData { - private final NumericType numericType; +public class SortedNumericIndexFieldData implements IndexNumericFieldData { + public static class Builder implements IndexFieldData.Builder { - public SortedNumericDVIndexFieldData(Index index, String fieldNames, NumericType numericType) { - super(index, fieldNames); - if (numericType == null) { - throw new IllegalArgumentException("numericType must be non-null"); + private final NumericType numericType; + + public Builder(NumericType numericType) { + this.numericType = numericType; } - this.numericType = numericType; + + @Override + public SortedNumericIndexFieldData build( + IndexSettings indexSettings, + MappedFieldType fieldType, + IndexFieldDataCache cache, + CircuitBreakerService breakerService, + MapperService mapperService + ) { + final String fieldName = fieldType.name(); + return new SortedNumericIndexFieldData(indexSettings.getIndex(), fieldName, numericType); + } + } + + private final NumericType numericType; + protected final Index index; + protected final String fieldName; + + public SortedNumericIndexFieldData(Index index, String fieldName, NumericType numericType) { + this.index = index; + this.fieldName = fieldName; + this.numericType = Objects.requireNonNull(numericType); + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } /** diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVBytesLeafFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetBytesLeafFieldData.java similarity index 91% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVBytesLeafFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetBytesLeafFieldData.java index 1412f9ab2ec..422573df21c 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVBytesLeafFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetBytesLeafFieldData.java @@ -34,12 +34,12 @@ import java.util.function.Function; /** * An {@link LeafFieldData} implementation that uses Lucene {@link SortedSetDocValues}. */ -public final class SortedSetDVBytesLeafFieldData extends AbstractLeafOrdinalsFieldData { +public final class SortedSetBytesLeafFieldData extends AbstractLeafOrdinalsFieldData { private final LeafReader reader; private final String field; - SortedSetDVBytesLeafFieldData(LeafReader reader, String field, Function> scriptFunction) { super(scriptFunction); this.reader = reader; diff --git a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVOrdinalsIndexFieldData.java b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java similarity index 77% rename from server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVOrdinalsIndexFieldData.java rename to server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java index 1a670a4df58..4441b9758a9 100644 --- a/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetDVOrdinalsIndexFieldData.java +++ b/server/src/main/java/org/elasticsearch/index/fielddata/plain/SortedSetOrdinalsIndexFieldData.java @@ -31,15 +31,19 @@ import org.apache.lucene.search.SortedSetSortField; import org.elasticsearch.ElasticsearchException; import org.elasticsearch.common.Nullable; import org.elasticsearch.common.util.BigArrays; +import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; -import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; +import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; +import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.ScriptDocValues; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData; import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsBuilder; +import org.elasticsearch.index.fielddata.ordinals.GlobalOrdinalsIndexFieldData; +import org.elasticsearch.index.mapper.MappedFieldType; +import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.MultiValueMode; @@ -49,23 +53,70 @@ import org.elasticsearch.search.sort.SortOrder; import java.io.IOException; import java.util.function.Function; -public class SortedSetDVOrdinalsIndexFieldData extends DocValuesIndexFieldData implements IndexOrdinalsFieldData { +public class SortedSetOrdinalsIndexFieldData implements IndexOrdinalsFieldData { + public static class Builder implements IndexFieldData.Builder { + private final Function> scriptFunction; + + public Builder() { + this(AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION); + } + + public Builder(Function> scriptFunction) { + this.scriptFunction = scriptFunction; + } + + @Override + public SortedSetOrdinalsIndexFieldData build( + IndexSettings indexSettings, + MappedFieldType fieldType, + IndexFieldDataCache cache, + CircuitBreakerService breakerService, + MapperService mapperService + ) { + final String fieldName = fieldType.name(); + return new SortedSetOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, scriptFunction); + } + } + + protected final Index index; + protected final String fieldName; private final IndexSettings indexSettings; private final IndexFieldDataCache cache; private final CircuitBreakerService breakerService; private final Function> scriptFunction; - private static final Logger logger = LogManager.getLogger(SortedSetDVOrdinalsIndexFieldData.class); + private static final Logger logger = LogManager.getLogger(SortedSetOrdinalsIndexFieldData.class); - public SortedSetDVOrdinalsIndexFieldData(IndexSettings indexSettings, IndexFieldDataCache cache, String fieldName, - CircuitBreakerService breakerService, Function> scriptFunction) { - super(indexSettings.getIndex(), fieldName); + public SortedSetOrdinalsIndexFieldData( + IndexSettings indexSettings, + IndexFieldDataCache cache, + String fieldName, + CircuitBreakerService breakerService, + Function> scriptFunction + ) { + this.index = indexSettings.getIndex(); + this.fieldName = fieldName; this.indexSettings = indexSettings; this.cache = cache; this.breakerService = breakerService; this.scriptFunction = scriptFunction; } + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; + } + @Override public SortField sortField(@Nullable Object missingValue, MultiValueMode sortMode, Nested nested, boolean reverse) { XFieldComparatorSource source = new BytesRefFieldComparatorSource(this, missingValue, sortMode, nested); @@ -93,7 +144,7 @@ public class SortedSetDVOrdinalsIndexFieldData extends DocValuesIndexFieldData i @Override public LeafOrdinalsFieldData load(LeafReaderContext context) { - return new SortedSetDVBytesLeafFieldData(context.reader(), fieldName, scriptFunction); + return new SortedSetBytesLeafFieldData(context.reader(), fieldName, scriptFunction); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java index a268e278f93..e0c0c2b4f31 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java @@ -35,7 +35,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.util.CollectionUtils; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.BytesBinaryDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.BytesBinaryIndexFieldData; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.index.query.QueryShardException; import org.elasticsearch.search.DocValueFormat; @@ -133,7 +133,7 @@ public class BinaryFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new BytesBinaryDVIndexFieldData.Builder(); + return new BytesBinaryIndexFieldData.Builder(); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java index 06d753f4b6e..8a3728a5c38 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java @@ -36,7 +36,7 @@ import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; @@ -186,7 +186,7 @@ public class BooleanFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder().numericType(NumericType.BOOLEAN); + return new SortedNumericIndexFieldData.Builder(NumericType.BOOLEAN); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java index 579f0fe4a2d..f24c20615cd 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java @@ -49,7 +49,7 @@ import org.elasticsearch.common.xcontent.XContentBuilder; import org.elasticsearch.common.xcontent.support.XContentMapValues; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexNumericFieldData.NumericType; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.query.DateRangeIncludingNowQuery; import org.elasticsearch.index.query.QueryRewriteContext; import org.elasticsearch.index.query.QueryShardContext; @@ -546,7 +546,7 @@ public final class DateFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder().numericType(resolution.numericType()); + return new SortedNumericIndexFieldData.Builder(resolution.numericType()); } @Override diff --git a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java index 4b3abf6f89e..722fbdf9c8c 100644 --- a/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java +++ b/server/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java @@ -29,7 +29,7 @@ import org.elasticsearch.common.geo.GeoUtils; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.fielddata.IndexFieldData; -import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointIndexFieldData; import org.elasticsearch.index.query.VectorGeoPointShapeQueryProcessor; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; @@ -192,7 +192,7 @@ public class GeoPointFieldMapper extends AbstractPointGeometryFieldMapper { throw new QueryShardException(context, "[numeric_type] option cannot be set on a non-numeric field, got " + fieldType.typeName()); } - SortedNumericDVIndexFieldData numericFieldData = (SortedNumericDVIndexFieldData) fieldData; + SortedNumericIndexFieldData numericFieldData = (SortedNumericIndexFieldData) fieldData; NumericType resolvedType = resolveNumericType(numericType); field = numericFieldData.sortField(resolvedType, missing, localSortMode(), nested, reverse); } else { @@ -487,7 +487,7 @@ public class FieldSortBuilder extends SortBuilder { throw new QueryShardException(context, "we only support AVG, MEDIAN and SUM on number based fields"); } if (numericType != null) { - SortedNumericDVIndexFieldData numericFieldData = (SortedNumericDVIndexFieldData) fieldData; + SortedNumericIndexFieldData numericFieldData = (SortedNumericIndexFieldData) fieldData; NumericType resolvedType = resolveNumericType(numericType); return numericFieldData.newBucketedSort(resolvedType, context.bigArrays(), missing, localSortMode(), nested, order, fieldType.docValueFormat(null, null), bucketSize, extra); diff --git a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java index d6fbbe81e67..971f44d78b9 100644 --- a/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java +++ b/server/src/main/java/org/elasticsearch/search/sort/GeoDistanceSortBuilder.java @@ -49,7 +49,7 @@ import org.elasticsearch.index.fielddata.IndexGeoPointFieldData; import org.elasticsearch.index.fielddata.MultiGeoPointValues; import org.elasticsearch.index.fielddata.NumericDoubleValues; import org.elasticsearch.index.fielddata.SortedNumericDoubleValues; -import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointDVIndexFieldData.LatLonPointDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.AbstractLatLonPointIndexFieldData.LatLonPointIndexFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.query.GeoValidationMethod; import org.elasticsearch.index.query.QueryBuilder; @@ -584,7 +584,7 @@ public class GeoDistanceSortBuilder extends SortBuilder IndexGeoPointFieldData geoIndexFieldData = fieldData(context); Nested nested = nested(context); - if (geoIndexFieldData.getClass() == LatLonPointDVIndexFieldData.class // only works with 5.x geo_point + if (geoIndexFieldData.getClass() == LatLonPointIndexFieldData.class // only works with 5.x geo_point && nested == null && localSortMode == MultiValueMode.MIN // LatLonDocValuesField internally picks the closest point && unit == DistanceUnit.METERS diff --git a/server/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java b/server/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java index 32ee2d76b13..e47a8de2d88 100644 --- a/server/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java +++ b/server/src/test/java/org/elasticsearch/index/fielddata/FieldDataCacheTests.java @@ -37,7 +37,7 @@ import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.plain.AbstractLeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData; -import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.TextFieldMapper; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; @@ -69,11 +69,11 @@ public class FieldDataCacheTests extends ESTestCase { ElasticsearchDirectoryReader.wrap(DirectoryReader.open(dir), new ShardId("_index", "_na_", 0)); DummyAccountingFieldDataCache fieldDataCache = new DummyAccountingFieldDataCache(); - // Testing SortedSetDVOrdinalsIndexFieldData: - SortedSetDVOrdinalsIndexFieldData sortedSetDVOrdinalsIndexFieldData = createSortedDV("field1", fieldDataCache); - sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir); + // Testing SortedSetOrdinalsIndexFieldData: + SortedSetOrdinalsIndexFieldData sortedSetOrdinalsIndexFieldData = createSortedDV("field1", fieldDataCache); + sortedSetOrdinalsIndexFieldData.loadGlobal(ir); assertThat(fieldDataCache.cachedGlobally, equalTo(1)); - sortedSetDVOrdinalsIndexFieldData.loadGlobal(new FieldMaskingReader("field1", ir)); + sortedSetOrdinalsIndexFieldData.loadGlobal(new FieldMaskingReader("field1", ir)); assertThat(fieldDataCache.cachedGlobally, equalTo(1)); // Testing PagedBytesIndexFieldData @@ -87,8 +87,8 @@ public class FieldDataCacheTests extends ESTestCase { dir.close(); } - private SortedSetDVOrdinalsIndexFieldData createSortedDV(String fieldName, IndexFieldDataCache indexFieldDataCache) { - return new SortedSetDVOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, fieldName, new NoneCircuitBreakerService(), + private SortedSetOrdinalsIndexFieldData createSortedDV(String fieldName, IndexFieldDataCache indexFieldDataCache) { + return new SortedSetOrdinalsIndexFieldData(createIndexSettings(), indexFieldDataCache, fieldName, new NoneCircuitBreakerService(), AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION); } diff --git a/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java b/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java index d70158714e6..a03a74a19bf 100644 --- a/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java +++ b/server/src/test/java/org/elasticsearch/index/fielddata/IndexFieldDataServiceTests.java @@ -33,8 +33,8 @@ import org.apache.lucene.util.Accountable; import org.elasticsearch.common.lucene.index.ElasticsearchDirectoryReader; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.index.IndexService; -import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; -import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.BooleanFieldMapper; import org.elasticsearch.index.mapper.ContentPath; import org.elasticsearch.index.mapper.KeywordFieldMapper; @@ -74,7 +74,7 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { final MappedFieldType stringMapper = new KeywordFieldMapper.Builder("string").build(ctx).fieldType(); ifdService.clear(); IndexFieldData fd = ifdService.getForField(stringMapper); - assertTrue(fd instanceof SortedSetDVOrdinalsIndexFieldData); + assertTrue(fd instanceof SortedSetOrdinalsIndexFieldData); for (MappedFieldType mapper : Arrays.asList( new NumberFieldMapper.Builder("int", NumberFieldMapper.NumberType.BYTE).build(ctx).fieldType(), @@ -84,20 +84,20 @@ public class IndexFieldDataServiceTests extends ESSingleNodeTestCase { )) { ifdService.clear(); fd = ifdService.getForField(mapper); - assertTrue(fd instanceof SortedNumericDVIndexFieldData); + assertTrue(fd instanceof SortedNumericIndexFieldData); } final MappedFieldType floatMapper = new NumberFieldMapper.Builder("float", NumberFieldMapper.NumberType.FLOAT) .build(ctx).fieldType(); ifdService.clear(); fd = ifdService.getForField(floatMapper); - assertTrue(fd instanceof SortedNumericDVIndexFieldData); + assertTrue(fd instanceof SortedNumericIndexFieldData); final MappedFieldType doubleMapper = new NumberFieldMapper.Builder("double", NumberFieldMapper.NumberType.DOUBLE) .build(ctx).fieldType(); ifdService.clear(); fd = ifdService.getForField(doubleMapper); - assertTrue(fd instanceof SortedNumericDVIndexFieldData); + assertTrue(fd instanceof SortedNumericIndexFieldData); } public void testClearField() throws Exception { diff --git a/server/src/test/java/org/elasticsearch/index/fielddata/plain/HalfFloatFielddataTests.java b/server/src/test/java/org/elasticsearch/index/fielddata/plain/HalfFloatFielddataTests.java index c5138b371d1..66145c7a866 100644 --- a/server/src/test/java/org/elasticsearch/index/fielddata/plain/HalfFloatFielddataTests.java +++ b/server/src/test/java/org/elasticsearch/index/fielddata/plain/HalfFloatFielddataTests.java @@ -48,7 +48,7 @@ public class HalfFloatFielddataTests extends ESTestCase { w.addDocument(doc); final DirectoryReader dirReader = DirectoryReader.open(w); LeafReader reader = getOnlyLeafReader(dirReader); - SortedNumericDoubleValues values = new SortedNumericDVIndexFieldData.SortedNumericHalfFloatFieldData( + SortedNumericDoubleValues values = new SortedNumericIndexFieldData.SortedNumericHalfFloatFieldData( reader, "half_float").getDoubleValues(); assertNotNull(FieldData.unwrapSingleton(values)); assertTrue(values.advanceExact(0)); @@ -70,7 +70,7 @@ public class HalfFloatFielddataTests extends ESTestCase { w.addDocument(doc); final DirectoryReader dirReader = DirectoryReader.open(w); LeafReader reader = getOnlyLeafReader(dirReader); - SortedNumericDoubleValues values = new SortedNumericDVIndexFieldData.SortedNumericHalfFloatFieldData( + SortedNumericDoubleValues values = new SortedNumericIndexFieldData.SortedNumericHalfFloatFieldData( reader, "half_float").getDoubleValues(); assertNull(FieldData.unwrapSingleton(values)); assertTrue(values.advanceExact(0)); diff --git a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java index e06b13caa82..e218c21910f 100644 --- a/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java +++ b/server/src/test/java/org/elasticsearch/index/mapper/DateFieldTypeTests.java @@ -43,7 +43,7 @@ import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.core.internal.io.IOUtils; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexNumericFieldData; -import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.fielddata.LeafNumericFieldData; import org.elasticsearch.index.mapper.DateFieldMapper.DateFieldType; import org.elasticsearch.index.mapper.DateFieldMapper.Resolution; @@ -332,7 +332,7 @@ public class DateFieldTypeTests extends FieldTypeTestCase { Settings settings = Settings.builder().put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT) .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1).put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 1).build(); IndexSettings indexSettings = new IndexSettings(IndexMetadata.builder("foo").settings(settings).build(), settings); - SortedNumericDVIndexFieldData fieldData = new SortedNumericDVIndexFieldData(indexSettings.getIndex(), "my_date", + SortedNumericIndexFieldData fieldData = new SortedNumericIndexFieldData(indexSettings.getIndex(), "my_date", IndexNumericFieldData.NumericType.DATE_NANOSECONDS); // Read index and check the doc values DirectoryReader reader = DirectoryReader.open(w); diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java index d9ebbf633f2..78d5830f5d3 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/sampler/DiversifiedSamplerTests.java @@ -36,7 +36,7 @@ import org.elasticsearch.common.lucene.search.function.FieldValueFactorFunction; import org.elasticsearch.common.lucene.search.function.FunctionScoreQuery; import org.elasticsearch.index.Index; import org.elasticsearch.index.fielddata.IndexNumericFieldData; -import org.elasticsearch.index.fielddata.plain.SortedNumericDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedNumericIndexFieldData; import org.elasticsearch.index.mapper.KeywordFieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.NumberFieldMapper; @@ -191,7 +191,7 @@ public class DiversifiedSamplerTests extends AggregatorTestCase { idFieldType.setName("id"); idFieldType.setHasDocValues(true); - SortedNumericDVIndexFieldData fieldData = new SortedNumericDVIndexFieldData(new Index("index", "index"), "price", + SortedNumericIndexFieldData fieldData = new SortedNumericIndexFieldData(new Index("index", "index"), "price", IndexNumericFieldData.NumericType.DOUBLE); FunctionScoreQuery query = new FunctionScoreQuery(new MatchAllDocsQuery(), new FieldValueFactorFunction("price", 1, FieldValueFactorFunction.Modifier.RECIPROCAL, null, fieldData)); diff --git a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java index 9f0cdb6900c..6823b970b6b 100644 --- a/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java +++ b/x-pack/plugin/mapper-flattened/src/main/java/org/elasticsearch/xpack/flattened/mapper/FlatObjectFieldMapper.java @@ -37,8 +37,7 @@ import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; import org.elasticsearch.index.fielddata.LeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; import org.elasticsearch.index.fielddata.plain.AbstractLeafOrdinalsFieldData; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; -import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.DynamicKeyFieldMapper; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.FieldNamesFieldMapper; @@ -460,7 +459,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { CircuitBreakerService breakerService, MapperService mapperService) { String fieldName = fieldType.name(); - IndexOrdinalsFieldData delegate = new SortedSetDVOrdinalsIndexFieldData(indexSettings, + IndexOrdinalsFieldData delegate = new SortedSetOrdinalsIndexFieldData(indexSettings, cache, fieldName, breakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION); return new KeyedFlatObjectFieldData(key, delegate); } @@ -537,7 +536,7 @@ public final class FlatObjectFieldMapper extends DynamicKeyFieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new DocValuesIndexFieldData.Builder(); + return new SortedSetOrdinalsIndexFieldData.Builder(); } @Override diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java index a86bb920631..be36b44da4f 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/xpack/security/authz/accesscontrol/FieldDataCacheWithFieldSubsetReaderTests.java @@ -30,7 +30,7 @@ import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.IndexOrdinalsFieldData; import org.elasticsearch.index.fielddata.plain.AbstractLeafOrdinalsFieldData; import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData; -import org.elasticsearch.index.fielddata.plain.SortedSetDVOrdinalsIndexFieldData; +import org.elasticsearch.index.fielddata.plain.SortedSetOrdinalsIndexFieldData; import org.elasticsearch.index.mapper.TextFieldMapper; import org.elasticsearch.index.shard.ShardId; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -45,7 +45,7 @@ import static org.hamcrest.Matchers.greaterThanOrEqualTo; public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase { - private SortedSetDVOrdinalsIndexFieldData sortedSetDVOrdinalsIndexFieldData; + private SortedSetOrdinalsIndexFieldData sortedSetOrdinalsIndexFieldData; private PagedBytesIndexFieldData pagedBytesIndexFieldData; private DirectoryReader ir; @@ -60,7 +60,7 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase { CircuitBreakerService circuitBreakerService = new NoneCircuitBreakerService(); String name = "_field"; indexFieldDataCache = new DummyAccountingFieldDataCache(); - sortedSetDVOrdinalsIndexFieldData = new SortedSetDVOrdinalsIndexFieldData(indexSettings,indexFieldDataCache, name, + sortedSetOrdinalsIndexFieldData = new SortedSetOrdinalsIndexFieldData(indexSettings,indexFieldDataCache, name, circuitBreakerService, AbstractLeafOrdinalsFieldData.DEFAULT_SCRIPT_FUNCTION); pagedBytesIndexFieldData = new PagedBytesIndexFieldData(indexSettings, name, indexFieldDataCache, circuitBreakerService, TextFieldMapper.Defaults.FIELDDATA_MIN_FREQUENCY, @@ -94,13 +94,13 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase { public void testSortedSetDVOrdinalsIndexFieldData_global() throws Exception { assertThat(indexFieldDataCache.topLevelBuilds, equalTo(0)); - IndexOrdinalsFieldData global = sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir); + IndexOrdinalsFieldData global = sortedSetOrdinalsIndexFieldData.loadGlobal(ir); LeafOrdinalsFieldData atomic = global.load(ir.leaves().get(0)); assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(numDocs)); assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1)); DirectoryReader ir = FieldSubsetReader.wrap(this.ir, new CharacterRunAutomaton(Automata.makeEmpty())); - global = sortedSetDVOrdinalsIndexFieldData.loadGlobal(ir); + global = sortedSetOrdinalsIndexFieldData.loadGlobal(ir); atomic = global.load(ir.leaves().get(0)); assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L)); assertThat(indexFieldDataCache.topLevelBuilds, equalTo(1)); @@ -108,13 +108,13 @@ public class FieldDataCacheWithFieldSubsetReaderTests extends ESTestCase { public void testSortedSetDVOrdinalsIndexFieldData_segment() throws Exception { for (LeafReaderContext context : ir.leaves()) { - LeafOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context); + LeafOrdinalsFieldData atomic = sortedSetOrdinalsIndexFieldData.load(context); assertThat(atomic.getOrdinalsValues().getValueCount(), greaterThanOrEqualTo(1L)); } DirectoryReader ir = FieldSubsetReader.wrap(this.ir, new CharacterRunAutomaton(Automata.makeEmpty())); for (LeafReaderContext context : ir.leaves()) { - LeafOrdinalsFieldData atomic = sortedSetDVOrdinalsIndexFieldData.load(context); + LeafOrdinalsFieldData atomic = sortedSetOrdinalsIndexFieldData.load(context); assertThat(atomic.getOrdinalsValues().getValueCount(), equalTo(0L)); } // dv based field data doesn't use index field data cache, so in the end noting should have been added diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeDVIndexFieldData.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java similarity index 82% rename from x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeDVIndexFieldData.java rename to x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java index 30c698b9670..14d1b3a4219 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeDVIndexFieldData.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/fielddata/AbstractLatLonShapeIndexFieldData.java @@ -17,7 +17,6 @@ import org.elasticsearch.index.Index; import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -26,9 +25,28 @@ import org.elasticsearch.search.MultiValueMode; import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.SortOrder; -public abstract class AbstractLatLonShapeDVIndexFieldData extends DocValuesIndexFieldData implements IndexGeoShapeFieldData { - AbstractLatLonShapeDVIndexFieldData(Index index, String fieldName) { - super(index, fieldName); +public abstract class AbstractLatLonShapeIndexFieldData implements IndexGeoShapeFieldData { + protected final Index index; + protected final String fieldName; + + AbstractLatLonShapeIndexFieldData(Index index, String fieldName) { + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } @Override @@ -37,8 +55,8 @@ public abstract class AbstractLatLonShapeDVIndexFieldData extends DocValuesIndex throw new IllegalArgumentException("can't sort on geo_shape field without using specific sorting feature, like geo_distance"); } - public static class LatLonShapeDVIndexFieldData extends AbstractLatLonShapeDVIndexFieldData { - public LatLonShapeDVIndexFieldData(Index index, String fieldName) { + public static class LatLonShapeIndexFieldData extends AbstractLatLonShapeIndexFieldData { + public LatLonShapeIndexFieldData(Index index, String fieldName) { super(index, fieldName); } @@ -81,7 +99,7 @@ public abstract class AbstractLatLonShapeDVIndexFieldData extends DocValuesIndex public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { // ignore breaker - return new LatLonShapeDVIndexFieldData(indexSettings.getIndex(), fieldType.name()); + return new LatLonShapeIndexFieldData(indexSettings.getIndex(), fieldType.name()); } } } diff --git a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java index c7aac2ddfdd..8b1daa6d6ae 100644 --- a/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java +++ b/x-pack/plugin/spatial/src/main/java/org/elasticsearch/xpack/spatial/index/mapper/GeoShapeWithDocValuesFieldMapper.java @@ -28,7 +28,7 @@ import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.mapper.TypeParsers; import org.elasticsearch.index.query.VectorGeoShapeQueryProcessor; import org.elasticsearch.search.aggregations.support.ValuesSourceType; -import org.elasticsearch.xpack.spatial.index.fielddata.AbstractLatLonShapeDVIndexFieldData; +import org.elasticsearch.xpack.spatial.index.fielddata.AbstractLatLonShapeIndexFieldData; import org.elasticsearch.xpack.spatial.index.fielddata.CentroidCalculator; import org.elasticsearch.xpack.spatial.search.aggregations.support.GeoShapeValuesSourceType; @@ -146,7 +146,7 @@ public class GeoShapeWithDocValuesFieldMapper extends GeoShapeFieldMapper { public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { failIfNoDocValues(); - return new AbstractLatLonShapeDVIndexFieldData.Builder(); + return new AbstractLatLonShapeIndexFieldData.Builder(); } @Override diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java index 2f42a951a19..7af5cf5cc0a 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/DenseVectorFieldMapper.java @@ -28,7 +28,7 @@ import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.DocValueFormat; import org.elasticsearch.search.aggregations.support.CoreValuesSourceType; import org.elasticsearch.search.aggregations.support.ValuesSourceType; -import org.elasticsearch.xpack.vectors.query.VectorDVIndexFieldData; +import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData; import java.io.IOException; import java.nio.ByteBuffer; @@ -147,7 +147,7 @@ public class DenseVectorFieldMapper extends FieldMapper implements ArrayValueMap @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { - return new VectorDVIndexFieldData.Builder(true); + return new VectorIndexFieldData.Builder(true); } @Override diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java index aa77bde6365..e6dd0da13ad 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/mapper/SparseVectorFieldMapper.java @@ -25,7 +25,7 @@ import org.elasticsearch.index.mapper.MapperParsingException; import org.elasticsearch.index.mapper.ParseContext; import org.elasticsearch.index.query.QueryShardContext; import org.elasticsearch.search.DocValueFormat; -import org.elasticsearch.xpack.vectors.query.VectorDVIndexFieldData; +import org.elasticsearch.xpack.vectors.query.VectorIndexFieldData; import java.io.IOException; import java.time.ZoneId; @@ -117,7 +117,7 @@ public class SparseVectorFieldMapper extends FieldMapper { @Override public IndexFieldData.Builder fielddataBuilder(String fullyQualifiedIndexName) { - return new VectorDVIndexFieldData.Builder(false); + return new VectorIndexFieldData.Builder(false); } @Override diff --git a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorDVIndexFieldData.java b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java similarity index 80% rename from x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorDVIndexFieldData.java rename to x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java index b64648cd79d..598c775a7da 100644 --- a/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorDVIndexFieldData.java +++ b/x-pack/plugin/vectors/src/main/java/org/elasticsearch/xpack/vectors/query/VectorIndexFieldData.java @@ -16,7 +16,6 @@ import org.elasticsearch.index.IndexSettings; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; -import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData; import org.elasticsearch.index.mapper.MappedFieldType; import org.elasticsearch.index.mapper.MapperService; import org.elasticsearch.indices.breaker.CircuitBreakerService; @@ -26,12 +25,31 @@ import org.elasticsearch.search.sort.BucketedSort; import org.elasticsearch.search.sort.SortOrder; -public class VectorDVIndexFieldData extends DocValuesIndexFieldData implements IndexFieldData { +public class VectorIndexFieldData implements IndexFieldData { + + protected final Index index; + protected final String fieldName; private final boolean isDense; - public VectorDVIndexFieldData(Index index, String fieldName, boolean isDense) { - super(index, fieldName); + public VectorIndexFieldData(Index index, String fieldName, boolean isDense) { this.isDense = isDense; + this.index = index; + this.fieldName = fieldName; + } + + @Override + public final String getFieldName() { + return fieldName; + } + + @Override + public final void clear() { + // can't do + } + + @Override + public final Index index() { + return index; } @Override @@ -65,7 +83,7 @@ public class VectorDVIndexFieldData extends DocValuesIndexFieldData implements I public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { final String fieldName = fieldType.name(); - return new VectorDVIndexFieldData(indexSettings.getIndex(), fieldName, isDense); + return new VectorIndexFieldData(indexSettings.getIndex(), fieldName, isDense); } } diff --git a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java index da0d781e4ff..ec503081885 100644 --- a/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java +++ b/x-pack/plugin/wildcard/src/main/java/org/elasticsearch/xpack/wildcard/mapper/WildcardFieldMapper.java @@ -44,7 +44,7 @@ import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldData.XFieldComparatorSource.Nested; import org.elasticsearch.index.fielddata.IndexFieldDataCache; import org.elasticsearch.index.fielddata.fieldcomparator.BytesRefFieldComparatorSource; -import org.elasticsearch.index.fielddata.plain.BytesBinaryDVIndexFieldData; +import org.elasticsearch.index.fielddata.plain.BytesBinaryIndexFieldData; import org.elasticsearch.index.mapper.BinaryFieldMapper.CustomBinaryDocValuesField; import org.elasticsearch.index.mapper.FieldMapper; import org.elasticsearch.index.mapper.MappedFieldType; @@ -467,7 +467,7 @@ public class WildcardFieldMapper extends FieldMapper { @Override public IndexFieldData build(IndexSettings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) { - return new WildcardBytesBinaryDVIndexFieldData(indexSettings.getIndex(), fieldType.name()); + return new WildcardBytesBinaryIndexFieldData(indexSettings.getIndex(), fieldType.name()); }}; } @@ -478,9 +478,9 @@ public class WildcardFieldMapper extends FieldMapper { } - static class WildcardBytesBinaryDVIndexFieldData extends BytesBinaryDVIndexFieldData{ + static class WildcardBytesBinaryIndexFieldData extends BytesBinaryIndexFieldData { - WildcardBytesBinaryDVIndexFieldData(Index index, String fieldName) { + WildcardBytesBinaryIndexFieldData(Index index, String fieldName) { super(index, fieldName); }