Skip to content

Commit

Permalink
*: remove the remaining uses of ReplicaDescriptors.Unwrap
Browse files Browse the repository at this point in the history
Closes #37916

Release note: None
  • Loading branch information
danhhz committed Aug 1, 2019
1 parent 8a08c17 commit dd5053e
Show file tree
Hide file tree
Showing 23 changed files with 679 additions and 573 deletions.
4 changes: 2 additions & 2 deletions pkg/roachpb/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func (r *RangeDescriptor) RemoveReplica(nodeID NodeID, storeID StoreID) (Replica
// GetReplicaDescriptor returns the replica which matches the specified store
// ID.
func (r *RangeDescriptor) GetReplicaDescriptor(storeID StoreID) (ReplicaDescriptor, bool) {
for _, repDesc := range r.Replicas().Unwrap() {
for _, repDesc := range r.Replicas().All() {
if repDesc.StoreID == storeID {
return repDesc, true
}
Expand All @@ -167,7 +167,7 @@ func (r *RangeDescriptor) GetReplicaDescriptor(storeID StoreID) (ReplicaDescript
// GetReplicaDescriptorByID returns the replica which matches the specified store
// ID.
func (r *RangeDescriptor) GetReplicaDescriptorByID(replicaID ReplicaID) (ReplicaDescriptor, bool) {
for _, repDesc := range r.Replicas().Unwrap() {
for _, repDesc := range r.Replicas().All() {
if repDesc.ReplicaID == replicaID {
return repDesc, true
}
Expand Down
7 changes: 0 additions & 7 deletions pkg/roachpb/metadata_replicas.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ func (d ReplicaDescriptors) String() string {
return buf.String()
}

// Unwrap returns every replica in the set. It is a placeholder for code that
// used to work on a slice of replicas until learner replicas are added. At that
// point, all uses of Unwrap will be migrated to All/Voters/Learners.
func (d ReplicaDescriptors) Unwrap() []ReplicaDescriptor {
return d.wrapped
}

// All returns every replica in the set, including both voter replicas and
// learner replicas. Voter replicas are ordered first in the returned slice.
func (d ReplicaDescriptors) All() []ReplicaDescriptor {
Expand Down
4 changes: 2 additions & 2 deletions pkg/server/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,7 @@ func (s *adminServer) DecommissionStatus(
if err := row.ValueProto(&rangeDesc); err != nil {
return errors.Wrapf(err, "%s: unable to unmarshal range descriptor", row.Key)
}
for _, r := range rangeDesc.Replicas().Unwrap() {
for _, r := range rangeDesc.Replicas().All() {
if _, ok := replicaCounts[r.NodeID]; ok {
replicaCounts[r.NodeID]++
}
Expand Down Expand Up @@ -1608,7 +1608,7 @@ func (s *adminServer) DataDistribution(
return err
}

for _, replicaDesc := range rangeDesc.Replicas().Unwrap() {
for _, replicaDesc := range rangeDesc.Replicas().All() {
tableInfo, ok := tableInfosByTableID[tableID]
if !ok {
// This is a database, skip.
Expand Down
Loading

0 comments on commit dd5053e

Please sign in to comment.