mdbx

package
v0.0.0-...-ff78b6e Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGrowthStep = 2 * datasize.GB
View Source
const DefaultMapSize = 2 * datasize.TB
View Source
const NonExistingDBI kv.DBI = 999_999_999

Variables

View Source
var ErrDBDoesNotExists = fmt.Errorf("can't create database - because opening in `Accede` mode. probably another (main) process can create it")

Functions

func MustOpen

func MustOpen(path string) kv.RwDB

func NewTemporaryMdbx

func NewTemporaryMdbx(ctx context.Context, tempdir string) (kv.RwDB, error)

func Open

func Open(ctx context.Context, path string, logger log.Logger, accede bool) (kv.RwDB, error)

Open - main method to open database.

func PathDbMap

func PathDbMap() map[string]kv.RoDB

func WithChaindataTables

func WithChaindataTables(defaultBuckets kv.TableCfg) kv.TableCfg

Types

type MdbxCursor

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

func (*MdbxCursor) Append

func (c *MdbxCursor) Append(k []byte, v []byte) error

Append - speedy feature of mdbx which is not part of KV interface. Cast your cursor to *MdbxCursor to use this method. Return error - if provided data will not sorted (or bucket have old records which mess with new in sorting manner).

func (*MdbxCursor) Close

func (c *MdbxCursor) Close()

func (*MdbxCursor) Count

func (c *MdbxCursor) Count() (uint64, error)

func (*MdbxCursor) Current

func (c *MdbxCursor) Current() ([]byte, []byte, error)

Current - return key/data at current cursor position

func (*MdbxCursor) Delete

func (c *MdbxCursor) Delete(k []byte) error

func (*MdbxCursor) DeleteCurrent

func (c *MdbxCursor) DeleteCurrent() error

DeleteCurrent This function deletes the key/data pair to which the cursor refers. This does not invalidate the cursor, so operations such as MDB_NEXT can still be used on it. Both MDB_NEXT and MDB_GET_CURRENT will return the same record after this operation.

func (*MdbxCursor) First

func (c *MdbxCursor) First() ([]byte, []byte, error)

func (*MdbxCursor) Last

func (c *MdbxCursor) Last() ([]byte, []byte, error)

func (*MdbxCursor) Next

func (c *MdbxCursor) Next() (k, v []byte, err error)

func (*MdbxCursor) Prev

func (c *MdbxCursor) Prev() (k, v []byte, err error)

func (*MdbxCursor) Put

func (c *MdbxCursor) Put(key []byte, value []byte) error

func (*MdbxCursor) PutNoOverwrite

func (c *MdbxCursor) PutNoOverwrite(key []byte, value []byte) error

func (*MdbxCursor) Seek

func (c *MdbxCursor) Seek(seek []byte) (k, v []byte, err error)

func (*MdbxCursor) SeekExact

func (c *MdbxCursor) SeekExact(key []byte) ([]byte, []byte, error)

type MdbxDupSortCursor

type MdbxDupSortCursor struct {
	*MdbxCursor
}

func (*MdbxDupSortCursor) Append

func (c *MdbxDupSortCursor) Append(k []byte, v []byte) error

func (*MdbxDupSortCursor) AppendDup

func (c *MdbxDupSortCursor) AppendDup(k []byte, v []byte) error

func (*MdbxDupSortCursor) CountDuplicates

func (c *MdbxDupSortCursor) CountDuplicates() (uint64, error)

CountDuplicates returns the number of duplicates for the current key. See mdb_cursor_count

func (*MdbxDupSortCursor) DeleteCurrentDuplicates

func (c *MdbxDupSortCursor) DeleteCurrentDuplicates() error

DeleteCurrentDuplicates - delete all of the data items for the current key.

func (*MdbxDupSortCursor) DeleteExact

func (c *MdbxDupSortCursor) DeleteExact(k1, k2 []byte) error

DeleteExact - does delete

func (*MdbxDupSortCursor) FirstDup

func (c *MdbxDupSortCursor) FirstDup() ([]byte, error)

func (*MdbxDupSortCursor) Internal

