This project has retired. For details please refer to its Attic page.
Apache Marmotta - KiWi Triple Table

KiWi Triple Table

The KiWi Triple Table offers efficient Java Collections over OpenRDF Statements. It implements the Java Set interface, but offers query support (listing triples with wildcards) with in-memory SPOC and CSPO indexes. This is useful if you want to keep large temporary in-memory collections of triples and is e.g. used by the kiwi-transactions module for keeping track of added and removed triples in the transaction data. It can also be used for caching purposes.

Maven Artifact

The KiWi Triple Table can be used with any OpenRDF repository, it is merely a container for triples. To use the library in your own project, add the following Maven dependency to your project:

 <dependency>
     <groupId>org.apache.marmotta</groupId>
     <artifactId>kiwi-tripletable</artifactId>
     <version>3.3.0</version>
 </dependency>

Code Usage

As the triple table implements the Set interface, usage is very simple. The following code block illustrates how:

TripleTable<Statement> triples = new TripleTable<Statement>();

// add some triples
triples.add(valueFactory.createStatement(s1,p1,o1);
triples.add(valueFactory.createStatement(s2,p2,o2);
...

// iterate over all triples
for(Statement t : triples) {
    // do something with t
}

// list only triples with subject s1
for(Statement t : triples.listTriples(s1,null,null,null)) {
    // do something with t
}

Note that the KiWi Triple Table does not implement a complete repository and therefore neither offers its own value factory nor allows persistence of statements or connection management. In case you need an in-memory repository with support for all these features, consider using a OpenRDF memory sail.