use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class LongDirectSelectiveStreamReader 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");
if (allNulls) {
return newLease(new RunLengthEncodedBlock(outputType.createBlockBuilder(null, 1).appendNull().build(), positionCount));
}
return buildOutputBlockView(positions, positionCount, nullsAllowed && presentStream != null);
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class TimestampSelectiveStreamReader 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 LongArrayBlock(positionCount, Optional.ofNullable(includeNulls ? nulls : null), values));
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class OrcFileWriter method appendRows.
@Override
public void appendRows(Page dataPage) {
Block[] blocks = new Block[fileInputColumnIndexes.length];
for (int i = 0; i < fileInputColumnIndexes.length; i++) {
int inputColumnIndex = fileInputColumnIndexes[i];
if (inputColumnIndex < 0) {
blocks[i] = new RunLengthEncodedBlock(nullBlocks.get(i), dataPage.getPositionCount());
} else {
blocks[i] = dataPage.getBlock(inputColumnIndex);
}
}
Page page = new Page(dataPage.getPositionCount(), blocks);
try {
orcWriter.write(page);
rowCount += page.getPositionCount();
} catch (IOException | UncheckedIOException e) {
throw new PrestoException(HIVE_WRITER_DATA_ERROR, e);
}
}
use of com.facebook.presto.common.block.RunLengthEncodedBlock in project presto by prestodb.
the class ByteSelectiveStreamReader 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 SliceDictionarySelectiveReader 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));
}
if (positionCount < outputPositionCount) {
compactValues(positions, positionCount);
}
wrapDictionaryIfNecessary();
return newLease(new DictionaryBlock(positionCount, dictionary, values));
}
Aggregations