Пример #1
0
  /**
   * Test that can be used to verify that we are doing an efficient scan for the distinct predicates
   * (distinct key prefix scan).
   */
  public void test_rdf01_distinctPrefixScan() throws Exception {

    final Properties properties = super.getProperties();

    // override the default axiom model.
    properties.setProperty(
        com.bigdata.rdf.store.AbstractTripleStore.Options.AXIOMS_CLASS, NoAxioms.class.getName());

    final AbstractTripleStore store = getStore(properties);

    try {

      final BigdataValueFactory f = store.getValueFactory();

      final URI A = f.createURI("http://www.foo.org/A");
      final URI B = f.createURI("http://www.foo.org/B");
      final URI C = f.createURI("http://www.foo.org/C");
      final URI D = f.createURI("http://www.foo.org/D");
      final URI E = f.createURI("http://www.foo.org/E");

      final URI rdfType = RDF.TYPE;
      final URI rdfProperty = RDF.PROPERTY;

      /*
       * Three statements that will trigger the rule, but two statements
       * share the same predicate. When it does the minimum amount of
       * work, the rule will fire for each distinct predicate in the KB --
       * for this KB that is only twice.
       */
      store.addStatement(A, B, C);
      store.addStatement(C, B, D);
      store.addStatement(A, E, C);

      assertTrue(store.hasStatement(A, B, C));
      assertTrue(store.hasStatement(C, B, D));
      assertTrue(store.hasStatement(A, E, C));
      assertFalse(store.hasStatement(B, rdfType, rdfProperty));
      assertFalse(store.hasStatement(E, rdfType, rdfProperty));
      assertEquals(3, store.getStatementCount());

      final Rule r = new RuleRdf01(store.getSPORelation().getNamespace(), store.getVocabulary());

      applyRule(store, r, 2 /* solutionCount */, 2 /* mutationCount */);

      /*
       * validate the state of the primary store.
       */
      assertTrue(store.hasStatement(A, B, C));
      assertTrue(store.hasStatement(C, B, D));
      assertTrue(store.hasStatement(A, E, C));
      assertTrue(store.hasStatement(B, rdfType, rdfProperty));
      assertTrue(store.hasStatement(E, rdfType, rdfProperty));
      assertEquals(5, store.getStatementCount());

    } finally {

      store.__tearDownUnitTest();
    }
  }
Пример #2
0
  /** Basic test of rule semantics. */
  public void test_rdf01() throws Exception {

    final Properties properties = super.getProperties();

    // override the default axiom model.
    properties.setProperty(
        com.bigdata.rdf.store.AbstractTripleStore.Options.AXIOMS_CLASS, NoAxioms.class.getName());

    final AbstractTripleStore store = getStore(properties);

    try {

      final BigdataValueFactory f = store.getValueFactory();

      final URI A = f.createURI("http://www.foo.org/A");
      final URI B = f.createURI("http://www.foo.org/B");
      final URI C = f.createURI("http://www.foo.org/C");

      final URI rdfType = RDF.TYPE;
      final URI rdfProperty = RDF.PROPERTY;

      store.addStatement(A, B, C);

      assertTrue(store.hasStatement(A, B, C));
      assertFalse(store.hasStatement(B, rdfType, rdfProperty));
      assertEquals(1, store.getStatementCount());

      final Rule r = new RuleRdf01(store.getSPORelation().getNamespace(), store.getVocabulary());

      applyRule(store, r, 1 /* solutionCount*/, 1 /*mutationCount*/);

      /*
       * validate the state of the primary store.
       */
      assertTrue(store.hasStatement(A, B, C));
      assertTrue(store.hasStatement(B, rdfType, rdfProperty));
      assertEquals(2, store.getStatementCount());

    } finally {

      store.__tearDownUnitTest();
    }
  }