repository created via RepositoryManager not behaving the same as repo created via workbench

StackOverflow https://stackoverflow.com/questions/17329768

  •  01-06-2022
  •  | 
  •  

Question

I create sesame native java store using following code:

Create a native java store:

  // create a configuration for the SAIL stack
  boolean persist = true;
  String indexes = "spoc,posc,cspo";
  SailImplConfig backendConfig = new NativeStoreConfig(indexes);
  // stack an inferencer config on top of our backend-config
  backendConfig = new ForwardChainingRDFSInferencerConfig(backendConfig);
  // create a configuration for the repository implementation
  RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(backendConfig);
  RepositoryConfig repConfig = new RepositoryConfig(repositoryId, repositoryTypeSpec);
  repConfig.setTitle(repositoryId);
  manager.addRepositoryConfig(repConfig);
  Repository repository = manager.getRepository(repositoryId);

create a in-memory store:

  // create a configuration for the SAIL stack
  boolean persist = true;
  SailImplConfig backendConfig = new MemoryStoreConfig(persist);
  // stack an inferencer config on top of our backend-config
  backendConfig = new ForwardChainingRDFSInferencerConfig(backendConfig);
  // create a configuration for the repository implementation
  RepositoryImplConfig repositoryTypeSpec = new SailRepositoryConfig(backendConfig);
  RepositoryConfig repConfig = new RepositoryConfig(repositoryId, repositoryTypeSpec);
  repConfig.setTitle(repositoryId);
  manager.addRepositoryConfig(repConfig);
  Repository repository = manager.getRepository(repositoryId);

When I store data in this repo and query back, the results are not same as the results returned from repository created using workbench. I get duplicate/multiple entries in my resultset.

Same behavior for in-memory store.

I also observed that my triples belong to a blank context which is not the case in repository created via workbench.

What is wrong with my code above?

Was it helpful?

Solution

There is nothing wrong with your code, as far as I can see. If the store as created from the Workbench behaves differently, this most likely means that it's configured with a different SAIL stack.

The most likely candidate for the difference is this bit:

// stack an inferencer config on top of our backend-config
backendConfig = new ForwardChainingRDFSInferencerConfig(backendConfig);

You have configured your repository with a reasoner on top here. If the repository created via the workbench does not use a reasoner, you will get different results on identical queries (including, sometimes, apparent duplicate results).

If you consider this a problem, you can fix this in two ways. One is (of course) to simply not create your repository with a reasoner on top. The other is to disable reasoning for specific queries. In the Workbench, you can do this by disabling the "Include inferred statements" checkbox in the query screen. Programmatically, you can do this by using Query.setIncludeInferred(false) on your prepared query object. See the javadoc for details.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top