From 703af6c3ce2cb571cd3b5b3c3b949a725ffb1725 Mon Sep 17 00:00:00 2001 From: "Frederick F. Kautz IV" Date: Sun, 22 Mar 2015 12:17:12 -0700 Subject: [PATCH] Removing gob from donut driver --- pkg/storage/donut/donutdriver.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/pkg/storage/donut/donutdriver.go b/pkg/storage/donut/donutdriver.go index 3a8a4a258..7ee88925a 100644 --- a/pkg/storage/donut/donutdriver.go +++ b/pkg/storage/donut/donutdriver.go @@ -2,6 +2,7 @@ package donut import ( "bytes" + "encoding/json" "errors" "io" "io/ioutil" @@ -13,9 +14,6 @@ import ( "strings" "time" - "encoding/gob" - "encoding/json" - "github.com/minio-io/minio/pkg/encoding/erasure" "github.com/minio-io/minio/pkg/utils/split" ) @@ -127,13 +125,9 @@ func erasureReader(readers []io.ReadCloser, donutMetadata map[string]string, wri for i := 0; i < totalChunks; i++ { encodedBytes := make([][]byte, 16) for i, reader := range readers { - var bytesArray []byte - decoder := gob.NewDecoder(reader) - err := decoder.Decode(&bytesArray) - if err != nil { - log.Println(err) - } - encodedBytes[i] = bytesArray + var bytesBuffer bytes.Buffer + io.Copy(&bytesBuffer, reader) + encodedBytes[i] = bytesBuffer.Bytes() } curBlockSize := totalLeft if blockSize < totalLeft { @@ -185,10 +179,7 @@ func erasureGoroutine(r *io.PipeReader, eWriter erasureWriter, isClosed chan<- b totalLength = totalLength + len(chunk.Data) encodedBlocks, _ := encoder.Encode(chunk.Data) for blockIndex, block := range encodedBlocks { - var byteBuffer bytes.Buffer - gobEncoder := gob.NewEncoder(&byteBuffer) - gobEncoder.Encode(block) - io.Copy(eWriter.writers[blockIndex], &byteBuffer) + io.Copy(eWriter.writers[blockIndex], bytes.NewBuffer(block)) } } chunkCount = chunkCount + 1