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


##########
parquet/src/main/java/org/apache/iceberg/parquet/ParquetIO.java:
##########
@@ -123,6 +135,62 @@ public void seek(long newPos) throws IOException {
     }
   }
 
+  private static class ParquetRangeReadableInputStreamAdapter<
+          T extends org.apache.iceberg.io.SeekableInputStream & RangeReadable>
+      extends DelegatingSeekableInputStream implements RangeReadable {
+    private final T delegate;
+
+    private ParquetRangeReadableInputStreamAdapter(T delegate) {
+      super(delegate);
+      this.delegate = delegate;
+    }
+
+    @Override
+    public long getPos() throws IOException {
+      return delegate.getPos();
+    }
+
+    @Override
+    public void seek(long newPos) throws IOException {
+      delegate.seek(newPos);
+    }
+
+    @Override
+    public void readFully(long position, byte[] buffer, int offset, int 
length) throws IOException {
+      delegate.readFully(position, buffer, offset, length);
+    }
+
+    @Override
+    public int readTail(byte[] buffer, int offset, int length) throws 
IOException {
+      return delegate.readTail(buffer, offset, length);
+    }
+
+    @Override
+    public boolean readVectoredAvailable(ByteBufferAllocator allocate) {
+      return delegate.readVectoredAvailable(allocate::allocate);
+    }
+
+    @Override
+    public void readVectored(List<ParquetFileRange> ranges, 
ByteBufferAllocator allocate)
+        throws IOException {
+      IntFunction<ByteBuffer> delegateAllocate = (allocate::allocate);
+      List<ParquetObjectRange> delegateRange = convertRanges(ranges);
+      delegate.readVectored(delegateRange, delegateAllocate);
+    }
+
+    private static List<ParquetObjectRange> 
convertRanges(List<ParquetFileRange> ranges) {
+      return ranges.stream()
+          .map(
+              parquetFileRange -> {
+                CompletableFuture<ByteBuffer> result = new 
CompletableFuture<>();
+                parquetFileRange.setDataReadFuture(result);

Review Comment:
   Would a parquetFileRange already have a CompletableFuture<ByteBuffer> that 
we can get and pass to parquetObjectRange?
   
   In other words, why do we need to create a new CompletableFuture<ByteBuffer> 
here as result and use it in both objects? Can we re-use one from 
parquetFileRange if it already has one when it is created?



##########
api/src/main/java/org/apache/iceberg/io/ParquetObjectRange.java:
##########
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.iceberg.io;
+
+import java.nio.ByteBuffer;
+import java.util.concurrent.CompletableFuture;
+
+public class ParquetObjectRange {

Review Comment:
   why is this class upside/down? Shouldn't it start with class variables -> 
constructors -> methods by java convention? 



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