diff --git a/server/src/main/java/module-info.java b/server/src/main/java/module-info.java index 6858f552434ad..abfea0b18b9d8 100644 --- a/server/src/main/java/module-info.java +++ b/server/src/main/java/module-info.java @@ -6,6 +6,7 @@ * Side Public License, v 1. */ +import org.elasticsearch.index.codec.Elasticsearch814Codec; import org.elasticsearch.index.codec.tsdb.ES87TSDBDocValuesFormat; import org.elasticsearch.plugins.internal.RestExtension; @@ -434,7 +435,7 @@ with org.elasticsearch.index.codec.vectors.ES813FlatVectorFormat, org.elasticsearch.index.codec.vectors.ES813Int8FlatVectorFormat; - provides org.apache.lucene.codecs.Codec with org.elasticsearch.index.codec.Elasticsearch813Codec; + provides org.apache.lucene.codecs.Codec with Elasticsearch814Codec; exports org.elasticsearch.cluster.routing.allocation.shards to diff --git a/server/src/main/java/org/elasticsearch/index/codec/CodecService.java b/server/src/main/java/org/elasticsearch/index/codec/CodecService.java index c18a95cd21324..3ebcd1cb5b420 100644 --- a/server/src/main/java/org/elasticsearch/index/codec/CodecService.java +++ b/server/src/main/java/org/elasticsearch/index/codec/CodecService.java @@ -13,7 +13,7 @@ import org.elasticsearch.common.util.BigArrays; import org.elasticsearch.common.util.FeatureFlag; import org.elasticsearch.core.Nullable; -import org.elasticsearch.index.codec.zstd.Zstd813StoredFieldsFormat; +import org.elasticsearch.index.codec.zstd.Zstd814StoredFieldsFormat; import org.elasticsearch.index.mapper.MapperService; import java.util.HashMap; @@ -44,7 +44,7 @@ public CodecService(@Nullable MapperService mapperService, BigArrays bigArrays) Codec legacyBestSpeedCodec = new LegacyPerFieldMapperCodec(Lucene99Codec.Mode.BEST_SPEED, mapperService, bigArrays); if (ZSTD_STORED_FIELDS_FEATURE_FLAG.isEnabled()) { - codecs.put(DEFAULT_CODEC, new PerFieldMapperCodec(Zstd813StoredFieldsFormat.Mode.BEST_SPEED, mapperService, bigArrays)); + codecs.put(DEFAULT_CODEC, new PerFieldMapperCodec(Zstd814StoredFieldsFormat.Mode.BEST_SPEED, mapperService, bigArrays)); } else { codecs.put(DEFAULT_CODEC, legacyBestSpeedCodec); } @@ -54,7 +54,7 @@ public CodecService(@Nullable MapperService mapperService, BigArrays bigArrays) if (ZSTD_STORED_FIELDS_FEATURE_FLAG.isEnabled()) { codecs.put( BEST_COMPRESSION_CODEC, - new PerFieldMapperCodec(Zstd813StoredFieldsFormat.Mode.BEST_COMPRESSION, mapperService, bigArrays) + new PerFieldMapperCodec(Zstd814StoredFieldsFormat.Mode.BEST_COMPRESSION, mapperService, bigArrays) ); } else { codecs.put(BEST_COMPRESSION_CODEC, legacyBestCompressionCodec); diff --git a/server/src/main/java/org/elasticsearch/index/codec/Elasticsearch813Codec.java b/server/src/main/java/org/elasticsearch/index/codec/Elasticsearch814Codec.java similarity index 86% rename from server/src/main/java/org/elasticsearch/index/codec/Elasticsearch813Codec.java rename to server/src/main/java/org/elasticsearch/index/codec/Elasticsearch814Codec.java index 9196c98d5f0ea..66b74073f153e 100644 --- a/server/src/main/java/org/elasticsearch/index/codec/Elasticsearch813Codec.java +++ b/server/src/main/java/org/elasticsearch/index/codec/Elasticsearch814Codec.java @@ -20,13 +20,13 @@ import org.apache.lucene.codecs.perfield.PerFieldDocValuesFormat; import org.apache.lucene.codecs.perfield.PerFieldKnnVectorsFormat; import org.apache.lucene.codecs.perfield.PerFieldPostingsFormat; -import org.elasticsearch.index.codec.zstd.Zstd813StoredFieldsFormat; +import org.elasticsearch.index.codec.zstd.Zstd814StoredFieldsFormat; /** * Elasticsearch codec as of 8.13. This extends the Lucene 9.9 codec to compressed stored fields with ZSTD instead of LZ4/DEFLATE. See - * {@link Zstd813StoredFieldsFormat}. + * {@link Zstd814StoredFieldsFormat}. */ -public class Elasticsearch813Codec extends FilterCodec { +public class Elasticsearch814Codec extends FilterCodec { private final StoredFieldsFormat storedFieldsFormat; @@ -34,7 +34,7 @@ public class Elasticsearch813Codec extends FilterCodec { private final PostingsFormat postingsFormat = new PerFieldPostingsFormat() { @Override public PostingsFormat getPostingsFormatForField(String field) { - return Elasticsearch813Codec.this.getPostingsFormatForField(field); + return Elasticsearch814Codec.this.getPostingsFormatForField(field); } }; @@ -42,7 +42,7 @@ public PostingsFormat getPostingsFormatForField(String field) { private final DocValuesFormat docValuesFormat = new PerFieldDocValuesFormat() { @Override public DocValuesFormat getDocValuesFormatForField(String field) { - return Elasticsearch813Codec.this.getDocValuesFormatForField(field); + return Elasticsearch814Codec.this.getDocValuesFormatForField(field); } }; @@ -50,21 +50,21 @@ public DocValuesFormat getDocValuesFormatForField(String field) { private final KnnVectorsFormat knnVectorsFormat = new PerFieldKnnVectorsFormat() { @Override public KnnVectorsFormat getKnnVectorsFormatForField(String field) { - return Elasticsearch813Codec.this.getKnnVectorsFormatForField(field); + return Elasticsearch814Codec.this.getKnnVectorsFormatForField(field); } }; /** Public no-arg constructor, needed for SPI loading at read-time. */ - public Elasticsearch813Codec() { - this(Zstd813StoredFieldsFormat.Mode.BEST_SPEED); + public Elasticsearch814Codec() { + this(Zstd814StoredFieldsFormat.Mode.BEST_SPEED); } /** - * Constructor. Takes a {@link Zstd813StoredFieldsFormat.Mode} that describes whether to optimize for retrieval speed at the expense of worse space-efficiency or vice-versa. + * Constructor. Takes a {@link Zstd814StoredFieldsFormat.Mode} that describes whether to optimize for retrieval speed at the expense of worse space-efficiency or vice-versa. */ - public Elasticsearch813Codec(Zstd813StoredFieldsFormat.Mode mode) { - super("Elasticsearch813", new Lucene99Codec()); - this.storedFieldsFormat = new Zstd813StoredFieldsFormat(mode); + public Elasticsearch814Codec(Zstd814StoredFieldsFormat.Mode mode) { + super("Elasticsearch814", new Lucene99Codec()); + this.storedFieldsFormat = new Zstd814StoredFieldsFormat(mode); this.defaultPostingsFormat = new Lucene99PostingsFormat(); this.defaultDVFormat = new Lucene90DocValuesFormat(); this.defaultKnnVectorsFormat = new Lucene99HnswVectorsFormat(); diff --git a/server/src/main/java/org/elasticsearch/index/codec/PerFieldMapperCodec.java b/server/src/main/java/org/elasticsearch/index/codec/PerFieldMapperCodec.java index 59bc2b502fec9..6f88578260db3 100644 --- a/server/src/main/java/org/elasticsearch/index/codec/PerFieldMapperCodec.java +++ b/server/src/main/java/org/elasticsearch/index/codec/PerFieldMapperCodec.java @@ -14,7 +14,7 @@ import org.apache.lucene.codecs.PostingsFormat; import org.elasticsearch.common.lucene.Lucene; import org.elasticsearch.common.util.BigArrays; -import org.elasticsearch.index.codec.zstd.Zstd813StoredFieldsFormat; +import org.elasticsearch.index.codec.zstd.Zstd814StoredFieldsFormat; import org.elasticsearch.index.mapper.MapperService; /** @@ -25,11 +25,11 @@ * per index in real time via the mapping API. If no specific postings format or vector format is * configured for a specific field the default postings or vector format is used. */ -public final class PerFieldMapperCodec extends Elasticsearch813Codec { +public final class PerFieldMapperCodec extends Elasticsearch814Codec { private final PerFieldFormatSupplier formatSupplier; - public PerFieldMapperCodec(Zstd813StoredFieldsFormat.Mode compressionMode, MapperService mapperService, BigArrays bigArrays) { + public PerFieldMapperCodec(Zstd814StoredFieldsFormat.Mode compressionMode, MapperService mapperService, BigArrays bigArrays) { super(compressionMode); this.formatSupplier = new PerFieldFormatSupplier(mapperService, bigArrays); // If the below assertion fails, it is a sign that Lucene released a new codec. You must create a copy of the current Elasticsearch diff --git a/server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd813StoredFieldsFormat.java b/server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd814StoredFieldsFormat.java similarity index 96% rename from server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd813StoredFieldsFormat.java rename to server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd814StoredFieldsFormat.java index a8175f229301a..e5722acd6ad6b 100644 --- a/server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd813StoredFieldsFormat.java +++ b/server/src/main/java/org/elasticsearch/index/codec/zstd/Zstd814StoredFieldsFormat.java @@ -32,7 +32,7 @@ * (64kB and 32kB respectively). In contrast, ZSTD doesn't have such a limitation and can better take advantage of large compression * buffers. */ -public final class Zstd813StoredFieldsFormat extends Lucene90CompressingStoredFieldsFormat { +public final class Zstd814StoredFieldsFormat extends Lucene90CompressingStoredFieldsFormat { // ZSTD has special optimizations for inputs that are less than 16kB and less than 256kB. So subtract a bit of memory from 16kB and // 256kB to make our inputs unlikely to grow beyond 16kB for BEST_SPEED and 256kB for BEST_COMPRESSION. @@ -52,12 +52,12 @@ private Mode(int level, int blockSizeInBytes, int blockDocCount) { } } - public Zstd813StoredFieldsFormat(Mode mode) { + public Zstd814StoredFieldsFormat(Mode mode) { this(mode.level, mode.blockSizeInBytes, mode.blockDocCount); } - Zstd813StoredFieldsFormat(int level, int blockSizeInBytes, int blockDocCount) { - super("ZstdStoredFields813", new ZstdCompressionMode(level), blockSizeInBytes, blockDocCount, 10); + Zstd814StoredFieldsFormat(int level, int blockSizeInBytes, int blockDocCount) { + super("ZstdStoredFields814", new ZstdCompressionMode(level), blockSizeInBytes, blockDocCount, 10); } private static class ZstdCompressionMode extends CompressionMode { diff --git a/server/src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec b/server/src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec index 2d2ff58a493d5..b99a15507f742 100644 --- a/server/src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec +++ b/server/src/main/resources/META-INF/services/org.apache.lucene.codecs.Codec @@ -1 +1 @@ -org.elasticsearch.index.codec.Elasticsearch813Codec +org.elasticsearch.index.codec.Elasticsearch814Codec diff --git a/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java b/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java index dcf6267ba8385..bd4aa0241cd27 100644 --- a/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java +++ b/server/src/test/java/org/elasticsearch/index/codec/CodecTests.java @@ -45,13 +45,13 @@ public class CodecTests extends ESTestCase { public void testResolveDefaultCodecs() throws Exception { CodecService codecService = createCodecService(); assertThat(codecService.codec("default"), instanceOf(PerFieldMapperCodec.class)); - assertThat(codecService.codec("default"), instanceOf(Elasticsearch813Codec.class)); + assertThat(codecService.codec("default"), instanceOf(Elasticsearch814Codec.class)); } public void testDefault() throws Exception { Codec codec = createCodecService().codec("default"); assertEquals( - "Zstd813StoredFieldsFormat(compressionMode=ZSTD(level=0), chunkSize=14336, maxDocsPerChunk=128, blockShift=10)", + "Zstd814StoredFieldsFormat(compressionMode=ZSTD(level=0), chunkSize=14336, maxDocsPerChunk=128, blockShift=10)", codec.storedFieldsFormat().toString() ); } @@ -59,7 +59,7 @@ public void testDefault() throws Exception { public void testBestCompression() throws Exception { Codec codec = createCodecService().codec("best_compression"); assertEquals( - "Zstd813StoredFieldsFormat(compressionMode=ZSTD(level=3), chunkSize=245760, maxDocsPerChunk=2048, blockShift=10)", + "Zstd814StoredFieldsFormat(compressionMode=ZSTD(level=3), chunkSize=245760, maxDocsPerChunk=2048, blockShift=10)", codec.storedFieldsFormat().toString() ); } diff --git a/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestCompressionStoredFieldsFormatTests.java b/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestCompressionStoredFieldsFormatTests.java similarity index 72% rename from server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestCompressionStoredFieldsFormatTests.java rename to server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestCompressionStoredFieldsFormatTests.java index 72df3b2ed1788..1679813ed1340 100644 --- a/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestCompressionStoredFieldsFormatTests.java +++ b/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestCompressionStoredFieldsFormatTests.java @@ -10,11 +10,11 @@ import org.apache.lucene.codecs.Codec; import org.apache.lucene.tests.index.BaseStoredFieldsFormatTestCase; -import org.elasticsearch.index.codec.Elasticsearch813Codec; +import org.elasticsearch.index.codec.Elasticsearch814Codec; -public class Zstd813BestCompressionStoredFieldsFormatTests extends BaseStoredFieldsFormatTestCase { +public class Zstd814BestCompressionStoredFieldsFormatTests extends BaseStoredFieldsFormatTestCase { - private final Codec codec = new Elasticsearch813Codec(Zstd813StoredFieldsFormat.Mode.BEST_COMPRESSION); + private final Codec codec = new Elasticsearch814Codec(Zstd814StoredFieldsFormat.Mode.BEST_COMPRESSION); @Override protected Codec getCodec() { diff --git a/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestSpeedStoredFieldsFormatTests.java b/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestSpeedStoredFieldsFormatTests.java similarity index 73% rename from server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestSpeedStoredFieldsFormatTests.java rename to server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestSpeedStoredFieldsFormatTests.java index 1c1b143c7edfa..5acdd4f5730e9 100644 --- a/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd813BestSpeedStoredFieldsFormatTests.java +++ b/server/src/test/java/org/elasticsearch/index/codec/zstd/Zstd814BestSpeedStoredFieldsFormatTests.java @@ -10,11 +10,11 @@ import org.apache.lucene.codecs.Codec; import org.apache.lucene.tests.index.BaseStoredFieldsFormatTestCase; -import org.elasticsearch.index.codec.Elasticsearch813Codec; +import org.elasticsearch.index.codec.Elasticsearch814Codec; -public class Zstd813BestSpeedStoredFieldsFormatTests extends BaseStoredFieldsFormatTestCase { +public class Zstd814BestSpeedStoredFieldsFormatTests extends BaseStoredFieldsFormatTestCase { - private final Codec codec = new Elasticsearch813Codec(Zstd813StoredFieldsFormat.Mode.BEST_SPEED); + private final Codec codec = new Elasticsearch814Codec(Zstd814StoredFieldsFormat.Mode.BEST_SPEED); @Override protected Codec getCodec() { diff --git a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java index cfd49043a543a..620db8dc83510 100644 --- a/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/index/mapper/MapperServiceTestCase.java @@ -42,7 +42,7 @@ import org.elasticsearch.index.analysis.NamedAnalyzer; import org.elasticsearch.index.cache.bitset.BitsetFilterCache; import org.elasticsearch.index.codec.PerFieldMapperCodec; -import org.elasticsearch.index.codec.zstd.Zstd813StoredFieldsFormat; +import org.elasticsearch.index.codec.zstd.Zstd814StoredFieldsFormat; import org.elasticsearch.index.fielddata.FieldDataContext; import org.elasticsearch.index.fielddata.IndexFieldData; import org.elasticsearch.index.fielddata.IndexFieldDataCache; @@ -243,7 +243,7 @@ protected static void withLuceneIndex( CheckedConsumer test ) throws IOException { IndexWriterConfig iwc = new IndexWriterConfig(IndexShard.buildIndexAnalyzer(mapperService)).setCodec( - new PerFieldMapperCodec(Zstd813StoredFieldsFormat.Mode.BEST_SPEED, mapperService, BigArrays.NON_RECYCLING_INSTANCE) + new PerFieldMapperCodec(Zstd814StoredFieldsFormat.Mode.BEST_SPEED, mapperService, BigArrays.NON_RECYCLING_INSTANCE) ); try (Directory dir = newDirectory(); RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc)) { builder.accept(iw);