chore(spanner): add sortable-string util methods - #6214
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces the routing module and its submodule ssformat to the spanner crate, providing utilities to encode various Spanner data types into a byte format that preserves lexicographic ordering, along with comprehensive unit tests. The reviewer's feedback focuses on improving code readability and idiomatic Rust patterns, specifically suggesting the use of key.to_vec() for simpler vector allocation, refactoring nested conditionals to return early, and extracting duplicated initialization logic in the signed integer encoding function.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6214 +/- ##
==========================================
+ Coverage 96.02% 96.04% +0.01%
==========================================
Files 269 270 +1
Lines 67282 67819 +537
==========================================
+ Hits 64607 65135 +528
- Misses 2675 2684 +9 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
36ae12a to
c8183d7
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces location-aware routing internal modules for Spanner, specifically implementing Sortable String Format (ssformat) encoding utilities to serialize various Spanner data types (such as integers, doubles, strings, bytes, timestamps, UUIDs, and nulls) into lexicographically ordered byte sequences. The review feedback highlights that f64::to_bits() does not guarantee a canonical representation for NaN values in Rust, and suggests normalizing NaN values in both append_double_increasing and append_double_decreasing to ensure consistent encoding and sorting.
c8183d7 to
ac8ceec
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new module routing::ssformat in the Spanner crate, which provides Sortable String Format (ssformat) encoding utilities for Spanner keys to preserve lexicographic ordering. The review feedback highlights two key areas for improvement: first, replacing the bit-shifted constant TIMESTAMP_SECONDS_OFFSET with i64::MIN for better readability and safety; second, addressing a potential usize underflow bug in append_int64_internal by performing the buffer bounds check before calculating the index 7 - len.
ac8ceec to
c3d8c6c
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new routing module containing ssformat utilities for encoding Spanner keys while preserving lexicographic ordering. A review comment identified a bug in the make_prefix_successor implementation, which fails to correctly handle certain byte sequences; a code-based fix was provided to ensure robust prefix successor generation.
c3d8c6c to
7f7da52
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new internal module routing containing ssformat encoding utilities for Spanner keys, enabling lexicographical sortable encoding of various Spanner data types. The reviewer suggested a minor improvement to ensure platform-independent NaN canonicalization by using a hardcoded IEEE 754 quiet NaN bit pattern constant instead of f64::NAN.to_bits().
7f7da52 to
b6e8111
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new routing module and a ssformat submodule in the spanner crate, implementing Sortable String Format encoding utilities for Spanner keys along with comprehensive unit tests. The review feedback suggests removing an unnecessary else block in canonical_double_bits to adhere to the repository style guide, and optimizing the integer encoding logic in append_int64_internal by utilizing standard library intrinsics like leading_zeros and leading_ones instead of loops.
Adds Sortable String Format util methods to the Rust client. These methods are used for location-aware routing in the Spanner client. This allows the client to route requests directly to the Spanner server that holds a given range of data. This implementation is a port of the corresponding Java client implementation.
b6e8111 to
77440ad
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new internal module routing and its submodule ssformat to the Spanner crate. The ssformat module implements Sortable String Format encoding utilities for Spanner keys, supporting ascending and descending lexicographical sorting for various data types (booleans, integers, doubles, strings, bytes, nullable markers, timestamps, and UUIDs). It also includes comprehensive unit tests verifying correct ordering behavior and edge cases. There are no review comments to address, and I have no additional feedback to provide.
Adds Sortable String Format util methods to the Rust client. These methods are used for location-aware routing in the Spanner client. This allows the client to route requests directly to the Spanner server that holds a given range of data.
This implementation is a port of the corresponding Java client implementation.