NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps#4417
Open
snazy wants to merge 1 commit into
Open
NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps#4417snazy wants to merge 1 commit into
snazy wants to merge 1 commit into
Conversation
Use the standard UUID v1 timestamp layout when converting snowflake ids into time-based UUIDs. The previous encoding did not line up with the normal v1 field ordering, which made these ids awkward to inspect and compare with other tooling. The tests pin the timestamp bits around the conversion. This is a non-breaking change, as there's no production use of UUIDs from snowflake IDs.
jbonofre
approved these changes
May 13, 2026
|
|
||
| // TODO add a specialized implementation using hard-coded values for the standardized parameters | ||
|
|
||
| @VisibleForTesting static final long TIME_UUID_EPOCH_OFFSET_100NS = 0x01b21dd213814000L; |
Member
There was a problem hiding this comment.
nit: Maybe a small comment here would help the reviewer (at least it would have helped me 😄 ).
flyrain
reviewed
May 14, 2026
| .isEqualTo(ID_EPOCH_MILLIS + timestamp); | ||
| soft.assertThat(impl.timeUuidToId(uuid)).isEqualTo(id); | ||
| } | ||
|
|
Contributor
There was a problem hiding this comment.
minor: add a negative test for unixMillisFromTimeUuidTimestamp rejecting a non-tick-aligned input (the % TICKS_PER_MILLISECOND == 0 branch), which is currently uncovered.
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.
Use the standard UUID v1 timestamp layout when converting snowflake ids into time-based UUIDs.
The previous encoding did not line up with the normal v1 field ordering, which made these ids awkward to inspect and compare with other tooling. The tests pin the timestamp bits around the conversion.
This is a non-breaking change, as there's no production use of UUIDs from snowflake IDs.