Пример #1
0
func (it *Iterator) Check(v graph.TSVal) bool {
	graph.CheckLogIn(it, v)
	if it.tree.Has(Int64(v.(int64))) {
		it.Last = v
		return graph.CheckLogOut(it, v, true)
	}
	return graph.CheckLogOut(it, v, false)
}
Пример #2
0
// Check a value against the entire graph.iterator, in order.
func (it *Or) Check(val graph.TSVal) bool {
	graph.CheckLogIn(it, val)
	anyGood := it.checkSubIts(val)
	if !anyGood {
		return graph.CheckLogOut(it, val, false)
	}
	it.Last = val
	return graph.CheckLogOut(it, val, true)
}
Пример #3
0
// Check() for an Int64 is merely seeing if the passed value is
// withing the range, assuming the value is an int64.
func (it *Int64) Check(tsv graph.Value) bool {
	graph.CheckLogIn(it, tsv)
	v := tsv.(int64)
	if it.min <= v && v <= it.max {
		it.Last = v
		return graph.CheckLogOut(it, v, true)
	}
	return graph.CheckLogOut(it, v, false)
}
Пример #4
0
// If it checks in the right direction for the subiterator, it is a valid link
// for the LinksTo.
func (it *LinksTo) Check(val graph.Value) bool {
	graph.CheckLogIn(it, val)
	node := it.ts.TripleDirection(val, it.dir)
	if it.primaryIt.Check(node) {
		it.Last = val
		return graph.CheckLogOut(it, val, true)
	}
	return graph.CheckLogOut(it, val, false)
}
Пример #5
0
// Check a value against our internal iterator. In order to do this, we must first open a new
// iterator of "triples that have `val` in our direction", given to us by the triple store,
// and then Next() values out of that iterator and Check() them against our subiterator.
func (it *HasA) Check(val graph.TSVal) bool {
	graph.CheckLogIn(it, val)
	if glog.V(4) {
		glog.V(4).Infoln("Id is", it.ts.GetNameFor(val))
	}
	// TODO(barakmich): Optimize this
	if it.resultIt != nil {
		it.resultIt.Close()
	}
	it.resultIt = it.ts.GetTripleIterator(it.dir, val)
	return graph.CheckLogOut(it, val, it.GetCheckResult())
}
Пример #6
0
// Check if the passed value is equal to one of the values stored in the iterator.
func (it *Fixed) Check(v graph.TSVal) bool {
	// Could be optimized by keeping it sorted or using a better datastructure.
	// However, for fixed iterators, which are by definition kind of tiny, this
	// isn't a big issue.
	graph.CheckLogIn(it, v)
	for _, x := range it.values {
		if it.cmp(x, v) {
			it.Last = x
			return graph.CheckLogOut(it, v, true)
		}
	}
	return graph.CheckLogOut(it, v, false)
}
Пример #7
0
// Check a value against the entire iterator, in order.
func (it *And) Check(val graph.TSVal) bool {
	graph.CheckLogIn(it, val)
	if it.checkList != nil {
		return it.checkCheckList(val)
	}
	mainGood := it.primaryIt.Check(val)
	if !mainGood {
		return graph.CheckLogOut(it, val, false)
	}
	othersGood := it.checkSubIts(val)
	if !othersGood {
		return graph.CheckLogOut(it, val, false)
	}
	it.Last = val
	return graph.CheckLogOut(it, val, true)
}
Пример #8
0
func (it *Iterator) Check(v graph.TSVal) bool {
	graph.CheckLogIn(it, v)
	if it.isAll {
		it.Last = v
		return graph.CheckLogOut(it, v, true)
	}
	var offset int
	switch it.dir {
	case graph.Subject:
		offset = 0
	case graph.Predicate:
		offset = (it.ts.hasher.Size() * 2)
	case graph.Object:
		offset = (it.ts.hasher.Size() * 2) * 2
	case graph.Provenance:
		offset = (it.ts.hasher.Size() * 2) * 3
	}
	val := v.(string)[offset : it.ts.hasher.Size()*2+offset]
	if val == it.hash {
		it.Last = v
		return graph.CheckLogOut(it, v, true)
	}
	return graph.CheckLogOut(it, v, false)
}