db

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DatabaseFactory

type DatabaseFactory interface {
	// CreateDatabase creates and initializes a database instance with the given name and path.
	CreateDatabase(name, path string) (types.Database, error)
}

DatabaseFactory is an interface for creating databases.

type IAVLDatabase

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

IAVLDatabase wraps an IAVL+ tree to implement the Database interface.

func NewIAVLDatabase

func NewIAVLDatabase(tree *iavl.MutableTree) *IAVLDatabase

NewIAVLDatabase creates a new IAVLDatabase instance.

func (*IAVLDatabase) AvailableVersions

func (db *IAVLDatabase) AvailableVersions() []int

AvailableVersions returns a list of available versions.

func (*IAVLDatabase) Close

func (db *IAVLDatabase) Close() error

Close closes the tree.

func (*IAVLDatabase) Delete

func (db *IAVLDatabase) Delete(key []byte) error

Delete removes the key-value pair from the tree.

func (*IAVLDatabase) Get

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

Get retrieves the value associated with the given key from the tree.

func (*IAVLDatabase) Has

func (db *IAVLDatabase) Has(key []byte) (bool, error)

Has returns true if the key exists in the tree, otherwise false.

func (*IAVLDatabase) Hash

func (db *IAVLDatabase) Hash() []byte

Hash returns the root hash of the tree.

func (*IAVLDatabase) IsEmpty

func (db *IAVLDatabase) IsEmpty() bool

IsEmpty checks if the database is empty.

func (*IAVLDatabase) Iterate

func (db *IAVLDatabase) Iterate(fn func(key, value []byte) bool) error

Iterate iterates over all keys of the tree and calls the given function for each key-value pair. Iteration stops if the function returns true.

func (*IAVLDatabase) IterateRange

func (db *IAVLDatabase) IterateRange(start, end []byte, ascending bool, fn func(key, value []byte) bool) error

IterateRange iterates over all key-value pairs with keys in the range [start, end) and calls the given function for each pair. Iteration stops if the function returns true.

func (*IAVLDatabase) Load

func (db *IAVLDatabase) Load() (int64, error)

Load loads the latest versioned tree from disk.

func (*IAVLDatabase) LoadVersion

func (db *IAVLDatabase) LoadVersion(targetVersion int64) (int64, error)

LoadVersion loads a specific version of the tree from disk.

func (*IAVLDatabase) Rollback

func (db *IAVLDatabase) Rollback()

Rollback resets the working tree to the latest saved version, discarding any unsaved modifications.

func (*IAVLDatabase) SaveVersion

func (db *IAVLDatabase) SaveVersion() ([]byte, int64, error)

SaveVersion saves a new tree version to disk.

func (*IAVLDatabase) Set

func (db *IAVLDatabase) Set(key, value []byte) error

Set stores the key-value pair in the tree. If the key already exists, its value will be updated.

func (*IAVLDatabase) String

func (db *IAVLDatabase) String() (string, error)

String returns a string representation of the tree.

func (*IAVLDatabase) Version

func (db *IAVLDatabase) Version() int64

Version returns the version of the tree.

func (*IAVLDatabase) WorkingHash

func (db *IAVLDatabase) WorkingHash() []byte

WorkingHash returns the root hash of the current working tree.

func (*IAVLDatabase) WorkingVersion

func (db *IAVLDatabase) WorkingVersion() int64

WorkingVersion returns the current working version of the tree.

type IAVLDatabaseFactory

type IAVLDatabaseFactory struct {
	DatabaseFactory
}

IAVLDatabaseFactory is a concrete implementation of the DatabaseFactory interface that creates IAVL database instances.

func NewIAVLDatabaseFactory

func NewIAVLDatabaseFactory() *IAVLDatabaseFactory

NewIAVLDatabaseFactory creates a new instance of IAVLDatabaseFactory with the given DB creator function.

func (*IAVLDatabaseFactory) CreateDatabase

func (f *IAVLDatabaseFactory) CreateDatabase(name, path string) (types.Database, error)

CreateDatabase creates and initializes an IAVL database instance with the given name and path.

type MutableTree

type MutableTree interface {
	iavl.MutableTree
}

Jump to

Keyboard shortcuts

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