blobs

package
v0.0.0-...-cffa139 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2015 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MinChunkSize = 4096

Minimum valid chunk size.

Variables

View Source
var MissingType = errors.New("Manifest is missing Type")

Functions

This section is empty.

Types

type Blob

type Blob struct {
	// contains filtered or unexported fields
}

Blob is a container for arbitrary size data (byte sequence), constructed from lower-level Chunks.

func Open

func Open(chunkStore chunks.Store, manifest *Manifest) (*Blob, error)

Open returns a new Blob, using the given chunk store and manifest.

It makes a copy of the manifest, so the caller is free to use it in any way after the call.

A Blob need not exist; passing in a Manifest with an Empty Root gives a Blob with zero contents. However, all the fields must be set to valid values.

func (*Blob) ReadAt

func (blob *Blob) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads data from the given offset. See io.ReaderAt.

func (*Blob) Save

func (blob *Blob) Save() (*Manifest, error)

Save persists the Blob into the Store and returns a new Manifest that can be passed to Open later.

func (*Blob) Size

func (blob *Blob) Size() uint64

Size returns the current byte size of the Blob.

func (*Blob) String

func (blob *Blob) String() string

func (*Blob) Truncate

func (blob *Blob) Truncate(size uint64) error

Truncate adjusts the size of the blob. If the new size is less than the old size, data past that point is lost. If the new size is greater than the old size, the new part is full of zeroes.

func (*Blob) WriteAt

func (blob *Blob) WriteAt(p []byte, off int64) (n int, err error)

WriteAt writes data to the given offset. See io.WriterAt.

type Manifest

type Manifest struct {
	Type string
	Root cas.Key
	Size uint64
	// Must be >= MinChunkSize.
	ChunkSize uint32
	// Must be >= 2.
	Fanout uint32
}

Manifest is a description of a Blob as persisted in a chunks.Store.

When creating a new Blob, create a Manifest and set the Type, ChunkSize and Fanout fields, the rest can be left to their zero values. See EmptyManifest for a helper that uses default tuning.

func EmptyManifest

func EmptyManifest(type_ string) *Manifest

EmptyManifest returns an empty manifest of the given type with the default tuning parameters.

type SmallChunkSizeError

type SmallChunkSizeError struct {
	Given uint32
}

SmallChunkSizeError is the error returned from Open if the configuration has a ChunkSize less than MinChunkSize

func (SmallChunkSizeError) Error

func (s SmallChunkSizeError) Error() string

type SmallFanoutError

type SmallFanoutError struct {
	Given uint32
}

SmallFanoutError is the error returned from Open if the configuration has a Fanout less than 2.

func (SmallFanoutError) Error

func (s SmallFanoutError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL