RecordBatchLoader batchLoader = new RecordBatchLoader(bit.getContext().getAllocator());
int recordCount = 0;
assertEquals(3, results.size());
QueryResultBatch batch = results.get(1);
assertTrue(batchLoader.load(batch.getHeader().getDef(), batch.getData()));
batchLoader.load(batch.getHeader().getDef(), batch.getData());
ValueVector.Accessor output = batchLoader.getValueAccessorById(NullableBigIntVector.class,
batchLoader.getValueVectorId(
new SchemaPath(new PathSegment.NameSegment("output"))).getFieldIds()[0]
).getValueVector().getAccessor();
ValueVector.Accessor sum = batchLoader.getValueAccessorById(
BigIntVector.class,
batchLoader.getValueVectorId(
new SchemaPath(new PathSegment.NameSegment("sum"))).getFieldIds()[0]
).getValueVector().getAccessor();
ValueVector.Accessor cnt = batchLoader.getValueAccessorById(
BigIntVector.class,
batchLoader.getValueVectorId(
new SchemaPath(new PathSegment.NameSegment("cnt"))).getFieldIds()[0]
).getValueVector().getAccessor();
int lastGroup = -1;
long groupCounter = 0;
long s = 0;
for (int r = 1; r <= batchLoader.getRecordCount(); r++) {
recordCount++;
int group = r / 4;
if(lastGroup != group) {
lastGroup = group;
groupCounter = 1;
s = 0;
} else {
groupCounter++;
}
s += group * 8 + r % 4;
assertEquals("Count, Row " + r, groupCounter, cnt.getObject(r - 1));
assertEquals("Sum, Row " + r, s, sum.getObject(r - 1));
assertEquals("Output, Row " + r, s, output.getObject(r - 1));
}
batchLoader.clear();
batch.release();
assertEquals(1000, recordCount);
}
}