[CALCITE-4102] Some improvements to aggregate related operations#2053
[CALCITE-4102] Some improvements to aggregate related operations#2053hsyuan merged 1 commit intoapache:masterfrom
Conversation
liyafan82
commented
Jul 2, 2020
- Improve the use of data structures
- Extract common methods
- Avoid expensive operations
1c39e51 to
5b3e872
Compare
|
looks all equivalent rewrites for the refactoring, |
| * Checks if all bit sets contain a particular bit. | ||
| */ | ||
| public static boolean allContain(Collection<ImmutableBitSet> bitSets, | ||
| int bit) { |
There was a problem hiding this comment.
we do not format like this
There was a problem hiding this comment.
Revised. Thank you for your kind reminder.
Sure. Thanks a lot for your feedback. Below are some explanations:
|
|
make sense. See the guide in https://calcite.apache.org/develop/#contributing |
@yanlin-Lynn Thanks a lot for your kind reminder. |
|
FWIW, I intentionally used
|
Thanks a lot for your feedback. It is clever to
Good suggestion. I have renamed |
| // Each subsequent items must be a subset with one fewer bit than the | ||
| // previous item | ||
| set.addAll(g.except(bitSet).toList()); | ||
| ImmutableBitSet diff = g.except(bitSet); |
There was a problem hiding this comment.
Would there be duplicate values since Set is changed to List?
There was a problem hiding this comment.
@chunweilei Thanks a lot for your feedback.
According to the definition of Rollup (https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/rel/core/Aggregate.java#L508-L513), there can be no duplicate.
I think what @julianhyde means is that the HashSet holds a pointer to HashMap, with HashSet object header, it will use 16 bytes more than bare HashMap. |
…a Fan) 1. Extract a common method for ImmutableBitSet 2. Refine the use of data structures 3. Replace expensive operations with cheap ones
@hsyuan Thanks for your kind reminder. I have reverted the code to use |
Suppose in Hotspot 64-bit VM, with COOPS enabled, the object header is 12 bytes, the pointer to HashMap uses 4 bytes. So it is 16 bytes. |
Awesome! Thanks for your clarification. |