Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read all row group metadata only when position column is projected #1716

Merged
merged 2 commits into from
Nov 7, 2020

Conversation

chenjunjiedada
Copy link
Collaborator

This is used to avoid reading all row group metadata if the position metadata column is not projected.

@@ -135,11 +135,9 @@ private void advance() {
throw new RuntimeIOException(e);
}

long rowPosition = rowGroupsStartRowPos[nextRowGroup];
model.setPageSource(pages, rowGroupsStartRowPos == null ? 0 : rowGroupsStartRowPos[nextRowGroup]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rowPosition will be ignored if the position column is not projected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this file should change. If the determination not to use correct start positions in made in ReadConf, then it should just set the position to 0 there. This can use whatever rowGroupStartRowPos contains.

@@ -102,7 +107,9 @@
long computedTotalValues = 0L;
for (int i = 0; i < shouldSkip.length; i += 1) {
BlockMetaData rowGroup = rowGroups.get(i);
startRowPositions[i] = offsetToStartPos.get(rowGroup.getStartingPos());
if (offsetToStartPos != null) {
startRowPositions[i] = offsetToStartPos.get(rowGroup.getStartingPos());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use offsetToStartPos.getOrDefault(0L).

Map<Long, Long> offsetToStartPos = null;
if (expectedSchema.findField(MetadataColumns.ROW_POSITION.fieldId()) != null) {
offsetToStartPos = generateOffsetToStartPos();
this.startRowPositions = new long[rowGroups.size()];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be defined for all cases so that ParquetReader doesn't need to check whether it is defined. In that case, it should still be a final variable.

The only change for this PR should be whether offsetToStartPos is an empty map or the result of generateOffsetToStartPos(). We may also want to do the ROW_POSITION check in that method instead of here, depending on what is cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. Updated.

@rdblue
Copy link
Contributor

rdblue commented Nov 7, 2020

Looks good now. Thanks @chenjunjiedada!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants