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

Function SpacedExpandRightward

cpp/src/arrow/util/spaced_internal.h:66–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64/// \param[in] valid_bits_offset offset into valid_bits
65template <typename T>
66inline void SpacedExpandRightward(T* buffer, int num_values, int null_count,
67 const uint8_t* valid_bits, int64_t valid_bits_offset) {
68 // Point to end as we add the spacing from the back.
69 int idx_decode = num_values - null_count;
70
71 // Depending on the number of nulls, some of the value slots in buffer may
72 // be uninitialized, and this will cause valgrind warnings / potentially UB
73 memset(static_cast<void*>(buffer + idx_decode), 0, null_count * sizeof(T));
74 if (idx_decode == 0) {
75 // All nulls, nothing more to do
76 return;
77 }
78
79 arrow::internal::ReverseSetBitRunReader reader(valid_bits, valid_bits_offset,
80 num_values);
81 while (true) {
82 const auto run = reader.NextRun();
83 if (run.length == 0) {
84 break;
85 }
86 idx_decode -= static_cast<int32_t>(run.length);
87 assert(idx_decode >= 0);
88 if (idx_decode == run.position) {
89 // We have come to the point where no more expansion is required: the remaining
90 // values are already in their final position.
91 return;
92 }
93 // Source and destination may overlap if run.length > 1
94 memmove(buffer + run.position, buffer + idx_decode, run.length * sizeof(T));
95 }
96
97 // Otherwise caller gave an incorrect null_count
98 assert(idx_decode == 0);
99}
100
101/// \brief Relocate values according to a validity bitmap, to the left
102///

Callers

nothing calls this directly

Calls 1

NextRunMethod · 0.45

Tested by

no test coverage detected