Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
Fix lints
Browse files Browse the repository at this point in the history
  • Loading branch information
lewiszlw committed Oct 28, 2023
1 parent 0362719 commit c8c86fe
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/kernel/lsm/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ mod tests {
loop {
let r = lr.read(&mut dst);

if !r.is_ok() {
if r.is_err() {
panic!("{}", r.unwrap_err());
} else if r.unwrap() == 0 {
break;
Expand Down
10 changes: 5 additions & 5 deletions src/kernel/lsm/mem_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,26 +451,26 @@ mod tests {
let old_seq_id = Sequence::create();

assert_eq!(
mem_table.find(&vec![b'k']),
mem_table.find(&[b'k']),
Some((Bytes::from(vec![b'k']), Some(Bytes::from(vec![b'1']))))
);

let _ = mem_table.insert_data(data_2)?;

assert_eq!(
mem_table.find(&vec![b'k']),
mem_table.find(&[b'k']),
Some((Bytes::from(vec![b'k']), Some(Bytes::from(vec![b'2']))))
);

assert_eq!(
mem_table.find_with_sequence_id(&vec![b'k'], old_seq_id),
mem_table.find_with_sequence_id(&[b'k'], old_seq_id),
Some((Bytes::from(vec![b'k']), Some(Bytes::from(vec![b'1']))))
);

let new_seq_id = Sequence::create();

assert_eq!(
mem_table.find_with_sequence_id(&vec![b'k'], new_seq_id),
mem_table.find_with_sequence_id(&[b'k'], new_seq_id),
Some((Bytes::from(vec![b'k']), Some(Bytes::from(vec![b'2']))))
);

Expand Down Expand Up @@ -632,7 +632,7 @@ mod tests {
assert_eq!(iter.try_next()?, None);

assert_eq!(
iter.seek(Seek::Backward(&vec![b'3']))?,
iter.seek(Seek::Backward(&[b'3']))?,
Some((key_4_2.key.clone(), None))
);

Expand Down
20 changes: 10 additions & 10 deletions src/kernel/lsm/mvcc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,38 +324,38 @@ mod tests {
}

// 模拟数据分布在MemTable以及SSTable中
for i in 0..50 {
for kv in vec_kv.iter().take(50) {
kv_store
.set(vec_kv[i].0.clone(), vec_kv[i].1.clone())
.set(kv.0.clone(), kv.1.clone())
.await?;
}

kv_store.flush().await?;

for i in 50..100 {
for kv in vec_kv.iter().take(100).skip(50) {
kv_store
.set(vec_kv[i].0.clone(), vec_kv[i].1.clone())
.set(kv.0.clone(), kv.1.clone())
.await?;
}

let mut tx_1 = kv_store.new_transaction().await;

for i in 100..times {
tx_1.set(vec_kv[i].0.clone(), vec_kv[i].1.clone());
for kv in vec_kv.iter().take(times).skip(100) {
tx_1.set(kv.0.clone(), kv.1.clone());
}

tx_1.remove(&vec_kv[times - 1].0)?;

// 事务在提交前事务可以读取到自身以及Store已写入的数据
for i in 0..times - 1 {
assert_eq!(tx_1.get(&vec_kv[i].0)?, Some(vec_kv[i].1.clone()));
for kv in vec_kv.iter().take(times - 1) {
assert_eq!(tx_1.get(&kv.0)?, Some(kv.1.clone()));
}

assert_eq!(tx_1.get(&vec_kv[times - 1].0)?, None);

// 事务在提交前Store不应该读取到事务中的数据
for i in 100..times {
assert_eq!(kv_store.get(&vec_kv[i].0).await?, None);
for kv in vec_kv.iter().take(times).skip(100) {
assert_eq!(kv_store.get(&kv.0).await?, None);
}

let vec_test = vec_kv[25..]
Expand Down
6 changes: 3 additions & 3 deletions src/kernel/lsm/table/ss_table/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,8 @@ mod tests {
let rand_max_idx: usize = rng.gen_range(2..all_item.len() - 1);
let rand_min_idx: usize = rng.gen_range(0..rand_max_idx - 1);

let min_key = full_key(&block, &block.vec_entry, rand_min_idx);
let max_key = full_key(&block, &block.vec_entry, rand_max_idx);
let min_key = full_key(block, &block.vec_entry, rand_min_idx);
let max_key = full_key(block, &block.vec_entry, rand_max_idx);

let excluded_vec = block.range(Bound::Excluded(&min_key), Bound::Excluded(&max_key));

Expand All @@ -803,7 +803,7 @@ mod tests {

fn full_key<T: BlockItem + Eq + Debug>(
block: &Block<T>,
all_entry: &Vec<(usize, Entry<T>)>,
all_entry: &[(usize, Entry<T>)],
index: usize,
) -> Vec<u8> {
let entry = &all_entry[index].1;
Expand Down

0 comments on commit c8c86fe

Please sign in to comment.