From 401881264c91f191ea4535968b6d1f146fd6906d Mon Sep 17 00:00:00 2001 From: mulugetam Date: Thu, 20 Apr 2023 11:49:25 -0700 Subject: [PATCH] Use lowercase letters for zstd, zstdnodict compression codecs. (#7231) Signed-off-by: Mulugeta Mammo Signed-off-by: Shivansh Arora --- .../codec/customcodecs/CustomCodecPlugin.java | 4 ++-- .../customcodecs/Lucene95CustomCodec.java | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/CustomCodecPlugin.java b/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/CustomCodecPlugin.java index ed2eb962050d4..9d36184bf81af 100644 --- a/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/CustomCodecPlugin.java +++ b/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/CustomCodecPlugin.java @@ -14,8 +14,8 @@ /** * A plugin that implements custom codecs. Supports these codecs: *
    - *
  • ZSTD - *
  • ZSTDNODICT + *
  • zstd + *
  • zstdnodict *
* * @opensearch.internal diff --git a/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java b/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java index 652306e59559b..ad9e5cd3374fa 100644 --- a/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java +++ b/sandbox/plugins/custom-codecs/src/main/java/org/opensearch/index/codec/customcodecs/Lucene95CustomCodec.java @@ -12,6 +12,8 @@ import org.apache.lucene.codecs.FilterCodec; import org.apache.lucene.codecs.lucene95.Lucene95Codec; +import java.util.Locale; + abstract class Lucene95CustomCodec extends FilterCodec { public static final int DEFAULT_COMPRESSION_LEVEL = 6; @@ -23,13 +25,25 @@ public enum Mode { private final StoredFieldsFormat storedFieldsFormat; - /** new codec for a given compression algorithm and default compression level */ + /** + * Creates a new compression codec with the default compression level. + * + * @param mode The compression codec (ZSTD or ZSTDNODICT). + */ public Lucene95CustomCodec(Mode mode) { this(mode, DEFAULT_COMPRESSION_LEVEL); } + /** + * Creates a new compression codec with the given compression level. We use + * lowercase letters when registering the codec so that we remain consistent with + * the other compression codecs: default, lucene_default, and best_compression. + * + * @param mode The compression codec (ZSTD or ZSTDNODICT). + * @parama compressionLevel The compression level. + */ public Lucene95CustomCodec(Mode mode, int compressionLevel) { - super(mode.name(), new Lucene95Codec()); + super(mode.name().toLowerCase(Locale.ROOT), new Lucene95Codec()); this.storedFieldsFormat = new Lucene95CustomStoredFieldsFormat(mode, compressionLevel); }