@ -546,8 +546,7 @@ bool DBIter::MergeValuesNewToOld() {
// hit a put, merge the put value with operands and store the
// hit a put, merge the put value with operands and store the
// final result in saved_value_. We are done!
// final result in saved_value_. We are done!
const Slice val = iter_ . value ( ) ;
const Slice val = iter_ . value ( ) ;
Status s = Merge ( & val , ikey . user_key ) ;
if ( ! Merge ( & val , ikey . user_key ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
// iter_ is positioned after put
// iter_ is positioned after put
@ -576,8 +575,7 @@ bool DBIter::MergeValuesNewToOld() {
return false ;
return false ;
}
}
valid_ = true ;
valid_ = true ;
Status s = Merge ( & blob_value_ , ikey . user_key ) ;
if ( ! Merge ( & blob_value_ , ikey . user_key ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
@ -591,11 +589,18 @@ bool DBIter::MergeValuesNewToOld() {
}
}
return true ;
return true ;
} else if ( kTypeWideColumnEntity = = ikey . type ) {
} else if ( kTypeWideColumnEntity = = ikey . type ) {
// TODO: support wide-column entities
if ( ! MergeEntity ( iter_ . value ( ) , ikey . user_key ) ) {
status_ = Status : : NotSupported (
return false ;
" Merge currently not supported for wide-column entities " ) ;
}
// iter_ is positioned after put
iter_ . Next ( ) ;
if ( ! iter_ . status ( ) . ok ( ) ) {
valid_ = false ;
valid_ = false ;
return false ;
return false ;
}
return true ;
} else {
} else {
valid_ = false ;
valid_ = false ;
status_ = Status : : Corruption (
status_ = Status : : Corruption (
@ -614,8 +619,7 @@ bool DBIter::MergeValuesNewToOld() {
// a deletion marker.
// a deletion marker.
// feed null as the existing value to the merge operator, such that
// feed null as the existing value to the merge operator, such that
// client can differentiate this scenario and do things accordingly.
// client can differentiate this scenario and do things accordingly.
Status s = Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
assert ( status_ . ok ( ) ) ;
assert ( status_ . ok ( ) ) ;
@ -964,8 +968,7 @@ bool DBIter::FindValueForCurrentKey() {
if ( last_not_merge_type = = kTypeDeletion | |
if ( last_not_merge_type = = kTypeDeletion | |
last_not_merge_type = = kTypeSingleDeletion | |
last_not_merge_type = = kTypeSingleDeletion | |
last_not_merge_type = = kTypeDeletionWithTimestamp ) {
last_not_merge_type = = kTypeDeletionWithTimestamp ) {
s = Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
return true ;
return true ;
@ -980,8 +983,7 @@ bool DBIter::FindValueForCurrentKey() {
return false ;
return false ;
}
}
valid_ = true ;
valid_ = true ;
s = Merge ( & blob_value_ , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( & blob_value_ , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
@ -989,15 +991,14 @@ bool DBIter::FindValueForCurrentKey() {
return true ;
return true ;
} else if ( last_not_merge_type = = kTypeWideColumnEntity ) {
} else if ( last_not_merge_type = = kTypeWideColumnEntity ) {
// TODO: support wide-column entities
if ( ! MergeEntity ( pinned_value_ , saved_key_ . GetUserKey ( ) ) ) {
status_ = Status : : NotSupported (
" Merge currently not supported for wide-column entities " ) ;
valid_ = false ;
return false ;
return false ;
}
return true ;
} else {
} else {
assert ( last_not_merge_type = = kTypeValue ) ;
assert ( last_not_merge_type = = kTypeValue ) ;
s = Merge ( & pinned_value_ , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( & pinned_value_ , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
return true ;
return true ;
@ -1181,8 +1182,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
if ( ikey . type = = kTypeValue ) {
if ( ikey . type = = kTypeValue ) {
const Slice val = iter_ . value ( ) ;
const Slice val = iter_ . value ( ) ;
Status s = Merge ( & val , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( & val , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
return true ;
return true ;
@ -1201,8 +1201,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
return false ;
return false ;
}
}
valid_ = true ;
valid_ = true ;
Status s = Merge ( & blob_value_ , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( & blob_value_ , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
@ -1210,11 +1209,11 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
return true ;
return true ;
} else if ( ikey . type = = kTypeWideColumnEntity ) {
} else if ( ikey . type = = kTypeWideColumnEntity ) {
// TODO: support wide-column entities
if ( ! MergeEntity ( iter_ . value ( ) , saved_key_ . GetUserKey ( ) ) ) {
status_ = Status : : NotSupported (
" Merge currently not supported for wide-column entities " ) ;
valid_ = false ;
return false ;
return false ;
}
return true ;
} else {
} else {
valid_ = false ;
valid_ = false ;
status_ = Status : : Corruption (
status_ = Status : : Corruption (
@ -1224,8 +1223,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
}
}
}
}
Status s = Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ;
if ( ! Merge ( nullptr , saved_key_ . GetUserKey ( ) ) ) {
if ( ! s . ok ( ) ) {
return false ;
return false ;
}
}
@ -1248,7 +1246,7 @@ bool DBIter::FindValueForCurrentKeyUsingSeek() {
return true ;
return true ;
}
}
Status DBIter : : Merge ( const Slice * val , const Slice & user_key ) {
bool DBIter : : Merge ( const Slice * val , const Slice & user_key ) {
Status s = MergeHelper : : TimedFullMerge (
Status s = MergeHelper : : TimedFullMerge (
merge_operator_ , user_key , val , merge_context_ . GetOperands ( ) ,
merge_operator_ , user_key , val , merge_context_ . GetOperands ( ) ,
& saved_value_ , logger_ , statistics_ , clock_ , & pinned_value_ ,
& saved_value_ , logger_ , statistics_ , clock_ , & pinned_value_ ,
@ -1256,14 +1254,33 @@ Status DBIter::Merge(const Slice* val, const Slice& user_key) {
if ( ! s . ok ( ) ) {
if ( ! s . ok ( ) ) {
valid_ = false ;
valid_ = false ;
status_ = s ;
status_ = s ;
return s ;
return fal se ;
}
}
SetValueAndColumnsFromPlain ( pinned_value_ . data ( ) ? pinned_value_
SetValueAndColumnsFromPlain ( pinned_value_ . data ( ) ? pinned_value_
: saved_value_ ) ;
: saved_value_ ) ;
valid_ = true ;
valid_ = true ;
return s ;
return true ;
}
bool DBIter : : MergeEntity ( const Slice & entity , const Slice & user_key ) {
Status s = MergeHelper : : TimedFullMergeWithEntity (
merge_operator_ , user_key , entity , merge_context_ . GetOperands ( ) ,
& saved_value_ , logger_ , statistics_ , clock_ ,
/* update_num_ops_stats */ true ) ;
if ( ! s . ok ( ) ) {
valid_ = false ;
status_ = s ;
return false ;
}
if ( ! SetValueAndColumnsFromEntity ( saved_value_ ) ) {
return false ;
}
valid_ = true ;
return true ;
}
}
// Move backwards until the key smaller than saved_key_.
// Move backwards until the key smaller than saved_key_.