Search in sources :

Example 1 with ParquetDataPageV2

use of com.facebook.presto.hive.parquet.ParquetDataPageV2 in project presto by prestodb.

the class ParquetColumnChunk method readDataPageV2.

private long readDataPageV2(PageHeader pageHeader, int uncompressedPageSize, int compressedPageSize, List<ParquetDataPage> pages) throws IOException {
    DataPageHeaderV2 dataHeaderV2 = pageHeader.getData_page_header_v2();
    int dataSize = compressedPageSize - dataHeaderV2.getRepetition_levels_byte_length() - dataHeaderV2.getDefinition_levels_byte_length();
    pages.add(new ParquetDataPageV2(dataHeaderV2.getNum_rows(), dataHeaderV2.getNum_nulls(), dataHeaderV2.getNum_values(), getSlice(dataHeaderV2.getRepetition_levels_byte_length()), getSlice(dataHeaderV2.getDefinition_levels_byte_length()), getParquetEncoding(Encoding.valueOf(dataHeaderV2.getEncoding().name())), getSlice(dataSize), uncompressedPageSize, ParquetMetadataReader.readStats(dataHeaderV2.getStatistics(), descriptor.getColumnDescriptor().getType()), dataHeaderV2.isIs_compressed()));
    return dataHeaderV2.getNum_values();
}
Also used : ParquetDataPageV2(com.facebook.presto.hive.parquet.ParquetDataPageV2) DataPageHeaderV2(parquet.format.DataPageHeaderV2)

Example 2 with ParquetDataPageV2

use of com.facebook.presto.hive.parquet.ParquetDataPageV2 in project presto by prestodb.

the class ParquetPageReader method readPage.

public ParquetDataPage readPage() {
    if (compressedPages.isEmpty()) {
        return null;
    }
    ParquetDataPage compressedPage = compressedPages.remove(0);
    try {
        if (compressedPage instanceof ParquetDataPageV1) {
            ParquetDataPageV1 dataPageV1 = (ParquetDataPageV1) compressedPage;
            return new ParquetDataPageV1(decompress(codec, dataPageV1.getSlice(), dataPageV1.getUncompressedSize()), dataPageV1.getValueCount(), dataPageV1.getUncompressedSize(), dataPageV1.getStatistics(), dataPageV1.getRepetitionLevelEncoding(), dataPageV1.getDefinitionLevelEncoding(), dataPageV1.getValueEncoding());
        } else {
            ParquetDataPageV2 dataPageV2 = (ParquetDataPageV2) compressedPage;
            if (!dataPageV2.isCompressed()) {
                return dataPageV2;
            }
            int uncompressedSize = toIntExact(dataPageV2.getUncompressedSize() - dataPageV2.getDefinitionLevels().length() - dataPageV2.getRepetitionLevels().length());
            return new ParquetDataPageV2(dataPageV2.getRowCount(), dataPageV2.getNullCount(), dataPageV2.getValueCount(), dataPageV2.getRepetitionLevels(), dataPageV2.getDefinitionLevels(), dataPageV2.getDataEncoding(), decompress(codec, dataPageV2.getSlice(), uncompressedSize), dataPageV2.getUncompressedSize(), dataPageV2.getStatistics(), false);
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not decompress page", e);
    }
}
Also used : ParquetDataPageV1(com.facebook.presto.hive.parquet.ParquetDataPageV1) ParquetDataPage(com.facebook.presto.hive.parquet.ParquetDataPage) ParquetDataPageV2(com.facebook.presto.hive.parquet.ParquetDataPageV2) IOException(java.io.IOException)

Aggregations

ParquetDataPageV2 (com.facebook.presto.hive.parquet.ParquetDataPageV2)2 ParquetDataPage (com.facebook.presto.hive.parquet.ParquetDataPage)1 ParquetDataPageV1 (com.facebook.presto.hive.parquet.ParquetDataPageV1)1 IOException (java.io.IOException)1 DataPageHeaderV2 (parquet.format.DataPageHeaderV2)1