diff --git a/TODO.md b/TODO.md index 92c0118..74973c9 100644 --- a/TODO.md +++ b/TODO.md @@ -52,7 +52,7 @@ An important failure of MQL before was that it was never well-specified. Let's n ### New Iterators #### Limit Iterator -The necessary component to make mid-query limit work. Acts as a limit on Next(), a passthrough on Contains(), and a limit on NextResult() +The necessary component to make mid-query limit work. Acts as a limit on Next(), a passthrough on Contains(), and a limit on NextPath() ## Medium Term diff --git a/graph/iterator.go b/graph/iterator.go index 972f334..5b3cd8a 100644 --- a/graph/iterator.go +++ b/graph/iterator.go @@ -79,15 +79,15 @@ type Iterator interface { // To get the full results of iteration, do the following: // while (!Next()): // emit result - // while (!NextResult()): + // while (!NextPath()): // emit result // // All of them should set iterator.Last to be the last returned value, to // make results work. // - // NextResult() advances iterators that may have more than one valid result, + // NextPath() advances iterators that may have more than one valid result, // from the bottom up. - NextResult() bool + NextPath() bool // Contains returns whether the value is within the set held by the iterator. Contains(Value) bool diff --git a/graph/iterator/all_iterator.go b/graph/iterator/all_iterator.go index a3e1174..79f4057 100644 --- a/graph/iterator/all_iterator.go +++ b/graph/iterator/all_iterator.go @@ -110,7 +110,7 @@ func (it *Int64) Result() graph.Value { return it.result } -func (it *Int64) NextResult() bool { +func (it *Int64) NextPath() bool { return false } diff --git a/graph/iterator/and_iterator.go b/graph/iterator/and_iterator.go index 654f7c6..3fba7d1 100644 --- a/graph/iterator/and_iterator.go +++ b/graph/iterator/and_iterator.go @@ -236,15 +236,15 @@ func (it *And) Size() (int64, bool) { return val, b } -// An And has no NextResult of its own -- that is, there are no other values +// An And has no NextPath of its own -- that is, there are no other values // which satisfy our previous result that are not the result itself. Our // subiterators might, however, so just pass the call recursively. -func (it *And) NextResult() bool { - if it.primaryIt.NextResult() { +func (it *And) NextPath() bool { + if it.primaryIt.NextPath() { return true } for _, sub := range it.internalIterators { - if sub.NextResult() { + if sub.NextPath() { return true } } diff --git a/graph/iterator/fixed_iterator.go b/graph/iterator/fixed_iterator.go index 7efee2d..4fbcf08 100644 --- a/graph/iterator/fixed_iterator.go +++ b/graph/iterator/fixed_iterator.go @@ -156,7 +156,7 @@ func (it *Fixed) Result() graph.Value { return it.result } -func (it *Fixed) NextResult() bool { +func (it *Fixed) NextPath() bool { return false } diff --git a/graph/iterator/hasa_iterator.go b/graph/iterator/hasa_iterator.go index 954102a..93305e7 100644 --- a/graph/iterator/hasa_iterator.go +++ b/graph/iterator/hasa_iterator.go @@ -27,9 +27,9 @@ package iterator // value to check, it means "Check all predicates that have this value for your // direction against the subiterator." This would imply that there's more than // one possibility for the same Contains()ed value. While we could return the -// number of options, it's simpler to return one, and then call NextResult() +// number of options, it's simpler to return one, and then call NextPath() // enough times to enumerate the options. (In fact, one could argue that the -// raison d'etre for NextResult() is this iterator). +// raison d'etre for NextPath() is this iterator). // // Alternatively, can be seen as the dual of the LinksTo iterator. @@ -175,14 +175,14 @@ func (it *HasA) NextContains() bool { } // Get the next result that matches this branch. -func (it *HasA) NextResult() bool { - // Order here is important. If the subiterator has a NextResult, then we +func (it *HasA) NextPath() bool { + // Order here is important. If the subiterator has a NextPath, then we // need do nothing -- there is a next result, and we shouldn't move forward. // However, we then need to get the next result from our last Contains(). // - // The upshot is, the end of NextResult() bubbles up from the bottom of the + // The upshot is, the end of NextPath() bubbles up from the bottom of the // iterator tree up, and we need to respect that. - if it.primaryIt.NextResult() { + if it.primaryIt.NextPath() { return true } return it.NextContains() diff --git a/graph/iterator/iterator.go b/graph/iterator/iterator.go index 69b26c5..582991f 100644 --- a/graph/iterator/iterator.go +++ b/graph/iterator/iterator.go @@ -95,7 +95,7 @@ func (it *Null) SubIterators() []graph.Iterator { return nil } -func (it *Null) NextResult() bool { +func (it *Null) NextPath() bool { return false } diff --git a/graph/iterator/linksto_iterator.go b/graph/iterator/linksto_iterator.go index a79b34b..8148aa4 100644 --- a/graph/iterator/linksto_iterator.go +++ b/graph/iterator/linksto_iterator.go @@ -183,8 +183,8 @@ func (it *LinksTo) Close() { } // We won't ever have a new result, but our subiterators might. -func (it *LinksTo) NextResult() bool { - return it.primaryIt.NextResult() +func (it *LinksTo) NextPath() bool { + return it.primaryIt.NextPath() } // Register the LinksTo. diff --git a/graph/iterator/optional_iterator.go b/graph/iterator/optional_iterator.go index 646bc7f..0cd7eb5 100644 --- a/graph/iterator/optional_iterator.go +++ b/graph/iterator/optional_iterator.go @@ -88,9 +88,9 @@ func (it *Optional) Result() graph.Value { // An optional iterator only has a next result if, (a) last time we checked // we had any results whatsoever, and (b) there was another subresult in our // optional subbranch. -func (it *Optional) NextResult() bool { +func (it *Optional) NextPath() bool { if it.lastCheck { - return it.subIt.NextResult() + return it.subIt.NextPath() } return false } diff --git a/graph/iterator/or_iterator.go b/graph/iterator/or_iterator.go index b7e765a..b1b8100 100644 --- a/graph/iterator/or_iterator.go +++ b/graph/iterator/or_iterator.go @@ -228,13 +228,13 @@ func (it *Or) Size() (int64, bool) { return val, b } -// An Or has no NextResult of its own -- that is, there are no other values +// An Or has no NextPath of its own -- that is, there are no other values // which satisfy our previous result that are not the result itself. Our // subiterators might, however, so just pass the call recursively. In the case of // shortcircuiting, only allow new results from the currently checked graph.iterator -func (it *Or) NextResult() bool { +func (it *Or) NextPath() bool { if it.currentIterator != -1 { - return it.internalIterators[it.currentIterator].NextResult() + return it.internalIterators[it.currentIterator].NextPath() } return false } diff --git a/graph/iterator/value_comparison_iterator.go b/graph/iterator/value_comparison_iterator.go index 7c2eb58..405d152 100644 --- a/graph/iterator/value_comparison_iterator.go +++ b/graph/iterator/value_comparison_iterator.go @@ -152,9 +152,9 @@ func (it *Comparison) Result() graph.Value { return it.result } -func (it *Comparison) NextResult() bool { +func (it *Comparison) NextPath() bool { for { - hasNext := it.subIt.NextResult() + hasNext := it.subIt.NextPath() if !hasNext { return false } diff --git a/graph/leveldb/all_iterator.go b/graph/leveldb/all_iterator.go index 5346f97..f0504f1 100644 --- a/graph/leveldb/all_iterator.go +++ b/graph/leveldb/all_iterator.go @@ -129,7 +129,7 @@ func (it *AllIterator) Result() graph.Value { return it.result } -func (it *AllIterator) NextResult() bool { +func (it *AllIterator) NextPath() bool { return false } diff --git a/graph/leveldb/iterator.go b/graph/leveldb/iterator.go index b434dfd..01e2ba8 100644 --- a/graph/leveldb/iterator.go +++ b/graph/leveldb/iterator.go @@ -154,7 +154,7 @@ func (it *Iterator) Result() graph.Value { return it.result } -func (it *Iterator) NextResult() bool { +func (it *Iterator) NextPath() bool { return false } diff --git a/graph/memstore/iterator.go b/graph/memstore/iterator.go index 8a7e1ef..a84b069 100644 --- a/graph/memstore/iterator.go +++ b/graph/memstore/iterator.go @@ -111,7 +111,7 @@ func (it *Iterator) Result() graph.Value { return it.result } -func (it *Iterator) NextResult() bool { +func (it *Iterator) NextPath() bool { return false } diff --git a/graph/memstore/triplestore_test.go b/graph/memstore/triplestore_test.go index 44c43b4..80d25f0 100644 --- a/graph/memstore/triplestore_test.go +++ b/graph/memstore/triplestore_test.go @@ -128,7 +128,7 @@ func TestIteratorsAndNextResultOrderA(t *testing.T) { ) for { got = append(got, ts.NameOf(all.Result())) - if !outerAnd.NextResult() { + if !outerAnd.NextPath() { break } } diff --git a/graph/mongo/iterator.go b/graph/mongo/iterator.go index f9cea5b..59444b7 100644 --- a/graph/mongo/iterator.go +++ b/graph/mongo/iterator.go @@ -165,7 +165,7 @@ func (it *Iterator) Result() graph.Value { return it.result } -func (it *Iterator) NextResult() bool { +func (it *Iterator) NextPath() bool { return false } diff --git a/graph/result_tree_evaluator.go b/graph/result_tree_evaluator.go index e2feb33..dfa988a 100644 --- a/graph/result_tree_evaluator.go +++ b/graph/result_tree_evaluator.go @@ -50,7 +50,7 @@ func StringResultTreeEvaluator(it Nexter) string { } out += it.ResultTree().String() out += "\n" - for it.NextResult() == true { + for it.NextPath() == true { out += " " out += it.ResultTree().String() out += "\n" diff --git a/query/gremlin/finals.go b/query/gremlin/finals.go index 022a394..dd9b2f0 100644 --- a/query/gremlin/finals.go +++ b/query/gremlin/finals.go @@ -162,7 +162,7 @@ func runIteratorToArray(it graph.Iterator, ses *Session, limit int) []map[string if limit >= 0 && count >= limit { break } - for it.NextResult() == true { + for it.NextPath() == true { if ses.doHalt { return nil } @@ -220,7 +220,7 @@ func runIteratorWithCallback(it graph.Iterator, ses *Session, callback otto.Valu if limit >= 0 && count >= limit { break } - for it.NextResult() == true { + for it.NextPath() == true { if ses.doHalt { return } @@ -259,7 +259,7 @@ func runIteratorOnSession(it graph.Iterator, ses *Session) { if !cont { break } - for it.NextResult() == true { + for it.NextPath() == true { if ses.doHalt { return } diff --git a/query/mql/session.go b/query/mql/session.go index c272005..3c6d1b1 100644 --- a/query/mql/session.go +++ b/query/mql/session.go @@ -96,7 +96,7 @@ func (s *Session) ExecInput(input string, c chan interface{}, limit int) { tags := make(map[string]graph.Value) it.TagResults(tags) c <- tags - for it.NextResult() == true { + for it.NextPath() == true { tags := make(map[string]graph.Value) it.TagResults(tags) c <- tags diff --git a/query/sexp/session.go b/query/sexp/session.go index c1a227b..2a3671a 100644 --- a/query/sexp/session.go +++ b/query/sexp/session.go @@ -89,7 +89,7 @@ func (s *Session) ExecInput(input string, out chan interface{}, limit int) { if nResults > limit && limit != -1 { break } - for it.NextResult() == true { + for it.NextPath() == true { tags := make(map[string]graph.Value) it.TagResults(tags) out <- &tags