Documentation
¶
Index ¶
Constants ¶
View Source
const BPlusTreeIndexFileName = "bplustree-index"
Variables ¶
View Source
var DefaultIteratorOptions = IteratorOptions{ Prefix: nil, Reverse: false, }
DefaultOptions default options of an iterator of an index
View Source
var IndexBucketName = []byte("baradb-index")
Functions ¶
This section is empty.
Types ¶
type Index ¶
type Index interface {
// Put stores a given key and its value in the index
//
// It may replaces the old value if the given already exists
//
// It returns the old value if the given key already exists and nil otherwise
Put([]byte, *data.LogRecordPosition) *data.LogRecordPosition
// Get returns the value of the given key from the index
//
// It returns a value if the given key already exists and nil otherwise
Get([]byte) *data.LogRecordPosition
// Delete deletes the value of the given key in the index
//
// It returns the deleted value and a boolean value true if the key exists
// Otherwise, it returns nil and a boolean value false
Delete([]byte) (*data.LogRecordPosition, bool)
// Size returns how many key/value pairs in the index
Size() int
// Iterator creates an iterator of the index
//
// The iterator supports reversed iteration if the given boolean value is true
Iterator(bool) Iterator
// Close closes the index
Close() error
}
Index repersents abstract interface of an in-memory index
An index stores key/value pairs. A key is the key of a log record, and a value is a log record's position in a data file in a disk.
type Iterator ¶
type Iterator interface {
Rewind() // Rewind resets the iteration
Seek([]byte)
Next()
Valid() bool
Key() []byte
Value() *data.LogRecordPosition
Close() // Close closes the iterator
}
An abstract interator of an index
type IteratorOptions ¶
type IteratorOptions struct {
Prefix []byte // Traverses an iterator's keys with a specified non-nil prefix
Reverse bool // Traverses an iterator reversely if true
}
Options options of an iterator of an index
Click to show internal directories.
Click to hide internal directories.