You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@polaris.apache.org by "snazy (via GitHub)" <gi...@apache.org> on 2026/05/12 18:15:11 UTC
[PR] NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps [polaris]
snazy opened a new pull request, #4417:
URL: https://github.com/apache/polaris/pull/4417
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps [polaris]
Posted by "jbonofre (via GitHub)" <gi...@apache.org>.
jbonofre commented on code in PR #4417:
URL: https://github.com/apache/polaris/pull/4417#discussion_r3231715836
##########
persistence/nosql/idgen/impl/src/main/java/org/apache/polaris/ids/impl/SnowflakeIdGeneratorImpl.java:
##########
@@ -54,6 +54,9 @@ class SnowflakeIdGeneratorImpl implements SnowflakeIdGenerator {
// TODO add a specialized implementation using hard-coded values for the standardized parameters
+ @VisibleForTesting static final long TIME_UUID_EPOCH_OFFSET_100NS = 0x01b21dd213814000L;
Review Comment:
nit: Maybe a small comment here would help the reviewer (at least it would have helped me 😄 ).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy commented on PR #4417:
URL: https://github.com/apache/polaris/pull/4417#issuecomment-4450226284
Comments addressed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps [polaris]
Posted by "flyrain (via GitHub)" <gi...@apache.org>.
flyrain commented on code in PR #4417:
URL: https://github.com/apache/polaris/pull/4417#discussion_r3238370212
##########
persistence/nosql/idgen/impl/src/test/java/org/apache/polaris/ids/impl/TestSnowflakeIdGeneratorImpl.java:
##########
@@ -559,12 +564,30 @@ void spinWaitSequence() {
() ->
impl.timeUuidToId(
new UUID(
- timeUuidMsbReal((1L << DEFAULT_TIMESTAMP_BITS) - 1),
+ timeUuidMsbReal(
+ timeUuidTimestampFromUnixMillis(
+ ID_EPOCH_MILLIS + ((1L << DEFAULT_TIMESTAMP_BITS) - 2))),
timeUuidLsb(
(1L << DEFAULT_SEQUENCE_BITS) - 1, (1L << DEFAULT_NODE_ID_BITS) - 1))))
.doesNotThrowAnyException();
}
+ @Test
+ public void timeUuidUsesStandardTimestampEncoding() {
+ var nodeId = 42;
+ var timestamp = TimeUnit.DAYS.toMillis(365);
+ var impl =
+ new SnowflakeIdGeneratorImpl(idGeneratorSource(nodeId, () -> ID_EPOCH_MILLIS + timestamp));
+ var id = impl.constructId(timestamp, 7, nodeId);
+ var uuid = impl.idToTimeUuid(id);
+
+ soft.assertThat(uuid.timestamp())
+ .isEqualTo(timeUuidTimestampFromUnixMillis(ID_EPOCH_MILLIS + timestamp));
+ soft.assertThat(unixMillisFromTimeUuidTimestamp(uuid.timestamp()))
+ .isEqualTo(ID_EPOCH_MILLIS + timestamp);
+ soft.assertThat(impl.timeUuidToId(uuid)).isEqualTo(id);
+ }
+
Review 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 is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] NoSQL: Encode Snowflake time UUIDs with standard v1 timestamps [polaris]
Posted by "snazy (via GitHub)" <gi...@apache.org>.
snazy merged PR #4417:
URL: https://github.com/apache/polaris/pull/4417
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@polaris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org