@ -299,17 +299,17 @@ class MemTableInserter : public WriteBatch::Handler {
public :
public :
SequenceNumber sequence_ ;
SequenceNumber sequence_ ;
ColumnFamilyMemTables * cf_mems_ ;
ColumnFamilyMemTables * cf_mems_ ;
bool recovery _;
bool ignore_missing_column_families _;
uint64_t log_number_ ;
uint64_t log_number_ ;
DBImpl * db_ ;
DBImpl * db_ ;
const bool dont_filter_deletes_ ;
const bool dont_filter_deletes_ ;
MemTableInserter ( SequenceNumber sequence , ColumnFamilyMemTables * cf_mems ,
MemTableInserter ( SequenceNumber sequence , ColumnFamilyMemTables * cf_mems ,
bool recovery , uint64_t log_number , DB * db ,
bool ignore_missing_column_families , uint64_t log_number ,
const bool dont_filter_deletes )
DB * db , const bool dont_filter_deletes )
: sequence_ ( sequence ) ,
: sequence_ ( sequence ) ,
cf_mems_ ( cf_mems ) ,
cf_mems_ ( cf_mems ) ,
recovery_ ( recovery ) ,
ignore_missing_column_families_ ( ignore_missing_column_families ) ,
log_number_ ( log_number ) ,
log_number_ ( log_number ) ,
db_ ( reinterpret_cast < DBImpl * > ( db ) ) ,
db_ ( reinterpret_cast < DBImpl * > ( db ) ) ,
dont_filter_deletes_ ( dont_filter_deletes ) {
dont_filter_deletes_ ( dont_filter_deletes ) {
@ -321,12 +321,18 @@ class MemTableInserter : public WriteBatch::Handler {
bool SeekToColumnFamily ( uint32_t column_family_id , Status * s ) {
bool SeekToColumnFamily ( uint32_t column_family_id , Status * s ) {
bool found = cf_mems_ - > Seek ( column_family_id ) ;
bool found = cf_mems_ - > Seek ( column_family_id ) ;
if ( recovery_ & & ( ! found | | log_number_ < cf_mems_ - > GetLogNumber ( ) ) ) {
if ( ! found ) {
// if in recovery envoronment:
if ( ignore_missing_column_families_ ) {
// * If column family was not found, it might mean that the WAL write
* s = Status : : OK ( ) ;
// batch references to the column family that was dropped after the
} else {
// insert. We don't want to fail the whole write batch in that case -- we
* s = Status : : InvalidArgument (
// just ignore the update.
" Invalid column family specified in write batch " ) ;
}
return false ;
}
if ( log_number_ ! = 0 & & log_number_ < cf_mems_ - > GetLogNumber ( ) ) {
// This is true only in recovery environment (log_number_ is always 0 in
// non-recovery, regular write code-path)
// * If log_number_ < cf_mems_->GetLogNumber(), this means that column
// * If log_number_ < cf_mems_->GetLogNumber(), this means that column
// family already contains updates from this log. We can't apply updates
// family already contains updates from this log. We can't apply updates
// twice because of update-in-place or merge workloads -- ignore the
// twice because of update-in-place or merge workloads -- ignore the
@ -334,18 +340,8 @@ class MemTableInserter : public WriteBatch::Handler {
* s = Status : : OK ( ) ;
* s = Status : : OK ( ) ;
return false ;
return false ;
}
}
if ( ! found ) {
assert ( ! recovery_ ) ;
// If the column family was not found in non-recovery enviornment
// (client's write code-path), we have to fail the write and return
// the failure status to the client.
* s = Status : : InvalidArgument (
" Invalid column family specified in write batch " ) ;
return false ;
}
return true ;
return true ;
}
}
virtual Status PutCF ( uint32_t column_family_id , const Slice & key ,
virtual Status PutCF ( uint32_t column_family_id , const Slice & key ,
const Slice & value ) {
const Slice & value ) {
Status seek_status ;
Status seek_status ;
@ -503,10 +499,12 @@ class MemTableInserter : public WriteBatch::Handler {
Status WriteBatchInternal : : InsertInto ( const WriteBatch * b ,
Status WriteBatchInternal : : InsertInto ( const WriteBatch * b ,
ColumnFamilyMemTables * memtables ,
ColumnFamilyMemTables * memtables ,
bool recovery , uint64_t log_number ,
bool ignore_missing_column_families ,
DB * db , const bool dont_filter_deletes ) {
uint64_t log_number , DB * db ,
const bool dont_filter_deletes ) {
MemTableInserter inserter ( WriteBatchInternal : : Sequence ( b ) , memtables ,
MemTableInserter inserter ( WriteBatchInternal : : Sequence ( b ) , memtables ,
recovery , log_number , db , dont_filter_deletes ) ;
ignore_missing_column_families , log_number , db ,
dont_filter_deletes ) ;
return b - > Iterate ( & inserter ) ;
return b - > Iterate ( & inserter ) ;
}
}