Search in sources :

Example 96 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestColumnarArray method test.

@Test
public void test() {
    Slice[][] expectedValues = new Slice[ARRAY_SIZES.length][];
    for (int i = 0; i < ARRAY_SIZES.length; i++) {
        expectedValues[i] = new Slice[ARRAY_SIZES[i]];
        for (int j = 0; j < ARRAY_SIZES[i]; j++) {
            if (j % 3 != 1) {
                expectedValues[i][j] = Slices.utf8Slice(format("%d.%d", i, j));
            }
        }
    }
    BlockBuilder blockBuilder = createBlockBuilderWithValues(expectedValues);
    verifyBlock(blockBuilder, expectedValues);
    verifyBlock(blockBuilder.build(), expectedValues);
    Slice[][] expectedValuesWithNull = alternatingNullValues(expectedValues);
    BlockBuilder blockBuilderWithNull = createBlockBuilderWithValues(expectedValuesWithNull);
    verifyBlock(blockBuilderWithNull, expectedValuesWithNull);
    verifyBlock(blockBuilderWithNull.build(), expectedValuesWithNull);
}
Also used : Slice(io.airlift.slice.Slice) BlockBuilder(io.prestosql.spi.block.BlockBuilder) ArrayBlockBuilder(io.prestosql.spi.block.ArrayBlockBuilder) Test(org.testng.annotations.Test)

Example 97 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestColumnarArray method createBlockBuilderWithValues.

public static BlockBuilder createBlockBuilderWithValues(Slice[][] expectedValues) {
    BlockBuilder blockBuilder = new ArrayBlockBuilder(VARCHAR, null, 100, 100);
    for (Slice[] expectedValue : expectedValues) {
        if (expectedValue == null) {
            blockBuilder.appendNull();
        } else {
            BlockBuilder elementBlockBuilder = VARCHAR.createBlockBuilder(null, expectedValue.length);
            for (Slice v : expectedValue) {
                if (v == null) {
                    elementBlockBuilder.appendNull();
                } else {
                    VARCHAR.writeSlice(elementBlockBuilder, v);
                }
            }
            blockBuilder.appendStructure(elementBlockBuilder.build());
        }
    }
    return blockBuilder;
}
Also used : ArrayBlockBuilder(io.prestosql.spi.block.ArrayBlockBuilder) Slice(io.airlift.slice.Slice) BlockBuilder(io.prestosql.spi.block.BlockBuilder) ArrayBlockBuilder(io.prestosql.spi.block.ArrayBlockBuilder)

Example 98 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class RowPageBuilder method append.

private void append(int channel, Object element) {
    BlockBuilder blockBuilder = builders.get(channel);
    Type type = types.get(channel);
    appendToBlockBuilder(type, element, blockBuilder);
}
Also used : Type(io.prestosql.spi.type.Type) BlockBuilder(io.prestosql.spi.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(io.prestosql.util.StructuralTestUtil.appendToBlockBuilder)

Example 99 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestHashAggregationOperator method testHashBuilderResizeLimit.

@Test(dataProvider = "hashEnabled", expectedExceptions = ExceededMemoryLimitException.class, expectedExceptionsMessageRegExp = "Query exceeded per-node user memory limit of 3MB.*")
public void testHashBuilderResizeLimit(boolean hashEnabled) {
    BlockBuilder builder = VARCHAR.createBlockBuilder(null, 1, MAX_BLOCK_SIZE_IN_BYTES);
    // this must be larger than MAX_BLOCK_SIZE_IN_BYTES, 64K
    VARCHAR.writeSlice(builder, Slices.allocate(5_000_000));
    builder.build();
    List<Integer> hashChannels = Ints.asList(0);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, hashChannels, VARCHAR);
    List<Page> input = rowPagesBuilder.addSequencePage(10, 100).addBlocksPage(builder.build()).addSequencePage(10, 100).build();
    DriverContext driverContext = createTaskContext(executor, scheduledExecutor, TEST_SESSION, new DataSize(3, MEGABYTE)).addPipelineContext(0, true, true, false).addDriverContext();
    HashAggregationOperatorFactory operatorFactory = new HashAggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR), hashChannels, ImmutableList.of(), Step.SINGLE, ImmutableList.of(COUNT.bind(ImmutableList.of(0), Optional.empty())), rowPagesBuilder.getHashChannel(), Optional.empty(), 100_000, Optional.of(new DataSize(16, MEGABYTE)), joinCompiler, false);
    toPages(operatorFactory, driverContext, input);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowPagesBuilder(io.prestosql.RowPagesBuilder) DataSize(io.airlift.units.DataSize) Page(io.prestosql.spi.Page) BlockBuilder(io.prestosql.spi.block.BlockBuilder) HashAggregationOperatorFactory(io.prestosql.operator.HashAggregationOperator.HashAggregationOperatorFactory) Test(org.testng.annotations.Test)

