-
Notifications
You must be signed in to change notification settings - Fork 453
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
RFC-0561: List metadata reuse #561
Conversation
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
And for this proposal's naming, |
1. fix up format of document Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Still not ready for review |
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
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. |
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
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 <cailue@bupt.edu.cn>
Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
…fs-list-with-metadata Signed-off-by: ClSlaid <cailue@bupt.edu.cn>
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 cailue@bupt.edu.cn
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