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/02/04 23:58:15 UTC
git commit: some performance optimizations for JDBC
Updated Branches:
refs/heads/develop e796661d7 -> b3be446e1
some performance optimizations for JDBC
Project: http://git-wip-us.apache.org/repos/asf/marmotta/repo
Commit: http://git-wip-us.apache.org/repos/asf/marmotta/commit/b3be446e
Tree: http://git-wip-us.apache.org/repos/asf/marmotta/tree/b3be446e
Diff: http://git-wip-us.apache.org/repos/asf/marmotta/diff/b3be446e
Branch: refs/heads/develop
Commit: b3be446e1bd188347194bde82ee006cd77f3ef97
Parents: e796661
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Tue Feb 4 23:58:08 2014 +0100
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Tue Feb 4 23:58:08 2014 +0100
----------------------------------------------------------------------
.../kiwi/persistence/KiWiConnection.java | 75 +++++++++++---------
.../apache/marmotta/kiwi/test/ClusterTest.java | 7 +-
2 files changed, 43 insertions(+), 39 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/marmotta/blob/b3be446e/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 20b6656..5093644 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
@@ -1557,8 +1557,10 @@ public class KiWiConnection implements AutoCloseable {
* @return
*/
protected KiWiNode constructNodeFromDatabase(ResultSet row) throws SQLException {
+ // column order; id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt
+ // 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10
- long id = row.getLong("id");
+ long id = row.getLong(1);
KiWiNode cached = nodeCache.get(id);
@@ -1567,66 +1569,66 @@ public class KiWiConnection implements AutoCloseable {
return cached;
}
- String ntype = row.getString("ntype");
+ String ntype = row.getString(2);
if("uri".equals(ntype)) {
- KiWiUriResource result = new KiWiUriResource(row.getString("svalue"),new Date(row.getTimestamp("createdAt").getTime()));
+ KiWiUriResource result = new KiWiUriResource(row.getString(3),new Date(row.getTimestamp(10).getTime()));
result.setId(id);
cacheNode(result);
return result;
} else if("bnode".equals(ntype)) {
- KiWiAnonResource result = new KiWiAnonResource(row.getString("svalue"), new Date(row.getTimestamp("createdAt").getTime()));
+ KiWiAnonResource result = new KiWiAnonResource(row.getString(3), new Date(row.getTimestamp(10).getTime()));
result.setId(id);
cacheNode(result);
return result;
} else if("string".equals(ntype)) {
- final KiWiStringLiteral result = new KiWiStringLiteral(row.getString("svalue"), new Date(row.getTimestamp("createdAt").getTime()));
+ final KiWiStringLiteral result = new KiWiStringLiteral(row.getString(3), new Date(row.getTimestamp(10).getTime()));
result.setId(id);
- if(row.getString("lang") != null) {
- result.setLocale(getLocale(row.getString("lang")));
+ if(row.getString(8) != null) {
+ result.setLocale(getLocale(row.getString(8)));
}
- if(row.getLong("ltype") != 0) {
- result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
+ if(row.getLong(9) != 0) {
+ result.setType((KiWiUriResource) loadNodeById(row.getLong(9)));
}
cacheNode(result);
return result;
} else if("int".equals(ntype)) {
- KiWiIntLiteral result = new KiWiIntLiteral(row.getLong("ivalue"), null, new Date(row.getTimestamp("createdAt").getTime()));
+ KiWiIntLiteral result = new KiWiIntLiteral(row.getLong(4), null, new Date(row.getTimestamp(10).getTime()));
result.setId(id);
- if(row.getLong("ltype") != 0) {
- result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
+ if(row.getLong(9) != 0) {
+ result.setType((KiWiUriResource) loadNodeById(row.getLong(9)));
}
cacheNode(result);
return result;
} else if("double".equals(ntype)) {
- KiWiDoubleLiteral result = new KiWiDoubleLiteral(row.getDouble("dvalue"), null, new Date(row.getTimestamp("createdAt").getTime()));
+ KiWiDoubleLiteral result = new KiWiDoubleLiteral(row.getDouble(5), null, new Date(row.getTimestamp(10).getTime()));
result.setId(id);
- if(row.getLong("ltype") != 0) {
- result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
+ if(row.getLong(9) != 0) {
+ result.setType((KiWiUriResource) loadNodeById(row.getLong(9)));
}
cacheNode(result);
return result;
} else if("boolean".equals(ntype)) {
- KiWiBooleanLiteral result = new KiWiBooleanLiteral(row.getBoolean("bvalue"),null,new Date(row.getTimestamp("createdAt").getTime()));
+ KiWiBooleanLiteral result = new KiWiBooleanLiteral(row.getBoolean(7),null,new Date(row.getTimestamp(10).getTime()));
result.setId(id);
- if(row.getLong("ltype") != 0) {
- result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
+ if(row.getLong(9) != 0) {
+ result.setType((KiWiUriResource) loadNodeById(row.getLong(9)));
}
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()));
+ KiWiDateLiteral result = new KiWiDateLiteral(new Date(row.getTimestamp(6).getTime()), null, new Date(row.getTimestamp(10).getTime()));
result.setId(id);
- if(row.getLong("ltype") != 0) {
- result.setType((KiWiUriResource) loadNodeById(row.getLong("ltype")));
+ if(row.getLong(9) != 0) {
+ result.setType((KiWiUriResource) loadNodeById(row.getLong(9)));
}
cacheNode(result);
@@ -1661,7 +1663,10 @@ public class KiWiConnection implements AutoCloseable {
throw new ResultInterruptedException("retrieving results has been interrupted");
}
- Long id = row.getLong("id");
+ // columns: id,subject,predicate,object,context,deleted,inferred,creator,createdAt,deletedAt
+ // 1 ,2 ,3 ,4 ,5 ,6 ,7 ,8 ,9 ,10
+
+ Long id = row.getLong(1);
KiWiTriple cached = tripleCache.get(id);
@@ -1672,19 +1677,19 @@ public class KiWiConnection implements AutoCloseable {
KiWiTriple result = new KiWiTriple();
result.setId(id);
- result.setSubject((KiWiResource)loadNodeById(row.getLong("subject")));
- result.setPredicate((KiWiUriResource) loadNodeById(row.getLong("predicate")));
- result.setObject(loadNodeById(row.getLong("object")));
- result.setContext((KiWiResource) loadNodeById(row.getLong("context")));
- if(row.getLong("creator") != 0) {
- result.setCreator((KiWiResource)loadNodeById(row.getLong("creator")));
- }
- result.setDeleted(row.getBoolean("deleted"));
- result.setInferred(row.getBoolean("inferred"));
- result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
+ result.setSubject((KiWiResource)loadNodeById(row.getLong(2)));
+ result.setPredicate((KiWiUriResource) loadNodeById(row.getLong(3)));
+ result.setObject(loadNodeById(row.getLong(4)));
+ result.setContext((KiWiResource) loadNodeById(row.getLong(5)));
+ if(row.getLong(8) != 0) {
+ result.setCreator((KiWiResource)loadNodeById(row.getLong(8)));
+ }
+ result.setDeleted(row.getBoolean(6));
+ result.setInferred(row.getBoolean(7));
+ result.setCreated(new Date(row.getTimestamp(9).getTime()));
try {
- if(row.getDate("deletedAt") != null) {
- result.setDeletedAt(new Date(row.getTimestamp("deletedAt").getTime()));
+ if(row.getDate(10) != null) {
+ result.setDeletedAt(new Date(row.getTimestamp(10).getTime()));
}
} catch (SQLException ex) {
// work around a MySQL problem with null dates
@@ -1725,7 +1730,7 @@ public class KiWiConnection implements AutoCloseable {
PreparedStatement statement = statementCache.get(key);
if(statement == null || statement.isClosed()) {
- statement = connection.prepareStatement(dialect.getStatement(key));
+ statement = connection.prepareStatement(dialect.getStatement(key), ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
statementCache.put(key,statement);
}
statement.clearParameters();
http://git-wip-us.apache.org/repos/asf/marmotta/blob/b3be446e/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
index cfff77b..5f4d719 100644
--- a/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
+++ b/libraries/kiwi/kiwi-triplestore/src/test/java/org/apache/marmotta/kiwi/test/ClusterTest.java
@@ -23,10 +23,7 @@ import org.apache.marmotta.kiwi.caching.KiWiCacheManager;
import org.apache.marmotta.kiwi.config.KiWiConfiguration;
import org.apache.marmotta.kiwi.persistence.h2.H2Dialect;
import org.apache.marmotta.kiwi.sail.KiWiStore;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.*;
import org.openrdf.model.URI;
import org.openrdf.repository.Repository;
import org.openrdf.repository.RepositoryException;
@@ -99,6 +96,7 @@ public class ClusterTest {
@Test
+ @Ignore
public void testClusteredCacheSync() throws InterruptedException, RepositoryException {
setupCluster(61222,61222);
@@ -125,6 +123,7 @@ public class ClusterTest {
}
@Test
+ @Ignore
public void testDisjointClusters() throws InterruptedException, RepositoryException {
setupCluster(61224,61225);