manner commented on code in PR #29103:
URL: https://github.com/apache/flink/pull/29103#discussion_r3947655218


##########
flink-core/src/main/java/org/apache/flink/types/variant/BinaryVariantUtil.java:
##########
@@ -674,6 +703,20 @@ public static String getString(byte[] value, int pos) {
         throw unexpectedType(Type.STRING);
     }
 
+    public static UUID getUUID(byte[] value, int pos) {
+        checkIndex(pos, value.length);
+        int basicType = value[pos] & BASIC_TYPE_MASK;
+        int typeInfo = (value[pos] >> BASIC_TYPE_BITS) & TYPE_INFO_MASK;
+        if (basicType != PRIMITIVE || typeInfo != UUID) {
+            throw unexpectedType(Type.UUID);
+        }
+        // The 16 UUID bytes are big-endian (most significant bytes first): 
the most significant 8
+        // bytes followed by the least significant 8 bytes.
+        long msb = readLongBigEndian(value, pos + 1);
+        long lsb = readLongBigEndian(value, pos + 9);

Review Comment:
   I was following the style of the other helper methods that each helper check 
its bounds before accessing the `byte[]`. I can remove the checks from 
`readLongBigEndian()`, because it's currently only used in the `getUUID` 
method, but then any future caller would also need to do the checks manually. 



-- 
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]

Reply via email to