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

#include <bit-util.h>

Collaboration diagram for impala::BitUtil:

Static Public Member Functions

static int Ceil (int value, int divisor)
 Returns the ceil of value/divisor. More...
 
static int RoundUp (int value, int factor)
 Returns 'value' rounded up to the nearest multiple of 'factor'. More...
 
static int RoundDown (int value, int factor)
 Returns 'value' rounded down to the nearest multiple of 'factor'. More...
 
static int64_t NextPowerOfTwo (int64_t v)
 
static int RoundUpToPowerOf2 (int value, int factor)
 
static int RoundDownToPowerOf2 (int value, int factor)
 
static uint32_t RoundUpNumBytes (uint32_t bits)
 
static uint32_t RoundDownNumBytes (uint32_t bits)
 Returns the rounded down number of bytes that fit the number of bits. More...
 
static uint32_t RoundUpNumi32 (uint32_t bits)
 Returns the rounded up to 32 multiple. Used for conversions of bits to i32. More...
 
static uint32_t RoundDownNumi32 (uint32_t bits)
 Returns the rounded up 32 multiple. More...
 
static uint32_t RoundUpNumi64 (uint32_t bits)
 Returns the rounded up to 64 multiple. Used for conversions of bits to i64. More...
 
static uint32_t RoundDownNumi64 (uint32_t bits)
 Returns the rounded down to 64 multiple. More...
 
static int PopcountNoHw (uint64_t x)
 
static int Popcount (uint64_t x)
 Returns the number of set bits in x. More...
 
static uint64_t TrailingBits (uint64_t v, int num_bits)
 Returns the 'num_bits' least-significant bits of 'v'. More...
 
static int Log2 (uint64_t x)
 
static int64_t ByteSwap (int64_t value)
 Swaps the byte order (i.e. endianess) More...
 
static uint64_t ByteSwap (uint64_t value)
 
static int32_t ByteSwap (int32_t value)
 
static uint32_t ByteSwap (uint32_t value)
 
static int16_t ByteSwap (int16_t value)
 
static uint16_t ByteSwap (uint16_t value)
 
static void ByteSwap (void *dst, const void *src, int len)
 Write the swapped bytes into dst. Src and st cannot overlap. More...
 
static int64_t ToBigEndian (int64_t value)
 
static uint64_t ToBigEndian (uint64_t value)
 
static int32_t ToBigEndian (int32_t value)
 
static uint32_t ToBigEndian (uint32_t value)
 
static int16_t ToBigEndian (int16_t value)
 
static uint16_t ToBigEndian (uint16_t value)
 
static int64_t FromBigEndian (int64_t value)
 Converts from big endian format to the machine's native endian format. More...
 
static uint64_t FromBigEndian (uint64_t value)
 
static int32_t FromBigEndian (int32_t value)
 
static uint32_t FromBigEndian (uint32_t value)
 
static int16_t FromBigEndian (int16_t value)
 
static uint16_t FromBigEndian (uint16_t value)
 

Detailed Description

Utility class to do standard bit tricks TODO: is this in boost or something else like that?

Definition at line 29 of file bit-util.h.

Member Function Documentation

static uint64_t impala::BitUtil::ByteSwap ( uint64_t  value)
inlinestatic

Definition at line 152 of file bit-util.h.

static int32_t impala::BitUtil::ByteSwap ( int32_t  value)
inlinestatic

Definition at line 155 of file bit-util.h.

static uint32_t impala::BitUtil::ByteSwap ( uint32_t  value)
inlinestatic

Definition at line 158 of file bit-util.h.

static int16_t impala::BitUtil::ByteSwap ( int16_t  value)
inlinestatic

Definition at line 161 of file bit-util.h.

static uint16_t impala::BitUtil::ByteSwap ( uint16_t  value)
inlinestatic

Definition at line 164 of file bit-util.h.

References ByteSwap().

static void impala::BitUtil::ByteSwap ( void *  dst,
const void *  src,
int  len 
)
inlinestatic

Write the swapped bytes into dst. Src and st cannot overlap.

Definition at line 169 of file bit-util.h.

References ByteSwap().

static int64_t impala::BitUtil::FromBigEndian ( int64_t  value)
inlinestatic

Converts from big endian format to the machine's native endian format.

Definition at line 216 of file bit-util.h.

References ByteSwap().

static uint64_t impala::BitUtil::FromBigEndian ( uint64_t  value)
inlinestatic

Definition at line 217 of file bit-util.h.

References ByteSwap().

static int32_t impala::BitUtil::FromBigEndian ( int32_t  value)
inlinestatic

Definition at line 218 of file bit-util.h.

References ByteSwap().

static uint32_t impala::BitUtil::FromBigEndian ( uint32_t  value)
inlinestatic

Definition at line 219 of file bit-util.h.

References ByteSwap().

static int16_t impala::BitUtil::FromBigEndian ( int16_t  value)
inlinestatic

Definition at line 220 of file bit-util.h.

References ByteSwap().

static uint16_t impala::BitUtil::FromBigEndian ( uint16_t  value)
inlinestatic

Definition at line 221 of file bit-util.h.

References ByteSwap().

static int impala::BitUtil::Log2 ( uint64_t  x)
inlinestatic

Returns ceil(log2(x)). TODO: this could be faster if we use __builtin_clz. Fix this if this ever shows up in a hot path.

Definition at line 135 of file bit-util.h.

