diff --git a/graph/iterator.go b/graph/iterator.go index 5e41810..0f3b76e 100644 --- a/graph/iterator.go +++ b/graph/iterator.go @@ -38,10 +38,12 @@ type Tagger struct { // Linkage is a union type representing a set of values established for a given // quad direction. type Linkage struct { - Dir quad.Direction - Values []Value + Dir quad.Direction + Value Value } +// TODO(barakmich): Helper functions as needed, eg, ValuesForDirection(quad.Direction) []Value + // Add a tag to the iterator. func (t *Tagger) Add(tag string) { t.tags = append(t.tags, tag) diff --git a/graph/mongo/indexed_linksto.go b/graph/mongo/indexed_linksto.go index 4f24d72..522cb6b 100644 --- a/graph/mongo/indexed_linksto.go +++ b/graph/mongo/indexed_linksto.go @@ -66,15 +66,9 @@ func NewLinksTo(qs *QuadStore, it graph.Iterator, collection string, d quad.Dire func (it *LinksTo) buildConstraint() bson.M { constraint := bson.M{} - for _, set := range it.lset { - var s []string - for _, v := range set.Values { - s = append(s, it.qs.NameOf(v)) - } - constraint[set.Dir.String()] = bson.M{"$in": s} - if len(s) == 1 { - constraint[set.Dir.String()] = s[0] - } + // TODO(barakmich): Currently this only works for an individual linkage in any direction. + for _, link := range it.lset { + constraint[link.Dir.String()] = link.Value } return constraint } @@ -201,16 +195,9 @@ func (it *LinksTo) Contains(val graph.Value) bool { graph.ContainsLogIn(it, val) it.runstats.Contains += 1 - for _, set := range it.lset { - dval := it.qs.QuadDirection(val, set.Dir) - good := false - for _, val := range set.Values { - if val == dval { - good = true - break - } - } - if !good { + for _, link := range it.lset { + dval := it.qs.QuadDirection(val, link.Dir) + if dval != link.Value { return graph.ContainsLogOut(it, val, false) } } diff --git a/graph/mongo/quadstore_iterator_optimize.go b/graph/mongo/quadstore_iterator_optimize.go index c85ba99..bb7d21e 100644 --- a/graph/mongo/quadstore_iterator_optimize.go +++ b/graph/mongo/quadstore_iterator_optimize.go @@ -68,7 +68,7 @@ func (qs *QuadStore) optimizeAndIterator(it *iterator.And) (graph.Iterator, bool lset := []graph.Linkage{ { Dir: mongoIt.dir, - Values: []graph.Value{qs.ValueOf(mongoIt.name)}, + Value: qs.ValueOf(mongoIt.name), }, }