Skip to content

Commit f9aca0c

Browse files
committed
reuse bytesref
1 parent af674a3 commit f9aca0c

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/aggregation/blockhash/TimeSeriesBlockHash.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ public void add(Page page, GroupingAggregatorFunction.AddInput addInput) {
9595
}
9696
try (var ordsBuilder = blockFactory.newIntVectorBuilder(tsidOrdinals.getPositionCount())) {
9797
final BytesRef spare = new BytesRef();
98+
final BytesRef lastTsid = new BytesRef();
9899
final LongVector timestampVector = getTimestampVector(page);
99100
int lastOrd = -1;
100101
for (int i = 0; i < tsidOrdinals.getPositionCount(); i++) {
@@ -105,7 +106,8 @@ public void add(Page page, GroupingAggregatorFunction.AddInput addInput) {
105106
if (positionCount() == 0) {
106107
newGroup = true;
107108
} else if (lastOrd == -1) {
108-
newGroup = lastTsid().equals(newTsid) == false;
109+
tsidArray.get(lastTsidPosition, lastTsid);
110+
newGroup = lastTsid.equals(newTsid) == false;
109111
} else {
110112
newGroup = true;
111113
}
@@ -138,12 +140,6 @@ private void endTsidGroup() {
138140
}
139141
}
140142

141-
private BytesRef lastTsid() {
142-
final BytesRef bytesRef = new BytesRef();
143-
tsidArray.get(lastTsidPosition, bytesRef);
144-
return bytesRef;
145-
}
146-
147143
@Override
148144
public ReleasableIterator<IntBlock> lookup(Page page, ByteSizeValue targetBlockSize) {
149145
throw new UnsupportedOperationException("TODO");

0 commit comments

Comments
 (0)