You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2024/04/23 16:13:18 UTC
(opendal) 01/01: feat: Add docs for read_with and reader_with
This is an automated email from the ASF dual-hosted git repository.
xuanwo pushed a commit to branch polish-docs-for-reader
in repository https://gitbox.apache.org/repos/asf/opendal.git
commit 3666b414d8db5262c6cb2e812295e4741142b1f2
Author: Xuanwo <gi...@xuanwo.io>
AuthorDate: Wed Apr 24 00:12:58 2024 +0800
feat: Add docs for read_with and reader_with
Signed-off-by: Xuanwo <gi...@xuanwo.io>
---
core/src/types/operator/operator.rs | 78 ++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 2 deletions(-)
diff --git a/core/src/types/operator/operator.rs b/core/src/types/operator/operator.rs
index ecc8935459..fc8eb36739 100644
--- a/core/src/types/operator/operator.rs
+++ b/core/src/types/operator/operator.rs
@@ -479,6 +479,43 @@ impl Operator {
/// # }
/// ```
///
+ /// ## `concurrent`
+ ///
+ /// Set `concurrent` for the reader.
+ ///
+ /// OpenDAL by default to write file without concurrent. This is not efficient for cases when users
+ /// read large chunks of data. By setting `concurrent`, opendal will reading files concurrently
+ /// on support storage services.
+ ///
+ /// By setting `concurrent``, opendal will fetch chunks concurrently with
+ /// the give chunk size.
+ ///
+ /// ```no_run
+ /// # use opendal::Result;
+ /// # use opendal::Operator;
+ /// # use opendal::Scheme;
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// let r = op.read_with("path/to/file").concurrent(8).await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
+ /// ## `chunk`
+ ///
+ /// OpenDAL will use services' preferred chunk size by default. Users can set chunk based on their own needs.
+ ///
+ /// This following example will make opendal read data in 4MiB chunks:
+ ///
+ /// ```no_run
+ /// # use opendal::Result;
+ /// # use opendal::Operator;
+ /// # use opendal::Scheme;
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// let r = op.read_with("path/to/file").chunk(4 * 1024 * 1024).await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
/// # Examples
///
/// Read the whole path into a bytes.
@@ -525,7 +562,7 @@ impl Operator {
/// ## Extra Options
///
/// [`Operator::reader`] is a wrapper of [`Operator::reader_with`] without any options. To use
- /// extra options like `range` and `if_match`, please use [`Operator::reader_with`] instead.
+ /// extra options like `concurrent`, please use [`Operator::reader_with`] instead.
///
/// # Examples
///
@@ -550,10 +587,47 @@ impl Operator {
/// ## Extra Options
///
/// [`Operator::reader`] is a wrapper of [`Operator::reader_with`] without any options. To use
- /// extra options like `range` and `if_match`, please use [`Operator::reader_with`] instead.
+ /// extra options like `version`, please use [`Operator::reader_with`] instead.
///
/// # Options
///
+ /// ## `concurrent`
+ ///
+ /// Set `concurrent` for the reader.
+ ///
+ /// OpenDAL by default to write file without concurrent. This is not efficient for cases when users
+ /// read large chunks of data. By setting `concurrent`, opendal will reading files concurrently
+ /// on support storage services.
+ ///
+ /// By setting `concurrent``, opendal will fetch chunks concurrently with
+ /// the give chunk size.
+ ///
+ /// ```no_run
+ /// # use opendal::Result;
+ /// # use opendal::Operator;
+ /// # use opendal::Scheme;
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// let r = op.reader_with("path/to/file").concurrent(8).await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
+ /// ## `chunk`
+ ///
+ /// OpenDAL will use services' preferred chunk size by default. Users can set chunk based on their own needs.
+ ///
+ /// This following example will make opendal read data in 4MiB chunks:
+ ///
+ /// ```no_run
+ /// # use opendal::Result;
+ /// # use opendal::Operator;
+ /// # use opendal::Scheme;
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// let r = op.reader_with("path/to/file").chunk(4 * 1024 * 1024).await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ ///
/// # Examples
///
/// ```no_run