You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by ok...@apache.org on 2015/05/21 22:30:30 UTC

incubator-tinkerpop git commit: removed GraphComputer.isolation() as all implementations use BSP. No point having it if no tests and no impls. If there is an ASP in the future, we can add back in the method.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/master b11629d82 -> 6153c5fe6


removed GraphComputer.isolation() as all implementations use BSP. No point having it if no tests and no impls. If there is an ASP in the future, we can add back in the method.


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

Branch: refs/heads/master
Commit: 6153c5fe6a64f316e3f0a8cd6b28e5e07be2cd09
Parents: b11629d
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Thu May 21 14:30:26 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Thu May 21 14:30:40 2015 -0600

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../gremlin/process/computer/GraphComputer.java | 29 -----------
 .../engine/ComputerTraversalEngine.java         |  9 +---
 .../tinkerpop/gremlin/structure/Graph.java      |  4 --
 .../process/computer/GraphComputerTest.java     | 32 +-----------
 .../computer/AbstractHadoopGraphComputer.java   | 11 -----
 .../process/computer/TinkerGraphComputer.java   | 51 +++++++++++++++++---
 .../process/computer/TinkerGraphView.java       |  4 +-
 .../tinkergraph/structure/TinkerHelper.java     |  4 +-
 9 files changed, 50 insertions(+), 95 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 072b3e6..7495b6a 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -25,6 +25,7 @@ image::http://www.tinkerpop.com/docs/current/images/gremlin-hindu.png[width=225]
 TinkerPop 3.0.0.M9 (NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Removed `GraphComputer.isolation()` as all implementations use standard BSP.
 * Added a Gremlin Server `LifeCycleHook` to ensure that certain scripts execute once at startup and once at shutdown.
 * `has(key)` and `hasNot(key)` are now aliases for `where(values(key))` and `where(not(values(key)))`, respectively.
 * TinkerGraph classes are now final to restrict user and vendor extension.

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputer.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputer.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputer.java
index dc6df81..272d6c0 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputer.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputer.java
@@ -31,19 +31,6 @@ import java.util.concurrent.Future;
  */
 public interface GraphComputer {
 
-    public enum Isolation {
-        /**
-         * Computations are carried out in a bulk synchronous manner.
-         * The results of a vertex property update are only visible after the round is complete.
-         */
-        BSP,
-        /**
-         * Computations are carried out in an bulk asynchronous manner.
-         * The results of a vertex property update are visible before the end of the round.
-         */
-        DIRTY_BSP
-    }
-
     public enum ResultGraph {
         /**
          * When the computation is complete, the {@link org.apache.tinkerpop.gremlin.structure.Graph} in {@link ComputerResult} is the original graph that spawned the graph computer.
@@ -71,14 +58,6 @@ public interface GraphComputer {
     }
 
     /**
-     * Set the {@link Isolation} of the computation.
-     *
-     * @param isolation the isolation of the computation
-     * @return the updated GraphComputer with newly set isolation
-     */
-    public GraphComputer isolation(final Isolation isolation);
-
-    /**
      * Set the {@link ResultGraph} of the computation.
      * If this is not set explicitly by the user, then the {@link VertexProgram} can choose the most efficient result for its intended use.
      * If there is no declared vertex program, then the {@link GraphComputer} defaults to {@link ResultGraph#ORIGINAL}.
@@ -174,10 +153,6 @@ public interface GraphComputer {
             return true;
         }
 
-        public default boolean supportsIsolation(final Isolation isolation) {
-            return true;
-        }
-
         /**
          * Supports {@link VertexProgram} and {@link MapReduce} parameters to be direct referenced Java objects (no serialization required).
          * This is typically true for single machine graph computer engines. For cluster oriented graph computers, this is typically false.
@@ -212,10 +187,6 @@ public interface GraphComputer {
             return new IllegalArgumentException("The provided key is not a memory compute key: " + key);
         }
 
-        public static IllegalArgumentException isolationNotSupported(final Isolation isolation) {
-            return new IllegalArgumentException("The provided isolation is not supported by this graph computer: " + isolation);
-        }
-
         public static IllegalArgumentException resultGraphPersistCombinationNotSupported(final ResultGraph resultGraph, final Persist persist) {
             return new IllegalArgumentException("The computer does not support the following result graph and persist combination: " + resultGraph + ":" + persist);
         }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/engine/ComputerTraversalEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/engine/ComputerTraversalEngine.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/engine/ComputerTraversalEngine.java
index bfcfaa2..8ef79f2 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/engine/ComputerTraversalEngine.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/engine/ComputerTraversalEngine.java
@@ -68,7 +68,6 @@ public final class ComputerTraversalEngine implements TraversalEngine {
     public static class Builder implements TraversalEngine.Builder {
 
         private Class<? extends GraphComputer> graphComputerClass;
-        private GraphComputer.Isolation isolation = GraphComputer.Isolation.BSP;
         private static final List<TraversalStrategy> WITH_STRATEGIES = Collections.singletonList(ComputerResultStrategy.instance());
 
         @Override
@@ -81,15 +80,11 @@ public final class ComputerTraversalEngine implements TraversalEngine {
             return this;
         }
 
-        public Builder isolation(final GraphComputer.Isolation isolation) {
-            this.isolation = isolation;
-            return this;
-        }
 
         public ComputerTraversalEngine create(final Graph graph) {
             return null == this.graphComputerClass ?
-                    new ComputerTraversalEngine(graph.compute().isolation(this.isolation)) :
-                    new ComputerTraversalEngine(graph.compute(this.graphComputerClass).isolation(this.isolation));
+                    new ComputerTraversalEngine(graph.compute()) :
+                    new ComputerTraversalEngine(graph.compute(this.graphComputerClass));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
index 1b514cc..10ca2a6 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/Graph.java
@@ -998,10 +998,6 @@ public interface Graph extends AutoCloseable, Host {
                     new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase() + " with id null does not exist in the graph") :
                     new NoSuchElementException("The " + elementClass.getSimpleName().toLowerCase() + " with id " + id + " of type " + id.getClass().getSimpleName() + " does not exist in the graph");
         }
-
-        public static IllegalArgumentException onlyOneOrNoGraphComputerClass() {
-            return new IllegalArgumentException("Provide either one or no graph computer class");
-        }
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
index 3827cc1..c1dc796 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphComputerTest.java
@@ -55,7 +55,6 @@ import static org.junit.Assert.*;
         "computerHasNoVertexProgramNorMapReducers",
         "computerHasAlreadyBeenSubmittedAVertexProgram",
         "providedKeyIsNotAnElementComputeKey",
-        "isolationNotSupported",
         "incidentAndAdjacentElementsCanNotBeAccessedInMapReduce",
         "adjacentVertexLabelsCanNotBeRead",
         "adjacentVertexPropertiesCanNotBeReadOrUpdated",
@@ -64,8 +63,7 @@ import static org.junit.Assert.*;
         "vertexPropertiesCanNotBeUpdatedInMapReduce"
 })
 @ExceptionCoverage(exceptionClass = Graph.Exceptions.class, methods = {
-        "graphDoesNotSupportProvidedGraphComputer",
-        "onlyOneOrNoGraphComputerClass"
+        "graphDoesNotSupportProvidedGraphComputer"
 })
 @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
 public class GraphComputerTest extends AbstractGremlinProcessTest {
@@ -88,30 +86,6 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
         }
     }
 
-    @Test
-    @LoadGraphWith(MODERN)
-    public void shouldFailIfIsolationIsNotSupported() {
-        final GraphComputer computer = graph.compute(graphComputerClass.get());
-        ;
-        if (!computer.features().supportsIsolation(GraphComputer.Isolation.BSP)) {
-            try {
-                computer.isolation(GraphComputer.Isolation.BSP);
-                fail("GraphComputer.isolation() should throw an exception if the isolation is not supported");
-            } catch (Exception ex) {
-                validateException(GraphComputer.Exceptions.isolationNotSupported(GraphComputer.Isolation.BSP), ex);
-            }
-        }
-        if (!computer.features().supportsIsolation(GraphComputer.Isolation.DIRTY_BSP)) {
-            try {
-                computer.isolation(GraphComputer.Isolation.DIRTY_BSP);
-                fail("GraphComputer.isolation() should throw an exception if the isolation is not supported");
-            } catch (Exception ex) {
-                validateException(GraphComputer.Exceptions.isolationNotSupported(GraphComputer.Isolation.DIRTY_BSP), ex);
-            }
-        }
-        assertEquals(StringFactory.graphComputerString(computer), computer.toString());
-    }
-
     /////////////////////////////////////////////
     @Test
     @LoadGraphWith(MODERN)
@@ -125,10 +99,6 @@ public class GraphComputerTest extends AbstractGremlinProcessTest {
     }
 
     public static class BadGraphComputer implements GraphComputer {
-        @Override
-        public GraphComputer isolation(final Isolation isolation) {
-            return null;
-        }
 
         @Override
         public GraphComputer result(final ResultGraph resultGraph) {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/AbstractHadoopGraphComputer.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/AbstractHadoopGraphComputer.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/AbstractHadoopGraphComputer.java
index 8bda57d..6cfc50e 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/AbstractHadoopGraphComputer.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/AbstractHadoopGraphComputer.java
@@ -59,13 +59,6 @@ public abstract class AbstractHadoopGraphComputer implements GraphComputer {
     }
 
     @Override
-    public GraphComputer isolation(final Isolation isolation) {
-        if (!isolation.equals(Isolation.BSP))
-            throw GraphComputer.Exceptions.isolationNotSupported(isolation);
-        return this;
-    }
-
-    @Override
     public GraphComputer result(final ResultGraph resultGraph) {
         this.resultGraph = Optional.of(resultGraph);
         return this;
@@ -150,10 +143,6 @@ public abstract class AbstractHadoopGraphComputer implements GraphComputer {
                 return false;
             }
 
-            public boolean supportsIsolation(final Isolation isolation) {
-                return isolation.equals(Isolation.BSP);
-            }
-
             public boolean supportsResultGraphPersistCombination(final ResultGraph resultGraph, final Persist persist) {
                 final OutputFormat<NullWritable, VertexWritable> outputFormat = ReflectionUtils.newInstance(hadoopGraph.configuration().getGraphOutputFormat(), ConfUtil.makeHadoopConfiguration(hadoopGraph.configuration()));
                 if (outputFormat instanceof PersistResultGraphAware)

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputer.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputer.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputer.java
index 7392e40..b92e9c1 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputer.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphComputer.java
@@ -45,7 +45,6 @@ import java.util.concurrent.Future;
  */
 public final class TinkerGraphComputer implements GraphComputer {
 
-    private Isolation isolation = Isolation.BSP;
     private Optional<ResultGraph> resultGraph = Optional.empty();
     private Optional<Persist> persist = Optional.empty();
 
@@ -66,12 +65,6 @@ public final class TinkerGraphComputer implements GraphComputer {
     }
 
     @Override
-    public GraphComputer isolation(final Isolation isolation) {
-        this.isolation = isolation;
-        return this;
-    }
-
-    @Override
     public GraphComputer result(final ResultGraph resultGraph) {
         this.resultGraph = Optional.of(resultGraph);
         return this;
@@ -124,7 +117,7 @@ public final class TinkerGraphComputer implements GraphComputer {
             final long time = System.currentTimeMillis();
             try (final TinkerWorkerPool workers = new TinkerWorkerPool(Runtime.getRuntime().availableProcessors())) {
                 if (null != this.vertexProgram) {
-                    TinkerHelper.createGraphView(this.graph, this.isolation, this.vertexProgram.getElementComputeKeys());
+                    TinkerHelper.createGraphView(this.graph, this.vertexProgram.getElementComputeKeys());
                     // execute the vertex program
                     this.vertexProgram.setup(this.memory);
                     this.memory.completeSubRound();
@@ -224,4 +217,46 @@ public final class TinkerGraphComputer implements GraphComputer {
             return this.iterator.hasNext() ? this.iterator.next() : null;
         }
     }
+
+    @Override
+    public Features features() {
+        return new Features() {
+
+            public boolean supportsVertexAddition() {
+                return false;
+            }
+
+            public boolean supportsVertexRemoval() {
+                return false;
+            }
+
+            public boolean supportsVertexPropertyRemoval() {
+                return false;
+            }
+
+            public boolean supportsEdgeAddition() {
+                return false;
+            }
+
+            public boolean supportsEdgeRemoval() {
+                return false;
+            }
+
+            public boolean supportsEdgePropertyAddition() {
+                return false;
+            }
+
+            public boolean supportsEdgePropertyRemoval() {
+                return false;
+            }
+
+            public boolean supportsResultGraphPersistCombination(final ResultGraph resultGraph, final Persist persist) {
+                return persist == Persist.NOTHING || resultGraph != ResultGraph.ORIGINAL;
+            }
+
+            public boolean supportsDirectObjects() {
+                return true;
+            }
+        };
+    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphView.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphView.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphView.java
index 0a9449f..d30b142 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphView.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/process/computer/TinkerGraphView.java
@@ -43,11 +43,9 @@ import java.util.stream.Stream;
 public final class TinkerGraphView {
 
     protected final Set<String> computeKeys;
-    protected final GraphComputer.Isolation isolation;
     private Map<Element, Map<String, List<VertexProperty>>> computeProperties;
 
-    public TinkerGraphView(final GraphComputer.Isolation isolation, final Set<String> computeKeys) {
-        this.isolation = isolation;
+    public TinkerGraphView(final Set<String> computeKeys) {
         this.computeKeys = computeKeys;
         this.computeProperties = new ConcurrentHashMap<>();
     }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/6153c5fe/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java
index 3105b7b..21e3beb 100644
--- a/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java
+++ b/tinkergraph-gremlin/src/main/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerHelper.java
@@ -101,8 +101,8 @@ public final class TinkerHelper {
         return null != graph.graphView;
     }
 
-    public static TinkerGraphView createGraphView(final TinkerGraph graph, final GraphComputer.Isolation isolation, final Set<String> computeKeys) {
-        return graph.graphView = new TinkerGraphView(isolation, computeKeys);
+    public static TinkerGraphView createGraphView(final TinkerGraph graph, final Set<String> computeKeys) {
+        return graph.graphView = new TinkerGraphView(computeKeys);
     }
 
     public static Map<String, List<VertexProperty>> getProperties(final TinkerVertex vertex) {