lyne7-sc opened a new pull request, #21237:
URL: https://github.com/apache/datafusion/pull/21237
## Which issue does this PR close?
<!--
We generally require a GitHub issue to be filed for all bug fixes and
enhancements and this helps us generate change logs for our releases. You can
link an issue to this PR using the GitHub syntax. For example `Closes #123`
indicates that this PR will close issue #123.
-->
- Closes #.
## Rationale for this change
<!--
Why are you proposing this change? If this is already explained clearly in
the issue then this section is not needed.
Explaining clearly why changes are proposed helps reviewers understand your
changes and offer better suggestions for fixes.
-->
This PR optimizes `map_extract` for common key types. Previously,
`map_extract` compared keys by building single-element array slices for each
comparison. That is more expensive than necessary for common key types such as
primitive integers, strings, and binary values.
## What changes are included in this PR?
- specialize `map_extract` key lookup for primitive, string, and binary key
types using direct value comparison instead of array slicing
- keep the generic fallback for unsupported key types
- add a `map_extract` benchmark with representative cases
### Benchmark
```
group main
optimized
----- ----
---------
map_extract_1000_binary_found_last 97.64 174.3±6.10ms
? ?/sec 1.00 1784.9±63.47µs ? ?/sec
map_extract_1000_binary_view_found_last 72.04 188.1±3.65ms
? ?/sec 1.00 2.6±0.18ms ? ?/sec
map_extract_1000_int32_found_last 388.31 154.4±2.12ms
? ?/sec 1.00 397.5±23.08µs ? ?/sec
map_extract_1000_utf8_found_last 80.58 173.5±6.90ms
? ?/sec 1.00 2.2±0.06ms ? ?/sec
map_extract_1000_utf8_found_middle 79.85 84.7±2.36ms
? ?/sec 1.00 1061.0±53.43µs ? ?/sec
map_extract_1000_utf8_view_found_last 64.81 175.7±5.23ms
? ?/sec 1.00 2.7±0.12ms ? ?/sec
```
<!--
There is no need to duplicate the description in the issue here but it is
sometimes worth providing a summary of the individual changes in this PR.
-->
## Are these changes tested?
Yes. slt passed, and benchmark coverage was added.
<!--
We typically require tests for all PRs in order to:
1. Prevent the code from being accidentally broken by subsequent changes
2. Serve as another way to document the expected behavior of the code
If tests are not included in your PR, please explain why (for example, are
they covered by existing tests)?
-->
## Are there any user-facing changes?
No.
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
--
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]