【问题标题】:repository created via RepositoryManager not behaving the same as repo created via workbench通过 RepositoryManager 创建的存储库与通过工作台创建的存储库的行为不同
【发布时间】:2013-06-26 20:24:40
【问题描述】:

我使用以下代码创建了芝麻原生 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);

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

内存存储的行为相同。

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

我上面的代码有什么问题?

【问题讨论】:

  • 这条线对我来说可能是个麻烦。 backendConfig = new ForwardChainingRDFSInferencerConfig(backendConfig);你能解释一下吗??

标签: sesame rdfstore


【解决方案1】:

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

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

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-02-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多