2015-03-07 16:03:21 -05:00
|
|
|
package erasure
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
"io"
|
|
|
|
|
|
|
|
"github.com/minio-io/minio/pkg/storage/donut/erasure/erasure1"
|
|
|
|
)
|
|
|
|
|
2015-03-08 19:58:36 -04:00
|
|
|
// EncoderTechnique - encoder matrix type
|
2015-03-07 16:03:21 -05:00
|
|
|
type EncoderTechnique int
|
|
|
|
|
|
|
|
const (
|
|
|
|
// Vandermonde matrix type
|
|
|
|
Vandermonde EncoderTechnique = iota
|
|
|
|
// Cauchy matrix type
|
|
|
|
Cauchy
|
|
|
|
)
|
|
|
|
|
|
|
|
// Write latest donut format
|
2015-03-12 04:52:14 -04:00
|
|
|
func Write(target io.Writer, length uint32, k, m uint8, technique EncoderTechnique, data io.Reader) error {
|
2015-03-07 16:03:21 -05:00
|
|
|
var versionedTechnique erasure1.EncoderTechnique
|
|
|
|
switch {
|
|
|
|
case technique == Vandermonde:
|
|
|
|
versionedTechnique = erasure1.Vandermonde
|
|
|
|
case technique == Cauchy:
|
|
|
|
versionedTechnique = erasure1.Cauchy
|
|
|
|
default:
|
|
|
|
errors.New("Unknown encoder technique")
|
|
|
|
}
|
2015-03-12 04:52:14 -04:00
|
|
|
return erasure1.Write(target, length, k, m, versionedTechnique, data)
|
2015-03-07 16:03:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read any donut format
|
|
|
|
func Read(reader io.Reader) (io.Reader, error) {
|
|
|
|
// when version2 is created, create a method in version2 that can transform version1 structure to version2
|
|
|
|
return nil, errors.New("Not Implemented")
|
|
|
|
}
|