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

Add rocksdb interface #29

Merged
merged 35 commits into from
Aug 28, 2022
Merged

Add rocksdb interface #29

merged 35 commits into from
Aug 28, 2022

Conversation

Milchstra3e
Copy link
Contributor

  • add some dependency
  • add rocksdb_kv module
  • implement rocksdb functions except revert_to_latest_checkpoint

Copy link
Member

@junha1 junha1 left a comment

Choose a reason for hiding this comment

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

Instead of using block_on, make the test tokio::test and just .await it.

let result = self.db.put(key.as_ref(), value);
match result {
Ok(_) => Ok(()),
Err(_) => Err(super::Error::Unknown("unknown error".to_string())),
Copy link
Member

Choose a reason for hiding this comment

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

use the err information, not just discarding it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

let result = self.db.delete(key.as_ref());
match result {
Ok(_) => Ok(()),
Err(_) => Err(super::Error::NotFound),
Copy link
Member

Choose a reason for hiding this comment

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

use the err information, not just discarding it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

let result = self.db.get(key.as_ref());
match result {
Ok(v) => Ok(v.unwrap()),
Err(_) => Err(super::Error::NotFound),
Copy link
Member

Choose a reason for hiding this comment

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

use the err information, not just discarding it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

.unwrap();
}

self.db = DB::open_default(new_current_db_dir.to_path_buf().as_path().join("db")).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

.unwrap();
checkpoint_db
.create_checkpoint(new_checkpoint_db_dir.to_path_buf().as_path().join("db"))
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

.unwrap();
checkpoint_db
.create_checkpoint(checkpoint_db_dir.to_path_buf().as_path().join("db"))
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix


checkpoint_db
.create_checkpoint(current_db_dir.to_path_buf().as_path().join("db"))
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

.unwrap();
checkpoint_db
.create_checkpoint(checkpoint_db_dir.to_path_buf().as_path().join("db"))
.unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

}

Ok(RocksDB {
db: DB::open_default(current_db_dir.to_path_buf().as_path().join("db")).unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

Don't unwrap, but handle it and propagate using ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

db.put(Hash256::hash("key3"), "val3").unwrap();
db.put(Hash256::hash("key4"), "val4").unwrap();

tmp_folder
Copy link
Member

Choose a reason for hiding this comment

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

tmp_directory

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

Changhun Oh added 25 commits August 27, 2022 18:06
add new folder(rocksdb) in kv-store
init RocksDB struct without fields and implementation each functions
change folder name from rocksdb_kv to rocksdb
change file name from rocksdb.rs to mod.rs
include rocksdb crate
declare new field db in RocksDB struct
implement function new / open / insert_or_update / remove / get
add new dependency mktemp
use mktemp module
implement comit_checkpoint
- add origin_path: PathBuf
- add current_db_path: Temp
- add checkpoint_Db_path: Temp
- rewrite logic of new / open
}

async fn contain(&self, key: Hash256) -> Result<bool, super::Error> {
let result = self.db.get(key.as_ref()).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

please handle the error instead of unwrapping it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

let result = self.db.delete(key.as_ref());
match result {
Ok(_) => Ok(()),
Err(e) => Err(super::Error::from(e)),
Copy link
Member

Choose a reason for hiding this comment

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

Do we need this? Not just ? ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

@junha1 junha1 merged commit b4b21a2 into postech-dao:main Aug 28, 2022
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