|
11 | 11 | import org.elasticsearch.compute.data.Block;
|
12 | 12 | import org.elasticsearch.compute.data.BlockFactory;
|
13 | 13 | import org.elasticsearch.compute.data.DocVector;
|
| 14 | +import org.elasticsearch.compute.data.IntVector; |
| 15 | +import org.elasticsearch.core.Releasables; |
14 | 16 |
|
15 | 17 | class ResultBuilderForDoc implements ResultBuilder {
|
16 | 18 | private final BlockFactory blockFactory;
|
@@ -42,12 +44,21 @@ public void decodeValue(BytesRef values) {
|
42 | 44 |
|
43 | 45 | @Override
|
44 | 46 | public Block build() {
|
45 |
| - return new DocVector( |
46 |
| - blockFactory.newIntArrayVector(shards, position), |
47 |
| - blockFactory.newIntArrayVector(segments, position), |
48 |
| - blockFactory.newIntArrayVector(docs, position), |
49 |
| - null |
50 |
| - ).asBlock(); |
| 47 | + boolean success = false; |
| 48 | + IntVector shardsVector = null; |
| 49 | + IntVector segmentsVector = null; |
| 50 | + try { |
| 51 | + shardsVector = blockFactory.newIntArrayVector(shards, position); |
| 52 | + segmentsVector = blockFactory.newIntArrayVector(segments, position); |
| 53 | + var docsVector = blockFactory.newIntArrayVector(docs, position); |
| 54 | + var docsBlock = new DocVector(shardsVector, segmentsVector, docsVector, null).asBlock(); |
| 55 | + success = true; |
| 56 | + return docsBlock; |
| 57 | + } finally { |
| 58 | + if (success == false) { |
| 59 | + Releasables.closeExpectNoException(shardsVector, segmentsVector); |
| 60 | + } |
| 61 | + } |
51 | 62 | }
|
52 | 63 |
|
53 | 64 | @Override
|
|
0 commit comments