-
Notifications
You must be signed in to change notification settings - Fork 1k
[TieredStorage] Add capacity() API and limit file size to 16GB #401
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,8 @@ use { | |
|
|
||
| pub type TieredStorageResult<T> = Result<T, TieredStorageError>; | ||
|
|
||
| const MAX_TIERED_STORAGE_FILE_SIZE: u64 = 16 * 1024 * 1024 * 1024; // 16 GiB; | ||
|
|
||
| /// The struct that defines the formats of all building blocks of a | ||
| /// TieredStorage. | ||
| #[derive(Clone, Debug, PartialEq)] | ||
|
|
@@ -163,6 +165,11 @@ impl TieredStorage { | |
| pub fn is_empty(&self) -> bool { | ||
| self.len() == 0 | ||
| } | ||
|
|
||
| pub fn capacity(&self) -> u64 { | ||
| self.reader() | ||
| .map_or(MAX_TIERED_STORAGE_FILE_SIZE, |reader| reader.capacity()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this impl makes sense. We don't want to have to specify the max size constant in multiple places (as is currently). So the one in
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think here we need MAX_TIERED_STORAGE_FILE_SIZE. Because the or case means we don't have a reader yet, meaning we don't know whether it is cold or hot yet. But yep, under the HotStorageReader it should return MAX_HOT_STORAGE_FILE_SIZE. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think this is another example of the API being inverted/backwards. The caller does have a tiered storage though, that's how they can even call
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
My original thinking is that: the accounts-db layer manages temperature (i.e., hot / cold / warm .. etc) as it has the whole picture of active / inactive accounts and other related information like shrink, and the accounts-file layer's job is to determine the best suitable file format based on the temperature assigned by the accounts-db. (and this is the reason why it was TieredHot previously as we eventually need an enum to determine the temperature.) So back to the main topic, if we think determining temperature is accounts-db layer's job, then we should have some temperature information here even without constructing a reader. We can revisit this later as we currently don't have plans for cold format. For now I think MAX_TIERED_STORAGE_FILE_SIZE is good enough. |
||
| } | ||
| } | ||
|
|
||
| #[cfg(test)] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.