@ -195,10 +195,10 @@ bool LDBCommand::ParseIntOption(const map<string, string>& options,
value = stoi ( itr - > second ) ;
return true ;
} catch ( const invalid_argument & ) {
exec_state = LDBCommandExecuteResult : : FAILED ( option +
exec_state = LDBCommandExecuteResult : : Failed ( option +
" has an invalid value. " ) ;
} catch ( const out_of_range & ) {
exec_state = LDBCommandExecuteResult : : FAILED ( option +
exec_state = LDBCommandExecuteResult : : Failed ( option +
" has a value out-of-range. " ) ;
}
}
@ -235,7 +235,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
use_table_options = true ;
table_options . filter_policy . reset ( NewBloomFilterPolicy ( bits ) ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_BLOOM_BITS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_BLOOM_BITS +
" must be > 0. " ) ;
}
}
@ -246,7 +246,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
use_table_options = true ;
table_options . block_size = block_size ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_BLOCK_SIZE +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_BLOCK_SIZE +
" must be > 0. " ) ;
}
}
@ -277,7 +277,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
opt . compression = kLZ4HCCompression ;
} else {
// Unknown compression.
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Unknown compression level: " + comp ) ;
}
}
@ -288,7 +288,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
if ( db_write_buffer_size > = 0 ) {
opt . db_write_buffer_size = db_write_buffer_size ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_DB_WRITE_BUFFER_SIZE +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_DB_WRITE_BUFFER_SIZE +
" must be >= 0. " ) ;
}
}
@ -299,7 +299,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
if ( write_buffer_size > 0 ) {
opt . write_buffer_size = write_buffer_size ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_WRITE_BUFFER_SIZE +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_WRITE_BUFFER_SIZE +
" must be > 0. " ) ;
}
}
@ -309,7 +309,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
if ( file_size > 0 ) {
opt . target_file_size_base = file_size ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_FILE_SIZE +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_FILE_SIZE +
" must be > 0. " ) ;
}
}
@ -326,7 +326,7 @@ Options LDBCommand::PrepareOptionsForOpenDB() {
NewFixedPrefixTransform ( static_cast < size_t > ( fix_prefix_len ) ) ) ;
} else {
exec_state_ =
LDBCommandExecuteResult : : FAILED ( ARG_FIX_PREFIX_LEN + " must be > 0. " ) ;
LDBCommandExecuteResult : : Failed ( ARG_FIX_PREFIX_LEN + " must be > 0. " ) ;
}
}
@ -436,7 +436,7 @@ void CompactorCommand::DoCommand() {
}
db_ - > CompactRange ( begin , end ) ;
exec_state_ = LDBCommandExecuteResult : : SUCCEED ( " " ) ;
exec_state_ = LDBCommandExecuteResult : : Succeed ( " " ) ;
delete begin ;
delete end ;
@ -568,7 +568,7 @@ ManifestDumpCommand::ManifestDumpCommand(const vector<string>& params,
if ( itr ! = options . end ( ) ) {
path_ = itr - > second ;
if ( path_ . empty ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " --path: missing pathname " ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( " --path: missing pathname " ) ;
}
}
}
@ -585,7 +585,7 @@ void ManifestDumpCommand::DoCommand() {
// containing the db for files of the form MANIFEST_[0-9]+
DIR * d = opendir ( db_path_ . c_str ( ) ) ;
if ( d = = nullptr ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
db_path_ + " is not a directory " ) ;
return ;
}
@ -602,7 +602,7 @@ void ManifestDumpCommand::DoCommand() {
manifestfile = db_path_ + " / " + std : : string ( entry - > d_name ) ;
found = true ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Multiple MANIFEST files found; use --path to select one " ) ;
closedir ( d ) ;
return ;
@ -637,7 +637,7 @@ ListColumnFamiliesCommand::ListColumnFamiliesCommand(
: LDBCommand ( options , flags , false , { } ) {
if ( params . size ( ) ! = 1 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" dbname must be specified for the list_column_families command " ) ;
} else {
dbname_ = params [ 0 ] ;
@ -780,7 +780,7 @@ void InternalDumpCommand::DoCommand() {
// Cast as DBImpl to get internal iterator
DBImpl * idb = dynamic_cast < DBImpl * > ( db_ ) ;
if ( ! idb ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " DB is not DBImpl " ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( " DB is not DBImpl " ) ;
return ;
}
string rtype1 , rtype2 , row , val ;
@ -792,7 +792,7 @@ void InternalDumpCommand::DoCommand() {
ScopedArenaIterator iter ( idb - > TEST_NewInternalIterator ( & arena ) ) ;
Status st = iter - > status ( ) ;
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " Iterator error: "
exec_state_ = LDBCommandExecuteResult : : Failed ( " Iterator error: "
+ st . ToString ( ) ) ;
}
@ -899,10 +899,10 @@ DBDumperCommand::DBDumperCommand(const vector<string>& params,
try {
max_keys_ = stoi ( itr - > second ) ;
} catch ( const invalid_argument & ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has an invalid value " ) ;
} catch ( const out_of_range & ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has a value out-of-range " ) ;
}
}
@ -961,7 +961,7 @@ void DBDumperCommand::DoCommand() {
Iterator * iter = db_ - > NewIterator ( ReadOptions ( ) ) ;
Status st = iter - > status ( ) ;
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " Iterator error. "
exec_state_ = LDBCommandExecuteResult : : Failed ( " Iterator error. "
+ st . ToString ( ) ) ;
}
@ -1094,7 +1094,7 @@ ReduceDBLevelsCommand::ReduceDBLevelsCommand(const vector<string>& params,
print_old_levels_ = IsFlagPresent ( flags , ARG_PRINT_OLD_LEVELS ) ;
if ( new_levels_ < = 0 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Use -- " + ARG_NEW_LEVELS + " to specify a new level number \n " ) ;
}
}
@ -1165,7 +1165,7 @@ Status ReduceDBLevelsCommand::GetOldNumOfLevels(Options& opt,
void ReduceDBLevelsCommand : : DoCommand ( ) {
if ( new_levels_ < = 1 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Invalid number of levels. \n " ) ;
return ;
}
@ -1175,7 +1175,7 @@ void ReduceDBLevelsCommand::DoCommand() {
int old_level_num = - 1 ;
st = GetOldNumOfLevels ( opt , & old_level_num ) ;
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
return ;
}
@ -1201,7 +1201,7 @@ void ReduceDBLevelsCommand::DoCommand() {
EnvOptions soptions ;
st = VersionSet : : ReduceNumberOfLevels ( db_path_ , & opt , soptions , new_levels_ ) ;
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
return ;
}
}
@ -1224,7 +1224,7 @@ ChangeCompactionStyleCommand::ChangeCompactionStyleCommand(
exec_state_ ) ;
if ( old_compaction_style_ ! = kCompactionStyleLevel & &
old_compaction_style_ ! = kCompactionStyleUniversal ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Use -- " + ARG_OLD_COMPACTION_STYLE + " to specify old compaction " +
" style. Check ldb help for proper compaction style value. \n " ) ;
return ;
@ -1234,14 +1234,14 @@ ChangeCompactionStyleCommand::ChangeCompactionStyleCommand(
exec_state_ ) ;
if ( new_compaction_style_ ! = kCompactionStyleLevel & &
new_compaction_style_ ! = kCompactionStyleUniversal ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Use -- " + ARG_NEW_COMPACTION_STYLE + " to specify new compaction " +
" style. Check ldb help for proper compaction style value. \n " ) ;
return ;
}
if ( new_compaction_style_ = = old_compaction_style_ ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Old compaction style is the same as new compaction style. "
" Nothing to do. \n " ) ;
return ;
@ -1249,7 +1249,7 @@ ChangeCompactionStyleCommand::ChangeCompactionStyleCommand(
if ( old_compaction_style_ = = kCompactionStyleUniversal & &
new_compaction_style_ = = kCompactionStyleLevel ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Convert from universal compaction to level compaction. "
" Nothing to do. \n " ) ;
return ;
@ -1320,14 +1320,14 @@ void ChangeCompactionStyleCommand::DoCommand() {
// level 0 should have only 1 file
if ( i = = 0 & & num_files ! = 1 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " Number of db files at "
exec_state_ = LDBCommandExecuteResult : : Failed ( " Number of db files at "
" level 0 after compaction is " + ToString ( num_files ) +
" , not 1. \n " ) ;
return ;
}
// other levels should have no file
if ( i > 0 & & num_files ! = 0 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( " Number of db files at "
exec_state_ = LDBCommandExecuteResult : : Failed ( " Number of db files at "
" level " + ToString ( i ) + " after compaction is " +
ToString ( num_files ) + " , not 0. \n " ) ;
return ;
@ -1395,7 +1395,7 @@ void DumpWalFile(std::string wal_file, bool print_header, bool print_values,
Status status = env_ - > NewSequentialFile ( wal_file , & file , soptions ) ;
if ( ! status . ok ( ) ) {
if ( exec_state ) {
* exec_state = LDBCommandExecuteResult : : FAILED ( " Failed to open WAL file " +
* exec_state = LDBCommandExecuteResult : : Failed ( " Failed to open WAL file " +
status . ToString ( ) ) ;
} else {
cerr < < " Error: Failed to open WAL file " < < status . ToString ( )
@ -1459,7 +1459,7 @@ WALDumperCommand::WALDumperCommand(const vector<string>& params,
print_header_ = IsFlagPresent ( flags , ARG_PRINT_HEADER ) ;
print_values_ = IsFlagPresent ( flags , ARG_PRINT_VALUE ) ;
if ( wal_file_ . empty ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Argument " + ARG_WAL_FILE + " must be specified. " ) ;
}
}
@ -1486,7 +1486,7 @@ GetCommand::GetCommand(const vector<string>& params,
ARG_VALUE_HEX } ) ) {
if ( params . size ( ) ! = 1 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" <key> must be specified for the get command " ) ;
} else {
key_ = params . at ( 0 ) ;
@ -1512,7 +1512,7 @@ void GetCommand::DoCommand() {
fprintf ( stdout , " %s \n " ,
( is_value_hex_ ? StringToHex ( value ) : value ) . c_str ( ) ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
}
@ -1527,7 +1527,7 @@ ApproxSizeCommand::ApproxSizeCommand(const vector<string>& params,
if ( options . find ( ARG_FROM ) ! = options . end ( ) ) {
start_key_ = options . find ( ARG_FROM ) - > second ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_FROM +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_FROM +
" must be specified for approxsize command " ) ;
return ;
}
@ -1535,7 +1535,7 @@ ApproxSizeCommand::ApproxSizeCommand(const vector<string>& params,
if ( options . find ( ARG_TO ) ! = options . end ( ) ) {
end_key_ = options . find ( ARG_TO ) - > second ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_TO +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_TO +
" must be specified for approxsize command " ) ;
return ;
}
@ -1563,7 +1563,7 @@ void ApproxSizeCommand::DoCommand() {
/* Weird that GetApproximateSizes() returns void, although documentation
* says that it returns a Status object .
if ( ! st . ok ( ) ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
*/
}
@ -1577,10 +1577,10 @@ BatchPutCommand::BatchPutCommand(const vector<string>& params,
ARG_CREATE_IF_MISSING } ) ) {
if ( params . size ( ) < 2 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" At least one <key> <value> pair must be specified batchput. " ) ;
} else if ( params . size ( ) % 2 ! = 0 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" Equal number of <key>s and <value>s must be specified for batchput. " ) ;
} else {
for ( size_t i = 0 ; i < params . size ( ) ; i + = 2 ) {
@ -1612,7 +1612,7 @@ void BatchPutCommand::DoCommand() {
if ( st . ok ( ) ) {
fprintf ( stdout , " OK \n " ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
}
@ -1656,10 +1656,10 @@ ScanCommand::ScanCommand(const vector<string>& params,
try {
max_keys_scanned_ = stoi ( itr - > second ) ;
} catch ( const invalid_argument & ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has an invalid value " ) ;
} catch ( const out_of_range & ) {
exec_state_ = LDBCommandExecuteResult : : FAILED ( ARG_MAX_KEYS +
exec_state_ = LDBCommandExecuteResult : : Failed ( ARG_MAX_KEYS +
" has a value out-of-range " ) ;
}
}
@ -1729,7 +1729,7 @@ void ScanCommand::DoCommand() {
}
}
if ( ! it - > status ( ) . ok ( ) ) { // Check for any errors found during the scan
exec_state_ = LDBCommandExecuteResult : : FAILED ( it - > status ( ) . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( it - > status ( ) . ToString ( ) ) ;
}
delete it ;
}
@ -1742,7 +1742,7 @@ DeleteCommand::DeleteCommand(const vector<string>& params,
BuildCmdLineOptions ( { ARG_HEX , ARG_KEY_HEX , ARG_VALUE_HEX } ) ) {
if ( params . size ( ) ! = 1 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" KEY must be specified for the delete command " ) ;
} else {
key_ = params . at ( 0 ) ;
@ -1763,7 +1763,7 @@ void DeleteCommand::DoCommand() {
if ( st . ok ( ) ) {
fprintf ( stdout , " OK \n " ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
}
@ -1775,7 +1775,7 @@ PutCommand::PutCommand(const vector<string>& params,
ARG_CREATE_IF_MISSING } ) ) {
if ( params . size ( ) ! = 2 ) {
exec_state_ = LDBCommandExecuteResult : : FAILED (
exec_state_ = LDBCommandExecuteResult : : Failed (
" <key> and <value> must be specified for the put command " ) ;
} else {
key_ = params . at ( 0 ) ;
@ -1804,7 +1804,7 @@ void PutCommand::DoCommand() {
if ( st . ok ( ) ) {
fprintf ( stdout , " OK \n " ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
}
@ -1922,7 +1922,7 @@ void CheckConsistencyCommand::DoCommand() {
if ( st . ok ( ) ) {
fprintf ( stdout , " OK \n " ) ;
} else {
exec_state_ = LDBCommandExecuteResult : : FAILED ( st . ToString ( ) ) ;
exec_state_ = LDBCommandExecuteResult : : Failed ( st . ToString ( ) ) ;
}
}