@Benchmark public void readCrc(final Reader r, final Blackhole bh) { r.crc.reset(); try (Cursor c = r.store.openCursor(r.tx)) { while (c.getNext()) { r.crc.update(c.getKey().getBytesUnsafe(), 0, r.keySize); r.crc.update(c.getValue().getBytesUnsafe(), 0, r.valSize); } } bh.consume(r.crc.getValue()); }
@Benchmark public void readSeq(final Reader r, final Blackhole bh) { try (Cursor c = r.store.openCursor(r.tx)) { while (c.getNext()) { bh.consume(c.getValue().getBytesUnsafe()); } } }
@Override public KVPair getAtLeast(byte[] minKey, byte[] maxKey) { Preconditions.checkState(!this.closed.get(), "transaction closed"); try (final Cursor cursor = this.store.openCursor(this.tx)) { final boolean found = minKey != null && minKey.length > 0 ? cursor.getSearchKeyRange(new ArrayByteIterable(minKey)) != null : cursor.getNext(); if (!found) return null; final byte[] key = XodusKVStore.get(cursor.getKey(), true); if (maxKey != null && ByteUtil.compare(key, maxKey) >= 0) return null; return new KVPair(key, XodusKVStore.get(cursor.getValue(), true)); } }
@Benchmark public void readRev(final Reader r, final Blackhole bh) { try (Cursor c = r.store.openCursor(r.tx)) { c.getLast(); do { bh.consume(c.getValue().getBytesUnsafe()); } while (c.getPrev()); } }
this.next = new KVPair(key, XodusKVStore.get(cursor.getValue(), true)); if (XodusKVStore.this.log.isTraceEnabled()) XodusKVStore.this.log.trace("seek " + (this.reverse ? "previous" : "next") + " -> " + this.next);
this.finished = true; else this.next = new KVPair(key, XodusKVStore.get(cursor.getValue(), true)); } else { if (XodusKVStore.this.log.isTraceEnabled())
@Override public KVPair getAtMost(byte[] maxKey, byte[] minKey) { Preconditions.checkState(!this.closed.get(), "transaction closed"); try (final Cursor cursor = this.store.openCursor(this.tx)) { // It's possible somebody could be simultaneously inserting keys just after maxKey, in which case we // could be tricked into returning a key > maxKey. This is unlikely, but make sure it can't affect us. while (true) { if (maxKey != null) cursor.getSearchKeyRange(new ArrayByteIterable(maxKey)); if (!cursor.getPrev()) return null; final byte[] key = XodusKVStore.get(cursor.getKey(), true); if (maxKey != null && ByteUtil.compare(key, maxKey) >= 0) continue; if (minKey != null && ByteUtil.compare(key, minKey) < 0) return null; return new KVPair(key, XodusKVStore.get(cursor.getValue(), true)); } } }
@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); }