mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Go vet fixes for donut
This commit is contained in:
parent
57a2b53178
commit
03b4d3b308
@ -47,8 +47,8 @@ const (
|
||||
SIMDAlign = 32
|
||||
)
|
||||
|
||||
// ErasureParams is a configuration set for building an encoder. It is created using ValidateParams().
|
||||
type ErasureParams struct {
|
||||
// Params is a configuration set for building an encoder. It is created using ValidateParams().
|
||||
type Params struct {
|
||||
K uint8
|
||||
M uint8
|
||||
Technique Technique // cauchy or vandermonde matrix (RS)
|
||||
@ -56,18 +56,18 @@ type ErasureParams struct {
|
||||
|
||||
// Erasure is an object used to encode and decode data.
|
||||
type Erasure struct {
|
||||
params *ErasureParams
|
||||
params *Params
|
||||
encodeMatrix, encodeTbls *C.uchar
|
||||
decodeMatrix, decodeTbls *C.uchar
|
||||
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
|
||||
// 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 {
|
||||
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 &ErasureParams{
|
||||
return &Params{
|
||||
K: k,
|
||||
M: m,
|
||||
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.
|
||||
func NewErasure(ep *ErasureParams) *Erasure {
|
||||
func NewErasure(ep *Params) *Erasure {
|
||||
var k = C.int(ep.K)
|
||||
var m = C.int(ep.M)
|
||||
|
||||
|
@ -44,8 +44,8 @@ type bucket struct {
|
||||
objects map[string]object
|
||||
}
|
||||
|
||||
// NewBucket - instantiate a new bucket
|
||||
func NewBucket(bucketName, aclType, donutName string, nodes map[string]Node) (bucket, map[string]string, error) {
|
||||
// newBucket - instantiate a new bucket
|
||||
func newBucket(bucketName, aclType, donutName string, nodes map[string]Node) (bucket, map[string]string, error) {
|
||||
errParams := map[string]string{
|
||||
"bucketName": bucketName,
|
||||
"donutName": donutName,
|
||||
@ -84,7 +84,7 @@ func (b bucket) ListObjects() (map[string]object, error) {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
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 {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
@ -318,7 +318,7 @@ func (b bucket) getDataAndParity(totalWriters int) (k uint8, m uint8, err error)
|
||||
// writeEncodedData -
|
||||
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)
|
||||
encoder, err := NewEncoder(k, m, "Cauchy")
|
||||
encoder, err := newEncoder(k, m, "Cauchy")
|
||||
if 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))
|
||||
return
|
||||
}
|
||||
encoder, err := NewEncoder(uint8(k), uint8(m), technique)
|
||||
encoder, err := newEncoder(uint8(k), uint8(m), technique)
|
||||
if err != nil {
|
||||
writer.CloseWithError(iodine.New(err, nil))
|
||||
return
|
||||
|
@ -27,6 +27,7 @@ import (
|
||||
"github.com/minio/minio/pkg/iodine"
|
||||
)
|
||||
|
||||
// Disk container for disk parameters
|
||||
type Disk struct {
|
||||
path string
|
||||
fsInfo map[string]string
|
||||
|
@ -42,8 +42,8 @@ func getErasureTechnique(technique string) (encoding.Technique, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// NewEncoder - instantiate a new encoder
|
||||
func NewEncoder(k, m uint8, technique string) (encoder, error) {
|
||||
// newEncoder - instantiate a new encoder
|
||||
func newEncoder(k, m uint8, technique string) (encoder, error) {
|
||||
errParams := map[string]string{
|
||||
"k": strconv.FormatUint(uint64(k), 10),
|
||||
"m": strconv.FormatUint(uint64(m), 10),
|
||||
|
@ -32,8 +32,8 @@ type object struct {
|
||||
donutObjectMetadata map[string]string
|
||||
}
|
||||
|
||||
// NewObject - instantiate a new object
|
||||
func NewObject(objectName, p string) (object, error) {
|
||||
// newObject - instantiate a new object
|
||||
func newObject(objectName, p string) (object, error) {
|
||||
if objectName == "" {
|
||||
return object{}, iodine.New(InvalidArgument{}, nil)
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ func (d donut) makeDonutBucket(bucketName, acl string) error {
|
||||
if _, ok := d.buckets[bucketName]; ok {
|
||||
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 {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
@ -385,7 +385,7 @@ func (d donut) getDonutBuckets() error {
|
||||
}
|
||||
bucketName := splitDir[0]
|
||||
// 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 {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user