vibhatha commented on code in PR #43077: URL: https://github.com/apache/arrow/pull/43077#discussion_r1689541373
########## 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: When it comes to this call, there is already a `PromotableWriter` which get created when we first start writing using the `StructWriter` (it could be an intWriter, a floatWriter, etc). So the `else` is the one get called when there is any vector type other than `ListViewVector` is being written first. So in order to make sure we get the correct writer (`UnionListViewWriter` in our case), we need to make sure this cast happens. -- 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