use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.
the class AssignUniqueIdOperator method generateIdColumn.
private Block generateIdColumn() {
BlockBuilder block = BIGINT.createFixedSizeBlockBuilder(inputPage.getPositionCount());
for (int currentPosition = 0; currentPosition < inputPage.getPositionCount(); currentPosition++) {
if (rowIdCounter >= maxRowIdCounterValue) {
requestValues();
}
long rowId = rowIdCounter++;
verify((rowId & uniqueValueMask) == 0, "RowId and uniqueValue mask overlaps");
BIGINT.writeLong(block, uniqueValueMask | rowId);
}
return block.build();
}
use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.
the class BigintGroupByHash method appendValuesTo.
@Override
public void appendValuesTo(int groupId, PageBuilder pageBuilder, int outputChannelOffset) {
checkArgument(groupId >= 0, "groupId is negative");
BlockBuilder blockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset);
if (groupId == nullGroupId) {
blockBuilder.appendNull();
} else {
BIGINT.writeLong(blockBuilder, valuesByGroupId.get(groupId));
}
if (outputRawHash) {
BlockBuilder hashBlockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset + 1);
if (groupId == nullGroupId) {
BIGINT.writeLong(hashBlockBuilder, NULL_HASH_CODE);
} else {
BIGINT.writeLong(hashBlockBuilder, BigintOperators.hashCode(valuesByGroupId.get(groupId)));
}
}
}
use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.
the class BigintGroupByHash method getGroupIds.
@Override
public GroupByIdBlock getGroupIds(Page page) {
int positionCount = page.getPositionCount();
// we know the exact size required for the block
BlockBuilder blockBuilder = BIGINT.createFixedSizeBlockBuilder(positionCount);
// get the group id for each position
Block block = page.getBlock(hashChannel);
for (int position = 0; position < positionCount; position++) {
// get the group for the current row
int groupId = putIfAbsent(position, block);
// output the group id for this row
BIGINT.writeLong(blockBuilder, groupId);
}
return new GroupByIdBlock(nextGroupId, blockBuilder.build());
}
use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.
the class DeleteOperator method getOutput.
@Override
public Page getOutput() {
if ((state != State.FINISHING) || !finishFuture.isDone()) {
return null;
}
state = State.FINISHED;
Collection<Slice> fragments = getFutureValue(finishFuture);
PageBuilder page = new PageBuilder(TYPES);
BlockBuilder rowsBuilder = page.getBlockBuilder(0);
BlockBuilder fragmentBuilder = page.getBlockBuilder(1);
// write row count
page.declarePosition();
BIGINT.writeLong(rowsBuilder, rowCount);
fragmentBuilder.appendNull();
// write fragments
for (Slice fragment : fragments) {
page.declarePosition();
rowsBuilder.appendNull();
VARBINARY.writeSlice(fragmentBuilder, fragment);
}
return page.build();
}
use of com.facebook.presto.spi.block.BlockBuilder in project presto by prestodb.
the class MapUnnester method appendTo.
protected void appendTo(PageBuilder pageBuilder, int outputChannelOffset) {
BlockBuilder keyBlockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset);
BlockBuilder valueBlockBuilder = pageBuilder.getBlockBuilder(outputChannelOffset + 1);
keyType.appendTo(block, position++, keyBlockBuilder);
valueType.appendTo(block, position++, valueBlockBuilder);
}
Aggregations