Java Code Examples for org.rocksdb.RocksIterator#seekToLast()

The following examples show how to use org.rocksdb.RocksIterator#seekToLast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Index.java    From outbackcdx with Apache License 2.0 6 votes vote down vote up
public Records(RocksDB db, ColumnFamilyHandle columnFamilyHandle, byte[] startKey, RecordConstructor<T> constructor, Predicate<T> scope, boolean reverse, long cap) {
    final RocksIterator it = db.newIterator(columnFamilyHandle);
    it.seek(startKey);
    if (reverse) {
        if (it.isValid()) {
            it.prev();
        } else {
            it.seekToLast();
        }
    }
    this.constructor = constructor;
    this.scope = scope;
    this.it = it;
    this.reverse = reverse;
    this.cap = cap;
}
 
Example 2
Source File: RocksDBIterator.java    From kcache with Apache License 2.0 5 votes vote down vote up
RocksDBIterator(final String storeName,
                final RocksIterator iter,
                final Set<KeyValueIterator<byte[], byte[]>> openIterators,
                final boolean isDescending) {
    this.storeName = storeName;
    this.iter = iter;
    this.openIterators = openIterators;
    this.isDescending = isDescending;
    if (isDescending) {
        iter.seekToLast();
    } else {
        iter.seekToFirst();
    }
}
 
Example 3
Source File: RocksDBRangeIterator.java    From kcache with Apache License 2.0 5 votes vote down vote up
RocksDBRangeIterator(String storeName,
                     RocksIterator iter,
                     Set<KeyValueIterator<byte[], byte[]>> openIterators,
                     byte[] from,
                     boolean fromInclusive,
                     byte[] to,
                     boolean toInclusive,
                     boolean isDescending,
                     Comparator<byte[]> comparator) {
    super(storeName, iter, openIterators, isDescending);
    this.rawFromKey = from;
    if (rawFromKey == null) {
        if (isDescending) {
            iter.seekToLast();
        } else {
            iter.seekToFirst();
        }
    } else {
        if (isDescending) {
            iter.seekForPrev(rawFromKey);
        } else {
            iter.seek(rawFromKey);
        }
    }
    this.fromInclusive = fromInclusive;
    if (rawFromKey != null && !fromInclusive) {
        checkAndSkipFrom = true;
    }

    this.rawToKey = to;
    this.toInclusive = toInclusive;
    this.comparator = isDescending ? Collections.reverseOrder(comparator) : comparator;
}
 
Example 4
Source File: RocksDb.java    From benchmarks with Apache License 2.0 5 votes vote down vote up
@Benchmark
@SuppressWarnings("PMD.CloseResource")
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();
  }
}