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

Method PutValue

cpp/src/arrow/util/bit_stream_utils_internal.h:198–225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196};
197
198inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
199 ARROW_DCHECK_LE(num_bits, 64);
200 if (num_bits < 64) {
201 ARROW_DCHECK_EQ(v >> num_bits, 0) << "v = " << v << ", num_bits = " << num_bits;
202 }
203
204 if (ARROW_PREDICT_FALSE(static_cast<int64_t>(byte_offset_) * 8 + bit_offset_ +
205 num_bits >
206 static_cast<int64_t>(max_bytes_) * 8)) {
207 return false;
208 }
209
210 buffered_values_ |= v << bit_offset_;
211 bit_offset_ += num_bits;
212
213 if (ARROW_PREDICT_FALSE(bit_offset_ >= 64)) {
214 // Flush buffered_values_ and write out bits of v that did not fit
215 buffered_values_ = arrow::bit_util::ToLittleEndian(buffered_values_);
216 memcpy(buffer_ + byte_offset_, &buffered_values_, 8);
217 buffered_values_ = 0;
218 byte_offset_ += 8;
219 bit_offset_ -= 64;
220 buffered_values_ =
221 (num_bits - bit_offset_ == 64) ? 0 : (v >> (num_bits - bit_offset_));
222 }
223 ARROW_DCHECK_LT(bit_offset_, 64);
224 return true;
225}
226
227inline void BitWriter::Flush(bool align) {
228 int num_bytes = static_cast<int>(bit_util::BytesForBits(bit_offset_));

Callers 7

TESTFunction · 0.80
TestBitArrayValuesFunction · 0.80
TestPutValueFunction · 0.80
PackValuesFunction · 0.80
FlushLiteralRunMethod · 0.80
FlushBlockMethod · 0.80
EncodeMethod · 0.80

Calls 1

ToLittleEndianFunction · 0.70

Tested by 4

TESTFunction · 0.64
TestBitArrayValuesFunction · 0.64
TestPutValueFunction · 0.64
PackValuesFunction · 0.64