Simplify Nexter interface
This change allows a Nexter to be used in the same manner as a scanner
using a for graph.Next(it) {} construction.
It is important that graph.Next(it) and any associated it.Result() calls
operate on the same iterator.
This commit is contained in:
parent
f8e28e066e
commit
b1a70d99aa
31 changed files with 168 additions and 233 deletions
|
|
@ -117,19 +117,19 @@ func (it *Iterator) Close() {
|
|||
}
|
||||
}
|
||||
|
||||
func (it *Iterator) Next() (graph.Value, bool) {
|
||||
func (it *Iterator) Next() bool {
|
||||
if it.iter == nil {
|
||||
it.result = nil
|
||||
return nil, false
|
||||
return false
|
||||
}
|
||||
if !it.open {
|
||||
it.result = nil
|
||||
return nil, false
|
||||
return false
|
||||
}
|
||||
if !it.iter.Valid() {
|
||||
it.result = nil
|
||||
it.Close()
|
||||
return nil, false
|
||||
return false
|
||||
}
|
||||
if bytes.HasPrefix(it.iter.Key(), it.nextPrefix) {
|
||||
out := make([]byte, len(it.iter.Key()))
|
||||
|
|
@ -139,11 +139,11 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
|||
if !ok {
|
||||
it.Close()
|
||||
}
|
||||
return out, true
|
||||
return true
|
||||
}
|
||||
it.Close()
|
||||
it.result = nil
|
||||
return nil, false
|
||||
return false
|
||||
}
|
||||
|
||||
func (it *Iterator) ResultTree() *graph.ResultTree {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue