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

Modularize database initialization #65

Merged
merged 3 commits into from
Aug 3, 2023
Merged

Conversation

rkuris
Copy link
Collaborator

@rkuris rkuris commented Apr 27, 2023

Pretty tough to implement v2 of the API since things are so tied to the db implementation.

This group of commits splits the db.rs file into parts, documenting the opening of the database as I go.

@rkuris rkuris marked this pull request as draft April 27, 2023 00:33
@rkuris rkuris force-pushed the rkuris/modularize-db-init branch from 5049ed7 to 83408fe Compare June 13, 2023 17:29
@rkuris rkuris force-pushed the rkuris/modularize-db-init branch 7 times, most recently from 83c878c to 6d3da4d Compare August 2, 2023 16:43
@rkuris rkuris marked this pull request as ready for review August 2, 2023 16:44
@@ -180,7 +180,7 @@ impl RevisionTracker {
fn get_revision(&self, index: usize) -> Revision<SharedStore> {
self.db
.get_revision(&self.hashes[index], None)
.expect(&format!("revision-{index} should exist"))
.unwrap_or_else(|| panic!("revision-{index} should exist"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Wondering why the change, is unwrap_or_else is better than expect?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This was recommended by clippy with a few extra warnings turned on. Reason: format is built into panic, and it won't evaluate/compute the string until the panic actually happens (I think, not 100% sure)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@@ -581,9 +579,12 @@ impl DiskBufferRequester {
}

/// Initialize the Wal.
pub fn init_wal(&self, waldir: &str, rootpath: PathBuf) {
pub fn init_wal(&self, waldir: &str, rootpath: &Path) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we change this to &Path as downstream is PathBuf?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The answer was in the commit comment for the second commit, probably not easy to find. The idea is that I want to defer cloning the dbpath because I want it after init_wal is finished.

Copy link
Contributor

Choose a reason for hiding this comment

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

Allocation should be explicit, not hidden. I don't quite understand the motivation here.

@rkuris rkuris force-pushed the rkuris/modularize-db-init branch 2 times, most recently from 35ac003 to 6dc0fbb Compare August 3, 2023 17:46
This moves DBConfig and DBRevConfig into a new config dir
allowing these configs to be fetched from elsewhere
Want access to it after the last init_wal for better errors
@rkuris rkuris merged commit 87837bf into main Aug 3, 2023
5 checks passed
@rkuris rkuris deleted the rkuris/modularize-db-init branch August 3, 2023 18:12
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