Search in sources :

Example 1 with InflateDecompressor

use of com.facebook.presto.orc.zlib.InflateDecompressor in project presto by prestodb.

the class PageFileWriterFactory method createPagesSerdeForPageFile.

public static PagesSerde createPagesSerdeForPageFile(BlockEncodingSerde blockEncodingSerde, Optional<HiveCompressionCodec> compressionCodec) {
    if (!compressionCodec.isPresent()) {
        return new PagesSerde(blockEncodingSerde, Optional.empty(), Optional.empty(), Optional.empty());
    }
    PageCompressor pageCompressor = null;
    PageDecompressor pageDecompressor = null;
    switch(compressionCodec.get()) {
        case NONE:
            break;
        case SNAPPY:
            pageCompressor = new AirliftCompressorAdapter(new SnappyCompressor());
            pageDecompressor = new AirliftDecompressorAdapter(new SnappyDecompressor());
            break;
        case LZ4:
            pageCompressor = new AirliftCompressorAdapter(new Lz4Compressor());
            pageDecompressor = new AirliftDecompressorAdapter(new Lz4Decompressor());
            break;
        case GZIP:
            pageCompressor = new AirliftCompressorAdapter(new DeflateCompressor(OptionalInt.empty()));
            pageDecompressor = new AirliftDecompressorAdapter(new InflateDecompressor());
            break;
        case ZSTD:
            pageCompressor = new AirliftCompressorAdapter(new ZstdJniCompressor(OptionalInt.empty()));
            pageDecompressor = new AirliftDecompressorAdapter(new ZstdJniDecompressor());
            break;
        default:
            throw new PrestoException(GENERIC_INTERNAL_ERROR, format("%s compression is not supported for %s", compressionCodec.get().name(), PAGEFILE.getOutputFormat()));
    }
    return new PagesSerde(blockEncodingSerde, Optional.ofNullable(pageCompressor), Optional.ofNullable(pageDecompressor), Optional.empty());
}
Also used : PageCompressor(com.facebook.presto.spi.page.PageCompressor) Lz4Compressor(io.airlift.compress.lz4.Lz4Compressor) DeflateCompressor(com.facebook.presto.orc.zlib.DeflateCompressor) PrestoException(com.facebook.presto.spi.PrestoException) SnappyDecompressor(io.airlift.compress.snappy.SnappyDecompressor) PagesSerde(com.facebook.presto.spi.page.PagesSerde) SnappyCompressor(io.airlift.compress.snappy.SnappyCompressor) Lz4Decompressor(io.airlift.compress.lz4.Lz4Decompressor) InflateDecompressor(com.facebook.presto.orc.zlib.InflateDecompressor) ZstdJniDecompressor(com.facebook.presto.orc.zstd.ZstdJniDecompressor) ZstdJniCompressor(com.facebook.presto.orc.zstd.ZstdJniCompressor) PageDecompressor(com.facebook.presto.spi.page.PageDecompressor)

Aggregations

DeflateCompressor (com.facebook.presto.orc.zlib.DeflateCompressor)1 InflateDecompressor (com.facebook.presto.orc.zlib.InflateDecompressor)1 ZstdJniCompressor (com.facebook.presto.orc.zstd.ZstdJniCompressor)1 ZstdJniDecompressor (com.facebook.presto.orc.zstd.ZstdJniDecompressor)1 PrestoException (com.facebook.presto.spi.PrestoException)1 PageCompressor (com.facebook.presto.spi.page.PageCompressor)1 PageDecompressor (com.facebook.presto.spi.page.PageDecompressor)1 PagesSerde (com.facebook.presto.spi.page.PagesSerde)1 Lz4Compressor (io.airlift.compress.lz4.Lz4Compressor)1 Lz4Decompressor (io.airlift.compress.lz4.Lz4Decompressor)1 SnappyCompressor (io.airlift.compress.snappy.SnappyCompressor)1 SnappyDecompressor (io.airlift.compress.snappy.SnappyDecompressor)1