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 2014/01/16 19:59:09 UTC

[1/2] git commit: better Infinispan serialization to improve cluster performance

Updated Branches:
  refs/heads/develop 019fa30e3 -> 23bae0562


better Infinispan serialization to improve cluster performance


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

Branch: refs/heads/develop
Commit: 69b01a53928ca01402b5627453c5846f0ec204ac
Parents: 4ebf089
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Jan 16 19:58:43 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Jan 16 19:58:43 2014 +0100

----------------------------------------------------------------------
 .../kiwi/loader/pgsql/create_indexes.sql        |  2 +-
 .../kiwi/caching/BNodeExternalizer.java         | 74 +++++++++++++++
 .../caching/BooleanLiteralExternalizer.java     | 72 +++++++++++++++
 .../kiwi/caching/DateLiteralExternalizer.java   | 72 +++++++++++++++
 .../kiwi/caching/DoubleLiteralExternalizer.java | 72 +++++++++++++++
 .../kiwi/caching/IntLiteralExternalizer.java    | 72 +++++++++++++++
 .../kiwi/caching/StringLiteralExternalizer.java | 95 ++++++++++++++++++++
 .../kiwi/caching/TripleExternalizer.java        | 20 ++++-
 .../marmotta/kiwi/caching/UriExternalizer.java  | 72 +++++++++++++++
 .../kiwi/persistence/KiWiConnection.java        | 14 ++-
 .../kiwi/persistence/KiWiPersistence.java       | 19 +++-
 11 files changed, 571 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-loader/src/main/resources/org/apache/marmotta/kiwi/loader/pgsql/create_indexes.sql
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-loader/src/main/resources/org/apache/marmotta/kiwi/loader/pgsql/create_indexes.sql b/libraries/kiwi/kiwi-loader/src/main/resources/org/apache/marmotta/kiwi/loader/pgsql/create_indexes.sql
index 30169fe..d05d926 100644
--- a/libraries/kiwi/kiwi-loader/src/main/resources/org/apache/marmotta/kiwi/loader/pgsql/create_indexes.sql
+++ b/libraries/kiwi/kiwi-loader/src/main/resources/org/apache/marmotta/kiwi/loader/pgsql/create_indexes.sql
@@ -1,4 +1,4 @@
-CREATE INDEX idx_triples_p ON triples(object,predicate) WHERE deleted = false;
+CREATE INDEX idx_triples_p ON triples(predicate) WHERE deleted = false;
 CREATE INDEX idx_triples_spo ON triples(subject,predicate,object) WHERE deleted = false;
 CREATE INDEX idx_triples_cspo ON triples(context,subject,predicate,object) WHERE deleted = false;
 CREATE INDEX idx_node_dcontent ON nodes(dvalue) WHERE dvalue IS NOT NULL;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BNodeExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BNodeExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BNodeExternalizer.java
