Search in sources :

Example 6 with InternalColumnDecryptionSetup

use of org.apache.parquet.crypto.InternalColumnDecryptionSetup in project parquet-mr by apache.

the class ParquetFileReader method readOffsetIndex.

/**
 * @param column
 *          the column chunk which the offset index is to be returned for
 * @return the offset index for the specified column chunk or {@code null} if there is no index
 * @throws IOException
 *           if any I/O error occurs during reading the file
 */
@Private
public OffsetIndex readOffsetIndex(ColumnChunkMetaData column) throws IOException {
    IndexReference ref = column.getOffsetIndexReference();
    if (ref == null) {
        return null;
    }
    f.seek(ref.getOffset());
    BlockCipher.Decryptor offsetIndexDecryptor = null;
    byte[] offsetIndexAAD = null;
    if (null != fileDecryptor && !fileDecryptor.plaintextFile()) {
        InternalColumnDecryptionSetup columnDecryptionSetup = fileDecryptor.getColumnSetup(column.getPath());
        if (columnDecryptionSetup.isEncrypted()) {
            offsetIndexDecryptor = columnDecryptionSetup.getMetaDataDecryptor();
            offsetIndexAAD = AesCipher.createModuleAAD(fileDecryptor.getFileAAD(), ModuleType.OffsetIndex, column.getRowGroupOrdinal(), columnDecryptionSetup.getOrdinal(), -1);
        }
    }
    return ParquetMetadataConverter.fromParquetOffsetIndex(Util.readOffsetIndex(f, offsetIndexDecryptor, offsetIndexAAD));
}
Also used : BlockCipher(org.apache.parquet.format.BlockCipher) InternalColumnDecryptionSetup(org.apache.parquet.crypto.InternalColumnDecryptionSetup) IndexReference(org.apache.parquet.internal.hadoop.metadata.IndexReference) Private(org.apache.yetus.audience.InterfaceAudience.Private)

Aggregations

InternalColumnDecryptionSetup (org.apache.parquet.crypto.InternalColumnDecryptionSetup)6 BlockCipher (org.apache.parquet.format.BlockCipher)4 IOException (java.io.IOException)2 ParquetCryptoRuntimeException (org.apache.parquet.crypto.ParquetCryptoRuntimeException)2 IndexReference (org.apache.parquet.internal.hadoop.metadata.IndexReference)2 Private (org.apache.yetus.audience.InterfaceAudience.Private)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 DictionaryPage (org.apache.parquet.column.page.DictionaryPage)1 BlockSplitBloomFilter (org.apache.parquet.column.values.bloomfilter.BlockSplitBloomFilter)1 BytesInputDecompressor (org.apache.parquet.compression.CompressionCodecFactory.BytesInputDecompressor)1 BloomFilterHeader (org.apache.parquet.format.BloomFilterHeader)1 ColumnMetaData (org.apache.parquet.format.ColumnMetaData)1 DataPageHeader (org.apache.parquet.format.DataPageHeader)1 DictionaryPageHeader (org.apache.parquet.format.DictionaryPageHeader)1 PageHeader (org.apache.parquet.format.PageHeader)1 Util.readColumnMetaData (org.apache.parquet.format.Util.readColumnMetaData)1 ColumnPath (org.apache.parquet.hadoop.metadata.ColumnPath)1