You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2015/09/03 17:33:34 UTC

[14/31] incubator-tinkerpop git commit: tweaked the commit logs (added a counter for processed elements per iteration per thread)

tweaked the commit logs (added a counter for processed elements per iteration per thread)


Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/9ec8c96d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/9ec8c96d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/9ec8c96d

Branch: refs/heads/master
Commit: 9ec8c96dad4d68463386b272815553f640d93ea9
Parents: 9cc985d
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Sun Aug 30 14:48:36 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Sun Aug 30 14:48:36 2015 +0200

----------------------------------------------------------------------
 .../bulkloading/BulkLoaderVertexProgram.java        | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/9ec8c96d/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
index b8219fb..9ab21c2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
@@ -46,6 +46,7 @@ import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 
 /**
  * @author Daniel Kuppitz (http://gremlin.guru)
@@ -68,7 +69,12 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
     private Graph graph;
     private GraphTraversalSource g;
     private long intermediateBatchSize;
-    private long counter;
+    private static ThreadLocal<AtomicLong> counter = new ThreadLocal<AtomicLong>() {
+        @Override
+        protected AtomicLong initialValue() {
+            return new AtomicLong();
+        }
+    };
 
     private BulkLoaderVertexProgram() {
         messageScope = MessageScope.Local.of(__::inE);
@@ -99,7 +105,7 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
                 throw new IllegalStateException(e);
             }
         } else {
-            loader = new DefaultBulkLoader();
+            loader = new IncrementalBulkLoader();
         }
         loader.configure(config);
         return loader;
@@ -112,10 +118,11 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
      * @param close Whether to close the current graph instance after calling commit() or not.
      */
     private void commit(final boolean close) {
-        if (!close && (intermediateBatchSize == 0L || ++counter % intermediateBatchSize != 0)) return;
+        if (!close && (counter.get().incrementAndGet() % intermediateBatchSize != 0 || intermediateBatchSize == 0L))
+            return;
         if (null != graph) {
             if (graph.features().graph().supportsTransactions()) {
-                LOGGER.info("Committing transaction on Graph instance: {}", graph);
+                LOGGER.info("Committing transaction on Graph instance: {} [{}]", graph, counter.get().get());
                 try {
                     graph.tx().commit();
                     LOGGER.debug("Committed transaction on Graph instance: {}", graph);
@@ -139,6 +146,7 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
 
     @Override
     public void setup(final Memory memory) {
+        counter.get().set(0L);
     }
 
     @Override