X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/eae1286badb67ee63888633ff59bda9cb736131e..127e916894bcd16f6978aa6488c81e79a9ca2812:/sdk/go/keepclient/block_cache.go diff --git a/sdk/go/keepclient/block_cache.go b/sdk/go/keepclient/block_cache.go index e841a00fa1..539975e161 100644 --- a/sdk/go/keepclient/block_cache.go +++ b/sdk/go/keepclient/block_cache.go @@ -49,6 +49,19 @@ func (c *BlockCache) Sweep() { } } +// ReadAt returns data from the cache, first retrieving it from Keep if +// necessary. +func (c *BlockCache) ReadAt(kc *KeepClient, locator string, p []byte, off int) (int, error) { + buf, err := c.Get(kc, locator) + if err != nil { + return 0, err + } + if off > len(buf) { + return 0, io.ErrUnexpectedEOF + } + return copy(p, buf[off:]), nil +} + // Get returns data from the cache, first retrieving it from Keep if // necessary. func (c *BlockCache) Get(kc *KeepClient, locator string) ([]byte, error) {