composite

package
v0.0.0-...-2627f95 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FlattenMap

func FlattenMap(m Map) kv.Map

FlattenMap converts a composite map to a flat map

Types

type Iterator

type Iterator interface {
	Next() bool
	Key() composite.Key
	Value() []byte
	Error() error
}

Iterator iterates over a set of composite keys. It must only be used by one goroutine at a time. Consumers should not attempt to use an iterator once its parent transaction has been rolled back. Behavior is undefined in this case. The transaction must not mutate the store when the iterator is in use. This may cause inconsistent behavior.

type Map

type Map interface {
	MapReader
	MapUpdater
}

Map combines CompositeMapReader and CompositeMapUpdater

func NamespaceMap

func NamespaceMap(m Map, ns [][]byte) Map

NamespaceMap returns a namespaced map

func NewMap

func NewMap(m kv.Map, nextNodeID func() int64) Map

NewMap returns an instance of composite.Map built on top of a kv.Map

type MapReader

type MapReader interface {
	Get(key composite.Key) ([]byte, error)
	Keys(keys composite.Range, order kv.SortOrder) (Iterator, error)
}

MapReader is an interface for reading a sorted key-value map whose keys consist of a sequence of byte slices

func NamespaceMapReader

func NamespaceMapReader(mr MapReader, ns [][]byte) MapReader

NamespaceMapReader returns a namespaced map reader

type MapUpdater

type MapUpdater interface {
	Put(key composite.Key, value []byte) error
	Delete(key composite.Key) error
}

MapUpdater is an interface for updating a sorted key-value map whose keys consist of a sequence of byte slices

func NamespaceMapUpdater

func NamespaceMapUpdater(mu MapUpdater, ns [][]byte) MapUpdater

NamespaceMapUpdater returns a namespaced map updater

type Partition

type Partition interface {
	Name() []byte
	Create(metadata []byte) error
	Delete() error
	Begin(writable bool) (Transaction, error)
	snapshot.Source
	snapshot.Acceptor
}

Partition is like kv.Partition except Begin returns composite.Transaction instead of kv.Transaction

func NewPartition

func NewPartition(p kv.Partition) Partition

NewPartition returns an instance of composite.Partition built on top of a kv.Partition

type Transaction

type Transaction interface {
	Map
	// Metadata returns the metadata for this partition
	Metadata() ([]byte, error)
	// SetMetadata sets the metadata for this partition
	SetMetadata(metadata []byte) error
	// Commit commits the transaction
	Commit() error
	// Rollback rolls back the transaction
	Rollback() error
}

Transaction is a transaction for a partition. It must only be used by one goroutine at a time.

func Namespace

func Namespace(txn Transaction, ns [][]byte) Transaction

Namespace ensures that all keys referenced within a transaction are prefixed with ns.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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