use of fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism in project graal by graphik-team.
the class NaturalRDBMSStore method match.
// /////////////////////////////////////////////////////////////////////////
// METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public CloseableIterator<Atom> match(Atom atom) throws AtomSetException {
if (!this.check(atom)) {
return Iterators.<Atom>emptyIterator();
}
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(new LinkedListAtomSet(atom));
SqlHomomorphism solver = SqlHomomorphism.instance();
try {
return new SubstitutionIterator2AtomIterator(atom, solver.execute(query, this));
} catch (HomomorphismException e) {
throw new AtomSetException(e);
}
}
use of fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism in project graal by graphik-team.
the class RdbmsAtomIterator method hasNext.
// /////////////////////////////////////////////////////////////////////////
// METHODS
// /////////////////////////////////////////////////////////////////////////
@Override
public boolean hasNext() throws IteratorException {
if (!this.hasNextCallDone) {
this.hasNextCallDone = true;
while (this.predicateIt.hasNext() && (this.atomIt == null || !this.atomIt.hasNext())) {
Predicate p = predicateIt.next();
List<Term> terms = new LinkedList<Term>();
VariableGenerator gen = new DefaultVariableGenerator("X");
for (int i = 0; i < p.getArity(); ++i) {
terms.add(gen.getFreshSymbol());
}
InMemoryAtomSet atomSet = new LinkedListAtomSet();
Atom atom = new DefaultAtom(p, terms);
atomSet.add(atom);
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(atomSet);
SqlHomomorphism solver = SqlHomomorphism.instance();
try {
this.atomIt = new SubstitutionIterator2AtomIterator(atom, solver.execute(query, this.store));
} catch (HomomorphismException e) {
throw new IteratorException(e);
}
}
}
return this.atomIt != null && this.atomIt.hasNext();
}
use of fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism in project graal by graphik-team.
the class AdHocRdbmsStore method match.
@Override
public CloseableIterator<Atom> match(Atom atom) throws AtomSetException {
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(new LinkedListAtomSet(atom));
SqlHomomorphism solver = SqlHomomorphism.instance();
try {
return new SubstitutionIterator2AtomIterator(atom, solver.execute(query, this));
} catch (HomomorphismException e) {
throw new AtomSetException(e);
}
}
use of fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism in project graal by graphik-team.
the class AdHocRdbmsStore method atomsByPredicate.
@Override
public CloseableIterator<Atom> atomsByPredicate(Predicate p) throws AtomSetException {
List<Term> terms = new LinkedList<Term>();
for (int i = 0; i < p.getArity(); ++i) {
terms.add(DefaultTermFactory.instance().createVariable("X" + i));
}
Atom atom = DefaultAtomFactory.instance().create(p, terms);
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(new LinkedListAtomSet(atom));
SqlHomomorphism solver = SqlHomomorphism.instance();
try {
return new SubstitutionIterator2AtomIterator(atom, solver.execute(query, this));
} catch (HomomorphismException e) {
throw new AtomSetException(e);
}
}
use of fr.lirmm.graphik.graal.store.rdbms.homomorphism.SqlHomomorphism in project graal by graphik-team.
the class NaturalRDBMSStore method atomsByPredicate.
@Override
public CloseableIterator<Atom> atomsByPredicate(Predicate p) throws AtomSetException {
if (!this.check(p)) {
return Iterators.<Atom>emptyIterator();
}
List<Term> terms = new LinkedList<Term>();
for (int i = 0; i < p.getArity(); ++i) {
terms.add(DefaultTermFactory.instance().createVariable("X" + i));
}
Atom atom = DefaultAtomFactory.instance().create(p, terms);
ConjunctiveQuery query = DefaultConjunctiveQueryFactory.instance().create(new LinkedListAtomSet(atom));
SqlHomomorphism solver = SqlHomomorphism.instance();
try {
return new SubstitutionIterator2AtomIterator(atom, solver.execute(query, this));
} catch (HomomorphismException e) {
throw new AtomSetException(e);
}
}
Aggregations