Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
wcy-fdu committed Mar 10, 2023
1 parent 7853f05 commit 8128253
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/storage/benches/bench_block_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn build_block_data(t: u32, i: u64) -> Bytes {
let mut builder = BlockBuilder::new(options);
for tt in 1..=t {
for ii in 1..=i {
builder.add(&FullKey::decode(&key(tt, ii)), &value(ii));
builder.add(FullKey::decode(&key(tt, ii)), &value(ii));
}
}
Bytes::from(builder.build().to_vec())
Expand Down
2 changes: 1 addition & 1 deletion src/storage/benches/bench_compactor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ async fn build_table(
full_key.user_key.table_key[table_key_len - 8..].copy_from_slice(&i.to_be_bytes());
builder
.add(
&full_key.to_ref(),
full_key.to_ref(),
HummockValue::put(&value[start..end]),
true,
)
Expand Down
2 changes: 1 addition & 1 deletion src/storage/benches/bench_multi_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async fn build_tables<F: SstableWriterFactory>(
for i in RANGE {
builder
.add_full_key(
&FullKey::from_user_key(test_user_key_of(i).as_ref(), 1),
FullKey::from_user_key(test_user_key_of(i).as_ref(), 1),
HummockValue::put(VALUE),
true,
)
Expand Down
2 changes: 1 addition & 1 deletion src/storage/src/hummock/compactor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ impl Compactor {

// Don't allow two SSTs to share same user key
sst_builder
.add_full_key(&iter_key, value, is_new_user_key)
.add_full_key(iter_key, value, is_new_user_key)
.await?;

iter.next().await?;
Expand Down
24 changes: 12 additions & 12 deletions src/storage/src/hummock/sstable/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ impl BlockBuilder {
/// # Panics
///
/// Panic if key is not added in ASCEND order.
pub fn add(&mut self, full_key: &FullKey<&[u8]>, value: &[u8]) {
pub fn add(&mut self, full_key: FullKey<&[u8]>, value: &[u8]) {
let mut key: BytesMut = Default::default();
full_key.encode_into(&mut key);
if self.entry_count > 0 {
Expand Down Expand Up @@ -400,10 +400,10 @@ mod tests {
fn test_block_enc_dec() {
let options = BlockBuilderOptions::default();
let mut builder = BlockBuilder::new(options);
builder.add(&construct_full_key_struct(0, b"k1", 1), b"v01");
builder.add(&construct_full_key_struct(0, b"k2", 2), b"v02");
builder.add(&construct_full_key_struct(0, b"k3", 3), b"v03");
builder.add(&construct_full_key_struct(0, b"k4", 4), b"v04");
builder.add(construct_full_key_struct(0, b"k1", 1), b"v01");
builder.add(construct_full_key_struct(0, b"k2", 2), b"v02");
builder.add(construct_full_key_struct(0, b"k3", 3), b"v03");
builder.add(construct_full_key_struct(0, b"k4", 4), b"v04");
let capacity = builder.uncompressed_block_size();
let buf = builder.build().to_vec();
let block = Box::new(Block::decode(buf.into(), capacity).unwrap());
Expand Down Expand Up @@ -445,10 +445,10 @@ mod tests {
..Default::default()
};
let mut builder = BlockBuilder::new(options);
builder.add(&construct_full_key_struct(0, b"k1", 1), b"v01");
builder.add(&construct_full_key_struct(0, b"k2", 2), b"v02");
builder.add(&construct_full_key_struct(0, b"k3", 3), b"v03");
builder.add(&construct_full_key_struct(0, b"k4", 4), b"v04");
builder.add(construct_full_key_struct(0, b"k1", 1), b"v01");
builder.add(construct_full_key_struct(0, b"k2", 2), b"v02");
builder.add(construct_full_key_struct(0, b"k3", 3), b"v03");
builder.add(construct_full_key_struct(0, b"k4", 4), b"v04");
let capcitiy = builder.uncompressed_block_size();
let buf = builder.build().to_vec();
let block = Box::new(Block::decode(buf.into(), capcitiy).unwrap());
Expand Down Expand Up @@ -501,9 +501,9 @@ mod tests {
let large_key = vec![b'b'; MAX_KEY_LEN];
let xlarge_key = vec![b'c'; MAX_KEY_LEN + 500];

builder.add(&construct_full_key_struct(0, &medium_key, 1), b"v1");
builder.add(&construct_full_key_struct(0, &large_key, 2), b"v2");
builder.add(&construct_full_key_struct(0, &xlarge_key, 3), b"v3");
builder.add(construct_full_key_struct(0, &medium_key, 1), b"v1");
builder.add(construct_full_key_struct(0, &large_key, 2), b"v2");
builder.add(construct_full_key_struct(0, &xlarge_key, 3), b"v3");
let capacity = builder.uncompressed_block_size();
let buf = builder.build().to_vec();
let block = Box::new(Block::decode(buf.into(), capacity).unwrap());
Expand Down
8 changes: 4 additions & 4 deletions src/storage/src/hummock/sstable/block_iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ mod tests {
fn build_iterator_for_test() -> BlockIterator {
let options = BlockBuilderOptions::default();
let mut builder = BlockBuilder::new(options);
builder.add(&construct_full_key_struct(0, b"k01", 1), b"v01");
builder.add(&construct_full_key_struct(0, b"k02", 2), b"v02");
builder.add(&construct_full_key_struct(0, b"k04", 4), b"v04");
builder.add(&construct_full_key_struct(0, b"k05", 5), b"v05");
builder.add(construct_full_key_struct(0, b"k01", 1), b"v01");
builder.add(construct_full_key_struct(0, b"k02", 2), b"v02");
builder.add(construct_full_key_struct(0, b"k04", 4), b"v04");
builder.add(construct_full_key_struct(0, b"k05", 5), b"v05");
let capacity = builder.uncompressed_block_size();
let buf = builder.build().to_vec();
BlockIterator::new(BlockHolder::from_owned_block(Box::new(
Expand Down
4 changes: 2 additions & 2 deletions src/storage/src/hummock/sstable/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<W: SstableWriter, F: FilterBuilder> SstableBuilder<W, F> {
/// Add kv pair to sstable.
pub async fn add(
&mut self,
full_key: &FullKey<&[u8]>,
full_key: FullKey<&[u8]>,
value: HummockValue<&[u8]>,
is_new_user_key: bool,
) -> HummockResult<()> {
Expand Down Expand Up @@ -526,7 +526,7 @@ pub(super) mod tests {

for i in 0..TEST_KEYS_COUNT {
b.add(
&test_key_of(i).to_ref(),
test_key_of(i).to_ref(),
HummockValue::put(&test_value_of(i)),
true,
)
Expand Down
10 changes: 5 additions & 5 deletions src/storage/src/hummock/sstable/multi_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ where
/// allowed, where `allow_split` should be `false`.
pub async fn add_full_key(
&mut self,
full_key: &FullKey<&[u8]>,
full_key: FullKey<&[u8]>,
value: HummockValue<&[u8]>,
is_new_user_key: bool,
) -> HummockResult<()> {
Expand Down Expand Up @@ -322,7 +322,7 @@ mod tests {
for i in 0..table_capacity {
builder
.add_full_key(
&FullKey::from_user_key(
FullKey::from_user_key(
test_user_key_of(i).as_ref(),
(table_capacity - i) as u64,
),
Expand Down Expand Up @@ -352,7 +352,7 @@ mod tests {
epoch -= 1;
builder
.add_full_key(
&FullKey::from_user_key(test_user_key_of(1).as_ref(), epoch),
FullKey::from_user_key(test_user_key_of(1).as_ref(), epoch),
HummockValue::put(b"v"),
true,
)
Expand Down Expand Up @@ -390,7 +390,7 @@ mod tests {
opts,
));
builder
.add_full_key(&test_key_of(0).to_ref(), HummockValue::put(b"v"), false)
.add_full_key(test_key_of(0).to_ref(), HummockValue::put(b"v"), false)
.await
.unwrap();
}
Expand All @@ -413,7 +413,7 @@ mod tests {
);
builder
.add_full_key(
&FullKey::for_test(table_id, b"k", 233),
FullKey::for_test(table_id, b"k", 233),
HummockValue::put(b"v"),
false,
)
Expand Down
4 changes: 2 additions & 2 deletions src/storage/src/hummock/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub async fn gen_test_sstable_data(
) -> (Bytes, SstableMeta) {
let mut b = SstableBuilder::for_test(0, mock_sst_writer(&opts), opts);
for (key, value) in kv_iter {
b.add(&key.to_ref(), value.as_slice(), true).await.unwrap();
b.add(key.to_ref(), value.as_slice(), true).await.unwrap();
}
let output = b.finish().await.unwrap();
output.writer_output
Expand Down Expand Up @@ -211,7 +211,7 @@ pub async fn gen_test_sstable_inner<B: AsRef<[u8]>>(
let writer = sstable_store.clone().create_sst_writer(sst_id, writer_opts);
let mut b = SstableBuilder::for_test(sst_id, writer, opts);
for (key, value) in kv_iter {
b.add(&key.to_ref(), value.as_slice(), true).await.unwrap();
b.add(key.to_ref(), value.as_slice(), true).await.unwrap();
}
b.add_delete_range(range_tombstones);
let output = b.finish().await.unwrap();
Expand Down

0 comments on commit 8128253

Please sign in to comment.