Skip to content

Commit

Permalink
move get to test_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
wenym1 committed Jan 15, 2025
1 parent 32c9826 commit 17e16c0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
21 changes: 21 additions & 0 deletions src/storage/src/hummock/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,3 +584,24 @@ impl<S: StateStore> StateStoreReadTestExt for S {
Ok(ret)
}
}

pub trait StateStoreGetTestExt: StateStoreGet {
fn get(
&self,
key: TableKey<Bytes>,
read_options: ReadOptions,
) -> impl StorageFuture<'_, Option<Bytes>>;
}

impl<S: StateStoreGet> StateStoreGetTestExt for S {
async fn get(
&self,
key: TableKey<Bytes>,
read_options: ReadOptions,
) -> StorageResult<Option<Bytes>> {
self.on_key_value(key, read_options, |_, value| {
Ok(Bytes::copy_from_slice(value))
})
.await
}
}
16 changes: 0 additions & 16 deletions src/storage/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,22 +264,6 @@ pub trait StateStoreGet: StaticSendSync {
read_options: ReadOptions,
on_key_value_fn: impl KeyValueFn<O>,
) -> impl StorageFuture<'_, Option<O>>;

/// Point gets a value from the state store.
/// The result is based on a snapshot corresponding to the given `epoch`.
/// Only the value is returned.
fn get(
&self,
key: TableKey<Bytes>,
read_options: ReadOptions,
) -> impl StorageFuture<'_, Option<Bytes>> {
async move {
self.on_key_value(key, read_options, |_, value| {
Ok(Bytes::copy_from_slice(value))
})
.await
}
}
}

pub trait StateStoreRead: StateStoreGet + StaticSendSync {
Expand Down

0 comments on commit 17e16c0

Please sign in to comment.