Example 100 with BlockBuilder

use of io.prestosql.spi.block.BlockBuilder in project hetu-core by openlookeng.

the class TestHashAggregationOperator method testHashBuilderResize.

@Test(dataProvider = "hashEnabledAndMemoryLimitForMergeValues")
public void testHashBuilderResize(boolean hashEnabled, boolean spillEnabled, boolean revokeMemoryWhenAddingPages, long memoryLimitForMerge, long memoryLimitForMergeWithMemory) {
    BlockBuilder builder = VARCHAR.createBlockBuilder(null, 1, MAX_BLOCK_SIZE_IN_BYTES);
    // this must be larger than MAX_BLOCK_SIZE_IN_BYTES, 64K
    VARCHAR.writeSlice(builder, Slices.allocate(200_000));
    builder.build();
    List<Integer> hashChannels = Ints.asList(0);
    RowPagesBuilder rowPagesBuilder = rowPagesBuilder(hashEnabled, hashChannels, VARCHAR);
    List<Page> input = rowPagesBuilder.addSequencePage(10, 100).addBlocksPage(builder.build()).addSequencePage(10, 100).build();
    DriverContext driverContext = createDriverContext(memoryLimitForMerge);
    HashAggregationOperatorFactory operatorFactory = new HashAggregationOperatorFactory(0, new PlanNodeId("test"), ImmutableList.of(VARCHAR), hashChannels, ImmutableList.of(), Step.SINGLE, false, ImmutableList.of(COUNT.bind(ImmutableList.of(0), Optional.empty())), rowPagesBuilder.getHashChannel(), Optional.empty(), 100_000, Optional.of(new DataSize(16, MEGABYTE)), spillEnabled, succinctBytes(memoryLimitForMerge), succinctBytes(memoryLimitForMergeWithMemory), spillerFactory, joinCompiler, false);
    toPages(operatorFactory, driverContext, input, revokeMemoryWhenAddingPages);
}
Also used : PlanNodeId(io.prestosql.spi.plan.PlanNodeId) RowPagesBuilder(io.prestosql.RowPagesBuilder) DataSize(io.airlift.units.DataSize) Page(io.prestosql.spi.Page) BlockBuilder(io.prestosql.spi.block.BlockBuilder) HashAggregationOperatorFactory(io.prestosql.operator.HashAggregationOperator.HashAggregationOperatorFactory) Test(org.testng.annotations.Test)

Aggregations

BlockBuilder (io.prestosql.spi.block.BlockBuilder)440 Block (io.prestosql.spi.block.Block)100 Test (org.testng.annotations.Test)84 Slice (io.airlift.slice.Slice)80 Type (io.prestosql.spi.type.Type)78 Page (io.prestosql.spi.Page)52 SqlType (io.prestosql.spi.function.SqlType)42 ArrayType (io.prestosql.spi.type.ArrayType)38 Map (java.util.Map)36 RowType (io.prestosql.spi.type.RowType)34 MapType (io.prestosql.spi.type.MapType)31 List (java.util.List)26 PageBuilder (io.prestosql.spi.PageBuilder)24 TimestampType (io.prestosql.spi.type.TimestampType)24 ImmutableList (com.google.common.collect.ImmutableList)23 PrestoException (io.prestosql.spi.PrestoException)23 BigintType (io.prestosql.spi.type.BigintType)23 BooleanType (io.prestosql.spi.type.BooleanType)21 DoubleType (io.prestosql.spi.type.DoubleType)21 UsedByGeneratedCode (io.prestosql.spi.annotation.UsedByGeneratedCode)20