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

Function ReplaceMaskArrayImpl

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

Source from the content-addressed store, hash-verified

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