Xuanwo commented on code in PR #5208:
URL: https://github.com/apache/opendal/pull/5208#discussion_r1810519200
##########
core/src/raw/adapters/kv/api.rs:
##########
@@ -25,10 +26,69 @@ use crate::Capability;
use crate::Scheme;
use crate::*;
+/// ScanIter is the async iterator returned by `Adapter::scan`.
+pub trait Scan: Send + Sync + Unpin {
+ /// Fetch the next key in the current key prefix
+ ///
+ /// `None` means no further key will be returned
+ fn next(&mut self) -> impl Future<Output = Option<Result<String>>> +
MaybeSend;
Review Comment:
Let's return `Result<Option<String>>` instead to make it easier to handling
errors.
##########
core/src/raw/adapters/kv/api.rs:
##########
@@ -25,10 +26,69 @@ use crate::Capability;
use crate::Scheme;
use crate::*;
+/// ScanIter is the async iterator returned by `Adapter::scan`.
Review Comment:
Please also update the comment.
##########
core/src/raw/adapters/kv/api.rs:
##########
@@ -25,10 +26,69 @@ use crate::Capability;
use crate::Scheme;
use crate::*;
+/// ScanIter is the async iterator returned by `Adapter::scan`.
+pub trait Scan: Send + Sync + Unpin {
+ /// Fetch the next key in the current key prefix
+ ///
+ /// `None` means no further key will be returned
+ fn next(&mut self) -> impl Future<Output = Option<Result<String>>> +
MaybeSend;
+}
+
+/// A noop implementation of Scan
+impl Scan for () {
+ async fn next(&mut self) -> Option<Result<String>> {
+ None
+ }
+}
+
+/// A ScanIterator implementation for all trivial non-async iterators
Review Comment:
I feel that this is unnecessary. The service should provide their own
scanner when needed. Ideally, service should perform real IO inside scanner
instead of in the `scan` call.
For example, mysql service should build connection / sending query inside
the first `next` call in scanner.
##########
core/src/raw/adapters/kv/mod.rs:
##########
@@ -22,6 +22,9 @@
mod api;
pub use api::Adapter;
pub use api::Metadata;
+pub use api::Scan;
+pub use api::ScanStdIter;
Review Comment:
I wish we won't expose this.
##########
core/src/services/sqlite/backend.rs:
##########
@@ -188,7 +195,35 @@ impl Adapter {
}
}
+#[self_referencing]
+pub struct SqlStream {
Review Comment:
How about following the same name pattern like `SqliteScanner`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]