@ -252,8 +252,8 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname)
: env_ ( options . env ) ,
: env_ ( options . env ) ,
dbname_ ( dbname ) ,
dbname_ ( dbname ) ,
internal_comparator_ ( options . comparator ) ,
internal_comparator_ ( options . comparator ) ,
options_ ( SanitizeOptions (
options_ ( SanitizeOptions ( dbname , & internal_comparator_ ,
dbname , & internal_comparator_ , & internal_filter_policy_ , options ) ) ,
& internal_filter_policy_ , options ) ) ,
internal_filter_policy_ ( options . filter_policy ) ,
internal_filter_policy_ ( options . filter_policy ) ,
owns_info_log_ ( options_ . info_log ! = options . info_log ) ,
owns_info_log_ ( options_ . info_log ! = options . info_log ) ,
db_lock_ ( nullptr ) ,
db_lock_ ( nullptr ) ,
@ -261,8 +261,7 @@ DBImpl::DBImpl(const Options& options, const std::string& dbname)
shutting_down_ ( nullptr ) ,
shutting_down_ ( nullptr ) ,
bg_cv_ ( & mutex_ ) ,
bg_cv_ ( & mutex_ ) ,
mem_rep_factory_ ( options_ . memtable_factory . get ( ) ) ,
mem_rep_factory_ ( options_ . memtable_factory . get ( ) ) ,
mem_ ( new MemTable ( internal_comparator_ , mem_rep_factory_ ,
mem_ ( new MemTable ( internal_comparator_ , options_ ) ) ,
NumberLevels ( ) , options_ ) ) ,
logfile_number_ ( 0 ) ,
logfile_number_ ( 0 ) ,
super_version_ ( nullptr ) ,
super_version_ ( nullptr ) ,
tmp_batch_ ( ) ,
tmp_batch_ ( ) ,
@ -408,7 +407,7 @@ uint64_t DBImpl::TEST_Current_Manifest_FileNo() {
}
}
Status DBImpl : : NewDB ( ) {
Status DBImpl : : NewDB ( ) {
VersionEdit new_db ( NumberLevels ( ) ) ;
VersionEdit new_db ;
new_db . SetComparatorName ( user_comparator ( ) - > Name ( ) ) ;
new_db . SetComparatorName ( user_comparator ( ) - > Name ( ) ) ;
new_db . SetLogNumber ( 0 ) ;
new_db . SetLogNumber ( 0 ) ;
new_db . SetNextFile ( 2 ) ;
new_db . SetNextFile ( 2 ) ;
@ -1031,8 +1030,7 @@ Status DBImpl::RecoverLogFile(uint64_t log_number,
WriteBatchInternal : : SetContents ( & batch , record ) ;
WriteBatchInternal : : SetContents ( & batch , record ) ;
if ( mem = = nullptr ) {
if ( mem = = nullptr ) {
mem = new MemTable ( internal_comparator_ , mem_rep_factory_ ,
mem = new MemTable ( internal_comparator_ , options_ ) ;
NumberLevels ( ) , options_ ) ;
mem - > Ref ( ) ;
mem - > Ref ( ) ;
}
}
status = WriteBatchInternal : : InsertInto ( & batch , mem , & options_ ) ;
status = WriteBatchInternal : : InsertInto ( & batch , mem , & options_ ) ;
@ -1358,7 +1356,7 @@ void DBImpl::ReFitLevel(int level, int target_level) {
Log ( options_ . info_log , " Before refitting: \n %s " ,
Log ( options_ . info_log , " Before refitting: \n %s " ,
versions_ - > current ( ) - > DebugString ( ) . data ( ) ) ;
versions_ - > current ( ) - > DebugString ( ) . data ( ) ) ;
VersionEdit edit ( NumberLevels ( ) ) ;
VersionEdit edit ;
for ( const auto & f : versions_ - > current ( ) - > files_ [ level ] ) {
for ( const auto & f : versions_ - > current ( ) - > files_ [ level ] ) {
edit . DeleteFile ( level , f - > number ) ;
edit . DeleteFile ( level , f - > number ) ;
edit . AddFile ( to_level , f - > number , f - > file_size , f - > smallest , f - > largest ,
edit . AddFile ( to_level , f - > number , f - > file_size , f - > smallest , f - > largest ,
@ -3289,17 +3287,13 @@ Status DBImpl::MakeRoomForWrite(bool force,
EnvOptions soptions ( storage_options_ ) ;
EnvOptions soptions ( storage_options_ ) ;
soptions . use_mmap_writes = false ;
soptions . use_mmap_writes = false ;
DelayLoggingAndReset ( ) ;
DelayLoggingAndReset ( ) ;
s = env_ - > NewWritableFile (
s = env_ - > NewWritableFile ( LogFileName ( options_ . wal_dir , new_log_number ) ,
LogFileName ( options_ . wal_dir , new_log_number ) ,
& lfile , soptions ) ;
& lfile ,
soptions
) ;
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
// Our final size should be less than write_buffer_size
// Our final size should be less than write_buffer_size
// (compression, etc) but err on the side of caution.
// (compression, etc) but err on the side of caution.
lfile - > SetPreallocationBlockSize ( 1.1 * options_ . write_buffer_size ) ;
lfile - > SetPreallocationBlockSize ( 1.1 * options_ . write_buffer_size ) ;
memtmp = new MemTable (
memtmp = new MemTable ( internal_comparator_ , options_ ) ;
internal_comparator_ , mem_rep_factory_ , NumberLevels ( ) , options_ ) ;
new_superversion = new SuperVersion ( options_ . max_write_buffer_number ) ;
new_superversion = new SuperVersion ( options_ . max_write_buffer_number ) ;
}
}
}
}
@ -3680,7 +3674,7 @@ Status DBImpl::DeleteFile(std::string name) {
int level ;
int level ;
FileMetaData metadata ;
FileMetaData metadata ;
int maxlevel = NumberLevels ( ) ;
int maxlevel = NumberLevels ( ) ;
VersionEdit edit ( maxlevel ) ;
VersionEdit edit ;
DeletionState deletion_state ( 0 , true ) ;
DeletionState deletion_state ( 0 , true ) ;
{
{
MutexLock l ( & mutex_ ) ;
MutexLock l ( & mutex_ ) ;
@ -3802,7 +3796,7 @@ Status DB::Open(const Options& options, const std::string& dbname, DB** dbptr) {
return s ;
return s ;
}
}
impl - > mutex_ . Lock ( ) ;
impl - > mutex_ . Lock ( ) ;
VersionEdit edit ( impl - > NumberLevels ( ) ) ;
VersionEdit edit ;
s = impl - > Recover ( & edit ) ; // Handles create_if_missing, error_if_exists
s = impl - > Recover ( & edit ) ; // Handles create_if_missing, error_if_exists
if ( s . ok ( ) ) {
if ( s . ok ( ) ) {
uint64_t new_log_number = impl - > versions_ - > NewFileNumber ( ) ;
uint64_t new_log_number = impl - > versions_ - > NewFileNumber ( ) ;