Repository navigation
Rename validity slots to validity_child instead of renaming their accessor - #11423
Conversation
…essor The #[array_slots] accessors take ArrayView by value, so a slot field named validity would generate an accessor that hides ArrayView::validity. #11418 worked around this with a #[slot(N, accessor = name)] option that renamed only the accessor, leaving the validity slots with a field called validity but an accessor called validity_slot. Drop the accessor option and rename the 15 validity slot fields to validity_child instead, matching Delta and BitPacked, so the field, view field, accessor, and index constant (now VALIDITY_CHILD) share one name. The macro still rejects slot field names that clash with ArrayView methods, now with an error that suggests renaming the field. The slot name shown in display trees changes from validity to validity_child; the display test, the display_tree docstring, and the vortex-btrblocks golden snapshots are updated to match. Signed-off-by: Robert Kruszewski <robert@spiraldb.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018SWbErpV8gppbsHrfq7fJD
| /// Slot field names that are rejected because their generated accessors would shadow the inherent | ||
| /// methods of `ArrayView` (which the by-value accessors take precedence over) or the ext trait's | ||
| /// own methods. | ||
| const RESERVED_FIELD_NAMES: &[&str] = &[ |
There was a problem hiding this comment.
so validity_child is not a reserved field name? why not have the macro detect that field and auto-generate stuff for it?
There was a problem hiding this comment.
validity is the reserved name of a method that the ArrayView provides. We want to avoid mismatch between field and accessor
Merging this PR will improve performance by 10.6%2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
) ## Summary Follow-up to #11418 and #11423. The `#[array_slots]` accessors now return references borrowed for the array, or for the `ArrayView`'s lifetime `'a`. So there's no longer a reason to index `slots()` by `XSlots` constants and unwrap by hand, or to keep hand-written accessors that duplicate the generated ones. ## API Changes - Removed `PrimitiveArrayExt::validity_child`, `DecimalArrayExt::validity_child`, `InterleaveArrayExt::array_indices`, `InterleaveArrayExt::row_indices` and `ChunkedArrayExt::chunk_offsets_array`. The generated accessors replace them, so callers need the encoding's `…ArraySlotsExt` trait in scope. Use `chunk_offsets()` in place of `chunk_offsets_array()`. - Newly public: `InterleaveSlots`, `InterleaveSlotsView` and `InterleaveArraySlotsExt` from `arrays::interleave`, and `ChunkedArraySlotsExt` from `arrays::chunked`. Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Follow-up to #11418. The
#[array_slots]accessors now takeArrayViewby value, so a slot field namedvaliditywould generate an accessor that hidesArrayView::validity. #11418 worked around this with a#[slot(N, accessor = name)]option that renamed only the accessor. That left 15 slot structs with a field calledvaliditybut an accessor calledvalidity_slot.This drops the accessor option and renames the fields instead. The field, view field, accessor and index constant now share one name, matching Delta and BitPacked, which already use
validity_child.