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>
impl<'a, V> PartitionedWrite<'a, V>
Sourcepub fn new(
table: &'a PartitionedTable<V>,
txn: &'a mut WriteTransaction,
) -> Self
pub fn new( table: &'a PartitionedTable<V>, txn: &'a mut WriteTransaction, ) -> Self
Creates a new write handle.
Sourcepub fn read_segment_data(
&self,
segment_info: &SegmentInfo,
) -> Result<Option<(SegmentInfo, Vec<u8>)>>
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
Sourcepub fn table(&self) -> &PartitionedTable<V>
pub fn table(&self) -> &PartitionedTable<V>
Gets the table reference.
Sourcepub fn find_head_segment_scan(
&self,
key: &[u8],
shard: u16,
) -> Result<Option<u16>>
pub fn find_head_segment_scan( &self, 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 (key, shard) pair and returns the one with the highest segment ID.
§Arguments
key- The key to search forshard- The shard ID
§Returns
The head segment ID, or None if no segments exist
Sourcepub fn create_new_segment(
&self,
key: &[u8],
shard: u16,
segment_id: u16,
data: &[u8],
) -> Result<()>
pub fn create_new_segment( &self, key: &[u8], shard: u16, segment_id: u16, data: &[u8], ) -> Result<()>
Sourcepub fn update_head_segment(
&self,
key: &[u8],
shard: u16,
data: &[u8],
) -> Result<(bool, u16)>
pub fn update_head_segment( &self, 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
key- The base keyshard- The shard IDdata- 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