Skip to content

Constrain List/ListView builder offset, size types to 32 and 64 bit types - #9053

Open
robert3005 wants to merge 4 commits into
developfrom
claude/arraybuilder-trait-refactor-1tveb1
Open

Constrain List/ListView builder offset, size types to 32 and 64 bit types#9053
robert3005 wants to merge 4 commits into
developfrom
claude/arraybuilder-trait-refactor-1tveb1

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

In #8609 we have inverted the flow of the append_to_builder methods. The side effect of that is we match on the builders but for lists the number of match cases is excessive due to trait bounds being arbitrary integer types. Realistically types smaller than u32 are not that useful as they define the upper bound on the size of the array. This pr introduces OffsetBuilderPType which constraints the offset and sizes buffer types in ListBuilder.

We will use that on VarBinBuilder in a follow up

claude added 2 commits July 29, 2026 00:31
Remove `append_list_array` and `append_listview_array` from the
`ArrayBuilder` trait; they only ever applied to list-typed builders. The
implementations now live as inherent methods on `ListBuilder<O>` and
`ListViewBuilder<O, S>`, and the List/ListView vtables dispatch through a
new `match_each_list_builder!` macro that trial-downcasts the
`dyn ArrayBuilder` against every concrete list builder instantiation over
the integer offset/size types. Non-list builders fail with the same error
as the old default trait implementations.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaXX3wiHuyhFvisiZV7SCn
Add a sealed `ListOffsetPType` trait (implemented for exactly u32, i32,
u64, and i64) and use it as the bound on `ListBuilder<O>` and
`ListViewBuilder<O, S>`, so builders with other integer widths can no
longer be constructed. This makes the `match_each_list_builder!` matcher
provably exhaustive and shrinks it from 72 downcast attempts to 20.

Incoming arrays are unaffected: their offsets/sizes still dispatch over
all integer ptypes when appended into a builder. The sparse encoding now
picks its builder offset type via a new
`match_smallest_list_offset_type!` (u32/u64), and arbitrary list
generation and tests drop the no-longer-constructible narrow widths.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaXX3wiHuyhFvisiZV7SCn
@robert3005 robert3005 added the changelog/break A breaking API change label Jul 29, 2026
@codspeed-hq

codspeed-hq Bot commented Jul 29, 2026

Copy link
Copy Markdown

Merging this PR will improve performance by 13.06%

⚡ 1 improved benchmark
✅ 1840 untouched benchmarks
⏩ 55 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation decompress[u64, (10000, 1024)] 57.9 µs 51.2 µs +13.06%

Tip

Curious why this is faster? Comment @codspeedbot explain why this is faster on this PR, or directly use the CodSpeed MCP with your agent.


Comparing claude/arraybuilder-trait-refactor-1tveb1 (0d7d5f6) with develop (2c8522f)

Open in CodSpeed

Footnotes

  1. 55 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

claude added 2 commits July 29, 2026 11:06
Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaXX3wiHuyhFvisiZV7SCn
Sparse list canonicalization now picks its builder offset type via
match_smallest_list_offset_type!, whose smallest choice is u32, so the
canonical offsets for a source outgrowing u8 are u32 rather than u16.

Signed-off-by: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NaXX3wiHuyhFvisiZV7SCn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants