Skip to content

Commit

Permalink
chore(compactor): add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
Li0k committed Jun 24, 2024
1 parent a26cee7 commit 3a69780
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions src/storage/src/hummock/compactor/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -988,5 +988,97 @@ mod tests {
assert_eq!(1, start_index);
assert_eq!(1, end_index);
}

{
let block_metas = vec![
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(1), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(1), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(1), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(2), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(3), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
];
let seek_key = None;

let (start_index, end_index) = ConcatSstableIterator::filter_block_metas(
&block_metas,
seek_key,
&HashSet::from_iter(vec![2_u32].into_iter()),
&KeyRange::default(),
);

assert_eq!(3, start_index);
assert_eq!(4, end_index);
}

{
let block_metas = vec![
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(1), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(2), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(3), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(3), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
BlockMeta {
smallest_key: FullKey::for_test(TableId::new(3), Vec::default(), 0)
.encode()
.into(),
..Default::default()
},
];
let seek_key = None;

let (start_index, end_index) = ConcatSstableIterator::filter_block_metas(
&block_metas,
seek_key,
&HashSet::from_iter(vec![2_u32].into_iter()),
&KeyRange::default(),
);

assert_eq!(1, start_index);
assert_eq!(1, end_index);
}
}
}

0 comments on commit 3a69780

Please sign in to comment.