Skip to content

NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps#4417

Open
snazy wants to merge 1 commit into
apache:mainfrom
snazy:nosql-snowflake-v1-uuid
Open

NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps#4417
snazy wants to merge 1 commit into
apache:mainfrom
snazy:nosql-snowflake-v1-uuid

Conversation

@snazy
Copy link
Copy Markdown
Member

@snazy snazy commented May 12, 2026

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.

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.

// TODO add a specialized implementation using hard-coded values for the standardized parameters

@VisibleForTesting static final long TIME_UUID_EPOCH_OFFSET_100NS = 0x01b21dd213814000L;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: Maybe a small comment here would help the reviewer (at least it would have helped me 😄 ).

@github-project-automation github-project-automation Bot moved this from PRs In Progress to Ready to merge in Basic Kanban Board May 13, 2026
.isEqualTo(ID_EPOCH_MILLIS + timestamp);
soft.assertThat(impl.timeUuidToId(uuid)).isEqualTo(id);
}

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.

minor: add a negative test for unixMillisFromTimeUuidTimestamp rejecting a non-tick-aligned input (the % TICKS_PER_MILLISECOND == 0 branch), which is currently uncovered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants