openinx commented on a change in pull request #2566:
URL: https://github.com/apache/iceberg/pull/2566#discussion_r630672091



##########
File path: 
flink/src/main/java/org/apache/iceberg/flink/data/vectorized/VectorizedFlinkOrcReaders.java
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.flink.data.vectorized;
+
+import java.util.List;
+import java.util.Map;
+import org.apache.flink.orc.nohive.vector.OrcNoHiveBytesVector;
+import org.apache.flink.orc.nohive.vector.OrcNoHiveDecimalVector;
+import org.apache.flink.orc.nohive.vector.OrcNoHiveDoubleVector;
+import org.apache.flink.orc.nohive.vector.OrcNoHiveLongVector;
+import org.apache.flink.orc.nohive.vector.OrcNoHiveTimestampVector;
+import org.apache.flink.table.data.ArrayData;
+import org.apache.flink.table.data.ColumnarArrayData;
+import org.apache.flink.table.data.ColumnarRowData;
+import org.apache.flink.table.data.vector.ArrayColumnVector;
+import org.apache.flink.table.data.vector.ColumnVector;
+import org.apache.flink.table.data.vector.RowColumnVector;
+import org.apache.flink.table.data.vector.VectorizedColumnBatch;
+import org.apache.iceberg.MetadataColumns;
+import org.apache.iceberg.Schema;
+import org.apache.iceberg.orc.OrcBatchReader;
+import org.apache.iceberg.orc.OrcSchemaWithTypeVisitor;
+import org.apache.iceberg.types.Type;
+import org.apache.iceberg.types.Types;
+import org.apache.orc.TypeDescription;
+import org.apache.orc.storage.ql.exec.vector.BytesColumnVector;
+import org.apache.orc.storage.ql.exec.vector.DecimalColumnVector;
+import org.apache.orc.storage.ql.exec.vector.DoubleColumnVector;
+import org.apache.orc.storage.ql.exec.vector.ListColumnVector;
+import org.apache.orc.storage.ql.exec.vector.LongColumnVector;
+import org.apache.orc.storage.ql.exec.vector.StructColumnVector;
+import org.apache.orc.storage.ql.exec.vector.TimestampColumnVector;
+import org.apache.orc.storage.ql.exec.vector.VectorizedRowBatch;
+
+public class VectorizedFlinkOrcReaders {
+  private VectorizedFlinkOrcReaders() {
+  }
+
+  public static OrcBatchReader<VectorizedColumnBatch> buildReader(Schema 
expectedSchema, TypeDescription fileSchema,
+                                                                  Map<Integer, 
?> idToConstant) {
+    Converter converter = OrcSchemaWithTypeVisitor.visit(expectedSchema, 
fileSchema, new ReadBuilder(idToConstant));
+
+    return new OrcBatchReader<VectorizedColumnBatch>() {
+      private long batchOffsetInFile;
+
+      @Override
+      public VectorizedColumnBatch read(VectorizedRowBatch batch) {
+        FlinkRowColumnVector cv = (FlinkRowColumnVector) converter.convert(
+            new StructColumnVector(batch.size, batch.cols), batch.size, 
batchOffsetInFile);

Review comment:
       Looks like the `batchOffsetInFile` is used for metacolumn to get the 
correct row offset for a given row, mainly used for iceberg format v2.




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

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