@@ -59,7 +59,7 @@ public static final class EarlyTerminationException extends RuntimeException {
59
59
}
60
60
61
61
private final int maxCountHits ;
62
- private final AtomicLong numCollected ;
62
+ private long numCollected ;
63
63
private final boolean forceTermination ;
64
64
private boolean earlyTerminated ;
65
65
@@ -74,19 +74,11 @@ public static final class EarlyTerminationException extends RuntimeException {
74
74
super (delegate );
75
75
this .maxCountHits = maxCountHits ;
76
76
this .forceTermination = forceTermination ;
77
- this .numCollected = new AtomicLong ();
78
- }
79
-
80
- EarlyTerminatingCollector (final Collector delegate , int maxCountHits , boolean forceTermination , AtomicLong numCollected ) {
81
- super (delegate );
82
- this .maxCountHits = maxCountHits ;
83
- this .forceTermination = forceTermination ;
84
- this .numCollected = numCollected ;
85
77
}
86
78
87
79
@ Override
88
80
public LeafCollector getLeafCollector (LeafReaderContext context ) throws IOException {
89
- if (numCollected . get () >= maxCountHits ) {
81
+ if (numCollected >= maxCountHits ) {
90
82
earlyTerminated = true ;
91
83
if (forceTermination ) {
92
84
throw new EarlyTerminationException ("early termination [CountBased]" );
@@ -97,7 +89,7 @@ public LeafCollector getLeafCollector(LeafReaderContext context) throws IOExcept
97
89
return new FilterLeafCollector (super .getLeafCollector (context )) {
98
90
@ Override
99
91
public void collect (int doc ) throws IOException {
100
- if (numCollected . incrementAndGet () > maxCountHits ) {
92
+ if (++ numCollected > maxCountHits ) {
101
93
earlyTerminated = true ;
102
94
if (forceTermination ) {
103
95
throw new EarlyTerminationException ("early termination [CountBased]" );
0 commit comments