Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request optimizes field index lookups in FieldList by pre-storing both exact-case and lowercase field names in a single map, avoiding string allocation and lowercasing on every lookup when exact or lowercase matches are found. It also ensures that the existing last-writer-wins behavior is preserved in case of case collisions. Unit tests have been added to verify these changes. I have no feedback to provide.
lqiu96
force-pushed
the
perf/bq-t1-02-fieldlist-getindex
branch
from
November 13, 2026 21:24
872ca0b to
2277d13
Compare
This branch has not been deployed
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
Avoids per-cell
String.toLowerCase()allocations when reading rows by column name (FieldValueList.get(String)->FieldList.getIndex(String)).Every row in a result set shares the same
FieldListschema, sogetIndex(name)runs once per cell lookup. Previously,FieldListused aCaseInsensitiveMapthat calledkey.toString().toLowerCase()on everyget(name)call:"UserName"),.toLowerCase()allocated a newStringon every cell read across every row..toLowerCase()scanned every character of the name on every lookup.Changes
FieldList:HashMapwithMaps.newHashMapWithExpectedSize(size * 2)and populate bothname.toLowerCase(Locale.ROOT)and exact-casename(when different) once when building the schema."FOO"at index 0 followed by"foo"at index 1).getIndex(String), probenameIndex.get(name)first so exact schema names and all-lowercase names hit with zero allocations, falling back toname.toLowerCase(Locale.ROOT)only on a miss.FieldListTest:testGetIndexExactLowerAndMixedCaseandtestGetIndexCaseCollisionPreservesLastWriterWins.Verification
mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=FieldListTest(6 passed)mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=SchemaTest(3 passed)mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=FieldValueListTest(5 passed)mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=FieldTest(12 passed)