-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: update map rather than create a new map #3302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
2c5c3ad
a071473
e39a29c
735af1d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -249,7 +249,7 @@ func (ca *clusterAdmin) CreateTopic(topic string, detail *TopicDetail, validateO | |||||||
| return errors.New("you must specify topic details") | ||||||||
| } | ||||||||
|
|
||||||||
| topicDetails := make(map[string]*TopicDetail) | ||||||||
| topicDetails := make(map[string]*TopicDetail, 1) | ||||||||
| topicDetails[topic] = detail | ||||||||
|
|
||||||||
| request := NewCreateTopicsRequest( | ||||||||
|
|
@@ -366,7 +366,7 @@ func (ca *clusterAdmin) ListTopics() (map[string]TopicDetail, error) { | |||||||
| return nil, err | ||||||||
| } | ||||||||
|
|
||||||||
| topicsDetailsMap := make(map[string]TopicDetail) | ||||||||
| topicsDetailsMap := make(map[string]TopicDetail, len(metadataResp.Topics)) | ||||||||
|
|
||||||||
| var describeConfigsResources []*ConfigResource | ||||||||
|
|
||||||||
|
|
@@ -375,7 +375,7 @@ func (ca *clusterAdmin) ListTopics() (map[string]TopicDetail, error) { | |||||||
| NumPartitions: int32(len(topic.Partitions)), | ||||||||
| } | ||||||||
| if len(topic.Partitions) > 0 { | ||||||||
| topicDetails.ReplicaAssignment = map[int32][]int32{} | ||||||||
| topicDetails.ReplicaAssignment = make(map[int32][]int32, len(topic.Partitions)) | ||||||||
| for _, partition := range topic.Partitions { | ||||||||
| topicDetails.ReplicaAssignment[partition.ID] = partition.Replicas | ||||||||
| } | ||||||||
|
|
@@ -479,7 +479,7 @@ func (ca *clusterAdmin) CreatePartitions(topic string, count int32, assignment [ | |||||||
| return ErrInvalidTopic | ||||||||
| } | ||||||||
|
|
||||||||
| topicPartitions := make(map[string]*TopicPartition) | ||||||||
| topicPartitions := make(map[string]*TopicPartition, 1) | ||||||||
| topicPartitions[topic] = &TopicPartition{Count: count, Assignment: assignment} | ||||||||
|
hindessm marked this conversation as resolved.
Outdated
|
||||||||
|
|
||||||||
| request := &CreatePartitionsRequest{ | ||||||||
|
|
@@ -615,8 +615,8 @@ func (ca *clusterAdmin) DeleteRecords(topic string, partitionOffsets map[int32]i | |||||||
| partitionPerBroker[broker] = append(partitionPerBroker[broker], partition) | ||||||||
| } | ||||||||
| for broker, partitions := range partitionPerBroker { | ||||||||
| topics := make(map[string]*DeleteRecordsRequestTopic) | ||||||||
| recordsToDelete := make(map[int32]int64) | ||||||||
| topics := make(map[string]*DeleteRecordsRequestTopic, 1) | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move this down to line 623, and convert it and lines 623–625 to a complex literal.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||||||||
| recordsToDelete := make(map[int32]int64, len(partitions)) | ||||||||
| for _, p := range partitions { | ||||||||
| recordsToDelete[p] = partitionOffsets[p] | ||||||||
| } | ||||||||
|
|
@@ -1032,7 +1032,7 @@ func (ca *clusterAdmin) ListConsumerGroups() (allGroups map[string]string, err e | |||||||
| return | ||||||||
| } | ||||||||
|
|
||||||||
| groups := make(map[string]string) | ||||||||
| groups := make(map[string]string, len(response.Groups)) | ||||||||
| maps.Copy(groups, response.Groups) | ||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than just do this one, I decided to make an additional commit with all of the uncontentious changes from your earlier comments on #3297. One of the changes, which looks logically correct to me, causes a linter error so I may live to regret making the wider changes. |
||||||||
|
|
||||||||
| groupMaps <- groups | ||||||||
|
|
@@ -1204,7 +1204,7 @@ func (ca *clusterAdmin) DescribeLogDirs(brokerIds []int32) (allLogDirs map[int32 | |||||||
| close(logDirsResults) | ||||||||
| close(errChan) | ||||||||
|
|
||||||||
| allLogDirs = make(map[int32][]DescribeLogDirsResponseDirMetadata) | ||||||||
| allLogDirs = make(map[int32][]DescribeLogDirsResponseDirMetadata, len(brokerIds)) | ||||||||
| for logDirsResult := range logDirsResults { | ||||||||
| allLogDirs[logDirsResult.id] = logDirsResult.logdirs | ||||||||
| } | ||||||||
|
|
||||||||
Uh oh!
There was an error while loading. Please reload this page.