Skip to content

Commit 1e73665

Browse files
committed
better initially size the bytesBuilder
1 parent 743d0c8 commit 1e73665

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
* Additionally, this implementation can collect complete value blocks.
2929
*/
3030
public class TSIDOrdinalsBuilder implements BlockLoader.TSIDOrdinalsBuilder, Releasable, Block.Builder {
31+
32+
private static final int TSID_SIZE_GUESS = 2 + 16 + 16 + 4 * 8;
33+
3134
private final BlockFactory blockFactory;
3235
private final SortedDocValues docValues;
3336
private final long[] ords;
@@ -83,7 +86,7 @@ BytesRefBlock buildOrdinal() {
8386
for (int i = 0; i < count; i++) {
8487
newOrds[i] = Math.toIntExact(ords[i]) - minOrd;
8588
}
86-
try (BytesRefVector.Builder bytesBuilder = blockFactory.newBytesRefVectorBuilder(valueCount)) {
89+
try (BytesRefVector.Builder bytesBuilder = blockFactory.newBytesRefVectorBuilder(valueCount * TSID_SIZE_GUESS)) {
8790
for (int ord = minOrd; ord <= maxOrd; ord++) {
8891
bytesBuilder.appendBytesRef(docValues.lookupOrd(ord));
8992
}

0 commit comments

Comments
 (0)