jvm.chisel.db.estimate
Cardinality-driven cost estimation: the hand-written precursor of the learned cost model (the “AI inside the chip”). Pure data in, number out, so it drops straight into the :cost-fn seam of schedule/schedule and cluster/admit — neither control plane changes, and a learned model can later replace this one function.
The model is deliberately textbook: * every value lives in the width-bit domain D = 2^width, uniform; * a predicate keeps a fraction of the domain (:eq 1/D, :gte c → (D-c)/D, …); * multiple predicates multiply (independence assumption); * :bloom-probe keeps the false-positive fraction of a filter loaded with the estimated input rows; * :join-probe keeps probe-rows × min(1, build-rows/D) — the fraction of the key domain present in the build table; * :hash and :join-build pass rows through; :reduce emits one row.
Cost unit = row-cycles: the sum over nodes of the (ceiled) input cardinality — what the work costs one pass wide. For a full-selectivity linear plan this equals schedule/estimate-cost (lanes × nodes), so a selective plan can only ever bid the default estimate down.
cardinalities
(cardinalities plan)Estimated output cardinality per node id — the inspectable intermediate a scheduler (or a human) uses to see where the plan actually narrows.
estimate-cost
(estimate-cost plan)(estimate-cost plan factors)Drop-in :cost-fn: row-cycles = Σ ceil(input cardinality) over all nodes. Full-selectivity linear plans reproduce schedule/estimate-cost. The 2-arity applies per-kind correction factors (see node-flows) — observe/make-cost-fn is the intended caller.
pred-selectivity
(pred-selectivity width [op c])Fraction of the width-bit domain one predicate keeps, assuming a uniform domain. Unknown ops are conservative (1.0 — keep everything).