Repository navigation
Conversation
…ping in TableResult
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 & Bottleneck
BigQueryImpl.transformTableDataandArrowDeserializer, everyFieldValueListinpageNoSchemais already constructed withschema.getFields()attached.TableResult.getValues()andTableResult.iterateAll()unconditionally wrap the underlying page iterable inaddSchema(...), which invokesIterables.transform(iter, list -> list.withSchema(getSchema().getFields())).getValues()oriterateAll(),TableResultcallsgetSchema().getFields()insideFunction.apply, andFieldValueList.withSchema(FieldList)allocates a newFieldValueListinstance and copiesthis.rowviaImmutableList.copyOfeven whenthis.schemais already the exact sameFieldList.pageNoSchema.getValues()inIterables.transformreturns a lazyFluentIterableview that does not implementjava.util.Collection, stripping known-sizeCollectionandRandomAccessfast-paths for callers collecting or streaming page results.Changes
java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/FieldValueList.java:withSchema(FieldList)to returnthiswhenthis.schema == schema || Objects.equals(this.schema, schema).getSchema()soTableResultcan inspect whether a page's rows already carry the targetFieldList.java-bigquery/google-cloud-bigquery/src/main/java/com/google/cloud/bigquery/TableResult.java:getSchema().getFields()outside theIterables.transformFunctioninaddSchema.getValues(), returnpageNoSchema.getValues()directly when it is aCollectionwhose elements already carry the matchingFieldList.java-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/FieldValueListTest.javaandjava-bigquery/google-cloud-bigquery/src/test/java/com/google/cloud/bigquery/TableResultTest.java:withSchemareturns the same instance when the schema matches and thatTableResult.getValues()andTableResult.iterateAll()preserveCollectionand row identity when rows already carry the schema.Expected Impact
FieldValueListallocations (24 bytes per row) on everyTableResult.getValues()andTableResult.iterateAll()traversal when rows already carry the schema.CollectionandListinterfaces onTableResult.getValues()when the underlying page holds a materialized collection.Verification
mvn test -pl java-bigquery/google-cloud-bigquery -Dtest=FieldValueListTest,TableResultTest,BigQueryImplTest -Dclirr.skip=true -Denforcer.skip=true -Dflatten.skip=true -Dcheckstyle.skip=true -Dfmt.skip=true(169 tests run, 0 failures).