Skip to content

Commit 9f6852e

Browse files
committed
Change version to 910
1 parent 01a5be0 commit 9f6852e

27 files changed

+173
-40
lines changed
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the "Elastic License
4+
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
5+
* Public License v 1"; you may not use this file except in compliance with, at
6+
* your election, the "Elastic License 2.0", the "GNU Affero General Public
7+
* License v3.0 only", or the "Server Side Public License, v 1".
8+
*/
9+
10+
package org.elasticsearch.index.codec;
11+
12+
import org.apache.lucene.codecs.DocValuesFormat;
13+
import org.apache.lucene.codecs.KnnVectorsFormat;
14+
import org.apache.lucene.codecs.PostingsFormat;
15+
import org.apache.lucene.codecs.StoredFieldsFormat;
16+
import org.apache.lucene.codecs.lucene101.Lucene101Codec;
17+
import org.apache.lucene.codecs.lucene101.Lucene101PostingsFormat;
18+
import org.apache.lucene.codecs.lucene90.Lucene90DocValuesFormat;
19+
import org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat;
20+
import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat;
21+
import org.elasticsearch.index.codec.perfield.XPerFieldDocValuesFormat;
22+
import org.elasticsearch.index.codec.vectors.es910.ES819HnswReducedHeapVectorsFormat;
23+
import org.elasticsearch.index.codec.zstd.Zstd814StoredFieldsFormat;
24+
25+
/**
26+
* Elasticsearch codec as of 9.0 relying on Lucene 10.1. This extends the Lucene 10.1 codec to compressed
27+
* stored fields with ZSTD instead of LZ4/DEFLATE. See {@link Zstd814StoredFieldsFormat}.
28+
*/
29+
public class Elasticsearch910Lucene102Codec extends CodecService.DeduplicateFieldInfosCodec {
30+
31+
static final PostingsFormat DEFAULT_POSTINGS_FORMAT = new Lucene101PostingsFormat();
32+
33+
private final StoredFieldsFormat storedFieldsFormat;
34+
35+
private final PostingsFormat defaultPostingsFormat;
36+
private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() {
37+
@Override
38+
public PostingsFormat getPostingsFormatForField(String field) {
39+
return Elasticsearch910Lucene102Codec.this.getPostingsFormatForField(field);
40+
}
41+
};
42+
43+
private final DocValuesFormat defaultDVFormat;
44+
private final DocValuesFormat docValuesFormat = new XPerFieldDocValuesFormat() {
45+
@Override
46+
public DocValuesFormat getDocValuesFormatForField(String field) {
47+
return Elasticsearch910Lucene102Codec.this.getDocValuesFormatForField(field);
48+
}
49+
};
50+
51+
private final KnnVectorsFormat defaultKnnVectorsFormat;
52+
private final KnnVectorsFormat knnVectorsFormat = new PerFieldKnnVectorsFormat() {
53+
@Override
54+
public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
55+
return Elasticsearch910Lucene102Codec.this.getKnnVectorsFormatForField(field);
56+
}
57+
};
58+
59+
/** Public no-arg constructor, needed for SPI loading at read-time. */
60+
public Elasticsearch910Lucene102Codec() {
61+
this(Zstd814StoredFieldsFormat.Mode.BEST_SPEED);
62+
}
63+
64+
/**
65+
* Constructor. Takes a {@link Zstd814StoredFieldsFormat.Mode} that describes whether to optimize for retrieval speed at the expense of
66+
* worse space-efficiency or vice-versa.
67+
*/
68+
public Elasticsearch910Lucene102Codec(Zstd814StoredFieldsFormat.Mode mode) {
69+
super("Elasticsearch900Lucene101", new Lucene101Codec());
70+
this.storedFieldsFormat = mode.getFormat();
71+
this.defaultPostingsFormat = DEFAULT_POSTINGS_FORMAT;
72+
this.defaultDVFormat = new Lucene90DocValuesFormat();
73+
this.defaultKnnVectorsFormat = new ES819HnswReducedHeapVectorsFormat();
74+
}
75+
76+
@Override
77+
public StoredFieldsFormat storedFieldsFormat() {
78+
return storedFieldsFormat;
79+
}
80+
81+
@Override
82+
public final PostingsFormat postingsFormat() {
83+
return postingsFormat;
84+
}
85+
86+
@Override
87+
public final DocValuesFormat docValuesFormat() {
88+
return docValuesFormat;
89+
}
90+
91+
@Override
92+
public final KnnVectorsFormat knnVectorsFormat() {
93+
return knnVectorsFormat;
94+
}
95+
96+
/**
97+
* Returns the postings format that should be used for writing new segments of <code>field</code>.
98+
*
99+
* <p>The default implementation always returns "Lucene912".
100+
*
101+
* <p><b>WARNING:</b> if you subclass, you are responsible for index backwards compatibility:
102+
* future version of Lucene are only guaranteed to be able to read the default implementation,
103+
*/
104+
public PostingsFormat getPostingsFormatForField(String field) {
105+
return defaultPostingsFormat;
106+
}
107+
108+
/**
109+
* Returns the docvalues format that should be used for writing new segments of <code>field</code>
110+
* .
111+
*
112+
* <p>The default implementation always returns "Lucene912".
113+
*
114+
* <p><b>WARNING:</b> if you subclass, you are responsible for index backwards compatibility:
115+
* future version of Lucene are only guaranteed to be able to read the default implementation.
116+
*/
117+
public DocValuesFormat getDocValuesFormatForField(String field) {
118+
return defaultDVFormat;
119+
}
120+
121+
/**
122+
* Returns the vectors format that should be used for writing new segments of <code>field</code>
123+
*
124+
* <p>The default implementation always returns "Lucene912".
125+
*
126+
* <p><b>WARNING:</b> if you subclass, you are responsible for index backwards compatibility:
127+
* future version of Lucene are only guaranteed to be able to read the default implementation.
128+
*/
129+
public KnnVectorsFormat getKnnVectorsFormatForField(String field) {
130+
return defaultKnnVectorsFormat;
131+
}
132+
133+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
2020

