Skip to content

Commit

Permalink
fix clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
jauhararifin committed Aug 13, 2024
1 parent d42b8e8 commit 3ebab4d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions benches/db_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ impl<'a> Profiler for FlamegraphProfiler<'a> {
fn stop_profiling(&mut self, _benchmark_id: &str, benchmark_dir: &Path) {
std::fs::create_dir_all(benchmark_dir).unwrap();
let flamegraph_path = benchmark_dir.join("flamegraph.svg");
let flamegraph_file = File::create(&flamegraph_path)
.expect("File system error while creating flamegraph.svg");
let flamegraph_file =
File::create(flamegraph_path).expect("File system error while creating flamegraph.svg");
if let Some(profiler) = self.active_profiler.take() {
profiler
.report()
Expand Down
16 changes: 8 additions & 8 deletions src/pager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ impl Pager {
let mut internal = self.internal.write();
let pgid = {
internal.db_state.page_count += 1;
PageId::new((internal.db_state.page_count - 1) as u64).unwrap()
PageId::new(internal.db_state.page_count - 1).unwrap()
};

let lsn = record_mutation(
Expand Down Expand Up @@ -688,7 +688,7 @@ impl Pager {

let mut f = f.lock();
let page_size = buffer.len();
write_page(&mut *f, pgid, page_size, buffer)?;
write_page(&mut f, pgid, page_size, buffer)?;
f.sync_all()?;
drop(f);

Expand Down Expand Up @@ -739,7 +739,7 @@ impl Pager {
let mut f = f.lock();
for (i, pgid) in internal.flushing_pgids.iter().enumerate() {
write_page(
&mut *f,
&mut f,
*pgid,
page_size,
&internal.flushing_pages[i * page_size..(i + 1) * page_size],
Expand Down Expand Up @@ -833,7 +833,7 @@ impl Pager {
} else {
drop(flush_internal);
let mut f = self.f.lock();
read_page(&mut *f, pgid, self.page_size, buff)?
read_page(&mut f, pgid, self.page_size, buff)?
}
};
if ok {
Expand Down Expand Up @@ -1099,7 +1099,7 @@ impl Pager {
// first, then to the actual page.
// TODO: also, we need to make sure that the WAL log is already written safely before we can
// write to disk.
write_page(&mut *f, *pgid, self.page_size, buffer)?;
write_page(&mut f, *pgid, self.page_size, buffer)?;
}

// TODO(important): this is not safe. We can get non-atomic write.
Expand Down Expand Up @@ -1602,7 +1602,7 @@ impl<'a> InteriorPageWrite<'a> {
}

pub(crate) fn reset(mut self, ctx: LogContext<'_>) -> anyhow::Result<PageWrite<'a>> {
Pager::encode(&self.0.meta, &mut self.0.buffer)?;
Pager::encode(&self.0.meta, self.0.buffer)?;

let pgid = self.id();
self.0.meta.lsn = Some(record_mutation(
Expand Down Expand Up @@ -2211,7 +2211,7 @@ impl<'a> LeafPageWrite<'a> {
}

pub(crate) fn reset(mut self, ctx: LogContext<'_>) -> anyhow::Result<PageWrite<'a>> {
Pager::encode(&self.0.meta, &mut self.0.buffer)?;
Pager::encode(&self.0.meta, self.0.buffer)?;

let pgid = self.id();
self.0.meta.lsn = Some(record_mutation(
Expand Down Expand Up @@ -2845,7 +2845,7 @@ impl<'a> OverflowPageWrite<'a> {
}

pub(crate) fn reset(mut self, ctx: LogContext<'_>) -> anyhow::Result<PageWrite<'a>> {
Pager::encode(&self.0.meta, &mut self.0.buffer)?;
Pager::encode(&self.0.meta, self.0.buffer)?;

let pgid = self.id();
self.0.meta.lsn = Some(record_mutation(
Expand Down
6 changes: 4 additions & 2 deletions src/wal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,10 @@ impl<'a> WalBackwardIterator<'a> {
self.start_offset -= s;
}

let calculated_checksum =
crc64::crc64(0x1d0f, &self.buffer[self.end_offset - size..self.end_offset - 8]);
let calculated_checksum = crc64::crc64(
0x1d0f,
&self.buffer[self.end_offset - size..self.end_offset - 8],
);
if recorded_checksum != calculated_checksum {
// TODO: maybe we can consider this entry as "uncompleted" and then skip it? but if
// it's in the middle of the WAL, this entry should be considered broken.
Expand Down
2 changes: 1 addition & 1 deletion tests/db_crash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn main() {
fn worker() {
env_logger::init();

let path = std::env::args().skip(1).next().unwrap();
let path = std::env::args().nth(1).unwrap();
let db = Db::open(
&PathBuf::from(path),
Setting {
Expand Down

0 comments on commit 3ebab4d

Please sign in to comment.