remoteobjcat

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(fs vfs.FS, dirname string) (*Catalog, CatalogContents, error)

Open creates a Catalog and loads any existing catalog file, returning the creator ID (if it is set) and the contents.

Types

type Batch

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

Batch is used to perform multiple object additions/deletions at once.

func (*Batch) AddObject

func (b *Batch) AddObject(meta RemoteObjectMetadata)

AddObject adds a new object to the batch.

The given FileNum must be new - it must not match that of any object that was ever in the catalog.

func (*Batch) Append

func (b *Batch) Append(other Batch)

Append merges two batches.

func (*Batch) Copy

func (b *Batch) Copy() Batch

Copy returns a copy of the Batch.

func (*Batch) DeleteObject

func (b *Batch) DeleteObject(fileNum base.DiskFileNum)

DeleteObject adds an object removal to the batch.

func (*Batch) IsEmpty

func (b *Batch) IsEmpty() bool

IsEmpty returns true if the batch is empty.

func (*Batch) Reset

func (b *Batch) Reset()

Reset clears the batch.

type Catalog

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

Catalog is used to manage the on-disk remote object catalog.

The catalog file is a log of records, where each record is an encoded VersionEdit.

func (*Catalog) ApplyBatch

func (c *Catalog) ApplyBatch(b Batch) error

ApplyBatch applies a batch of updates; returns after the change is stably recorded on storage.

func (*Catalog) Close

func (c *Catalog) Close() error

Close any open files.

func (*Catalog) SetCreatorID

func (c *Catalog) SetCreatorID(id objstorage.CreatorID) error

SetCreatorID sets the creator ID. If it is already set, it must match.

type CatalogContents

type CatalogContents struct {
	// CreatorID, if it is set.
	CreatorID objstorage.CreatorID
	Objects   []RemoteObjectMetadata
}

CatalogContents contains the remote objects in the catalog.

type RemoteObjectMetadata

type RemoteObjectMetadata struct {
	// FileNum is the identifier for the object within the context of a single DB
	// instance.
	FileNum base.DiskFileNum
	// FileType is the type of the object. Only certain FileTypes are possible.
	FileType base.FileType
	// CreatorID identifies the DB instance that originally created the object.
	CreatorID objstorage.CreatorID
	// CreatorFileNum is the identifier for the object within the context of the
	// DB instance that originally created the object.
	CreatorFileNum base.DiskFileNum
	// CleanupMethod indicates the method for cleaning up unused shared objects.
	CleanupMethod objstorage.SharedCleanupMethod
	// Locator identifies a remote.Storage implementation.
	Locator remote.Locator
	// CustomObjectName (if it is set) overrides the object name that is normally
	// derived from the CreatorID and CreatorFileNum.
	CustomObjectName string
}

RemoteObjectMetadata encapsulates the data stored in the catalog file for each object.

type VersionEdit

type VersionEdit struct {
	NewObjects     []RemoteObjectMetadata
	DeletedObjects []base.DiskFileNum
	CreatorID      objstorage.CreatorID
}

VersionEdit is a modification to the remote object state which can be encoded into a record.

TODO(radu): consider adding creation and deletion time for debugging purposes.

func (*VersionEdit) Apply

func (v *VersionEdit) Apply(
	creatorID *objstorage.CreatorID, objects map[base.DiskFileNum]RemoteObjectMetadata,
) error

Apply the version edit to a creator ID and a map of objects.

func (*VersionEdit) Decode

func (v *VersionEdit) Decode(r io.Reader) error

Decode decodes an edit from the specified reader.

func (*VersionEdit) Encode

func (v *VersionEdit) Encode(w io.Writer) error

Encode encodes an edit to the specified writer.

Jump to

Keyboard shortcuts

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