mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-26 02:17:34 +00:00
Unbox and pin database streams.
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
1 parent
98affbdeaf
commit
71f3ccf140
26 files changed
+217
-166
No files matched your search
+15
-13
@@ -1,6 +1,6 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt};
|
||||
use futures::{FutureExt, Stream, StreamExt, TryFutureExt, TryStreamExt, future::Either};
|
||||
use rocksdb::Direction;
|
||||
use serde::Deserialize;
|
||||
use tokio::task;
|
||||
@@ -27,11 +27,12 @@ pub fn raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + Send
|
||||
let state = stream::State::new(self, opts);
|
||||
if is_cached(self) {
|
||||
let state = state.init_fwd(None);
|
||||
return task::consume_budget()
|
||||
.map(move |()| stream::Keys::<'_>::from(state))
|
||||
.into_stream()
|
||||
.flatten()
|
||||
.boxed();
|
||||
return Either::Left(
|
||||
task::consume_budget()
|
||||
.map(move |()| stream::Keys::<'_>::from(state))
|
||||
.into_stream()
|
||||
.flatten(),
|
||||
);
|
||||
}
|
||||
|
||||
let seek = Seek {
|
||||
@@ -42,11 +43,12 @@ pub fn raw_keys(self: &Arc<Self>) -> impl Stream<Item = Result<Key<'_>>> + Send
|
||||
res: None,
|
||||
};
|
||||
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Keys<'_>>()
|
||||
.into_stream()
|
||||
.try_flatten()
|
||||
.boxed()
|
||||
Either::Right(
|
||||
self.engine
|
||||
.pool
|
||||
.execute_iter(seek)
|
||||
.ok_into::<stream::Keys<'_>>()
|
||||
.into_stream()
|
||||
.try_flatten(),
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user