felipecrv commented on code in PR #43415:
URL: https://github.com/apache/arrow/pull/43415#discussion_r1693483154


##########
cpp/src/arrow/compute/row/row_internal.cc:
##########
@@ -293,8 +293,12 @@ Status RowTableImpl::ResizeFixedLengthBuffers(int64_t 
num_extra_rows) {
 }
 
 Status RowTableImpl::ResizeOptionalVaryingLengthBuffer(int64_t 
num_extra_bytes) {
+  if (metadata_.is_fixed_length) {
+    return Status::OK();
+  }

Review Comment:
   In the first callsite it's clearly inside a branch where 
`!metadata_.is_fixed_length`.
   
   The second callsite should have an if guarding the call to 
`ResizeOptionalVaryingLengthBuffer` as it doesn't make sense to resize varying 
length buffers if there aren't any. The client code become more explicit.
   
   ```diff
    Status RowTableImpl::AppendEmpty(uint32_t num_rows_to_append,
                                     uint32_t num_extra_bytes_to_append) {
      RETURN_NOT_OK(ResizeFixedLengthBuffers(num_rows_to_append));
   -  
RETURN_NOT_OK(ResizeOptionalVaryingLengthBuffer(num_extra_bytes_to_append));
   +  if (!metadata_.is_fixed_length) {
   +    
RETURN_NOT_OK(ResizeOptionalVaryingLengthBuffer(num_extra_bytes_to_append));
   +  }
      num_rows_ += num_rows_to_append;
      if (metadata_.row_alignment > 1 || metadata_.string_alignment > 1) {
        memset(rows_->mutable_data(), 0, bytes_capacity_);
      }
      return Status::OK();
    }
   ```
   
   



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