pub(crate) struct Table {
options: DbOptions,
file: Box<dyn ReadonlyRandomAccessFile>,
cache_partition_id: u64,
footer: Footer,
index_block: BlockReader<InternalKey>,
maybe_filter_block: Option<FilterBlockReader>,
}
Expand description
Fields§
§options: DbOptions
Database options to refer to when reading the table file.
file: Box<dyn ReadonlyRandomAccessFile>
The underlying file holding the table data.
cache_partition_id: u64
The partition ID to use when reading from the block cache.
A block cache may be used by multiple clients and this ID is used to partition the cache to differentiate values cached by different clients.
The footer of the table file.
The footer contains handles to the metaindex and index blocks.
index_block: BlockReader<InternalKey>
Block containing the index.
maybe_filter_block: Option<FilterBlockReader>
Optional block containing filters defined by the database filter policy.
Implementations§
Source§impl Table
Public methods
impl Table
Public methods
Sourcepub fn open(
options: DbOptions,
file: Box<dyn ReadonlyRandomAccessFile>,
) -> Result<Table, ReadError>
pub fn open( options: DbOptions, file: Box<dyn ReadonlyRandomAccessFile>, ) -> Result<Table, ReadError>
Open a table file and parse some initial information for iterating the file.
Sourcepub fn get(
&self,
read_options: &ReadOptions,
key: &InternalKey,
) -> Result<Option<Vec<u8>>, ReadError>
pub fn get( &self, read_options: &ReadOptions, key: &InternalKey, ) -> Result<Option<Vec<u8>>, ReadError>
Get the value for the given seek key stored in the table file.
This method corresponds to the publicly exposed Db::get
operation so will ignore deleted
values.
Returns a non-deleted value if the key is in the table. Otherwise, return None
.
Sourcepub fn iter_with(
table: Arc<Table>,
read_options: ReadOptions,
) -> TwoLevelIterator
pub fn iter_with( table: Arc<Table>, read_options: ReadOptions, ) -> TwoLevelIterator
Get an iterator for the table. NOTE: This iterator is initially invalid until an operation is performed with it.
In the terminology set by LevelDB, this is a two level iterator. We invert the lifetime
relationship of the iterator object and the table unlike common Rust iterator objects. This is
because of the requirement to keep a list of table iterators in a single iterator that merges
all of the table data. There was an effort to use std::borrow::Cow
and std::ops::Deref
in RainDB but things got a little hairy and the effort was not worth it at the time to come up
with a more generic solution to allow a method that accepts either a table reference or an
owned value.
Source§impl Table
impl Table
Sourcefn get_data_block_reader_from_disk<K: RainDbKeyType>(
file: &dyn ReadonlyRandomAccessFile,
block_handle: &BlockHandle,
) -> Result<BlockReader<K>, ReadError>
fn get_data_block_reader_from_disk<K: RainDbKeyType>( file: &dyn ReadonlyRandomAccessFile, block_handle: &BlockHandle, ) -> Result<BlockReader<K>, ReadError>
Return a reader from disk for the data block at the specified handle.
Sourcefn read_block_from_disk(
file: &dyn ReadonlyRandomAccessFile,
block_handle: &BlockHandle,
) -> Result<Vec<u8>, ReadError>
fn read_block_from_disk( file: &dyn ReadonlyRandomAccessFile, block_handle: &BlockHandle, ) -> Result<Vec<u8>, ReadError>
Return decompressed byte buffer from disk representing the block at the specified block handle.
Sourcefn read_filter_meta_block(
options: &DbOptions,
file: &dyn ReadonlyRandomAccessFile,
metaindex_block: &BlockReader<MetaIndexKey>,
) -> Result<Option<FilterBlockReader>, ReadError>
fn read_filter_meta_block( options: &DbOptions, file: &dyn ReadonlyRandomAccessFile, metaindex_block: &BlockReader<MetaIndexKey>, ) -> Result<Option<FilterBlockReader>, ReadError>
Return a reader for the filter meta block at the specified block handle.
Sourcefn get_block_reader(
&self,
read_options: &ReadOptions,
block_handle: &BlockHandle,
) -> Result<Arc<BlockReader<InternalKey>>, ReadError>
fn get_block_reader( &self, read_options: &ReadOptions, block_handle: &BlockHandle, ) -> Result<Arc<BlockReader<InternalKey>>, ReadError>
Get a block reader by checking the block cache first and reading it from disk if there’s a cache miss.
Sourcefn get_block_reader_from_cache(
&self,
block_handle: &BlockHandle,
) -> Option<Box<dyn CacheEntry<Arc<BlockReader<InternalKey>>>>>
fn get_block_reader_from_cache( &self, block_handle: &BlockHandle, ) -> Option<Box<dyn CacheEntry<Arc<BlockReader<InternalKey>>>>>
Check the block cache for the block at the specified block handle.
Return the block reader if found. Otherwise, return None
.
Sourcefn cache_block_reader(
&self,
block_reader: BlockReader<InternalKey>,
block_handle: &BlockHandle,
) -> Box<dyn CacheEntry<Arc<BlockReader<InternalKey>>>>
fn cache_block_reader( &self, block_reader: BlockReader<InternalKey>, block_handle: &BlockHandle, ) -> Box<dyn CacheEntry<Arc<BlockReader<InternalKey>>>>
Cache the specified block reader in the block cache.