Browse files

Renamed the PlanBuilder to MonoPlanBuilder

  • Loading branch information...
1 parent 4a41899 commit a8a73c6e38cb2b3c0dd4fd14dd14bac42e80cd5c @systay committed Sep 23, 2012
Showing with 55 additions and 45 deletions.
  1. +12 −4 ...rc/main/scala/org/neo4j/cypher/internal/executionplan/{PlanBuilder.scala → MonoPlanBuilder.scala}
  2. +2 −1 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/PartiallySolvedQuery.scala
  3. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/AggregationBuilder.scala
  4. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ColumnFilterBuilder.scala
  5. +2 −2 ...n/scala/org/neo4j/cypher/internal/executionplan/builders/CreateNodesAndRelationshipsBuilder.scala
  6. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/EmptyResultBuilder.scala
  7. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ExtractBuilder.scala
  8. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilder.scala
  9. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/GraphGlobalStartBuilder.scala
  10. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/IndexQueryBuilder.scala
  11. +2 −3 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/MatchBuilder.scala
  12. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/NamedPathBuilder.scala
  13. +1 −1 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/NodeByIdBuilder.scala
  14. +1 −1 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/RelationshipByIdBuilder.scala
  15. +2 −3 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ShortestPathBuilder.scala
  16. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/SliceBuilder.scala
  17. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/SortBuilder.scala
  18. +2 −2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/UpdateActionBuilder.scala
  19. +8 −5 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/nestedHashJoin/HashJoinContext.scala
  20. +1 −1 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/ExecutionPlanImplTest.scala
  21. +2 −2 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/builders/NodeByIdBuilderTest.scala
