lidavidm commented on code in PR #41930:
URL: https://github.com/apache/arrow/pull/41930#discussion_r1625023631
##########
java/c/src/main/java/org/apache/arrow/c/StructVectorLoader.java:
##########
@@ -54,7 +55,12 @@ public class StructVectorLoader {
/**
* Construct with a schema.
- *
+ * <p>
+ * The schema referred to here can be obtained from the struct vector.
+ * Consider a {@link StructVector} structVector, the schema can be obtained
as follows:
+ * <code>
+ * Schema schema = new Schema(structVector.getField().getChildren());
+ * </code>
Review Comment:
So in other words, the schema should not be the schema including the struct
field, it should be the struct's children?
##########
java/c/src/main/java/org/apache/arrow/c/StructVectorLoader.java:
##########
@@ -111,7 +117,7 @@ private void loadBuffers(FieldVector vector, Field field,
Iterator<ArrowBuf> buf
ArrowFieldNode fieldNode = nodes.next();
// variadicBufferLayoutCount will be 0 for vectors of type except
BaseVariableWidthViewVector
long variadicBufferLayoutCount = 0;
- if (variadicBufferCounts != null) {
+ if (vector instanceof BaseVariableWidthViewVector &&
variadicBufferCounts.hasNext()) {
Review Comment:
nit: I think if there's no next count, we should error in this case
##########
java/c/src/main/java/org/apache/arrow/c/StructVectorLoader.java:
##########
@@ -111,7 +117,7 @@ private void loadBuffers(FieldVector vector, Field field,
Iterator<ArrowBuf> buf
ArrowFieldNode fieldNode = nodes.next();
// variadicBufferLayoutCount will be 0 for vectors of type except
BaseVariableWidthViewVector
long variadicBufferLayoutCount = 0;
- if (variadicBufferCounts != null) {
+ if (vector instanceof BaseVariableWidthViewVector &&
variadicBufferCounts.hasNext()) {
Review Comment:
I suppose if you want to be like Rust, at the end of this method you should
also `assert !variadicBufferCounts.hasNext()`
--
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]