Skip to content

Commit

Permalink
Add more insert batch APIs for generic wal
Browse files Browse the repository at this point in the history
  • Loading branch information
al8n committed Oct 1, 2024
1 parent ddb999f commit 17953d8
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 90 deletions.
28 changes: 26 additions & 2 deletions src/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ where
{
/// Returns the length of the value.
#[inline]
pub fn value_len(&self) -> usize {
pub(crate) fn value_len(&self) -> usize {
self.value.borrow().len()
}
}
Expand Down Expand Up @@ -167,7 +167,7 @@ where
{
/// Returns the length of the key.
#[inline]
pub fn key_len(&self) -> usize {
pub(crate) fn key_len(&self) -> usize {
self.key.borrow().len()
}
}
Expand Down Expand Up @@ -284,6 +284,30 @@ impl<'a, K: ?Sized, V: ?Sized> GenericEntry<'a, K, V> {
}
}

/// Returns the length of the key.
#[inline]
pub fn key_len(&self) -> usize
where
K: Type,
{
match self.key.data() {
Either::Left(val) => val.encoded_len(),
Either::Right(val) => val.len(),

Check warning on line 295 in src/entry.rs

View check run for this annotation

Codecov / codecov/patch

src/entry.rs#L295

Added line #L295 was not covered by tests
}
}

/// Returns the length of the value.
#[inline]
pub fn value_len(&self) -> usize
where
V: Type,
{
match self.value.data() {
Either::Left(val) => val.encoded_len(),
Either::Right(val) => val.len(),
}
}

/// Returns the key.
#[inline]
pub const fn key(&self) -> Either<&K, &[u8]> {
Expand Down
Loading

0 comments on commit 17953d8

Please sign in to comment.