Documentation
¶
Index ¶
- Constants
- type Cursor
- func (cursor *Cursor) Del() (e error)
- func (cursor *Cursor) Get(key []byte) (value []byte, e error)
- func (cursor *Cursor) GetFirst() (key, value []byte, e error)
- func (cursor *Cursor) GetLast() (key, value []byte, e error)
- func (cursor *Cursor) GetNext() (key, value []byte, e error)
- func (cursor *Cursor) GetPrev() (key, value []byte, e error)
- func (cursor *Cursor) Put(key, value []byte) (e error)
- func (cursor *Cursor) ToLinkCursor() *linkCursor
- type Medium
Constants ¶
const ( MaxKeyLength = node.MaxKeyLength MaxValueLength = math.MaxUint32 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
A Cursor enables storage, retrieval, destruction of, and bidirectional iteration over key-value mappings in a keyspace via its methods. Out of the box, it is not safe for concurrent use; an application intending to do so should implement its own means of ensuring mutual exclusion.
func NewCursor ¶
NewCursor is a low-level constructor used by *github.com/voidDB/voidDB.Txn.OpenCursor and *github.com/voidDB/voidDB.Void.BeginTxn.
func (*Cursor) Del ¶
Del deletes the key-value record indexed by the cursor. To delete a record by key, position the cursor with *Cursor.Get beforehand.
func (*Cursor) Get ¶
Get retrieves the value corresponding to key and positions the cursor at the record found.
CAUTION: The value returned is immutable and valid only during the lifetime of the transaction to which the cursor belongs, since the slice merely reflects the relevant section of the memory map containing the value. Hence, any attempt at mutating the slice at any time or accessing it after the transaction has been committed/aborted will result in a fatal syscall.SIGSEGV. (See also runtime/debug.SetPanicOnFault.) Instead, applications should allocate a slice of size equal to len(value) and copy value into the new slice for modification/retention. This also applies to *Cursor.GetFirst, *Cursor.GetLast, *Cursor.GetNext, and *Cursor.GetPrev.
func (*Cursor) GetFirst ¶
GetFirst retrieves and positions the cursor at the first key-value record, sorted by key using bytes.Compare.
CAUTION: See *Cursor.Get.
func (*Cursor) GetLast ¶
GetLast retrieves and positions the cursor at the last key-value record, sorted by key using bytes.Compare.
CAUTION: See *Cursor.Get.
func (*Cursor) GetNext ¶
GetNext advances the cursor and retrieves the next key-value record, sorted by key using bytes.Compare. On a newly opened cursor, it has the same effect as *Cursor.GetFirst.
CAUTION: See *Cursor.Get.
func (*Cursor) GetPrev ¶
GetPrev regresses the cursor and retrieves the previous key-value record, sorted by key using bytes.Compare.
CAUTION: See *Cursor.Get.
func (*Cursor) Put ¶
Put stores a key-value pair (or overwrites the corresponding value, if key already exists) and positions the cursor at the inserted record. It returns syscall.EINVAL (“invalid argument”) if the length of key or value is zero, or otherwise exceeds MaxKeyLength or MaxValueLength respectively.
CAUTION: The data in value must not be modified until the transaction has been successfully committed.
func (*Cursor) ToLinkCursor ¶ added in v0.1.9
func (cursor *Cursor) ToLinkCursor() *linkCursor