Skip to content

Commit f4e9f69

Browse files
committed
Merge pull request elastic#14082 from jpountz/remove/uninverted_numeric_fielddata
Remove "uninverted" and "binary" fielddata support for numeric and boolean fields.
2 parents eaffa97 + 76231c8 commit f4e9f69

20 files changed

+143
-2786
lines changed

core/src/main/java/org/elasticsearch/index/fielddata/IndexFieldDataService.java

+18-30
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,9 @@
3030
import org.elasticsearch.index.fielddata.plain.BytesBinaryDVIndexFieldData;
3131
import org.elasticsearch.index.fielddata.plain.DisabledIndexFieldData;
3232
import org.elasticsearch.index.fielddata.plain.DocValuesIndexFieldData;
33-
import org.elasticsearch.index.fielddata.plain.DoubleArrayIndexFieldData;
34-
import org.elasticsearch.index.fielddata.plain.FloatArrayIndexFieldData;
3533
import org.elasticsearch.index.fielddata.plain.GeoPointBinaryDVIndexFieldData;
3634
import org.elasticsearch.index.fielddata.plain.GeoPointDoubleArrayIndexFieldData;
3735
import org.elasticsearch.index.fielddata.plain.IndexIndexFieldData;
38-
import org.elasticsearch.index.fielddata.plain.PackedArrayIndexFieldData;
3936
import org.elasticsearch.index.fielddata.plain.PagedBytesIndexFieldData;
4037
import org.elasticsearch.index.fielddata.plain.ParentChildIndexFieldData;
4138
import org.elasticsearch.index.mapper.MappedFieldType;
@@ -64,9 +61,18 @@ public class IndexFieldDataService extends AbstractIndexComponent {
6461
public static final String FIELDDATA_CACHE_KEY = "index.fielddata.cache";
6562
public static final String FIELDDATA_CACHE_VALUE_NODE = "node";
6663

64+
private static final IndexFieldData.Builder MISSING_DOC_VALUES_BUILDER = new IndexFieldData.Builder() {
65+
@Override
66+
public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldType fieldType, IndexFieldDataCache cache, CircuitBreakerService breakerService, MapperService mapperService) {
67+
throw new IllegalStateException("Can't load fielddata on [" + fieldType.names().fullName()
68+
+ "] of index [" + index.getName() + "] because fielddata is unsupported on fields of type ["
69+
+ fieldType.fieldDataType().getType() + "]. Use doc values instead.");
70+
}
71+
};
72+
73+
private static final String ARRAY_FORMAT = "array";
6774
private static final String DISABLED_FORMAT = "disabled";
6875
private static final String DOC_VALUES_FORMAT = "doc_values";
69-
private static final String ARRAY_FORMAT = "array";
7076
private static final String PAGED_BYTES_FORMAT = "paged_bytes";
7177

