Search in sources :

Example 11 with VariableWidthBlock

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

the class TestVariableWidthBlock method testCompactBlock.

@Test
public void testCompactBlock() {
    Slice compactSlice = Slices.copyOf(createExpectedValue(16));
    Slice incompactSlice = Slices.copyOf(createExpectedValue(20)).slice(0, 16);
    int[] offsets = { 0, 1, 1, 2, 4, 8, 16 };
    boolean[] valueIsNull = { false, true, false, false, false, false };
    testCompactBlock(new VariableWidthBlock(0, EMPTY_SLICE, new int[1], Optional.empty()));
    testCompactBlock(new VariableWidthBlock(valueIsNull.length, compactSlice, offsets, Optional.of(valueIsNull)));
    testIncompactBlock(new VariableWidthBlock(valueIsNull.length - 1, compactSlice, offsets, Optional.of(valueIsNull)));
    // underlying slice is not compact
    testIncompactBlock(new VariableWidthBlock(valueIsNull.length, incompactSlice, offsets, Optional.of(valueIsNull)));
}
Also used : Slice(io.airlift.slice.Slice) VariableWidthBlock(io.prestosql.spi.block.VariableWidthBlock) Test(org.testng.annotations.Test)

Example 12 with VariableWidthBlock

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

the class OperatorUtils method buildVariableWidthOmniBlock.

private static VariableWidthOmniBlock buildVariableWidthOmniBlock(VecAllocator vecAllocator, Block block, int positionCount, boolean isRLE) {
    if (!isRLE) {
        int[] offsets = ((VariableWidthBlock) block).getOffsets();
        int offset = block.getBlockOffset();
        boolean[] valueIsNull = block.getValueNulls();
        Slice slice = ((VariableWidthBlock) block).getRawSlice(0);
        return new VariableWidthOmniBlock(vecAllocator, offset, positionCount, slice, offsets, transformBooleanToByte(valueIsNull));
    } else {
        AbstractVariableWidthBlock variableWidthBlock = (AbstractVariableWidthBlock) ((RunLengthEncodedBlock) block).getValue();
        VarcharVec vec = new VarcharVec(vecAllocator, variableWidthBlock.getSliceLength(0) * positionCount, positionCount);
        for (int i = 0; i < positionCount; i++) {
            if (block.isNull(i)) {
                vec.setNull(i);
            } else {
                vec.set(i, (byte[]) block.get(i));
            }
        }
        return new VariableWidthOmniBlock(positionCount, vec);
    }
}
Also used : AbstractVariableWidthBlock(io.prestosql.spi.block.AbstractVariableWidthBlock) Slice(io.airlift.slice.Slice) VariableWidthOmniBlock(nova.hetu.olk.block.VariableWidthOmniBlock) VarcharVec(nova.hetu.omniruntime.vector.VarcharVec) AbstractVariableWidthBlock(io.prestosql.spi.block.AbstractVariableWidthBlock) VariableWidthBlock(io.prestosql.spi.block.VariableWidthBlock)

Example 13 with VariableWidthBlock

use of io.prestosql.spi.block.VariableWidthBlock in project carbondata by apache.

the class SliceStreamReader method setDictionary.

@Override
public void setDictionary(CarbonDictionary dictionary) {
    super.setDictionary(dictionary);
    if (dictionary == null) {
        dictionaryBlock = null;
        this.isLocalDict = false;
        return;
    }
    boolean[] nulls = new boolean[dictionary.getDictionarySize()];
    nulls[0] = true;
    nulls[1] = true;
    int[] dictOffsets = new int[dictionary.getDictionarySize() + 1];
    int size = 0;
    for (int i = 0; i < dictionary.getDictionarySize(); i++) {
        dictOffsets[i] = size;
        if (dictionary.getDictionaryValue(i) != null) {
            size += dictionary.getDictionaryValue(i).length;
        }
    }
    byte[] singleArrayDictValues = new byte[size];
    for (int i = 0; i < dictionary.getDictionarySize(); i++) {
        if (dictionary.getDictionaryValue(i) != null) {
            System.arraycopy(dictionary.getDictionaryValue(i), 0, singleArrayDictValues, dictOffsets[i], dictionary.getDictionaryValue(i).length);
        }
    }
    dictOffsets[dictOffsets.length - 1] = size;
    dictionaryBlock = new VariableWidthBlock(dictionary.getDictionarySize(), Slices.wrappedBuffer(singleArrayDictValues), dictOffsets, Optional.of(nulls));
    this.isLocalDict = true;
}
Also used : VariableWidthBlock(io.prestosql.spi.block.VariableWidthBlock)

Aggregations

VariableWidthBlock (io.prestosql.spi.block.VariableWidthBlock)13 Slice (io.airlift.slice.Slice)5 Block (io.prestosql.spi.block.Block)5 Test (org.testng.annotations.Test)4 AbstractVariableWidthBlock (io.prestosql.spi.block.AbstractVariableWidthBlock)2 RunLengthEncodedBlock (io.prestosql.spi.block.RunLengthEncodedBlock)2 ShortArrayBlock (io.prestosql.spi.block.ShortArrayBlock)2 VarcharVec (nova.hetu.omniruntime.vector.VarcharVec)2 HBaseTableHandle (io.hetu.core.plugin.hbase.connector.HBaseTableHandle)1 HBaseTransactionHandle (io.hetu.core.plugin.hbase.connector.HBaseTransactionHandle)1 HBasePageSinkProvider (io.hetu.core.plugin.hbase.query.HBasePageSinkProvider)1 OrcCorruptionException (io.prestosql.orc.OrcCorruptionException)1 Page (io.prestosql.spi.Page)1 PrestoException (io.prestosql.spi.PrestoException)1 IntArrayBlock (io.prestosql.spi.block.IntArrayBlock)1 LongArrayBlock (io.prestosql.spi.block.LongArrayBlock)1 ConnectorInsertTableHandle (io.prestosql.spi.connector.ConnectorInsertTableHandle)1 ConnectorPageSink (io.prestosql.spi.connector.ConnectorPageSink)1 MapType (io.prestosql.spi.type.MapType)1 MethodHandle (java.lang.invoke.MethodHandle)1