offload initial iterator seeks to threadpool
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
320b0680bd
commit
b5006a4c41
20 changed files with 361 additions and 131 deletions
|
@ -1,4 +1,4 @@
|
|||
use std::{pin::Pin, sync::Arc};
|
||||
use std::{convert, pin::Pin, sync::Arc};
|
||||
|
||||
use conduit::Result;
|
||||
use futures::{
|
||||
|
@ -16,9 +16,17 @@ pub(crate) struct Items<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Items<'a> {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions, from: From<'_>) -> Self {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
|
||||
Self {
|
||||
state: State::new(db, cf, opts).init_fwd(from),
|
||||
state: State::new(db, cf, opts),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::From<State<'a>> for Items<'a> {
|
||||
fn from(state: State<'a>) -> Self {
|
||||
Self {
|
||||
state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +38,13 @@ impl<'a> Cursor<'a, KeyVal<'a>> for Items<'a> {
|
|||
|
||||
#[inline]
|
||||
fn seek(&mut self) { self.state.seek_fwd(); }
|
||||
|
||||
#[inline]
|
||||
fn init(self, from: From<'a>) -> Self {
|
||||
Self {
|
||||
state: self.state.init_fwd(from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stream for Items<'a> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{pin::Pin, sync::Arc};
|
||||
use std::{convert, pin::Pin, sync::Arc};
|
||||
|
||||
use conduit::Result;
|
||||
use futures::{
|
||||
|
@ -16,9 +16,17 @@ pub(crate) struct ItemsRev<'a> {
|
|||
}
|
||||
|
||||
impl<'a> ItemsRev<'a> {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions, from: From<'_>) -> Self {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
|
||||
Self {
|
||||
state: State::new(db, cf, opts).init_rev(from),
|
||||
state: State::new(db, cf, opts),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::From<State<'a>> for ItemsRev<'a> {
|
||||
fn from(state: State<'a>) -> Self {
|
||||
Self {
|
||||
state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,6 +38,13 @@ impl<'a> Cursor<'a, KeyVal<'a>> for ItemsRev<'a> {
|
|||
|
||||
#[inline]
|
||||
fn seek(&mut self) { self.state.seek_rev(); }
|
||||
|
||||
#[inline]
|
||||
fn init(self, from: From<'a>) -> Self {
|
||||
Self {
|
||||
state: self.state.init_rev(from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stream for ItemsRev<'a> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{pin::Pin, sync::Arc};
|
||||
use std::{convert, pin::Pin, sync::Arc};
|
||||
|
||||
use conduit::Result;
|
||||
use futures::{
|
||||
|
@ -16,9 +16,17 @@ pub(crate) struct Keys<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Keys<'a> {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions, from: From<'_>) -> Self {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
|
||||
Self {
|
||||
state: State::new(db, cf, opts).init_fwd(from),
|
||||
state: State::new(db, cf, opts),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::From<State<'a>> for Keys<'a> {
|
||||
fn from(state: State<'a>) -> Self {
|
||||
Self {
|
||||
state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +39,13 @@ impl<'a> Cursor<'a, Key<'a>> for Keys<'a> {
|
|||
|
||||
#[inline]
|
||||
fn seek(&mut self) { self.state.seek_fwd(); }
|
||||
|
||||
#[inline]
|
||||
fn init(self, from: From<'a>) -> Self {
|
||||
Self {
|
||||
state: self.state.init_fwd(from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stream for Keys<'a> {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{pin::Pin, sync::Arc};
|
||||
use std::{convert, pin::Pin, sync::Arc};
|
||||
|
||||
use conduit::Result;
|
||||
use futures::{
|
||||
|
@ -16,9 +16,17 @@ pub(crate) struct KeysRev<'a> {
|
|||
}
|
||||
|
||||
impl<'a> KeysRev<'a> {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions, from: From<'_>) -> Self {
|
||||
pub(crate) fn new(db: &'a Arc<Engine>, cf: &'a Arc<ColumnFamily>, opts: ReadOptions) -> Self {
|
||||
Self {
|
||||
state: State::new(db, cf, opts).init_rev(from),
|
||||
state: State::new(db, cf, opts),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> convert::From<State<'a>> for KeysRev<'a> {
|
||||
fn from(state: State<'a>) -> Self {
|
||||
Self {
|
||||
state,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +39,13 @@ impl<'a> Cursor<'a, Key<'a>> for KeysRev<'a> {
|
|||
|
||||
#[inline]
|
||||
fn seek(&mut self) { self.state.seek_rev(); }
|
||||
|
||||
#[inline]
|
||||
fn init(self, from: From<'a>) -> Self {
|
||||
Self {
|
||||
state: self.state.init_rev(from),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stream for KeysRev<'a> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue