Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
impala::BitReader_8byte Class Reference

#include <bit-stream-utils.8byte.h>

Collaboration diagram for impala::BitReader_8byte:

Public Member Functions

 BitReader_8byte (uint8_t *buffer, int buffer_len)
 
 BitReader_8byte ()
 
template<typename T >
bool GetValue (int num_bits, T *v)
 
template<typename T >
bool GetAligned (int num_bits, 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 Member Functions

void Align ()
 Advances offset_ and/or bit_offset_ to next byte boundary in buffer_. More...
 

Private Attributes

uint64_tbuffer_
 
int max_bytes_
 
int offset_
 
int bit_offset_
 

Detailed Description

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 84 of file bit-stream-utils.8byte.h.

Constructor & Destructor Documentation

impala::BitReader_8byte::BitReader_8byte ( uint8_t *  buffer,
int  buffer_len 
)
inline

buffer: buffer to read from. The buffer's length is 'buffer_len' and must be a multiple of 8.

Definition at line 88 of file bit-stream-utils.8byte.h.

impala::BitReader_8byte::BitReader_8byte ( )
inline

Definition at line 96 of file bit-stream-utils.8byte.h.

Member Function Documentation

void impala::BitReader_8byte::Align ( )
inlineprivate

Advances offset_ and/or bit_offset_ to next byte boundary in buffer_.

Definition at line 130 of file bit-stream-utils.8byte.inline.h.

References bit_offset_, max_bytes_, offset_, impala::BitUtil::RoundUpNumBytes(), and UNLIKELY.

Referenced by GetAligned().

int impala::BitReader_8byte::bytes_left ( )
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 115 of file bit-stream-utils.8byte.h.

References bit_offset_, impala::BitUtil::Ceil(), max_bytes_, and offset_.

Referenced by GetAligned().

template<typename T >
bool impala::BitReader_8byte::GetAligned ( int  num_bits,
T *  v 
)
inline

Reads a T sized value from the buffer. T needs to be a native type and little endian. The value is assumed to be byte aligned so the stream will be advance to the start of the next byte before v is read.

Definition at line 106 of file bit-stream-utils.8byte.inline.h.

References Align(), bit_offset_, bytes_left(), impala::BitUtil::Ceil(), GetValue(), and UNLIKELY.

template<typename T >
bool impala::BitReader_8byte::GetValue ( int  num_bits,
T *  v 
)
inline

Gets the next value from the buffer. Returns true if 'v' could be read or false if there are not enough bytes left.

Definition at line 87 of file bit-stream-utils.8byte.inline.h.

References bit_offset_, buffer_, max_bytes_, offset_, impala::BitUtil::TrailingBits(), and UNLIKELY.

Referenced by GetAligned(), and TestBitWriter8ByteDecode().

bool impala::BitReader_8byte::GetVlqInt ( int32_t *  v)
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 116 of file bit-stream-utils.8byte.inline.h.

References MAX_VLQ_BYTE_LEN.

Member Data Documentation

int impala::BitReader_8byte::bit_offset_
private

Definition at line 126 of file bit-stream-utils.8byte.h.

Referenced by Align(), bytes_left(), GetAligned(), and GetValue().

uint64_t* impala::BitReader_8byte::buffer_
private

Definition at line 123 of file bit-stream-utils.8byte.h.

Referenced by GetValue().

int impala::BitReader_8byte::max_bytes_
private

Definition at line 124 of file bit-stream-utils.8byte.h.

Referenced by Align(), bytes_left(), and GetValue().

const int impala::BitReader_8byte::MAX_VLQ_BYTE_LEN = 5
static

Maximum byte length of a vlq encoded int.

Definition at line 120 of file bit-stream-utils.8byte.h.

Referenced by GetVlqInt().

int impala::BitReader_8byte::offset_
private

Definition at line 125 of file bit-stream-utils.8byte.h.

Referenced by Align(), bytes_left(), and GetValue().


The documentation for this class was generated from the following files: