-
Notifications
You must be signed in to change notification settings - Fork 128
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set additional settings at index level
Signed-off-by: Martin Gaievski <[email protected]>
- Loading branch information
1 parent
185b54d
commit 3a9ba8d
Showing
2 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/test/java/org/opensearch/knn/plugin/KNNPluginTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.knn.plugin; | ||
|
||
import org.opensearch.common.settings.Settings; | ||
import org.opensearch.index.IndexModule; | ||
import org.opensearch.index.shard.IndexSettingProvider; | ||
import org.opensearch.knn.KNNTestCase; | ||
import org.opensearch.knn.index.util.KNNEngine; | ||
|
||
import java.util.Collection; | ||
import java.util.List; | ||
|
||
public class KNNPluginTests extends KNNTestCase { | ||
|
||
private static final String INDEX_NAME = "test_index"; | ||
|
||
public void testMMapFileExtensionsForHybridFs() { | ||
final KNNPlugin knnPlugin = new KNNPlugin(); | ||
|
||
final Collection<IndexSettingProvider> additionalIndexSettingProviders = knnPlugin.getAdditionalIndexSettingProviders(); | ||
|
||
assertEquals(1, additionalIndexSettingProviders.size()); | ||
|
||
final IndexSettingProvider indexSettingProvider = additionalIndexSettingProviders.iterator().next(); | ||
// settings for knn enabled index | ||
final Settings knnIndexSettings = indexSettingProvider.getAdditionalIndexSettings(INDEX_NAME, false, getKnnDefaultIndexSettings()); | ||
final List<String> mmapFileExtensionsForHybridFsKnnIndex = knnIndexSettings.getAsList( | ||
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getKey() | ||
); | ||
|
||
assertNotNull(mmapFileExtensionsForHybridFsKnnIndex); | ||
assertFalse(mmapFileExtensionsForHybridFsKnnIndex.isEmpty()); | ||
|
||
for (KNNEngine engine : KNNEngine.values()) { | ||
assertTrue(mmapFileExtensionsForHybridFsKnnIndex.containsAll(engine.mmapFileExtensions())); | ||
} | ||
|
||
// settings for index without knn | ||
final Settings nonKnnIndexSettings = indexSettingProvider.getAdditionalIndexSettings(INDEX_NAME, false, getNonKnnIndexSettings()); | ||
final List<String> mmapFileExtensionsForHybridFsNonKnnIndex = nonKnnIndexSettings.getAsList( | ||
IndexModule.INDEX_STORE_HYBRID_MMAP_EXTENSIONS.getKey() | ||
); | ||
|
||
assertNotNull(mmapFileExtensionsForHybridFsNonKnnIndex); | ||
assertTrue(mmapFileExtensionsForHybridFsNonKnnIndex.isEmpty()); | ||
} | ||
|
||
private Settings getKnnDefaultIndexSettings() { | ||
return Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).put("index.knn", true).build(); | ||
} | ||
|
||
private Settings getNonKnnIndexSettings() { | ||
return Settings.builder().put("number_of_shards", 1).put("number_of_replicas", 0).build(); | ||
} | ||
} |