nastra commented on code in PR #14700:
URL: https://github.com/apache/iceberg/pull/14700#discussion_r2579746562
##########
api/src/main/java/org/apache/iceberg/util/UUIDUtil.java:
##########
@@ -78,4 +81,32 @@ public static ByteBuffer convertToByteBuffer(UUID value,
ByteBuffer reuse) {
buffer.putLong(8, value.getLeastSignificantBits());
return buffer;
}
+
+ /**
+ * Generate a RFC 9562 UUIDv7 string.
+ *
+ * <p>Layout: - 48-bit Unix epoch milliseconds - 4-bit version (0b0111) -
12-bit random (rand_a) -
+ * 2-bit variant (RFC 4122, 0b10) - 62-bit random (rand_b)
+ */
+ public static String generateUuidV7() {
+ long epochMs = System.currentTimeMillis();
+ Preconditions.checkArgument(
+ (epochMs >>> 48) == 0, "timestamp does not fit within 48 bits: %s",
epochMs);
Review Comment:
maybe this should be an IllegalStateException, since the user can't really
provide an argument here and we're throwing a IAE? Also I would probably update
the error msg to align with the rest of the codebase to something like `Invalid
timestamp: does not fit within 48 bits: ...`
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]