/** * Returns the bucket of the row for the given hash bucket schema. All columns * in the hash bucket schema must be set in the row. * * @param row the row containing hash schema columns * @param hashSchema the hash schema * @return the hash bucket of the row */ public static int getHashBucket(PartialRow row, HashBucketSchema hashSchema) { ByteVec buf = ByteVec.create(); encodeColumns(row, hashSchema.getColumnIds(), buf); long hash = Murmur2.hash64(buf.data(), buf.len(), hashSchema.getSeed()); return (int) UnsignedLongs.remainder(hash, hashSchema.getNumBuckets()); }
private void checkByteVec(List<Byte> vals) { ByteVec vec = ByteVec.create(); assertEquals(0, vec.len()); copy.truncate(vec.len() + 1); assertEquals(vals, copy.asList()); vec.truncate(copy.len()); assertEquals(vals, copy.asList()); copy.truncate(vals.size() / 2); int unused = copy.capacity() - copy.len(); unused = copy.capacity() - copy.len(); copy.reserveExact(unused + 3); assertEquals(copy.capacity() - copy.len(), unused + 3); assertEquals(0, copy.len()); assertEquals(0, copy.capacity()); vec.shrinkToFit(); assertEquals(vec.len(), vec.capacity()); if (vec.len() > 0) { copy = vec.clone(); int index = RAND.nextInt(vec.len()); copy.set(index, (byte) index); List<Byte> intsCopy = new ArrayList<>(vals);