feat(bigquery-jdbc): optimize memory footprint for JSON result set streaming#13660
feat(bigquery-jdbc): optimize memory footprint for JSON result set streaming#13660Neenu1995 wants to merge 11 commits into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces BigQueryJsonStreamParser to parse BigQuery REST JSON responses into lightweight Object[] row buffers, reducing JVM heap overhead and GC pause times. It also updates BigQueryFieldValueListWrapper and BigQueryStatement to support and utilize these lightweight row buffers. The review feedback highlights critical infinite loop vulnerabilities in the JSON parsing loops when handling truncated or abruptly ended streams, and suggests using standard Jackson parsing patterns with explicit null token checks. Additionally, the reviewer recommends chaining constructors to reduce code duplication and removing unused stream parsing methods from the production code.
| Uninterruptibles.putUninterruptibly( | ||
| bigQueryFieldValueListWrapperBlockingQueue, | ||
| BigQueryFieldValueListWrapper.of(schema.getFields(), fieldValueList)); | ||
| BigQueryFieldValueListWrapper.ofUnpackedRow( |
There was a problem hiding this comment.
We already pass schema.getFields(), so we can just move isComplexColumn to be a part of BigQueryFieldValueListWrapper.of()? So no changes in statement, changes are scoped to the object itself
There was a problem hiding this comment.
BigQueryFieldValueListWrapper.of() is called once per row. Computing isComplexColumn that many times can be costly. It is ideal to call isComplexColumn once per query. Hence the current design.
I will keep the isComplexColumn in Statement but can eliminate the other change by reusing the of method instead of creating a new ofUnpackedRow method.
b/529436374
BigQueryFieldValueListWrapperusing a static, stateless utility pattern to reduce object allocations during JSON result set parsing.ARRAY,STRUCT,RANGE) outside the page-fetching loop inBigQueryStatementto avoid redundant per-row inspection.FieldValuereferences for complex types (RANGE,ARRAY,STRUCT) during row unpacking to prevent improper string coercion.