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 2016/02/05 09:35:44 UTC

incubator-tinkerpop git commit: Added JavaDoc to GraphFilter and GraphFilterInputFormat. More JavaDoc to GraphFilter along the way...

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-962 502113545 -> 4134254c5


Added JavaDoc to GraphFilter and GraphFilterInputFormat. More JavaDoc to GraphFilter along the way...


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

Branch: refs/heads/TINKERPOP-962
Commit: 4134254c510150e9c9314dc85d25be54dd1a4a9f
Parents: 5021135
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Feb 5 01:35:50 2016 -0700
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Feb 5 01:35:50 2016 -0700

----------------------------------------------------------------------
 .../gremlin/process/computer/GraphFilter.java      |  7 +++++++
 .../process/computer/GraphFilterInputFormat.java   | 17 +++++++++++++----
 2 files changed, 20 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4134254c/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
index 0be3392..d5d4186 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/GraphFilter.java
@@ -41,6 +41,13 @@ import java.util.Optional;
 import java.util.Set;
 
 /**
+ * GraphFilter is used by {@link GraphComputer} implementations to prune the source graph data being loaded into the OLAP system.
+ * There are two types of filters: a {@link Vertex} filter and an {@link Edge} filter.
+ * The vertex filter is a {@link Traversal} that can only check the id, label, and properties of the vertex.
+ * The edge filter is a {@link Traversal} that starts at the vertex are emits all legal incident edges.
+ * The use of GraphFilter can greatly reduce the amount of data processed by the {@link GraphComputer}.
+ * For instance, for {@code g.V().count()}, there is no reason to load edges, and thus, the edge filter can be {@code bothE().limit(0)}.
+ *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
 public final class GraphFilter implements Cloneable, Serializable {

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/4134254c/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/GraphFilterInputFormat.java
----------------------------------------------------------------------
diff --git a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/GraphFilterInputFormat.java b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/GraphFilterInputFormat.java
index 1d1b150..2ba48df 100644
--- a/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/GraphFilterInputFormat.java
+++ b/hadoop-gremlin/src/main/java/org/apache/tinkerpop/gremlin/hadoop/process/computer/GraphFilterInputFormat.java
@@ -28,15 +28,22 @@ import org.apache.hadoop.mapreduce.RecordReader;
 import org.apache.hadoop.mapreduce.TaskAttemptContext;
 import org.apache.hadoop.util.ReflectionUtils;
 import org.apache.tinkerpop.gremlin.hadoop.Constants;
+import org.apache.tinkerpop.gremlin.hadoop.structure.io.GraphFilterAware;
 import org.apache.tinkerpop.gremlin.hadoop.structure.io.VertexWritable;
+import org.apache.tinkerpop.gremlin.process.computer.GraphFilter;
 
 import java.io.IOException;
 import java.util.List;
 
 /**
+ * GraphFilterInputFormat is a utility {@link InputFormat} that is useful if the underlying InputFormat is not {@link GraphFilterAware}.
+ * If the underlying InputFormat is GraphFilterAware, then GraphFilterInputFormat acts as an identity mapping.
+ * If the underlying InputFormat is not GraphFilterAware, then GraphFilterInputFormat will apply the respective {@link GraphFilter}
+ * and prune the loaded source graph data accordingly.
+ *
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  */
-public final class GraphFilterInputFormat extends InputFormat<NullWritable, VertexWritable> {
+public final class GraphFilterInputFormat extends InputFormat<NullWritable, VertexWritable> implements GraphFilterAware {
 
     @Override
     public List<InputSplit> getSplits(final JobContext jobContext) throws IOException, InterruptedException {
@@ -46,9 +53,11 @@ public final class GraphFilterInputFormat extends InputFormat<NullWritable, Vert
 
     @Override
     public RecordReader<NullWritable, VertexWritable> createRecordReader(final InputSplit inputSplit, final TaskAttemptContext taskAttemptContext) throws IOException, InterruptedException {
-        final GraphFilterRecordReader recordReader = new GraphFilterRecordReader();
-        recordReader.initialize(inputSplit, taskAttemptContext);
-        return recordReader;
+        return new GraphFilterRecordReader();
     }
 
+    @Override
+    public void setGraphFilter(final GraphFilter graphFilter) {
+        // do nothing -- loaded via configuration
+    }
 }