MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / new_with_path

Method new_with_path

graphlite/src/txn/wal.rs:395–428  ·  view source on GitHub ↗

Create a new persistent WAL instance with a specific path This is the internal method that requires a path. All WAL instances must be associated with a database directory to ensure proper data organization.

(db_path: PathBuf)

Source from the content-addressed store, hash-verified

393 /// This is the internal method that requires a path. All WAL instances must be
394 /// associated with a database directory to ensure proper data organization.
395 pub fn new_with_path(db_path: PathBuf) -> Result<Self, WALError> {
396 let wal_dir = db_path.join("wal");
397
398 // Create WAL directory if it doesn't exist
399 create_dir_all(&wal_dir)
400 .map_err(|e| WALError::IOError(format!("Failed to create WAL directory: {}", e)))?;
401
402 // Create catalog WAL directory
403 let catalog_wal_dir = wal_dir.join("catalog");
404 create_dir_all(&catalog_wal_dir).map_err(|e| {
405 WALError::IOError(format!("Failed to create catalog WAL directory: {}", e))
406 })?;
407
408 let catalog_wal = CatalogWAL {
409 catalog_wal_dir,
410 writer: Arc::new(Mutex::new(None)),
411 file_number: Arc::new(Mutex::new(0)),
412 };
413
414 let mut wal = Self {
415 wal_dir,
416 current_writer: Arc::new(Mutex::new(None)),
417 current_file_number: Arc::new(Mutex::new(0)),
418 global_sequence: Arc::new(Mutex::new(0)),
419 current_file_path: Arc::new(Mutex::new(None)),
420 current_file_size: Arc::new(Mutex::new(0)),
421 catalog_wal: Some(Arc::new(catalog_wal)),
422 };
423
424 // Initialize WAL by finding the latest file and sequence numbers
425 wal.initialize()?;
426
427 Ok(wal)
428 }
429
430 /// Initialize WAL by scanning existing files
431 fn initialize(&mut self) -> Result<(), WALError> {

Callers

nothing calls this directly

Calls 1

initializeMethod · 0.80

Tested by

no test coverage detected