use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class AbstractDecimalSelectiveStreamReader 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(nullBlock, positionCount);
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount == outputPositionCount) {
Block block = makeBlock(positionCount, nullsAllowed, nulls, values);
nulls = null;
values = null;
return block;
}
long[] valuesCopy = new long[valuesPerPosition * positionCount];
boolean[] nullsCopy = null;
if (includeNulls) {
nullsCopy = new boolean[positionCount];
}
copyValues(positions, positionCount, valuesCopy, nullsCopy);
return makeBlock(positionCount, includeNulls, nullsCopy, valuesCopy);
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class BooleanSelectiveStreamReader 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(NULL_BLOCK, positionCount));
}
boolean includeNulls = nullsAllowed && presentStream != null;
if (positionCount != outputPositionCount) {
compactValues(positions, positionCount, includeNulls);
}
return newLease(new ByteArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values));
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class BooleanSelectiveStreamReader 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 ByteArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values);
nulls = null;
values = null;
return block;
}
byte[] valuesCopy = new byte[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 ByteArrayBlock(positionCount, Optional.ofNullable(nullsCopy), valuesCopy);
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class TestColumnarArray method assertRunLengthEncodedBlock.
private static <T> void assertRunLengthEncodedBlock(Block block, T[] expectedValues) {
for (int position = 0; position < block.getPositionCount(); position++) {
RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position);
T[] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position);
assertBlock(runLengthEncodedBlock, expectedDictionaryValues);
assertColumnarArray(runLengthEncodedBlock, expectedDictionaryValues);
}
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class TestColumnarRow method assertRunLengthEncodedBlock.
private static <T> void assertRunLengthEncodedBlock(Block block, T[] expectedValues) {
for (int position = 0; position < block.getPositionCount(); position++) {
RunLengthEncodedBlock runLengthEncodedBlock = createTestRleBlock(block, position);
T[] expectedDictionaryValues = createTestRleExpectedValues(expectedValues, position);
assertBlock(runLengthEncodedBlock, expectedDictionaryValues);
assertColumnarRow(runLengthEncodedBlock, expectedDictionaryValues);
}
}
Aggregations