You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2015/09/01 16:26:26 UTC
[10/19] incubator-tinkerpop git commit: removed unnecessary code to
make BLVP thread safe
removed unnecessary code to make BLVP thread safe
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/99a85aee
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/99a85aee
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/99a85aee
Branch: refs/heads/tp30
Commit: 99a85aee46535e2f26f24178153e9b3e207ba1a2
Parents: abb9a73
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Thu Aug 27 20:03:10 2015 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Thu Aug 27 20:03:10 2015 +0200
----------------------------------------------------------------------
.../bulkloading/BulkLoaderVertexProgram.java | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/99a85aee/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 67d8da0..bfa88fd 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,7 +46,6 @@ 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,8 +67,8 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
private BulkLoader bulkLoader;
private Graph graph;
private GraphTraversalSource g;
- private Long intermediateBatchSize;
- private AtomicLong counter = new AtomicLong();
+ private long intermediateBatchSize;
+ private long counter;
private BulkLoaderVertexProgram() {
messageScope = MessageScope.Local.of(__::inE);
@@ -107,14 +106,14 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
}
private void commit(final boolean force) {
- if (!force && (intermediateBatchSize == 0L || counter.incrementAndGet() % intermediateBatchSize != 0)) return;
+ if (!force && (intermediateBatchSize == 0L || ++counter % intermediateBatchSize != 0)) return;
if (null != graph) {
if (graph.features().graph().supportsTransactions()) {
LOGGER.info("Committing transaction on Graph instance: {}", graph);
try {
graph.tx().commit(); // TODO will Giraph/MR restart the program and re-run execute if this fails?
LOGGER.debug("Committed transaction on Graph instance: {}", graph);
- counter.set(0L);
+ counter = 0L;
} catch (Exception e) {
LOGGER.error("Failed to commit transaction on Graph instance: {}", graph);
graph.tx().rollback();
@@ -148,13 +147,7 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple> {
DEFAULT_BULK_LOADER_VERTEX_ID);
}
intermediateBatchSize = configuration.getLong(INTERMEDIATE_BATCH_SIZE_CFG_KEY, 0L);
- final String bulkLoaderVertexIdProperty = configuration.subset(BULK_LOADER_CFG_KEY)
- .getString(BULK_LOADER_VERTEX_ID_CFG_KEY);
- if (!elementComputeKeys.contains(bulkLoaderVertexIdProperty)) {
- synchronized (elementComputeKeys) {
- elementComputeKeys.add(bulkLoaderVertexIdProperty);
- }
- }
+ elementComputeKeys.add(configuration.subset(BULK_LOADER_CFG_KEY).getString(BULK_LOADER_VERTEX_ID_CFG_KEY));
}
@Override