Skip to content

Commit eb437ff

Browse files
authored
Merge pull request #1326 from ideawu/dev
ssdb-repair compact after repairing
2 parents 16a032b + 6258c5e commit eb437ff

2 files changed

Lines changed: 25 additions & 0 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ tools/leveldb-import
2727
_pack
2828
build_config.mk
2929
log.txt
30+
repair.log
3031
log_slave.txt
3132
src/client/demo
3233
src/client/hello-ssdb

tools/ssdb-repair.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,30 @@ int main(int argc, char **argv){
6565
}
6666

6767
printf("leveldb repaired.\n");
68+
69+
{
70+
leveldb::DB* db;
71+
leveldb::Options options;
72+
leveldb::Status status;
73+
options.create_if_missing = true;
74+
options.write_buffer_size = 32 * 1024 * 1024;
75+
options.compression = leveldb::kSnappyCompression;
76+
77+
status = leveldb::DB::Open(options, leveldb_folder.c_str(), &db);
78+
if(!status.ok()){
79+
fprintf(stderr, "ERROR: open leveldb: %s error!\n", leveldb_folder.c_str());
80+
exit(1);
81+
}
82+
printf("compacting data...\n");
83+
db->CompactRange(NULL, NULL);
84+
85+
{
86+
std::string val;
87+
if(db->GetProperty("leveldb.stats", &val)){
88+
printf("%s\n", val.c_str());
89+
}
90+
}
91+
}
6892

6993
return 0;
7094
}

0 commit comments

Comments
 (0)