@ -11,36 +11,50 @@ namespace {
inline double SafeDivide ( double a , double b ) { return b = = 0.0 ? 0 : a / b ; }
inline double SafeDivide ( double a , double b ) { return b = = 0.0 ? 0 : a / b ; }
} // namespace
} // namespace
void EventLoggerHelpers : : AppendCurrentTime ( JSONWriter * jwriter ) {
* jwriter < < " time_micros "
< < std : : chrono : : duration_cast < std : : chrono : : microseconds > (
std : : chrono : : system_clock : : now ( ) . time_since_epoch ( ) ) . count ( ) ;
}
void EventLoggerHelpers : : LogTableFileCreation (
void EventLoggerHelpers : : LogTableFileCreation (
EventLogger * event_logger , int job_id , uint64_t file_number ,
EventLogger * event_logger , int job_id , uint64_t file_number ,
uint64_t file_size , const TableProperties & table_properties ) {
uint64_t file_size , const TableProperties & table_properties ) {
auto stream = event_logger - > Log ( ) ;
JSONWriter jwriter ;
stream < < " job " < < job_id < < " event "
AppendCurrentTime ( & jwriter ) ;
< < " table_file_creation "
jwriter < < " job " < < job_id
< < " file_number " < < file_number < < " file_size " < < file_size
< < " event " < < " table_file_creation "
< < " table_properties " ;
< < " file_number " < < file_number
stream . StartObject ( ) ;
< < " file_size " < < file_size ;
// basic properties:
// table_properties
stream < < " data_size " < < table_properties . data_size
{
< < " index_size " < < table_properties . index_size
jwriter < < " table_properties " ;
< < " filter_size " < < table_properties . filter_size
jwriter . StartObject ( ) ;
< < " raw_key_size " < < table_properties . raw_key_size
< < " raw_average_key_size " < < SafeDivide ( table_properties . raw_key_size ,
// basic properties:
table_properties . num_entries )
jwriter < < " data_size " < < table_properties . data_size
< < " raw_value_size " < < table_properties . raw_value_size
< < " index_size " < < table_properties . index_size
< < " raw_average_value_size " < < SafeDivide (
< < " filter_size " < < table_properties . filter_size
table_properties . raw_value_size , table_properties . num_entries )
< < " raw_key_size " < < table_properties . raw_key_size
< < " num_data_blocks " < < table_properties . num_data_blocks
< < " raw_average_key_size " < < SafeDivide (
< < " num_entries " < < table_properties . num_entries
table_properties . raw_key_size ,
< < " filter_policy_name " < < table_properties . filter_policy_name ;
table_properties . num_entries )
< < " raw_value_size " < < table_properties . raw_value_size
// user collected properties
< < " raw_average_value_size " < < SafeDivide (
for ( const auto & prop : table_properties . user_collected_properties ) {
table_properties . raw_value_size , table_properties . num_entries )
stream < < prop . first < < prop . second ;
< < " num_data_blocks " < < table_properties . num_data_blocks
< < " num_entries " < < table_properties . num_entries
< < " filter_policy_name " < < table_properties . filter_policy_name ;
// user collected properties
for ( const auto & prop : table_properties . user_collected_properties ) {
jwriter < < prop . first < < prop . second ;
}
jwriter . EndObject ( ) ;
}
}
stream . EndObject ( ) ;
event_logger - > Log ( jwriter ) ;
}
}
} // namespace rocksdb
} // namespace rocksdb