7278
private final static Map<String, IndexFieldData.Builder> buildersByType;
@@ -77,19 +83,18 @@ public class IndexFieldDataService extends AbstractIndexComponent {
7783
static {
7884
Map<String, IndexFieldData.Builder> buildersByTypeBuilder = new HashMap<>();
7985
buildersByTypeBuilder.put("string", new PagedBytesIndexFieldData.Builder());
80-
buildersByTypeBuilder.put("float", new FloatArrayIndexFieldData.Builder());
81-
buildersByTypeBuilder.put("double", new DoubleArrayIndexFieldData.Builder());
82-
buildersByTypeBuilder.put("byte", new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.BYTE));
83-
buildersByTypeBuilder.put("short", new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.SHORT));
84-
buildersByTypeBuilder.put("int", new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.INT));
85-
buildersByTypeBuilder.put("long", new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.LONG));
86+
buildersByTypeBuilder.put("float", MISSING_DOC_VALUES_BUILDER);
87+
buildersByTypeBuilder.put("double", MISSING_DOC_VALUES_BUILDER);
88+
buildersByTypeBuilder.put("byte", MISSING_DOC_VALUES_BUILDER);
89+
buildersByTypeBuilder.put("short", MISSING_DOC_VALUES_BUILDER);
90+
buildersByTypeBuilder.put("int", MISSING_DOC_VALUES_BUILDER);
91+
buildersByTypeBuilder.put("long", MISSING_DOC_VALUES_BUILDER);
8692
buildersByTypeBuilder.put("geo_point", new GeoPointDoubleArrayIndexFieldData.Builder());
8793
buildersByTypeBuilder.put(ParentFieldMapper.NAME, new ParentChildIndexFieldData.Builder());
8894
buildersByTypeBuilder.put(IndexFieldMapper.NAME, new IndexIndexFieldData.Builder());
8995
buildersByTypeBuilder.put("binary", new DisabledIndexFieldData.Builder());
90-
buildersByTypeBuilder.put(BooleanFieldMapper.CONTENT_TYPE,
91-
new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.BOOLEAN));
92-
buildersByType = unmodifiableMap(buildersByTypeBuilder);
96+
buildersByTypeBuilder.put(BooleanFieldMapper.CONTENT_TYPE, MISSING_DOC_VALUES_BUILDER);
97+
buildersByType = unmodifiableMap(buildersByTypeBuilder);
9398

9499

