denis-chudov commented on code in PR #2141:
URL: https://github.com/apache/ignite-3/pull/2141#discussion_r1251261351


##########
modules/core/src/main/java/org/apache/ignite/internal/util/IgniteUtils.java:
##########
@@ -1087,4 +1088,56 @@ public static boolean startsWith(byte[] key, byte[] 
prefix) {
         return key.length >= prefix.length
                 && Arrays.equals(key, 0, prefix.length, prefix, 0, 
prefix.length);
     }
+
+    /**
+     * Serializes collection to bytes.
+     *
+     * @param collection Collection.
+     * @param transform Tranform function for the collection element.
+     * @return Byte array.
+     */
+    public static <T> byte[] collectionToBytes(Collection<T> collection, 
Function<T, byte[]> transform) {
+        int bytesObjects = 0;
+        List<byte[]> objects = new ArrayList<>();
+
+        for (T o : collection) {
+            byte[] b = transform.apply(o);
+            objects.add(b);
+            bytesObjects += b.length;
+        }
+
+        bytesObjects += Integer.BYTES * (objects.size() + 1);

Review Comment:
   fixed



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