Skip to content

Commit

Permalink
Rename RedbValueMutInPlace to MutInPlaceValue
Browse files Browse the repository at this point in the history
  • Loading branch information
cberner committed Dec 4, 2023
1 parent b34b590 commit 8d7810d
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::tree_store::{
AccessGuardMut, Btree, BtreeDrain, BtreeDrainFilter, BtreeMut, BtreeRangeIter, Checksum,
PageHint, PageNumber, RawBtree, TransactionalMemory, MAX_VALUE_LENGTH,
};
use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace};
use crate::types::{MutInPlaceValue, RedbKey, RedbValue};
use crate::{AccessGuard, StorageError, WriteTransaction};
use crate::{Result, TableHandle};
use std::borrow::Borrow;
Expand Down Expand Up @@ -186,7 +186,7 @@ impl<'db, 'txn, K: RedbKey + 'static, V: RedbValue + 'static> Table<'db, 'txn, K
}
}

impl<'db, 'txn, K: RedbKey + 'static, V: RedbValueMutInPlace + 'static> Table<'db, 'txn, K, V> {
impl<'db, 'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'db, 'txn, K, V> {
/// Reserve space to insert a key-value pair
/// The returned reference will have length equal to value_length
pub fn insert_reserve<'a>(
Expand Down
4 changes: 2 additions & 2 deletions src/tree_store/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::tree_store::page_store::{CachePriority, Page, PageImpl, PageMut, Tran
use crate::tree_store::{
AccessGuardMut, AllPageNumbersBtreeIter, BtreeDrainFilter, BtreeRangeIter, PageHint, PageNumber,
};
use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace};
use crate::types::{MutInPlaceValue, RedbKey, RedbValue};
use crate::{AccessGuard, Result};
#[cfg(feature = "logging")]
use log::trace;
Expand Down Expand Up @@ -429,7 +429,7 @@ impl<'a, K: RedbKey + 'a, V: RedbValue + 'a> BtreeMut<'a, K, V> {
}
}

impl<'a, K: RedbKey + 'a, V: RedbValueMutInPlace + 'a> BtreeMut<'a, K, V> {
impl<'a, K: RedbKey + 'a, V: MutInPlaceValue + 'a> BtreeMut<'a, K, V> {
/// Reserve space to insert a key-value pair
/// The returned reference will have length equal to value_length
// Return type has the same lifetime as &self, because the tree must not be modified until the mutable guard is dropped
Expand Down
4 changes: 2 additions & 2 deletions src/tree_store/btree_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::tree_store::page_store::{
xxh3_checksum, CachePriority, Page, PageImpl, PageMut, TransactionalMemory,
};
use crate::tree_store::PageNumber;
use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace};
use crate::types::{MutInPlaceValue, RedbKey, RedbValue};
use crate::{Result, StorageError};
use std::cmp::Ordering;
use std::marker::PhantomData;
Expand Down Expand Up @@ -204,7 +204,7 @@ impl<'a, V: RedbValue> AccessGuardMut<'a, V> {
}
}

impl<'a, V: RedbValueMutInPlace> AsMut<V::BaseRefType> for AccessGuardMut<'a, V> {
impl<'a, V: MutInPlaceValue> AsMut<V::BaseRefType> for AccessGuardMut<'a, V> {
fn as_mut(&mut self) -> &mut V::BaseRefType {
V::from_bytes_mut(&mut self.page.memory_mut()[self.offset..(self.offset + self.len)])
}
Expand Down
4 changes: 2 additions & 2 deletions src/tree_store/table_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::tree_store::btree::{btree_stats, UntypedBtreeMut};
use crate::tree_store::btree_base::Checksum;
use crate::tree_store::btree_iters::AllPageNumbersBtreeIter;
use crate::tree_store::{BtreeMut, BtreeRangeIter, PageNumber, RawBtree, TransactionalMemory};
use crate::types::{RedbKey, RedbValue, RedbValueMutInPlace, TypeName};
use crate::types::{MutInPlaceValue, RedbKey, RedbValue, TypeName};
use crate::{DatabaseStats, Result};
use std::cmp::max;
use std::collections::{HashMap, HashSet};
Expand Down Expand Up @@ -158,7 +158,7 @@ impl RedbValue for FreedPageList<'_> {
}
}

impl RedbValueMutInPlace for FreedPageList<'_> {
impl MutInPlaceValue for FreedPageList<'_> {
type BaseRefType = FreedPageListMut;

fn initialize(data: &mut [u8]) {
Expand Down
4 changes: 2 additions & 2 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub trait RedbValue: Debug {

/// Implementing this trait indicates that the type can be mutated in-place as a &mut [u8].
/// This enables the .insert_reserve() method on Table
pub trait RedbValueMutInPlace: RedbValue {
pub trait MutInPlaceValue: RedbValue {
/// The base type such that &mut [u8] can be safely transmuted to &mut BaseRefType
type BaseRefType: Debug + ?Sized;

Expand All @@ -112,7 +112,7 @@ pub trait RedbValueMutInPlace: RedbValue {
fn from_bytes_mut(data: &mut [u8]) -> &mut Self::BaseRefType;
}

impl RedbValueMutInPlace for &[u8] {
impl MutInPlaceValue for &[u8] {
type BaseRefType = [u8];

fn initialize(_data: &mut [u8]) {
Expand Down

0 comments on commit 8d7810d

Please sign in to comment.