projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Refactor the multi-host salt install page.
[arvados.git]
/
sdk
/
go
/
keepclient
/
block_cache.go
diff --git
a/sdk/go/keepclient/block_cache.go
b/sdk/go/keepclient/block_cache.go
index 539975e1616637cad2d002c8e9e7d697c0820f63..bac4a24fd5a037d9cdcafb663612677304184c97 100644
(file)
--- a/
sdk/go/keepclient/block_cache.go
+++ b/
sdk/go/keepclient/block_cache.go
@@
-7,6
+7,8
@@
package keepclient
import (
"io"
"sort"
import (
"io"
"sort"
+ "strconv"
+ "strings"
"sync"
"time"
)
"sync"
"time"
)
@@
-66,6
+68,13
@@
func (c *BlockCache) ReadAt(kc *KeepClient, locator string, p []byte, off int) (
// necessary.
func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {
cacheKey := locator[:32]
// necessary.
func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {
cacheKey := locator[:32]
+ bufsize := BLOCKSIZE
+ if parts := strings.SplitN(locator, "+", 3); len(parts) >= 2 {
+ datasize, err := strconv.ParseInt(parts[1], 10, 32)
+ if err == nil && datasize >= 0 {
+ bufsize = int(datasize)
+ }
+ }
c.mtx.Lock()
if c.cache == nil {
c.cache = make(map[string]*cacheBlock)
c.mtx.Lock()
if c.cache == nil {
c.cache = make(map[string]*cacheBlock)
@@
-81,7
+90,7
@@
func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {
rdr, size, _, err := kc.Get(locator)
var data []byte
if err == nil {
rdr, size, _, err := kc.Get(locator)
var data []byte
if err == nil {
- data = make([]byte, size,
BLOCKSIZE
)
+ data = make([]byte, size,
bufsize
)
_, err = io.ReadFull(rdr, data)
err2 := rdr.Close()
if err == nil {
_, err = io.ReadFull(rdr, data)
err2 := rdr.Close()
if err == nil {