use of com.facebook.presto.common.block.VariableWidthBlock 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.VariableWidthBlock in project presto by prestodb.
the class SliceDictionaryBatchStreamReader method setDictionaryBlockData.
private void setDictionaryBlockData(byte[] dictionaryData, int[] dictionaryOffsets, int positionCount) {
verify(positionCount > 0);
// the engine currently uses identity equality to test if dictionaries are the same
if (currentDictionaryData != dictionaryData) {
boolean[] isNullVector = new boolean[positionCount];
isNullVector[positionCount - 1] = true;
dictionaryOffsets[positionCount] = dictionaryOffsets[positionCount - 1];
dictionaryBlock = new VariableWidthBlock(positionCount, wrappedBuffer(dictionaryData), dictionaryOffsets, Optional.of(isNullVector));
currentDictionaryData = dictionaryData;
}
}
use of com.facebook.presto.common.block.VariableWidthBlock in project presto by prestodb.
the class TestOptimizedPartitionedOutputOperator method createVariableWidthBlockOverSliceView.
private static Block createVariableWidthBlockOverSliceView(int entries) {
// Create a slice view whose address starts in the middle of the original slice, and length is half of original slice
DynamicSliceOutput dynamicSliceOutput = new DynamicSliceOutput(entries * 2);
for (int i = 0; i < entries * 2; i++) {
dynamicSliceOutput.writeByte(i);
}
Slice slice = dynamicSliceOutput.slice().slice(entries, entries);
int[] offsets = IntStream.range(0, entries + 1).toArray();
return new VariableWidthBlock(entries, slice, offsets, Optional.empty());
}
Aggregations