@ -124,8 +124,8 @@ struct SavePoints {
std : : stack < SavePoint > stack ;
std : : stack < SavePoint > stack ;
} ;
} ;
WriteBatch : : WriteBatch ( size_t reserved_bytes )
WriteBatch : : WriteBatch ( size_t reserved_bytes , size_t max_bytes )
: save_points_ ( nullptr ) , content_flags_ ( 0 ) , rep_ ( ) {
: save_points_ ( nullptr ) , content_flags_ ( 0 ) , max_bytes_ ( max_bytes ) , rep_ ( ) {
rep_ . reserve ( ( reserved_bytes > WriteBatchInternal : : kHeader ) ?
rep_ . reserve ( ( reserved_bytes > WriteBatchInternal : : kHeader ) ?
reserved_bytes : WriteBatchInternal : : kHeader ) ;
reserved_bytes : WriteBatchInternal : : kHeader ) ;
rep_ . resize ( WriteBatchInternal : : kHeader ) ;
rep_ . resize ( WriteBatchInternal : : kHeader ) ;
@ -134,18 +134,21 @@ WriteBatch::WriteBatch(size_t reserved_bytes)
WriteBatch : : WriteBatch ( const std : : string & rep )
WriteBatch : : WriteBatch ( const std : : string & rep )
: save_points_ ( nullptr ) ,
: save_points_ ( nullptr ) ,
content_flags_ ( ContentFlags : : DEFERRED ) ,
content_flags_ ( ContentFlags : : DEFERRED ) ,
max_bytes_ ( 0 ) ,
rep_ ( rep ) { }
rep_ ( rep ) { }
WriteBatch : : WriteBatch ( const WriteBatch & src )
WriteBatch : : WriteBatch ( const WriteBatch & src )
: save_points_ ( src . save_points_ ) ,
: save_points_ ( src . save_points_ ) ,
wal_term_point_ ( src . wal_term_point_ ) ,
wal_term_point_ ( src . wal_term_point_ ) ,
content_flags_ ( src . content_flags_ . load ( std : : memory_order_relaxed ) ) ,
content_flags_ ( src . content_flags_ . load ( std : : memory_order_relaxed ) ) ,
max_bytes_ ( src . max_bytes_ ) ,
rep_ ( src . rep_ ) { }
rep_ ( src . rep_ ) { }
WriteBatch : : WriteBatch ( WriteBatch & & src )
WriteBatch : : WriteBatch ( WriteBatch & & src )
: save_points_ ( std : : move ( src . save_points_ ) ) ,
: save_points_ ( std : : move ( src . save_points_ ) ) ,
wal_term_point_ ( std : : move ( src . wal_term_point_ ) ) ,
wal_term_point_ ( std : : move ( src . wal_term_point_ ) ) ,
content_flags_ ( src . content_flags_ . load ( std : : memory_order_relaxed ) ) ,
content_flags_ ( src . content_flags_ . load ( std : : memory_order_relaxed ) ) ,
max_bytes_ ( src . max_bytes_ ) ,
rep_ ( std : : move ( src . rep_ ) ) { }
rep_ ( std : : move ( src . rep_ ) ) { }
WriteBatch & WriteBatch : : operator = ( const WriteBatch & src ) {
WriteBatch & WriteBatch : : operator = ( const WriteBatch & src ) {
@ -470,8 +473,9 @@ size_t WriteBatchInternal::GetFirstOffset(WriteBatch* b) {
return WriteBatchInternal : : kHeader ;
return WriteBatchInternal : : kHeader ;
}
}
void WriteBatchInternal : : Put ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Put ( WriteBatch * b , uint32_t column_family_id ,
const Slice & key , const Slice & value ) {
const Slice & key , const Slice & value ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeValue ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeValue ) ) ;
@ -484,15 +488,18 @@ void WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store (
b - > content_flags_ . store (
b - > content_flags_ . load ( std : : memory_order_relaxed ) | ContentFlags : : HAS_PUT ,
b - > content_flags_ . load ( std : : memory_order_relaxed ) | ContentFlags : : HAS_PUT ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Put ( ColumnFamilyHandle * column_family , const Slice & key ,
Status WriteBatch : : Put ( ColumnFamilyHandle * column_family , const Slice & key ,
const Slice & value ) {
const Slice & value ) {
WriteBatchInternal : : Put ( this , GetColumnFamilyID ( column_family ) , key , value ) ;
return WriteBatchInternal : : Put ( this , GetColumnFamilyID ( column_family ) , key ,
value ) ;
}
}
void WriteBatchInternal : : Put ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Put ( WriteBatch * b , uint32_t column_family_id ,
const SliceParts & key , const SliceParts & value ) {
const SliceParts & key , const SliceParts & value ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeValue ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeValue ) ) ;
@ -505,18 +512,21 @@ void WriteBatchInternal::Put(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store (
b - > content_flags_ . store (
b - > content_flags_ . load ( std : : memory_order_relaxed ) | ContentFlags : : HAS_PUT ,
b - > content_flags_ . load ( std : : memory_order_relaxed ) | ContentFlags : : HAS_PUT ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Put ( ColumnFamilyHandle * column_family , const SliceParts & key ,
Status WriteBatch : : Put ( ColumnFamilyHandle * column_family , const SliceParts & key ,
const SliceParts & value ) {
const SliceParts & value ) {
WriteBatchInternal : : Put ( this , GetColumnFamilyID ( column_family ) , key , value ) ;
return WriteBatchInternal : : Put ( this , GetColumnFamilyID ( column_family ) , key ,
value ) ;
}
}
void WriteBatchInternal : : InsertNoop ( WriteBatch * b ) {
Status WriteBatchInternal : : InsertNoop ( WriteBatch * b ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeNoop ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeNoop ) ) ;
return Status : : OK ( ) ;
}
}
void WriteBatchInternal : : MarkEndPrepare ( WriteBatch * b , const Slice & xid ) {
Status WriteBatchInternal : : MarkEndPrepare ( WriteBatch * b , const Slice & xid ) {
// a manually constructed batch can only contain one prepare section
// a manually constructed batch can only contain one prepare section
assert ( b - > rep_ [ 12 ] = = static_cast < char > ( kTypeNoop ) ) ;
assert ( b - > rep_ [ 12 ] = = static_cast < char > ( kTypeNoop ) ) ;
@ -535,26 +545,30 @@ void WriteBatchInternal::MarkEndPrepare(WriteBatch* b, const Slice& xid) {
ContentFlags : : HAS_END_PREPARE |
ContentFlags : : HAS_END_PREPARE |
ContentFlags : : HAS_BEGIN_PREPARE ,
ContentFlags : : HAS_BEGIN_PREPARE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return Status : : OK ( ) ;
}
}
void WriteBatchInternal : : MarkCommit ( WriteBatch * b , const Slice & xid ) {
Status WriteBatchInternal : : MarkCommit ( WriteBatch * b , const Slice & xid ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeCommitXID ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeCommitXID ) ) ;
PutLengthPrefixedSlice ( & b - > rep_ , xid ) ;
PutLengthPrefixedSlice ( & b - > rep_ , xid ) ;
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_COMMIT ,
ContentFlags : : HAS_COMMIT ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return Status : : OK ( ) ;
}
}
void WriteBatchInternal : : MarkRollback ( WriteBatch * b , const Slice & xid ) {
Status WriteBatchInternal : : MarkRollback ( WriteBatch * b , const Slice & xid ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeRollbackXID ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeRollbackXID ) ) ;
PutLengthPrefixedSlice ( & b - > rep_ , xid ) ;
PutLengthPrefixedSlice ( & b - > rep_ , xid ) ;
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_ROLLBACK ,
ContentFlags : : HAS_ROLLBACK ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return Status : : OK ( ) ;
}
}
void WriteBatchInternal : : Delete ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Delete ( WriteBatch * b , uint32_t column_family_id ,
const Slice & key ) {
const Slice & key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeDeletion ) ) ;
@ -566,14 +580,17 @@ void WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_DELETE ,
ContentFlags : : HAS_DELETE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Delete ( ColumnFamilyHandle * column_family , const Slice & key ) {
Status WriteBatch : : Delete ( ColumnFamilyHandle * column_family , const Slice & key ) {
WriteBatchInternal : : Delete ( this , GetColumnFamilyID ( column_family ) , key ) ;
return WriteBatchInternal : : Delete ( this , GetColumnFamilyID ( column_family ) ,
key ) ;
}
}
void WriteBatchInternal : : Delete ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Delete ( WriteBatch * b , uint32_t column_family_id ,
const SliceParts & key ) {
const SliceParts & key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeDeletion ) ) ;
@ -585,15 +602,19 @@ void WriteBatchInternal::Delete(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_DELETE ,
ContentFlags : : HAS_DELETE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Delete ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : Delete ( ColumnFamilyHandle * column_family ,
const SliceParts & key ) {
const SliceParts & key ) {
WriteBatchInternal : : Delete ( this , GetColumnFamilyID ( column_family ) , key ) ;
return WriteBatchInternal : : Delete ( this , GetColumnFamilyID ( column_family ) ,
key ) ;
}
}
void WriteBatchInternal : : SingleDelete ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : SingleDelete ( WriteBatch * b ,
const Slice & key ) {
uint32_t column_family_id ,
const Slice & key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeSingleDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeSingleDeletion ) ) ;
@ -605,15 +626,19 @@ void WriteBatchInternal::SingleDelete(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_SINGLE_DELETE ,
ContentFlags : : HAS_SINGLE_DELETE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : SingleDelete ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : SingleDelete ( ColumnFamilyHandle * column_family ,
const Slice & key ) {
const Slice & key ) {
WriteBatchInternal : : SingleDelete ( this , GetColumnFamilyID ( column_family ) , key ) ;
return WriteBatchInternal : : SingleDelete (
this , GetColumnFamilyID ( column_family ) , key ) ;
}
}
void WriteBatchInternal : : SingleDelete ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : SingleDelete ( WriteBatch * b ,
const SliceParts & key ) {
uint32_t column_family_id ,
const SliceParts & key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeSingleDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeSingleDeletion ) ) ;
@ -625,16 +650,19 @@ void WriteBatchInternal::SingleDelete(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_SINGLE_DELETE ,
ContentFlags : : HAS_SINGLE_DELETE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : SingleDelete ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : SingleDelete ( ColumnFamilyHandle * column_family ,
const SliceParts & key ) {
const SliceParts & key ) {
WriteBatchInternal : : SingleDelete ( this , GetColumnFamilyID ( column_family ) , key ) ;
return WriteBatchInternal : : SingleDelete (
this , GetColumnFamilyID ( column_family ) , key ) ;
}
}
void WriteBatchInternal : : DeleteRange ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : DeleteRange ( WriteBatch * b , uint32_t column_family_id ,
const Slice & begin_key ,
const Slice & begin_key ,
const Slice & end_key ) {
const Slice & end_key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeRangeDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeRangeDeletion ) ) ;
@ -647,17 +675,19 @@ void WriteBatchInternal::DeleteRange(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_DELETE_RANGE ,
ContentFlags : : HAS_DELETE_RANGE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : DeleteRange ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : DeleteRange ( ColumnFamilyHandle * column_family ,
const Slice & begin_key , const Slice & end_key ) {
const Slice & begin_key , const Slice & end_key ) {
WriteBatchInternal : : DeleteRange ( this , GetColumnFamilyID ( column_family ) ,
return WriteBatchInternal : : DeleteRange ( this , GetColumnFamilyID ( column_family ) ,
begin_key , end_key ) ;
begin_key , end_key ) ;
}
}
void WriteBatchInternal : : DeleteRange ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : DeleteRange ( WriteBatch * b , uint32_t column_family_id ,
const SliceParts & begin_key ,
const SliceParts & begin_key ,
const SliceParts & end_key ) {
const SliceParts & end_key ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeRangeDeletion ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeRangeDeletion ) ) ;
@ -670,17 +700,19 @@ void WriteBatchInternal::DeleteRange(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_DELETE_RANGE ,
ContentFlags : : HAS_DELETE_RANGE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : DeleteRange ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : DeleteRange ( ColumnFamilyHandle * column_family ,
const SliceParts & begin_key ,
const SliceParts & begin_key ,
const SliceParts & end_key ) {
const SliceParts & end_key ) {
WriteBatchInternal : : DeleteRange ( this , GetColumnFamilyID ( column_family ) ,
return WriteBatchInternal : : DeleteRange ( this , GetColumnFamilyID ( column_family ) ,
begin_key , end_key ) ;
begin_key , end_key ) ;
}
}
void WriteBatchInternal : : Merge ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Merge ( WriteBatch * b , uint32_t column_family_id ,
const Slice & key , const Slice & value ) {
const Slice & key , const Slice & value ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeMerge ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeMerge ) ) ;
@ -693,16 +725,19 @@ void WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_MERGE ,
ContentFlags : : HAS_MERGE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Merge ( ColumnFamilyHandle * column_family , const Slice & key ,
Status WriteBatch : : Merge ( ColumnFamilyHandle * column_family , const Slice & key ,
const Slice & value ) {
const Slice & value ) {
WriteBatchInternal : : Merge ( this , GetColumnFamilyID ( column_family ) , key , value ) ;
return WriteBatchInternal : : Merge ( this , GetColumnFamilyID ( column_family ) , key ,
value ) ;
}
}
void WriteBatchInternal : : Merge ( WriteBatch * b , uint32_t column_family_id ,
Status WriteBatchInternal : : Merge ( WriteBatch * b , uint32_t column_family_id ,
const SliceParts & key ,
const SliceParts & key ,
const SliceParts & value ) {
const SliceParts & value ) {
LocalSavePoint save ( b ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
WriteBatchInternal : : SetCount ( b , WriteBatchInternal : : Count ( b ) + 1 ) ;
if ( column_family_id = = 0 ) {
if ( column_family_id = = 0 ) {
b - > rep_ . push_back ( static_cast < char > ( kTypeMerge ) ) ;
b - > rep_ . push_back ( static_cast < char > ( kTypeMerge ) ) ;
@ -715,18 +750,20 @@ void WriteBatchInternal::Merge(WriteBatch* b, uint32_t column_family_id,
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
b - > content_flags_ . store ( b - > content_flags_ . load ( std : : memory_order_relaxed ) |
ContentFlags : : HAS_MERGE ,
ContentFlags : : HAS_MERGE ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : Merge ( ColumnFamilyHandle * column_family ,
Status WriteBatch : : Merge ( ColumnFamilyHandle * column_family ,
const SliceParts & key ,
const SliceParts & key , const SliceParts & value ) {
const SliceParts & value ) {
return WriteBatchInternal : : Merge ( this , GetColumnFamilyID ( column_family ) , key ,
WriteBatchInternal : : Merge ( this , GetColumnFamilyID ( column_family ) ,
value ) ;
key , value ) ;
}
}
void WriteBatch : : PutLogData ( const Slice & blob ) {
Status WriteBatch : : PutLogData ( const Slice & blob ) {
LocalSavePoint save ( this ) ;
rep_ . push_back ( static_cast < char > ( kTypeLogData ) ) ;
rep_ . push_back ( static_cast < char > ( kTypeLogData ) ) ;
PutLengthPrefixedSlice ( & rep_ , blob ) ;
PutLengthPrefixedSlice ( & rep_ , blob ) ;
return save . commit ( ) ;
}
}
void WriteBatch : : SetSavePoint ( ) {
void WriteBatch : : SetSavePoint ( ) {
@ -1300,14 +1337,15 @@ Status WriteBatchInternal::InsertInto(
return s ;
return s ;
}
}
void WriteBatchInternal : : SetContents ( WriteBatch * b , const Slice & contents ) {
Status WriteBatchInternal : : SetContents ( WriteBatch * b , const Slice & contents ) {
assert ( contents . size ( ) > = WriteBatchInternal : : kHeader ) ;
assert ( contents . size ( ) > = WriteBatchInternal : : kHeader ) ;
b - > rep_ . assign ( contents . data ( ) , contents . size ( ) ) ;
b - > rep_ . assign ( contents . data ( ) , contents . size ( ) ) ;
b - > content_flags_ . store ( ContentFlags : : DEFERRED , std : : memory_order_relaxed ) ;
b - > content_flags_ . store ( ContentFlags : : DEFERRED , std : : memory_order_relaxed ) ;
return Status : : OK ( ) ;
}
}
void WriteBatchInternal : : Append ( WriteBatch * dst , const WriteBatch * src ,
Status WriteBatchInternal : : Append ( WriteBatch * dst , const WriteBatch * src ,
const bool wal_only ) {
const bool wal_only ) {
size_t src_len ;
size_t src_len ;
int src_count ;
int src_count ;
uint32_t src_flags ;
uint32_t src_flags ;
@ -1330,6 +1368,7 @@ void WriteBatchInternal::Append(WriteBatch* dst, const WriteBatch* src,
dst - > content_flags_ . store (
dst - > content_flags_ . store (
dst - > content_flags_ . load ( std : : memory_order_relaxed ) | src_flags ,
dst - > content_flags_ . load ( std : : memory_order_relaxed ) | src_flags ,
std : : memory_order_relaxed ) ;
std : : memory_order_relaxed ) ;
return Status : : OK ( ) ;
}
}
size_t WriteBatchInternal : : AppendedByteSize ( size_t leftByteSize ,
size_t WriteBatchInternal : : AppendedByteSize ( size_t leftByteSize ,