@@ -1394,72 +1394,20 @@ func (p *pebbleMVCCScanner) seekVersion(
1394
1394
return true /* ok */ , false
1395
1395
}
1396
1396
1397
- seekKey := MVCCKey {Key : p .curUnsafeKey .Key , Timestamp : seekTS }
1398
- p .keyBuf = EncodeMVCCKeyToBuf (p .keyBuf [:0 ], seekKey )
1399
- origKey := p .keyBuf [:len (p .curUnsafeKey .Key )]
1400
- // We will need seekKey below, if the next's don't suffice. Even though the
1401
- // MVCCIterator will be at a different version of the same key, it is free
1402
- // to mutate the backing for p.curUnsafeKey.Key in an arbitrary manner. So
1403
- // assign to this copy, to make it stable.
1404
- seekKey .Key = origKey
1405
-
1406
- for i := 0 ; i < p .itersBeforeSeek ; i ++ {
1407
- if ! p .iterNext () {
1408
- p .setAdvanceKeyAtEnd ()
1409
- return true /* ok */ , false
1410
- }
1411
- if ! bytes .Equal (p .curUnsafeKey .Key , origKey ) {
1412
- p .incrementItersBeforeSeek ()
1413
- p .setAdvanceKeyAtNewKey (origKey )
1414
- return true /* ok */ , false
1415
- }
1416
- if p .curUnsafeKey .Timestamp .LessEq (seekTS ) {
1417
- p .incrementItersBeforeSeek ()
1418
- v , valid := p .getFromLazyValue ()
1419
- if ! valid {
1420
- return false , false
1421
- }
1422
- uncertaintyCheckRequired := uncertaintyCheck && ! p .curUnsafeKey .Timestamp .LessEq (p .ts )
1423
- if ! p .mvccHeaderRequired (uncertaintyCheckRequired ) {
1424
- if ! p .decodeCurrentValueIgnoringHeader (v ) {
1425
- return false , false
1426
- }
1427
- } else if extended , valid := p .tryDecodeCurrentValueSimple (v ); ! valid {
1428
- return false , false
1429
- } else if extended {
1430
- if ! p .decodeCurrentValueExtended (v ) {
1431
- return false , false
1432
- }
1433
- }
1434
- if ! uncertaintyCheckRequired {
1435
- if rkv , ok := p .coveredByRangeKey (p .curUnsafeKey .Timestamp ); ok {
1436
- return p .addSynthetic (ctx , p .curUnsafeKey .Key , rkv )
1437
- }
1438
- return p .add (ctx , p .curUnsafeKey .Key , p .curRawKey , p .curUnsafeValue .Value .RawBytes , v )
1439
- }
1440
- // Iterate through uncertainty interval. Though we found a value in
1441
- // the interval, it may not be uncertainty. This is because seekTS
1442
- // is set to the transaction's global uncertainty limit, so we are
1443
- // seeking based on the worst-case uncertainty, but values with a
1444
- // time in the range (uncertainty.LocalLimit, uncertainty.GlobalLimit]
1445
- // are only uncertain if they have an earlier local timestamp that is
1446
- // before uncertainty.LocalLimit. Meanwhile, any value with a time in
1447
- // the range (ts, uncertainty.LocalLimit] is uncertain.
1448
- localTS := p .curUnsafeValue .GetLocalTimestamp (p .curUnsafeKey .Timestamp )
1449
- if p .uncertainty .IsUncertain (p .curUnsafeKey .Timestamp , localTS ) {
1450
- return p .uncertaintyError (p .curUnsafeKey .Timestamp , localTS ), false
1451
- }
1452
- }
1453
- }
1454
-
1455
- p .decrementItersBeforeSeek ()
1397
+ p .keyBuf = append (p .keyBuf [:0 ], p .curUnsafeKey .Key ... )
1398
+ originalUserKey := p .keyBuf
1399
+ seekKey := MVCCKey {Key : originalUserKey , Timestamp : seekTS }
1400
+ // NB: We do not use a the p.itersBeforeSeek optimization here, because the
1401
+ // Pebble iterator is already equipped to detect successive SeekGEs to
1402
+ // increasing keys and optimize the seek using its own 'TrySeekUsingNext'
1403
+ // optimization.
1456
1404
if ! p .iterSeek (seekKey ) {
1457
1405
p .setAdvanceKeyAtEnd ()
1458
1406
return true /* ok */ , false
1459
1407
}
1460
1408
for {
1461
- if ! bytes .Equal (p .curUnsafeKey .Key , origKey ) {
1462
- p .setAdvanceKeyAtNewKey (origKey )
1409
+ if ! bytes .Equal (p .curUnsafeKey .Key , originalUserKey ) {
1410
+ p .setAdvanceKeyAtNewKey (originalUserKey )
1463
1411
return true /* ok */ , false
1464
1412
}
1465
1413
v , valid := p .getFromLazyValue ()
0 commit comments