@ -392,7 +392,7 @@ void DBLoaderCommand::DoCommand() {
std : : cout < < " Warning: " < < bad_lines < < " bad lines ignored. " < < std : : endl ;
std : : cout < < " Warning: " < < bad_lines < < " bad lines ignored. " < < std : : endl ;
}
}
if ( compact_ ) {
if ( compact_ ) {
db_ - > CompactRange ( NULL , NULL ) ;
db_ - > CompactRange ( nullptr , nullptr ) ;
}
}
}
}
@ -560,27 +560,24 @@ leveldb::Options ReduceDBLevelsCommand::PrepareOptionsForOpenDB() {
Status ReduceDBLevelsCommand : : GetOldNumOfLevels ( leveldb : : Options & opt ,
Status ReduceDBLevelsCommand : : GetOldNumOfLevels ( leveldb : : Options & opt ,
int * levels ) {
int * levels ) {
TableCache * tc = new TableCache ( db_path_ , & opt , 10 ) ;
TableCache tc ( db_path_ , & opt , 10 ) ;
const InternalKeyComparator * cmp = new InternalKeyComparator (
const InternalKeyComparator cmp ( opt . comparator ) ;
opt . comparator ) ;
VersionSet versions ( db_path_ , & opt , & tc , & cmp ) ;
VersionSet * versions = new VersionSet ( db_path_ , & opt ,
tc , cmp ) ;
// We rely the VersionSet::Recover to tell us the internal data structures
// We rely the VersionSet::Recover to tell us the internal data structures
// in the db. And the Recover() should never do any change
// in the db. And the Recover() should never do any change
// (like LogAndApply) to the manifest file.
// (like LogAndApply) to the manifest file.
Status st = versions - > Recover ( ) ;
Status st = versions . Recover ( ) ;
if ( ! st . ok ( ) ) {
if ( ! st . ok ( ) ) {
return st ;
return st ;
}
}
int max = - 1 ;
int max = - 1 ;
for ( int i = 0 ; i < versions - > NumberLevels ( ) ; i + + ) {
for ( int i = 0 ; i < versions . NumberLevels ( ) ; i + + ) {
if ( versions - > NumLevelFiles ( i ) ) {
if ( versions . NumLevelFiles ( i ) ) {
max = i ;
max = i ;
}
}
}
}
* levels = max + 1 ;
* levels = max + 1 ;
delete versions ;
return st ;
return st ;
}
}
@ -619,15 +616,13 @@ void ReduceDBLevelsCommand::DoCommand() {
db_ - > CompactRange ( nullptr , nullptr ) ;
db_ - > CompactRange ( nullptr , nullptr ) ;
CloseDB ( ) ;
CloseDB ( ) ;
TableCache * tc = new TableCache ( db_path_ , & opt , 10 ) ;
TableCache tc ( db_path_ , & opt , 10 ) ;
const InternalKeyComparator * cmp = new InternalKeyComparator (
const InternalKeyComparator cmp ( opt . comparator ) ;
opt . comparator ) ;
VersionSet versions ( db_path_ , & opt , & tc , & cmp ) ;
VersionSet * versions = new VersionSet ( db_path_ , & opt ,
tc , cmp ) ;
// We rely the VersionSet::Recover to tell us the internal data structures
// We rely the VersionSet::Recover to tell us the internal data structures
// in the db. And the Recover() should never do any change (like LogAndApply)
// in the db. And the Recover() should never do any change (like LogAndApply)
// to the manifest file.
// to the manifest file.
st = versions - > Recover ( ) ;
st = versions . Recover ( ) ;
if ( ! st . ok ( ) ) {
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
return ;
return ;
@ -635,7 +630,7 @@ void ReduceDBLevelsCommand::DoCommand() {
port : : Mutex mu ;
port : : Mutex mu ;
mu . Lock ( ) ;
mu . Lock ( ) ;
st = versions - > ReduceNumberOfLevels ( new_levels_ , & mu ) ;
st = versions . ReduceNumberOfLevels ( new_levels_ , & mu ) ;
mu . Unlock ( ) ;
mu . Unlock ( ) ;
if ( ! st . ok ( ) ) {
if ( ! st . ok ( ) ) {