95100
docValuesBuildersByType = MapBuilder.<String, IndexFieldData.Builder>newMapBuilder()
@@ -110,27 +115,21 @@ public class IndexFieldDataService extends AbstractIndexComponent {
110115
.put(Tuple.tuple("string", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder())
111116
.put(Tuple.tuple("string", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
112117

113-
.put(Tuple.tuple("float", ARRAY_FORMAT), new FloatArrayIndexFieldData.Builder())
114118
.put(Tuple.tuple("float", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.FLOAT))
115119
.put(Tuple.tuple("float", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
116120

117-
.put(Tuple.tuple("double", ARRAY_FORMAT), new DoubleArrayIndexFieldData.Builder())
118121
.put(Tuple.tuple("double", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.DOUBLE))
119122
.put(Tuple.tuple("double", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
120123

121-
.put(Tuple.tuple("byte", ARRAY_FORMAT), new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.BYTE))
122124
.put(Tuple.tuple("byte", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.BYTE))
123125
.put(Tuple.tuple("byte", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
124126

125-
.put(Tuple.tuple("short", ARRAY_FORMAT), new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.SHORT))
126127
.put(Tuple.tuple("short", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.SHORT))
127128
.put(Tuple.tuple("short", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
128129

129-
.put(Tuple.tuple("int", ARRAY_FORMAT), new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.INT))
130130
.put(Tuple.tuple("int", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.INT))
131131
.put(Tuple.tuple("int", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
132132

133-
.put(Tuple.tuple("long", ARRAY_FORMAT), new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.LONG))
134133
.put(Tuple.tuple("long", DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.LONG))
135134
.put(Tuple.tuple("long", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
136135

@@ -141,7 +140,6 @@ public class IndexFieldDataService extends AbstractIndexComponent {
141140
.put(Tuple.tuple("binary", DOC_VALUES_FORMAT), new BytesBinaryDVIndexFieldData.Builder())
142141
.put(Tuple.tuple("binary", DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
143142

144-
.put(Tuple.tuple(BooleanFieldMapper.CONTENT_TYPE, ARRAY_FORMAT), new PackedArrayIndexFieldData.Builder().setNumericType(IndexNumericFieldData.NumericType.BOOLEAN))
145143
.put(Tuple.tuple(BooleanFieldMapper.CONTENT_TYPE, DOC_VALUES_FORMAT), new DocValuesIndexFieldData.Builder().numericType(IndexNumericFieldData.NumericType.BOOLEAN))
146144
.put(Tuple.tuple(BooleanFieldMapper.CONTENT_TYPE, DISABLED_FORMAT), new DisabledIndexFieldData.Builder())
147145

@@ -163,12 +161,6 @@ public void onRemoval(ShardId shardId, Names fieldNames, FieldDataType fieldData
163161
};
164162
private volatile IndexFieldDataCache.Listener listener = DEFAULT_NOOP_LISTENER;
165163

166-
167-
// We need to cache fielddata on the _parent field because of 1.x indices.
168-
// When we don't support 1.x anymore (3.0) then remove this caching
169-
// This variable needs to be read/written under lock
170-
private IndexFieldData<?> parentIndexFieldData;
171-
172164
@Inject
173165
public IndexFieldDataService(Index index, @IndexSettings Settings indexSettings, IndicesFieldDataCache indicesFieldDataCache,
174166
CircuitBreakerService circuitBreakerService, MapperService mapperService) {
@@ -179,7 +171,6 @@ public IndexFieldDataService(Index index, @IndexSettings Settings indexSettings,
179171
}
180172

181173
public synchronized void clear() {
182-
parentIndexFieldData = null;
183174
List<Throwable> exceptions = new ArrayList<>(0);
184175
final Collection<IndexFieldDataCache> fieldDataCacheValues = fieldDataCaches.values();
185176
for (IndexFieldDataCache cache : fieldDataCacheValues) {
@@ -194,9 +185,6 @@ public synchronized void clear() {
194185
}
195186

196187
public synchronized void clearField(final String fieldName) {
197-
if (ParentFieldMapper.NAME.equals(fieldName)) {
198-
parentIndexFieldData = null;
199-
}
200188
List<Throwable> exceptions = new ArrayList<>(0);
201189
final IndexFieldDataCache cache = fieldDataCaches.remove(fieldName);
202190
if (cache != null) {

core/src/main/java/org/elasticsearch/index/fielddata/plain/BinaryDVNumericIndexFieldData.java

-225
This file was deleted.

core/src/main/java/org/elasticsearch/index/fielddata/plain/DocValuesIndexFieldData.java

+1-9
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
package org.elasticsearch.index.fielddata.plain;
2121

2222
import org.apache.lucene.index.IndexReader;
23-
import org.elasticsearch.Version;
2423
import org.elasticsearch.common.logging.ESLogger;
2524
import org.elasticsearch.common.logging.Loggers;
2625
import org.elasticsearch.common.settings.Settings;
@@ -33,7 +32,6 @@
3332
import org.elasticsearch.index.mapper.MappedFieldType.Names;
3433
import org.elasticsearch.index.mapper.MapperService;
3534
import org.elasticsearch.index.mapper.internal.IdFieldMapper;
36-
import org.elasticsearch.index.mapper.internal.TimestampFieldMapper;
3735
import org.elasticsearch.index.mapper.internal.UidFieldMapper;
3836
import org.elasticsearch.indices.breaker.CircuitBreakerService;
3937

@@ -104,13 +102,7 @@ public IndexFieldData<?> build(Index index, Settings indexSettings, MappedFieldT
104102
assert numericType == null;
105103
return new BinaryDVIndexFieldData(index, fieldNames, fieldType.fieldDataType());
106104
} else if (numericType != null) {
107-
if (TimestampFieldMapper.NAME.equals(fieldNames.indexName())
108-
|| Version.indexCreated(indexSettings).onOrAfter(Version.V_1_4_0_Beta1)) {
109-
return new SortedNumericDVIndexFieldData(index, fieldNames, numericType, fieldType.fieldDataType());
110-
} else {
111-
// prior to ES 1.4: multi-valued numerics were boxed inside a byte[] as BINARY
112-
return new BinaryDVNumericIndexFieldData(index, fieldNames, numericType, fieldType.fieldDataType());
113-
}
105+
return new SortedNumericDVIndexFieldData(index, fieldNames, numericType, fieldType.fieldDataType());
114106
} else {
115107
return new SortedSetDVOrdinalsIndexFieldData(index, cache, indexSettings, fieldNames, breakerService, fieldType.fieldDataType());
116108
}

0 commit comments

Comments
 (0)