@ -1008,7 +1008,8 @@ Status ParseDBOption(const std::string& name,
std : : string ParseBlockBasedTableOption ( const std : : string & name ,
std : : string ParseBlockBasedTableOption ( const std : : string & name ,
const std : : string & org_value ,
const std : : string & org_value ,
BlockBasedTableOptions * new_options ,
BlockBasedTableOptions * new_options ,
bool input_strings_escaped = false ) {
bool input_strings_escaped = false ,
bool ignore_unknown_options = false ) {
const std : : string & value =
const std : : string & value =
input_strings_escaped ? UnescapeOptionString ( org_value ) : org_value ;
input_strings_escaped ? UnescapeOptionString ( org_value ) : org_value ;
if ( ! input_strings_escaped ) {
if ( ! input_strings_escaped ) {
@ -1042,8 +1043,12 @@ std::string ParseBlockBasedTableOption(const std::string& name,
}
}
const auto iter = block_based_table_type_info . find ( name ) ;
const auto iter = block_based_table_type_info . find ( name ) ;
if ( iter = = block_based_table_type_info . end ( ) ) {
if ( iter = = block_based_table_type_info . end ( ) ) {
if ( ignore_unknown_options ) {
return " " ;
} else {
return " Unrecognized option " ;
return " Unrecognized option " ;
}
}
}
const auto & opt_info = iter - > second ;
const auto & opt_info = iter - > second ;
if ( opt_info . verification ! = OptionVerificationType : : kDeprecated & &
if ( opt_info . verification ! = OptionVerificationType : : kDeprecated & &
! ParseOptionHelper ( reinterpret_cast < char * > ( new_options ) + opt_info . offset ,
! ParseOptionHelper ( reinterpret_cast < char * > ( new_options ) + opt_info . offset ,
@ -1056,13 +1061,18 @@ std::string ParseBlockBasedTableOption(const std::string& name,
std : : string ParsePlainTableOptions ( const std : : string & name ,
std : : string ParsePlainTableOptions ( const std : : string & name ,
const std : : string & org_value ,
const std : : string & org_value ,
PlainTableOptions * new_options ,
PlainTableOptions * new_options ,
bool input_strings_escaped = false ) {
bool input_strings_escaped = false ,
bool ignore_unknown_options = false ) {
const std : : string & value =
const std : : string & value =
input_strings_escaped ? UnescapeOptionString ( org_value ) : org_value ;
input_strings_escaped ? UnescapeOptionString ( org_value ) : org_value ;
const auto iter = plain_table_type_info . find ( name ) ;
const auto iter = plain_table_type_info . find ( name ) ;
if ( iter = = plain_table_type_info . end ( ) ) {
if ( iter = = plain_table_type_info . end ( ) ) {
if ( ignore_unknown_options ) {
return " " ;
} else {
return " Unrecognized option " ;
return " Unrecognized option " ;
}
}
}
const auto & opt_info = iter - > second ;
const auto & opt_info = iter - > second ;
if ( opt_info . verification ! = OptionVerificationType : : kDeprecated & &
if ( opt_info . verification ! = OptionVerificationType : : kDeprecated & &
! ParseOptionHelper ( reinterpret_cast < char * > ( new_options ) + opt_info . offset ,
! ParseOptionHelper ( reinterpret_cast < char * > ( new_options ) + opt_info . offset ,
@ -1075,12 +1085,14 @@ std::string ParsePlainTableOptions(const std::string& name,
Status GetBlockBasedTableOptionsFromMap (
Status GetBlockBasedTableOptionsFromMap (
const BlockBasedTableOptions & table_options ,
const BlockBasedTableOptions & table_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
BlockBasedTableOptions * new_table_options , bool input_strings_escaped ) {
BlockBasedTableOptions * new_table_options , bool input_strings_escaped ,
bool ignore_unknown_options ) {
assert ( new_table_options ) ;
assert ( new_table_options ) ;
* new_table_options = table_options ;
* new_table_options = table_options ;
for ( const auto & o : opts_map ) {
for ( const auto & o : opts_map ) {
auto error_message = ParseBlockBasedTableOption (
auto error_message = ParseBlockBasedTableOption (
o . first , o . second , new_table_options , input_strings_escaped ) ;
o . first , o . second , new_table_options , input_strings_escaped ,
ignore_unknown_options ) ;
if ( error_message ! = " " ) {
if ( error_message ! = " " ) {
const auto iter = block_based_table_type_info . find ( o . first ) ;
const auto iter = block_based_table_type_info . find ( o . first ) ;
if ( iter = = block_based_table_type_info . end ( ) | |
if ( iter = = block_based_table_type_info . end ( ) | |
@ -1090,7 +1102,8 @@ Status GetBlockBasedTableOptionsFromMap(
( iter - > second . verification ! = OptionVerificationType : : kByName & &
( iter - > second . verification ! = OptionVerificationType : : kByName & &
iter - > second . verification ! =
iter - > second . verification ! =
OptionVerificationType : : kByNameAllowNull & &
OptionVerificationType : : kByNameAllowNull & &
iter - > second . verification ! = OptionVerificationType : : kDeprecated ) ) {
iter - > second . verification ! =
OptionVerificationType : : kDeprecated ) ) {
// Restore "new_options" to the default "base_options".
// Restore "new_options" to the default "base_options".
* new_table_options = table_options ;
* new_table_options = table_options ;
return Status : : InvalidArgument ( " Can't parse BlockBasedTableOptions: " ,
return Status : : InvalidArgument ( " Can't parse BlockBasedTableOptions: " ,
@ -1117,7 +1130,8 @@ Status GetBlockBasedTableOptionsFromString(
Status GetPlainTableOptionsFromMap (
Status GetPlainTableOptionsFromMap (
const PlainTableOptions & table_options ,
const PlainTableOptions & table_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
PlainTableOptions * new_table_options , bool input_strings_escaped ) {
PlainTableOptions * new_table_options , bool input_strings_escaped ,
bool ignore_unknown_options ) {
assert ( new_table_options ) ;
assert ( new_table_options ) ;
* new_table_options = table_options ;
* new_table_options = table_options ;
for ( const auto & o : opts_map ) {
for ( const auto & o : opts_map ) {
@ -1132,7 +1146,8 @@ Status GetPlainTableOptionsFromMap(
( iter - > second . verification ! = OptionVerificationType : : kByName & &
( iter - > second . verification ! = OptionVerificationType : : kByName & &
iter - > second . verification ! =
iter - > second . verification ! =
OptionVerificationType : : kByNameAllowNull & &
OptionVerificationType : : kByNameAllowNull & &
iter - > second . verification ! = OptionVerificationType : : kDeprecated ) ) {
iter - > second . verification ! =
OptionVerificationType : : kDeprecated ) ) {
// Restore "new_options" to the default "base_options".
// Restore "new_options" to the default "base_options".
* new_table_options = table_options ;
* new_table_options = table_options ;
return Status : : InvalidArgument ( " Can't parse PlainTableOptions: " ,
return Status : : InvalidArgument ( " Can't parse PlainTableOptions: " ,
@ -1229,16 +1244,19 @@ Status GetMemTableRepFactoryFromString(const std::string& opts_str,
Status GetColumnFamilyOptionsFromMap (
Status GetColumnFamilyOptionsFromMap (
const ColumnFamilyOptions & base_options ,
const ColumnFamilyOptions & base_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
ColumnFamilyOptions * new_options , bool input_strings_escaped ) {
ColumnFamilyOptions * new_options , bool input_strings_escaped ,
bool ignore_unknown_options ) {
return GetColumnFamilyOptionsFromMapInternal (
return GetColumnFamilyOptionsFromMapInternal (
base_options , opts_map , new_options , input_strings_escaped ) ;
base_options , opts_map , new_options , input_strings_escaped , nullptr ,
ignore_unknown_options ) ;
}
}
Status GetColumnFamilyOptionsFromMapInternal (
Status GetColumnFamilyOptionsFromMapInternal (
const ColumnFamilyOptions & base_options ,
const ColumnFamilyOptions & base_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
ColumnFamilyOptions * new_options , bool input_strings_escaped ,
ColumnFamilyOptions * new_options , bool input_strings_escaped ,
std : : vector < std : : string > * unsupported_options_names ) {
std : : vector < std : : string > * unsupported_options_names ,
bool ignore_unknown_options ) {
assert ( new_options ) ;
assert ( new_options ) ;
* new_options = base_options ;
* new_options = base_options ;
if ( unsupported_options_names ) {
if ( unsupported_options_names ) {
@ -1258,6 +1276,8 @@ Status GetColumnFamilyOptionsFromMapInternal(
// Note that we still return Status::OK in such case to maintain
// Note that we still return Status::OK in such case to maintain
// the backward compatibility in the old public API defined in
// the backward compatibility in the old public API defined in
// rocksdb/convenience.h
// rocksdb/convenience.h
} else if ( s . IsInvalidArgument ( ) & & ignore_unknown_options ) {
continue ;
} else {
} else {
// Restore "new_options" to the default "base_options".
// Restore "new_options" to the default "base_options".
* new_options = base_options ;
* new_options = base_options ;
@ -1284,16 +1304,19 @@ Status GetColumnFamilyOptionsFromString(
Status GetDBOptionsFromMap (
Status GetDBOptionsFromMap (
const DBOptions & base_options ,
const DBOptions & base_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
DBOptions * new_options , bool input_strings_escaped ) {
DBOptions * new_options , bool input_strings_escaped ,
return GetDBOptionsFromMapInternal (
bool ignore_unknown_options ) {
base_options , opts_map , new_options , input_strings_escaped ) ;
return GetDBOptionsFromMapInternal ( base_options , opts_map , new_options ,
input_strings_escaped , nullptr ,
ignore_unknown_options ) ;
}
}
Status GetDBOptionsFromMapInternal (
Status GetDBOptionsFromMapInternal (
const DBOptions & base_options ,
const DBOptions & base_options ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
const std : : unordered_map < std : : string , std : : string > & opts_map ,
DBOptions * new_options , bool input_strings_escaped ,
DBOptions * new_options , bool input_strings_escaped ,
std : : vector < std : : string > * unsupported_options_names ) {
std : : vector < std : : string > * unsupported_options_names ,
bool ignore_unknown_options ) {
assert ( new_options ) ;
assert ( new_options ) ;
* new_options = base_options ;
* new_options = base_options ;
if ( unsupported_options_names ) {
if ( unsupported_options_names ) {
@ -1313,6 +1336,8 @@ Status GetDBOptionsFromMapInternal(
// Note that we still return Status::OK in such case to maintain
// Note that we still return Status::OK in such case to maintain
// the backward compatibility in the old public API defined in
// the backward compatibility in the old public API defined in
// rocksdb/convenience.h
// rocksdb/convenience.h
} else if ( s . IsInvalidArgument ( ) & & ignore_unknown_options ) {
continue ;
} else {
} else {
// Restore "new_options" to the default "base_options".
// Restore "new_options" to the default "base_options".
* new_options = base_options ;
* new_options = base_options ;
@ -1360,12 +1385,14 @@ Status GetOptionsFromString(const Options& base_options,
Status GetTableFactoryFromMap (
Status GetTableFactoryFromMap (
const std : : string & factory_name ,
const std : : string & factory_name ,
const std : : unordered_map < std : : string , std : : string > & opt_map ,
const std : : unordered_map < std : : string , std : : string > & opt_map ,
std : : shared_ptr < TableFactory > * table_factory ) {
std : : shared_ptr < TableFactory > * table_factory , bool ignore_unknown_options ) {
Status s ;
Status s ;
if ( factory_name = = BlockBasedTableFactory ( ) . Name ( ) ) {
if ( factory_name = = BlockBasedTableFactory ( ) . Name ( ) ) {
BlockBasedTableOptions bbt_opt ;
BlockBasedTableOptions bbt_opt ;
s = GetBlockBasedTableOptionsFromMap ( BlockBasedTableOptions ( ) , opt_map ,
s = GetBlockBasedTableOptionsFromMap ( BlockBasedTableOptions ( ) , opt_map ,
& bbt_opt , true ) ;
& bbt_opt ,
true , /* input_strings_escaped */
ignore_unknown_options ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
}
}
@ -1374,7 +1401,8 @@ Status GetTableFactoryFromMap(
} else if ( factory_name = = PlainTableFactory ( ) . Name ( ) ) {
} else if ( factory_name = = PlainTableFactory ( ) . Name ( ) ) {
PlainTableOptions pt_opt ;
PlainTableOptions pt_opt ;
s = GetPlainTableOptionsFromMap ( PlainTableOptions ( ) , opt_map , & pt_opt ,
s = GetPlainTableOptionsFromMap ( PlainTableOptions ( ) , opt_map , & pt_opt ,
true ) ;
true , /* input_strings_escaped */
ignore_unknown_options ) ;
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
return s ;
return s ;
}
}