From e022a2b831f6f6149609ecf507531ae8061629c9 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 6 Apr 2023 00:43:56 +0300 Subject: [PATCH] [#16] object: Allow set `copy_number` for every placement vector Signed-off-by: Pavel Karpy --- object/grpc/service.go | 2 +- object/grpc/service.pb.go | Bin 131213 -> 131703 bytes object/marshal.go | 6 ++++-- object/test/generate.go | 2 +- object/types.go | 8 ++++---- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/object/grpc/service.go b/object/grpc/service.go index 44b5f4a..74dc168 100644 --- a/object/grpc/service.go +++ b/object/grpc/service.go @@ -109,7 +109,7 @@ func (m *PutRequest_Body_Init) SetHeader(v *Header) { } // SetCopiesNumber sets number of the copies to save. -func (m *PutRequest_Body_Init) SetCopiesNumber(v uint32) { +func (m *PutRequest_Body_Init) SetCopiesNumber(v []uint32) { m.CopiesNumber = v } diff --git a/object/grpc/service.pb.go b/object/grpc/service.pb.go index 207b0b0880ec9cd55b1c363caaa87136db46bc35..6ba4090c66ebffd0a385d126d9d652ad2a8dcbba 100644 GIT binary patch delta 604 zcmZXRF)u_x6os=A!78aFk{g|5V_BW8M5UlXB@(mq?%SR9-psf&Z)G(bqE)^Buo@DH zLgOz8{)9r*wCOY z6rOj43o-&yrBy1Dp-4fYO~g39B|M~=>v?eA5VF9KtxJ?Q+wA0_k)9d@~k1a-6LTd=javkROf$5d1_@(XeUPdEHb1q`pyiE=;D^Z%sL zP7M;^uwz3hMjX#ZsD3;22m1$^(tfoDhn9>tjVxYU=!pFAYNAYND^|!OjPBZ3&GE7Q ggZ$;Xo{XtQdK>3mY+}TmS&}t|hzx diff --git a/object/marshal.go b/object/marshal.go index b918e69..7a89b97 100644 --- a/object/marshal.go +++ b/object/marshal.go @@ -516,7 +516,7 @@ func (r *PutObjectPartInit) StableMarshal(buf []byte) []byte { offset += proto.NestedStructureMarshal(putReqInitObjectIDField, buf[offset:], r.id) offset += proto.NestedStructureMarshal(putReqInitSignatureField, buf[offset:], r.sig) offset += proto.NestedStructureMarshal(putReqInitHeaderField, buf[offset:], r.hdr) - proto.UInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum) + proto.RepeatedUInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum) return buf } @@ -529,7 +529,9 @@ func (r *PutObjectPartInit) StableSize() (size int) { size += proto.NestedStructureSize(putReqInitObjectIDField, r.id) size += proto.NestedStructureSize(putReqInitSignatureField, r.sig) size += proto.NestedStructureSize(putReqInitHeaderField, r.hdr) - size += proto.UInt32Size(putReqInitCopiesNumField, r.copyNum) + + arrSize, _ := proto.RepeatedUInt32Size(putReqInitCopiesNumField, r.copyNum) + size += arrSize return size } diff --git a/object/test/generate.go b/object/test/generate.go index 0816ffc..32d7a3c 100644 --- a/object/test/generate.go +++ b/object/test/generate.go @@ -216,7 +216,7 @@ func GeneratePutObjectPartInit(empty bool) *object.PutObjectPartInit { m := new(object.PutObjectPartInit) if !empty { - m.SetCopiesNumber(234) + m.SetCopiesNumber([]uint32{234}) m.SetObjectID(refstest.GenerateObjectID(false)) } diff --git a/object/types.go b/object/types.go index f076b74..a40de57 100644 --- a/object/types.go +++ b/object/types.go @@ -128,7 +128,7 @@ type PutObjectPartInit struct { hdr *Header - copyNum uint32 + copyNum []uint32 } type PutObjectPartChunk struct { @@ -894,15 +894,15 @@ func (r *PutObjectPartInit) SetHeader(v *Header) { r.hdr = v } -func (r *PutObjectPartInit) GetCopiesNumber() uint32 { +func (r *PutObjectPartInit) GetCopiesNumber() []uint32 { if r != nil { return r.copyNum } - return 0 + return nil } -func (r *PutObjectPartInit) SetCopiesNumber(v uint32) { +func (r *PutObjectPartInit) SetCopiesNumber(v []uint32) { r.copyNum = v }