-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generalized hash trie indexes for relational tuples (#1503)
Generalized Hash Tries are part of the SIGMOD '23 FreeJoin [paper](https://dl.acm.org/doi/abs/10.1145/3589295) by Wang/Willsey/Suciu. They provide a compressed ("factorized") representation of relations. By operating in the factorized domain, join algorithms can defer cross-products and achieve asymptotically optimal performance. --------- Co-authored-by: Mingwei Samuel <mingwei.samuel@gmail.com> Co-authored-by: Andre Giron <agiron123@gmail.com>
- Loading branch information
1 parent
b961233
commit f7e740f
Showing
24 changed files
with
2,612 additions
and
29 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ members = [ | |
"stageleft_tool", | ||
"topolotree", | ||
"variadics", | ||
"variadics_macro", | ||
"website_playground", | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,3 @@ Hello 6 | |
Hello 7 | ||
Hello 8 | ||
Hello 9 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,4 +81,3 @@ digraph { | |
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,4 +67,3 @@ subgraph sg_4v1 ["sg_4v1 stratum 1"] | |
9v1 | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,3 @@ subgraph sg_3v1 ["sg_3v1 stratum 1"] | |
3v1 | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,4 +61,3 @@ digraph { | |
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,4 +53,3 @@ subgraph sg_2v1 ["sg_2v1 stratum 0"] | |
3v1 | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use hydroflow::hydroflow_syntax; | ||
use hydroflow::lattices::ght::lattice::{DeepJoinLatticeBimorphism, GhtBimorphism}; | ||
use hydroflow::lattices::ght::GeneralizedHashTrieNode; | ||
use hydroflow::lattices::GhtType; | ||
use hydroflow::util::collect_ready; | ||
use hydroflow::variadics::{var_expr, var_type}; | ||
use variadics::variadic_collections::VariadicHashSet; // Import the Insert trait | ||
|
||
#[test] | ||
fn test_basic() { | ||
type MyGht = GhtType!(u16, u32 => u64: VariadicHashSet); | ||
type FlatTup = var_type!(u16, u32, u64); | ||
let input: Vec<FlatTup> = vec![ | ||
var_expr!(42, 314, 43770), | ||
var_expr!(42, 315, 43770), | ||
var_expr!(42, 314, 30619), | ||
var_expr!(43, 10, 600), | ||
]; | ||
let mut merged = MyGht::default(); | ||
for i in input.clone() { | ||
merged.insert(i); | ||
} | ||
println!("merged: {:?}", merged); | ||
let mut df = hydroflow_syntax! { | ||
source_iter(input) | ||
-> map(|t| MyGht::new_from(vec![t])) | ||
-> lattice_fold::<'static>(MyGht::default) | ||
-> inspect(|t| println!("{:?}", t)) | ||
-> assert(|x: &MyGht| x.eq(&merged)) | ||
-> null(); | ||
}; | ||
df.run_available(); | ||
} | ||
|
||
#[test] | ||
fn test_join() { | ||
type MyGht = GhtType!(u8 => u16: VariadicHashSet); | ||
type ResultGht = GhtType!(u8 => u16, u16: VariadicHashSet); | ||
let (out_send, out_recv) = hydroflow::util::unbounded_channel::<_>(); | ||
|
||
let r = vec![ | ||
var_expr!(1, 10), | ||
var_expr!(2, 20), | ||
var_expr!(3, 30), | ||
var_expr!(4, 40), | ||
]; | ||
let s = vec![var_expr!(1, 10), var_expr!(5, 50)]; | ||
|
||
type MyNodeBim = <(MyGht, MyGht) as DeepJoinLatticeBimorphism< | ||
VariadicHashSet<var_type!(u8, u16, u16)>, | ||
>>::DeepJoinLatticeBimorphism; | ||
type MyBim = GhtBimorphism<MyNodeBim>; | ||
|
||
let mut df = hydroflow_syntax! { | ||
R = source_iter(r) | ||
-> map(|t| MyGht::new_from([t])) | ||
-> state::<MyGht>(); | ||
S = source_iter(s) | ||
-> map(|t| MyGht::new_from([t])) | ||
-> state::<MyGht>(); | ||
R[items] -> [0]my_join; | ||
S[items] -> [1]my_join; | ||
my_join = lattice_bimorphism(MyBim::default(), #R, #S) | ||
-> lattice_reduce() | ||
-> for_each(|x| out_send.send(x).unwrap()); | ||
}; | ||
df.run_available(); | ||
|
||
assert_eq!( | ||
&[ResultGht::new_from(vec![var_expr!(1, 10, 10),])], | ||
&*collect_ready::<Vec<_>, _>(out_recv) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.