redundancy

package
v2.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: BSD-3-Clause Imports: 6 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeLevel

func EncodeLevel(span []byte, level Level)

EncodeLevel encodes used redundancy level for uploading into span keeping the real byte count for the chunk. assumes span is LittleEndian

func GetReplicaCounts

func GetReplicaCounts() [5]int

GetReplicaCounts returns back the ascending dispersed replica counts for all redundancy levels

func IsLevelEncoded

func IsLevelEncoded(span []byte) bool

IsLevelEncoded checks whether the redundancy level is encoded in the span assumes span is LittleEndian

func SetLevelInContext

func SetLevelInContext(ctx context.Context, level Level) context.Context

SetLevelInContext sets the redundancy level in the context

Types

type ErasureEncoder

type ErasureEncoder interface {
	Encode([][]byte) error
}

type Level

type Level uint8

Level is the redundancy level which carries information about how much redundancy should be added to data to remain retrievable with a 1-10^(-6) certainty in different groups of expected chunk retrieval error rates (level values)

const (
	// no redundancy will be added
	NONE Level = iota
	// expected 1% chunk retrieval error rate
	MEDIUM
	// expected 5% chunk retrieval error rate
	STRONG
	// expected 10% chunk retrieval error rate
	INSANE
	// expected 50% chunk retrieval error rate
	PARANOID
)

func DecodeSpan

func DecodeSpan(span []byte) (Level, []byte)

DecodeSpan decodes the used redundancy level from span keeping the real byte count for the chunk. assumes span is LittleEndian

func GetLevelFromContext

func GetLevelFromContext(ctx context.Context) Level

GetLevelFromContext is a helper function to extract the redundancy level from the context

func (Level) Decrement

func (l Level) Decrement() Level

Decrement returns a weaker redundancy level compare to the current one

func (Level) GetEncParities

func (l Level) GetEncParities(shards int) int

GetEncParities returns number of parities for encrypted chunks based on appendix F table 6

func (Level) GetMaxEncShards

func (l Level) GetMaxEncShards() int

GetMaxEncShards returns back the maximum number of effective encrypted data chunks

func (Level) GetMaxShards

func (l Level) GetMaxShards() int

GetMaxShards returns back the maximum number of effective data chunks

func (Level) GetParities

func (l Level) GetParities(shards int) int

GetParities returns number of parities based on appendix F table 5

func (Level) GetReplicaCount

func (l Level) GetReplicaCount() int

GetReplicaCount returns back the dispersed replica number

type Params

type Params struct {
	// contains filtered or unexported fields
}

func New

func New(level Level, encryption bool, pipeLine pipeline.PipelineFunc) *Params

func (*Params) ChunkWrite

func (p *Params) ChunkWrite(chunkLevel int, data []byte, callback ParityChunkCallback) error

ChunkWrite caches the chunk data on the given chunk level and if it is full then it calls Encode

func (*Params) ElevateCarrierChunk

func (p *Params) ElevateCarrierChunk(chunkLevel int, callback ParityChunkCallback) error

ElevateCarrierChunk moves the last poor orphan chunk to the level above where it can fit and there are other chunks as well.

func (*Params) Encode

func (p *Params) Encode(chunkLevel int, callback ParityChunkCallback) error

Encode produces and stores parity chunks that will be also passed back to the caller

func (*Params) GetRootData

func (p *Params) GetRootData() ([]byte, error)

GetRootData returns the topmost chunk in the tree. throws and error if the encoding has not been finished in the BMT OR redundancy is not used in the BMT

func (*Params) Level

func (p *Params) Level() Level

func (*Params) MaxShards

func (p *Params) MaxShards() int

func (*Params) Parities

func (p *Params) Parities(shards int) int

type ParityChunkCallback

type ParityChunkCallback func(level int, span, address []byte) error

ParityChunkCallback is called when a new parity chunk has been created

type RedundancyParams

type RedundancyParams interface {
	MaxShards() int // returns the maximum data shard number being used in an intermediate chunk
	Level() Level
	Parities(int) int
	ChunkWrite(int, []byte, ParityChunkCallback) error
	ElevateCarrierChunk(int, ParityChunkCallback) error
	Encode(int, ParityChunkCallback) error
	GetRootData() ([]byte, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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