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/11 19:26:45 UTC

[29/50] [abbrv] incubator-tinkerpop git commit: Fixed PartitionStrategy tests.

Fixed PartitionStrategy tests.

Still some weirdness around how this works in relation to the GraphTraversalContext.  Since this is all going to change to TraversalStrategy, there really isn't much point in trying to fully resolve these issues.  For now it is enough that tests are passing.


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

Branch: refs/heads/master
Commit: c17607c32c2c4c9c294c861a3bcff6954e49b1b7
Parents: b0b66f3
Author: Stephen Mallette <sp...@apache.org>
Authored: Tue Mar 10 08:14:24 2015 -0400
Committer: Stephen Mallette <sp...@apache.org>
Committed: Tue Mar 10 08:14:24 2015 -0400

----------------------------------------------------------------------
 .../gremlin/structure/strategy/PartitionStrategy.java  | 13 +++++++++++++
 .../structure/strategy/PartitionStrategyTest.java      |  8 ++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c17607c3/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategy.java
index 40e5cce..5a6a6e1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategy.java
@@ -122,6 +122,19 @@ public final class PartitionStrategy implements GraphStrategy {
     }
 
     @Override
+    public UnaryOperator<Function<Object[], Iterator<Edge>>> getGraphIteratorsEdgeIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+        return (f) -> ids -> IteratorUtils.filter(f.apply(ids), e -> {
+            final Set<String> partitions = getReadPartitions();
+            return partitions.contains(e.value(partitionKey)) && partitions.contains(e.inVertex().value(partitionKey))  && partitions.contains(e.outVertex().value(partitionKey));
+        });
+    }
+
+    @Override
+    public UnaryOperator<Function<Object[], Iterator<Vertex>>> getGraphIteratorsVertexIteratorStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
+        return (f) -> ids -> IteratorUtils.filter(f.apply(ids), v -> getReadPartitions().contains((String) v.value(partitionKey)));
+    }
+
+    @Override
     public UnaryOperator<Function<Object[], GraphTraversal<Vertex, Vertex>>> getGraphVStrategy(final StrategyContext<StrategyGraph> ctx, final GraphStrategy composingStrategy) {
         return (f) -> ids -> {
             final GraphTraversal<Vertex, Vertex> traversal = this.generateTraversal(ctx.getStrategyGraph().getBaseGraph());

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/c17607c3/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategyTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategyTest.java b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategyTest.java
index 3891d67..3099d9c 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategyTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/structure/strategy/PartitionStrategyTest.java
@@ -196,8 +196,8 @@ public class PartitionStrategyTest extends AbstractGremlinTest {
         final Edge eAtovC = vA.addEdge("a->c", vC);
 
         strategy.clearReadPartitions();
-        assertEquals(new Long(0), g.V().count().next());
-        assertEquals(new Long(0), g.E().count().next());
+        assertEquals(0, IteratorUtils.count(graph.vertices()));
+        assertEquals(0, IteratorUtils.count(graph.edges()));
 
         strategy.addReadPartition("A");
         assertEquals(new Long(2), g.V().count().next());
@@ -224,9 +224,9 @@ public class PartitionStrategyTest extends AbstractGremlinTest {
         strategy.removeReadPartition("A");
         strategy.removeReadPartition("B");
 
-        assertEquals(new Long(1), g.V().count().next());
+        assertEquals(1, IteratorUtils.count(graph.vertices()));
         // two edges are in the "C" partition, but one each of their incident vertices are not
-        assertEquals(new Long(0), g.E().count().next());
+        assertEquals(0, IteratorUtils.count(graph.edges()));
 
         assertEquals(new Long(0), g.V(vC.id()).inE().count().next());
         assertEquals(new Long(0), g.V(vC.id()).in().count().next());