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

Function CheckReplaceMaskInputs

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

Source from the content-addressed store, hash-verified

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