Documentation ¶
Index ¶
- func Next(it Iterator) bool
- type Direction
- type Iterator
- func Empty() Iterator
- func Error(err error) Iterator
- func NewIndexIterator(index Iterator, blockf func([]byte) Iterator) Iterator
- func NewMergeIterator(cmp keys.Comparer, iterators ...Iterator) Iterator
- func NewRangeIterator(start, limit []byte, cmp keys.Comparer, it Iterator) Iterator
- func WithCleanup(iterator Iterator, cleanup func() error) Iterator
- type Status
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Iterator ¶
type Iterator interface { // Next moves to next entry. It returns whether such entry exists. // The behaviour is undefined if current status of iterator is invalid. Next() bool // Prev moves to previous entry. It returns whether such entry exists. // The behaviour is undefined if current status of iterator is invalid. Prev() bool // First moves to the first entry. It returns whether such entry exists. First() bool // Last moves to the last entry. It returns whether such entry exists. Last() bool // Seek moves the iterator to the first entry with key >= target. // It returns whether such entry exists. Seek(target []byte) bool // Valid returns whether the iterator is point to a valid entry. Valid() bool // Key returns the key of current entry. The behaviour is undefined if // current status of iterator is invalid. Key() []byte // Value returns the value of current entry. The behaviour is undefined // if current status of iterator is invalid. Value() []byte // Err returns error we encounters so far. Seek methods, First, Last and Seek may // clear this error. Err() error // Close releases any resources hold by this iterator, and returns // any error it encounters so far. The behaviour is undefined if you // call any methods after this iterator has been closed. Close() error }
Iterator has same method set as the exported one, but with fewer safety guarantees. The exported interface is a superset of internal one. Not all internal iterators can be safely exported to clients. Internal functions can't specify exported interface in their signature. Callers should be aware of this fact, and don't call any method that may lead to undefined behaviours.
func Empty ¶
func Empty() Iterator
Empty returns an empty iterator.
This empty iterator has following properties: * First/Last/Seek/Valid return false. * Next/Prev/Key/Value panic. * Err/Close return nil.
func Error ¶
Error returns an error iterator.
This error iterator has following properties: * First/Last/Seek/Valid return false. * Next/Prev/Key/Value panic. * Err/Close return the specified err.
func NewIndexIterator ¶
func NewMergeIterator ¶
NewMergeIterator creates a iterator merging all entries from iterators. The resulting iterator implements semantics the exported Iterator interface defines. This means that if Next/Prev is the first seek method called, they act as First/Last respectively. If equal keys exist in different iterators, it is undefined and hence unstable which entry is retrieved first among different iterations.
func NewRangeIterator ¶
NewRangeIterator creates a range iterator for keys in range [start, limit). Nil or empty start or limit act as no limitation in corresponding end. The resulting iterator implements semantics the exported Iterator interface defines. This means that if Next/Prev is the first seek method called, they act as First/Last respectively.
func WithCleanup ¶
type Status ¶
type Status int
Status defines statuses for iterator.
const ( // Initial is the initial status of iterator. Initial Status = iota // Invalid specifies that iterator encounters an error which can be // retrieved through Err(). Invalid // Closed specifies that iterator has been closed. Closed // Valid specifies that iterator has entry retrieved in its Key/Value. Valid )