You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@marmotta.apache.org by ss...@apache.org on 2013/11/08 11:44:08 UTC

svn commit: r1539972 - in /incubator/marmotta/site/trunk: content/markdown/kiwi/index.md.vm content/markdown/kiwi/sparql.md.vm content/site.xml pom.xml

Author: sschaffert
Date: Fri Nov  8 10:44:08 2013
New Revision: 1539972

URL: http://svn.apache.org/r1539972
Log:
added description of KiWi SPARQL module

Added:
    incubator/marmotta/site/trunk/content/markdown/kiwi/sparql.md.vm
      - copied, changed from r1539962, incubator/marmotta/site/trunk/content/markdown/kiwi/reasoner.md.vm
Modified:
    incubator/marmotta/site/trunk/content/markdown/kiwi/index.md.vm
    incubator/marmotta/site/trunk/content/site.xml
    incubator/marmotta/site/trunk/pom.xml

Modified: incubator/marmotta/site/trunk/content/markdown/kiwi/index.md.vm
URL: http://svn.apache.org/viewvc/incubator/marmotta/site/trunk/content/markdown/kiwi/index.md.vm?rev=1539972&r1=1539971&r2=1539972&view=diff
==============================================================================
--- incubator/marmotta/site/trunk/content/markdown/kiwi/index.md.vm (original)
+++ incubator/marmotta/site/trunk/content/markdown/kiwi/index.md.vm Fri Nov  8 10:44:08 2013
@@ -11,6 +11,7 @@ Currently (Apache Marmotta v3.0), the Ki
 * kiwi-triplestore: implements triple persistence in a relational database
 * kiwi-transactions: adds extended transaction support to a notifying sail (notifies on transaction commit)
 * kiwi-tripletable: support for in-memory indexed Java Collections for OpenRDF statements
+* kiwi-sparql: implements native SPARQL support by translating some critical constructs directly into SQL
 * kiwi-contextaware: support for context-aware OpenRDF Sails (allow overriding contexts in statements)
 * kiwi-reasoner: adds a rule-based forward chaining reasoner with truth maintenance for the KiWi triple store
 * kiwi-versioning: adds versioning of updates to a KiWi triple store