new file mode 100644
index 0000000..79c8b51
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BNodeExternalizer.java
@@ -0,0 +1,74 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiAnonResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class BNodeExternalizer implements AdvancedExternalizer<KiWiAnonResource> {
+
+
+    @Override
+    public Set<Class<? extends KiWiAnonResource>> getTypeClasses() {
+        return Util.<Class<? extends KiWiAnonResource>>asSet(KiWiAnonResource.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 23;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiAnonResource object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeInt(object.stringValue().length());
+        output.writeChars(object.stringValue());
+        output.writeLong(object.getCreated().getTime());
+    }
+
+    @Override
+    public KiWiAnonResource readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        int len = input.readInt();
+
+        char[] anonId = new char[len];
+        for(int i=0; i<len; i++) {
+            anonId[i] = input.readChar();
+        }
+
+        Date created = new Date(input.readLong());
+
+        KiWiAnonResource r = new KiWiAnonResource(new String(anonId),created);
+        r.setId(id);
+
+        return r;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BooleanLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BooleanLiteralExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BooleanLiteralExternalizer.java
new file mode 100644
index 0000000..9c3c88d
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/BooleanLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiBooleanLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class BooleanLiteralExternalizer implements AdvancedExternalizer<KiWiBooleanLiteral> {
+
+    @Override
+    public Set<Class<? extends KiWiBooleanLiteral>> getTypeClasses() {
+        return Util.<Class<? extends KiWiBooleanLiteral>>asSet(KiWiBooleanLiteral.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 31;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiBooleanLiteral object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeBoolean(object.booleanValue());
+        output.writeObject(object.getDatatype());
+
+        output.writeLong(object.getCreated().getTime());
+
+    }
+
+    @Override
+    public KiWiBooleanLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        boolean content = input.readBoolean();
+
+        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
+
+        Date created = new Date(input.readLong());
+
+        KiWiBooleanLiteral r = new KiWiBooleanLiteral(content, dtype, created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DateLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DateLiteralExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DateLiteralExternalizer.java
new file mode 100644
index 0000000..58c6aac
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DateLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiDateLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class DateLiteralExternalizer implements AdvancedExternalizer<KiWiDateLiteral> {
+
+    @Override
+    public Set<Class<? extends KiWiDateLiteral>> getTypeClasses() {
+        return Util.<Class<? extends KiWiDateLiteral>>asSet(KiWiDateLiteral.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 29;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiDateLiteral object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeLong(object.getDateContent().getTime());
+        output.writeObject(object.getDatatype());
+
+        output.writeLong(object.getCreated().getTime());
+
+    }
+
+    @Override
+    public KiWiDateLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        Date content = new Date(input.readLong());
+
+        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
+
+        Date created = new Date(input.readLong());
+
+        KiWiDateLiteral r = new KiWiDateLiteral(content, dtype, created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DoubleLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DoubleLiteralExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DoubleLiteralExternalizer.java
new file mode 100644
index 0000000..cb755a6
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/DoubleLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiDoubleLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class DoubleLiteralExternalizer implements AdvancedExternalizer<KiWiDoubleLiteral> {
+
+    @Override
+    public Set<Class<? extends KiWiDoubleLiteral>> getTypeClasses() {
+        return Util.<Class<? extends KiWiDoubleLiteral>>asSet(KiWiDoubleLiteral.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 37;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiDoubleLiteral object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeDouble(object.getDoubleContent());
+        output.writeObject(object.getDatatype());
+
+        output.writeLong(object.getCreated().getTime());
+
+    }
+
+    @Override
+    public KiWiDoubleLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        double content = input.readDouble();
+
+        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
+
+        Date created = new Date(input.readLong());
+
+        KiWiDoubleLiteral r = new KiWiDoubleLiteral(content, dtype, created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/IntLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/IntLiteralExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/IntLiteralExternalizer.java
new file mode 100644
index 0000000..64c1b04
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/IntLiteralExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiIntLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class IntLiteralExternalizer implements AdvancedExternalizer<KiWiIntLiteral> {
+
+    @Override
+    public Set<Class<? extends KiWiIntLiteral>> getTypeClasses() {
+        return Util.<Class<? extends KiWiIntLiteral>>asSet(KiWiIntLiteral.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 37;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiIntLiteral object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeLong(object.getIntContent());
+        output.writeObject(object.getDatatype());
+
+        output.writeLong(object.getCreated().getTime());
+
+    }
+
+    @Override
+    public KiWiIntLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        long content = input.readLong();
+
+        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
+
+        Date created = new Date(input.readLong());
+
+        KiWiIntLiteral r = new KiWiIntLiteral(content, dtype, created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/StringLiteralExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/StringLiteralExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/StringLiteralExternalizer.java
new file mode 100644
index 0000000..d8ad4d8
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/StringLiteralExternalizer.java
@@ -0,0 +1,95 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiStringLiteral;
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class StringLiteralExternalizer implements AdvancedExternalizer<KiWiStringLiteral> {
+
+    @Override
+    public Set<Class<? extends KiWiStringLiteral>> getTypeClasses() {
+        return Util.<Class<? extends KiWiStringLiteral>>asSet(KiWiStringLiteral.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 19;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiStringLiteral object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeInt(object.getContent().length());
+        output.writeChars(object.getContent());
+        if(object.getLanguage() != null) {
+            output.writeInt(object.getLanguage().length());
+            output.writeChars(object.getLanguage());
+        } else {
+            output.writeInt(0);
+        }
+
+        output.writeObject(object.getDatatype());
+
+        output.writeLong(object.getCreated().getTime());
+
+    }
+
+    @Override
+    public KiWiStringLiteral readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        int clen = input.readInt();
+        char[] content = new char[clen];
+        for(int i=0; i<clen; i++) {
+            content[i]=input.readChar();
+        }
+
+        int llen = input.readInt();
+        String lang = null;
+        if(llen > 0) {
+            char[] lb = new char[llen];
+            for(int i=0; i<llen; i++) {
+                lb[i] = input.readChar();
+            }
+            lang = new String(lb);
+        }
+
+        KiWiUriResource dtype = (KiWiUriResource) input.readObject();
+
+        Date created = new Date(input.readLong());
+
+        KiWiStringLiteral r = new KiWiStringLiteral(new String(content), lang != null ? Locale.forLanguageTag(lang) : null, dtype, created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/TripleExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/TripleExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/TripleExternalizer.java
index 737d331..fd281e2 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/TripleExternalizer.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/TripleExternalizer.java
@@ -24,6 +24,8 @@ import org.apache.marmotta.kiwi.persistence.KiWiConnection;
 import org.apache.marmotta.kiwi.persistence.KiWiPersistence;
 import org.infinispan.commons.marshall.AdvancedExternalizer;
 import org.infinispan.commons.util.Util;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import java.io.IOException;
 import java.io.ObjectInput;
@@ -38,6 +40,8 @@ import java.util.Set;
  */
 public class TripleExternalizer implements AdvancedExternalizer<KiWiTriple> {
 
+    private static Logger log = LoggerFactory.getLogger(TripleExternalizer.class);
+
     private KiWiPersistence persistence;
 
     public TripleExternalizer(KiWiPersistence persistence) {
@@ -65,8 +69,12 @@ public class TripleExternalizer implements AdvancedExternalizer<KiWiTriple> {
         output.writeBoolean(object.isDeleted());
         output.writeBoolean(object.isInferred());
         output.writeBoolean(object.isNewTriple());
-        output.writeObject(object.getCreated());
-        output.writeObject(object.getDeletedAt());
+        output.writeLong(object.getCreated().getTime());
+        if(object.getDeletedAt() != null) {
+            output.writeLong(object.getDeletedAt().getTime());
+        } else {
+            output.writeLong(0);
+        }
     }
 
     @Override
@@ -93,8 +101,12 @@ public class TripleExternalizer implements AdvancedExternalizer<KiWiTriple> {
                 result.setInferred(input.readBoolean());
                 result.setNewTriple(input.readBoolean());
 
-                result.setCreated((Date) input.readObject());
-                result.setDeletedAt((Date) input.readObject());
+                result.setCreated(new Date(input.readLong()));
+
+                long deletedAt = input.readLong();
+                if(deletedAt > 0) {
+                    result.setDeletedAt(new Date(deletedAt));
+                }
 
 
                 return result;

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/UriExternalizer.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/UriExternalizer.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/UriExternalizer.java
new file mode 100644
index 0000000..176db19
--- /dev/null
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/caching/UriExternalizer.java
@@ -0,0 +1,72 @@
+/*
+ * 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.caching;
+
+import org.apache.marmotta.kiwi.model.rdf.KiWiUriResource;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
+import org.infinispan.commons.util.Util;
+
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.Date;
+import java.util.Set;
+
+/**
+ * Add file description here!
+ *
+ * @author Sebastian Schaffert (sschaffert@apache.org)
+ */
+public class UriExternalizer implements AdvancedExternalizer<KiWiUriResource> {
+
+    @Override
+    public Set<Class<? extends KiWiUriResource>> getTypeClasses() {
+        return Util.<Class<? extends KiWiUriResource>>asSet(KiWiUriResource.class);
+    }
+
+    @Override
+    public Integer getId() {
+        return 17;
+    }
+
+    @Override
+    public void writeObject(ObjectOutput output, KiWiUriResource object) throws IOException {
+        output.writeLong(object.getId());
+        output.writeInt(object.stringValue().length());
+        output.writeChars(object.stringValue());
+        output.writeLong(object.getCreated().getTime());
+    }
+
+    @Override
+    public KiWiUriResource readObject(ObjectInput input) throws IOException, ClassNotFoundException {
+        long id = input.readLong();
+        int len = input.readInt();
+
+        char[] uri = new char[len];
+        for(int i=0; i<len; i++) {
+            uri[i] = input.readChar();
+        }
+
+        Date created = new Date(input.readLong());
+
+        KiWiUriResource r = new KiWiUriResource(new String(uri),created);
+        r.setId(id);
+
+        return r;
+    }
+}

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/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 9773003..fde7bb1 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
@@ -1073,7 +1073,9 @@ public class KiWiConnection implements AutoCloseable {
                 if(batchCommit) {
                     commitLock.lock();
                     try {
-                        cacheTriple(triple);
+                        if(!persistence.getConfiguration().isClustered()) {
+                            cacheTriple(triple);
+                        }
                         tripleBatch.add(triple);
                         if(tripleBatch.size() >= batchSize) {
                             flushBatch();
@@ -1107,7 +1109,9 @@ public class KiWiConnection implements AutoCloseable {
                                 insertTriple.setTimestamp(7, new Timestamp(triple.getCreated().getTime()));
                                 int count = insertTriple.executeUpdate();
 
-                                cacheTriple(triple);
+                                if(!persistence.getConfiguration().isClustered()) {
+                                    cacheTriple(triple);
+                                }
 
                                 return count > 0;
                             }
@@ -1267,7 +1271,9 @@ public class KiWiConnection implements AutoCloseable {
             undeleteTriple.setLong(1, triple.getId());
             undeleteTriple.executeUpdate();
 
-            cacheTriple(triple);
+            if(!persistence.getConfiguration().isClustered()) {
+                cacheTriple(triple);
+            }
         }
 
     }
@@ -1689,7 +1695,7 @@ public class KiWiConnection implements AutoCloseable {
             // (see http://stackoverflow.com/questions/782823/handling-datetime-values-0000-00-00-000000-in-jdbc)
         }
 
-        tripleCache.put(id,result);
+        cacheTriple(result);
 
         return result;
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/69b01a53/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
index d55c5bd..0dca557 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
+++ b/libraries/kiwi/kiwi-triplestore/src/main/java/org/apache/marmotta/kiwi/persistence/KiWiPersistence.java
@@ -17,8 +17,7 @@
  */
 package org.apache.marmotta.kiwi.persistence;
 
-import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
-import org.apache.marmotta.kiwi.caching.TripleExternalizer;
+import org.apache.marmotta.kiwi.caching.*;
 import org.apache.marmotta.kiwi.config.KiWiConfiguration;
 import org.apache.marmotta.kiwi.generator.IDGenerator;
 import org.apache.marmotta.kiwi.generator.SnowflakeIDGenerator;
@@ -26,6 +25,7 @@ import org.apache.marmotta.kiwi.persistence.util.ScriptRunner;
 import org.apache.marmotta.kiwi.sail.KiWiValueFactory;
 import org.apache.tomcat.jdbc.pool.DataSource;
 import org.apache.tomcat.jdbc.pool.PoolProperties;
+import org.infinispan.commons.marshall.AdvancedExternalizer;
 import org.infinispan.manager.EmbeddedCacheManager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -138,10 +138,21 @@ public class KiWiPersistence {
 
 
     private void initCachePool() {
+        AdvancedExternalizer[] externalizers =  new AdvancedExternalizer[] {
+                new TripleExternalizer(this),
+                new UriExternalizer(),
+                new BNodeExternalizer(),
+                new StringLiteralExternalizer(),
+                new DateLiteralExternalizer(),
+                new BooleanLiteralExternalizer(),
+                new IntLiteralExternalizer(),
+                new DoubleLiteralExternalizer()
+        };
+
         if(infinispan != null) {
-            cacheManager = new KiWiCacheManager(infinispan,configuration, new TripleExternalizer(this));
+            cacheManager = new KiWiCacheManager(infinispan,configuration, externalizers);
         } else {
-            cacheManager = new KiWiCacheManager(configuration, new TripleExternalizer(this));
+            cacheManager = new KiWiCacheManager(configuration, externalizers);
         }
     }
 


[2/2] git commit: Merge remote-tracking branch 'origin/develop' into develop

Posted by ss...@apache.org.
Merge remote-tracking branch 'origin/develop' into develop


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

Branch: refs/heads/develop
Commit: 23bae0562ab0f18302223f85db5fb78da347abd8
Parents: 69b01a5 019fa30
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Thu Jan 16 19:58:55 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Thu Jan 16 19:58:55 2014 +0100

----------------------------------------------------------------------
 launchers/marmotta-webapp/pom.xml               | 99 +++++++++++++-------
 .../main/resources/config-defaults.properties   |  4 +-
 2 files changed, 67 insertions(+), 36 deletions(-)
----------------------------------------------------------------------