You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Lzzzzzt (via GitHub)" <gi...@apache.org> on 2024/07/13 02:45:22 UTC
[I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Lzzzzzt opened a new issue, #4888:
URL: https://github.com/apache/opendal/issues/4888
### Feature Description
Since the `CompleteAccessor` stores the metadata, and `Access::info` return the `Arc<AccessorInfo>`, we can move logic from `fn metadata(&self) -> Arc<AccessorInfo>` to `impl<A: Access> Layer<A> for CompleteLayer` to avoid creating a new `Arc<AccessorInfo>`(this is not add the reference count).
### Problem and Solution
just change `CompleteAccessor::metadata`:
```rust
fn metadata(&self) -> Arc<AccessorInfo> {
let mut meta = (*self.meta).clone();
let cap = meta.full_capability_mut();
if cap.list && cap.write_can_empty {
cap.create_dir = true;
}
meta.into()
}
```
to
```rust
fn metadata(&self) -> Arc<AccessorInfo> {
self.meta.clone()
}
```
and change `CompleteLayer::layer`:
```rust
fn layer(&self, inner: A) -> Self::LayeredAccess {
CompleteAccessor {
meta: inner.info(),
inner: Arc::new(inner),
}
}
```
to
```rust
fn layer(&self, inner: A) -> Self::LayeredAccess {
let mut meta = inner.info().as_ref().clone();
let cap = meta.full_capability_mut();
if cap.list && cap.write_can_empty {
cap.create_dir = true;
}
CompleteAccessor {
meta: meta.into(),
inner: Arc::new(inner),
}
}
```
### Additional Context
All the layers that store the metadata can apply this change.
### Are you willing to contribute to the development of this feature?
- [X] Yes, I am willing to contribute to the development of this feature.
--
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.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4888:
URL: https://github.com/apache/opendal/issues/4888#issuecomment-2713117098
Implemented.
--
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
Re: [I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo commented on issue #4888:
URL: https://github.com/apache/opendal/issues/4888#issuecomment-2226960020
Looks good to me.
--
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
Re: [I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Posted by "Lzzzzzt (via GitHub)" <gi...@apache.org>.
Lzzzzzt commented on issue #4888:
URL: https://github.com/apache/opendal/issues/4888#issuecomment-2226941763
should these accessor like `BlockingAccessor` that doesn't store the metadata but change the capability add a field to store the new metadata to avoid needless memory allocation.
https://github.com/apache/opendal/blob/31d09673093d92a87e72575d1b00bdd4529dcf56/core/src/layers/blocking.rs#L183-L187
--
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
Re: [I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Posted by "Lzzzzzt (via GitHub)" <gi...@apache.org>.
Lzzzzzt commented on issue #4888:
URL: https://github.com/apache/opendal/issues/4888#issuecomment-2227188030
It seems that after apply this change, the c binding CI test will fail, but I don't know why this happens.
--
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
Re: [I] idea: move logic from `fn metadata(&self) -> Arc` to `impl Layer for CompleteLayer` [opendal]
Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo closed issue #4888: idea: move logic from `fn metadata(&self) -> Arc<AccessorInfo>` to `impl<A: Access> Layer<A> for CompleteLayer`
URL: https://github.com/apache/opendal/issues/4888
--
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