Skip to content
Browse files

intermediate

  • Loading branch information...
1 parent 3fc8c39 commit 1fb1caf8a67f642dac505b2017dd783192c7c2e5 @systay committed Oct 25, 2012
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/TrailBuilder.scala
@@ -167,8 +167,8 @@ final class TrailBuilder(patterns: Seq[Pattern], boundPoints: Seq[String], predi
val seq = p.asSeq
val idxOfVar = seq.indexWhere(_.isInstanceOf[VariableLengthStepTrail])
- val apa = p.asSeq.size - 2
- val result = startBound && !endBound && numberOfVarlength <= 1 && (numberOfVarlength == 0 || idxOfVar == apa)
+ val numberOfTrails = p.asSeq.size - 2
+ val result = startBound && !endBound && numberOfVarlength <= 1 && (numberOfVarlength == 0 || idxOfVar == numberOfTrails)
result
}
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/TraversalMatchPipe.scala
@@ -35,12 +35,14 @@ class TraversalMatchPipe(source: Pipe, matcher: TraversalMatcher, trail: Trail)
//Transform paths to maps
- paths.flatMap {
+ val res = paths.flatMap {
path =>
val seq = path.iterator().asScala.toSeq
val maps = trail.decompose(seq)
maps.map(context.newWith)
}
+
+ res
}
}
View
8 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/matching/PatternMatcher.scala
@@ -23,6 +23,7 @@ import org.neo4j.graphdb.Node
import org.neo4j.cypher.internal.commands.{True, Predicate}
import collection.Map
import org.neo4j.cypher.internal.pipes.ExecutionContext
+import org.neo4j.cypher.EntityNotFoundException
class PatternMatcher(bindings: Map[String, MatchingPair], predicates: Seq[Predicate], includeOptionals: Boolean, source:ExecutionContext)
extends Traversable[ExecutionContext] {
@@ -164,7 +165,12 @@ class PatternMatcher(bindings: Map[String, MatchingPair], predicates: Seq[Predic
private def isMatchSoFar(history: History): Boolean = {
val m = history.toMap
val predicate = predicates.filter(predicate=> !predicate.containsIsNull && predicate.symbolTableDependencies.forall(m contains))
- predicate.forall(_.isMatch(m))
+ predicate.forall(predicate1 => try {
+ predicate1.isMatch(m)
+ } catch {
+ case e: EntityNotFoundException => println(e)
+ throw e
+ })
}
private def traverseNextNodeOrYield[U](remaining: Set[MatchingPair], history: History, yielder: ExecutionContext => U): Boolean = {
View
47 cypher/src/test/scala/org/neo4j/cypher/ExecutionEngineTest.scala
@@ -2243,4 +2243,51 @@ RETURN x0.name?
assert(result.toList === List(Map("coll" -> List(refNode))))
}
+ @Test
+ def linked_list_retrieval() {
+ /*
+ (1) {"name":"A","value":10}
+(2) {"name":"B","value":20}
+(3) {"name":"C","value":30}
+(4) {"name":"ROOT"}
+(1)-[:LINK]->(2) {}
+(2)-[:LINK]->(3) {}
+(3)-[:LINK]->(4) {}
+(4)-[:LINK]->(1) {}
+ */
+
+ val root = createNode()
+ val a = createNode("value"->10)
+ val b = createNode("value"->20)
+ val c = createNode("value"->30)
+
+ relate(root,a)
+ relate(a,b)
+ relate(b,c)
+ relate(c,root)
+
+ val result = parseAndExecute(
+ """
+START root = node(1)
+MATCH root-[*0..]->x-[*0..]->root
+WHERE has(x.value)
+RETURN x.value
+ORDER BY x.value
+""")
+
+ println(parseAndExecute("""
+START root = node(1)
+MATCH
+ root-[*0..]->before,// before could be same as root
+ after-[*0..]->root, // after could be same as root
+ before-[old]->after
+WHERE before.value? < 25 // This is the value, which would normally
+ AND 25 < after.value? // be supplied through a parameter.
+CREATE before-[:X]->({value:25})-[:X]->after
+DELETE old""").dumpToString())
+
+
+ assert(result.toList === List(Map("x.value" -> 10),Map("x.value" -> 20),Map("x.value" -> 30)))
+ }
+
}

0 comments on commit 1fb1caf

Please sign in to comment.
Something went wrong with that request. Please try again.