Skip to content
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

store: remove integer values from DBCol variants #7441

Merged
merged 4 commits into from
Aug 26, 2022
Merged

Conversation

mina86
Copy link
Contributor

@mina86 mina86 commented Aug 19, 2022

So far we’ve been using ‘col##’ names for the RocksDB column families.
This commit proposes to move away from this pattern for new columns
and instead use variant name as the column family name. For example,
rather than ‘col50’ for flat state we would simply use ‘FlatState’.

This has a couple of advantages. Firstly, there’s no longer need to
manually assign unique numbers to columns. Secondly, troubleshooting
on RocksDB level becomes easier since it’s simpler to map from column
family name to the column name used in source code.

As far as I can tell, RocksDB doesn’t have a simple way to rename
a column family. Because of that, this commit only makes the change
in names for future columns leaving currently existing ones with
‘col##’ names.

@mina86 mina86 requested a review from Longarithm August 19, 2022 13:53
@mina86 mina86 requested a review from a team as a code owner August 19, 2022 13:53
@mina86 mina86 requested a review from mzhangmzz August 19, 2022 13:53
@mina86
Copy link
Contributor Author

mina86 commented Aug 19, 2022

Discussion on Zulip: https://near.zulipchat.com/#narrow/stream/313099-pagoda.2Fstorage/topic/Using.20variant.20name.20as.20col_name

@Longarithm, this might mess with any flat state tests you’re doing since it renames the FlatState column family.

Comment on lines 36 to 39
/// Returns column's name as name in the DBCol enum without '_' prefix for deprecated columns.
fn col_verbose_name(col: near_store::DBCol) -> &'static str {
let name: &str = col.into();
name.strip_prefix("_").unwrap_or(name)
<&str>::from(col)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this fn probably doesn't pull its weight anymore?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though, I'd maybe add this as a convenience API to use instead of <str>::from

impl DBCol {
   pub fn name(&self) -> &'static str { self.into() }
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We used to have this function but then it turns out it was only ever used when Display could be used so I got rid of it. At the moment it would be used in just two places so dunno really if it’s worth it.

@near-bulldozer near-bulldozer bot merged commit 5ad65be into near:master Aug 26, 2022
@mina86 mina86 deleted the d branch August 26, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants