for (int n = 0; n < numNodes; n++) {
batchLists[n] = new ArrayList<BatchElement>();
}
IMessageDigest md = HashFactory.getInstance("RIPEMD-160");
CLBuffer clBuffer = CLBuffer.create();
byte[] buf = new byte[512]; // for holding set and key
int setOffset = 0;
int setLen = CLBuffer.stringToUtf8(set, buf, setOffset);
int keyOffset = setLen + 1;
// Create the digests for all the keys passed in.
Iterator<Object> keysIterator = keys.iterator();
for (int i = 0; keysIterator.hasNext(); i++) {
Object key = keysIterator.next();
int keyLen = clBuffer.keyToBytes(key, buf, keyOffset);
md.reset();
md.update(buf, setOffset, setLen);
md.update(buf, keyOffset, keyLen);
byte[] digest = md.digest();
long partitionId = CLBuffer.get_ntohl_intel(digest, 0);
// Can't use mod directly - mod will give negative numbers. First
// bitwise-and determines positive/negative correctly, then mod.
partitionId = (partitionId & 0xFFFF) %