@ -133,12 +133,9 @@ bool NotifyCollectTableCollectorsOnFinish(
return all_succeeded ;
return all_succeeded ;
}
}
Status ReadProperties (
Status ReadProperties ( const Slice & handle_value , RandomAccessFile * file ,
const Slice & handle_value ,
Env * env , Logger * logger ,
RandomAccessFile * file ,
TableProperties * * table_properties ) {
Env * env ,
Logger * logger ,
TableProperties * table_properties ) {
assert ( table_properties ) ;
assert ( table_properties ) ;
Slice v = handle_value ;
Slice v = handle_value ;
@ -161,18 +158,22 @@ Status ReadProperties(
std : : unique_ptr < Iterator > iter (
std : : unique_ptr < Iterator > iter (
properties_block . NewIterator ( BytewiseComparator ( ) ) ) ;
properties_block . NewIterator ( BytewiseComparator ( ) ) ) ;
auto new_table_properties = new TableProperties ( ) ;
// All pre-defined properties of type uint64_t
// All pre-defined properties of type uint64_t
std : : unordered_map < std : : string , uint64_t * > predefined_uint64_properties = {
std : : unordered_map < std : : string , uint64_t * > predefined_uint64_properties = {
{ TablePropertiesNames : : kDataSize , & table_properties - > data_size } ,
{ TablePropertiesNames : : kDataSize , & new_table_properties - > data_size } ,
{ TablePropertiesNames : : kIndexSize , & table_properties - > index_size } ,
{ TablePropertiesNames : : kIndexSize , & new_table_properties - > index_size } ,
{ TablePropertiesNames : : kFilterSize , & table_properties - > filter_size } ,
{ TablePropertiesNames : : kFilterSize , & new_table_properties - > filter_size } ,
{ TablePropertiesNames : : kRawKeySize , & table_properties - > raw_key_size } ,
{ TablePropertiesNames : : kRawKeySize , & new_table_properties - > raw_key_size } ,
{ TablePropertiesNames : : kRawValueSize , & table_properties - > raw_value_size } ,
{ TablePropertiesNames : : kRawValueSize ,
& new_table_properties - > raw_value_size } ,
{ TablePropertiesNames : : kNumDataBlocks ,
{ TablePropertiesNames : : kNumDataBlocks ,
& table_properties - > num_data_blocks } ,
& new_table_properties - > num_data_blocks } ,
{ TablePropertiesNames : : kNumEntries , & table_properties - > num_entries } ,
{ TablePropertiesNames : : kNumEntries , & new_table_properties - > num_entries } ,
{ TablePropertiesNames : : kFormatVersion , & table_properties - > format_version } ,
{ TablePropertiesNames : : kFormatVersion ,
{ TablePropertiesNames : : kFixedKeyLen , & table_properties - > fixed_key_len } } ;
& new_table_properties - > format_version } ,
{ TablePropertiesNames : : kFixedKeyLen ,
& new_table_properties - > fixed_key_len } , } ;
std : : string last_key ;
std : : string last_key ;
for ( iter - > SeekToFirst ( ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
for ( iter - > SeekToFirst ( ) ; iter - > Valid ( ) ; iter - > Next ( ) ) {
@ -203,24 +204,25 @@ Status ReadProperties(
}
}
* ( pos - > second ) = val ;
* ( pos - > second ) = val ;
} else if ( key = = TablePropertiesNames : : kFilterPolicy ) {
} else if ( key = = TablePropertiesNames : : kFilterPolicy ) {
table_properties - > filter_policy_name = raw_val . ToString ( ) ;
new_ table_properties- > filter_policy_name = raw_val . ToString ( ) ;
} else {
} else {
// handle user-collected properties
// handle user-collected properties
table_properties - > user_collected_properties . insert (
new_ table_properties- > user_collected_properties . insert (
{ key , raw_val . ToString ( ) } ) ;
{ key , raw_val . ToString ( ) } ) ;
}
}
}
}
if ( s . ok ( ) ) {
* table_properties = new_table_properties ;
} else {
delete new_table_properties ;
}
return s ;
return s ;
}
}
Status ReadTableProperties (
Status ReadTableProperties ( RandomAccessFile * file , uint64_t file_size ,
RandomAccessFile * file ,
uint64_t table_magic_number , Env * env ,
uint64_t file_size ,
Logger * info_log , TableProperties * * properties ) {
uint64_t table_magic_number ,
Env * env ,
Logger * info_log ,
TableProperties * properties ) {
// -- Read metaindex block
// -- Read metaindex block
Footer footer ( table_magic_number ) ;
Footer footer ( table_magic_number ) ;
auto s = ReadFooterFromFile ( file , file_size , & footer ) ;
auto s = ReadFooterFromFile ( file , file_size , & footer ) ;