Documentation
¶
Overview ¶
Package mojette implements the Mojette transform erasure code: the discrete Radon-projection code used by RozoFS, operating XOR-wise (GF(2) addition) over fixed-size byte blocks.
Data is arranged as a Grid of Rows*Cols blocks in row-major order, each block being BlockSize bytes. Each Direction (P, Q) yields one Projection built by summing (XOR-ing) grid blocks that fall onto the same discrete line. Given a Katz-sufficient subset of projections, the grid can be rebuilt with the iterative inverse Mojette (back-projection) algorithm.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidGrid reports a grid (or reconstruction target) whose // dimensions or block sizes are inconsistent. ErrInvalidGrid = errors.New("mojette: invalid grid dimensions or block sizes") // ErrInvalidDirection reports a direction violating Q>=1 and gcd(|P|,Q)=1. ErrInvalidDirection = errors.New("mojette: direction requires Q>=1 and gcd(|P|,Q)=1") // ErrNotReconstructible reports that the supplied projections are not // sufficient to rebuild the grid. ErrNotReconstructible = errors.New("mojette: projections insufficient to reconstruct") )
Functions ¶
func Reconstructible ¶
Reconstructible reports whether dirs satisfy the Katz criterion for a rows*cols grid:
sum(Q_k) >= rows OR sum(|P_k|) >= cols
Types ¶
type Direction ¶
type Direction struct{ P, Q int }
Direction is a Mojette projection direction (P, Q). It requires Q >= 1 and gcd(|P|, Q) == 1.
type Grid ¶
type Grid struct {
Rows, Cols int
BlockSize int
Data [][]byte // len == Rows*Cols, each block == BlockSize bytes
}
Grid holds Rows*Cols data blocks in row-major order, each block BlockSize bytes long.
func Reconstruct ¶
func Reconstruct(rows, cols, blockSize int, projs []Projection) (*Grid, error)
Reconstruct rebuilds the rows*cols grid (blocks of blockSize) from a subset of projections using the iterative inverse Mojette (back-projection) over XOR. It returns ErrInvalidGrid for bad dimensions or mismatched projection bins, ErrInvalidDirection for a bad projection direction, and ErrNotReconstructible when the projections do not suffice.
type Projection ¶
type Projection struct {
Dir Direction
Bins [][]byte // len == nbins for Dir on the grid; each block BlockSize bytes
}
Projection is the Mojette projection of a grid along Dir. Bins has one block per discrete line; its length is the number of bins of Dir on the grid.