mem

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrepareType prepare event
	PrepareType = EventType(0)
	// CommitType commit event
	CommitType = EventType(1)
	// CommittingType committing type
	CommittingType = EventType(2)
	// RollbackType rollback type
	RollbackType = EventType(3)
)

Functions

func MustParseGetPayload

func MustParseGetPayload(payload []byte) [][]byte

MustParseGetPayload must parse get payload

func NewGetTxnRequest

func NewGetTxnRequest(ks [][]byte) txn.TxnRequest

NewGetTxnRequest returns a kv get txn request

func NewMemLog

func NewMemLog() logservice.Client

NewMemLog new log use memory as backend. Log index is start from 1.

func NewSetTxnRequest

func NewSetTxnRequest(ks, vs [][]byte) txn.TxnRequest

NewSetTxnRequest returns a kv set txn request

Types

type Event added in v0.5.1

type Event struct {
	// Txn event txn
	Txn txn.TxnMeta
	// Type event type
	Type EventType
}

Event event

type EventType added in v0.5.1

type EventType int

EventType event type

type KV

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

KV mem kv based on btree. Just used to test transaction.

func NewKV

func NewKV() *KV

NewKV returns a Mem KV

func (*KV) AscendRange

func (kv *KV) AscendRange(start, end []byte, fn func(key, value []byte) bool)

AscendRange iter in [start, end)

func (*KV) Delete

func (kv *KV) Delete(key []byte) bool

Delete delete key from KV

func (*KV) Get

func (kv *KV) Get(key []byte) ([]byte, bool)

Get returns the value of the key

func (*KV) Len

func (kv *KV) Len() int

Len return the count of keys

func (*KV) Set

func (kv *KV) Set(key, value []byte)

Set set key value to KV

type KVLog

type KVLog struct {
	Txn    txn.TxnMeta `json:"txn"`
	Keys   [][]byte    `json:"key,omitempty"`
	Values [][]byte    `json:"value,omitempty"`
}

KVLog kv log

func (*KVLog) MustMarshal

func (l *KVLog) MustMarshal() []byte

MustMarshal must marshal

func (*KVLog) MustUnmarshal

func (l *KVLog) MustUnmarshal(data []byte)

MustUnmarshal must unmarshal

type KVTxnStorage

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

KVTxnStorage KV-based implementation of TxnStorage. Just used to test.

func NewKVTxnStorage

func NewKVTxnStorage(recoverFrom logservice.Lsn, logClient logservice.Client, clock clock.Clock) *KVTxnStorage

NewKVTxnStorage create KV-based implementation of TxnStorage

func (*KVTxnStorage) Close added in v0.6.0

func (kv *KVTxnStorage) Close(ctx context.Context) error

func (*KVTxnStorage) Commit

func (kv *KVTxnStorage) Commit(ctx context.Context, txnMeta txn.TxnMeta) (timestamp.Timestamp, error)

func (*KVTxnStorage) Committing

func (kv *KVTxnStorage) Committing(ctx context.Context, txnMeta txn.TxnMeta) error

func (*KVTxnStorage) Debug added in v0.6.0

func (kv *KVTxnStorage) Debug(ctx context.Context, meta txn.TxnMeta, op uint32, data []byte) ([]byte, error)

func (*KVTxnStorage) Destroy added in v0.6.0

func (kv *KVTxnStorage) Destroy(ctx context.Context) error

func (*KVTxnStorage) GetCommittedKV

func (kv *KVTxnStorage) GetCommittedKV() *MVCCKV

func (*KVTxnStorage) GetEventC added in v0.5.1

func (kv *KVTxnStorage) GetEventC() chan Event

func (*KVTxnStorage) GetUncommittedKV

func (kv *KVTxnStorage) GetUncommittedKV() *KV

func (*KVTxnStorage) GetUncommittedTxn

func (kv *KVTxnStorage) GetUncommittedTxn(txnID []byte) *txn.TxnMeta

func (*KVTxnStorage) Prepare

func (kv *KVTxnStorage) Prepare(ctx context.Context, txnMeta txn.TxnMeta) (timestamp.Timestamp, error)

func (*KVTxnStorage) Read

func (kv *KVTxnStorage) Read(ctx context.Context, txnMeta txn.TxnMeta, op uint32, payload []byte) (storage.ReadResult, error)

func (*KVTxnStorage) Rollback

func (kv *KVTxnStorage) Rollback(ctx context.Context, txnMeta txn.TxnMeta) error

func (*KVTxnStorage) Start added in v0.7.0

func (kv *KVTxnStorage) Start() error

func (*KVTxnStorage) StartRecovery

func (kv *KVTxnStorage) StartRecovery(ctx context.Context, c chan txn.TxnMeta)

func (*KVTxnStorage) Write

func (kv *KVTxnStorage) Write(ctx context.Context, txnMeta txn.TxnMeta, op uint32, payload []byte) ([]byte, error)

type MVCCKV

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

MVCCKV mvcc kv based on KV

func NewMVCCKV

func NewMVCCKV() *MVCCKV

NewMVCCKV create a mvcc based kv

func (*MVCCKV) AscendRange

func (mkv *MVCCKV) AscendRange(rawKey []byte, from timestamp.Timestamp, to timestamp.Timestamp,
	fn func([]byte, timestamp.Timestamp))

AscendRange iter in [rawkey:from, rawkey:to)

func (*MVCCKV) Delete

func (mkv *MVCCKV) Delete(rawKey []byte, ts timestamp.Timestamp) bool

Delete delete the value of a key in the specified version

func (*MVCCKV) Get

func (mkv *MVCCKV) Get(rawKey []byte, ts timestamp.Timestamp) ([]byte, bool)

Get returns the value of a key in the specified version

func (*MVCCKV) Set

func (mkv *MVCCKV) Set(rawKey []byte, ts timestamp.Timestamp, value []byte)

Set set mvcc key value

Jump to

Keyboard shortcuts

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