Table

Struct Table 

Source
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

An immutable, sorted map of strings to strings.

§Concurrency

A table is thread-safe.

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.

§footer: Footer

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

Source

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.

Source

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.

Source

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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Table

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl !RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl !UnwindSafe for Table

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V