21-
package org.elasticsearch.index.codec.vectors.es819;
21+
package org.elasticsearch.index.codec.vectors.es910;
2222

2323
import org.apache.lucene.codecs.KnnVectorsFormat;
2424
import org.apache.lucene.codecs.KnnVectorsReader;
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
20-
package org.elasticsearch.index.codec.vectors.es819;
20+
package org.elasticsearch.index.codec.vectors.es910;
2121

2222
import org.apache.lucene.codecs.CodecUtil;
2323
import org.apache.lucene.codecs.KnnFieldVectorsWriter;
@@ -46,13 +46,13 @@
4646
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
4747
import org.apache.lucene.util.hnsw.UpdateableRandomVectorScorer;
4848
import org.apache.lucene.util.packed.DirectMonotonicWriter;
49-
import org.elasticsearch.index.codec.vectors.es819.hnsw.ConcurrentHnswMerger;
50-
import org.elasticsearch.index.codec.vectors.es819.hnsw.HnswGraph;
51-
import org.elasticsearch.index.codec.vectors.es819.hnsw.HnswGraphBuilder;
52-
import org.elasticsearch.index.codec.vectors.es819.hnsw.HnswGraphMerger;
53-
import org.elasticsearch.index.codec.vectors.es819.hnsw.IncrementalHnswGraphMerger;
54-
import org.elasticsearch.index.codec.vectors.es819.hnsw.NeighborArray;
55-
import org.elasticsearch.index.codec.vectors.es819.hnsw.OnHeapHnswGraph;
49+
import org.elasticsearch.index.codec.vectors.es910.hnsw.ConcurrentHnswMerger;
50+
import org.elasticsearch.index.codec.vectors.es910.hnsw.HnswGraph;
51+
import org.elasticsearch.index.codec.vectors.es910.hnsw.HnswGraphBuilder;
52+
import org.elasticsearch.index.codec.vectors.es910.hnsw.HnswGraphMerger;
53+
import org.elasticsearch.index.codec.vectors.es910.hnsw.IncrementalHnswGraphMerger;
54+
import org.elasticsearch.index.codec.vectors.es910.hnsw.NeighborArray;
55+
import org.elasticsearch.index.codec.vectors.es910.hnsw.OnHeapHnswGraph;
5656

5757
import java.io.IOException;
5858
import java.util.ArrayList;
@@ -62,7 +62,7 @@
6262

6363
import static org.apache.lucene.codecs.KnnVectorsWriter.MergedVectorValues.hasVectorValues;
6464
import static org.apache.lucene.codecs.lucene99.Lucene99HnswVectorsReader.SIMILARITY_FUNCTIONS;
65-
import static org.elasticsearch.index.codec.vectors.es819.ES819HnswReducedHeapVectorsFormat.DIRECT_MONOTONIC_BLOCK_SHIFT;
65+
import static org.elasticsearch.index.codec.vectors.es910.ES819HnswReducedHeapVectorsFormat.DIRECT_MONOTONIC_BLOCK_SHIFT;
6666

6767
/**
6868
* Copied from Lucene, replace with Lucene's implementation sometime after Lucene 10.3.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
20-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
20+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2121

2222
import org.apache.lucene.search.KnnCollector;
2323
import org.apache.lucene.util.Bits;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
20-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
20+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2121

2222
import org.apache.lucene.codecs.KnnVectorsReader;
2323
import org.apache.lucene.index.FieldInfo;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
20-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
20+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2121

2222
import org.apache.lucene.search.KnnCollector;
2323
import org.apache.lucene.util.BitSet;

server/src/main/java/org/elasticsearch/index/codec/vectors/es819/hnsw/HnswBuilder.java renamed to server/src/main/java/org/elasticsearch/index/codec/vectors/es910/hnsw/HnswBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
2020

21-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
21+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2222

2323
import org.apache.lucene.util.InfoStream;
2424

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
20-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
20+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2121

2222
import org.apache.lucene.search.TaskExecutor;
2323
import org.apache.lucene.util.BitSet;

server/src/main/java/org/elasticsearch/index/codec/vectors/es819/hnsw/HnswGraph.java renamed to server/src/main/java/org/elasticsearch/index/codec/vectors/es910/hnsw/HnswGraph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
2020

21-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
21+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2222

2323
import org.apache.lucene.index.FloatVectorValues;
2424
import org.apache.lucene.internal.hppc.IntArrayList;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Modifications copyright (C) 2025 Elasticsearch B.V.
1919
*/
2020

21-
package org.elasticsearch.index.codec.vectors.es819.hnsw;
21+
package org.elasticsearch.index.codec.vectors.es910.hnsw;
2222

2323
import org.apache.lucene.internal.hppc.IntHashSet;
2424
import org.apache.lucene.search.KnnCollector;
@@ -29,7 +29,7 @@
2929
import org.apache.lucene.util.hnsw.RandomVectorScorer;
3030
import org.apache.lucene.util.hnsw.RandomVectorScorerSupplier;
3131
import org.apache.lucene.util.hnsw.UpdateableRandomVectorScorer;
32-
import org.elasticsearch.index.codec.vectors.es819.hnsw.HnswUtil.Component;
32+
import org.elasticsearch.index.codec.vectors.es910.hnsw.HnswUtil.Component;
3333

3434
import java.io.IOException;
3535
import java.util.Comparator;

0 commit comments

Comments
 (0)