Tushar7012 opened a new pull request, #20055:
URL: https://github.com/apache/datafusion/pull/20055
## Rationale for this change
The
[ArrowBytesViewMap](cci:2://file:///d:/Agentic_AI/Gssoc_Apache/datafusion/datafusion/physical-expr-common/src/binary_view_map.rs:118:0-146:1)
is a high-performance structure used for interning string and binary views in
operators like `GROUP BY` and `COUNT DISTINCT`. This PR addresses performance
bottlenecks identified during maintainer review:
1. **Redundant Memory Access**: Previously, the input value
(`values.value(i)`) was fetched and converted to a byte slice multiple times
during hash collisions and insertion. This added unnecessary overhead to the
interning loop.
2. **Suboptimal Comparison**: Inlined values (strings ≤ 12 bytes) were being
converted to byte slices for comparison rather than leveraging direct `u128`
bitwise equality.
## What changes are included in this PR?
- **Direct `u128` View Comparison**: Updated the interning logic to perform
bitwise equality checks on the `u128` views for inlined values, providing a
single-cycle fast path.
- **"Single Fetch" Optimization**: Refactored
[insert_if_new_inner](cci:1://file:///d:/Agentic_AI/Gssoc_Apache/datafusion/datafusion/physical-expr-common/src/binary_view_map.rs:235:4-356:5)
to fetch and convert the input value exactly once per row. This value is
reused for both lookup and insertion branches.
- **Optimized Comparison Sequence**:
1. Direct hash match.
2. Bitwise `u128` view equality for inlined strings (≤12 bytes).
3. Prefix comparison for larger strings before falling back to full
byte-slice comparison.
- **Generic Type Resolution**: Fixed compilation errors by correctly
leveraging `GenericByteViewArray<B>` to provide specialized access for
StringView/BinaryView types.
## Are these changes tested?
Yes. I have verified the changes using the existing unit test suite:
- `cargo test -p datafusion-physical-expr-common --lib
binary_view_map::tests`
- Result: **8 passed; 0 failed**
## Are there any user-facing changes?
No. This is a internal performance optimization.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]