Apache Lucene open-source search software
Replace AtomicLong with LongAdder in HitsThresholdChecker (#13546)
Armin Braun2a8d328ab222
diff --git a/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java b/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.javaindex fb6f6bf4343..4232af53fe6 100644--- a/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java+++ b/lucene/core/src/java/org/apache/lucene/search/HitsThresholdChecker.java@@ -17,13 +17,13 @@package org.apache.lucene.search;-import java.util.concurrent.atomic.AtomicLong;+import java.util.concurrent.atomic.LongAdder;/** Used for defining custom algorithms to allow searches to early terminate */abstract class HitsThresholdChecker {/** Implementation of HitsThresholdChecker which allows global hit counting */private static class GlobalHitsThresholdChecker extends HitsThresholdChecker {- private final AtomicLong globalHitCount = new AtomicLong();+ private final LongAdder globalHitCount = new LongAdder();GlobalHitsThresholdChecker(int totalHitsThreshold) {super(totalHitsThreshold);@@ -32,12 +32,12 @@ abstract class HitsThresholdChecker {@Overridevoid incrementHitCount() {- globalHitCount.incrementAndGet();+ globalHitCount.increment();}@Overrideboolean isThresholdReached() {- return globalHitCount.getAcquire() > getHitsThreshold();+ return globalHitCount.longValue() > getHitsThreshold();}@Override