Apache Arrow (C++)
A columnar in-memory analytics layer designed to accelerate big data.
Public Member Functions | Static Public Attributes | List of all members
arrow::BitReader Class Reference

Utility class to read bit/byte stream. More...

#include <arrow/util/bit-stream-utils.h>

Public Member Functions

 BitReader (const uint8_t *buffer, int buffer_len)
 'buffer' is the buffer to read from. The buffer's length is 'buffer_len'. More...
 
 BitReader ()
 
void Reset (const uint8_t *buffer, int buffer_len)
 
template<typename T >
bool GetValue (int num_bits, T *v)
 Gets the next value from the buffer. More...
 
template<typename T >
int GetBatch (int num_bits, T *v, int batch_size)
 Get a number of values from the buffer. Return the number of values actually read. More...
 
template<typename T >
bool GetAligned (int num_bytes, T *v)
 Reads a 'num_bytes'-sized value from the buffer and stores it in 'v'. More...
 
bool GetVlqInt (int32_t *v)
 Reads a vlq encoded int from the stream. More...
 
bool GetZigZagVlqInt (int32_t *v)
 
int bytes_left ()
 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). More...
 

Static Public Attributes

static const int MAX_VLQ_BYTE_LEN = 5
 Maximum byte length of a vlq encoded int. More...
 

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).

Constructor & Destructor Documentation

◆ BitReader() [1/2]

arrow::BitReader::BitReader ( const uint8_t *  buffer,
int  buffer_len 
)
inline

'buffer' is the buffer to read from. The buffer's length is 'buffer_len'.

◆ BitReader() [2/2]

arrow::BitReader::BitReader ( )
inline

Member Function Documentation

◆ bytes_left()

int arrow::BitReader::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).

◆ GetAligned()

template<typename T >
bool arrow::BitReader::GetAligned ( int  num_bytes,
T *  v 
)
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.

◆ GetBatch()

template<typename T >
int arrow::BitReader::GetBatch ( int  num_bits,
T *  v,
int  batch_size 
)
inline

Get a number of values from the buffer. Return the number of values actually read.

◆ GetValue()

template<typename T >
bool arrow::BitReader::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. num_bits must be <= 32.

◆ GetVlqInt()

bool arrow::BitReader::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.

◆ GetZigZagVlqInt()

bool arrow::BitReader::GetZigZagVlqInt ( int32_t *  v)
inline

◆ Reset()

void arrow::BitReader::Reset ( const uint8_t *  buffer,
int  buffer_len 
)
inline

Member Data Documentation

◆ MAX_VLQ_BYTE_LEN

const int arrow::BitReader::MAX_VLQ_BYTE_LEN = 5
static

Maximum byte length of a vlq encoded int.


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