erasurecode

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: Apache-2.0 Imports: 5 Imported by: 4 modules, 12 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
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
)
View Source
const EncodedShardUnit = 64

EncodedShardUnit minimum unit for encoded data structure

Variables

View Source
var ErrInsufficientData = errors.New("not sufficient data for recovery")

ErrInsufficientData is the error that not sufficient data is provided for recovery.

View Source
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

Jump to

Keyboard shortcuts

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