Skip to content

kvserver: use wrapper type for Store.mu.replicas#72430

Merged
craig[bot] merged 3 commits intocockroachdb:masterfrom
tbg:store-clarify-maps
Nov 4, 2021
Merged

kvserver: use wrapper type for Store.mu.replicas#72430
craig[bot] merged 3 commits intocockroachdb:masterfrom
tbg:store-clarify-maps

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented Nov 4, 2021

This simplifies lots of callers and it will also make it easier to work
on #72374, where this map will start containing more than one type as
value.

Release note: None

@tbg tbg requested a review from a team as a code owner November 4, 2021 14:05
@tbg tbg requested a review from erikgrinaker November 4, 2021 14:05
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Contributor

@erikgrinaker erikgrinaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 7 of 7 files at r1, 1 of 6 files at r2.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @erikgrinaker and @tbg)


pkg/kv/kvserver/store_replicas_by_rangeid.go, line 23 at r1 (raw file):

type rangeIDReplicaMap struct {
	m syncutil.IntMap

nit: consider calling this replicas or something -- m.m is a bit terse.


pkg/kv/kvserver/store_replicas_by_rangeid.go, line 52 at r1 (raw file):

// returned from the closure to stop iteration without an error
// resulting from Range().
func (m *rangeIDReplicaMap) Range(f func(*Replica) error) error {

nit: looks like we're never returning an error from the closure, so I wonder if it'd be just as easy to return a bool here for consistency with sync.Map and avoid the errcheck appeasement.

tbg added 3 commits November 4, 2021 23:05
This simplifies lots of callers and it will also make it easier to work
on cockroachdb#72374, where this map will start containing more than one type as
value.

Release note: None
- avoid the struct wrapper (and thus the need to name the inner map)
- don't return an error in Range()

Release note: None
@tbg tbg force-pushed the store-clarify-maps branch from 3853f67 to 2113763 Compare November 4, 2021 22:05
@tbg
Copy link
Copy Markdown
Member Author

tbg commented Nov 4, 2021

TFTR! I addressed your comments.

bors r=erikgrinaker

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Nov 4, 2021

Build succeeded:

@craig craig bot merged commit ed35bbe into cockroachdb:master Nov 4, 2021
@tbg tbg deleted the store-clarify-maps branch November 4, 2021 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants