通过RepositoryManager创建的存储库与通过工作台创建的存储库的行为不同

时间:2013-06-26 20:24:40

标签: sesame rdfstore

我使用以下代码创建sesame本机java商店:

创建本机Java商店:

  // 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 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);

当我在此仓库中存储数据并进行查询时,结果与使用工作台创建的存储库返回的结果不同。我在结果集中得到重复/多个条目。

内存存储的行为相同。

我还观察到我的三元组属于空白上下文,而不是通过工作台创建的存储库中的情况。

上面的代码出了什么问题?

1 个答案:

答案 0 :(得分:0)

据我所见,您的代码没有任何问题。如果从Workbench创建的商店的行为不同,这很可能意味着它配置了不同的SAIL堆栈。

最有可能的差异就是这一点:

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

您已在此处使用推理器配置了您的存储库。如果通过工作台创建的存储库使用推理器,您将在相同的查询上获得不同的结果(有时,包括明显的重复结果)。

如果您认为这是一个问题,您可以通过两种方式解决此问题。一个是(当然)只是没有用推理器创建你的存储库。另一种是禁用特定查询的推理。在Workbench中,您可以通过在查询屏幕中禁用“包含推断语句”复选框来执行此操作。以编程方式,您可以在准备好的查询对象上使用Query.setIncludeInferred(false)来执行此操作。有关详细信息,请参阅javadoc

相关问题