Documentation ¶
Index ¶
- Constants
- func FindLastIntLess(val int, vals []int) int
- func U32varint(buf []byte) (uint32, int)
- type Cache
- type CacheHandle
- type Comparator
- type EmptyIterator
- func (this EmptyIterator) Close() error
- func (this EmptyIterator) Key() []byte
- func (this EmptyIterator) Next()
- func (this EmptyIterator) Prev()
- func (this EmptyIterator) Seek(key []byte)
- func (this EmptyIterator) SeekToFirst()
- func (this EmptyIterator) SeekToLast()
- func (this EmptyIterator) Status() error
- func (this EmptyIterator) Valid() bool
- func (this EmptyIterator) Value() []byte
- type Iterator
Constants ¶
View Source
const ( MinUint = uint(0) MaxUint = ^MinUint MaxInt = int(MaxUint >> 1) MinInt = ^MaxInt )
MaxUint, MinUint 的类型总是 uint 类型. MinInt, MaxInt 总是 int 类型. 仅当 unsafe.Sizeof(int) == Sizeof(uint) 时下面才是正确的. 感谢 go spec 指定: int, same size as uint
View Source
const (
UintLen32 = 4
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Cache ¶
type Cache interface { EraseAll() Insert(key string, val interface{}, charge int, deler func(key string, val interface{})) CacheHandle Lookup(key string) CacheHandle Release(handle CacheHandle) Erase(key string) NewId() int }
func NewLRUCache ¶
type CacheHandle ¶
type CacheHandle interface {
Value() interface{}
}
type Comparator ¶
type Comparator interface { Compare(a, b []byte) int Name() string // 注意返回值可能与 start 公用内存. FindShortestSeparator(start []byte, limit []byte) []byte // 注意返回值可能与 start 公用内存. FindShortSuccessor(start []byte) []byte }
Comparator 的实现需要做到 goroutine 安全.
func NewBytewiseComparator ¶
func NewBytewiseComparator() Comparator
type EmptyIterator ¶
type EmptyIterator struct { }
func NewEmptyIterator ¶
func NewEmptyIterator() EmptyIterator
func (EmptyIterator) Close ¶
func (this EmptyIterator) Close() error
func (EmptyIterator) Key ¶
func (this EmptyIterator) Key() []byte
func (EmptyIterator) Next ¶
func (this EmptyIterator) Next()
func (EmptyIterator) Prev ¶
func (this EmptyIterator) Prev()
func (EmptyIterator) Seek ¶
func (this EmptyIterator) Seek(key []byte)
func (EmptyIterator) SeekToFirst ¶
func (this EmptyIterator) SeekToFirst()
func (EmptyIterator) SeekToLast ¶
func (this EmptyIterator) SeekToLast()
func (EmptyIterator) Status ¶
func (this EmptyIterator) Status() error
func (EmptyIterator) Valid ¶
func (this EmptyIterator) Valid() bool
func (EmptyIterator) Value ¶
func (this EmptyIterator) Value() []byte
type Iterator ¶
type Iterator interface { Close() error Valid() bool SeekToFirst() SeekToLast() Seek(key []byte) Next() Prev() Status() error /* Key(), Value() 返回迭代器当前位置对应的 key/value. 调用者不应该修改返回值. 返回值会一直有效直至下一次移动迭代器的位置 */ Key() []byte Value() []byte }
Iterator, 其对应的底层数据模型类似与 std::map. 对 Key(), Value() 返回值的解释权由底层实现所有.
Iterator 并不是 goroutine 安全, 即不要在多个 goroutine 上不加任何同步的前提下并行访问 Iterator.
Iterator 在不需要的时候应该调用其 Close() 接口来释放资源.
当对 Iterator 的遍历结束之后, 应该通过 Status() 来判断结束的原因. 若 Status() 返回 nil, 则表明是因为没有多余 的数据了; 若 Status() 返回非 nil, 则表明是由于底层实现出了错导致遍历结束了.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.