Documentation ¶
Overview ¶
Package erasure is a Go wrapper for the Intel Intelligent Storage Acceleration Library (Intel ISA-L). Intel ISA-L is a CPU optimized implementation of erasure coding algorithms.
For more information on Intel ISA-L, please visit: https://01.org/intel%C2%AE-storage-acceleration-library-open-source-version
Usage:
Encode encodes a block of data. The input is the original data. The output is a 2 tuple containing (k + m) chunks of erasure encoded data and the length of the original object.
Decode decodes 2 tuple data containing (k + m) chunks back into its original form. Additionally original block length should also be provided as input.
Decoded data is exactly similar in length and content as the original data.
Encoding data may be performed in 3 steps.
- Create a parse set of encoder parameters
- Create a new encoder
- Encode data
Decoding data is also performed in 3 steps.
- Create a parse set of encoder parameters for validation
- Create a new encoder
- Decode data
Erasure parameters contain three configurable elements:
ValidateParams(k, m, technique int) (ErasureParams, error) k - Number of rows in matrix m - Number of colums in matrix technique - Matrix type, can be either Cauchy (recommended) or Vandermonde constraints: k + m < Galois Field (2^8)
Choosing right parity and matrix technique is left for application to decide.
But here are the few points to keep in mind
Techniques: - Vandermonde is most commonly used method for choosing coefficients in erasure encoding but does not guarantee invertable for every sub matrix. Users may want to adjust for k > 5. (k is data blocks) - Whereas Cauchy is our recommended method for choosing coefficients in erasure coding. Since any sub-matrix of a Cauchy matrix is invertable. Total blocks: - Data blocks and Parity blocks should not be greater than 'Galois Field' (2^8)
Example ¶
Creating and using an encoder
var bytes []byte params := erasure.ValidateParams(10, 5, erasure.Cauchy) encoder := erasure.NewErasure(params) encodedData, length := encoder.Encode(bytes)
Creating and using a decoder
var encodedData [][]byte var length int params := erasure.ValidateParams(10, 5, erasure.Cauchy) encoder := erasure.NewErasure(params) originalData, err := encoder.Decode(encodedData, length)
Index ¶
Constants ¶
const ( K = 10 M = 3 )
Default Data and Parity blocks
const (
SIMDAlign = 32
)
Block alignment
Variables ¶
This section is empty.
Functions ¶
func GetEncodedBlockLen ¶
GetEncodedBlockLen - length per block of encoded blocks
func GetEncodedBlocksLen ¶
GetEncodedBlocksLen - total length of all encoded blocks
Types ¶
type Erasure ¶
type Erasure struct {
// contains filtered or unexported fields
}
Erasure is an object used to encode and decode data.
func NewErasure ¶
NewErasure creates an encoder object with a given set of parameters.
func (*Erasure) Decode ¶
Decode decodes erasure coded blocks of data into its original form. Erasure coded data contains K data blocks and M parity blocks. Decode can withstand data loss up to any M number of blocks.
"encodedDataBlocks" is an array of K data blocks and M parity blocks. Data blocks are position and order dependent. Missing blocks are set to "nil". There must be at least "K" number of data|parity blocks.
"dataLen" is the length of original source data