Skip to main content

StoreEngine

Trait StoreEngine 

Source
pub trait StoreEngine:
    Send
    + Sync
    + 'static {
    // Required methods
    fn put_batch(&self, kvs: &[(Bytes, Bytes)]) -> Result<u64, String>;
    fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String>;
    fn range_scan(
        &self,
        start: &[u8],
        end: &[u8],
        limit: usize,
        forward: bool,
    ) -> Result<Vec<(Bytes, Bytes)>, String>;
    fn delete_batch(&self, keys: &[&[u8]]) -> Result<u64, String>;
    fn current_sequence(&self) -> u64;

    // Provided method
    fn get_many(
        &self,
        keys: &[&[u8]],
    ) -> Result<Vec<(Vec<u8>, Option<Vec<u8>>)>, String> { ... }
}
Expand description

Implement these operations for your store. All methods must be thread-safe.

Required Methods§

Source

fn put_batch(&self, kvs: &[(Bytes, Bytes)]) -> Result<u64, String>

Persist key-value pairs atomically and return the new global sequence number for this write.

Source

fn get(&self, key: &[u8]) -> Result<Option<Vec<u8>>, String>

Fetch the value for a single key. Returns None when the key does not exist.

Source

fn range_scan( &self, start: &[u8], end: &[u8], limit: usize, forward: bool, ) -> Result<Vec<(Bytes, Bytes)>, String>

Keys in [start, end] (inclusive) when end is non-empty; empty end means unbounded above. Matches store.query.v1.RangeRequest / ReduceRequest on the wire. limit caps rows returned.

Source

fn delete_batch(&self, keys: &[&[u8]]) -> Result<u64, String>

Delete a batch of keys atomically. Returns the new global sequence number.

Source

fn current_sequence(&self) -> u64

Current sequence number visible to readers (used for min_sequence_number checks).

Provided Methods§

Source

fn get_many( &self, keys: &[&[u8]], ) -> Result<Vec<(Vec<u8>, Option<Vec<u8>>)>, String>

Batch-get: returns (key, Option<value>) for each input key, preserving order.

Implementors§