Skip to content

chore(spanner): implement key_recipe routing engine for basic types - #6281

Open
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-key-recipe-impl-1
Open

chore(spanner): implement key_recipe routing engine for basic types#6281
olavloite wants to merge 1 commit into
googleapis:mainfrom
olavloite:spanner-key-recipe-impl-1

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

Add key_recipe location-aware routing engine (encode_key_from_recipe and encode_key_from_recipe_into) to generate binary storage specification keys (ssformat) from Spanner KeyRecipe metadata for location-aware routing.

@olavloite
olavloite requested review from a team as code owners August 5, 2026 11:54
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Aug 5, 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 introduces a key recipe evaluation engine for Spanner location-aware routing, enabling the encoding of KeyRecipe specifications into lexicographical binary keys, along with unit and golden conformance tests. It also refactors composite tag validation in ssformat.rs to use u32 instead of i32. The review feedback identifies a correctness issue in the golden tests' byte unescaping logic where casting char to u8 can truncate non-ASCII characters, and suggests applying the 'Return Early' style guide principle in check_supported_key_type and encode_bytes_part to reduce nesting.

Comment thread src/spanner/src/routing/key_recipe/golden_tests.rs
Comment thread src/spanner/src/routing/key_recipe.rs Outdated
Comment thread src/spanner/src/routing/key_recipe.rs
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.35897% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.27%. Comparing base (35b9590) to head (d9f6f45).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
src/spanner/src/routing/key_recipe.rs 99.35% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6281      +/-   ##
==========================================
+ Coverage   96.24%   96.27%   +0.02%     
==========================================
  Files         280      281       +1     
  Lines       72146    72767     +621     
==========================================
+ Hits        69440    70058     +618     
- Misses       2706     2709       +3     

☔ 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 force-pushed the spanner-key-recipe-impl-1 branch from c6486aa to 8b69c57 Compare August 5, 2026 14:57
@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 introduces a key recipe evaluation engine for Spanner location-aware routing, implementing key encoding from a KeyRecipe and column values, along with extensive unit and golden conformance tests. It also updates composite tag constants and validation in ssformat.rs to use u32 instead of i32. The review feedback suggests enhancing transactional safety in encode_key_from_recipe_into by truncating the buffer on error, and refactoring check_supported_key_type and encode_part to return and use &TypeCode directly to avoid redundant lookups.

Comment thread src/spanner/src/routing/key_recipe.rs
Comment thread src/spanner/src/routing/key_recipe.rs Outdated
Comment thread src/spanner/src/routing/key_recipe.rs
Add `key_recipe` location-aware routing engine (`encode_key_from_recipe` and
`encode_key_from_recipe_into`) to generate binary storage specification keys
(`ssformat`) from Spanner `KeyRecipe` metadata for location-aware routing.
@olavloite
olavloite force-pushed the spanner-key-recipe-impl-1 branch from 8b69c57 to d9f6f45 Compare August 5, 2026 15:44
@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 introduces a key recipe evaluation engine for Spanner location-aware routing. It adds key_recipe.rs to evaluate and encode KeyRecipe instances into lexicographical binary keys, along with a comprehensive suite of unit tests and golden conformance tests in golden_tests.rs. Additionally, it updates composite tag validation constants and the append_composite_tag function in ssformat.rs to use u32 instead of i32. I have no further feedback to provide.

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.

1 participant