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

Function LoadWord

cpp/src/arrow/util/bit_run_reader.h:143–165  ·  view source on GitHub ↗

Helper method for Loading the next word.

Source from the content-addressed store, hash-verified

141
142 // Helper method for Loading the next word.
143 void LoadWord(int64_t bits_remaining) {
144 word_ = 0;
145 // we need at least an extra byte in this case.
146 if (ARROW_PREDICT_TRUE(bits_remaining >= 64)) {
147 std::memcpy(&word_, bitmap_, 8);
148 } else {
149 int64_t bytes_to_load = bit_util::BytesForBits(bits_remaining);
150 auto word_ptr = reinterpret_cast<uint8_t*>(&word_);
151 std::memcpy(word_ptr, bitmap_, bytes_to_load);
152 // Ensure stoppage at last bit in bitmap by reversing the next higher
153 // order bit.
154 bit_util::SetBitTo(word_ptr, bits_remaining,
155 !bit_util::GetBit(word_ptr, bits_remaining - 1));
156 }
157
158 // Two cases:
159 // 1. For unset, std::countr_zero works naturally so we don't
160 // invert the word.
161 // 2. Otherwise invert so we can use std::countr_zero.
162 if (current_run_bit_set_) {
163 word_ = ~word_;
164 }
165 }
166 const uint8_t* bitmap_;
167 int64_t position_;
168 int64_t length_;

Callers 2

BitRunReaderMethod · 0.70
LoadNextWordFunction · 0.70

Calls 3

BytesForBitsFunction · 0.85
SetBitToFunction · 0.70
GetBitFunction · 0.70

Tested by

no test coverage detected