Documentation
¶
Index ¶
- Variables
- func IsValidDatabase(path string) error
- func KeyValueCompare(a KeyValue, b KeyValue) int
- func Remove(path string) error
- type Database
- func (db *Database) Close() error
- func (db *Database) CloseWithMerge(segmentCount int) error
- func (db *Database) Get(key []byte) (value []byte, err error)
- func (db *Database) Lookup(lower []byte, upper []byte) (LookupIterator, error)
- func (db *Database) Put(key []byte, value []byte) error
- func (db *Database) Remove(key []byte) ([]byte, error)
- func (db *Database) Write(wb WriteBatch) error
- type Deleter
- type KeyValue
- type LookupIterator
- type Options
- type SkipList
- type WriteBatch
Constants ¶
This section is empty.
Variables ¶
var DatabaseClosed = errors.New("database closed")
var DatabaseCorrupted = errors.New("database corrupted, run repair")
var DatabaseInUse = errors.New("database in use")
var EmptyKey = errors.New("key is empty")
var EndOfIterator = errors.New("end of iterator")
var KeyNotFound = errors.New("key not found")
var KeyTooLong = errors.New("key too long, max 1024")
var NoDatabaseFound = errors.New("no database found")
var NotADirectory = errors.New("path is not a directory")
var NotValidDatabase = errors.New("path is not a valid database")
var ReadOnlySegment = errors.New("read only segment")
Functions ¶
func IsValidDatabase ¶
IsValidDatabase checks if the path points to a valid database or empty directory (which is also valid)
func KeyValueCompare ¶
Types ¶
type Database ¶
Database reference is obtained via Open()
func Open ¶
Open a database. The database can only be opened by a single process, but the *Database reference can be shared across Go routines. The path is a directory name. if createIfNeeded is true, them if the db doesn't exist it will be created.
func (*Database) Close ¶
Close the database. any memory segments are persisted to disk. The resulting segments are merged until the default maxSegments is reached
func (*Database) CloseWithMerge ¶
CloseWithMerge closes the database with control of the segment count. if segmentCount is 0, then the merge process is skipped
func (*Database) Get ¶
Get a value for a key, error is non-nil if the key was not found or an error occurred
func (*Database) Lookup ¶
func (db *Database) Lookup(lower []byte, upper []byte) (LookupIterator, error)
Lookup finds matching record between lower and upper inclusive. lower or upper can be nil and then the range is unbounded on that side. Using the iterator after the transaction has been Commit/Rollback is not supported.
func (*Database) Put ¶
Put a key/value pair into the table, overwriting any existing entry. empty keys are not supported.
func (*Database) Write ¶
func (db *Database) Write(wb WriteBatch) error
type LookupIterator ¶
type LookupIterator interface { // Next returns EndOfIterator when complete, if err is nil, then key and value are valid Next() (key []byte, value []byte, err error) // contains filtered or unexported methods }
LookupIterator iterator interface for table scanning. all iterators should be read until completion
type SkipList ¶
type SkipList[K any] struct { // contains filtered or unexported fields }
func NewSkipList ¶
type WriteBatch ¶
type WriteBatch struct {
// contains filtered or unexported fields
}
func (*WriteBatch) Put ¶
func (wb *WriteBatch) Put(key []byte, value []byte)
func (*WriteBatch) Remove ¶
func (wb *WriteBatch) Remove(key []byte)