From 525230206a0ed079e1bdfaebf5ec280ec97d0140 Mon Sep 17 00:00:00 2001 From: kortschak Date: Wed, 30 Jul 2014 12:11:14 +0930 Subject: [PATCH] Move SubIterator handling out of Base --- graph/iterator/all_iterator.go | 5 +++++ graph/iterator/fixed_iterator.go | 5 +++++ graph/iterator/optional_iterator.go | 7 ++++++- graph/iterator/value_comparison_iterator.go | 5 +++++ graph/leveldb/all_iterator.go | 5 +++++ graph/leveldb/iterator.go | 5 +++++ graph/memstore/all_iterator.go | 5 +++++ graph/memstore/iterator.go | 5 +++++ graph/mongo/iterator.go | 5 +++++ 9 files changed, 46 insertions(+), 1 deletion(-) diff --git a/graph/iterator/all_iterator.go b/graph/iterator/all_iterator.go index 9bf6441..004bc68 100644 --- a/graph/iterator/all_iterator.go +++ b/graph/iterator/all_iterator.go @@ -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) { diff --git a/graph/iterator/fixed_iterator.go b/graph/iterator/fixed_iterator.go index 61e9b50..23bf177 100644 --- a/graph/iterator/fixed_iterator.go +++ b/graph/iterator/fixed_iterator.go @@ -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. diff --git a/graph/iterator/optional_iterator.go b/graph/iterator/optional_iterator.go index defee8c..fa9396d 100644 --- a/graph/iterator/optional_iterator.go +++ b/graph/iterator/optional_iterator.go @@ -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. diff --git a/graph/iterator/value_comparison_iterator.go b/graph/iterator/value_comparison_iterator.go index c29fda0..c0631fe 100644 --- a/graph/iterator/value_comparison_iterator.go +++ b/graph/iterator/value_comparison_iterator.go @@ -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 diff --git a/graph/leveldb/all_iterator.go b/graph/leveldb/all_iterator.go index 84d815c..80046c3 100644 --- a/graph/leveldb/all_iterator.go +++ b/graph/leveldb/all_iterator.go @@ -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 diff --git a/graph/leveldb/iterator.go b/graph/leveldb/iterator.go index c4c98a3..d677bcb 100644 --- a/graph/leveldb/iterator.go +++ b/graph/leveldb/iterator.go @@ -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 { diff --git a/graph/memstore/all_iterator.go b/graph/memstore/all_iterator.go index 371a958..204a015 100644 --- a/graph/memstore/all_iterator.go +++ b/graph/memstore/all_iterator.go @@ -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 { diff --git a/graph/memstore/iterator.go b/graph/memstore/iterator.go index 7d08a09..290fef6 100644 --- a/graph/memstore/iterator.go +++ b/graph/memstore/iterator.go @@ -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 } diff --git a/graph/mongo/iterator.go b/graph/mongo/iterator.go index a5b6dc7..3afe77e 100644 --- a/graph/mongo/iterator.go +++ b/graph/mongo/iterator.go @@ -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 {