db: Simplify exists check, fix IsKeyInDomain signature, Iterator Close

+ *FSDB.HasKey now uses common.FileExists to test for file existence
+ IsKeyInDomain takes key as a []byte slice instead of as a string
to avoid extraneous []byte<-->string conversions for start and end
+ Iterator.Close() instead of Iterator.Release()
+ withDB helper to encapsulate DB creation, deferred cleanups
so that for loops can use opened DBs and discard them ASAP

Addressing accepted changes from review with @jaekwon
This commit is contained in:
Emmanuel Odeke
2017-12-15 02:48:40 -07:00
parent a2f7898b6d
commit a7b20d4e46
7 changed files with 37 additions and 45 deletions

View File

@ -68,7 +68,7 @@ func EndingKey() []byte {
Usage:
var itr Iterator = ...
defer itr.Release()
defer itr.Close()
for ; itr.Valid(); itr.Next() {
k, v := itr.Key(); itr.Value()
@ -108,7 +108,7 @@ type Iterator interface {
Value() []byte
// Release deallocates the given Iterator.
Release()
Close()
}
// For testing convenience.