Repository navigation
perf(column): scan Array(String) into []string without reflection - #2152
Open
TheNetherWatcher wants to merge 1 commit into
Open
TheNetherWatcher wants to merge 1 commit into
TheNetherWatcher wants to merge 1 commit into
Conversation
TheNetherWatcher
requested review from
a team,
kavirajk and
polyglotAI-bot
as code owners
November 21, 2026 17:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1747.
Array.ScanRowgoes throughscanSlicefor every element:Rowboxes the string intoany, thenreflect.ValueOf,reflect.New,setJSONFieldValueandreflect.Append. ForArray(String)into[]stringthat is the main cost of the scan.This adds a fast path in
ScanRowfor a single-levelArray(String)and a*[]stringdestination. It makes the slice with the exact length and reads each value from theStringcolumn directly. All other types and destinations use the old path. I also moved the start/end offset lookup into a small helper so both paths use it.Benchmark (
lib/column, 64 rows of 100 elements, Apple M-series,-count 6):About 11x faster, and one allocation per element (the string copy) instead of six.
Checklist
TestArrayStringScanRowchecks that the fast path returns the same values as the reflection path (scan intoany), including empty rows.BenchmarkArrayStringScanRowis the benchmark above.lib/column, and theArray/Stringtests intestsandtests/stdpass against 26.9.Note
Low Risk
Localized performance optimization with a type-specific branch and tests; other scan destinations and array shapes are unchanged.
Overview
Adds a reflection-free fast path in
Array.ScanRowwhen scanning single-levelArray(String)into*[]string: it usesoffsetRangeto find element bounds, allocates a[]stringof the right length, and copies values directly from the underlyingStringcolumn.Extracts
offsetRangesoscanSlice(and the new path) share the same start/end offset logic instead of duplicating it inline.Adds
TestArrayStringScanRow(fast path vs reflection/any) andBenchmarkArrayStringScanRowto track correctness and scan performance for this case; all other array types and destinations still use the existing reflection path.Reviewed by Cursor Bugbot for commit e30d9c5. Bugbot is set up for automated code reviews on this repo. Configure here.