Skip to content

Commit

Permalink
Merge pull request #1326 from ideawu/dev
Browse files Browse the repository at this point in the history
ssdb-repair compact after repairing
  • Loading branch information
ideawu authored Feb 11, 2020
2 parents 16a032b + 6258c5e commit eb437ff
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ tools/leveldb-import
_pack
build_config.mk
log.txt
repair.log
log_slave.txt
src/client/demo
src/client/hello-ssdb
Expand Down
24 changes: 24 additions & 0 deletions tools/ssdb-repair.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,30 @@ int main(int argc, char **argv){
}

printf("leveldb repaired.\n");

{
leveldb::DB* db;
leveldb::Options options;
leveldb::Status status;
options.create_if_missing = true;
options.write_buffer_size = 32 * 1024 * 1024;
options.compression = leveldb::kSnappyCompression;

status = leveldb::DB::Open(options, leveldb_folder.c_str(), &db);
if(!status.ok()){
fprintf(stderr, "ERROR: open leveldb: %s error!\n", leveldb_folder.c_str());
exit(1);
}
printf("compacting data...\n");
db->CompactRange(NULL, NULL);

{
std::string val;
if(db->GetProperty("leveldb.stats", &val)){
printf("%s\n", val.c_str());
}
}
}

return 0;
}

0 comments on commit eb437ff

Please sign in to comment.