shangxinli commented on a change in pull request #945:
URL: https://github.com/apache/parquet-mr/pull/945#discussion_r814786613
##########
File path:
parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
##########
@@ -1400,34 +1400,67 @@ public ParquetMetadata readParquetMetadata(final
InputStream from, MetadataFilte
return readParquetMetadata(from, filter, null, false, 0);
}
+ private Map<RowGroup, Long> generateRowGroupOffsets(FileMetaData metaData) {
+ Map<RowGroup, Long> rowGroupOrdinalToRowIdx = new HashMap<>();
+ List<RowGroup> rowGroups = metaData.getRow_groups();
+ if (rowGroups != null) {
+ long rowIdxSum = 0;
+ for (int i = 0; i < rowGroups.size(); i++) {
+ rowGroupOrdinalToRowIdx.put(rowGroups.get(i), rowIdxSum);
+ rowIdxSum += rowGroups.get(i).getNum_rows();
+ }
+ }
+ return rowGroupOrdinalToRowIdx;
+ }
+
+ /**
+ * A container for [[FileMetaData]] and [[RowGroup]] to ROW_INDEX offset map.
+ */
+ private class FileMetaDataAndRowGroupOffsetInfo {
+ FileMetaData fileMetadata;
+ Map<RowGroup, Long> rowGroupToRowIndexOffsetMap;
+ public FileMetaDataAndRowGroupOffsetInfo(FileMetaData fileMetadata,
Map<RowGroup, Long> rowGroupToRowIndexOffsetMap) {
+ this.fileMetadata = fileMetadata;
+ this.rowGroupToRowIndexOffsetMap = rowGroupToRowIndexOffsetMap;
+ }
+ }
+
public ParquetMetadata readParquetMetadata(final InputStream from,
MetadataFilter filter,
final InternalFileDecryptor fileDecryptor, final boolean encryptedFooter,
final int combinedFooterLength) throws IOException {
final BlockCipher.Decryptor footerDecryptor = (encryptedFooter?
fileDecryptor.fetchFooterDecryptor() : null);
final byte[] encryptedFooterAAD = (encryptedFooter?
AesCipher.createFooterAAD(fileDecryptor.getFileAAD()) : null);
- FileMetaData fileMetaData = filter.accept(new
MetadataFilterVisitor<FileMetaData, IOException>() {
+ FileMetaDataAndRowGroupOffsetInfo fileMetaDataAndRowGroupInfo =
filter.accept(new MetadataFilterVisitor<FileMetaDataAndRowGroupOffsetInfo,
IOException>() {
Review comment:
Got it.
--
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]