@ -38,13 +38,9 @@ namespace ROCKSDB_NAMESPACE {
// http://en.cppreference.com/w/cpp/concept/StandardLayoutType
// http://en.cppreference.com/w/cpp/concept/StandardLayoutType
// https://gist.github.com/graphitemaster/494f21190bb2c63c5516
// https://gist.github.com/graphitemaster/494f21190bb2c63c5516
# ifndef ROCKSDB_LITE
# ifndef ROCKSDB_LITE
static ColumnFamily Options dummy_cf_options ;
static ImmutableCF Options dummy_cf_options ;
template < typename T1 >
template < typename T1 >
int offset_of ( T1 ColumnFamilyOptions : : * member ) {
int offset_of ( T1 ImmutableCFOptions : : * member ) {
return int ( size_t ( & ( dummy_cf_options . * member ) ) - size_t ( & dummy_cf_options ) ) ;
}
template < typename T1 >
int offset_of ( T1 AdvancedColumnFamilyOptions : : * member ) {
return int ( size_t ( & ( dummy_cf_options . * member ) ) - size_t ( & dummy_cf_options ) ) ;
return int ( size_t ( & ( dummy_cf_options . * member ) ) - size_t ( & dummy_cf_options ) ) ;
}
}
@ -492,57 +488,58 @@ static std::unordered_map<std::string, OptionTypeInfo>
{ 0 , OptionType : : kBoolean , OptionVerificationType : : kDeprecated ,
{ 0 , OptionType : : kBoolean , OptionVerificationType : : kDeprecated ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " inplace_update_support " ,
{ " inplace_update_support " ,
{ offset_of ( & ColumnFamily Options: : inplace_update_support ) ,
{ offset_of ( & ImmutableCF Options: : inplace_update_support ) ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " level_compaction_dynamic_level_bytes " ,
{ " level_compaction_dynamic_level_bytes " ,
{ offset_of ( & ColumnFamily Options: : level_compaction_dynamic_level_bytes ) ,
{ offset_of ( & ImmutableCF Options: : level_compaction_dynamic_level_bytes ) ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " optimize_filters_for_hits " ,
{ " optimize_filters_for_hits " ,
{ offset_of ( & ColumnFamily Options: : optimize_filters_for_hits ) ,
{ offset_of ( & ImmutableCF Options: : optimize_filters_for_hits ) ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " force_consistency_checks " ,
{ " force_consistency_checks " ,
{ offset_of ( & ColumnFamily Options: : force_consistency_checks ) ,
{ offset_of ( & ImmutableCF Options: : force_consistency_checks ) ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionType : : kBoolean , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " purge_redundant_kvs_while_flush " ,
{ " purge_redundant_kvs_while_flush " ,
{ offset_of ( & ColumnFamily Options: : purge_redundant_kvs_while_flush ) ,
{ offset_of ( & ImmutableCF Options: : purge_redundant_kvs_while_flush ) ,
OptionType : : kBoolean , OptionVerificationType : : kDeprecated ,
OptionType : : kBoolean , OptionVerificationType : : kDeprecated ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " max_mem_compaction_level " ,
{ " max_mem_compaction_level " ,
{ 0 , OptionType : : kInt , OptionVerificationType : : kDeprecated ,
{ 0 , OptionType : : kInt , OptionVerificationType : : kDeprecated ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " max_write_buffer_number_to_maintain " ,
{ " max_write_buffer_number_to_maintain " ,
{ offset_of ( & ColumnFamily Options: : max_write_buffer_number_to_maintain ) ,
{ offset_of ( & ImmutableCF Options: : max_write_buffer_number_to_maintain ) ,
OptionType : : kInt , OptionVerificationType : : kNormal ,
OptionType : : kInt , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone , 0 } } ,
OptionTypeFlags : : kNone , 0 } } ,
{ " max_write_buffer_size_to_maintain " ,
{ " max_write_buffer_size_to_maintain " ,
{ offset_of ( & ColumnFamily Options: : max_write_buffer_size_to_maintain ) ,
{ offset_of ( & ImmutableCF Options: : max_write_buffer_size_to_maintain ) ,
OptionType : : kInt64T , OptionVerificationType : : kNormal ,
OptionType : : kInt64T , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " min_write_buffer_number_to_merge " ,
{ " min_write_buffer_number_to_merge " ,
{ offset_of ( & ColumnFamily Options: : min_write_buffer_number_to_merge ) ,
{ offset_of ( & ImmutableCF Options: : min_write_buffer_number_to_merge ) ,
OptionType : : kInt , OptionVerificationType : : kNormal ,
OptionType : : kInt , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone , 0 } } ,
OptionTypeFlags : : kNone , 0 } } ,
{ " num_levels " ,
{ " num_levels " ,
{ offset_of ( & ColumnFamily Options: : num_levels ) , OptionType : : kInt ,
{ offset_of ( & ImmutableCF Options: : num_levels ) , OptionType : : kInt ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone } } ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone } } ,
{ " bloom_locality " ,
{ " bloom_locality " ,
{ offset_of ( & ColumnFamily Options: : bloom_locality ) , OptionType : : kUInt32T ,
{ offset_of ( & ImmutableCF Options: : bloom_locality ) , OptionType : : kUInt32T ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone } } ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone } } ,
{ " rate_limit_delay_max_milliseconds " ,
{ " rate_limit_delay_max_milliseconds " ,
{ 0 , OptionType : : kUInt , OptionVerificationType : : kDeprecated ,
{ 0 , OptionType : : kUInt , OptionVerificationType : : kDeprecated ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " compression_per_level " ,
{ " compression_per_level " ,
OptionTypeInfo : : Vector < CompressionType > (
OptionTypeInfo : : Vector < CompressionType > (
offset_of ( & ColumnFamily Options: : compression_per_level ) ,
offset_of ( & ImmutableCF Options: : compression_per_level ) ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone ,
OptionVerificationType : : kNormal , OptionTypeFlags : : kNone ,
{ 0 , OptionType : : kCompressionType } ) } ,
{ 0 , OptionType : : kCompressionType } ) } ,
{ " comparator " ,
{ " comparator " ,
{ offset_of ( & ColumnFamilyOptions : : comparator ) , OptionType : : kComparator ,
{ offset_of ( & ImmutableCFOptions : : user_comparator ) ,
OptionVerificationType : : kByName , OptionTypeFlags : : kCompareLoose ,
OptionType : : kComparator , OptionVerificationType : : kByName ,
OptionTypeFlags : : kCompareLoose ,
// Parses the string and sets the corresponding comparator
// Parses the string and sets the corresponding comparator
[ ] ( const ConfigOptions & /*opts*/ , const std : : string & /*name*/ ,
[ ] ( const ConfigOptions & /*opts*/ , const std : : string & /*name*/ ,
const std : : string & value , char * addr ) {
const std : : string & value , char * addr ) {
@ -558,15 +555,15 @@ static std::unordered_map<std::string, OptionTypeInfo>
} } } ,
} } } ,
{ " memtable_insert_with_hint_prefix_extractor " ,
{ " memtable_insert_with_hint_prefix_extractor " ,
{ offset_of (
{ offset_of (
& ColumnFamily Options: : memtable_insert_with_hint_prefix_extractor ) ,
& ImmutableCF Options: : memtable_insert_with_hint_prefix_extractor ) ,
OptionType : : kSliceTransform , OptionVerificationType : : kByNameAllowNull ,
OptionType : : kSliceTransform , OptionVerificationType : : kByNameAllowNull ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " memtable_factory " ,
{ " memtable_factory " ,
{ offset_of ( & ColumnFamily Options: : memtable_factory ) ,
{ offset_of ( & ImmutableCF Options: : memtable_factory ) ,
OptionType : : kMemTableRepFactory , OptionVerificationType : : kByName ,
OptionType : : kMemTableRepFactory , OptionVerificationType : : kByName ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " memtable " ,
{ " memtable " ,
{ offset_of ( & ColumnFamily Options: : memtable_factory ) ,
{ offset_of ( & ImmutableCF Options: : memtable_factory ) ,
OptionType : : kMemTableRepFactory , OptionVerificationType : : kAlias ,
OptionType : : kMemTableRepFactory , OptionVerificationType : : kAlias ,
OptionTypeFlags : : kNone ,
OptionTypeFlags : : kNone ,
// Parses the value string and updates the memtable_factory
// Parses the value string and updates the memtable_factory
@ -582,13 +579,13 @@ static std::unordered_map<std::string, OptionTypeInfo>
return s ;
return s ;
} } } ,
} } } ,
{ " table_factory " , OptionTypeInfo : : AsCustomSharedPtr < TableFactory > (
{ " table_factory " , OptionTypeInfo : : AsCustomSharedPtr < TableFactory > (
offset_of ( & ColumnFamily Options: : table_factory ) ,
offset_of ( & ImmutableCF Options: : table_factory ) ,
OptionVerificationType : : kByName ,
OptionVerificationType : : kByName ,
( OptionTypeFlags : : kCompareLoose |
( OptionTypeFlags : : kCompareLoose |
OptionTypeFlags : : kStringNameOnly |
OptionTypeFlags : : kStringNameOnly |
OptionTypeFlags : : kDontPrepare ) ) } ,
OptionTypeFlags : : kDontPrepare ) ) } ,
{ " block_based_table_factory " ,
{ " block_based_table_factory " ,
{ offset_of ( & ColumnFamily Options: : table_factory ) ,
{ offset_of ( & ImmutableCF Options: : table_factory ) ,
OptionType : : kCustomizable , OptionVerificationType : : kAlias ,
OptionType : : kCustomizable , OptionVerificationType : : kAlias ,
OptionTypeFlags : : kShared | OptionTypeFlags : : kCompareLoose ,
OptionTypeFlags : : kShared | OptionTypeFlags : : kCompareLoose ,
// Parses the input value and creates a BlockBasedTableFactory
// Parses the input value and creates a BlockBasedTableFactory
@ -620,7 +617,7 @@ static std::unordered_map<std::string, OptionTypeInfo>
}
}
} } } ,
} } } ,
{ " plain_table_factory " ,
{ " plain_table_factory " ,
{ offset_of ( & ColumnFamily Options: : table_factory ) ,
{ offset_of ( & ImmutableCF Options: : table_factory ) ,
OptionType : : kCustomizable , OptionVerificationType : : kAlias ,
OptionType : : kCustomizable , OptionVerificationType : : kAlias ,
OptionTypeFlags : : kShared | OptionTypeFlags : : kCompareLoose ,
OptionTypeFlags : : kShared | OptionTypeFlags : : kCompareLoose ,
// Parses the input value and creates a PlainTableFactory
// Parses the input value and creates a PlainTableFactory
@ -651,15 +648,15 @@ static std::unordered_map<std::string, OptionTypeInfo>
}
}
} } } ,
} } } ,
{ " compaction_filter " ,
{ " compaction_filter " ,
{ offset_of ( & ColumnFamily Options: : compaction_filter ) ,
{ offset_of ( & ImmutableCF Options: : compaction_filter ) ,
OptionType : : kCompactionFilter , OptionVerificationType : : kByName ,
OptionType : : kCompactionFilter , OptionVerificationType : : kByName ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " compaction_filter_factory " ,
{ " compaction_filter_factory " ,
{ offset_of ( & ColumnFamily Options: : compaction_filter_factory ) ,
{ offset_of ( & ImmutableCF Options: : compaction_filter_factory ) ,
OptionType : : kCompactionFilterFactory , OptionVerificationType : : kByName ,
OptionType : : kCompactionFilterFactory , OptionVerificationType : : kByName ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " merge_operator " ,
{ " merge_operator " ,
{ offset_of ( & ColumnFamily Options: : merge_operator ) ,
{ offset_of ( & ImmutableCF Options: : merge_operator ) ,
OptionType : : kMergeOperator ,
OptionType : : kMergeOperator ,
OptionVerificationType : : kByNameAllowFromNull ,
OptionVerificationType : : kByNameAllowFromNull ,
OptionTypeFlags : : kCompareLoose ,
OptionTypeFlags : : kCompareLoose ,
@ -677,11 +674,11 @@ static std::unordered_map<std::string, OptionTypeInfo>
return Status : : OK ( ) ;
return Status : : OK ( ) ;
} } } ,
} } } ,
{ " compaction_style " ,
{ " compaction_style " ,
{ offset_of ( & ColumnFamily Options: : compaction_style ) ,
{ offset_of ( & ImmutableCF Options: : compaction_style ) ,
OptionType : : kCompactionStyle , OptionVerificationType : : kNormal ,
OptionType : : kCompactionStyle , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
{ " compaction_pri " ,
{ " compaction_pri " ,
{ offset_of ( & ColumnFamily Options: : compaction_pri ) ,
{ offset_of ( & ImmutableCF Options: : compaction_pri ) ,
OptionType : : kCompactionPri , OptionVerificationType : : kNormal ,
OptionType : : kCompactionPri , OptionVerificationType : : kNormal ,
OptionTypeFlags : : kNone } } ,
OptionTypeFlags : : kNone } } ,
} ;
} ;
@ -705,11 +702,10 @@ class ConfigurableCFOptions : public ConfigurableMutableCFOptions {
ConfigurableCFOptions ( const ColumnFamilyOptions & opts ,
ConfigurableCFOptions ( const ColumnFamilyOptions & opts ,
const std : : unordered_map < std : : string , std : : string > * map )
const std : : unordered_map < std : : string , std : : string > * map )
: ConfigurableMutableCFOptions ( MutableCFOptions ( opts ) ) ,
: ConfigurableMutableCFOptions ( MutableCFOptions ( opts ) ) ,
immutable_ ( opts ) ,
immutable_ ( ImmutableDBOptions ( ) , opts ) ,
cf_options_ ( opts ) ,
cf_options_ ( opts ) ,
opt_map_ ( map ) {
opt_map_ ( map ) {
ConfigurableHelper : : RegisterOptions ( * this , OptionsHelper : : kCFOptionsName ,
ConfigurableHelper : : RegisterOptions ( * this , & immutable_ ,
& immutable_ ,
& cf_immutable_options_type_info ) ;
& cf_immutable_options_type_info ) ;
}
}
@ -774,7 +770,7 @@ class ConfigurableCFOptions : public ConfigurableMutableCFOptions {
}
}
private :
private :
ColumnFamily Options immutable_ ;
ImmutableCF Options immutable_ ;
ColumnFamilyOptions cf_options_ ;
ColumnFamilyOptions cf_options_ ;
const std : : unordered_map < std : : string , std : : string > * opt_map_ ;
const std : : unordered_map < std : : string , std : : string > * opt_map_ ;
} ;
} ;
@ -792,18 +788,22 @@ std::unique_ptr<Configurable> CFOptionsAsConfigurable(
}
}
# endif // ROCKSDB_LITE
# endif // ROCKSDB_LITE
ImmutableCFOptions : : ImmutableCFOptions ( ) : ImmutableCFOptions ( Options ( ) ) { }
ImmutableCFOptions : : ImmutableCFOptions ( const Options & options )
ImmutableCFOptions : : ImmutableCFOptions ( const Options & options )
: ImmutableCFOptions ( ImmutableDBOptions ( options ) , options ) { }
: ImmutableCFOptions ( ImmutableDBOptions ( options ) , options ) { }
ImmutableCFOptions : : ImmutableCFOptions ( const ImmutableDBOptions & db_options ,
ImmutableCFOptions : : ImmutableCFOptions ( const ImmutableDBOptions & db_options ,
const ColumnFamilyOptions & cf_options )
const ColumnFamilyOptions & cf_options )
: compaction_style ( cf_options . compaction_style ) ,
: logger ( db_options . info_log ) ,
stats ( db_options . statistics ) ,
compaction_style ( cf_options . compaction_style ) ,
compaction_pri ( cf_options . compaction_pri ) ,
compaction_pri ( cf_options . compaction_pri ) ,
user_comparator ( cf_options . comparator ) ,
user_comparator ( cf_options . comparator ) ,
internal_comparator ( InternalKeyComparator ( cf_options . comparator ) ) ,
internal_comparator ( InternalKeyComparator ( cf_options . comparator ) ) ,
merge_operator ( cf_options . merge_operator . get ( ) ) ,
merge_operator ( cf_options . merge_operator ) ,
compaction_filter ( cf_options . compaction_filter ) ,
compaction_filter ( cf_options . compaction_filter ) ,
compaction_filter_factory ( cf_options . compaction_filter_factory . get ( ) ) ,
compaction_filter_factory ( cf_options . compaction_filter_factory ) ,
min_write_buffer_number_to_merge (
min_write_buffer_number_to_merge (
cf_options . min_write_buffer_number_to_merge ) ,
cf_options . min_write_buffer_number_to_merge ) ,
max_write_buffer_number_to_maintain (
max_write_buffer_number_to_maintain (
@ -812,9 +812,9 @@ ImmutableCFOptions::ImmutableCFOptions(const ImmutableDBOptions& db_options,
cf_options . max_write_buffer_size_to_maintain ) ,
cf_options . max_write_buffer_size_to_maintain ) ,
inplace_update_support ( cf_options . inplace_update_support ) ,
inplace_update_support ( cf_options . inplace_update_support ) ,
inplace_callback ( cf_options . inplace_callback ) ,
inplace_callback ( cf_options . inplace_callback ) ,
info_log ( db_options . info_log . get ( ) ) ,
info_log ( logger . get ( ) ) ,
statistics ( db_options . statistic s . get ( ) ) ,
statistics ( stats . get ( ) ) ,
rate_limiter ( db_options . rate_limiter . get ( ) ) ,
rate_limiter ( db_options . rate_limiter ) ,
info_log_level ( db_options . info_log_level ) ,
info_log_level ( db_options . info_log_level ) ,
env ( db_options . env ) ,
env ( db_options . env ) ,
fs ( db_options . fs . get ( ) ) ,
fs ( db_options . fs . get ( ) ) ,
@ -822,8 +822,8 @@ ImmutableCFOptions::ImmutableCFOptions(const ImmutableDBOptions& db_options,
allow_mmap_reads ( db_options . allow_mmap_reads ) ,
allow_mmap_reads ( db_options . allow_mmap_reads ) ,
allow_mmap_writes ( db_options . allow_mmap_writes ) ,
allow_mmap_writes ( db_options . allow_mmap_writes ) ,
db_paths ( db_options . db_paths ) ,
db_paths ( db_options . db_paths ) ,
memtable_factory ( cf_options . memtable_factory . get ( ) ) ,
memtable_factory ( cf_options . memtable_factory ) ,
table_factory ( cf_options . table_factory . get ( ) ) ,
table_factory ( cf_options . table_factory ) ,
table_properties_collector_factories (
table_properties_collector_factories (
cf_options . table_properties_collector_factories ) ,
cf_options . table_properties_collector_factories ) ,
advise_random_on_open ( db_options . advise_random_on_open ) ,
advise_random_on_open ( db_options . advise_random_on_open ) ,
@ -846,10 +846,10 @@ ImmutableCFOptions::ImmutableCFOptions(const ImmutableDBOptions& db_options,
listeners ( db_options . listeners ) ,
listeners ( db_options . listeners ) ,
row_cache ( db_options . row_cache ) ,
row_cache ( db_options . row_cache ) ,
memtable_insert_with_hint_prefix_extractor (
memtable_insert_with_hint_prefix_extractor (
cf_options . memtable_insert_with_hint_prefix_extractor . get ( ) ) ,
cf_options . memtable_insert_with_hint_prefix_extractor ) ,
cf_paths ( cf_options . cf_paths ) ,
cf_paths ( cf_options . cf_paths ) ,
compaction_thread_limiter ( cf_options . compaction_thread_limiter ) ,
compaction_thread_limiter ( cf_options . compaction_thread_limiter ) ,
file_checksum_gen_factory ( db_options . file_checksum_gen_factory . get ( ) ) ,
file_checksum_gen_factory ( db_options . file_checksum_gen_factory ) ,
sst_partitioner_factory ( cf_options . sst_partitioner_factory ) ,
sst_partitioner_factory ( cf_options . sst_partitioner_factory ) ,
allow_data_in_errors ( db_options . allow_data_in_errors ) ,
allow_data_in_errors ( db_options . allow_data_in_errors ) ,
db_host_id ( db_options . db_host_id ) ,
db_host_id ( db_options . db_host_id ) ,