use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.
the class AbstractRdbmsStore method createPredicateTable.
/**
* Create a table associated to the specified predicate and return the table
* informations.
*
* @param predicate
* @return the table informations.
* @throws AtomSetException
*/
protected DBTable createPredicateTable(Predicate predicate) throws AtomSetException {
String tableName = this.getFreshPredicateTableName(predicate);
DBTable table = null;
if (predicate.getArity() >= 1) {
Statement stat = this.createStatement();
table = generateNewDBTableData(tableName, predicate.getArity());
String query = this.getConjunctiveQueryTranslator().translateCreateTable(table);
try {
stat.executeUpdate(query);
} catch (SQLException e) {
throw new AtomSetException("Error during table creation: " + query, e);
}
if (stat != null) {
try {
stat.close();
} catch (SQLException e) {
throw new AtomSetException(e);
}
}
// add to the local map
this.predicateMap.put(predicate, table);
} else {
throw new AtomSetException("Unsupported arity 0");
}
return table;
}
use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.
the class Neo4jStore method getTerms.
@Override
public Set<Term> getTerms() throws AtomSetException {
TreeSet<Term> set = new TreeSet<Term>();
CloseableIterator<Term> it = this.termsIterator();
try {
while (it.hasNext()) {
set.add(it.next());
}
} catch (IteratorException e) {
throw new AtomSetException("An errors occurs while iterating terms", e);
}
it.close();
return set;
}
use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.
the class AbstractRdbmsBatchProcessor method flush.
@Override
public void flush() throws AtomSetException {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("batch flush, size=" + MAX_BATCH_SIZE);
}
if (this.statement != null) {
try {
this.statement.executeBatch();
this.unflushedAtoms = 0;
} catch (SQLException e) {
throw new AtomSetException(e);
}
}
}
use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.
the class StoreTest method bugConcurrentModificationException.
@Theory
public void bugConcurrentModificationException(InMemoryAtomSet store) throws IteratorException, RuleApplicationException, AtomSetException {
Assume.assumeTrue(store instanceof Store);
Rule r = DlgpParser.parseRule("<T>(Z,W), <P>(Y,W) :- <P>(X,Y).");
store.addAll(DlgpParser.parseAtomSet("<P>(a,a)."));
try {
DefaultRuleApplier<InMemoryAtomSet> applier = new DefaultRuleApplier<InMemoryAtomSet>();
applier.apply(r, store);
applier.apply(r, store);
} catch (Exception e) {
Assert.fail();
}
}
use of fr.lirmm.graphik.graal.api.core.AtomSetException in project graal by graphik-team.
the class TestUtil method getStores.
public static RdbmsStore[] getStores() {
if (defaultRdbms != null) {
try {
defaultRdbms.getDriver().getConnection().createStatement().executeQuery("DROP SCHEMA PUBLIC CASCADE");
} catch (SQLException e) {
throw new Error(e);
}
defaultRdbms.close();
}
if (plainTableRdbms != null) {
try {
plainTableRdbms.getDriver().getConnection().createStatement().executeQuery("DROP SCHEMA PUBLIC CASCADE");
} catch (SQLException e) {
throw new Error(e);
}
plainTableRdbms.close();
}
try {
defaultRdbms = new AdHocRdbmsStore(new HSQLDBDriver(DEFAULT_TEST, null));
plainTableRdbms = new NaturalRDBMSStore(new HSQLDBDriver(PLAIN_TABLE_TEST, null));
} catch (AtomSetException e) {
throw new Error(e);
} catch (SQLException e) {
throw new Error(e);
}
return new RdbmsStore[] { defaultRdbms, plainTableRdbms };
}
Aggregations