Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[rdf4j-dev] ForwardChainingRDFSInferencer issue

Hi,

We're currently upgrading from RDF4J 2.4.5 to 3.7.7 and have encountered an issue with the ForwardChainingRDFSInferencer Sail. What happens is that when you clear a specific context and then try and re-add a statement you had in that context it doesn't get re-added. That is unless you execute some other operation like a getStatements which flushes the changes between the clear and the add. It doesn't happen without the inferencer or with the new SchemaCachingRDFSInferencer. I have attached a Java class which reproduces the issue.

I have noticed that it seems to be fixed in 4.1.1 but I can't find the ticket for it on github. It is unlikely we will be able to upgrade to that version so we will probably need to either patch 3.7.7. ourselves or switch to SchemaCachingRDFSInferencer. I'm not sure how safe it is at the moment to just switch over to that class. Could you point me in the right direction of the github issue please so I can see the fix?

Thanks,
Ieuan
import org.eclipse.rdf4j.model.IRI;
import org.eclipse.rdf4j.model.Resource;
import org.eclipse.rdf4j.model.Statement;
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
import org.eclipse.rdf4j.model.vocabulary.RDF;
import org.eclipse.rdf4j.repository.Repository;
import org.eclipse.rdf4j.repository.RepositoryConnection;
import org.eclipse.rdf4j.repository.RepositoryResult;
import org.eclipse.rdf4j.repository.sail.SailRepository;
import org.eclipse.rdf4j.sail.inferencer.fc.ForwardChainingRDFSInferencer;
import org.eclipse.rdf4j.sail.memory.MemoryStore;

public class ClearContextTest {


    public static void main(String[] args) {

        final MemoryStore memoryStore = new MemoryStore();
        Repository testRepository = new SailRepository(new ForwardChainingRDFSInferencer(memoryStore));

        final IRI context = SimpleValueFactory.getInstance().createIRI("test:context");

        try (RepositoryConnection connection = testRepository.getConnection()) {
            connection.begin();
            addStatementToContext(connection, context);
            connection.commit();
        }

        try (RepositoryConnection connection = testRepository.getConnection()) {
            connection.begin();
            connection.clear(context);
            //connection.getStatements(null, null, null, context);
            addStatementToContext(connection, context);
            connection.commit();
        }

        try (RepositoryConnection connection = testRepository.getConnection()) {
            final RepositoryResult<Statement> statements = connection.getStatements(null, null, null, context);
            for (Statement statement : statements) {
                System.out.println(statement);
            }
        }
    }

    private static void addStatementToContext(RepositoryConnection connection, Resource context) {
        connection.add(SimpleValueFactory.getInstance().createIRI("test:subject"),
                RDF.TYPE,
                SimpleValueFactory.getInstance().createIRI("test:object"), context);
    }
}

Back to the top