16 #ifndef IMPALA_EXPERIMENTS_BIT_STREAM_UTILS_8BYTE_INLINE_H
17 #define IMPALA_EXPERIMENTS_BIT_STREAM_UTILS_8BYTE_INLINE_H
24 DCHECK_LE(num_bits, 64);
25 DCHECK(num_bits == 64 || v >> num_bits == 0)
26 <<
"v = " << v <<
", num_bits = " << num_bits;
31 bit_offset_ += num_bits;
32 if (bit_offset_ >= 64) {
41 DCHECK_LT(bit_offset_, 64);
68 bool result =
PutValue(val, num_bits);
69 if (!result)
return false;
72 DCHECK(byte_ptr != NULL);
78 while ((v & 0xFFFFFF80) != 0L) {
79 result &= PutAligned<uint8_t>((v & 0x7F) | 0x80, 8);
82 result &= PutAligned<uint8_t>(v & 0x7F, 8);
88 int size =
sizeof(T) * 8;
89 DCHECK_LE(num_bits, size);
110 bool result =
GetValue(num_bits, v);
122 if (!GetAligned<uint8_t>(8, &byte))
return false;
123 *v |= (byte & 0x7F) << shift;
126 }
while ((byte & 0x80) != 0);
bool PutVlqInt(int32_t v)
void Align()
Advances offset_ and/or bit_offset_ to next byte boundary in buffer_.
bool GetValue(int num_bits, T *v)
static uint64_t TrailingBits(uint64_t v, int num_bits)
Returns the 'num_bits' least-significant bits of 'v'.
static uint32_t RoundUpNumBytes(uint32_t bits)
static int Ceil(int value, int divisor)
Returns the ceil of value/divisor.
static const int MAX_VLQ_BYTE_LEN
Maximum byte length of a vlq encoded int.
int bytes_written() const
bool GetAligned(int num_bits, T *v)
bool GetVlqInt(int32_t *v)
uint8_t * GetNextBytePtr(int num_bytes=1)
bool PutAligned(T v, int num_bits)
Writes v to the next aligned byte.
bool PutValue(uint64_t v, int num_bits)