Skip to content

Commit

Permalink
disable the cache
Browse files Browse the repository at this point in the history
Signed-off-by: bowenlan-amzn <[email protected]>
  • Loading branch information
bowenlan-amzn committed Jan 24, 2025
1 parent 2f5d74b commit 5beb5c0
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.apache.lucene.index.IndexableField;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryCachingPolicy;
import org.apache.lucene.search.TotalHitCountCollectorManager;
import org.apache.lucene.store.FSDirectory;
import org.apache.lucene.index.IndexWriter;
Expand Down Expand Up @@ -48,7 +49,7 @@
@Warmup(iterations = 10)
@Measurement(iterations = 5)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
public class RangeQueryBenchmark {

Expand Down Expand Up @@ -100,6 +101,15 @@ public void indexRandomDocs() throws IOException {

private void setUpSearch() {
searcher = new IndexSearcher(reader);
searcher.setQueryCachingPolicy(new QueryCachingPolicy() {
@Override
public void onUse(Query query) { }

@Override
public boolean shouldCache(Query query) {
return false;
}
});
prq = LongPoint.newRangeQuery("number", 0, docCount);
dvq = SortedNumericDocValuesField.newSlowRangeQuery("number", 0, docCount);
}
Expand Down

0 comments on commit 5beb5c0

Please sign in to comment.