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
|
||||
|
|
|
|||
|
|
@ -121,6 +121,11 @@ func (it *AllIterator) Next() (graph.Value, bool) {
|
|||
return out, true
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *AllIterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (it *AllIterator) Check(v graph.Value) bool {
|
||||
it.Last = v
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -146,6 +146,11 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
|||
return nil, false
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *Iterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func PositionOf(prefix []byte, d graph.Direction, ts *TripleStore) int {
|
||||
if bytes.Equal(prefix, []byte("sp")) {
|
||||
switch d {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,11 @@ func NewMemstoreAllIterator(ts *TripleStore) *AllIterator {
|
|||
return &out
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *AllIterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (it *AllIterator) Next() (graph.Value, bool) {
|
||||
next, out := it.Int64.Next()
|
||||
if !out {
|
||||
|
|
|
|||
|
|
@ -105,6 +105,11 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
|||
return graph.NextLogOut(it, it.Last, true)
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *Iterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (it *Iterator) Size() (int64, bool) {
|
||||
return int64(it.tree.Len()), true
|
||||
}
|
||||
|
|
|
|||
|
|
@ -162,6 +162,11 @@ func (it *Iterator) Next() (graph.Value, bool) {
|
|||
return result.Id, true
|
||||
}
|
||||
|
||||
// No subiterators.
|
||||
func (it *Iterator) SubIterators() []graph.Iterator {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (it *Iterator) Check(v graph.Value) bool {
|
||||
graph.CheckLogIn(it, v)
|
||||
if it.isAll {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue