Search in sources :

Example 11 with PagesSerde

use of com.facebook.presto.spi.page.PagesSerde in project presto by prestodb.

the class EchoFirstInputThriftUdfService method invokeUdf.

@Override
public ListenableFuture<ThriftUdfResult> invokeUdf(ThriftUdfRequest request) throws ThriftUdfServiceException {
    ThriftUdfPage inputs = request.getInputs();
    ThriftUdfPage result;
    switch(inputs.getPageFormat()) {
        case PRESTO_THRIFT:
            PrestoThriftPage thriftPage = inputs.getThriftPage();
            if (thriftPage.getThriftBlocks().isEmpty()) {
                throw toThriftUdfServiceException(false, EchoFirstInputErrorCode.GENERIC_INTERNAL_ERROR.toErrorCode(), new UnsupportedOperationException("No input to echo"));
            }
            result = thriftPage(new PrestoThriftPage(ImmutableList.of(thriftPage.getThriftBlocks().get(0)), inputs.getThriftPage().getPositionCount()));
            break;
        case PRESTO_SERIALIZED:
            PagesSerde pagesSerde = new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
            Page page = pagesSerde.deserialize(inputs.getPrestoPage().toSerializedPage());
            if (page.getChannelCount() == 0) {
                throw toThriftUdfServiceException(false, EchoFirstInputErrorCode.GENERIC_INTERNAL_ERROR.toErrorCode(), new UnsupportedOperationException("No input to echo"));
            }
            result = prestoPage(pagesSerde.serialize(new Page(page.getBlock(0))));
            break;
        default:
            throw new UnsupportedOperationException();
    }
    return immediateFuture(new ThriftUdfResult(result, new ThriftUdfStats(100)));
}
Also used : PrestoThriftPage(com.facebook.presto.thrift.api.udf.PrestoThriftPage) PagesSerde(com.facebook.presto.spi.page.PagesSerde) ThriftUdfStats(com.facebook.presto.thrift.api.udf.ThriftUdfStats) Page(com.facebook.presto.common.Page) ThriftUdfPage(com.facebook.presto.thrift.api.udf.ThriftUdfPage) ThriftUdfPage.prestoPage(com.facebook.presto.thrift.api.udf.ThriftUdfPage.prestoPage) ThriftUdfPage.thriftPage(com.facebook.presto.thrift.api.udf.ThriftUdfPage.thriftPage) PrestoThriftPage(com.facebook.presto.thrift.api.udf.PrestoThriftPage) ThriftUdfResult(com.facebook.presto.thrift.api.udf.ThriftUdfResult) ThriftUdfPage(com.facebook.presto.thrift.api.udf.ThriftUdfPage)

Aggregations

PagesSerde (com.facebook.presto.spi.page.PagesSerde)11 Page (com.facebook.presto.common.Page)4 SpillCipher (com.facebook.presto.spi.spiller.SpillCipher)3 Block (com.facebook.presto.common.block.Block)2 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)2 Type (com.facebook.presto.common.type.Type)2 PrestoException (com.facebook.presto.spi.PrestoException)2 SerializedPage (com.facebook.presto.spi.page.SerializedPage)2 PrestoThriftPage (com.facebook.presto.thrift.api.udf.PrestoThriftPage)2 ThriftUdfPage (com.facebook.presto.thrift.api.udf.ThriftUdfPage)2 DynamicSliceOutput (io.airlift.slice.DynamicSliceOutput)2 Test (org.testng.annotations.Test)2 SqlFunctionResult (com.facebook.presto.common.function.SqlFunctionResult)1 DataSink (com.facebook.presto.common.io.DataSink)1 TestingPagesSerdeFactory (com.facebook.presto.execution.buffer.TestingPagesSerdeFactory)1 GrpcSerializedPage (com.facebook.presto.grpc.udf.GrpcSerializedPage)1 HiveCompressionCodec (com.facebook.presto.hive.HiveCompressionCodec)1 DeflateCompressor (com.facebook.presto.orc.zlib.DeflateCompressor)1 InflateDecompressor (com.facebook.presto.orc.zlib.InflateDecompressor)1 ZstdJniCompressor (com.facebook.presto.orc.zstd.ZstdJniCompressor)1