Skip to content

Commit de0d4bd

Browse files
committed
Fix double ref counting from previous PR
1 parent 97af248 commit de0d4bd

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneOperator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ protected LuceneOperator(
8686
LuceneSliceQueue sliceQueue
8787
) {
8888
this.shardContextCounters = shardContextCounters;
89-
shardContextCounters.forEach(RefCounted::incRef);
89+
shardContextCounters.forEach(RefCounted::mustIncRef);
9090
this.blockFactory = blockFactory;
9191
this.maxPageSize = maxPageSize;
9292
this.sliceQueue = sliceQueue;

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneSourceOperator.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,6 @@ public LuceneSourceOperator(
227227
boolean needsScore
228228
) {
229229
super(shardContextCounters, blockFactory, maxPageSize, sliceQueue);
230-
shardContextCounters.forEach(RefCounted::mustIncRef);
231230
this.minPageSize = Math.max(1, maxPageSize / 2);
232231
this.remainingDocs = limit;
233232
this.limiter = limiter;

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/LuceneTopNSourceOperator.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,12 @@ private Page emit(boolean startEmitting) {
241241
}
242242
}
243243

244-
shard = blockFactory.newConstantIntBlockWith(perShardCollector.shardContext.index(), size);
244+
int shardId = perShardCollector.shardContext.index();
245+
shard = blockFactory.newConstantIntBlockWith(shardId, size);
245246
segments = currentSegmentBuilder.build();
246247
docs = currentDocsBuilder.build();
247-
docBlock = new DocVector(ShardRefCounted.fromList(contexts), shard.asVector(), segments, docs, null).asBlock();
248+
ShardRefCounted shardRefCounted = ShardRefCounted.single(shardId, contexts.get(shardId));
249+
docBlock = new DocVector(shardRefCounted, shard.asVector(), segments, docs, null).asBlock();
248250
shard = null;
249251
segments = null;
250252
docs = null;

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/TimeSeriesSourceOperator.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.elasticsearch.compute.data.OrdinalBytesRefVector;
3131
import org.elasticsearch.compute.data.Page;
3232
import org.elasticsearch.compute.operator.Operator;
33-
import org.elasticsearch.core.RefCounted;
3433
import org.elasticsearch.core.Releasable;
3534
import org.elasticsearch.core.Releasables;
3635
import org.elasticsearch.xcontent.XContentBuilder;
@@ -64,7 +63,6 @@ public final class TimeSeriesSourceOperator extends LuceneOperator {
6463
int limit
6564
) {
6665
super(contexts, blockFactory, maxPageSize, sliceQueue);
67-
contexts.forEach(RefCounted::mustIncRef);
6866
this.maxPageSize = maxPageSize;
6967
this.blockFactory = blockFactory;
7068
this.remainingDocs = limit;

0 commit comments

Comments
 (0)