use of com.facebook.presto.common.function.SqlFunctionResult in project presto by prestodb.
the class RemoteProjectOperator method addInput.
@Override
public void addInput(Page page) {
checkState(!finishing, "Operator is already finishing");
checkState(!processingPage(), "Still processing previous input");
requireNonNull(page, "page is null");
for (int channel = 0; channel < projections.size(); channel++) {
RowExpression projection = projections.get(channel);
if (projection instanceof InputReferenceExpression) {
result[channel] = completedFuture(new SqlFunctionResult(page.getBlock(((InputReferenceExpression) projection).getField()), 0));
} else if (projection instanceof CallExpression) {
CallExpression remoteCall = (CallExpression) projection;
result[channel] = functionAndTypeManager.executeFunction(operatorContext.getDriverContext().getTaskId().toString(), remoteCall.getFunctionHandle(), page, remoteCall.getArguments().stream().map(InputReferenceExpression.class::cast).map(InputReferenceExpression::getField).collect(toImmutableList()));
} else {
checkState(projection instanceof ConstantExpression, format("Does not expect expression type %s", projection.getClass()));
}
}
}
use of com.facebook.presto.common.function.SqlFunctionResult in project presto by prestodb.
the class GrpcSqlFunctionExecutor method toSqlFunctionResult.
private SqlFunctionResult toSqlFunctionResult(GrpcUdfResult grpcUdfResult) {
checkState(blockEncodingSerde != null, "blockEncodingSerde not set");
GrpcUdfPage grpcUdfPage = grpcUdfResult.getResult();
switch(grpcUdfPage.getGrpcUdfPageFormat()) {
case Presto:
Page resultPage = toPrestoPage(blockEncodingSerde, grpcUdfPage.getGrpcSerializedPage());
return new SqlFunctionResult(resultPage.getBlock(0), grpcUdfResult.getUdfStats().getTotalCpuTimeMs());
default:
throw new IllegalArgumentException(format("Unknown page format: %s", grpcUdfPage.getGrpcUdfPageFormat()));
}
}
use of com.facebook.presto.common.function.SqlFunctionResult in project presto by prestodb.
the class ThriftSqlFunctionExecutor method toSqlFunctionResult.
private SqlFunctionResult toSqlFunctionResult(ThriftUdfResult result, Type returnType) {
ThriftUdfPage page = result.getResult();
switch(page.getPageFormat()) {
case PRESTO_THRIFT:
return new SqlFunctionResult(getOnlyElement(page.getThriftPage().getThriftBlocks()).toBlock(returnType), result.getUdfStats().getTotalCpuTimeMs());
case PRESTO_SERIALIZED:
checkState(blockEncodingSerde != null, "blockEncodingSerde not set");
PagesSerde pagesSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
return new SqlFunctionResult(pagesSerde.deserialize(page.getPrestoPage().toSerializedPage()).getBlock(0), result.getUdfStats().getTotalCpuTimeMs());
default:
throw new IllegalArgumentException(format("Unknown page format: %s", page.getPageFormat()));
}
}
Aggregations