[
https://issues.apache.org/jira/browse/PARQUET-2117?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17492975#comment-17492975
]
ASF GitHub Bot commented on PARQUET-2117:
-----------------------------------------
prakharjain09 commented on a change in pull request #945:
URL: https://github.com/apache/parquet-mr/pull/945#discussion_r807496428
##########
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:
The `visit(OffsetMetadataFilter filter)` and `visit(RangeMetadataFilter
filter)` returns the "filtered" FileMetadata and so few of the rowGroups might
be missing in that. So doing it at the end will generate incorrect
rowIndexOffset.
--
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]
> Add rowPosition API in parquet record readers
> ---------------------------------------------
>
> Key: PARQUET-2117
> URL: https://issues.apache.org/jira/browse/PARQUET-2117
> Project: Parquet
> Issue Type: New Feature
> Components: parquet-mr
> Reporter: Prakhar Jain
> Priority: Major
> Fix For: 1.13.0
>
>
> Currently the parquet-mr RecordReader/ParquetFileReader exposes API’s to read
> parquet file in columnar fashion or record-by-record.
> It will be great to extend them to also support rowPosition API which can
> tell the position of the current record in the parquet file.
> The rowPosition can be used as a unique row identifier to mark a row. This
> can be useful to create an index (e.g. B+ tree) over a parquet file/parquet
> table (e.g. Spark/Hive).
> There are multiple projects in the parquet eco-system which can benefit from
> such a functionality:
> # Apache Iceberg needs this functionality. It has this implementation
> already as it relies on low level parquet APIs -
> [Link1|https://github.com/apache/iceberg/blob/apache-iceberg-0.12.1/parquet/src/main/java/org/apache/iceberg/parquet/ReadConf.java#L171],
>
> [Link2|https://github.com/apache/iceberg/blob/d4052a73f14b63e1f519aaa722971dc74f8c9796/core/src/main/java/org/apache/iceberg/MetadataColumns.java#L37]
> # Apache Spark can use this functionality - SPARK-37980
--
This message was sent by Atlassian Jira
(v8.20.1#820001)