-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: Add new chunk count column for tracking #342
base: main
Are you sure you want to change the base?
Conversation
… index and lenght of columns
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.
Nice job! Left some comments but overall great 💯
client/file-manager/src/rocksdb.rs
Outdated
@@ -20,23 +20,50 @@ use crate::{ | |||
LOG_TARGET, | |||
}; | |||
use codec::{Decode, Encode}; | |||
use strum::{EnumCount, VariantArray}; | |||
|
|||
#[derive(Debug, Clone, Copy, EnumCount, VariantArray)] |
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.
Love the refactor 💯
|
||
#[derive(Debug, Clone, Copy, EnumCount, VariantArray)] | ||
pub enum Column { | ||
Metadata, |
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.
We should have docs for the Metadata
member as well, and if possible for all the columns
@@ -58,7 +85,8 @@ fn open_or_creating_rocksdb(db_path: String) -> io::Result<kvdb_rocksdb::Databas | |||
Ok(db) | |||
} | |||
|
|||
/// Storage backend for RocksDB. | |||
/// Storage backend implementation for RocksDB. |
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.
Love the improved docs on all functions!
@@ -46,7 +73,7 @@ fn open_or_creating_rocksdb(db_path: String) -> io::Result<kvdb_rocksdb::Databas | |||
path.push(db_path.as_str()); | |||
path.push("storagehub/file_storage/"); | |||
|
|||
let db_config = kvdb_rocksdb::DatabaseConfig::with_columns(8); | |||
let db_config = kvdb_rocksdb::DatabaseConfig::with_columns(NUMBER_OF_COLUMNS); |
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.
Nice improvement.
Indeed in the past I had errors when forgetting to increase the columns number hardcoded value. It would avoid it in the future.
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.
Looks good but seems to me we need another locker for the write_chunk
so that we don't end up with wrong chunk_count
value.w
Adds new
CHUNK_COUNT_COLUMN
to track number of chunks for a given file key. This avoids having to iterate through the entire file trie to count all the chunks and conclude if we have uploaded all the chunks yet for a file.These changes also include a refactor of our column definitions to have consistent index retrievals and column length constant. In addition, I added some documentation to these columns to have a clear definition for their purpose in the context of RocksDB file storage.
Resolves issue #20