forked from TrueCloudLab/frostfs-api-go
[#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:
parent
4fe42ac4ad
commit
0803bc6ded
5 changed files with 33 additions and 19 deletions
|
@ -270,7 +270,7 @@ func (h *ECHeader) ToGRPCMessage() grpc.Message {
|
||||||
|
|
||||||
m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID)
|
m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID)
|
||||||
m.ParentSplitId = h.ParentSplitID
|
m.ParentSplitId = h.ParentSplitID
|
||||||
m.ParentSplitIndex = h.ParentSplitIndex
|
m.ParentSplitParentId = h.ParentSplitParentID.ToGRPCMessage().(*refsGRPC.ObjectID)
|
||||||
m.Index = h.Index
|
m.Index = h.Index
|
||||||
m.Total = h.Total
|
m.Total = h.Total
|
||||||
m.Header = h.Header
|
m.Header = h.Header
|
||||||
|
@ -303,7 +303,21 @@ func (h *ECHeader) FromGRPCMessage(m grpc.Message) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
h.ParentSplitID = v.GetParentSplitId()
|
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.Index = v.GetIndex()
|
||||||
h.Total = v.GetTotal()
|
h.Total = v.GetTotal()
|
||||||
h.Header = v.GetHeader()
|
h.Header = v.GetHeader()
|
||||||
|
|
BIN
object/grpc/types.pb.go
generated
BIN
object/grpc/types.pb.go
generated
Binary file not shown.
|
@ -26,13 +26,13 @@ const (
|
||||||
splitHdrChildrenField = 5
|
splitHdrChildrenField = 5
|
||||||
splitHdrSplitIDField = 6
|
splitHdrSplitIDField = 6
|
||||||
|
|
||||||
ecHdrParentField = 1
|
ecHdrParentField = 1
|
||||||
ecHdrIndexField = 2
|
ecHdrIndexField = 2
|
||||||
ecHdrTotalField = 3
|
ecHdrTotalField = 3
|
||||||
ecHdrHeaderLengthField = 4
|
ecHdrHeaderLengthField = 4
|
||||||
ecHdrHeaderField = 5
|
ecHdrHeaderField = 5
|
||||||
ecHdrParentSplitID = 6
|
ecHdrParentSplitID = 6
|
||||||
ecHdrParentSplitIndex = 7
|
ecHdrParentSplitParentID = 7
|
||||||
|
|
||||||
hdrVersionField = 1
|
hdrVersionField = 1
|
||||||
hdrContainerIDField = 2
|
hdrContainerIDField = 2
|
||||||
|
@ -264,7 +264,7 @@ func (h *ECHeader) StableMarshal(buf []byte) []byte {
|
||||||
offset += proto.UInt32Marshal(ecHdrHeaderLengthField, buf[offset:], h.HeaderLength)
|
offset += proto.UInt32Marshal(ecHdrHeaderLengthField, buf[offset:], h.HeaderLength)
|
||||||
offset += proto.BytesMarshal(ecHdrHeaderField, buf[offset:], h.Header)
|
offset += proto.BytesMarshal(ecHdrHeaderField, buf[offset:], h.Header)
|
||||||
offset += proto.BytesMarshal(ecHdrParentSplitID, buf[offset:], h.ParentSplitID)
|
offset += proto.BytesMarshal(ecHdrParentSplitID, buf[offset:], h.ParentSplitID)
|
||||||
proto.UInt32Marshal(ecHdrParentSplitIndex, buf[offset:], h.ParentSplitIndex)
|
proto.NestedStructureMarshal(ecHdrParentSplitParentID, buf[offset:], h.ParentSplitParentID)
|
||||||
return buf
|
return buf
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ func (h *ECHeader) StableSize() (size int) {
|
||||||
size += proto.UInt32Size(ecHdrHeaderLengthField, h.HeaderLength)
|
size += proto.UInt32Size(ecHdrHeaderLengthField, h.HeaderLength)
|
||||||
size += proto.BytesSize(ecHdrHeaderField, h.Header)
|
size += proto.BytesSize(ecHdrHeaderField, h.Header)
|
||||||
size += proto.BytesSize(ecHdrParentSplitID, h.ParentSplitID)
|
size += proto.BytesSize(ecHdrParentSplitID, h.ParentSplitID)
|
||||||
size += proto.UInt32Size(ecHdrParentSplitIndex, h.ParentSplitIndex)
|
size += proto.NestedStructureSize(ecHdrParentSplitParentID, h.ParentSplitParentID)
|
||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,7 +92,7 @@ func GenerateECHeader(empty bool) *object.ECHeader {
|
||||||
if !empty {
|
if !empty {
|
||||||
ech.Parent = refstest.GenerateObjectID(empty)
|
ech.Parent = refstest.GenerateObjectID(empty)
|
||||||
ech.ParentSplitID = []byte{1, 2, 3}
|
ech.ParentSplitID = []byte{1, 2, 3}
|
||||||
ech.ParentSplitIndex = 1
|
ech.ParentSplitParentID = refstest.GenerateObjectID(empty)
|
||||||
ech.Index = 0
|
ech.Index = 0
|
||||||
ech.Total = 2
|
ech.Total = 2
|
||||||
ech.Header = []byte("chunk of ec-encoded parent header")
|
ech.Header = []byte("chunk of ec-encoded parent header")
|
||||||
|
|
|
@ -40,13 +40,13 @@ type SplitHeader struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ECHeader struct {
|
type ECHeader struct {
|
||||||
Parent *refs.ObjectID
|
Parent *refs.ObjectID
|
||||||
ParentSplitID []byte
|
ParentSplitID []byte
|
||||||
ParentSplitIndex uint32
|
ParentSplitParentID *refs.ObjectID
|
||||||
Index uint32
|
Index uint32
|
||||||
Total uint32
|
Total uint32
|
||||||
Header []byte
|
Header []byte
|
||||||
HeaderLength uint32
|
HeaderLength uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
type Header struct {
|
type Header struct {
|
||||||
|
|
Loading…
Reference in a new issue