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/03/27 14:01:48 UTC
[4/6] incubator-tinkerpop git commit: Add "Event" related classes to
standard imports.
Add "Event" related classes to standard imports.
Event related classes are now available in the ScriptEngine and Console. Unsure how useful they ultimately are in this context, but will at least make experimentation possible in the console.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/ea51641f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/ea51641f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/ea51641f
Branch: refs/heads/master
Commit: ea51641ff4da600f484c469742d0aff71e1526e8
Parents: f0c9774
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Fri Mar 27 08:37:04 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Fri Mar 27 08:37:04 2015 -0400
----------------------------------------------------------------------
docs/src/the-traversal.asciidoc | 26 +++++++++++++++++++-
.../AbstractImportCustomizerProvider.java | 4 ++-
2 files changed, 28 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea51641f/docs/src/the-traversal.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/the-traversal.asciidoc b/docs/src/the-traversal.asciidoc
index 276172d..d9aa4ea 100644
--- a/docs/src/the-traversal.asciidoc
+++ b/docs/src/the-traversal.asciidoc
@@ -1491,10 +1491,11 @@ g.V().out().out().path().by('name').
TraversalStrategy
-----------------
-image:traversal-strategy.png[width=125,float=right] A `TraversalStrategy` can analyze a `Traversal` and mutate the traversal as it deems fit. This is useful in two situations:
+image:traversal-strategy.png[width=125,float=right] A `TraversalStrategy` can analyze a `Traversal` and mutate the traversal as it deems fit. This is useful in multiple situations:
* There is a more efficient way to express the traversal at the TinkerPop3 level.
* There is a more efficient way to express the traversal at the graph vendor level.
+ * There are generally useful features that can be automatically embedded into the traversal logic and tend to be applicable to end-users.
A simple TraversalStrategy is the `IdentityRemovalStrategy` and it is a type-1 strategy defined as follows:
@@ -1592,6 +1593,29 @@ t.iterate(); null
t.toString()
----
+TinkerPop3 has a number of type-3 strategies distributed as part of its core library. These strategies add generalized features to a traversal that are typically useful to end-users. The following sections detail these strategies:
+
+EventStrategy
+=============
+
+The purpose of the `EventStrategy` is to raise events to one or more `MutationListener` objects as changes to the underlying `Graph` occur within a `Traversal`. Such a strategy is useful for logging changes, triggering certain actions based on change, or any application that needs notification of some mutating operation during a `Traversal`. Graphs that do not support transactions will generate events immediately upon mutation, while those graphs that support transactions will queue the mutations until that transaction is committed and will then raise the events. If the transaction is rolled back, the event queue is reset.
+
+The following events are raised to the `MutationListener`:
+
+* New vertex
+* New edge
+* Vertex property changed
+* Edge property changed
+* Vertex property removed
+* Edge property removed
+* Vertex removed
+* Edge removed
+
+To start processing events from a `Traversal` first implement the `MutationListener` interface. An example of this implementation is the `ConsoleMutationListener` which writes output to the console for each event.
+
+
+CAUTION: `EventStrategy` is not meant for usage in tracking global mutations across separate processes. In other words, an mutation in what JVM process is not raised as an event in a different JVM process. In addition, events are not raised when mutations occur as part of side-effect steps (i.e. a lambda).
+
Domain Specific Languages
-------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/ea51641f/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
index 6053cc0..a48dffb 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/AbstractImportCustomizerProvider.java
@@ -37,6 +37,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalOptionParent;
import org.apache.tinkerpop.gremlin.process.traversal.engine.ComputerTraversalEngine;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.event.Event;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.decoration.PartitionStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalMetrics;
import org.apache.tinkerpop.gremlin.structure.Compare;
@@ -88,7 +89,8 @@ public abstract class AbstractImportCustomizerProvider implements ImportCustomiz
imports.add(GraphComputer.class.getPackage().getName() + DOT_STAR);
imports.add(GraphTraversal.class.getPackage().getName() + DOT_STAR);
imports.add(ComputerTraversalEngine.class.getPackage().getName() + DOT_STAR);
- imports.add(PartitionStrategy.class.getPackage().getName() + DOT_STAR);
+ imports.add(PartitionStrategy.class.getPackage().getName() + DOT_STAR); // decoration strategies
+ imports.add(Event.class.getPackage().getName() + DOT_STAR); // eventing
staticImports.add(__.class.getCanonicalName() + DOT_STAR);
staticImports.add(TraversalOptionParent.Pick.class.getCanonicalName() + DOT_STAR);
staticImports.add(GraphTraversalSource.class.getCanonicalName() + DOT_STAR);