GH-301: [C#] Use an index lookup for O(1) field index access#300
Merged
Conversation
adamreeve
approved these changes
Mar 31, 2026
Contributor
adamreeve
left a comment
There was a problem hiding this comment.
This looks good to me thanks @vthemelis
From apache/arrow#44633 there were a couple of issues raised:
- This doesn't support lookup of multiple indexes for the same name. I think this is OK, the PR just speeds up the existing API without changing behaviour (the first matching index is returned). If there's a need to support lookup with multiple results that could be a separate change.
- Use of
StringComparer.CurrentCulture. I think it's correct to use this here to avoid changing behaviour. If we want to switch to theOrdinalcomparer being the default, that should be a separate change.
CurtHagenlocher
approved these changes
Mar 31, 2026
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.
Closes #301.
Ports the optimization from the closed PR at apache/arrow#44633 into the new .NET-specific repository.
The original PR was closed on November 18, 2025 with the note that the C# implementation had moved to a new repository.
This version keeps the current
arrow-dotnetbehavior intact:GetFieldIndex(..., comparer: null)and the default path now use a cachedCurrentCultureindex lookup for the common case.-1.I also added dedicated schema tests covering:
null,Ordinal,OrdinalIgnoreCase, andCurrentCulturecomparersLocal verification:
dotnet build test/Apache.Arrow.Tests/Apache.Arrow.Tests.csprojDOTNET_ROLL_FORWARD=Major DOTNET_ROLL_FORWARD_TO_PRERELEASE=1 dotnet test test/Apache.Arrow.Tests/Apache.Arrow.Tests.csproj --no-restore --logger 'console;verbosity=minimal'