erasure

package
v0.0.0-...-f4bd7b1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2015 License: Apache-2.0 Imports: 5 Imported by: 0

README

Introduction

Erasure is an open source Golang library written on top of ISAL (Intel Intelligent Storage Library) released under Apache license v2

Developers

Supported platforms

Name Supported
Linux Yes
Windows Not yet
Mac OSX Yes

Supported architectures

Arch Supported
x86-64 Yes
arm64 Not yet
i386 Never

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.

  1. Create a parse set of encoder parameters
  2. Create a new encoder
  3. Encode data

Decoding data is also performed in 3 steps.

  1. Create a parse set of encoder parameters for validation
  2. Create a new encoder
  3. 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

View Source
const (
	K = 10
	M = 3
)

Default Data and Parity blocks

View Source
const (
	SIMDAlign = 32
)

Block alignment

Variables

This section is empty.

Functions

func GetEncodedBlockLen

func GetEncodedBlockLen(inputLen int, k uint8) (encodedOutputLen int)

GetEncodedBlockLen - length per block of encoded blocks

func GetEncodedBlocksLen

func GetEncodedBlocksLen(inputLen int, k, m uint8) (outputLen int)

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

func NewErasure(ep *Params) *Erasure

NewErasure creates an encoder object with a given set of parameters.

func (*Erasure) Decode

func (e *Erasure) Decode(encodedDataBlocks [][]byte, dataLen int) (decodedData []byte, err error)

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

func (*Erasure) Encode

func (e *Erasure) Encode(inputData []byte) (encodedBlocks [][]byte, err error)

Encode erasure codes a block of data in "k" data blocks and "m" parity blocks. Output is [k+m][]blocks of data and parity slices.

func (*Erasure) EncodeStream

func (e *Erasure) EncodeStream(data io.Reader, size int64) ([][]byte, []byte, error)

EncodeStream erasure codes a block of data in "k" data blocks and "m" parity blocks. Output is [k+m][]blocks of data and parity slices.

type Params

type Params struct {
	K         uint8
	M         uint8
	Technique Technique // cauchy or vandermonde matrix (RS)
}

Params is a configuration set for building an encoder. It is created using ValidateParams().

func ValidateParams

func ValidateParams(k, m uint8, technique Technique) (*Params, error)

ValidateParams creates an Params object.

k and m represent the matrix size, which corresponds to the protection level technique is the matrix type. Valid inputs are Cauchy (recommended) or Vandermonde.

type Technique

type Technique uint8

Technique - type of matrix type used in encoding

const (
	Vandermonde Technique = iota
	Cauchy
	None
)

Different types of supported matrix types

Jump to

Keyboard shortcuts

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