-
Notifications
You must be signed in to change notification settings - Fork 621
RFC-0561: List metadata reuse #561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: ClSlaid <[email protected]>
And for this proposal's naming, |
1. fix up format of document Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
Still not ready for review |
Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
There are two ways of implementation:
struct MetaLite {
pub content_length: u64, // size of file
pub last_modified: OffsetDateTime,
pub created: OffsetDateTime, // time created
}
pub struct DirEntry {
acc: Arc<dyn Accessor>,
mode: ObjectMode,
path: String,
// newly add metadata struct
metadata: Option<MetaLite>,
}
impl DirEntry {
// get size of file
pub fn content_length(&self) -> Option<u64> {
self.metadata.as_ref().map(|m| m.content_length)
}
// get the last modified time
pub fn last_modified(&self) -> Option<OffsetDateTime> {
self.metadata.as_ref().map(|m| m.last_modified)
}
// get the create time
pub fn created(&self) -> Option<OffsetDateTime> {
self.metadata.as_ref().map(|m| m.created)
}
}
pub struct DirEntry {
acc: Arc<dyn Accessor>,
mode: ObjectMode,
path: String,
// newly add metadata fields
content_length: Option<u64>, // size of file
last_modified: Option<u64>,
created: Option<u64>, // time created
}
impl DirEntry {
// get size of file
pub fn content_length(&self) -> Option<u64> {
self.content_length
}
// get the last modified time
pub fn last_modified(&self) -> Option<OffsetDateTime> {
self.last_modified
}
// get the create time
pub fn created(&self) -> Option<OffsetDateTime> {
self.created
}
} I prefer the first one because it provides a compacter memory layout. The first one saves 8 bytes of space. Implementing this RFC will increase the size of The second approach may be a little faster because no intermediate function calls are involved. But it's worth sacrificing an infrequently used feature's performance to save memory. |
Plan A: simply extend `DirEntry` Plan B: define a new MetaLite struct and embed it into `DirEntry` @ClSlaid prefered. Plan C: embed `ObjectMetadata` into `DirEntry` @Xuanwo prefered Signed-off-by: ClSlaid <[email protected]>
Signed-off-by: ClSlaid <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LGTM!
This RFC is really great.
Signed-off-by: ClSlaid <[email protected]>
Please also update https://github.com/datafuselabs/opendal/blob/main/docs/SUMMARY.md |
Signed-off-by: ClSlaid <[email protected]>
…fs-list-with-metadata Signed-off-by: ClSlaid <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Congrats on your first RFC!
Signed-off-by: ClSlaid [email protected]
I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/
Summary
Open an RFC for adding metadata to DirEntry
related: #558
thanks to: @sandflee