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


##########
cpp/src/arrow/compute/kernels/vector_run_end_encode.cc:
##########
@@ -196,17 +198,26 @@ class RunEndEncodeImpl {
         /*output_run_ends=*/NULLPTR);
     std::tie(num_valid_runs, num_output_runs, data_buffer_size) =
         counting_loop.CountNumberOfRuns();
+    const int64_t physical_null_count = num_output_runs - num_valid_runs;
+    DCHECK(!has_validity_buffer || physical_null_count > 0)
+        << "has_validity_buffer is expected to imply physical_null_count > 0";
 
     ARROW_ASSIGN_OR_RAISE(
         auto output_array_data,
         ree_util::PreallocateREEArray(
-            std::move(ree_type), has_validity_buffer, input_length, 
num_output_runs,
-            num_output_runs - num_valid_runs, ctx_->memory_pool(), 
data_buffer_size));
+            std::move(ree_type), has_validity_buffer, 
/*logical_length=*/input_length,
+            /*physical_length=*/num_output_runs, ctx_->memory_pool(), 
data_buffer_size));
 
     // Initialize the output pointers
     auto* output_run_ends =
         output_array_data->child_data[0]->template 
GetMutableValues<RunEndCType>(1, 0);
     auto* output_values_array_data = output_array_data->child_data[1].get();
+    // Set the null_count on the physical array
+    DCHECK(!has_validity_buffer || output_values_array_data->buffers[0])
+        << "has_validity_buffer implies a validity buffer is allocated";
+    DCHECK(output_values_array_data->null_count == kUnknownNullCount ||
+           physical_null_count == 0);

Review Comment:
   So I thought, but the sneaky `AdjustNonNullable` (called from the 
`ArrayData` constructor) sets it to 0 if `length == 0`.



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