use of io.trino.block.BlockAssertions.createLongsBlock in project trino by trinodb.
the class TestGroupByHash method testGetGroupIds.
@Test
public void testGetGroupIds() {
GroupByHash groupByHash = createGroupByHash(TEST_SESSION, ImmutableList.of(BIGINT), new int[] { 0 }, Optional.of(1), 100, JOIN_COMPILER, TYPE_OPERATOR_FACTORY, NOOP);
for (int tries = 0; tries < 2; tries++) {
for (int value = 0; value < MAX_GROUP_ID; value++) {
Block block = BlockAssertions.createLongsBlock(value);
Block hashBlock = TypeTestUtils.getHashBlock(ImmutableList.of(BIGINT), block);
Page page = new Page(block, hashBlock);
for (int addValuesTries = 0; addValuesTries < 10; addValuesTries++) {
Work<GroupByIdBlock> work = groupByHash.getGroupIds(page);
work.process();
GroupByIdBlock groupIds = work.getResult();
assertEquals(groupIds.getGroupCount(), tries == 0 ? value + 1 : MAX_GROUP_ID);
assertEquals(groupIds.getPositionCount(), 1);
long groupId = groupIds.getGroupId(0);
assertEquals(groupId, value);
}
}
}
}
Aggregations