Search in sources :

Example 46 with AtomSetException

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;
}
Also used : DBTable(fr.lirmm.graphik.graal.store.rdbms.util.DBTable) SQLException(java.sql.SQLException) Statement(java.sql.Statement) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException)

Example 47 with AtomSetException

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;
}
Also used : IteratorException(fr.lirmm.graphik.util.stream.IteratorException) TreeSet(java.util.TreeSet) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) Term(fr.lirmm.graphik.graal.api.core.Term)

Example 48 with AtomSetException

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);
        }
    }
}
Also used : SQLException(java.sql.SQLException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException)

Example 49 with AtomSetException

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();
    }
}
Also used : InMemoryAtomSet(fr.lirmm.graphik.graal.api.core.InMemoryAtomSet) RdbmsStore(fr.lirmm.graphik.graal.store.rdbms.RdbmsStore) Store(fr.lirmm.graphik.graal.api.store.Store) TripleStore(fr.lirmm.graphik.graal.api.store.TripleStore) Rule(fr.lirmm.graphik.graal.api.core.Rule) RuleApplicationException(fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) SQLException(java.sql.SQLException) HomomorphismException(fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException) ParseException(fr.lirmm.graphik.graal.api.io.ParseException) IteratorException(fr.lirmm.graphik.util.stream.IteratorException) DefaultRuleApplier(fr.lirmm.graphik.graal.forward_chaining.rule_applier.DefaultRuleApplier) Theory(org.junit.experimental.theories.Theory)

Example 50 with AtomSetException

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 };
}
Also used : SQLException(java.sql.SQLException) AtomSetException(fr.lirmm.graphik.graal.api.core.AtomSetException) HSQLDBDriver(fr.lirmm.graphik.graal.store.rdbms.driver.HSQLDBDriver) RdbmsStore(fr.lirmm.graphik.graal.store.rdbms.RdbmsStore) AdHocRdbmsStore(fr.lirmm.graphik.graal.store.rdbms.adhoc.AdHocRdbmsStore) NaturalRDBMSStore(fr.lirmm.graphik.graal.store.rdbms.natural.NaturalRDBMSStore) AdHocRdbmsStore(fr.lirmm.graphik.graal.store.rdbms.adhoc.AdHocRdbmsStore)

Aggregations

AtomSetException (fr.lirmm.graphik.graal.api.core.AtomSetException)69 IteratorException (fr.lirmm.graphik.util.stream.IteratorException)26 SQLException (java.sql.SQLException)26 Atom (fr.lirmm.graphik.graal.api.core.Atom)25 Term (fr.lirmm.graphik.graal.api.core.Term)23 HomomorphismException (fr.lirmm.graphik.graal.api.homomorphism.HomomorphismException)12 Substitution (fr.lirmm.graphik.graal.api.core.Substitution)11 Statement (java.sql.Statement)11 DBTable (fr.lirmm.graphik.graal.store.rdbms.util.DBTable)10 Predicate (fr.lirmm.graphik.graal.api.core.Predicate)9 BacktrackException (fr.lirmm.graphik.graal.homomorphism.BacktrackException)9 ConjunctiveQuery (fr.lirmm.graphik.graal.api.core.ConjunctiveQuery)7 TreeSet (java.util.TreeSet)7 SQLQuery (fr.lirmm.graphik.graal.store.rdbms.util.SQLQuery)6 CloseableIteratorAdapter (fr.lirmm.graphik.util.stream.CloseableIteratorAdapter)6 RuleApplicationException (fr.lirmm.graphik.graal.api.forward_chaining.RuleApplicationException)5 LinkedListAtomSet (fr.lirmm.graphik.graal.core.atomset.LinkedListAtomSet)5 TreeMap (java.util.TreeMap)5 AtomSet (fr.lirmm.graphik.graal.api.core.AtomSet)4 Variable (fr.lirmm.graphik.graal.api.core.Variable)4