Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <bit-stream-utils.h>
Public Member Functions | |
BitReader (uint8_t *buffer, int buffer_len) | |
'buffer' is the buffer to read from. The buffer's length is 'buffer_len'. More... | |
BitReader () | |
template<typename T > | |
bool | GetValue (int num_bits, T *v) |
template<typename T > | |
bool | GetAligned (int num_bytes, T *v) |
bool | GetVlqInt (int32_t *v) |
int | bytes_left () |
Static Public Attributes | |
static const int | MAX_VLQ_BYTE_LEN = 5 |
Maximum byte length of a vlq encoded int. More... | |
Private Attributes | |
uint8_t * | buffer_ |
int | max_bytes_ |
uint64_t | buffered_values_ |
int | byte_offset_ |
int | bit_offset_ |
Utility class to read bit/byte stream. This class can read bits or bytes that are either byte aligned or not. It also has utilities to read multiple bytes in one read (e.g. encoded int).
Definition at line 92 of file bit-stream-utils.h.
|
inline |
'buffer' is the buffer to read from. The buffer's length is 'buffer_len'.
Definition at line 95 of file bit-stream-utils.h.
References buffer_, buffered_values_, byte_offset_, and max_bytes_.
|
inline |
Definition at line 104 of file bit-stream-utils.h.
|
inline |
Returns the number of bytes left in the stream, not including the current byte (i.e., there may be an additional fraction of a byte).
Definition at line 124 of file bit-stream-utils.h.
References bit_offset_, byte_offset_, impala::BitUtil::Ceil(), and max_bytes_.
|
inline |
Reads a 'num_bytes'-sized value from the buffer and stores it in 'v'. T needs to be a little-endian native type and big enough to store 'num_bytes'. The value is assumed to be byte-aligned so the stream will be advanced to the start of the next byte before 'v' is read. Returns false if there are not enough bytes left.
Definition at line 115 of file bit-stream-utils.inline.h.
References bit_offset_, buffer_, buffered_values_, byte_offset_, impala::BitUtil::Ceil(), LIKELY, max_bytes_, and UNLIKELY.
Referenced by impala::RleDecoder::Get().
|
inline |
Gets the next value from the buffer. Returns true if 'v' could be read or false if there are not enough bytes left. num_bits must be <= 32.
Definition at line 85 of file bit-stream-utils.inline.h.
References bit_offset_, buffer_, buffered_values_, byte_offset_, LIKELY, max_bytes_, impala::BitUtil::TrailingBits(), and UNLIKELY.
Referenced by impala::RleDecoder::Get(), impala::HdfsParquetScanner::BoolColumnReader::ReadSlot(), impala::TEST(), and TestBitWriterDecode().
|
inline |
Reads a vlq encoded int from the stream. The encoded int must start at the beginning of a byte. Return false if there were not enough bytes in the buffer.
Definition at line 136 of file bit-stream-utils.inline.h.
References MAX_VLQ_BYTE_LEN.
Referenced by impala::RleDecoder::Get().
|
private |
Definition at line 138 of file bit-stream-utils.h.
Referenced by bytes_left(), GetAligned(), and GetValue().
|
private |
Definition at line 130 of file bit-stream-utils.h.
Referenced by BitReader(), GetAligned(), and GetValue().
|
private |
Bytes are memcpy'd from buffer_ and values are read from this variable. This is faster than reading values byte by byte directly from buffer_.
Definition at line 135 of file bit-stream-utils.h.
Referenced by BitReader(), GetAligned(), and GetValue().
|
private |
Definition at line 137 of file bit-stream-utils.h.
Referenced by BitReader(), bytes_left(), GetAligned(), and GetValue().
|
private |
Definition at line 131 of file bit-stream-utils.h.
Referenced by BitReader(), bytes_left(), GetAligned(), and GetValue().
|
static |
Maximum byte length of a vlq encoded int.
Definition at line 127 of file bit-stream-utils.h.
Referenced by GetVlqInt(), and impala::RleEncoder::MinBufferSize().