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/03/25 17:53:57 UTC
[23/24] incubator-tinkerpop git commit: a few PRs ago I added
TraversalParent.isGlobalChild()/isLocalChild(). These are not really helpful
as you need to recurse up the traversal tree to know if they are global or
local. I removed these methods (its okay
a few PRs ago I added TraversalParent.isGlobalChild()/isLocalChild(). These are not really helpful as you need to recurse up the traversal tree to know if they are global or local. I removed these methods (its okay, were added in 3.2.0) and added TraversalHelper.isGlobalChild() which does hte recurssion. I added a nice array of validations for this method in TraversalHelperTest. CTR.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/29d267f2
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/29d267f2
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/29d267f2
Branch: refs/heads/TINKERPOP-1236
Commit: 29d267f26639ed093209687c5259350a2dd8fe88
Parents: cbdac5e
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Fri Mar 25 10:11:49 2016 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Fri Mar 25 10:11:49 2016 -0600
----------------------------------------------------------------------
.../step/map/TraversalVertexProgramStep.java | 10 ---
.../process/traversal/step/TraversalParent.java | 8 --
.../process/traversal/step/util/EmptyStep.java | 10 ---
.../process/traversal/util/TraversalHelper.java | 2 +-
.../traversal/step/TraversalParentTest.java | 79 --------------------
.../process/util/TraversalHelperTest.java | 50 +++++++++++++
6 files changed, 51 insertions(+), 108 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
index a81fbaf..6a0191b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/traversal/step/map/TraversalVertexProgramStep.java
@@ -54,16 +54,6 @@ public final class TraversalVertexProgramStep extends VertexProgramStep implemen
}
@Override
- public boolean isGlobalChild(final Traversal.Admin<?, ?> childTraversal) {
- return true;
- }
-
- @Override
- public boolean isLocalChild(final Traversal.Admin<?, ?> childTraversal) {
- return false;
- }
-
- @Override
public String toString() {
return StringFactory.stepString(this, this.computerTraversal.get());
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParent.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParent.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParent.java
index 4fb5e27..33272ab 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParent.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParent.java
@@ -57,14 +57,6 @@ public interface TraversalParent {
throw new IllegalStateException("This traversal parent does not support the removal of global traversals: " + this.getClass().getCanonicalName());
}
- public default boolean isLocalChild(final Traversal.Admin<?, ?> childTraversal) {
- return this.getLocalChildren().contains(childTraversal);
- }
-
- public default boolean isGlobalChild(final Traversal.Admin<?, ?> childTraversal) {
- return this.getGlobalChildren().contains(childTraversal);
- }
-
public default Set<TraverserRequirement> getSelfAndChildRequirements(final TraverserRequirement... selfRequirements) {
final Set<TraverserRequirement> requirements = EnumSet.noneOf(TraverserRequirement.class);
Collections.addAll(requirements, selfRequirements);
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/EmptyStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/EmptyStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/EmptyStep.java
index 4741fb9..8e699f1 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/EmptyStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/EmptyStep.java
@@ -144,14 +144,4 @@ public final class EmptyStep<S, E> implements Step<S, E>, TraversalParent {
public Set<TraverserRequirement> getRequirements() {
return Collections.emptySet();
}
-
- @Override
- public boolean isGlobalChild(final Traversal.Admin<?, ?> childTraversal) {
- return true;
- }
-
- @Override
- public boolean isLocalChild(final Traversal.Admin<?, ?> childTraversal) {
- return false;
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
index 9f5a236..fe76381 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/util/TraversalHelper.java
@@ -240,7 +240,7 @@ public final class TraversalHelper {
public static boolean isGlobalChild(Traversal.Admin<?, ?> traversal) {
while (!(traversal.getParent() instanceof EmptyStep)) {
- if (traversal.getParent().isLocalChild(traversal))
+ if (traversal.getParent().getLocalChildren().contains(traversal))
return false;
traversal = traversal.getParent().asStep().getTraversal();
}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParentTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParentTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParentTest.java
deleted file mode 100644
index 6248fcb..0000000
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/traversal/step/TraversalParentTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.tinkerpop.gremlin.process.traversal.step;
-
-import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
-import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
-import org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalFlatMapStep;
-import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep;
-import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
-import org.junit.Test;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author Marko A. Rodriguez (http://markorodriguez.com)
- */
-public class TraversalParentTest {
-
- @Test
- public void shouldIdentityLocalChildren() {
- final Traversal.Admin<?, ?> localChild = __.as("x").select("a", "b").by("name").asAdmin();
- TraversalParent parent = new LocalStep<>(new DefaultTraversal(), localChild);
- assertTrue(parent.isLocalChild(localChild));
- assertFalse(parent.isGlobalChild(localChild));
- ///
- parent = new WhereTraversalStep<>(new DefaultTraversal(), localChild);
- assertTrue(parent.isLocalChild(localChild));
- assertFalse(parent.isGlobalChild(localChild));
- ///
- parent = new TraversalFilterStep<>(new DefaultTraversal(), localChild);
- assertTrue(parent.isLocalChild(localChild));
- assertFalse(parent.isGlobalChild(localChild));
- ///
- parent = new TraversalMapStep<>(new DefaultTraversal(), localChild);
- assertTrue(parent.isLocalChild(localChild));
- assertFalse(parent.isGlobalChild(localChild));
- ///
- parent = new TraversalFlatMapStep<>(new DefaultTraversal(), localChild);
- assertTrue(parent.isLocalChild(localChild));
- assertFalse(parent.isGlobalChild(localChild));
- }
-
- @Test
- public void shouldIdentityGlobalChildren() {
- final Traversal.Admin<?, ?> globalChild = __.select("a", "b").by("name").asAdmin();
- TraversalParent parent = new RepeatStep<>(new DefaultTraversal());
- ((RepeatStep) parent).setRepeatTraversal(globalChild);
- assertFalse(parent.isLocalChild(globalChild));
- assertTrue(parent.isGlobalChild(globalChild));
- ///
- parent = new UnionStep<>(new DefaultTraversal(), globalChild);
- assertFalse(parent.isLocalChild(globalChild));
- assertTrue(parent.isGlobalChild(globalChild));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/29d267f2/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java
index 626cd0b..6d3577c 100644
--- a/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java
+++ b/gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/process/util/TraversalHelperTest.java
@@ -18,13 +18,22 @@
*/
package org.apache.tinkerpop.gremlin.process.util;
+import org.apache.tinkerpop.gremlin.process.computer.traversal.step.map.TraversalVertexProgramStep;
import org.apache.tinkerpop.gremlin.process.traversal.Step;
import org.apache.tinkerpop.gremlin.process.traversal.Traversal;
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.__;
+import org.apache.tinkerpop.gremlin.process.traversal.step.TraversalParent;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.LocalStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.RepeatStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.branch.UnionStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.FilterStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.LambdaFilterStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.TraversalFilterStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereTraversalStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.PropertiesStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalFlatMapStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.map.TraversalMapStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.sideEffect.IdentityStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
import org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal;
@@ -47,6 +56,47 @@ import static org.junit.Assert.assertTrue;
public class TraversalHelperTest {
@Test
+ public void shouldIdentifyLocalChildren() {
+ final Traversal.Admin<?, ?> localChild = __.as("x").select("a", "b").by("name").asAdmin();
+ new LocalStep<>(new DefaultTraversal(), localChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ ///
+ new WhereTraversalStep<>(new DefaultTraversal(), localChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ ///
+ new TraversalFilterStep<>(new DefaultTraversal(), localChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ ///
+ new TraversalMapStep<>(new DefaultTraversal(), localChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ ///
+ new TraversalFlatMapStep<>(new DefaultTraversal(), localChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ ///
+ final Traversal.Admin<?, ?> remoteLocalChild = __.repeat(localChild).asAdmin();
+ new LocalStep<>(new DefaultTraversal<>(), remoteLocalChild);
+ assertFalse(TraversalHelper.isGlobalChild(localChild));
+ }
+
+ @Test
+ public void shouldIdentifyGlobalChildren() {
+ final Traversal.Admin<?, ?> globalChild = __.select("a", "b").by("name").asAdmin();
+ TraversalParent parent = new RepeatStep<>(new DefaultTraversal());
+ ((RepeatStep) parent).setRepeatTraversal(globalChild);
+ assertTrue(TraversalHelper.isGlobalChild(globalChild));
+ ///
+ new UnionStep<>(new DefaultTraversal(), globalChild);
+ assertTrue(TraversalHelper.isGlobalChild(globalChild));
+ ///
+ new TraversalVertexProgramStep(new DefaultTraversal<>(), globalChild);
+ assertTrue(TraversalHelper.isGlobalChild(globalChild));
+ ///
+ final Traversal.Admin<?, ?> remoteRemoteChild = __.repeat(globalChild).asAdmin();
+ new UnionStep<>(new DefaultTraversal(), remoteRemoteChild);
+ assertTrue(TraversalHelper.isGlobalChild(globalChild));
+ }
+
+ @Test
public void shouldIdentityLocalProperties() {
assertTrue(TraversalHelper.isLocalProperties(__.identity().asAdmin()));
assertTrue(TraversalHelper.isLocalProperties(__.id().asAdmin()));