Move pkg/storage/erasure to pkg/encoding/erasure - and other cleanups

This commit is contained in:
Harshavardhana 2015-03-07 00:15:58 -08:00
parent 80fa38a41f
commit d992bccd9a
57 changed files with 17 additions and 24 deletions

View File

@ -16,7 +16,6 @@ getdeps: checkdeps checkgopath
verifier: getdeps
@echo "Checking for offending code"
@go run buildscripts/verifier.go ${PWD}
@go vet ./...
build-all: verifier
@echo "Building Libraries"

View File

@ -14,13 +14,12 @@
* limitations under the License.
*/
package erasure_test
package erasure
import (
"bytes"
"testing"
"github.com/minio-io/minio/pkg/storage/erasure"
. "gopkg.in/check.v1"
)
@ -31,11 +30,11 @@ var _ = Suite(&MySuite{})
func Test(t *testing.T) { TestingT(t) }
func (s *MySuite) TestCauchyDecode(c *C) {
ep, _ := erasure.ParseEncoderParams(10, 5, erasure.Cauchy)
ep, _ := ParseEncoderParams(10, 5, Cauchy)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
e := erasure.NewEncoder(ep)
e := NewEncoder(ep)
chunks, length := e.Encode(data)
c.Assert(length, Equals, len(data))

View File

@ -14,21 +14,20 @@
* limitations under the License.
*/
package erasure_test
package erasure
import (
"bytes"
"github.com/minio-io/minio/pkg/storage/erasure"
. "gopkg.in/check.v1"
)
func (s *MySuite) TestVanderMondeDecode(c *C) {
ep, _ := erasure.ParseEncoderParams(10, 5, erasure.Vandermonde)
ep, _ := ParseEncoderParams(10, 5, Vandermonde)
data := []byte("Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.")
e := erasure.NewEncoder(ep)
e := NewEncoder(ep)
chunks, length := e.Encode(data)
c.Logf("chunks length: %d", len(chunks))
c.Logf("length: %d", length)

View File

@ -63,7 +63,7 @@ func validateHeader(header DataHeader) error {
return nil
}
// WriteData returns error upon any failure
// Write returns error upon any failure
func Write(target io.Writer, key string, part uint8, length uint32, k, m uint8, technique EncoderTechnique, data io.Reader) error {
header := DataHeader{
Key: key,

View File

@ -86,8 +86,8 @@ type DonutFrameFooter struct {
// Data buffer
type Data bytes.Buffer
// WriteFrame - write donut format to input io.Writer, returns error upon any failure
func WriteFrame(target io.Writer, reader io.Reader, length uint64) error {
// Write - write donut format to input io.Writer, returns error upon any failure
func Write(target io.Writer, reader io.Reader, length uint64) error {
// write header
header := DonutFrameHeader{
MagicMINI: MagicMINI,

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package fragment_test
package fragment
import (
"bytes"
@ -22,7 +22,6 @@ import (
"encoding/binary"
"testing"
"github.com/minio-io/minio/pkg/storage/donut/fragment/fragment_v1"
"github.com/minio-io/minio/pkg/utils/checksum/crc32c"
. "gopkg.in/check.v1"
)
@ -39,7 +38,7 @@ func (s *MySuite) TestSingleWrite(c *C) {
testData := "Hello, World"
testLength := uint64(len(testData))
err := fragment.WriteFrame(&testBuffer, bytes.NewBufferString(testData), testLength)
err := Write(&testBuffer, bytes.NewBufferString(testData), testLength)
c.Assert(err, IsNil)
testBufferLength := uint64(testBuffer.Len())
@ -112,7 +111,7 @@ func (s *MySuite) TestSingleWrite(c *C) {
func (s *MySuite) TestLengthMismatchInWrite(c *C) {
var testData bytes.Buffer
err := fragment.WriteFrame(&testData, bytes.NewBufferString("hello, world"), 5)
err := Write(&testData, bytes.NewBufferString("hello, world"), 5)
c.Assert(err, Not(IsNil))
}
@ -122,7 +121,7 @@ func benchmarkSize(b *testing.B, size int) {
b.SetBytes(int64(size))
target := new(bytes.Buffer)
for i := 0; i < b.N; i++ {
fragment.WriteFrame(target, bytes.NewReader(buf[:size]), uint64(size))
Write(target, bytes.NewReader(buf[:size]), uint64(size))
}
}

View File

@ -1 +0,0 @@
newfile

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package fs_test
package fs
import (
"io/ioutil"
@ -22,7 +22,6 @@ import (
"testing"
mstorage "github.com/minio-io/minio/pkg/storage"
"github.com/minio-io/minio/pkg/storage/fs"
. "gopkg.in/check.v1"
)
@ -39,7 +38,7 @@ func (s *MySuite) TestAPISuite(c *C) {
path, err := ioutil.TempDir(os.TempDir(), "minio-fs-")
c.Check(err, IsNil)
storageList = append(storageList, path)
_, _, store := fs.Start(path)
_, _, store := Start(path)
return store
}
mstorage.APITestSuite(c, create)

View File

@ -14,13 +14,12 @@
* limitations under the License.
*/
package inmemory_test
package inmemory
import (
"testing"
mstorage "github.com/minio-io/minio/pkg/storage"
"github.com/minio-io/minio/pkg/storage/inmemory"
. "gopkg.in/check.v1"
)
@ -33,7 +32,7 @@ var _ = Suite(&MySuite{})
func (s *MySuite) TestAPISuite(c *C) {
create := func() mstorage.Storage {
_, _, store := inmemory.Start()
_, _, store := Start()
return store
}