-
Notifications
You must be signed in to change notification settings - Fork 478
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
ORC-1332: Avoid NegativeArraySizeException when using searchArgument #1340
Conversation
@@ -237,7 +237,7 @@ protected RecordReaderImpl(ReaderImpl fileReader, | |||
this.fileIncluded = evolution.getFileIncluded(); | |||
SearchArgument sarg = options.getSearchArgument(); | |||
boolean[] rowIndexCols = new boolean[evolution.getFileIncluded().length]; | |||
if (sarg != null && rowIndexStride != 0) { | |||
if (sarg != null && rowIndexStride > 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
orc/java/core/src/java/org/apache/orc/impl/WriterImpl.java
Lines 186 to 188 in becf5a5
this.rowIndexStride = opts.getRowIndexStride(); | |
this.buildIndex = opts.isBuildIndex() && (rowIndexStride > 0); |
Thank you @cxzl25. This is a good fix. The main problem is the the inconsistency of reading and writing implementation. |
java/core/src/test/org/apache/orc/impl/TestRecordReaderImpl.java
Outdated
Show resolved
Hide resolved
Thank you for making a PR. I think it would be better to also make the writer reset the negative rowIndexStride to 0. This provides a wider range of compatibility. Allowing a negative rowIndexStride to be written to the file footer, then older versions of the ORC reader will still not be read correctly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 LGTM
### What changes were proposed in this pull request? searchArgument takes effect only when rowIndexStride is greater than 0. ### Why are the changes needed? When `orc.row.index.stride` is set to a negative number, using searchArgument will throw NegativeArraySizeException. ```java Caused by: java.lang.NegativeArraySizeException at org.apache.orc.impl.RecordReaderImpl$SargApplier.pickRowGroups(RecordReaderImpl.java:1164) at org.apache.orc.impl.RecordReaderImpl.pickRowGroups(RecordReaderImpl.java:1273) at org.apache.orc.impl.RecordReaderImpl.readStripe(RecordReaderImpl.java:1293) at org.apache.orc.impl.RecordReaderImpl.advanceStripe(RecordReaderImpl.java:1345) at org.apache.orc.impl.RecordReaderImpl.advanceToNextRow(RecordReaderImpl.java:1388) at org.apache.orc.impl.RecordReaderImpl.<init>(RecordReaderImpl.java:367) ``` ### How was this patch tested? add UT Closes #1340 from cxzl25/ORC-1332. Authored-by: sychen <sychen@ctrip.com> Signed-off-by: William Hyun <william@apache.org> (cherry picked from commit ae84ad0) Signed-off-by: William Hyun <william@apache.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, late LGTM.
### What changes were proposed in this pull request? searchArgument takes effect only when rowIndexStride is greater than 0. ### Why are the changes needed? When `orc.row.index.stride` is set to a negative number, using searchArgument will throw NegativeArraySizeException. ```java Caused by: java.lang.NegativeArraySizeException at org.apache.orc.impl.RecordReaderImpl$SargApplier.pickRowGroups(RecordReaderImpl.java:1164) at org.apache.orc.impl.RecordReaderImpl.pickRowGroups(RecordReaderImpl.java:1273) at org.apache.orc.impl.RecordReaderImpl.readStripe(RecordReaderImpl.java:1293) at org.apache.orc.impl.RecordReaderImpl.advanceStripe(RecordReaderImpl.java:1345) at org.apache.orc.impl.RecordReaderImpl.advanceToNextRow(RecordReaderImpl.java:1388) at org.apache.orc.impl.RecordReaderImpl.<init>(RecordReaderImpl.java:367) ``` ### How was this patch tested? add UT Closes #1340 from cxzl25/ORC-1332. Authored-by: sychen <sychen@ctrip.com> Signed-off-by: William Hyun <william@apache.org> (cherry picked from commit ae84ad0) Signed-off-by: William Hyun <william@apache.org> (cherry picked from commit 38aef73) Signed-off-by: Dongjoon Hyun <dongjoon@apache.org>
I backported this to branch-1.7 too. |
### What changes were proposed in this pull request? searchArgument takes effect only when rowIndexStride is greater than 0. ### Why are the changes needed? When `orc.row.index.stride` is set to a negative number, using searchArgument will throw NegativeArraySizeException. ```java Caused by: java.lang.NegativeArraySizeException at org.apache.orc.impl.RecordReaderImpl$SargApplier.pickRowGroups(RecordReaderImpl.java:1164) at org.apache.orc.impl.RecordReaderImpl.pickRowGroups(RecordReaderImpl.java:1273) at org.apache.orc.impl.RecordReaderImpl.readStripe(RecordReaderImpl.java:1293) at org.apache.orc.impl.RecordReaderImpl.advanceStripe(RecordReaderImpl.java:1345) at org.apache.orc.impl.RecordReaderImpl.advanceToNextRow(RecordReaderImpl.java:1388) at org.apache.orc.impl.RecordReaderImpl.<init>(RecordReaderImpl.java:367) ``` ### How was this patch tested? add UT Closes apache#1340 from cxzl25/ORC-1332. Authored-by: sychen <sychen@ctrip.com> Signed-off-by: William Hyun <william@apache.org>
What changes were proposed in this pull request?
searchArgument takes effect only when rowIndexStride is greater than 0.
Why are the changes needed?
When
orc.row.index.stride
is set to a negative number, using searchArgument will throw NegativeArraySizeException.How was this patch tested?
add UT