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

git commit: fixed problem with memory sequences in H2

Updated Branches:
  refs/heads/develop 8eb1f1b29 -> 901526c82


fixed problem with memory sequences in H2


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

Branch: refs/heads/develop
Commit: 901526c82a10557925ff74e1511afb71dc09375b
Parents: 8eb1f1b
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Wed Oct 2 10:36:57 2013 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Wed Oct 2 10:36:57 2013 +0200

----------------------------------------------------------------------
 .../apache/marmotta/kiwi/persistence/h2/statements.properties   | 4 ++++
 .../org/apache/marmotta/kiwi/persistence/KiWiConnection.java    | 4 +++-
 .../org/apache/marmotta/kiwi/persistence/KiWiPersistence.java   | 5 +++++
 .../apache/marmotta/kiwi/persistence/h2/statements.properties   | 3 +++
 .../apache/marmotta/kiwi/persistence/h2/statements.properties   | 1 +
 .../apache/marmotta/kiwi/persistence/h2/statements.properties   | 1 +
 .../platform/core/services/triplestore/SesameServiceImpl.java   | 2 ++
 7 files changed, 19 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/libraries/kiwi/kiwi-reasoner/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-reasoner/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties b/libraries/kiwi/kiwi-reasoner/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
index 89143ad..6a4c55c 100644
--- a/libraries/kiwi/kiwi-reasoner/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
+++ b/libraries/kiwi/kiwi-reasoner/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
@@ -18,8 +18,12 @@
 
 # get sequence numbers
 seq.rules             = SELECT nextval('seq_rules')
+seq.rules.set         = ALTER SEQUENCE seq_rules RESTART WITH ?
 seq.programs          = SELECT nextval('seq_programs')
+seq.programs.set      = ALTER SEQUENCE seq_programs RESTART WITH ?
 seq.justifications    = SELECT nextval('seq_justifications')
+seq.justifications.set= ALTER SEQUENCE seq_justifications RESTART WITH ?
+
 
 # rules
 rules.insert          = INSERT INTO reasoner_rules (id,name,description,body,createdAt) VALUES (?,?,?,?,now())

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/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 4f0fd4f..c33b157 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
@@ -1983,7 +1983,9 @@ public class KiWiConnection {
         execution.execute(connection, new RetryCommand<Void>() {
             @Override
             public Void run() throws SQLException {
-                persistence.getIdGenerator().commit(persistence, getJDBCConnection());
+                if(connection != null) {
+                    persistence.getIdGenerator().commit(persistence, connection);
+                }
 
                 if(tripleBatch != null && tripleBatch.size() > 0) {
                     flushBatch();

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/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 7ec1109..91cc750 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
@@ -186,18 +186,23 @@ public class KiWiPersistence {
         switch (configuration.getIdGeneratorType()) {
             case DATABASE_SEQUENCE:
                 idGenerator = new DatabaseSequenceIDGenerator();
+                log.info("database key generation strategy: database sequences (slow, reliable)");
                 break;
             case MEMORY_SEQUENCE:
                 idGenerator = new MemorySequenceIDGenerator();
+                log.info("database key generation strategy: memory sequences (fast, no distribution)");
                 break;
             case UUID_TIME:
                 idGenerator = new UUIDTimeIDGenerator();
+                log.info("database key generation strategy: time-based UUIDs (very fast, rare conflicts with distribution");
                 break;
             case UUID_RANDOM:
                 idGenerator = new UUIDRandomIDGenerator();
+                log.info("database key generation strategy: secure random UUIDs (fast, almost no conflicts with distribution");
                 break;
             case SNOWFLAKE:
                 idGenerator = new SnowflakeIDGenerator();
+                log.info("database key generation strategy: Twitter Snowflake (very fast, almost no conflicts with distribution");
                 break;
             default:
                 idGenerator = new DatabaseSequenceIDGenerator();

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
index 092cfcb..cdebd9e 100644
--- a/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
+++ b/libraries/kiwi/kiwi-triplestore/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
@@ -22,8 +22,11 @@ meta.version           = SELECT mvalue FROM metadata WHERE mkey = 'version';
 
 # get sequence numbers
 seq.nodes              = SELECT nextval('seq_nodes')
+seq.nodes.set          = ALTER SEQUENCE seq_nodes RESTART WITH ?
 seq.triples            = SELECT nextval('seq_triples')
+seq.triples.set        = ALTER SEQUENCE seq_triples RESTART WITH ?
 seq.namespaces         = SELECT nextval('seq_namespaces')
+seq.namespaces.set     = ALTER SEQUENCE seq_namespaces RESTART WITH ?
 
 # load entities
 load.node_by_id        = SELECT id,ntype,svalue,ivalue,dvalue,tvalue,bvalue,lang,ltype,createdAt FROM nodes WHERE id = ?

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
index e5b1ae3..c48d5de 100644
--- a/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
+++ b/libraries/kiwi/kiwi-versioning/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
@@ -18,6 +18,7 @@
 
 # get sequence numbers
 seq.versions          = SELECT nextval('seq_versions')
+seq.versions.set      = ALTER SEQUENCE seq_versions RESTART WITH ?
 
 load.version_by_id    = SELECT id,creator,createdAt FROM versions WHERE id = ?
 load.version_between  = SELECT id,creator,createdAt FROM versions WHERE createdAt > ? AND createdAt <= ?  ORDER BY createdAt ASC

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/libraries/ldcache/ldcache-backend-kiwi/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
----------------------------------------------------------------------
diff --git a/libraries/ldcache/ldcache-backend-kiwi/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties b/libraries/ldcache/ldcache-backend-kiwi/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
index e8af848..bd8b999 100644
--- a/libraries/ldcache/ldcache-backend-kiwi/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
+++ b/libraries/ldcache/ldcache-backend-kiwi/src/main/resources/org/apache/marmotta/kiwi/persistence/h2/statements.properties
@@ -18,6 +18,7 @@
 
 # get sequence numbers
 seq.ldcache           = SELECT nextval('seq_ldcache')
+seq.ldcache.set       = ALTER SEQUENCE seq_ldcache RESTART WITH ?
 
 load.entry_by_id      = SELECT id,retrieved_at,expires_at,resource_id,update_count,triple_count FROM ldcache_entries WHERE id = ?
 load.entry_by_uri     = SELECT E.id,retrieved_at,expires_at,resource_id,update_count,triple_count FROM ldcache_entries E, nodes N WHERE e.resource_id = N.id AND N.ntype = 'uri' and N.svalue = ?

http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/901526c8/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java
----------------------------------------------------------------------
diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java
index 2684984..620e6a7 100644
--- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java
+++ b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/services/triplestore/SesameServiceImpl.java
@@ -166,6 +166,8 @@ public class SesameServiceImpl implements SesameService {
                 configuration.setIdGeneratorType(IDGeneratorType.DATABASE_SEQUENCE);
             } else if("memory".equals(generatorType)) {
                 configuration.setIdGeneratorType(IDGeneratorType.MEMORY_SEQUENCE);
+            } else if("snowflake".equals(generatorType)) {
+                configuration.setIdGeneratorType(IDGeneratorType.SNOWFLAKE);
             }
 
             store = new KiWiStore(configuration);