diff --git a/pkg/ccl/changefeedccl/kvfeed/scanner.go b/pkg/ccl/changefeedccl/kvfeed/scanner.go index e22d3d128536..5bfbeb67dedd 100644 --- a/pkg/ccl/changefeedccl/kvfeed/scanner.go +++ b/pkg/ccl/changefeedccl/kvfeed/scanner.go @@ -250,7 +250,7 @@ func allRangeSpans( ranges := make([]roachpb.Span, 0, len(spans)) - it := kvcoord.NewRangeIterator(ds) + it := kvcoord.MakeRangeIterator(ds) for i := range spans { rSpan, err := keys.SpanAddr(spans[i]) diff --git a/pkg/kv/kvclient/kvcoord/dist_sender.go b/pkg/kv/kvclient/kvcoord/dist_sender.go index 6d1d69c1f26b..184cc6e1f55a 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender.go @@ -555,7 +555,7 @@ func (ds *DistSender) getNodeDescriptor() *roachpb.NodeDescriptor { // CountRanges returns the number of ranges that encompass the given key span. func (ds *DistSender) CountRanges(ctx context.Context, rs roachpb.RSpan) (int64, error) { var count int64 - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) for ri.Seek(ctx, rs.Key, Ascending); ri.Valid(); ri.Next(ctx) { count++ if !ri.NeedAnother(rs) { @@ -1165,7 +1165,7 @@ func (ds *DistSender) divideAndSendBatchToRanges( scanDir = Descending seekKey = rs.EndKey } - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) ri.Seek(ctx, seekKey, scanDir) if !ri.Valid() { return nil, roachpb.NewError(ri.Error()) diff --git a/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go b/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go index 71b401f7938d..f2f9be5c5af4 100644 --- a/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go +++ b/pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go @@ -208,7 +208,7 @@ func (ds *DistSender) divideAndSendRangeFeedToRanges( // boundaries. So, as we go, keep track of the remaining uncovered part of // `rs` in `nextRS`. nextRS := rs - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) for ri.Seek(ctx, nextRS.Key, Ascending); ri.Valid(); ri.Next(ctx) { desc := ri.Desc() partialRS, err := nextRS.Intersect(desc) diff --git a/pkg/kv/kvclient/kvcoord/range_iter.go b/pkg/kv/kvclient/kvcoord/range_iter.go index 4f9acab754dd..614aa8d8842c 100644 --- a/pkg/kv/kvclient/kvcoord/range_iter.go +++ b/pkg/kv/kvclient/kvcoord/range_iter.go @@ -35,9 +35,9 @@ type RangeIterator struct { err error } -// NewRangeIterator creates a new RangeIterator. -func NewRangeIterator(ds *DistSender) *RangeIterator { - return &RangeIterator{ +// MakeRangeIterator creates a new RangeIterator. +func MakeRangeIterator(ds *DistSender) RangeIterator { + return RangeIterator{ ds: ds, } } diff --git a/pkg/kv/kvclient/kvcoord/range_iter_test.go b/pkg/kv/kvclient/kvcoord/range_iter_test.go index 70817761df8d..b1a1905effa1 100644 --- a/pkg/kv/kvclient/kvcoord/range_iter_test.go +++ b/pkg/kv/kvclient/kvcoord/range_iter_test.go @@ -69,7 +69,7 @@ func TestRangeIterForward(t *testing.T) { Settings: cluster.MakeTestingClusterSettings(), }) - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) i := 0 span := roachpb.RSpan{ Key: testMetaEndKey, @@ -105,7 +105,7 @@ func TestRangeIterSeekForward(t *testing.T) { Settings: cluster.MakeTestingClusterSettings(), }) - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) i := 0 for ri.Seek(ctx, testMetaEndKey, Ascending); ri.Valid(); { if !reflect.DeepEqual(alphaRangeDescriptors[i], *ri.Desc()) { @@ -144,7 +144,7 @@ func TestRangeIterReverse(t *testing.T) { Settings: cluster.MakeTestingClusterSettings(), }) - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) i := len(alphaRangeDescriptors) - 1 span := roachpb.RSpan{ Key: testMetaEndKey, @@ -180,7 +180,7 @@ func TestRangeIterSeekReverse(t *testing.T) { Settings: cluster.MakeTestingClusterSettings(), }) - ri := NewRangeIterator(ds) + ri := MakeRangeIterator(ds) i := len(alphaRangeDescriptors) - 1 for ri.Seek(ctx, roachpb.RKey([]byte{'z'}), Descending); ri.Valid(); { if !reflect.DeepEqual(alphaRangeDescriptors[i], *ri.Desc()) { diff --git a/pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go b/pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go index 3ce69beaf955..60e4753308df 100644 --- a/pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go +++ b/pkg/kv/kvclient/kvcoord/txn_interceptor_pipeliner.go @@ -250,7 +250,8 @@ func (f rangeIteratorFactory) newRangeIterator() condensableSpanSetRangeIterator return f.factory() } if f.ds != nil { - return NewRangeIterator(f.ds) + ri := MakeRangeIterator(f.ds) + return &ri } panic("no iterator factory configured") } diff --git a/pkg/kv/kvclient/rangefeed/db_adapter.go b/pkg/kv/kvclient/rangefeed/db_adapter.go index 832c9adc1824..b0884b093f82 100644 --- a/pkg/kv/kvclient/rangefeed/db_adapter.go +++ b/pkg/kv/kvclient/rangefeed/db_adapter.go @@ -232,7 +232,7 @@ func (dbc *dbAdapter) divideAndSendScanRequests( currentScanLimit := parallelismFn() exportLim := limit.MakeConcurrentRequestLimiter("rangefeedScanLimiter", parallelismFn()) - ri := kvcoord.NewRangeIterator(dbc.distSender) + ri := kvcoord.MakeRangeIterator(dbc.distSender) for _, sp := range sg.Slice() { nextRS, err := keys.SpanAddr(sp) diff --git a/pkg/sql/gcjob/table_garbage_collection.go b/pkg/sql/gcjob/table_garbage_collection.go index ffb8b163cce1..a5c22d218ed0 100644 --- a/pkg/sql/gcjob/table_garbage_collection.go +++ b/pkg/sql/gcjob/table_garbage_collection.go @@ -134,7 +134,7 @@ func clearSpanData( var n int lastKey := span.Key - ri := kvcoord.NewRangeIterator(distSender) + ri := kvcoord.MakeRangeIterator(distSender) timer := timeutil.NewTimer() defer timer.Stop() diff --git a/pkg/sql/physicalplan/span_resolver.go b/pkg/sql/physicalplan/span_resolver.go index ce47cda2f6e1..a1c00697d551 100644 --- a/pkg/sql/physicalplan/span_resolver.go +++ b/pkg/sql/physicalplan/span_resolver.go @@ -150,7 +150,7 @@ type spanResolverIterator struct { // txn is the transaction using the iterator. txn *kv.Txn // it is a wrapped RangeIterator. - it *kvcoord.RangeIterator + it kvcoord.RangeIterator // oracle is used to choose a lease holders for ranges when one isn't present // in the cache. oracle replicaoracle.Oracle @@ -170,7 +170,7 @@ var _ SpanResolverIterator = &spanResolverIterator{} func (sr *spanResolver) NewSpanResolverIterator(txn *kv.Txn) SpanResolverIterator { return &spanResolverIterator{ txn: txn, - it: kvcoord.NewRangeIterator(sr.distSender), + it: kvcoord.MakeRangeIterator(sr.distSender), oracle: sr.oracle, queryState: replicaoracle.MakeQueryState(), }