func (c *MdbxDupSortCursor) Internal() *mdbx.Cursor

func (*MdbxDupSortCursor) LastDup

func (c *MdbxDupSortCursor) LastDup() ([]byte, error)

func (*MdbxDupSortCursor) NextDup

func (c *MdbxDupSortCursor) NextDup() ([]byte, []byte, error)

NextDup - iterate only over duplicates of current key

func (*MdbxDupSortCursor) NextNoDup

func (c *MdbxDupSortCursor) NextNoDup() ([]byte, []byte, error)

NextNoDup - iterate with skipping all duplicates

func (*MdbxDupSortCursor) PrevDup

func (c *MdbxDupSortCursor) PrevDup() ([]byte, []byte, error)

func (*MdbxDupSortCursor) PrevNoDup

func (c *MdbxDupSortCursor) PrevNoDup() ([]byte, []byte, error)

func (*MdbxDupSortCursor) PutNoDupData

func (c *MdbxDupSortCursor) PutNoDupData(k, v []byte) error

func (*MdbxDupSortCursor) SeekBothExact

func (c *MdbxDupSortCursor) SeekBothExact(key, value []byte) ([]byte, []byte, error)

func (*MdbxDupSortCursor) SeekBothRange

func (c *MdbxDupSortCursor) SeekBothRange(key, value []byte) ([]byte, error)

type MdbxKV

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

func (*MdbxKV) Accede

func (db *MdbxKV) Accede() bool

func (*MdbxKV) AllDBI

func (db *MdbxKV) AllDBI() map[string]kv.DBI

func (*MdbxKV) AllTables

func (db *MdbxKV) AllTables() kv.TableCfg

func (*MdbxKV) BeginRo

func (db *MdbxKV) BeginRo(ctx context.Context) (txn kv.Tx, err error)

func (*MdbxKV) BeginRw

func (db *MdbxKV) BeginRw(ctx context.Context) (kv.RwTx, error)

func (*MdbxKV) BeginRwNosync

func (db *MdbxKV) BeginRwNosync(ctx context.Context) (kv.RwTx, error)

func (*MdbxKV) CHandle

func (db *MdbxKV) CHandle() unsafe.Pointer

func (*MdbxKV) Close

func (db *MdbxKV) Close()

Close closes db All transactions must be closed before closing the database.

func (*MdbxKV) Env

func (db *MdbxKV) Env() *mdbx.Env

func (*MdbxKV) PageSize

func (db *MdbxKV) PageSize() uint64

func (*MdbxKV) ReadOnly

func (db *MdbxKV) ReadOnly() bool

func (*MdbxKV) Update

func (db *MdbxKV) Update(ctx context.Context, f func(tx kv.RwTx) error) (err error)

func (*MdbxKV) UpdateNosync

func (db *MdbxKV) UpdateNosync(ctx context.Context, f func(tx kv.RwTx) error) (err error)

func (*MdbxKV) View

func (db *MdbxKV) View(ctx context.Context, f func(tx kv.Tx) error) (err error)

type MdbxOpts

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

func NewMDBX

func NewMDBX(log log.Logger) MdbxOpts

func (MdbxOpts) Accede

func (opts MdbxOpts) Accede() MdbxOpts

func (MdbxOpts) DBVerbosity

func (opts MdbxOpts) DBVerbosity(v kv.DBVerbosityLvl) MdbxOpts

func (MdbxOpts) DirtySpace

func (opts MdbxOpts) DirtySpace(s uint64) MdbxOpts

func (MdbxOpts) Exclusive

func (opts MdbxOpts) Exclusive() MdbxOpts

func (MdbxOpts) Flags

func (opts MdbxOpts) Flags(f func(uint) uint) MdbxOpts

func (MdbxOpts) GetInMem

func (opts MdbxOpts) GetInMem() bool

func (MdbxOpts) GetLabel

func (opts MdbxOpts) GetLabel() kv.Label

func (MdbxOpts) GetPageSize

func (opts MdbxOpts) GetPageSize() uint64

func (MdbxOpts) GrowthStep

