commits

package
v1.18.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadCommitObject = errors.New("first record of object not a commit")
	ErrExists          = errors.New("commit object already exists")
	ErrNotFound        = errors.New("commit object not found")
)
View Source
var ActionTypes = []interface{}{
	Add{},
	AddVector{},
	Delete{},
	DeleteVector{},
	Commit{},
}
View Source
var ErrEmptyTransaction = errors.New("empty transaction")
View Source
var ErrWriteConflict = errors.New("write conflict")

Functions

func Exists

func Exists(view View, id ksuid.KSUID) bool

func Play

func Play(w Writeable, o *Object) error

Play "plays" a recorded transaction into a writeable snapshot.

func PlayAction

func PlayAction(w Writeable, action Action) error

Types

type Action

type Action interface {
	CommitID() ksuid.KSUID
	fmt.Stringer
}

type Add

type Add struct {
	Commit ksuid.KSUID `zed:"commit"`
	Object data.Object `zed:"object"`
}

func (*Add) CommitID

func (a *Add) CommitID() ksuid.KSUID

func (*Add) String

func (a *Add) String() string

type AddVector added in v1.3.0

type AddVector struct {
	Commit ksuid.KSUID `zed:"commit"`
	ID     ksuid.KSUID `zed:"id"`
}

func (*AddVector) CommitID added in v1.3.0

func (a *AddVector) CommitID() ksuid.KSUID

func (*AddVector) String added in v1.3.0

func (a *AddVector) String() string

type Commit

type Commit struct {
	ID      ksuid.KSUID `zed:"id"`
	Parent  ksuid.KSUID `zed:"parent"`
	Retries uint8       `zed:"retries"`
	Author  string      `zed:"author"`
	Date    nano.Ts     `zed:"date"`
	Message string      `zed:"message"`
	Meta    zed.Value   `zed:"meta"`
}

func (*Commit) CommitID

func (c *Commit) CommitID() ksuid.KSUID

func (*Commit) String

func (c *Commit) String() string

type DataObjects

type DataObjects []*data.Object

func (*DataObjects) Append

func (d *DataObjects) Append(objects DataObjects)

type Delete

type Delete struct {
	Commit ksuid.KSUID `zed:"commit"`
	ID     ksuid.KSUID `zed:"id"`
}

func (*Delete) CommitID

func (d *Delete) CommitID() ksuid.KSUID

func (*Delete) String

func (d *Delete) String() string

type DeleteVector added in v1.3.0

type DeleteVector struct {
	Commit ksuid.KSUID `zed:"commit"`
	ID     ksuid.KSUID `zed:"id"`
}

func (*DeleteVector) CommitID added in v1.3.0

func (d *DeleteVector) CommitID() ksuid.KSUID

func (*DeleteVector) String added in v1.3.0

func (d *DeleteVector) String() string

type LogReader

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

func (*LogReader) Read

func (r *LogReader) Read() (*zed.Value, error)

type Object

type Object struct {
	Commit  ksuid.KSUID `zed:"commit"`
	Parent  ksuid.KSUID `zed:"parent"`
	Actions []Action    `zed:"actions"`
}

func DecodeObject

func DecodeObject(r io.Reader) (*Object, error)

func NewAddVectorsObject added in v1.3.0

func NewAddVectorsObject(parent ksuid.KSUID, author, message string, ids []ksuid.KSUID, retries int) *Object

func NewAddsObject

func NewAddsObject(parent ksuid.KSUID, retries int, author, message string, meta zed.Value, objects []data.Object) *Object

func NewDeleteVectorsObject added in v1.3.0

func NewDeleteVectorsObject(parent ksuid.KSUID, author, message string, ids []ksuid.KSUID, retries int) *Object

func NewDeletesObject

func NewDeletesObject(parent ksuid.KSUID, retries int, author, message string, ids []ksuid.KSUID) *Object

func NewObject

func NewObject(parent ksuid.KSUID, author, message string, meta zed.Value, retries int) *Object

func (Object) Serialize

func (o Object) Serialize() ([]byte, error)

type Patch

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

A Patch represents a difference between a base snapshot and the patched snapshot. Patch implements View so either a patch or a base snapshot can be traversed in the same manner. Furthermore, patches can be easily chained to implement a sequence of patches to a base snapshot.

func Diff added in v1.2.0

func Diff(parent, child *Patch) (*Patch, error)

func NewPatch

func NewPatch(base View) *Patch

func (*Patch) AddDataObject

func (p *Patch) AddDataObject(object *data.Object) error

func (*Patch) AddVector added in v1.3.0

func (p *Patch) AddVector(id ksuid.KSUID) error

func (*Patch) DataObjects

func (p *Patch) DataObjects() []ksuid.KSUID

func (*Patch) DeleteObject

func (p *Patch) DeleteObject(id ksuid.KSUID) error

func (*Patch) DeleteVector added in v1.3.0

func (p *Patch) DeleteVector(id ksuid.KSUID) error

func (*Patch) HasVector added in v1.3.0

func (p *Patch) HasVector(id ksuid.KSUID) bool

