database

package
v0.9.0-RC2 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	SetKeyPrefix = iota
	SortedSetKeyPrefix
)
View Source
const (
	PlainValuePrefix = iota
	ReferenceValuePrefix
)
View Source
const MaxKeyResolutionLimit = 1
View Source
const MaxKeyScanLimit = 1000

Variables

View Source
var (
	ErrIndexKeyMismatch      = status.New(codes.InvalidArgument, "mismatch between provided index and key").Err()
	ErrNoReferenceProvided   = status.New(codes.InvalidArgument, "provided argument is not a reference").Err()
	ErrReferenceKeyMissing   = status.New(codes.InvalidArgument, "reference key not provided").Err()
	ErrZAddIndexMissing      = status.New(codes.InvalidArgument, "zAdd index not provided").Err()
	ErrReferenceIndexMissing = status.New(codes.InvalidArgument, "reference index not provided").Err()
)
View Source
var ErrFinalKeyCannotBeConvertedIntoReference = errors.New("final key cannot be converted into a reference")
View Source
var ErrMaxKeyResolutionLimitReached = errors.New("max key resolution limit reached. It may be due to cyclic references")
View Source
var ErrMaxKeyScanLimitExceeded = errors.New("max key scan limit exceeded")
View Source
var ErrReferencedKeyCannotBeAReference = errors.New("referenced key cannot be a reference")

Functions

func EncodeKV

func EncodeKV(key []byte, value []byte) *store.KV

func EncodeKey

func EncodeKey(key []byte) []byte

func EncodeReference

func EncodeReference(key, referencedKey []byte, atTx uint64) *store.KV

func EncodeZAdd

func EncodeZAdd(set []byte, score float64, key []byte, atTx uint64) *store.KV

func UnWrapWithPrefix

func UnWrapWithPrefix(wb []byte) (b []byte, prefix byte)

unWrapWithPrefix ...

func WrapReferenceValueAt

func WrapReferenceValueAt(key []byte, atTx uint64) []byte

func WrapWithPrefix

func WrapWithPrefix(b []byte, prefix byte) []byte

WrapWithPrefix ...

func WrapZAddReferenceAt

func WrapZAddReferenceAt(set []byte, score float64, key []byte, atTx uint64) []byte

Types

type DB

type DB interface {
	Health(e *empty.Empty) (*schema.HealthResponse, error)
	CurrentState() (*schema.ImmutableState, error)
	Set(req *schema.SetRequest) (*schema.TxMetadata, error)
	Get(req *schema.KeyRequest) (*schema.Entry, error)
	VerifiableSet(req *schema.VerifiableSetRequest) (*schema.VerifiableTx, error)
	VerifiableGet(req *schema.VerifiableGetRequest) (*schema.VerifiableEntry, error)
	GetAll(req *schema.KeyListRequest) (*schema.Entries, error)
	ExecAll(operations *schema.ExecAllRequest) (*schema.TxMetadata, error)
	Size() (uint64, error)
	Count(prefix *schema.KeyPrefix) (*schema.EntryCount, error)
	CountAll() (*schema.EntryCount, error)
	TxByID(req *schema.TxRequest) (*schema.Tx, error)
	VerifiableTxByID(req *schema.VerifiableTxRequest) (*schema.VerifiableTx, error)
	History(req *schema.HistoryRequest) (*schema.Entries, error)
	SetReference(req *schema.ReferenceRequest) (*schema.TxMetadata, error)
	VerifiableSetReference(req *schema.VerifiableReferenceRequest) (*schema.VerifiableTx, error)
	ZAdd(req *schema.ZAddRequest) (*schema.TxMetadata, error)
	ZScan(req *schema.ZScanRequest) (*schema.ZEntries, error)
	VerifiableZAdd(req *schema.VerifiableZAddRequest) (*schema.VerifiableTx, error)
	Scan(req *schema.ScanRequest) (*schema.Entries, error)
	PrintTree() (*schema.Tree, error)
	Close() error
	GetOptions() *DbOptions
}

func NewDb

func NewDb(op *DbOptions, log logger.Logger) (DB, error)

NewDb Creates a new Database along with it's directories and files

func OpenDb

func OpenDb(op *DbOptions, log logger.Logger) (DB, error)

OpenDb Opens an existing Database from disk

type DbOptions

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

DbOptions database instance options

func DefaultOption

func DefaultOption() *DbOptions

DefaultOption Initialise Db Optionts to default values

func (*DbOptions) GetCorruptionChecker

func (o *DbOptions) GetCorruptionChecker() bool

GetCorruptionChecker returns if corruption checker should start for this database instance

func (*DbOptions) GetDbName

func (o *DbOptions) GetDbName() string

GetDbName Returns Database name which is also db instance directory

func (*DbOptions) GetDbRootPath

func (o *DbOptions) GetDbRootPath() string

GetDbRootPath returns the directory in which this database resides

func (*DbOptions) GetStoreOptions

func (o *DbOptions) GetStoreOptions() *store.Options

GetStoreOptions returns backing store options

func (*DbOptions) WithCorruptionChecker

func (o *DbOptions) WithCorruptionChecker(cc bool) *DbOptions

WithCorruptionChecker sets if corruption checker should start for this database instance

func (*DbOptions) WithDbName

func (o *DbOptions) WithDbName(dbName string) *DbOptions

WithDbName sets dbName, which is also db instance directory

func (*DbOptions) WithDbRootPath

func (o *DbOptions) WithDbRootPath(Path string) *DbOptions

WithDbRootPath sets the directory in which this database will reside

func (*DbOptions) WithStoreOptions

func (o *DbOptions) WithStoreOptions(storeOpts *store.Options) *DbOptions

WithStoreOptions sets backing store options

type KeyIndex

type KeyIndex interface {
	Get(key []byte) (value []byte, tx uint64, err error)
}

Jump to

Keyboard shortcuts

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