2

Is it possible to read all values matching key pattern from rocks db. e.g:

key1 -> value1
key12 -> value12
key123 -> value123

I want to ready all keys matching pattern => "key1*" or "key*2"

Is there a way to perform this kind of search operation in Rocks Db.

vineet pant
  • 77
  • 1
  • 9

1 Answers1

2
  • key1* yes: You can use rocksdb::DB::iterator with RocksDB::IteratorMode::From("key1".as_bytes(), rocksdb::Direction::Forward), and then put a .take_while(|(k, _)| k.starts_with("key1".as_bytes())) to stop it from leaving key1*.
  • key*2 no

Why is this tagged Rust?

Caesar
  • 6,733
  • 4
  • 38
  • 44