Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
176 commits
Select commit Hold shift + click to select a range
89eed55
v2.4.0 (#327)
singaraiona Jul 11, 2026
eb66eed
feat(query): support live inserts into parted tables
singaraiona Jul 14, 2026
bbdc419
fix(core): restore total-core -c semantics
singaraiona Jul 15, 2026
9961388
fix(parse) Fix nonstring if not defined
protocolstardust Jul 16, 2026
6cac6e8
Merge pull request #330 from protocolstardust/dev
protocolstardust Jul 16, 2026
f44ab81
Merge branch 'master' into dev
singaraiona Jul 16, 2026
49d8524
fix(store): surface FlushFileBuffers failure in journal SYNC mode (#335)
belowzeroff Jul 18, 2026
cb1c6cd
fix(hnsw): reject build dims whose vector count overflows size_t (#333)
belowzeroff Jul 18, 2026
7475949
fix(store): read full link sidecar to avoid wrong-symbol truncation (…
belowzeroff Jul 18, 2026
ebadd07
fix(hnsw): reject index files whose vector count overflows size_t (#332)
belowzeroff Jul 21, 2026
fa39d9d
fix(docs): remediate F-0001 F-0005 F-0007
singaraiona Jul 22, 2026
ffd784f
fix(docs): remediate CF-0001
singaraiona Jul 22, 2026
1f27e61
fix(docs): remediate CF-0002
singaraiona Jul 22, 2026
465e58e
chore(audit): plan CF-0003 ratification
singaraiona Jul 22, 2026
8f8033c
fix(docs): remediate CF-0003
singaraiona Jul 22, 2026
3ae79f5
feat(docs): redesign website and documentation
singaraiona Jul 22, 2026
5dc8265
Merge branch 'master' into dev
singaraiona Jul 22, 2026
4d2c8f3
fix(null): avoid f64 null casts to integers (#340)
belowzeroff Jul 23, 2026
4e49626
fix(expr): avoid null truthiness casts in fallback binary ops (#339)
belowzeroff Jul 23, 2026
a05886d
ci: make Rayforce audit PR comments best-effort
singaraiona Jul 23, 2026
6ca3d8a
ci: publish Rayforce audit comments from trusted workflow
singaraiona Jul 23, 2026
04d8f3d
ci: resolve fork PRs for audit commenter
singaraiona Jul 23, 2026
6acdc2c
perf: parallelize serial stages around group-by; unify binary-agg nul…
ser-vasilich Jul 23, 2026
a53d98e
Merge branch 'master' into dev
singaraiona Jul 23, 2026
260e018
fix(aggr): preserve slice nullability in binary groups
singaraiona Jul 23, 2026
492c5db
fix(expr): avoid f64 null cast in fallback idiv integer output (#344)
belowzeroff Jul 23, 2026
d250108
fix(group): avoid f64 null read cast in dense aggs (#343)
belowzeroff Jul 23, 2026
95f0a3d
fix(ipc): preserve boxed data list args (#346)
belowzeroff Jul 24, 2026
e10d1ab
fix(group): avoid f64 null cast in DA reads (#348)
belowzeroff Jul 24, 2026
842acc0
ci: use portable march for fuzz jobs (#347)
belowzeroff Jul 24, 2026
84cea17
chore(release): merge master into dev
singaraiona Jul 24, 2026
7a5839e
fix(pivot): preserve generic missing cells as null (#350)
belowzeroff Jul 27, 2026
57628fb
fix(xbar): avoid narrow bucket truncation (#351)
belowzeroff Jul 28, 2026
d7a1f6f
Merge branch 'master' into dev
singaraiona Jul 28, 2026
c501ae0
fix(arith): reject float temporal operands (#353)
belowzeroff Jul 29, 2026
aea9bda
fix(ops): make nested (LIST) columns usable through a parted view (fi…
singaraiona Jul 30, 2026
0605f1a
fix(query): preserve temporal arithmetic semantics (#354)
belowzeroff Jul 30, 2026
282d3a1
Merge branch 'master' into dev
singaraiona Jul 30, 2026
17bf2b8
ci: skip audit comments for cancelled runs
singaraiona Jul 30, 2026
05c8078
fix(query): preserve if temporal branch types (#359)
belowzeroff Jul 31, 2026
488a296
fix(store): reject duplicate splayed column names (#360)
belowzeroff Aug 3, 2026
5684559
fix(builtins): reject malformed strings in TIMESTAMP cast (#361)
belowzeroff Aug 3, 2026
c9b9a66
fix(store): support nested column inserts and persistence (#365)
singaraiona Aug 3, 2026
4c0fa46
fix(eval): enforce restricted mode in compiled lambdas (#366)
singaraiona Aug 3, 2026
8c9300b
feat(core): add bounded poll step for embedders (#367)
singaraiona Aug 3, 2026
3c79632
Merge branch 'master' into dev
singaraiona Aug 3, 2026
9b05f60
fix(test): rely on public runtime declarations (#369)
belowzeroff Aug 4, 2026
add3498
feat: website add consumer
singaraiona Aug 4, 2026
9d255c2
Merge branch 'master' into dev
singaraiona Aug 4, 2026
a1dcfd9
feat(core): expose restricted poll mode (#372)
singaraiona Aug 4, 2026
d5d5240
fix(aggr): preserve grouped nested first and last
singaraiona Aug 4, 2026
c35fa2b
Merge branch 'master' into dev
singaraiona Aug 4, 2026
2cfc70e
fix(join): preserve nested columns (#376)
singaraiona Aug 4, 2026
ac9d0cc
Merge branch 'master' into dev
singaraiona Aug 4, 2026
2fa0fbd
fix(csv): round-trip signed and >=24h TIME values in .csv.read (#379)
belowzeroff Aug 4, 2026
959db02
fix(str): propagate null start/length in substr instead of overflowin…
belowzeroff Aug 4, 2026
2083f24
fix(builtins): clamp out-of-range float in scalar numeric casts (#380)
belowzeroff Aug 5, 2026
5419053
Merge branch 'master' into dev
singaraiona Aug 5, 2026
c731b42
fix(builtins): validate bounds in DATE string cast (#382)
belowzeroff Aug 6, 2026
93db5ce
perf(aggr): specialize reduction scans (#383)
singaraiona Aug 6, 2026
e71798a
perf(collection): parallel radix distinct for fixed-width columns (#384)
protocolstardust Aug 6, 2026
8d6466f
fix(csv): harden import cancellation and schema handling (#387)
singaraiona Aug 7, 2026
8a1cf0c
fix(temporal): guard int64 overflow in DATE/TIMESTAMP decomposition (…
belowzeroff Aug 9, 2026
7bf522a
fix(eval): materialize lazy values at compiled boundaries (#391)
singaraiona Aug 11, 2026
caa529d
fix(arith): wrap scalar integer add/sub/mul on overflow instead of UB…
belowzeroff Aug 11, 2026
a2607ac
fix(builtins): reject malformed strings in TIME cast (#389)
belowzeroff Aug 11, 2026
a14ba5c
Merge branch 'master' into dev
singaraiona Aug 11, 2026
5aa47a5
fix(builtins): validate hex digits and dash layout in GUID string cas…
belowzeroff Aug 12, 2026
d1d256e
feat(core): address Data Vault workflow gaps (#395)
singaraiona Aug 12, 2026
f1d1b71
feat(io): add binary file read and write (#396)
singaraiona Aug 12, 2026
9a4ea60
Merge branch 'master' into dev
singaraiona Aug 12, 2026
776b290
fix(store): repair legacy string hash caches (#398)
singaraiona Aug 12, 2026
afbcf69
fix(builtins): reject trailing garbage and overflow in numeric string…
belowzeroff Aug 13, 2026
31d8970
fix(query): reject STR equality keys in asof-join and window-join (#400)
belowzeroff Aug 14, 2026
95defb7
fix(store): support LIST columns in parted fill (#402)
singaraiona Aug 14, 2026
4098f8b
fix(exec): propagate str_pool in OP_HEAD/OP_TAIL flat-column copies (…
singaraiona Aug 14, 2026
55c6e22
fix(query): evaluate whole-column aggregate args once in ungrouped se…
singaraiona Aug 14, 2026
bafb435
fix(group): sign-extend narrow keys in the DA accumulate loops
singaraiona Aug 14, 2026
4c0ed09
perf(group): size filtered group-by work from the surviving rows (Cli…
singaraiona Aug 14, 2026
68ace96
perf(agg): fix radix hash-bit overlap and rehash ladders in the v2 gr…
singaraiona Aug 15, 2026
76c50e3
perf(group): prime fat-entry radix payload buffers to expected load
singaraiona Aug 15, 2026
75b6901
feat(store): decide hash-vs-zone indexes at csv->splayed conversion; …
singaraiona Aug 15, 2026
2dc9cff
perf(group): route wide-domain SYM emit-filter groups to the parallel…
singaraiona Aug 15, 2026
e9c2d64
perf(group): tighten emit-filter v2 rerouting gates
singaraiona Aug 15, 2026
07ff419
perf(agg): memset the phase-3 order map instead of a scalar -1 loop
singaraiona Aug 15, 2026
399f9dd
perf(agg): parallelize the phase-3 stable-order scatter and compaction
singaraiona Aug 15, 2026
6357a2c
perf(pool): default worker auto-sizing to physical cores, not SMT thr…
singaraiona Aug 15, 2026
212fff3
perf(mem): reuse cache for direct (large) allocations
singaraiona Aug 15, 2026
1842700
fix(mem): public drain for the direct reuse cache + watermark test co…
singaraiona Aug 15, 2026
1ae57b9
refactor(mem): derive the direct-cache budget instead of an env knob
singaraiona Aug 15, 2026
d5867b6
perf(mem): raise the direct-cache cap to 4GB for 100M-row scale
singaraiona Aug 15, 2026
5d318ec
perf(group): pipelined slot prefetch in the v2 direct-insert phase1
singaraiona Aug 15, 2026
88c95bb
test(group): pin high-cardinality radix_v2 group shapes before partit…
singaraiona Aug 15, 2026
f30b578
fix(test): cast I32 key column to ensure radix_v2 path exercises I32 …
singaraiona Aug 15, 2026
9768280
perf(group): partition-major morsel batching in radix_v2 phase1
singaraiona Aug 15, 2026
34c9be0
perf(group): sparse touched-partition histogram + u32 partition ids i…
singaraiona Aug 15, 2026
0ac9aa4
feat(group): fused grouped count-distinct kernel (unwired)
singaraiona Aug 15, 2026
9959cbf
fix(cdfuse): guard dropped dispatch tasks; strengthen fused-cd tests
singaraiona Aug 15, 2026
0c68d3b
perf(query): route single-key unfiltered count-distinct through the f…
singaraiona Aug 15, 2026
94e28b9
perf(cdfuse): pair-hash partitioning with additive per-key merge (ske…
singaraiona Aug 15, 2026
125336f
perf(cdfuse): parallel key-bucketed merge phase
singaraiona Aug 15, 2026
66dcdd2
fix(cdfuse): asymmetric pair-hash combine (k==v cancellation cliff)
singaraiona Aug 15, 2026
c0cf496
fix(cdfuse): memory admission gate, SYM + boundary coverage, self-con…
singaraiona Aug 15, 2026
f3b2cbb
perf(mem): drop the direct-cache absolute cap; watermark/16 is the bound
singaraiona Aug 15, 2026
f1aaa73
perf(query): push a positive take: into grouped DAGs and bound v2's emit
singaraiona Aug 15, 2026
5684d4c
fix(query): guard the grouped take: pushdown and trim LIST columns
singaraiona Aug 15, 2026
2dd36e9
fix(query): pin the parted take guard, drop the take_pre allocation
singaraiona Aug 15, 2026
5784c19
perf(group): packed narrow-key fast path in the fat-entry radix pipeline
singaraiona Aug 15, 2026
ab5053a
fix(group): restore packed-key hash lockstep in the fused radix path
singaraiona Aug 15, 2026
701c7b8
test(group): pin F64 packed-key exclusion; honest 9-key test comment
singaraiona Aug 15, 2026
16bd46d
perf(group): prefetched partition-major probe for COUNT/SUM/AVG near-…
singaraiona Aug 16, 2026
ead2fff
fix(group): bound the grow_cap jump and keep it off the row array
singaraiona Aug 16, 2026
f2fba93
perf(group): parallelize the top-N group compaction
singaraiona Aug 16, 2026
bd9e743
fix(group): guard the top-N pre-pass against a cancelled dispatch
singaraiona Aug 16, 2026
853b3d3
perf(temporal): parallelize the extract/truncate kernels over the pool
singaraiona Aug 16, 2026
d64eb1d
test(temporal): pin the HAS_NULLS fold with vec-gate consumers; slim …
singaraiona Aug 16, 2026
902f294
perf(group): parallelize the radix key-column emit
singaraiona Aug 16, 2026
9e3cb09
test(group): slim the key-emit fixture; correct the take-bounded rout…
singaraiona Aug 16, 2026
d315102
perf(group): fuse the per-partition top-k into radix phase 2
singaraiona Aug 16, 2026
03142f5
fix(group): honour asc: on the top-N group emit filter (#408)
singaraiona Aug 16, 2026
9d95f6f
docs(group): pin the emit-filter .desc contract; honest #408 test com…
singaraiona Aug 16, 2026
c3fb6c6
fix(group): canonicalise -0.0 F64 group keys at the key-read boundary…
singaraiona Aug 16, 2026
2ec5284
fix(group): bit-level -0.0 fold in mode_scalar_key; precise NaN-polic…
singaraiona Aug 16, 2026
d59bb43
fix(collection): reject INT64_MIN count in take/drop instead of overf…
belowzeroff Aug 16, 2026
cd84f48
fix(cal): decode dates near INT32_MAX without int32 overflow (#410)
belowzeroff Aug 16, 2026
91fe7e3
fix(query): support update over parted tables and prevent column dupl…
belowzeroff Aug 16, 2026
66a80fb
fix(arith): keep integer div exact and UB-free (#403)
belowzeroff Aug 16, 2026
9e5f0a1
perf(expr): stop rescanning operands for the integer div gate (#403 f…
singaraiona Aug 16, 2026
2b93010
test(expr): pin the div gate bound; defensive idiv_i64_small reset un…
singaraiona Aug 16, 2026
412b69d
Merge branch 'master' into dev
singaraiona Aug 16, 2026
4fca523
fix(build): clang-clean boolean accumulation in the div gate scans
singaraiona Aug 16, 2026
c303733
docs(query): neutralize a product-name mention in the update by: scat…
singaraiona Aug 16, 2026
e5d87cd
docs(test): neutralize remaining product-name mentions in update-by c…
singaraiona Aug 16, 2026
3b1f533
perf(csv): drop load-time index attach from .csv.read
singaraiona Aug 17, 2026
b3f0275
feat(progress): byte-metered span for multi-phase ops
singaraiona Aug 17, 2026
0273a44
perf(csv): parallel row-offset scan, per-column finalize, whole-load …
singaraiona Aug 17, 2026
9e1592a
test(csv): boundary-dense chunking in test builds + stitching matrix
singaraiona Aug 17, 2026
bfb5b38
fix(core): normalize null and schema handling
singaraiona Aug 17, 2026
82661f4
perf(csv): parallelize the sym intern by per-column local dedupe
singaraiona Aug 17, 2026
2e6f8c8
test(csv): mixed-vocabulary column in sym_id_order; comment corrections
singaraiona Aug 17, 2026
5857e0c
perf(csv): fold bfb5b380's null scan into the finalizer's write sites
singaraiona Aug 17, 2026
3ebf8f2
fix(store): canonical SYM/STR nulls reach converted stores; HAS_NULLS…
singaraiona Aug 17, 2026
dfc0613
perf(query): fused equality on nullable SYM/STR columns
singaraiona Aug 17, 2026
12567b3
fix(group): canonical null for SYM/GUID keys in the radix emit
singaraiona Aug 17, 2026
0fb4d01
test(null): fused-relaxation and converted-store HAS_NULLS differentials
singaraiona Aug 17, 2026
47538c4
fix(collection,query): harden take/drop count-overflow family (#424)
belowzeroff Aug 25, 2026
782a63b
fix(csv): reject malformed separators and trailing garbage in typed t…
belowzeroff Aug 25, 2026
4297e72
fix: silent zero-match predicates — guid equality and like over list …
protocolstardust Aug 25, 2026
ca5a2d3
fix(join): compare GUID keys by full cell bytes (#425)
belowzeroff Aug 25, 2026
955a2fd
fix(agg): keep sum/prod list reductions exact and UB-free for i64 (#423)
belowzeroff Aug 25, 2026
8719121
fix(csv): reject impossible calendar dates in typed DATE/TIMESTAMP pa…
belowzeroff Aug 26, 2026
a4776b7
fix(storage): reject unsafe splayed column names (#434)
belowzeroff Aug 26, 2026
fabd746
fix(builtins): reject out-of-range numeric string casts (#432)
belowzeroff Aug 26, 2026
61c7c9c
fix(format): bound fmt_ensure growth; loud failure past 2GiB output (…
belowzeroff Aug 26, 2026
2b71135
fix(sort): one rule for where a null sorts, across every sort path (#…
ser-vasilich Aug 26, 2026
a4e38f1
fix(query): close the two ways an unresolved name still passed a sele…
ser-vasilich Aug 28, 2026
a93763c
fix(datalog): reject forged dl-program handles instead of dereferenci…
belowzeroff Aug 28, 2026
72f5810
refactor(ops): drop unreachable ISNULL paths; pin load-select mask re…
protocolstardust Aug 28, 2026
3fb5aff
fix(store): let a mapped string column's pool own the region they sha…
ser-vasilich Aug 28, 2026
a8102e6
feat(repl): add .repl.complete namespace completion verb (#441) (#442)
singaraiona Aug 30, 2026
b033fd2
fix(serde): reject table frames with mismatched schema/column counts …
belowzeroff Aug 31, 2026
057f519
fix(system): reject partially-numeric .ipc.open ports (#440)
belowzeroff Aug 31, 2026
86a7941
fix(repl): flush system command output (#443)
vbmithr Aug 31, 2026
322501d
fix: eliminate the three UBSan errors the test suite was swallowing (…
singaraiona Aug 31, 2026
0299511
fix(mem): size the scratch arena window from the backing block's real…
ser-vasilich Aug 31, 2026
dd80619
fix(mem): hand a cross-thread free back to its owner, and return idle…
ser-vasilich Aug 31, 2026
5d6bde8
fix(vec): flag sentinel nulls in every from_raw payload, not just SYM…
singaraiona Sep 1, 2026
ed46884
perf(query): append insert batches into a named table's columns in pl…
singaraiona Sep 1, 2026
657e853
fix(join): a null equi-join key equals another null key (#449)
protocolstardust Sep 1, 2026
14f366b
fix(format): pad table cells by display width, not byte length (#459)
singaraiona Sep 1, 2026
f1c54af
fix(journal): recovery skips log entries the snapshot already contain…
singaraiona Sep 1, 2026
4006e94
perf(join): route heavy-null build sides to the chained path upfront …
singaraiona Sep 2, 2026
5f20751
feat(ipc): bind a listener to a given address — loopback-only listene…
singaraiona Sep 2, 2026
612c0af
fix(serde): validate table/dict counts and lengths on decode (#452)
belowzeroff Sep 2, 2026
30a88e7
fix(query): handle guid membership predicates (#456)
belowzeroff Sep 2, 2026
04dc656
chore: record v2.5.15 squash (#413) as merged into dev
singaraiona Sep 2, 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
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ UNAME_S := $(shell uname -s)
RAY_MARCH ?= native

DEBUG_CFLAGS = -fPIC $(WARNS) -std=$(STD) -g -O0 -march=$(RAY_MARCH) -DDEBUG \
-fsanitize=address,undefined -fno-omit-frame-pointer
-fsanitize=address,undefined -fno-sanitize-recover=undefined \
-fno-omit-frame-pointer
RELEASE_CFLAGS = -fPIC $(WARNS) -std=$(STD) -O3 -march=$(RAY_MARCH) \
-funroll-loops -fomit-frame-pointer -fno-math-errno -falign-functions=64 \
-fassociative-math -ffp-contract=fast -fno-signed-zeros -fno-trapping-math
Expand Down
2 changes: 2 additions & 0 deletions docs/docs/c-api/dag.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ ray_op_t* ray_filter(ray_graph_t* g, ray_op_t* input,

Multi-column sort. Pass arrays of key nodes, sort directions (1=descending), and null ordering (1=nulls first). Uses parallel radix sort for numerics, merge sort for strings.

Passing `NULL` for `nulls_first` takes the default, which treats a null as the smallest value: nulls first when ascending, last when descending. A top-k over a column that holds nulls therefore returns those nulls, since they are the smallest rows.

```c
ray_op_t* ray_sort_op(ray_graph_t* g, ray_op_t* table_node,
ray_op_t** keys, uint8_t* descs,
Expand Down
16 changes: 16 additions & 0 deletions docs/docs/queries/joins.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,22 @@ The `anti-join` function keeps rows from the left table whose key does not appea
; 3 MSFT
```

## Null-key semantics (equi-joins)

`inner-join`, `left-join`, `full-join` and `anti-join` treat **a null key as equal to another null key**, and never equal to a non-null one:

```lisp
(set left (table [k v] (list (as 'SYM ["a" ""]) [1 2])))
(set right (table [k w] (list (as 'SYM ["a" ""]) [10 20])))

(at (left-join [k] left right) 'w) ; [10 20] — the null key finds its match
(count (anti-join [k] left left)) ; 0 — X anti-joined with itself is empty
```

This is the rule the rest of the runtime already applies to key columns: `distinct` keeps exactly one null, group-by folds nulls into a single group, and `in` matches a null against a null. It differs from SQL, where `NULL = NULL` is unknown and a self-anti-join can return rows. The invariant that follows — `(anti-join [cols] X X)` is empty for every `X` and every key set — is what makes anti-join usable for "which of these tuples have I not seen yet".

As-of join is the exception — its null keys never match. See its own [Null-key semantics](#null-key-semantics) section below.

## As-of Join

The `asof-join` function is designed for time-series data. For each row in the left table, it finds the most recent matching row in the right table where the time column is less than or equal to the left's time value. The last column in the key list is the temporal column; any preceding keys are exact-match equality keys.
Expand Down
83 changes: 66 additions & 17 deletions include/rayforce.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ typedef enum {
* singleton (global intern table) or a refcounted mmapped symfile. */
struct ray_sym_domain_s;

/* One file mapping shared by more than one block (src/mem/heap.h): a mapped
* string column and its pool live in the same region, so neither can end it
* alone. Held by the pool at aux[8..15] under mmod 3. */
struct ray_file_map_s;

typedef union ray_t {
/* Allocated: object header */
struct {
Expand Down Expand Up @@ -173,9 +178,25 @@ typedef union ray_t {
* 8-15 hold an int64 sym ID naming the target table.
* link_lo[8] aliases bytes 0-7. See ops/linkop.h. */
struct { uint8_t link_lo[8]; int64_t link_target; };
/* mmod 3 (string pools only): the shared mapping this block
* lives in. Typed rather than reached by offset, so it moves
* with the union if the layout is ever reshuffled. */
struct { uint8_t _aux_map_lo[8]; struct ray_file_map_s* file_map; };
};
/* Bytes 16-31: metadata + value */
uint8_t mmod; /* 0=heap, 1=file-mmap */
/* Where this block's memory came from, and who ends it:
* 0 heap — the buddy allocator owns it
* 1 file-mmap — this block's own free munmaps the region, whose
* size it derives from its type and length
* 2 borrowed — somebody else owns the memory and ends it on its
* own schedule; free does nothing at all
* 3 file-mmap, shared — the region is described by a heap-side
* ray_file_map_t held in aux[8..15] and ends when the last
* block referencing it is freed. A string column and its pool
* live in one mapping, and a selection may keep the pool after
* the column is gone, so the pool carries this and the column
* merely holds a reference to it. */
uint8_t mmod;
uint8_t order; /* block order (block size = 2^order) */
int8_t type; /* negative=atom, positive=vector, 0=LIST */
uint8_t attrs; /* attribute flags */
Expand Down Expand Up @@ -360,13 +381,23 @@ bool ray_interrupted(void);
typedef struct {
const char* op_name; /* coarse: scan, group, pivot, join, ... */
const char* phase; /* optional finer label, e.g. "pivot: dedupe" */
/* Units follow the op: normally rows, but while a byte-metered span is
* active (see ray_progress_span_begin) these two carry BYTES — the same
* values as bytes_done/bytes_total below — so that the percentage a
* callback derives from them is the span's, not some inner dispatch's. */
uint64_t rows_done;
uint64_t rows_total; /* 0 = indeterminate */
double elapsed_sec;
int64_t mem_used; /* bytes: live object footprint (buddy + direct mmap) */
int64_t mem_total; /* bytes: total physical RAM (the disk-spill threshold) */
bool final; /* true on the last tick of a query — renderers
use this to clear the line */
/* Byte-metered ops (currently .csv.read) publish their real progress on a
* byte axis as well as the row counters, so a renderer can show
* "3.2G/8.1G" instead of a row count nobody can size. bytes_total == 0
* means the op is not byte-metered and these two must be ignored. */
uint64_t bytes_done;
uint64_t bytes_total;
} ray_progress_t;

typedef void (*ray_progress_cb)(const ray_progress_t* snapshot, void* user);
Expand Down Expand Up @@ -407,6 +438,25 @@ bool ray_progress_active(void);
void ray_progress_dispatch_begin(uint64_t phase_rows_total);
void ray_progress_pump(void);

/* ===== Byte-metered span (main-thread only) =====
*
* An op made of several internal phases — each of which may run its own pool
* dispatch over a different element count — cannot report honest progress
* through the per-dispatch pump: every dispatch restarts at 0%, so the bar
* saws. A SPAN gives such an op one monotone axis (bytes of input) that all
* of its phases share.
*
* ray_progress_span_begin declares the axis (bytes_total, e.g. the file size).
* ray_progress_span_phase declares that whatever runs next occupies
* [base, base+len) of that axis: the dispatch pump maps its own 0..100% into
* that window instead of publishing raw row counts, and a serial phase can
* drive the same window directly with ray_progress_span_set. The published
* value never decreases. All are no-ops with no callback registered. */
void ray_progress_span_begin(const char* op_name, uint64_t bytes_total);
void ray_progress_span_phase(const char* phase, uint64_t base, uint64_t len);
void ray_progress_span_set(uint64_t bytes_done);
void ray_progress_span_end(void);

/* ===== COW / Ref Counting API ===== */

void ray_retain(ray_t* v);
Expand Down Expand Up @@ -444,14 +494,14 @@ ray_t* ray_typed_null(int8_t type);
* F32/F64 NaN NaN
* GUID 16 all-zero bytes 16 all-zero bytes
* BOOL/U8 ray_typed_null aux bit non-nullable
* SYM/STR no distinct null non-nullable
* SYM/STR canonical empty value canonical empty value
*
* Empty SYM/STR values are ordinary values. A requested typed or input null
* for either type collapses to the ordinary empty value; its public null
* predicate remains false and a vector does not acquire HAS_NULLS. Callers
* compare sentinel-backed payloads directly (for example `x == NULL_I64` or
* `x != x` for NaN). Temporal types reuse NULL_I32 or NULL_I64 according to
* storage width. */
* Empty SYM/STR values are their canonical in-band nulls. A requested typed
* or input null for either type collapses to that empty representation; the
* public null predicate recognizes it and vectors containing it acquire
* HAS_NULLS. Callers compare sentinel-backed payloads directly (for example
* `x == NULL_I64` or `x != x` for NaN). Temporal types reuse NULL_I32 or
* NULL_I64 according to storage width. */
#define NULL_I16 ((int16_t)INT16_MIN)
#define NULL_I32 ((int32_t)INT32_MIN)
#define NULL_I64 ((int64_t)INT64_MIN)
Expand All @@ -460,8 +510,8 @@ ray_t* ray_typed_null(int8_t type);

/* Atom null check. RAY_NULL_OBJ is the untyped null singleton.
* Sentinel-backed atoms use payload comparison. BOOL/U8 typed-null atoms
* use the aux[0]&1 bit written by ray_typed_null. SYM/STR always return
* false because their empty payloads are ordinary values. */
* use the aux[0]&1 bit written by ray_typed_null. SYM/STR use their
* canonical in-band empty values (sym 0 / "") as null. */
static inline bool ray_atom_is_null_fn(const union ray_t* x) {
if (RAY_IS_NULL(x)) return true;
if (x->type >= 0) return false;
Expand All @@ -479,14 +529,11 @@ static inline bool ray_atom_is_null_fn(const union ray_t* x) {
case RAY_TIME: return x->i32 == NULL_I32;
case RAY_I16: return x->i16 == NULL_I16;
case RAY_SYM:
/* SYM has no null — sym 0 is the empty symbol ' (a value), mirroring
* STR's empty "" below. A SYM atom is never null. */
return false;
return x->i64 == 0;
case RAY_STR:
/* STR has no null distinct from "" (char lists have no null, only
* symbols do). A STR atom is never null — the empty
* string is a value. */
return false;
/* Empty SSO is the only STR atom whose value union is all zero;
* non-empty SSO and long-string pointers are both non-NULL. */
return x->obj == NULL;
case RAY_GUID: {
/* GUID null = 16 all-zero bytes in obj's U8 buffer.
* obj is always populated by ray_guid / ray_typed_null —
Expand Down Expand Up @@ -516,6 +563,7 @@ ray_t* ray_vec_new(int8_t type, int64_t capacity);

ray_t* ray_sym_vec_new(uint8_t sym_width, int64_t capacity); /* RAY_SYM with adaptive width */
ray_t* ray_vec_append(ray_t* vec, const void* elem);
ray_t* ray_vec_append_raw(ray_t* vec, const void* src, int64_t count); /* one reserve + one memcpy */
ray_t* ray_vec_set(ray_t* vec, int64_t idx, const void* elem);
void* ray_vec_get(ray_t* vec, int64_t idx);
ray_t* ray_vec_slice(ray_t* vec, int64_t offset, int64_t len);
Expand Down Expand Up @@ -596,6 +644,7 @@ ray_err_t ray_env_set(int64_t sym_id, ray_t* val);

ray_t* ray_table_new(int64_t ncols);
ray_t* ray_table_add_col(ray_t* tbl, int64_t name_id, ray_t* col_vec);
ray_t* ray_table_validate_rectangular(ray_t* tbl, const char* context);
ray_t* ray_table_get_col(ray_t* tbl, int64_t name_id);
ray_t* ray_table_get_col_idx(ray_t* tbl, int64_t idx);
int64_t ray_table_col_name(ray_t* tbl, int64_t idx);
Expand Down
43 changes: 35 additions & 8 deletions src/app/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ int main(int argc, char** argv) {
int interactive = 0;
const char* file = NULL;
uint16_t port = 0;
char bind_host[64] = ""; /* -p HOST:PORT bind address; empty = all interfaces */
int n_cores = -1; /* total execution cores; -1 = leave pool lazy */
int timeit_init = 0; /* -t N: enable profiler at startup */
int qlog_init = 0; /* -Q N: enable query-statistics logging at startup */
Expand All @@ -91,7 +92,7 @@ int main(int argc, char** argv) {

/* Parse args. Supported flags:
* -f FILE run script file
* -p PORT IPC listen port
* -p PORT|HOST:PORT IPC listen port, optionally bound to HOST
* -c N total execution cores, main included (0 = auto)
* -t N enable timeit at startup (N != 0 turns on)
* -Q N enable query-statistics logging (N != 0 turns on)
Expand All @@ -103,8 +104,32 @@ int main(int argc, char** argv) {
for (int i = 1; i < argc; i++) {
if (strcmp(argv[i], "-i") == 0 || strcmp(argv[i], "--interactive") == 0)
interactive = 1;
else if ((strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--port") == 0) && i + 1 < argc)
port = (uint16_t)atoi(argv[++i]);
else if ((strcmp(argv[i], "-p") == 0 || strcmp(argv[i], "--port") == 0) && i + 1 < argc) {
/* PORT binds all interfaces; HOST:PORT confines the listener
* to one IPv4 address (#427). Strict digits-only port — a
* silently truncated "65536x" listener is worse than exiting. */
const char* parg = argv[++i];
const char* colon = strchr(parg, ':');
const char* pstr = parg;
if (colon) {
size_t hlen = (size_t)(colon - parg);
if (hlen == 0 || hlen >= sizeof(bind_host)) {
fprintf(stderr, "bad -p bind address: %s\n", parg);
return 2;
}
memcpy(bind_host, parg, hlen);
bind_host[hlen] = '\0';
pstr = colon + 1;
}
char* endp;
errno = 0;
long pv = strtol(pstr, &endp, 10);
if (endp == pstr || *endp != '\0' || errno == ERANGE || pv <= 0 || pv > 65535) {
fprintf(stderr, "bad -p port (must be 1..65535): %s\n", parg);
return 2;
}
port = (uint16_t)pv;
}
else if ((strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "--cores") == 0) && i + 1 < argc) {
int v = atoi(argv[++i]);
if (v < 0) v = 0;
Expand Down Expand Up @@ -151,7 +176,8 @@ int main(int argc, char** argv) {
"usage: %s [-f file] [-p port] [-c cores] [-t 0|1] [-i]"
" [-u PW | -U PW] [-l BASE | -L BASE] [-m SIZE] [file.rfl] [-- app args]\n"
" -f, --file FILE run script file (or pass as a positional arg)\n"
" -p, --port PORT listen for IPC clients on PORT\n"
" -p, --port PORT listen for IPC clients on PORT (all interfaces)\n"
" --port HOST:PORT bind the listener to HOST only (e.g. 127.0.0.1:7701)\n"
" -c, --cores N total execution cores, main included (0 = auto)\n"
" -t, --timeit N enable profiler at startup (N != 0)\n"
" -i, --interactive start the REPL even after running a file\n"
Expand Down Expand Up @@ -238,11 +264,12 @@ int main(int argc, char** argv) {

/* Start IPC server if port specified */
if (port > 0) {
if (poll && ray_ipc_listen(poll, port) >= 0)
fprintf(stderr, "listening on port %u\n", port);
const char* bh = bind_host[0] ? bind_host : NULL;
if (poll && ray_ipc_listen_at(poll, bh, port) >= 0)
fprintf(stderr, "listening on %s:%u\n", bh ? bh : "*", port);
else
fprintf(stderr, "failed to listen on port %u: %s\n",
port, strerror(errno));
fprintf(stderr, "failed to listen on %s:%u: %s\n",
bh ? bh : "*", port, strerror(errno));
}

/* Load script if specified */
Expand Down
Loading
Loading