From 00381c887a287cde8fdc30b33745ad7851bddce2 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sat, 7 Mar 2015 13:03:21 -0800 Subject: [PATCH] Adding erasure package to wrap versioned erasure. Ensures we always write latest version. --- pkg/storage/donut/erasure/erasure.go | 37 ++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 pkg/storage/donut/erasure/erasure.go diff --git a/pkg/storage/donut/erasure/erasure.go b/pkg/storage/donut/erasure/erasure.go new file mode 100644 index 000000000..5a2d7d0e4 --- /dev/null +++ b/pkg/storage/donut/erasure/erasure.go @@ -0,0 +1,37 @@ +package erasure + +import ( + "errors" + "io" + + "github.com/minio-io/minio/pkg/storage/donut/erasure/erasure1" +) + +type EncoderTechnique int + +const ( + // Vandermonde matrix type + Vandermonde EncoderTechnique = iota + // Cauchy matrix type + Cauchy +) + +// Write latest donut format +func Write(target io.Writer, key string, part uint8, length uint32, k, m uint8, technique EncoderTechnique, data io.Reader) error { + var versionedTechnique erasure1.EncoderTechnique + switch { + case technique == Vandermonde: + versionedTechnique = erasure1.Vandermonde + case technique == Cauchy: + versionedTechnique = erasure1.Cauchy + default: + errors.New("Unknown encoder technique") + } + return erasure1.Write(target, key, part, length, k, m, versionedTechnique, data) +} + +// 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") +}