|
11 | 11 |
|
12 | 12 | import org.apache.logging.log4j.LogManager; |
13 | 13 | import org.apache.logging.log4j.Logger; |
| 14 | +import org.apache.lucene.index.IndexReader; |
14 | 15 | import org.apache.lucene.index.LeafReaderContext; |
15 | 16 | import org.apache.lucene.search.Explanation; |
16 | | -import org.apache.lucene.search.LRUQueryCache; |
17 | 17 | import org.apache.lucene.search.Query; |
18 | 18 | import org.apache.lucene.search.QueryCache; |
19 | 19 | import org.apache.lucene.search.QueryCachingPolicy; |
|
30 | 30 | import org.elasticsearch.index.cache.query.QueryCacheStats; |
31 | 31 | import org.elasticsearch.index.shard.IndexShard; |
32 | 32 | import org.elasticsearch.index.shard.ShardId; |
| 33 | +import org.elasticsearch.lucene.search.XLRUQueryCache; |
33 | 34 |
|
34 | 35 | import java.io.Closeable; |
35 | 36 | import java.io.IOException; |
@@ -66,7 +67,7 @@ public class IndicesQueryCache implements QueryCache, Closeable { |
66 | 67 | Property.NodeScope |
67 | 68 | ); |
68 | 69 |
|
69 | | - private final LRUQueryCache cache; |
| 70 | + private final XLRUQueryCache cache; |
70 | 71 | private final ShardCoreKeyMap shardKeyMap = new ShardCoreKeyMap(); |
71 | 72 | private final Map<ShardId, Stats> shardStats = new ConcurrentHashMap<>(); |
72 | 73 | private volatile long sharedRamBytesUsed; |
@@ -336,7 +337,7 @@ public void onClose(ShardId shardId) { |
336 | 337 | shardStats.remove(shardId); |
337 | 338 | } |
338 | 339 |
|
339 | | - private class ElasticsearchLRUQueryCache extends LRUQueryCache { |
| 340 | + private class ElasticsearchLRUQueryCache extends XLRUQueryCache { |
340 | 341 |
|
341 | 342 | ElasticsearchLRUQueryCache(int maxSize, long maxRamBytesUsed, Predicate<LeafReaderContext> leavesToCache, float skipFactor) { |
342 | 343 | super(maxSize, maxRamBytesUsed, leavesToCache, skipFactor); |
@@ -432,5 +433,16 @@ protected void onMiss(Object readerCoreKey, Query filter) { |
432 | 433 | final Stats shardStats = getOrCreateStats(readerCoreKey); |
433 | 434 | shardStats.missCount += 1; |
434 | 435 | } |
| 436 | + |
| 437 | + @Override |
| 438 | + protected CacheAndCount tryPopulateCache( |
| 439 | + IndexReader.CacheHelper cacheKey, |
| 440 | + Weight weight, |
| 441 | + ScorerSupplier scorerSupplier, |
| 442 | + LeafReaderContext context |
| 443 | + ) throws IOException { |
| 444 | + // TODO: handle intra-segment Weight |
| 445 | + return super.tryPopulateCache(cacheKey, weight, scorerSupplier, context); |
| 446 | + } |
435 | 447 | } |
436 | 448 | } |
0 commit comments