Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Version release version Version = "0.0.1" // Commit will be overwritten automatically by the build system Commit = "HEAD" )
Functions ¶
Types ¶
type Encoder ¶
type Encoder struct {
// contains filtered or unexported fields
}
Encoder is a Reed-Solomon encoder/decoder. It implements the modules.ErasureCoder interface.
func (*Encoder) Encode ¶
Encode splits data into equal-length shards, some containing the original data and some containing parity data.
func (*Encoder) EncodeShards ¶
EncodeShards creates the parity shards for an already sharded input.
func (*Encoder) MinShards ¶
MinShards return the minimum number of shards that must be present to recover the original data.
type ErasureCoder ¶
type ErasureCoder interface { // NumShards is the number of shards returned by Encode. NumShards() int // MinShards is the minimum number of shards that must be present to // recover the original data. MinShards() int // Encode splits data into equal-length shards, with some shards // containing parity data. Encode(data []byte) ([][]byte, error) // EncodeShards encodes the input data like Encode but accepts an already // sharded input. EncodeShards(data [][]byte, shardSize uint64) ([][]byte, error) // Recover recovers the original data from shards and writes it to w. // shards should be identical to the slice returned by Encode (length and // order must be preserved), but with missing elements set to nil. n is // the number of bytes to be written to w; this is necessary because // shards may have been padded with zeros during encoding. Recover(shards [][]byte, n uint64, w io.Writer) error }
ErasureCoder is an error-correcting encoder and decoder.
func NewEncoder ¶
func NewEncoder(dataShards, parityShards int) (ErasureCoder, error)
NewEncoder creates a new Reed-Solomon encoder/decoder using the supplied parameters.
Click to show internal directories.
Click to hide internal directories.