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

Method open_with_start_lsn

nodedb-wal/src/writer.rs:225–254  ·  view source on GitHub ↗

Open a new WAL segment file with a specific starting LSN. Used by `SegmentedWal` when rolling to a new segment. The file must not already exist (or be empty). The writer will assign LSNs starting from `start_lsn`.

(
        path: &Path,
        config: WalWriterConfig,
        start_lsn: u64,
    )

Source from the content-addressed store, hash-verified

223 /// not already exist (or be empty). The writer will assign LSNs starting
224 /// from `start_lsn`.
225 pub fn open_with_start_lsn(
226 path: &Path,
227 config: WalWriterConfig,
228 start_lsn: u64,
229 ) -> Result<Self> {
230 let mut opts = OpenOptions::new();
231 opts.create(true).write(true).append(false);
232
233 #[cfg(not(target_arch = "wasm32"))]
234 if config.use_direct_io {
235 opts.custom_flags(libc::O_DIRECT);
236 }
237
238 let file = opts.open(path)?;
239 let buffer = AlignedBuf::new(config.write_buffer_size, config.alignment)?;
240
241 let double_write = open_dwb_for(&config, path);
242
243 Ok(Self {
244 file,
245 buffer,
246 file_offset: 0,
247 next_lsn: AtomicU64::new(start_lsn),
248 sealed: false,
249 config,
250 encryption_ring: None,
251 segment_preamble: None,
252 double_write,
253 })
254 }
255
256 /// Open a WAL writer with O_DIRECT disabled (for testing on tmpfs, etc.).
257 pub fn open_without_direct_io(path: &Path) -> Result<Self> {

Callers

nothing calls this directly

Calls 5

open_dwb_forFunction · 0.85
appendMethod · 0.45
writeMethod · 0.45
createMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected