mvcc

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mvcc implements Multi-Version Concurrency Control for ScoriaDB, providing snapshot isolation with versioned key-value pairs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvertTimestamp

func InvertTimestamp(ts uint64) uint64

InvertTimestamp инвертирует timestamp для сортировки новых версий первыми. Используется в MVCCKey.

func RevertTimestamp

func RevertTimestamp(inverted uint64) uint64

RevertTimestamp восстанавливает оригинальный timestamp из инвертированного.

Types

type MVCCKey

type MVCCKey struct {
	Key       []byte
	Timestamp uint64 // инвертированный: MaxUint64 - commitTS
}

MVCCKey представляет ключ с версией (инвертированный timestamp).

func NewMVCCKey

func NewMVCCKey(key []byte, commitTS uint64) MVCCKey

NewMVCCKey создает MVCCKey из пользовательского ключа и commit timestamp.

func (MVCCKey) CommitTS

func (k MVCCKey) CommitTS() uint64

CommitTS возвращает оригинальный commit timestamp.

func (MVCCKey) Compare

func (k MVCCKey) Compare(other MVCCKey) int

Compare сравнивает два ключа лексикографически (ключ, затем timestamp).

func (MVCCKey) Less

func (k MVCCKey) Less(than btree.Item) bool

Less реализует интерфейс btree.Item для сортировки.

type TimestampGenerator

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

TimestampGenerator генерирует монотонные временные метки.

func NewTimestampGenerator

func NewTimestampGenerator() *TimestampGenerator

NewTimestampGenerator создает новый генератор.

func (*TimestampGenerator) Increment

func (tg *TimestampGenerator) Increment() uint64

Increment увеличивает счетчик и возвращает новый timestamp.

func (*TimestampGenerator) Next

func (tg *TimestampGenerator) Next() uint64

Next возвращает следующий timestamp.

func (*TimestampGenerator) Set

func (tg *TimestampGenerator) Set(val uint64)

Set устанавливает счетчик в значение (для восстановления).

Jump to

Keyboard shortcuts

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