-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Open unknown columns in the RocksDB for forward compatibility #2079
Conversation
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.
LGTM, left a question and a nit in-line :)
for column_name in existing_column_families { | ||
if cf_descriptors_to_open.contains_key(&column_name) | ||
|| cf_descriptors_to_create.contains_key(&column_name) | ||
{ | ||
continue; | ||
} | ||
|
||
let unknown_column_name = column_name; | ||
let unknown_column_options = Self::default_cf_opts(&block_opts); | ||
cf_descriptors_to_open.insert(unknown_column_name, unknown_column_options); | ||
} |
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.
how about this?
for column_name in existing_column_families { | |
if cf_descriptors_to_open.contains_key(&column_name) | |
|| cf_descriptors_to_create.contains_key(&column_name) | |
{ | |
continue; | |
} | |
let unknown_column_name = column_name; | |
let unknown_column_options = Self::default_cf_opts(&block_opts); | |
cf_descriptors_to_open.insert(unknown_column_name, unknown_column_options); | |
} | |
existing_column_families | |
.iter() | |
.filter(|column_name| { | |
!cf_descriptors_to_open.contains_key(*column_name) | |
&& !cf_descriptors_to_create.contains_key(*column_name) | |
}) | |
.for_each(|column_name| { | |
let unknown_column_options = Self::default_cf_opts(&block_opts); | |
cf_descriptors_to_open.insert(column_name.clone(), unknown_column_options); | |
}); |
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.
While this PR is merged without applying this suggestion, I also generally prefer using iterators to populate collections over using for loops and .insert
. In this scenario I would also have advised to use .map
instead of .for_each
, to avoid having to call .insert
from within the for_each closure.
Something along the lines of:
cf_descriptors_to_open.extend(existing_column_families.iter().filter(...).map(...))
@@ -428,12 +441,18 @@ where | |||
format!("col-{}", column) | |||
} | |||
|
|||
fn cf_opts(column: Description::Column, block_opts: &BlockBasedOptions) -> Options { | |||
fn default_cf_opts(block_opts: &BlockBasedOptions) -> Options { |
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.
qq: where do we describe the column to use in default_cf_opts
?
Addressed comments in the unknown columns PR #2079. ### Before requesting review - [x] I have reviewed the code myself
Rocksdb requires opening all columns mentioned in the Manifest file. This means that old versions of the
fuel-core
are unable to open columns created by a new version of thefuel-core
. The change adds forward compatibility by opening unknown columns with default options.Checklist
Before requesting review