Commit 8f254ac
Decode u64s rather than u8s (#78)
* Add from_u64s and decode_u64s for panic-free, alignment-check-free decoding
Adds a new decode path that preserves u64 alignment information through
the entire pipeline, eliminating per-field alignment checks that
bytemuck::try_cast_slice required when going through &[u8].
Key changes:
- decode_u64s: returns (&[u64], u8) pairs instead of &[u8] slices,
where the u8 indicates valid trailing bytes in the last word
- from_u64s on FromBytes: non-panicking field construction that enables
LLVM to eliminate unused tuple fields as dead code
- validate/validate_typed: upfront structural and type-compatibility
checks for encoded data, replacing the implicit panic-on-bad-data
- Remove inspect module (superseded by examples/decode_asm.rs)
Assembly impact for accessing field 0 of a k-tuple of u64s:
Old (from_bytes): k=3 → 133 insns, k=8 → 273 insns (linear in k)
New (from_u64s): k=3 → 68 insns, k=8 → 68 insns (constant in k)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Remove EncodeDecode trait and Sequence encoding, rename module to indexed
Indexed is now the sole encoding format with inherent methods, so callers
don't need to import a trait. The Sequence format provided no random
access or u64-aligned decoding and is no longer needed.
Renames serialization_neu to indexed now that there is no other
serialization module to distinguish from.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Move validate_typed to FromBytes::validate, remove Indexed struct
validate_typed was partly a function of the Indexed format and partly
of the type being decoded. It now lives as FromBytes::validate, which
combines structural and type-compatibility checks using element_sizes.
The Indexed struct's methods were all one-line delegates to free
functions in the indexed module. Removed the struct and inlined
length_in_words/length_in_bytes as free functions. Callers use the
module directly (columnar::bytes::indexed::encode, etc).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Hide element_sizes as implementation detail of FromBytes::validate
element_sizes is only used internally by validate. Mark it #[doc(hidden)]
and simplify tests to exercise validate directly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Make both element_sizes and validate public on FromBytes
element_sizes is public for implementors to override.
validate is public for callers to use at trust boundaries.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Clean up decode_asm example to three representative approaches
Trimmed from experimental accumulation to a clean comparison of:
- from_bytes + decode (O(k) baseline)
- from_u64s + decode_u64s (O(1) in k via dead code elimination)
- decode_field random access (O(1) in both k and field position)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Update benchmarks to use indexed module instead of removed Sequence
The bench and serde benchmarks referenced the removed EncodeDecode
trait and Sequence type. Updated to use the indexed module directly.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Fix from_u64s for Discriminant and updated enum container layout
The enum container struct now uses a single `indexes: Discriminant`
field instead of separate `variant` and `offset` fields. Update the
derive macro's from_u64s to match, and add from_u64s/element_sizes
to the Discriminant FromBytes impl.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Rework validate to take decoded slices, add validate_typed entry point
FromBytes::validate now takes &[(&[u64], u8)] matching the from_u64s
input shape, making it composable for nested types. Added
indexed::validate_typed::<T> as the single entry point that combines
structural and type-level validation. Also added from_u64s and
element_sizes for Discriminant.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Rename validate to validate_structure, validate_typed to validate
The obvious name should do the obvious thing: indexed::validate::<T>
does full validation (structural + type compatibility). The structural-
only check is now validate_structure, an implementation detail.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* Remove unused FromBytes import in test module
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 432aa95 commit 8f254ac
File tree
15 files changed
+699
-159
lines changed- benches
- columnar_derive/src
- examples
- src
15 files changed
+699
-159
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
334 | 338 | | |
335 | 339 | | |
336 | 340 | | |
| |||
519 | 523 | | |
520 | 524 | | |
521 | 525 | | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
522 | 531 | | |
523 | 532 | | |
524 | 533 | | |
| |||
910 | 919 | | |
911 | 920 | | |
912 | 921 | | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
913 | 929 | | |
914 | 930 | | |
915 | 931 | | |
| |||
1203 | 1219 | | |
1204 | 1220 | | |
1205 | 1221 | | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
1206 | 1226 | | |
1207 | 1227 | | |
1208 | 1228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
0 commit comments