Added comments for the not operator.

This commit is contained in:
Matei Chiperi 2014-08-26 11:59:14 -07:00
parent d3bc8c1736
commit d9b67c8335
2 changed files with 14 additions and 5 deletions

View file

@ -300,21 +300,24 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph.
it = buildInOutIterator(obj, ts, subIt, true)
case "not":
// Not is implemented as the difference between the primary iterator
// and the iterator chain of (primaryIt, follow, followR).
// Build the follow iterator
// and the iterator chain composed of (primaryIt->Follow->FollowR).
// Arguments for follow iterator
arg, _ := obj.Get("_gremlin_values")
firstArg, _ := arg.Object().Get("0")
if isVertexChain(firstArg.Object()) {
return iterator.NewNull()
}
// Build the followR iterator
// Arguments for followR iterator
revArg, _ := obj.Get("_gremlin_followr")
if isVertexChain(revArg.Object()) {
return iterator.NewNull()
}
// Build the primaryIt->Follow iterator
followIt := buildIteratorTreeHelper(firstArg.Object(), ts, subIt)
// Build the primaryIt->Follow->FollowR iterator
forbiddenIt := buildIteratorTreeHelper(revArg.Object(), ts, followIt)
it = iterator.NewNot(subIt, forbiddenIt)