From a473a9e7598161d74cbb027837943ab3f7c718f7 Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Sun, 3 Sep 2023 07:55:04 +0530 Subject: [PATCH] review comments Signed-off-by: Sarthak Aggarwal --- .../index/codec/customcodecs/Lucene95CustomCodec.java | 4 ++-- .../index/codec/customcodecs/CustomCodecTests.java | 3 --- .../java/org/opensearch/index/codec/CodecAliases.java | 8 +++++++- .../java/org/opensearch/index/engine/EngineConfig.java | 4 ++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java b/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java index 27c69db6f537f..a777ce781d518 100644 --- a/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java +++ b/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java @@ -32,11 +32,11 @@ public enum Mode { /** * ZStandard mode with dictionary */ - ZSTD("zstd"), + ZSTD("Lucene95CustomCodec"), /** * ZStandard mode without dictionary */ - ZSTD_NO_DICT("zstdnodict"); + ZSTD_NO_DICT("Lucene95CustomCodec"); private final String codec; diff --git a/plugins/custom-codecs/src/test/java/org/opensearch/index/codec/customcodecs/CustomCodecTests.java b/plugins/custom-codecs/src/test/java/org/opensearch/index/codec/customcodecs/CustomCodecTests.java index 6ed936742957a..688d0b0557fce 100644 --- a/plugins/custom-codecs/src/test/java/org/opensearch/index/codec/customcodecs/CustomCodecTests.java +++ b/plugins/custom-codecs/src/test/java/org/opensearch/index/codec/customcodecs/CustomCodecTests.java @@ -113,9 +113,6 @@ public void testBestCompressionWithCompressionLevel() { } public void testLuceneCodecsWithCompressionLevel() { - String codecName = randomFrom(Codec.availableCodecs()); - Codec codec = Codec.forName(codecName); - final Settings customCodecSettings = Settings.builder() .put(INDEX_CODEC_COMPRESSION_LEVEL_SETTING.getKey(), randomIntBetween(1, 6)) .put(EngineConfig.INDEX_CODEC_SETTING.getKey(), randomFrom("zstd", "zstd_no_dict")) diff --git a/server/src/main/java/org/opensearch/index/codec/CodecAliases.java b/server/src/main/java/org/opensearch/index/codec/CodecAliases.java index d9849f7e4c79b..74c4ccda575f9 100644 --- a/server/src/main/java/org/opensearch/index/codec/CodecAliases.java +++ b/server/src/main/java/org/opensearch/index/codec/CodecAliases.java @@ -13,10 +13,16 @@ import java.util.Set; /** - * This {@link CodecAliases} allows us to manage the settings with {@link Codec}. + * This {@link CodecAliases} to provide aliases for the {@link Codec}. * * @opensearch.internal */ public interface CodecAliases { + + /** + * Retrieves a set of aliases for an codec. + * + * @return A non-null set of alias strings. If no aliases are available, an empty set should be returned. + */ Set aliases(); } diff --git a/server/src/main/java/org/opensearch/index/engine/EngineConfig.java b/server/src/main/java/org/opensearch/index/engine/EngineConfig.java index ae2cce1272b9d..00f8ff6d3cd40 100644 --- a/server/src/main/java/org/opensearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/opensearch/index/engine/EngineConfig.java @@ -145,7 +145,7 @@ public Supplier retentionLeasesSupplier() { Codec codec = Codec.forName(codecName); if (codec instanceof CodecAliases) { CodecAliases codecWithAlias = (CodecAliases) codec; - if (codecWithAlias.aliases() != null && codecWithAlias.aliases().contains(s)) { + if (codecWithAlias.aliases().contains(s)) { return s; } } @@ -208,7 +208,7 @@ private static void doValidateCodecSettings(final String codec) { Codec availableCodec = Codec.forName(codecName); if (availableCodec instanceof CodecAliases) { CodecAliases availableCodecWithAlias = (CodecAliases) availableCodec; - if (availableCodecWithAlias.aliases() != null && availableCodecWithAlias.aliases().contains(codec)) { + if (availableCodecWithAlias.aliases().contains(codec)) { if (availableCodec instanceof CodecSettings && ((CodecSettings) availableCodec).supports(INDEX_CODEC_COMPRESSION_LEVEL_SETTING)) { return;