Skip to content

Commit d65eb94

Browse files
authored
MINOR: [C++] Remove TODO asking why null count set unknown (#48823)
### Rationale for this change Removed a TODO from `replace_with_mask` implementation that asking why the replacements null count wasn't sufficient for a slice operation. When slicing an array, the null count from the original full array doesn't apply to the slice. The null count must be marked as `kUnknownNullCount` and computed lazily when needed. ### What changes are included in this PR? Replaced the TODO with some comments clarifying: - Why manual slicing is used (avoids extra allocation from `ArrayData::Slice()`) - Why `kUnknownNullCount` is necessary (original null count doesn't apply to slice) ### Are these changes tested? No, I did not test. ### Are there any user-facing changes? No. Authored-by: Hyukjin Kwon <gurwls223@apache.org> Signed-off-by: David Li <li.davidm96@gmail.com>
1 parent b14c6e0 commit d65eb94

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

cpp/src/arrow/compute/kernels/vector_replace.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,13 @@ struct ReplaceMaskImpl<Type, enable_if_base_binary<Type>> {
252252
MakeArrayFromScalar(*replacements.scalar, array.length, ctx->memory_pool()));
253253
out->value = std::move(replacement_array->data());
254254
} else {
255-
// Set to be a slice of replacements
255+
// Set to be a slice of replacements. We manually adjust offset/length instead of
256+
// calling ArrayData::Slice() to avoid creating an extra copy.
256257
std::shared_ptr<ArrayData> result = replacements.array.ToArrayData();
257258
result->offset += replacements_offset;
258259
result->length = array.length;
259-
260-
// TODO(wesm): why is the replacements null count not sufficient?
260+
// The null count from the original replacements array is not sufficient because
261+
// it applies to the entire array, not this specific slice. Must mark as unknown.
261262
result->null_count = kUnknownNullCount;
262263
out->value = result;
263264
}

0 commit comments

Comments
 (0)