Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,26 +203,24 @@ private void setHashLoc(int hash1, int hash2) {
* @param pos index of bit
*/
void set(long pos) {
int bytePos = (int) (pos / 8);
int bitPos = (int) (pos % 8);
int bytePos = (int) (pos >> 3);
int bitPos = (int) (pos & 7);
byte curByte = bloom.get(bytePos);
curByte |= BloomFilterUtil.bitvals[bitPos];
curByte |= (1 << bitPos);
bloom.put(bytePos, curByte);
}
}

/**
* Check if bit at specified index is 1.
* @param pos index of bit
* @return true if bit at specified index is 1, false if 0.
*/
static boolean get(int pos, ByteBuffer bloomBuf, int bloomOffset) {
int bytePos = pos >> 3; // pos / 8
int bitPos = pos & 0x7; // pos % 8
// TODO access this via Util API which can do Unsafe access if possible(?)
int bytePos = pos >> 3;
int bitPos = pos & 0x7;
byte curByte = bloomBuf.get(bloomOffset + bytePos);
curByte &= BloomFilterUtil.bitvals[bitPos];
return (curByte != 0);
}
return (curByte & (1 << bitPos)) != 0;
}

@Override
public long getKeyCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ public final class BloomFilterUtil {

public static final String PREFIX_LENGTH_KEY = "RowPrefixBloomFilter.prefix_length";

/** Bit-value lookup array to prevent doing the same work over and over */
public static final byte[] bitvals = { (byte) 0x01, (byte) 0x02, (byte) 0x04, (byte) 0x08,
(byte) 0x10, (byte) 0x20, (byte) 0x40, (byte) 0x80 };

/**
* Private constructor to keep this class from being instantiated.
*/
Expand Down Expand Up @@ -221,8 +217,7 @@ static boolean checkBit(int pos, ByteBuff bloomBuf, int bloomOffset) {
int bytePos = pos >> 3; // pos / 8
int bitPos = pos & 0x7; // pos % 8
byte curByte = bloomBuf.get(bloomOffset + bytePos);
curByte &= bitvals[bitPos];
return (curByte != 0);
return (curByte & (1 << bitPos)) != 0;
}

/**
Expand Down