Skip to content

Commit

Permalink
Fix other Clippy lints
Browse files Browse the repository at this point in the history
Signed-off-by: Filippo Costa <[email protected]>
  • Loading branch information
neysofu committed Mar 4, 2024
1 parent 7456e92 commit 3276a40
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 43 deletions.
41 changes: 10 additions & 31 deletions src/cache/cache_container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,10 +382,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

let snapshot_id = 1;
let db_snapshot = CacheDb::new(snapshot_id, snapshot_manager.clone().into());
Expand All @@ -405,10 +402,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

let snapshot_id = 1;
// Both share the same ID
Expand All @@ -429,7 +423,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let mut cache_container = CacheContainer::new(db, to_parent.clone().into());
let mut cache_container = CacheContainer::new(db, to_parent.into());

cache_container.commit_snapshot(&1).unwrap();
}
Expand All @@ -441,7 +435,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let mut cache_container = CacheContainer::new(db, to_parent.clone().into());
let mut cache_container = CacheContainer::new(db, to_parent.into());

cache_container.discard_snapshot(&1);
}
Expand All @@ -451,10 +445,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

let snapshot_id = 1;
let db_snapshot = CacheDb::new(snapshot_id, snapshot_manager.clone().into());
Expand All @@ -473,7 +464,7 @@ mod tests {
let tempdir = tempfile::tempdir().unwrap();
let db = create_test_db(tempdir.path());
let to_parent = Arc::new(RwLock::new(HashMap::new()));
let snapshot_manager = CacheContainer::new(db, to_parent.clone().into());
let snapshot_manager = CacheContainer::new(db, to_parent.into());
assert_eq!(None, snapshot_manager.get::<S>(1, &TestField(1)).unwrap());
}

Expand All @@ -492,10 +483,7 @@ mod tests {
db_data.put::<S>(&three, &three).unwrap();
db.write_schemas(db_data).unwrap();

let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

let db_snapshot = CacheDb::new(1, snapshot_manager.clone().into());
db_snapshot.put::<S>(&two, &two).unwrap();
Expand Down Expand Up @@ -543,10 +531,7 @@ mod tests {
db_data.put::<S>(&f1, &f1).unwrap();
db.write_schemas(db_data).unwrap();

let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

// Operations:
// | snapshot_id | key | operation |
Expand Down Expand Up @@ -698,10 +683,7 @@ mod tests {
// | 0 | 1 |
// | 11 | 9 |

let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let snapshot_manager = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

// Operations:
// | snapshot_id | key | operation |
Expand Down Expand Up @@ -908,10 +890,7 @@ mod tests {
}
}

let cache_container = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let cache_container = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

// Creating snapshots
let n_chunks = 10; // Number of chunks you want
Expand Down
16 changes: 5 additions & 11 deletions tests/iterator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -363,10 +363,7 @@ fn test_db_snapshot_get_last_value() {
let mut to_parent = to_parent.write().unwrap();
to_parent.insert(1, 0);
}
let manager = Arc::new(RwLock::new(CacheContainer::new(
db.db,
to_parent.clone().into(),
)));
let manager = Arc::new(RwLock::new(CacheContainer::new(db.db, to_parent.into())));

let snapshot_1 = CacheDb::new(0, ReadOnlyLock::new(manager.clone()));

Expand Down Expand Up @@ -396,7 +393,7 @@ fn test_db_snapshot_get_last_value() {
manager.add_snapshot(snapshot_1.into()).unwrap();
}

let snapshot_2 = CacheDb::new(1, ReadOnlyLock::new(manager.clone()));
let snapshot_2 = CacheDb::new(1, ReadOnlyLock::new(manager));

{
let (latest_key, latest_value) = snapshot_2
Expand Down Expand Up @@ -454,10 +451,7 @@ fn test_db_cache_container_get_prev_value() {
to_parent.insert(1, 0);
to_parent.insert(2, 1);
}
let cache_container = Arc::new(RwLock::new(CacheContainer::new(
db,
to_parent.clone().into(),
)));
let cache_container = Arc::new(RwLock::new(CacheContainer::new(db, to_parent.into())));

// Snapshots 1 and 2 are to black box usages of parents iterator
let snapshot_1 = CacheDb::new(0, ReadOnlyLock::new(cache_container.clone()));
Expand Down Expand Up @@ -537,7 +531,7 @@ fn test_db_cache_container_get_prev_value() {
let mut manager = cache_container.write().unwrap();
manager.add_snapshot(snapshot_2.into()).unwrap();
}
let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(cache_container.clone()));
let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(cache_container));
assert_eq!(
(key_2.clone(), TestField(20)),
snapshot_3
Expand All @@ -546,7 +540,7 @@ fn test_db_cache_container_get_prev_value() {
.unwrap()
);
assert_eq!(
(key_2.clone(), TestField(20)),
(key_2, TestField(20)),
snapshot_3.get_prev::<S>(&key_1).unwrap().unwrap()
);
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion tests/snapshot_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn snapshot_lifecycle() {
}

// Snapshot 3: gets empty result, event value is in some previous snapshots
let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(manager.clone()));
let snapshot_3 = CacheDb::new(2, ReadOnlyLock::new(manager));
{
let mut to_parent = to_parent.write().unwrap();
to_parent.insert(2, 1);
Expand Down

0 comments on commit 3276a40

Please sign in to comment.