func (*Patch) Lookup

func (p *Patch) Lookup(id ksuid.KSUID) (*data.Object, error)

func (*Patch) NewCommitObject

func (p *Patch) NewCommitObject(parent ksuid.KSUID, retries int, author, message string, meta zed.Value) *Object

func (*Patch) Revert

func (p *Patch) Revert(tip *Snapshot, commit, parent ksuid.KSUID, retries int, author, message string) (*Object, error)

func (*Patch) Select

func (p *Patch) Select(span extent.Span, o order.Which) DataObjects

func (*Patch) SelectAll

func (p *Patch) SelectAll() DataObjects

type Snapshot

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

A snapshot summarizes the pool state at any point in the commit object tree. XXX redefine snapshot as type map instead of struct

func NewSnapshot

func NewSnapshot() *Snapshot

func Vectors added in v1.3.0

func Vectors(view View) *Snapshot

func (*Snapshot) AddDataObject

func (s *Snapshot) AddDataObject(object *data.Object) error

func (*Snapshot) AddVector added in v1.3.0

func (s *Snapshot) AddVector(id ksuid.KSUID) error

func (*Snapshot) Copy

func (s *Snapshot) Copy() *Snapshot

func (*Snapshot) DeleteObject

func (s *Snapshot) DeleteObject(id ksuid.KSUID) error

func (*Snapshot) DeleteVector added in v1.3.0

func (s *Snapshot) DeleteVector(id ksuid.KSUID) error

func (*Snapshot) Exists

func (s *Snapshot) Exists(id ksuid.KSUID) bool

func (*Snapshot) HasVector added in v1.3.0

func (s *Snapshot) HasVector(id ksuid.KSUID) bool

func (*Snapshot) Lookup

func (s *Snapshot) Lookup(id ksuid.KSUID) (*data.Object, error)

func (*Snapshot) Select

func (s *Snapshot) Select(scan extent.Span, order order.Which) DataObjects

func (*Snapshot) SelectAll

func (s *Snapshot) SelectAll() DataObjects

type Store

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

func OpenStore

func OpenStore(engine storage.Engine, logger *zap.Logger, path *storage.URI) (*Store, error)

func (*Store) Get

func (s *Store) Get(ctx context.Context, commit ksuid.KSUID) (*Object, error)

func (*Store) GetBytes

func (s *Store) GetBytes(ctx context.Context, commit ksuid.KSUID) ([]byte, *Commit, error)

func (*Store) Open

func (s *Store) Open(ctx context.Context, commit, stop ksuid.KSUID) (io.Reader, error)

func (*Store) OpenAsZNG

func (s *Store) OpenAsZNG(ctx context.Context, zctx *zed.Context, commit, stop ksuid.KSUID) (*zngio.Reader, error)

func (*Store) OpenCommitLog

func (s *Store) OpenCommitLog(ctx context.Context, zctx *zed.Context, commit, stop ksuid.KSUID) zio.Reader

func (*Store) PatchOfCommit

func (s *Store) PatchOfCommit(ctx context.Context, commit ksuid.KSUID) (*Patch, error)

PatchOfCommit computes the snapshot at the parent of the indicated commit then computes the difference between that snapshot and the child commit, returning the difference as a patch.

func (*Store) PatchOfPath

func (s *Store) PatchOfPath(ctx context.Context, base *Snapshot, baseID, commit ksuid.KSUID) (*Patch, error)

func (*Store) Path

func (s *Store) Path(ctx context.Context, leaf ksuid.KSUID) ([]ksuid.KSUID, error)

Path return the entire path from the commit object to the root in leaf to root order.

func (*Store) PathRange

func (s *Store) PathRange(ctx context.Context, from, to ksuid.KSUID) ([]ksuid.KSUID, error)

func (*Store) Put

func (s *Store) Put(ctx context.Context, o *Object) error

func (*Store) ReadAll

func (s *Store) ReadAll(ctx context.Context, commit, stop ksuid.KSUID) ([]byte, error)

func (*Store) Remove

func (s *Store) Remove(ctx context.Context, o *Object) error

DANGER ZONE - objects should only be removed when GC says they are not used.

func (*Store) Snapshot

func (s *Store) Snapshot(ctx context.Context, leaf ksuid.KSUID) (*Snapshot, error)

func (*Store) Vacuumable added in v1.8.0

func (s *Store) Vacuumable(ctx context.Context, leaf ksuid.KSUID, out chan<- *data.Object) error

Vacuumable returns the set of data.Objects in the path of leaf that are not referenced by the leaf's snapshot.

type View

type View interface {
	Lookup(ksuid.KSUID) (*data.Object, error)
	HasVector(ksuid.KSUID) bool
	Select(extent.Span, order.Which) DataObjects
	SelectAll() DataObjects
}

type Writeable

type Writeable interface {
	View
	AddDataObject(*data.Object) error
	DeleteObject(ksuid.KSUID) error
	AddVector(ksuid.KSUID) error
	DeleteVector(ksuid.KSUID) error
}

Jump to

Keyboard shortcuts

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