func (opts MdbxOpts) GrowthStep(v datasize.ByteSize) MdbxOpts

func (MdbxOpts) HasFlag

func (opts MdbxOpts) HasFlag(flag uint) bool

func (MdbxOpts) InMem

func (opts MdbxOpts) InMem(tmpDir string) MdbxOpts

func (MdbxOpts) Label

func (opts MdbxOpts) Label(label kv.Label) MdbxOpts

func (MdbxOpts) MapSize

func (opts MdbxOpts) MapSize(sz datasize.ByteSize) MdbxOpts

func (MdbxOpts) MustOpen

func (opts MdbxOpts) MustOpen() kv.RwDB

func (MdbxOpts) Open

func (opts MdbxOpts) Open(ctx context.Context) (kv.RwDB, error)

func (MdbxOpts) PageSize

func (opts MdbxOpts) PageSize(v uint64) MdbxOpts

func (MdbxOpts) Path

func (opts MdbxOpts) Path(path string) MdbxOpts

func (MdbxOpts) Readonly

func (opts MdbxOpts) Readonly() MdbxOpts

func (MdbxOpts) RoTxsLimiter

func (opts MdbxOpts) RoTxsLimiter(l *semaphore.Weighted) MdbxOpts

func (MdbxOpts) Set

func (opts MdbxOpts) Set(opt MdbxOpts) MdbxOpts

func (MdbxOpts) SyncPeriod

func (opts MdbxOpts) SyncPeriod(period time.Duration) MdbxOpts

func (MdbxOpts) WithTableCfg

func (opts MdbxOpts) WithTableCfg(f TableCfgFunc) MdbxOpts

func (MdbxOpts) WriteMap

func (opts MdbxOpts) WriteMap() MdbxOpts

func (MdbxOpts) WriteMergeThreshold

func (opts MdbxOpts) WriteMergeThreshold(v uint64) MdbxOpts

type MdbxTx

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

func (*MdbxTx) Append

func (tx *MdbxTx) Append(bucket string, k, v []byte) error

func (*MdbxTx) AppendDup

func (tx *MdbxTx) AppendDup(bucket string, k, v []byte) error

func (*MdbxTx) BucketSize

func (tx *MdbxTx) BucketSize(name string) (uint64, error)

func (*MdbxTx) BucketStat

func (tx *MdbxTx) BucketStat(name string) (*mdbx.Stat, error)

func (*MdbxTx) CHandle

func (tx *MdbxTx) CHandle() unsafe.Pointer

func (*MdbxTx) ClearBucket

func (tx *MdbxTx) ClearBucket(bucket string) error

func (*MdbxTx) CollectMetrics

func (tx *MdbxTx) CollectMetrics()

func (*MdbxTx) Commit

func (tx *MdbxTx) Commit() error

func (*MdbxTx) CreateBucket

func (tx *MdbxTx) CreateBucket(name string) error

func (*MdbxTx) Cursor

func (tx *MdbxTx) Cursor(bucket string) (kv.Cursor, error)

func (*MdbxTx) CursorDupSort

func (tx *MdbxTx) CursorDupSort(bucket string) (kv.CursorDupSort, error)

func (*MdbxTx) DBSize

func (tx *MdbxTx) DBSize() (uint64, error)

func (*MdbxTx) Delete

func (tx *MdbxTx) Delete(table string, k []byte) error

func (*MdbxTx) DropBucket

func (tx *MdbxTx) DropBucket(bucket string) error

func (*MdbxTx) ExistsBucket

func (tx *MdbxTx) ExistsBucket(bucket string) (bool, error)

func (*MdbxTx) ForAmount

func (tx *MdbxTx) ForAmount(bucket string, fromPrefix []byte, amount uint32, walker func(k, v []byte) error) error

func (*MdbxTx) ForEach

func (tx *MdbxTx) ForEach(bucket string, fromPrefix []byte, walker func(k, v []byte) error) error

func (*MdbxTx) ForPrefix

func (tx *MdbxTx) ForPrefix(bucket string, prefix []byte, walker func(k, v []byte) error) error

