kerneltime commented on code in PR #3730:
URL: https://github.com/apache/ozone/pull/3730#discussion_r1083267139


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/keyvalue/helpers/ChunkUtils.java:
##########
@@ -227,10 +248,40 @@ public static void readData(File file, ByteBuffer[] 
buffers,
         bytesRead, offset, file);
 
     validateReadSize(len, bytesRead);
+  }
 
-    for (ByteBuffer buf : buffers) {
-      buf.flip();
-    }
+  public static ChunkBufferToByteString readData(File file, long chunkSize,
+      long offset, long length, HddsVolume volume)
+      throws StorageContainerException {
+    final List<ByteBuf> buffers = ChunkUtils.readDataNettyChunkedNioFile(
+        file, Math.toIntExact(chunkSize), offset, length, volume);
+    return ChunkBufferToByteString.wrap(buffers);
+  }
+
+  /**
+   * Read data from the given file using {@link ChunkedNioFile}.
+   *
+   * @return a list of {@link ByteBuf} containing the data.
+   */
+  private static List<ByteBuf> readDataNettyChunkedNioFile(
+      File file, int chunkSize,
+      long offset, long length, HddsVolume volume)
+      throws StorageContainerException {
+
+    final List<ByteBuf> buffers = new ArrayList<>(
+        Math.toIntExact((length - 1) / chunkSize) + 1);

Review Comment:
   Won't this depend on the allocator using buffers the same size as chunks?



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

Reply via email to