@ -282,22 +282,24 @@ Status MergeHelper::MergeUntil(InternalIterator* iter,
return Status : : OK ( ) ;
return Status : : OK ( ) ;
}
}
// We are sure we have seen this key's entire history if we are at the
// We are sure we have seen this key's entire history if:
// last level and exhausted all internal keys of this user key.
// at_bottom == true (this does not necessarily mean it is the bottommost
// NOTE: !iter->Valid() does not necessarily mean we hit the
// layer, but rather that we are confident the key does not appear on any of
// beginning of a user key, as versions of a user key might be
// the lower layers, at_bottom == false doesn't mean it does appear, just
// split into multiple files (even files on the same level)
// that we can't be sure, see Compaction::IsBottommostLevel for details)
// and some files might not be included in the compaction/merge.
// AND
// we have either encountered another key or end of key history on this
// layer.
//
//
// There are also cases where we have seen the root of history of this
// When these conditions are true we are able to merge all the keys
// key without being sure of it. Then, we simply miss the opportunity
// using full merge.
//
// For these cases we are not sure about, we simply miss the opportunity
// to combine the keys. Since VersionSet::SetupOtherInputs() always makes
// to combine the keys. Since VersionSet::SetupOtherInputs() always makes
// sure that all merge-operands on the same level get compacted together,
// sure that all merge-operands on the same level get compacted together,
// this will simply lead to these merge operands moving to the next level.
// this will simply lead to these merge operands moving to the next level.
//
bool surely_seen_the_beginning = ( hit_the_next_user_key | | ! iter - > Valid ( ) )
// So, we only perform the following logic (to merge all operands together
& & at_bottom ;
// without a Put/Delete) if we are certain that we have seen the end of key.
bool surely_seen_the_beginning = hit_the_next_user_key & & at_bottom ;
if ( surely_seen_the_beginning ) {
if ( surely_seen_the_beginning ) {
// do a final merge with nullptr as the existing value and say
// do a final merge with nullptr as the existing value and say
// bye to the merge type (it's now converted to a Put)
// bye to the merge type (it's now converted to a Put)