Search in sources :

Example 1 with GrpcUdfResult

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();
}
Also used : GrpcUdfResult(com.facebook.presto.grpc.udf.GrpcUdfResult) GrpcUtils.toGrpcUdfPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcUdfPage) GrpcUdfPage(com.facebook.presto.grpc.udf.GrpcUdfPage) Page(com.facebook.presto.common.Page) GrpcSerializedPage(com.facebook.presto.grpc.udf.GrpcSerializedPage) GrpcUtils.toPrestoPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toPrestoPage) GrpcUtils.toGrpcUdfPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcUdfPage) GrpcUtils.toGrpcSerializedPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcSerializedPage) GrpcUdfPage(com.facebook.presto.grpc.udf.GrpcUdfPage) GrpcSerializedPage(com.facebook.presto.grpc.udf.GrpcSerializedPage) GrpcUtils.toGrpcSerializedPage(com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcSerializedPage)

Aggregations

Page (com.facebook.presto.common.Page)1 GrpcUtils.toGrpcSerializedPage (com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcSerializedPage)1 GrpcUtils.toGrpcUdfPage (com.facebook.presto.grpc.api.udf.GrpcUtils.toGrpcUdfPage)1 GrpcUtils.toPrestoPage (com.facebook.presto.grpc.api.udf.GrpcUtils.toPrestoPage)1 GrpcSerializedPage (com.facebook.presto.grpc.udf.GrpcSerializedPage)1 GrpcUdfPage (com.facebook.presto.grpc.udf.GrpcUdfPage)1 GrpcUdfResult (com.facebook.presto.grpc.udf.GrpcUdfResult)1