overlaydb

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: LGPL-3.0 Imports: 10 Imported by: 12

Documentation

Overview

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. * * The ontology is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The ontology is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with The ontology. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	FromMem  KeyOrigin = iota
	FromBack           = iota
	FromBoth           = iota
)

Variables

View Source
var (
	ErrNotFound     = errors.ErrNotFound
	ErrIterReleased = errors.New("leveldb/memdb: iterator released")
)

Common errors.

Functions

This section is empty.

Types

type JoinIter

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

func NewJoinIter

func NewJoinIter(memIter, backendIter common.StoreIterator) *JoinIter

func (*JoinIter) Error

func (iter *JoinIter) Error() error

func (*JoinIter) First

func (iter *JoinIter) First() bool

func (*JoinIter) Key

func (iter *JoinIter) Key() []byte

func (*JoinIter) Next

func (iter *JoinIter) Next() bool

func (*JoinIter) Release

func (iter *JoinIter) Release()

func (*JoinIter) Value

func (iter *JoinIter) Value() []byte

type KeyOrigin

type KeyOrigin byte

type MemDB

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

MemDB is an in-memdb key/value database.

func NewMemDB

func NewMemDB(capacity int, kvNum int) *MemDB

NewMemDB creates a new initialized in-memdb key/value MemDB. The capacity is the initial key/value buffer capacity. The capacity is advisory, not enforced.

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

The returned MemDB instance is safe for concurrent use.

func (*MemDB) Capacity

func (p *MemDB) Capacity() int

Capacity returns keys/values buffer capacity.

func (*MemDB) DeepClone added in v1.14.1

func (self *MemDB) DeepClone() *MemDB

func (*MemDB) Delete

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

Delete deletes the value for the given key.

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

func (*MemDB) DumpToDot

func (db *MemDB) DumpToDot() string

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) ForEach

func (p *MemDB) ForEach(f func(key, val []byte))

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, unkown bool)

Get gets the value for the given key. It returns unkown == true if the MemDB does not contain the key. It returns nil, false if MemDB has deleted 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 MemDB.

func (*MemDB) NewIterator

func (p *MemDB) NewIterator(slice *util.Range) iterator.Iterator

NewIterator returns an iterator of the MemDB. The returned iterator is not safe for concurrent use, but it is safe to use multiple iterators concurrently, with each in a dedicated goroutine. It is also safe to use an iterator concurrently with modifying its underlying MemDB. However, the resultant key/value pairs are not guaranteed to be a consistent snapshot of the MemDB at a particular point in time.

Slice allows slicing the iterator to only contains keys in the given range. A nil Range.Start is treated as a key before all keys in the MemDB. And a nil Range.Limit is treated as a key after all keys in the MemDB.

The iterator must be released after use, by calling Release method.

Also read Iterator documentation of the leveldb/iterator package.

func (*MemDB) Put

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

Put sets the value for the given key. It overwrites any previous value for that key; a MemDB 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 MemDB 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 OverlayDB

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

func NewOverlayDB

func NewOverlayDB(store common.PersistStore) *OverlayDB

func (*OverlayDB) ChangeHash

func (self *OverlayDB) ChangeHash() comm.Uint256

func (*OverlayDB) CommitTo

func (self *OverlayDB) CommitTo()

func (*OverlayDB) Delete

func (self *OverlayDB) Delete(key []byte)

func (*OverlayDB) Error

func (self *OverlayDB) Error() error

func (*OverlayDB) Get

func (self *OverlayDB) Get(key []byte) (value []byte, err error)

if key is deleted, value == nil

func (*OverlayDB) GetWriteSet added in v1.6.0

func (self *OverlayDB) GetWriteSet() *MemDB

func (*OverlayDB) NewIterator

func (self *OverlayDB) NewIterator(key []byte) common.StoreIterator

param key is referenced by iterator

func (*OverlayDB) Put

func (self *OverlayDB) Put(key []byte, value []byte)

func (*OverlayDB) Reset

func (self *OverlayDB) Reset()

func (*OverlayDB) SetError

func (self *OverlayDB) SetError(err error)

Jump to

Keyboard shortcuts

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