mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 19:49:28 +00:00
remove get_range
This commit is contained in:
parent
01150ab84c
commit
7200dc08ba
5 changed files with 24 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
//! Implementation of `trait Database` for `heed`.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::{cell::RefCell, ops::RangeBounds};
|
||||
use std::cell::RefCell;
|
||||
|
||||
use crate::{
|
||||
backend::heed::types::HeedDb,
|
||||
|
@ -96,6 +96,7 @@ fn is_empty<T: Table>(
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- DatabaseIter Impl
|
||||
impl<T: Table> DatabaseIter<T> for HeedTableRo<'_, T> {
|
||||
/*
|
||||
#[inline]
|
||||
fn get_range<'a, Range>(
|
||||
&'a self,
|
||||
|
@ -107,6 +108,8 @@ impl<T: Table> DatabaseIter<T> for HeedTableRo<'_, T> {
|
|||
Ok(self.db.range(self.tx_ro, &range)?.map(|res| Ok(res?.1)))
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
#[inline]
|
||||
fn iter(
|
||||
&self,
|
||||
|
|
|
@ -65,6 +65,7 @@ fn is_empty<T: Table>(
|
|||
|
||||
//---------------------------------------------------------------------------------------------------- DatabaseIter
|
||||
impl<T: Table + 'static> DatabaseIter<T> for RedbTableRo<T::Key, T::Value> {
|
||||
/*
|
||||
#[inline]
|
||||
fn get_range<'a, Range>(
|
||||
&'a self,
|
||||
|
@ -79,6 +80,8 @@ impl<T: Table + 'static> DatabaseIter<T> for RedbTableRo<T::Key, T::Value> {
|
|||
}))
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
#[inline]
|
||||
fn iter(
|
||||
&self,
|
||||
|
|
|
@ -34,8 +34,14 @@ impl<T> redb::Value for StorableRedb<T>
|
|||
where
|
||||
T: Storable + 'static,
|
||||
{
|
||||
type SelfType<'a> = T where Self: 'a;
|
||||
type AsBytes<'a> = &'a [u8] where Self: 'a;
|
||||
type SelfType<'a>
|
||||
= T
|
||||
where
|
||||
Self: 'a;
|
||||
type AsBytes<'a>
|
||||
= &'a [u8]
|
||||
where
|
||||
Self: 'a;
|
||||
|
||||
#[inline]
|
||||
fn fixed_width() -> Option<usize> {
|
||||
|
|
|
@ -225,7 +225,7 @@ fn db_read_write() {
|
|||
|
||||
// Assert the whole range is there.
|
||||
{
|
||||
let range = table_ro.get_range(..).unwrap();
|
||||
let range = table_ro.values().unwrap();
|
||||
let mut i = 0;
|
||||
for result in range {
|
||||
let value = result.unwrap();
|
||||
|
@ -241,14 +241,11 @@ fn db_read_write() {
|
|||
let range = KEY..key;
|
||||
|
||||
// Assert count is correct.
|
||||
assert_eq!(
|
||||
N as usize,
|
||||
table_ro.get_range(range.clone()).unwrap().count()
|
||||
);
|
||||
assert_eq!(N as usize, table_ro.values().unwrap().count());
|
||||
|
||||
// Assert each returned value from the iterator is owned.
|
||||
{
|
||||
let mut iter = table_ro.get_range(range.clone()).unwrap();
|
||||
let mut iter = table_ro.values().unwrap();
|
||||
let value = iter.next().unwrap().unwrap(); // 1. take value out
|
||||
drop(iter); // 2. drop the `impl Iterator + 'a`
|
||||
assert_value(value); // 3. assert even without the iterator, the value is alive
|
||||
|
@ -256,7 +253,7 @@ fn db_read_write() {
|
|||
|
||||
// Assert each value is the same.
|
||||
{
|
||||
let mut iter = table_ro.get_range(range).unwrap();
|
||||
let mut iter = table_ro.values().unwrap();
|
||||
for _ in 0..N {
|
||||
let value = iter.next().unwrap().unwrap();
|
||||
assert_value(value);
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
//! Abstracted database table operations; `trait DatabaseRo` & `trait DatabaseRw`.
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- Import
|
||||
use std::ops::RangeBounds;
|
||||
|
||||
use crate::{error::RuntimeError, table::Table};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------- DatabaseIter
|
||||
|
@ -32,6 +30,9 @@ Each iteration of the iterator has the potential to error as well."
|
|||
/// - <https://github.com/Cuprate/cuprate/pull/102#discussion_r1548695610>
|
||||
/// - <https://github.com/Cuprate/cuprate/pull/104>
|
||||
pub trait DatabaseIter<T: Table> {
|
||||
/*
|
||||
FIXME: <https://github.com/Cuprate/cuprate/issues/348>
|
||||
|
||||
/// Get an [`Iterator`] of value's corresponding to a range of keys.
|
||||
///
|
||||
/// For example:
|
||||
|
@ -52,6 +53,8 @@ pub trait DatabaseIter<T: Table> {
|
|||
where
|
||||
Range: RangeBounds<T::Key> + 'a;
|
||||
|
||||
*/
|
||||
|
||||
/// Get an [`Iterator`] that returns the `(key, value)` types for this database.
|
||||
#[doc = doc_iter!()]
|
||||
#[expect(clippy::iter_not_returning_iterator)]
|
||||
|
|
Loading…
Reference in a new issue