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

Method PutValue

be/src/util/bit-stream-utils.inline.h:28–57  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26namespace impala {
27
28inline bool BitWriter::PutValue(uint64_t v, int num_bits) {
29 DCHECK_LE(num_bits, MAX_BITWIDTH);
30 DCHECK(num_bits == MAX_BITWIDTH || v >> num_bits == 0)
31 << "v = " << v << ", num_bits = " << num_bits;
32
33 if (UNLIKELY(byte_offset_ * 8 + bit_offset_ + num_bits > max_bytes_ * 8)) return false;
34
35 buffered_values_ |= v << bit_offset_;
36 bit_offset_ += num_bits;
37
38 if (UNLIKELY(bit_offset_ >= 64)) {
39 // Flush buffered_values_ and write out bits of v that did not fit
40 memcpy(buffer_ + byte_offset_, &buffered_values_, 8);
41 byte_offset_ += 8;
42 bit_offset_ -= 64;
43
44 // Shifting with the same or greater amount than the number of bits in the number is
45 // undefined behaviour.
46 int shift = num_bits - bit_offset_;
47
48 if (LIKELY(shift < 64)) {
49 buffered_values_ = v >> shift;
50 } else {
51 buffered_values_ = 0;
52 }
53 }
54
55 DCHECK_LT(bit_offset_, 64);
56 return true;
57}
58
59inline void BitWriter::Flush(bool align) {
60 int num_bytes = BitUtil::Ceil(bit_offset_, 8);

Callers 9

WriteMiniblocksMethod · 0.45
ProcessValueMethod · 0.45
EncodeDataFunction · 0.45
TESTFunction · 0.45
TestBitArrayValuesFunction · 0.45
PackUnpackFunction · 0.45
DictEncodeFunction · 0.45
DeltaEncodeFunction · 0.45
FlushLiteralRunMethod · 0.45

Calls

no outgoing calls

Tested by 6

EncodeDataFunction · 0.36
TESTFunction · 0.36
TestBitArrayValuesFunction · 0.36
PackUnpackFunction · 0.36
DictEncodeFunction · 0.36
DeltaEncodeFunction · 0.36