ebakusdb

package module
v0.0.0-...-727f157 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: MIT Imports: 19 Imported by: 14

README

EbakusDB

Each smart contract in ebakus has its own schema defined database (ESDD). This database can support any number of tables with typed fields and indexes. A smart contract is able to perform the following operations on the data:

Create/Drop tables Create/Drop indexes on specific fields Retrieve/update/delete single or multiple rows of data Do ordered range queries on these data The ebakus software makes sure that the data are stored in such a way in order to support the above operations in the most efficient way. The smart contract should not need to implement most common query types by itself.

The EbakusDB layer is providing to the ebakus blockchain a very fast database layer that supports O(1) time and space complexity snapshots. This is essential to the operation of a blockchain system that has requirements for querying old block states. The database achieves high performance by being aware of the transactional log functionality that the layer above it is using and not reimplementing it itself. Therefore achieving ACID compliance without sacrificing performance.

Smart contracts deployed in Ethereum compatibility mode will not be able to make use of the ESDD, hence will not be able to benefit from the extra functionality and performance.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFailedToCreateDB = errors.New("Failed to create database")
	ErrDirtyDB          = errors.New("Dirty database found")
)
View Source
var DefaultOptions = &Options{
	ReadOnly: false,
}

DefaultOptions for the DB

View Source
var (
	ErrInvalidSize = errors.New("Input data size is invalid")
)

Functions

func GetNodeCount

func GetNodeCount() int64

Types

type ByteArray

type ByteArray struct {
	Offset uint64
	Size   uint32
}

func (*ByteArray) Release

func (b *ByteArray) Release(mm balloc.MemoryManager)

func (*ByteArray) Retain

func (b *ByteArray) Retain(mm balloc.MemoryManager)

type ComparisonFunction

type ComparisonFunction = func(arg1, arg2 reflect.Value) (bool, error)

type DB

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

func Open

func Open(path string, mode os.FileMode, options *Options) (*DB, error)

func OpenInMemory

func OpenInMemory(options *Options) (*DB, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) Commit

func (db *DB) Commit(txn *Txn) error

func (*DB) CreateIndex

func (db *DB) CreateIndex(index IndexField) error

func (*DB) CreateTable

func (db *DB) CreateTable(table string, obj interface{}) error

func (*DB) Get

func (db *DB) Get(k []byte) (*[]byte, bool)

func (*DB) GetInfo

func (db *DB) GetInfo() DBInfo

func (*DB) GetPath

func (db *DB) GetPath() string

func (*DB) GetRootSnapshot

func (db *DB) GetRootSnapshot() *Snapshot

func (*DB) Grow

func (db *DB) Grow() error

func (*DB) HasTable

func (db *DB) HasTable(table string) bool

func (*DB) Iter

func (db *DB) Iter() *Iterator

func (*DB) PrintFreeChunks

func (db *DB) PrintFreeChunks()

func (*DB) PrintTree

func (db *DB) PrintTree()

func (*DB) SetCustomEncoder

func (db *DB) SetCustomEncoder(encode DBEncoder, decode DBDecoder)

func (*DB) SetRootSnapshot

func (db *DB) SetRootSnapshot(s *Snapshot)

func (*DB) Snapshot

func (db *DB) Snapshot(id uint64) *Snapshot

type DBDecoder

type DBDecoder func(b []byte, val interface{}) error

type DBEncoder

type DBEncoder func(val interface{}) ([]byte, error)

type DBInfo

type DBInfo struct {
	Path          string
	BufferStart   uint32
	PageSize      uint16
	Watermark     uint64
	TotalUsed     uint64
	TotalCapacity uint64
}

type IndexField

type IndexField struct {
	Table string
	Field string
}

type Iterator

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

func (*Iterator) Next

func (i *Iterator) Next() ([]byte, []byte, bool)

func (*Iterator) Prev

func (i *Iterator) Prev() ([]byte, []byte, bool)

func (*Iterator) Release

func (i *Iterator) Release()

func (*Iterator) SeekPrefix

func (i *Iterator) SeekPrefix(prefix []byte)

type Node

type Node struct {
	RefCountedObject
	// contains filtered or unexported fields
}

func (*Node) Get

func (n *Node) Get(db *DB, k []byte) (*[]byte, bool)

func (*Node) LongestPrefix

func (n *Node) LongestPrefix(db *DB, k []byte) ([]byte, interface{}, bool)

type Options

type Options struct {
	// Open database in read-only mode.
	ReadOnly bool
}

