vibhatha commented on code in PR #43077:
URL: https://github.com/apache/arrow/pull/43077#discussion_r1689544628


##########
java/vector/src/main/codegen/templates/StructWriters.java:
##########
@@ -200,6 +203,31 @@ public ListWriter list(String name) {
     return writer;
   }
 
+  @Override
+  public ListWriter listView(String name) {
+    String finalName = handleCase(name);
+    FieldWriter writer = fields.get(finalName);
+    int vectorCount = container.size();
+    if(writer == null) {
+      FieldType fieldType = new FieldType(addVectorAsNullable, 
MinorType.LISTVIEW.getType(), null, null);
+      writer = new PromotableViewWriter(container.addOrGet(name, fieldType, 
ListViewVector.class), container, getNullableStructWriterFactory());
+      if (container.size() > vectorCount) {
+        writer.allocate();
+      }
+      writer.setPosition(idx());
+      fields.put(finalName, writer);
+    } else {
+      if (writer instanceof PromotableViewWriter) {
+        // ensure writers are initialized
+        ((PromotableViewWriter) writer).getWriter(MinorType.LISTVIEW);
+      } else {
+        writer = ((PromotableWriter) writer).promote();
+        ((PromotableViewWriter) writer).getWriter(MinorType.LISTVIEW);
+      }

Review Comment:
   In the beginning it was confusing to me how the original logic works, it 
contains only a single instance of `PromotableWriter` and using that we do all 
the writing (even though there are multiple writer types being used via the 
`StructWriter`) and since we needed a differentiation in the first place to 
make sure we can accomodate the `ListView` types to be included into the 
`UnionVector` maintained underneath this writers. 



-- 
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: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to