15 #ifndef IMPALA_RLE_ENCODING_H
16 #define IMPALA_RLE_ENCODING_H
81 RleDecoder(uint8_t* buffer,
int buffer_len,
int bit_width)
134 int max_literal_run_size = 1 +
138 return std::max(max_literal_run_size, max_repeated_run_size);
144 int num_runs =
BitUtil::Ceil(num_values, MAX_VALUES_PER_LITERAL_RUN);
145 int literal_max_size = num_runs + num_runs * bytes_per_run;
233 int32_t indicator_value = 0;
235 if (!result)
return false;
238 bool is_literal = indicator_value & 1;
305 DCHECK(success) <<
"There is a bug in using CheckBufferFull()";
307 num_buffered_values_ = 0;
309 if (update_indicator_byte) {
316 int32_t indicator_value = (num_groups << 1) | 1;
317 DCHECK_EQ(indicator_value & 0xFFFFFF00, 0);
359 if (num_groups + 1 >= (1 << 6)) {
bool GetAligned(int num_bytes, T *v)
bool PutValue(uint64_t v, int num_bits)
int num_buffered_values_
Number of values in buffered_values_.
static const int MAX_VALUES_PER_LITERAL_RUN
BitWriter bit_writer_
Underlying buffer.
const int bit_width_
Number of bits needed to encode the value.
int bytes_written() const
uint8_t * buffer()
Returns pointer to underlying buffer.
RleEncoder(uint8_t *buffer, int buffer_len, int bit_width)
void FlushBufferedValues(bool done)
void FlushLiteralRun(bool update_indicator_byte)
uint8_t * GetNextBytePtr(int num_bytes=1)
bool PutAligned(T v, int num_bytes)
bool GetVlqInt(int32_t *v)
void Flush(bool align=false)
static int Ceil(int value, int divisor)
Returns the ceil of value/divisor.
bool PutVlqInt(int32_t v)
int max_run_byte_size_
The maximum byte size a single run can take.
bool buffer_full_
If true, the buffer is full and subsequent Put()'s will fail.
static int MinBufferSize(int bit_width)
RleDecoder(uint8_t *buffer, int buffer_len, int bit_width)
void FlushRepeatedRun()
Flushes a repeated run to the underlying buffer.
bool Get(T *val)
Gets the next value. Returns false if there are no more.
static int MaxBufferSize(int bit_width, int num_values)
Returns the maximum byte size it could take to encode 'num_values'.
void Clear()
Resets all the state in the encoder.
static const int MAX_VLQ_BYTE_LEN
Maximum byte length of a vlq encoded int.
Decoder class for RLE encoded data.
uint8_t * literal_indicator_byte_
bool GetValue(int num_bits, T *v)
int64_t buffered_values_[8]