mvccdb

package
v2.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2019 License: LGPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedNestedTransaction    = errors.New("unsupported nested transaction")
	ErrTransactionNotStarted           = errors.New("transaction is not started")
	ErrDisallowedCallingInNoPreparedDB = errors.New("disallowed calling in No-Prepared MVCCDB")
	ErrTidIsNil                        = errors.New("tid is nil")
	ErrUnsupportedBeginInPreparedDB    = errors.New("unsupported begin transaction in prepared MVCCDB")
	ErrUnsupportedCommitInPreparedDB   = errors.New("unsupported commit transaction in prepared MVCCDB")
	ErrUnsupportedRollBackInPreparedDB = errors.New("unsupported rollback transaction in prepared MVCCDB")
	ErrPreparedDBIsDirty               = errors.New("prepared MVCCDB is dirty")
	ErrPreparedDBIsClosed              = errors.New("prepared MVCCDB is closed")
	ErrTidIsExist                      = errors.New("tid is exist")
)

Errors

View Source
var (
	ErrStagingTableKeyConfliction = errors.New("staging table key confliction")
	ErrParentStagingTableIsNil    = errors.New("parent Staging Table is nil")
)

Error

Functions

This section is empty.

Types

type MVCCDB

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

MVCCDB the data with MVCC supporting.

func NewMVCCDB

func NewMVCCDB(storage storage.Storage, trieSameKeyCompatibility bool) (*MVCCDB, error)

NewMVCCDB create and return new MVCCDB. The `trieSameKeyCompatibility` is used to prevent conflict in continuous changes with same key/value.

func (*MVCCDB) Begin

func (db *MVCCDB) Begin() error

Begin begin a transaction.

func (*MVCCDB) CheckAndUpdate

func (db *MVCCDB) CheckAndUpdate() ([]interface{}, error)

CheckAndUpdate merge current changes to `FinalVersionizedValues`.

func (*MVCCDB) Close

func (db *MVCCDB) Close() error

Close close prepared DB.

func (*MVCCDB) Commit

func (db *MVCCDB) Commit() error

Commit commit changes to storage.

func (*MVCCDB) Del

func (db *MVCCDB) Del(key []byte) error

Del value

func (*MVCCDB) DisableBatch

func (db *MVCCDB) DisableBatch()

DisableBatch disable batch write.

func (*MVCCDB) EnableBatch

func (db *MVCCDB) EnableBatch()

EnableBatch enable batch write.

func (*MVCCDB) Flush

func (db *MVCCDB) Flush() error

Flush write and flush pending batch write.

func (*MVCCDB) Get

func (db *MVCCDB) Get(key []byte) ([]byte, error)

Get value

func (*MVCCDB) GetParentDB

func (db *MVCCDB) GetParentDB() *MVCCDB

GetParentDB return the root db.

func (*MVCCDB) Prepare

func (db *MVCCDB) Prepare(tid interface{}) (*MVCCDB, error)

Prepare a nested transaction

func (*MVCCDB) Put

func (db *MVCCDB) Put(key []byte, val []byte) error

Put value

func (*MVCCDB) Reset

func (db *MVCCDB) Reset() error

Reset the nested transaction

func (*MVCCDB) RollBack

func (db *MVCCDB) RollBack() error

RollBack the transaction

func (*MVCCDB) SetStrictGlobalVersionCheck

func (db *MVCCDB) SetStrictGlobalVersionCheck(flag bool)

SetStrictGlobalVersionCheck set strict global version check flag.

type StagingTable

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

StagingTable a struct to store all staging changed key/value pairs. There are two map to store the key/value pairs. One are stored associated with tid, the other is `finalVersionizedValue`, record the `ready to commit` key/value pairs.

func NewStagingTable

func NewStagingTable(storage storage.Storage, tid interface{}, trieSameKeyCompatibility bool) *StagingTable

NewStagingTable return new instance of StagingTable.

func (*StagingTable) Del

func (tbl *StagingTable) Del(key []byte) (*VersionizedValueItem, error)

Del del the tid/key pair. If tid+key does not exist, copy and incr version from `finalVersionizedValues` to record previous version.

func (*StagingTable) Detach

func (tbl *StagingTable) Detach() error

Detach the staging table

func (*StagingTable) Get

func (tbl *StagingTable) Get(key []byte) (*VersionizedValueItem, error)

Get return value by key. If key does not exist, copy and incr version from `parentStagingTable` to record previous version.

func (*StagingTable) GetByKey

func (tbl *StagingTable) GetByKey(key []byte, loadFromStorage bool) (*VersionizedValueItem, error)

GetByKey return value by key. If key does not exist, copy and incr version from `parentStagingTable` to record previous version.

func (*StagingTable) Lock

func (tbl *StagingTable) Lock()

Lock staging table

func (*StagingTable) MergeToParent

func (tbl *StagingTable) MergeToParent() ([]interface{}, error)

MergeToParent merge key/value pair of tid to `finalVersionizedValues` which the version of value are the same.

func (*StagingTable) Prepare

func (tbl *StagingTable) Prepare(tid interface{}) (*StagingTable, error)

Prepare a independent staging table

func (*StagingTable) Purge

func (tbl *StagingTable) Purge()

Purge purge key/value pairs of tid.

func (*StagingTable) Put

func (tbl *StagingTable) Put(key []byte, val []byte) (*VersionizedValueItem, error)

Put put the key/val pair. If key does not exist, copy and incr version from `parentStagingTable` to record previous version.

func (*StagingTable) SetStrictGlobalVersionCheck

func (tbl *StagingTable) SetStrictGlobalVersionCheck(flag bool)

SetStrictGlobalVersionCheck set global version check

func (*StagingTable) Unlock

func (tbl *StagingTable) Unlock()

Unlock staging table

type VersionizedValueItem

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

VersionizedValueItem a struct for key/value pair, with version, dirty, deleted flags.

func CloneVersionizedValueItem

func CloneVersionizedValueItem(tid interface{}, oldValue *VersionizedValueItem) *VersionizedValueItem

CloneVersionizedValueItem copy and return the version increased VersionizedValueItem.

func NewDefaultVersionizedValueItem

func NewDefaultVersionizedValueItem(key []byte, val []byte, tid interface{}, globalVersion int64) *VersionizedValueItem

NewDefaultVersionizedValueItem return new instance of VersionizedValueItem, old/new version are 0, dirty is false.

func (*VersionizedValueItem) CloneForMerge

func (value *VersionizedValueItem) CloneForMerge(globalVersion int64) *VersionizedValueItem

CloneForMerge shadow copy of `VersionizedValueItem` with dirty is true.

Jump to

Keyboard shortcuts

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