Documentation ¶
Overview ¶
Package coqdb implements an embedded key-value store for read-heavy workloads.
Index ¶
- Constants
- Variables
- func NewSegmentIterator(f *segment) (*segmentIterator, error)
- func OpenDatalog(opts *Options) (*datalog, error)
- func SetLogger(l *log.Logger)
- type CompactionResult
- type DB
- func (db *DB) Close() error
- func (db *DB) Compact() (CompactionResult, error)
- func (db *DB) Count() uint32
- func (db *DB) Delete(key []byte, wo *WriteOption) error
- func (db *DB) FileSize() (int64, error)
- func (db *DB) Get(key []byte, ro *ReadOption) ([]byte, error)
- func (db *DB) Has(key []byte, ro *ReadOption) (bool, error)
- func (db *DB) Items() *ItemIterator
- func (db *DB) Metrics() *Metrics
- func (db *DB) Put(key []byte, value []byte, wo *WriteOption) error
- func (db *DB) Sync() error
- type ItemIterator
- type Metrics
- type Options
- type ReadOption
- type Record
- type RecordType
- type WriteOption
Constants ¶
const ( // MaxKeyLength is the maximum size of a key in bytes. MaxKeyLength = math.MaxUint16 // MaxValueLength is the maximum size of a value in bytes. MaxValueLength = 512 << 20 // 512 MiB // MaxKeys is the maximum numbers of keys in the DB. MaxKeys = math.MaxUint32 )
Variables ¶
var ( // ErrIterationDone is returned by ItemIterator.Next calls when there are no more items to return. ErrIterationDone = errors.New("no more items in iterator") ErrNotFound = errors.New("not found") ErrNotSupportIter = errors.New("not support b iter because of not set BtreeIndex option") )
Functions ¶
func NewSegmentIterator ¶ added in v0.0.2
func NewSegmentIterator(f *segment) (*segmentIterator, error)
func OpenDatalog ¶ added in v0.0.2
Types ¶
type CompactionResult ¶
CompactionResult holds the compaction result.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB represents the key-value storage. All DB methods are safe for concurrent use by multiple goroutines.
func Open ¶
Open opens or creates a new DB. The DB must be closed after use, by calling Close method.
func (*DB) Compact ¶
func (db *DB) Compact() (CompactionResult, error)
Compact compacts the DB. Deleted and overwritten items are discarded. Returns an error if compaction is already in progress.
func (*DB) Delete ¶
func (db *DB) Delete(key []byte, wo *WriteOption) error
Delete deletes the given key from the DB.
func (*DB) Get ¶
func (db *DB) Get(key []byte, ro *ReadOption) ([]byte, error)
Get returns the value for the given key stored in the DB or nil if the key doesn't exist.
func (*DB) Has ¶
func (db *DB) Has(key []byte, ro *ReadOption) (bool, error)
Has returns true if the DB contains the given key.
type ItemIterator ¶
type ItemIterator struct {
// contains filtered or unexported fields
}
ItemIterator is an iterator over DB key-value pairs. It iterates the items in an unspecified order.
type Options ¶
type Options struct { // BackgroundSyncInterval sets the amount of time between background Sync() calls. // // Setting the value to 0 disables the automatic background synchronization. // Setting the value to -1 makes the DB call Sync() after every write operation. BackgroundSyncInterval time.Duration // BackgroundCompactionInterval sets the amount of time between background Compact() calls. // // Setting the value to 0 disables the automatic background compaction. BackgroundCompactionInterval time.Duration // FileSystem sets the file system implementation. // // Default: fs.OSMMap. FileSystem fs.FileSystem // contains filtered or unexported fields }
Options holds the optional DB parameters.
type ReadOption ¶
type ReadOption struct { }
type Record ¶ added in v0.0.2
type Record struct {
// contains filtered or unexported fields
}
Binary representation of a segment Record: +---------------+------------------+------------------+-...-+--...--+----------+ | Key Size (2B) | Record Type (1b) | Value Size (31b) | Key | Value | CRC (4B) | +---------------+------------------+------------------+-...-+--...--+----------+
func (*Record) Type ¶ added in v0.0.2
func (r *Record) Type() RecordType
type RecordType ¶ added in v0.0.2
type RecordType int
const ( RecordTypePut RecordType = iota RecordTypeDelete )
type WriteOption ¶
type WriteOption struct {
Repeat bool // if true , key exists, then append , not override
}