Converted the Not operator to a complement operator in terms of functionality.

This commit is contained in:
Matei Chiperi 2014-08-27 13:42:56 -07:00
parent a0318aa7b2
commit 5d4e22498d
3 changed files with 35 additions and 48 deletions

View file

@ -299,28 +299,14 @@ func buildIteratorTreeHelper(obj *otto.Object, ts graph.TripleStore, base graph.
case "in":
it = buildInOutIterator(obj, ts, subIt, true)
case "not":
// Not is implemented as the difference between the primary iterator
// and the iterator chain composed of (primaryIt->Follow->FollowR).
// arg, _ := obj.Get("_gremlin_values")
// firstArg, _ := arg.Object().Get("0")
// if !isVertexChain(firstArg.Object()) {
// return iterator.NewNull()
// }
// forbiddenIt := buildIteratorTree(firstArg.Object(), ts)
// Arguments for follow iterator
arg, _ := obj.Get("_gremlin_values")
firstArg, _ := arg.Object().Get("0")
if isVertexChain(firstArg.Object()) {
return iterator.NewNull()
}
// 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)
it = iterator.NewNot(ts, subIt)
case "loop":
arg, _ := obj.Get("_gremlin_values")
firstArg, _ := arg.Object().Get("0")