use of io.trino.spi.block.RowBlockBuilder in project trino by trinodb.
the class OperatorAssertion method toRow.
public static Block toRow(List<Type> parameterTypes, Object... values) {
checkArgument(parameterTypes.size() == values.length, "parameterTypes.size(" + parameterTypes.size() + ") does not equal to values.length(" + values.length + ")");
RowType rowType = RowType.anonymous(parameterTypes);
BlockBuilder blockBuilder = new RowBlockBuilder(parameterTypes, null, 1);
BlockBuilder singleRowBlockWriter = blockBuilder.beginBlockEntry();
for (int i = 0; i < values.length; i++) {
appendToBlockBuilder(parameterTypes.get(i), values[i], singleRowBlockWriter);
}
blockBuilder.closeEntry();
return rowType.getObject(blockBuilder, 0);
}
use of io.trino.spi.block.RowBlockBuilder in project trino by trinodb.
the class CassandraType method buildUserTypeValue.
private Block buildUserTypeValue(GettableByIndexData row, int position) {
verify(this.kind == Kind.UDT, "Not a user defined type: %s", this.kind);
UDTValue udtValue = row.getUDTValue(position);
String[] fieldNames = udtValue.getType().getFieldNames().toArray(String[]::new);
RowBlockBuilder blockBuilder = (RowBlockBuilder) this.trinoType.createBlockBuilder(null, 1);
SingleRowBlockWriter singleRowBlockWriter = blockBuilder.beginBlockEntry();
int tuplePosition = 0;
for (CassandraType argumentType : this.getArgumentTypes()) {
int finalTuplePosition = tuplePosition;
NullableValue value = argumentType.getColumnValue(udtValue, tuplePosition, () -> udtValue.getType().getFieldType(fieldNames[finalTuplePosition]));
writeNativeValue(argumentType.getTrinoType(), singleRowBlockWriter, value.getValue());
tuplePosition++;
}
blockBuilder.closeEntry();
return (Block) this.trinoType.getObject(blockBuilder, 0);
}
Aggregations