[#83] object: Regenerate protobufs for ECHeader

* Fix marshalers and converters;
* Fix unit-tests.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-05-16 12:03:42 +03:00
parent 4fe42ac4ad
commit 0803bc6ded
5 changed files with 33 additions and 19 deletions

View file

@ -270,7 +270,7 @@ func (h *ECHeader) ToGRPCMessage() grpc.Message {
m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID)
m.ParentSplitId = h.ParentSplitID
m.ParentSplitIndex = h.ParentSplitIndex
m.ParentSplitParentId = h.ParentSplitParentID.ToGRPCMessage().(*refsGRPC.ObjectID)
m.Index = h.Index
m.Total = h.Total
m.Header = h.Header
@ -303,7 +303,21 @@ func (h *ECHeader) FromGRPCMessage(m grpc.Message) error {
}
h.ParentSplitID = v.GetParentSplitId()
h.ParentSplitIndex = v.GetParentSplitIndex()
parSplitParentID := v.GetParentSplitParentId()
if parSplitParentID == nil {
h.ParentSplitParentID = nil
} else {
if h.ParentSplitParentID == nil {
h.ParentSplitParentID = new(refs.ObjectID)
}
err = h.ParentSplitParentID.FromGRPCMessage(parSplitParentID)
if err != nil {
return err
}
}
h.Index = v.GetIndex()
h.Total = v.GetTotal()
h.Header = v.GetHeader()

BIN
object/grpc/types.pb.go generated

Binary file not shown.

View file

@ -26,13 +26,13 @@ const (
splitHdrChildrenField = 5
splitHdrSplitIDField = 6
ecHdrParentField = 1
ecHdrIndexField = 2
ecHdrTotalField = 3
ecHdrHeaderLengthField = 4
ecHdrHeaderField = 5
ecHdrParentSplitID = 6
ecHdrParentSplitIndex = 7
ecHdrParentField = 1
ecHdrIndexField = 2
ecHdrTotalField = 3
ecHdrHeaderLengthField = 4
ecHdrHeaderField = 5
ecHdrParentSplitID = 6
ecHdrParentSplitParentID = 7
hdrVersionField = 1
hdrContainerIDField = 2
@ -264,7 +264,7 @@ func (h *ECHeader) StableMarshal(buf []byte) []byte {
offset += proto.UInt32Marshal(ecHdrHeaderLengthField, buf[offset:], h.HeaderLength)
offset += proto.BytesMarshal(ecHdrHeaderField, buf[offset:], h.Header)
offset += proto.BytesMarshal(ecHdrParentSplitID, buf[offset:], h.ParentSplitID)
proto.UInt32Marshal(ecHdrParentSplitIndex, buf[offset:], h.ParentSplitIndex)
proto.NestedStructureMarshal(ecHdrParentSplitParentID, buf[offset:], h.ParentSplitParentID)
return buf
}
@ -279,7 +279,7 @@ func (h *ECHeader) StableSize() (size int) {
size += proto.UInt32Size(ecHdrHeaderLengthField, h.HeaderLength)
size += proto.BytesSize(ecHdrHeaderField, h.Header)
size += proto.BytesSize(ecHdrParentSplitID, h.ParentSplitID)
size += proto.UInt32Size(ecHdrParentSplitIndex, h.ParentSplitIndex)
size += proto.NestedStructureSize(ecHdrParentSplitParentID, h.ParentSplitParentID)
return size
}

View file

@ -92,7 +92,7 @@ func GenerateECHeader(empty bool) *object.ECHeader {
if !empty {
ech.Parent = refstest.GenerateObjectID(empty)
ech.ParentSplitID = []byte{1, 2, 3}
ech.ParentSplitIndex = 1
ech.ParentSplitParentID = refstest.GenerateObjectID(empty)
ech.Index = 0
ech.Total = 2
ech.Header = []byte("chunk of ec-encoded parent header")

View file

@ -40,13 +40,13 @@ type SplitHeader struct {
}
type ECHeader struct {
Parent *refs.ObjectID
ParentSplitID []byte
ParentSplitIndex uint32
Index uint32
Total uint32
Header []byte
HeaderLength uint32
Parent *refs.ObjectID
ParentSplitID []byte
ParentSplitParentID *refs.ObjectID
Index uint32
Total uint32
Header []byte
HeaderLength uint32
}
type Header struct {