diff --git a/pkg/ccl/storageccl/engineccl/encrypted_fs_test.go b/pkg/ccl/storageccl/engineccl/encrypted_fs_test.go index afd8c681b7bb..0e1b027e40f0 100644 --- a/pkg/ccl/storageccl/engineccl/encrypted_fs_test.go +++ b/pkg/ccl/storageccl/engineccl/encrypted_fs_test.go @@ -244,7 +244,7 @@ func TestPebbleEncryption(t *testing.T) { require.NoError(t, batch.Put(storage.MVCCKey{Key: roachpb.Key("a")}, []byte("a"))) require.NoError(t, batch.Commit(true)) require.NoError(t, db.Flush()) - val, err := db.Get(storage.MVCCKey{Key: roachpb.Key("a")}) + val, err := db.MVCCGet(storage.MVCCKey{Key: roachpb.Key("a")}) require.NoError(t, err) require.Equal(t, "a", string(val)) db.Close() @@ -266,7 +266,7 @@ func TestPebbleEncryption(t *testing.T) { Opts: opts2, }) require.NoError(t, err) - val, err = db.Get(storage.MVCCKey{Key: roachpb.Key("a")}) + val, err = db.MVCCGet(storage.MVCCKey{Key: roachpb.Key("a")}) require.NoError(t, err) require.Equal(t, "a", string(val)) diff --git a/pkg/ccl/storageccl/export.go b/pkg/ccl/storageccl/export.go index e47c16626c7c..97af3bf04916 100644 --- a/pkg/ccl/storageccl/export.go +++ b/pkg/ccl/storageccl/export.go @@ -156,7 +156,7 @@ func evalExport( maxSize = targetSize + uint64(allowedOverage) } for start := args.Key; start != nil; { - data, summary, resume, err := e.ExportToSst(start, args.EndKey, args.StartTime, + data, summary, resume, err := e.ExportMVCCToSst(start, args.EndKey, args.StartTime, h.Timestamp, exportAllRevisions, targetSize, maxSize, io) if err != nil { return result.Result{}, err diff --git a/pkg/ccl/storageccl/export_test.go b/pkg/ccl/storageccl/export_test.go index 83461957a3df..0ad3e9e16181 100644 --- a/pkg/ccl/storageccl/export_test.go +++ b/pkg/ccl/storageccl/export_test.go @@ -433,7 +433,7 @@ func assertEqualKVs( var summary roachpb.BulkOpSummary maxSize := uint64(0) prevStart := start - sst, summary, start, err = e.ExportToSst(start, endKey, startTime, endTime, + sst, summary, start, err = e.ExportMVCCToSst(start, endKey, startTime, endTime, exportAllRevisions, targetSize, maxSize, io) require.NoError(t, err) loaded := loadSST(t, sst, startKey, endKey) @@ -472,7 +472,7 @@ func assertEqualKVs( if dataSizeWhenExceeded == maxSize { maxSize-- } - _, _, _, err = e.ExportToSst(prevStart, endKey, startTime, endTime, + _, _, _, err = e.ExportMVCCToSst(prevStart, endKey, startTime, endTime, exportAllRevisions, targetSize, maxSize, io) require.Regexp(t, fmt.Sprintf("export size \\(%d bytes\\) exceeds max size \\(%d bytes\\)", dataSizeWhenExceeded, maxSize), err) diff --git a/pkg/ccl/storageccl/writebatch.go b/pkg/ccl/storageccl/writebatch.go index 3a8518a9a880..0838beceff10 100644 --- a/pkg/ccl/storageccl/writebatch.go +++ b/pkg/ccl/storageccl/writebatch.go @@ -84,7 +84,7 @@ func clearExistingData( ) (enginepb.MVCCStats, error) { { isEmpty := true - if err := batch.Iterate(start, end, func(_ storage.MVCCKeyValue) error { + if err := batch.MVCCIterate(start, end, func(_ storage.MVCCKeyValue) error { isEmpty = false return iterutil.StopIteration() // stop right away }); err != nil { diff --git a/pkg/cli/debug.go b/pkg/cli/debug.go index 87d819a4818e..8d1a1e157931 100644 --- a/pkg/cli/debug.go +++ b/pkg/cli/debug.go @@ -215,7 +215,7 @@ func runDebugKeys(cmd *cobra.Command, args []string) error { } results := 0 - return db.Iterate(debugCtx.startKey.Key, debugCtx.endKey.Key, func(kv storage.MVCCKeyValue) error { + return db.MVCCIterate(debugCtx.startKey.Key, debugCtx.endKey.Key, func(kv storage.MVCCKeyValue) error { done, err := printer(kv) if err != nil { return err @@ -380,7 +380,7 @@ func loadRangeDescriptor( start := keys.LocalRangePrefix end := keys.LocalRangeMax - if err := db.Iterate(start, end, handleKV); err != nil { + if err := db.MVCCIterate(start, end, handleKV); err != nil { return roachpb.RangeDescriptor{}, err } if desc.RangeID == rangeID { @@ -401,7 +401,7 @@ func runDebugRangeDescriptors(cmd *cobra.Command, args []string) error { start := keys.LocalRangePrefix end := keys.LocalRangeMax - return db.Iterate(start, end, func(kv storage.MVCCKeyValue) error { + return db.MVCCIterate(start, end, func(kv storage.MVCCKeyValue) error { if kvserver.IsRangeDescriptorKey(kv.Key) != nil { return nil } @@ -531,7 +531,7 @@ func runDebugRaftLog(cmd *cobra.Command, args []string) error { string(storage.EncodeKey(storage.MakeMVCCMetadataKey(start))), string(storage.EncodeKey(storage.MakeMVCCMetadataKey(end)))) - return db.Iterate(start, end, func(kv storage.MVCCKeyValue) error { + return db.MVCCIterate(start, end, func(kv storage.MVCCKeyValue) error { kvserver.PrintKeyValue(kv) return nil }) diff --git a/pkg/cli/debug_check_store.go b/pkg/cli/debug_check_store.go index 90039c2ab1c7..a58eef737323 100644 --- a/pkg/cli/debug_check_store.go +++ b/pkg/cli/debug_check_store.go @@ -224,7 +224,7 @@ func checkStoreRaftState( return err } - // Iterate over the entire range-id-local space. + // MVCCIterate over the entire range-id-local space. start := roachpb.Key(keys.LocalRangeIDPrefix) end := start.PrefixEnd() diff --git a/pkg/cli/debug_synctest.go b/pkg/cli/debug_synctest.go index 2dc463c38eeb..40d2b69ce991 100644 --- a/pkg/cli/debug_synctest.go +++ b/pkg/cli/debug_synctest.go @@ -144,7 +144,7 @@ func runSyncer( } fmt.Fprintf(stderr, "verifying existing sequence numbers...") - if err := db.Iterate(roachpb.KeyMin, roachpb.KeyMax, check); err != nil { + if err := db.MVCCIterate(roachpb.KeyMin, roachpb.KeyMax, check); err != nil { return 0, err } // We must not lose writes, but sometimes we get extra ones (i.e. we caught an diff --git a/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go b/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go index fdd7bb0927ce..0324777d7112 100644 --- a/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go +++ b/pkg/kv/kvclient/kvcoord/txn_coord_sender_test.go @@ -414,8 +414,8 @@ func verifyCleanup(key roachpb.Key, eng storage.Engine, t *testing.T, coords ... } } meta := &enginepb.MVCCMetadata{} - //lint:ignore SA1019 historical usage of deprecated eng.GetProto is OK - ok, _, _, err := eng.GetProto(storage.MakeMVCCMetadataKey(key), meta) + //lint:ignore SA1019 historical usage of deprecated eng.MVCCGetProto is OK + ok, _, _, err := eng.MVCCGetProto(storage.MakeMVCCMetadataKey(key), meta) if err != nil { return fmt.Errorf("error getting MVCC metadata: %s", err) } diff --git a/pkg/kv/kvserver/batch_spanset_test.go b/pkg/kv/kvserver/batch_spanset_test.go index 490047e5b961..f43d290595ec 100644 --- a/pkg/kv/kvserver/batch_spanset_test.go +++ b/pkg/kv/kvserver/batch_spanset_test.go @@ -118,21 +118,21 @@ func TestSpanSetBatchBoundaries(t *testing.T) { t.Run("reads inside range", func(t *testing.T) { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if value, err := batch.Get(insideKey); err != nil { + if value, err := batch.MVCCGet(insideKey); err != nil { t.Errorf("failed to read inside the range: %+v", err) } else if !bytes.Equal(value, []byte("value")) { t.Errorf("failed to read previously written value, got %q", value) } - //lint:ignore SA1019 historical usage of deprecated batch.GetProto is OK - if _, _, _, err := batch.GetProto(insideKey, nil); err != nil { - t.Errorf("GetProto: unexpected error %v", err) + //lint:ignore SA1019 historical usage of deprecated batch.MVCCGetProto is OK + if _, _, _, err := batch.MVCCGetProto(insideKey, nil); err != nil { + t.Errorf("MVCCGetProto: unexpected error %v", err) } - if err := batch.Iterate(insideKey.Key, insideKey2.Key, + if err := batch.MVCCIterate(insideKey.Key, insideKey2.Key, func(v storage.MVCCKeyValue) error { return nil }, ); err != nil { - t.Errorf("Iterate: unexpected error %v", err) + t.Errorf("MVCCIterate: unexpected error %v", err) } }) @@ -143,37 +143,37 @@ func TestSpanSetBatchBoundaries(t *testing.T) { t.Run("reads before range", func(t *testing.T) { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if _, err := batch.Get(outsideKey); !isReadSpanErr(err) { + if _, err := batch.MVCCGet(outsideKey); !isReadSpanErr(err) { t.Errorf("Get: unexpected error %v", err) } - //lint:ignore SA1019 historical usage of deprecated batch.GetProto is OK - if _, _, _, err := batch.GetProto(outsideKey, nil); !isReadSpanErr(err) { - t.Errorf("GetProto: unexpected error %v", err) + //lint:ignore SA1019 historical usage of deprecated batch.MVCCGetProto is OK + if _, _, _, err := batch.MVCCGetProto(outsideKey, nil); !isReadSpanErr(err) { + t.Errorf("MVCCGetProto: unexpected error %v", err) } - if err := batch.Iterate(outsideKey.Key, insideKey2.Key, + if err := batch.MVCCIterate(outsideKey.Key, insideKey2.Key, func(v storage.MVCCKeyValue) error { return errors.Errorf("unexpected callback: %v", v) }, ); !isReadSpanErr(err) { - t.Errorf("Iterate: unexpected error %v", err) + t.Errorf("MVCCIterate: unexpected error %v", err) } }) t.Run("reads after range", func(t *testing.T) { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if _, err := batch.Get(outsideKey3); !isReadSpanErr(err) { + if _, err := batch.MVCCGet(outsideKey3); !isReadSpanErr(err) { t.Errorf("Get: unexpected error %v", err) } - //lint:ignore SA1019 historical usage of deprecated batch.GetProto is OK - if _, _, _, err := batch.GetProto(outsideKey3, nil); !isReadSpanErr(err) { - t.Errorf("GetProto: unexpected error %v", err) + //lint:ignore SA1019 historical usage of deprecated batch.MVCCGetProto is OK + if _, _, _, err := batch.MVCCGetProto(outsideKey3, nil); !isReadSpanErr(err) { + t.Errorf("MVCCGetProto: unexpected error %v", err) } - if err := batch.Iterate(insideKey2.Key, outsideKey4.Key, + if err := batch.MVCCIterate(insideKey2.Key, outsideKey4.Key, func(v storage.MVCCKeyValue) error { return errors.Errorf("unexpected callback: %v", v) }, ); !isReadSpanErr(err) { - t.Errorf("Iterate: unexpected error %v", err) + t.Errorf("MVCCIterate: unexpected error %v", err) } }) @@ -349,7 +349,7 @@ func TestSpanSetBatchTimestamps(t *testing.T) { // Reads. for _, batch := range []storage.Batch{batchBefore, batchDuring} { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if res, err := batch.Get(rkey); err != nil { + if res, err := batch.MVCCGet(rkey); err != nil { t.Errorf("failed to read inside the range: %+v", err) } else if !bytes.Equal(res, value) { t.Errorf("failed to read previously written value, got %q", res) @@ -362,20 +362,20 @@ func TestSpanSetBatchTimestamps(t *testing.T) { for _, batch := range []storage.Batch{batchAfter, batchNonMVCC} { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if _, err := batch.Get(rkey); !isReadSpanErr(err) { + if _, err := batch.MVCCGet(rkey); !isReadSpanErr(err) { t.Errorf("Get: unexpected error %v", err) } - //lint:ignore SA1019 historical usage of deprecated batch.GetProto is OK - if _, _, _, err := batch.GetProto(rkey, nil); !isReadSpanErr(err) { - t.Errorf("GetProto: unexpected error %v", err) + //lint:ignore SA1019 historical usage of deprecated batch.MVCCGetProto is OK + if _, _, _, err := batch.MVCCGetProto(rkey, nil); !isReadSpanErr(err) { + t.Errorf("MVCCGetProto: unexpected error %v", err) } - if err := batch.Iterate(rkey.Key, rkey.Key, + if err := batch.MVCCIterate(rkey.Key, rkey.Key, func(v storage.MVCCKeyValue) error { return errors.Errorf("unexpected callback: %v", v) }, ); !isReadSpanErr(err) { - t.Errorf("Iterate: unexpected error %v", err) + t.Errorf("MVCCIterate: unexpected error %v", err) } } } @@ -510,7 +510,7 @@ func TestSpanSetNonMVCCBatch(t *testing.T) { // Reads. for _, batch := range []storage.Batch{batchNonMVCC, batchMVCC} { //lint:ignore SA1019 historical usage of deprecated batch.Get is OK - if res, err := batch.Get(rkey); err != nil { + if res, err := batch.MVCCGet(rkey); err != nil { t.Errorf("read disallowed through non-MVCC latch: %+v", err) } else if !bytes.Equal(res, value) { t.Errorf("failed to read previously written value, got %q", res) diff --git a/pkg/kv/kvserver/batcheval/cmd_clear_range.go b/pkg/kv/kvserver/batcheval/cmd_clear_range.go index 4b45dc5be064..59eb7463b805 100644 --- a/pkg/kv/kvserver/batcheval/cmd_clear_range.go +++ b/pkg/kv/kvserver/batcheval/cmd_clear_range.go @@ -87,7 +87,7 @@ func ClearRange( // instead of using a range tombstone (inefficient for small ranges). if total := statsDelta.Total(); total < ClearRangeBytesThreshold { log.VEventf(ctx, 2, "delta=%d < threshold=%d; using non-range clear", total, ClearRangeBytesThreshold) - if err := readWriter.Iterate(from, to, + if err := readWriter.MVCCIterate(from, to, func(kv storage.MVCCKeyValue) error { return readWriter.Clear(kv.Key) }, diff --git a/pkg/kv/kvserver/batcheval/cmd_clear_range_test.go b/pkg/kv/kvserver/batcheval/cmd_clear_range_test.go index 0f5dc8ac3e87..d5b1e1d785e8 100644 --- a/pkg/kv/kvserver/batcheval/cmd_clear_range_test.go +++ b/pkg/kv/kvserver/batcheval/cmd_clear_range_test.go @@ -142,7 +142,7 @@ func TestCmdClearRangeBytesThreshold(t *testing.T) { if err := batch.Commit(true /* commit */); err != nil { t.Fatal(err) } - if err := eng.Iterate(startKey, endKey, + if err := eng.MVCCIterate(startKey, endKey, func(kv storage.MVCCKeyValue) error { return errors.New("expected no data in underlying engine") }, diff --git a/pkg/kv/kvserver/batcheval/cmd_revert_range_test.go b/pkg/kv/kvserver/batcheval/cmd_revert_range_test.go index 9f08ab2e2f99..4f4060f4caf0 100644 --- a/pkg/kv/kvserver/batcheval/cmd_revert_range_test.go +++ b/pkg/kv/kvserver/batcheval/cmd_revert_range_test.go @@ -30,7 +30,7 @@ import ( func hashRange(t *testing.T, reader storage.Reader, start, end roachpb.Key) []byte { t.Helper() h := sha256.New() - if err := reader.Iterate(start, end, + if err := reader.MVCCIterate(start, end, func(kv storage.MVCCKeyValue) error { h.Write(kv.Key.Key) h.Write(kv.Value) diff --git a/pkg/kv/kvserver/compactor/compactor.go b/pkg/kv/kvserver/compactor/compactor.go index 952f1557bebc..e8f064df18c4 100644 --- a/pkg/kv/kvserver/compactor/compactor.go +++ b/pkg/kv/kvserver/compactor/compactor.go @@ -294,7 +294,7 @@ func (c *Compactor) fetchSuggestions( delBatch := c.eng.NewBatch() defer delBatch.Close() - err = c.eng.Iterate( + err = c.eng.MVCCIterate( keys.LocalStoreSuggestedCompactionsMin, keys.LocalStoreSuggestedCompactionsMax, func(kv storage.MVCCKeyValue) error { @@ -462,7 +462,7 @@ func (c *Compactor) aggregateCompaction( // BytesQueued gauge. func (c *Compactor) examineQueue(ctx context.Context) (int64, error) { var totalBytes int64 - if err := c.eng.Iterate( + if err := c.eng.MVCCIterate( keys.LocalStoreSuggestedCompactionsMin, keys.LocalStoreSuggestedCompactionsMax, func(kv storage.MVCCKeyValue) error { @@ -488,8 +488,8 @@ func (c *Compactor) Suggest(ctx context.Context, sc kvserverpb.SuggestedCompacti // Check whether a suggested compaction already exists for this key span. key := keys.StoreSuggestedCompactionKey(sc.StartKey, sc.EndKey) var existing kvserverpb.Compaction - //lint:ignore SA1019 historical usage of deprecated c.eng.GetProto is OK - ok, _, _, err := c.eng.GetProto(storage.MVCCKey{Key: key}, &existing) + //lint:ignore SA1019 historical usage of deprecated c.eng.MVCCGetProto is OK + ok, _, _, err := c.eng.MVCCGetProto(storage.MVCCKey{Key: key}, &existing) if err != nil { log.VErrEventf(ctx, 2, "unable to record suggested compaction: %s", err) return diff --git a/pkg/kv/kvserver/compactor/compactor_test.go b/pkg/kv/kvserver/compactor/compactor_test.go index ea08f80e1a4c..4030eef2005b 100644 --- a/pkg/kv/kvserver/compactor/compactor_test.go +++ b/pkg/kv/kvserver/compactor/compactor_test.go @@ -568,7 +568,7 @@ func TestCompactorThresholds(t *testing.T) { // Read the remaining suggestions in the queue; verify compacted // spans have been cleared and uncompacted spans remain. var idx int - return we.Iterate( + return we.MVCCIterate( keys.LocalStoreSuggestedCompactionsMin, keys.LocalStoreSuggestedCompactionsMax, func(kv storage.MVCCKeyValue) error { diff --git a/pkg/kv/kvserver/gc_queue_test.go b/pkg/kv/kvserver/gc_queue_test.go index 63c1df68c064..d3f612648f06 100644 --- a/pkg/kv/kvserver/gc_queue_test.go +++ b/pkg/kv/kvserver/gc_queue_test.go @@ -967,12 +967,12 @@ func TestGCQueueIntentResolution(t *testing.T) { } assert.True(t, processed, "queue not processed") - // Iterate through all values to ensure intents have been fully resolved. + // MVCCIterate through all values to ensure intents have been fully resolved. // This must be done in a SucceedsSoon loop because intent resolution // is initiated asynchronously from the GC queue. testutils.SucceedsSoon(t, func() error { meta := &enginepb.MVCCMetadata{} - return tc.store.Engine().Iterate(roachpb.KeyMin, roachpb.KeyMax, + return tc.store.Engine().MVCCIterate(roachpb.KeyMin, roachpb.KeyMax, func(kv storage.MVCCKeyValue) error { if !kv.Key.IsValue() { if err := protoutil.Unmarshal(kv.Value, meta); err != nil { diff --git a/pkg/kv/kvserver/spanset/batch.go b/pkg/kv/kvserver/spanset/batch.go index 84635bb2c7dd..e9f3b4c2231e 100644 --- a/pkg/kv/kvserver/spanset/batch.go +++ b/pkg/kv/kvserver/spanset/batch.go @@ -233,18 +233,18 @@ func (s spanSetReader) Closed() bool { return s.r.Closed() } -// ExportToSst is part of the engine.Reader interface. -func (s spanSetReader) ExportToSst( +// ExportMVCCToSst is part of the engine.Reader interface. +func (s spanSetReader) ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, targetSize, maxSize uint64, io storage.IterOptions, ) ([]byte, roachpb.BulkOpSummary, roachpb.Key, error) { - return s.r.ExportToSst(startKey, endKey, startTS, endTS, exportAllRevisions, targetSize, maxSize, io) + return s.r.ExportMVCCToSst(startKey, endKey, startTS, endTS, exportAllRevisions, targetSize, maxSize, io) } -func (s spanSetReader) Get(key storage.MVCCKey) ([]byte, error) { +func (s spanSetReader) MVCCGet(key storage.MVCCKey) ([]byte, error) { if s.spansOnly { if err := s.spans.CheckAllowed(SpanReadOnly, roachpb.Span{Key: key.Key}); err != nil { return nil, err @@ -255,10 +255,10 @@ func (s spanSetReader) Get(key storage.MVCCKey) ([]byte, error) { } } //lint:ignore SA1019 implementing deprecated interface function (Get) is OK - return s.r.Get(key) + return s.r.MVCCGet(key) } -func (s spanSetReader) GetProto( +func (s spanSetReader) MVCCGetProto( key storage.MVCCKey, msg protoutil.Message, ) (bool, int64, int64, error) { if s.spansOnly { @@ -270,11 +270,13 @@ func (s spanSetReader) GetProto( return false, 0, 0, err } } - //lint:ignore SA1019 implementing deprecated interface function (GetProto) is OK - return s.r.GetProto(key, msg) + //lint:ignore SA1019 implementing deprecated interface function (MVCCGetProto) is OK + return s.r.MVCCGetProto(key, msg) } -func (s spanSetReader) Iterate(start, end roachpb.Key, f func(storage.MVCCKeyValue) error) error { +func (s spanSetReader) MVCCIterate( + start, end roachpb.Key, f func(storage.MVCCKeyValue) error, +) error { if s.spansOnly { if err := s.spans.CheckAllowed(SpanReadOnly, roachpb.Span{Key: start, EndKey: end}); err != nil { return err @@ -284,7 +286,7 @@ func (s spanSetReader) Iterate(start, end roachpb.Key, f func(storage.MVCCKeyVal return err } } - return s.r.Iterate(start, end, f) + return s.r.MVCCIterate(start, end, f) } func (s spanSetReader) NewIterator(opts storage.IterOptions) storage.MVCCIterator { diff --git a/pkg/storage/batch_test.go b/pkg/storage/batch_test.go index eb6c5b9474eb..2491651017b6 100644 --- a/pkg/storage/batch_test.go +++ b/pkg/storage/batch_test.go @@ -199,9 +199,9 @@ func TestReadOnlyBasics(t *testing.T) { a := mvccKey("a") getVal := &roachpb.Value{} successTestCases := []func(){ - func() { _, _ = ro.Get(a) }, - func() { _, _, _, _ = ro.GetProto(a, getVal) }, - func() { _ = ro.Iterate(a.Key, a.Key, func(MVCCKeyValue) error { return iterutil.StopIteration() }) }, + func() { _, _ = ro.MVCCGet(a) }, + func() { _, _, _, _ = ro.MVCCGetProto(a, getVal) }, + func() { _ = ro.MVCCIterate(a.Key, a.Key, func(MVCCKeyValue) error { return iterutil.StopIteration() }) }, func() { ro.NewIterator(IterOptions{UpperBound: roachpb.KeyMax}).Close() }, func() { ro.NewIterator(IterOptions{ @@ -409,7 +409,7 @@ func TestApplyBatchRepr(t *testing.T) { t.Fatal(err) } - if b, err := e.Get(key); err != nil { + if b, err := e.MVCCGet(key); err != nil { t.Fatal(err) } else if !reflect.DeepEqual(b, val) { t.Fatalf("read %q from engine, expected %q", b, val) @@ -465,7 +465,7 @@ func TestBatchGet(t *testing.T) { {Key: mvccKey("d"), Value: []byte("after")}, } for i, expKV := range expValues { - kv, err := b.Get(expKV.Key) + kv, err := b.MVCCGet(expKV.Key) if err != nil { t.Fatal(err) } @@ -523,7 +523,7 @@ func TestBatchMerge(t *testing.T) { } // Verify values. - val, err := b.Get(mvccKey("a")) + val, err := b.MVCCGet(mvccKey("a")) if err != nil { t.Fatal(err) } @@ -531,7 +531,7 @@ func TestBatchMerge(t *testing.T) { t.Error("mismatch of \"a\"") } - val, err = b.Get(mvccKey("b")) + val, err = b.MVCCGet(mvccKey("b")) if err != nil { t.Fatal(err) } @@ -539,7 +539,7 @@ func TestBatchMerge(t *testing.T) { t.Error("mismatch of \"b\"") } - val, err = b.Get(mvccKey("c")) + val, err = b.MVCCGet(mvccKey("c")) if err != nil { t.Fatal(err) } @@ -567,9 +567,9 @@ func TestBatchProto(t *testing.T) { t.Fatal(err) } getVal := &roachpb.Value{} - ok, keySize, valSize, err := b.GetProto(mvccKey("proto"), getVal) + ok, keySize, valSize, err := b.MVCCGetProto(mvccKey("proto"), getVal) if !ok || err != nil { - t.Fatalf("expected GetProto to success ok=%t: %+v", ok, err) + t.Fatalf("expected MVCCGetProto to success ok=%t: %+v", ok, err) } if keySize != 6 { t.Errorf("expected key size 6; got %d", keySize) @@ -586,16 +586,16 @@ func TestBatchProto(t *testing.T) { } // Before commit, proto will not be available via engine. fmt.Printf("before\n") - if ok, _, _, err := e.GetProto(mvccKey("proto"), getVal); ok || err != nil { + if ok, _, _, err := e.MVCCGetProto(mvccKey("proto"), getVal); ok || err != nil { fmt.Printf("after\n") - t.Fatalf("expected GetProto to fail ok=%t: %+v", ok, err) + t.Fatalf("expected MVCCGetProto to fail ok=%t: %+v", ok, err) } // Commit and verify the proto can be read directly from the engine. if err := b.Commit(false /* sync */); err != nil { t.Fatal(err) } - if ok, _, _, err := e.GetProto(mvccKey("proto"), getVal); !ok || err != nil { - t.Fatalf("expected GetProto to success ok=%t: %+v", ok, err) + if ok, _, _, err := e.MVCCGetProto(mvccKey("proto"), getVal); !ok || err != nil { + t.Fatalf("expected MVCCGetProto to success ok=%t: %+v", ok, err) } if !proto.Equal(getVal, &val) { t.Errorf("expected %v; got %v", &val, getVal) @@ -790,7 +790,7 @@ func TestBatchConcurrency(t *testing.T) { if err := b.Merge(mvccKey("a"), appender("bar")); err != nil { t.Fatal(err) } - val, err := b.Get(mvccKey("a")) + val, err := b.MVCCGet(mvccKey("a")) if err != nil { t.Fatal(err) } @@ -802,7 +802,7 @@ func TestBatchConcurrency(t *testing.T) { t.Fatal(err) } // Now, read again and verify that the merge happens on top of the mod. - val, err = b.Get(mvccKey("a")) + val, err = b.MVCCGet(mvccKey("a")) if err != nil { t.Fatal(err) } @@ -842,7 +842,7 @@ func TestBatchDistinctAfterApplyBatchRepr(t *testing.T) { defer distinct.Close() // The distinct batch can see the earlier write to the batch. - v, err := distinct.Get(mvccKey("batchkey")) + v, err := distinct.MVCCGet(mvccKey("batchkey")) if err != nil { t.Fatal(err) } @@ -875,7 +875,7 @@ func TestBatchDistinct(t *testing.T) { } // The original batch can see the writes to the batch. - if v, err := batch.Get(mvccKey("a")); err != nil { + if v, err := batch.MVCCGet(mvccKey("a")); err != nil { t.Fatal(err) } else if string(v) != "a" { t.Fatalf("expected a, but got %s", v) @@ -883,12 +883,12 @@ func TestBatchDistinct(t *testing.T) { // The distinct batch will see previous writes to the batch. distinct := batch.Distinct() - if v, err := distinct.Get(mvccKey("a")); err != nil { + if v, err := distinct.MVCCGet(mvccKey("a")); err != nil { t.Fatal(err) } else if string(v) != "a" { t.Fatalf("expected a, but got %s", v) } - if v, err := distinct.Get(mvccKey("b")); err != nil { + if v, err := distinct.MVCCGet(mvccKey("b")); err != nil { t.Fatal(err) } else if v != nil { t.Fatalf("expected nothing, but got %s", v) @@ -909,7 +909,7 @@ func TestBatchDistinct(t *testing.T) { if err := distinct.Put(mvccKey("c"), []byte("c")); err != nil { t.Fatal(err) } - if v, err := distinct.Get(mvccKey("c")); err != nil { + if v, err := distinct.MVCCGet(mvccKey("c")); err != nil { t.Fatal(err) } else { switch engineImpl.name { @@ -931,7 +931,7 @@ func TestBatchDistinct(t *testing.T) { distinct.Close() // Writes to the distinct batch are reflected in the original batch. - if v, err := batch.Get(mvccKey("c")); err != nil { + if v, err := batch.MVCCGet(mvccKey("c")); err != nil { t.Fatal(err) } else if string(v) != "c" { t.Fatalf("expected c, but got %s", v) @@ -974,14 +974,14 @@ func TestWriteOnlyBatchDistinct(t *testing.T) { } iter.Close() - if v, err := distinct.Get(mvccKey("b")); err != nil { + if v, err := distinct.MVCCGet(mvccKey("b")); err != nil { t.Fatal(err) } else if string(v) != "b" { t.Fatalf("expected b, but got %s", v) } val := &roachpb.Value{} - if _, _, _, err := distinct.GetProto(mvccKey("c"), val); err != nil { + if _, _, _, err := distinct.MVCCGetProto(mvccKey("c"), val); err != nil { t.Fatal(err) } }) @@ -1012,9 +1012,9 @@ func TestBatchDistinctPanics(t *testing.T) { func() { _ = batch.Clear(a) }, func() { _ = batch.SingleClear(a) }, func() { _ = batch.ApplyBatchRepr(nil, false) }, - func() { _, _ = batch.Get(a) }, - func() { _, _, _, _ = batch.GetProto(a, nil) }, - func() { _ = batch.Iterate(a.Key, a.Key, nil) }, + func() { _, _ = batch.MVCCGet(a) }, + func() { _, _, _, _ = batch.MVCCGetProto(a, nil) }, + func() { _ = batch.MVCCIterate(a.Key, a.Key, nil) }, func() { _ = batch.NewIterator(IterOptions{UpperBound: roachpb.KeyMax}) }, } for i, f := range testCases { @@ -1173,7 +1173,7 @@ func TestBatchCombine(t *testing.T) { } // Verify we can read the key we just wrote immediately. - if v, err := e.Get(mvccKey(k)); err != nil { + if v, err := e.MVCCGet(mvccKey(k)); err != nil { errs <- errors.Wrap(err, "get failed") return } else if string(v) != k { diff --git a/pkg/storage/bench_test.go b/pkg/storage/bench_test.go index 26438ec094fd..35addd35e571 100644 --- a/pkg/storage/bench_test.go +++ b/pkg/storage/bench_test.go @@ -1065,7 +1065,7 @@ func runExportToSst( for i := 0; i < b.N; i++ { startTS := hlc.Timestamp{WallTime: int64(numRevisions / 2)} endTS := hlc.Timestamp{WallTime: int64(numRevisions + 2)} - _, _, _, err := engine.ExportToSst(roachpb.KeyMin, roachpb.KeyMax, startTS, endTS, exportAllRevisions, 0 /* targetSize */, 0 /* maxSize */, IterOptions{ + _, _, _, err := engine.ExportMVCCToSst(roachpb.KeyMin, roachpb.KeyMax, startTS, endTS, exportAllRevisions, 0 /* targetSize */, 0 /* maxSize */, IterOptions{ LowerBound: roachpb.KeyMin, UpperBound: roachpb.KeyMax, }) diff --git a/pkg/storage/engine.go b/pkg/storage/engine.go index e1bb08e377b5..74a7b0552c4a 100644 --- a/pkg/storage/engine.go +++ b/pkg/storage/engine.go @@ -170,14 +170,15 @@ type EngineIterator interface { SetUpperBound(roachpb.Key) } -// IterOptions contains options used to create an MVCCIterator. +// IterOptions contains options used to create an {MVCC,Engine}Iterator. // -// For performance, every MVCCIterator must specify either Prefix or UpperBound. +// For performance, every {MVCC,Engine}Iterator must specify either Prefix or +// UpperBound. type IterOptions struct { - // If Prefix is true, Seek will use the user-key prefix of - // the supplied MVCC key to restrict which sstables are searched, - // but iteration (using Next) over keys without the same user-key - // prefix will not work correctly (keys may be skipped). + // If Prefix is true, Seek will use the user-key prefix of the supplied + // {MVCC,Engine}Key (the Key field) to restrict which sstables are searched, + // but iteration (using Next) over keys without the same user-key prefix + // will not work correctly (keys may be skipped). Prefix bool // LowerBound gives this iterator an inclusive lower bound. Attempts to // SeekReverse or Prev to a key that is strictly less than the bound will @@ -188,7 +189,7 @@ type IterOptions struct { // the iterator. UpperBound must be provided unless Prefix is true, in which // case the end of the prefix will be used as the upper bound. UpperBound roachpb.Key - // If WithStats is true, the iterator accumulates RocksDB performance + // If WithStats is true, the iterator accumulates performance // counters over its lifetime which can be queried via `Stats()`. WithStats bool // MinTimestampHint and MaxTimestampHint, if set, indicate that keys outside @@ -201,9 +202,28 @@ type IterOptions struct { // iterators with time bounds hints will frequently return keys outside of the // [start, end] time range. If you must guarantee that you never see a key // outside of the time bounds, perform your own filtering. + // + // These fields are only relevant for MVCCIterators. MinTimestampHint, MaxTimestampHint hlc.Timestamp } +// MVCCIterKind is used to inform Reader about the kind of iteration desired +// by the caller. +//lint:ignore U1001 unused +type MVCCIterKind int + +const ( + // MVCCKeyAndIntentsIterKind specifies that intents must be seen, and appear + // interleaved with keys, even if they are in a separated lock table. + //lint:ignore U1001 unused + MVCCKeyAndIntentsIterKind MVCCIterKind = iota + // MVCCKeyIterKind specifies that the caller does not need to see intents. + // Any interleaved intents may be seen, but no correctness properties are + // derivable from such partial knowledge of intents. + //lint:ignore U1001 unused + MVCCKeyIterKind +) + // Reader is the read interface to an engine's data. type Reader interface { // Close closes the reader, freeing up any outstanding resources. Note that @@ -216,7 +236,7 @@ type Reader interface { // that they are not using a closed engine. Intended for use within package // engine; exported to enable wrappers to exist in other packages. Closed() bool - // ExportToSst exports changes to the keyrange [startKey, endKey) over the + // ExportMVCCToSst exports changes to the keyrange [startKey, endKey) over the // interval (startTS, endTS]. Passing exportAllRevisions exports // every revision of a key for the interval, otherwise only the latest value // within the interval is exported. Deletions are included if all revisions are @@ -233,33 +253,38 @@ type Reader interface { // returned sst. If it is the case that the versions of the last key will lead // to an SST that exceeds maxSize, an error will be returned. This parameter // exists to prevent creating SSTs which are too large to be used. - ExportToSst( + // + // This function looks at MVCC versions and intents, and returns an error if an + // intent is found. + ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, targetSize uint64, maxSize uint64, io IterOptions, ) (sst []byte, _ roachpb.BulkOpSummary, resumeKey roachpb.Key, _ error) // Get returns the value for the given key, nil otherwise. // - // Deprecated: use MVCCGet instead. - Get(key MVCCKey) ([]byte, error) - // GetProto fetches the value at the specified key and unmarshals it + // Deprecated: use storage.MVCCGet instead. + MVCCGet(key MVCCKey) ([]byte, error) + // MVCCGetProto fetches the value at the specified key and unmarshals it // using a protobuf decoder. Returns true on success or false if the // key was not found. On success, returns the length in bytes of the // key and the value. // // Deprecated: use MVCCIterator.ValueProto instead. - GetProto(key MVCCKey, msg protoutil.Message) (ok bool, keyBytes, valBytes int64, err error) - // Iterate scans from the start key to the end key (exclusive), invoking the + MVCCGetProto(key MVCCKey, msg protoutil.Message) (ok bool, keyBytes, valBytes int64, err error) + // MVCCIterate scans from the start key to the end key (exclusive), invoking the // function f on each key value pair. If f returns an error or if the scan // itself encounters an error, the iteration will stop and return the error. // If the first result of f is true, the iteration stops and returns a nil // error. Note that this method is not expected take into account the // timestamp of the end key; all MVCCKeys at end.Key are considered excluded // in the iteration. - Iterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error + // TODO(sumeer): add MVCCIterKind parameter. + MVCCIterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error // NewIterator returns a new instance of an MVCCIterator over this // engine. The caller must invoke MVCCIterator.Close() when finished // with the iterator to free resources. + // TODO(sumeer): add MVCCIterKind parameter and rename to NewMVCCIterator. NewIterator(opts IterOptions) MVCCIterator } @@ -606,7 +631,7 @@ func PutProto( // Specify max=0 for unbounded scans. func Scan(reader Reader, start, end roachpb.Key, max int64) ([]MVCCKeyValue, error) { var kvs []MVCCKeyValue - err := reader.Iterate(start, end, func(kv MVCCKeyValue) error { + err := reader.MVCCIterate(start, end, func(kv MVCCKeyValue) error { if max != 0 && int64(len(kvs)) >= max { return iterutil.StopIteration() } @@ -744,10 +769,10 @@ func calculatePreIngestDelay(settings *cluster.Settings, metrics *Metrics) time. return 0 } -// Helper function to implement Reader.Iterate(). +// Helper function to implement Reader.MVCCIterate(). func iterateOnReader(reader Reader, start, end roachpb.Key, f func(MVCCKeyValue) error) error { if reader.Closed() { - return errors.New("cannot call Iterate on a closed batch") + return errors.New("cannot call MVCCIterate on a closed batch") } if start.Compare(end) >= 0 { return nil diff --git a/pkg/storage/engine_test.go b/pkg/storage/engine_test.go index 915fb78d2fc8..95e595edb934 100644 --- a/pkg/storage/engine_test.go +++ b/pkg/storage/engine_test.go @@ -91,7 +91,7 @@ func TestEngineBatchCommit(t *testing.T) { case <-writesDone: return nil default: - val, err := e.Get(key) + val, err := e.MVCCGet(key) if err != nil { return err } @@ -263,7 +263,7 @@ func TestEngineBatch(t *testing.T) { } get := func(rw ReadWriter, key MVCCKey) []byte { - b, err := rw.Get(key) + b, err := rw.MVCCGet(key) if err != nil { t.Fatal(err) } @@ -367,12 +367,12 @@ func TestEnginePutGetDelete(t *testing.T) { engine.Put(mvccKey(""), []byte("")), engine.Put(NilKey, []byte("")), func() error { - _, err := engine.Get(mvccKey("")) + _, err := engine.MVCCGet(mvccKey("")) return err }(), engine.Clear(NilKey), func() error { - _, err := engine.Get(NilKey) + _, err := engine.MVCCGet(NilKey) return err }(), engine.Clear(NilKey), @@ -395,7 +395,7 @@ func TestEnginePutGetDelete(t *testing.T) { {mvccKey("server"), []byte("42")}, } for _, c := range testCases { - val, err := engine.Get(c.key) + val, err := engine.MVCCGet(c.key) if err != nil { t.Errorf("get: expected no error, but got %s", err) } @@ -405,7 +405,7 @@ func TestEnginePutGetDelete(t *testing.T) { if err := engine.Put(c.key, c.value); err != nil { t.Errorf("put: expected no error, but got %s", err) } - val, err = engine.Get(c.key) + val, err = engine.MVCCGet(c.key) if err != nil { t.Errorf("get: expected no error, but got %s", err) } @@ -415,7 +415,7 @@ func TestEnginePutGetDelete(t *testing.T) { if err := engine.Clear(c.key); err != nil { t.Errorf("delete: expected no error, but got %s", err) } - val, err = engine.Get(c.key) + val, err = engine.MVCCGet(c.key) if err != nil { t.Errorf("get: expected no error, but got %s", err) } @@ -542,7 +542,7 @@ func TestEngineMerge(t *testing.T) { t.Fatalf("%d: %+v", i, err) } } - result, _ := engine.Get(tc.testKey) + result, _ := engine.MVCCGet(tc.testKey) engineBytes[engineIndex][tcIndex] = result var resultV, expectedV enginepb.MVCCMetadata if err := protoutil.Unmarshal(result, &resultV); err != nil { @@ -1005,7 +1005,7 @@ func TestSnapshot(t *testing.T) { if err := engine.Put(key, val1); err != nil { t.Fatal(err) } - val, _ := engine.Get(key) + val, _ := engine.MVCCGet(key) if !bytes.Equal(val, val1) { t.Fatalf("the value %s in get result does not match the value %s in request", val, val1) @@ -1018,8 +1018,8 @@ func TestSnapshot(t *testing.T) { if err := engine.Put(key, val2); err != nil { t.Fatal(err) } - val, _ = engine.Get(key) - valSnapshot, error := snap.Get(key) + val, _ = engine.MVCCGet(key) + valSnapshot, error := snap.MVCCGet(key) if error != nil { t.Fatalf("error : %s", error) } @@ -1066,7 +1066,7 @@ func TestSnapshotMethods(t *testing.T) { if err := engine.Put(keys[i], vals[i]); err != nil { t.Fatal(err) } - if val, err := engine.Get(keys[i]); err != nil { + if val, err := engine.MVCCGet(keys[i]); err != nil { t.Fatal(err) } else if !bytes.Equal(vals[i], val) { t.Fatalf("expected %s, but found %s", vals[i], val) @@ -1077,7 +1077,7 @@ func TestSnapshotMethods(t *testing.T) { // Verify Get. for i := range keys { - valSnapshot, err := snap.Get(keys[i]) + valSnapshot, err := snap.MVCCGet(keys[i]) if err != nil { t.Fatal(err) } @@ -1098,9 +1098,9 @@ func TestSnapshotMethods(t *testing.T) { keyvals, keyvalsSnapshot) } - // Verify Iterate. + // Verify MVCCIterate. index := 0 - if err := snap.Iterate(roachpb.KeyMin, roachpb.KeyMax, func(kv MVCCKeyValue) error { + if err := snap.MVCCIterate(roachpb.KeyMin, roachpb.KeyMax, func(kv MVCCKeyValue) error { if !kv.Key.Equal(keys[index]) || !bytes.Equal(kv.Value, vals[index]) { t.Errorf("%d: key/value not equal between expected and snapshot: %s/%s, %s/%s", index, keys[index], vals[index], kv.Key, kv.Value) diff --git a/pkg/storage/mvcc_history_test.go b/pkg/storage/mvcc_history_test.go index a880e057a257..17c3d214fae2 100644 --- a/pkg/storage/mvcc_history_test.go +++ b/pkg/storage/mvcc_history_test.go @@ -97,7 +97,7 @@ func TestMVCCHistories(t *testing.T) { reportDataEntries := func(buf *bytes.Buffer) error { hasData := false - err := engine.Iterate( + err := engine.MVCCIterate( span.Key, span.EndKey, func(r MVCCKeyValue) error { @@ -521,7 +521,7 @@ func cmdCheckIntent(e *evalCtx) error { } metaKey := mvccKey(key) var meta enginepb.MVCCMetadata - ok, _, _, err := e.engine.GetProto(metaKey, &meta) + ok, _, _, err := e.engine.MVCCGetProto(metaKey, &meta) if err != nil { return err } diff --git a/pkg/storage/mvcc_incremental_iterator_test.go b/pkg/storage/mvcc_incremental_iterator_test.go index ca2667d302e2..cfd478da1b63 100644 --- a/pkg/storage/mvcc_incremental_iterator_test.go +++ b/pkg/storage/mvcc_incremental_iterator_test.go @@ -79,7 +79,7 @@ func assertExportedKVs( expected []MVCCKeyValue, ) { const big = 1 << 30 - data, _, _, err := e.ExportToSst(startKey, endKey, startTime, endTime, revisions, big, big, io) + data, _, _, err := e.ExportMVCCToSst(startKey, endKey, startTime, endTime, revisions, big, big, io) require.NoError(t, err) if data == nil { diff --git a/pkg/storage/mvcc_test.go b/pkg/storage/mvcc_test.go index 65f0f6c41062..2937d48676dc 100644 --- a/pkg/storage/mvcc_test.go +++ b/pkg/storage/mvcc_test.go @@ -867,7 +867,7 @@ func TestMVCCDeleteMissingKey(t *testing.T) { t.Fatal(err) } // Verify nothing is written to the engine. - if val, err := engine.Get(mvccKey(testKey1)); err != nil || val != nil { + if val, err := engine.MVCCGet(mvccKey(testKey1)); err != nil || val != nil { t.Fatalf("expected no mvcc metadata after delete of a missing key; got %q: %+v", val, err) } }) @@ -1170,7 +1170,7 @@ func TestMVCCGetInconsistent(t *testing.T) { } } -// TestMVCCGetProtoInconsistent verifies the behavior of GetProto with +// TestMVCCGetProtoInconsistent verifies the behavior of MVCCGetProto with // consistent set to false. func TestMVCCGetProtoInconsistent(t *testing.T) { defer leaktest.AfterTest(t)() @@ -3470,7 +3470,7 @@ func TestMVCCAbortTxn(t *testing.T) { } else if value != nil { t.Fatalf("expected the value to be empty: %s", value) } - if meta, err := engine.Get(mvccKey(testKey1)); err != nil { + if meta, err := engine.MVCCGet(mvccKey(testKey1)); err != nil { t.Fatal(err) } else if len(meta) != 0 { t.Fatalf("expected no more MVCCMetadata, got: %s", meta) @@ -3509,7 +3509,7 @@ func TestMVCCAbortTxnWithPreviousVersion(t *testing.T) { t.Fatal(err) } - if meta, err := engine.Get(mvccKey(testKey1)); err != nil { + if meta, err := engine.MVCCGet(mvccKey(testKey1)); err != nil { t.Fatal(err) } else if len(meta) != 0 { t.Fatalf("expected no more MVCCMetadata, got: %s", meta) @@ -5230,7 +5230,7 @@ func TestResolveIntentWithLowerEpoch(t *testing.T) { // Check that the intent was not cleared. metaKey := mvccKey(testKey1) meta := &enginepb.MVCCMetadata{} - ok, _, _, err := engine.GetProto(metaKey, meta) + ok, _, _, err := engine.MVCCGetProto(metaKey, meta) if err != nil { t.Fatal(err) } diff --git a/pkg/storage/pebble.go b/pkg/storage/pebble.go index 156b14b62361..32e032b33b5a 100644 --- a/pkg/storage/pebble.go +++ b/pkg/storage/pebble.go @@ -626,8 +626,8 @@ func (p *Pebble) Closed() bool { return p.closed } -// ExportToSst is part of the engine.Reader interface. -func (p *Pebble) ExportToSst( +// ExportMVCCToSst is part of the engine.Reader interface. +func (p *Pebble) ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, @@ -637,8 +637,8 @@ func (p *Pebble) ExportToSst( return pebbleExportToSst(p, startKey, endKey, startTS, endTS, exportAllRevisions, targetSize, maxSize, io) } -// Get implements the Engine interface. -func (p *Pebble) Get(key MVCCKey) ([]byte, error) { +// MVCCGet implements the Engine interface. +func (p *Pebble) MVCCGet(key MVCCKey) ([]byte, error) { if len(key.Key) == 0 { return nil, emptyKeyError() } @@ -663,8 +663,8 @@ func (p *Pebble) GetCompactionStats() string { return "\n" + p.db.Metrics().String() } -// GetProto implements the Engine interface. -func (p *Pebble) GetProto( +// MVCCGetProto implements the Engine interface. +func (p *Pebble) MVCCGetProto( key MVCCKey, msg protoutil.Message, ) (ok bool, keyBytes, valBytes int64, err error) { if len(key.Key) == 0 { @@ -687,8 +687,8 @@ func (p *Pebble) GetProto( return false, 0, 0, err } -// Iterate implements the Engine interface. -func (p *Pebble) Iterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { +// MVCCIterate implements the Engine interface. +func (p *Pebble) MVCCIterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { return iterateOnReader(p, start, end, f) } @@ -1115,8 +1115,8 @@ func (p *pebbleReadOnly) Closed() bool { return p.closed } -// ExportToSst is part of the engine.Reader interface. -func (p *pebbleReadOnly) ExportToSst( +// ExportMVCCToSst is part of the engine.Reader interface. +func (p *pebbleReadOnly) ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, @@ -1126,23 +1126,23 @@ func (p *pebbleReadOnly) ExportToSst( return pebbleExportToSst(p, startKey, endKey, startTS, endTS, exportAllRevisions, targetSize, maxSize, io) } -func (p *pebbleReadOnly) Get(key MVCCKey) ([]byte, error) { +func (p *pebbleReadOnly) MVCCGet(key MVCCKey) ([]byte, error) { if p.closed { panic("using a closed pebbleReadOnly") } - return p.parent.Get(key) + return p.parent.MVCCGet(key) } -func (p *pebbleReadOnly) GetProto( +func (p *pebbleReadOnly) MVCCGetProto( key MVCCKey, msg protoutil.Message, ) (ok bool, keyBytes, valBytes int64, err error) { if p.closed { panic("using a closed pebbleReadOnly") } - return p.parent.GetProto(key, msg) + return p.parent.MVCCGetProto(key, msg) } -func (p *pebbleReadOnly) Iterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { +func (p *pebbleReadOnly) MVCCIterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { if p.closed { panic("using a closed pebbleReadOnly") } @@ -1237,8 +1237,8 @@ func (p *pebbleSnapshot) Closed() bool { return p.closed } -// ExportToSst is part of the engine.Reader interface. -func (p *pebbleSnapshot) ExportToSst( +// ExportMVCCToSst is part of the engine.Reader interface. +func (p *pebbleSnapshot) ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, @@ -1249,7 +1249,7 @@ func (p *pebbleSnapshot) ExportToSst( } // Get implements the Reader interface. -func (p *pebbleSnapshot) Get(key MVCCKey) ([]byte, error) { +func (p *pebbleSnapshot) MVCCGet(key MVCCKey) ([]byte, error) { if len(key.Key) == 0 { return nil, emptyKeyError() } @@ -1267,8 +1267,8 @@ func (p *pebbleSnapshot) Get(key MVCCKey) ([]byte, error) { return ret, err } -// GetProto implements the Reader interface. -func (p *pebbleSnapshot) GetProto( +// MVCCGetProto implements the Reader interface. +func (p *pebbleSnapshot) MVCCGetProto( key MVCCKey, msg protoutil.Message, ) (ok bool, keyBytes, valBytes int64, err error) { if len(key.Key) == 0 { @@ -1291,8 +1291,8 @@ func (p *pebbleSnapshot) GetProto( return false, 0, 0, err } -// Iterate implements the Reader interface. -func (p *pebbleSnapshot) Iterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { +// MVCCIterate implements the Reader interface. +func (p *pebbleSnapshot) MVCCIterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { return iterateOnReader(p, start, end, f) } diff --git a/pkg/storage/pebble_batch.go b/pkg/storage/pebble_batch.go index c6cecab30521..d1110f5b8c3f 100644 --- a/pkg/storage/pebble_batch.go +++ b/pkg/storage/pebble_batch.go @@ -89,8 +89,8 @@ func (p *pebbleBatch) Closed() bool { return p.closed } -// ExportToSst is part of the engine.Reader interface. -func (p *pebbleBatch) ExportToSst( +// ExportMVCCToSst is part of the engine.Reader interface. +func (p *pebbleBatch) ExportMVCCToSst( startKey, endKey roachpb.Key, startTS, endTS hlc.Timestamp, exportAllRevisions bool, @@ -101,7 +101,7 @@ func (p *pebbleBatch) ExportToSst( } // Get implements the Batch interface. -func (p *pebbleBatch) Get(key MVCCKey) ([]byte, error) { +func (p *pebbleBatch) MVCCGet(key MVCCKey) ([]byte, error) { r := pebble.Reader(p.batch) if !p.isDistinct { if !p.batch.Indexed() { @@ -130,8 +130,8 @@ func (p *pebbleBatch) Get(key MVCCKey) ([]byte, error) { return ret, err } -// GetProto implements the Batch interface. -func (p *pebbleBatch) GetProto( +// MVCCGetProto implements the Batch interface. +func (p *pebbleBatch) MVCCGetProto( key MVCCKey, msg protoutil.Message, ) (ok bool, keyBytes, valBytes int64, err error) { r := pebble.Reader(p.batch) @@ -165,8 +165,8 @@ func (p *pebbleBatch) GetProto( return false, 0, 0, err } -// Iterate implements the Batch interface. -func (p *pebbleBatch) Iterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { +// MVCCIterate implements the Batch interface. +func (p *pebbleBatch) MVCCIterate(start, end roachpb.Key, f func(MVCCKeyValue) error) error { if p.distinctOpen { panic("distinct batch open") }