Documentation
¶
Index ¶
- Constants
- func ConcatDataParts(rule Rule, dataLen uint64, parts [][]byte) []byte
- func Decode(rule Rule, dataLen uint64, parts [][]byte) ([]byte, error)
- func Encode(rule Rule, data []byte) ([][]byte, error)
- func FormObjectForECPart(signer neofscrypto.Signer, parent object.Object, part []byte, ...) (object.Object, error)
- func NodeSequenceForPart(partIdx, totalParts, nodes int) iter.Seq[int]
- func ObjectWithAttributes(obj object.Object) bool
- type ErrParts
- type PartInfo
- type Rule
Constants ¶
const ( AttributePrefix = "__NEOFS__EC_" AttributeRuleIdx = AttributePrefix + "RULE_IDX" AttributePartIdx = AttributePrefix + "PART_IDX" )
Erasure coding attributes.
Variables ¶
This section is empty.
Functions ¶
func ConcatDataParts ¶
ConcatDataParts returns a new slice of dataLen bytes originating given EC parts according to rule.
Panics if there are less than Rule.DataPartNum parts.
func Decode ¶
Decode decodes source data of known len from EC parts obtained by applying specified rule.
func Encode ¶
Encode encodes given data according to specified EC rule and returns coded parts. First Rule.DataPartNum elements are data parts, other Rule.ParityPartNum ones are parity blocks.
All parts are the same length. If data len is not divisible by Rule.DataPartNum, last data part is aligned with zeros.
If data is empty, all parts are nil.
func FormObjectForECPart ¶
func FormObjectForECPart(signer neofscrypto.Signer, parent object.Object, part []byte, partInfo PartInfo) (object.Object, error)
FormObjectForECPart forms object for EC part produced from given parent object.
func NodeSequenceForPart ¶
NodeSequenceForPart returns sorted sequence of node indexes to store object for EC part with index = partIdx produced by applying the rule such that Rule.DataPartNum + Rule.ParityPartNum = totalParts.
func ObjectWithAttributes ¶
ObjectWithAttributes checks whether obj contains at least one EC attribute.
Types ¶
type PartInfo ¶
type PartInfo struct {
// Index of EC rule in the container storage policy.
RuleIndex int
// Part index.
Index int
}
PartInfo groups information about single EC part produced according to some Rule.
func DecodePartInfoFromAttributes ¶
DecodePartInfoFromAttributes decodes EC part info from given object attributes. It one of attributes is set, the other must be set too. If both are missing, DecodePartInfoFromAttributes returns PartInfo.RuleIndex = -1 without error.
func GetPartInfo ¶
GetPartInfo fetches EC part info from given object header. It one of AttributeRuleIdx or AttributeRuleIdx attributes is set, the other must be set too. If both are missing, GetPartInfo returns PartInfo.RuleIndex = -1 without error.