be/src/formats/orc/apache-orc/c++/src/BloomFilter.cc
// caller should make sure input proto::BloomFilter is valid since
// no check will be performed in the following constructor
caller should make sure input proto::BloomFilter is valid since
no check will be performed in the following constructor
caller should make sure input proto :: BloomFilter is valid since no check will be performed in the following constructor
BloomFilterImpl::BloomFilterImpl(const proto::BloomFilter& bloomFilter) {
    mNumHashFunctions = static_cast<int32_t>(bloomFilter.numhashfunctions());
    const std::string& bitsetStr = bloomFilter.utf8bitset();
    mNumBits = bitsetStr.size() << SHIFT_3_BITS;
    checkArgument(mNumBits % BITS_OF_LONG == 0, "numBits should be multiple of 64!");
    const uint64_t* bitset = reinterpret_cast<const uint64_t*>(bitsetStr.data());
    if (isLittleEndian()) {
        mBitSet.reset(new BitSet(bitset, mNumBits));
    } else {
        std::vector<uint64_t> longs(mNumBits >> SHIFT_6_BITS);
        for (size_t i = 0; i != longs.size(); ++i) {
            const uint64_t src = bitset[i];
            uint64_t& dst = longs[i];
            for (size_t bit = 0; bit != 64; bit += 8) {
                dst |= (((src & (0xFFu << bit)) >> bit) << (56 - bit));
            }
        }
        mBitSet.reset(new BitSet(longs.data(), mNumBits));
    }
}
BloomFilterImpl :: BloomFilterImpl ( const proto :: BloomFilter & bloomFilter ) { mNumHashFunctions = static_cast < int32_t > ( bloomFilter . numhashfunctions ( ) ) ; const std :: string & bitsetStr = bloomFilter . utf8bitset ( ) ; mNumBits = bitsetStr . size ( ) << SHIFT_3_BITS ; checkArgument ( mNumBits % BITS_OF_LONG == 0 , " " ) ; const uint64_t * bitset = reinterpret_cast < const uint64_t * > ( bitsetStr . data ( ) ) ; if ( isLittleEndian ( ) ) { mBitSet . reset ( new BitSet ( bitset , mNumBits ) ) ; } else { std :: vector < uint64_t > longs ( mNumBits >> SHIFT_6_BITS ) ; for ( size_t i = 0 ; i != longs . size ( ) ; ++ i ) { const uint64_t src = bitset [ i ] ; uint64_t & dst = longs [ i ] ; for ( size_t bit = 0 ; bit != 64 ; bit += 8 ) { dst |= ( ( ( src & ( 0xFFu << bit ) ) >> bit ) << ( 56 - bit ) ) ; } } mBitSet . reset ( new BitSet ( longs . data ( ) , mNumBits ) ) ; } }
caller should make sure input proto::BloomFilter is valid since
no check will be performed in the following constructor
caller should make sure input proto :: BloomFilter is valid since no check will be performed in the following constructor
// convert little-endian to big-endian