Go vet fixes for donut

master
Harshavardhana 10 years ago
parent 57a2b53178
commit 03b4d3b308
  1. 14
      pkg/erasure/erasure_encode.go
  2. 10
      pkg/storage/donut/bucket.go
  3. 1
      pkg/storage/donut/disk/disk.go
  4. 4
      pkg/storage/donut/encoder.go
  5. 4
      pkg/storage/donut/object.go
  6. 4
      pkg/storage/donut/objectstorage.go

@ -47,8 +47,8 @@ const (
SIMDAlign = 32 SIMDAlign = 32
) )
// ErasureParams is a configuration set for building an encoder. It is created using ValidateParams(). // Params is a configuration set for building an encoder. It is created using ValidateParams().
type ErasureParams struct { type Params struct {
K uint8 K uint8
M uint8 M uint8
Technique Technique // cauchy or vandermonde matrix (RS) Technique Technique // cauchy or vandermonde matrix (RS)
@ -56,18 +56,18 @@ type ErasureParams struct {
// Erasure is an object used to encode and decode data. // Erasure is an object used to encode and decode data.
type Erasure struct { type Erasure struct {
params *ErasureParams params *Params
encodeMatrix, encodeTbls *C.uchar encodeMatrix, encodeTbls *C.uchar
decodeMatrix, decodeTbls *C.uchar decodeMatrix, decodeTbls *C.uchar
decodeIndex *C.uint32_t decodeIndex *C.uint32_t
} }
// ValidateParams creates an ErasureParams object. // ValidateParams creates an Params object.
// //
// k and m represent the matrix size, which corresponds to the protection level // k and m represent the matrix size, which corresponds to the protection level
// technique is the matrix type. Valid inputs are Cauchy (recommended) or Vandermonde. // technique is the matrix type. Valid inputs are Cauchy (recommended) or Vandermonde.
// //
func ValidateParams(k, m uint8, technique Technique) (*ErasureParams, error) { func ValidateParams(k, m uint8, technique Technique) (*Params, error) {
if k < 1 { if k < 1 {
return nil, errors.New("k cannot be zero") return nil, errors.New("k cannot be zero")
} }
@ -89,7 +89,7 @@ func ValidateParams(k, m uint8, technique Technique) (*ErasureParams, error) {
return nil, errors.New("Technique can be either vandermonde or cauchy") return nil, errors.New("Technique can be either vandermonde or cauchy")
} }
return &ErasureParams{ return &Params{
K: k, K: k,
M: m, M: m,
Technique: technique, Technique: technique,
@ -97,7 +97,7 @@ func ValidateParams(k, m uint8, technique Technique) (*ErasureParams, error) {
} }
// NewErasure creates an encoder object with a given set of parameters. // NewErasure creates an encoder object with a given set of parameters.
func NewErasure(ep *ErasureParams) *Erasure { func NewErasure(ep *Params) *Erasure {
var k = C.int(ep.K) var k = C.int(ep.K)
var m = C.int(ep.M) var m = C.int(ep.M)

@ -44,8 +44,8 @@ type bucket struct {
objects map[string]object objects map[string]object
} }
// NewBucket - instantiate a new bucket // newBucket - instantiate a new bucket
func NewBucket(bucketName, aclType, donutName string, nodes map[string]Node) (bucket, map[string]string, error) { func newBucket(bucketName, aclType, donutName string, nodes map[string]Node) (bucket, map[string]string, error) {
errParams := map[string]string{ errParams := map[string]string{
"bucketName": bucketName, "bucketName": bucketName,
"donutName": donutName, "donutName": donutName,
@ -84,7 +84,7 @@ func (b bucket) ListObjects() (map[string]object, error) {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
for _, object := range objects { for _, object := range objects {
newObject, err := NewObject(object.Name(), filepath.Join(disk.GetPath(), bucketPath)) newObject, err := newObject(object.Name(), filepath.Join(disk.GetPath(), bucketPath))
if err != nil { if err != nil {
return nil, iodine.New(err, nil) return nil, iodine.New(err, nil)
} }
@ -318,7 +318,7 @@ func (b bucket) getDataAndParity(totalWriters int) (k uint8, m uint8, err error)
// writeEncodedData - // writeEncodedData -
func (b bucket) writeEncodedData(k, m uint8, writers []io.WriteCloser, objectData io.Reader, summer hash.Hash) (int, int, error) { func (b bucket) writeEncodedData(k, m uint8, writers []io.WriteCloser, objectData io.Reader, summer hash.Hash) (int, int, error) {
chunks := split.Stream(objectData, 10*1024*1024) chunks := split.Stream(objectData, 10*1024*1024)
encoder, err := NewEncoder(k, m, "Cauchy") encoder, err := newEncoder(k, m, "Cauchy")
if err != nil { if err != nil {
return 0, 0, iodine.New(err, nil) return 0, 0, iodine.New(err, nil)
} }
@ -367,7 +367,7 @@ func (b bucket) readEncodedData(objectName string, writer *io.PipeWriter, donutO
writer.CloseWithError(iodine.New(MissingErasureTechnique{}, nil)) writer.CloseWithError(iodine.New(MissingErasureTechnique{}, nil))
return return
} }
encoder, err := NewEncoder(uint8(k), uint8(m), technique) encoder, err := newEncoder(uint8(k), uint8(m), technique)
if err != nil { if err != nil {
writer.CloseWithError(iodine.New(err, nil)) writer.CloseWithError(iodine.New(err, nil))
return return

@ -27,6 +27,7 @@ import (
"github.com/minio/minio/pkg/iodine" "github.com/minio/minio/pkg/iodine"
) )
// Disk container for disk parameters
type Disk struct { type Disk struct {
path string path string
fsInfo map[string]string fsInfo map[string]string

@ -42,8 +42,8 @@ func getErasureTechnique(technique string) (encoding.Technique, error) {
} }
} }
// NewEncoder - instantiate a new encoder // newEncoder - instantiate a new encoder
func NewEncoder(k, m uint8, technique string) (encoder, error) { func newEncoder(k, m uint8, technique string) (encoder, error) {
errParams := map[string]string{ errParams := map[string]string{
"k": strconv.FormatUint(uint64(k), 10), "k": strconv.FormatUint(uint64(k), 10),
"m": strconv.FormatUint(uint64(m), 10), "m": strconv.FormatUint(uint64(m), 10),

@ -32,8 +32,8 @@ type object struct {
donutObjectMetadata map[string]string donutObjectMetadata map[string]string
} }
// NewObject - instantiate a new object // newObject - instantiate a new object
func NewObject(objectName, p string) (object, error) { func newObject(objectName, p string) (object, error) {
if objectName == "" { if objectName == "" {
return object{}, iodine.New(InvalidArgument{}, nil) return object{}, iodine.New(InvalidArgument{}, nil)
} }

@ -325,7 +325,7 @@ func (d donut) makeDonutBucket(bucketName, acl string) error {
if _, ok := d.buckets[bucketName]; ok { if _, ok := d.buckets[bucketName]; ok {
return iodine.New(BucketExists{Bucket: bucketName}, nil) return iodine.New(BucketExists{Bucket: bucketName}, nil)
} }
bucket, bucketMetadata, err := NewBucket(bucketName, acl, d.name, d.nodes) bucket, bucketMetadata, err := newBucket(bucketName, acl, d.name, d.nodes)
if err != nil { if err != nil {
return iodine.New(err, nil) return iodine.New(err, nil)
} }
@ -385,7 +385,7 @@ func (d donut) getDonutBuckets() error {
} }
bucketName := splitDir[0] bucketName := splitDir[0]
// we dont need this NewBucket once we cache from makeDonutBucket() // we dont need this NewBucket once we cache from makeDonutBucket()
bucket, _, err := NewBucket(bucketName, "private", d.name, d.nodes) bucket, _, err := newBucket(bucketName, "private", d.name, d.nodes)
if err != nil { if err != nil {
return iodine.New(err, nil) return iodine.New(err, nil)
} }

Loading…
Cancel
Save