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);
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations