Rocksdb: How do range scan in rocksdb?

Created on 17 Jul 2014  路  5Comments  路  Source: facebook/rocksdb

rocksdb supports prefix_extractor, namely supports range queries, but there is no get_range() like interface for us to call? so, how do I perform range scan? using Get()?

Most helpful comment

You can do it through iterators. Create a iterator by using DB::NewIterator(), Seek to the smaller boundary of your range, keep doing next() and read key() until either you reach the larger boundary of your range or Valid() becomes false.

All 5 comments

You can do it through iterators. Create a iterator by using DB::NewIterator(), Seek to the smaller boundary of your range, keep doing next() and read key() until either you reach the larger boundary of your range or Valid() becomes false.

Does any way to get the count of total data? Or, is it possible?

@yuchi518 RocksDB doesn't know number of all live keys. But we recently add a feature to estimate total number of keys: https://github.com/facebook/rocksdb/commit/f6784766db165188613f581afd40ba8fb90aa2cd if you just want an estimation.

@siying

Thank you for the information.

Close the issue for now, feel free to reopen if the issue is not resolved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

abhimadan picture abhimadan  路  7Comments

kumasento picture kumasento  路  8Comments

mdcallag picture mdcallag  路  3Comments

cooljiansir picture cooljiansir  路  4Comments

zhangjinpeng1987 picture zhangjinpeng1987  路  10Comments