use of com.facebook.presto.grpc.udf.GrpcUdfResult in project presto by prestodb.
the class EchoFirstInputGrpcUdfService method invokeUdf.
@Override
public void invokeUdf(GrpcUdfRequest request, StreamObserver<GrpcUdfResult> responseObserver) {
GrpcUdfPage grpcUdfPage = request.getInputs();
GrpcUdfPage result;
switch(grpcUdfPage.getGrpcUdfPageFormat()) {
case Presto:
Page prestoPage = toPrestoPage(blockEncodingSerde, grpcUdfPage.getGrpcSerializedPage());
if (prestoPage.getPositionCount() == 0) {
new UnsupportedOperationException("No input to echo");
}
GrpcSerializedPage grpcSerializedPage = toGrpcSerializedPage(blockEncodingSerde, new Page(prestoPage.getBlock(0)));
result = toGrpcUdfPage(Presto, grpcSerializedPage);
break;
default:
throw new UnsupportedOperationException();
}
GrpcUdfResult grpcUdfResult = GrpcUdfResult.newBuilder().setResult(result).setUdfStats(GrpcUdfStats.newBuilder().setTotalCpuTimeMs(100).build()).build();
responseObserver.onNext(grpcUdfResult);
responseObserver.onCompleted();
}
Aggregations