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

[03/10] git commit: MARMOTTA-365: moved module kiwi-tripletable to commons/sesame-tripletable

MARMOTTA-365: moved module kiwi-tripletable to commons/sesame-tripletable


Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/e0beeb7d
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/e0beeb7d
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/e0beeb7d

Branch: refs/heads/develop
Commit: e0beeb7d127578fbe65186f1997f32ee36a16974
Parents: b253b86
Author: Jakob Frank <ja...@apache.org>
Authored: Tue Nov 12 17:58:30 2013 +0100
Committer: Jakob Frank <ja...@apache.org>
Committed: Wed Nov 27 13:27:48 2013 +0100

----------------------------------------------------------------------
 commons/pom.xml                                 |   1 +
 commons/sesame-tripletable/pom.xml              |  88 ++++
 .../commons/sesame/tripletable/ByteArray.java   |  63 +++
 .../commons/sesame/tripletable/IntArray.java    | 175 +++++++
 .../commons/sesame/tripletable/TripleTable.java | 478 +++++++++++++++++++
 .../sesame/tripletable/TripleTableTest.java     | 128 +++++
 .../kiwi/reasoner/engine/ReasoningEngine.java   |   2 +-
 libraries/kiwi/kiwi-transactions/pom.xml        |   2 +-
 .../transactions/model/TransactionData.java     |   2 +-
 libraries/kiwi/kiwi-triplestore/pom.xml         |   2 +-
 .../marmotta/kiwi/caching/KiWiQueryCache.java   |   3 +-
 .../kiwi/persistence/KiWiConnection.java        | 132 +++--
 .../apache/marmotta/kiwi/sail/KiWiStore.java    |   3 +-
 .../marmotta/kiwi/sail/KiWiValueFactory.java    |   2 +-
 libraries/kiwi/kiwi-tripletable/pom.xml         |  87 ----
 .../marmotta/kiwi/model/caching/ByteArray.java  |  63 ---
 .../marmotta/kiwi/model/caching/IntArray.java   | 175 -------
 .../kiwi/model/caching/TripleTable.java         | 478 -------------------
 .../kiwi/model/caching/TripleTableTest.java     | 127 -----
 libraries/kiwi/pom.xml                          |   1 -
 .../ldcache/ldcache-backend-ehcache/pom.xml     |   2 +-
 parent/pom.xml                                  |   8 +-
 22 files changed, 1005 insertions(+), 1017 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/pom.xml
----------------------------------------------------------------------
diff --git a/commons/pom.xml b/commons/pom.xml
index 83eae52..8234d71 100644
--- a/commons/pom.xml
+++ b/commons/pom.xml
@@ -55,6 +55,7 @@
         <module>marmotta-commons</module>
         <module>sesame-filter</module>
         <module>sesame-contextaware</module>
+        <module>sesame-tripletable</module>
         <module>sesame-tools-rio-api</module>
         <module>sesame-tools-rio-ical</module>
         <module>sesame-tools-rio-rss</module>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/sesame-tripletable/pom.xml
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/pom.xml b/commons/sesame-tripletable/pom.xml
new file mode 100644
index 0000000..75e40b5
--- /dev/null
+++ b/commons/sesame-tripletable/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+        http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.marmotta</groupId>
+        <artifactId>marmotta-parent</artifactId>
+        <version>3.2.0-SNAPSHOT</version>
+        <relativePath>../../parent/</relativePath>
+    </parent>
+
+    <artifactId>sesame-tripletable</artifactId>
+    <packaging>jar</packaging>
+
+    <name>Sesame Tools: Triple Table</name>
+
+    <description>
+        Provides a simple in-memory table using the Java Collections API to access triples. Additionally, the
+        triple table offers in-memory indexes for typical query operations (e.g. listing by subject).
+    </description>
+
+    <dependencies>
+        <!-- data model -->
+        <dependency>
+            <groupId>org.openrdf.sesame</groupId>
+            <artifactId>sesame-model</artifactId>
+        </dependency>
+
+        <!-- Utilities -->
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.marmotta</groupId>
+            <artifactId>marmotta-commons</artifactId>
+        </dependency>
+
+        <dependency>
+            <artifactId>junit</artifactId>
+            <groupId>junit</groupId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <artifactId>hamcrest-core</artifactId>
+            <groupId>org.hamcrest</groupId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <artifactId>hamcrest-library</artifactId>
+            <groupId>org.hamcrest</groupId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>ch.qos.logback</groupId>
+            <artifactId>logback-classic</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-lang3</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+
+    </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
new file mode 100644
index 0000000..b4a56cf
--- /dev/null
+++ b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/ByteArray.java
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.tripletable;
+
+import java.util.Arrays;
+
+/**
+* Add file description here!
+* <p/>
+* Author: Sebastian Schaffert
+*/
+final class ByteArray implements Comparable<ByteArray> {
+
+    private byte[] data;
+
+    ByteArray(byte[] data) {
+        this.data = data;
+    }
+
+    @Override
+    public int compareTo(ByteArray o) {
+        for(int i=0; i < data.length && i < o.data.length; i++) {
+            if(((int) data[i] & 0xff) < ((int) o.data[i] & 0xff)) {
+                return -1;
+            } else if(((int)data[i] & 0xff) > ((int)o.data[i] & 0xff)) {
+                return 1;
+            }
+        }
+        return 0;
+    }
+
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        ByteArray byteArray = (ByteArray) o;
+
+        return Arrays.equals(data, byteArray.data);
+
+    }
+
+    @Override
+    public int hashCode() {
+        return data != null ? Arrays.hashCode(data) : 0;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
new file mode 100644
index 0000000..5ed0145
--- /dev/null
+++ b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/IntArray.java
@@ -0,0 +1,175 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.tripletable;
+
+import com.google.common.hash.HashCode;
+import com.google.common.hash.HashFunction;
+import com.google.common.hash.Hasher;
+import com.google.common.hash.Hashing;
+import org.openrdf.model.Resource;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+
+import java.nio.IntBuffer;
+import java.util.Arrays;
+
+/**
+ * Add file description here!
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public final class IntArray implements Comparable<IntArray> {
+
+    private static HashFunction hashFunction = Hashing.goodFastHash(32);
+
+    private int[] data;
+
+    private HashCode goodHashCode;
+
+
+    public IntArray(int[] data) {
+        this.data = data;
+    }
+
+    private void ensureHashCode() {
+        if(goodHashCode == null) {
+            Hasher hasher = hashFunction.newHasher();
+            for(int i : data) {
+                hasher.putInt(i);
+            }
+            goodHashCode = hasher.hash();
+        }
+    }
+
+    public static final IntArray createSPOCKey(Resource subject, URI property, Value object, Resource context){
+
+        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+        // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+        int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
+        int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
+        int o = object != null ? object.hashCode() : Integer.MIN_VALUE;
+        int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
+
+        IntBuffer bb = IntBuffer.allocate(4);
+        bb.put(s);
+        bb.put(p);
+        bb.put(o);
+        bb.put(c);
+
+        return new IntArray(bb.array());
+
+    }
+
+    public static final IntArray createSPOCMaxKey(Resource subject, URI property, Value object, Resource context){
+
+        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+        // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+        int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
+        int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
+        int o = object != null ? object.hashCode() : Integer.MAX_VALUE;
+        int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
+
+        IntBuffer bb = IntBuffer.allocate(4);
+        bb.put(s);
+        bb.put(p);
+        bb.put(o);
+        bb.put(c);
+
+        return new IntArray(bb.array());
+
+    }
+
+    public static final IntArray createCSPOKey(Resource subject, URI property, Value object, Resource context){
+
+        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+        // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+        int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
+        int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
+        int o = object != null ? object.hashCode() : Integer.MIN_VALUE;
+        int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
+
+        IntBuffer bb = IntBuffer.allocate(4);
+        bb.put(c);
+        bb.put(s);
+        bb.put(p);
+        bb.put(o);
+
+        return new IntArray(bb.array());
+
+    }
+
+    public static final IntArray createCSPOMaxKey(Resource subject, URI property, Value object, Resource context){
+
+        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
+        // storing them as a BigInteger; generating the cache key should thus be very efficient
+
+        int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
+        int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
+        int o = object != null ? object.hashCode() : Integer.MAX_VALUE;
+        int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
+
+        IntBuffer bb = IntBuffer.allocate(4);
+        bb.put(c);
+        bb.put(s);
+        bb.put(p);
+        bb.put(o);
+
+        return new IntArray(bb.array());
+
+    }
+
+    @Override
+    public String toString() {
+        return "IntArray{" +
+                "data=" + Arrays.toString(data) +
+                '}';
+    }
+
+    @Override
+    public int compareTo(IntArray o) {
+        for(int i=0; i < data.length && i < o.data.length; i++) {
+            if(data[i] < o.data[i]) {
+                return -1;
+            } else if(data[i]  > o.data[i]) {
+                return 1;
+            }
+        }
+        return 0;
+    }
+
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        IntArray intArray = (IntArray) o;
+
+        return Arrays.equals(data, intArray.data);
+
+    }
+
+    @Override
+    public int hashCode() {
+        ensureHashCode();
+        return goodHashCode.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
new file mode 100644
index 0000000..d149b87
--- /dev/null
+++ b/commons/sesame-tripletable/src/main/java/org/apache/marmotta/commons/sesame/tripletable/TripleTable.java
@@ -0,0 +1,478 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.marmotta.commons.sesame.tripletable;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import org.apache.marmotta.commons.collections.EquivalenceHashSet;
+import org.apache.marmotta.commons.sesame.model.StatementCommons;
+import org.openrdf.model.Resource;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.Value;
+
+import java.io.Serializable;
+import java.util.*;
+
+/**
+ * A triple table that allows efficient in-memory operations over large collections of triples. This can be used as
+ * a simplified version of a Sesame in-memory repository (MemStore) using typical collection methods.
+ * <p/>
+ * Author: Sebastian Schaffert
+ */
+public class TripleTable<Triple extends Statement> implements Set<Triple>, Serializable {
+
+	private static final long serialVersionUID = 1L;
+
+	private Set<Triple> data;
+
+    /**
+     * A set that orders triples orderd in a way that the subject is the most significant, while the context is the
+     * least significant property in the order. Can be used for efficient queries that involve either just a subject,
+     * a subject and a property, a subject, property and object or a subject, property, object and context
+     */
+    private NavigableMap<IntArray,Triple> indexSPOC;
+
+    /**
+     * A set that orders triples orderd in a way that the context is the most significant, while the object is the
+     * least significant property in the order. Can be used for efficient queries that involve either just a context,
+     * a context and a subject, a context, subject, and property
+     */
+    private NavigableMap<IntArray,Triple> indexCSPO;
+
+    public TripleTable() {
+        data = StatementCommons.newQuadrupleSet();
+        indexSPOC = new TreeMap<IntArray, Triple>();
+        indexCSPO = new TreeMap<IntArray, Triple>();
+    }
+
+
+    public TripleTable(Collection<Triple> triples) {
+        data = StatementCommons.newQuadrupleSet();
+        indexSPOC = new TreeMap<IntArray, Triple>();
+        indexCSPO = new TreeMap<IntArray, Triple>();
+        addAll(triples);
+    }
+
+
+    /**
+     * Returns the number of elements in this set (its cardinality).  If this
+     * set contains more than <tt>Integer.MAX_VALUE</tt> elements, returns
+     * <tt>Integer.MAX_VALUE</tt>.
+     *
+     * @return the number of elements in this set (its cardinality)
+     */
+    @Override
+    public synchronized int size() {
+        return data.size();
+    }
+
+    /**
+     * Returns <tt>true</tt> if this set contains no elements.
+     *
+     * @return <tt>true</tt> if this set contains no elements
+     */
+    @Override
+    public synchronized boolean isEmpty() {
+        return data.isEmpty();
+    }
+
+    /**
+     * Returns <tt>true</tt> if this set contains the specified element.
+     * More formally, returns <tt>true</tt> if and only if this set
+     * contains an element <tt>e</tt> such that
+     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>.
+     *
+     * @param o element whose presence in this set is to be tested
+     * @return <tt>true</tt> if this set contains the specified element
+     * @throws ClassCastException if the type of the specified element
+     *         is incompatible with this set (optional)
+     * @throws NullPointerException if the specified element is null and this
+     *         set does not permit null elements (optional)
+     */
+    @Override
+    public synchronized boolean contains(Object o) {
+        return data.contains(o);
+    }
+
+    /**
+     * Returns an iterator over the elements in this set.  The elements are
+     * returned in no particular order (unless this set is an instance of some
+     * class that provides a guarantee).
+     *
+     * @return an iterator over the elements in this set
+     */
+    @Override
+    public Iterator<Triple> iterator() {
+        return data.iterator();
+    }
+
+    /**
+     * Returns an array containing all of the elements in this set.
+     * If this set makes any guarantees as to what order its elements
+     * are returned by its iterator, this method must return the
+     * elements in the same order.
+     *
+     * <p>The returned array will be "safe" in that no references to it
+     * are maintained by this set.  (In other words, this method must
+     * allocate a new array even if this set is backed by an array).
+     * The caller is thus free to modify the returned array.
+     *
+     * <p>This method acts as bridge between array-based and collection-based
+     * APIs.
+     *
+     * @return an array containing all the elements in this set
+     */
+    @Override
+    public synchronized Object[] toArray() {
+        return data.toArray();
+    }
+
+    /**
+     * Returns an array containing all of the elements in this set; the
+     * runtime type of the returned array is that of the specified array.
+     * If the set fits in the specified array, it is returned therein.
+     * Otherwise, a new array is allocated with the runtime type of the
+     * specified array and the size of this set.
+     *
+     * <p>If this set fits in the specified array with room to spare
+     * (i.e., the array has more elements than this set), the element in
+     * the array immediately following the end of the set is set to
+     * <tt>null</tt>.  (This is useful in determining the length of this
+     * set <i>only</i> if the caller knows that this set does not contain
+     * any null elements.)
+     *
+     * <p>If this set makes any guarantees as to what order its elements
+     * are returned by its iterator, this method must return the elements
+     * in the same order.
+     *
+     * <p>Like the {@link #toArray()} method, this method acts as bridge between
+     * array-based and collection-based APIs.  Further, this method allows
+     * precise control over the runtime type of the output array, and may,
+     * under certain circumstances, be used to save allocation costs.
+     *
+     * <p>Suppose <tt>x</tt> is a set known to contain only strings.
+     * The following code can be used to dump the set into a newly allocated
+     * array of <tt>String</tt>:
+     *
+     * <pre>
+     *     String[] y = x.toArray(new String[0]);</pre>
+     *
+     * Note that <tt>toArray(new Object[0])</tt> is identical in function to
+     * <tt>toArray()</tt>.
+     *
+     * @param a the array into which the elements of this set are to be
+     *        stored, if it is big enough; otherwise, a new array of the same
+     *        runtime type is allocated for this purpose.
+     * @return an array containing all the elements in this set
+     * @throws ArrayStoreException if the runtime type of the specified array
+     *         is not a supertype of the runtime type of every element in this
+     *         set
+     * @throws NullPointerException if the specified array is null
+     */
+    @Override
+    public synchronized <T> T[] toArray(T[] a) {
+        return data.toArray(a);
+    }
+
+    /**
+     * Adds the specified element to this set if it is not already present
+     * (optional operation).  More formally, adds the specified element
+     * <tt>e</tt> to this set if the set contains no element <tt>e2</tt>
+     * such that
+     * <tt>(e==null&nbsp;?&nbsp;e2==null&nbsp;:&nbsp;e.equals(e2))</tt>.
+     * If this set already contains the element, the call leaves the set
+     * unchanged and returns <tt>false</tt>.  In combination with the
+     * restriction on constructors, this ensures that sets never contain
+     * duplicate elements.
+     *
+     * <p>The stipulation above does not imply that sets must accept all
+     * elements; sets may refuse to add any particular element, including
+     * <tt>null</tt>, and throw an exception, as described in the
+     * specification for {@link java.util.Collection#add Collection.add}.
+     * Individual set implementations should clearly document any
+     * restrictions on the elements that they may contain.
+     *
+     * @param triple element to be added to this set
+     * @return <tt>true</tt> if this set did not already contain the specified
+     *         element
+     * @throws UnsupportedOperationException if the <tt>add</tt> operation
+     *         is not supported by this set
+     * @throws ClassCastException if the class of the specified element
+     *         prevents it from being added to this set
+     * @throws NullPointerException if the specified element is null and this
+     *         set does not permit null elements
+     * @throws IllegalArgumentException if some property of the specified element
+     *         prevents it from being added to this set
+     */
+    @Override
+    public synchronized boolean add(Triple triple) {
+        indexSPOC.put(IntArray.createSPOCKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()),triple);
+        indexCSPO.put(IntArray.createCSPOKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()),triple);
+        return data.add(triple);
+    }
+
+    /**
+     * Removes the specified element from this set if it is present
+     * (optional operation).  More formally, removes an element <tt>e</tt>
+     * such that
+     * <tt>(o==null&nbsp;?&nbsp;e==null&nbsp;:&nbsp;o.equals(e))</tt>, if
+     * this set contains such an element.  Returns <tt>true</tt> if this set
+     * contained the element (or equivalently, if this set changed as a
+     * result of the call).  (This set will not contain the element once the
+     * call returns.)
+     *
+     * @param o object to be removed from this set, if present
+     * @return <tt>true</tt> if this set contained the specified element
+     * @throws ClassCastException if the type of the specified element
+     *         is incompatible with this set (optional)
+     * @throws NullPointerException if the specified element is null and this
+     *         set does not permit null elements (optional)
+     * @throws UnsupportedOperationException if the <tt>remove</tt> operation
+     *         is not supported by this set
+     */
+    @Override
+    public synchronized boolean remove(Object o) {
+        if(o instanceof Statement) {
+            Statement triple = (Statement)o;
+            indexSPOC.remove(IntArray.createSPOCKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()));
+            indexCSPO.remove(IntArray.createCSPOKey(triple.getSubject(), triple.getPredicate(), triple.getObject(), triple.getContext()));
+        }
+        return data.remove(o);
+    }
+
+    /**
+     * Returns <tt>true</tt> if this set contains all of the elements of the
+     * specified collection.  If the specified collection is also a set, this
+     * method returns <tt>true</tt> if it is a <i>subset</i> of this set.
+     *
+     * @param  c collection to be checked for containment in this set
+     * @return <tt>true</tt> if this set contains all of the elements of the
+     * 	       specified collection
+     * @throws ClassCastException if the types of one or more elements
+     *         in the specified collection are incompatible with this
+     *         set (optional)
+     * @throws NullPointerException if the specified collection contains one
+     *         or more null elements and this set does not permit null
+     *         elements (optional), or if the specified collection is null
+     * @see    #contains(Object)
+     */
+    @Override
+    public synchronized boolean containsAll(Collection<?> c) {
+        return data.containsAll(c);
+    }
+
+    /**
+     * Adds all of the elements in the specified collection to this set if
+     * they're not already present (optional operation).  If the specified
+     * collection is also a set, the <tt>addAll</tt> operation effectively
+     * modifies this set so that its value is the <i>union</i> of the two
+     * sets.  The behavior of this operation is undefined if the specified
+     * collection is modified while the operation is in progress.
+     *
+     * @param  c collection containing elements to be added to this set
+     * @return <tt>true</tt> if this set changed as a result of the call
+     *
+     * @throws UnsupportedOperationException if the <tt>addAll</tt> operation
+     *         is not supported by this set
+     * @throws ClassCastException if the class of an element of the
+     *         specified collection prevents it from being added to this set
+     * @throws NullPointerException if the specified collection contains one
+     *         or more null elements and this set does not permit null
+     *         elements, or if the specified collection is null
+     * @throws IllegalArgumentException if some property of an element of the
+     *         specified collection prevents it from being added to this set
+     * @see #add(Object)
+     */
+    @Override
+    public synchronized boolean addAll(Collection<? extends Triple> c) {
+        boolean modified = false;
+        for(Triple t : c) {
+            modified = add(t) || modified;
+        }
+        return modified;
+    }
+
+    /**
+     * Retains only the elements in this set that are contained in the
+     * specified collection (optional operation).  In other words, removes
+     * from this set all of its elements that are not contained in the
+     * specified collection.  If the specified collection is also a set, this
+     * operation effectively modifies this set so that its value is the
+     * <i>intersection</i> of the two sets.
+     *
+     * @param  c collection containing elements to be retained in this set
+     * @return <tt>true</tt> if this set changed as a result of the call
+     * @throws UnsupportedOperationException if the <tt>retainAll</tt> operation
+     *         is not supported by this set
+     * @throws ClassCastException if the class of an element of this set
+     *         is incompatible with the specified collection (optional)
+     * @throws NullPointerException if this set contains a null element and the
+     *         specified collection does not permit null elements (optional),
+     *         or if the specified collection is null
+     * @see #remove(Object)
+     */
+    @Override
+    public synchronized boolean retainAll(Collection<?> c) {
+        Iterator<Map.Entry<IntArray,Triple>> it = indexSPOC.entrySet().iterator();
+        while(it.hasNext()) {
+            if(!c.contains(it.next().getValue())) {
+                it.remove();
+            }
+        }
+        Iterator<Map.Entry<IntArray,Triple>> it2 = indexCSPO.entrySet().iterator();
+        while(it2.hasNext()) {
+            if(!c.contains(it2.next().getValue())) {
+                it2.remove();
+            }
+        }
+        return data.retainAll(c);
+    }
+
+    /**
+     * Removes from this set all of its elements that are contained in the
+     * specified collection (optional operation).  If the specified
+     * collection is also a set, this operation effectively modifies this
+     * set so that its value is the <i>asymmetric set difference</i> of
+     * the two sets.
+     *
+     * @param  c collection containing elements to be removed from this set
+     * @return <tt>true</tt> if this set changed as a result of the call
+     * @throws UnsupportedOperationException if the <tt>removeAll</tt> operation
+     *         is not supported by this set
+     * @throws ClassCastException if the class of an element of this set
+     *         is incompatible with the specified collection (optional)
+     * @throws NullPointerException if this set contains a null element and the
+     *         specified collection does not permit null elements (optional),
+     *         or if the specified collection is null
+     * @see #remove(Object)
+     * @see #contains(Object)
+     */
+    @Override
+    public synchronized boolean removeAll(Collection<?> c) {
+        boolean modified = false;
+        for(Object o : c) {
+            modified = remove(o) || modified;
+        }
+        return modified;
+    }
+
+    /**
+     * Removes all of the elements from this set (optional operation).
+     * The set will be empty after this call returns.
+     *
+     * @throws UnsupportedOperationException if the <tt>clear</tt> method
+     *         is not supported by this set
+     */
+    @Override
+    public synchronized void clear() {
+        data.clear();
+        indexSPOC.clear();
+        indexCSPO.clear();
+    }
+
+    /**
+     * Return a subset of the triples matching the filter criteria. Arguments with null value are treated as wildcards.
+     *
+     *
+     * @param subject
+     * @param property
+     * @param object
+     * @param context
+     * @param wildcardContext
+     * @return
+     */
+    public synchronized Collection<Triple> listTriples(final Resource subject, final URI property, final Value object, final Resource context, boolean wildcardContext) {
+        // in special cases we can make use of the index
+        if(subject != null && property != null && object != null && context != null) {
+            IntArray key = IntArray.createSPOCKey(subject, property, object, context);
+            Triple result = indexSPOC.get(key);
+            if(result != null) {
+                return Collections.singleton(result);
+            } else {
+                return Collections.emptyList();
+            }
+        } else if(wildcardContext &&
+                (  (subject != null && property != null && object != null)
+                 || (subject != null && property != null)
+                 || subject != null)) {
+            IntArray fromKey = IntArray.createSPOCKey(subject, property, object, context);
+            IntArray toKey   = IntArray.createSPOCMaxKey(subject, property, object, context);
+
+            return indexSPOC.subMap(fromKey,true,toKey,true).values();
+        } else if(  (context != null && subject != null && property != null)
+                 || (context != null && subject != null)
+                 || context != null) {
+            IntArray fromKey = IntArray.createCSPOKey(subject, property, object, context);
+            IntArray toKey   = IntArray.createCSPOMaxKey(subject, property, object, context);
+
+            return indexCSPO.subMap(fromKey,true,toKey,true).values();
+        } else {
+            // in all other cases we need to iterate and filter :-(
+            Predicate<Statement> p = new Predicate<Statement>() {
+                @Override
+                public boolean apply(Statement triple) {
+                    if(subject != null && !triple.getSubject().equals(subject)) {
+                        return false;
+                    }
+                    if(property != null && !triple.getPredicate().equals(property)) {
+                        return false;
+                    }
+                    if(object != null && !triple.getObject().equals(object)) {
+                        return false;
+                    }
+                    if(context != null && !triple.getContext().equals(context)) {
+                        return false;
+                    }
+
+                    return true;
+                }
+            };
+
+            return Collections2.filter(data, p);
+        }
+    }
+
+    public synchronized Collection<Resource> listContextIDs() {
+        Set<Resource> result = new HashSet<>();
+        for(Triple t : data) {
+            result.add(t.getContext());
+        }
+        return result;
+    }
+
+    @Override
+    public synchronized boolean equals(Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+		@SuppressWarnings("rawtypes")
+		TripleTable that = (TripleTable) o;
+
+        if (!data.equals(that.data)) return false;
+
+        return true;
+    }
+
+    @Override
+    public synchronized int hashCode() {
+        return data.hashCode();
+    }
+
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/commons/sesame-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
----------------------------------------------------------------------
diff --git a/commons/sesame-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java b/commons/sesame-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
new file mode 100644
index 0000000..9a3db75
--- /dev/null
+++ b/commons/sesame-tripletable/src/test/java/org/apache/marmotta/commons/sesame/tripletable/TripleTableTest.java
@@ -0,0 +1,128 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.marmotta.commons.sesame.tripletable;
+
+import org.apache.commons.lang3.RandomStringUtils;
+import org.apache.marmotta.commons.sesame.tripletable.TripleTable;
+import org.junit.Test;
+import org.openrdf.model.Literal;
+import org.openrdf.model.Statement;
+import org.openrdf.model.URI;
+import org.openrdf.model.impl.LiteralImpl;
+import org.openrdf.model.impl.StatementImpl;
+import org.openrdf.model.impl.URIImpl;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Test cases for triple tables.
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class TripleTableTest {
+
+
+
+    @Test
+    public void testListTriples() {
+        URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+        Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+
+        Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
+        Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
+        Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
+        Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
+        Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
+        Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
+        Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
+        Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
+
+        TripleTable<Statement> table = new TripleTable<>();
+        table.add(stmt1);
+        table.add(stmt2);
+        table.add(stmt3);
+        table.add(stmt4);
+        table.add(stmt5);
+        table.add(stmt6);
+        table.add(stmt7);
+        //table.add(stmt8);
+
+        // tests
+
+        // 1. test existence and non-existence of a triple
+        assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+        assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
+
+        // 2. test listing with wildcards
+        assertEquals(7, table.listTriples(null,null,null,null, true).size());
+        assertEquals(4, table.listTriples(subject1,null,null,null, true).size());
+        assertEquals(3, table.listTriples(subject2,null,null,null, true).size());
+        assertEquals(4, table.listTriples(null,predicate1,null,null, true).size());
+        assertEquals(3, table.listTriples(null,predicate2,null,null, true).size());
+        assertEquals(4, table.listTriples(null,null,object1,null, true).size());
+        assertEquals(3, table.listTriples(null,null,object2,null, true).size());
+        assertEquals(2, table.listTriples(subject1,predicate1,null,null, true).size());
+        assertEquals(1, table.listTriples(subject2,predicate2,null,null, true).size());
+    }
+
+    @Test
+    public void testRemoveTriples() {
+        URI subject1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI subject2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI predicate1 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        URI predicate2 = new URIImpl("http://localhost/"+ RandomStringUtils.randomAlphanumeric(8));
+        Literal object1 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+        Literal object2 = new LiteralImpl("http://localhost/"+ RandomStringUtils.random(40));
+
+        Statement stmt1 = new StatementImpl(subject1,predicate1,object1);
+        Statement stmt2 = new StatementImpl(subject1,predicate1,object2);
+        Statement stmt3 = new StatementImpl(subject1,predicate2,object1);
+        Statement stmt4 = new StatementImpl(subject1,predicate2,object2);
+        Statement stmt5 = new StatementImpl(subject2,predicate1,object1);
+        Statement stmt6 = new StatementImpl(subject2,predicate1,object2);
+        Statement stmt7 = new StatementImpl(subject2,predicate2,object1);
+        Statement stmt8 = new StatementImpl(subject2,predicate2,object2);
+
+        TripleTable<Statement> table = new TripleTable<>();
+        table.add(stmt1);
+        table.add(stmt2);
+        table.add(stmt3);
+        table.add(stmt4);
+        table.add(stmt5);
+        table.add(stmt6);
+        table.add(stmt7);
+        table.add(stmt8);
+
+        // tests
+
+        // 1. test existence and non-existence of a triple
+        assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+        assertEquals(1, table.listTriples(subject2,predicate2,object2,null, true).size());
+
+
+        table.remove(stmt8);
+
+        assertEquals(1, table.listTriples(subject2,predicate2,object1,null, true).size());
+        assertEquals(0, table.listTriples(subject2,predicate2,object2,null, true).size());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
index 69d6cde..f84b99f 100644
--- a/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
+++ b/libraries/kiwi/kiwi-reasoner/src/main/java/org/apache/marmotta/kiwi/reasoner/engine/ReasoningEngine.java
@@ -25,7 +25,7 @@ import info.aduna.iteration.EmptyIteration;
 import info.aduna.iteration.Iterations;
 import info.aduna.iteration.SingletonIteration;
 import org.apache.marmotta.commons.sesame.model.StatementCommons;
-import org.apache.marmotta.kiwi.model.caching.TripleTable;
+import org.apache.marmotta.commons.sesame.tripletable.TripleTable;
 import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
 import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
 import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-transactions/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-transactions/pom.xml b/libraries/kiwi/kiwi-transactions/pom.xml
index 502701d..e0824e5 100644
--- a/libraries/kiwi/kiwi-transactions/pom.xml
+++ b/libraries/kiwi/kiwi-transactions/pom.xml
@@ -34,7 +34,7 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.marmotta</groupId>
-            <artifactId>kiwi-tripletable</artifactId>
+            <artifactId>sesame-tripletable</artifactId>
         </dependency>
 
         <!-- Logging -->

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-transactions/src/main/java/org/apache/marmotta/kiwi/transactions/model/TransactionData.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-transactions/src/main/java/org/apache/marmotta/kiwi/transactions/model/TransactionData.java b/libraries/kiwi/kiwi-transactions/src/main/java/org/apache/marmotta/kiwi/transactions/model/TransactionData.java
index 0676179..eb33688 100644
--- a/libraries/kiwi/kiwi-transactions/src/main/java/org/apache/marmotta/kiwi/transactions/model/TransactionData.java
+++ b/libraries/kiwi/kiwi-transactions/src/main/java/org/apache/marmotta/kiwi/transactions/model/TransactionData.java
@@ -17,7 +17,7 @@
  */
 package org.apache.marmotta.kiwi.transactions.model;
 
-import org.apache.marmotta.kiwi.model.caching.TripleTable;
+import org.apache.marmotta.commons.sesame.tripletable.TripleTable;
 import org.openrdf.model.Statement;
 
 import java.util.Date;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-triplestore/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/pom.xml b/libraries/kiwi/kiwi-triplestore/pom.xml
index 046afdd..e815cce 100644
--- a/libraries/kiwi/kiwi-triplestore/pom.xml
+++ b/libraries/kiwi/kiwi-triplestore/pom.xml
@@ -104,7 +104,7 @@
         <!-- Utilities -->
         <dependency>
             <groupId>org.apache.marmotta</groupId>
-            <artifactId>kiwi-tripletable</artifactId>
+            <artifactId>sesame-tripletable</artifactId>
         </dependency>
         <dependency>
             <groupId>com.google.guava</groupId>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiQueryCache.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiQueryCache.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiQueryCache.java
index 2ec1144..cf9b457 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiQueryCache.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/KiWiQueryCache.java
@@ -20,7 +20,8 @@ package org.apache.marmotta.kiwi.caching;
 import com.google.common.collect.ImmutableList;
 import net.sf.ehcache.Ehcache;
 import net.sf.ehcache.Element;
-import org.apache.marmotta.kiwi.model.caching.IntArray;
+
+import org.apache.marmotta.commons.sesame.tripletable.IntArray;
 import org.apache.marmotta.kiwi.model.rdf.KiWiNode;
 import org.apache.marmotta.kiwi.model.rdf.KiWiResource;
 import org.apache.marmotta.kiwi.model.rdf.KiWiTriple;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
index 0163870..857e879 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiConnection.java
@@ -32,11 +32,11 @@ import net.sf.ehcache.Element;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.marmotta.commons.sesame.model.LiteralCommons;
 import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.apache.marmotta.commons.sesame.tripletable.TripleTable;
 import org.apache.marmotta.commons.util.DateUtils;
 import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
 import org.apache.marmotta.kiwi.exception.ResultInterruptedException;
-import org.apache.marmotta.kiwi.model.caching.TripleTable;
 import org.apache.marmotta.kiwi.model.rdf.*;
 import org.apache.marmotta.kiwi.persistence.util.ResultSetIteration;
 import org.apache.marmotta.kiwi.persistence.util.ResultTransformerFunction;
@@ -308,7 +308,7 @@ public class KiWiConnection {
      */
     public void storeNamespace(KiWiNamespace namespace) throws SQLException {
         // TODO: add unique constraints to table
-        if(namespace.getId() >= 0) {
+        if(namespace.getId() != null) {
             log.warn("trying to store namespace which is already persisted: {}",namespace);
             return;
         }
@@ -335,7 +335,7 @@ public class KiWiConnection {
      * @throws SQLException in case a database error occurred
      */
     public void deleteNamespace(KiWiNamespace namespace) throws SQLException {
-        if(namespace.getId() < 0) {
+        if(namespace.getId() == null) {
             log.warn("trying to remove namespace which is not persisted: {}",namespace);
             return;
         }
@@ -377,7 +377,7 @@ public class KiWiConnection {
      * @throws SQLException
      */
     public long getSize(KiWiResource context) throws SQLException {
-        if(context.getId() < 0) {
+        if(context.getId() == null) {
             return 0;
         };
 
@@ -605,7 +605,7 @@ public class KiWiConnection {
         requireJDBCConnection();
 
         // ltype not persisted
-        if(ltype != null && ltype.getId() < 0) {
+        if(ltype != null && ltype.getId() == null) {
             return null;
         }
 
@@ -671,7 +671,7 @@ public class KiWiConnection {
 
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "dateTime");
 
-        if(ltype == null || ltype.getId() < 0) {
+        if(ltype == null || ltype.getId() == null) {
             return null;
         }
 
@@ -726,7 +726,7 @@ public class KiWiConnection {
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "integer");
 
         // ltype not persisted
-        if(ltype == null || ltype.getId() < 0) {
+        if(ltype == null || ltype.getId() == null) {
             return null;
         }
 
@@ -781,7 +781,7 @@ public class KiWiConnection {
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "double");
 
         // ltype not persisted
-        if(ltype == null || ltype.getId() < 0) {
+        if(ltype == null || ltype.getId() == null) {
             return null;
         }
 
@@ -836,7 +836,7 @@ public class KiWiConnection {
         KiWiUriResource ltype = loadUriResource(Namespaces.NS_XSD + "boolean");
 
         // ltype not persisted
-        if(ltype == null || ltype.getId() < 0) {
+        if(ltype == null || ltype.getId() == null) {
             return null;
         }
 
@@ -883,7 +883,7 @@ public class KiWiConnection {
         // ensure the data type of a literal is persisted first
         if(node instanceof KiWiLiteral) {
             KiWiLiteral literal = (KiWiLiteral)node;
-            if(literal.getType() != null && literal.getType().getId() < 0) {
+            if(literal.getType() != null && literal.getType().getId() == null) {
                 storeNode(literal.getType(), batch);
             }
         }
@@ -891,7 +891,7 @@ public class KiWiConnection {
         requireJDBCConnection();
 
         // retrieve a new node id and set it in the node object
-        if(node.getId() < 0) {
+        if(node.getId() == null) {
             node.setId(getNextSequence("seq.nodes"));
         }
 
@@ -999,43 +999,20 @@ public class KiWiConnection {
         } else if(node instanceof KiWiStringLiteral) {
             KiWiStringLiteral stringLiteral = (KiWiStringLiteral)node;
 
-
-            Double dbl_value = null;
-            Long   lng_value = null;
-            if(stringLiteral.getContent().length() < 64 && NumberUtils.isNumber(stringLiteral.getContent()))
-            try {
-                dbl_value = Double.parseDouble(stringLiteral.getContent());
-                lng_value = Long.parseLong(stringLiteral.getContent());
-            } catch (NumberFormatException ex) {
-                // ignore, keep NaN
-            }
-
-
             PreparedStatement insertNode = getPreparedStatement("store.sliteral");
             insertNode.setLong(1,node.getId());
             insertNode.setString(2, stringLiteral.getContent());
-            if(dbl_value != null) {
-                insertNode.setDouble(3, dbl_value);
-            } else {
-                insertNode.setObject(3, null);
-            }
-            if(lng_value != null) {
-                insertNode.setLong(4, lng_value);
-            } else {
-                insertNode.setObject(4, null);
-            }
-
             if(stringLiteral.getLocale() != null) {
-                insertNode.setString(5, stringLiteral.getLocale().getLanguage());
+                insertNode.setString(3,stringLiteral.getLocale().getLanguage());
             } else {
-                insertNode.setObject(5, null);
+                insertNode.setObject(3, null);
             }
             if(stringLiteral.getType() != null) {
-                insertNode.setLong(6,stringLiteral.getType().getId());
+                insertNode.setLong(4,stringLiteral.getType().getId());
             } else {
-                insertNode.setObject(6, null);
+                insertNode.setObject(4, null);
             }
-            insertNode.setTimestamp(7, new Timestamp(stringLiteral.getCreated().getTime()));
+            insertNode.setTimestamp(5, new Timestamp(stringLiteral.getCreated().getTime()));
 
             if(batch) {
                 insertNode.addBatch();
@@ -1063,7 +1040,7 @@ public class KiWiConnection {
 
             requireJDBCConnection();
 
-            boolean hasId = triple.getId() >= 0;
+            boolean hasId = triple.getId() != null;
 
             if(hasId && deletedStatementsLog.contains(triple.getId())) {
                 // this is a hack for a concurrency problem that may occur in case the triple is removed in the
@@ -1076,7 +1053,7 @@ public class KiWiConnection {
                 return true;
             } else {
                 // retrieve a new triple ID and set it in the object
-                if(triple.getId() < 0) {
+                if(triple.getId() == null) {
                     triple.setId(getNextSequence("seq.triples"));
                 }
 
@@ -1150,7 +1127,7 @@ public class KiWiConnection {
      * @param inferred
      * @return
      */
-    public synchronized long getTripleId(final KiWiResource subject, final KiWiUriResource predicate, final KiWiNode object, final KiWiResource context, final boolean inferred) throws SQLException {
+    public synchronized Long getTripleId(final KiWiResource subject, final KiWiUriResource predicate, final KiWiNode object, final KiWiResource context, final boolean inferred) throws SQLException {
         if(tripleBatch != null && tripleBatch.size() > 0) {
             Collection<KiWiTriple> batched = tripleBatch.listTriples(subject,predicate,object,context, false);
             if(batched.size() > 0) {
@@ -1174,7 +1151,7 @@ public class KiWiConnection {
             if(result.next()) {
                 return result.getLong(1);
             } else {
-                return -1L;
+                return null;
             }
 
         } finally {
@@ -1206,7 +1183,7 @@ public class KiWiConnection {
                     triple.setDeleted(true);
                     triple.setDeletedAt(new Date());
 
-                    if (triple.getId() < 0) {
+                    if (triple.getId() == null) {
                         log.warn("attempting to remove non-persistent triple: {}", triple);
                         removeCachedTriple(triple);
                     } else {
@@ -1259,7 +1236,7 @@ public class KiWiConnection {
      * @param triple
      */
     public void undeleteTriple(KiWiTriple triple) throws SQLException {
-        if(triple.getId() < 0) {
+        if(triple.getId() == null) {
             log.warn("attempting to undelete non-persistent triple: {}",triple);
             return;
         }
@@ -1358,7 +1335,7 @@ public class KiWiConnection {
         requireJDBCConnection();
 
         PreparedStatement queryContexts = getPreparedStatement("query.resources_prefix");
-        queryContexts.setString(1, prefix + "%");
+        queryContexts.setString(1, prefix+"%");
 
         final ResultSet result = queryContexts.executeQuery();
 
@@ -1463,16 +1440,16 @@ public class KiWiConnection {
      */
     private CloseableIteration<Statement, SQLException> listTriplesInternal(KiWiResource subject, KiWiUriResource predicate, KiWiNode object, KiWiResource context, boolean inferred, final boolean wildcardContext) throws SQLException {
         // if one of the database ids is null, there will not be any database results, so we can return an empty result
-        if(subject != null && subject.getId() < 0) {
+        if(subject != null && subject.getId() == null) {
             return new EmptyIteration<Statement, SQLException>();
         }
-        if(predicate != null && predicate.getId() < 0) {
+        if(predicate != null && predicate.getId() == null) {
             return new EmptyIteration<Statement, SQLException>();
         }
-        if(object != null && object.getId() < 0) {
+        if(object != null && object.getId() == null) {
             return new EmptyIteration<Statement, SQLException>();
         }
-        if(context != null && context.getId() < 0) {
+        if(context != null && context.getId() == null) {
             return new EmptyIteration<Statement, SQLException>();
         }
 
@@ -1569,7 +1546,7 @@ public class KiWiConnection {
      */
     protected KiWiNode constructNodeFromDatabase(ResultSet row) throws SQLException {
 
-        long id = row.getLong("id");
+        Long id = row.getLong("id");
 
         Element cached = nodeCache.get(id);
 
@@ -1580,20 +1557,23 @@ public class KiWiConnection {
 
         String ntype = row.getString("ntype");
         if("uri".equals(ntype)) {
-            KiWiUriResource result = new KiWiUriResource(row.getString("svalue"),new Date(row.getTimestamp("createdAt").getTime()));
+            KiWiUriResource result = new KiWiUriResource(row.getString("svalue"));
             result.setId(id);
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
 
             cacheNode(result);
             return result;
         } else if("bnode".equals(ntype)) {
-            KiWiAnonResource result = new KiWiAnonResource(row.getString("svalue"), new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            KiWiAnonResource result = new KiWiAnonResource(row.getString("svalue"));
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
 
             cacheNode(result);
             return result;
         } else if("string".equals(ntype)) {
-            final KiWiStringLiteral result = new KiWiStringLiteral(row.getString("svalue"), new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            final KiWiStringLiteral result = new KiWiStringLiteral(row.getString("svalue"));
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
 
             if(row.getString("lang") != null) {
                 result.setLocale(getLocale(row.getString("lang")));
@@ -1605,8 +1585,10 @@ public class KiWiConnection {
             cacheNode(result);
             return result;
         } else if("int".equals(ntype)) {
-            KiWiIntLiteral result = new KiWiIntLiteral(row.getLong("ivalue"), null, new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            KiWiIntLiteral result = new KiWiIntLiteral();
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
+            result.setIntContent(row.getLong("ivalue"));
             if(row.getLong("ltype") != 0) {
                 result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
             }
@@ -1614,8 +1596,10 @@ public class KiWiConnection {
             cacheNode(result);
             return result;
         } else if("double".equals(ntype)) {
-            KiWiDoubleLiteral result = new KiWiDoubleLiteral(row.getDouble("dvalue"), null, new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            KiWiDoubleLiteral result = new KiWiDoubleLiteral();
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
+            result.setDoubleContent(row.getDouble("dvalue"));
             if(row.getLong("ltype") != 0) {
                 result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
             }
@@ -1623,8 +1607,10 @@ public class KiWiConnection {
             cacheNode(result);
             return result;
         } else if("boolean".equals(ntype)) {
-            KiWiBooleanLiteral result = new KiWiBooleanLiteral(row.getBoolean("bvalue"),null,new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            KiWiBooleanLiteral result = new KiWiBooleanLiteral();
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
+            result.setValue(row.getBoolean("bvalue"));
 
             if(row.getLong("ltype") != 0) {
                 result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
@@ -1633,8 +1619,10 @@ public class KiWiConnection {
             cacheNode(result);
             return result;
         } else if("date".equals(ntype)) {
-            KiWiDateLiteral result = new KiWiDateLiteral(new Date(row.getTimestamp("tvalue").getTime()), null, new Date(row.getTimestamp("createdAt").getTime()));
-            result.setId(id);
+            KiWiDateLiteral result = new KiWiDateLiteral();
+            result.setId(row.getLong("id"));
+            result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
+            result.setDateContent(new Date(row.getTimestamp("tvalue").getTime()));
 
             if(row.getLong("ltype") != 0) {
                 result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
@@ -1668,10 +1656,6 @@ public class KiWiConnection {
      * @return a KiWiTriple representation of the database result
      */
     protected KiWiTriple constructTripleFromDatabase(ResultSet row) throws SQLException {
-        if(row.isClosed()) {
-            throw new ResultInterruptedException("retrieving results has been interrupted");
-        }
-
         Long id = row.getLong("id");
 
         Element cached = tripleCache.get(id);
@@ -1710,7 +1694,7 @@ public class KiWiConnection {
 
     protected static Locale getLocale(String language) {
         Locale locale = localeMap.get(language);
-        if(locale == null && language != null && !language.isEmpty()) {
+        if(locale == null && language != null) {
             try {
                 Locale.Builder builder = new Locale.Builder();
                 builder.setLanguageTag(language);
@@ -1784,7 +1768,7 @@ public class KiWiConnection {
 
 
     private void cacheNode(KiWiNode node) {
-        if(node.getId() >= 0) {
+        if(node.getId() != null) {
             nodeCache.put(new Element(node.getId(), node));
         }
         if(node instanceof KiWiUriResource) {
@@ -1797,13 +1781,13 @@ public class KiWiConnection {
     }
 
     private void cacheTriple(KiWiTriple triple) {
-        if(triple.getId() >= 0) {
+        if(triple.getId() != null) {
             tripleCache.put(new Element(triple.getId(),triple));
         }
     }
 
     private void removeCachedTriple(KiWiTriple triple) {
-        if(triple.getId() >= 0) {
+        if(triple.getId() != null) {
             tripleCache.remove(triple.getId());
         }
     }
@@ -2067,7 +2051,7 @@ public class KiWiConnection {
         if(tripleBatch != null && tripleBatch.size() > 0) {
             synchronized (tripleBatch) {
                 for(KiWiTriple triple : tripleBatch) {
-                    triple.setId(-1L);
+                    triple.setId(null);
                 }
                 tripleBatch.clear();
             }
@@ -2166,7 +2150,7 @@ public class KiWiConnection {
                                 }
 
                                 // retrieve a new triple ID and set it in the object
-                                if(triple.getId() < 0) {
+                                if(triple.getId() == null) {
                                     triple.setId(getNextSequence("seq.triples"));
                                 }
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiStore.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiStore.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiStore.java
index 4119023..a3fec3a 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiStore.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiStore.java
@@ -18,8 +18,9 @@
 package org.apache.marmotta.kiwi.sail;
 
 import com.google.common.collect.MapMaker;
+
+import org.apache.marmotta.commons.sesame.tripletable.IntArray;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
-import org.apache.marmotta.kiwi.model.caching.IntArray;
 import org.apache.marmotta.kiwi.persistence.KiWiDialect;
 import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
 import org.openrdf.model.Statement;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
index c54b576..92f63ca 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/sail/KiWiValueFactory.java
@@ -23,8 +23,8 @@ import net.sf.ehcache.constructs.blocking.SelfPopulatingCache;
 import org.apache.marmotta.commons.sesame.model.LiteralCommons;
 import org.apache.marmotta.commons.sesame.model.LiteralKey;
 import org.apache.marmotta.commons.sesame.model.Namespaces;
+import org.apache.marmotta.commons.sesame.tripletable.IntArray;
 import org.apache.marmotta.commons.util.DateUtils;
-import org.apache.marmotta.kiwi.model.caching.IntArray;
 import org.apache.marmotta.kiwi.model.rdf.*;
 import org.apache.marmotta.kiwi.persistence.KiWiConnection;
 import org.openrdf.model.BNode;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-tripletable/pom.xml
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-tripletable/pom.xml b/libraries/kiwi/kiwi-tripletable/pom.xml
deleted file mode 100644
index f2de727..0000000
--- a/libraries/kiwi/kiwi-tripletable/pom.xml
+++ /dev/null
@@ -1,87 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-   Licensed to the Apache Software Foundation (ASF) under one or more
-   contributor license agreements.  See the NOTICE file distributed with
-   this work for additional information regarding copyright ownership.
-   The ASF licenses this file to You under the Apache License, Version 2.0
-   (the "License"); you may not use this file except in compliance with
-   the License.  You may obtain a copy of the License at
-
-        http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>org.apache.marmotta</groupId>
-        <artifactId>kiwi-parent</artifactId>
-        <version>3.2.0-SNAPSHOT</version>
-    </parent>
-
-    <artifactId>kiwi-tripletable</artifactId>
-    <packaging>jar</packaging>
-
-    <name>KiWi Triplestore: Triple Table</name>
-
-    <description>
-        Provides a simple in-memory table using the Java Collections API to access triples. Additionally, the
-        triple table offers in-memory indexes for typical query operations (e.g. listing by subject).
-    </description>
-
-    <dependencies>
-        <!-- data model -->
-        <dependency>
-            <groupId>org.openrdf.sesame</groupId>
-            <artifactId>sesame-model</artifactId>
-        </dependency>
-
-        <!-- Utilities -->
-        <dependency>
-            <groupId>com.google.guava</groupId>
-            <artifactId>guava</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.marmotta</groupId>
-            <artifactId>marmotta-commons</artifactId>
-        </dependency>
-
-        <dependency>
-            <artifactId>junit</artifactId>
-            <groupId>junit</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <artifactId>hamcrest-core</artifactId>
-            <groupId>org.hamcrest</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <artifactId>hamcrest-library</artifactId>
-            <groupId>org.hamcrest</groupId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>ch.qos.logback</groupId>
-            <artifactId>logback-classic</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.commons</groupId>
-            <artifactId>commons-lang3</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/ByteArray.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/ByteArray.java b/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/ByteArray.java
deleted file mode 100644
index 5b5d313..0000000
--- a/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/ByteArray.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.kiwi.model.caching;
-
-import java.util.Arrays;
-
-/**
-* Add file description here!
-* <p/>
-* Author: Sebastian Schaffert
-*/
-final class ByteArray implements Comparable<ByteArray> {
-
-    private byte[] data;
-
-    ByteArray(byte[] data) {
-        this.data = data;
-    }
-
-    @Override
-    public int compareTo(ByteArray o) {
-        for(int i=0; i < data.length && i < o.data.length; i++) {
-            if(((int) data[i] & 0xff) < ((int) o.data[i] & 0xff)) {
-                return -1;
-            } else if(((int)data[i] & 0xff) > ((int)o.data[i] & 0xff)) {
-                return 1;
-            }
-        }
-        return 0;
-    }
-
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        ByteArray byteArray = (ByteArray) o;
-
-        return Arrays.equals(data, byteArray.data);
-
-    }
-
-    @Override
-    public int hashCode() {
-        return data != null ? Arrays.hashCode(data) : 0;
-    }
-}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/e0beeb7d/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/IntArray.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/IntArray.java b/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/IntArray.java
deleted file mode 100644
index 549bddf..0000000
--- a/libraries/kiwi/kiwi-tripletable/src/main/java/org/apache/marmotta/kiwi/model/caching/IntArray.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.marmotta.kiwi.model.caching;
-
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hasher;
-import com.google.common.hash.Hashing;
-import org.openrdf.model.Resource;
-import org.openrdf.model.URI;
-import org.openrdf.model.Value;
-
-import java.nio.IntBuffer;
-import java.util.Arrays;
-
-/**
- * Add file description here!
- * <p/>
- * Author: Sebastian Schaffert
- */
-public final class IntArray implements Comparable<IntArray> {
-
-    private static HashFunction hashFunction = Hashing.goodFastHash(32);
-
-    private int[] data;
-
-    private HashCode goodHashCode;
-
-
-    public IntArray(int[] data) {
-        this.data = data;
-    }
-
-    private void ensureHashCode() {
-        if(goodHashCode == null) {
-            Hasher hasher = hashFunction.newHasher();
-            for(int i : data) {
-                hasher.putInt(i);
-            }
-            goodHashCode = hasher.hash();
-        }
-    }
-
-    public static final IntArray createSPOCKey(Resource subject, URI property, Value object, Resource context){
-
-        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
-        // storing them as a BigInteger; generating the cache key should thus be very efficient
-
-        int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
-        int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
-        int o = object != null ? object.hashCode() : Integer.MIN_VALUE;
-        int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
-
-        IntBuffer bb = IntBuffer.allocate(4);
-        bb.put(s);
-        bb.put(p);
-        bb.put(o);
-        bb.put(c);
-
-        return new IntArray(bb.array());
-
-    }
-
-    public static final IntArray createSPOCMaxKey(Resource subject, URI property, Value object, Resource context){
-
-        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
-        // storing them as a BigInteger; generating the cache key should thus be very efficient
-
-        int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
-        int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
-        int o = object != null ? object.hashCode() : Integer.MAX_VALUE;
-        int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
-
-        IntBuffer bb = IntBuffer.allocate(4);
-        bb.put(s);
-        bb.put(p);
-        bb.put(o);
-        bb.put(c);
-
-        return new IntArray(bb.array());
-
-    }
-
-    public static final IntArray createCSPOKey(Resource subject, URI property, Value object, Resource context){
-
-        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
-        // storing them as a BigInteger; generating the cache key should thus be very efficient
-
-        int s = subject != null ? subject.hashCode() : Integer.MIN_VALUE;
-        int p = property != null ? property.hashCode() : Integer.MIN_VALUE;
-        int o = object != null ? object.hashCode() : Integer.MIN_VALUE;
-        int c = context != null ? context.hashCode() : Integer.MIN_VALUE;
-
-        IntBuffer bb = IntBuffer.allocate(4);
-        bb.put(c);
-        bb.put(s);
-        bb.put(p);
-        bb.put(o);
-
-        return new IntArray(bb.array());
-
-    }
-
-    public static final IntArray createCSPOMaxKey(Resource subject, URI property, Value object, Resource context){
-
-        // the cache key is generated by appending the bytes of the hashcodes of subject, property, object, context and inferred and
-        // storing them as a BigInteger; generating the cache key should thus be very efficient
-
-        int s = subject != null ? subject.hashCode() : Integer.MAX_VALUE;
-        int p = property != null ? property.hashCode() : Integer.MAX_VALUE;
-        int o = object != null ? object.hashCode() : Integer.MAX_VALUE;
-        int c = context != null ? context.hashCode() : Integer.MAX_VALUE;
-
-        IntBuffer bb = IntBuffer.allocate(4);
-        bb.put(c);
-        bb.put(s);
-        bb.put(p);
-        bb.put(o);
-
-        return new IntArray(bb.array());
-
-    }
-
-    @Override
-    public String toString() {
-        return "IntArray{" +
-                "data=" + Arrays.toString(data) +
-                '}';
-    }
-
-    @Override
-    public int compareTo(IntArray o) {
-        for(int i=0; i < data.length && i < o.data.length; i++) {
-            if(data[i] < o.data[i]) {
-                return -1;
-            } else if(data[i]  > o.data[i]) {
-                return 1;
-            }
-        }
-        return 0;
-    }
-
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) return true;
-        if (o == null || getClass() != o.getClass()) return false;
-
-        IntArray intArray = (IntArray) o;
-
-        return Arrays.equals(data, intArray.data);
-
-    }
-
-    @Override
-    public int hashCode() {
-        ensureHashCode();
-        return goodHashCode.hashCode();
-    }
-}