Skip to content

Apache Lucene open-source search software

LUCENE-8942: Tighten Up LRUQueryCache's Methods (#816)

Atri Sharmaa3cb9cb32406
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index 82ec8c0fb42..a52a86c8dfd 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -105,6 +105,9 @@ Improvements
* LUCENE-8906: Expose Lucene50PostingsFormat.IntBlockTermState as public so that other postings formats can re-use it.
(Bruno Roustant)
+* LUCENE-8942: Remove redundant parameters and improve visibility strictness in
+ LRUQueryCache (Atri Sharma)
+
* SOLR-13663: Introduce <SpanPositionRange> into XML Query Parser (Alessandro Benedetti via Mikhail Khludnev)
* LUCENE-8952: Use a sort key instead of true distance in NearestNeighbor (Julie Tibshirani).
diff --git a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
index ce2d37040a9..ea3c158ce8c 100644
--- a/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
+++ b/lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java
@@ -258,7 +258,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
}
}
- DocIdSet get(Query key, LeafReaderContext context, IndexReader.CacheHelper cacheHelper) {
+ DocIdSet get(Query key, IndexReader.CacheHelper cacheHelper) {
assert lock.isHeldByCurrentThread();
assert key instanceof BoostQuery == false;
assert key instanceof ConstantScoreQuery == false;
@@ -283,7 +283,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
return cached;
}
- void putIfAbsent(Query query, LeafReaderContext context, DocIdSet set, IndexReader.CacheHelper cacheHelper) {
+ private void putIfAbsent(Query query, DocIdSet set, IndexReader.CacheHelper cacheHelper) {
assert query instanceof BoostQuery == false;
assert query instanceof ConstantScoreQuery == false;
// under a lock to make sure that mostRecentlyUsedQueries and cache remain sync'ed
@@ -312,7 +312,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
}
}
- void evictIfNecessary() {
+ private void evictIfNecessary() {
assert lock.isHeldByCurrentThread();
// under a lock to make sure that mostRecentlyUsedQueries and cache keep sync'ed
if (requiresEviction()) {
@@ -725,7 +725,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
DocIdSet docIdSet;
try {
- docIdSet = get(in.getQuery(), context, cacheHelper);
+ docIdSet = get(in.getQuery(), cacheHelper);
} finally {
lock.unlock();
}
@@ -733,7 +733,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
if (docIdSet == null) {
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
- putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
+ putIfAbsent(in.getQuery(), docIdSet, cacheHelper);
} else {
return in.scorerSupplier(context);
}
@@ -806,7 +806,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
DocIdSet docIdSet;
try {
- docIdSet = get(in.getQuery(), context, cacheHelper);
+ docIdSet = get(in.getQuery(), cacheHelper);
} finally {
lock.unlock();
}
@@ -814,7 +814,7 @@ public class LRUQueryCache implements QueryCache, Accountable {
if (docIdSet == null) {
if (policy.shouldCache(in.getQuery())) {
docIdSet = cache(context);
- putIfAbsent(in.getQuery(), context, docIdSet, cacheHelper);
+ putIfAbsent(in.getQuery(), docIdSet, cacheHelper);
} else {
return in.bulkScorer(context);
}