use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class AtomTest method equalsTest.
@Test
public void equalsTest() {
Predicate predicate = new Predicate("pred", 3);
Term[] terms = new Term[3];
terms[0] = new DefaultVariable("X");
terms[1] = new DefaultConstant("a");
terms[2] = new DefaultConstant("b");
Atom atom = new DefaultAtom(predicate, Arrays.asList(terms));
Assert.assertTrue("Atom not equals itself", atom.equals(atom));
Assert.assertTrue("Atom not equals it clone", atom.equals(new DefaultAtom(atom)));
Predicate otherPred = new Predicate("otherPred", 3);
Term[] otherTerms = new Term[3];
otherTerms[0] = new DefaultVariable("Y");
otherTerms[1] = new DefaultConstant("b");
otherTerms[2] = new DefaultConstant("b");
Atom other = new DefaultAtom(otherPred, Arrays.asList(terms));
Assert.assertFalse("Atom equals an other atom with other predicate", atom.equals(other));
other = new DefaultAtom(predicate, Arrays.asList(otherTerms));
Assert.assertFalse("Atom equals an other atom with other terms", atom.equals(other));
other = new DefaultAtom(atom);
other.setPredicate(otherPred);
Assert.assertFalse("Atom equals a copy with modified predicate", predicate.equals(other));
other = new DefaultAtom(atom);
other.setTerm(2, terms[0]);
Assert.assertFalse("Atom equals a copy with modified terms", atom.equals(other));
}
use of fr.lirmm.graphik.graal.api.core.Predicate in project graal by graphik-team.
the class BreadthFirstChase method dispatchNewData.
// /////////////////////////////////////////////////////////////////////////
// PRIVATE CLASS
// /////////////////////////////////////////////////////////////////////////
protected void dispatchNewData(Collection<Atom> newData) throws ChaseException {
for (Atom a : newData) {
Predicate p = a.getPredicate();
for (Rule r : ruleSet.getRulesByBodyPredicate(p)) {
if (linearRuleCheck(r)) {
AtomSet set = nextRulesToCheck.get(r);
if (set == null) {
set = new DefaultInMemoryGraphStore();
nextRulesToCheck.put(r, set);
}
try {
set.add(a);
} catch (AtomSetException e) {
throw new ChaseException("Exception while adding data into a tmp store", e);
}
} else {
nextRulesToCheck.put(r, atomSet);
}
}
}
}
Aggregations