store

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInconsistentState  = status.New(codes.Unknown, "inconsistent state").Err()
	ErrIndexNotFound      = status.New(codes.NotFound, "index not found").Err()
	ErrInvalidKey         = status.New(codes.InvalidArgument, "invalid key").Err()
	ErrInvalidReference   = status.New(codes.InvalidArgument, "invalid reference").Err()
	ErrInvalidKeyPrefix   = status.New(codes.InvalidArgument, "invalid key prefix").Err()
	ErrInvalidSet         = status.New(codes.InvalidArgument, "invalid set").Err()
	ErrInvalidOffset      = status.New(codes.InvalidArgument, "invalid offset").Err()
	ErrInvalidRootIndex   = status.New(codes.InvalidArgument, "invalid root index").Err()
	ErrObsoleteDataFormat = status.New(codes.Unknown, "data format in which elements are written on disk is not up to date to the current version of immudb server. Please upgrade to access to complete functionalities").Err()
	ErrInconsistentDigest = status.New(codes.Unknown, "insertion order index hash is not equal to the digest of the related value").Err()
)

immudb errors

View Source
var (
	// ErrValueLogSize is returned when opt.ValueLogFileSize option is not within the valid
	// range.
	ErrValueLogSize = status.New(codes.Unknown, badger.ErrValueLogSize.Error()).Err()

	// ErrKeyNotFound is returned when key isn't found on a txn.Get.
	ErrKeyNotFound = status.New(codes.NotFound, badger.ErrKeyNotFound.Error()).Err()

	// ErrTxnTooBig is returned if too many writes are fit into a single transaction.
	ErrTxnTooBig = status.New(codes.Unknown, badger.ErrTxnTooBig.Error()).Err()

	// ErrConflict is returned when a transaction conflicts with another transaction. This can
	// happen if the read rows had been updated concurrently by another transaction.
	ErrConflict = status.New(codes.Unknown, badger.ErrConflict.Error()).Err()

	// ErrReadOnlyTxn is returned if an update function is called on a read-only transaction.
	ErrReadOnlyTxn = status.New(codes.Unknown, badger.ErrReadOnlyTxn.Error()).Err()

	// ErrDiscardedTxn is returned if a previously discarded transaction is re-used.
	ErrDiscardedTxn = status.New(codes.Unknown, badger.ErrDiscardedTxn.Error()).Err()

	// ErrEmptyKey is returned if an empty key is passed on an update function.
	ErrEmptyKey = status.New(codes.Unknown, badger.ErrEmptyKey.Error()).Err()

	// ErrRetry is returned when a log file containing the value is not found.
	// This usually indicates that it may have been garbage collected, and the
	// operation needs to be retried.
	ErrRetry = status.New(codes.Unknown, badger.ErrRetry.Error()).Err()

	// ErrThresholdZero is returned if threshold is set to zero, and value log GC is called.
	// In such a case, GC can't be run.
	ErrThresholdZero = status.New(codes.Unknown, badger.ErrThresholdZero.Error()).Err()

	// ErrNoRewrite is returned if a call for value log GC doesn't result in a log file rewrite.
	ErrNoRewrite = status.New(codes.Unknown, badger.ErrNoRewrite.Error()).Err()

	// ErrRejected is returned if a value log GC is called either while another GC is running, or
	// after DB::Close has been called.
	ErrRejected = status.New(codes.Unknown, badger.ErrRejected.Error()).Err()

	// ErrInvalidRequest is returned if the user request is invalid.
	ErrInvalidRequest = status.New(codes.Unknown, badger.ErrInvalidRequest.Error()).Err()

	// ErrManagedTxn is returned if the user tries to use an API which isn't
	// allowed due to external management of transactions, when using ManagedDB.
	ErrManagedTxn = status.New(codes.Unknown, badger.ErrManagedTxn.Error()).Err()

	// ErrInvalidDump if a data dump made previously cannot be loaded into the database.
	ErrInvalidDump = status.New(codes.Unknown, badger.ErrInvalidDump.Error()).Err()

	// ErrZeroBandwidth is returned if the user passes in zero bandwidth for sequence.
	ErrZeroBandwidth = status.New(codes.Unknown, badger.ErrZeroBandwidth.Error()).Err()

	// ErrInvalidLoadingMode is returned when opt.ValueLogLoadingMode option is not
	// within the valid range
	ErrInvalidLoadingMode = status.New(codes.Unknown, badger.ErrInvalidLoadingMode.Error()).Err()

	// ErrReplayNeeded is returned when opt.ReadOnly is set but the
	// database requires a value log replay.
	ErrReplayNeeded = status.New(codes.Unknown, badger.ErrReplayNeeded.Error()).Err()

	// ErrWindowsNotSupported is returned when opt.ReadOnly is used on Windows
	ErrWindowsNotSupported = status.New(codes.Unknown, badger.ErrWindowsNotSupported.Error()).Err()

	// ErrTruncateNeeded is returned when the value log gets corrupt, and requires truncation of
	// corrupt data to allow Badger to run properly.
	ErrTruncateNeeded = status.New(codes.Unknown, badger.ErrTruncateNeeded.Error()).Err()

	// ErrBlockedWrites is returned if the user called DropAll. During the process of dropping all
	// data from Badger, we stop accepting new writes, by returning this error.
	ErrBlockedWrites = status.New(codes.Unknown, badger.ErrBlockedWrites.Error()).Err()

	// ErrNilCallback is returned when subscriber's callback is nil.
	ErrNilCallback = status.New(codes.Unknown, badger.ErrNilCallback.Error()).Err()

	// ErrEncryptionKeyMismatch is returned when the storage key is not
	// matched with the key previously given.
	ErrEncryptionKeyMismatch = status.New(codes.Unknown, badger.ErrEncryptionKeyMismatch.Error()).Err()

	// ErrInvalidDataKeyID is returned if the datakey id is invalid.
	ErrInvalidDataKeyID = status.New(codes.Unknown, badger.ErrInvalidDataKeyID.Error()).Err()

	ErrInvalidEncryptionKey = status.New(codes.Unknown, badger.ErrInvalidEncryptionKey.Error()).Err()

	ErrGCInMemoryMode = status.New(codes.Unknown, badger.ErrGCInMemoryMode.Error()).Err()
)

