update document

This commit is contained in:
siddontang 2014-07-09 10:26:15 +08:00
parent 961b4f393d
commit 5e87dc9437
4 changed files with 23 additions and 24 deletions

View File

@ -289,14 +289,16 @@ func (db *DB) RevRangeIterator(min []byte, max []byte, rangeType uint8) *RangeLi
return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1}) return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1})
} }
//count < 0, unlimit //count < 0, unlimit.
//offset must >= 0, if < 0, will get nothing //
//offset must >= 0, if < 0, will get nothing.
func (db *DB) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator { func (db *DB) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
return NewRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count}) return NewRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
} }
//count < 0, unlimit //count < 0, unlimit.
//offset must >= 0, if < 0, will get nothing //
//offset must >= 0, if < 0, will get nothing.
func (db *DB) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator { func (db *DB) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count}) return NewRevRangeLimitIterator(db.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
} }

View File

@ -24,11 +24,14 @@ const (
) )
// min must less or equal than max // min must less or equal than max
//
// range type: // range type:
// close: [min, max] //
// open: (min, max) // close: [min, max]
// lopen: (min, max] // open: (min, max)
// ropen: [min, max) // lopen: (min, max]
// ropen: [min, max)
//
type Range struct { type Range struct {
Min []byte Min []byte
Max []byte Max []byte
@ -92,7 +95,7 @@ func (it *Iterator) RawValue() []byte {
return slice(unsafe.Pointer(vdata), int(C.int(vlen))) return slice(unsafe.Pointer(vdata), int(C.int(vlen)))
} }
// Copy key to b, if b len is small or nil, returns a new one // Copy key to b, if b len is small or nil, returns a new one.
func (it *Iterator) BufKey(b []byte) []byte { func (it *Iterator) BufKey(b []byte) []byte {
k := it.RawKey() k := it.RawKey()
if k == nil { if k == nil {
@ -106,7 +109,7 @@ func (it *Iterator) BufKey(b []byte) []byte {
return append(b, k...) return append(b, k...)
} }
// Copy value to b, if b len is small or nil, returns a new one // Copy value to b, if b len is small or nil, returns a new one.
func (it *Iterator) BufValue(b []byte) []byte { func (it *Iterator) BufValue(b []byte) []byte {
v := it.RawValue() v := it.RawValue()
if v == nil { if v == nil {
@ -150,7 +153,7 @@ func (it *Iterator) Seek(key []byte) {
it.isValid = C.leveldb_iter_seek_ext(it.it, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key))) it.isValid = C.leveldb_iter_seek_ext(it.it, (*C.char)(unsafe.Pointer(&key[0])), C.size_t(len(key)))
} }
// Finds by key, if not found, nil returns // Finds by key, if not found, nil returns.
func (it *Iterator) Find(key []byte) []byte { func (it *Iterator) Find(key []byte) []byte {
it.Seek(key) it.Seek(key)
if it.Valid() { if it.Valid() {
@ -165,7 +168,7 @@ func (it *Iterator) Find(key []byte) []byte {
return nil return nil
} }
// Finds by key, if not found, nil returns, else a reference of value returns // Finds by key, if not found, nil returns, else a reference of value returns.
// you must be careful that it will be changed after next iterate. // you must be careful that it will be changed after next iterate.
func (it *Iterator) RawFind(key []byte) []byte { func (it *Iterator) RawFind(key []byte) []byte {
it.Seek(key) it.Seek(key)

View File

@ -55,14 +55,6 @@ func (o *Options) SetCache(cache *Cache) {
C.leveldb_options_set_cache(o.Opt, cache.Cache) C.leveldb_options_set_cache(o.Opt, cache.Cache)
} }
// func (o *Options) SetEnv(env *Env) {
// C.leveldb_options_set_env(o.Opt, env.Env)
// }
func (o *Options) SetInfoLog(log *C.leveldb_logger_t) {
C.leveldb_options_set_info_log(o.Opt, log)
}
func (o *Options) SetWriteBufferSize(s int) { func (o *Options) SetWriteBufferSize(s int) {
C.leveldb_options_set_write_buffer_size(o.Opt, C.size_t(s)) C.leveldb_options_set_write_buffer_size(o.Opt, C.size_t(s))
} }

View File

@ -45,14 +45,16 @@ func (s *Snapshot) RevRangeIterator(min []byte, max []byte, rangeType uint8) *Ra
return NewRevRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1}) return NewRevRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{0, -1})
} }
//count < 0, unlimit //count < 0, unlimit.
//offset must >= 0, if < 0, will get nothing //
//offset must >= 0, if < 0, will get nothing.
func (s *Snapshot) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator { func (s *Snapshot) RangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
return NewRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count}) return NewRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
} }
//count < 0, unlimit //count < 0, unlimit.
//offset must >= 0, if < 0, will get nothing //
//offset must >= 0, if < 0, will get nothing.
func (s *Snapshot) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator { func (s *Snapshot) RevRangeLimitIterator(min []byte, max []byte, rangeType uint8, offset int, count int) *RangeLimitIterator {
return NewRevRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count}) return NewRevRangeLimitIterator(s.NewIterator(), &Range{min, max, rangeType}, &Limit{offset, count})
} }