goldb

package module
v0.0.0-...-2f59ada Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 19 Imported by: 1

README

goldb

Go LevelDB

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Break = errors.New("break of fetching")

Functions

func Key

func Key(entityID Entity, vv ...interface{}) []byte

func PrimaryKey

func PrimaryKey(tableID Entity, id uint64) []byte

Types

type DBDecoder

type DBDecoder interface {
	DBDecode([]byte) error
}

type DBEncoder

type DBEncoder interface {
	DBEncode() []byte
}

type DumpOptions

type DumpOptions struct {
	Filter           *Query
	CompressionLevel int // 0-9 (0 - no compression; 9 - by default)
}

type Entity

type Entity int

type Query

type Query struct {

	// results
	NumRows uint64
	// contains filtered or unexported fields
}

func NewQuery

func NewQuery(idxID Entity, filterVal ...interface{}) *Query

func (*Query) AddFilter

func (q *Query) AddFilter(filterVal ...interface{}) *Query

func (*Query) CurrentOffset

func (q *Query) CurrentOffset() []byte

func (*Query) FilterFn

func (q *Query) FilterFn(fn func(Record) bool) *Query

func (*Query) First

func (q *Query) First() *Query

func (*Query) Last

func (q *Query) Last() *Query

func (*Query) Limit

func (q *Query) Limit(limit int64) *Query

func (*Query) Offset

func (q *Query) Offset(offset ...interface{}) *Query

func (*Query) Order

func (q *Query) Order(desc bool) *Query

func (*Query) OrderAsk

func (q *Query) OrderAsk() *Query

func (*Query) OrderDesc

func (q *Query) OrderDesc() *Query

func (*Query) String

func (q *Query) String() string

type Record

type Record struct {
	Key   []byte
	Value []byte
}

func NewRecord

func NewRecord(key []byte, v interface{}) Record

func (Record) Decode

func (r Record) Decode(v interface{}) error

func (Record) DecodeKey

func (r Record) DecodeKey(vv ...interface{}) (err error)

func (Record) KeyOffset

func (r Record) KeyOffset(q *Query) []byte

func (Record) MustDecode

func (r Record) MustDecode(v interface{})

------ value --------------

func (Record) MustDecodeKey

func (r Record) MustDecodeKey(vv ...interface{})

func (Record) RowID

func (r Record) RowID() (id uint64)

func (Record) String

func (r Record) String() string

func (Record) Table

func (r Record) Table() Entity

------- key ---------

func (Record) ValueBigInt

func (r Record) ValueBigInt() (v *big.Int)

func (Record) ValueID

func (r Record) ValueID() (id uint64)

func (Record) ValueInt

func (r Record) ValueInt() (v int64)

func (Record) ValueStr

func (r Record) ValueStr() (v string)

type Storage

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

func NewStorage

func NewStorage(dir string, op *opt.Options) (s *Storage)

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) CountReads

func (c *Storage) CountReads() int64

CountReads returns number of waiting reads

func (*Storage) Delete

func (s *Storage) Delete(key []byte) error

func (*Storage) Drop

func (s *Storage) Drop() error

func (*Storage) Dump

func (s *Storage) Dump(filepath string, options *DumpOptions) (err error)

func (*Storage) Exec

func (s *Storage) Exec(fn func(tx *Transaction)) (err error)

Exec executes transaction. The executing transaction can be discard by methods tx.Fail(err) or by panic(err)

func (*Storage) ExecBatch

func (s *Storage) ExecBatch(fn func(tx *Transaction)) error

func (*Storage) Exists

func (c *Storage) Exists(q *Query) (ok bool, err error)

Exists returns true when exists results by query

func (*Storage) Fetch

func (c *Storage) Fetch(q *Query, fnRecord func(rec Record) error) error

Fetch fetches data by query

func (*Storage) FetchID

func (c *Storage) FetchID(q *Query, fnRow func(id uint64) error) error

FetchID fetches uint64-ID by query

func (*Storage) Get

func (c *Storage) Get(key []byte) ([]byte, error)

Get returns raw data by key

func (*Storage) GetBigInt

func (c *Storage) GetBigInt(key []byte) (num *big.Int, err error)

GetBigInt returns bigint-number by key

func (*Storage) GetID

func (c *Storage) GetID(key []byte) (v uint64, err error)

GetID returns uint64-data by key

func (*Storage) GetInt

func (c *Storage) GetInt(key []byte) (num int64, err error)

GetInt returns uint64-data by key

func (*Storage) GetNumRows

func (c *Storage) GetNumRows(q *Query) (numRows uint64, err error)

GetNumRows fetches data by query and calculates count rows

func (*Storage) GetStr

func (c *Storage) GetStr(key []byte) (s string, err error)

GetStr returns string-data by key

func (*Storage) GetVar

func (c *Storage) GetVar(key []byte, v interface{}) (bool, error)

GetVar get data by key and unmarshal to to variable; Returns true when data by key existed

func (*Storage) LastRowID

