Documentation
¶
Index ¶
- type XRS
- func (x *XRS) Encode(vects [][]byte) (err error)
- func (x *XRS) GetNeedVects(needReconst int) (aNeed, bNeed []int, err error)
- func (x *XRS) Reconst(vects [][]byte, dpHas, needReconst []int) (err error)
- func (x *XRS) ReconstOne(vects [][]byte, needReconst int) (err error)
- func (x *XRS) Replace(data [][]byte, replaceRows []int, parity [][]byte) (err error)
- func (x *XRS) Update(oldData, newData []byte, row int, parity [][]byte) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type XRS ¶
type XRS struct {
// RS is the backend of XRS>
RS *rs.RS
// XORSet shows how XRS combines sub-vectors by xor.
//
// Key: Parity index(except first parity).
// Value: Data indexes.
XORSet map[int][]int
}
XRS X-Reed-Solomon Codes receiver.
func (*XRS) Encode ¶
Encode encodes data for generating parity. Write parity vectors into vects[r.DataNum:].
func (*XRS) GetNeedVects ¶
GetNeedVects receives needReconst index(it must be data vector) returns a_vectors' indexes and b_parity_vectors' indexes for reconstructing needReconst. It's used for ReconstOne to read correct vectors for saving I/O.
bNeed always has two elements, the first one is DataNum.
func (*XRS) Reconst ¶
Reconst reconstructs missing vectors, vects: All vectors, len(vects) = dataNum + parityNum. dpHas: Survived data & parity index, need dataNum indexes at least. needReconst: Vectors indexes which need to be reconstructed.
Warn: If there is only one needReconst, it will call ReconstOne, so make sure you have correct data, if there is only one vectors need to repair.
e.g: in 3+2, the whole index: [0,1,2,3,4], if vects[0,4] are lost & they need to be reconstructed (Maybe you only need vects[0], so the needReconst should be [0], but not [0,4]). the "dpHas" will be [1,2,3] ,and you must be sure that vects[1] vects[2] vects[3] have correct data, results will be written into vects[0]&vects[4] directly.
func (*XRS) ReconstOne ¶
ReconstOne reconstruct one data vector, it saves I/O. Make sure you have some specific vectors data. ( you can get the vectors' indexes from GetNeedVects)
func (*XRS) Replace ¶
Replace replaces oldData vectors with 0 or replaces 0 with newData vectors.
In practice, If len(replaceRows) > dataNum-parityNum, it's better to use Encode, because Replace need to read len(replaceRows) + parityNum vectors, if replaceRows are too many, the cost maybe larger than Encode (Encode only need read dataNum). Think about an EC compute node, and dataNum+parityNum data nodes model.
It's used in two situations: 1. We didn't have enough data for filling in a stripe, but still did ec encode, we need replace several zero vectors with new vectors which have data after we get enough data finally. 2. After compact, we may have several useless vectors in a stripe, we need replaces these useless vectors with zero vectors for free space.
Warn: data's index & replaceRows must has the same sort.