Beispiel #1
0
// Contains() for an Int64 is merely seeing if the passed value is
// within the range, assuming the value is an int64.
func (it *Int64) Contains(tsv graph.Value) bool {
	graph.ContainsLogIn(it, tsv)
	it.runstats.Contains += 1
	var v int64
	if tsv.IsNode() {
		v = int64(tsv.(Int64Node))
	} else {
		v = int64(tsv.(Int64Quad))
	}
	if it.min <= v && v <= it.max {
		it.result = v
		return graph.ContainsLogOut(it, it.toValue(v), true)
	}
	return graph.ContainsLogOut(it, it.toValue(v), false)
}
Beispiel #2
0
func (it *Iterator) Contains(v graph.Value) bool {
	graph.ContainsLogIn(it, v)
	if v == nil {
		return graph.ContainsLogOut(it, v, false)
	} else if it.nodes != v.IsNode() {
		return graph.ContainsLogOut(it, v, false)
	}
	var vi int64
	if it.nodes {
		vi = int64(v.(iterator.Int64Node))
	} else {
		vi = int64(v.(iterator.Int64Quad))
	}
	if _, ok := it.tree.Get(vi); ok {
		it.result = vi
		return graph.ContainsLogOut(it, v, true)
	}
	return graph.ContainsLogOut(it, v, false)
}
Beispiel #3
0
func (qs *QuadStore) NameOf(v graph.Value) quad.Value {
	if v == nil {
		return nil
	} else if v, ok := v.(graph.PreFetchedValue); ok {
		return v.NameOf()
	}
	hash := v.(NodeHash)
	if hash == "" {
		return nil
	}
	if val, ok := qs.ids.Get(string(hash)); ok {
		return val.(quad.Value)
	}
	var node MongoNode
	err := qs.db.C("nodes").FindId(string(hash)).One(&node)
	if err != nil {
		clog.Errorf("Error: Couldn't retrieve node %s %v", v, err)
	}
	qv := toQuadValue(node.Name)
	if node.ID != "" && qv != nil {
		qs.ids.Put(string(hash), qv)
	}
	return qv
}