-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Cleanup IndexFieldData visibility #25900
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -172,7 +172,7 @@ public IndexService( | |
| this.indexStore = indexStore; | ||
| indexFieldData.setListener(new FieldDataCacheListener(this)); | ||
| this.bitsetFilterCache = new BitsetFilterCache(indexSettings, new BitsetCacheListener(this)); | ||
| this.warmer = new IndexWarmer(indexSettings.getSettings(), threadPool, | ||
| this.warmer = new IndexWarmer(indexSettings.getSettings(), threadPool, indexFieldData, | ||
| bitsetFilterCache.createListener(threadPool)); | ||
| this.indexCache = new IndexCache(indexSettings, queryCache, bitsetFilterCache); | ||
| this.engineFactory = engineFactory; | ||
|
|
@@ -231,10 +231,6 @@ public IndexCache cache() { | |
| return indexCache; | ||
| } | ||
|
|
||
| public IndexFieldDataService fieldData() { | ||
| return indexFieldData; | ||
| } | ||
|
|
||
| public IndexAnalyzers getIndexAnalyzers() { | ||
| return this.mapperService.getIndexAnalyzers(); | ||
| } | ||
|
|
@@ -363,7 +359,7 @@ public synchronized IndexShard createShard(ShardRouting routing) throws IOExcept | |
| store = new Store(shardId, this.indexSettings, indexStore.newDirectoryService(path), lock, | ||
| new StoreCloseListener(shardId, () -> eventListener.onStoreClosed(shardId))); | ||
| indexShard = new IndexShard(routing, this.indexSettings, path, store, indexSortSupplier, | ||
| indexCache, mapperService, similarityService, indexFieldData, engineFactory, | ||
| indexCache, mapperService, similarityService, engineFactory, | ||
| eventListener, searcherWrapper, threadPool, bigArrays, engineWarmer, | ||
| searchOperationListeners, indexingOperationListeners); | ||
| eventListener.indexShardStateChanged(indexShard, null, indexShard.state(), "shard created"); | ||
|
|
@@ -892,4 +888,37 @@ AsyncTranslogFSync getFsyncTask() { // for tests | |
| return fsyncTask; | ||
| } | ||
|
|
||
| /** | ||
| * Clears the caches for the given shard id if the shard is still allocated on this node | ||
| */ | ||
| public boolean clearCaches(boolean queryCache, boolean fieldDataCache, String...fields) { | ||
| boolean clearedAtLeastOne = false; | ||
| if (queryCache) { | ||
| clearedAtLeastOne = true; | ||
| indexCache.query().clear("api"); | ||
| } | ||
| if (fieldDataCache) { | ||
| clearedAtLeastOne = true; | ||
| if (fields.length == 0) { | ||
| indexFieldData.clear(); | ||
| } else { | ||
| for (String field : fields) { | ||
| indexFieldData.clearField(field); | ||
| } | ||
| } | ||
| } | ||
| if (clearedAtLeastOne == false) { | ||
| if (fields.length == 0) { | ||
| indexCache.clear("api"); | ||
| indexFieldData.clear(); | ||
| } else { | ||
| // only clear caches relating to the specified fields | ||
| for (String field : fields) { | ||
| indexFieldData.clearField(field); | ||
| } | ||
| } | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see you did not change that logic but it confuses me a bit as it seems we always clear fileddata even when fieldDataCache is false?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah we are on the same page. I will open a followup with a BWC break |
||
| return clearedAtLeastOne; | ||
| } | ||
|
|
||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that change alone makes me happy