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/06/18 01:39:01 UTC
incubator-tinkerpop git commit: fixed a bug in ORing where I needed
the traversal parent ID, not the step ID. Also,
fixed a index lookup issue with nested AND/OR match patterns.
Repository: incubator-tinkerpop
Updated Branches:
refs/heads/master 03289c879 -> 064e48fd1
fixed a bug in ORing where I needed the traversal parent ID, not the step ID. Also, fixed a index lookup issue with nested AND/OR match patterns.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/commit/064e48fd
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/tree/064e48fd
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/diff/064e48fd
Branch: refs/heads/master
Commit: 064e48fd1cfe67f63582a109716d195d5038a04d
Parents: 03289c8
Author: Marko A. Rodriguez <ok...@gmail.com>
Authored: Wed Jun 17 17:38:58 2015 -0600
Committer: Marko A. Rodriguez <ok...@gmail.com>
Committed: Wed Jun 17 17:38:58 2015 -0600
----------------------------------------------------------------------
.../traversal/step/filter/exp/XMatchStep.java | 6 ++--
.../optimization/MatchWhereStrategy.java | 29 +++++++++++---------
.../tinkergraph/structure/TinkerGraphTest.java | 14 +++++-----
3 files changed, 26 insertions(+), 23 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/064e48fd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
index dff2d42..e3384fa 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/filter/exp/XMatchStep.java
@@ -73,7 +73,7 @@ public final class XMatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
private Set<String> scopeKeys = null;
private final Conjunction conjunction;
private final String startKey;
- private final MatchAlgorithm matchAlgorithm = new CountMatchAlgorithm();
+ private final MatchAlgorithm matchAlgorithm = new GreedyMatchAlgorithm();
public XMatchStep(final Traversal.Admin traversal, final String startKey, final Conjunction conjunction, final Traversal... conjunctionTraversals) {
super(traversal);
@@ -246,7 +246,7 @@ public final class XMatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
} else {
for (final Traversal.Admin<?, ?> conjunctionTraversal : this.conjunctionTraversals) {
final Traverser split = traverser.split();
- split.path().addLabel(conjunctionTraversal.getStartStep().getId());
+ split.path().addLabel(conjunctionTraversal.getParent().asStep().getId());
conjunctionTraversal.addStart(split);
}
}
@@ -273,7 +273,7 @@ public final class XMatchStep<S, E> extends ComputerAwareStep<S, Map<String, E>>
final List<Traverser<Map<String, E>>> traversers = new ArrayList<>();
this.conjunctionTraversals.forEach(conjunctionTraversal -> {
final Traverser.Admin split = traverser.split();
- split.path().addLabel(conjunctionTraversal.getStartStep().getId());
+ split.path().addLabel(conjunctionTraversal.getParent().asStep().getId());
split.setStepId(conjunctionTraversal.getStartStep().getId());
traversers.add(split);
});
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/064e48fd/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchWhereStrategy.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchWhereStrategy.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchWhereStrategy.java
index 93881ab..3adee58 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchWhereStrategy.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/optimization/MatchWhereStrategy.java
@@ -24,6 +24,7 @@ import org.apache.tinkerpop.gremlin.process.traversal.step.filter.HasStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.WhereStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.filter.exp.XMatchStep;
import org.apache.tinkerpop.gremlin.process.traversal.step.map.match.MatchStep;
+import org.apache.tinkerpop.gremlin.process.traversal.step.util.EmptyStep;
import org.apache.tinkerpop.gremlin.process.traversal.strategy.AbstractTraversalStrategy;
import org.apache.tinkerpop.gremlin.process.traversal.util.TraversalHelper;
@@ -64,19 +65,21 @@ public final class MatchWhereStrategy extends AbstractTraversalStrategy<Traversa
TraversalHelper.getStepsOfClass(XMatchStep.class, traversal).forEach(matchStep -> {
if (matchStep.getStartKey().isPresent()) {
((XMatchStep<?, ?>) matchStep).getGlobalChildren().stream().collect(Collectors.toList()).forEach(conjunction -> {
- ((XMatchStep<?, ?>.XMatchStartStep) conjunction.getStartStep()).getSelectKey().ifPresent(selectKey -> {
- if (selectKey.equals(matchStep.getStartKey().get()) && !conjunction.getSteps().stream()
- .filter(step -> !(step instanceof XMatchStep.XMatchStartStep) &&
- !(step instanceof XMatchStep.XMatchEndStep) &&
- !(step instanceof HasStep))
- .findAny()
- .isPresent()) {
- matchStep.removeGlobalChild(conjunction);
- conjunction.removeStep(0); // remove XMatchStartStep
- conjunction.removeStep(conjunction.getSteps().size() - 1); // remove XMatchEndStep
- TraversalHelper.insertTraversal(matchStep.getPreviousStep(), conjunction, traversal);
- }
- });
+ if (conjunction.getStartStep() instanceof XMatchStep.XMatchStartStep) {
+ ((XMatchStep<?, ?>.XMatchStartStep) conjunction.getStartStep()).getSelectKey().ifPresent(selectKey -> {
+ if (selectKey.equals(matchStep.getStartKey().get()) && !conjunction.getSteps().stream()
+ .filter(step -> !(step instanceof XMatchStep.XMatchStartStep) &&
+ !(step instanceof XMatchStep.XMatchEndStep) &&
+ !(step instanceof HasStep))
+ .findAny()
+ .isPresent() && !(matchStep.getPreviousStep() instanceof EmptyStep)) {
+ matchStep.removeGlobalChild(conjunction);
+ conjunction.removeStep(0); // remove XMatchStartStep
+ conjunction.removeStep(conjunction.getSteps().size() - 1); // remove XMatchEndStep
+ TraversalHelper.insertTraversal(matchStep.getPreviousStep(), conjunction, traversal);
+ }
+ });
+ }
});
}
});
http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/064e48fd/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
----------------------------------------------------------------------
diff --git a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
index 78fc475..c68d4f3 100644
--- a/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
+++ b/tinkergraph-gremlin/src/test/java/org/apache/tinkerpop/gremlin/tinkergraph/structure/TinkerGraphTest.java
@@ -221,7 +221,7 @@ public class TinkerGraphTest {
@Test
@Ignore
public void testPlay5() throws Exception {
- GraphTraversalSource g = TinkerFactory.createModern().traversal(GraphTraversalSource.standard());
+ GraphTraversalSource g = TinkerFactory.createModern().traversal(GraphTraversalSource.computer());
/*final Supplier<Traversal<?, ?>> traversal = () -> g.V().xmatch("a",
as("a").out("created").as("b"),
or(
@@ -237,17 +237,17 @@ public class TinkerGraphTest {
as("a").local(out("created").count()).as("b"))
.select().by("name");*/
- /*final Supplier<Traversal<?, ?>> traversal = () ->
+ final Supplier<Traversal<?, ?>> traversal = () ->
g.V().xmatch("a",
where("a", P.neq("c")),
as("a").out("created").as("b"),
or(
as("a").out("knows").has("name", "vadas"),
- as("a").in("knows")
+ as("a").in("knows").and().as("a").has(T.label,"person")
),
as("b").in("created").as("c"),
- as("b").where(in("created").count().is(P.gt(1))))
- .select();*/
+ as("b").in("created").count().is(P.gt(1)))
+ .select().by("name");
/*final Supplier<Traversal<?,?>> traversal = () ->
g.V().xmatch("a",
@@ -260,8 +260,8 @@ public class TinkerGraphTest {
not(in("knows").as("a")).and().as("b").in().count().is(P.gt(1))
).select().by("name"); */
- final Supplier<Traversal<?,?>> traversal = () ->
- g.V().as("a").out("created").as("b").in("created").as("c").both("knows").both("knows").as("d").where("c",P.not(P.eq("a").or(P.eq("d")))).select().by("name");
+ /*final Supplier<Traversal<?,?>> traversal = () ->
+ g.V().as("a").out("created").as("b").in("created").as("c").both("knows").both("knows").as("d").where("c",P.not(P.eq("a").or(P.eq("d")))).select().by("name"); */
System.out.println(traversal.get());
System.out.println(traversal.get().iterate());