Repository navigation
Conversation
singaraiona
left a comment
There was a problem hiding this comment.
Code review of b0adcb2: clean.
- Cause:
ray_union_fnis the only implementation, and both its typed and list paths now keep first appearance. The span/point split (left deduplicated by its own cells, right probed by span keys) is right. - Oracle: 20 cases across every type, null/NaN/-0.0, span pairs both ways, mixed lists and empty operands. Each gives the same elements as
(distinct (concat a b))in order of first appearance. - Sanitizers and memory: ASan clean; memory flat over repeated calls.
- Performance: within noise, except F64 at about +5%.
- Tests: all four changed tests fail on dev.
Two small notes:
list_cell_setsandspan_vec_cell_hashnow compareunionwithdistinct (concat …), so a change todistinctwould silently carryunionalong. Keep a few literal expectations per rule.- The bench comment and the body name a private hostname; please drop it from
bench/union_set.rfl.
This changes union's results for any left operand with duplicates, so it needs a maintainer decision; I've asked for one and will report back here. Please hold the merge until then.
|
Both notes done: |
|
The owner has decided this one: |
|
Docs and notes done at 7fce041: the reference and the function table now say that |
|
CI note: |
|
Reviewed at 7fce041 against the owner's decision (union is a set). The semantics are right:
Before merge:
|
7fce041 to
6c267cf
Compare
|
Done at 6c267cf (rebased on current
CI: the macOS debug job still shows the |
6c267cf to
ce6f1e9
Compare
|
#1478 is merged, so I rebased on |
…o too The owner decided (RayforceDB#1385, option A) that union is a set: its result drops the duplicates of the left operand as well, and is the distinct elements of the left operand followed by those of the right it lacks, each once, in order of first appearance. (union [1 1 2] [2 3]) was [1 1 2 3]: only the right operand was checked, and the reference page says "Set union (deduplicated)". Both paths change: the typed vectors (a hash set over the left operand; its rows are gathered only when it holds a duplicate) and the boxed lists. On a span/point pair (a TIMESTAMP or TIME against a TIMESPAN) the left operand is told apart by its own cells: the keys it is compared with at the other side can make two points collide (two timestamps a day apart have one time of day), which the list path never did. The second hash set is built only when two keys collide: equal cells have equal keys, so a left whose keys are all distinct holds no duplicate. Tests: union.rfl states the set invariants, with the per-type, boxed, hashed-size and null cases, counts above a morsel (65,536 rows) against literals, and a TIMESTAMP against a TIMESPAN with and without duplicates on the left. The assertions of union_rhs_distinct, list_cell_sets and span_vec_cell_hash that pinned the duplicates say that, for list operands, union is identical to distinct of the concatenation, next to a few literal expectations so that a change to distinct does not carry union along. Closes RayforceDB#1385
The reference and the function table state it, with examples, and a pointer to distinct for a set from the other two. union.rfl pins the three behaviours side by side.
…s and span/point Release build, best of 5, dev and the change side by side in the header: all within noise, the span/point route included (10M TIMESTAMP against a TIMESPAN: distinct left 596 -> 569 ms, duplicate left 261 -> 259 ms).
(count (union Z (list [0.0 0.0] [1.0 0.0] P))) was 61: Z's 60 elements, duplicates included, plus one new cell. A union is a set (RayforceDB#1385), so it is 4, as (union (list P) Z) on the next line already was.
ce6f1e9 to
06a48f2
Compare
|
#1478 and #1372 are merged, so as planned I rebased on
|
singaraiona
left a comment
There was a problem hiding this comment.
Verified at 06a48f2, against the owner's decision that union is a set.
- Correctness:
(union a b)equals(distinct (concat a b))across every type and type pair, both orders, nulls, -0.0/NaN, and 12 to 100k rows, at -c 1/28 and under ASan, with 0 mismatches. - Speed: the span/point all-distinct case is back at dev speed. A duplicate-heavy left operand pays about 10% for the dedup the decision requires.
- Tests, docs and naming: the tests fail on dev, the docs are right, and naming is clean.
Approved; thanks for the follow-up.
The owner decided (#1385, option A) that
unionis a set:(union [1 1 2] [2 3])is[1 2 3]. The result is the distinct elements of the left operand, then those of the right it lacks, each once, in order of first appearance; it equalsdistinctof the concatenation.exceptandsectkeep the duplicates of the left operand, as documented; the docs now say so side by side.Both paths change: typed vectors (a hash set over the left operand, rows gathered only when it holds a duplicate) and boxed lists. On a span/point pair (TIMESTAMP or TIME against TIMESPAN) the left operand is deduplicated by its own cells, because the keys it is compared with can make two timestamps a day apart collide; the second hash set that needs is built only when two keys collide (equal cells have equal keys, so all-distinct keys mean no duplicate).
Answers that change: any
unionwhose left operand had a duplicate. Three older tests pinned that (union_rhs_distinct,list_cell_sets,span_vec_cell_hash); for list operands they now assert identity withdistinctof the concatenation, next to a few literal expectations so a change todistinctdoes not carryunionalong.Performance, release build, best of 5, dev vs this branch (ms, laptop, -c 4): i64 5M distinct 585 vs 575, heavy duplicates 72 vs 70, moderate duplicates 467 vs 441, sym 38 vs 38, str 42 vs 38, f64 75 vs 75, empty left 315 vs 294, 30k-cell lists 0.62 vs 0.62; span/point (10M TIMESTAMP against a TIMESPAN) distinct left 596 vs 569, duplicate left 261 vs 259, 1000-row left 225 vs 226. The reviewer's example of an all-distinct left, which was 65% slower with an always-built second set, is now at parity. One run of the duplicate-left span/point case showed a 3.7 s outlier that did not repeat in four more runs (about 255-330 ms against dev's 255-262); I did not find a cause and put it down to system load, which I cannot prove.
Land order: after #1478 and #1372 (the
distinctorder) merge, this is rebased ondev,list_cell_rules.rflis repinned for the set rule, and the docs conflicts are resolved by keeping their first-occurrence wording.Closes #1385