blobs

package
v0.0.0-...-810cf82 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2019 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const MinChunkSize = 4096

Minimum valid chunk size.

Variables

View Source
var ErrMissingType = 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) IO

func (blob *Blob) IO(ctx context.Context) *IO

IO returns a value that remembers ctx and lets the caller perform I/O operations that do not take a context argument.

func (*Blob) Save

func (blob *Blob) Save(ctx context.Context) (*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(ctx context.Context, 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.

type IO

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

IO provides cancellable I/O operations on blobs.

func (*IO) ReadAt

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

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

func (*IO) WriteAt

func (bio *IO) 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