mdbx

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: GPL-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound     = fmt.Errorf("not found")
	ErrIterReleased = fmt.Errorf("memdb: iterator released")
)

Common errors.

View Source
var (
	ErrReleased    = fmt.Errorf("resource already relesed")
	ErrHasReleaser = fmt.Errorf("releaser already defined")
)

Functions

This section is empty.

Types

type BasicReleaser

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

BasicReleaser provides basic implementation of Releaser and ReleaseSetter.

func (*BasicReleaser) Release

func (r *BasicReleaser) Release()

Release implements Releaser.Release.

func (*BasicReleaser) Released

func (r *BasicReleaser) Released() bool

Released returns whether Release method already called.

func (*BasicReleaser) SetReleaser

func (r *BasicReleaser) SetReleaser(releaser Releaser)

SetReleaser implements ReleaseSetter.SetReleaser.

type Compare

type Compare func(a, b []byte) int

type KVBatch

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

KVBatch is a batch write for leveldb

func (*KVBatch) Set

func (b *KVBatch) Set(dbi string, k, v []byte) error

func (*KVBatch) Write

func (b *KVBatch) Write() error

why no error handle

type MdbxDB

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

func NewMDBX

func NewMDBX(path string, logger hclog.Logger) *MdbxDB

func (*MdbxDB) Batch

func (d *MdbxDB) Batch() ethdb.Batch

func (*MdbxDB) Close

func (d *MdbxDB) Close() error

func (*MdbxDB) Get

func (d *MdbxDB) Get(dbi string, k []byte) ([]byte, bool, error)

func (*MdbxDB) Remove

func (d *MdbxDB) Remove(dbi string, k []byte) error

func (*MdbxDB) Set

func (d *MdbxDB) Set(dbi string, k []byte, v []byte) error

func (*MdbxDB) Sync

func (d *MdbxDB) Sync() error

type MemDB

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

func New

func New(capacity int) *MemDB

New creates a new initialized in-memory key/value DB. The capacity is the initial key/value buffer capacity. The capacity is advisory, not enforced.

This DB is append-only, deleting an entry would remove entry node but not reclaim KV buffer.

The returned DB instance is safe for concurrent use.

func (*MemDB) Capacity

func (p *MemDB) Capacity() int

Capacity returns keys/values buffer capacity.

func (*MemDB) Contains

func (p *MemDB) Contains(key []byte) bool

Contains returns true if the given key are in the DB.

It is safe to modify the contents of the arguments after Contains returns.

func (*MemDB) Delete

func (p *MemDB) Delete(key []byte) error

Delete deletes the value for the given key. It returns ErrNotFound if the DB does not contain the key.

It is safe to modify the contents of the arguments after Delete returns.

func (*MemDB) Find

func (p *MemDB) Find(key []byte) (rkey, value []byte, err error)

Find finds key/value pair whose key is greater than or equal to the given key. It returns ErrNotFound if the table doesn't contain such pair.

The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Find returns.

func (*MemDB) Free

func (p *MemDB) Free() int

Free returns keys/values free buffer before need to grow.

func (*MemDB) Get

func (p *MemDB) Get(key []byte) (value []byte, err error)

Get gets the value for the given key. It returns error.ErrNotFound if the DB does not contain the key.

The caller should not modify the contents of the returned slice, but it is safe to modify the contents of the argument after Get returns.

func (*MemDB) Len

func (p *MemDB) Len() int

Len returns the number of entries in the DB.

func (*MemDB) NewIterator

func (p *MemDB) NewIterator() *dbIter

func (*MemDB) Put

func (p *MemDB) Put(key []byte, value []byte) error

Put sets the value for the given key. It overwrites any previous value for that key; a DB is not a multi-map.

It is safe to modify the contents of the arguments after Put returns.

func (*MemDB) Reset

func (p *MemDB) Reset()

Reset resets the DB to initial empty state. Allows reuse the buffer.

func (*MemDB) Size

func (p *MemDB) Size() int

Size returns sum of keys and values length. Note that deleted key/value will not be accounted for, but it will still consume the buffer, since the buffer is append only.

type NewValue

type NewValue struct {
	Dbi string
	Key []byte
	Val []byte
}

type NoopReleaser

type NoopReleaser struct{}

func (NoopReleaser) Release

func (NoopReleaser) Release()

type ReleaseSetter

type ReleaseSetter interface {
	// SetReleaser associates the given releaser to the resources. The
	// releaser will be called once coresponding resources released.
	// Calling SetReleaser with nil will clear the releaser.
	//
	// This will panic if a releaser already present or coresponding
	// resource is already released. Releaser should be cleared first
	// before assigned a new one.
	SetReleaser(releaser Releaser)
}

ReleaseSetter is the interface that wraps the basic SetReleaser method.

type Releaser

type Releaser interface {
	// Release releases associated resources. Release should always success
	// and can be called multiple times without causing error.
	Release()
}

Releaser is the interface that wraps the basic Release method.

Jump to

Keyboard shortcuts

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