PartitionedWrite

Struct PartitionedWrite 

Source
pub struct PartitionedWrite<'a, V> { /* private fields */ }
Expand description

Write operations for partitioned tables.

Provides read-write access to partitioned data with the ability to modify values.

Implementations§

Source§

impl<'a, V> PartitionedWrite<'a, V>

Source

pub fn new( table: &'a PartitionedTable<V>, txn: &'a mut WriteTransaction, ) -> Self

Creates a new write handle.

Source

pub fn read_segment_data( &self, segment_info: &SegmentInfo, ) -> Result<Option<(SegmentInfo, Vec<u8>)>>

Reads segment data for the given segment info.

If segment_info already contains data, it’s returned directly. Otherwise, the data is read from the database.

§Arguments
  • segment_info - Information about the segment to read
§Returns

Option containing (segment_info, segment_data) or None if segment doesn’t exist

Source

pub fn table(&self) -> &PartitionedTable<V>

Gets the table reference.

Source

pub fn find_head_segment_scan( &self, base_key: &[u8], shard: u16, ) -> Result<Option<u16>>

Finds the head segment using scan method (when meta table is disabled).

This method scans all segments for the given (base_key, shard) pair and returns the one with the highest segment ID.

§Arguments
  • base_key - The base key to search for
  • shard - The shard ID
§Returns

The head segment ID, or None if no segments exist

Source

pub fn write_segment_data(&self, segment_key: &[u8], data: &[u8]) -> Result<()>

Writes data to a specific segment.

This method overwrites any existing data at the segment key.

§Arguments
  • segment_key - The encoded segment key
  • data - The data to write
§Returns

Ok on success, error on failure

Source

pub fn create_new_segment( &self, base_key: &[u8], shard: u16, segment_id: u16, data: &[u8], ) -> Result<()>

Creates a new segment with the given data.

The segment_id should be the next available ID for this shard.

§Arguments
  • base_key - The base key
  • shard - The shard ID
  • segment_id - The segment ID
  • data - The segment data
§Returns

Ok on success, error on failure

Source

pub fn update_head_segment( &self, base_key: &[u8], shard: u16, data: &[u8], ) -> Result<(bool, u16)>

Updates the head segment with new data, rolling if necessary.

This method checks if the new data fits in the current head segment. If it doesn’t fit, a new segment is created.

§Arguments
  • base_key - The base key
  • shard - The shard ID
  • data - The new segment data
§Returns

Tuple of (was_rolled, new_segment_id) where:

  • was_rolled: true if a new segment was created
  • new_segment_id: ID of the segment that now contains the data

Auto Trait Implementations§

§

impl<'a, V> Freeze for PartitionedWrite<'a, V>

§

impl<'a, V> !RefUnwindSafe for PartitionedWrite<'a, V>

§

impl<'a, V> Send for PartitionedWrite<'a, V>
where V: Sync,

§

impl<'a, V> Sync for PartitionedWrite<'a, V>
where V: Sync,

§

impl<'a, V> Unpin for PartitionedWrite<'a, V>

§

impl<'a, V> !UnwindSafe for PartitionedWrite<'a, V>

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.