View
16 .../internal/executionplan/PlanBuilder.scala → ...ernal/executionplan/MonoPlanBuilder.scala
@@ -19,10 +19,7 @@
*/
package org.neo4j.cypher.internal.executionplan
-/*
-PlanBuilders take a unsolved query, and solves another piece of it.
-*/
-trait PlanBuilder {
+trait MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress): ExecutionPlanInProgress
def canWorkWith(plan: ExecutionPlanInProgress): Boolean
@@ -33,6 +30,17 @@ trait PlanBuilder {
def priority: Int
}
+trait PlanBuilder {
+ def apply(plan: PartialExecPlan): PartialExecPlan
+
+ def canWorkWith(plan: PartialExecPlan): Boolean
+
+ def missingDependencies(plan: PartialExecPlan):Seq[String] = Seq()
+
+ // Lower priority wins
+ def priority: Int
+}
+
// The priorities are all here, to make it easy to change and compare
// Lower priority wins
object PlanBuilder extends Enumeration {
View
3 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/PartiallySolvedQuery.scala
@@ -165,4 +165,5 @@ case class PartiallySolvedQuery(returns: Seq[QueryToken[ReturnColumn]],
}
}
-case class ExecutionPlanInProgress(query: PartiallySolvedQuery, pipe: Pipe, containsTransaction: Boolean=false)
+case class ExecutionPlanInProgress(query: PartiallySolvedQuery, pipe: Pipe, containsTransaction: Boolean=false)
+case class PartialExecPlan(query: PartiallySolvedQuery, pipe: Seq[Pipe], containsTransaction: Boolean=false)
View
4 .../src/main/scala/org/neo4j/cypher/internal/executionplan/builders/AggregationBuilder.scala
@@ -20,7 +20,7 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.{Pipe, ExtractPipe, EagerAggregationPipe}
-import org.neo4j.cypher.internal.executionplan.{PartiallySolvedQuery, ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, PartiallySolvedQuery, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.internal.commands.expressions.{Identifier, CachedExpression, AggregationExpression, Expression}
import org.neo4j.cypher.internal.symbols.SymbolTable
@@ -45,7 +45,7 @@ Rewrite the remainder of the query to not use the aggregation expression, instea
value.
*/
-class AggregationBuilder extends PlanBuilder {
+class AggregationBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
// First, calculate the key expressions and save them down to the map
val keyExpressionsToExtract = getExpressions(plan)
View
4 ...src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ColumnFilterBuilder.scala
@@ -20,11 +20,11 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.ColumnFilterPipe
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.internal.symbols.SymbolTable
import org.neo4j.cypher.internal.commands.{AllIdentifiers, ReturnItem, ReturnColumn}
-class ColumnFilterBuilder extends PlanBuilder {
+class ColumnFilterBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
View
4 ...org/neo4j/cypher/internal/executionplan/builders/CreateNodesAndRelationshipsBuilder.scala
@@ -19,7 +19,7 @@
*/
package org.neo4j.cypher.internal.executionplan.builders
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.graphdb.GraphDatabaseService
import org.neo4j.cypher.internal.pipes.{Pipe, ExecuteUpdateCommandsPipe, TransactionStartPipe}
import org.neo4j.cypher.internal.mutation.UpdateAction
@@ -30,7 +30,7 @@ import collection.mutable
import expressions.{Identifier, Expression}
import org.neo4j.cypher.SyntaxException
-class CreateNodesAndRelationshipsBuilder(db: GraphDatabaseService) extends PlanBuilder {
+class CreateNodesAndRelationshipsBuilder(db: GraphDatabaseService) extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val mutatingQueryTokens = q.start.filter(applicableTo(plan.pipe))
View
4 .../src/main/scala/org/neo4j/cypher/internal/executionplan/builders/EmptyResultBuilder.scala
@@ -19,10 +19,10 @@
*/
package org.neo4j.cypher.internal.executionplan.builders
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.internal.pipes.EmptyResultPipe
-class EmptyResultBuilder extends PlanBuilder {
+class EmptyResultBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val resultPipe = new EmptyResultPipe(plan.pipe)
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ExtractBuilder.scala
@@ -20,10 +20,10 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.ExtractPipe
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.internal.commands.expressions.{Identifier, CachedExpression, Expression}
-class ExtractBuilder extends PlanBuilder {
+class ExtractBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val expressions: Map[String, Expression] =
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/FilterBuilder.scala
@@ -22,10 +22,10 @@ package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.commands.Predicate
import org.neo4j.cypher.internal.pipes.{FilterPipe, Pipe}
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.{CypherException, CypherTypeException, SyntaxException}
-class FilterBuilder extends PlanBuilder {
+class FilterBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
View
4 ...main/scala/org/neo4j/cypher/internal/executionplan/builders/GraphGlobalStartBuilder.scala
@@ -24,9 +24,9 @@ import org.neo4j.cypher.internal.pipes.{RelationshipStartPipe, NodeStartPipe, Pi
import org.neo4j.graphdb.GraphDatabaseService
import collection.JavaConverters._
import org.neo4j.tooling.GlobalGraphOperations
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PartiallySolvedQuery, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, PartiallySolvedQuery, MonoPlanBuilder}
-class GraphGlobalStartBuilder(graph: GraphDatabaseService) extends PlanBuilder {
+class GraphGlobalStartBuilder(graph: GraphDatabaseService) extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
View
4 ...r/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/IndexQueryBuilder.scala
@@ -25,9 +25,9 @@ import org.neo4j.graphdb.{Relationship, Node, GraphDatabaseService}
import collection.JavaConverters._
import java.lang.{Iterable => JIterable}
import org.neo4j.cypher.MissingIndexException
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
-class IndexQueryBuilder(graph: GraphDatabaseService) extends PlanBuilder {
+class IndexQueryBuilder(graph: GraphDatabaseService) extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
View
5 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/MatchBuilder.scala
@@ -21,14 +21,13 @@ package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.{MatchPipe, Pipe}
import org.neo4j.cypher.internal.commands._
-import org.neo4j.cypher.internal.executionplan.PlanBuilder
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, MonoPlanBuilder, ExecutionPlanInProgress}
import org.neo4j.cypher.internal.symbols.{SymbolTable, NodeType}
import org.neo4j.cypher.internal.pipes.matching.{PatternRelationship, PatternNode, PatternGraph}
import org.neo4j.cypher.SyntaxException
-import org.neo4j.cypher.internal.executionplan.ExecutionPlanInProgress
import org.neo4j.cypher.internal.commands.ShortestPath
-class MatchBuilder extends PlanBuilder with PatternGraphBuilder {
+class MatchBuilder extends MonoPlanBuilder with PatternGraphBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
View
4 ...er/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/NamedPathBuilder.scala
@@ -21,9 +21,9 @@ package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.commands.NamedPath
import org.neo4j.cypher.internal.pipes.{NamedPathPipe, Pipe}
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
-class NamedPathBuilder extends PlanBuilder {
+class NamedPathBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val p = plan.pipe
View
2 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/NodeByIdBuilder.scala
@@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.pipes.{NodeStartPipe, Pipe}
import GetGraphElements.getElements
import org.neo4j.cypher.internal.executionplan._
-class NodeByIdBuilder(graph: GraphDatabaseService) extends PlanBuilder {
+class NodeByIdBuilder(graph: GraphDatabaseService) extends MonoPlanBuilder {
def priority: Int = PlanBuilder.NodeById
def apply(plan: ExecutionPlanInProgress) = {
View
2 ...main/scala/org/neo4j/cypher/internal/executionplan/builders/RelationshipByIdBuilder.scala
@@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.commands.{RelationshipById, StartItem}
import org.neo4j.graphdb.{Relationship, GraphDatabaseService}
import org.neo4j.cypher.internal.pipes.RelationshipStartPipe
-class RelationshipByIdBuilder(graph: GraphDatabaseService) extends PlanBuilder {
+class RelationshipByIdBuilder(graph: GraphDatabaseService) extends MonoPlanBuilder {
def priority = PlanBuilder.RelationshipById
def apply(plan: ExecutionPlanInProgress) = {
View
5 ...src/main/scala/org/neo4j/cypher/internal/executionplan/builders/ShortestPathBuilder.scala
@@ -20,11 +20,11 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.commands.ShortestPath
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import collection.Seq
import org.neo4j.cypher.internal.pipes.{ShortestPathPipe, Pipe}
-class ShortestPathBuilder extends PlanBuilder {
+class ShortestPathBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val q = plan.query
val p = plan.pipe
@@ -46,7 +46,6 @@ class ShortestPathBuilder extends PlanBuilder {
def priority: Int = PlanBuilder.ShortestPath
-
override def missingDependencies(plan: ExecutionPlanInProgress) = {
val querySoFar = plan.query
val symbols = plan.pipe.symbols
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/SliceBuilder.scala
@@ -20,9 +20,9 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.{SlicePipe, Pipe}
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PartiallySolvedQuery, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, PartiallySolvedQuery, MonoPlanBuilder}
-class SliceBuilder extends PlanBuilder {
+class SliceBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val slice = plan.query.slice.map(_.token).head
val pipe = new SlicePipe(plan.pipe, slice.from, slice.limit)
View
4 cypher/src/main/scala/org/neo4j/cypher/internal/executionplan/builders/SortBuilder.scala
@@ -20,11 +20,11 @@
package org.neo4j.cypher.internal.executionplan.builders
import org.neo4j.cypher.internal.pipes.SortPipe
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.cypher.internal.commands.expressions.{Identifier, CachedExpression, Expression}
import org.neo4j.cypher.CypherTypeException
-class SortBuilder extends PlanBuilder {
+class SortBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val sortExpressionsToExtract: Seq[(String, Expression)] = plan.query.sort.flatMap(x => x.token.expression match {
case _: CachedExpression => None
View
4 ...src/main/scala/org/neo4j/cypher/internal/executionplan/builders/UpdateActionBuilder.scala
@@ -19,13 +19,13 @@
*/
package org.neo4j.cypher.internal.executionplan.builders
-import org.neo4j.cypher.internal.executionplan.{ExecutionPlanInProgress, PlanBuilder}
+import org.neo4j.cypher.internal.executionplan.{PlanBuilder, ExecutionPlanInProgress, MonoPlanBuilder}
import org.neo4j.graphdb.GraphDatabaseService
import org.neo4j.cypher.internal.pipes.{Pipe, ExecuteUpdateCommandsPipe, TransactionStartPipe}
import org.neo4j.cypher.internal.mutation.{CreateUniqueAction, UpdateAction}
import org.neo4j.cypher.internal.commands.StartItem
-class UpdateActionBuilder(db: GraphDatabaseService) extends PlanBuilder {
+class UpdateActionBuilder(db: GraphDatabaseService) extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = {
val p = if (plan.containsTransaction) {
View
13 cypher/src/main/scala/org/neo4j/cypher/internal/pipes/nestedHashJoin/HashJoinContext.scala
@@ -38,8 +38,13 @@ class HashJoinContext(private var inputA: Iterator[Map[String, Any]],
//If we have zipped two probe tables, this is where we'll find the buffer from that result
var zipBuffer: Iterator[Map[String, Any]] = None.toIterator
+ //Here is the probe result for when we have done a end-probe
var probe: Probe = null
+
+ //If a drop probe has been started, this is the next one to do after the first one is finished
var nextDropProbe: Option[Probe] = None
+
+ //This is the drop probe that we are currently working on
var dropProbe: Probe = null
@@ -96,10 +101,8 @@ class HashJoinContext(private var inputA: Iterator[Map[String, Any]],
val map = mapA
val (a, b) = inputB.duplicate
- val (a1,a2) = a.duplicate
- val asdfasdf = a2.toList
- val input = a1
+ val input = a
inputB = b
mapA = mutable.Map.empty
@@ -151,9 +154,9 @@ class HashJoinContext(private var inputA: Iterator[Map[String, Any]],
def switchDropProbe() {
dropProbe = nextDropProbe match {
- case Some(p) =>
+ case Some(nextProbe) =>
nextDropProbe = None
- p
+ nextProbe
case None =>
throw new ThisShouldNotHappenError("Andrés", "Can not get next drop probe because there is none")
}
View
2 cypher/src/test/scala/org/neo4j/cypher/internal/executionplan/ExecutionPlanImplTest.scala
@@ -48,7 +48,7 @@ class FakeEPI(q: Query, gds: GraphDatabaseService) extends ExecutionPlanImpl(q,
// This is a builder that accepts everything, but changes nothing
// It's a never ending loop waiting to happen
-class BadBuilder extends PlanBuilder {
+class BadBuilder extends MonoPlanBuilder {
def apply(plan: ExecutionPlanInProgress) = plan
def canWorkWith(plan: ExecutionPlanInProgress) = true
View
4 ...src/test/scala/org/neo4j/cypher/internal/executionplan/builders/NodeByIdBuilderTest.scala
@@ -22,12 +22,12 @@ package org.neo4j.cypher.internal.executionplan.builders
import org.junit.Assert._
import org.junit.{Ignore, Test}
import org.neo4j.cypher.internal.commands.{RelationshipById, NodeById}
-import org.neo4j.cypher.internal.executionplan.{PlanBuilder, PartiallySolvedQuery}
+import org.neo4j.cypher.internal.executionplan.{MonoPlanBuilder, PartiallySolvedQuery}
import org.neo4j.cypher.internal.commands.expressions.ParameterExpression
class NodeByIdBuilderTest extends BuilderTest {
- val builder: PlanBuilder = new NodeByIdBuilder(null)
+ val builder: MonoPlanBuilder = new NodeByIdBuilder(null)
@Test
def says_yes_to_node_by_id_queries() {

0 comments on commit a8a73c6

Please sign in to comment.