Skip to content

Commit

Permalink
Fix bug in ORC flat map reader causing 'Read past RLE' and 'Positions…
Browse files Browse the repository at this point in the history
… must monotonically increase' errors
  • Loading branch information
sdruzkin authored and ARUNACHALAM THIRUPATHI committed Sep 6, 2022
1 parent fd4ee43 commit 818adb6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -774,23 +774,6 @@ private boolean hasAnyFilter(int columnIndex)
return columnsWithFilterScores.containsKey(columnIndex) || filterFunctionInputMapping.containsKey(columnIndex);
}

private void initializePositions(int batchSize)
{
if (positions == null || positions.length < batchSize) {
positions = new int[batchSize];
for (int i = 0; i < batchSize; i++) {
positions[i] = i;
}
}

if (errors == null || errors.length < batchSize) {
errors = new RuntimeException[batchSize];
}
else {
Arrays.fill(errors, null);
}
}

private int applyFilterFunctionWithNoInputs(int positionCount)
{
initializeOutputPositions(positionCount);
Expand Down Expand Up @@ -876,6 +859,24 @@ private void initializeTmpErrors(int positionCount)
}
}

private void initializePositions(int batchSize)
{
if (positions == null || positions.length < batchSize) {
positions = new int[batchSize];
}

for (int i = 0; i < batchSize; i++) {
positions[i] = i;
}

if (errors == null || errors.length < batchSize) {
errors = new RuntimeException[batchSize];
}
else {
Arrays.fill(errors, null);
}
}

private void initializeOutputPositions(int positionCount)
{
if (outputPositions == null || outputPositions.length < positionCount) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public int read(int offset, int[] positions, int positionCount)
outputPositions = initializeOutputPositions(outputPositions, positions, positionCount);

if (keyCount == 0 && presentStream == null) {
readAllEmpty(positions, positionCount);
readAllEmpty(positionCount);
}
else {
readNotAllNulls(offset, positions, positionCount);
Expand All @@ -244,9 +244,8 @@ public int read(int offset, int[] positions, int positionCount)
return outputPositionCount;
}

private void readAllEmpty(int[] positions, int positionCount)
private void readAllEmpty(int positionCount)
{
outputPositions = positions;
outputPositionsReadOnly = true;

if (!nonNullsAllowed) {
Expand Down

0 comments on commit 818adb6

Please sign in to comment.