You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/05/10 11:38:25 UTC

[GitHub] [nifi] MikeThomsen commented on a diff in pull request #6013: NIFI-9981 Added support for Avro UUID types

MikeThomsen commented on code in PR #6013:
URL: https://github.com/apache/nifi/pull/6013#discussion_r869131518


##########
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java:
##########
@@ -712,6 +746,20 @@ public static Object[] toArray(final Object value, final String fieldName, final
             return dest;
         }
 
+        if (value instanceof UUID) {
+            UUID uuid = (UUID)value;
+            ByteBuffer buffer = ByteBuffer.allocate(16);
+            buffer.putLong(uuid.getMostSignificantBits());
+            buffer.putLong(uuid.getLeastSignificantBits());
+            Byte[] result = new Byte[16];
+            byte[] array = buffer.array();
+            for (int index = 0; index < array.length; index++) {
+                result[index] = array[index];
+            }
+
+            return result;

Review Comment:
   I noticed that everything, even the "to byte array" conversion goes to the boxed byte type, so I followed the convention on the assumption that somewhere there might be an expectation of that method not returning a primitive array.



-- 
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@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org