database

package
v0.0.0-...-e0ee87b Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2021 License: MIT Imports: 21 Imported by: 3

Documentation

Index

Constants

View Source
const (
	INSERT = undoOperatorType(0)
	REMOVE = undoOperatorType(1)
	MODIFY = undoOperatorType(2)
)
View Source
const (
	MAX_NUM_ARRAY_ELEMENT   = int(1024 * 1024)
	MAX_SIZE_OF_BYTE_ARRAYS = int(20 * 1024 * 1024)
)

Variables

View Source
var (
	ErrNoID = errors.New("database : missing struct tag id field")

	ErrBadType = errors.New("database : provided data must be a struct or a pointer to struct")

	ErrAlreadyExists = errors.New("database : already exists")

	ErrIdNoSort = errors.New("database : The id field cannot use great or less")

	ErrTagInvalid = errors.New("database : Invalid tag")

	ErrIncompleteStructure = errors.New("database : Incomplete structure")

	ErrStructPtrNeeded = errors.New("database : provided target must be a pointer to struct")

	ErrPtrNeeded = errors.New("database : provided target must be a pointer to a valid variable")

	ErrNotFound = errors.New("database not found")
)

Errors

View Source
var (
	EOL                 = errors.New("rlp: end of list")
	ErrUnPointer        = errors.New("rlp: interface given to Decode must be a pointer")
	ErrElemTooLarge     = errors.New("rlp: element is larger than containing list")
	ErrValueTooLarge    = errors.New("rlp: value size exceeds available input length")
	ErrVarIntBufferSize = errors.New("rlp: invalid buffer size")
)
View Source
var TypeSize = struct {
	Bool        int
	Byte        int
	UInt8       int
	Int8        int
	UInt16      int
	Int16       int
	UInt32      int
	Int32       int
	UInt        int
	Int         int
	UInt64      int
	Int64       int
	SHA256Bytes int
	PublicKey   int
	Signature   int
}{
	Bool:        1,
	Byte:        1,
	UInt8:       1,
	Int8:        1,
	UInt16:      2,
	Int16:       2,
	UInt32:      4,
	Int32:       4,
	UInt:        4,
	Int:         4,
	UInt64:      8,
	Int64:       8,
	SHA256Bytes: 32,
	PublicKey:   34,
	Signature:   66,
}

Functions

func Decode

func Decode(r io.Reader, val interface{}) error

func DecodeBytes

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

func Encode

func Encode(w io.Writer, val interface{}) error

func EncodeSize

func EncodeSize(val interface{}) (int, error)

func EncodeToBytes

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

func EncodeToReader

func EncodeToReader(val interface{}) (size int, r io.Reader, err error)

func LogObj

func LogObj(data interface{})

Types

type AccountName

type AccountName uint64

type ActionName

type ActionName uint64

type Carnivore

type Carnivore struct {
	Lion  int `multiIndex:"orderedUnique,less"`
	Tiger int `multiIndex:"orderedUnique,less"`
}

///////////////////////////////////////////////////// test struct ///////////////////////////////////////////

type DataBase

type DataBase interface {
	Close()

	Insert(in interface{}) error

	Find(tagName string, in interface{}, out interface{}, skip ...SkipSuffix) error

	Empty(begin, end, fieldName []byte) bool

	GetIndex(tagName string, in interface{}) (*MultiIndex, error)

	GetMutableIndex(tagName string, in interface{}) (*MultiIndex, error)

	Modify(data interface{}, fn interface{}) error

	Remove(data interface{}) error

	Undo()

	UndoAll()

	StartSession() *Session

	Commit(revision int64)

	SetRevision(revision int64)

	Revision() int64

	LowerBound(key, value, typeName []byte, in interface{}, skip ...SkipSuffix) (*DbIterator, error)

	UpperBound(key, value, typeName []byte, in interface{}, skip ...SkipSuffix) (*DbIterator, error)

	IteratorTo(begin, end, fieldName []byte, in interface{}, skip ...SkipSuffix) (*DbIterator, error)

	BeginIterator(begin, end, typeName []byte) (*DbIterator, error)

	Squash()

	EndIterator(begin, end, typeName []byte) (*DbIterator, error)
}

func NewDataBase

func NewDataBase(path string, flag ...bool) (DataBase, error)

type DbHouse

type DbHouse struct {
	Id        uint64    `multiIndex:"id,increment"`
	Area      uint64    `multiIndex:"orderedUnique,less"`
	Name      string    `multiIndex:"orderedUnique,less"`
	Carnivore Carnivore `multiIndex:"inline"`
}

type DbIterator

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

Do not use the functions in this file

func (*DbIterator) Begin

func (index *DbIterator) Begin() bool

func (*DbIterator) Data

func (index *DbIterator) Data(data interface{}) error

func (*DbIterator) End

func (index *DbIterator) End() bool

func (*DbIterator) First

func (index *DbIterator) First() bool

func (*DbIterator) Key

func (index *DbIterator) Key() []byte

func (*DbIterator) Last

func (index *DbIterator) Last() bool

func (*DbIterator) Next

func (index *DbIterator) Next() bool

func (*DbIterator) Prev

func (index *DbIterator) Prev() bool

func (*DbIterator) Release

func (index *DbIterator) Release()

func (*DbIterator) Seek

func (index *DbIterator) Seek(key []byte) bool

func (*DbIterator) Value

func (index *DbIterator) Value() []byte

type DbResourceLimitsObject

