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

Function ReplaceMaskArrayImpl

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

Source from the content-addressed store, hash-verified

65// array replacements
66template <typename Type, typename Data, typename CopyBitmap>
67int64_t ReplaceMaskArrayImpl(const ArraySpan& array, const ArraySpan& mask,
68 int64_t mask_offset, const Data& replacements,
69 bool replacements_bitmap, int64_t replacements_offset,
70 const CopyBitmap& copy_bitmap, uint8_t* out_bitmap,
71 uint8_t* out_values, const int64_t out_offset) {
72 const uint8_t* mask_bitmap = mask.buffers[0].data;
73 const uint8_t* mask_values = mask.buffers[1].data;
74 CopyDataUtils<Type>::CopyData(*array.type, array, /*in_offset=*/0, out_values,
75 /*out_offset=*/0, array.length);
76 arrow::internal::OptionalBinaryBitBlockCounter counter(
77 mask_values, mask.offset + mask_offset, mask_bitmap, mask.offset + mask_offset,
78 std::min(mask.length, array.length));
79 int64_t write_offset = 0;
80 while (write_offset < array.length) {
81 BitBlockCount block = counter.NextAndBlock();
82 if (block.AllSet()) {
83 // Copy from replacement array
84 CopyDataUtils<Type>::CopyData(*array.type, replacements, replacements_offset,
85 out_values, out_offset + write_offset, block.length);
86
87 if (replacements_bitmap) {
88 copy_bitmap.CopyBitmap(out_bitmap, out_offset + write_offset, replacements_offset,
89 block.length);
90 } else if (out_bitmap) {
91 bit_util::SetBitsTo(out_bitmap, out_offset + write_offset, block.length, true);
92 }
93 replacements_offset += block.length;
94 } else if (block.popcount) {
95 for (int64_t i = 0; i < block.length; ++i) {
96 if (bit_util::GetBit(mask_values, write_offset + mask.offset + mask_offset + i) &&
97 (!mask_bitmap || bit_util::GetBit(mask_bitmap, write_offset + mask.offset +
98 mask_offset + i))) {
99 CopyDataUtils<Type>::CopyData(*array.type, replacements, replacements_offset,
100 out_values, out_offset + write_offset + i,
101 /*length=*/1);
102 if (replacements_bitmap) {
103 copy_bitmap.SetBit(out_bitmap, out_offset + write_offset + i,
104 replacements_offset);
105 } else if (out_bitmap) {
106 bit_util::SetBitTo(out_bitmap, out_offset + write_offset + i, true);
107 }
108 replacements_offset++;
109 }
110 }
111 }
112 write_offset += block.length;
113 }
114 return replacements_offset;
115}
116
117template <typename Type, typename Enable = void>
118struct ReplaceMaskImpl {};

Callers

nothing calls this directly

Calls 6

SetBitsToFunction · 0.50
GetBitFunction · 0.50
SetBitToFunction · 0.50
AllSetMethod · 0.45
CopyBitmapMethod · 0.45
SetBitMethod · 0.45

Tested by

no test coverage detected