Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
import org.opensearch.core.xcontent.MediaTypeRegistry;
import org.opensearch.core.xcontent.XContentBuilder;
import org.opensearch.index.IndexService;
import org.opensearch.index.cache.bitset.BitsetFilterCache;
import org.opensearch.index.engine.Engine;
import org.opensearch.index.fielddata.ScriptDocValues;
import org.opensearch.index.query.Operator;
import org.opensearch.index.query.QueryBuilder;
import org.opensearch.index.query.QueryBuilders;
import org.opensearch.index.query.QueryShardContext;
import org.opensearch.indices.IndicesBitsetFilterCache;
import org.opensearch.plugins.Plugin;
import org.opensearch.script.MockScriptPlugin;
import org.opensearch.script.Script;
Expand Down Expand Up @@ -149,7 +149,9 @@ public void testPercolateQueryWithNestedDocuments_doNotLeakBitsetCacheEntries()
.indices()
.prepareCreate("test")
// to avoid normal document from being cached by BitsetFilterCache
.setSettings(Settings.builder().put(BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false))
.setSettings(
Settings.builder().put(IndicesBitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING.getKey(), false)
)
.setMapping(mapping)
);
client().prepareIndex("test")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.opensearch.index.MergeSchedulerConfig;
import org.opensearch.index.SearchSlowLog;
import org.opensearch.index.TieredMergePolicyProvider;
import org.opensearch.index.cache.bitset.BitsetFilterCache;
import org.opensearch.index.compositeindex.datacube.startree.StarTreeIndexSettings;
import org.opensearch.index.engine.EngineConfig;
import org.opensearch.index.fielddata.IndexFieldDataService;
Expand All @@ -59,6 +58,7 @@
import org.opensearch.index.similarity.SimilarityService;
import org.opensearch.index.store.FsDirectoryFactory;
import org.opensearch.index.store.Store;
import org.opensearch.indices.IndicesBitsetFilterCache;
import org.opensearch.indices.IndicesRequestCache;
import org.opensearch.search.streaming.FlushModeResolver;

Expand Down Expand Up @@ -206,7 +206,7 @@ public final class IndexScopedSettings extends AbstractScopedSettings {
MapperService.INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING,
MapperService.INDEX_MAPPING_DEPTH_LIMIT_SETTING,
MapperService.INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING,
BitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING,
IndicesBitsetFilterCache.INDEX_LOAD_RANDOM_ACCESS_FILTERS_EAGERLY_SETTING,
IndexModule.INDEX_STORE_TYPE_SETTING,
IndexModule.INDEX_COMPOSITE_STORE_TYPE_SETTING,
IndexModule.INDEX_STORE_FACTORY_SETTING,
Expand Down
78 changes: 78 additions & 0 deletions server/src/main/java/org/opensearch/index/IndexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
import org.opensearch.index.store.remote.filecache.FileCache;
import org.opensearch.index.translog.TranslogFactory;
import org.opensearch.indices.ClusterMergeSchedulerConfig;
import org.opensearch.indices.IndicesBitsetFilterCache;
import org.opensearch.indices.IndicesQueryCache;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.fielddata.cache.IndicesFieldDataCache;
Expand Down Expand Up @@ -824,6 +825,79 @@ public IndexService newIndexService(
indicesQueryCache,
mapperRegistry,
indicesFieldDataCache,
null,
namedWriteableRegistry,
idFieldDataEnabled,
valuesSourceRegistry,
remoteDirectoryFactory,
translogFactorySupplier,
clusterDefaultRefreshIntervalSupplier,
fixedRefreshIntervalSchedulingEnabled,
shardLevelRefreshEnabled,
recoverySettings,
remoteStoreSettings,
replicator,
segmentReplicationStatsProvider,
clusterDefaultMaxMergeAtOnceSupplier,
clusterMergeSchedulerConfig,
(DataFormatRegistry) null
);
}

