Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/3.0' into 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mats-SX committed Nov 23, 2016
2 parents a8637ed + 458ce3b commit 1e1bac5
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.compiler.v3_1.pipes

import org.neo4j.cypher.internal.compiler.v3_1._
import org.neo4j.cypher.internal.compiler.v3_1.commands.SortItem
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpression
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpressions

import scala.math.signum

Expand All @@ -37,8 +37,13 @@ case class LegacySortPipe(source: Pipe, sortDescription: List[SortItem])
sortWith((a, b) => compareBy(a, b, sortDescription)(state)).iterator
}

def planDescription =
source.planDescription.andThen(this.id, "Sort", variables, sortDescription.map(item => LegacyExpression(item.expression)):_*)
def planDescription = {
val sorting = sortDescription.zipWithIndex.map {
case (sortItem, idx) => s"o$idx" -> sortItem.expression
}

source.planDescription.andThen(this.id, "Sort", variables, LegacyExpressions(sorting.toMap))
}

override def dup(sources: List[Pipe]): Pipe = {
val (source :: Nil) = sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.neo4j.cypher.internal.compiler.v3_1.pipes
import org.neo4j.cypher.internal.compiler.v3_1.ExecutionContext
import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.Expression
import org.neo4j.cypher.internal.compiler.v3_1.executionplan.Effects._
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpression
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpressions

/*
Projection evaluates expressions and stores their values into new slots in the execution context.
Expand Down Expand Up @@ -55,7 +55,7 @@ case class ProjectionPipe(source: Pipe, expressions: Map[String, Expression])(va

def planDescriptionWithoutCardinality =
source.planDescription
.andThen(this.id, "Projection", variables, expressions.values.toIndexedSeq.map(LegacyExpression):_*)
.andThen(this.id, "Projection", variables, LegacyExpressions(expressions))

def dup(sources: List[Pipe]): Pipe = {
val (source :: Nil) = sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.ShortestPath
import org.neo4j.cypher.internal.compiler.v3_1.commands.predicates.Predicate
import org.neo4j.cypher.internal.compiler.v3_1.executionplan.{Effects, ReadsAllNodes, ReadsAllRelationships}
import org.neo4j.cypher.internal.compiler.v3_1.helpers.{CastSupport, ListSupport}
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpression
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpressions
import org.neo4j.cypher.internal.frontend.v3_1.symbols._
import org.neo4j.graphdb.Path

Expand Down Expand Up @@ -66,10 +66,8 @@ case class ShortestPathPipe(source: Pipe, shortestPathCommand: ShortestPath, pre
}

override def planDescriptionWithoutCardinality = {
val args = predicates.map { p =>
LegacyExpression(p)
}
source.planDescription.andThen(this.id, "ShortestPath", variables, args:_*)
val args = predicates.zipWithIndex.map { case (p, idx) => s"p$idx" -> p }
source.planDescription.andThen(this.id, "ShortestPath", variables, LegacyExpressions(args.toMap))
}

def dup(sources: List[Pipe]): Pipe = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.compiler.v3_1.ExecutionContext
import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.Expression
import org.neo4j.cypher.internal.compiler.v3_1.commands.predicates.Equivalent
import org.neo4j.cypher.internal.compiler.v3_1.executionplan.Effects
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments.LegacyExpressions
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.{InternalPlanDescription, PlanDescriptionImpl, TwoChildren}

import scala.collection.mutable
Expand Down Expand Up @@ -59,11 +59,11 @@ case class ValueHashJoinPipe(lhsExpression: Expression, rhsExpression: Expressio


override def planDescriptionWithoutCardinality: InternalPlanDescription = {
new PlanDescriptionImpl(
PlanDescriptionImpl(
id = id,
name = "ValueHashJoin",
children = TwoChildren(left.planDescription, right.planDescription),
arguments = Seq(Arguments.LegacyExpression(lhsExpression), Arguments.LegacyExpression(rhsExpression)),
arguments = Seq(LegacyExpressions(Map("lhs" -> lhsExpression, "rhs" -> rhsExpression))),
variables
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ object InternalPlanDescription {
case class ColumnsLeft(value: Seq[String]) extends Argument
case class Expression(value: ast.Expression) extends Argument
case class LegacyExpression(value: commands.expressions.Expression) extends Argument
case class LegacyExpressions(expressions: Map[String, commands.expressions.Expression]) extends Argument {
override def name = "LegacyExpression"
}
case class UpdateActionName(value: String) extends Argument
case class MergePattern(startPoint: String) extends Argument
case class LegacyIndex(value: String) extends Argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ object PlanDescriptionArgumentSerializer {
arg match {
case ColumnsLeft(columns) => s"keep columns ${columns.mkString(SEPARATOR)}"
case LegacyExpression(expr) => removeGeneratedNames(expr.toString)
case LegacyExpressions(expressions) => expressions.map({ case (k, v) => s"$k : $v" }).mkString("{", ", ", "}")
case Expression(expr) => removeGeneratedNames(expr.toString)
case UpdateActionName(action) => action
case MergePattern(startPoint) => s"MergePattern($startPoint)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.neo4j.cypher.internal.compiler.v3_1.planDescription

import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.ProjectedPath.{nilProjector, singleNodeProjector}
import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.{NestedPipeExpression, ProjectedPath}
import org.neo4j.cypher.internal.compiler.v3_1.commands.expressions.{Literal, NestedPipeExpression, ProjectedPath}
import org.neo4j.cypher.internal.compiler.v3_1.pipes.{ArgumentPipe, PipeMonitor}
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.InternalPlanDescription.Arguments._
import org.neo4j.cypher.internal.compiler.v3_1.planDescription.PlanDescriptionArgumentSerializer.serialize
Expand Down Expand Up @@ -57,4 +57,9 @@ class PlanDescriptionArgumentSerializerTests extends CypherFunSuite {

serialize(LegacyExpression(nested)) should equal("NestedExpression(Argument)")
}

test("projection should show multiple expressions") {
serialize(LegacyExpressions(Map("1" -> Literal(42), "2" -> Literal(56)))) should equal(
"{1 : Literal(42), 2 : Literal(56)}")
}
}

0 comments on commit 1e1bac5

Please sign in to comment.