diff --git a/velox/common/base/BitSet.h b/velox/common/base/BitSet.h index bcdb6e0a38ba..21653a818408 100644 --- a/velox/common/base/BitSet.h +++ b/velox/common/base/BitSet.h @@ -46,8 +46,8 @@ class BitSet { bits::setBit(bits_.data(), bit, true); } - bool contains(uint32_t index) const { - uint64_t bit = index - min_; + bool contains(int64_t index) const { + auto bit = index - min_; if (bit >= bits_.size() * 64) { // If index was < min_, bit will have wrapped around and will be > // size * 64. diff --git a/velox/common/base/BitUtil.h b/velox/common/base/BitUtil.h index 3ef7856ed554..b8c4f594b0a2 100644 --- a/velox/common/base/BitUtil.h +++ b/velox/common/base/BitUtil.h @@ -49,7 +49,7 @@ namespace velox { namespace bits { template -inline bool isBitSet(const T* bits, int32_t idx) { +inline bool isBitSet(const T* bits, uint64_t idx) { return bits[idx / (sizeof(bits[0]) * 8)] & (static_cast(1) << (idx & ((sizeof(bits[0]) * 8) - 1))); } @@ -76,19 +76,19 @@ static constexpr uint8_t kZeroBitmasks[] = { }; template -inline void setBit(T* bits, uint32_t idx) { +inline void setBit(T* bits, uint64_t idx) { auto bitsAs8Bit = reinterpret_cast(bits); bitsAs8Bit[idx / 8] |= (1 << (idx % 8)); } template -inline void clearBit(T* bits, uint32_t idx) { +inline void clearBit(T* bits, uint64_t idx) { auto bitsAs8Bit = reinterpret_cast(bits); bitsAs8Bit[idx / 8] &= kZeroBitmasks[idx % 8]; } template -inline void setBit(T* bits, uint32_t idx, bool value) { +inline void setBit(T* bits, uint64_t idx, bool value) { value ? setBit(bits, idx) : clearBit(bits, idx); } @@ -124,11 +124,11 @@ constexpr inline uint64_t highMask(int32_t bits) { return lowMask(bits) << (64 - bits); } -constexpr inline uint64_t nbytes(int32_t bits) { +constexpr inline uint64_t nbytes(uint64_t bits) { return roundUp(bits, 8) / 8; } -constexpr inline uint64_t nwords(int32_t bits) { +constexpr inline uint64_t nwords(uint64_t bits) { return roundUp(bits, 64) / 64; }