Impala
Impalaistheopensource,nativeanalyticdatabaseforApacheHadoop.
|
#include <bit-util.h>
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) |
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.
|
inlinestatic |
Swaps the byte order (i.e. endianess)
Definition at line 149 of file bit-util.h.
Referenced by impala::HdfsAvroTableWriter::AppendField(), impala::HBaseTableWriter::AppendRowBatch(), ByteSwap(), impala::DecimalUtil::DecodeFromFixedLenByteArray(), impala::DecimalUtil::EncodeToFixedLenByteArray(), FromBigEndian(), impala::ReadWriteUtil::PutInt(), impala::HdfsAvroScanner::ReadAvroDecimal(), impala::TEST(), ToBigEndian(), and impala::HBaseTableScanner::WriteTupleSlot().
Definition at line 152 of file bit-util.h.
|
inlinestatic |
Definition at line 155 of file bit-util.h.
|
inlinestatic |
Definition at line 158 of file bit-util.h.
|
inlinestatic |
Definition at line 161 of file bit-util.h.
|
inlinestatic |
Definition at line 164 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Write the swapped bytes into dst. Src and st cannot overlap.
Definition at line 169 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Returns the ceil of value/divisor.
Definition at line 32 of file bit-util.h.
Referenced by impala::DescriptorTblBuilder::Build(), impala::BitReader_8byte::bytes_left(), impala::BitReader::bytes_left(), impala::BitWriter::bytes_written(), impala::BitWriter_8byte::bytes_written(), impala::BufferedBlockMgr::ConsumeMemory(), impala::DiskIoMgr::DiskIoMgr(), impala::BitWriter::Flush(), impala::RleEncoder::FlushRepeatedRun(), impala::DiskIoMgr::free_buffers_idx(), impala::RleDecoder::Get(), impala::BitReader_8byte::GetAligned(), impala::BitReader::GetAligned(), impala::RleEncoder::MaxBufferSize(), impala::RleEncoder::MinBufferSize(), impala::HdfsParquetScanner::BaseColumnReader::ReadDataPage(), impala::DiskIoMgr::ReturnFreeBuffer(), impala::TEST(), impala::TestBitArrayValues(), TestBitWriter8ByteEncode(), and TestBitWriterEncode().
|
inlinestatic |
Converts from big endian format to the machine's native endian format.
Definition at line 216 of file bit-util.h.
References ByteSwap().
Definition at line 217 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 218 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 219 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 220 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 221 of file bit-util.h.
References ByteSwap().
|
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().
|
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().
|
inlinestatic |
Returns the number of set bits in x.
Definition at line 116 of file bit-util.h.
References impala::CpuInfo::IsSupported(), LIKELY, impala::CpuInfo::POPCNT, impala::POPCNT_popcnt_u64(), and PopcountNoHw().
Referenced by impala::HdfsScanNode::StopAndFinalizeCounters(), and impala::TEST().
|
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().
|
inlinestatic |
Returns 'value' rounded down to the nearest multiple of 'factor'.
Definition at line 42 of file bit-util.h.
Referenced by TruncQuarter().
|
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().
|
inlinestatic |
Returns the rounded up 32 multiple.
Definition at line 92 of file bit-util.h.
Referenced by impala::TEST().
|
inlinestatic |
Returns the rounded down to 64 multiple.
Definition at line 102 of file bit-util.h.
Referenced by impala::TEST().
|
inlinestatic |
Definition at line 69 of file bit-util.h.
Referenced by impala::TEST().
|
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().
|
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().
|
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().
|
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().
|
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().
|
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().
Definition at line 200 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 201 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 202 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 203 of file bit-util.h.
References ByteSwap().
|
inlinestatic |
Definition at line 204 of file bit-util.h.
References ByteSwap().
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().