Search in sources :

Example 6 with BlockAssertions.createLongsBlock

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);
            }
        }
    }
}
Also used : GroupByHash.createGroupByHash(io.trino.operator.GroupByHash.createGroupByHash) TypeTestUtils.getHashBlock(io.trino.type.TypeTestUtils.getHashBlock) BlockAssertions.createLongSequenceBlock(io.trino.block.BlockAssertions.createLongSequenceBlock) DictionaryBlock(io.trino.spi.block.DictionaryBlock) BlockAssertions.createStringSequenceBlock(io.trino.block.BlockAssertions.createStringSequenceBlock) Block(io.trino.spi.block.Block) RunLengthEncodedBlock(io.trino.spi.block.RunLengthEncodedBlock) VariableWidthBlock(io.trino.spi.block.VariableWidthBlock) BlockAssertions.createLongsBlock(io.trino.block.BlockAssertions.createLongsBlock) Page(io.trino.spi.Page) Test(org.testng.annotations.Test)

Aggregations

BlockAssertions.createLongSequenceBlock (io.trino.block.BlockAssertions.createLongSequenceBlock)6 BlockAssertions.createLongsBlock (io.trino.block.BlockAssertions.createLongsBlock)6 BlockAssertions.createStringSequenceBlock (io.trino.block.BlockAssertions.createStringSequenceBlock)6 Page (io.trino.spi.Page)6 Block (io.trino.spi.block.Block)6 DictionaryBlock (io.trino.spi.block.DictionaryBlock)6 RunLengthEncodedBlock (io.trino.spi.block.RunLengthEncodedBlock)6 VariableWidthBlock (io.trino.spi.block.VariableWidthBlock)6 TypeTestUtils.getHashBlock (io.trino.type.TypeTestUtils.getHashBlock)6 Test (org.testng.annotations.Test)6 GroupByHash.createGroupByHash (io.trino.operator.GroupByHash.createGroupByHash)5 PageBuilder (io.trino.spi.PageBuilder)1 ArrayList (java.util.ArrayList)1