Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pola-rs
GitHub Repository: pola-rs/polars
Path: blob/main/crates/polars-plan/src/plans/optimizer/predicate_pushdown/keys.rs
7889 views
1
//! Keys in the `acc_predicates` hashmap.
2
use super::*;
3
4
// an invisible ascii token we use as delimiter
5
const HIDDEN_DELIMITER: &str = "\u{1D17A}";
6
7
/// Determine the hashmap key by combining all the leaf column names of a predicate
8
pub(super) fn predicate_to_key(predicate: Node, expr_arena: &Arena<AExpr>) -> PlSmallStr {
9
let mut iter = aexpr_to_leaf_names_iter(predicate, expr_arena);
10
if let Some(first) = iter.next() {
11
if let Some(second) = iter.next() {
12
let mut new = String::with_capacity(32 * iter.size_hint().0);
13
new.push_str(first);
14
new.push_str(HIDDEN_DELIMITER);
15
new.push_str(second);
16
17
for name in iter {
18
new.push_str(HIDDEN_DELIMITER);
19
new.push_str(name);
20
}
21
return PlSmallStr::from_string(new);
22
}
23
first.clone()
24
} else {
25
PlSmallStr::from_str(HIDDEN_DELIMITER)
26
}
27
}
28
29