Search in sources :

Example 21 with DictionaryBlock

use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.

the class OperatorUtils method buildDictionaryBlock.

private static Block buildDictionaryBlock(Block block, int positionCount) {
    DictionaryVec dictionaryVec = (DictionaryVec) block.getValues();
    int[] newIds = dictionaryVec.getIds(positionCount);
    Block dictionary = buildOnHeapBlock(((DictionaryOmniBlock) block).getDictionary());
    return new DictionaryBlock(dictionary, newIds);
}
Also used : DictionaryVec(nova.hetu.omniruntime.vector.DictionaryVec) DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) RunLengthEncodedBlock(io.prestosql.spi.block.RunLengthEncodedBlock) LongArrayBlock(io.prestosql.spi.block.LongArrayBlock) DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) IntArrayOmniBlock(nova.hetu.olk.block.IntArrayOmniBlock) ByteArrayOmniBlock(nova.hetu.olk.block.ByteArrayOmniBlock) DictionaryOmniBlock(nova.hetu.olk.block.DictionaryOmniBlock) LazyBlock(io.prestosql.spi.block.LazyBlock) LazyOmniBlock(nova.hetu.olk.block.LazyOmniBlock) AbstractVariableWidthBlock(io.prestosql.spi.block.AbstractVariableWidthBlock) VariableWidthOmniBlock(nova.hetu.olk.block.VariableWidthOmniBlock) VariableWidthBlock(io.prestosql.spi.block.VariableWidthBlock) DoubleArrayOmniBlock(nova.hetu.olk.block.DoubleArrayOmniBlock) RowOmniBlock(nova.hetu.olk.block.RowOmniBlock) Int128ArrayOmniBlock(nova.hetu.olk.block.Int128ArrayOmniBlock) Block(io.prestosql.spi.block.Block) Int128ArrayBlock(io.prestosql.spi.block.Int128ArrayBlock) LongArrayOmniBlock(nova.hetu.olk.block.LongArrayOmniBlock) ByteArrayBlock(io.prestosql.spi.block.ByteArrayBlock) IntArrayBlock(io.prestosql.spi.block.IntArrayBlock) RowBlock(io.prestosql.spi.block.RowBlock)

Example 22 with DictionaryBlock

use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.

the class BlockUtil method createDoubleDictionaryBlock.

public static Block createDoubleDictionaryBlock(int start, int length) {
    checkArgument(length > 5, "block must have more than 5 entries");
    int dictionarySize = length / 5;
    BlockBuilder builder = DOUBLE.createBlockBuilder(null, dictionarySize);
    for (int i = start; i < start + dictionarySize; i++) {
        DOUBLE.writeDouble(builder, i);
    }
    int[] ids = new int[length];
    for (int i = 0; i < length; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(builder.build(), ids);
}
Also used : DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 23 with DictionaryBlock

use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.

the class BlockUtil method createRealDictionaryBlock.

public static Block createRealDictionaryBlock(int start, int length) {
    checkArgument(length > 5, "block must have more than 5 entries");
    int dictionarySize = length / 5;
    BlockBuilder builder = REAL.createBlockBuilder(null, dictionarySize);
    for (int i = start; i < start + dictionarySize; i++) {
        REAL.writeLong(builder, i);
    }
    int[] ids = new int[length];
    for (int i = 0; i < length; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(builder.build(), ids);
}
Also used : DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 24 with DictionaryBlock

use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.

the class BlockUtil method createBooleanDictionaryBlock.

public static Block createBooleanDictionaryBlock(int start, int length) {
    checkArgument(length > 5, "block must have more than 5 entries");
    int dictionarySize = length / 5;
    BlockBuilder builder = BOOLEAN.createBlockBuilder(null, dictionarySize);
    for (int i = start; i < start + dictionarySize; i++) {
        BOOLEAN.writeBoolean(builder, i % 2 == 0);
    }
    int[] ids = new int[length];
    for (int i = 0; i < length; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(builder.build(), ids);
}
Also used : DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Example 25 with DictionaryBlock

use of io.prestosql.spi.block.DictionaryBlock in project boostkit-bigdata by kunpengcompute.

the class BlockUtil method createDateDictionaryBlock.

public static Block createDateDictionaryBlock(int start, int length) {
    checkArgument(length > 5, "block must have more than 5 entries");
    int dictionarySize = length / 5;
    BlockBuilder builder = DATE.createBlockBuilder(null, dictionarySize);
    for (int i = start; i < start + dictionarySize; i++) {
        DATE.writeLong(builder, i);
    }
    int[] ids = new int[length];
    for (int i = 0; i < length; i++) {
        ids[i] = i % dictionarySize;
    }
    return new DictionaryBlock(builder.build(), ids);
}
Also used : DictionaryBlock(io.prestosql.spi.block.DictionaryBlock) BlockBuilder(io.prestosql.spi.block.BlockBuilder)

Aggregations

DictionaryBlock (io.prestosql.spi.block.DictionaryBlock)69 Block (io.prestosql.spi.block.Block)31 Test (org.testng.annotations.Test)29 Slice (io.airlift.slice.Slice)17 BlockBuilder (io.prestosql.spi.block.BlockBuilder)16 RunLengthEncodedBlock (io.prestosql.spi.block.RunLengthEncodedBlock)11 Page (io.prestosql.spi.Page)9 ColumnarTestUtils.assertBlock (io.prestosql.block.ColumnarTestUtils.assertBlock)8 LazyBlock (io.prestosql.spi.block.LazyBlock)8 LongArrayBlock (io.prestosql.spi.block.LongArrayBlock)8 PageBuilderStatus (io.prestosql.spi.block.PageBuilderStatus)8 BlockAssertions.createLongSequenceBlock (io.prestosql.block.BlockAssertions.createLongSequenceBlock)7 DictionaryId (io.prestosql.spi.block.DictionaryId)6 TestUnnesterUtil.createSimpleBlock (io.prestosql.operator.unnest.TestUnnesterUtil.createSimpleBlock)5 DictionaryId.randomDictionaryId (io.prestosql.spi.block.DictionaryId.randomDictionaryId)5 BlockAssertions.createLongsBlock (io.prestosql.block.BlockAssertions.createLongsBlock)4 BlockAssertions.createLongDictionaryBlock (io.prestosql.block.BlockAssertions.createLongDictionaryBlock)3 ColumnarTestUtils.createTestDictionaryBlock (io.prestosql.block.ColumnarTestUtils.createTestDictionaryBlock)3 DriverYieldSignal (io.prestosql.operator.DriverYieldSignal)3 JoinProbeFactory (io.prestosql.operator.JoinProbe.JoinProbeFactory)3