Search in sources :

Example 16 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class BlockAssertions method createRLEBlock.

public static RunLengthEncodedBlock createRLEBlock(String value, int positionCount) {
    BlockBuilder blockBuilder = VARCHAR.createBlockBuilder(null, 1);
    VARCHAR.writeSlice(blockBuilder, wrappedBuffer(value.getBytes()));
    return new RunLengthEncodedBlock(blockBuilder.build(), positionCount);
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) RowBlockBuilder(com.facebook.presto.common.block.RowBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)

Example 17 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class BlockAssertions method createRLEBlock.

public static RunLengthEncodedBlock createRLEBlock(double value, int positionCount) {
    BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(null, 1);
    DOUBLE.writeDouble(blockBuilder, value);
    return new RunLengthEncodedBlock(blockBuilder.build(), positionCount);
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) RowBlockBuilder(com.facebook.presto.common.block.RowBlockBuilder) BlockBuilder(com.facebook.presto.common.block.BlockBuilder) StructuralTestUtil.appendToBlockBuilder(com.facebook.presto.util.StructuralTestUtil.appendToBlockBuilder)

Example 18 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class TestDictionaryAwarePageProjection method testRleBlockWithFailure.

@Test(dataProvider = "forceYield")
public void testRleBlockWithFailure(boolean forceYield) {
    Block value = createLongSequenceBlock(-43, -42);
    RunLengthEncodedBlock block = new RunLengthEncodedBlock(value, 100);
    testProjectFails(block, RunLengthEncodedBlock.class, forceYield);
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) BlockAssertions.createLongSequenceBlock(com.facebook.presto.block.BlockAssertions.createLongSequenceBlock) LongArrayBlock(com.facebook.presto.common.block.LongArrayBlock) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Block(com.facebook.presto.common.block.Block) LazyBlock(com.facebook.presto.common.block.LazyBlock) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Test(org.testng.annotations.Test)

Example 19 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class TestDictionaryAwarePageProjection method testRleBlock.

@Test(dataProvider = "forceYield")
public void testRleBlock(boolean forceYield) {
    Block value = createLongSequenceBlock(42, 43);
    RunLengthEncodedBlock block = new RunLengthEncodedBlock(value, 100);
    testProject(block, RunLengthEncodedBlock.class, forceYield);
}
Also used : RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) BlockAssertions.createLongSequenceBlock(com.facebook.presto.block.BlockAssertions.createLongSequenceBlock) LongArrayBlock(com.facebook.presto.common.block.LongArrayBlock) DictionaryBlock(com.facebook.presto.common.block.DictionaryBlock) Block(com.facebook.presto.common.block.Block) LazyBlock(com.facebook.presto.common.block.LazyBlock) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Test(org.testng.annotations.Test)

Example 20 with RunLengthEncodedBlock

use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.

the class RcFilePageSource method getNextPage.

@Override
public Page getNextPage() {
    try {
        // advance in the current batch
        pageId++;
        // if the batch has been consumed, read the next batch
        int currentPageSize = rcFileReader.advance();
        if (currentPageSize < 0) {
            close();
            return null;
        }
        completedPositions += currentPageSize;
        Block[] blocks = new Block[hiveColumnIndexes.length];
        for (int fieldId = 0; fieldId < blocks.length; fieldId++) {
            if (constantBlocks[fieldId] != null) {
                blocks[fieldId] = new RunLengthEncodedBlock(constantBlocks[fieldId], currentPageSize);
            } else {
                blocks[fieldId] = createBlock(currentPageSize, fieldId);
            }
        }
        return new Page(currentPageSize, blocks);
    } catch (PrestoException e) {
        closeWithSuppression(e);
        throw e;
    } catch (RcFileCorruptionException e) {
        closeWithSuppression(e);
        throw new PrestoException(HIVE_BAD_DATA, format("Corrupted RC file: %s", rcFileReader.getId()), e);
    } catch (IOException | RuntimeException e) {
        closeWithSuppression(e);
        throw new PrestoException(HIVE_CURSOR_ERROR, format("Failed to read RC file: %s", rcFileReader.getId()), e);
    }
}
Also used : RcFileCorruptionException(com.facebook.presto.rcfile.RcFileCorruptionException) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock) Block(com.facebook.presto.common.block.Block) LazyBlock(com.facebook.presto.common.block.LazyBlock) Page(com.facebook.presto.common.Page) PrestoException(com.facebook.presto.spi.PrestoException) IOException(java.io.IOException) RunLengthEncodedBlock(com.facebook.presto.common.block.RunLengthEncodedBlock)

Aggregations

RunLengthEncodedBlock (com.facebook.presto.common.block.RunLengthEncodedBlock)50 Block (com.facebook.presto.common.block.Block)27 Page (com.facebook.presto.common.Page)14 Test (org.testng.annotations.Test)9 DictionaryBlock (com.facebook.presto.common.block.DictionaryBlock)7 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)6 LongArrayBlock (com.facebook.presto.common.block.LongArrayBlock)6 PrestoException (com.facebook.presto.spi.PrestoException)6 ByteArrayBlock (com.facebook.presto.common.block.ByteArrayBlock)5 Slice (io.airlift.slice.Slice)5 IOException (java.io.IOException)4 ArrayBlock (com.facebook.presto.common.block.ArrayBlock)3 LazyBlock (com.facebook.presto.common.block.LazyBlock)3 RowBlockBuilder (com.facebook.presto.common.block.RowBlockBuilder)3 BlockAssertions.createLongSequenceBlock (com.facebook.presto.block.BlockAssertions.createLongSequenceBlock)2 BlockLease (com.facebook.presto.common.block.BlockLease)2 IntArrayBlock (com.facebook.presto.common.block.IntArrayBlock)2 VariableWidthBlock (com.facebook.presto.common.block.VariableWidthBlock)2 Type (com.facebook.presto.common.type.Type)2 DriverYieldSignal (com.facebook.presto.operator.DriverYieldSignal)2