MCPcopy Create free account
hub / github.com/apache/arrow / CheckReplaceMaskInputs

Function CheckReplaceMaskInputs

cpp/src/arrow/compute/kernels/vector_replace.cc:325–356  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323};
324
325Status CheckReplaceMaskInputs(const DataType& value_type, int64_t arr_length,
326 const ExecValue& mask_box,
327 const DataType& replacements_type,
328 int64_t replacements_length, bool replacements_is_array) {
329 // Needed for FixedSizeBinary/parameterized types
330 if (!value_type.Equals(replacements_type, /*check_metadata=*/false)) {
331 return Status::Invalid("Replacements must be of same type (expected ",
332 value_type.ToString(), " but got ",
333 replacements_type.ToString(), ")");
334 }
335
336 int64_t mask_count = 0;
337 if (mask_box.is_scalar()) {
338 const auto& mask = mask_box.scalar_as<BooleanScalar>();
339 mask_count = (mask.is_valid && mask.value) ? arr_length : 0;
340 } else {
341 const ArraySpan& mask = mask_box.array;
342 mask_count = GetTrueCount(mask);
343 if (mask.length != arr_length) {
344 return Status::Invalid("Mask must be of same length as array (expected ",
345 arr_length, " items but got ", mask.length, " items)");
346 }
347 }
348 if (replacements_is_array) {
349 if (replacements_length < mask_count) {
350 return Status::Invalid("Replacement array must be of appropriate length (expected ",
351 mask_count, " items but got ", replacements_length,
352 " items)");
353 }
354 }
355 return Status::OK();
356}
357
358template <typename Type>
359struct ReplaceMask {

Callers 2

ExecMethod · 0.85
ExecMethod · 0.85

Calls 6

GetTrueCountFunction · 0.85
is_scalarMethod · 0.80
InvalidFunction · 0.50
OKFunction · 0.50
EqualsMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected