Skip to main content

kermit_algos/
lib.rs

1//! Join algorithms for Kermit's relational algebra engine.
2//!
3//! Implements the [Leapfrog Triejoin](https://arxiv.org/abs/1210.0481) algorithm,
4//! which performs worst-case optimal multi-way joins over trie-structured
5//! relations. The algorithm is generic over any data structure that implements
6//! [`TrieIterable`](kermit_iters::TrieIterable).
7#![deny(missing_docs)]
8
9mod const_rewrite;
10mod join_algo;
11mod leapfrog_join;
12mod leapfrog_triejoin;
13mod singleton;
14mod trie_iter_kind;
15
16use {clap::ValueEnum, std::str::FromStr};
17pub use {
18    const_rewrite::{rewrite_atoms, ConstSpec, RewriteError},
19    join_algo::JoinAlgo,
20    kermit_parser::JoinQuery,
21    leapfrog_triejoin::LeapfrogTriejoin,
22    singleton::SingletonTrieIter,
23    trie_iter_kind::TrieIterKind,
24};
25
26/// The available join algorithm implementations.
27///
28/// Used as a CLI argument to select which algorithm to run.
29#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
30pub enum JoinAlgorithm {
31    /// The [Leapfrog Triejoin](https://arxiv.org/abs/1210.0481) algorithm;
32    /// see [`LeapfrogTriejoin`].
33    LeapfrogTriejoin,
34}
35
36impl FromStr for JoinAlgorithm {
37    type Err = String;
38
39    fn from_str(s: &str) -> Result<Self, Self::Err> {
40        match s {
41            | "leapfrog_triejoin" => Ok(Self::LeapfrogTriejoin),
42            | _ => Err(format!("Invalid join algorithm: {}", s)),
43        }
44    }
45}