Skip to content

Support variadic tail slots in #[array_slots] macro - #8950

Merged
robert3005 merged 4 commits into
developfrom
claude/array-slots-macro-design-pemah1
Jul 27, 2026
Merged

Support variadic tail slots in #[array_slots] macro#8950
robert3005 merged 4 commits into
developfrom
claude/array-slots-macro-design-pemah1

Conversation

@joseph-isaacs

@joseph-isaacs joseph-isaacs commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Rationale for this change

The #[array_slots] macro currently supports fixed-size slot layouts with required (ArrayRef) and optional (Option<ArrayRef>) fields. However, several encodings like Chunked, Struct, and Union have variable-length slot runs (e.g., [chunk_offsets, chunks...]) that cannot be cleanly expressed with the current macro.

This change extends the macro to support a variadic tail — a final field of type Vec<ArrayRef> — enabling these encodings to use the macro-generated slot accessors and constants instead of hand-written slot index management.

What changes are included in this PR?

Macro enhancements (vortex-array-macros/src/lib.rs)

  • Added SlotFieldType::VariadicTail variant to recognize Vec<ArrayRef> fields
  • Validation ensures variadic tails only appear as the final field
  • Split slot field processing into fixed_specs and optional tail_spec
  • Generated different constant sets for variadic layouts:
    • FIXED_COUNT: number of fixed slots
    • FIXED_NAMES: names of fixed slots
    • {FIELD}_OFFSET: offset where the tail begins
    • slot_name(idx) function: returns slot names like "chunks[3]" for tail slots
  • Updated from_slots() and into_slots() to handle tail draining/extending
  • View struct and ext trait accessors for tail fields now return SlotSlice<'a> instead of Vec<ArrayRef>

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants