optimize get w/ zero-copy ref handle

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk committed 2024-07-03 06:34:16 +00:00
1 parent 0522fe7d92
commit ee64fb149c
11 files changed
+46 -16

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
use std::ops::Deref;
use rocksdb::DBPinnableSlice;
pub struct Handle<'a> {
val: DBPinnableSlice<'a>,
}
impl<'a> From<DBPinnableSlice<'a>> for Handle<'a> {
fn from(val: DBPinnableSlice<'a>) -> Self {
Self {
val,
}
}
}
impl Deref for Handle<'_> {
type Target = [u8];
fn deref(&self) -> &Self::Target { &self.val }
}
impl AsRef<[u8]> for Handle<'_> {
fn as_ref(&self) -> &[u8] { &self.val }
}