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/10/07 11:50:09 UTC

git commit: KiWi code cleanups

Repository: marmotta
Updated Branches:
  refs/heads/develop b32dd5d7f -> 817307c95


KiWi code cleanups


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

Branch: refs/heads/develop
Commit: 817307c95331e3e05b806f8436e78693aa7617a1
Parents: b32dd5d
Author: Sebastian Schaffert <ss...@apache.org>
Authored: Tue Oct 7 11:50:30 2014 +0200
Committer: Sebastian Schaffert <ss...@apache.org>
Committed: Tue Oct 7 11:50:30 2014 +0200

----------------------------------------------------------------------
 .../kiwi/loader/KiWiLoaderConfiguration.java    | 96 ++++++++++++++------
 .../kiwi/loader/generic/KiWiHandler.java        |  2 +
 .../kiwi/persistence/KiWiConnection.java        |  8 +-
 3 files changed, 76 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/marmotta/blob/817307c9/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/KiWiLoaderConfiguration.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/KiWiLoaderConfiguration.java b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/KiWiLoaderConfiguration.java
index ac1fdd1..e663a6c 100644
--- a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/KiWiLoaderConfiguration.java
+++ b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/KiWiLoaderConfiguration.java
@@ -38,30 +38,6 @@ public class KiWiLoaderConfiguration {
     public static final String IGNORE_NAMESPACES = "loader.namespaces.ignore";
 
 
-    /**
-     * the size of a batch insert into the database; only when this number of statements has been processed will
-     * an insert statement to the database be issued.
-     */
-
-    int statementBatchSize = 1000;
-
-    /**
-     * the size of a database transaction; the database transaction will commit after this number of statements
-     */
-    int commitBatchSize = 10000;
-
-    /**
-     * If true, the importer will check if a statement already exists; this check is necessary to ensure consistency
-     * of the database, but it is also very expensive, because every triple needs to be checked. Set this option to
-     * false in case you are sure that every imported triple does not yet exist in the database.
-     */
-    boolean statementExistanceCheck = false;
-
-    /**
-     * Import into this context, ignoring context provided by the statements
-     */
-    String context;
-
     private Configuration config;
 
     public KiWiLoaderConfiguration() {
@@ -72,51 +48,115 @@ public class KiWiLoaderConfiguration {
         this.config = config;
     }
 
+    /**
+     * the size of a database transaction; the database transaction will commit after this number of statements
+     *
+     * Default: 10000
+     */
     public int getCommitBatchSize() {
-        return config.getInt(LOADER_COMMIT_BATCH_SIZE,commitBatchSize);
+        return config.getInt(LOADER_COMMIT_BATCH_SIZE,10000);
     }
 
+    /**
+     * the size of a database transaction; the database transaction will commit after this number of statements
+     *
+     * Default: 10000
+     */
     public void setCommitBatchSize(int commitBatchSize) {
         config.setProperty(LOADER_COMMIT_BATCH_SIZE, commitBatchSize);
     }
 
+    /**
+     * the size of a batch insert into the database; only when this number of statements has been processed will
+     * an insert statement to the database be issued.
+     *
+     * Default: 1000
+     */
     public int getStatementBatchSize() {
-        return config.getInt(LOADER_STATEMENT_BATCH_SIZE,statementBatchSize);
+        return config.getInt(LOADER_STATEMENT_BATCH_SIZE,1000);
     }
 
+    /**
+     * the size of a batch insert into the database; only when this number of statements has been processed will
+     * an insert statement to the database be issued.
+     *
+     * Default: 1000
+     */
     public void setStatementBatchSize(int statementBatchSize) {
         config.setProperty(LOADER_STATEMENT_BATCH_SIZE, statementBatchSize);
     }
 
+    /**
+     * If true, the importer will check if a statement already exists; this check is necessary to ensure consistency
+     * of the database, but it is also very expensive, because every triple needs to be checked. Set this option to
+     * false in case you are sure that every imported triple does not yet exist in the database.
+     *
+     * Default: false
+     */
     public boolean isStatementExistanceCheck() {
-        return config.getBoolean(LOADER_STATEMENT_EXISTENCE_CHECK,statementExistanceCheck);
+        return config.getBoolean(LOADER_STATEMENT_EXISTENCE_CHECK,false);
     }
 
+    /**
+     * If true, the importer will check if a statement already exists; this check is necessary to ensure consistency
+     * of the database, but it is also very expensive, because every triple needs to be checked. Set this option to
+     * false in case you are sure that every imported triple does not yet exist in the database.
+     *
+     * Default: false
+     */
     public void setStatementExistanceCheck(boolean statementExistanceCheck) {
         config.setProperty(LOADER_STATEMENT_EXISTENCE_CHECK, statementExistanceCheck);
     }
 
+    /**
+     * If not null, import into this context, ignoring context provided by the statements. Default: null
+     * @return
+     */
     public String getContext() {
-        return config.getString(LOADER_CONTEXT, context);
+        return config.getString(LOADER_CONTEXT, null);
     }
 
+    /**
+     * If not null, import into this context, ignoring context provided by the statements. Default: null
+     */
     public void setContext(String context) {
         config.setProperty(LOADER_CONTEXT, context);
     }
 
 
+    /**
+     * If set to true, database indexes are dropped before import. This can significantly speed up the import, but
+     * will cause problems in concurrent environments, so set to false when other users are connected to the database.
+     * Default: true.
+     * @return
+     */
     public boolean isDropIndexes() {
         return config.getBoolean(LOADER_DROP_INDEXES, true);
     }
 
+    /**
+     * If set to true, database indexes are dropped before import. This can significantly speed up the import, but
+     * will cause problems in concurrent environments, so set to false when other users are connected to the database.
+     * Default: true.
+     * @return
+     */
     public void setDropIndexes(boolean v) {
         config.setProperty(LOADER_DROP_INDEXES,v);
     }
 
+
+    /**
+     * If set to true, namespace definitions contained in the imported file are ignored. Default: false
+     * @return
+     */
     public boolean isIgnoreNamespaces() {
         return config.getBoolean(IGNORE_NAMESPACES, false);
     }
 
+    /**
+     * If set to true, namespace definitions contained in the imported file are ignored. Default: false
+     * @return
+     */
     public void setIgnoreNamespaces(boolean v) {
         config.setProperty(IGNORE_NAMESPACES,v);
     }

http://git-wip-us.apache.org/repos/asf/marmotta/blob/817307c9/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
----------------------------------------------------------------------
diff --git a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
index 3bf9728..835c31b 100644
--- a/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
+++ b/libraries/kiwi/kiwi-loader/src/main/java/org/apache/marmotta/kiwi/loader/generic/KiWiHandler.java
@@ -120,6 +120,8 @@ public class KiWiHandler implements RDFHandler {
                     registry        = new LocalTripleRegistry();
             }
         }
+
+        log.info("KiWi Loader: namespaces {}", config.isIgnoreNamespaces() ? "ignored" : "enabled");
     }
 
 

http://git-wip-us.apache.org/repos/asf/marmotta/blob/817307c9/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 ccb6023..2c68a78 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
@@ -1760,8 +1760,12 @@ public class KiWiConnection implements AutoCloseable {
         result.setId(row.getLong("id"));
         result.setCreated(new Date(row.getTimestamp("createdAt").getTime()));
 
-        namespacePrefixCache.put(result.getPrefix(),result);
-        namespaceUriCache.put(result.getUri(),result);
+        if(!namespacePrefixCache.containsKey(result.getPrefix())) {
+            namespacePrefixCache.put(result.getPrefix(), result);
+        }
+        if(!namespaceUriCache.containsKey(result.getUri())) {
+            namespaceUriCache.put(result.getUri(), result);
+        }
 
         return result;
     }