From 40360aa868cdee3a3bfc7dd3c27b32f0868f0768 Mon Sep 17 00:00:00 2001 From: Samuel Herman Date: Wed, 1 May 2024 14:40:33 -0700 Subject: [PATCH] review feedback Signed-off-by: Samuel Herman --- CHANGELOG.md | 1 + .../java/org/opensearch/index/engine/EngineConfig.java | 7 ++----- .../java/org/opensearch/index/engine/InternalEngine.java | 2 +- .../org/opensearch/index/engine/EngineConfigTests.java | 2 +- .../org/opensearch/index/engine/InternalEngineTests.java | 9 +++------ 5 files changed, 8 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdaa1904e2522..f0a1fcde56322 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ## [Unreleased 2.x] ### Added +- Add useCompoundFile index setting ([#13478](https://github.com/opensearch-project/OpenSearch/pull/13478)) - Constant Keyword Field ([#12285](https://github.com/opensearch-project/OpenSearch/pull/12285)) - Convert ingest processor supports ip type ([#12818](https://github.com/opensearch-project/OpenSearch/pull/12818)) - Add a counter to node stat api to track shard going from idle to non-idle ([#12768](https://github.com/opensearch-project/OpenSearch/pull/12768)) 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 670127b187b84..fe2ce470cda03 100644 --- a/server/src/main/java/org/opensearch/index/engine/EngineConfig.java +++ b/server/src/main/java/org/opensearch/index/engine/EngineConfig.java @@ -159,8 +159,6 @@ public Supplier retentionLeasesSupplier() { } }, Property.IndexScope, Property.NodeScope); - - /** * Index setting to change the compression level of zstd and zstd_no_dict lucene codecs. * Compression Level gives a trade-off between compression ratio and speed. The higher compression level results in higher compression ratio but slower compression and decompression speeds. @@ -241,8 +239,7 @@ private static void doValidateCodecSettings(final String codec) { public static final Setting INDEX_USE_COMPOUND_FILE = Setting.boolSetting( "index.use_compound_file", true, - Property.IndexScope, - Property.Dynamic + Property.IndexScope ); private final TranslogConfig translogConfig; @@ -503,7 +500,7 @@ public boolean isReadOnlyReplica() { return indexSettings.isSegRepEnabledOrRemoteNode() && isReadOnlyReplica; } - public boolean isUseCompoundFile() { + public boolean useCompoundFile() { return indexSettings.getValue(INDEX_USE_COMPOUND_FILE); } diff --git a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java index feed307a1120b..59165b936aec8 100644 --- a/server/src/main/java/org/opensearch/index/engine/InternalEngine.java +++ b/server/src/main/java/org/opensearch/index/engine/InternalEngine.java @@ -2341,7 +2341,7 @@ private IndexWriterConfig getIndexWriterConfig() { iwc.setSimilarity(engineConfig.getSimilarity()); iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().getMbFrac()); iwc.setCodec(engineConfig.getCodec()); - iwc.setUseCompoundFile(engineConfig.isUseCompoundFile()); + iwc.setUseCompoundFile(engineConfig.useCompoundFile()); if (config().getIndexSort() != null) { iwc.setIndexSort(config().getIndexSort()); } diff --git a/server/src/test/java/org/opensearch/index/engine/EngineConfigTests.java b/server/src/test/java/org/opensearch/index/engine/EngineConfigTests.java index 9a88c584ef9eb..f42188d55bca3 100644 --- a/server/src/test/java/org/opensearch/index/engine/EngineConfigTests.java +++ b/server/src/test/java/org/opensearch/index/engine/EngineConfigTests.java @@ -36,7 +36,7 @@ public void testEngineConfig_DefaultValueFoUseCompoundFile() { EngineConfig config = new EngineConfig.Builder().indexSettings(defaultIndexSettings) .retentionLeasesSupplier(() -> RetentionLeases.EMPTY) .build(); - assertTrue(config.isUseCompoundFile()); + assertTrue(config.useCompoundFile()); } public void testEngineConfig_DefaultValueForReadOnlyEngine() { diff --git a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java index 6a9f4623665c0..54a562642d4ab 100644 --- a/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java +++ b/server/src/test/java/org/opensearch/index/engine/InternalEngineTests.java @@ -349,7 +349,7 @@ public void testSegmentsWithUseCompoundFileFlag_true() throws IOException { engine.index(index); engine.flush(); final List segments = engine.segments(false); - assertThat(segments.size(), equalTo(1)); + assertThat(segments, hasSize(1)); assertTrue(segments.get(0).compound); boolean cfeCompoundFileFound = false; boolean cfsCompoundFileFound = false; @@ -369,10 +369,7 @@ public void testSegmentsWithUseCompoundFileFlag_true() throws IOException { public void testSegmentsWithUseCompoundFileFlag_false() throws IOException { final IndexSettings indexSettings = IndexSettingsModule.newIndexSettings( "test", - Settings.builder() - .put(defaultSettings.getSettings()) - .put(EngineConfig.INDEX_USE_COMPOUND_FILE.getKey(), false) - .build() + Settings.builder().put(defaultSettings.getSettings()).put(EngineConfig.INDEX_USE_COMPOUND_FILE.getKey(), false).build() ); try (Store store = createStore(); Engine engine = createEngine(indexSettings, store, createTempDir(), new TieredMergePolicy())) { ParsedDocument doc = testParsedDocument("1", null, testDocument(), B_1, null); @@ -380,7 +377,7 @@ public void testSegmentsWithUseCompoundFileFlag_false() throws IOException { engine.index(index); engine.flush(); final List segments = engine.segments(false); - assertThat(segments.size(), equalTo(1)); + assertThat(segments, hasSize(1)); assertFalse(segments.get(0).compound); boolean cfeCompoundFileFound = false; boolean cfsCompoundFileFound = false;