Search in sources :

Example 1 with RequiresPreviousReader

use of org.apache.parquet.column.values.RequiresPreviousReader in project parquet-mr by apache.

the class ColumnReaderImpl method initDataReader.

private void initDataReader(Encoding dataEncoding, ByteBufferInputStream in, int valueCount) {
    ValuesReader previousReader = this.dataColumn;
    this.currentEncoding = dataEncoding;
    this.pageValueCount = valueCount;
    this.endOfPageValueCount = readValues + pageValueCount;
    if (dataEncoding.usesDictionary()) {
        if (dictionary == null) {
            throw new ParquetDecodingException("could not read page in col " + path + " as the dictionary was missing for encoding " + dataEncoding);
        }
        this.dataColumn = dataEncoding.getDictionaryBasedValuesReader(path, VALUES, dictionary);
    } else {
        this.dataColumn = dataEncoding.getValuesReader(path, VALUES);
    }
    if (dataEncoding.usesDictionary() && converter.hasDictionarySupport()) {
        bindToDictionary(dictionary);
    } else {
        bind(path.getType());
    }
    try {
        dataColumn.initFromPage(pageValueCount, in);
    } catch (IOException e) {
        throw new ParquetDecodingException("could not read page in col " + path, e);
    }
    if (CorruptDeltaByteArrays.requiresSequentialReads(writerVersion, dataEncoding) && previousReader != null && previousReader instanceof RequiresPreviousReader) {
        // previous reader can only be set if reading sequentially
        ((RequiresPreviousReader) dataColumn).setPreviousReader(previousReader);
    }
}
Also used : ValuesReader(org.apache.parquet.column.values.ValuesReader) ParquetDecodingException(org.apache.parquet.io.ParquetDecodingException) RequiresPreviousReader(org.apache.parquet.column.values.RequiresPreviousReader) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 RequiresPreviousReader (org.apache.parquet.column.values.RequiresPreviousReader)1 ValuesReader (org.apache.parquet.column.values.ValuesReader)1 ParquetDecodingException (org.apache.parquet.io.ParquetDecodingException)1