Liking cljdoc? Tell your friends :D

datajure.asof

Core sorted-merge algorithm for as-of join.

Part 1 — asof-search / asof-indices: asof-search — binary search for the last right index where value <= target. asof-indices — two-pointer merge over pre-sorted, pre-grouped vectors; public utility, not used internally by asof-match.

Part 2 — asof-match: full key-handling layer. Groups right rows by exact keys, sorts within each group, runs asof-search (binary search) per left row. Returns a lazy sequence of [left-row-idx right-row-idx-or-nil] pairs.

Part 3 — build-result: assembles a tech.v3.dataset from the index pairs. Left columns always present in original order; right non-key columns appended (nil-filled for unmatched rows). Conflicting non-key column names suffixed :right.<n>.

Core sorted-merge algorithm for as-of join.

Part 1 — asof-search / asof-indices:
  asof-search  — binary search for the last right index where value <= target.
  asof-indices — two-pointer merge over pre-sorted, pre-grouped vectors;
                 public utility, not used internally by asof-match.

Part 2 — asof-match: full key-handling layer. Groups right rows by exact
keys, sorts within each group, runs asof-search (binary search) per left
row. Returns a lazy sequence of [left-row-idx right-row-idx-or-nil] pairs.

Part 3 — build-result: assembles a tech.v3.dataset from the index pairs.
Left columns always present in original order; right non-key columns
appended (nil-filled for unmatched rows). Conflicting non-key column
names suffixed :right.<n>.
raw docstring

asof-indicesclj

(asof-indices left-vals right-vals)

Two-pointer merge: for each element in left-vals, return a long-array of the matched right-row index within right-vals (both must be pre-sorted ascending). Returns -1 for left rows with no match. Nil values are skipped.

Public utility — not used internally by asof-match, which uses asof-search (binary search per group) instead.

Two-pointer merge: for each element in `left-vals`, return a long-array
of the matched right-row index within `right-vals` (both must be pre-sorted
ascending). Returns -1 for left rows with no match. Nil values are skipped.

Public utility — not used internally by asof-match, which uses asof-search
(binary search per group) instead.
sourceraw docstring

asof-matchclj

(asof-match left right left-keys right-keys)

Produce index pairs for an as-of join.

Arguments: left — tech.v3.dataset right — tech.v3.dataset left-keys — vector of column keywords; last = asof col, rest = exact cols right-keys — vector of column keywords; same structure

Returns a lazy sequence of [left-row-idx right-row-idx-or-nil] pairs in left-row order. Unmatched left rows (no exact-key group, or asof-key earlier than all right asof-keys for that group) yield nil for right index.

Produce index pairs for an as-of join.

Arguments:
  left       — tech.v3.dataset
  right      — tech.v3.dataset
  left-keys  — vector of column keywords; last = asof col, rest = exact cols
  right-keys — vector of column keywords; same structure

Returns a lazy sequence of [left-row-idx right-row-idx-or-nil] pairs in
left-row order. Unmatched left rows (no exact-key group, or asof-key
earlier than all right asof-keys for that group) yield nil for right index.
sourceraw docstring

(asof-search right-vals n target)

Binary search: find the last index in sorted right-vals where value <= target. Nils in right-vals are treated as greater than any real value (they sort last), so a nil at mid causes the search to go left, not right. Returns -1 if no such element exists. Nil target returns -1.

Binary search: find the last index in sorted `right-vals` where value <= `target`.
Nils in right-vals are treated as greater than any real value (they sort last),
so a nil at mid causes the search to go left, not right.
Returns -1 if no such element exists. Nil target returns -1.
sourceraw docstring

build-resultclj

(build-result left right pairs right-keys)

Assemble the as-of join result dataset from index pairs.

Arguments: left — tech.v3.dataset (all rows preserved, in original order) right — tech.v3.dataset pairs — seq of [left-row-idx right-row-idx-or-nil] right-keys — right key columns (dropped from the appended right columns)

Returns a dataset with:

  • all left columns in original order
  • right non-key columns appended (nil-filled for unmatched rows)
  • conflicting non-key column names suffixed with :right.<n>
Assemble the as-of join result dataset from index pairs.

Arguments:
  left       — tech.v3.dataset (all rows preserved, in original order)
  right      — tech.v3.dataset
  pairs      — seq of [left-row-idx right-row-idx-or-nil]
  right-keys — right key columns (dropped from the appended right columns)

Returns a dataset with:
  - all left columns in original order
  - right non-key columns appended (nil-filled for unmatched rows)
  - conflicting non-key column names suffixed with :right.<n>
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close