Copied: incubator/marmotta/site/trunk/content/markdown/kiwi/sparql.md.vm (from r1539962, incubator/marmotta/site/trunk/content/markdown/kiwi/reasoner.md.vm)
URL: http://svn.apache.org/viewvc/incubator/marmotta/site/trunk/content/markdown/kiwi/sparql.md.vm?p2=incubator/marmotta/site/trunk/content/markdown/kiwi/sparql.md.vm&p1=incubator/marmotta/site/trunk/content/markdown/kiwi/reasoner.md.vm&r1=1539962&r2=1539972&rev=1539972&view=diff
==============================================================================
--- incubator/marmotta/site/trunk/content/markdown/kiwi/reasoner.md.vm (original)
+++ incubator/marmotta/site/trunk/content/markdown/kiwi/sparql.md.vm Fri Nov  8 10:44:08 2013
@@ -1,81 +1,84 @@
-# KiWi Reasoner #
+# KiWi Native SPARQL #
+
+The KiWi SPARQL module offers optimized [SPARQL 1.1][http://www.w3.org/TR/sparql11-query/] query support for typical
+cases by translating parts of a SPARQL query directly into SQL. Currently, the following SPARQL constructs are translated:
+
+* JOIN between statement patterns: in case a part of a SPARQL query is a join between statement patterns, this part
+  will be optimized by translating the whole JOIN into a single SQL query involving all patterns
+* FILTER for a statement pattern or join of statement patterns: in this case, the filter conditions are translated
+  into SQL WHERE conditions on the nodes occurring in the patterns; most SPARQL constructs are supported (including
+  regular expressions), including (starting with Marmotta 3.2) most XPath functions defined in the SPARQL specification
+* full-text search (Marmotta 3.2 and above): adds additional full-text search functions to SPARQL that can be used in
+  the FILTER part of a query (see below)
+
+Note that KiWi SPARQL does not translate the complete query to SQL. Instead, it walks through the abstract syntax
+tree of a query and optimizes those parts where it can reliably do so and where it makes sense. This allows us to
+make efficient use of the performance of the underlying database while at the same time retaining the flexibility
+of full SPARQL 1.1. Specifically, the following popular constructs are currently *not* completely translated:
+
+* OPTIONAL (left join): the SPARQL OPTIONAL has a slighly different semantics than its SQL left join counterpart, so
+  OPTIONAL can at the moment not be optimized (but those parts of a query that are normal joins will still be optimized)
+* DISTINCT, ORDER BY, GROUP BY: since KiWi SPARQL currently only optimizes the query part and not the projection,
+  expressions operating on the query result like those mentioned will not be translated and instead evaluated in-memory;
+
 
-The KiWi reasoner is a powerful and flexible rule-based reasoner that can be used on top of a KiWi Triple Store. Its
-expressivity is more or less the same as Datalog, i.e. it will always terminate and can be evaluated in polynomial
-time (data complexity not taking into account the number of rules). In the context of triple stores, the KiWi
-reasoner can be used to easily implement the implicit semantics of different domain vocabularies. For example, the
-following rule program expresses SKOS semantics:
-
-    @prefix skos: <http://www.w3.org/2004/02/skos/core#>
-
-    ($1 skos:broader $2) -> ($1 skos:broaderTransitive $2)
-    ($1 skos:narrower $2) -> ($1 skos:narrowerTransitive $2)
-
-    ($1 skos:broaderTransitive $2), ($2 skos:broaderTransitive $3) -> ($1 skos:broaderTransitive $3)
-    ($1 skos:narrowerTransitive $2), ($2 skos:narrowerTransitive $3) -> ($1 skos:narrowerTransitive $3)
-
-    ($1 skos:broader $2) -> ($2 skos:narrower $1)
-    ($1 skos:narrower $2) -> ($2 skos:broader $1)
-
-    ($1 skos:broader $2) -> ($1 skos:related $2)
-    ($1 skos:narrower $2) -> ($1 skos:related $2)
-    ($1 skos:related $2) -> ($2 skos:related $1)
-
-Similarly, the reasoner can be used for expressing RDFS subclass and domain inference, as well as a subset of OWL
-semantics (the one that is most interesting :-P ). Beyond RDFS and OWL, it also allows implementing domain-specific
-rule semantics. Additional examples for programs can be found in the source code.
-
-The reasoner is implemented as a incremental forward-chaining reasoner with truth maintenance. In practice, this
-means that:
-
-* incremental reasoning is triggered after a transaction commits successfully; the reasoner will then apply those
-  rules that match with at least one of the newly added triples
-* inferred triples are then materialized in the triple store in the inferred context (see the configuration of
-  the triple store above) and are thus available in the same way as base triples
-* truth maintenance keeps track of the reasons (i.e. rules and triples) why an inferred triple exists; this helps
-  making updates (especially removals of rules and triples) very efficient without requiring to completely
-  recompute all inferred triples
 
 Maven Artifact
 --------------
 
-The KiWi Reasoner can only be used in conjunction with the KiWi Triple Store, because it maintains most of its
-information in the relational database (e.g. the data structures for truth maintenance) and directly translates
-rule body query patterns into SQL. To include it in a project that uses the KiWi Triple Store, add the following
+The KiWi SPARQL optimizations can only be used in conjunction with the KiWi Triple Store, because it works directly on
+the internal KiWi data structures. To include it in a project that uses the KiWi Triple Store, add the following
 dependency to your Maven project:
 
      <dependency>
          <groupId>org.apache.marmotta</groupId>
-         <artifactId>kiwi-reasoner</artifactId>
+         <artifactId>kiwi-sparql</artifactId>
          <version>${projectVersion}</version>
      </dependency>
 
 
-Code Usage
-----------
+Full-Text Search (3.2 and above)
+--------------------------------
+
+Starting with the development version of Apache Marmotta 3.2, there is also full-text search support in SPARQL queries.
+Full-text search works over the literal values of nodes and differs from normal literal queries or regexp filters in that
+it applies language-specific lingustic processing (e.g. stemming and stop-word elimination). The KiWi SPARQL module
+comes with its own namespace for SPARQL extensions:
+
+    PREFIX mm: <http://marmotta.apache.org/vocabulary/sparql-functions#>
+
+Full-text search currently offers two SPARQL functions that can be used in the FILTER part of a query and return
+boolean values (found or not found):
+
+* `fulltext-search(text, query, [language])`: searches "text" for the words occurring in "query", optionally applying
+  the language-specific processing for the given language; query is a simple text literal (list of words) without any
+  boolean connectors; words are AND connected, i.e. all words have to be found in the text for a successful match
+* `fulltext-query(text, query, [language])`: searches "text" using the boolean query string passed in "query", optionally
+  applying language-specific processing for the given language; query is a boolean query string following the
+  [syntax used by PostgreSQL][http://www.postgresql.org/docs/9.3/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES]
+
+Note that full-text search is only available when using backend databases that support this functionality (currently only
+PostgreSQL and MySQL). Only PostgreSQL has real support for language specific processing. Also note that performance
+heavily depends on the availability of an appropriate full-text index in the database. The KiWi SPARQL module will
+automatically create full-text indexes for the languages configured in the KiWiConfiguration used for creating the
+triple store.
+
+The following example searches for the word "software" occurring in the dc:description field of the resource using the
+literal language of dc:description:
+
+    PREFIX foaf: <http://xmlns.com/foaf/0.1/>
+    PREFIX dc: <http://purl.org/dc/elements/1.1/>
+    PREFIX mm: <http://marmotta.apache.org/vocabulary/sparql-functions#>
+
+    SELECT ?p1 ?fn ?age WHERE {
+        ?p1 foaf:name ?fn .
+        ?p1 foaf:age ?age .
+        ?p1 dc:description ?desc .
+        FILTER( mm:fulltext-search(str(?desc), "software", lang(?desc)) )
+    }
+
+
 
-The KiWi Reasoner can be stacked into any [sail stack](http://openrdf.callimachus.net/sesame/2.7/docs/users.docbook?view#chapter-repository-api) 
-with a transactional sail (see kiwi-transactions) and a KiWi Store at its root. The relevant database tables are 
-created automatically when the repository is initialised.A simple repository with reasoner is initialized as follows:
-
-    KiWistore store = new KiWiStore("test",jdbcUrl,jdbcUser,jdbcPass,dialect, "http://localhost/context/default", "http://localhost/context/inferred");
-    KiWiTransactionalSail tsail = new KiWiTransactionalSail(store);
-    KiWiReasoningSail rsail = new KiWiReasoningSail(tsail, new ReasoningConfiguration());
-    Repository repository = new SailRepository(rsail);
-    repository.initialize();
-
-    // add a reasoning program
-    rsail.addProgram("simple", this.getClass().getResourceAsStream("simple.kwrl"));
-
-    // update an existing reasoning program
-    rsail.updateProgram("simple", ...);
-
-    // run full reasoning (delete all existing inferred triples and re-create them)
-    rsail.reRunPrograms();
-
-The reasoner can have any number of reasoning programs. The concept of a program is merely introduced to group
-different tasks. Internally, all reasoning rules are considered as an unordered collection, regardless which
-program they belong to.
 
 Performance Considerations
 --------------------------

Modified: incubator/marmotta/site/trunk/content/site.xml
URL: http://svn.apache.org/viewvc/incubator/marmotta/site/trunk/content/site.xml?rev=1539972&r1=1539971&r2=1539972&view=diff
==============================================================================
--- incubator/marmotta/site/trunk/content/site.xml (original)
+++ incubator/marmotta/site/trunk/content/site.xml Fri Nov  8 10:44:08 2013
@@ -91,6 +91,7 @@
             <item name="Introduction" href="kiwi/index.html"/>
             <item name="Store" href="kiwi/triplestore.html"/>
             <item name="Transactions" href="kiwi/transactions.html"/>
+            <item name="SPARQL" href="kiwi/sparql.html"/>
             <item name="Triple Table" href="kiwi/tripletable.html"/>
             <item name="Reasoner" href="kiwi/reasoner.html" />
             <item name="Versioning" href="kiwi/versioning.html"/>

Modified: incubator/marmotta/site/trunk/pom.xml
URL: http://svn.apache.org/viewvc/incubator/marmotta/site/trunk/pom.xml?rev=1539972&r1=1539971&r2=1539972&view=diff
==============================================================================
--- incubator/marmotta/site/trunk/pom.xml (original)
+++ incubator/marmotta/site/trunk/pom.xml Fri Nov  8 10:44:08 2013
@@ -882,12 +882,6 @@
             <artifactId>marmotta-core</artifactId>
             <version>${project.version}</version>
             <classifier>sources</classifier>
-            <exclusions>
-                <exclusion>
-                    <groupId>org.scannotation</groupId>
-                    <artifactId>scannotation</artifactId>
-                </exclusion>
-            </exclusions>
         </dependency>
         -->
         <dependency>