pvary commented on code in PR #13997:
URL: https://github.com/apache/iceberg/pull/13997#discussion_r2382513747


##########
api/src/main/java/org/apache/iceberg/io/RangeReadable.java:
##########
@@ -77,4 +83,61 @@ default void readFully(long position, byte[] buffer) throws 
IOException {
   default int readTail(byte[] buffer) throws IOException {
     return readTail(buffer, 0, buffer.length);
   }
+
+  /**
+   * Read fully a list of file ranges asynchronously from this file. As a 
result of the call, each
+   * range will have FileRange.setData(CompletableFuture) called with a future 
that when complete
+   * will have a ByteBuffer with the data from the file's range.
+   *
+   * <p>The position returned by getPos() after readVectored() is undefined.
+   *
+   * <p>If a file is changed while the readVectored() operation is in 
progress, the output is
+   * undefined. Some ranges may have old data, some may have new and some may 
have both.
+   *
+   * <p>While a readVectored() operation is in progress, normal read api calls 
may block.
+   *
+   * @param ranges the byte ranges to read
+   * @param allocate the function to allocate ByteBuffer
+   * @throws IOException any IOE.
+   * @throws IllegalArgumentException if any of ranges are invalid, or they 
overlap.
+   */
+  default void readVectored(List<FileRange> ranges, IntFunction<ByteBuffer> 
allocate)
+      throws IOException {
+    List<FileRange> validatedRanges = sortRanges(ranges);
+    for (FileRange range : validatedRanges) {
+      ByteBuffer buffer = allocate.apply(range.length());
+      readFully(range.offset(), buffer.array());
+      range.byteBuffer().complete(buffer);
+    }
+  }
+
+  static List<FileRange> sortRanges(final List<FileRange> input) {
+    Preconditions.checkNotNull(input, "Null input list");

Review Comment:
   nit: fix this too please.
   ```
   Preconditions.checkNotNull(input, "Input list can't be null");
   ```



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