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/04/28 16:21:32 UTC

[3/3] incubator-tinkerpop git commit: Fixed up batching in readers and ensured a final commit at the end.

Fixed up batching in readers and ensured a final commit at the end.


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

Branch: refs/heads/master
Commit: 4a1aa0203e826e43f8b0edd0d542c86c556eb715
Parents: be1411a
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Apr 28 10:20:57 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Apr 28 10:20:57 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/io/graphml/GraphMLReader.java     | 12 ++++++++++--
 .../gremlin/structure/io/graphson/GraphSONReader.java   |  2 ++
 .../tinkerpop/gremlin/structure/io/gryo/GryoReader.java |  2 ++
 3 files changed, 14 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4a1aa020/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
index 89aed88..88ac149 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphml/GraphMLReader.java
@@ -155,6 +155,9 @@ public class GraphMLReader implements GraphReader {
                             edgeOutVertex = findOrCreate(vertexIdOut, graphToWriteTo, supportsVertexIds, cache);
                             edgeInVertex = findOrCreate(vertexIdIn, graphToWriteTo, supportsVertexIds, cache);
 
+                            if (supportsTx && counter.incrementAndGet() % batchSize == 0)
+                                graphToWriteTo.tx().commit();
+
                             isInEdge = true;
                             edgeProps = new HashMap<>();
 
@@ -191,6 +194,9 @@ public class GraphMLReader implements GraphReader {
 
                         findOrCreate(currentVertexId, graphToWriteTo, supportsVertexIds, cache, ElementHelper.upsert(propsAsArray, T.label, currentVertexLabel));
 
+                        if (supportsTx && counter.incrementAndGet() % batchSize == 0)
+                            graphToWriteTo.tx().commit();
+
                         vertexId = null;
                         vertexLabel = null;
                         vertexProps = null;
@@ -200,6 +206,9 @@ public class GraphMLReader implements GraphReader {
                         final Object[] propsReady = supportsEdgeIds ? ElementHelper.upsert(propsAsArray, T.id, edgeId) : propsAsArray;
                         edgeOutVertex.addEdge(edgeLabel, edgeInVertex, propsReady);
 
+                        if (supportsTx && counter.incrementAndGet() % batchSize == 0)
+                            graphToWriteTo.tx().commit();
+
                         edgeId = null;
                         edgeLabel = null;
                         edgeOutVertex = null;
@@ -211,8 +220,7 @@ public class GraphMLReader implements GraphReader {
                 }
             }
 
-            if (supportsTx && counter.incrementAndGet() % batchSize == 0)
-                graphToWriteTo.tx().commit();
+            if (supportsTx) graphToWriteTo.tx().commit();
         } catch (XMLStreamException xse) {
             // rollback whatever portion failed
             if (supportsTx && counter.incrementAndGet() % batchSize == 0)

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4a1aa020/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
index fad958a..a91cc24 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/graphson/GraphSONReader.java
@@ -88,6 +88,8 @@ public class GraphSONReader implements GraphReader {
             if (supportsTx && counter.incrementAndGet() % batchSize == 0)
                 graphToWriteTo.tx().commit();
         }));
+
+        if (supportsTx) graphToWriteTo.tx().commit();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4a1aa020/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
index 95dce2c..cf19c62 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/io/gryo/GryoReader.java
@@ -109,6 +109,8 @@ public class GryoReader implements GraphReader {
             if (supportsTx && counter.incrementAndGet() % batchSize == 0)
                 graphToWriteTo.tx().commit();
         }));
+
+        if (supportsTx) graphToWriteTo.tx().commit();
     }
 
     @Override