use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class AggregationTestUtils method maskPagesWithRle.
// Adds the mask as the last channel
private static Page[] maskPagesWithRle(boolean maskValue, Page... pages) {
Page[] maskedPages = new Page[pages.length];
for (int i = 0; i < pages.length; i++) {
Page page = pages[i];
maskedPages[i] = page.appendColumn(new RunLengthEncodedBlock(BooleanType.createBlockForSingleNonNullValue(maskValue), page.getPositionCount()));
}
return maskedPages;
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
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 com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class SliceDirectSelectiveStreamReader method getBlockView.
@Override
public BlockLease getBlockView(int[] positions, int positionCount) {
checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero");
checkState(outputRequired, "This stream reader doesn't produce output");
checkState(positionCount <= outputPositionCount, "Not enough values");
checkState(!valuesInUse, "BlockLease hasn't been closed yet");
if (allNulls) {
return newLease(new RunLengthEncodedBlock(outputType.createBlockBuilder(null, 1).appendNull().build(), positionCount));
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount != outputPositionCount) {
compactValues(positions, positionCount, includeNulls);
}
return newLease(new VariableWidthBlock(positionCount, dataAsSlice, offsets, Optional.ofNullable(includeNulls ? nulls : null)));
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class SliceDirectSelectiveStreamReader method getBlock.
@Override
public Block getBlock(int[] positions, int positionCount) {
checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero");
checkState(outputRequired, "This stream reader doesn't produce output");
checkState(positionCount <= outputPositionCount, "Not enough values");
checkState(!valuesInUse, "BlockLease hasn't been closed yet");
if (allNulls) {
return new RunLengthEncodedBlock(outputType.createBlockBuilder(null, 1).appendNull().build(), positionCount);
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount != outputPositionCount) {
compactValues(positions, positionCount, includeNulls);
}
Block block = new VariableWidthBlock(positionCount, dataAsSlice, offsets, Optional.ofNullable(includeNulls ? nulls : null));
dataAsSlice = null;
data = null;
offsets = null;
nulls = null;
return block;
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class TimestampSelectiveStreamReader method getBlock.
@Override
public Block getBlock(int[] positions, int positionCount) {
checkArgument(outputPositionCount > 0, "outputPositionCount must be greater than zero");
checkState(outputRequired, "This stream reader doesn't produce output");
checkState(positionCount <= outputPositionCount, "Not enough values");
checkState(!valuesInUse, "BlockLease hasn't been closed yet");
if (allNulls) {
return new RunLengthEncodedBlock(NULL_BLOCK, positionCount);
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount == outputPositionCount) {
Block block = new LongArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values);
nulls = null;
values = null;
return block;
}
long[] valuesCopy = new long[positionCount];
boolean[] nullsCopy = null;
if (includeNulls) {
nullsCopy = new boolean[positionCount];
}
int positionIndex = 0;
int nextPosition = positions[positionIndex];
for (int i = 0; i < outputPositionCount; i++) {
if (outputPositions[i] < nextPosition) {
continue;
}
assert outputPositions[i] == nextPosition;
valuesCopy[positionIndex] = this.values[i];
if (nullsCopy != null) {
nullsCopy[positionIndex] = this.nulls[i];
}
positionIndex++;
if (positionIndex >= positionCount) {
break;
}
nextPosition = positions[positionIndex];
}
return new LongArrayBlock(positionCount, Optional.ofNullable(nullsCopy), valuesCopy);
}
Aggregations