ggershinsky commented on a change in pull request #925:
URL: https://github.com/apache/parquet-mr/pull/925#discussion_r704102666
##########
File path:
parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
##########
@@ -1226,14 +1240,32 @@ public ParquetMetadata readParquetMetadata(InputStream
from) throws IOException
static FileMetaData filterFileMetaDataByMidpoint(FileMetaData metaData,
RangeMetadataFilter filter) {
List<RowGroup> rowGroups = metaData.getRow_groups();
List<RowGroup> newRowGroups = new ArrayList<RowGroup>();
+ long preStartIndex = 0;
+ long preCompressedSize = 0;
+ boolean firstColumnWithMetadata = true;
+ if (rowGroups != null && rowGroups.size() > 0) {
+ firstColumnWithMetadata =
rowGroups.get(0).getColumns().get(0).isSetMeta_data();
+ }
for (RowGroup rowGroup : rowGroups) {
long totalSize = 0;
long startIndex;
+ ColumnChunk columnChunk = rowGroup.getColumns().get(0);
+ if (firstColumnWithMetadata) {
+ startIndex = getOffset(columnChunk);
+ } else {
+ assert rowGroup.isSetFile_offset();
+ assert rowGroup.isSetTotal_compressed_size();
- if (rowGroup.isSetFile_offset()) {
+ //the file_offset of first block always holds the truth, while other
blocks don't :
+ //see PARQUET-2078 for details
startIndex = rowGroup.getFile_offset();
- } else {
- startIndex = getOffset(rowGroup.getColumns().get(0));
+ if (invalidFileOffset(startIndex, preStartIndex, preCompressedSize)) {
+ // use minStartIndex(imprecise in case of padding, but good enough
for filtering)
+ startIndex = preStartIndex + preCompressedSize;
+ }
+ preStartIndex = startIndex;
+ preCompressedSize = rowGroup.getTotal_compressed_size();
+
Review comment:
nit: empty line
##########
File path:
parquet-hadoop/src/main/java/org/apache/parquet/format/converter/ParquetMetadataConverter.java
##########
@@ -201,9 +201,23 @@ public FileMetaData toParquetMetadata(int currentVersion,
ParquetMetadata parque
List<BlockMetaData> blocks = parquetMetadata.getBlocks();
List<RowGroup> rowGroups = new ArrayList<RowGroup>();
long numRows = 0;
+ long preBlockStartPos = 0;
+ long preBlockCompressedSize = 0;
for (BlockMetaData block : blocks) {
numRows += block.getRowCount();
+ long blockStartPos = block.getStartingPos();
+ // first block
+ if (blockStartPos == 4) {
+ preBlockStartPos = 0;
+ preBlockCompressedSize = 0;
+ }
+ if (preBlockStartPos != 0) {
+ assert blockStartPos >= preBlockStartPos + preBlockCompressedSize;
+ }
+ preBlockStartPos = blockStartPos;
+ preBlockCompressedSize = block.getCompressedSize();
addRowGroup(parquetMetadata, rowGroups, block, fileEncryptor);
+
Review comment:
nit: empty line
--
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]