use of com.facebook.presto.thrift.api.udf.ThriftUdfPageFormat in project presto by prestodb.
the class ThriftSqlFunctionExecutor method buildThriftPage.
private ThriftUdfPage buildThriftPage(RemoteScalarFunctionImplementation functionImplementation, Page input, List<Integer> channels, List<Type> argumentTypes) {
ThriftUdfPageFormat pageFormat = executionConfigs.get(functionImplementation.getLanguage()).getThriftPageFormat();
Block[] blocks = new Block[channels.size()];
for (int i = 0; i < channels.size(); i++) {
blocks[i] = input.getBlock(channels.get(i));
}
switch(pageFormat) {
case PRESTO_THRIFT:
ImmutableList.Builder<PrestoThriftBlock> thriftBlocks = ImmutableList.builder();
for (int i = 0; i < blocks.length; i++) {
thriftBlocks.add(PrestoThriftBlock.fromBlock(blocks[i], argumentTypes.get(i)));
}
return thriftPage(new PrestoThriftPage(thriftBlocks.build(), input.getPositionCount()));
case PRESTO_SERIALIZED:
checkState(blockEncodingSerde != null, "blockEncodingSerde not set");
PagesSerde pagesSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
return prestoPage(pagesSerde.serialize(wrapBlocksWithoutCopy(input.getPositionCount(), blocks)));
default:
throw new IllegalArgumentException(format("Unknown page format: %s", pageFormat));
}
}
Aggregations