@@ -255,25 +255,16 @@ func (w *RawColumnWriter) ComparePrev(k []byte) int {
255255 return int (w .dataBlock .KeyWriter .ComparePrev (k ).UserKeyComparison )
256256}
257257
258- // IsPrefixEqualPrev compares the provided user key's prefix to the key
259- // prefix of the last point key written to the writer.
258+ // IsLikelyMVCCGarbage implements the RawWriter interface.
260259//
261- // If no key has been written yet, IsPrefixEqualPrev returns false.
262- //
263- // Must not be called after Writer is closed.
264- func (w * RawColumnWriter ) IsPrefixEqualPrev (k []byte ) bool {
260+ // If no key has been written yet, IsLikelyMVCCGarbage returns false.
261+ func (w * RawColumnWriter ) IsLikelyMVCCGarbage (k []byte , keyKind base.InternalKeyKind ) bool {
265262 if w == nil || w .dataBlock .Rows () == 0 {
266263 return false
267264 }
268- return w .dataBlock .KeyWriter .ComparePrev (k ).PrefixEqual ()
269- }
270-
271- // PrevPointKeyKind implements the RawWriter interface.
272- func (w * RawColumnWriter ) PrevPointKeyKind () base.InternalKeyKind {
273- if w == nil || w .dataBlock .Rows () == 0 {
274- return base .InternalKeyKindInvalid
275- }
276- return w .prevPointKey .trailer .Kind ()
265+ return w .prevPointKey .trailer .Kind ().IsSet () &&
266+ keyKind .IsSet () &&
267+ w .dataBlock .KeyWriter .ComparePrev (k ).PrefixEqual ()
277268}
278269
279270// SetSnapshotPinnedProperties sets the properties for pinned keys. Should only
@@ -641,9 +632,6 @@ func (w *RawColumnWriter) evaluatePoint(
641632 key .Pretty (w .comparer .FormatKey ))
642633 }
643634
644- prefixEqual := func (k []byte ) bool {
645- return w .IsPrefixEqualPrev (k )
646- }
647635 // We might want to write this key's value to a value block if it has the
648636 // same prefix.
649637 //
@@ -660,7 +648,7 @@ func (w *RawColumnWriter) evaluatePoint(
660648 useValueBlock := ! w .opts .DisableValueBlocks &&
661649 w .valueBlock != nil &&
662650 valueLen > 0 &&
663- IsLikelyMVCCGarbage (key .UserKey , prevKeyKind , keyKind , valueLen , prefixEqual )
651+ w . IsLikelyMVCCGarbage (key .UserKey , key . Kind () )
664652 if ! useValueBlock {
665653 return eval , nil
666654 }
@@ -1293,25 +1281,3 @@ func (w *RawColumnWriter) SetValueSeparationProps(
12931281 w .props .ValueSeparationMinSize = minValueSize
12941282 w .props .ValueSeparationBySuffixDisabled = disableSeparationBySuffix
12951283}
1296-
1297- // IsLikelyMVCCGarbage determines whether the given user key is likely MVCC
1298- // garbage.
1299- //
1300- // We require:
1301- //
1302- // . The previous key to be a SET/SETWITHDEL.
1303- // . The current key to be a SET/SETWITHDEL.
1304- // . The current key to have the same prefix as the previous key.
1305- func IsLikelyMVCCGarbage (
1306- k []byte ,
1307- prevKeyKind , keyKind base.InternalKeyKind ,
1308- valueLen int ,
1309- prefixEqual func (k []byte ) bool ,
1310- ) bool {
1311- isSetStarKind := func (k base.InternalKeyKind ) bool {
1312- return k == InternalKeyKindSet || k == InternalKeyKindSetWithDelete
1313- }
1314- return isSetStarKind (prevKeyKind ) &&
1315- isSetStarKind (keyKind ) &&
1316- prefixEqual (k )
1317- }
0 commit comments