@ -195,11 +195,11 @@ bool LDBCommand::ParseIntOption(const map<string, string>& options,
value = stoi ( itr - > second ) ;
value = stoi ( itr - > second ) ;
return true ;
return true ;
} catch ( const invalid_argument & ) {
} catch ( const invalid_argument & ) {
exec_state = LDBCommandExecuteResult : : Failed ( option +
exec_state =
" has an invalid value. " ) ;
LDBCommandExecuteResult : : Failed ( option + " has an invalid value. " ) ;
} catch ( const out_of_range & ) {
} catch ( const out_of_range & ) {
exec_state = LDBCommandExecuteResult : : Failed ( option +
exec_state = LDBCommandExecuteResult : : Failed (
" has a value out-of-range. " ) ;
option + " has a value out-of-range. " ) ;
}
}
}
}
return false ;
return false ;
@ -235,8 +235,8 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
use_table_options = true ;
use_table_options = true ;
table_options . filter_policy . reset ( NewBloomFilterPolicy ( bits ) ) ;
table_options . filter_policy . reset ( NewBloomFilterPolicy ( bits ) ) ;
} else {
} else {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_BLOOM_BITS +
exec_state_ =
" must be > 0. " ) ;
LDBCommandExecuteResult : : Failed ( ARG_BLOOM_BITS + " must be > 0. " ) ;
}
}
}
}
@ -246,8 +246,8 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
use_table_options = true ;
use_table_options = true ;
table_options . block_size = block_size ;
table_options . block_size = block_size ;
} else {
} else {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_BLOCK_SIZE +
exec_state_ =
" must be > 0. " ) ;
LDBCommandExecuteResult : : Failed ( ARG_BLOCK_SIZE + " must be > 0. " ) ;
}
}
}
}
@ -277,8 +277,8 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
opt . compression = kLZ4HCCompression ;
opt . compression = kLZ4HCCompression ;
} else {
} else {
// Unknown compression.
// Unknown compression.
exec_state_ = LDBCommandExecuteResult : : Failed (
exec_state_ =
" Unknown compression level: " + comp ) ;
LDBCommandExecuteResult : : Failed ( " Unknown compression level: " + comp ) ;
}
}
}
}
@ -309,8 +309,8 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
if ( file_size > 0 ) {
if ( file_size > 0 ) {
opt . target_file_size_base = file_size ;
opt . target_file_size_base = file_size ;
} else {
} else {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_FILE_SIZE +
exec_state_ =
" must be > 0. " ) ;
LDBCommandExecuteResult : : Failed ( ARG_FILE_SIZE + " must be > 0. " ) ;
}
}
}
}
@ -585,8 +585,8 @@ void ManifestDumpCommand::DoCommand() {
// containing the db for files of the form MANIFEST_[0-9]+
// containing the db for files of the form MANIFEST_[0-9]+
DIR * d = opendir ( db_path_ . c_str ( ) ) ;
DIR * d = opendir ( db_path_ . c_str ( ) ) ;
if ( d = = nullptr ) {
if ( d = = nullptr ) {
exec_state_ = LDBCommandExecuteResult : : Failed (
exec_state_ =
db_path_ + " is not a directory " ) ;
LDBCommandExecuteResult : : Failed ( db_path_ + " is not a directory " ) ;
return ;
return ;
}
}
struct dirent * entry ;
struct dirent * entry ;
@ -792,8 +792,8 @@ void InternalDumpCommand::DoCommand() {
ScopedArenaIterator iter ( idb - > TEST_NewInternalIterator ( & arena ) ) ;
ScopedArenaIterator iter ( idb - > TEST_NewInternalIterator ( & arena ) ) ;
Status st = iter - > status ( ) ;
Status st = iter - > status ( ) ;
if ( ! st . ok ( ) ) {
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( " Iterator error: "
exec_state_ =
+ st . ToString ( ) ) ;
LDBCommandExecuteResult : : Failed ( " Iterator error: " + st . ToString ( ) ) ;
}
}
if ( has_from_ ) {
if ( has_from_ ) {
@ -902,8 +902,8 @@ DBDumperCommand::DBDumperCommand(const vector<string>& params,
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has an invalid value " ) ;
" has an invalid value " ) ;
} catch ( const out_of_range & ) {
} catch ( const out_of_range & ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed (
" has a value out-of-range " ) ;
ARG_MAX_KEYS + " has a value out-of-range " ) ;
}
}
}
}
itr = options . find ( ARG_COUNT_DELIM ) ;
itr = options . find ( ARG_COUNT_DELIM ) ;
@ -961,8 +961,8 @@ void DBDumperCommand::DoCommand() {
Iterator * iter = db_ - > NewIterator ( ReadOptions ( ) ) ;
Iterator * iter = db_ - > NewIterator ( ReadOptions ( ) ) ;
Status st = iter - > status ( ) ;
Status st = iter - > status ( ) ;
if ( ! st . ok ( ) ) {
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( " Iterator error. "
exec_state_ =
+ st . ToString ( ) ) ;
LDBCommandExecuteResult : : Failed ( " Iterator error. " + st . ToString ( ) ) ;
}
}
if ( ! null_from_ ) {
if ( ! null_from_ ) {
@ -1165,8 +1165,8 @@ Status ReduceDBLevelsCommand::GetOldNumOfLevels(Options& opt,
void ReduceDBLevelsCommand : : DoCommand ( ) {
void ReduceDBLevelsCommand : : DoCommand ( ) {
if ( new_levels_ < = 1 ) {
if ( new_levels_ < = 1 ) {
exec_state_ = LDBCommandExecuteResult : : Failed (
exec_state_ =
" Invalid number of levels. \n " ) ;
LDBCommandExecuteResult : : Failed ( " Invalid number of levels. \n " ) ;
return ;
return ;
}
}
@ -1320,16 +1320,19 @@ void ChangeCompactionStyleCommand::DoCommand() {
// level 0 should have only 1 file
// level 0 should have only 1 file
if ( i = = 0 & & num_files ! = 1 ) {
if ( i = = 0 & & num_files ! = 1 ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( " Number of db files at "
exec_state_ = LDBCommandExecuteResult : : Failed (
" level 0 after compaction is " + ToString ( num_files ) +
" Number of db files at "
" , not 1. \n " ) ;
" level 0 after compaction is " +
ToString ( num_files ) + " , not 1. \n " ) ;
return ;
return ;
}
}
// other levels should have no file
// other levels should have no file
if ( i > 0 & & num_files ! = 0 ) {
if ( i > 0 & & num_files ! = 0 ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( " Number of db files at "
exec_state_ = LDBCommandExecuteResult : : Failed (
" level " + ToString ( i ) + " after compaction is " +
" Number of db files at "
ToString ( num_files ) + " , not 0. \n " ) ;
" level " +
ToString ( i ) + " after compaction is " + ToString ( num_files ) +
" , not 0. \n " ) ;
return ;
return ;
}
}
}
}
@ -1459,8 +1462,8 @@ WALDumperCommand::WALDumperCommand(const vector<string>& params,
print_header_ = IsFlagPresent ( flags , ARG_PRINT_HEADER ) ;
print_header_ = IsFlagPresent ( flags , ARG_PRINT_HEADER ) ;
print_values_ = IsFlagPresent ( flags , ARG_PRINT_VALUE ) ;
print_values_ = IsFlagPresent ( flags , ARG_PRINT_VALUE ) ;
if ( wal_file_ . empty ( ) ) {
if ( wal_file_ . empty ( ) ) {
exec_state_ = LDBCommandExecuteResult : : Failed (
exec_state_ = LDBCommandExecuteResult : : Failed ( " Argument " + ARG_WAL_FILE +
" Argument " + ARG_WAL_FILE + " must be specified. " ) ;
" must be specified. " ) ;
}
}
}
}
@ -1527,16 +1530,16 @@ ApproxSizeCommand::ApproxSizeCommand(const vector<string>& params,
if ( options . find ( ARG_FROM ) ! = options . end ( ) ) {
if ( options . find ( ARG_FROM ) ! = options . end ( ) ) {
start_key_ = options . find ( ARG_FROM ) - > second ;
start_key_ = options . find ( ARG_FROM ) - > second ;
} else {
} else {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_FROM +
exec_state_ = LDBCommandExecuteResult : : Failed (
" must be specified for approxsize command " ) ;
ARG_FROM + " must be specified for approxsize command " ) ;
return ;
return ;
}
}
if ( options . find ( ARG_TO ) ! = options . end ( ) ) {
if ( options . find ( ARG_TO ) ! = options . end ( ) ) {
end_key_ = options . find ( ARG_TO ) - > second ;
end_key_ = options . find ( ARG_TO ) - > second ;
} else {
} else {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_TO +
exec_state_ = LDBCommandExecuteResult : : Failed (
" must be specified for approxsize command " ) ;
ARG_TO + " must be specified for approxsize command " ) ;
return ;
return ;
}
}
@ -1659,8 +1662,8 @@ ScanCommand::ScanCommand(const vector<string>& params,
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has an invalid value " ) ;
" has an invalid value " ) ;
} catch ( const out_of_range & ) {
} catch ( const out_of_range & ) {
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed (
" has a value out-of-range " ) ;
ARG_MAX_KEYS + " has a value out-of-range " ) ;
}
}
}
}
}
}