sgup432 commented on code in PR #16212:
URL: https://github.com/apache/lucene/pull/16212#discussion_r3462493409
##########
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java:
##########
@@ -1290,14 +1325,8 @@ public synchronized void cleanUp() {
keysToClean.removeAll(keysToCleanCopy);
queriesToClean.removeAll(queriesToCleanCopy);
- for (QueryCacheKey queryCacheKey : keys()) {
- boolean shouldEvict =
- (queryCacheKey.cacheKey != null &&
keysToCleanCopy.contains(queryCacheKey.cacheKey))
- || (queryCacheKey.query != null &&
queriesToCleanCopy.contains(queryCacheKey.query));
- if (shouldEvict) {
- int partitionNumber = getPartitionNumber(queryCacheKey);
- lruQueryCachePartition[partitionNumber].remove(queryCacheKey);
- }
+ for (int i = 0; i < numberOfPartitions; i++) {
+ lruQueryCachePartition[i].removeMatching(keysToCleanCopy,
queriesToCleanCopy);
Review Comment:
We don't need this logic. We can infer partition number from the cache key,
so checking for each partition is unnecessary.
We can keep the original logic now considering
`lruQueryCachePartition.keys()` is now returning copies instead of original
keys. You can verify concurrent modification by running your unit test below.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]