Documentation
¶
Index ¶
Constants ¶
const ( // ECTypeInvalid is the type not supported ECTypeInvalid uint8 = iota // ECTypeStandard is the type code for standardErasureCode ECTypeStandard // ECTypeShard is the type code for shardErasureCode ECTypeShard )
const EncodedShardUnit = 64
EncodedShardUnit minimum unit for encoded data structure
Variables ¶
var ErrInsufficientData = errors.New("not sufficient data for recovery")
ErrInsufficientData is the error that not sufficient data is provided for recovery.
var ErrInvalidECType = errors.New("invalid erasure code type")
ErrInvalidECType is the error that the input type code is not supported
Functions ¶
This section is empty.
Types ¶
type ErasureCoder ¶
type ErasureCoder interface {
// Type return the type of the code
Type() uint8
// NumSectors return the total number of encoded sectors
NumSectors() uint32
// MinSectors return the number of minimum sectors that is required to recover the original data
MinSectors() uint32
// Extra return the extra info included in the ErasureCoder
Extra() []interface{}
// Encode encode the segment to sectors
Encode(data []byte) ([][]byte, error)
// Recover decode the input sectors to the original data with length outLen
Recover(sectors [][]byte, n int, w io.Writer) error
}
ErasureCoder is the interface supported for this package. Implemented types are
ECTypeStandard - standardErasureCode ECTypeShard - shardErasureCode
Recommend to use the standard erasure code instead of the sharding one because of performance
func New ¶
func New(ecType uint8, minSectors uint32, numSectors uint32, extra ...interface{}) (ErasureCoder, error)
New returns a new ErasureCoder. Type supported are ECTypeStandard, and ECTypeShard. The two parameters followed is parameters used for erasure code: num of data sectors and total number of sectors. Additional arguments could be attached for param specification. Note in this implementation, the following condition must be met: numSectors > minSectors > 0