Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <bit-stream-utils.h>
Public Member Functions | |
BitWriter (uint8_t *buffer, int buffer_len) | |
void | Clear () |
int | bytes_written () const |
uint8_t * | buffer () const |
int | buffer_len () const |
bool | PutValue (uint64_t v, int num_bits) |
template<typename T > | |
bool | PutAligned (T v, int num_bytes) |
bool | PutVlqInt (int32_t v) |
uint8_t * | GetNextBytePtr (int num_bytes=1) |
void | Flush (bool align=false) |
Private Attributes | |
uint8_t * | buffer_ |
int | max_bytes_ |
uint64_t | buffered_values_ |
int | byte_offset_ |
int | bit_offset_ |
Utility class to write bit/byte streams. This class can write data to either be bit packed or byte aligned (and a single stream that has a mix of both). This class does not allocate memory.
Definition at line 30 of file bit-stream-utils.h.
|
inline |
buffer: buffer to write bits to. Buffer should be preallocated with 'buffer_len' bytes.
Definition at line 34 of file bit-stream-utils.h.
References Clear().
|
inline |
Definition at line 49 of file bit-stream-utils.h.
References buffer_.
Referenced by impala::RleEncoder::buffer().
|
inline |
Definition at line 50 of file bit-stream-utils.h.
References max_bytes_.
Referenced by impala::RleEncoder::CheckBufferFull().
|
inline |
The number of current bytes written, including the current byte (i.e. may include a fraction of a byte). Includes buffered values.
Definition at line 48 of file bit-stream-utils.h.
References bit_offset_, byte_offset_, and impala::BitUtil::Ceil().
Referenced by impala::RleEncoder::CheckBufferFull(), impala::RleEncoder::Flush(), impala::RleEncoder::len(), and impala::TestBitArrayValues().
|
inline |
Definition at line 40 of file bit-stream-utils.h.
References bit_offset_, buffered_values_, and byte_offset_.
Referenced by BitWriter(), and impala::RleEncoder::Clear().
|
inline |
Flushes all buffered values to the buffer. Call this when done writing to the buffer. If 'align' is true, buffered_values_ is reset and any future writes will be written to the next byte boundary.
Definition at line 45 of file bit-stream-utils.inline.h.
References bit_offset_, buffer_, buffered_values_, byte_offset_, impala::BitUtil::Ceil(), and max_bytes_.
Referenced by impala::RleEncoder::Flush(), GetNextBytePtr(), impala::TEST(), impala::TestBitArrayValues(), and TestBitWriterEncode().
|
inline |
Get a pointer to the next aligned byte and advance the underlying buffer by num_bytes. Returns NULL if there was not enough space.
Definition at line 57 of file bit-stream-utils.inline.h.
References buffer_, byte_offset_, Flush(), and max_bytes_.
Referenced by impala::RleEncoder::FlushLiteralRun(), and PutAligned().
|
inline |
Writes v to the next aligned byte using num_bytes. If T is larger than num_bytes, the extra high-order bytes will be ignored. Returns false if there was not enough space.
Definition at line 67 of file bit-stream-utils.inline.h.
References GetNextBytePtr().
Referenced by impala::RleEncoder::FlushRepeatedRun().
Writes a value to buffered_values_, flushing to buffer_ if necessary. This is bit packed. Returns false if there was not enough space. num_bits must be <= 32.
Definition at line 23 of file bit-stream-utils.inline.h.
References bit_offset_, buffer_, buffered_values_, byte_offset_, max_bytes_, and UNLIKELY.
Referenced by impala::RleEncoder::FlushLiteralRun(), impala::TEST(), impala::TestBitArrayValues(), and TestBitWriterEncode().
|
inline |
Write a Vlq encoded int to the buffer. Returns false if there was not enough room. The value is written byte aligned. For more details on vlq: en.wikipedia.org/wiki/Variable-length_quantity
Definition at line 74 of file bit-stream-utils.inline.h.
Referenced by impala::RleEncoder::FlushRepeatedRun().
|
private |
Definition at line 86 of file bit-stream-utils.h.
Referenced by bytes_written(), Clear(), Flush(), and PutValue().
|
private |
Definition at line 78 of file bit-stream-utils.h.
Referenced by buffer(), Flush(), GetNextBytePtr(), and PutValue().
|
private |
Bit-packed values are initially written to this variable before being memcpy'd to buffer_. This is faster than writing values byte by byte directly to buffer_.
Definition at line 83 of file bit-stream-utils.h.
Referenced by Clear(), Flush(), and PutValue().
|
private |
Definition at line 85 of file bit-stream-utils.h.
Referenced by bytes_written(), Clear(), Flush(), GetNextBytePtr(), and PutValue().
|
private |
Definition at line 79 of file bit-stream-utils.h.
Referenced by buffer_len(), Flush(), GetNextBytePtr(), and PutValue().