Mryange opened a new pull request, #61999:
URL: https://github.com/apache/doris/pull/61999
### What problem does this PR solve?
The HybridSet / FixedContainer / InListPredicateBase template system has
~264 redundant template instantiations and a latent bug. This PR fixes 4 issues:
**1. Bug: `in.h` `create_string_value_set` matches wrong overload**
`create_string_value_set(get_size_with_out_null(context))` silently matches
the single-parameter template overload `create_string_value_set(bool)` via
implicit `size_t→bool` conversion, instead of the intended two-parameter
`create_string_value_set(size_t, bool)`. This causes `FixedContainer<StringRef,
N>` to never activate for string IN queries. Fixed by calling
`create_string_value_set(size, true)`.
**2. Eliminate 24 redundant instances in `create_set` path**
String types always use `StringSet<DynamicContainer>` regardless of N, but
previous code still instantiated all N variants. Added `if constexpr
(is_string_type(type))` short-circuit in `HybridSetTraits::get_function`.
**3. Eliminate ~320 redundant instances in `InListPredicateBase`**
- Non-string types in the constructor simply do `_values = hybrid_set`
(pointer sharing), making N irrelevant. Moved N-dispatch behind `if constexpr
(is_string_type(TYPE))` in both `predicate_creator_in_list_*.cpp`.
- Date/DECIMALV2 types have identical `ElementType` and `ContainerType`
between caller's HybridSet and InListPredicateBase — the data copy was
unnecessary. Narrowed the copy branch to string-only.
**4. Simplify `FixedContainer::find()` with fold expression**
Replaced ~60-line manual `if constexpr` expansion (N=0..8) with a C++17 fold
expression + `std::index_sequence`. Identical assembly at `-O2`.
### Changed files
| File | Change |
|------|--------|
| `be/src/exprs/function/in.h` | Fix `create_string_value_set` call to use
2-arg overload |
| `be/src/exprs/create_predicate_function.h` | Compile-time short-circuit
for string types |
| `be/src/exprs/hybrid_set.h` | Fold expression rewrite of
`FixedContainer::find()` |
| `be/src/storage/predicate/in_list_predicate.h` | Narrow if-branch to
string-only; remove unnecessary data copy for date/DECIMALV2 |
| `be/src/storage/predicate/predicate_creator_in_list_in.cpp` | N-dispatch
only for string types |
| `be/src/storage/predicate/predicate_creator_in_list_not_in.cpp` | Same as
above |
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [ ] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [ ] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [ ] No.
- [ ] Yes. <!-- Add document PR link here. eg:
https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should
merge into -->
--
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]