From 1cb0be6b0473786ca9e4ed22d11f921dae252c1d Mon Sep 17 00:00:00 2001 From: Christopher Berner Date: Sat, 3 Feb 2024 10:09:12 -0800 Subject: [PATCH] Rename RedbKey to Key --- examples/special_values.rs | 8 ++--- src/db.rs | 30 +++++++++--------- src/lib.rs | 2 +- src/multimap_table.rs | 48 ++++++++++++++-------------- src/table.rs | 56 ++++++++++++++++----------------- src/transaction_tracker.rs | 4 +-- src/transactions.rs | 44 +++++++++++++------------- src/tree_store/btree.rs | 12 +++---- src/tree_store/btree_base.rs | 12 +++---- src/tree_store/btree_iters.rs | 42 ++++++++++++------------- src/tree_store/btree_mutator.rs | 6 ++-- src/tree_store/table_tree.rs | 10 +++--- src/tuple_types.rs | 6 ++-- src/types.rs | 18 +++++------ tests/backward_compatibility.rs | 2 +- tests/basic_tests.rs | 8 ++--- 16 files changed, 153 insertions(+), 155 deletions(-) diff --git a/examples/special_values.rs b/examples/special_values.rs index f925b584..9b5a1092 100644 --- a/examples/special_values.rs +++ b/examples/special_values.rs @@ -1,5 +1,5 @@ use redb::{ - Database, Error, ReadableTable, RedbKey, Table, TableDefinition, TableHandle, Value, + Database, Error, Key, ReadableTable, Table, TableDefinition, TableHandle, Value, WriteTransaction, }; use std::fs::{File, OpenOptions}; @@ -40,7 +40,7 @@ struct SpecialValuesTransaction<'db> { } impl<'db> SpecialValuesTransaction<'db> { - fn open_table( + fn open_table( &mut self, table: TableDefinition, ) -> SpecialValuesTable { @@ -58,13 +58,13 @@ impl<'db> SpecialValuesTransaction<'db> { } } -struct SpecialValuesTable<'txn, K: RedbKey + 'static, V: Value + 'static> { +struct SpecialValuesTable<'txn, K: Key + 'static, V: Value + 'static> { inner: Table<'txn, K, (u64, u64)>, file: &'txn mut File, _value_type: PhantomData, } -impl<'txn, K: RedbKey + 'static, V: Value + 'static> SpecialValuesTable<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Value + 'static> SpecialValuesTable<'txn, K, V> { fn insert(&mut self, key: K::SelfType<'_>, value: V::SelfType<'_>) { // Append to end of file let offset = self.file.seek(SeekFrom::End(0)).unwrap(); diff --git a/src/db.rs b/src/db.rs index c21e939e..924d297f 100644 --- a/src/db.rs +++ b/src/db.rs @@ -4,7 +4,7 @@ use crate::tree_store::{ InternalTableDefinition, PageHint, PageNumber, RawBtree, SerializedSavepoint, TableTreeMut, TableType, TransactionalMemory, PAGE_SIZE, }; -use crate::types::{RedbKey, Value}; +use crate::types::{Key, Value}; use crate::{ CompactionError, DatabaseError, Durability, ReadOnlyTable, SavepointError, StorageError, }; @@ -108,13 +108,13 @@ impl Sealed for UntypedMultimapTableHandle {} /// /// Note that the lifetime of the `K` and `V` type parameters does not impact the lifetimes of the data /// that is stored or retreived from the table -pub struct TableDefinition<'a, K: RedbKey + 'static, V: Value + 'static> { +pub struct TableDefinition<'a, K: Key + 'static, V: Value + 'static> { name: &'a str, _key_type: PhantomData, _value_type: PhantomData, } -impl<'a, K: RedbKey + 'static, V: Value + 'static> TableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> TableDefinition<'a, K, V> { /// Construct a new table with given `name` /// /// ## Invariant @@ -130,23 +130,23 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> TableDefinition<'a, K, V> { } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> TableHandle for TableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> TableHandle for TableDefinition<'a, K, V> { fn name(&self) -> &str { self.name } } -impl Sealed for TableDefinition<'_, K, V> {} +impl Sealed for TableDefinition<'_, K, V> {} -impl<'a, K: RedbKey + 'static, V: Value + 'static> Clone for TableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Clone for TableDefinition<'a, K, V> { fn clone(&self) -> Self { *self } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Copy for TableDefinition<'a, K, V> {} +impl<'a, K: Key + 'static, V: Value + 'static> Copy for TableDefinition<'a, K, V> {} -impl<'a, K: RedbKey + 'static, V: Value + 'static> Display for TableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Display for TableDefinition<'a, K, V> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, @@ -166,13 +166,13 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> Display for TableDefinition<' /// /// Note that the lifetime of the `K` and `V` type parameters does not impact the lifetimes of the data /// that is stored or retreived from the table -pub struct MultimapTableDefinition<'a, K: RedbKey + 'static, V: RedbKey + 'static> { +pub struct MultimapTableDefinition<'a, K: Key + 'static, V: Key + 'static> { name: &'a str, _key_type: PhantomData, _value_type: PhantomData, } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Key + 'static> MultimapTableDefinition<'a, K, V> { pub const fn new(name: &'a str) -> Self { assert!(!name.is_empty()); Self { @@ -183,7 +183,7 @@ impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTableDefinition<'a, } } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTableHandle +impl<'a, K: Key + 'static, V: Key + 'static> MultimapTableHandle for MultimapTableDefinition<'a, K, V> { fn name(&self) -> &str { @@ -191,17 +191,17 @@ impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTableHandle } } -impl Sealed for MultimapTableDefinition<'_, K, V> {} +impl Sealed for MultimapTableDefinition<'_, K, V> {} -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> Clone for MultimapTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Key + 'static> Clone for MultimapTableDefinition<'a, K, V> { fn clone(&self) -> Self { *self } } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> Copy for MultimapTableDefinition<'a, K, V> {} +impl<'a, K: Key + 'static, V: Key + 'static> Copy for MultimapTableDefinition<'a, K, V> {} -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> Display for MultimapTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Key + 'static> Display for MultimapTableDefinition<'a, K, V> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, diff --git a/src/lib.rs b/src/lib.rs index 49f9863c..65543649 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -71,7 +71,7 @@ pub use table::{ }; pub use transactions::{DatabaseStats, Durability, ReadTransaction, WriteTransaction}; pub use tree_store::{AccessGuard, AccessGuardMut, Savepoint}; -pub use types::{MutInPlaceValue, RedbKey, TypeName, Value}; +pub use types::{Key, MutInPlaceValue, TypeName, Value}; type Result = std::result::Result; diff --git a/src/multimap_table.rs b/src/multimap_table.rs index e9ab9982..cbb824d5 100644 --- a/src/multimap_table.rs +++ b/src/multimap_table.rs @@ -7,7 +7,7 @@ use crate::tree_store::{ BtreeStats, CachePriority, Checksum, LeafAccessor, LeafMutator, Page, PageHint, PageNumber, RawBtree, RawLeafBuilder, TransactionalMemory, UntypedBtreeMut, BRANCH, LEAF, MAX_VALUE_LENGTH, }; -use crate::types::{RedbKey, TypeName, Value}; +use crate::types::{Key, TypeName, Value}; use crate::{AccessGuard, MultimapTableHandle, Result, StorageError, WriteTransaction}; use std::borrow::Borrow; use std::cmp::max; @@ -475,7 +475,7 @@ impl DynamicCollection { } } -impl DynamicCollection { +impl DynamicCollection { fn iter<'a>( collection: AccessGuard<'a, &'static DynamicCollection>, guard: Arc, @@ -555,12 +555,12 @@ impl UntypedDynamicCollection { } } -enum ValueIterState<'a, V: RedbKey + 'static> { +enum ValueIterState<'a, V: Key + 'static> { Subtree(BtreeRangeIter), InlineLeaf(LeafKeyIter<'a, V>), } -pub struct MultimapValue<'a, V: RedbKey + 'static> { +pub struct MultimapValue<'a, V: Key + 'static> { inner: Option>, freed_pages: Option>>>, free_on_drop: Vec, @@ -569,7 +569,7 @@ pub struct MultimapValue<'a, V: RedbKey + 'static> { _value_type: PhantomData, } -impl<'a, V: RedbKey + 'static> MultimapValue<'a, V> { +impl<'a, V: Key + 'static> MultimapValue<'a, V> { fn new_subtree(inner: BtreeRangeIter, guard: Arc) -> Self { Self { inner: Some(ValueIterState::Subtree(inner)), @@ -610,7 +610,7 @@ impl<'a, V: RedbKey + 'static> MultimapValue<'a, V> { } } -impl<'a, V: RedbKey + 'static> Iterator for MultimapValue<'a, V> { +impl<'a, V: Key + 'static> Iterator for MultimapValue<'a, V> { type Item = Result>; fn next(&mut self) -> Option { @@ -628,7 +628,7 @@ impl<'a, V: RedbKey + 'static> Iterator for MultimapValue<'a, V> { } } -impl<'a, V: RedbKey + 'static> DoubleEndedIterator for MultimapValue<'a, V> { +impl<'a, V: Key + 'static> DoubleEndedIterator for MultimapValue<'a, V> { fn next_back(&mut self) -> Option { // TODO: optimize out this copy let bytes = match self.inner.as_mut().unwrap() { @@ -644,7 +644,7 @@ impl<'a, V: RedbKey + 'static> DoubleEndedIterator for MultimapValue<'a, V> { } } -impl<'a, V: RedbKey + 'static> Drop for MultimapValue<'a, V> { +impl<'a, V: Key + 'static> Drop for MultimapValue<'a, V> { fn drop(&mut self) { // Drop our references to the pages that are about to be freed drop(mem::take(&mut self.inner)); @@ -659,7 +659,7 @@ impl<'a, V: RedbKey + 'static> Drop for MultimapValue<'a, V> { } } -pub struct MultimapRange<'a, K: RedbKey + 'static, V: RedbKey + 'static> { +pub struct MultimapRange<'a, K: Key + 'static, V: Key + 'static> { inner: BtreeRangeIter>, mem: Arc, transaction_guard: Arc, @@ -668,7 +668,7 @@ pub struct MultimapRange<'a, K: RedbKey + 'static, V: RedbKey + 'static> { _lifetime: PhantomData<&'a ()>, } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapRange<'a, K, V> { +impl<'a, K: Key + 'static, V: Key + 'static> MultimapRange<'a, K, V> { fn new( inner: BtreeRangeIter>, guard: Arc, @@ -685,7 +685,7 @@ impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> MultimapRange<'a, K, V> { } } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> Iterator for MultimapRange<'a, K, V> { +impl<'a, K: Key + 'static, V: Key + 'static> Iterator for MultimapRange<'a, K, V> { type Item = Result<(AccessGuard<'a, K>, MultimapValue<'a, V>)>; fn next(&mut self) -> Option { @@ -708,9 +708,7 @@ impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> Iterator for MultimapRange< } } -impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> DoubleEndedIterator - for MultimapRange<'a, K, V> -{ +impl<'a, K: Key + 'static, V: Key + 'static> DoubleEndedIterator for MultimapRange<'a, K, V> { fn next_back(&mut self) -> Option { match self.inner.next_back()? { Ok(entry) => { @@ -734,7 +732,7 @@ impl<'a, K: RedbKey + 'static, V: RedbKey + 'static> DoubleEndedIterator /// A multimap table /// /// [Multimap tables](https://en.wikipedia.org/wiki/Multimap) may have multiple values associated with each key -pub struct MultimapTable<'txn, K: RedbKey + 'static, V: RedbKey + 'static> { +pub struct MultimapTable<'txn, K: Key + 'static, V: Key + 'static> { name: String, transaction: &'txn WriteTransaction, freed_pages: Arc>>, @@ -743,13 +741,13 @@ pub struct MultimapTable<'txn, K: RedbKey + 'static, V: RedbKey + 'static> { _value_type: PhantomData, } -impl MultimapTableHandle for MultimapTable<'_, K, V> { +impl MultimapTableHandle for MultimapTable<'_, K, V> { fn name(&self) -> &str { &self.name } } -impl<'txn, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTable<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Key + 'static> MultimapTable<'txn, K, V> { pub(crate) fn new( name: &str, table_root: Option<(PageNumber, Checksum)>, @@ -1101,7 +1099,7 @@ impl<'txn, K: RedbKey + 'static, V: RedbKey + 'static> MultimapTable<'txn, K, V> } } -impl<'txn, K: RedbKey + 'static, V: RedbKey + 'static> ReadableMultimapTable +impl<'txn, K: Key + 'static, V: Key + 'static> ReadableMultimapTable for MultimapTable<'txn, K, V> { /// Returns an iterator over all values for the given key. Values are in ascending order. @@ -1173,15 +1171,15 @@ impl<'txn, K: RedbKey + 'static, V: RedbKey + 'static> ReadableMultimapTable Sealed for MultimapTable<'_, K, V> {} +impl Sealed for MultimapTable<'_, K, V> {} -impl<'txn, K: RedbKey + 'static, V: RedbKey + 'static> Drop for MultimapTable<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Key + 'static> Drop for MultimapTable<'txn, K, V> { fn drop(&mut self) { self.transaction.close_table(&self.name, &self.tree); } } -pub trait ReadableMultimapTable: Sealed { +pub trait ReadableMultimapTable: Sealed { /// Returns an iterator over all values for the given key. Values are in ascending order. fn get<'a>(&self, key: impl Borrow>) -> Result> where @@ -1255,14 +1253,14 @@ impl ReadOnlyUntypedMultimapTable { } /// A read-only multimap table -pub struct ReadOnlyMultimapTable { +pub struct ReadOnlyMultimapTable { tree: Btree>, mem: Arc, transaction_guard: Arc, _value_type: PhantomData, } -impl ReadOnlyMultimapTable { +impl ReadOnlyMultimapTable { pub(crate) fn new( root_page: Option<(PageNumber, Checksum)>, hint: PageHint, @@ -1307,7 +1305,7 @@ impl ReadOnlyMultimapTable { } } -impl ReadableMultimapTable +impl ReadableMultimapTable for ReadOnlyMultimapTable { /// Returns an iterator over all values for the given key. Values are in ascending order. @@ -1375,4 +1373,4 @@ impl ReadableMultimapTable } } -impl Sealed for ReadOnlyMultimapTable {} +impl Sealed for ReadOnlyMultimapTable {} diff --git a/src/table.rs b/src/table.rs index 25ad414f..0d243d17 100644 --- a/src/table.rs +++ b/src/table.rs @@ -4,7 +4,7 @@ use crate::tree_store::{ AccessGuardMut, Btree, BtreeDrain, BtreeDrainFilter, BtreeMut, BtreeRangeIter, Checksum, PageHint, PageNumber, RawBtree, TransactionalMemory, MAX_VALUE_LENGTH, }; -use crate::types::{MutInPlaceValue, RedbKey, Value}; +use crate::types::{Key, MutInPlaceValue, Value}; use crate::{AccessGuard, StorageError, WriteTransaction}; use crate::{Result, TableHandle}; use std::borrow::Borrow; @@ -58,19 +58,19 @@ impl TableStats { } /// A table containing key-value mappings -pub struct Table<'txn, K: RedbKey + 'static, V: Value + 'static> { +pub struct Table<'txn, K: Key + 'static, V: Value + 'static> { name: String, transaction: &'txn WriteTransaction, tree: BtreeMut<'txn, K, V>, } -impl TableHandle for Table<'_, K, V> { +impl TableHandle for Table<'_, K, V> { fn name(&self) -> &str { &self.name } } -impl<'txn, K: RedbKey + 'static, V: Value + 'static> Table<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Value + 'static> Table<'txn, K, V> { pub(crate) fn new( name: &str, table_root: Option<(PageNumber, Checksum)>, @@ -193,7 +193,7 @@ impl<'txn, K: RedbKey + 'static, V: Value + 'static> Table<'txn, K, V> { } } -impl<'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V> { +impl<'txn, K: Key + 'static, V: MutInPlaceValue + 'static> Table<'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>( @@ -215,7 +215,7 @@ impl<'txn, K: RedbKey + 'static, V: MutInPlaceValue + 'static> Table<'txn, K, V> } } -impl<'txn, K: RedbKey + 'static, V: Value + 'static> ReadableTable for Table<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Value + 'static> ReadableTable for Table<'txn, K, V> { fn get<'a>(&self, key: impl Borrow>) -> Result>> where K: 'a, @@ -255,15 +255,15 @@ impl<'txn, K: RedbKey + 'static, V: Value + 'static> ReadableTable for Tab } } -impl Sealed for Table<'_, K, V> {} +impl Sealed for Table<'_, K, V> {} -impl<'txn, K: RedbKey + 'static, V: Value + 'static> Drop for Table<'txn, K, V> { +impl<'txn, K: Key + 'static, V: Value + 'static> Drop for Table<'txn, K, V> { fn drop(&mut self) { self.transaction.close_table(&self.name, &self.tree); } } -fn debug_helper( +fn debug_helper( f: &mut Formatter<'_>, name: &str, len: Result, @@ -306,13 +306,13 @@ fn debug_helper( Ok(()) } -impl Debug for Table<'_, K, V> { +impl Debug for Table<'_, K, V> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { debug_helper(f, &self.name, self.len(), self.first(), self.last()) } } -pub trait ReadableTable: Sealed { +pub trait ReadableTable: Sealed { /// Returns the value corresponding to the given key fn get<'a>(&self, key: impl Borrow>) -> Result>> where @@ -413,13 +413,13 @@ impl ReadOnlyUntypedTable { } /// A read-only table -pub struct ReadOnlyTable { +pub struct ReadOnlyTable { name: String, tree: Btree, transaction_guard: Arc, } -impl ReadOnlyTable { +impl ReadOnlyTable { pub(crate) fn new( name: String, root_page: Option<(PageNumber, Checksum)>, @@ -446,7 +446,7 @@ impl ReadOnlyTable { } } -impl ReadableTable for ReadOnlyTable { +impl ReadableTable for ReadOnlyTable { fn get<'a>(&self, key: impl Borrow>) -> Result>> where K: 'a, @@ -486,20 +486,20 @@ impl ReadableTable for ReadOnlyT } } -impl Sealed for ReadOnlyTable {} +impl Sealed for ReadOnlyTable {} -impl Debug for ReadOnlyTable { +impl Debug for ReadOnlyTable { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { debug_helper(f, &self.name, self.len(), self.first(), self.last()) } } -pub struct Drain<'a, K: RedbKey + 'static, V: Value + 'static> { +pub struct Drain<'a, K: Key + 'static, V: Value + 'static> { inner: BtreeDrain, _lifetime: PhantomData<&'a ()>, } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Drain<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Drain<'a, K, V> { fn new(inner: BtreeDrain) -> Self { Self { inner, @@ -508,7 +508,7 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> Drain<'a, K, V> { } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Iterator for Drain<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Iterator for Drain<'a, K, V> { type Item = Result<(AccessGuard<'a, K>, AccessGuard<'a, V>)>; fn next(&mut self) -> Option { @@ -522,7 +522,7 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> Iterator for Drain<'a, K, V> } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> DoubleEndedIterator for Drain<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> DoubleEndedIterator for Drain<'a, K, V> { fn next_back(&mut self) -> Option { let entry = self.inner.next_back()?; Some(entry.map(|entry| { @@ -536,7 +536,7 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> DoubleEndedIterator for Drain pub struct DrainFilter< 'a, - K: RedbKey + 'static, + K: Key + 'static, V: Value + 'static, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool, > { @@ -546,7 +546,7 @@ pub struct DrainFilter< impl< 'a, - K: RedbKey + 'static, + K: Key + 'static, V: Value + 'static, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool, > DrainFilter<'a, K, V, F> @@ -561,7 +561,7 @@ impl< impl< 'a, - K: RedbKey + 'static, + K: Key + 'static, V: Value + 'static, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool, > Iterator for DrainFilter<'a, K, V, F> @@ -581,7 +581,7 @@ impl< impl< 'a, - K: RedbKey + 'static, + K: Key + 'static, V: Value + 'static, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool, > DoubleEndedIterator for DrainFilter<'a, K, V, F> @@ -598,14 +598,14 @@ impl< } #[derive(Clone)] -pub struct Range<'a, K: RedbKey + 'static, V: Value + 'static> { +pub struct Range<'a, K: Key + 'static, V: Value + 'static> { inner: BtreeRangeIter, _transaction_guard: Arc, // TODO: replace with TransactionGuard? _lifetime: PhantomData<&'a ()>, } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Range<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Range<'a, K, V> { pub(super) fn new(inner: BtreeRangeIter, guard: Arc) -> Self { Self { inner, @@ -615,7 +615,7 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> Range<'a, K, V> { } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Iterator for Range<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Iterator for Range<'a, K, V> { type Item = Result<(AccessGuard<'a, K>, AccessGuard<'a, V>)>; fn next(&mut self) -> Option { @@ -630,7 +630,7 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> Iterator for Range<'a, K, V> } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> DoubleEndedIterator for Range<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> DoubleEndedIterator for Range<'a, K, V> { fn next_back(&mut self) -> Option { self.inner.next_back().map(|x| { x.map(|entry| { diff --git a/src/transaction_tracker.rs b/src/transaction_tracker.rs index ea5fde24..7dc2dd9c 100644 --- a/src/transaction_tracker.rs +++ b/src/transaction_tracker.rs @@ -1,5 +1,5 @@ use crate::tree_store::TransactionalMemory; -use crate::{RedbKey, Result, Savepoint, TypeName, Value}; +use crate::{Key, Result, Savepoint, TypeName, Value}; #[cfg(feature = "logging")] use log::info; use std::cmp::Ordering; @@ -76,7 +76,7 @@ impl Value for SavepointId { } } -impl RedbKey for SavepointId { +impl Key for SavepointId { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { Self::from_bytes(data1).0.cmp(&Self::from_bytes(data2).0) } diff --git a/src/transactions.rs b/src/transactions.rs index 1d81d906..dd8915d0 100644 --- a/src/transactions.rs +++ b/src/transactions.rs @@ -9,7 +9,7 @@ use crate::tree_store::{ PageNumber, SerializedSavepoint, TableTree, TableTreeMut, TableType, TransactionalMemory, MAX_VALUE_LENGTH, }; -use crate::types::{RedbKey, Value}; +use crate::types::{Key, Value}; use crate::{ AccessGuard, MultimapTable, MultimapTableDefinition, MultimapTableHandle, Range, ReadOnlyMultimapTable, ReadOnlyTable, Result, Savepoint, SavepointError, StorageError, Table, @@ -33,13 +33,13 @@ const NEXT_SAVEPOINT_TABLE: SystemTableDefinition<(), SavepointId> = pub(crate) const SAVEPOINT_TABLE: SystemTableDefinition = SystemTableDefinition::new("persistent_savepoints"); -pub struct SystemTableDefinition<'a, K: RedbKey + 'static, V: Value + 'static> { +pub struct SystemTableDefinition<'a, K: Key + 'static, V: Value + 'static> { name: &'a str, _key_type: PhantomData, _value_type: PhantomData, } -impl<'a, K: RedbKey + 'static, V: Value + 'static> SystemTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> SystemTableDefinition<'a, K, V> { pub const fn new(name: &'a str) -> Self { assert!(!name.is_empty()); Self { @@ -50,23 +50,23 @@ impl<'a, K: RedbKey + 'static, V: Value + 'static> SystemTableDefinition<'a, K, } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> TableHandle for SystemTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> TableHandle for SystemTableDefinition<'a, K, V> { fn name(&self) -> &str { self.name } } -impl Sealed for SystemTableDefinition<'_, K, V> {} +impl Sealed for SystemTableDefinition<'_, K, V> {} -impl<'a, K: RedbKey + 'static, V: Value + 'static> Clone for SystemTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Clone for SystemTableDefinition<'a, K, V> { fn clone(&self) -> Self { *self } } -impl<'a, K: RedbKey + 'static, V: Value + 'static> Copy for SystemTableDefinition<'a, K, V> {} +impl<'a, K: Key + 'static, V: Value + 'static> Copy for SystemTableDefinition<'a, K, V> {} -impl<'a, K: RedbKey + 'static, V: Value + 'static> Display for SystemTableDefinition<'a, K, V> { +impl<'a, K: Key + 'static, V: Value + 'static> Display for SystemTableDefinition<'a, K, V> { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { write!( f, @@ -190,14 +190,14 @@ pub enum Durability { } // Like a Table but only one may be open at a time to avoid possible races -pub struct SystemTable<'db, 's, K: RedbKey + 'static, V: Value + 'static> { +pub struct SystemTable<'db, 's, K: Key + 'static, V: Value + 'static> { name: String, namespace: &'s mut SystemNamespace<'db>, tree: BtreeMut<'s, K, V>, transaction_guard: Arc, } -impl<'db, 's, K: RedbKey + 'static, V: Value + 'static> SystemTable<'db, 's, K, V> { +impl<'db, 's, K: Key + 'static, V: Value + 'static> SystemTable<'db, 's, K, V> { fn new( name: &str, table_root: Option<(PageNumber, Checksum)>, @@ -258,7 +258,7 @@ impl<'db, 's, K: RedbKey + 'static, V: Value + 'static> SystemTable<'db, 's, K, } } -impl<'db, 's, K: RedbKey + 'static, V: Value + 'static> Drop for SystemTable<'db, 's, K, V> { +impl<'db, 's, K: Key + 'static, V: Value + 'static> Drop for SystemTable<'db, 's, K, V> { fn drop(&mut self) { self.namespace.close_table(&self.name, &self.tree); } @@ -270,7 +270,7 @@ struct SystemNamespace<'db> { } impl<'db> SystemNamespace<'db> { - fn open_system_table<'txn, 's, K: RedbKey + 'static, V: Value + 'static>( + fn open_system_table<'txn, 's, K: Key + 'static, V: Value + 'static>( &'s mut self, transaction: &'txn WriteTransaction, definition: SystemTableDefinition, @@ -295,7 +295,7 @@ impl<'db> SystemNamespace<'db> { )) } - fn close_table( + fn close_table( &mut self, name: &str, table: &BtreeMut, @@ -312,7 +312,7 @@ struct TableNamespace<'db> { impl<'db> TableNamespace<'db> { #[track_caller] - fn inner_open( + fn inner_open( &mut self, name: &str, table_type: TableType, @@ -331,7 +331,7 @@ impl<'db> TableNamespace<'db> { } #[track_caller] - pub fn open_multimap_table<'txn, K: RedbKey + 'static, V: RedbKey + 'static>( + pub fn open_multimap_table<'txn, K: Key + 'static, V: Key + 'static>( &mut self, transaction: &'txn WriteTransaction, definition: MultimapTableDefinition, @@ -351,7 +351,7 @@ impl<'db> TableNamespace<'db> { } #[track_caller] - pub fn open_table<'txn, K: RedbKey + 'static, V: Value + 'static>( + pub fn open_table<'txn, K: Key + 'static, V: Value + 'static>( &mut self, transaction: &'txn WriteTransaction, definition: TableDefinition, @@ -403,7 +403,7 @@ impl<'db> TableNamespace<'db> { self.inner_delete(name, TableType::Multimap) } - pub(crate) fn close_table( + pub(crate) fn close_table( &mut self, name: &str, table: &BtreeMut, @@ -784,7 +784,7 @@ impl WriteTransaction { /// /// The table will be created if it does not exist #[track_caller] - pub fn open_table<'txn, K: RedbKey + 'static, V: Value + 'static>( + pub fn open_table<'txn, K: Key + 'static, V: Value + 'static>( &'txn self, definition: TableDefinition, ) -> Result, TableError> { @@ -795,7 +795,7 @@ impl WriteTransaction { /// /// The table will be created if it does not exist #[track_caller] - pub fn open_multimap_table<'txn, K: RedbKey + 'static, V: RedbKey + 'static>( + pub fn open_multimap_table<'txn, K: Key + 'static, V: Key + 'static>( &'txn self, definition: MultimapTableDefinition, ) -> Result, TableError> { @@ -805,7 +805,7 @@ impl WriteTransaction { .open_multimap_table(self, definition) } - pub(crate) fn close_table( + pub(crate) fn close_table( &self, name: &str, table: &BtreeMut, @@ -1200,7 +1200,7 @@ impl ReadTransaction { } /// Open the given table - pub fn open_table( + pub fn open_table( &self, definition: TableDefinition, ) -> Result, TableError> { @@ -1237,7 +1237,7 @@ impl ReadTransaction { } /// Open the given table - pub fn open_multimap_table( + pub fn open_multimap_table( &self, definition: MultimapTableDefinition, ) -> Result, TableError> { diff --git a/src/tree_store/btree.rs b/src/tree_store/btree.rs index 6ba729c8..17ae9501 100644 --- a/src/tree_store/btree.rs +++ b/src/tree_store/btree.rs @@ -9,7 +9,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::{MutInPlaceValue, RedbKey, Value}; +use crate::types::{Key, MutInPlaceValue, Value}; use crate::{AccessGuard, Result}; #[cfg(feature = "logging")] use log::trace; @@ -217,7 +217,7 @@ impl UntypedBtreeMut { } } -pub(crate) struct BtreeMut<'a, K: RedbKey + 'static, V: Value + 'static> { +pub(crate) struct BtreeMut<'a, K: Key + 'static, V: Value + 'static> { mem: Arc, transaction_guard: Arc, root: Arc>>, @@ -227,7 +227,7 @@ pub(crate) struct BtreeMut<'a, K: RedbKey + 'static, V: Value + 'static> { _lifetime: PhantomData<&'a ()>, } -impl BtreeMut<'_, K, V> { +impl BtreeMut<'_, K, V> { pub(crate) fn new( root: Option<(PageNumber, Checksum)>, guard: Arc, @@ -440,7 +440,7 @@ impl BtreeMut<'_, K, V> { } } -impl<'a, K: RedbKey + 'a, V: MutInPlaceValue + 'a> BtreeMut<'a, K, V> { +impl<'a, K: Key + '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 @@ -552,7 +552,7 @@ impl RawBtree { } } -pub(crate) struct Btree { +pub(crate) struct Btree { mem: Arc, _transaction_guard: Arc, // Cache of the root page to avoid repeated lookups @@ -563,7 +563,7 @@ pub(crate) struct Btree { _value_type: PhantomData, } -impl Btree { +impl Btree { pub(crate) fn new( root: Option<(PageNumber, Checksum)>, hint: PageHint, diff --git a/src/tree_store/btree_base.rs b/src/tree_store/btree_base.rs index cabe36d0..74f52322 100644 --- a/src/tree_store/btree_base.rs +++ b/src/tree_store/btree_base.rs @@ -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::{MutInPlaceValue, RedbKey, Value}; +use crate::types::{Key, MutInPlaceValue, Value}; use crate::{Result, StorageError}; use std::cmp::Ordering; use std::marker::PhantomData; @@ -243,7 +243,7 @@ impl<'a> LeafAccessor<'a> { } } - pub(super) fn print_node(&self, include_value: bool) { + pub(super) fn print_node(&self, include_value: bool) { let mut i = 0; while let Some(entry) = self.entry(i) { eprint!(" key_{}={:?}", i, K::from_bytes(entry.key())); @@ -254,7 +254,7 @@ impl<'a> LeafAccessor<'a> { } } - pub(crate) fn position(&self, query: &[u8]) -> (usize, bool) { + pub(crate) fn position(&self, query: &[u8]) -> (usize, bool) { // inclusive let mut min_entry = 0; // inclusive. Start past end, since it might be positioned beyond the end of the leaf @@ -278,7 +278,7 @@ impl<'a> LeafAccessor<'a> { (min_entry, false) } - pub(crate) fn find_key(&self, query: &[u8]) -> Option { + pub(crate) fn find_key(&self, query: &[u8]) -> Option { let (entry, found) = self.position::(query); if found { Some(entry) @@ -1069,7 +1069,7 @@ impl<'a: 'b, 'b, T: Page + 'a> BranchAccessor<'a, 'b, T> { } } - pub(super) fn print_node(&self) { + pub(super) fn print_node(&self) { eprint!( "Internal[ (page={:?}), child_0={:?}", self.page.get_page_number(), @@ -1090,7 +1090,7 @@ impl<'a: 'b, 'b, T: Page + 'a> BranchAccessor<'a, 'b, T> { self.key_end(self.num_keys() - 1) } - pub(super) fn child_for_key(&self, query: &[u8]) -> (usize, PageNumber) { + pub(super) fn child_for_key(&self, query: &[u8]) -> (usize, PageNumber) { let mut min_child = 0; // inclusive let mut max_child = self.num_keys(); // inclusive while min_child < max_child { diff --git a/src/tree_store/btree_iters.rs b/src/tree_store/btree_iters.rs index 39ce4cd2..456a2a0b 100644 --- a/src/tree_store/btree_iters.rs +++ b/src/tree_store/btree_iters.rs @@ -3,7 +3,7 @@ use crate::tree_store::btree_base::{BRANCH, LEAF}; use crate::tree_store::btree_iters::RangeIterState::{Internal, Leaf}; use crate::tree_store::page_store::{Page, PageImpl, TransactionalMemory}; use crate::tree_store::PageNumber; -use crate::types::{RedbKey, Value}; +use crate::types::{Key, Value}; use crate::Result; use std::borrow::Borrow; use std::collections::Bound; @@ -123,7 +123,7 @@ impl RangeIterState { } } - fn get_entry(&self) -> Option> { + fn get_entry(&self) -> Option> { match self { Leaf { page, @@ -142,7 +142,7 @@ impl RangeIterState { } } -pub(crate) struct EntryGuard { +pub(crate) struct EntryGuard { page: PageImpl, key_range: Range, value_range: Range, @@ -150,7 +150,7 @@ pub(crate) struct EntryGuard { _value_type: PhantomData, } -impl EntryGuard { +impl EntryGuard { fn new(page: PageImpl, key_range: Range, value_range: Range) -> Self { Self { page, @@ -243,14 +243,14 @@ impl Iterator for AllPageNumbersBtreeIter { } } -pub(crate) struct BtreeDrain { +pub(crate) struct BtreeDrain { inner: BtreeRangeIter, free_on_drop: Vec, master_free_list: Arc>>, mem: Arc, } -impl BtreeDrain { +impl BtreeDrain { pub(crate) fn new( inner: BtreeRangeIter, free_on_drop: Vec, @@ -266,7 +266,7 @@ impl BtreeDrain { } } -impl Iterator for BtreeDrain { +impl Iterator for BtreeDrain { type Item = Result>; fn next(&mut self) -> Option { @@ -274,13 +274,13 @@ impl Iterator for BtreeDrain { } } -impl DoubleEndedIterator for BtreeDrain { +impl DoubleEndedIterator for BtreeDrain { fn next_back(&mut self) -> Option { self.inner.next_back() } } -impl Drop for BtreeDrain { +impl Drop for BtreeDrain { fn drop(&mut self) { // Ensure that the iter is entirely consumed, so that it doesn't have any references to the pages // to be freed @@ -298,7 +298,7 @@ impl Drop for BtreeDrain { } pub(crate) struct BtreeDrainFilter< - K: RedbKey + 'static, + K: Key + 'static, V: Value + 'static, F: for<'f> FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool, > { @@ -309,7 +309,7 @@ pub(crate) struct BtreeDrainFilter< mem: Arc, } -impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> +impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> BtreeDrainFilter { pub(crate) fn new( @@ -329,7 +329,7 @@ impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> } } -impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> Iterator +impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> Iterator for BtreeDrainFilter { type Item = Result>; @@ -346,7 +346,7 @@ impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> } } -impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> +impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> DoubleEndedIterator for BtreeDrainFilter { fn next_back(&mut self) -> Option { @@ -361,7 +361,7 @@ impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> } } -impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> Drop +impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> bool> Drop for BtreeDrainFilter { fn drop(&mut self) { @@ -381,7 +381,7 @@ impl FnMut(K::SelfType<'f>, V::SelfType<'f>) -> } #[derive(Clone)] -pub(crate) struct BtreeRangeIter { +pub(crate) struct BtreeRangeIter { left: Option, // Exclusive. The previous element returned right: Option, // Exclusive. The previous element returned include_left: bool, // left is inclusive, instead of exclusive @@ -391,7 +391,7 @@ pub(crate) struct BtreeRangeIter { _value_type: PhantomData, } -impl BtreeRangeIter { +impl BtreeRangeIter { pub(crate) fn new<'a, T: RangeBounds, KR: Borrow>>( query_range: &'_ T, table_root: Option, @@ -467,7 +467,7 @@ impl BtreeRangeIter { } } -impl Iterator for BtreeRangeIter { +impl Iterator for BtreeRangeIter { type Item = Result>; fn next(&mut self) -> Option { @@ -535,7 +535,7 @@ impl Iterator for BtreeRangeIter { } } -impl DoubleEndedIterator for BtreeRangeIter { +impl DoubleEndedIterator for BtreeRangeIter { fn next_back(&mut self) -> Option { if let ( Some(Leaf { @@ -601,7 +601,7 @@ impl DoubleEndedIterator for BtreeRangeIter { } } -fn find_iter_unbounded( +fn find_iter_unbounded( page: PageImpl, mut parent: Option>, reverse: bool, @@ -647,7 +647,7 @@ fn find_iter_unbounded( // Returns a bool indicating whether the first entry pointed to by the state is included in the // queried range -fn find_iter_left( +fn find_iter_left( page: PageImpl, mut parent: Option>, query: &[u8], @@ -695,7 +695,7 @@ fn find_iter_left( } } -fn find_iter_right( +fn find_iter_right( page: PageImpl, mut parent: Option>, query: &[u8], diff --git a/src/tree_store/btree_mutator.rs b/src/tree_store/btree_mutator.rs index ec31037a..b1bdcfbd 100644 --- a/src/tree_store/btree_mutator.rs +++ b/src/tree_store/btree_mutator.rs @@ -7,7 +7,7 @@ use crate::tree_store::btree_mutator::DeletionResult::{ }; use crate::tree_store::page_store::{Page, PageImpl}; use crate::tree_store::{AccessGuardMut, PageNumber, RawLeafBuilder, TransactionalMemory}; -use crate::types::{RedbKey, Value}; +use crate::types::{Key, Value}; use crate::{AccessGuard, Result}; use std::cmp::{max, min}; use std::marker::PhantomData; @@ -44,7 +44,7 @@ struct InsertionResult<'a, V: Value> { old_value: Option>, } -pub(crate) struct MutateHelper<'a, 'b, K: RedbKey, V: Value> { +pub(crate) struct MutateHelper<'a, 'b, K: Key, V: Value> { root: &'b mut Option<(PageNumber, Checksum)>, modify_uncommitted: bool, mem: Arc, @@ -54,7 +54,7 @@ pub(crate) struct MutateHelper<'a, 'b, K: RedbKey, V: Value> { _lifetime: PhantomData<&'a ()>, } -impl<'a, 'b, K: RedbKey, V: Value> MutateHelper<'a, 'b, K, V> { +impl<'a, 'b, K: Key, V: Value> MutateHelper<'a, 'b, K, V> { pub(crate) fn new( root: &'b mut Option<(PageNumber, Checksum)>, mem: Arc, diff --git a/src/tree_store/table_tree.rs b/src/tree_store/table_tree.rs index a7d6cce9..7b33b7c3 100644 --- a/src/tree_store/table_tree.rs +++ b/src/tree_store/table_tree.rs @@ -9,7 +9,7 @@ use crate::tree_store::btree_iters::AllPageNumbersBtreeIter; use crate::tree_store::{ Btree, BtreeMut, BtreeRangeIter, PageHint, PageNumber, RawBtree, TransactionalMemory, }; -use crate::types::{MutInPlaceValue, RedbKey, TypeName, Value}; +use crate::types::{Key, MutInPlaceValue, TypeName, Value}; use crate::{DatabaseStats, Result}; use std::cmp::max; use std::collections::{HashMap, HashSet}; @@ -68,7 +68,7 @@ impl Value for FreedTableKey { } } -impl RedbKey for FreedTableKey { +impl Key for FreedTableKey { fn compare(data1: &[u8], data2: &[u8]) -> std::cmp::Ordering { let value1 = Self::from_bytes(data1); let value2 = Self::from_bytes(data2); @@ -475,7 +475,7 @@ impl TableTree { } // root_page: the root of the master table - pub(crate) fn get_table( + pub(crate) fn get_table( &self, name: &str, table_type: TableType, @@ -697,7 +697,7 @@ impl<'txn> TableTreeMut<'txn> { } // root_page: the root of the master table - pub(crate) fn get_table( + pub(crate) fn get_table( &self, name: &str, table_type: TableType, @@ -750,7 +750,7 @@ impl<'txn> TableTreeMut<'txn> { // Returns a tuple of the table id and the new root page // root_page: the root of the master table - pub(crate) fn get_or_create_table( + pub(crate) fn get_or_create_table( &mut self, name: &str, table_type: TableType, diff --git a/src/tuple_types.rs b/src/tuple_types.rs index 499f16b4..2838303c 100644 --- a/src/tuple_types.rs +++ b/src/tuple_types.rs @@ -1,4 +1,4 @@ -use crate::types::{RedbKey, TypeName, Value}; +use crate::types::{Key, TypeName, Value}; use std::borrow::Borrow; use std::cmp::Ordering; use std::mem::size_of; @@ -34,7 +34,7 @@ fn parse_lens(data: &[u8]) -> [usize; N] { result } -fn not_equal(data1: &[u8], data2: &[u8]) -> Option { +fn not_equal(data1: &[u8], data2: &[u8]) -> Option { match T::compare(data1, data2) { Ordering::Less => Some(Ordering::Less), Ordering::Equal => None, @@ -223,7 +223,7 @@ macro_rules! tuple_impl { } } - impl<$($t: RedbKey,)+ $t_last: RedbKey> RedbKey for ($($t,)+ $t_last) { + impl<$($t: Key,)+ $t_last: Key> Key for ($($t,)+ $t_last) { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { if Self::fixed_width().is_some() { compare_fixed_impl!(data1, data2, $($t,)+ $t_last) diff --git a/src/types.rs b/src/types.rs index 1b65b945..9371bf14 100644 --- a/src/types.rs +++ b/src/types.rs @@ -124,7 +124,7 @@ impl MutInPlaceValue for &[u8] { } } -pub trait RedbKey: Value { +pub trait Key: Value { /// Compare data1 with data2 fn compare(data1: &[u8], data2: &[u8]) -> Ordering; } @@ -162,7 +162,7 @@ impl Value for () { } } -impl RedbKey for () { +impl Key for () { fn compare(_data1: &[u8], _data2: &[u8]) -> Ordering { Ordering::Equal } @@ -207,7 +207,7 @@ impl Value for bool { } } -impl RedbKey for bool { +impl Key for bool { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { let value1 = Self::from_bytes(data1); let value2 = Self::from_bytes(data2); @@ -258,7 +258,7 @@ impl Value for Option { } } -impl RedbKey for Option { +impl Key for Option { #[allow(clippy::collapsible_else_if)] fn compare(data1: &[u8], data2: &[u8]) -> Ordering { if data1[0] == 0 { @@ -309,7 +309,7 @@ impl Value for &[u8] { } } -impl RedbKey for &[u8] { +impl Key for &[u8] { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { data1.cmp(data2) } @@ -347,7 +347,7 @@ impl Value for &[u8; N] { } } -impl RedbKey for &[u8; N] { +impl Key for &[u8; N] { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { data1.cmp(data2) } @@ -385,7 +385,7 @@ impl Value for &str { } } -impl RedbKey for &str { +impl Key for &str { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { let str1 = Self::from_bytes(data1); let str2 = Self::from_bytes(data2); @@ -422,7 +422,7 @@ impl Value for char { } } -impl RedbKey for char { +impl Key for char { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { Self::from_bytes(data1).cmp(&Self::from_bytes(data2)) } @@ -466,7 +466,7 @@ macro_rules! le_impl { ($t:ty) => { le_value!($t); - impl RedbKey for $t { + impl Key for $t { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { Self::from_bytes(data1).cmp(&Self::from_bytes(data2)) } diff --git a/tests/backward_compatibility.rs b/tests/backward_compatibility.rs index f3852a33..cdb392c1 100644 --- a/tests/backward_compatibility.rs +++ b/tests/backward_compatibility.rs @@ -196,7 +196,7 @@ fn create_tempfile() -> tempfile::NamedTempFile { } } -fn test_helper() { +fn test_helper() { let tmpfile = create_tempfile(); let db = redb1::Database::create(tmpfile.path()).unwrap(); let table_def: redb1::TableDefinition = redb1::TableDefinition::new("table"); diff --git a/tests/basic_tests.rs b/tests/basic_tests.rs index b622a78e..97532c6f 100644 --- a/tests/basic_tests.rs +++ b/tests/basic_tests.rs @@ -1,6 +1,6 @@ use redb::backends::InMemoryBackend; use redb::{ - Database, MultimapTableDefinition, MultimapTableHandle, Range, ReadableTable, RedbKey, + Database, Key, MultimapTableDefinition, MultimapTableHandle, Range, ReadableTable, TableDefinition, TableError, TableHandle, TypeName, Value, }; use std::cmp::Ordering; @@ -1378,7 +1378,7 @@ fn custom_ordering() { } } - impl RedbKey for ReverseKey { + impl Key for ReverseKey { fn compare(data1: &[u8], data2: &[u8]) -> Ordering { data2.cmp(data1) } @@ -1632,7 +1632,7 @@ fn signature_lifetimes() { #[test] fn generic_signature_lifetimes() { - fn write_key_generic( + fn write_key_generic( table: TableDefinition, key: K::SelfType<'_>, db: &Database, @@ -1646,7 +1646,7 @@ fn generic_signature_lifetimes() { write_txn.commit().unwrap(); } - fn read_key_generic( + fn read_key_generic( table: TableDefinition, key: K::SelfType<'_>, db: &Database,