Repository navigation
Commit 45b918d
committed
Apply the RowFn review: trim the API, sharpen the contracts
A review pass over the row scalar-function framework in three parts. Every
surviving change is codegen-neutral: the emitted IR of every
`visit_prepared_into` monomorph, profiled by vector width, reduction count,
overflow-intrinsic survival and bounds checks, is identical to the parent commit.
API:
- Delete `decode_null_tolerant` overrides that only restated the default, from
the primitive, bool and `TensorRow` elements. `GeometryRow`'s is the only real
one. The doc now says a dense-safe element should not override.
- Delete the nullary path (`ElementTuple for ()` and the `num_inputs() == 0`
branch). With no inputs there is no validity to propagate, which is the whole
of what the lifting does, so such a function belongs on `ScalarFnVTable`.
- Replace `OutputSink::row_count_matches(rows, n) -> bool` with
`rows_len(rows) -> usize`. The executor compares it against the batch row
count, which gives the optimizer the same bound and lets the error report the
length it actually found. `SpreadSink`'s width invariant, the one use of the
extra expressiveness, moves to `rows()` where it belongs.
- Give `reduce_encoded` an explicit `row_count`. The required length is the
filtered count under filter-and-scatter, which was prose discoverable only on
a mixed validity mask, and is now in the signature.
- Record on `ElementTuple` why it carries arities past the widest function in
tree: it is sealed, so a downstream crate cannot add the one it needs, and an
uninstantiated arity costs only its own macro expansion.
Execution:
- Share `resolve_validity` between `execute_filtered` and the forced-strategy
test seam so the mask shortcuts cannot drift apart between them.
- Correct the dense-retry comment. It filters unconditionally because
`execute_dense` is not handed the `branch` closure, not because a deferred
sink cannot skip rows: `ERRORS_ARE_DEFERRED` and `SUPPORTS_SKIPPED_ROWS` are
independent consts.
- Pin the two `reduce_encoded` probes and their row counts with a test. The
first sees the original arrays at full length and is the only one that does;
the second sees filtered copies at the surviving count.
Implementations:
- Keep one `l2_norm_row`. Cosine's prepared and per-row arms must agree bit for
bit, which holds only while both accumulate in the same order, so a second copy
was an invitation to break the property its comments defend.
- Zip the cosine `reduce_encoded` loops instead of indexing three slices per row,
and record why it materializes where `InnerProduct` stays lazy.
- Collapse the checked-arithmetic macros so each predicate is written once:
`impl_checked_integer!` owns the shape, and the unsigned and signed wrappers
own their add/sub/div. Only `mul_failure` varies per width, and only signed
64-bit needs to spell its own. Delete `CheckedArithmetic::mul_error`, which had
no caller left once `CheckedMul` reported through `mul_failure`.
- Cover every container variant of geo's `contains_route` against plain
`a.contains(b)` in all four constant arrangements. The existing agreement grid
goes through real arrays but only covers four of the ten container types, so a
geo release that moved a row would leave it green.
- Correct `scalar_fn`'s trait-choice doc, which listed `vortex.byte_length` as a
`RowFn` when it is a `ScalarFnVTable`, and add it as the worked example of
row-determined being necessary but not sufficient.
Two changes were made, reviewed and reverted; `SCALAR_FN_HANDOFF.md` records both
so they are not retried. Making `CheckedSink` safe with `BufferMut::zeroed`
measured 1.65 to 1.71x slower than the `MaybeUninit` storage it replaced, because
`alloc_zeroed` does not avoid the write pass the row loop then duplicates.
Hoisting `SUPPORTS_SKIPPED_ROWS` into the plan, which #9130
records as a follow-up, is not sound: the branch path probes `reduce_encoded`
against the original arrays before it consults the sink, and that is the only
probe that sees them still encoded.
Verification: 3318 vortex-array, 179 vortex-tensor and 241 vortex-geo tests, 72
doctests, clippy over the three crates with `--all-targets --all-features`,
nightly fmt, and `git diff --check`.
Signed-off-by: "Connor Tsui" <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014mwiAahcxc5xBfTrhDK11L1 parent f430847 commit 45b918d
25 files changed
Lines changed: 595 additions & 425 deletions
File tree
- vortex-array
- benches
- src/scalar_fn
- fns/binary/numeric
- row
- element
- tests
- vortex-geo/src/scalar_fn
- vortex-tensor/src/scalar_fns
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
163 | 167 | | |
164 | 168 | | |
165 | 169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
278 | 278 | | |
279 | 279 | | |
280 | 280 | | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
281 | 400 | | |
282 | 401 | | |
283 | 402 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
| 123 | + | |
| 124 | + | |
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
187 | | - | |
188 | | - | |
| 187 | + | |
| 188 | + | |
189 | 189 | | |
190 | 190 | | |
191 | 191 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| 105 | + | |
105 | 106 | | |
106 | 107 | | |
107 | 108 | | |
| |||
0 commit comments