jvm.chisel.db.join

Direct-mapped hash join, split into a build stage (construct a hash table from build-side keys) and a probe stage (look a probe-side key up). Reuses the jvm.chisel.db/mhash bucket function and mirrors the bloom/scan/reduce convention: a pure *-ref reference model, composable *-data fragments, and *-module builders.

Collision semantics are last-writer-wins: every build key maps to exactly one bucket; if two build keys collide, the later lane wins. The reference and the hardware implement the identical rule, so they agree by construction (see join-test). Chaining / open addressing is a later enhancement.

This is the operator only. Join has two inputs (build + probe); wiring it into the plan/pipeline as a DAG node is a separate slice.

build-table-data

(build-table-data keys-vec valid-mask lanes width buckets k)

Hardware fragment: combinational direct-mapped hash-table build. keys-vec is a Vec of lanes UInt(width), valid-mask a UInt(lanes). Returns {:valid UInt(buckets) :keys clojure-vector-of-buckets-Data}, last-wins.

join-build-module

(join-build-module {:keys [lanes width buckets k name], :or {name "JoinBuild", k 158}})

Build module. opts: {:lanes n :width w :buckets B :k K :name “JoinBuild”}. Inputs: keyslanes, validMask. Outputs: tableValid (UInt B), tableKeys (Vec B UInt w).

join-build-ref

(join-build-ref build-keys valid-mask width buckets k)

Build a direct-mapped hash table from build-keys (seq of ints) gated by valid-mask (int bitmask). Returns {:valid int :keys vector} where :keys is a length-buckets vector (0 for empty buckets) and :valid is the bucket bitmask. Last-writer-wins on collision. buckets must be a power of two.

join-probe-data

(join-probe-data probe-key table-valid table-keys width buckets k)

Hardware fragment: probe table-valid (UInt(buckets)) / table-keys (Vec(buckets,UInt(width))) with probe-key (UInt(width)). Returns a Bool Data.

join-probe-module

(join-probe-module {:keys [width buckets k name], :or {name "JoinProbe", k 158}})

Probe module. opts: {:width w :buckets B :k K :name “JoinProbe”}. Inputs: key, tableValid (UInt B), tableKeys (Vec B UInt w). Output: match (Bool).

join-probe-ref

(join-probe-ref probe-key table width buckets k)

Probe table (from join-build-ref) with probe-key. True iff the probe key’s bucket is valid and holds probe-key.