ORC: Fix non-vectorized reader incorrectly skipping rows #1706
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ORC non-vectorized code path uses the following condition in
OrcRowIterator#next()to determine if a new batch should be read and row batch counter should be reset.if (batch == null || nextRow >= batch.size)(Note: the code usescurrentas the variable name instead ofbatch)Since the batch object is reused,
#hasNext()can cause a new batch to be loaded in case the existing batch was consumed. In such a case, the condition in#next()will cause the row batch counter to be reset. However, if#hasNext()was called prior to this, thebatchvariable will already have data loaded for the next batch and sobatch.sizewill give size of the newly loaded batch.In some cases, the batch sizes across batches will remain the same and so the current condition works fine. However, there can be cases where batch size of the next batch is greater than the current batch and so the condition
nextRow >= batch.sizewill be false even if a new batch was loaded causingnextRowto not be reset and rows from the new row batch being skipped.The conditions under which this case can occur:
This PR stores the current batch size in a local variable when the batch is loaded so that calls to
#hasNext()do not affect the condition in#next().