-
Notifications
You must be signed in to change notification settings - Fork 506
ORC-1942: Fix PhysicalFsWriter not to change ZstdCodec's default option
#2304
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
Conversation
| @Override | ||
| public Options getDefaultOptions() { | ||
| return DEFAULT_OPTIONS; | ||
| return DEFAULT_OPTIONS.copy(); |
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.
In addition, this PR makes this return a copied one to make it sure.
PhysicalFsWriter to change tempOptions directlyPhysicalFsWriter not to change ZstdCodec's default option
|
cc @cxzl25 |
…option ### What changes were proposed in this pull request? This PR aims to fix `PhysicalFsWriter` to change `tempOptions` directly. ### Why are the changes needed? In the following code path, `tempOptions` is supposed to be updated and used. However, `codec.getDefaultOptions() instanceof ZstdCodec.ZstdOptions options` code is currently updating the return value of `codec.getDefaultOptions()` via a variable `options`. https://github.com/apache/orc/blob/d3843bc043bea97bdd81a0f8e1fab3329efc7308/java/core/src/java/org/apache/orc/impl/PhysicalFsWriter.java#L118-L127 Technically, `ZstdCodec.getDefaultOptions()` returns the final static variable. This AS-IS code is trying to change this static object which leads unintended side-effects. We should avoid this code pattern. https://github.com/apache/orc/blob/d3843bc043bea97bdd81a0f8e1fab3329efc7308/java/core/src/java/org/apache/orc/impl/ZstdCodec.java#L150-L156 ### How was this patch tested? Pass the CIs with a newly added test case. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #2304 from dongjoon-hyun/ORC-1942. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 3c63bf7) Signed-off-by: Dongjoon Hyun <[email protected]>
…option ### What changes were proposed in this pull request? This PR aims to fix `PhysicalFsWriter` to change `tempOptions` directly. ### Why are the changes needed? In the following code path, `tempOptions` is supposed to be updated and used. However, `codec.getDefaultOptions() instanceof ZstdCodec.ZstdOptions options` code is currently updating the return value of `codec.getDefaultOptions()` via a variable `options`. https://github.com/apache/orc/blob/d3843bc043bea97bdd81a0f8e1fab3329efc7308/java/core/src/java/org/apache/orc/impl/PhysicalFsWriter.java#L118-L127 Technically, `ZstdCodec.getDefaultOptions()` returns the final static variable. This AS-IS code is trying to change this static object which leads unintended side-effects. We should avoid this code pattern. https://github.com/apache/orc/blob/d3843bc043bea97bdd81a0f8e1fab3329efc7308/java/core/src/java/org/apache/orc/impl/ZstdCodec.java#L150-L156 ### How was this patch tested? Pass the CIs with a newly added test case. ### Was this patch authored or co-authored using generative AI tooling? No. Closes #2304 from dongjoon-hyun/ORC-1942. Authored-by: Dongjoon Hyun <[email protected]> Signed-off-by: Dongjoon Hyun <[email protected]> (cherry picked from commit 3c63bf7) Signed-off-by: Dongjoon Hyun <[email protected]>
|
Merged to main/2.1/2.0. |
cxzl25
left a comment
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.
Late LGTM. Thank you @dongjoon-hyun
|
Thank you for reviewing, @cxzl25 ! |
What changes were proposed in this pull request?
This PR aims to fix
PhysicalFsWriterto changetempOptionsdirectly.Why are the changes needed?
In the following code path,
tempOptionsis supposed to be updated and used. However,codec.getDefaultOptions() instanceof ZstdCodec.ZstdOptions optionscode is currently updating the return value ofcodec.getDefaultOptions()via a variableoptions.orc/java/core/src/java/org/apache/orc/impl/PhysicalFsWriter.java
Lines 118 to 127 in d3843bc
Technically,
ZstdCodec.getDefaultOptions()returns the final static variable. This AS-IS code is trying to change this static object which leads unintended side-effects. We should avoid this code pattern.orc/java/core/src/java/org/apache/orc/impl/ZstdCodec.java
Lines 150 to 156 in d3843bc
How was this patch tested?
Pass the CIs with a newly added test case.
Was this patch authored or co-authored using generative AI tooling?
No.