type OrderCondition

type OrderCondition int
const (
	ASC OrderCondition = iota
	DESC
)

type OrderField

type OrderField struct {
	Field string
	Order OrderCondition
}

type Ptr

type Ptr uint64

func (*Ptr) NodeRelease

func (nPtr *Ptr) NodeRelease(mm balloc.MemoryManager) bool

func (*Ptr) NodeRetain

func (p *Ptr) NodeRetain(mm balloc.MemoryManager) bool

type RefCounted

type RefCounted interface {
	Retain()
	Release() bool
	GetRefCount() int
}

type RefCountedObject

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

func (*RefCountedObject) Retain

func (p *RefCountedObject) Retain()

type ResultIterator

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

func (*ResultIterator) Next

func (ri *ResultIterator) Next(val interface{}) bool

func (*ResultIterator) Release

func (ri *ResultIterator) Release()

type Snapshot

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

func (*Snapshot) CreateIndex

func (s *Snapshot) CreateIndex(index IndexField) error

func (*Snapshot) CreateTable

func (s *Snapshot) CreateTable(table string, obj interface{}) error

func (*Snapshot) Delete

func (s *Snapshot) Delete(k []byte) bool

func (*Snapshot) DeleteObj

func (s *Snapshot) DeleteObj(table string, id interface{}) error

func (*Snapshot) Get

func (s *Snapshot) Get(k []byte) (*[]byte, bool)

func (*Snapshot) GetFreeMemory

func (s *Snapshot) GetFreeMemory() uint64

func (*Snapshot) GetId

func (s *Snapshot) GetId() uint64

func (*Snapshot) GetObjAllocated

func (s *Snapshot) GetObjAllocated() int64

func (*Snapshot) GetUsedMemory

func (s *Snapshot) GetUsedMemory() uint64

func (*Snapshot) HasTable

func (s *Snapshot) HasTable(table string) bool

func (*Snapshot) Insert

func (s *Snapshot) Insert(k, v []byte) (*[]byte, bool)

func (*Snapshot) InsertObj

func (s *Snapshot) InsertObj(table string, obj interface{}) error

func (*Snapshot) InsertWithNode

func (s *Snapshot) InsertWithNode(k, v []byte, vp Ptr) (*[]byte, bool)

func (*Snapshot) Iter

func (s *Snapshot) Iter() *Iterator

func (*Snapshot) OrderParser

func (s *Snapshot) OrderParser(input []byte) (*OrderField, error)

func (*Snapshot) PrintTree

func (s *Snapshot) PrintTree()

func (*Snapshot) Release

func (s *Snapshot) Release()

func (*Snapshot) ResetObjAllocated

func (s *Snapshot) ResetObjAllocated()

func (*Snapshot) ResetTo

func (s *Snapshot) ResetTo(to *Snapshot)

func (*Snapshot) Root

func (s *Snapshot) Root() *Ptr

func (*Snapshot) RootNode

func (s *Snapshot) RootNode() *Node

func (*Snapshot) Select

func (s *Snapshot) Select(table string, args ...interface{}) (*ResultIterator, error)

func (*Snapshot) Snapshot

func (s *Snapshot) Snapshot() *Snapshot

func (*Snapshot) WhereParser

func (s *Snapshot) WhereParser(input []byte) (*WhereField, error)

type Table

type Table struct {
	Indexes []string
	Node    Ptr
	Schema  string
}

type Tokenizer

type Tokenizer interface {
	Tokenize(content []byte) [][]byte
}

Tokenizer interface

func NewTokenizer

func NewTokenizer(seps []string) Tokenizer

New Tokenizer

type Txn

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

func (*Txn) Commit

func (t *Txn) Commit() (uint64, error)

func (*Txn) Delete

func (t *Txn) Delete(k []byte) bool

func (*Txn) Get

func (t *Txn) Get(k []byte) (*[]byte, bool)

Get returns the key

func (*Txn) Insert

func (t *Txn) Insert(k, v []byte) (*[]byte, bool)

func (*Txn) Rollback

func (t *Txn) Rollback()

func (*Txn) Root

func (t *Txn) Root() *Ptr

func (*Txn) RootNode

func (t *Txn) RootNode() *Node

type WhereCondition

type WhereCondition int
const (
	Equal WhereCondition = iota
	NotEqual
	Smaller
	SmallerOrEqual
	Larger
	LargerOrEqual
	Like
)

type WhereField

type WhereField struct {
	Field     string
	Condition WhereCondition
	Value     []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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