Search in sources :

Example 1 with PrestoSparkRowOutputFactory

use of com.facebook.presto.spark.execution.PrestoSparkRowOutputOperator.PrestoSparkRowOutputFactory in project presto by prestodb.

the class PrestoSparkTaskExecutorFactory method configureOutput.

@SuppressWarnings("unchecked")
private static <T extends PrestoSparkTaskOutput> Output<T> configureOutput(Class<T> outputType, BlockEncodingManager blockEncodingManager, OutputBufferMemoryManager memoryManager, DataSize targetAverageRowSize, Optional<OutputPartitioning> preDeterminedPartition, TempStorage tempStorage, TempDataOperationContext tempDataOperationContext, DataSize writeBufferSize) {
    if (outputType.equals(PrestoSparkMutableRow.class)) {
        PrestoSparkOutputBuffer<PrestoSparkRowBatch> outputBuffer = new PrestoSparkOutputBuffer<>(memoryManager);
        OutputFactory outputFactory = new PrestoSparkRowOutputFactory(outputBuffer, targetAverageRowSize, preDeterminedPartition);
        OutputSupplier<T> outputSupplier = (OutputSupplier<T>) new RowOutputSupplier(outputBuffer);
        return new Output<>(OutputBufferType.SPARK_ROW_OUTPUT_BUFFER, outputBuffer, outputFactory, outputSupplier);
    } else if (outputType.equals(PrestoSparkSerializedPage.class)) {
        PrestoSparkOutputBuffer<PrestoSparkBufferedSerializedPage> outputBuffer = new PrestoSparkOutputBuffer<>(memoryManager);
        OutputFactory outputFactory = new PrestoSparkPageOutputFactory(outputBuffer, blockEncodingManager);
        OutputSupplier<T> outputSupplier = (OutputSupplier<T>) new PageOutputSupplier(outputBuffer);
        return new Output<>(OutputBufferType.SPARK_PAGE_OUTPUT_BUFFER, outputBuffer, outputFactory, outputSupplier);
    } else if (outputType.equals(PrestoSparkStorageHandle.class)) {
        PrestoSparkOutputBuffer<PrestoSparkBufferedSerializedPage> outputBuffer = new PrestoSparkOutputBuffer<>(memoryManager);
        OutputFactory outputFactory = new PrestoSparkPageOutputFactory(outputBuffer, blockEncodingManager);
        OutputSupplier<T> outputSupplier = (OutputSupplier<T>) new DiskPageOutputSupplier(outputBuffer, tempStorage, tempDataOperationContext, writeBufferSize);
        return new Output<>(OutputBufferType.SPARK_DISK_PAGE_OUTPUT_BUFFER, outputBuffer, outputFactory, outputSupplier);
    } else {
        throw new IllegalArgumentException("Unexpected output type: " + outputType.getName());
    }
}
Also used : PrestoSparkRowOutputFactory(com.facebook.presto.spark.execution.PrestoSparkRowOutputOperator.PrestoSparkRowOutputFactory) PrestoSparkUtils.toPrestoSparkSerializedPage(com.facebook.presto.spark.util.PrestoSparkUtils.toPrestoSparkSerializedPage) PrestoSparkSerializedPage(com.facebook.presto.spark.classloader_interface.PrestoSparkSerializedPage) PrestoSparkPageOutputFactory(com.facebook.presto.spark.execution.PrestoSparkPageOutputOperator.PrestoSparkPageOutputFactory) PageDataOutput(com.facebook.presto.spi.page.PageDataOutput) PrestoSparkTaskOutput(com.facebook.presto.spark.classloader_interface.PrestoSparkTaskOutput) DataOutput(com.facebook.presto.common.io.DataOutput) PrestoSparkPageOutputFactory(com.facebook.presto.spark.execution.PrestoSparkPageOutputOperator.PrestoSparkPageOutputFactory) PrestoSparkRowOutputFactory(com.facebook.presto.spark.execution.PrestoSparkRowOutputOperator.PrestoSparkRowOutputFactory) OutputFactory(com.facebook.presto.operator.OutputFactory)

Aggregations

DataOutput (com.facebook.presto.common.io.DataOutput)1 OutputFactory (com.facebook.presto.operator.OutputFactory)1 PrestoSparkSerializedPage (com.facebook.presto.spark.classloader_interface.PrestoSparkSerializedPage)1 PrestoSparkTaskOutput (com.facebook.presto.spark.classloader_interface.PrestoSparkTaskOutput)1 PrestoSparkPageOutputFactory (com.facebook.presto.spark.execution.PrestoSparkPageOutputOperator.PrestoSparkPageOutputFactory)1 PrestoSparkRowOutputFactory (com.facebook.presto.spark.execution.PrestoSparkRowOutputOperator.PrestoSparkRowOutputFactory)1 PrestoSparkUtils.toPrestoSparkSerializedPage (com.facebook.presto.spark.util.PrestoSparkUtils.toPrestoSparkSerializedPage)1 PageDataOutput (com.facebook.presto.spi.page.PageDataOutput)1