Repository navigation
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces several performance and memory optimizations across the BigQuery client library. Key improvements include replacing lazy Guava transformations with eager materialization using pre-sized collections, converting a LinkedList to an ArrayList in InsertAllRequest to reduce per-row memory overhead, and simplifying a mutable single-element boolean array to a standard boolean variable in BigQueryImpl. I have no feedback to provide as there are no review comments.
lqiu96
force-pushed
the
perf/bq-t1-10-insertall-pre-sizing
branch
from
November 14, 2026 01:04
a551158 to
89636a1
Compare
lqiu96
marked this pull request as ready for review
November 19, 2026 19:39
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
Reduces collection allocations and resizing in
InsertAllRequest,BigQueryImpl.insertAll, andInsertAllResponsewithout changing lazy evaluation semantics:InsertAllRequest.Builder.setRows: Stages rows in anArrayListinstead of aLinkedList, avoiding per-rowNodeallocations beforebuild()copies them into anImmutableList.BigQueryImpl.insertAll: ReplacesFluentIterable.from(rows).transform(...).toList()and itsboolean[]wrapper with a loop intonew ArrayList<>(rows.size()).InsertAllResponse.toPb/fromPb: UsesImmutableList.builderWithExpectedSize(insertErrors.size())intoPb()andImmutableMap.builderWithExpectedSize(errorsPb.size()).buildKeepingLast()infromPb(), avoiding a temporaryHashMapcopy.Why Lazy Evaluation Is Unaffected
BigQueryImpl.insertAllpreviously called.toList()onFluentIterable.transform(...), andInsertAllResponse.toPb()previously calledImmutableList.copyOf(...)onIterables.transform(...). Both already materialized immediately on the same statement. The lazy wrappers only hid.size()and caused array resizing.BigQueryErrorlists inInsertAllResponsestill use lazyLists.transformviews, preserving existing behavior.Verification
mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=InsertAllRequestTest,BigQueryImplTest -Dclirr.skip=true -Denforcer.skip=true -Dflatten.skip=true(InsertAllRequestTest: 21 passed,BigQueryImplTest: 133 passed)mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=InsertAllResponseTest -Dclirr.skip=true -Denforcer.skip=true -Dflatten.skip=true(4 passed)