forked from TrueCloudLab/frostfs-sdk-go
[#224] object: Introduce parent attributes in EC-header
Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
parent
717a7d00ef
commit
ebd8fcd168
5 changed files with 59 additions and 13 deletions
|
@ -13,18 +13,34 @@ type ECHeader struct {
|
|||
parent oid.ID
|
||||
parentSplitID *SplitID
|
||||
parentSplitParentID *oid.ID
|
||||
parentAttributes []Attribute
|
||||
index uint32
|
||||
total uint32
|
||||
header []byte
|
||||
headerLength uint32
|
||||
}
|
||||
|
||||
type ECParentInfo struct {
|
||||
// EC-parent's ID.
|
||||
ID oid.ID
|
||||
|
||||
// EC-parent's split ID if the parent is a part of Split itself.
|
||||
SplitID *SplitID
|
||||
|
||||
// EC-parent's parent split ID if the parent is a part of Split itself.
|
||||
SplitParentID *oid.ID
|
||||
|
||||
// EC-parent's attributes.
|
||||
Attributes []Attribute
|
||||
}
|
||||
|
||||
// NewECHeader constructs new erasure coding header.
|
||||
func NewECHeader(parent oid.ID, parentSplitID *SplitID, parentSplitParentID *oid.ID, index, total uint32, header []byte, headerLength uint32) *ECHeader {
|
||||
func NewECHeader(ecParentInfo ECParentInfo, index, total uint32, header []byte, headerLength uint32) *ECHeader {
|
||||
return &ECHeader{
|
||||
parent: parent,
|
||||
parentSplitID: parentSplitID,
|
||||
parentSplitParentID: parentSplitParentID,
|
||||
parent: ecParentInfo.ID,
|
||||
parentSplitID: ecParentInfo.SplitID,
|
||||
parentSplitParentID: ecParentInfo.SplitParentID,
|
||||
parentAttributes: ecParentInfo.Attributes,
|
||||
index: index,
|
||||
total: total,
|
||||
header: header,
|
||||
|
@ -45,6 +61,13 @@ func (e *ECHeader) WriteToV2(h *object.ECHeader) {
|
|||
}
|
||||
|
||||
h.Parent = &parent
|
||||
|
||||
attrs := make([]object.Attribute, len(e.parentAttributes))
|
||||
for i := range e.parentAttributes {
|
||||
attrs[i] = *e.parentAttributes[i].ToV2()
|
||||
}
|
||||
h.ParentAttributes = attrs
|
||||
|
||||
h.Index = e.index
|
||||
h.Total = e.total
|
||||
h.Header = e.header
|
||||
|
@ -60,6 +83,12 @@ func (e *ECHeader) ReadFromV2(h *object.ECHeader) error {
|
|||
return errors.New("empty parent")
|
||||
}
|
||||
|
||||
attrs := make([]Attribute, len(h.ParentAttributes))
|
||||
for i := range h.ParentAttributes {
|
||||
attrs[i] = *NewAttributeFromV2(&h.ParentAttributes[i])
|
||||
}
|
||||
e.parentAttributes = attrs
|
||||
|
||||
_ = e.parent.ReadFromV2(*h.Parent)
|
||||
e.parentSplitID = NewSplitIDFromV2(h.ParentSplitID)
|
||||
if h.ParentSplitParentID != nil {
|
||||
|
@ -123,6 +152,14 @@ func (e *ECHeader) SetParentSplitParentID(parentSplitParentID *oid.ID) {
|
|||
e.parentSplitParentID = parentSplitParentID
|
||||
}
|
||||
|
||||
func (e *ECHeader) ParentAttributes() []Attribute {
|
||||
return e.parentAttributes
|
||||
}
|
||||
|
||||
func (e *ECHeader) SetParentAttributes(attrs []Attribute) {
|
||||
e.parentAttributes = attrs
|
||||
}
|
||||
|
||||
func (e *ECHeader) Index() uint32 {
|
||||
return e.index
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue