RussellSpitzer commented on code in PR #3935:
URL: https://github.com/apache/parquet-java/pull/3935#discussion_r4488138488
##########
parquet-hadoop/src/main/java/org/apache/parquet/hadoop/ColumnChunkPageReadStore.java:
##########
@@ -218,85 +220,180 @@ public DataPage visit(DataPageV1 dataPageV1) {
@Override
public DataPage visit(DataPageV2 dataPageV2) {
- if (!dataPageV2.isCompressed() && offsetIndex == null && null ==
blockDecryptor) {
- return dataPageV2;
+ if (dataPageV2 instanceof FullBodyEncryptedDataPageV2) {
+ return readPageV2WithEncryptedLevels(
+ (FullBodyEncryptedDataPageV2) dataPageV2, currentPageIndex);
}
- BytesInput pageBytes = dataPageV2.getData();
- try {
- if (options.getAllocator().isDirect() &&
options.useOffHeapDecryptBuffer()) {
- ByteBuffer byteBuffer = pageBytes.toByteBuffer(releaser);
- if (!byteBuffer.isDirect()) {
- throw new ParquetDecodingException("Expected a direct buffer");
- }
- if (blockDecryptor != null) {
- byteBuffer = blockDecryptor.decrypt(byteBuffer, dataPageAAD);
- }
- long compressedSize = byteBuffer.limit();
- if (dataPageV2.isCompressed()) {
- int uncompressedSize =
Math.toIntExact(dataPageV2.getUncompressedSize()
- - dataPageV2.getDefinitionLevels().size()
- - dataPageV2.getRepetitionLevels().size());
- ByteBuffer decompressedBuffer =
- options.getAllocator().allocate(uncompressedSize);
- releaser.releaseLater(decompressedBuffer);
- long start = System.nanoTime();
- decompressor.decompress(
- byteBuffer, (int) compressedSize, decompressedBuffer,
uncompressedSize);
- setDecompressMetrics(pageBytes, start);
- decompressedBuffer.flip();
- pageBytes = BytesInput.from(decompressedBuffer);
- } else {
- pageBytes = BytesInput.from(byteBuffer);
- }
- } else {
- if (null != blockDecryptor) {
- pageBytes =
-
BytesInput.from(blockDecryptor.decrypt(pageBytes.toByteArray(), dataPageAAD));
- }
- if (dataPageV2.isCompressed()) {
- int uncompressedSize =
Math.toIntExact(dataPageV2.getUncompressedSize()
- - dataPageV2.getDefinitionLevels().size()
- - dataPageV2.getRepetitionLevels().size());
- long start = System.nanoTime();
- pageBytes = BytesInput.copy(decompressor.decompress(pageBytes,
uncompressedSize));
- setDecompressMetrics(pageBytes, start);
- }
- }
- } catch (IOException e) {
- throw new ParquetDecodingException("could not decompress page", e);
- }
-
- final DataPageV2 decompressedPage;
- if (offsetIndex == null) {
- decompressedPage = DataPageV2.uncompressed(
- dataPageV2.getRowCount(),
- dataPageV2.getNullCount(),
- dataPageV2.getValueCount(),
- dataPageV2.getRepetitionLevels(),
- dataPageV2.getDefinitionLevels(),
- dataPageV2.getDataEncoding(),
- pageBytes,
- dataPageV2.getStatistics());
- } else {
- decompressedPage = DataPageV2.uncompressed(
- dataPageV2.getRowCount(),
- dataPageV2.getNullCount(),
- dataPageV2.getValueCount(),
- offsetIndex.getFirstRowIndex(currentPageIndex),
- dataPageV2.getRepetitionLevels(),
- dataPageV2.getDefinitionLevels(),
- dataPageV2.getDataEncoding(),
- pageBytes,
- dataPageV2.getStatistics());
- }
- if (dataPageV2.getCrc().isPresent()) {
- decompressedPage.setCrc(dataPageV2.getCrc().getAsInt());
- }
- return decompressedPage;
+ return readPageV2WithPlaintextLevels(dataPageV2, currentPageIndex);
}
});
}
+ /**
+ * Reads a page whose levels are not encrypted. If the column is
encrypted, only the values are an
+ * encrypted module.
Review Comment:
We should make sure to note this exists for backwards compatibility only and
that this is not spec compliant or expected.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]