1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
//! JIT compilation phases b, c, and d — Cranelift-based codegen for filter expressions,
//! hash-join key comparison, ORDER BY evaluation, PROJECT column extraction, DISTINCT
//! deduplication hashing, and HAVING clause predicates over aggregate results.
//!
//! # Phase b — filter expressions
//!
//! Compiles a supported subset of SPARQL filter expressions to native machine code,
//! giving 5–10× speedup on hot numeric-filter queries.
//!
//! ## Supported subset
//!
//! - Numeric literals (xsd:integer, xsd:decimal, xsd:double, xsd:float, xsd:int, xsd:long)
//! - Variables (`?x` → `f64` slot loaded from a caller-provided slice)
//! - Comparisons: `<`, `>`, `<=`, `>=`, `=`, `!=`
//! - Arithmetic: `+`, `-`, `*`, `/`
//! - Logical: `&&`, `||`, `!`
//! - Built-ins: `ABS()`, `CEIL()`, `FLOOR()`, `ROUND()`
//!
//! ## Fall-back to interpreter
//!
//! Everything else (string ops, REGEX, ISIRI, ISBLANK, ISLITERAL, mixed types, …) returns
//! `None` from `try_lower` and the caller must delegate to the interpreted evaluator.
//!
//! # Phase c — hash-join key comparison
//!
//! Compiles a multi-key join comparator: given two `&[f64]` rows, returns `true` if all
//! configured key columns match. Supports epsilon (`|a-b| < 1e-9`) and exact (bitcast to
//! `i64`) comparison modes per column.
//!
//! # Phase c — ORDER BY evaluation
//!
//! Compiles a multi-column lexicographic comparator returning `-1 / 0 / 1` with per-column
//! ascending/descending flags baked into the native function.
//!
//! # Phase d — PROJECT/DISTINCT/HAVING codegen
//!
//! Three new operator families completing full SPARQL operator JIT coverage:
//!
//! ## PROJECT column extraction
//!
//! [`ProjectCompiler`] compiles column selection and reordering for the SPARQL PROJECT
//! and GROUP BY operators. The compiled function copies selected columns from a source
//! `f64` slice into a destination slice, performing a bounds check and returning `1` on
//! success or `0` on bounds error.
//!
//! ## DISTINCT deduplication hashing
//!
//! [`DistinctCompiler`] compiles an FNV-1a hash over selected key columns for DISTINCT
//! deduplication. Each selected column's `f64` bit pattern is incorporated into the
//! hash via bitcast to `i64`, ensuring that distinct NaN payloads hash differently.
//!
//! ## HAVING clause predicates
//!
//! [`HavingCompiler`] is a thin typed wrapper over [`FilterCompiler`] for HAVING clause
//! compilation. It validates that all variable references in the predicate expression
//! appear in the supplied aggregate-variable-to-index map before delegating to Cranelift
//! codegen. The resulting [`CompiledFilter`] evaluates the predicate when called with
//! aggregate result tuples as `f64` slices.
//!
//! # Feature gate
//!
//! All items in this module require the `jit` Cargo feature.
pub use ;
pub use ;
pub use ;
pub use JitFilterCache;
pub use ;
pub use ;
pub use ;