cecemei commented on code in PR #19510:
URL: https://github.com/apache/druid/pull/19510#discussion_r3326166142


##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergInputSource.java:
##########


Review Comment:
   The arrow based approach is so different from the file catalog based, it 
also doesn't really implement `SplittableInputSource` any more, have you 
considered adding it as a separate `InputSource`? maybe we can extract some 
shared logic into a separate abstract class.



##########
extensions-contrib/druid-iceberg-extensions/src/main/java/org/apache/druid/iceberg/input/IcebergArrowInputSourceReader.java:
##########
@@ -0,0 +1,402 @@
+/*
+ * 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.druid.iceberg.input;
+
+import com.google.common.collect.Maps;
+import org.apache.arrow.vector.BigIntVector;
+import org.apache.arrow.vector.BitVector;
+import org.apache.arrow.vector.DateDayVector;
+import org.apache.arrow.vector.DecimalVector;
+import org.apache.arrow.vector.FieldVector;
+import org.apache.arrow.vector.FixedSizeBinaryVector;
+import org.apache.arrow.vector.Float4Vector;
+import org.apache.arrow.vector.Float8Vector;
+import org.apache.arrow.vector.IntVector;
+import org.apache.arrow.vector.SmallIntVector;
+import org.apache.arrow.vector.TimeMicroVector;
+import org.apache.arrow.vector.TimeStampMicroTZVector;
+import org.apache.arrow.vector.TimeStampMicroVector;
+import org.apache.arrow.vector.TimeStampMilliTZVector;
+import org.apache.arrow.vector.TimeStampMilliVector;
+import org.apache.arrow.vector.TimeStampNanoTZVector;
+import org.apache.arrow.vector.TimeStampNanoVector;
+import org.apache.arrow.vector.TinyIntVector;
+import org.apache.arrow.vector.VarBinaryVector;
+import org.apache.arrow.vector.VarCharVector;
+import org.apache.druid.data.input.ColumnsFilter;
+import org.apache.druid.data.input.InputRow;
+import org.apache.druid.data.input.InputRowListPlusRawValues;
+import org.apache.druid.data.input.InputRowSchema;
+import org.apache.druid.data.input.InputSourceReader;
+import org.apache.druid.data.input.InputStats;
+import org.apache.druid.data.input.MapBasedInputRow;
+import org.apache.druid.iceberg.filter.IcebergFilter;
+import org.apache.druid.java.util.common.parsers.CloseableIterator;
+import org.apache.iceberg.CombinedScanTask;
+import org.apache.iceberg.Table;
+import org.apache.iceberg.TableScan;
+import org.apache.iceberg.arrow.vectorized.ArrowReader;
+import org.apache.iceberg.arrow.vectorized.ColumnarBatch;
+import org.apache.iceberg.io.CloseableIterable;
+import org.apache.iceberg.types.Types;
+import org.apache.iceberg.util.TableScanUtil;
+import org.joda.time.DateTime;
+
+import javax.annotation.Nullable;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+
+/**
+ * Reads an Iceberg table via iceberg-arrow's {@link ArrowReader}, yielding 
{@link InputRow} objects.
+ *
+ * Delete application (V2 equality and positional deletes), type coercion, and 
schema evolution are
+ * handled entirely by the Iceberg library. Druid only consumes the resulting 
{@link ColumnarBatch}
+ * batches and maps them to {@link MapBasedInputRow}.
+ *
+ * Column projection and predicate push-down are applied at scan planning time 
so only requested
+ * columns and matching files are read from storage.
+ *
+ * Note: iceberg-arrow currently supports Parquet data files only. ORC and 
Avro files will throw
+ * {@link UnsupportedOperationException} at read time; use the standard 
delegate path for those.
+ */
+public class IcebergArrowInputSourceReader implements InputSourceReader
+{
+  // Pin Arrow to Unsafe allocator: Netty backend fails on JDK 25 
(EmptyByteBuf.memoryAddress UnsupportedOperationException).
+  static {
+    if (System.getProperty("arrow.allocation.manager.type") == null) {
+      System.setProperty("arrow.allocation.manager.type", "Unsafe");
+    }
+  }
+
+  static final int DEFAULT_BATCH_SIZE = 1024;
+
+  private final Table table;
+  @Nullable
+  private final IcebergFilter icebergFilter;
+  @Nullable
+  private final DateTime snapshotTime;
+  private final boolean caseSensitive;
+  private final InputRowSchema schema;
+  private final int batchSize;
+
+  public IcebergArrowInputSourceReader(
+      final Table table,
+      @Nullable final IcebergFilter icebergFilter,
+      @Nullable final DateTime snapshotTime,
+      final boolean caseSensitive,
+      final InputRowSchema schema,
+      final int batchSize
+  )
+  {
+    this.table = table;
+    this.icebergFilter = icebergFilter;
+    this.snapshotTime = snapshotTime;
+    this.caseSensitive = caseSensitive;
+    this.schema = schema;
+    this.batchSize = batchSize;
+  }
+
+  @Override
+  public CloseableIterator<InputRow> read(final InputStats inputStats) throws 
IOException

Review Comment:
   InputStats is nullable, since the default `read()` just pass in 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