/**
* @deprecated Use the overload that accepts {@code indicesBitsetFilterCache} and {@code dataFormatRegistry} parameters.
*/
@Deprecated(forRemoval = true)
public IndexService newIndexService(
IndexService.IndexCreationContext indexCreationContext,
NodeEnvironment environment,
NamedXContentRegistry xContentRegistry,
IndexService.ShardStoreDeleter shardStoreDeleter,
CircuitBreakerService circuitBreakerService,
BigArrays bigArrays,
ThreadPool threadPool,
ScriptService scriptService,
ClusterService clusterService,
Client client,
IndicesQueryCache indicesQueryCache,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache,
NamedWriteableRegistry namedWriteableRegistry,
BooleanSupplier idFieldDataEnabled,
ValuesSourceRegistry valuesSourceRegistry,
IndexStorePlugin.DirectoryFactory remoteDirectoryFactory,
BiFunction<IndexSettings, ShardRouting, TranslogFactory> translogFactorySupplier,
Supplier<TimeValue> clusterDefaultRefreshIntervalSupplier,
Supplier<Boolean> fixedRefreshIntervalSchedulingEnabled,
Supplier<Boolean> shardLevelRefreshEnabled,
RecoverySettings recoverySettings,
RemoteStoreSettings remoteStoreSettings,
Consumer<IndexShard> replicator,
Function<ShardId, ReplicationStats> segmentReplicationStatsProvider,
Supplier<Integer> clusterDefaultMaxMergeAtOnceSupplier,
ClusterMergeSchedulerConfig clusterMergeSchedulerConfig,
CheckedTriFunction<
ShardPath,
MapperService,
IndexSettings,
DataFormatAwareEngineFactory,
IOException> dataFormatAwareEngineFactorySupplier
) throws IOException {
return newIndexService(
indexCreationContext,
environment,
xContentRegistry,
shardStoreDeleter,
circuitBreakerService,
bigArrays,
threadPool,
scriptService,
clusterService,
client,
indicesQueryCache,
mapperRegistry,
indicesFieldDataCache,
null,
namedWriteableRegistry,
idFieldDataEnabled,
valuesSourceRegistry,
Expand Down Expand Up @@ -860,6 +934,7 @@ public IndexService newIndexService(
IndicesQueryCache indicesQueryCache,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache,
IndicesBitsetFilterCache indicesBitsetFilterCache,
NamedWriteableRegistry namedWriteableRegistry,
BooleanSupplier idFieldDataEnabled,
ValuesSourceRegistry valuesSourceRegistry,
Expand Down Expand Up @@ -896,6 +971,7 @@ public IndexService newIndexService(
indicesQueryCache,
mapperRegistry,
indicesFieldDataCache,
indicesBitsetFilterCache,
namedWriteableRegistry,
idFieldDataEnabled,
valuesSourceRegistry,
Expand Down Expand Up @@ -928,6 +1004,7 @@ public IndexService newIndexService(
IndicesQueryCache indicesQueryCache,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache,
IndicesBitsetFilterCache indicesBitsetFilterCache,
NamedWriteableRegistry namedWriteableRegistry,
BooleanSupplier idFieldDataEnabled,
ValuesSourceRegistry valuesSourceRegistry,
Expand Down Expand Up @@ -1000,6 +1077,7 @@ public IndexService newIndexService(
readerWrapperFactory,
mapperRegistry,
indicesFieldDataCache,
indicesBitsetFilterCache,
searchOperationListeners,
indexOperationListeners,
namedWriteableRegistry,
Expand Down
11 changes: 9 additions & 2 deletions server/src/main/java/org/opensearch/index/IndexService.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
import org.opensearch.index.translog.Translog;
import org.opensearch.index.translog.TranslogFactory;
import org.opensearch.indices.ClusterMergeSchedulerConfig;
import org.opensearch.indices.IndicesBitsetFilterCache;
import org.opensearch.indices.RemoteStoreSettings;
import org.opensearch.indices.cluster.IndicesClusterStateService;
import org.opensearch.indices.fielddata.cache.IndicesFieldDataCache;
Expand Down Expand Up @@ -243,6 +244,7 @@ public IndexService(
Function<IndexService, CheckedFunction<DirectoryReader, DirectoryReader, IOException>> wrapperFactory,
MapperRegistry mapperRegistry,
IndicesFieldDataCache indicesFieldDataCache,
IndicesBitsetFilterCache indicesBitsetFilterCache,
List<SearchOperationListener> searchOperationListeners,
List<IndexingOperationListener> indexingOperationListeners,
NamedWriteableRegistry namedWriteableRegistry,
Expand Down Expand Up @@ -310,8 +312,12 @@ public IndexService(
this.indexSortSupplier = () -> null;
}
indexFieldData.setListener(new FieldDataCacheListener(this));
this.bitsetFilterCache = new BitsetFilterCache(indexSettings, new BitsetCacheListener(this));
this.warmer = new IndexWarmer(threadPool, indexFieldData, bitsetFilterCache.createListener(threadPool));
this.bitsetFilterCache = new BitsetFilterCache(indexSettings, indicesBitsetFilterCache, new BitsetCacheListener(this));
this.warmer = new IndexWarmer(
threadPool,
indexFieldData,
indicesBitsetFilterCache != null ? indicesBitsetFilterCache.createListener(threadPool) : null
);
this.indexCache = new IndexCache(indexSettings, queryCache, bitsetFilterCache);
} else {
assert indexAnalyzers == null;
Expand Down Expand Up @@ -448,6 +454,7 @@ public IndexService(
wrapperFactory,
mapperRegistry,
indicesFieldDataCache,
null,
searchOperationListeners,
indexingOperationListeners,
namedWriteableRegistry,
Expand Down
Loading
Loading