Skip to content

Commit

Permalink
goleveldb: bound iterator range for improved performance (#134)
Browse files Browse the repository at this point in the history
  • Loading branch information
Klimov Sergey authored Nov 9, 2020
1 parent 772df13 commit feb7d28
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- [\#134](https://github.com/tendermint/tm-db/pull/134) Improve GoLevelDB iterator performance by bounding underlying iterator range (@klim0v)

## 0.6.2

**2020-08-27**
Expand Down
5 changes: 3 additions & 2 deletions goleveldb.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/syndtr/goleveldb/leveldb"
"github.com/syndtr/goleveldb/leveldb/errors"
"github.com/syndtr/goleveldb/leveldb/opt"
"github.com/syndtr/goleveldb/leveldb/util"
)

func init() {
Expand Down Expand Up @@ -175,7 +176,7 @@ func (db *GoLevelDB) Iterator(start, end []byte) (Iterator, error) {
if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
return nil, errKeyEmpty
}
itr := db.db.NewIterator(nil, nil)
itr := db.db.NewIterator(&util.Range{Start: start, Limit: end}, nil)
return newGoLevelDBIterator(itr, start, end, false), nil
}

Expand All @@ -184,6 +185,6 @@ func (db *GoLevelDB) ReverseIterator(start, end []byte) (Iterator, error) {
if (start != nil && len(start) == 0) || (end != nil && len(end) == 0) {
return nil, errKeyEmpty
}
itr := db.db.NewIterator(nil, nil)
itr := db.db.NewIterator(&util.Range{Start: start, Limit: end}, nil)
return newGoLevelDBIterator(itr, start, end, true), nil
}

0 comments on commit feb7d28

Please sign in to comment.