mirror of
https://github.com/pgsty/minio.git
synced 2026-08-09 15:53:28 +03:00
XL: Implement new ReadAll API for files which are read in single call. (#1974)
Add a unit test as well.
This commit is contained in:
committed by
Anand Babu (AB) Periasamy
parent
ed2fdd90b0
commit
42286cba70
+4
-11
@@ -17,7 +17,6 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"math/rand"
|
||||
"path"
|
||||
@@ -64,22 +63,16 @@ func randInts(count int) []int {
|
||||
return ints
|
||||
}
|
||||
|
||||
// readXLMeta reads `xl.json` returns contents as byte array.
|
||||
// readXLMeta reads `xl.json` and returns back XL metadata structure.
|
||||
func readXLMeta(disk StorageAPI, bucket string, object string) (xlMeta xlMetaV1, err error) {
|
||||
// Allocate 32k buffer, this is sufficient for the most of `xl.json`.
|
||||
buf := make([]byte, 128*1024)
|
||||
|
||||
// Allocate a new `xl.json` buffer writer.
|
||||
var buffer = new(bytes.Buffer)
|
||||
|
||||
// Reads entire `xl.json`.
|
||||
if err = copyBuffer(buffer, disk, bucket, path.Join(object, xlMetaJSONFile), buf); err != nil {
|
||||
buf, err := disk.ReadAll(bucket, path.Join(object, xlMetaJSONFile))
|
||||
if err != nil {
|
||||
return xlMetaV1{}, err
|
||||
}
|
||||
|
||||
// Unmarshal xl metadata.
|
||||
d := json.NewDecoder(buffer)
|
||||
if err = d.Decode(&xlMeta); err != nil {
|
||||
if err = json.Unmarshal(buf, &xlMeta); err != nil {
|
||||
return xlMetaV1{}, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user