Search in sources :

Example 1 with DataPageV2

use of com.facebook.presto.parquet.DataPageV2 in project presto by prestodb.

the class PageReader method readPage.

public DataPage readPage() {
    if (compressedPages.isEmpty()) {
        return null;
    }
    DataPage compressedPage = compressedPages.removeFirst();
    try {
        long firstRowIndex = getFirstRowIndex(pageIndex, offsetIndex);
        pageIndex = pageIndex + 1;
        if (compressedPage instanceof DataPageV1) {
            DataPageV1 dataPageV1 = (DataPageV1) compressedPage;
            Slice slice = decompress(codec, dataPageV1.getSlice(), dataPageV1.getUncompressedSize());
            return new DataPageV1(slice, dataPageV1.getValueCount(), dataPageV1.getUncompressedSize(), firstRowIndex, dataPageV1.getStatistics(), dataPageV1.getRepetitionLevelEncoding(), dataPageV1.getDefinitionLevelEncoding(), dataPageV1.getValueEncoding());
        } else {
            DataPageV2 dataPageV2 = (DataPageV2) compressedPage;
            if (!dataPageV2.isCompressed()) {
                return dataPageV2;
            }
            int uncompressedSize = toIntExact(dataPageV2.getUncompressedSize() - dataPageV2.getDefinitionLevels().length() - dataPageV2.getRepetitionLevels().length());
            Slice slice = decompress(codec, dataPageV2.getSlice(), uncompressedSize);
            return new DataPageV2(dataPageV2.getRowCount(), dataPageV2.getNullCount(), dataPageV2.getValueCount(), firstRowIndex, dataPageV2.getRepetitionLevels(), dataPageV2.getDefinitionLevels(), dataPageV2.getDataEncoding(), slice, dataPageV2.getUncompressedSize(), dataPageV2.getStatistics(), false);
        }
    } catch (IOException e) {
        throw new RuntimeException("Could not decompress page", e);
    }
}
Also used : DataPage(com.facebook.presto.parquet.DataPage) Slice(io.airlift.slice.Slice) DataPageV2(com.facebook.presto.parquet.DataPageV2) DataPageV1(com.facebook.presto.parquet.DataPageV1) IOException(java.io.IOException)

Example 2 with DataPageV2

use of com.facebook.presto.parquet.DataPageV2 in project presto by prestodb.

the class ParquetColumnChunk method readDataPageV2.

private long readDataPageV2(PageHeader pageHeader, int uncompressedPageSize, int compressedPageSize, long firstRowIndex, List<DataPage> 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 DataPageV2(dataHeaderV2.getNum_rows(), dataHeaderV2.getNum_nulls(), dataHeaderV2.getNum_values(), firstRowIndex, getSlice(dataHeaderV2.getRepetition_levels_byte_length()), getSlice(dataHeaderV2.getDefinition_levels_byte_length()), getParquetEncoding(Encoding.valueOf(dataHeaderV2.getEncoding().name())), getSlice(dataSize), uncompressedPageSize, MetadataReader.readStats(dataHeaderV2.getStatistics(), descriptor.getColumnDescriptor().getType()), dataHeaderV2.isIs_compressed()));
    return dataHeaderV2.getNum_values();
}
Also used : DataPageV2(com.facebook.presto.parquet.DataPageV2) DataPageHeaderV2(org.apache.parquet.format.DataPageHeaderV2)

Aggregations

DataPageV2 (com.facebook.presto.parquet.DataPageV2)2 DataPage (com.facebook.presto.parquet.DataPage)1 DataPageV1 (com.facebook.presto.parquet.DataPageV1)1 Slice (io.airlift.slice.Slice)1 IOException (java.io.IOException)1 DataPageHeaderV2 (org.apache.parquet.format.DataPageHeaderV2)1