MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / append

Method append

nodedb-wal/src/segmented.rs:158–173  ·  view source on GitHub ↗

Append a record to the WAL. Returns the assigned LSN. If the active segment has exceeded the target size, a new segment is created before appending. The rollover is transparent to the caller. `database_id` is stored in header bytes 34-41. Pass `0` for the default database (backward-compatible with pre-existing records).

(
        &mut self,
        record_type: u32,
        tenant_id: u64,
        vshard_id: u32,
        database_id: u64,
        payload: &[u8],
    )

Source from the content-addressed store, hash-verified

156 /// `database_id` is stored in header bytes 34-41. Pass `0` for the
157 /// default database (backward-compatible with pre-existing records).
158 pub fn append(
159 &mut self,
160 record_type: u32,
161 tenant_id: u64,
162 vshard_id: u32,
163 database_id: u64,
164 payload: &[u8],
165 ) -> Result<u64> {
166 // Check if we need to roll to a new segment.
167 if self.writer.file_offset() >= self.segment_target_size {
168 self.roll_segment()?;
169 }
170
171 self.writer
172 .append(record_type, tenant_id, vshard_id, database_id, payload)
173 }
174
175 /// Flush all buffered records and fsync the active segment.
176 pub fn sync(&mut self) -> Result<()> {

Callers 14

create_and_appendFunction · 0.45
replay_after_closeFunction · 0.45
total_size_bytesFunction · 0.45
reopen_continues_lsnFunction · 0.45
epoch_tamper_rejectedFunction · 0.45
replay_from_limit_basicFunction · 0.45

Calls 2

roll_segmentMethod · 0.80
file_offsetMethod · 0.45

Tested by 14

create_and_appendFunction · 0.36
replay_after_closeFunction · 0.36
total_size_bytesFunction · 0.36
reopen_continues_lsnFunction · 0.36
epoch_tamper_rejectedFunction · 0.36
replay_from_limit_basicFunction · 0.36