mirror of https://github.com/apache/lucene.git
LUCENE-7817: pass cached query to onQueryCache instead of null
Closes #199
This commit is contained in:
parent
30a50eaf83
commit
fb56948e70
|
@ -298,7 +298,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
|
||||||
try {
|
try {
|
||||||
Query singleton = uniqueQueries.putIfAbsent(query, query);
|
Query singleton = uniqueQueries.putIfAbsent(query, query);
|
||||||
if (singleton == null) {
|
if (singleton == null) {
|
||||||
onQueryCache(singleton, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query));
|
onQueryCache(query, LINKED_HASHTABLE_RAM_BYTES_PER_ENTRY + ramBytesUsed(query));
|
||||||
} else {
|
} else {
|
||||||
query = singleton;
|
query = singleton;
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,12 +660,14 @@ public class TestLRUQueryCache extends LuceneTestCase {
|
||||||
@Override
|
@Override
|
||||||
protected void onQueryCache(Query query, long ramBytesUsed) {
|
protected void onQueryCache(Query query, long ramBytesUsed) {
|
||||||
super.onQueryCache(query, ramBytesUsed);
|
super.onQueryCache(query, ramBytesUsed);
|
||||||
|
assertNotNull("cached query is null", query);
|
||||||
ramBytesUsage.addAndGet(ramBytesUsed);
|
ramBytesUsage.addAndGet(ramBytesUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onQueryEviction(Query query, long ramBytesUsed) {
|
protected void onQueryEviction(Query query, long ramBytesUsed) {
|
||||||
super.onQueryEviction(query, ramBytesUsed);
|
super.onQueryEviction(query, ramBytesUsed);
|
||||||
|
assertNotNull("evicted query is null", query);
|
||||||
ramBytesUsage.addAndGet(-ramBytesUsed);
|
ramBytesUsage.addAndGet(-ramBytesUsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue