@ -1274,6 +1274,7 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
const uint64_t start_micros = env_ - > NowMicros ( ) ;
const uint64_t start_micros = env_ - > NowMicros ( ) ;
FileMetaData meta ;
FileMetaData meta ;
std : : vector < BlobFileAddition > blob_file_additions ;
std : : unique_ptr < std : : list < uint64_t > : : iterator > pending_outputs_inserted_elem (
std : : unique_ptr < std : : list < uint64_t > : : iterator > pending_outputs_inserted_elem (
new std : : list < uint64_t > : : iterator (
new std : : list < uint64_t > : : iterator (
@ -1326,10 +1327,10 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
s = BuildTable (
s = BuildTable (
dbname_ , versions_ . get ( ) , env_ , fs_ . get ( ) , * cfd - > ioptions ( ) ,
dbname_ , versions_ . get ( ) , env_ , fs_ . get ( ) , * cfd - > ioptions ( ) ,
mutable_cf_options , file_options_for_compaction_ , cfd - > table_cache ( ) ,
mutable_cf_options , file_options_for_compaction_ , cfd - > table_cache ( ) ,
iter . get ( ) , std : : move ( range_del_iters ) , & meta ,
iter . get ( ) , std : : move ( range_del_iters ) , & meta , & blob_file_additions ,
nullptr /* blob_file_additions */ , cfd - > internal_comparator ( ) ,
cfd - > internal_comparator ( ) , cfd - > int_tbl_prop_collector_factories ( ) ,
cfd - > int_tbl_prop_collector_factories ( ) , cfd - > GetID ( ) , cfd - > GetName ( ) ,
cfd - > GetID ( ) , cfd - > GetName ( ) , snapshot_seqs ,
snapshot_seqs , earliest_write_conflict_snapshot , snapshot_checker ,
earliest_write_conflict_snapshot , snapshot_checker ,
GetCompressionFlush ( * cfd - > ioptions ( ) , mutable_cf_options ) ,
GetCompressionFlush ( * cfd - > ioptions ( ) , mutable_cf_options ) ,
mutable_cf_options . sample_for_compression ,
mutable_cf_options . sample_for_compression ,
mutable_cf_options . compression_opts , paranoid_file_checks ,
mutable_cf_options . compression_opts , paranoid_file_checks ,
@ -1351,23 +1352,39 @@ Status DBImpl::WriteLevel0TableForRecovery(int job_id, ColumnFamilyData* cfd,
// Note that if file_size is zero, the file has been deleted and
// Note that if file_size is zero, the file has been deleted and
// should not be added to the manifest.
// should not be added to the manifest.
int level = 0 ;
const bool has_output = meta . fd . GetFileSize ( ) > 0 ;
if ( s . ok ( ) & & meta . fd . GetFileSize ( ) > 0 ) {
assert ( has_output | | blob_file_additions . empty ( ) ) ;
constexpr int level = 0 ;
if ( s . ok ( ) & & has_output ) {
edit - > AddFile ( level , meta . fd . GetNumber ( ) , meta . fd . GetPathId ( ) ,
edit - > AddFile ( level , meta . fd . GetNumber ( ) , meta . fd . GetPathId ( ) ,
meta . fd . GetFileSize ( ) , meta . smallest , meta . largest ,
meta . fd . GetFileSize ( ) , meta . smallest , meta . largest ,
meta . fd . smallest_seqno , meta . fd . largest_seqno ,
meta . fd . smallest_seqno , meta . fd . largest_seqno ,
meta . marked_for_compaction , meta . oldest_blob_file_number ,
meta . marked_for_compaction , meta . oldest_blob_file_number ,
meta . oldest_ancester_time , meta . file_creation_time ,
meta . oldest_ancester_time , meta . file_creation_time ,
meta . file_checksum , meta . file_checksum_func_name ) ;
meta . file_checksum , meta . file_checksum_func_name ) ;
edit - > SetBlobFileAdditions ( std : : move ( blob_file_additions ) ) ;
}
}
InternalStats : : CompactionStats stats ( CompactionReason : : kFlush , 1 ) ;
InternalStats : : CompactionStats stats ( CompactionReason : : kFlush , 1 ) ;
stats . micros = env_ - > NowMicros ( ) - start_micros ;
stats . micros = env_ - > NowMicros ( ) - start_micros ;
if ( has_output ) {
stats . bytes_written = meta . fd . GetFileSize ( ) ;
stats . bytes_written = meta . fd . GetFileSize ( ) ;
stats . num_output_files = 1 ;
const auto & blobs = edit - > GetBlobFileAdditions ( ) ;
for ( const auto & blob : blobs ) {
stats . bytes_written + = blob . GetTotalBlobBytes ( ) ;
}
stats . num_output_files = static_cast < int > ( blobs . size ( ) ) + 1 ;
}
cfd - > internal_stats ( ) - > AddCompactionStats ( level , Env : : Priority : : USER , stats ) ;
cfd - > internal_stats ( ) - > AddCompactionStats ( level , Env : : Priority : : USER , stats ) ;
cfd - > internal_stats ( ) - > AddCFStats ( InternalStats : : BYTES_FLUSHED ,
cfd - > internal_stats ( ) - > AddCFStats ( InternalStats : : BYTES_FLUSHED ,
meta . fd . GetFileSize ( ) ) ;
stats . bytes_written ) ;
RecordTick ( stats_ , COMPACT_WRITE_BYTES , meta . fd . GetFileSize ( ) ) ;
RecordTick ( stats_ , COMPACT_WRITE_BYTES , meta . fd . GetFileSize ( ) ) ;
return s ;
return s ;
}
}