database

package
v1.0.0-alpha.14 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AllowedEnginesDefault = []hivedb.Engine{
		hivedb.EngineAuto,
		hivedb.EngineMapDB,
		hivedb.EngineRocksDB,
	}

	AllowedEnginesStorage = []hivedb.Engine{
		hivedb.EngineRocksDB,
	}

	AllowedEnginesStorageAuto = append(AllowedEnginesStorage, hivedb.EngineAuto)
)
View Source
var (
	ErrEpochPruned       = ierrors.New("epoch pruned")
	ErrNoPruningNeeded   = ierrors.New("no pruning needed")
	ErrDatabaseFull      = ierrors.New("database full")
	ErrDatabaseShutdown  = ierrors.New("cannot open DBInstance that is shutdown")
	ErrDatabaseNotClosed = ierrors.New("cannot open DBInstance that is not closed")
)
View Source
var (
	// ErrNothingToCleanUp is returned when nothing is there to clean up in the database.
	ErrNothingToCleanUp = ierrors.New("Nothing to clean up in the databases")
)

Functions

func CheckEngine

func CheckEngine(dbPath string, createDatabaseIfNotExists bool, dbEngine hivedb.Engine, allowedEngines ...hivedb.Engine) (hivedb.Engine, error)

CheckEngine is a wrapper around hivedb.CheckEngine to throw a custom error message in case of engine mismatch.

func NewRocksDB

func NewRocksDB(path string) (*rocksdb.RocksDB, error)

NewRocksDB creates a new RocksDB instance.

func StoreWithDefaultSettings

func StoreWithDefaultSettings(path string, createDatabaseIfNotExists bool, dbEngine hivedb.Engine, allowedEngines ...hivedb.Engine) (kvstore.KVStore, error)

StoreWithDefaultSettings returns a kvstore with default settings. It also checks if the database engine is correct.

Types

type Cleanup

type Cleanup struct {
	Start time.Time
	End   time.Time
}

func (*Cleanup) MarshalJSON

func (c *Cleanup) MarshalJSON() ([]byte, error)

type Config

type Config struct {
	Engine       db.Engine
	Directory    string
	Version      byte
	PrefixHealth []byte
}

func (Config) WithDirectory

func (c Config) WithDirectory(directory string) Config

type DBInstance

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

func NewDBInstance

func NewDBInstance(dbConfig Config, openedCallback func(d *DBInstance)) *DBInstance

func (*DBInstance) Close

func (d *DBInstance) Close()

func (*DBInstance) CloseWithoutLocking

func (d *DBInstance) CloseWithoutLocking()

func (*DBInstance) Flush

func (d *DBInstance) Flush()

func (*DBInstance) KVStore

func (d *DBInstance) KVStore() kvstore.KVStore

func (*DBInstance) LockAccess

func (d *DBInstance) LockAccess()

func (*DBInstance) Open

func (d *DBInstance) Open() error

Open re-opens a closed DBInstance. It must only be called while holding a lock on DBInstance, otherwise it might cause a race condition and corruption of node's state.

func (*DBInstance) Shutdown

func (d *DBInstance) Shutdown()

func (*DBInstance) UnlockAccess

func (d *DBInstance) UnlockAccess()

type Database

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

Database holds the underlying KVStore and database specific functions.

func New

func New(databaseDirectory string, kvStore kvstore.KVStore, engine hivedb.Engine, metrics *metrics.DatabaseMetrics, events *Events, compactionSupported bool, compactionRunningFunc func() bool) *Database

New creates a new Database instance.

func (*Database) CompactionRunning

func (db *Database) CompactionRunning() bool

CompactionRunning returns whether a compaction is running.

func (*Database) CompactionSupported

func (db *Database) CompactionSupported() bool

CompactionSupported returns whether the database engine supports compaction.

func (*Database) Engine

func (db *Database) Engine() hivedb.Engine

Engine returns the database engine.

func (*Database) Events

func (db *Database) Events() *Events

Events returns the events of the database.

func (*Database) KVStore

func (db *Database) KVStore() kvstore.KVStore

KVStore returns the underlying KVStore.

func (*Database) Metrics

func (db *Database) Metrics() *metrics.DatabaseMetrics

Metrics returns the database metrics.

func (*Database) Size

func (db *Database) Size() (int64, error)

Size returns the size of the database.

type Events

type Events struct {
	Cleanup    *event.Event1[*Cleanup]
	Compaction *event.Event1[bool]
}

Jump to

Keyboard shortcuts

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