Move SubIterator handling out of Base
This commit is contained in:
parent
189910c4b8
commit
525230206a
9 changed files with 46 additions and 1 deletions
|
|
@ -103,6 +103,11 @@ func (it *Int64) Next() (graph.Value, bool) {
|
|||
return graph.NextLogOut(it, val, true)
|
||||
}
|
||||
|
||||
// No sub-iterators.
|
||||
func (it *Int64) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
// The number of elements in an Int64 is the size of the range.
|
||||
// The size is exact.
|
||||
func (it *Int64) Size() (int64, bool) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,11 @@ func (it *Fixed) Next() (graph.Value, bool) {
|
|||
return graph.NextLogOut(it, out, true)
|
||||
}
|
||||
|
||||
// No sub-iterators.
|
||||
func (it *Fixed) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Optimize() for a Fixed iterator is simple. Returns a Null iterator if it's empty
|
||||
// (so that other iterators upstream can treat this as null) or there is no
|
||||
// optimization.
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ import (
|
|||
"github.com/google/cayley/graph"
|
||||
)
|
||||
|
||||
// An optional iterator has the subconstraint iterator we wish to be optional
|
||||
// An optional iterator has the sub-constraint iterator we wish to be optional
|
||||
// and whether the last check we received was true or false.
|
||||
type Optional struct {
|
||||
Base
|
||||
|
|
@ -95,6 +95,11 @@ func (it *Optional) NextResult() bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *Optional) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check() is the real hack of this iterator. It always returns true, regardless
|
||||
// of whether the subiterator matched. But we keep track of whether the subiterator
|
||||
// matched for results purposes.
|
||||
|
|
|
|||
|
|
@ -159,6 +159,11 @@ func (it *Comparison) NextResult() bool {
|
|||
return true
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *Comparison) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (it *Comparison) Check(val graph.Value) bool {
|
||||
if !it.doComparison(val) {
|
||||
return false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue