@ -122,7 +122,7 @@ Status DBImpl::FlushMemTableToOutputFile(
env_options_for_compaction_ , versions_ . get ( ) , & mutex_ , & shutting_down_ ,
env_options_for_compaction_ , versions_ . get ( ) , & mutex_ , & shutting_down_ ,
snapshot_seqs , earliest_write_conflict_snapshot , snapshot_checker ,
snapshot_seqs , earliest_write_conflict_snapshot , snapshot_checker ,
job_context , log_buffer , directories_ . GetDbDir ( ) ,
job_context , log_buffer , directories_ . GetDbDir ( ) ,
directories_ . GetDataDir ( 0U ) ,
GetDataDir ( cfd , 0U ) ,
GetCompressionFlush ( * cfd - > ioptions ( ) , mutable_cf_options ) , stats_ ,
GetCompressionFlush ( * cfd - > ioptions ( ) , mutable_cf_options ) , stats_ ,
& event_logger_ , mutable_cf_options . report_bg_io_stats ) ;
& event_logger_ , mutable_cf_options . report_bg_io_stats ) ;
@ -195,7 +195,7 @@ Status DBImpl::FlushMemTableToOutputFile(
if ( sfm ) {
if ( sfm ) {
// Notify sst_file_manager that a new file was added
// Notify sst_file_manager that a new file was added
std : : string file_path = MakeTableFileName (
std : : string file_path = MakeTableFileName (
immutable_db_options_ . db _paths[ 0 ] . path , file_meta . fd . GetNumber ( ) ) ;
cfd - > ioptions ( ) - > cf _paths[ 0 ] . path , file_meta . fd . GetNumber ( ) ) ;
sfm - > OnAddFile ( file_path ) ;
sfm - > OnAddFile ( file_path ) ;
if ( sfm - > IsMaxAllowedSpaceReached ( ) & & bg_error_ . ok ( ) ) {
if ( sfm - > IsMaxAllowedSpaceReached ( ) & & bg_error_ . ok ( ) ) {
Status new_bg_error = Status : : NoSpace ( " Max allowed space was reached " ) ;
Status new_bg_error = Status : : NoSpace ( " Max allowed space was reached " ) ;
@ -240,7 +240,7 @@ void DBImpl::NotifyOnFlushBegin(ColumnFamilyData* cfd, FileMetaData* file_meta,
info . cf_name = cfd - > GetName ( ) ;
info . cf_name = cfd - > GetName ( ) ;
// TODO(yhchiang): make db_paths dynamic in case flush does not
// TODO(yhchiang): make db_paths dynamic in case flush does not
// go to L0 in the future.
// go to L0 in the future.
info . file_path = MakeTableFileName ( immutable_db_options_ . db _paths[ 0 ] . path ,
info . file_path = MakeTableFileName ( cfd - > ioptions ( ) - > cf _paths[ 0 ] . path ,
file_meta - > fd . GetNumber ( ) ) ;
file_meta - > fd . GetNumber ( ) ) ;
info . thread_id = env_ - > GetThreadID ( ) ;
info . thread_id = env_ - > GetThreadID ( ) ;
info . job_id = job_id ;
info . job_id = job_id ;
@ -285,7 +285,7 @@ void DBImpl::NotifyOnFlushCompleted(ColumnFamilyData* cfd,
info . cf_name = cfd - > GetName ( ) ;
info . cf_name = cfd - > GetName ( ) ;
// TODO(yhchiang): make db_paths dynamic in case flush does not
// TODO(yhchiang): make db_paths dynamic in case flush does not
// go to L0 in the future.
// go to L0 in the future.
info . file_path = MakeTableFileName ( immutable_db_options_ . db _paths[ 0 ] . path ,
info . file_path = MakeTableFileName ( cfd - > ioptions ( ) - > cf _paths[ 0 ] . path ,
file_meta - > fd . GetNumber ( ) ) ;
file_meta - > fd . GetNumber ( ) ) ;
info . thread_id = env_ - > GetThreadID ( ) ;
info . thread_id = env_ - > GetThreadID ( ) ;
info . job_id = job_id ;
info . job_id = job_id ;
@ -308,12 +308,13 @@ void DBImpl::NotifyOnFlushCompleted(ColumnFamilyData* cfd,
Status DBImpl : : CompactRange ( const CompactRangeOptions & options ,
Status DBImpl : : CompactRange ( const CompactRangeOptions & options ,
ColumnFamilyHandle * column_family ,
ColumnFamilyHandle * column_family ,
const Slice * begin , const Slice * end ) {
const Slice * begin , const Slice * end ) {
if ( options . target_path_id > = immutable_db_options_ . db_paths . size ( ) ) {
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
auto cfd = cfh - > cfd ( ) ;
if ( options . target_path_id > = cfd - > ioptions ( ) - > cf_paths . size ( ) ) {
return Status : : InvalidArgument ( " Invalid target path ID " ) ;
return Status : : InvalidArgument ( " Invalid target path ID " ) ;
}
}
auto cfh = reinterpret_cast < ColumnFamilyHandleImpl * > ( column_family ) ;
auto cfd = cfh - > cfd ( ) ;
bool exclusive = options . exclusive_manual_compaction ;
bool exclusive = options . exclusive_manual_compaction ;
bool flush_needed = true ;
bool flush_needed = true ;
@ -579,7 +580,7 @@ Status DBImpl::CompactFilesImpl(
version - > GetColumnFamilyMetaData ( & cf_meta ) ;
version - > GetColumnFamilyMetaData ( & cf_meta ) ;
if ( output_path_id < 0 ) {
if ( output_path_id < 0 ) {
if ( immutable_db_options_ . db _paths. size ( ) = = 1U ) {
if ( cfd - > ioptions ( ) - > cf _paths. size ( ) = = 1U ) {
output_path_id = 0 ;
output_path_id = 0 ;
} else {
} else {
return Status : : NotSupported (
return Status : : NotSupported (
@ -651,8 +652,9 @@ Status DBImpl::CompactFilesImpl(
job_context - > job_id , c . get ( ) , immutable_db_options_ ,
job_context - > job_id , c . get ( ) , immutable_db_options_ ,
env_options_for_compaction_ , versions_ . get ( ) , & shutting_down_ ,
env_options_for_compaction_ , versions_ . get ( ) , & shutting_down_ ,
preserve_deletes_seqnum_ . load ( ) , log_buffer , directories_ . GetDbDir ( ) ,
preserve_deletes_seqnum_ . load ( ) , log_buffer , directories_ . GetDbDir ( ) ,
directories_ . GetDataDir ( c - > output_path_id ( ) ) , stats_ , & mutex_ , & bg_error_ ,
GetDataDir ( c - > column_family_data ( ) , c - > output_path_id ( ) ) ,
snapshot_seqs , earliest_write_conflict_snapshot , snapshot_checker ,
stats_ , & mutex_ , & bg_error_ , snapshot_seqs ,
earliest_write_conflict_snapshot , snapshot_checker ,
table_cache_ , & event_logger_ ,
table_cache_ , & event_logger_ ,
c - > mutable_cf_options ( ) - > paranoid_file_checks ,
c - > mutable_cf_options ( ) - > paranoid_file_checks ,
c - > mutable_cf_options ( ) - > report_bg_io_stats , dbname_ ,
c - > mutable_cf_options ( ) - > report_bg_io_stats , dbname_ ,
@ -729,7 +731,7 @@ Status DBImpl::CompactFilesImpl(
if ( output_file_names ! = nullptr ) {
if ( output_file_names ! = nullptr ) {
for ( const auto newf : c - > edit ( ) - > GetNewFiles ( ) ) {
for ( const auto newf : c - > edit ( ) - > GetNewFiles ( ) ) {
( * output_file_names ) . push_back ( TableFileName (
( * output_file_names ) . push_back ( TableFileName (
immutable_db_options_ . db _paths, newf . second . fd . GetNumber ( ) ,
c - > immutable_cf_options ( ) - > cf _paths, newf . second . fd . GetNumber ( ) ,
newf . second . fd . GetPathId ( ) ) ) ;
newf . second . fd . GetPathId ( ) ) ) ;
}
}
}
}
@ -805,7 +807,7 @@ void DBImpl::NotifyOnCompactionCompleted(
info . compression = c - > output_compression ( ) ;
info . compression = c - > output_compression ( ) ;
for ( size_t i = 0 ; i < c - > num_input_levels ( ) ; + + i ) {
for ( size_t i = 0 ; i < c - > num_input_levels ( ) ; + + i ) {
for ( const auto fmd : * c - > inputs ( i ) ) {
for ( const auto fmd : * c - > inputs ( i ) ) {
auto fn = TableFileName ( immutable_db_options_ . db _paths,
auto fn = TableFileName ( c - > immutable_cf_options ( ) - > cf _paths,
fmd - > fd . GetNumber ( ) , fmd - > fd . GetPathId ( ) ) ;
fmd - > fd . GetNumber ( ) , fmd - > fd . GetPathId ( ) ) ;
info . input_files . push_back ( fn ) ;
info . input_files . push_back ( fn ) ;
if ( info . table_properties . count ( fn ) = = 0 ) {
if ( info . table_properties . count ( fn ) = = 0 ) {
@ -818,7 +820,8 @@ void DBImpl::NotifyOnCompactionCompleted(
}
}
}
}
for ( const auto newf : c - > edit ( ) - > GetNewFiles ( ) ) {
for ( const auto newf : c - > edit ( ) - > GetNewFiles ( ) ) {
info . output_files . push_back ( TableFileName ( immutable_db_options_ . db_paths ,
info . output_files . push_back ( TableFileName (
c - > immutable_cf_options ( ) - > cf_paths ,
newf . second . fd . GetNumber ( ) ,
newf . second . fd . GetNumber ( ) ,
newf . second . fd . GetPathId ( ) ) ) ;
newf . second . fd . GetPathId ( ) ) ) ;
}
}
@ -1292,10 +1295,9 @@ void DBImpl::SchedulePendingCompaction(ColumnFamilyData* cfd) {
}
}
void DBImpl : : SchedulePendingPurge ( std : : string fname , FileType type ,
void DBImpl : : SchedulePendingPurge ( std : : string fname , FileType type ,
uint64_t number , uint32_t path_id ,
uint64_t number , int job_id ) {
int job_id ) {
mutex_ . AssertHeld ( ) ;
mutex_ . AssertHeld ( ) ;
PurgeFileInfo file_info ( fname , type , number , path_id , job_id ) ;
PurgeFileInfo file_info ( fname , type , number , job_id ) ;
purge_queue_ . push_back ( std : : move ( file_info ) ) ;
purge_queue_ . push_back ( std : : move ( file_info ) ) ;
}
}
@ -1876,8 +1878,9 @@ Status DBImpl::BackgroundCompaction(bool* made_progress,
job_context - > job_id , c . get ( ) , immutable_db_options_ ,
job_context - > job_id , c . get ( ) , immutable_db_options_ ,
env_options_for_compaction_ , versions_ . get ( ) , & shutting_down_ ,
env_options_for_compaction_ , versions_ . get ( ) , & shutting_down_ ,
preserve_deletes_seqnum_ . load ( ) , log_buffer , directories_ . GetDbDir ( ) ,
preserve_deletes_seqnum_ . load ( ) , log_buffer , directories_ . GetDbDir ( ) ,
directories_ . GetDataDir ( c - > output_path_id ( ) ) , stats_ , & mutex_ ,
GetDataDir ( c - > column_family_data ( ) , c - > output_path_id ( ) ) ,
& bg_error_ , snapshot_seqs , earliest_write_conflict_snapshot ,
stats_ , & mutex_ , & bg_error_ ,
snapshot_seqs , earliest_write_conflict_snapshot ,
snapshot_checker , table_cache_ , & event_logger_ ,
snapshot_checker , table_cache_ , & event_logger_ ,
c - > mutable_cf_options ( ) - > paranoid_file_checks ,
c - > mutable_cf_options ( ) - > paranoid_file_checks ,
c - > mutable_cf_options ( ) - > report_bg_io_stats , dbname_ ,
c - > mutable_cf_options ( ) - > report_bg_io_stats , dbname_ ,