You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by iv...@apache.org on 2026/06/01 14:32:16 UTC

(lucene) branch main updated: Add query cache randomly in LuceneTestCaseParent (#16162)

This is an automated email from the ASF dual-hosted git repository.

iverase pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/lucene.git


The following commit(s) were added to refs/heads/main by this push:
     new d82d21045e3 Add query cache randomly in LuceneTestCaseParent (#16162)
d82d21045e3 is described below

commit d82d21045e3075903441faa20c776933885aeb42
Author: Ignacio Vera <iv...@apache.org>
AuthorDate: Mon Jun 1 15:32:09 2026 +0100

    Add query cache randomly in LuceneTestCaseParent (#16162)
---
 .../org/apache/lucene/tests/util/LuceneTestCaseParent.java     | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java
index 9fcfb9e259d..0f1035df27c 100644
--- a/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java
+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/util/LuceneTestCaseParent.java
@@ -2682,6 +2682,10 @@ public abstract sealed class LuceneTestCaseParent extends Assert
       } else {
         ret = random.nextBoolean() ? new IndexSearcher(r) : new IndexSearcher(r.getContext());
       }
+      if (random.nextBoolean()) {
+        ret.setQueryCache(new LRUQueryCache(100, 1024 * 1024, _ -> true, 1f));
+        ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);
+      }
       ret.setSimilarity(getTestFrameworkInfra().getClassEnv().similarity);
       return ret;
     } else {
@@ -2728,7 +2732,11 @@ public abstract sealed class LuceneTestCaseParent extends Assert
             };
       }
       ret.setSimilarity(getTestFrameworkInfra().getClassEnv().similarity);
-      ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);
+
+      if (random.nextBoolean()) {
+        ret.setQueryCache(new LRUQueryCache(100, 1024 * 1024, _ -> true, 1f));
+        ret.setQueryCachingPolicy(MAYBE_CACHE_POLICY);
+      }
       if (random().nextBoolean()) {
         ret.setTimeout(() -> false);
       }