/** * Perform xxHash64 hashing on a string. * * @param str - The string to be hashed. * @return String - The hex representation of the hash value. */ private static String performXxHash64(String str) { return Long.toHexString(LongHashFunction.xx_r39().hashChars(str)); } }
private long getHash(String text) { return LongHashFunction.xx_r39().hash(text, LOWER_CASE_ACCESS_INSTANCE, 0, text.length()); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; final Iterator<Entry<byte[], byte[]>> iterator = r.map.entryIterator(); while (iterator.hasNext()) { final Entry<byte[], byte[]> entry = iterator.next(); result += xx_r39().hashBytes(entry.getKey()); result += xx_r39().hashBytes(entry.getValue()); } bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; final Iterator<byte[]> iter = r.map.keyIterator(null); while (iter.hasNext()) { final byte[] k = iter.next(); final byte[] v = r.map.get(k); result += xx_r39().hashBytes(k); result += xx_r39().hashBytes(v); } bh.consume(result); }
for (int i = 0; i < _numProbes; i++) _hashFunctions[i] = LongHashFunction.xx_r39(i);
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) throws IOException { long result = 0; try (DBIterator iterator = r.db.iterator()) { for (iterator.seekToFirst(); iterator.hasNext(); iterator.next()) { final Entry<byte[], byte[]> peeked = iterator.peekNext(); result += xx_r39().hashBytes(peeked.getKey()); result += xx_r39().hashBytes(peeked.getValue()); } } bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; final RocksIterator iterator = r.db.newIterator(); iterator.seekToFirst(); while (iterator.isValid()) { result += xx_r39().hashBytes(iterator.key()); result += xx_r39().hashBytes(iterator.value()); iterator.next(); } bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; try (Cursor c = r.store.openCursor(r.tx)) { while (c.getNext()) { result += xx_r39().hashBytes(c.getKey().getBytesUnsafe(), 0, r.keySize); result += xx_r39(). hashBytes(c.getValue().getBytesUnsafe(), 0, r.valSize); } } bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; bh.consume(r.c.seek(MDB_FIRST)); do { result += xx_r39().hashMemory(r.txn.key().addressOffset(), r.keySize); result += xx_r39().hashMemory(r.txn.val().addressOffset(), r.valSize); } while (r.c.seek(MDB_NEXT)); bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { long result = 0; bh.consume(r.c.first()); do { result += xx_r39().hashMemory(r.c.keyBuffer().addressOffset(), r.keySize); result += xx_r39().hashMemory(r.c.valBuffer().addressOffset(), r.valSize); } while (r.c.next()); bh.consume(result); }
@Benchmark public void readXxh64(final Reader r, final Blackhole bh) { try (MemoryStack stack = stackPush()) { final MDBVal key = mallocStack(stack); final MDBVal val = mallocStack(stack); long result = 0; int status = mdb_cursor_get(r.c, key, val, MDB_FIRST); while (status != MDB_NOTFOUND) { result += xx_r39().hashBytes(key.mv_data()); result += xx_r39().hashBytes(val.mv_data()); status = mdb_cursor_get(r.c, key, val, MDB_NEXT); } bh.consume(result); } }