Skip to content

Commit

Permalink
make aol read write path independent of common locks
Browse files Browse the repository at this point in the history
  • Loading branch information
arriqaaq committed Jan 28, 2025
1 parent ad83476 commit 00a1051
Show file tree
Hide file tree
Showing 9 changed files with 198 additions and 175 deletions.
2 changes: 1 addition & 1 deletion cli/src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ impl Analyzer {
.with_file_extension("clog".to_string());

// Open the commit log
let mut destination_commit_log =
let destination_commit_log =
Aol::open(&destination_clog_subdir, &copts).map_err(Error::from)?;

// Write latest versions to new location
Expand Down
16 changes: 8 additions & 8 deletions src/compaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ impl Store {
let oracle_lock = oracle.write_lock.lock();

// Rotate the commit log and get the new segment ID
let mut clog = self.core.clog.as_ref().unwrap().write();
let clog = self.core.clog.as_ref().unwrap().write();
let new_segment_id = clog.rotate()?;
let last_updated_segment_id = new_segment_id - 1;
drop(clog); // Explicitly drop the lock
Expand All @@ -75,7 +75,7 @@ impl Store {
fs::create_dir_all(&tmp_merge_dir)?;

// Initialize a new manifest in the temporary directory
let mut manifest = Core::initialize_manifest(&tmp_merge_dir)?;
let manifest = Core::initialize_manifest(&tmp_merge_dir)?;
// Add the last updated segment ID to the manifest
let changeset = Manifest::with_compacted_up_to_segment(last_updated_segment_id);
manifest.append(&changeset.serialize()?)?;
Expand All @@ -86,7 +86,7 @@ impl Store {
let tm_opts = LogOptions::default()
.with_max_file_size(self.core.opts.max_compaction_segment_size)
.with_file_extension("clog".to_string());
let mut temp_writer = Aol::open(&temp_clog_dir, &tm_opts)?;
let temp_writer = Aol::open(&temp_clog_dir, &tm_opts)?;

// TODO: Check later to add a new way for compaction by reading from the files first and then
// check in files for the keys that are not found in memory to handle deletion
Expand All @@ -101,11 +101,11 @@ impl Store {
// Do compaction and write

// Define a closure for writing entries to the temporary commit log
let mut write_entry = |key: &[u8],
value: Vec<u8>,
version: u64,
ts: u64,
metadata: Option<Metadata>|
let write_entry = |key: &[u8],
value: Vec<u8>,
version: u64,
ts: u64,
metadata: Option<Metadata>|
-> Result<()> {
let mut entry = Entry::new(key, &value);
entry.set_ts(ts);
Expand Down
Loading

0 comments on commit 00a1051

Please sign in to comment.