Visitar URL original
chore(spanner): clean up chunked value merging by olavloite · Pull Request #7150 · googleapis/google-cloud-rust · GitHub
Skip to content

chore(spanner): clean up chunked value merging - #7150

Merged
olavloite merged 2 commits into
googleapis:mainfrom
olavloite:spanner-cleanup-chunked-value-merging
Oct 8, 2026
Merged

olavloite merged 2 commits into
googleapis:mainfrom
olavloite:spanner-cleanup-chunked-value-merging

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Clean up and optimize chunked result set merging in Cloud Spanner and add comprehensive golden acceptance and unit test coverage.

What changed:

  • Value merging cleanup: Refactored merge_values in result_set.rs to consume source list values via an iterator instead of calling remove(0) (avoiding O(N) memory copies on every chunk), and eliminated an unreachable dead-code branch.
  • Wire protocol verification: Confirmed that array element boundary concatenation is intended Spanner wire protocol behavior, and that SQL STRUCT values are transmitted as ListValue over the wire (making StructValue merge logic dead code).
  • Acceptance tests: Added the 18 golden acceptance test scenarios from the Spanner specification (in streaming_read_acceptance_test.json) covering string, numeric, integer, float, json, and nested struct array chunking.
  • Edge case unit tests: Added targeted unit tests for empty string prefixes, empty list head/tail merges, base64 BYTES / ARRAY splits, intermediate single-value chunks, and stream resumption with retry tokens mid-chunk for both scalar and array values.

@olavloite
olavloite requested review from a team as code owners October 8, 2026 07:27
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Oct 8, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the merge_values function in result_set.rs to optimize the merging of ListValue types by using an iterator instead of remove(0), which avoids O(N) shifts. It also introduces a comprehensive suite of acceptance and unit tests for streaming reads and chunked values, supported by a new JSON test data file. Feedback suggests using .expect() instead of if let Some when retrieving the last element of target_list.values to explicitly assert the non-empty invariant and reduce nesting.

Comment thread src/spanner/src/result_set.rs Outdated
Clean up and optimize chunked result set merging in Cloud Spanner
and add comprehensive golden acceptance and unit test coverage.

What changed:
- Value merging cleanup: Refactored merge_values in result_set.rs
  to consume source list values via an iterator instead of
  calling remove(0) (avoiding O(N) memory copies on every chunk),
  and eliminated an unreachable dead-code branch.
- Wire protocol verification: Confirmed that array element boundary
  concatenation is intended Spanner wire protocol behavior, and that
  SQL STRUCT values are transmitted as ListValue over the wire
  (making StructValue merge logic dead code).
- Acceptance tests: Added the 18 golden acceptance test scenarios
  from the Spanner specification (in streaming_read_acceptance_test.json)
  covering string, numeric, integer, float, json, and nested struct
  array chunking.
- Edge case unit tests: Added targeted unit tests for empty string
  prefixes, empty list head/tail merges, base64 BYTES / ARRAY<BYTES>
  splits, intermediate single-value chunks, and stream resumption with
  retry tokens mid-chunk for both scalar and array values.
@olavloite
olavloite force-pushed the spanner-cleanup-chunked-value-merging branch from 7b269cd to 2e46b67 Compare October 8, 2026 07:40
@olavloite

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the merge_values function in result_set.rs to optimize the merging of chunked ListValue types by using an iterator instead of an expensive remove(0) operation. It also cleans up imports and variable names for better readability. Additionally, a comprehensive suite of unit and acceptance tests has been added, including a new JSON-based test suite (streaming_read_acceptance_test.json) to validate various chunking and merging scenarios such as empty strings, nested structs, retries with resume tokens, and incompatible type errors. There are no review comments, and the changes look excellent, so I have no further feedback to provide.

@olavloite
olavloite requested a review from rahul2393 October 8, 2026 07:46

let source_first = source_list.values.remove(0);
if let Some(target_last) = target_list.values.last_mut() {
let mut source_iterator = source_list.values.into_iter();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a small optimization to prevent O(N) memory copies on every chunk

@codecov

codecov Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.74016% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 97.35%. Comparing base (0ce0b37) to head (0f8e112).

Files with missing lines Patch % Lines
src/spanner/src/result_set.rs 98.74% 8 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #7150    +/-   ##
========================================
  Coverage   97.34%   97.35%            
========================================
  Files         327      327            
  Lines      127848   128475   +627     
========================================
+ Hits       124452   125075   +623     
- Misses       3396     3400     +4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@olavloite
olavloite merged commit 7743b26 into googleapis:main Oct 8, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants