You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "suyanhanx (via GitHub)" <gi...@apache.org> on 2023/04/02 13:35:58 UTC
[GitHub] [incubator-opendal] suyanhanx opened a new pull request, #1841: feat(core): basic copy
suyanhanx opened a new pull request, #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841
This is still a draft. Need a lot of things to do.
Did I miss something? I can't call the override parts. @Xuanwo
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#issuecomment-1493791338
> As a new capability, I intend to add a new behavioral test.
This PR is good enough to be merged. Maybe we can add behavior test in next PR?
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155530271
##########
core/src/services/fs/backend.rs:
##########
@@ -441,6 +441,17 @@ impl Accessor for FsBackend {
Ok((RpWrite::new(), FsWriter::new(target_path, tmp_path, f)))
}
+ async fn copy(&self, from: &str, to: &str, _args: OpCopy) -> Result<RpCopy> {
Review Comment:
Make sense.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155431486
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,59 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ ///
+ /// # Notes
+ ///
+ /// - `from` and `to` must be a file.
+ /// - `to` will be overwritten if it exists.
+ /// - If `from` and `to` are the same, nothing will happen.
+ /// - `copy` is idempotent. For same `from` and `to` input, the result will be the same.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use std::io::Result;
+ /// # use opendal::Operator;
+ ///
+ /// # #[tokio::main]
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// op.copy("path/to/file", "path/to/file2").await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
+ if from == to {
+ return Ok(());
+ }
Review Comment:
Same above.
In a normal POSIX copy, if the from and to are the same, the contents of this file will simply be cleared.
Do we want to keep this behavior?
Other backends don't necessarily behave this way. So I simply return directly.
##########
core/src/services/fs/backend.rs:
##########
@@ -441,6 +441,17 @@ impl Accessor for FsBackend {
Ok((RpWrite::new(), FsWriter::new(target_path, tmp_path, f)))
}
+ async fn copy(&self, from: &str, to: &str, _args: OpCopy) -> Result<RpCopy> {
Review Comment:
Some operations may behave differently between our different backends.
For example, for POSIX copy, if the parent path to does not exist, it will report an error, while s3 will use the normal write for our subsequent implementation because it does not provide a copy operation, at which point it will automatically create the path.
So the question is, do we need to standardize the behaviour of these operations, e.g., create all the parent paths automatically?
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155351109
##########
core/src/layers/logging.rs:
##########
@@ -322,6 +322,47 @@ impl<A: Accessor> LayeredAccessor for LoggingAccessor<A> {
})
}
+ async fn copy(&self, from: &str, to: &str, args: OpCopy) -> Result<RpCopy> {
Review Comment:
It's not meant to be done all at once. I just saw it used in the example, so I wanted to test it together by the way.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155350741
##########
core/examples/object.rs:
##########
@@ -31,7 +31,8 @@ async fn main() -> Result<()> {
.try_init();
// Pick a builder and configure it.
- let builder = services::Memory::default();
+ let mut builder = services::Fs::default();
Review Comment:
It's for my local testing. I'll roll back it before merging.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155471935
##########
core/src/services/fs/backend.rs:
##########
@@ -441,6 +441,17 @@ impl Accessor for FsBackend {
Ok((RpWrite::new(), FsWriter::new(target_path, tmp_path, f)))
}
+ async fn copy(&self, from: &str, to: &str, _args: OpCopy) -> Result<RpCopy> {
Review Comment:
Yes, following the same behaviour like write does.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155352906
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
> Could you try it? I tried and had been able to only call the default implementation(with the `unsupported` error). I don't know what I missed.
Ok, I got it. You need to add `copy` in [LayeredAccessor](https://opendal.apache.org/docs/rust/opendal/raw/trait.LayeredAccessor.html) and forword to inner.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155351769
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
> I think we can copy code like:
Yes. This is what it needs.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on pull request #1841: feat(core): Add Copy Support
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#issuecomment-1493792845
> This PR is good enough to be merged. Maybe we can add behavior test in next PR?
LGTM. Will open another.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155354733
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
You are right. I missed the second part `impl<L: LayeredAccessor> Accessor for L`. It works.
I'll finish it tomorrow.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155472779
##########
core/src/types/operator/metadata.rs:
##########
@@ -57,6 +57,11 @@ impl OperatorInfo {
self.0.capabilities().contains(AccessorCapability::Write)
}
+ /// Check if current backend supports [`Accessor::copy`] or not.
+ pub fn can_copy(&self) -> bool {
Review Comment:
This logic is wrong. Copy is different from read A and write B. We only implement Copy when backend has native copy support.
##########
core/src/types/operator/blocking_operator.rs:
##########
@@ -447,6 +447,58 @@ impl BlockingOperator {
self.write_with(path, OpWrite::new(), bs)
}
+ /// Copy a file from `from` to `to`.
+ ///
+ /// # Notes
+ ///
+ /// - `from` and `to` must be a file.
+ /// - `to` will be overwritten if it exists.
+ /// - If `from` and `to` are the same, nothing will happen.
+ /// - `copy` is idempotent. For same `from` and `to` input, the result will be the same.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use std::io::Result;
+ /// # use opendal::BlockingOperator;
+ ///
+ /// # fn test(op: BlockingOperator) -> Result<()> {
+ /// op.copy("path/to/file", "path/to/file2")?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn copy(&self, from: &str, to: &str) -> Result<()> {
+ if from == to {
Review Comment:
We should check this after normalize.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155543141
##########
core/src/types/operator/metadata.rs:
##########
@@ -57,6 +57,11 @@ impl OperatorInfo {
self.0.capabilities().contains(AccessorCapability::Write)
}
+ /// Check if current backend supports [`Accessor::copy`] or not.
+ pub fn can_copy(&self) -> bool {
Review Comment:
> but we can do so by combining several different operations and it won't be complex.
Yes, we can do this. But not in service level.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#issuecomment-1493788085
As a new capability, I intend to add a new behavioral test.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155350447
##########
core/src/layers/logging.rs:
##########
@@ -322,6 +322,47 @@ impl<A: Accessor> LayeredAccessor for LoggingAccessor<A> {
})
}
+ async fn copy(&self, from: &str, to: &str, args: OpCopy) -> Result<RpCopy> {
Review Comment:
You don't have to support all layers when adding a new operation for `Accessor`, but thank you for your effort!
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
We do not support copying a directory in `copy`. Therefore, we need to ensure that the input path is not a directory.
##########
core/examples/object.rs:
##########
@@ -31,7 +31,8 @@ async fn main() -> Result<()> {
.try_init();
// Pick a builder and configure it.
- let builder = services::Memory::default();
+ let mut builder = services::Fs::default();
Review Comment:
Avoid using `fs` as an example, as it may cause unexpected changes in the user's environment.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155351676
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
Could you try it? I tried and had been able to only call the default implementation(with the `unsupported` error).
I don't know what I missed.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155350831
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
This is exactly what I was about to achieve. However, I can't actually call it, so I haven't dealt with the rest of the logic yet.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo merged pull request #1841: feat(core): Add Copy Support
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155351261
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,13 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
Review Comment:
Which part blocks you? I think we can copy code like:
https://github.com/apache/incubator-opendal/blob/d5e0ccaae6feb6ef5278c40eb75c4bb3256bec73/core/src/types/operator/operator.rs#L641-L648
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155480599
##########
core/src/types/operator/operator.rs:
##########
@@ -544,6 +544,59 @@ impl Operator {
self.write_with(path, OpWrite::new(), bs).await
}
+ /// Copy a file from `from` to `to`.
+ ///
+ /// # Notes
+ ///
+ /// - `from` and `to` must be a file.
+ /// - `to` will be overwritten if it exists.
+ /// - If `from` and `to` are the same, nothing will happen.
+ /// - `copy` is idempotent. For same `from` and `to` input, the result will be the same.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use std::io::Result;
+ /// # use opendal::Operator;
+ ///
+ /// # #[tokio::main]
+ /// # async fn test(op: Operator) -> Result<()> {
+ /// op.copy("path/to/file", "path/to/file2").await?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub async fn copy(&self, from: &str, to: &str) -> Result<()> {
+ if from == to {
+ return Ok(());
+ }
Review Comment:
I prefer to return an `IsSameFile` error here.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155532553
##########
core/src/types/operator/blocking_operator.rs:
##########
@@ -447,6 +447,58 @@ impl BlockingOperator {
self.write_with(path, OpWrite::new(), bs)
}
+ /// Copy a file from `from` to `to`.
+ ///
+ /// # Notes
+ ///
+ /// - `from` and `to` must be a file.
+ /// - `to` will be overwritten if it exists.
+ /// - If `from` and `to` are the same, nothing will happen.
+ /// - `copy` is idempotent. For same `from` and `to` input, the result will be the same.
+ ///
+ /// # Examples
+ ///
+ /// ```
+ /// # use std::io::Result;
+ /// # use opendal::BlockingOperator;
+ ///
+ /// # fn test(op: BlockingOperator) -> Result<()> {
+ /// op.copy("path/to/file", "path/to/file2")?;
+ /// # Ok(())
+ /// # }
+ /// ```
+ pub fn copy(&self, from: &str, to: &str) -> Result<()> {
+ if from == to {
Review Comment:
Make sense.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] suyanhanx commented on a diff in pull request #1841: feat(core): basic copy
Posted by "suyanhanx (via GitHub)" <gi...@apache.org>.
suyanhanx commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155532193
##########
core/src/types/operator/metadata.rs:
##########
@@ -57,6 +57,11 @@ impl OperatorInfo {
self.0.capabilities().contains(AccessorCapability::Write)
}
+ /// Check if current backend supports [`Accessor::copy`] or not.
+ pub fn can_copy(&self) -> bool {
Review Comment:
How to define `native copy support`?
Some backends don't provide copy support directly, but we can do so by combining several different operations and it won't be complex.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1841: feat(core): basic copy
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on code in PR #1841:
URL: https://github.com/apache/incubator-opendal/pull/1841#discussion_r1155542768
##########
core/src/types/operator/metadata.rs:
##########
@@ -57,6 +57,11 @@ impl OperatorInfo {
self.0.capabilities().contains(AccessorCapability::Write)
}
+ /// Check if current backend supports [`Accessor::copy`] or not.
+ pub fn can_copy(&self) -> bool {
Review Comment:
> Some backends don't provide copy support directly, but we can do so by combining several different operations and it won't be complex.
Native support refers to a backend's ability to perform an operation using its native API without requiring additional workarounds or hacks. This type of support typically results in better performance.
For instance, the `fs` service supports native copy by utilizing the syscall provided by different platforms such as `copy_file_range` on Linux. Similarly, the `s3` service supports native copy through the use of `CopyObject`.
It is essential for services to report their level of native support accurately so that operators can choose whether to utilize it or fallback to read and write logic.
In summary, all services should only provide native support and return 'NotSupported' for operations they do not support.
--
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: commits-unsubscribe@opendal.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org