RocksDB Get operation retrieves the record value for a given key. RocksDB code is very flexible and has several levels of abstractions. If you are planning to understand the code path you can start reading from the functions specified in this post.
DB Get Operation
RocksDB stores the recently inserted data in the MemTable and periodically flushes the data to disk based SSTables (sst files). It needs to search both MemTable and SSTables for the given key.
The entry function for the Get operation is db_impl_readonly.cc:DBImplReadOnly::Get() .
MemTable lookup
Table Lookup
If
it is not found in table cache then it searches the files at each level
starting from level 0. If you use BlockBasedTable the default option
the entry point is table/block_based/block_based_table_reader.cc:BlockBasedTable::Get().
It will search the block index to find the given key. It uses
BlockIter::Seek() function to search. The keys are compared using the
comparator function and the corresponding value is returned.
No comments:
Post a Comment