fixme(leogr): review codes and fix/remove errors which do not make sense in this context, finally correct comments accordingly.

Functions

func Bytes2float

func Bytes2float(bytes []byte) float64

Bytes2float ...

func Float642bytes

func Float642bytes(float float64) []byte

Float642bytes ...

func SetKey

func SetKey(key []byte, set []byte, score float64) (ik []byte, err error)

SetKey ...

Types

type Options

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

Options ...

func DefaultOptions

func DefaultOptions(path string, log logger.Logger) (Options, badger.Options)

DefaultOptions ...

type Store

type Store struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

Store ...

func Open

func Open(options Options, badgerOptions badger.Options) (*Store, error)

Open opens the store with the specified options

func (*Store) ByIndex

func (t *Store) ByIndex(index schema.Index) (item *schema.Item, err error)

ByIndex fetches the entry at the specified index

func (*Store) BySafeIndex

func (t *Store) BySafeIndex(options schema.SafeIndexOptions) (safeitem *schema.SafeItem, err error)

BySafeIndex fetches the entry at the specified index together with the inclusion proof for it and the consistency proof for the current root

func (*Store) Close

func (t *Store) Close() error

Close closes the store

func (*Store) ConsistencyProof

func (s *Store) ConsistencyProof(index schema.Index) (*schema.ConsistencyProof, error)

ConsistencyProof returns the consistency proof between the specified index and the current root

func (*Store) Count

func (t *Store) Count(prefix schema.KeyPrefix) (count *schema.ItemsCount, err error)

Count returns the number of entris having the specified key prefix

func (*Store) CountAll

func (t *Store) CountAll() (count uint64)

CountAll returns the total number of entries

func (*Store) CurrentRoot

