felipecrv commented on code in PR #36740:
URL: https://github.com/apache/arrow/pull/36740#discussion_r1268213685
##########
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";
Review Comment:
I put it here to communicate the invariants close to the point of buffer
usage, but I'm going to remove it to reduce noise — we can rely on the `\post`
comment in the docs and I added the `DCHECK` there instead.
##########
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";
Review Comment:
I put it here to communicate the invariants close to the point of buffer
usage, but I'm going to remove it to reduce noise — we can rely on the `\post`
comment in the docs and I added the `DCHECK` there instead.
--
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]