netmap: Add method Clone #344

Merged
dstepanov-yadro merged 1 commit from acid-ant/frostfs-sdk-go:feature/add-clone into master 2025-03-10 06:43:48 +00:00
Member

Signed-off-by: Anton Nikiforov an.nikiforov@yadro.com

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
acid-ant added 1 commit 2025-03-07 11:01:10 +00:00
[#xx] netmap: Add method Clone
Some checks failed
DCO / DCO (pull_request) Failing after 25s
Code generation / Generate proto (pull_request) Successful in 37s
Tests and linters / Tests (pull_request) Successful in 45s
Tests and linters / Lint (pull_request) Failing after 1m8s
00bbc56b6d
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
acid-ant force-pushed feature/add-clone from 00bbc56b6d to 224e921447 2025-03-07 11:01:49 +00:00 Compare
fyrchik reviewed 2025-03-07 11:21:54 +00:00
@ -468,0 +485,4 @@
state: ni.state,
}
for _, v := range ni.attributes {
dst.attributes = append(dst.attributes, *v.Clone())
Owner

dst.attributes can be preallocated, we know its size exactly.

`dst.attributes` can be preallocated, we know its size exactly.
Author
Member

Fixed.

Fixed.
fyrchik marked this conversation as resolved
netmap/netmap.go Outdated
@ -99,0 +102,4 @@
epoch: x.epoch,
}
for _, node := range x.nodes {
dst.nodes = append(dst.nodes, *node.Clone())
Owner

dst.nodes can be preallocated.

`dst.nodes` can be preallocated.
Author
Member

Fixed.

Fixed.
fyrchik marked this conversation as resolved
@ -48,0 +54,4 @@
c := nm.Clone()
require.True(t, c != nm)
Owner

I would also check that they serialize to exactly the same value (byte-by-byte).

I would also check that they serialize to exactly the same value (byte-by-byte).
Author
Member

Added.

Added.
fyrchik marked this conversation as resolved
acid-ant force-pushed feature/add-clone from 224e921447 to 6b84730319 2025-03-07 12:33:01 +00:00 Compare
acid-ant force-pushed feature/add-clone from 6b84730319 to 0085de210c 2025-03-07 12:33:24 +00:00 Compare
acid-ant changed title from WIP: netmap: Add method Clone to netmap: Add method Clone 2025-03-07 12:39:11 +00:00
requested reviews from storage-core-committers, storage-core-developers, storage-services-committers, storage-services-developers 2025-03-07 12:39:13 +00:00
dstepanov-yadro requested changes 2025-03-07 13:46:36 +00:00
Dismissed
@ -382,6 +385,15 @@ func (a *Attribute) SetParents(parent []string) {
a.parents = parent
}
// Clone returns a copy of Attribute.

As this is SDK, I think it is required to add a nil check.

As this is SDK, I think it is required to add a `nil` check.
Author
Member

Fair point, check added.

Fair point, check added.
acid-ant force-pushed feature/add-clone from 0085de210c to 749b4e9ab5 2025-03-07 15:02:15 +00:00 Compare
fyrchik approved these changes 2025-03-07 15:18:02 +00:00
dstepanov-yadro approved these changes 2025-03-10 06:43:37 +00:00
dstepanov-yadro merged commit 749b4e9ab5 into master 2025-03-10 06:43:48 +00:00
Sign in to join this conversation.
No reviewers
TrueCloudLab/storage-services-committers
TrueCloudLab/storage-services-developers
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: TrueCloudLab/frostfs-sdk-go#344
No description provided.