type DbResourceLimitsObject struct {
	ID        IdType      `multiIndex:"id,increment"`
	Pending   bool        `multiIndex:"byOwner,orderedUnique"`
	Owner     AccountName `multiIndex:"byOwner,orderedUnique"`
	NetWeight int64
	CpuWeight int64
	RamBytes  int64
}

type DbTableIdObject

type DbTableIdObject struct {
	ID    IdType      `multiIndex:"id,increment,byScope"`
	Code  AccountName `multiIndex:"orderedUnique,less"`
	Scope ScopeName   `multiIndex:"byTable,orderedUnique,less:byScope,orderedUnique,less"`
	Table TableName   `multiIndex:"byTable,orderedUnique,less"`
	Payer AccountName `multiIndex:"byScope,orderedUnique"`
	Count uint32
}

type IdType

type IdType int64

type Iterator

type Iterator interface {
	Data(data interface{}) error
	End() bool
	Begin() bool
	// contains filtered or unexported methods
}

Do not use the functions in this file

type LDataBase

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

func (*LDataBase) BeginIterator

func (ldb *LDataBase) BeginIterator(begin, end, typeName []byte) (*DbIterator, error)

func (*LDataBase) Close

func (ldb *LDataBase) Close()

func (*LDataBase) Commit

func (ldb *LDataBase) Commit(reversion int64)

func (*LDataBase) Empty

func (ldb *LDataBase) Empty(begin, end, fieldName []byte) bool

func (*LDataBase) EndIterator

func (ldb *LDataBase) EndIterator(begin, end, typeName []byte) (*DbIterator, error)

func (*LDataBase) Find

func (ldb *LDataBase) Find(tagName string, in interface{}, out interface{}, skip ...SkipSuffix) error

func (*LDataBase) GetIndex

func (ldb *LDataBase) GetIndex(tagName string, in interface{}) (*MultiIndex, error)

@param tagName --> tag in field tags @param in --> object

@return success --> iterator error --> error

func (*LDataBase) GetMutableIndex

func (ldb *LDataBase) GetMutableIndex(fieldName string, in interface{}) (*MultiIndex, error)

func (*LDataBase) Insert

func (ldb *LDataBase) Insert(in interface{}) error

func (*LDataBase) IteratorTo

func (ldb *LDataBase) IteratorTo(begin, end, fieldName []byte, data interface{}, skip ...SkipSuffix) (*DbIterator, error)

func (*LDataBase) LowerBound

func (ldb *LDataBase) LowerBound(begin, end, fieldName []byte, data interface{}, skip ...SkipSuffix) (*DbIterator, error)

func (*LDataBase) Modify

func (ldb *LDataBase) Modify(old interface{}, fn interface{}) error

func (*LDataBase) Remove

func (ldb *LDataBase) Remove(in interface{}) error

func (*LDataBase) Revision

func (ldb *LDataBase) Revision() int64

func (*LDataBase) SetRevision

func (ldb *LDataBase) SetRevision(reversion int64)

func (*LDataBase) Squash

func (ldb *LDataBase) Squash()

func (*LDataBase) StartSession

func (ldb *LDataBase) StartSession() *Session

func (*LDataBase) Undo

func (ldb *LDataBase) Undo()

func (*LDataBase) UndoAll

func (ldb *LDataBase) UndoAll()

func (*LDataBase) UpperBound

func (ldb *LDataBase) UpperBound(begin, end, fieldName []byte, data interface{}, skip ...SkipSuffix) (*DbIterator, error)

type MultiIndex

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

func (*MultiIndex) Begin

func (index *MultiIndex) Begin() Iterator

func (*MultiIndex) BeginData

func (index *MultiIndex) BeginData(out interface{}) error

func (*MultiIndex) CompareBegin

func (index *MultiIndex) CompareBegin(in Iterator) bool

func (*MultiIndex) CompareEnd

func (index *MultiIndex) CompareEnd(in Iterator) bool

func (*MultiIndex) CompareIterator

func (index *MultiIndex) CompareIterator(it1 Iterator, it2 Iterator) bool

func (*MultiIndex) Empty

func (index *MultiIndex) Empty() bool

func (*MultiIndex) End

func (index *MultiIndex) End() Iterator

func (*MultiIndex) Find

func (index *MultiIndex) Find(in interface{}, out interface{}, skip ...SkipSuffix) error

func (*MultiIndex) IteratorTo

func (index *MultiIndex) IteratorTo(in interface{}) Iterator

func (*MultiIndex) LowerBound

func (index *MultiIndex) LowerBound(in interface{}, skip ...SkipSuffix) (Iterator, error)

func (*MultiIndex) UpperBound

func (index *MultiIndex) UpperBound(in interface{}, skip ...SkipSuffix) (Iterator, error)

type Name

type Name uint64

type Pack

type Pack interface {
	EncodeRLP(io.Writer) error
}

type PermissionName

type PermissionName uint64

type ScopeName

type ScopeName uint64

type Session

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

///////////////////////////////////////////////////// Session //////////////////////////////////////////////////////////

func (*Session) Push

func (session *Session) Push()

func (*Session) Revision

func (session *Session) Revision() int64

func (*Session) Squash

func (session *Session) Squash()

func (*Session) Undo

func (session *Session) Undo()

type SkipSuffix

type SkipSuffix int
const (
	SKIP_ONE SkipSuffix
	SKIP_TWO
)

type TableName

type TableName uint64

Jump to

Keyboard shortcuts

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