Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CDB ¶
type CDB struct {
Hasher
}
CDB is an associative array: it maps strings (“keys”) to strings (“data”).
func (*CDB) GetWriter ¶
func (cdb *CDB) GetWriter(writer io.WriteSeeker) (Writer, error)
GetWriter returns new Writer object.
func (*CDB) SetHash ¶
SetHash tells cdb to use given hash function for calculations. Given hash will be used only for new instances of Reader, Writer, i.e.
h := cdb.New() h.GetWriter(f) ... do some work ( here we use default Hasher ) h.SetHash(fnv.Hash32) h.GetReader(f) - only new instances will be use fnv.Hash32
type Iterator ¶
type Iterator interface {
// Next moves iterator to the next record. Returns true on success otherwise false.
Next() (bool, error)
// Record returns record on which points given iterator.
Record() Record
// HasNext tells can iterator be moved to the next record.
HasNext() bool
}
Iterator provides API for walking through database's records. Do not share object between multiple goroutines.
type Reader ¶
type Reader interface {
// Get returns first value associated with given key or returns nil if there is no associations.
Get(key []byte) ([]byte, error)
// Has returns true if given key exists, otherwise returns false.
Has(key []byte) (bool, error)
// Iterator returns new Iterator object that points on first record.
Iterator() (Iterator, error)
// IteratorAt returns new Iterator object that points on first record associated with given key.
IteratorAt(key []byte) (Iterator, error)
// Size returns the size of the dataset
Size() int
}
Reader provides API for getting values by given keys. All methods are thread safe.
type Record ¶
type Record interface {
// Key returns io.Reader with given record's key and key size.
Key() (io.Reader, uint32)
// Value returns io.Reader with given record's value and value size.
Value() (io.Reader, uint32)
}
Record provides API for reading record key, value. Do not share object between multiple goroutines.