func (*MdbxTx) GetOne

func (tx *MdbxTx) GetOne(bucket string, k []byte) ([]byte, error)

func (*MdbxTx) Has

func (tx *MdbxTx) Has(bucket string, key []byte) (bool, error)

func (*MdbxTx) IncrementSequence

func (tx *MdbxTx) IncrementSequence(bucket string, amount uint64) (uint64, error)

func (*MdbxTx) IsRo

func (tx *MdbxTx) IsRo() bool

func (*MdbxTx) ListBuckets

func (tx *MdbxTx) ListBuckets() ([]string, error)

ListBuckets - all buckets stored as keys of un-named bucket

func (*MdbxTx) Prefix

func (tx *MdbxTx) Prefix(table string, prefix []byte) (iter.KV, error)

func (*MdbxTx) PrintDebugInfo

func (tx *MdbxTx) PrintDebugInfo()

func (*MdbxTx) Put

func (tx *MdbxTx) Put(table string, k, v []byte) error

func (*MdbxTx) Range

func (tx *MdbxTx) Range(table string, fromPrefix, toPrefix []byte) (iter.KV, error)

func (*MdbxTx) RangeAscend

func (tx *MdbxTx) RangeAscend(table string, fromPrefix, toPrefix []byte, limit int) (iter.KV, error)

func (*MdbxTx) RangeDescend

func (tx *MdbxTx) RangeDescend(table string, fromPrefix, toPrefix []byte, limit int) (iter.KV, error)

func (*MdbxTx) RangeDupSort

func (tx *MdbxTx) RangeDupSort(table string, key []byte, fromPrefix, toPrefix []byte, asc order.By, limit int) (iter.KV, error)

func (*MdbxTx) ReadSequence

func (tx *MdbxTx) ReadSequence(bucket string) (uint64, error)

func (*MdbxTx) Rollback

func (tx *MdbxTx) Rollback()

func (*MdbxTx) RwCursor

func (tx *MdbxTx) RwCursor(bucket string) (kv.RwCursor, error)

func (*MdbxTx) RwCursorDupSort

func (tx *MdbxTx) RwCursorDupSort(bucket string) (kv.RwCursorDupSort, error)

func (*MdbxTx) SpaceDirty

func (tx *MdbxTx) SpaceDirty() (uint64, uint64, error)

func (*MdbxTx) ViewID

func (tx *MdbxTx) ViewID() uint64

type TableCfgFunc

type TableCfgFunc func(defaultBuckets kv.TableCfg) kv.TableCfg

type TemporaryMdbx

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

func (*TemporaryMdbx) AllTables

func (t *TemporaryMdbx) AllTables() kv.TableCfg

func (*TemporaryMdbx) BeginRo

func (t *TemporaryMdbx) BeginRo(ctx context.Context) (kv.Tx, error)

func (*TemporaryMdbx) BeginRw

func (t *TemporaryMdbx) BeginRw(ctx context.Context) (kv.RwTx, error)

func (*TemporaryMdbx) BeginRwNosync

func (t *TemporaryMdbx) BeginRwNosync(ctx context.Context) (kv.RwTx, error)

func (*TemporaryMdbx) CHandle

func (t *TemporaryMdbx) CHandle() unsafe.Pointer

func (*TemporaryMdbx) Close

func (t *TemporaryMdbx) Close()

func (*TemporaryMdbx) PageSize

func (t *TemporaryMdbx) PageSize() uint64

func (*TemporaryMdbx) ReadOnly

func (t *TemporaryMdbx) ReadOnly() bool

func (*TemporaryMdbx) Update

func (t *TemporaryMdbx) Update(ctx context.Context, f func(kv.RwTx) error) error

func (*TemporaryMdbx) UpdateNosync

func (t *TemporaryMdbx) UpdateNosync(ctx context.Context, f func(kv.RwTx) error) error

func (*TemporaryMdbx) View

func (t *TemporaryMdbx) View(ctx context.Context, f func(kv.Tx) error) error

Jump to

Keyboard shortcuts

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