use of io.trino.spi.block.SingleRowBlockWriter 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