Commit ede7f84
fix(encoding): broadcast 1-element constant child segments on bulk read
Commit 10a7776 made ConstantEncoding allocate a single element regardless
of declared rowCount as a zip-bomb defense. Consumers that bulk-read a
child segment via raw `MemorySegment.copy(seg, i * elemBytes, ...)` or
`seg.get(LAYOUT, i * sz)` then ran off the end of the 1-element segment as
soon as i > 0 — surfacing as IndexOutOfBoundsException in
RustVsJavaReadBenchmark.javaReadClose (ALP F64 column with bitpacked
patches whose values child was constant-encoded).
LongArray.getLong and sibling typed accessors already wrap with `i % cap`;
this commit teaches the segment-level consumers the same broadcast
arithmetic via a new SegmentBroadcast helper exposing elementOffset,
capacity, and broadcastCopy.
Patched call sites (every decodeChildSegment consumer that reads more
than one element by offset):
- BitpackedEncoding.applyPatches (idx + val)
- SparseEncoding.applyPatches, decodeBool, decodeVarBin
- AlpEncoding.decodeF64/decodeF32 source loop and applyPatches
- AlpRdEncoding.decodeF64/decodeF32 left+right loops and patches
- PatchedEncoding.decode bulk inner copy and applyPatches
- ZigZagEncoding.decode per-ptype loops
- DeltaEncoding.readLongs
- RleEncoding.readLongs, readIndices, readUnsignedLongs
- RunEndEncoding.expandByte/Short/Int/Long/Bool/Strings
- DictEncoding.readCode and expandU8/U16/U32
- FsstEncoding decode (uncompressed lens + codes offsets)
- ChunkedEncoding.readOffsets
- VarBinEncoding.decode (materialize 1-element offsets before VarBinArray)
Added PatchesBroadcastRegressionTest with a hand-built ArrayNode tree
that puts ConstantEncoding under bitpacked patches, plus direct coverage
for SegmentBroadcast.elementOffset/capacity/broadcastCopy.
Bench (RustVsJavaReadBenchmark): javaReadClose now passes at 60.7 ops/s
vs JNI 49.1 ops/s (Java 1.24× faster). Volume, Symbol, Cascading, and JNI
methods remain within run-to-run noise of the prior numbers — modulo
arithmetic is hoisted by the JIT as a loop invariant.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent e696f07 commit ede7f84
15 files changed
Lines changed: 409 additions & 113 deletions
File tree
- core/src
- main/java/io/github/dfa1/vortex/encoding
- test/java/io/github/dfa1/vortex/encoding
Lines changed: 15 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
426 | | - | |
| 426 | + | |
| 427 | + | |
427 | 428 | | |
428 | 429 | | |
| 430 | + | |
429 | 431 | | |
430 | | - | |
| 432 | + | |
431 | 433 | | |
432 | 434 | | |
433 | 435 | | |
| |||
450 | 452 | | |
451 | 453 | | |
452 | 454 | | |
| 455 | + | |
453 | 456 | | |
454 | | - | |
| 457 | + | |
455 | 458 | | |
456 | 459 | | |
457 | 460 | | |
| |||
471 | 474 | | |
472 | 475 | | |
473 | 476 | | |
| 477 | + | |
474 | 478 | | |
475 | 479 | | |
476 | 480 | | |
477 | 481 | | |
478 | 482 | | |
479 | | - | |
480 | | - | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
481 | 486 | | |
482 | 487 | | |
483 | 488 | | |
484 | | - | |
| 489 | + | |
485 | 490 | | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
490 | 495 | | |
491 | 496 | | |
492 | 497 | | |
| |||
Lines changed: 28 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
399 | 399 | | |
400 | 400 | | |
401 | 401 | | |
| 402 | + | |
| 403 | + | |
402 | 404 | | |
403 | 405 | | |
404 | 406 | | |
405 | | - | |
| 407 | + | |
406 | 408 | | |
407 | | - | |
| 409 | + | |
408 | 410 | | |
409 | 411 | | |
410 | 412 | | |
411 | 413 | | |
412 | | - | |
| 414 | + | |
413 | 415 | | |
414 | 416 | | |
415 | 417 | | |
| |||
420 | 422 | | |
421 | 423 | | |
422 | 424 | | |
| 425 | + | |
| 426 | + | |
423 | 427 | | |
424 | 428 | | |
425 | 429 | | |
426 | | - | |
| 430 | + | |
427 | 431 | | |
428 | | - | |
| 432 | + | |
429 | 433 | | |
430 | 434 | | |
431 | 435 | | |
432 | 436 | | |
433 | | - | |
| 437 | + | |
434 | 438 | | |
435 | 439 | | |
436 | 440 | | |
437 | 441 | | |
438 | 442 | | |
439 | 443 | | |
440 | 444 | | |
441 | | - | |
| 445 | + | |
442 | 446 | | |
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
446 | 450 | | |
447 | 451 | | |
| 452 | + | |
| 453 | + | |
448 | 454 | | |
449 | 455 | | |
450 | | - | |
451 | | - | |
| 456 | + | |
| 457 | + | |
452 | 458 | | |
453 | | - | |
| 459 | + | |
454 | 460 | | |
455 | 461 | | |
456 | 462 | | |
457 | 463 | | |
458 | | - | |
| 464 | + | |
| 465 | + | |
459 | 466 | | |
460 | 467 | | |
461 | 468 | | |
462 | 469 | | |
463 | 470 | | |
464 | 471 | | |
| 472 | + | |
| 473 | + | |
465 | 474 | | |
466 | 475 | | |
467 | | - | |
468 | | - | |
| 476 | + | |
| 477 | + | |
469 | 478 | | |
470 | | - | |
| 479 | + | |
471 | 480 | | |
472 | 481 | | |
473 | 482 | | |
474 | 483 | | |
475 | | - | |
| 484 | + | |
476 | 485 | | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
481 | 490 | | |
482 | 491 | | |
483 | 492 | | |
| |||
Lines changed: 9 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
619 | 619 | | |
620 | 620 | | |
621 | 621 | | |
| 622 | + | |
622 | 623 | | |
623 | 624 | | |
624 | | - | |
| 625 | + | |
625 | 626 | | |
626 | 627 | | |
627 | 628 | | |
628 | 629 | | |
629 | | - | |
| 630 | + | |
| 631 | + | |
630 | 632 | | |
631 | 633 | | |
632 | 634 | | |
633 | | - | |
| 635 | + | |
634 | 636 | | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
639 | 641 | | |
640 | 642 | | |
641 | 643 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| 142 | + | |
142 | 143 | | |
143 | 144 | | |
144 | | - | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
Lines changed: 2 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
357 | 357 | | |
358 | 358 | | |
359 | 359 | | |
| 360 | + | |
360 | 361 | | |
361 | | - | |
| 362 | + | |
362 | 363 | | |
363 | 364 | | |
364 | 365 | | |
| |||
0 commit comments