ec

package
v0.49.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 15, 2025 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AttributePrefix  = "__NEOFS__EC_"
	AttributeRuleIdx = AttributePrefix + "RULE_IDX"
	AttributePartIdx = AttributePrefix + "PART_IDX"
)

Erasure coding attributes.

Variables

This section is empty.

Functions

func ConcatDataParts

func ConcatDataParts(rule Rule, dataLen uint64, parts [][]byte) []byte

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

func Decode(rule Rule, dataLen uint64, parts [][]byte) ([]byte, error)

Decode decodes source data of known len from EC parts obtained by applying specified rule.

func Encode

func Encode(rule Rule, data []byte) ([][]byte, error)

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

func NodeSequenceForPart(partIdx, totalParts, nodes int) iter.Seq[int]

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

func ObjectWithAttributes(obj object.Object) bool

ObjectWithAttributes checks whether obj contains at least one EC attribute.

Types

type ErrParts

type ErrParts []oid.ID

ErrParts is error carrying ID set of EC parts.

func (ErrParts) Error

func (x ErrParts) Error() string

Error implements [error].

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

func DecodePartInfoFromAttributes(ruleIdxAttr, partIdxAttr string) (PartInfo, error)

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

func GetPartInfo(obj object.Object) (PartInfo, error)

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.

type Rule

type Rule struct {
	DataPartNum   uint8
	ParityPartNum uint8
}

Rule represents erasure coding rule for object payload's encoding and placement.

func (Rule) String

func (x Rule) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL