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



##########
File path: spark/src/main/java/org/apache/iceberg/spark/data/SparkOrcWriter.java
##########
@@ -126,30 +122,106 @@ public SparkOrcValueWriter primitive(Type.PrimitiveType 
iPrimitive, TypeDescript
     }
   }
 
-  private static class StructWriter implements SparkOrcValueWriter {
-    private final List<SparkOrcValueWriter> writers;
+  private static class InternalRowWriter extends 
GenericOrcWriters.StructWriter<InternalRow> {
+    private final List<FieldGetter<?>> fieldGetters;
 
-    StructWriter(List<SparkOrcValueWriter> writers) {
-      this.writers = writers;
-    }
+    InternalRowWriter(List<OrcValueWriter<?>> writers, List<TypeDescription> 
orcTypes) {
+      super(writers);
+      this.fieldGetters = Lists.newArrayListWithExpectedSize(orcTypes.size());
 
-    List<SparkOrcValueWriter> writers() {
-      return writers;
+      for (int i = 0; i < orcTypes.size(); i++) {
+        fieldGetters.add(createFieldGetter(orcTypes.get(i)));
+      }
     }
 
     @Override
-    public void nonNullWrite(int rowId, int column, SpecializedGetters data, 
ColumnVector output) {
-      InternalRow value = data.getStruct(column, writers.size());
-      StructColumnVector cv = (StructColumnVector) output;
-      for (int c = 0; c < writers.size(); ++c) {
-        writers.get(c).write(rowId, c, value, cv.fields[c]);
-      }
+    public Class<?> getJavaClass() {
+      return InternalRow.class;
     }
 
     @Override
     public Stream<FieldMetrics<?>> metrics() {
-      return writers.stream().flatMap(SparkOrcValueWriter::metrics);
+      return writers().stream().flatMap(OrcValueWriter::metrics);

Review comment:
       Nit:  No need to rewrite this method because seems like it has the same 
implementation as the super class 's `metrics`.




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