mzabaluev opened a new pull request, #26609: URL: https://github.com/apache/datafusion/pull/26609
## Rationale for this change A `CASE <expr> WHEN <literal> ...` over a primitive type maps each value to its branch with a hash map lookup. For a few literals, comparing each value with all of them is much cheaper, and its cost does not depend on how the literals happen to be placed in the hash map, which with the per-process random hash seed varies between runs. ## What changes are included in this PR? Up to 128 bytes of literals, but no more than 32 of them, the values are now compared with every literal a chunk at a time, selecting the branch index without branching, so that the comparisons vectorize. That is 32 literals of 4-byte types, 16 of 8-byte types and 8 of `Decimal128`. ## What is the testing strategy for this PR? Adds a benchmark over the number of literals for `Int32`, `Int64` and `Decimal128` values. Measured on an Apple M4 Pro, against the hash map: `Int32` with 2-32 literals is 44-88% faster, `Int64` with 2-16 literals 57-86% faster, and `Decimal128` with 2-8 literals 30-65% faster. The existing `Int32`-to-string lookup benchmarks with 5-20 literals are 10-34% faster. The size limit is about half the measured break-even point for each of these types. ## Are there any user-facing changes? No -- 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]
