Compare commits

...

1 commit

Author SHA1 Message Date
f0b01527c1 [#84] object: Regenerate EC-header type
All checks were successful
DCO action / DCO (pull_request) Successful in 58s
Tests and linters / Tests (1.20) (pull_request) Successful in 1m16s
Tests and linters / Tests (1.19) (pull_request) Successful in 1m27s
Tests and linters / Lint (pull_request) Successful in 1m53s
Tests and linters / Tests with -race (pull_request) Successful in 1m58s
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
2024-05-30 11:18:24 +03:00
5 changed files with 15 additions and 1 deletions

View file

@ -271,6 +271,7 @@ func (h *ECHeader) ToGRPCMessage() grpc.Message {
m.Parent = h.Parent.ToGRPCMessage().(*refsGRPC.ObjectID)
m.ParentSplitId = h.ParentSplitID
m.ParentSplitParentId = h.ParentSplitParentID.ToGRPCMessage().(*refsGRPC.ObjectID)
m.ParentAttributes = AttributesToGRPC(h.ParentAttributes)
m.Index = h.Index
m.Total = h.Total
m.Header = h.Header
@ -318,6 +319,10 @@ func (h *ECHeader) FromGRPCMessage(m grpc.Message) error {
}
}
if h.ParentAttributes, err = AttributesFromGRPC(v.GetParentAttributes()); 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

@ -33,6 +33,7 @@ const (
ecHdrHeaderField = 5
ecHdrParentSplitID = 6
ecHdrParentSplitParentID = 7
ecHdrParentAttributes = 8
hdrVersionField = 1
hdrContainerIDField = 2
@ -264,7 +265,10 @@ 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.NestedStructureMarshal(ecHdrParentSplitParentID, buf[offset:], h.ParentSplitParentID)
offset += proto.NestedStructureMarshal(ecHdrParentSplitParentID, buf[offset:], h.ParentSplitParentID)
for i := range h.ParentAttributes {
offset += proto.NestedStructureMarshal(ecHdrParentAttributes, buf[offset:], &h.ParentAttributes[i])
}
return buf
}
@ -280,6 +284,9 @@ func (h *ECHeader) StableSize() (size int) {
size += proto.BytesSize(ecHdrHeaderField, h.Header)
size += proto.BytesSize(ecHdrParentSplitID, h.ParentSplitID)
size += proto.NestedStructureSize(ecHdrParentSplitParentID, h.ParentSplitParentID)
for i := range h.ParentAttributes {
size += proto.NestedStructureSize(ecHdrParentAttributes, &h.ParentAttributes[i])
}
return size
}

View file

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

View file

@ -43,6 +43,7 @@ type ECHeader struct {
Parent *refs.ObjectID
ParentSplitID []byte
ParentSplitParentID *refs.ObjectID
ParentAttributes []Attribute
Index uint32
Total uint32
Header []byte