dao

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyValue

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

KeyValue LevelDB uses key-value struct

func CopyKeyValue

func CopyKeyValue(key []byte, value []byte) KeyValue

CopyKeyValue clone and return enw KeyValue

func NewKeyValue

func NewKeyValue(key []byte, value []byte) KeyValue

NewKeyValue new KeyValue

type KeyValueDAO

type KeyValueDAO interface {
	Put(record KeyValue) error
	BatchPut(records []KeyValue) error
	BatchDelete(keys [][]byte) error
	DeleteByKey(key []byte) error
	FindByKeyPrefix(prefix []byte, asc bool, rows int, start int) (int, []KeyValue)
	CountByKeyPrefix(prefix []byte) int
	FindByRange(rg *util.Range, asc bool, rows int, start int) (int, []KeyValue)
	CountByRange(rg *util.Range) int
	FindByKey(key []byte) (*KeyValue, error)
	GetNFirstRecords(n int) []KeyValue
	GetNLastRecords(n int) []KeyValue
	GetNFirstPredicate(pre Predicate) []KeyValue
	GetAllRecords() []KeyValue
}

KeyValueDAO generic DAO interface for the indexer

type LevelDbDAO

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

LevelDbDAO a dao implementation using leveldb

func NewLevelDbDAO

func NewLevelDbDAO(db *leveldb.DB) LevelDbDAO

NewLevelDbDAO New instance of LevelDbDAO struct

func (LevelDbDAO) BatchDelete

func (ld LevelDbDAO) BatchDelete(keys [][]byte) error

BatchDelete delete by key array

func (LevelDbDAO) BatchPut

func (ld LevelDbDAO) BatchPut(records []KeyValue) error

BatchPut put an array in batch

func (LevelDbDAO) CountByKeyPrefix added in v1.0.0

func (ld LevelDbDAO) CountByKeyPrefix(prefix []byte) int

CountByKeyPrefix count by a key prefix

func (LevelDbDAO) CountByRange added in v1.0.0

func (ld LevelDbDAO) CountByRange(rg *util.Range) int

CountByRange count total of items

func (LevelDbDAO) DeleteByKey

func (ld LevelDbDAO) DeleteByKey(key []byte) error

DeleteByKey delete by a key

func (LevelDbDAO) FindByKey

func (ld LevelDbDAO) FindByKey(key []byte) (*KeyValue, error)

FindByKey find by a key

func (LevelDbDAO) FindByKeyPrefix

func (ld LevelDbDAO) FindByKeyPrefix(prefix []byte, asc bool, rows int, start int) (int, []KeyValue)

FindByKeyPrefix find by a key prefix

func (LevelDbDAO) FindByRange

func (ld LevelDbDAO) FindByRange(rg *util.Range, asc bool, rows int, start int) (int, []KeyValue)

FindByRange find by a range

func (LevelDbDAO) GetAllRecords

func (ld LevelDbDAO) GetAllRecords() []KeyValue

GetAllRecords get all records

func (LevelDbDAO) GetNFirstPredicate

func (ld LevelDbDAO) GetNFirstPredicate(prep Predicate) []KeyValue

GetNFirstPredicate go from first record until predicate evaluation is false

func (LevelDbDAO) GetNFirstRecords

func (ld LevelDbDAO) GetNFirstRecords(n int) []KeyValue

GetNFirstRecords get n first records

func (LevelDbDAO) GetNLastRecords

func (ld LevelDbDAO) GetNLastRecords(n int) []KeyValue

GetNLastRecords get n last records

func (LevelDbDAO) Put

func (ld LevelDbDAO) Put(record KeyValue) error

Put put a single KeyValue

type MemDbDAO

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

MemDbDAO an in-memory dao implementation using memdb package of leveldb

func NewMemDbDAO

func NewMemDbDAO(db *memdb.DB) MemDbDAO

NewMemDbDAO new memdb dao instance

func (MemDbDAO) BatchDelete

func (md MemDbDAO) BatchDelete(keys [][]byte) error

BatchDelete implement interface

func (MemDbDAO) BatchPut

func (md MemDbDAO) BatchPut(records []KeyValue) error

BatchPut implement interface

func (MemDbDAO) CountByKeyPrefix added in v1.0.0

func (md MemDbDAO) CountByKeyPrefix(prefix []byte) int

CountByKeyPrefix count by key prefix

func (MemDbDAO) CountByRange added in v1.0.0

func (md MemDbDAO) CountByRange(rg *util.Range) int

CountByRange count total of items

func (MemDbDAO) DeleteByKey

func (md MemDbDAO) DeleteByKey(key []byte) error

DeleteByKey implement interface

func (MemDbDAO) FindByKey

func (md MemDbDAO) FindByKey(key []byte) (*KeyValue, error)

FindByKey implement interface

func (MemDbDAO) FindByKeyPrefix

func (md MemDbDAO) FindByKeyPrefix(prefix []byte, asc bool, rows int, start int) (int, []KeyValue)

FindByKeyPrefix implement interface

func (MemDbDAO) FindByRange

func (md MemDbDAO) FindByRange(rg *util.Range, asc bool, rows int, start int) (int, []KeyValue)

FindByRange find by a range

func (MemDbDAO) GetAllRecords

func (md MemDbDAO) GetAllRecords() []KeyValue

GetAllRecords implement interface

func (MemDbDAO) GetNFirstPredicate

func (md MemDbDAO) GetNFirstPredicate(prep Predicate) []KeyValue

GetNFirstPredicate go from first record until predicate evaluation is false

func (MemDbDAO) GetNFirstRecords

func (md MemDbDAO) GetNFirstRecords(n int) []KeyValue

GetNFirstRecords implement interface

func (MemDbDAO) GetNLastRecords

func (md MemDbDAO) GetNLastRecords(n int) []KeyValue

GetNLastRecords implement interface

func (MemDbDAO) Put

func (md MemDbDAO) Put(record KeyValue) error

Put implement interface

type Predicate

type Predicate func(KeyValue) bool

Predicate predicate

Jump to

Keyboard shortcuts

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