func (t *Store) CurrentRoot() (root *schema.Root, err error)

CurrentRoot returns the index and the hash of the current tree root, if any. When the tree is empty and no root is available then the zerovalue for _schema.Root_ is returned instead.

func (*Store) DbSize

func (t *Store) DbSize() (int64, int64)

DbSize ...

func (*Store) Dump

func (t *Store) Dump(kvChan chan *pb.KVList) (err error)

Dump returns a dump of the database

func (*Store) FlushToDisk

func (t *Store) FlushToDisk()

FlushToDisk flushes cached data from memory to disk

func (*Store) Get

func (t *Store) Get(key schema.Key) (item *schema.Item, err error)

Get fetches the entry having the specified key

func (*Store) GetTree added in v0.6.1

func (t *Store) GetTree() *schema.Tree

GetTree returns a structure that rapresents merkle tree. Every node is marked as in memory, root and with reference key.

func (*Store) HealthCheck

func (t *Store) HealthCheck() bool

HealthCheck ...

func (*Store) History

func (t *Store) History(key schema.Key) (list *schema.ItemList, err error)

History fetches the complete history of entries for the specified key

func (*Store) IScan

func (t *Store) IScan(options schema.IScanOptions) (list *schema.Page, err error)

IScan iterates over all entries by the insertion order

func (*Store) InclusionProof

func (s *Store) InclusionProof(index schema.Index) (*schema.InclusionProof, error)

InclusionProof returns the inclusion proof of the specified index in the current tree

func (*Store) Reference

func (t *Store) Reference(refOpts *schema.ReferenceOptions, options ...WriteOption) (index *schema.Index, err error)

Reference adds a new entry who's value is an existing key

func (*Store) Restore

func (t *Store) Restore(kvChan chan *pb.KVList) (i uint64, err error)

Restore restores a database

func (*Store) SafeGet

func (t *Store) SafeGet(options schema.SafeGetOptions) (safeItem *schema.SafeItem, err error)

SafeGet fetches the entry having the specified key together with the inclusion proof for it and the consistency proof for the current root

func (*Store) SafeReference

func (t *Store) SafeReference(options schema.SafeReferenceOptions) (proof *schema.Proof, err error)

SafeReference adds a reference entry to an existing key and returns the inclusion proof for it and the consistency proof for the previous root

func (*Store) SafeSet

func (t *Store) SafeSet(options schema.SafeSetOptions) (proof *schema.Proof, err error)

SafeSet adds an entry and returns the inclusion proof for it and the consistency proof for the previous root

func (*Store) SafeZAdd

func (t *Store) SafeZAdd(options schema.SafeZAddOptions) (proof *schema.Proof, err error)

SafeZAdd adds the specified score and key to the specified sorted set and returns the inclusion proof for it and the consistency proof for the previous root

func (*Store) Scan

func (t *Store) Scan(options schema.ScanOptions) (list *schema.ItemList, err error)

Scan fetch the entries having the specified key prefix

func (*Store) Set

func (t *Store) Set(kv schema.KeyValue, options ...WriteOption) (index *schema.Index, err error)

Set adds a new entry

func (*Store) SetBatch

func (t *Store) SetBatch(list schema.KVList, options ...WriteOption) (index *schema.Index, err error)

SetBatch adds many entries at once

func (*Store) Wait

func (t *Store) Wait()

Wait ...

func (*Store) ZAdd

func (t *Store) ZAdd(zaddOpts schema.ZAddOptions, options ...WriteOption) (index *schema.Index, err error)

ZAdd adds a score for an existing key in the specified sorted set

func (*Store) ZScan

func (t *Store) ZScan(options schema.ZScanOptions) (list *schema.ItemList, err error)

ZScan The SCAN command is used in order to incrementally iterate over a collection of elements.

type WriteOption

type WriteOption func(*WriteOptions)

WriteOption ...

func WithAsyncCommit

func WithAsyncCommit(async bool) WriteOption

WithAsyncCommit ...

type WriteOptions

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

WriteOptions ...

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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