func (c *Storage) LastRowID(tableID Entity) (rowID uint64, err error)

LastRowID returns rowID of last record in table

func (*Storage) Open

func (s *Storage) Open() error

func (*Storage) Put

func (s *Storage) Put(key, data []byte) error

func (*Storage) PutID

func (s *Storage) PutID(key []byte, id uint64) error

func (*Storage) PutInt

func (s *Storage) PutInt(key []byte, num int64) error

func (*Storage) PutVar

func (s *Storage) PutVar(key []byte, v interface{}) error

func (*Storage) QueryID

func (c *Storage) QueryID(q *Query) (id uint64, err error)

QueryID returns first row-id by query

func (*Storage) QueryIDs

func (c *Storage) QueryIDs(q *Query) (ids []uint64, err error)

QueryIDs returns slice of row-id by query

func (*Storage) QueryValue

func (c *Storage) QueryValue(q *Query, v interface{}) error

QueryValue returns first row-value by query

func (*Storage) Recover

func (s *Storage) Recover() error

func (*Storage) RemoveByQuery

func (s *Storage) RemoveByQuery(q *Query) error

func (*Storage) Restore

func (s *Storage) Restore(filepath string) (err error)

func (*Storage) Size

func (s *Storage) Size() (size int64)

func (*Storage) Truncate

func (s *Storage) Truncate() error

func (*Storage) Vacuum

func (s *Storage) Vacuum() (err error)

func (*Storage) WaitingTransactions

func (s *Storage) WaitingTransactions() int64

type Transaction

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

func (*Transaction) Commit

func (t *Transaction) Commit() error

func (*Transaction) CountReads

func (c *Transaction) CountReads() int64

CountReads returns number of waiting reads

func (*Transaction) CountUpdates

func (t *Transaction) CountUpdates() int64

func (*Transaction) Delete

func (t *Transaction) Delete(key []byte) error

func (*Transaction) Discard

func (t *Transaction) Discard()

func (*Transaction) Exists

func (c *Transaction) Exists(q *Query) (ok bool, err error)

Exists returns true when exists results by query

func (*Transaction) Fail

func (t *Transaction) Fail(err error)

func (*Transaction) Fetch

func (c *Transaction) Fetch(q *Query, fnRecord func(rec Record) error) error

Fetch fetches data by query

func (*Transaction) FetchID

func (c *Transaction) FetchID(q *Query, fnRow func(id uint64) error) error

FetchID fetches uint64-ID by query

func (*Transaction) Get

func (c *Transaction) Get(key []byte) ([]byte, error)

Get returns raw data by key

func (*Transaction) GetBigInt

func (c *Transaction) GetBigInt(key []byte) (num *big.Int, err error)

GetBigInt returns bigint-number by key

func (*Transaction) GetID

func (c *Transaction) GetID(key []byte) (v uint64, err error)

GetID returns uint64-data by key

func (*Transaction) GetInt

func (c *Transaction) GetInt(key []byte) (num int64, err error)

GetInt returns uint64-data by key

func (*Transaction) GetNumRows

func (c *Transaction) GetNumRows(q *Query) (numRows uint64, err error)

GetNumRows fetches data by query and calculates count rows

func (*Transaction) GetStr

func (c *Transaction) GetStr(key []byte) (s string, err error)

GetStr returns string-data by key

func (*Transaction) GetVar

func (c *Transaction) GetVar(key []byte, v interface{}) (bool, error)

GetVar get data by key and unmarshal to to variable; Returns true when data by key existed

func (*Transaction) Increment

func (t *Transaction) Increment(key []byte, delta int64) (v int64)

Increment increments int-value by key

func (*Transaction) IncrementBig

func (t *Transaction) IncrementBig(key []byte, delta *big.Int) *big.Int

func (*Transaction) LastRowID

func (c *Transaction) LastRowID(tableID Entity) (rowID uint64, err error)

LastRowID returns rowID of last record in table

func (*Transaction) Put

func (t *Transaction) Put(key, data []byte) error

func (*Transaction) PutID

func (t *Transaction) PutID(key []byte, id uint64) error

func (*Transaction) PutInt

func (t *Transaction) PutInt(key []byte, num int64) error

func (*Transaction) PutVar

func (t *Transaction) PutVar(key []byte, v interface{}) error

func (*Transaction) QueryID

func (c *Transaction) QueryID(q *Query) (id uint64, err error)

QueryID returns first row-id by query

func (*Transaction) QueryIDs

func (c *Transaction) QueryIDs(q *Query) (ids []uint64, err error)

QueryIDs returns slice of row-id by query

func (*Transaction) QueryValue

func (c *Transaction) QueryValue(q *Query, v interface{}) error

QueryValue returns first row-value by query

func (*Transaction) SequenceCurVal

func (t *Transaction) SequenceCurVal(tab Entity) (seq uint64)

func (*Transaction) SequenceNextVal

func (t *Transaction) SequenceNextVal(tab Entity) (seq uint64)

Jump to

Keyboard shortcuts

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