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

Function LoadWord

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

Helper method for Loading the next word.

Source from the content-addressed store, hash-verified

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