From a3fdc2a0af2e50df8d3ca3f765d539c19b387326 Mon Sep 17 00:00:00 2001 From: Sarthak Aggarwal Date: Fri, 26 Jan 2024 21:00:36 +0530 Subject: [PATCH] old segments not readable by new storedfieldsformat Signed-off-by: Sarthak Aggarwal --- .../codec/Lucene99CoreStoredFieldsFormat.java | 18 +----------------- .../org/opensearch/index/codec/CodecTests.java | 1 - 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/server/src/main/java/org/opensearch/index/codec/Lucene99CoreStoredFieldsFormat.java b/server/src/main/java/org/opensearch/index/codec/Lucene99CoreStoredFieldsFormat.java index 2e2bca1615638..0cafe0291f840 100644 --- a/server/src/main/java/org/opensearch/index/codec/Lucene99CoreStoredFieldsFormat.java +++ b/server/src/main/java/org/opensearch/index/codec/Lucene99CoreStoredFieldsFormat.java @@ -64,12 +64,7 @@ public Lucene99CoreStoredFieldsFormat(Lucene99Codec.Mode mode) { */ @Override public StoredFieldsReader fieldsReader(Directory directory, SegmentInfo si, FieldInfos fn, IOContext context) throws IOException { - - if (si.getAttribute(Lucene90StoredFieldsFormat.MODE_KEY) != null) { - String value = si.getAttribute(Lucene90StoredFieldsFormat.MODE_KEY); - Lucene90StoredFieldsFormat.Mode mode = Lucene90StoredFieldsFormat.Mode.valueOf(value); - return impl(mode).fieldsReader(directory, si, fn, context); - } else if (si.getAttribute(MODE_KEY) != null) { + if (si.getAttribute(MODE_KEY) != null) { String value = si.getAttribute(MODE_KEY); Lucene99Codec.Mode mode = Lucene99Codec.Mode.valueOf(value); return impl(mode).fieldsReader(directory, si, fn, context); @@ -79,17 +74,6 @@ public StoredFieldsReader fieldsReader(Directory directory, SegmentInfo si, Fiel } - private StoredFieldsFormat impl(Lucene90StoredFieldsFormat.Mode mode) { - switch (mode) { - case BEST_SPEED: - return getLZ4CompressingStoredFieldsFormat(); - case BEST_COMPRESSION: - return getZlibCompressingStoredFieldsFormat(); - default: - throw new AssertionError(); - } - } - /** * Returns a {@link StoredFieldsReader} to write stored fields. * diff --git a/server/src/test/java/org/opensearch/index/codec/CodecTests.java b/server/src/test/java/org/opensearch/index/codec/CodecTests.java index 0b157d46754b3..784f1b9d868b9 100644 --- a/server/src/test/java/org/opensearch/index/codec/CodecTests.java +++ b/server/src/test/java/org/opensearch/index/codec/CodecTests.java @@ -34,7 +34,6 @@ import org.apache.logging.log4j.LogManager; import org.apache.lucene.codecs.Codec; -import org.apache.lucene.codecs.lucene90.Lucene90StoredFieldsFormat; import org.apache.lucene.codecs.lucene99.Lucene99Codec; import org.apache.lucene.document.Document; import org.apache.lucene.index.DirectoryReader;