tsrocksdb

package
v0.0.0-...-547a3fa Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TimestampSize = 8

	StorePrefixTpl = "s/k:%s/"

	ImportCommitBatchSize = 10000
)
View Source
const VersionDBCFName = "versiondb"

Variables

This section is empty.

Functions

func CreateTSComparator

func CreateTSComparator() *grocksdb.Comparator

CreateTSComparator should behavior identical with rocksdb builtin timestamp comparator. we also use the same builtin comparator name so the builtin tools `ldb`/`sst_dump` can work with the database.

func NewVersionDBOpts

func NewVersionDBOpts(sstFileWriter bool) *grocksdb.Options

NewVersionDBOpts returns the options used for the versiondb column family. FIXME: we don't enable dict compression for SSTFileWriter, because otherwise the file writer won't report correct file size. https://github.com/facebook/rocksdb/issues/11146

func OpenVersionDB

func OpenVersionDB(dir string) (*grocksdb.DB, *grocksdb.ColumnFamilyHandle, error)

OpenVersionDB opens versiondb, the default column family is used for metadata, actually key-value pairs are stored on another column family named with "versiondb", which has user-defined timestamp enabled.

func OpenVersionDBAndTrimHistory

func OpenVersionDBAndTrimHistory(dir string, version int64) (*grocksdb.DB, *grocksdb.ColumnFamilyHandle, error)

OpenVersionDBAndTrimHistory opens versiondb similar to `OpenVersionDB`, but it also trim the versions newer than target one, can be used for rollback.

Types

type Store

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

func NewStore

func NewStore(dir string) (Store, error)

func NewStoreWithDB

func NewStoreWithDB(db *grocksdb.DB, cfHandle *grocksdb.ColumnFamilyHandle) Store

func (Store) FeedChangeSet

func (s Store) FeedChangeSet(version int64, store string, changeSet *iavl.ChangeSet) error

FeedChangeSet is used to migrate legacy change sets into versiondb

func (Store) GetAtVersion

func (s Store) GetAtVersion(storeKey string, key []byte, version *int64) ([]byte, error)

GetAtVersion implements VersionStore interface

func (Store) GetAtVersionSlice

func (s Store) GetAtVersionSlice(storeKey string, key []byte, version *int64) (*grocksdb.Slice, error)

func (Store) GetLatestVersion

func (s Store) GetLatestVersion() (int64, error)

GetLatestVersion returns the latest version stored in plain state, it's committed after the changesets, so the data for this version is guaranteed to be persisted. returns -1 if the key don't exists.

func (Store) HasAtVersion

func (s Store) HasAtVersion(storeKey string, key []byte, version *int64) (bool, error)

HasAtVersion implements VersionStore interface

func (Store) Import

func (s Store) Import(version int64, ch <-chan versiondb.ImportEntry) error

Import loads the initial version of the state

func (Store) IteratorAtVersion

func (s Store) IteratorAtVersion(storeKey string, start, end []byte, version *int64) (types.Iterator, error)

IteratorAtVersion implements VersionStore interface

func (Store) PutAtVersion

func (s Store) PutAtVersion(version int64, changeSet []types.StoreKVPair) error

PutAtVersion implements VersionStore interface

func (Store) ReverseIteratorAtVersion

func (s Store) ReverseIteratorAtVersion(storeKey string, start, end []byte, version *int64) (types.Iterator, error)

ReverseIteratorAtVersion implements VersionStore interface

func (Store) SetLatestVersion

func (s Store) SetLatestVersion(version int64) error

Jump to

Keyboard shortcuts

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