From f7b3ba3a4e81e46e493c34d7eab31f71e7d64ac6 Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Wed, 19 Jul 2023 15:14:39 +0530 Subject: [PATCH] reinstating default and best_compression Signed-off-by: Sarthak Aggarwal --- .../main/java/org/opensearch/index/codec/CodecService.java | 6 ++++++ .../main/java/org/opensearch/index/engine/EngineConfig.java | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/org/opensearch/index/codec/CodecService.java b/server/src/main/java/org/opensearch/index/codec/CodecService.java index 13b7accf4ac69..0bad6b504a89b 100644 --- a/server/src/main/java/org/opensearch/index/codec/CodecService.java +++ b/server/src/main/java/org/opensearch/index/codec/CodecService.java @@ -67,6 +67,8 @@ public class CodecService { * the raw unfiltered lucene default. useful for testing */ public static final String LUCENE_DEFAULT_CODEC = "lucene_default"; + public static final String DEFAULT = "default"; + public static final String BEST_COMPRESSION = "best_compression"; public static final String ZSTD_CODEC = "zstd"; public static final String ZSTD_NO_DICT_CODEC = "zstd_no_dict"; @@ -80,12 +82,16 @@ public CodecService(@Nullable MapperService mapperService, IndexSettings indexSe } if (mapperService == null) { codecs.put(LZ4_CODEC, new Lucene95Codec()); + codecs.put(DEFAULT, new Lucene95Codec()); codecs.put(ZLIB_CODEC, new Lucene95Codec(Mode.BEST_COMPRESSION)); + codecs.put(BEST_COMPRESSION, new Lucene95Codec(Mode.BEST_COMPRESSION)); codecs.put(ZSTD_CODEC, new ZstdCodec(compressionLevel)); codecs.put(ZSTD_NO_DICT_CODEC, new ZstdNoDictCodec(compressionLevel)); } else { codecs.put(LZ4_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); + codecs.put(DEFAULT, new PerFieldMappingPostingFormatCodec(Mode.BEST_SPEED, mapperService, logger)); codecs.put(ZLIB_CODEC, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); + codecs.put(BEST_COMPRESSION, new PerFieldMappingPostingFormatCodec(Mode.BEST_COMPRESSION, mapperService, logger)); codecs.put(ZSTD_CODEC, new ZstdCodec(mapperService, logger, compressionLevel)); codecs.put(ZSTD_NO_DICT_CODEC, new ZstdNoDictCodec(mapperService, logger, compressionLevel)); } 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 68403b146c435..4ac06524ee755 100644 --- a/server/src/main/java/org/opensearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/opensearch/index/engine/EngineConfig.java @@ -131,6 +131,8 @@ public Supplier retentionLeasesSupplier() { public static final Setting INDEX_CODEC_SETTING = new Setting<>("index.codec", "lz4", s -> { switch (s) { case "lz4": + case "default": + case "best_compression": case "zlib": case "zstd": case "zstd_no_dict": @@ -139,7 +141,8 @@ public Supplier retentionLeasesSupplier() { default: if (Codec.availableCodecs().contains(s) == false) { // we don't error message the not officially supported ones throw new IllegalArgumentException( - "unknown value for [index.codec] must be one of [lz4, zlib, zstd, zstd_no_dict] but was: " + s + "unknown value for [index.codec] must be one of [default, best_compression, lz4, zlib, zstd, zstd_no_dict] but was: " + + s ); } return s;