Referenced by impala::FreePool::Allocate(), impala::DictEncoderBase::bit_width(), impala::DiskIoMgr::DiskIoMgr(), impala::DiskIoMgr::free_buffers_idx(), impala::HdfsParquetScanner::BaseColumnReader::ReadDataPage(), and impala::TEST().

static int64_t impala::BitUtil::NextPowerOfTwo ( int64_t  v)
inlinestatic

Returns the smallest power of two that contains v. Taken from http://graphics.stanford.edu/~seander/bithacks.html#RoundUpPowerOf2 TODO: Pick a better name, as it is not clear what happens when the input is already a power of two.

Definition at line 50 of file bit-util.h.

Referenced by impala::HashTable::EstimateNumBuckets(), impala::PartitionedAggregationNode::GetNext(), and impala::HashTableTest::ScanTest().

static int impala::BitUtil::Popcount ( uint64_t  x)
inlinestatic
static int impala::BitUtil::PopcountNoHw ( uint64_t  x)
inlinestatic

Non hw accelerated pop count. TODO: we don't use this in any perf sensitive code paths currently. There might be a much faster way to implement this.

Definition at line 109 of file bit-util.h.

References count.

Referenced by Popcount(), and impala::TEST().

static int impala::BitUtil::RoundDown ( int  value,
int  factor 
)
inlinestatic

Returns 'value' rounded down to the nearest multiple of 'factor'.

Definition at line 42 of file bit-util.h.

Referenced by TruncQuarter().

static uint32_t impala::BitUtil::RoundDownNumBytes ( uint32_t  bits)
inlinestatic

Returns the rounded down number of bytes that fit the number of bits.

Definition at line 82 of file bit-util.h.

Referenced by impala::TEST().

static uint32_t impala::BitUtil::RoundDownNumi32 ( uint32_t  bits)
inlinestatic

Returns the rounded up 32 multiple.

Definition at line 92 of file bit-util.h.

Referenced by impala::TEST().

static uint32_t impala::BitUtil::RoundDownNumi64 ( uint32_t  bits)
inlinestatic

Returns the rounded down to 64 multiple.

Definition at line 102 of file bit-util.h.

Referenced by impala::TEST().

static int impala::BitUtil::RoundDownToPowerOf2 ( int  value,
int  factor 
)
inlinestatic

Definition at line 69 of file bit-util.h.

Referenced by impala::TEST().

static int impala::BitUtil::RoundUp ( int  value,
int  factor 
)
inlinestatic

Returns 'value' rounded up to the nearest multiple of 'factor'.

Definition at line 37 of file bit-util.h.

Referenced by impala::Bitmap::DebugString(), and impala::HdfsParquetTableWriter::default_block_size().

static uint32_t impala::BitUtil::RoundUpNumBytes ( uint32_t  bits)
inlinestatic

Specialized round up and down functions for frequently used factors, like 8 (bits->bytes), 32 (bits->i32), and 64 (bits->i64). Returns the rounded up number of bytes that fit the number of bits.

Definition at line 77 of file bit-util.h.

Referenced by impala::BitReader_8byte::Align(), impala::BitWriter_8byte::GetNextBytePtr(), impala::HiveUdfCall::Prepare(), and impala::TEST().

static uint32_t impala::BitUtil::RoundUpNumi32 ( uint32_t  bits)
inlinestatic

Returns the rounded up to 32 multiple. Used for conversions of bits to i32.

Definition at line 87 of file bit-util.h.

Referenced by impala::TEST().

static uint32_t impala::BitUtil::RoundUpNumi64 ( uint32_t  bits)
inlinestatic

Returns the rounded up to 64 multiple. Used for conversions of bits to i64.

Definition at line 97 of file bit-util.h.

Referenced by impala::Bitmap::Bitmap(), impala::BufferedTupleStream::ComputeNumNullIndicatorBytes(), and impala::TEST().

static int impala::BitUtil::RoundUpToPowerOf2 ( int  value,
int  factor 
)
inlinestatic

Returns 'value' rounded up to the nearest multiple of 'factor' when factor is a power of two

Definition at line 64 of file bit-util.h.

Referenced by impala::TEST().

static int64_t impala::BitUtil::ToBigEndian ( int64_t  value)
inlinestatic

Converts to big endian format (if not already in big endian) from the machine's native endian format.

Definition at line 199 of file bit-util.h.

References ByteSwap().

Referenced by impala::KeyNormalizer::StoreFinalValue().

static uint64_t impala::BitUtil::ToBigEndian ( uint64_t  value)
inlinestatic

Definition at line 200 of file bit-util.h.

References ByteSwap().

static int32_t impala::BitUtil::ToBigEndian ( int32_t  value)
inlinestatic

Definition at line 201 of file bit-util.h.

References ByteSwap().

static uint32_t impala::BitUtil::ToBigEndian ( uint32_t  value)
inlinestatic

Definition at line 202 of file bit-util.h.

References ByteSwap().

static int16_t impala::BitUtil::ToBigEndian ( int16_t  value)
inlinestatic

Definition at line 203 of file bit-util.h.

References ByteSwap().

static uint16_t impala::BitUtil::ToBigEndian ( uint16_t  value)
inlinestatic

Definition at line 204 of file bit-util.h.

References ByteSwap().

static uint64_t impala::BitUtil::TrailingBits ( uint64_t  v,
int  num_bits 
)
inlinestatic

Returns the 'num_bits' least-significant bits of 'v'.

Definition at line 125 of file bit-util.h.

References UNLIKELY.

Referenced by impala::BitReader_8byte::GetValue(), impala::BitReader::GetValue(), and impala::TEST().


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