Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
7548da2
feat(ipc): fire .ipc.on.close for outbound connections, report direct…
singaraiona Sep 10, 2026
d4b8711
Merge pull request #504 from RayforceDB/feat/ipc-close-symmetric
singaraiona Sep 10, 2026
13ed98f
fix(load): name the file and the OS cause when a script cannot be loaded
singaraiona Sep 10, 2026
42a4843
fix(app): a failed startup script under -p is fatal when not interactive
singaraiona Sep 10, 2026
4281317
feat(load): RAYFORCE_HOME fallback for relative paths, and `source` i…
singaraiona Sep 10, 2026
ff095ee
Merge pull request #510 from RayforceDB/feat/load-home-source
singaraiona Sep 10, 2026
58c1f5f
Merge pull request #509 from RayforceDB/fix/startup-script-fatal
singaraiona Sep 10, 2026
0e39bd8
Merge pull request #508 from RayforceDB/fix/load-error-path
singaraiona Sep 10, 2026
64088ca
perf(query): keep the keyed-upsert key map on the table instead of re…
ser-vasilich Sep 11, 2026
b7f5965
perf(query): let a single-row upsert use and maintain the table's key…
ser-vasilich Sep 11, 2026
c65f6fc
fix(datalog): semi-naive delta keyed by body position, fixes non-line…
singaraiona Sep 11, 2026
3342459
fix(datalog): repeated variable inside one atom enforces column equality
singaraiona Sep 11, 2026
d6fa485
fix(datalog): negated literal with no shared variables acts as a guard
singaraiona Sep 11, 2026
d7877cf
fix(datalog): typed constant filters — F64 columns compare, other typ…
singaraiona Sep 11, 2026
df8ef2a
fix(datalog): route source-provenance const match through dl_col_eq_r…
singaraiona Sep 11, 2026
770e189
fix(datalog): reject over-width find and unknown relations at admission
singaraiona Sep 11, 2026
ae166c5
fix(datalog): own expression trees per rule, free on every path
singaraiona Sep 11, 2026
e2170ef
test(datalog): warm the .sys.mem measurement path in the §2.1 leak test
singaraiona Sep 11, 2026
d7d45ee
test(datalog): re-bind lb0 to net out its own boxed-result cost
singaraiona Sep 11, 2026
822d9b6
fix(datalog): checked integer arithmetic — overflow and div-by-zero y…
singaraiona Sep 11, 2026
d1a7b2a
fix(datalog): tag symbol values in datoms so they never collide with …
singaraiona Sep 11, 2026
0d9095d
fix(datalog): a STR triple-pattern literal matches a SYM-tagged datom…
singaraiona Sep 11, 2026
5b997dd
perf(query): keep the key map across in-place insert and non-key update
ser-vasilich Sep 11, 2026
1296f5b
fix(datalog): tag hand-built SYM v columns, document range limit, mis…
singaraiona Sep 11, 2026
04bbb81
docs(datalog): describe the materialising evaluator, arithmetic contr…
singaraiona Sep 11, 2026
cbb229a
fix(mem): drop a table's key map when the table is copied
ser-vasilich Sep 11, 2026
9d3871c
Merge pull request #513 from RayforceDB/fix/datalog-audit
singaraiona Sep 11, 2026
7968a86
fix(group): size the hash-path agg VLAs by vla_aggs so table distinct…
singaraiona Sep 11, 2026
ac0f7f8
Merge pull request #516 from RayforceDB/fix/distinct-zero-agg-vla
singaraiona Sep 11, 2026
2e8bb5c
perf(alter): amend a sole-owned value in place instead of copying it
ser-vasilich Sep 12, 2026
c7e40d2
fix(query): use canonical text nulls and compact symbol grouping
singaraiona Sep 12, 2026
9b07af1
fix(query): preserve text fast paths with canonical nulls
singaraiona Sep 12, 2026
6e533ec
fix(docs): restore visible search results across screen sizes
singaraiona Sep 12, 2026
bc1eac9
Merge pull request #517 from RayforceDB/fix/text-null-grouping
singaraiona Sep 12, 2026
a36ee6a
Merge pull request #518 from RayforceDB/fix/docs-search
singaraiona Sep 12, 2026
84807fd
feat(idx): consult the hash index from vector-needle find / in / dict…
singaraiona Sep 12, 2026
771090a
fix(journal): preserve archives when rolls share a timestamp
belowzeroff Sep 13, 2026
1f9cddd
fix(idx): overflow guard in ray_index_carry_append without signed ove…
singaraiona Sep 13, 2026
5cc817b
Merge remote-tracking branch 'origin/dev' into perf/upsert-key-index
ser-vasilich Sep 13, 2026
b152d28
Merge branch 'perf/upsert-key-index' into fix/alter-inplace
ser-vasilich Sep 13, 2026
991702e
Merge pull request #520 from RayforceDB/feat/idx-vector-find
singaraiona Sep 13, 2026
932e6e7
Merge pull request #521 from belowzeroff/fix/journal-roll-archive-col…
singaraiona Sep 13, 2026
7b8b9f9
feat(mem): ray_shallow_bytes / ray_retained_bytes — the native footpr…
singaraiona Sep 13, 2026
2582d6f
Merge remote-tracking branch 'origin/dev' into perf/upsert-key-index
ser-vasilich Sep 13, 2026
1bfd9e2
Merge branch 'perf/upsert-key-index' into fix/alter-inplace
ser-vasilich Sep 13, 2026
fad0e13
feat(query): give the upsert key map tombstones and count them
ser-vasilich Sep 12, 2026
1654c0d
feat(query): delete, an in-place row removal that keeps the key map
ser-vasilich Sep 12, 2026
34957b4
fix(alter): keep the copy for a dotted target
ser-vasilich Sep 13, 2026
b16d5da
Merge branch 'fix/alter-inplace' into feat/delete-inplace
ser-vasilich Sep 13, 2026
4fbfbf5
fix(query): delete rebinds a quoted symbol even when the in-place gat…
ser-vasilich Sep 13, 2026
544f3df
Merge pull request #523 from RayforceDB/feat/footprint-bytes
singaraiona Sep 13, 2026
78c1713
fix(journal): propagate purge close errors
belowzeroff Sep 13, 2026
ddc1376
fix(cmp, expr): order integer atoms and run the integer arms of binar…
singaraiona Sep 13, 2026
e0d141f
fix(query,mem): three holes the key map opened, found by review
ser-vasilich Sep 13, 2026
ade4080
Merge branch 'fix/alter-inplace' into feat/delete-inplace
ser-vasilich Sep 13, 2026
7996123
Merge branch 'perf/upsert-key-index' into fix/alter-inplace
ser-vasilich Sep 13, 2026
24bafb9
Merge pull request #528 from RayforceDB/fix/i64-exact-ordering
singaraiona Sep 13, 2026
611b576
Merge pull request #527 from belowzeroff/fix/journal-purge-close-errors
singaraiona Sep 14, 2026
418b899
Merge remote-tracking branch 'origin/dev' into perf/upsert-key-index
ser-vasilich Sep 14, 2026
19b4a34
Merge branch 'fix/alter-inplace' into feat/delete-inplace
ser-vasilich Sep 14, 2026
e380107
Merge branch 'perf/upsert-key-index' into fix/alter-inplace
ser-vasilich Sep 14, 2026
0f96a7a
fix(idx): cover RAY_IDX_UKEY in ray_index_child_blocks
ser-vasilich Sep 14, 2026
10db098
Merge branch 'fix/alter-inplace' into feat/delete-inplace
ser-vasilich Sep 14, 2026
912c2b2
Merge branch 'perf/upsert-key-index' into fix/alter-inplace
ser-vasilich Sep 14, 2026
8168a28
test(query): pin that a copied table does not carry the key map
ser-vasilich Sep 14, 2026
0878f61
test(query): cover delete over a parted table
ser-vasilich Sep 14, 2026
79f03ae
Merge pull request #526 from RayforceDB/feat/delete-inplace
singaraiona Sep 14, 2026
fc49366
Merge pull request #525 from RayforceDB/fix/alter-inplace
singaraiona Sep 14, 2026
29e2476
Merge pull request #512 from RayforceDB/perf/upsert-key-index
singaraiona Sep 14, 2026
c53db8c
chore: merge master back into dev after the v2.6.2 release (#502) so …
singaraiona Sep 14, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 99 additions & 83 deletions docs/assets/extra.css

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions docs/docs/c-api/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,32 @@ Decrements the reference count. When `rc` reaches zero, the object and any owned
void ray_release(ray_t* v);
```

### ray_shallow_bytes / ray_retained_bytes

How many bytes of native memory a value stands for, so an embedding runtime (an OCaml or Python binding that wraps a `ray_t*` in a finalized object) can charge its garbage collector for the wrapper. Neither call allocates on the Rayforce heap.

```c
size_t ray_shallow_bytes(const ray_t* v);
size_t ray_retained_bytes(const ray_t* v);
```

`ray_shallow_bytes` is what this value's own release gives back: the block the allocator committed for it (header plus capacity; a buddy block is a power of two, a large direct block its exact page-rounded mapping) plus the private storage that no public API hands out on its own and that only this value releases:

- a long string atom's payload and a GUID atom's payload;
- a string vector's pool;
- an attached accelerator index with its tables;
- a file-mapped column's mapping (a splayed string column's region is charged to the column; the pool block inside it reports 0).

Values that are reachable but are values in their own right are **not** included: list elements, table and dict slots, lambda parts, a slice's parent. A table and its separately wrapped columns are therefore never charged twice; a slice reports only its header block. Non-owning values report 0: the null and OOM singletons, arena-allocated values, borrowed blocks, an index that is a passenger in a column's mapping. A string pool shared by copy-on-write copies of one vector is charged to each copy. Symbol domains, lazy DAGs and opaque native handles (HNSW, graph) are outside the accounting.

`ray_retained_bytes` is the shallow figure of the value plus that of everything reachable through ownership edges (list elements, table and dict slots, lambda parts, slice parents, parted segments), each distinct block counted once. Sharing inside the walked graph is not double counted, but two calls on two values that share children both report the shared part. Use it for diagnostics; drive GC pressure with the shallow figure.

```c
ray_t* col = ray_vec_new(RAY_I64, 1000000);
/* ... */
caml_alloc_custom_mem(&ops, sizeof(ray_t*), ray_shallow_bytes(col)); /* OCaml: charge the GC */
```

### ray_cow

Copy-on-write: if `v` is the sole owner (`rc == 1`), returns `v` unchanged. Otherwise, creates a deep copy and returns it with `rc = 1`. The original is not modified. After `ray_cow()`, if the returned pointer differs from the original, the caller must release it on error paths.
Expand Down
62 changes: 55 additions & 7 deletions docs/docs/guides/datalog-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,15 @@ Use `_` to match any value without binding it to a variable:

### How queries compile to the DAG

Under the hood, each query compiles to Rayforce's DAG execution pipeline:

- Each triple pattern `(?e :attr ?v)` becomes a `ray_scan` + `ray_filter` on the datoms table
- Shared variables across patterns become `ray_join` operations
- The `find` clause becomes a final projection selecting the requested columns
- The optimizer applies predicate pushdown, filter reorder, and fusion — the same passes used for `select`
Under the hood each rule is evaluated by materialisation: every positive body
atom is filtered on its constants and repeated variables, joined with the
accumulated result on shared variables (hash join, morsel-parallel), then
negations, comparisons, assignments and aggregates are applied in declared
order, and the head projection is de-duplicated and merged into the derived
relation. Recursive rules run to fixpoint with semi-naive evaluation. Joins
execute on the same operators as `select`, but a whole rule is not planned as
one DAG: body atoms are joined in the order written, and comparisons are
applied after the joins that bind their variables.

## Negation

Expand Down Expand Up @@ -459,7 +462,52 @@ Every Datalog concept compiles down to existing Rayforce DAG operations. The Dat

!!! note "Performance"

Because Datalog compiles to the same DAG as `select`/`update`, queries benefit from all optimizer passes: predicate pushdown, filter reorder, fusion, and morsel-parallel execution with SIMD.
Joins and distinct inside a rule use the parallel `select` operators. Rule-level
join ordering, predicate pushdown across atoms and plan reuse between queries are
not performed; write the most selective atom first.

## Constants in patterns

In a `where` clause or rule body, a quoted symbol (`'Alice`) or keyword
(`:name`) is a literal; a bare unquoted symbol (`sid`) is evaluated as a
variable reference to a bound value (integer, float, symbol or string). Head
arguments still treat a bare symbol as a literal constant.

## Arithmetic

Integer expressions in `(= ?y (+ ?x 1))` and comparisons are 64-bit and checked:
overflow, division by zero, `INT64_MIN / -1` and any null operand produce the
null integer `0Nl`. Float expressions follow IEEE 754 (division by zero gives
`0Nf`). The error code surfaced for a failed query evaluation is `domain`.

## Limits

| Limit | Value | On overflow |
|---|---|---|
| Variables in `find` | 16 | error `find supports at most 16 variables` |
| Arity of a relation | 16 | error at rule or EDB registration |
| Body literals per rule | 16 | error `too many body literals` |
| Rules per program | 128 | error `too many rules` |
| Relations per program | 64 | error |
| Strata | 16 | error |
| Group keys in an aggregate | 8 | error |

An unknown relation name in a body is an error (`unknown relation 'name'`),
not an empty result.

## Symbol storage

`assert-fact` stores symbol values in the `v` column with a type tag, so the
symbol `'Alice` and the integer equal to its intern id are different values.
Query results, `pull` and `scan-eav` return the plain intern id; use `sym-name`
to read it back. Inspecting the raw datoms table shows the tagged encoding.

A datoms table whose `v` column is a real symbol vector (hand-built or
loaded) is also recognised as holding symbols. A legacy table whose `v`
column holds bare integer intern ids is not — those integers stay integers
and are not matched against a symbol or keyword literal. Positive integer
values of 2^61 and above cannot be stored in the `v` column or returned
from a query without being masked; this is a limit of the tag encoding.

## Complete Example

Expand Down
2 changes: 1 addition & 1 deletion docs/docs/language/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ Cross-temporal comparisons are supported: dates, times, and timestamps are all c
| `read-bytes` | unary | Read file contents as a `U8` byte vector | `(read-bytes "file.bin")` |
| `write` | binary | Write a string to a file | `(write "file.txt" "content")` |
| `write-bytes` | binary | Write a `U8` byte vector to a file | `(write-bytes "file.bin" bytes)` |
| `load` | unary | Load and evaluate a Rayfall script | `(load "lib.rfl")` |
| `load` | unary | Load and evaluate a Rayfall script; a relative path is tried against the working directory, then below `RAYFORCE_HOME` | `(load "lib.rfl")` |

## Control Flow

Expand Down
7 changes: 7 additions & 0 deletions docs/docs/namespaces/sys.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ Signature: `(.sys.args)`. Returns the process's command-line arguments as a dict
| `querylog` | bool | `-Q` | Query-statistics logging enabled at startup. |
| `interactive` | bool | `-i` | Force the REPL after a script. |
| `log` | str | `-l` / `-L` | Journal base path; empty if none. |
| `source` | str | — | The file currently being evaluated: the innermost `load`, or the command-line script, by the path that was actually opened. Empty at the REPL, under a pipe, or in a hook or timer that runs outside any file. `file` is the script named on the command line (`$0`); `source` follows nested loads (`$BASH_SOURCE`). |
| `user` | dict | after `--` | The application's own arguments. |

The top-level schema is **stable** — every launcher key is always present with its effective value (the default when the flag wasn't passed), so `(get (.sys.args) 'port)` never misses. Auth passwords (`-u` / `-U`) are deliberately **not** exposed.

```lisp
;; load a sibling of the running file, whichever directory it was started from
(set here (str-join (drop -1 (split (at (.sys.args) 'source) "/")) "/"))
(load (concat here "/lib.rfl"))
```

**`user` parsing.** Tokens after `--` are paired `-key value` / `--key value`: a token starting with `-` is a key (leading dashes stripped to a symbol), and the next token is its value — unless that token also starts with `-`, in which case the value is the empty string (a bare flag). Duplicate keys keep the last value.

```lisp
Expand Down
16 changes: 11 additions & 5 deletions docs/docs/queries/attributes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Semantic properties stamped onto columns — `sorted`, `unique`, `grouped`, `parted`. Where an [accelerator index](indexes.md) is a *physical* structure (a hash table, a permutation), a column attribute is an *assertion about meaning*: this column is non-descending, these values are distinct. The `.attr.*` family layers over the same storage as `.idx.*`, but its contract is semantic, not structural.

!!! note "v1 status"
The four attributes, their strict verify-on-set kernels, and the `(.attr.*)` Rayfall surface are shipped. `sorted` and `unique` are numeric; the backing-index attributes `grouped` and `parted` also support symbol columns.
The four attributes, their strict verify-on-set kernels, and the `(.attr.*)` Rayfall surface are shipped. `sorted` and `parted` are numeric (`parted` also takes symbols); `unique` and `grouped` take numeric, symbol and string columns.

## Why Attributes Are Separate from Indexes

An [accelerator index](indexes.md) answers *"what structure is attached?"* — a zonemap, a hash table, a sort permutation. A column attribute answers a different question: *"what is semantically true of these values?"* The two markers (`sorted`, `unique`) carry no allocation at all — they are cheap flags. The two backing-index attributes (`grouped`, `parted`) do reuse the index layer underneath (so a `grouped` or `parted` column also shows up via `.idx.has?` and `.idx.info`), but `.attr.*` exists to assert a *property* the engine can trust, not merely to build a structure.

The payoff is that consumers can trust a stamped attribute unconditionally. Besides the [as-of join executor](joins.md#pre-sorted-fast-path), filters and grouped aggregation use the physical layout directly.
The payoff is that consumers can trust a stamped attribute unconditionally. Besides the [as-of join executor](joins.md#pre-sorted-fast-path), filters and grouped aggregation use the physical layout directly, and a keyed lookup against a `grouped` vector — `find` or `in` with a vector of needles, `at` on a dict keyed by it — probes the hash once per needle instead of building one over the whole vector per call.

## The Four Attributes

Expand Down Expand Up @@ -108,7 +108,9 @@ But a column holds at most one backing index — setting `grouped` or `parted` r

## Conservative Propagation

Attributes propagate **conservatively**. Only operations that trivially preserve the values — a refcount / copy-on-write copy, a plain rebind — keep the attributes. *Any* transform that could change ordering, length, or values (arithmetic, `filter` / `where`, `reverse`, `concat`, reordering `take`) **drops** them. This keeps the invariant honest: a held attribute always reflects the current bytes.
Attributes propagate **conservatively**. Only operations that trivially preserve the values — a refcount / copy-on-write copy, a plain rebind — keep the attributes. *Any* transform that could change ordering, length, or values (arithmetic, `filter` / `where`, `reverse`, reordering `take`) **drops** them. This keeps the invariant honest: a held attribute always reflects the current bytes.

One append shape is the exception. `(concat v rows)` and `(concat v atom)` on a `grouped` vector keep the hash (and a `unique` marker) when **every appended key is new** — the existing groups are copied and each appended row becomes a group of its own, so an append-only keyed vector never pays a rebuild. An appended row that repeats a key, a null, or a symbol from another domain leaves the result a plain vector, exactly as before; `sorted` is always dropped by `concat`.

```lisp
; Arithmetic drops the marker (and a backing index).
Expand All @@ -119,6 +121,10 @@ Attributes propagate **conservatively**. Only operations that trivially preserv
(.attr.get (reverse (.attr.set 'sorted [1 2 3]))) ; ⇒ no attributes
(.attr.get (concat (.attr.set 'sorted [1 2 3]) [0 1])) ; ⇒ no attributes

; An append of NEW keys carries a hash index (and `unique`); a repeat drops it.
(.attr.get (concat (.attr.set 'unique (.attr.set 'grouped [1 2 3])) [4 5])) ; ⇒ ['unique 'grouped]
(.attr.get (concat (.attr.set 'grouped [1 2 3]) [3])) ; ⇒ no attributes

; Plain rebind preserves.
(set _s (.attr.set 'sorted [1 2 3]))
(.attr.get _s) ; ⇒ ['sorted]
Expand Down Expand Up @@ -162,9 +168,9 @@ For a partitioned join `(asof-join [Key Time] L R)`, if the single numeric equal

## Caveats and Limits

- **Type support.** `sorted` and `unique` accept numeric types. `grouped` and `parted` also accept `SYM`; `STR` remains unsupported.
- **Type support.** `sorted` accepts numeric types; `parted` numeric and `SYM`. `unique` and `grouped` accept numeric, `SYM` and `STR` — a `STR` hash is keyed on a 64-bit hash of the bytes with the payload compared on every hit, so a content-keyed column (a digest) carries an index like any other. A `STR` `grouped` column persists its hash through a splayed save in place of the automatic string dictionary (one index per column).
- **Strict verify, no silent stamping.** `.attr.set` errors on violation rather than recording a property it cannot confirm; this is what lets consumers trust the stamp unconditionally.
- **Conservative propagation.** Only copy / rebind preserve attributes; every transform drops them. Re-assert with `.attr.set` after a transform.
- **Conservative propagation.** Only copy / rebind preserve attributes; every transform drops them, except an append of new keys onto a `grouped` vector (see above). Re-assert with `.attr.set` after any other transform.
- **One backing index per column.** `grouped` and `parted` share the [accelerator-index](indexes.md) slot, so a column carries at most one of them at a time; the markers are separate and free.

## Quick Reference
Expand Down
13 changes: 9 additions & 4 deletions docs/docs/queries/indexes.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ The executor consults indexes at five sites. Each site has a specific consumpti
| `.idx.hash` / `part` backing | `where key IN …` + `group by key` | Resolve only the requested key slices and aggregate them directly, skipping filter scan and group discovery. Part slices stream as contiguous ranges. |
| `.idx.sort` | ORDER BY — single ascending key | The pre-built permutation is reused directly rather than re-sorting. Descending ORDER BY falls back to recompute (reversing the perm would swap tie-group positions relative to stable DESC sort). |
| `.idx.sort` | `distinct` | Walk the sort permutation once to collect first-occurrence row ids per distinct value — O(n) with no hash table. SYM/GUID/STR columns fall back. |
| `.idx.hash` | `find` | Hash-chain probe returns the minimum row id matching the needle, or a provably-absent signal. Integer-family needles only; float and cross-family needles fall through to the scan. |
| `.idx.hash` | `find` | Hash-chain probe returns the minimum row id matching the needle, or a provably-absent signal. Integer-family, `SYM` and `STR` needles against a column of the same family; float and cross-family needles fall through to the scan. A **vector** of needles probes once per needle — nothing is built per call. |
| `.idx.hash` | `in` — `(in needles v)` with `v` indexed, and `(at d keys)` on a dict keyed by an indexed vector | One probe per needle, same type matrix as `find`. Without an index, `find` / `in` hash whichever side is smaller and scan the other once. |

### Eligibility conditions (uniform)

Expand All @@ -34,7 +35,7 @@ All five sites apply the same prechecks before consulting an index:
- **Not parted / not MAPCOMMON:** parted and MAPCOMMON columns skip routing at the filter and IN sites.
- **Default table:** filter and IN sites only route columns from the query's default table (non-default table references are skipped).

Mutation auto-drops the attached index — the in-place mutators (`(insert 'v val)`, `(alter 'v set i val)`, `(alter 'v concat vals)`) call `ray_index_drop()` before writing, so a mutated column always has `HAS_INDEX` clear afterward. Reattach explicitly after the write.
Mutation auto-drops the attached index — the in-place mutators (`(insert 'v val)`, `(alter 'v set i val)`) call `ray_index_drop()` before writing, so a mutated column always has `HAS_INDEX` clear afterward. Reattach explicitly after the write. The one append that keeps a hash index is `concat` (and `(alter 'v concat vals)`, which rebinds to a `concat` result) when every appended key is new — see [Common Workflows](#common-workflows).

### Fallback guarantee

Expand Down Expand Up @@ -93,7 +94,7 @@ Each kind has a one-arg attach builtin. Attaching is idempotent — if a differ

`(.idx.zone v) (.idx.hash v) (.idx.sort v) (.idx.bloom v)`

Attach an index of the named kind to a vector `v`. Returns the column with the new index attached (the underlying values are unchanged). All kinds accept the numeric/boolean types `RAY_BOOL`, `RAY_U8`, `RAY_I16`, `RAY_I32`, `RAY_I64`, `RAY_F32`, `RAY_F64`, `RAY_DATE`, `RAY_TIME`, `RAY_TIMESTAMP`; `.idx.hash` **additionally** accepts `RAY_SYM`. `RAY_STR` (and `RAY_SYM` on the non-hash kinds) is deferred to v2.
Attach an index of the named kind to a vector `v`. Returns the column with the new index attached (the underlying values are unchanged). All kinds accept the numeric/boolean types `RAY_BOOL`, `RAY_U8`, `RAY_I16`, `RAY_I32`, `RAY_I64`, `RAY_F32`, `RAY_F64`, `RAY_DATE`, `RAY_TIME`, `RAY_TIMESTAMP`; `.idx.hash` **additionally** accepts `RAY_SYM` (keyed on domain ids) and `RAY_STR` (keyed on a 64-bit hash of the bytes, payload compared on every hit). `RAY_SYM` / `RAY_STR` on the non-hash kinds is deferred to v2.

### Examples

Expand Down Expand Up @@ -133,7 +134,7 @@ Indexed columns participate in normal operations transparently. `(sum vh)`, `(a

### Mutation Drops the Index

The Rayfall in-place mutators — `(insert 'v val)` for append and `(alter 'v set i val)` / `(alter 'v concat val)` for set / append — invalidate the attached index. The mutator paths drop the index transparently, restore the original nullmap bytes, and proceed with the write. Subsequent `(.idx.has?)` calls return false; reattach the index after the write if you want index routing on the updated column.
The Rayfall in-place mutators — `(insert 'v val)` for append and `(alter 'v set i val)` for set — invalidate the attached index. The mutator paths drop the index transparently, restore the original nullmap bytes, and proceed with the write. Subsequent `(.idx.has?)` calls return false; reattach the index after the write if you want index routing on the updated column. `(alter 'v concat val)` rebinds `v` to `(concat v val)`, so a hash index survives it when every appended key is new (see below).

```lisp
(set v [5 1 9 3 7])
Expand All @@ -157,9 +158,13 @@ An accelerator index uses bytes 0–7 of the column's [nullmap union](https://gi
(in 700 v) ; ⇒ true (700 = 7 × 100) — hash-chain probe
(in 701 v) ; ⇒ false
(find v 700) ; ⇒ 100 — hash fast path returns minimum row id
(find v [700 701 6993]) ; ⇒ [100 0N 999] — one probe per needle
(in [700 701] v) ; ⇒ [true false]
(set v (.idx.drop v)) ; optional early release; mutators auto-drop
```

An append of new keys keeps the hash: `(concat v [7000 7007])` carries the index over (see [Attributes — Conservative Propagation](attributes.md#conservative-propagation)); an appended repeat drops it as before.

### Range scans on a stable column

```lisp
Expand Down
Loading
Loading