kou commented on code in PR #47522:
URL: https://github.com/apache/arrow/pull/47522#discussion_r2328951954


##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -771,6 +771,13 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
     return Status::OK();
   }
 
+  /// This method is "unsafe" because it does not update the null bitmap

Review Comment:
   ```suggestion
     /// This method is "unsafe" because it does not update the null bitmap.
   ```



##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -771,6 +771,13 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
     return Status::OK();
   }
 
+  /// This method is "unsafe" because it does not update the null bitmap
+  /// It doesn't check the capacity. Caller is responsible for calling 
Reserve()
+  /// beforehand.
+  void UnsafeAppend(){

Review Comment:
   ```suggestion
     void UnsafeAppend(bool is_valid = true) {
   ```



##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -780,6 +787,19 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
     return Append(false);
   }
 
+  /// This method is "unsafe" because it does not check for capacity.
+  /// The caller is responsible for calling Reserve() beforehand to ensure
+  /// there is enough space. This method will append nulls to all child
+  /// builders to maintain a consistent state.
+  Status UnsafeAppendNull(){
+    null_bitmap_builder_.UnsafeAppend(false);
+    for(const auto& child: children_){
+      ARROW_RETURN_NOT_OK(child->AppendNull());
+    }
+    length_++;

Review Comment:
   ```suggestion
       UnsafeAppend(false);
   ```



##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -780,6 +787,19 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
     return Append(false);
   }
 
+  /// This method is "unsafe" because it does not check for capacity.
+  /// The caller is responsible for calling Reserve() beforehand to ensure
+  /// there is enough space. This method will append nulls to all child
+  /// builders to maintain a consistent state.
+  Status UnsafeAppendNull(){
+    null_bitmap_builder_.UnsafeAppend(false);
+    for(const auto& child: children_){
+      ARROW_RETURN_NOT_OK(child->AppendNull());

Review Comment:
   We need to append an empty value not null.
   
   Ah, we may need `UnsafeAppendEmptyValue()` before we work on this. @pitrou 
What do you think about this?



##########
cpp/src/arrow/array/builder_nested.h:
##########
@@ -771,6 +771,13 @@ class ARROW_EXPORT StructBuilder : public ArrayBuilder {
     return Status::OK();
   }
 
+  /// This method is "unsafe" because it does not update the null bitmap
+  /// It doesn't check the capacity. Caller is responsible for calling 
Reserve()
+  /// beforehand.
+  void UnsafeAppend(){
+    ++length_;

Review Comment:
   ```suggestion
       UnsafeAppendToBitmap(is_valid);
   ```
   
   Could you use `UnsafeAppend(is_valid)` in `Append()` instead of 
`UnsafeAppendToBitmap(is_valid)`?



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

Reply via email to