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


##########
cpp/src/arrow/compute/kernels/ree_util_internal.cc:
##########
@@ -79,7 +80,10 @@ Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
   } else {
     values_data_buffers = {std::move(validity_buffer), 
std::move(values_buffer)};
   }
-  return ArrayData::Make(value_type, length, std::move(values_data_buffers), 
null_count);
+  auto data =
+      ArrayData::Make(value_type, length, std::move(values_data_buffers), 
null_count);
+  DCHECK(!has_validity_buffer || data->buffers[0] != NULLPTR);
+  return {std::move(data)};

Review Comment:
   Do we need explicit `std::move()` here?
   
   ```suggestion
     return data;
   ```



##########
cpp/src/arrow/compute/kernels/ree_util_internal.cc:
##########
@@ -60,6 +60,7 @@ Result<std::shared_ptr<ArrayData>> PreallocateRunEndsArray(
 Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
     const std::shared_ptr<DataType>& value_type, bool has_validity_buffer, 
int64_t length,
     int64_t null_count, MemoryPool* pool, int64_t data_buffer_size) {
+  DCHECK(!has_validity_buffer || null_count != 0);

Review Comment:
   It's difficult to understand for me... How about this style?
   
   ```suggestion
     DCHECK(!(has_validity_buffer && null_count == 0));
   ```
   
   And how about adding the pre-condition in the doc as a comment here too?



##########
cpp/src/arrow/compute/kernels/ree_util_internal.cc:
##########
@@ -79,7 +80,10 @@ Result<std::shared_ptr<ArrayData>> PreallocateValuesArray(
   } else {
     values_data_buffers = {std::move(validity_buffer), 
std::move(values_buffer)};
   }
-  return ArrayData::Make(value_type, length, std::move(values_data_buffers), 
null_count);
+  auto data =
+      ArrayData::Make(value_type, length, std::move(values_data_buffers), 
null_count);
+  DCHECK(!has_validity_buffer || data->buffers[0] != NULLPTR);

Review Comment:
   We don't need to use `NULLPTR` in `.cc`.
   
   And how about using this style?
   
   ```suggestion
     DCHECK(!(has_validity_buffer && data->buffers[0]));
   ```
   
   (Post-condition as a comment will help use here too.)



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