-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Ensure all the lists used in PinotQuery are ArrayList #13017
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #13017 +/- ##
============================================
+ Coverage 61.75% 62.13% +0.37%
+ Complexity 207 198 -9
============================================
Files 2436 2502 +66
Lines 133233 136612 +3379
Branches 20636 21162 +526
============================================
+ Hits 82274 84879 +2605
- Misses 44911 45434 +523
- Partials 6048 6299 +251
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
c0bd24e
to
7306905
Compare
|
||
public static Function getFunction(String canonicalName, Expression... operands) { | ||
// NOTE: Create an ArrayList because we might need to modify the list later | ||
return getFunction(canonicalName, new ArrayList<>(Arrays.asList(operands))); |
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.
just loop over operands and add to the new list, w/o calling Arrays.asList() to avoid creating a temp list.
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.
I actually considered that, but not sure if that is really faster. The trade-off is one extra array copy vs a lot of extra method invocations and a for loop. Seems IDE doesn't like the for loop, thus I decided to use the IDE suggested way
pinot-common/src/main/java/org/apache/pinot/common/utils/request/RequestUtils.java
Outdated
Show resolved
Hide resolved
7306905
to
5e9bcea
Compare
Refactor the code to ensure the lists used in
PinotQuery
(thrift object) are allArrayList
.Thrift internally always use
ArrayList
, but we might set it with other list types, such asArrays.asList()
,Collections.singletonList()
etc. The problem with this is that query optimizer assumes the lists are mutable, and might modify the list. Currently query optimizer only replaces elements, which is supported byArrays.asList()
but notCollections.singletonList()
. This PR ensures all lists areArrayList
so that it is also future proof.We detect this issue by using ordinal in ORDER BY along with expression override. Here is the exception: