public void seekToLast() { iterator.seekToLast(); }
@Benchmark public void readRev(final Reader r, final Blackhole bh) { final RocksIterator iterator = r.db.newIterator(); iterator.seekToLast(); while (iterator.isValid()) { bh.consume(iterator.value()); iterator.prev(); } }
RocksDBKVStore.this.log.trace("not valid, seek to last"); assert RocksDBUtil.isInitialized(this.cursor); this.cursor.seekToLast(); RocksDBKVStore.this.log.trace("seek to last"); assert RocksDBUtil.isInitialized(this.cursor); this.cursor.seekToLast();
private Pair<byte[], byte[]> getRealRange(byte[] rawKey, byte[] rawEndKey) { boolean isNullStartKey = Constants.isNullStartKey(rawKey); boolean isNullEndKey = Constants.isNullEndKey(rawEndKey); if (isNullStartKey || isNullEndKey) { try (RocksIterator iter = db.newIterator(dataCfHandle)) { if (isNullStartKey) { iter.seekToFirst(); if (!iter.isValid()) { // no key to delete return null; } rawKey = iter.key(); } if (isNullEndKey) { iter.seekToLast(); if (!iter.isValid()) { // no key to delete return null; } rawEndKey = iter.key(); } } } return Pair.of(rawKey, rawEndKey); } }
@Override public Entry<byte[], byte[]> getFloor(byte[] key) throws IOException { try (RocksIterator iterator = db.newIterator(optionCache)) { // Position the iterator on the record whose key is >= to the supplied key iterator.seek(key); if (!iterator.isValid()) { // There are no entries >= key iterator.seekToLast(); if (iterator.isValid()) { return new EntryWrapper(iterator.key(), iterator.value()); } else { // Db is empty return null; } } iterator.prev(); if (!iterator.isValid()) { // Iterator is on the 1st entry of the db and this entry key is >= to the target // key return null; } else { return new EntryWrapper(iterator.key(), iterator.value()); } } }