use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.
the class TestApproximatePercentileAggregation method createRLEBlock.
private static RunLengthEncodedBlock createRLEBlock(Iterable<Double> percentiles, int positionCount) {
BlockBuilder rleBlockBuilder = new ArrayType(DOUBLE).createBlockBuilder(null, 1);
BlockBuilder arrayBlockBuilder = rleBlockBuilder.beginBlockEntry();
for (double percentile : percentiles) {
DOUBLE.writeDouble(arrayBlockBuilder, percentile);
}
rleBlockBuilder.closeEntry();
return new RunLengthEncodedBlock(rleBlockBuilder.build(), positionCount);
}
use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.
the class TestApproximatePercentileAggregation method createRLEBlock.
private static RunLengthEncodedBlock createRLEBlock(double percentile, int positionCount) {
BlockBuilder blockBuilder = DOUBLE.createBlockBuilder(null, 1);
DOUBLE.writeDouble(blockBuilder, percentile);
return new RunLengthEncodedBlock(blockBuilder.build(), positionCount);
}
use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.
the class TestPartitionedOutputOperator method testPartitionPositionsWithRleNullWithNullChannel.
@Test
public void testPartitionPositionsWithRleNullWithNullChannel() {
PartitionedOutputOperator partitionedOutputOperator = partitionedOutputOperator(BIGINT, BIGINT).withNullChannel(0).build();
Page page = new Page(new RunLengthEncodedBlock(createLongsBlock((Long) null), POSITIONS_PER_PAGE), createLongSequenceBlock(0, POSITIONS_PER_PAGE));
processPages(partitionedOutputOperator, page);
List<Object> partition0 = readLongs(outputBuffer.getEnqueuedDeserialized(0), 1);
assertThat(partition0).containsExactlyElementsOf(readLongs(Stream.of(page), 1));
List<Object> partition1 = readLongs(outputBuffer.getEnqueuedDeserialized(1), 1);
assertThat(partition1).containsExactlyElementsOf(readLongs(Stream.of(page), 1));
}
use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.
the class TestDictionaryAwarePageProjection method testRleBlockWithFailure.
@Test(dataProvider = "forceYield")
public void testRleBlockWithFailure(boolean forceYield, boolean produceLazyBlock) {
Block value = createLongSequenceBlock(-43, -42);
RunLengthEncodedBlock block = new RunLengthEncodedBlock(value, 100);
testProjectFails(block, RunLengthEncodedBlock.class, forceYield, produceLazyBlock);
}
use of io.trino.spi.block.RunLengthEncodedBlock in project trino by trinodb.
the class DeltaLakePageSource method getNextPage.
@Override
public Page getNextPage() {
try {
Page dataPage = delegate.getNextPage();
if (dataPage == null) {
return null;
}
int batchSize = dataPage.getPositionCount();
Block[] blocks = new Block[prefilledBlocks.length];
for (int i = 0; i < prefilledBlocks.length; i++) {
if (prefilledBlocks[i] != null) {
blocks[i] = new RunLengthEncodedBlock(prefilledBlocks[i], batchSize);
} else {
blocks[i] = dataPage.getBlock(delegateIndexes[i]);
}
}
return new Page(batchSize, blocks);
} catch (RuntimeException e) {
closeWithSuppression(e);
throwIfInstanceOf(e, TrinoException.class);
throw new TrinoException(DELTA_LAKE_BAD_DATA, e);
}
}
Aggregations