use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class ConjunctiveQueryTest method emptyQueryTest.
/**
* Test an empty query that must have an empty substitution
*/
@Theory
public void emptyQueryTest(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
try {
store.addAll(DlgpParser.parseAtomSet("<P>(a,b), <P>(b,c), <Q>(c,a)."));
InMemoryAtomSet queryAtomSet = new LinkedListAtomSet();
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(queryAtomSet);
CloseableIterator<Substitution> subReader;
Substitution sub;
subReader = h.execute(query, store);
Assert.assertTrue(subReader.hasNext());
sub = subReader.next();
Assert.assertEquals(0, sub.getTerms().size());
Assert.assertFalse(subReader.hasNext());
subReader.close();
} catch (Exception e) {
Assert.assertTrue(e.getMessage(), false);
}
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet in project graal by graphik-team.
the class ConjunctiveQueryTest method emptyQueryAndEmptyAtomSetTest.
/**
* Test an empty query with an empty atomSet that must have an empty
* substitution
*/
@Theory
public void emptyQueryAndEmptyAtomSetTest(Homomorphism<ConjunctiveQuery, AtomSet> h, AtomSet store) {
try {
InMemoryAtomSet queryAtomSet = new LinkedListAtomSet();
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(queryAtomSet);
CloseableIterator<Substitution> subReader;
Substitution sub;
subReader = h.execute(query, store);
Assert.assertTrue(subReader.hasNext());
sub = subReader.next();
Assert.assertEquals(0, sub.getTerms().size());
Assert.assertFalse(subReader.hasNext());
subReader.close();
} catch (Exception e) {
Assert.assertTrue(e.getMessage(), false);
}
}
use of fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet 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.atomset.LinkedListAtomSet 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.atomset.LinkedListAtomSet in project graal by graphik-team.
the class AbstractMapper method map.
@Override
public InMemoryAtomSet map(InMemoryAtomSet atomset) {
InMemoryAtomSet mapped;
try {
mapped = atomset.getClass().newInstance();
} catch (InstantiationException e) {
mapped = new LinkedListAtomSet();
} catch (IllegalAccessException e) {
mapped = new LinkedListAtomSet();
}
CloseableIteratorWithoutException<Atom> it = atomset.iterator();
while (it.hasNext()) {
mapped.add(this.map(it.next()));
}
it.close();
return mapped;
}
Aggregations