use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.
the class DefaultConjunctiveQueryFactory method create.
@Override
public ConjunctiveQuery create(Atom atom, List<Term> ans) {
LinkedList<Atom> list = new LinkedList<Atom>();
list.add(atom);
return new DefaultConjunctiveQuery(new LinkedListAtomSet(list), ans);
}
use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.
the class ConjunctiveQueryWithCompilation method issueWithAtom2SubstitutionConverter.
@Theory
public void issueWithAtom2SubstitutionConverter(RulesCompilationFactory factory, AtomSet store) throws Exception {
Assume.assumeFalse(store instanceof TripleStore);
HomomorphismWithCompilation<ConjunctiveQuery, AtomSet> h = AtomicQueryHomomorphism.instance();
store.addAll(DlgpParser.parseAtomSet("<P>(a,a)."));
RuleSet rules = new LinkedListRuleSet();
rules.add(DlgpParser.parseRule("<Q>(X,Y,X) :- <P>(X,Y)."));
RulesCompilation comp = factory.create();
comp.compile(rules.iterator());
StaticChase.executeChase(store, rules);
ConjunctiveQuery query = DlgpParser.parseQuery("?(X) :- <Q>(X,Y,Y).");
CloseableIterator<Substitution> results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
Assert.assertTrue(results.hasNext());
results.close();
query = DlgpParser.parseQuery("?(Y) :- <Q>(X,Y,Y).");
results = h.execute(new DefaultConjunctiveQuery(query), store, comp);
Assert.assertTrue(results.hasNext());
results.close();
}
use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.
the class LiteralsTest method integerType.
@Theory
public void integerType(AtomSet store) throws Exception {
Atom a = DlgpParser.parseAtom("<AGE>(a,1).");
store.add(a);
ConjunctiveQuery q = new DefaultConjunctiveQuery(new LinkedListAtomSet(a), Collections.<Term>emptyList());
Assert.assertTrue(SmartHomomorphism.instance().execute(q, store).hasNext());
Atom b = store.iterator().next();
Assert.assertEquals(a, b);
}
use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.
the class DefaultConjunctiveQueryFactory method create.
@Override
public ConjunctiveQuery create(Atom atom) {
LinkedList<Atom> list = new LinkedList<Atom>();
list.add(atom);
return new DefaultConjunctiveQuery(new LinkedListAtomSet(list));
}
use of fr.lirmm.graphik.graal.core.DefaultConjunctiveQuery in project graal by graphik-team.
the class ConjunctiveQueryFixedBugTest method GraphAtomSetQuery.
/**
* Query using an DefaultInMemoryGraphAtomSet.
*
* @param h
* @param store
*/
@Theory
public void GraphAtomSetQuery(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
try {
InMemoryAtomSet atomset = new DefaultInMemoryGraphStore();
atomset.add(DlgpParser.parseAtom("<P>(X)."));
ConjunctiveQuery query = new DefaultConjunctiveQuery(atomset);
CloseableIterator<Substitution> subReader;
subReader = h.execute(query, store);
Assert.assertFalse(subReader.hasNext());
subReader.close();
} catch (Exception e) {
Assert.assertTrue(e.getMessage(), false);
}
}
Aggregations