func NewIterator(ts *TripleStore, collection string, d graph.Direction, val graph.TSVal) *Iterator { var m Iterator iterator.BaseInit(&m.Base) m.name = ts.GetNameFor(val) m.collection = collection switch d { case graph.Subject: m.constraint = bson.M{"Subject": m.name} case graph.Predicate: m.constraint = bson.M{"Predicate": m.name} case graph.Object: m.constraint = bson.M{"Object": m.name} case graph.Provenance: m.constraint = bson.M{"Provenance": m.name} } m.ts = ts m.dir = d m.iter = ts.db.C(collection).Find(m.constraint).Iter() size, err := ts.db.C(collection).Find(m.constraint).Count() if err != nil { glog.Errorln("Trouble getting size for iterator! ", err) return nil } m.size = int64(size) m.hash = val.(string) m.isAll = false return &m }
func NewLlrbIterator(tree *llrb.LLRB, data string) *Iterator { var it Iterator iterator.BaseInit(&it.Base) it.tree = tree it.iterLast = Int64(-1) it.data = data return &it }
func NewAllIterator(prefix string, d graph.Direction, ts *TripleStore) *AllIterator { var it AllIterator iterator.BaseInit(&it.Base) it.ro = &opt.ReadOptions{} it.ro.DontFillCache = true it.iter = ts.db.NewIterator(nil, it.ro) it.prefix = []byte(prefix) it.dir = d it.open = true it.ts = ts it.iter.Seek(it.prefix) if !it.iter.Valid() { it.open = false it.iter.Release() } return &it }
func NewIterator(prefix string, d graph.Direction, value graph.TSVal, ts *TripleStore) *Iterator { var it Iterator iterator.BaseInit(&it.Base) it.checkId = value.([]byte) it.dir = d it.originalPrefix = prefix it.nextPrefix = make([]byte, 0, 2+ts.hasher.Size()) it.nextPrefix = append(it.nextPrefix, []byte(prefix)...) it.nextPrefix = append(it.nextPrefix, []byte(it.checkId[1:])...) it.ro = &opt.ReadOptions{} it.ro.DontFillCache = true it.it = ts.db.NewIterator(nil, it.ro) it.open = true it.ts = ts ok := it.it.Seek(it.nextPrefix) if !ok { it.open = false it.it.Release() } return &it }