Skip to content

Commit d0da0d4

Browse files
committed
move GPU plugin to x-pack
1 parent 3af34ab commit d0da0d4

File tree

33 files changed

+1939
-1503
lines changed

33 files changed

+1939
-1503
lines changed

server/src/internalClusterTest/java/org/elasticsearch/search/query/RescoreKnnVectorQueryIT.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.elasticsearch.common.settings.Settings;
1818
import org.elasticsearch.index.IndexVersion;
1919
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
20-
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.VectorIndexType;
20+
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper.BasicVectorIndexType;
2121
import org.elasticsearch.index.mapper.vectors.DenseVectorScriptDocValues;
2222
import org.elasticsearch.index.query.MatchAllQueryBuilder;
2323
import org.elasticsearch.index.query.QueryBuilders;
@@ -84,8 +84,8 @@ protected Map<String, Function<Map<String, Object>, Object>> pluginScripts() {
8484
@Before
8585
public void setup() throws IOException {
8686
String type = randomFrom(
87-
Arrays.stream(VectorIndexType.values())
88-
.filter(VectorIndexType::isQuantized)
87+
Arrays.stream(BasicVectorIndexType.values())
88+
.filter(BasicVectorIndexType::isQuantized)
8989
.map(t -> t.name().toLowerCase(Locale.ROOT))
9090
.collect(Collectors.toCollection(ArrayList::new))
9191
);

server/src/main/java/module-info.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,8 +457,7 @@
457457
org.elasticsearch.index.codec.vectors.es816.ES816HnswBinaryQuantizedVectorsFormat,
458458
org.elasticsearch.index.codec.vectors.es818.ES818BinaryQuantizedVectorsFormat,
459459
org.elasticsearch.index.codec.vectors.es818.ES818HnswBinaryQuantizedVectorsFormat,
460-
org.elasticsearch.index.codec.vectors.IVFVectorsFormat,
461-
org.elasticsearch.index.codec.vectors.GPUVectorsFormat;
460+
org.elasticsearch.index.codec.vectors.IVFVectorsFormat;
462461

463462
provides org.apache.lucene.codecs.Codec
464463
with

server/src/main/java/org/elasticsearch/index/mapper/DocumentParser.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,8 @@ private static void postProcessDynamicArrayMapping(DocumentParserContext context
804804

805805
DenseVectorFieldMapper.Builder builder = new DenseVectorFieldMapper.Builder(
806806
fieldName,
807-
context.indexSettings().getIndexVersionCreated()
807+
context.indexSettings().getIndexVersionCreated(),
808+
context::denseVectorIndexType
808809
);
809810
DenseVectorFieldMapper denseVectorFieldMapper = builder.build(builderContext);
810811
context.updateDynamicMappers(fullFieldName, List.of(denseVectorFieldMapper));

server/src/main/java/org/elasticsearch/index/mapper/DocumentParserContext.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.elasticsearch.index.IndexSettings;
2020
import org.elasticsearch.index.analysis.IndexAnalyzers;
2121
import org.elasticsearch.index.mapper.MapperService.MergeReason;
22+
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
2223
import org.elasticsearch.xcontent.FilterXContentParserWrapper;
2324
import org.elasticsearch.xcontent.FlatteningXContentParser;
2425
import org.elasticsearch.xcontent.XContentBuilder;
@@ -287,6 +288,10 @@ public final RootObjectMapper root() {
287288
return this.mappingLookup.getMapping().getRoot();
288289
}
289290

291+
public final DenseVectorFieldMapper.VectorIndexType denseVectorIndexType(String type) {
292+
return mappingParserContext.denseVectorIndexType(type);
293+
}
294+
290295
public final ObjectMapper parent() {
291296
return parent;
292297
}

server/src/main/java/org/elasticsearch/index/mapper/Mapper.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,18 @@ default boolean supportsVersion(IndexVersion indexCreatedVersion) {
131131
}
132132
}
133133

134+
// public interface DenseVectorTypeParser {
135+
// DenseVectorFieldMapper parse(String name, Map<String, Object> node, MappingParserContext parserContext)
136+
// throws MapperParsingException;
137+
//
138+
// /**
139+
// * Whether we can parse this type on indices with the given index created version.
140+
// */
141+
// default boolean supportsVersion(IndexVersion indexCreatedVersion) {
142+
// return indexCreatedVersion.onOrAfter(IndexVersions.MINIMUM_READONLY_COMPATIBLE);
143+
// }
144+
// }
145+
134146
private final String leafName;
135147

136148
@SuppressWarnings("this-escape")

server/src/main/java/org/elasticsearch/index/mapper/MapperRegistry.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.index.IndexVersion;
1313
import org.elasticsearch.index.IndexVersions;
14+
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
1415
import org.elasticsearch.plugins.FieldPredicate;
1516
import org.elasticsearch.plugins.MapperPlugin;
1617

@@ -31,12 +32,14 @@ public final class MapperRegistry {
3132
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers6x;
3233
private final Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers5x;
3334
private final Function<String, FieldPredicate> fieldFilter;
35+
private final Map<String, DenseVectorFieldMapper.VectorIndexType> denseVectorIndexTypes;
3436

3537
public MapperRegistry(
3638
Map<String, Mapper.TypeParser> mapperParsers,
3739
Map<String, RuntimeField.Parser> runtimeFieldParsers,
3840
Map<String, MetadataFieldMapper.TypeParser> metadataMapperParsers,
39-
Function<String, FieldPredicate> fieldFilter
41+
Function<String, FieldPredicate> fieldFilter,
42+
Map<String, DenseVectorFieldMapper.VectorIndexType> denseVectorIndexTypes
4043
) {
4144
this.mapperParsers = Collections.unmodifiableMap(new LinkedHashMap<>(mapperParsers));
4245
this.runtimeFieldParsers = runtimeFieldParsers;
@@ -50,6 +53,7 @@ public MapperRegistry(
5053
metadata5x.put(LegacyTypeFieldMapper.NAME, LegacyTypeFieldMapper.PARSER);
5154
this.metadataMapperParsers5x = metadata5x;
5255
this.fieldFilter = fieldFilter;
56+
this.denseVectorIndexTypes = Collections.unmodifiableMap(denseVectorIndexTypes);
5357
}
5458

5559
/**
@@ -100,4 +104,11 @@ public Map<String, MetadataFieldMapper.TypeParser> getMetadataMapperParsers(Inde
100104
public Function<String, FieldPredicate> getFieldFilter() {
101105
return fieldFilter;
102106
}
107+
108+
/**
109+
* Returns ...
110+
*/
111+
public DenseVectorFieldMapper.VectorIndexType getDenseVectorIndexType(String type) {
112+
return denseVectorIndexTypes.get(type);
113+
}
103114
}

server/src/main/java/org/elasticsearch/index/mapper/MapperService.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ public MapperService(
238238
similarityService::getSimilarity,
239239
type -> mapperRegistry.getMapperParser(type, indexVersionCreated),
240240
mapperRegistry.getRuntimeFieldParsers()::get,
241+
mapperRegistry::getDenseVectorIndexType,
241242
indexVersionCreated,
242243
clusterTransportVersion,
243244
searchExecutionContextSupplier,

server/src/main/java/org/elasticsearch/index/mapper/MappingParserContext.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.elasticsearch.index.IndexSettings;
1818
import org.elasticsearch.index.IndexVersion;
1919
import org.elasticsearch.index.analysis.IndexAnalyzers;
20+
import org.elasticsearch.index.mapper.vectors.DenseVectorFieldMapper;
2021
import org.elasticsearch.index.query.SearchExecutionContext;
2122
import org.elasticsearch.index.similarity.SimilarityProvider;
2223
import org.elasticsearch.script.ScriptCompiler;
@@ -33,6 +34,7 @@ public class MappingParserContext {
3334
private final Function<String, SimilarityProvider> similarityLookupService;
3435
private final Function<String, Mapper.TypeParser> typeParsers;
3536
private final Function<String, RuntimeField.Parser> runtimeFieldParsers;
37+
private final Function<String, DenseVectorFieldMapper.VectorIndexType> denseVectorIndexType;
3638
private final IndexVersion indexVersionCreated;
3739
private final Supplier<TransportVersion> clusterTransportVersion;
3840
private final Supplier<SearchExecutionContext> searchExecutionContextSupplier;
@@ -48,6 +50,7 @@ public MappingParserContext(
4850
Function<String, SimilarityProvider> similarityLookupService,
4951
Function<String, Mapper.TypeParser> typeParsers,
5052
Function<String, RuntimeField.Parser> runtimeFieldParsers,
53+
Function<String, DenseVectorFieldMapper.VectorIndexType> denseVectorIndexType,
5154
IndexVersion indexVersionCreated,
5255
Supplier<TransportVersion> clusterTransportVersion,
5356
Supplier<SearchExecutionContext> searchExecutionContextSupplier,
@@ -60,6 +63,7 @@ public MappingParserContext(
6063
this.similarityLookupService = similarityLookupService;
6164
this.typeParsers = typeParsers;
6265
this.runtimeFieldParsers = runtimeFieldParsers;
66+
this.denseVectorIndexType = denseVectorIndexType;
6367
this.indexVersionCreated = indexVersionCreated;
6468
this.clusterTransportVersion = clusterTransportVersion;
6569
this.searchExecutionContextSupplier = searchExecutionContextSupplier;
@@ -99,6 +103,10 @@ public RuntimeField.Parser runtimeFieldParser(String type) {
99103
return runtimeFieldParsers.apply(type);
100104
}
101105

106+
public DenseVectorFieldMapper.VectorIndexType denseVectorIndexType(String type) {
107+
return denseVectorIndexType.apply(type);
108+
}
109+
102110
public IndexVersion indexVersionCreated() {
103111
return indexVersionCreated;
104112
}
@@ -163,6 +171,7 @@ private static class MultiFieldParserContext extends MappingParserContext {
163171
in.similarityLookupService,
164172
in.typeParsers,
165173
in.runtimeFieldParsers,
174+
null, // TODO: serialization
166175
in.indexVersionCreated,
167176
in.clusterTransportVersion,
168177
in.searchExecutionContextSupplier,
@@ -193,6 +202,7 @@ private static class DynamicTemplateParserContext extends MappingParserContext {
193202
in.similarityLookupService,
194203
in.typeParsers,
195204
in.runtimeFieldParsers,
205+
null, // TODO: serialization
196206
in.indexVersionCreated,
197207
in.clusterTransportVersion,
198208
in.searchExecutionContextSupplier,

0 commit comments

Comments
 (0)