From 3160a5a2088ffae04246cc06953f086d81bdf342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Louise=20S=C3=B6derstr=C3=B6m?= Date: Fri, 22 Dec 2017 14:59:18 +0100 Subject: [PATCH] Remove LogicalPlanId and use the new Id instead. --- .../v3_4/logical/plans/Argument.scala | 8 +- .../v3_4/logical/plans/LogicalPlan.scala | 60 +---- ...cedureCallOrSchemaCommandPlanBuilder.scala | 2 +- .../planner/logical/debug/DebugPrinter.scala | 3 +- .../plans/rewriter/LogicalPlanRewriter.scala | 1 - .../logical/steps/LogicalPlanProducer.scala | 2 +- .../LogicalPlanConstructionTestSupport.scala | 2 +- .../logical/PlanEventHorizonTest.scala | 2 +- .../plans/LogicalPlanAssignedIdTest.scala | 46 +--- .../v2_3/ExecutionResultWrapper.scala | 4 +- .../v3_1/ExecutionResultWrapper.scala | 5 +- .../v3_3/LogicalPlanConverter.scala | 19 +- .../internal/compatibility/v3_3/helpers.scala | 4 +- .../v3_4/runtime/CommunityPipeBuilder.scala | 6 +- .../procs/ProcedureCallExecutionPlan.scala | 7 +- .../procs/PureSideEffectExecutionPlan.scala | 4 +- .../v3_4/runtime/pipes/DropResultPipe.scala | 4 +- .../v3_4/runtime/profiler/Profiler.scala | 14 +- .../v3_3/LogicalPlanConverterTest.scala | 12 +- .../runtime/PipeExecutionPlanBuilderIT.scala | 1 - .../ExecutionWorkflowBuilderTest.scala | 8 +- .../v3_4/runtime/profiler/ProfilerTest.scala | 4 +- .../interpreted/pipes/AllNodesScanPipe.scala | 4 +- .../runtime/interpreted/pipes/ApplyPipe.scala | 4 +- .../pipes/AssertSameNodePipe.scala | 4 +- .../pipes/CartesianProductPipe.scala | 4 +- .../pipes/ConditionalApplyPipe.scala | 4 +- .../pipes/ConstraintOperationPipe.scala | 4 +- .../interpreted/pipes/CreateNodePipe.scala | 6 +- .../pipes/CreateRelationshipPipe.scala | 6 +- .../interpreted/pipes/DeletePipe.scala | 4 +- .../DirectedRelationshipByIdSeekPipe.scala | 4 +- .../interpreted/pipes/DistinctPipe.scala | 4 +- .../pipes/EagerAggregationPipe.scala | 4 +- .../runtime/interpreted/pipes/EagerPipe.scala | 4 +- .../interpreted/pipes/EmptyResultPipe.scala | 4 +- .../runtime/interpreted/pipes/ErrorPipe.scala | 4 +- .../interpreted/pipes/ExpandAllPipe.scala | 4 +- .../interpreted/pipes/ExpandIntoPipe.scala | 4 +- .../interpreted/pipes/FilterPipe.scala | 4 +- .../interpreted/pipes/ForeachPipe.scala | 4 +- .../FullPruningVarLengthExpandPipe.scala | 4 +- .../pipes/IndexOperationPipe.scala | 4 +- .../pipes/LetSelectOrSemiApplyPipe.scala | 4 +- .../interpreted/pipes/LetSemiApplyPipe.scala | 4 +- .../runtime/interpreted/pipes/LimitPipe.scala | 4 +- .../interpreted/pipes/LoadCSVPipe.scala | 4 +- .../interpreted/pipes/LockNodesPipe.scala | 4 +- .../interpreted/pipes/NodeByIdSeekPipe.scala | 4 +- .../pipes/NodeByLabelScanPipe.scala | 4 +- .../pipes/NodeCountFromCountStorePipe.scala | 4 +- .../interpreted/pipes/NodeHashJoinPipe.scala | 4 +- .../pipes/NodeIndexContainsScanPipe.scala | 6 +- .../interpreted/pipes/NodeIndexScanPipe.scala | 4 +- .../interpreted/pipes/NodeIndexSeekPipe.scala | 5 +- .../pipes/NodeOuterHashJoinPipe.scala | 4 +- .../pipes/OptionalExpandAllPipe.scala | 4 +- .../pipes/OptionalExpandIntoPipe.scala | 4 +- .../interpreted/pipes/OptionalPipe.scala | 4 +- .../runtime/interpreted/pipes/Pipe.scala | 6 +- .../interpreted/pipes/ProcedureCallPipe.scala | 4 +- .../pipes/ProduceResultsPipe.scala | 4 +- .../pipes/ProjectEndpointsPipe.scala | 4 +- .../interpreted/pipes/ProjectionPipe.scala | 4 +- .../pipes/PruningVarLengthExpandPipe.scala | 4 +- .../RelationshipCountFromCountStorePipe.scala | 4 +- .../interpreted/pipes/RemoveLabelsPipe.scala | 4 +- .../interpreted/pipes/RollUpApplyPipe.scala | 4 +- .../pipes/SelectOrSemiApplyPipe.scala | 4 +- .../interpreted/pipes/SemiApplyPipe.scala | 4 +- .../runtime/interpreted/pipes/SetPipe.scala | 4 +- .../interpreted/pipes/ShortestPathPipe.scala | 4 +- .../runtime/interpreted/pipes/SkipPipe.scala | 4 +- .../runtime/interpreted/pipes/SortPipe.scala | 4 +- .../runtime/interpreted/pipes/TopPipe.scala | 8 +- .../pipes/TriadicSelectionPipe.scala | 4 +- .../UndirectedRelationshipByIdSeekPipe.scala | 4 +- .../runtime/interpreted/pipes/UnionPipe.scala | 4 +- .../interpreted/pipes/UnwindPipe.scala | 4 +- .../interpreted/pipes/ValueHashJoinPipe.scala | 4 +- .../pipes/VarLengthExpandPipe.scala | 4 +- .../runtime/interpreted/pipes/FakePipe.scala | 4 +- .../interpreted/pipes/LimitPipeTest.scala | 4 +- .../interpreted/pipes/PipeTestSupport.scala | 4 +- .../InternalPlanDescription.scala | 11 +- .../LogicalPlan2PlanDescription.scala | 14 +- .../InternalPlanDescriptionTest.scala | 4 +- .../LogicalPlan2PlanDescriptionTest.scala | 11 +- ...anDescriptionArgumentSerializerTests.scala | 2 +- .../planDescription/RenderSummaryTest.scala | 12 +- .../planDescription/RenderTreeTableTest.scala | 218 +++++++++--------- .../internal/util/v3_4/Rewritable.scala | 23 +- .../internal/util/v3_4/attribution/Ids.scala | 2 +- .../v3_4/codegen/QueryExecutionTracer.java | 4 +- .../codegen/profiling/ProfilingTracer.java | 14 +- .../BuildVectorizedExecutionPlan.scala | 5 +- .../cypher/internal/DebugPrettyPrinter.scala | 21 +- .../compiled/codegen/CodeGenContext.scala | 7 +- .../compiled/codegen/CodeGenerator.scala | 7 +- .../compiled/codegen/spi/CodeStructure.scala | 4 +- .../codegen/GeneratedMethodStructure.scala | 4 +- .../codegen/GeneratedQueryStructure.scala | 8 +- .../internal/spi/v3_4/codegen/Methods.scala | 4 +- .../v3_4/BuildCompiledExecutionPlanTest.scala | 3 +- .../v3_4/codegen/CodeGeneratorTest.scala | 1 - .../ir/BuildProbeTableInstructionsTest.scala | 4 +- .../v3_4/codegen/ir/CodeGenSugar.scala | 9 +- .../codegen/ir/CompiledProfilingTest.scala | 11 +- .../profiling/ProfilingTracerTest.scala | 16 +- .../runtime/vectorized/PipelineBuilder.scala | 13 +- .../v3_4/runtime/SlotAllocation.scala | 23 +- .../v3_4/runtime/SlottedRewriter.scala | 28 +-- .../runtime/SlotAllocationArgumentsTest.scala | 55 ++--- .../v3_4/runtime/SlotAllocationTest.scala | 196 +++++++--------- .../v3_4/runtime/SlottedRewriterTest.scala | 137 +++++------ ...SlottedExecutionResultBuilderFactory.scala | 5 +- .../runtime/slotted/SlottedPipeBuilder.scala | 44 ++-- .../pipes/AllNodesScanSlottedPipe.scala | 4 +- .../slotted/pipes/ApplySlottedPipe.scala | 4 +- .../slotted/pipes/ArgumentSlottedPipe.scala | 4 +- .../pipes/BaseRelationshipSlottedPipe.scala | 6 +- .../pipes/CartesianProductSlottedPipe.scala | 4 +- .../pipes/ConditionalApplySlottedPipe.scala | 4 +- .../slotted/pipes/CreateNodeSlottedPipe.scala | 6 +- .../slotted/pipes/DistinctSlottedPipe.scala | 4 +- .../pipes/EagerAggregationSlottedPipe.scala | 4 +- ...ggregationWithoutGroupingSlottedPipe.scala | 4 +- .../slotted/pipes/EagerSlottedPipe.scala | 4 +- .../slotted/pipes/ExpandAllSlottedPipe.scala | 4 +- .../slotted/pipes/ExpandIntoSlottedPipe.scala | 4 +- .../slotted/pipes/ForeachSlottedPipe.scala | 4 +- .../pipes/NodeHashJoinSlottedPipe.scala | 4 +- .../pipes/NodeIndexScanSlottedPipe.scala | 4 +- .../pipes/NodeIndexSeekSlottedPipe.scala | 5 +- .../pipes/NodesByLabelScanSlottedPipe.scala | 4 +- .../pipes/OptionalExpandAllSlottedPipe.scala | 4 +- .../pipes/OptionalExpandIntoSlottedPipe.scala | 4 +- .../slotted/pipes/OptionalSlottedPipe.scala | 4 +- .../pipes/ProduceResultSlottedPipe.scala | 4 +- .../slotted/pipes/ProjectionSlottedPipe.scala | 4 +- .../pipes/RollUpApplySlottedPipe.scala | 6 +- .../slotted/pipes/SortSlottedPipe.scala | 6 +- .../slotted/pipes/TopSlottedPipe.scala | 8 +- .../slotted/pipes/UnionSlottedPipe.scala | 4 +- .../slotted/pipes/UnwindSlottedPipe.scala | 4 +- .../pipes/ValueHashJoinSlottedPipe.scala | 4 +- .../pipes/VarLengthExpandSlottedPipe.scala | 4 +- .../slotted/SlottedPipeBuilderTest.scala | 1 - .../slotted/pipes/FakeSlottedPipe.scala | 6 +- 149 files changed, 696 insertions(+), 843 deletions(-) diff --git a/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/Argument.scala b/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/Argument.scala index 4fa88d7a9ed29..320d0fb27bc31 100644 --- a/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/Argument.scala +++ b/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/Argument.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.v3_4.logical.plans import org.neo4j.cypher.internal.ir.v3_4.{CardinalityEstimation, IdName, PlannerQuery} -import org.neo4j.cypher.internal.util.v3_4.attribution.IdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{IdGen, SameId} import org.neo4j.cypher.internal.util.v3_4.symbols._ /** @@ -32,20 +32,20 @@ case class Argument(argumentIds: Set[IdName] = Set.empty)(val solved: PlannerQue def availableSymbols: Set[IdName] = argumentIds override def updateSolved(newSolved: PlannerQuery with CardinalityEstimation): Argument = { - val resultingPlan = copy(argumentIds)(newSolved) + val resultingPlan = copy(argumentIds)(newSolved)(SameId(this.id)) resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) resultingPlan } override def copyPlan(): LogicalPlan = { - val resultingPlan = this.copy(argumentIds)(solved).asInstanceOf[this.type] + val resultingPlan = this.copy(argumentIds)(solved)(SameId(this.id)).asInstanceOf[this.type] resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) resultingPlan } override def dup(children: Seq[AnyRef]) = children.size match { case 1 => - val resultingPlan = copy(children.head.asInstanceOf[Set[IdName]])(solved).asInstanceOf[this.type] + val resultingPlan = copy(children.head.asInstanceOf[Set[IdName]])(solved)(SameId(this.id)).asInstanceOf[this.type] resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) resultingPlan } diff --git a/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/LogicalPlan.scala b/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/LogicalPlan.scala index 2651192428950..20e938ed0c90e 100644 --- a/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/LogicalPlan.scala +++ b/community/cypher/cypher-logical-plans-3.4/src/main/scala/org/neo4j/cypher/internal/v3_4/logical/plans/LogicalPlan.scala @@ -22,10 +22,10 @@ package org.neo4j.cypher.internal.v3_4.logical.plans import java.lang.reflect.Method import org.neo4j.cypher.internal.util.v3_4.Foldable._ -import org.neo4j.cypher.internal.util.v3_4.{Foldable, InternalException, Unchangeable} +import org.neo4j.cypher.internal.util.v3_4.{Foldable, InternalException, Rewritable, Unchangeable} import org.neo4j.cypher.internal.util.v3_4.Rewritable._ import org.neo4j.cypher.internal.ir.v3_4.{CardinalityEstimation, IdName, PlannerQuery, Strictness} -import org.neo4j.cypher.internal.util.v3_4.attribution.IdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{IdGen, SameId} import org.neo4j.cypher.internal.v3_4.expressions.Expression object LogicalPlan { @@ -42,7 +42,7 @@ abstract class LogicalPlan(idGen: IdGen) extends Product with Foldable with Strictness - with RewritableWithMemory { + with Rewritable { self => @@ -56,36 +56,6 @@ abstract class LogicalPlan(idGen: IdGen) val readTransactionLayer: Unchangeable[Int] = new Unchangeable[Int] val id = idGen.id() - // -------- - /* - A id for the logical plan operator, unique inside of the given query tree. These identifiers will be - copied to a rewritten version of the logical plan, as long as there is a one-to-one mapping between - rewritten plans. In other words - once ids have been assigned, plan rewriting should not collapse multiple - operators into one, or split a single one into multiple new ones. - */ - def assignedId: LogicalPlanId = _id.getOrElse(throw new InternalException("Plan has not had an id assigned yet")) - - def assignIds(): Unit = { - if (_id.nonEmpty) - throw new InternalException("Id has already been assigned") - - var count = 0 - val plans = this.findByAllClass[LogicalPlan] - plans.foreach { lp => - lp._id = Some(new LogicalPlanId(count)) - count = count + 1 - } - assignedId - } - - private var _id: Option[LogicalPlanId] = None - - override def rememberMe(old: AnyRef): Unit = _id = old.asInstanceOf[LogicalPlan]._id - - // This should only be used for converting old versions of LogicalPlans - def setIdTo(id: LogicalPlanId) : Unit = _id = Some(id) - // ^ TODO DIE - // --------- def leaves: Seq[LogicalPlan] = this.treeFold(Seq.empty[LogicalPlan]) { case plan: LogicalPlan @@ -93,7 +63,7 @@ abstract class LogicalPlan(idGen: IdGen) } def updateSolved(newSolved: PlannerQuery with CardinalityEstimation): LogicalPlan = { - val arguments = this.children.toList :+ newSolved :+ idGen + val arguments = this.children.toList :+ newSolved :+ SameId(this.id) try { val resultingPlan = copyConstructor.invoke(this, arguments: _*).asInstanceOf[this.type] resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) @@ -106,7 +76,7 @@ abstract class LogicalPlan(idGen: IdGen) def copyPlan(): LogicalPlan = { try { - val arguments = this.children.toList :+ solved :+ idGen + val arguments = this.children.toList :+ solved :+ SameId(this.id) val resultingPlan = copyConstructor.invoke(this, arguments: _*).asInstanceOf[this.type] resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) resultingPlan @@ -131,11 +101,11 @@ abstract class LogicalPlan(idGen: IdGen) val resultingPlan = if (params.length == args.length + 1 && params.last.isAssignableFrom(classOf[IdGen])) - constructor.invoke(this, args :+ this.idGen: _*).asInstanceOf[this.type] + constructor.invoke(this, args :+ SameId(this.id): _*).asInstanceOf[this.type] else if ((params.length == args.length + 2) && params(params.length - 2).isAssignableFrom(classOf[PlannerQuery]) && params(params.length - 1).isAssignableFrom(classOf[IdGen])) - constructor.invoke(this, args :+ this.solved :+ this.idGen: _*).asInstanceOf[this.type] + constructor.invoke(this, args :+ this.solved :+ SameId(this.id): _*).asInstanceOf[this.type] else constructor.invoke(this, args: _*).asInstanceOf[this.type] resultingPlan.readTransactionLayer.copyFrom(readTransactionLayer) @@ -230,19 +200,3 @@ final case class SchemaIndexSeekUsage(identifier: String, labelId : Int, label: final case class SchemaIndexScanUsage(identifier: String, labelId : Int, label: String, propertyKey: String) extends IndexUsage final case class ExplicitNodeIndexUsage(identifier: String, index: String) extends IndexUsage final case class ExplicitRelationshipIndexUsage(identifier: String, index: String) extends IndexUsage - -object LogicalPlanId { - // This is probably a safe way of assigning ids, but should only be used in tests - private var counter = 0 - def DEFAULT: LogicalPlanId = { - val id = new LogicalPlanId(counter) - counter += 1 - id - } -} - -class LogicalPlanId(val underlying: Int) extends AnyVal { - def ++ : LogicalPlanId = new LogicalPlanId(underlying + 1) - - override def toString: String = s"id:$underlying" -} diff --git a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/ProcedureCallOrSchemaCommandPlanBuilder.scala b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/ProcedureCallOrSchemaCommandPlanBuilder.scala index 395babeacb897..4f537e7f03fce 100644 --- a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/ProcedureCallOrSchemaCommandPlanBuilder.scala +++ b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/ProcedureCallOrSchemaCommandPlanBuilder.scala @@ -42,7 +42,7 @@ case object ProcedureCallOrSchemaCommandPlanBuilder extends Phase[CompilerContex override def postConditions: Set[Condition] = Set.empty override def process(from: BaseState, context: CompilerContext): LogicalPlanState = { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() val maybeLogicalPlan: Option[LogicalPlan] = from.statement() match { // Global call: CALL foo.bar.baz("arg1", 2) case Query(None, SingleQuery(Seq(resolved@ResolvedCall(signature, args, _, _, _)))) => diff --git a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/debug/DebugPrinter.scala b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/debug/DebugPrinter.scala index 490c4189875ec..bfc672d1eb619 100644 --- a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/debug/DebugPrinter.scala +++ b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/debug/DebugPrinter.scala @@ -54,14 +54,13 @@ object DebugPrinter extends Phase[CompilerContext, LogicalPlanState, LogicalPlan } private def stringToLogicalPlan(string: String): (LogicalPlan, Statement) = { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() val pos = InputPosition(0, 0, 0) val solved = CardinalityEstimation.lift(RegularPlannerQuery(QueryGraph.empty), 0.0) val stringValues = string.split("\n").map(s => StringLiteral(s)(pos)) val expression = ListLiteral(stringValues.toSeq)(pos) val unwind = UnwindCollection(Argument(Set.empty)(solved), IdName("col"), expression)(solved) val logicalPlan = ProduceResult(unwind, Seq("col")) - logicalPlan.assignIds() val variable = Variable("col")(pos) val returnItem = AliasedReturnItem(variable, variable)(pos) diff --git a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/rewriter/LogicalPlanRewriter.scala b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/rewriter/LogicalPlanRewriter.scala index a746da1972246..28cb315147c07 100644 --- a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/rewriter/LogicalPlanRewriter.scala +++ b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/rewriter/LogicalPlanRewriter.scala @@ -58,7 +58,6 @@ trait LogicalPlanRewriter extends Phase[CompilerContext, LogicalPlanState, Logic override def process(from: LogicalPlanState, context: CompilerContext): LogicalPlanState = { val rewritten = from.logicalPlan.endoRewrite(instance(context)) - rewritten.assignIds() // This should be the only place where ids are assigned. from.copy(maybeLogicalPlan = Some(rewritten)) } } diff --git a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/steps/LogicalPlanProducer.scala b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/steps/LogicalPlanProducer.scala index f306ce01ecb86..e518c5c280274 100644 --- a/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/steps/LogicalPlanProducer.scala +++ b/community/cypher/cypher-planner-3.4/src/main/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/steps/LogicalPlanProducer.scala @@ -38,7 +38,7 @@ import org.neo4j.cypher.internal.v3_4.logical.plans.{DeleteExpression => DeleteE */ case class LogicalPlanProducer(cardinalityModel: CardinalityModel, readTransactionLayer: Int) extends ListSupport { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() def withNextTxLayer: LogicalPlanProducer = copy(readTransactionLayer = this.readTransactionLayer + 1) diff --git a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/LogicalPlanConstructionTestSupport.scala b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/LogicalPlanConstructionTestSupport.scala index 5820f7666a7f4..65c8e38b05a17 100644 --- a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/LogicalPlanConstructionTestSupport.scala +++ b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/LogicalPlanConstructionTestSupport.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.util.v3_4.attribution.SequentialIdGen import scala.language.implicitConversions trait LogicalPlanConstructionTestSupport extends CypherTestSupport { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() implicit protected def idName(name: String): IdName = IdName(name) implicit protected def idSymbol(name: Symbol): IdName = IdName(name.name) } diff --git a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/PlanEventHorizonTest.scala b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/PlanEventHorizonTest.scala index f3e12da5125f8..6cf32444751f6 100644 --- a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/PlanEventHorizonTest.scala +++ b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/PlanEventHorizonTest.scala @@ -33,7 +33,7 @@ import org.neo4j.cypher.internal.v3_4.logical.plans._ class PlanEventHorizonTest extends CypherFunSuite { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() val pos = DummyPosition(1) val context = LogicalPlanningContext(mock[PlanContext], LogicalPlanProducer(mock[Metrics.CardinalityModel], LogicalPlan.LOWEST_TX_LAYER), diff --git a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/LogicalPlanAssignedIdTest.scala b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/LogicalPlanAssignedIdTest.scala index 506ddc2ac3513..58ed490684375 100644 --- a/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/LogicalPlanAssignedIdTest.scala +++ b/community/cypher/cypher-planner-3.4/src/test/scala/org/neo4j/cypher/internal/compiler/v3_4/planner/logical/plans/LogicalPlanAssignedIdTest.scala @@ -26,26 +26,24 @@ import org.neo4j.cypher.internal.util.v3_4.{CypherException, Rewriter, topDown} import org.neo4j.cypher.internal.v3_4.logical.plans.{NestedPlanExpression, _} class LogicalPlanAssignedIdTest extends CypherFunSuite with LogicalPlanningTestSupport2 { - test("assignedId survives rewriting") { + test("id survives rewriting") { val sr1 = Argument()(solved) val pr = Projection(sr1, Map.empty)(solved) - pr.assignIds() val prPrim = pr.endoRewrite(topDown(Rewriter.lift { case sr: Argument => Argument()(solved) })) - pr.assignedId should equal(prPrim.assignedId) - pr.lhs.get.assignedId should equal(prPrim.lhs.get.assignedId) + pr.id should equal(prPrim.id) + pr.lhs.get.id should equal(prPrim.lhs.get.id) } - test("assignedIds are different between plans") { + test("ids are different between plans") { val sr1 = Argument()(solved) val sr2 = Argument()(solved) val apply = Apply(sr1, sr2)(solved) - apply.assignIds() - sr1.assignedId shouldNot equal(sr2.assignedId) + sr1.id shouldNot equal(sr2.id) } test("tree structure is assigned ids in a predictable way") { @@ -62,32 +60,12 @@ class LogicalPlanAssignedIdTest extends CypherFunSuite with LogicalPlanningTestS val applyB = Apply(sr1B, sr2B)(solved) val applyAll = Apply(applyA, applyB)(solved) // I heard you guys like Apply, so we applied an Apply in your Apply - applyAll.assignIds() - - applyAll.assignedId.underlying should equal(0) - applyA.assignedId.underlying should equal(1) - sr1A.assignedId.underlying should equal(2) - sr2A.assignedId.underlying should equal(3) - applyB.assignedId.underlying should equal(4) - sr1B.assignedId.underlying should equal(5) - sr2B.assignedId.underlying should equal(6) - } - - test("cant assign ids twice") { - val sr1 = Argument()(solved) - val pr = Projection(sr1, Map.empty)(solved) - pr.assignIds() - intercept[CypherException](pr.assignIds()) + applyAll.id.x should equal(0) + applyA.id.x should equal(1) + sr1A.id.x should equal(2) + sr2A.id.x should equal(3) + applyB.id.x should equal(4) + sr1B.id.x should equal(5) + sr2B.id.x should equal(6) } - - test("can assign inside expressions as well") { - val argument = Argument()(solved) - val inner = AllNodesScan(IdName("x"), Set.empty)(solved) - val filter = Selection(Seq(NestedPlanExpression(inner, literalInt(42))(pos)), argument)(solved) - - filter.assignIds() - - val x = inner.assignedId // should not fail - } - } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExecutionResultWrapper.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExecutionResultWrapper.scala index e2dbe4562884b..3104c3047972f 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExecutionResultWrapper.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v2_3/ExecutionResultWrapper.scala @@ -34,8 +34,8 @@ import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.runtime.planDescription.{Children, NoChildren, PlanDescriptionImpl, SingleChild, TwoChildren, Argument => Argument3_4, InternalPlanDescription => InternalPlanDescription3_4} import org.neo4j.cypher.internal.runtime.{QueryStatistics, SCHEMA_WRITE, ExecutionMode => ExecutionModeV3_4, _} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection.{BOTH, INCOMING, OUTGOING} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.result.QueryResult import org.neo4j.cypher.result.QueryResult.Record import org.neo4j.graphdb.Result.ResultVisitor @@ -194,7 +194,7 @@ class ExecutionResultWrapper(val inner: InternalExecutionResult, val planner: Pl case planDescriptionv2_3.InternalPlanDescription.Arguments.SourceCode(className, sourceCode) => Arguments.SourceCode(className, sourceCode) } - PlanDescriptionImpl(LogicalPlanId.DEFAULT, name, children, arguments, planDescription.identifiers) + PlanDescriptionImpl(Id.INVALID_ID, name, children, arguments, planDescription.identifiers) } override def hasNext: Boolean = inner.hasNext diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExecutionResultWrapper.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExecutionResultWrapper.scala index 4f3ddec101aff..4968c8a8f6ffe 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExecutionResultWrapper.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_1/ExecutionResultWrapper.scala @@ -36,9 +36,10 @@ import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.runtime.planDescription.{Argument, Children, NoChildren, PlanDescriptionImpl, SingleChild, TwoChildren, InternalPlanDescription => InternalPlanDescription3_4} import org.neo4j.cypher.internal.runtime.{ExplainMode, NormalMode, ProfileMode, QueryStatistics} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{symbols => symbolsv3_4} import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection.{BOTH, INCOMING, OUTGOING} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId, QualifiedName} +import org.neo4j.cypher.internal.v3_4.logical.plans.QualifiedName import org.neo4j.cypher.result.QueryResult import org.neo4j.cypher.result.QueryResult.Record import org.neo4j.graphdb @@ -145,7 +146,7 @@ class ExecutionResultWrapper(val inner: InternalExecutionResult, val planner: Pl val procName = QualifiedName(procedureName.namespace, procedureName.name) Arguments.Signature(procName, Seq.empty, results.map(pair => (pair._1, lift(pair._2)))) } - PlanDescriptionImpl(LogicalPlanId.DEFAULT, name, children, arguments, planDescription.variables) + PlanDescriptionImpl(Id.INVALID_ID, name, children, arguments, planDescription.variables) } private def lift(cypherType: symbols3_1.CypherType): symbolsv3_4.CypherType = cypherType match { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverter.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverter.scala index 413de525eb420..ef8cb93009d7c 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverter.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverter.scala @@ -38,7 +38,7 @@ import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan => LogicalPlanV import org.neo4j.cypher.internal.v3_4.logical.{plans => plansV3_4} import org.neo4j.cypher.internal.v3_4.{expressions => expressionsV3_4} import org.neo4j.cypher.internal.compiler.{v3_3 => compilerV3_3} -import org.neo4j.cypher.internal.util.v3_4.attribution.{IdGen, SequentialIdGen} +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, IdGen, SameId, SequentialIdGen} import scala.collection.mutable import scala.collection.mutable.{HashMap => MutableHashMap} @@ -55,27 +55,25 @@ object LogicalPlanConverter { override def apply(v1: (AnyRef, Seq[AnyRef])): AnyRef = rewriter.apply(v1) private val rewriter: RewriterWithArgs = bottomUpWithArgs { before => - implicit val idGen = SequentialIdGen - val rewritten = RewriterWithArgs.lift { case (plan: plansV3_3.Argument, children: Seq[AnyRef]) => - plansV3_4.Argument(children.head.asInstanceOf[Set[IdNameV3_4]])(new PlannerQueryWrapper(plan.solved)) + plansV3_4.Argument(children.head.asInstanceOf[Set[IdNameV3_4]])(new PlannerQueryWrapper(plan.solved))(SameId(Id(plan.assignedId.underlying))) case (plan: plansV3_3.SingleRow, _) => - plansV3_4.Argument()(new PlannerQueryWrapper(plan.solved)) - case (_: plansV3_3.ProduceResult, children: Seq[AnyRef]) => + plansV3_4.Argument()(new PlannerQueryWrapper(plan.solved))(SameId(Id(plan.assignedId.underlying))) + case (plan: plansV3_3.ProduceResult, children: Seq[AnyRef]) => plansV3_4.ProduceResult(source = children(1).asInstanceOf[LogicalPlanV3_4], - columns = children(0).asInstanceOf[Seq[String]]) + columns = children(0).asInstanceOf[Seq[String]])(SameId(Id(plan.assignedId.underlying))) case (plan: plansV3_3.TriadicSelection, children: Seq[AnyRef]) => plansV3_4.TriadicSelection(left = children(1).asInstanceOf[LogicalPlanV3_4], right = children(5).asInstanceOf[LogicalPlanV3_4], positivePredicate = children(0).asInstanceOf[Boolean], sourceId = children(2).asInstanceOf[IdNameV3_4], seenId = children(3).asInstanceOf[IdNameV3_4], - targetId = children(4).asInstanceOf[IdNameV3_4])(new PlannerQueryWrapper(plan.solved)) + targetId = children(4).asInstanceOf[IdNameV3_4])(new PlannerQueryWrapper(plan.solved))(SameId(Id(plan.assignedId.underlying))) case (plan: plansV3_3.ProceduralLogicalPlan, children: Seq[AnyRef]) => - convertVersion("v3_3", "v3_4", plan, children, idGen, classOf[IdGen]) + convertVersion("v3_3", "v3_4", plan, children, SameId(Id(plan.assignedId.underlying)), classOf[IdGen]) case (plan: plansV3_3.LogicalPlan, children: Seq[AnyRef]) => - convertVersion("v3_3", "v3_4", plan, children, new PlannerQueryWrapper(plan.solved), classOf[PlannerQuery], idGen, classOf[IdGen]) + convertVersion("v3_3", "v3_4", plan, children, new PlannerQueryWrapper(plan.solved), classOf[PlannerQuery], SameId(Id(plan.assignedId.underlying)), classOf[IdGen]) case (inp: astV3_3.InvalidNodePattern, children: Seq[AnyRef]) => new expressionsV3_4.InvalidNodePattern(children.head.asInstanceOf[Option[expressionsV3_4.Variable]].get)(helpers.as3_4(inp.position)) @@ -164,7 +162,6 @@ object LogicalPlanConverter { case plan: LogicalPlanV3_3 => try { val plan3_4 = rewritten.asInstanceOf[LogicalPlanV3_4] - plan3_4.setIdTo(helpers.as3_4(plan.assignedId)) // 3.3 does not know about transaction layers, it plans Eagers instead. plan3_4.readTransactionLayer.value = 0 } catch { diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/helpers.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/helpers.scala index f0678e15222fe..e2365b9441c29 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/helpers.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_3/helpers.scala @@ -38,9 +38,9 @@ import org.neo4j.cypher.internal.frontend.v3_4.{phases => phasesV3_4} import org.neo4j.cypher.internal.ir.v3_3.{Cardinality => CardinalityV3_3} import org.neo4j.cypher.internal.ir.{v3_3 => irV3_3, v3_4 => irV3_4} import org.neo4j.cypher.internal.planner.v3_4.spi.{DPPlannerName, IDPPlannerName, PlannerNameWithVersion, ProcedurePlannerName} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{Cardinality, InputPosition} import org.neo4j.cypher.internal.v3_3.logical.plans.{LogicalPlanId => LogicalPlanIdV3_3} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId => LogicalPlanIdV3_4} import org.neo4j.kernel.impl.query.{QueryExecutionMonitor, TransactionalContext} object helpers { @@ -97,7 +97,7 @@ object helpers { def as3_4(pos: InputPositionV3_3): InputPosition = if(pos == null) null else InputPosition(pos.offset, pos.line, pos.column) - def as3_4(planId: LogicalPlanIdV3_3) : LogicalPlanIdV3_4 = new LogicalPlanIdV3_4(planId.underlying) + def as3_4(planId: LogicalPlanIdV3_3) : Id = Id(planId.underlying) def as3_4(plannerName: PlannerNameV3_3) : PlannerName = plannerName match { case IDPPlannerNameV3_3 => IDPPlannerName diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/CommunityPipeBuilder.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/CommunityPipeBuilder.scala index e3d85b9549b9d..1df0ca6c66417 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/CommunityPipeBuilder.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/CommunityPipeBuilder.scala @@ -56,7 +56,7 @@ case class CommunityPipeBuilder(monitors: Monitors, recurse: LogicalPlan => Pipe def build(plan: LogicalPlan): Pipe = { - val id = plan.assignedId + val id = plan.id plan match { case Argument(_) => ArgumentPipe()(id) @@ -103,7 +103,7 @@ case class CommunityPipeBuilder(monitors: Monitors, recurse: LogicalPlan => Pipe } def build(plan: LogicalPlan, source: Pipe): Pipe = { - val id = plan.assignedId + val id = plan.id plan match { case Projection(_, expressions) => ProjectionPipe(source, Eagerly.immutableMapValues(expressions, buildExpression))(id = id) @@ -343,7 +343,7 @@ case class CommunityPipeBuilder(monitors: Monitors, recurse: LogicalPlan => Pipe } def build(plan: LogicalPlan, lhs: Pipe, rhs: Pipe): Pipe = { - val id = plan.assignedId + val id = plan.id plan match { case CartesianProduct(_, _) => CartesianProductPipe(lhs, rhs)(id = id) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/ProcedureCallExecutionPlan.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/ProcedureCallExecutionPlan.scala index f1ee7db3f20e7..609b3bb8bbd7c 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/ProcedureCallExecutionPlan.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/ProcedureCallExecutionPlan.scala @@ -32,9 +32,10 @@ import org.neo4j.cypher.internal.runtime.interpreted.pipes.{ExternalCSVResource, import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.runtime.planDescription.{Argument, NoChildren, PlanDescriptionImpl} import org.neo4j.cypher.internal.util.v3_4.TaskCloser +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.symbols.CypherType import org.neo4j.cypher.internal.v3_4.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId, ProcedureSignature} +import org.neo4j.cypher.internal.v3_4.logical.plans.ProcedureSignature import org.neo4j.graphdb.Notification import org.neo4j.values.virtual.MapValue @@ -114,13 +115,13 @@ case class ProcedureCallExecutionPlan(signature: ProcedureSignature, } private def createNormalPlan = - PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ProcedureCall", NoChildren, + PlanDescriptionImpl(Id.INVALID_ID, "ProcedureCall", NoChildren, arguments, resultSymbols.map(_._1).toSet ) private def createProfilePlanGenerator(rowCounter: Counter) = () => - PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ProcedureCall", NoChildren, + PlanDescriptionImpl(Id.INVALID_ID, "ProcedureCall", NoChildren, Seq(createSignatureArgument, DbHits(1), Rows(rowCounter.counted)) ++ arguments, resultSymbols.map(_._1).toSet ) diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/PureSideEffectExecutionPlan.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/PureSideEffectExecutionPlan.scala index 2836ec4d48461..27dda10dd220d 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/PureSideEffectExecutionPlan.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/procs/PureSideEffectExecutionPlan.scala @@ -29,7 +29,7 @@ import org.neo4j.cypher.internal.runtime._ import org.neo4j.cypher.internal.runtime.interpreted.UpdateCountingQueryContext import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.runtime.planDescription.{NoChildren, PlanDescriptionImpl} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.virtual.MapValue /** @@ -58,7 +58,7 @@ case class PureSideEffectExecutionPlan(name: String, queryType: InternalQueryTyp } } - private def description = PlanDescriptionImpl(LogicalPlanId.DEFAULT, name, NoChildren, + private def description = PlanDescriptionImpl(Id.INVALID_ID, name, NoChildren, Seq(Planner(plannerUsed.toTextOutput), PlannerImpl(plannerUsed.name), PlannerVersion(plannerUsed.version), diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/pipes/DropResultPipe.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/pipes/DropResultPipe.scala index 4e2790a06e8ba..f8c5efb2d8d35 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/pipes/DropResultPipe.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/pipes/DropResultPipe.scala @@ -21,9 +21,9 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class DropResultPipe(source: Pipe)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { +case class DropResultPipe(source: Pipe)(val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = Iterator.empty } diff --git a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/Profiler.scala b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/Profiler.scala index abe6484e2c939..364497ba92875 100644 --- a/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/Profiler.scala +++ b/community/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/Profiler.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.runtime.interpreted.{DelegatingOperations, Dele import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments import org.neo4j.cypher.internal.runtime.{Operations, QueryContext} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.helpers.MathUtil import org.neo4j.kernel.impl.api.RelationshipVisitor import org.neo4j.kernel.impl.api.store.RelationshipIterator @@ -38,9 +38,9 @@ import scala.collection.mutable class Profiler(databaseInfo: DatabaseInfo = DatabaseInfo.COMMUNITY) extends PipeDecorator { outerProfiler => - val pageCacheStats: mutable.Map[LogicalPlanId, (Long, Long)] = mutable.Map.empty - val dbHitsStats: mutable.Map[LogicalPlanId, ProfilingPipeQueryContext] = mutable.Map.empty - val rowStats: mutable.Map[LogicalPlanId, ProfilingIterator] = mutable.Map.empty + val pageCacheStats: mutable.Map[Id, (Long, Long)] = mutable.Map.empty + val dbHitsStats: mutable.Map[Id, ProfilingPipeQueryContext] = mutable.Map.empty + val rowStats: mutable.Map[Id, ProfilingIterator] = mutable.Map.empty private var parentPipe: Option[Pipe] = None @@ -67,7 +67,7 @@ class Profiler(databaseInfo: DatabaseInfo = DatabaseInfo.COMMUNITY) extends Pipe state.withQueryContext(decoratedContext) } - private def updatePageCacheStatistics(pipeId: LogicalPlanId) = { + private def updatePageCacheStatistics(pipeId: Id) = { val context = dbHitsStats(pipeId) val statisticProvider = context.transactionalContext.kernelStatisticProvider val currentStat = pageCacheStats(pipeId) @@ -177,8 +177,8 @@ final class ProfilingPipeQueryContext(inner: QueryContext, val p: Pipe) override def relationshipOps: Operations[EdgeValue] = new ProfilerOperations(inner.relationshipOps) } -class ProfilingIterator(inner: Iterator[ExecutionContext], startValue: Long, pipeId: LogicalPlanId, - updatePageCacheStatistics: LogicalPlanId => Unit) extends Iterator[ExecutionContext] +class ProfilingIterator(inner: Iterator[ExecutionContext], startValue: Long, pipeId: Id, + updatePageCacheStatistics: Id => Unit) extends Iterator[ExecutionContext] with Counter { _count = startValue diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverterTest.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverterTest.scala index 2e211ea6df932..3782622bf9432 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverterTest.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_3/LogicalPlanConverterTest.scala @@ -44,7 +44,7 @@ import scala.util.{Failure, Success, Try} class LogicalPlanConverterTest extends FunSuite with Matchers { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() val pos3_3 = InputPositionV3_3(0,0,0) val pos3_4 = InputPosition(0,0,0) @@ -254,7 +254,7 @@ class LogicalPlanConverterTest extends FunSuite with Matchers { val rewrittenPlan = LogicalPlanConverter.convertLogicalPlan[plansV3_4.AllNodesScan](a3_3)._1 rewrittenPlan should be(a3_4) - rewrittenPlan.assignedId should be(helpers.as3_4(id3_3)) + rewrittenPlan.id should be(helpers.as3_4(id3_3)) } test("should convert Aggregation and keep ids") { @@ -273,8 +273,8 @@ class LogicalPlanConverterTest extends FunSuite with Matchers { val rewrittenPlan = LogicalPlanConverter.convertLogicalPlan[plansV3_4.Aggregation](ag3_3)._1 rewrittenPlan should be(ag3_4) - rewrittenPlan.assignedId should be(helpers.as3_4(ag_id)) - rewrittenPlan.lhs.get.assignedId should be(helpers.as3_4(ans_id)) + rewrittenPlan.id should be(helpers.as3_4(ag_id)) + rewrittenPlan.lhs.get.id should be(helpers.as3_4(ans_id)) } test("should convert ProduceResult and keep ids") { @@ -290,8 +290,8 @@ class LogicalPlanConverterTest extends FunSuite with Matchers { val rewrittenPlan = LogicalPlanConverter.convertLogicalPlan[plansV3_4.ProduceResult](p3_3)._1 rewrittenPlan should be(p3_4) - rewrittenPlan.assignedId should be(helpers.as3_4(p3_3_id)) - rewrittenPlan.lhs.get.assignedId should be(helpers.as3_4(s3_3_id)) + rewrittenPlan.id should be(helpers.as3_4(p3_3_id)) + rewrittenPlan.lhs.get.id should be(helpers.as3_4(s3_3_id)) } test("should convert ErrorPlan") { diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/PipeExecutionPlanBuilderIT.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/PipeExecutionPlanBuilderIT.scala index 10729cbf5a6c7..09f95abbb167a 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/PipeExecutionPlanBuilderIT.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/PipeExecutionPlanBuilderIT.scala @@ -58,7 +58,6 @@ class PipeExecutionPlanBuilderIT extends CypherFunSuite with LogicalPlanningTest private def build(f: PlannerQuery with CardinalityEstimation => LogicalPlan): PipeInfo = { val logicalPlan = f(solved) - logicalPlan.assignIds() planBuilder.build(None, logicalPlan) } diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/ExecutionWorkflowBuilderTest.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/ExecutionWorkflowBuilderTest.scala index 760fb488d7c09..a151b26be5ee2 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/ExecutionWorkflowBuilderTest.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/executionplan/ExecutionWorkflowBuilderTest.scala @@ -34,15 +34,11 @@ import org.neo4j.cypher.internal.v3_4.logical.plans.Argument import org.neo4j.values.virtual.VirtualValues.EMPTY_MAP class ExecutionWorkflowBuilderTest extends CypherFunSuite { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() val PlannerName = IDPPlannerName val solved = CardinalityEstimation.lift(PlannerQuery.empty, Cardinality(1)) - val logicalPlan = { - val x = Argument()(solved) - x.assignIds() - x - } + val logicalPlan = Argument()(solved) test("produces eager results for updating queries") { // GIVEN diff --git a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/ProfilerTest.scala b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/ProfilerTest.scala index 9eef6a0cbba6e..87f777eeceef4 100644 --- a/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/ProfilerTest.scala +++ b/community/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/profiler/ProfilerTest.scala @@ -28,8 +28,8 @@ import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, QuerySta import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.runtime.planDescription.{PlanDescriptionImpl, _} import org.neo4j.cypher.internal.runtime.{QueryContext, QueryTransactionalContext} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.kernel.impl.factory.DatabaseInfo import org.neo4j.values.storable.Values.NO_VALUE @@ -320,7 +320,7 @@ case class ProfilerTestPipe(source: Pipe, name: String, rows: Int, dbAccess: Int hits: Long = 0, misses: Long = 0) extends PipeWithSource(source) { - var id = LogicalPlanId.DEFAULT + var id: Id = Id.INVALID_ID protected def internalCreateResults(input:Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { input.size diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AllNodesScanPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AllNodesScanPipe.scala index f888abcbfed12..960baa8362105 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AllNodesScanPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AllNodesScanPipe.scala @@ -20,9 +20,9 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class AllNodesScanPipe(ident: String)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { +case class AllNodesScanPipe(ident: String)(val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { val baseContext = state.createOrGetInitialContext(executionContextFactory) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ApplyPipe.scala index d6ca1e7ac79b9..1a08872f9e7e0 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ApplyPipe.scala @@ -20,9 +20,9 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class ApplyPipe(source: Pipe, inner: Pipe)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { +case class ApplyPipe(source: Pipe, inner: Pipe)(val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = input.flatMap { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AssertSameNodePipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AssertSameNodePipe.scala index 1d9781f47d917..5bccc8690a425 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AssertSameNodePipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/AssertSameNodePipe.scala @@ -22,11 +22,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.util.v3_4.MergeConstraintConflictException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.CastSupport -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.virtual.VirtualNodeValue case class AssertSameNodePipe(source: Pipe, inner: Pipe, node: String) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(lhsResult: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CartesianProductPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CartesianProductPipe.scala index 06bef5d11a047..2839540078298 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CartesianProductPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CartesianProductPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class CartesianProductPipe(lhs: Pipe, rhs: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { for (outer <- lhs.createResults(state); inner <- rhs.createResults(state)) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConditionalApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConditionalApplyPipe.scala index 52c35b4235b4b..46d99a59925a9 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConditionalApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConditionalApplyPipe.scala @@ -20,11 +20,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class ConditionalApplyPipe(source: Pipe, inner: Pipe, items: Seq[String], negated: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConstraintOperationPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConstraintOperationPipe.scala index 640b115e2513d..3475230a1580a 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConstraintOperationPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ConstraintOperationPipe.scala @@ -23,10 +23,10 @@ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands._ import org.neo4j.cypher.internal.runtime.interpreted.commands.values.KeyToken import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id class ConstraintOperationPipe(op: PropertyConstraintOperation, keyToken: KeyToken, propertyKey: KeyToken) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { val keyTokenId = keyToken.getOrCreateId(state.query) val propertyKeyId = propertyKey.getOrCreateId(state.query) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateNodePipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateNodePipe.scala index db899cf6568d9..edbf79592f83f 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateNodePipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateNodePipe.scala @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.util.v3_4.{CypherTypeException, InvalidSemanticsException} import org.neo4j.cypher.internal.runtime.interpreted._ import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.kernel.impl.util.ValueUtils import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values @@ -79,7 +79,7 @@ abstract class BaseCreateNodePipe(src: Pipe, key: String, labels: Seq[LazyLabel] } case class CreateNodePipe(src: Pipe, key: String, labels: Seq[LazyLabel], properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends BaseCreateNodePipe(src, key, labels, properties) { + (val id: Id = Id.INVALID_ID) extends BaseCreateNodePipe(src, key, labels, properties) { override protected def handleNull(key: String) { // do nothing @@ -87,7 +87,7 @@ case class CreateNodePipe(src: Pipe, key: String, labels: Seq[LazyLabel], proper } case class MergeCreateNodePipe(src: Pipe, key: String, labels: Seq[LazyLabel], properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends BaseCreateNodePipe(src, key, labels, properties) { + (val id: Id = Id.INVALID_ID) extends BaseCreateNodePipe(src, key, labels, properties) { override protected def handleNull(key: String) { //merge cannot use null properties, since in that case the match part will not find the result of the create throw new InvalidSemanticsException(s"Cannot merge node using null property value for $key") diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateRelationshipPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateRelationshipPipe.scala index 6c05bf9c0a929..b0fafac6d65e7 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateRelationshipPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/CreateRelationshipPipe.scala @@ -24,8 +24,8 @@ import java.util.function.BiConsumer import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.runtime.interpreted._ import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{CypherTypeException, InternalException, InvalidSemanticsException} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.{EdgeValue, NodeValue} @@ -84,7 +84,7 @@ abstract class BaseRelationshipPipe(src: Pipe, key: String, startNode: String, t case class CreateRelationshipPipe(src: Pipe, key: String, startNode: String, typ: LazyType, endNode: String, properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseRelationshipPipe(src, key, startNode, typ, endNode, properties) { override protected def handleNull(key: String) { //do nothing @@ -93,7 +93,7 @@ case class CreateRelationshipPipe(src: Pipe, case class MergeCreateRelationshipPipe(src: Pipe, key: String, startNode: String, typ: LazyType, endNode: String, properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseRelationshipPipe(src, key, startNode, typ, endNode, properties) { override protected def handleNull(key: String) { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DeletePipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DeletePipe.scala index a161728ae9124..86ee40256a0f8 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DeletePipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DeletePipe.scala @@ -23,14 +23,14 @@ import org.neo4j.cypher.internal.util.v3_4.CypherTypeException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.GraphElementPropertyFunctions -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values import org.neo4j.values.virtual.{EdgeValue, NodeValue, PathValue} import scala.collection.JavaConverters._ case class DeletePipe(src: Pipe, expression: Expression, forced: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(src) with GraphElementPropertyFunctions { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DirectedRelationshipByIdSeekPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DirectedRelationshipByIdSeekPipe.scala index f7d1a7b064ebe..ef4f83da1aa2e 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DirectedRelationshipByIdSeekPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DirectedRelationshipByIdSeekPipe.scala @@ -23,7 +23,7 @@ import java.lang import java.util.function import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.VirtualValues @@ -31,7 +31,7 @@ import org.neo4j.values.virtual.VirtualValues import scala.collection.JavaConverters._ case class DirectedRelationshipByIdSeekPipe(ident: String, relIdExpr: SeekArgs, toNode: String, fromNode: String) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { relIdExpr.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DistinctPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DistinctPipe.scala index c839f464ec2cb..068174883573a 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DistinctPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/DistinctPipe.scala @@ -22,14 +22,14 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.util.v3_4.Eagerly -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.virtual.VirtualValues import scala.collection.mutable case class DistinctPipe(source: Pipe, expressions: Map[String, Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { val keyNames: Seq[String] = expressions.keys.toIndexedSeq diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerAggregationPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerAggregationPipe.scala index 178736ca6ac3b..cd484ad2dbfad 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerAggregationPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerAggregationPipe.scala @@ -22,7 +22,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, MutableMaps} import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{AggregationExpression, Expression} import org.neo4j.cypher.internal.runtime.interpreted.pipes.aggregation.AggregationFunction -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.virtual.{ListValue, MapValue, VirtualValues} @@ -33,7 +33,7 @@ import scala.collection.mutable.{Map => MutableMap} // to emit aggregated results. // Cypher is lazy until it can't - this pipe will eagerly load the full match case class EagerAggregationPipe(source: Pipe, keyExpressions: Map[String, Expression], aggregations: Map[String, AggregationExpression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { aggregations.values.foreach(_.registerOwningPipe(this)) keyExpressions.values.foreach(_.registerOwningPipe(this)) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerPipe.scala index 4168b529aeab9..91966f66e9be7 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EagerPipe.scala @@ -20,9 +20,9 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class EagerPipe(src: Pipe)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) +case class EagerPipe(src: Pipe)(val id: Id = Id.INVALID_ID) extends PipeWithSource(src) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EmptyResultPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EmptyResultPipe.scala index be35ff0c1f314..7d890d1afdf55 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EmptyResultPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/EmptyResultPipe.scala @@ -20,9 +20,9 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class EmptyResultPipe(source: Pipe)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { +case class EmptyResultPipe(source: Pipe)(val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(input:Iterator[ExecutionContext], state: QueryState) = { while(input.hasNext) { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ErrorPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ErrorPipe.scala index 4bbba1dcbc797..65e414044f33a 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ErrorPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ErrorPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ErrorPipe(source: Pipe, exception: Exception) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = throw exception diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandAllPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandAllPipe.scala index 660dff74b74f3..6e20fde8d7a01 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandAllPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandAllPipe.scala @@ -21,8 +21,8 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.{EdgeValue, NodeValue} @@ -33,7 +33,7 @@ case class ExpandAllPipe(source: Pipe, toName: String, dir: SemanticDirection, types: LazyTypes) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { input.flatMap { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandIntoPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandIntoPipe.scala index 86f687b621836..7b439ceb660f9 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandIntoPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ExpandIntoPipe.scala @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.InternalException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection import org.neo4j.values.storable.Values import org.neo4j.values.virtual.NodeValue @@ -41,7 +41,7 @@ case class ExpandIntoPipe(source: Pipe, toName: String, dir: SemanticDirection, lazyTypes: LazyTypes) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with CachingExpandInto { self => private final val CACHE_SIZE = 100000 diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FilterPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FilterPipe.scala index 670bb6a096426..eb73ed3b961fd 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FilterPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FilterPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class FilterPipe(source: Pipe, predicate: Predicate) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { predicate.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ForeachPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ForeachPipe.scala index a68957f2a36e1..4351cf24dbabc 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ForeachPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ForeachPipe.scala @@ -22,12 +22,12 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.ListSupport -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import scala.collection.JavaConverters._ case class ForeachPipe(source: Pipe, inner: Pipe, variable: String, expression: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with ListSupport { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FullPruningVarLengthExpandPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FullPruningVarLengthExpandPipe.scala index b9feacb8a5647..ea9b4af9c985d 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FullPruningVarLengthExpandPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FullPruningVarLengthExpandPipe.scala @@ -22,8 +22,8 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.collection.primitive.{Primitive, PrimitiveLongObjectMap} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.virtual.{EdgeValue, NodeValue} case class FullPruningVarLengthExpandPipe(source: Pipe, @@ -34,7 +34,7 @@ case class FullPruningVarLengthExpandPipe(source: Pipe, min: Int, max: Int, filteringStep: VarLengthPredicate = VarLengthPredicate.NONE) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with Pipe { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { self => assert(min <= max) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/IndexOperationPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/IndexOperationPipe.scala index 4523c23a1667e..e45c8d43467b2 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/IndexOperationPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/IndexOperationPipe.scala @@ -23,9 +23,9 @@ import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor import org.neo4j.cypher.internal.util.v3_4.SyntaxException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.{CreateIndex, DropIndex, IndexOperation} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class IndexOperationPipe(indexOp: IndexOperation)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { +case class IndexOperationPipe(indexOp: IndexOperation)(val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { val queryContext = state.query diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSelectOrSemiApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSelectOrSemiApplyPipe.scala index a1866f1039fdd..22c0d7d446486 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSelectOrSemiApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSelectOrSemiApplyPipe.scala @@ -21,11 +21,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class LetSelectOrSemiApplyPipe(source: Pipe, inner: Pipe, letVarName: String, predicate: Predicate, negated: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { predicate.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSemiApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSemiApplyPipe.scala index 085c264c7ba95..2b5cc6b32d7e2 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSemiApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LetSemiApplyPipe.scala @@ -20,11 +20,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class LetSemiApplyPipe(source: Pipe, inner: Pipe, letVarName: String, negated: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { input.map { (outerContext) => diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipe.scala index 91e5a0c8ceaee..2560594483870 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{Expression, NumericHelper} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class LimitPipe(source: Pipe, exp: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with NumericHelper { exp.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LoadCSVPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LoadCSVPipe.scala index 5d08bfea5d653..61034089fda0b 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LoadCSVPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LoadCSVPipe.scala @@ -25,9 +25,9 @@ import java.util import org.neo4j.cypher.internal.util.v3_4.LoadExternalResourceException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.internal.ir.v3_4.{CSVFormat, HasHeaders, NoHeaders} import org.neo4j.cypher.internal.runtime.{ArrayBackedMap, QueryContext} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values._ import org.neo4j.values.storable.{TextValue, Value, Values} import org.neo4j.values.virtual.VirtualValues @@ -40,7 +40,7 @@ case class LoadCSVPipe(source: Pipe, variable: String, fieldTerminator: Option[String], legacyCsvQuoteEscaping: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { urlExpression.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LockNodesPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LockNodesPipe.scala index 318bc2ca996eb..a5f2b9c489031 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LockNodesPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LockNodesPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.virtual.VirtualNodeValue -case class LockNodesPipe(src: Pipe, variablesToLock: Set[String])(val id: LogicalPlanId = LogicalPlanId.DEFAULT) +case class LockNodesPipe(src: Pipe, variablesToLock: Set[String])(val id: Id = Id.INVALID_ID) extends PipeWithSource(src) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByIdSeekPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByIdSeekPipe.scala index b08394dec63f0..5f1bef5d2833f 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByIdSeekPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByIdSeekPipe.scala @@ -22,7 +22,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.IsList -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.virtual.{ListValue, VirtualValues} import scala.collection.JavaConverters._ @@ -60,7 +60,7 @@ case class ManySeekArgs(coll: Expression) extends SeekArgs { } case class NodeByIdSeekPipe(ident: String, nodeIdsExpr: SeekArgs) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { nodeIdsExpr.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByLabelScanPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByLabelScanPipe.scala index 609c41da87974..08a62c1665854 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByLabelScanPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeByLabelScanPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class NodeByLabelScanPipe(ident: String, label: LazyLabel) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeCountFromCountStorePipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeCountFromCountStorePipe.scala index a82d8c7556878..8a532ea6a46f5 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeCountFromCountStorePipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeCountFromCountStorePipe.scala @@ -21,11 +21,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.NameId -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class NodeCountFromCountStorePipe(ident: String, labels: List[Option[LazyLabel]]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { var count = 1L diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeHashJoinPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeHashJoinPipe.scala index 06e0606f11902..5382b19ed4da7 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeHashJoinPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeHashJoinPipe.scala @@ -21,14 +21,14 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.util.v3_4.CypherTypeException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values import org.neo4j.values.virtual.VirtualNodeValue import scala.collection.mutable case class NodeHashJoinPipe(nodeVariables: Set[String], left: Pipe, right: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(left) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexContainsScanPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexContainsScanPipe.scala index c6d1fda82b3ea..4cde8415bd85e 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexContainsScanPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexContainsScanPipe.scala @@ -23,8 +23,8 @@ import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.util.v3_4.CypherTypeException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.{LabelToken, PropertyKeyToken} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.storable.{TextValue, Values} import org.neo4j.values.virtual.NodeValue @@ -61,7 +61,7 @@ case class NodeIndexContainsScanPipe(ident: String, label: LabelToken, propertyKey: PropertyKeyToken, valueExpr: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends AbstractNodeIndexStringScanPipe(ident, label, propertyKey, valueExpr) { override protected def queryContextCall(state: QueryState, indexDescriptor: IndexDescriptor, value: String) = @@ -72,7 +72,7 @@ case class NodeIndexEndsWithScanPipe(ident: String, label: LabelToken, propertyKey: PropertyKeyToken, valueExpr: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends AbstractNodeIndexStringScanPipe(ident, label, propertyKey, valueExpr) { override protected def queryContextCall(state: QueryState, indexDescriptor: IndexDescriptor, value: String) = diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexScanPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexScanPipe.scala index 697b30b92a655..9e978324aa5e8 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexScanPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexScanPipe.scala @@ -21,13 +21,13 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.{LabelToken, PropertyKeyToken} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId case class NodeIndexScanPipe(ident: String, label: LabelToken, propertyKey: PropertyKeyToken) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { private val descriptor = IndexDescriptor(label.nameId.id, propertyKey.nameId.id) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexSeekPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexSeekPipe.scala index fb19fc8478e29..53e18393ee915 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexSeekPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeIndexSeekPipe.scala @@ -23,15 +23,16 @@ import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.commands.indexQuery +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.{LabelToken, PropertyKeyToken} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId, QueryExpression} +import org.neo4j.cypher.internal.v3_4.logical.plans.QueryExpression case class NodeIndexSeekPipe(ident: String, label: LabelToken, propertyKeys: Seq[PropertyKeyToken], valueExpr: QueryExpression[Expression], indexMode: IndexSeekMode = IndexSeek) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { private val propertyIds: Array[Int] = propertyKeys.map(_.nameId.id).toArray diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeOuterHashJoinPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeOuterHashJoinPipe.scala index ee957af57d34f..30a7fe151fadc 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeOuterHashJoinPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/NodeOuterHashJoinPipe.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.VirtualNodeValue @@ -29,7 +29,7 @@ import scala.collection.mutable import scala.collection.mutable.ListBuffer case class NodeOuterHashJoinPipe(nodeVariables: Set[String], source: Pipe, inner: Pipe, nullableVariables: Set[String]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { val nullColumns: Seq[(String, AnyValue)] = nullableVariables.map(_ -> Values.NO_VALUE).toSeq diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandAllPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandAllPipe.scala index 67b3ad19861bf..13e0a49440b6e 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandAllPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandAllPipe.scala @@ -22,15 +22,15 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.NodeValue case class OptionalExpandAllPipe(source: Pipe, fromName: String, relName: String, toName: String, dir: SemanticDirection, types: LazyTypes, predicate: Predicate) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { predicate.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandIntoPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandIntoPipe.scala index 0249f2d6a45a1..040e62ddc0ae2 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandIntoPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalExpandIntoPipe.scala @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection import org.neo4j.values.storable.Values import org.neo4j.values.virtual.NodeValue @@ -30,7 +30,7 @@ import scala.collection.mutable.ListBuffer case class OptionalExpandIntoPipe(source: Pipe, fromName: String, relName: String, toName: String, dir: SemanticDirection, types: LazyTypes, predicate: Predicate) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with CachingExpandInto { private final val CACHE_SIZE = 100000 diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalPipe.scala index e494fbf2c1490..633ad714c9f8e 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/OptionalPipe.scala @@ -20,11 +20,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class OptionalPipe(nullableVariables: Set[String], source: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { private def notFoundExecutionContext(initialContext: Option[ExecutionContext]): ExecutionContext = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/Pipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/Pipe.scala index ca1d854218fdf..f1beb70a6ffc4 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/Pipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/Pipe.scala @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.Unchangeable -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id /** * Pipe is a central part of Cypher. Most pipes are decorators - they @@ -48,7 +48,7 @@ trait Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] // Used by profiling to identify where to report dbhits and rows - def id: LogicalPlanId + def id(): Id // TODO: Alternatively we could pass the logicalPlanId when we create contexts, and in the SlottedQueryState use the // SlotConfigurations map to get the slot configuration needed for the context creation, @@ -60,7 +60,7 @@ trait Pipe { } } -case class ArgumentPipe()(val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { +case class ArgumentPipe()(val id: Id = Id.INVALID_ID) extends Pipe { def internalCreateResults(state: QueryState) = Iterator(state.createOrGetInitialContext(executionContextFactory)) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProcedureCallPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProcedureCallPipe.scala index 252c21b8df785..c38921a07a388 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProcedureCallPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProcedureCallPipe.scala @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.runtime.ProcedureCallMode import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.ValueConversion -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.logical.plans.ProcedureSignature import org.neo4j.cypher.internal.util.v3_4.symbols.CypherType import org.neo4j.values.AnyValue @@ -45,7 +45,7 @@ case class ProcedureCallPipe(source: Pipe, rowProcessing: ProcedureCallRowProcessing, resultSymbols: Seq[(String, CypherType)], resultIndices: Seq[(Int, String)]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProduceResultsPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProduceResultsPipe.scala index 618b882a1db3c..780f6761def0b 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProduceResultsPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProduceResultsPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, MutableMaps} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ProduceResultsPipe(source: Pipe, columns: Seq[String]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState) = { // do not register this pipe as parent as it does not do anything except filtering of already fetched // key-value pairs and thus should not have any stats diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectEndpointsPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectEndpointsPipe.scala index 15b9c907396f1..69cb40ad19d45 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectEndpointsPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectEndpointsPipe.scala @@ -21,7 +21,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, ListSupport} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.virtual.VirtualValues.reverse import org.neo4j.values.virtual.{EdgeReference, EdgeValue, ListValue, NodeValue} @@ -29,7 +29,7 @@ case class ProjectEndpointsPipe(source: Pipe, relName: String, start: String, startInScope: Boolean, end: String, endInScope: Boolean, relTypes: Option[LazyTypes], directed: Boolean, simpleLength: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with ListSupport { type Projector = (ExecutionContext) => Iterator[ExecutionContext] diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectionPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectionPipe.scala index 7dba003e636c5..cad7db83fc5db 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectionPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ProjectionPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ProjectionPipe(source: Pipe, expressions: Map[String, Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { expressions.values.foreach(_.registerOwningPipe(this)) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PruningVarLengthExpandPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PruningVarLengthExpandPipe.scala index 7d83bc439a089..b75319473d6e6 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PruningVarLengthExpandPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PruningVarLengthExpandPipe.scala @@ -22,8 +22,8 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.collection.primitive.{Primitive, PrimitiveLongObjectMap} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.storable.{Value, Values} import org.neo4j.values.virtual.{EdgeValue, NodeReference, NodeValue} @@ -35,7 +35,7 @@ case class PruningVarLengthExpandPipe(source: Pipe, min: Int, max: Int, filteringStep: VarLengthPredicate = VarLengthPredicate.NONE) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with Pipe { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { self => assert(min <= max) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RelationshipCountFromCountStorePipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RelationshipCountFromCountStorePipe.scala index 7e05d611f3057..9f65df42cfb90 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RelationshipCountFromCountStorePipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RelationshipCountFromCountStorePipe.scala @@ -21,12 +21,12 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.NameId -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class RelationshipCountFromCountStorePipe(ident: String, startLabel: Option[LazyLabel], typeNames: LazyTypes, endLabel: Option[LazyLabel]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { val maybeStartLabelId = getLabelId(startLabel, state) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RemoveLabelsPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RemoveLabelsPipe.scala index df4a3a31b7874..142e90cd1227b 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RemoveLabelsPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RemoveLabelsPipe.scala @@ -22,12 +22,12 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.CastSupport import org.neo4j.cypher.internal.runtime.interpreted.GraphElementPropertyFunctions -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values import org.neo4j.values.virtual.VirtualNodeValue case class RemoveLabelsPipe(src: Pipe, variable: String, labels: Seq[LazyLabel]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(src) with GraphElementPropertyFunctions { override protected def internalCreateResults(input: Iterator[ExecutionContext], diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RollUpApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RollUpApplyPipe.scala index 742cc0dffbbfd..b6d46fac85701 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RollUpApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/RollUpApplyPipe.scala @@ -20,12 +20,12 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values.NO_VALUE import org.neo4j.values.virtual.VirtualValues case class RollUpApplyPipe(lhs: Pipe, rhs: Pipe, collectionName: String, identifierToCollect: String, nullableIdentifiers: Set[String]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(lhs) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState) = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SelectOrSemiApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SelectOrSemiApplyPipe.scala index b30a550a26151..de9d062a7975a 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SelectOrSemiApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SelectOrSemiApplyPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class SelectOrSemiApplyPipe(source: Pipe, inner: Pipe, predicate: Predicate, negated: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { predicate.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SemiApplyPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SemiApplyPipe.scala index 894a672b8c83b..0f5482a385532 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SemiApplyPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SemiApplyPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class SemiApplyPipe(source: Pipe, inner: Pipe, negated: Boolean) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { input.filter { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SetPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SetPipe.scala index 8ea3a2d7db51c..c05cfa48b13ec 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SetPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SetPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class SetPipe(src: Pipe, setOperation: SetOperation) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(src) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(src) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { input.map { row => diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ShortestPathPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ShortestPathPipe.scala index 6f7542f3c1ac4..072b60e737fc2 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ShortestPathPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ShortestPathPipe.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.ShortestPath import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.ShortestPathExpression import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values import org.neo4j.values.virtual.{ListValue, PathValue, VirtualValues} @@ -35,7 +35,7 @@ import scala.collection.JavaConverters._ */ case class ShortestPathPipe(source: Pipe, shortestPathCommand: ShortestPath, predicates: Seq[Predicate] = Seq.empty, withFallBack: Boolean = false, disallowSameNode: Boolean = true) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { private def pathName = shortestPathCommand.pathName private val shortestPathExpression = ShortestPathExpression(shortestPathCommand, predicates, withFallBack, disallowSameNode) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SkipPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SkipPipe.scala index 3e8a9e6a49059..5be2d0dbe9750 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SkipPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SkipPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{Expression, NumericHelper} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class SkipPipe(source: Pipe, exp: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with NumericHelper { exp.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SortPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SortPipe.scala index c7e16611e84cd..e777fd6cc71a5 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SortPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/SortPipe.scala @@ -22,11 +22,11 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import java.util.Comparator import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.{AnyValue, AnyValues} case class SortPipe(source: Pipe, orderBy: Seq[ColumnOrder]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { assert(orderBy.nonEmpty) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TopPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TopPipe.scala index e194a283c17ff..d812285cb1c7f 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TopPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TopPipe.scala @@ -23,7 +23,7 @@ import java.util.Comparator import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.NumberValue @@ -66,7 +66,7 @@ abstract class TopPipe(source: Pipe, sortDescription: List[ColumnOrder]) } case class TopNPipe(source: Pipe, sortDescription: List[ColumnOrder], countExpression: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends TopPipe(source, sortDescription) { + (val id: Id = Id.INVALID_ID) extends TopPipe(source, sortDescription) { countExpression.registerOwningPipe(this) @@ -124,7 +124,7 @@ case class TopNPipe(source: Pipe, sortDescription: List[ColumnOrder], countExpre * an array, instead just store a single value. */ case class Top1Pipe(source: Pipe, sortDescription: List[ColumnOrder]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends TopPipe(source, sortDescription) { protected override def internalCreateResults(input: Iterator[ExecutionContext], @@ -156,7 +156,7 @@ case class Top1Pipe(source: Pipe, sortDescription: List[ColumnOrder]) * Special case for when we only want one element, and all others that have the same value (tied for first place) */ case class Top1WithTiesPipe(source: Pipe, sortDescription: List[ColumnOrder]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends TopPipe(source, sortDescription) { protected override def internalCreateResults(input: Iterator[ExecutionContext], diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TriadicSelectionPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TriadicSelectionPipe.scala index 0fbcc93110796..5c8030f589fc1 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TriadicSelectionPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/TriadicSelectionPipe.scala @@ -22,7 +22,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.collection.primitive.{Primitive, PrimitiveLongSet} import org.neo4j.cypher.internal.util.v3_4.CypherTypeException import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values import org.neo4j.values.virtual.NodeValue @@ -30,7 +30,7 @@ import scala.collection.mutable.ListBuffer import scala.collection.{AbstractIterator, Iterator} case class TriadicSelectionPipe(positivePredicate: Boolean, left: Pipe, source: String, seen: String, target: String, right: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(left) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState) = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UndirectedRelationshipByIdSeekPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UndirectedRelationshipByIdSeekPipe.scala index dd029fe4066f9..844693d7720d1 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UndirectedRelationshipByIdSeekPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UndirectedRelationshipByIdSeekPipe.scala @@ -23,7 +23,7 @@ import java.lang import java.util.function import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import org.neo4j.values.virtual.VirtualValues @@ -31,7 +31,7 @@ import org.neo4j.values.virtual.VirtualValues import scala.collection.JavaConverters._ case class UndirectedRelationshipByIdSeekPipe(ident: String, relIdExpr: SeekArgs, toNode: String, fromNode: String) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { relIdExpr.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnionPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnionPipe.scala index f42e104c2fa8e..a3a98275557f3 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnionPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnionPipe.scala @@ -20,10 +20,10 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class UnionPipe(l: Pipe, r: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = l.createResults(state) ++ r.createResults(state) } diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnwindPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnwindPipe.scala index 11854cf62da90..28895b6379a77 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnwindPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/UnwindPipe.scala @@ -22,14 +22,14 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.ListSupport -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import scala.annotation.tailrec import scala.collection.JavaConverters._ case class UnwindPipe(source: Pipe, collection: Expression, variable: String) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with ListSupport { collection.registerOwningPipe(this) diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ValueHashJoinPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ValueHashJoinPipe.scala index 491afc0d45723..f7c0e1cdc0f85 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ValueHashJoinPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/ValueHashJoinPipe.scala @@ -21,14 +21,14 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values import scala.collection.mutable case class ValueHashJoinPipe(lhsExpression: Expression, rhsExpression: Expression, left: Pipe, right: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(left) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { diff --git a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/VarLengthExpandPipe.scala b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/VarLengthExpandPipe.scala index 7ca4f556f490e..f462f9b1f55fa 100644 --- a/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/VarLengthExpandPipe.scala +++ b/community/cypher/interpreted-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/VarLengthExpandPipe.scala @@ -21,8 +21,8 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.values.storable.Values import org.neo4j.values.virtual._ @@ -53,7 +53,7 @@ case class VarLengthExpandPipe(source: Pipe, max: Option[Int], nodeInScope: Boolean, filteringStep: VarLengthPredicate= VarLengthPredicate.NONE) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { private def varLengthExpand(node: NodeValue, state: QueryState, maxDepth: Option[Int], row: ExecutionContext): Iterator[(NodeValue, Seq[EdgeValue])] = { val stack = new mutable.Stack[(NodeValue, Seq[EdgeValue])] diff --git a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FakePipe.scala b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FakePipe.scala index 270c1d2b188c0..d04d2ff419861 100644 --- a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FakePipe.scala +++ b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/FakePipe.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.runtime.interpreted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.symbols.CypherType import org.neo4j.kernel.impl.util.ValueUtils import org.scalatest.mock.MockitoSugar @@ -34,5 +34,5 @@ class FakePipe(val data: Iterator[Map[String, Any]], newVariables: (String, Cyph def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = data.map(m => ExecutionContext(collection.mutable.Map(m.mapValues(ValueUtils.of).toSeq: _*))) - var id = LogicalPlanId.DEFAULT + var id: Id = Id.INVALID_ID } diff --git a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipeTest.scala b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipeTest.scala index c7ada06a72742..1938ad1742bf1 100644 --- a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipeTest.scala +++ b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/LimitPipeTest.scala @@ -23,7 +23,7 @@ import org.mockito.Mockito._ import org.mockito.internal.stubbing.defaultanswers.ReturnsMocks import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, QueryStateHelper} import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Literal -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite class LimitPipeTest extends CypherFunSuite { @@ -47,7 +47,7 @@ class LimitPipeTest extends CypherFunSuite { class DummyPipe(inputIterator: Iterator[ExecutionContext]) extends Pipe { override protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = ??? - override def id: LogicalPlanId = ??? + override def id(): Id = ??? override def createResults(state: QueryState): Iterator[ExecutionContext] = inputIterator } diff --git a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PipeTestSupport.scala b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PipeTestSupport.scala index 6e34ec4bf9614..3d0124c2c383f 100644 --- a/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PipeTestSupport.scala +++ b/community/cypher/interpreted-runtime/src/test/scala/org/neo4j/cypher/internal/runtime/interpreted/pipes/PipeTestSupport.scala @@ -25,9 +25,9 @@ import org.mockito.invocation.InvocationOnMock import org.mockito.stubbing.Answer import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.symbols.{CypherType, _} import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherTestSupport -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.graphdb.{Node, Relationship} import org.neo4j.kernel.impl.util.ValueUtils import org.scalatest.mock.MockitoSugar @@ -40,7 +40,7 @@ trait PipeTestSupport extends CypherTestSupport with MockitoSugar { protected def internalCreateResults(state: QueryState) = f(state) // Used by profiling to identify where to report dbhits and rows - override def id: LogicalPlanId = LogicalPlanId.DEFAULT + override def id(): Id = Id.INVALID_ID } def row(values: (String, Any)*) = ExecutionContext.from(values.map(v => (v._1, ValueUtils.of(v._2))): _*) diff --git a/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescription.scala b/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescription.scala index 7542c01798c4d..273a7b7ddade1 100644 --- a/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescription.scala +++ b/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescription.scala @@ -24,9 +24,10 @@ import java.util import org.neo4j.cypher.exceptionHandler import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.symbols.CypherType import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId, QualifiedName, SeekableArgs} +import org.neo4j.cypher.internal.v3_4.logical.plans.{QualifiedName, SeekableArgs} import org.neo4j.cypher.internal.v3_4.{expressions => ast} import org.neo4j.graphdb.ExecutionPlanDescription import org.neo4j.graphdb.ExecutionPlanDescription.ProfilerStatistics @@ -39,7 +40,7 @@ sealed trait InternalPlanDescription extends org.neo4j.graphdb.ExecutionPlanDesc def arguments: Seq[Argument] - def id: LogicalPlanId + def id: Id def name: String @@ -264,7 +265,7 @@ final case class TwoChildren(lhs: InternalPlanDescription, rhs: InternalPlanDesc def map(f: InternalPlanDescription => InternalPlanDescription) = TwoChildren(lhs = lhs.map(f), rhs = rhs.map(f)) } -final case class PlanDescriptionImpl(id: LogicalPlanId, +final case class PlanDescriptionImpl(id: Id, name: String, children: Children, arguments: Seq[Argument], @@ -357,7 +358,7 @@ final case class CompactedPlanDescription(similar: Seq[InternalPlanDescription]) override def find(name: String): Seq[InternalPlanDescription] = similar.last.find(name) - override def id: LogicalPlanId = similar.last.id + override def id: Id = similar.last.id override def addArgument(argument: Argument): InternalPlanDescription = ??? @@ -367,7 +368,7 @@ final case class CompactedPlanDescription(similar: Seq[InternalPlanDescription]) } -final case class ArgumentPlanDescription(id: LogicalPlanId, +final case class ArgumentPlanDescription(id: Id, arguments: Seq[Argument] = Seq.empty, variables: Set[String]) extends InternalPlanDescription { diff --git a/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescription.scala b/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescription.scala index 84787c5eb04b3..ceccb2627d62f 100644 --- a/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescription.scala +++ b/community/cypher/runtime-util/src/main/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescription.scala @@ -47,7 +47,7 @@ case class LogicalPlan2PlanDescription(readOnly: Boolean) override protected def build(plan: LogicalPlan): InternalPlanDescription = { assert(plan.isLeaf) - val id = plan.assignedId + val id = plan.id val variables = plan.availableSymbols.map(_.name) val result: InternalPlanDescription = plan match { @@ -121,7 +121,7 @@ case class LogicalPlan2PlanDescription(readOnly: Boolean) assert(plan.lhs.nonEmpty) assert(plan.rhs.isEmpty) - val id = plan.assignedId + val id = plan.id val variables = plan.availableSymbols.map(_.name) val children = if (source.isInstanceOf[ArgumentPlanDescription]) NoChildren else SingleChild(source) @@ -158,17 +158,17 @@ case class LogicalPlan2PlanDescription(readOnly: Boolean) PlanDescriptionImpl(id, "DropResult", children, Seq.empty, variables) case NodeCountFromCountStore(IdName(id), labelName, arguments) => - PlanDescriptionImpl(id = plan.assignedId, "NodeCountFromCountStore", NoChildren, + PlanDescriptionImpl(id = plan.id, "NodeCountFromCountStore", NoChildren, Seq(CountNodesExpression(id, labelName.map(l => l.map(_.name)))), variables) case RelationshipCountFromCountStore(IdName(id), start, types, end, arguments) => - PlanDescriptionImpl(id = plan.assignedId, "RelationshipCountFromCountStore", NoChildren, + PlanDescriptionImpl(id = plan.id, "RelationshipCountFromCountStore", NoChildren, Seq( CountRelationshipsExpression(id, start.map(_.name), types.map(_.name), end.map(_.name))), variables) case NodeUniqueIndexSeek(IdName(id), label, propKeys, value, arguments) => - PlanDescriptionImpl(id = plan.assignedId, "NodeUniqueIndexSeek", NoChildren, + PlanDescriptionImpl(id = plan.id, "NodeUniqueIndexSeek", NoChildren, Seq(Index(label.name, propKeys.map(_.name))), variables) case _: ErrorPlan => @@ -299,7 +299,7 @@ case class LogicalPlan2PlanDescription(readOnly: Boolean) assert(plan.lhs.nonEmpty) assert(plan.rhs.nonEmpty) - val id = plan.assignedId + val id = plan.id val variables = plan.availableSymbols.map(_.name) val children = TwoChildren(lhs, rhs) @@ -332,7 +332,7 @@ case class LogicalPlan2PlanDescription(readOnly: Boolean) PlanDescriptionImpl(id, "LetSelectOrSemiApply", children, Seq(Expression(predicate)), variables) case row: plans.Argument => - ArgumentPlanDescription(id = plan.assignedId, Seq.empty, row.argumentIds.map(_.name)) + ArgumentPlanDescription(id = plan.id, Seq.empty, row.argumentIds.map(_.name)) case LetSelectOrAntiSemiApply(_, _, _, predicate) => PlanDescriptionImpl(id, "LetSelectOrAntiSemiApply", children, Seq(Expression(predicate)), variables) diff --git a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescriptionTest.scala b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescriptionTest.scala index 9f2126162001f..95db1934d5f53 100644 --- a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescriptionTest.scala +++ b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/InternalPlanDescriptionTest.scala @@ -19,12 +19,12 @@ */ package org.neo4j.cypher.internal.runtime.planDescription +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId class InternalPlanDescriptionTest extends CypherFunSuite { - private val ID = LogicalPlanId.DEFAULT + private val ID = Id.INVALID_ID test("flatten behaves like expected for plan with two children") { val child1 = PlanDescriptionImpl(ID, "child1", NoChildren, Seq.empty, Set()) diff --git a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescriptionTest.scala b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescriptionTest.scala index b6dc587b06f53..4a7ac853a8b48 100644 --- a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescriptionTest.scala +++ b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/LogicalPlan2PlanDescriptionTest.scala @@ -23,7 +23,7 @@ import org.neo4j.cypher.internal.ir.v3_4.{CardinalityEstimation, IdName, Planner import org.neo4j.cypher.internal.planner.v3_4.spi.IDPPlannerName import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ import org.neo4j.cypher.internal.util.v3_4._ -import org.neo4j.cypher.internal.util.v3_4.attribution.SequentialIdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, SequentialIdGen} import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.v3_4.expressions.{SemanticDirection, LabelName => AstLabelName, _} import org.neo4j.cypher.internal.v3_4.logical.plans._ @@ -35,16 +35,16 @@ class LogicalPlan2PlanDescriptionTest extends CypherFunSuite with TableDrivenPro implicit def emptySolvedWithCardinality(i: Int): PlannerQuery with CardinalityEstimation = CardinalityEstimation.lift(PlannerQuery.empty, Cardinality(i)) - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() + val id = Id.INVALID_ID val lhsLP = AllNodesScan(IdName("a"), Set.empty)(2) - val lhsPD = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "AllNodesScan", NoChildren, Seq(EstimatedRows(2)), Set("a")) + val lhsPD = PlanDescriptionImpl(id, "AllNodesScan", NoChildren, Seq(EstimatedRows(2)), Set("a")) - val rhsPD = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "AllNodesScan", NoChildren, Seq(EstimatedRows(2)), Set("b")) + val rhsPD = PlanDescriptionImpl(id, "AllNodesScan", NoChildren, Seq(EstimatedRows(2)), Set("b")) val rhsLP = AllNodesScan(IdName("b"), Set.empty)(2) val pos = InputPosition(0, 0, 0) - val id = LogicalPlanId.DEFAULT val modeCombinations = Table( "logical plan" -> "expected plan description", @@ -80,7 +80,6 @@ class LogicalPlan2PlanDescriptionTest extends CypherFunSuite with TableDrivenPro forAll(modeCombinations) { case (logicalPlan: LogicalPlan, expectedPlanDescription: PlanDescriptionImpl) => - logicalPlan.assignIds() val producedPlanDescription = LogicalPlan2PlanDescription(logicalPlan, IDPPlannerName) def shouldBeEqual(a: InternalPlanDescription, b: InternalPlanDescription) = { diff --git a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/PlanDescriptionArgumentSerializerTests.scala b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/PlanDescriptionArgumentSerializerTests.scala index de2f3ddd4c193..fcfc565accae0 100644 --- a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/PlanDescriptionArgumentSerializerTests.scala +++ b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/PlanDescriptionArgumentSerializerTests.scala @@ -33,7 +33,7 @@ import org.neo4j.cypher.internal.v3_4.logical.plans class PlanDescriptionArgumentSerializerTests extends CypherFunSuite { val solved = CardinalityEstimation.lift(PlannerQuery.empty, Cardinality(1)) private val pos = DummyPosition(0) - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() test("serialization should leave numeric arguments as numbers") { serialize(DbHits(12)) shouldBe a [java.lang.Number] diff --git a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderSummaryTest.scala b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderSummaryTest.scala index e64edd4a05919..553c3d2d0edfb 100644 --- a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderSummaryTest.scala +++ b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderSummaryTest.scala @@ -20,17 +20,19 @@ package org.neo4j.cypher.internal.runtime.planDescription import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments.{DbHits, Rows} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId class RenderSummaryTest extends CypherFunSuite { + val id = Id.INVALID_ID + test("single node is represented nicely") { val arguments = Seq( Rows(42), DbHits(33)) - val plan = PlanDescriptionImpl(new LogicalPlanId(0), "NAME", NoChildren, arguments, Set()) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set()) renderSummary(plan) should equal("Total database accesses: 33") } @@ -44,15 +46,15 @@ class RenderSummaryTest extends CypherFunSuite { Rows(42), DbHits(22)) - val child = PlanDescriptionImpl(new LogicalPlanId(0), "NAME1", NoChildren, arguments1, Set()) - val parent = PlanDescriptionImpl(new LogicalPlanId(1), "NAME2", SingleChild(child), arguments2, Set()) + val child = PlanDescriptionImpl(Id(0), "NAME1", NoChildren, arguments1, Set()) + val parent = PlanDescriptionImpl(Id(1), "NAME2", SingleChild(child), arguments2, Set()) renderSummary(parent) should equal("Total database accesses: 55") } test("execution plan without profiler stats uses question marks") { val arguments = Seq() - val plan = PlanDescriptionImpl(new LogicalPlanId(0), "NAME", NoChildren, arguments, Set()) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set()) renderSummary(plan) should equal("Total database accesses: ?") } } diff --git a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderTreeTableTest.scala b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderTreeTableTest.scala index 989bd59a19c3a..cfbf3f322aed5 100644 --- a/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderTreeTableTest.scala +++ b/community/cypher/runtime-util/src/test/scala/org/neo4j/cypher/internal/runtime/planDescription/RenderTreeTableTest.scala @@ -23,17 +23,17 @@ import java.util.Locale import org.neo4j.cypher.internal.ir.v3_4.{CardinalityEstimation, IdName, PlannerQuery} import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments._ -import org.neo4j.cypher.internal.util.v3_4.attribution.SequentialIdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, SequentialIdGen} import org.neo4j.cypher.internal.util.v3_4.test_helpers.{CypherFunSuite, WindowsStringSafe} import org.neo4j.cypher.internal.util.v3_4.{Cardinality, DummyPosition} import org.neo4j.cypher.internal.v3_4.expressions.{Expression => ASTExpression, LabelName => ASTLabelName, Range => ASTRange, _} -import org.neo4j.cypher.internal.v3_4.logical.plans.{Expand, ExpandAll, LogicalPlanId} +import org.neo4j.cypher.internal.v3_4.logical.plans.{Expand, ExpandAll} import org.neo4j.cypher.internal.v3_4.logical.plans import org.scalatest.BeforeAndAfterAll class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { implicit val windowsSafe = WindowsStringSafe - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() private val defaultLocale = Locale.getDefault override def beforeAll() { @@ -47,10 +47,11 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } private val pos = DummyPosition(0) + private val id = Id.INVALID_ID test("node feeding from other node") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", SingleChild(leaf), Seq.empty, Set()) + val leaf = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", SingleChild(leaf), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+----------+ @@ -64,9 +65,9 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("node feeding from two nodes") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF1", NoChildren, Seq.empty, Set()) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF2", NoChildren, Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", TwoChildren(leaf1, leaf2), Seq.empty, Set()) + val leaf1 = PlanDescriptionImpl(id, "LEAF1", NoChildren, Seq.empty, Set()) + val leaf2 = PlanDescriptionImpl(id, "LEAF2", NoChildren, Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", TwoChildren(leaf1, leaf2), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+----------+ @@ -82,9 +83,9 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("node feeding of node that is feeding of node") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq.empty, Set()) - val intermediate = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", SingleChild(leaf), Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", SingleChild(intermediate), Seq.empty, Set()) + val leaf = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq.empty, Set()) + val intermediate = PlanDescriptionImpl(id, "INTERMEDIATE", SingleChild(leaf), Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", SingleChild(intermediate), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+---------------+ @@ -100,11 +101,11 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("root with two leafs, one of which is deep") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF1", NoChildren, Seq.empty, Set()) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF2", NoChildren, Seq.empty, Set()) - val leaf3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF3", NoChildren, Seq.empty, Set()) - val intermediate = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", TwoChildren(leaf1, leaf2), Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", TwoChildren(leaf3, intermediate), Seq.empty, Set()) + val leaf1 = PlanDescriptionImpl(id, "LEAF1", NoChildren, Seq.empty, Set()) + val leaf2 = PlanDescriptionImpl(id, "LEAF2", NoChildren, Seq.empty, Set()) + val leaf3 = PlanDescriptionImpl(id, "LEAF3", NoChildren, Seq.empty, Set()) + val intermediate = PlanDescriptionImpl(id, "INTERMEDIATE", TwoChildren(leaf1, leaf2), Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", TwoChildren(leaf3, intermediate), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+-----------------+ @@ -124,13 +125,13 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("root with two intermediate nodes coming from four leaf nodes") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("a")) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("b")) - val leaf3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("c")) - val leaf4 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("d")) - val intermediate1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", TwoChildren(leaf1, leaf2), Seq.empty, Set()) - val intermediate2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", TwoChildren(leaf3, leaf4), Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) + val leaf1 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("a")) + val leaf2 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("b")) + val leaf3 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("c")) + val leaf4 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("d")) + val intermediate1 = PlanDescriptionImpl(id, "INTERMEDIATE", TwoChildren(leaf1, leaf2), Seq.empty, Set()) + val intermediate2 = PlanDescriptionImpl(id, "INTERMEDIATE", TwoChildren(leaf3, leaf4), Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+-----------------+-----------+ @@ -154,49 +155,49 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("complex tree") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF1", NoChildren, Seq( + val leaf1 = PlanDescriptionImpl(id, "LEAF1", NoChildren, Seq( Rows(42), DbHits(33), PageCacheHits(1), PageCacheMisses(2), PageCacheHitRatio(1.0/3), EstimatedRows(1)), Set()) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF2", NoChildren, Seq( + val leaf2 = PlanDescriptionImpl(id, "LEAF2", NoChildren, Seq( Rows(9), DbHits(2), PageCacheHits(2), PageCacheMisses(3), PageCacheHitRatio(2.0/5), EstimatedRows(1)), Set()) - val leaf3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF3", NoChildren, Seq( + val leaf3 = PlanDescriptionImpl(id, "LEAF3", NoChildren, Seq( Rows(9), DbHits(2), PageCacheHits(3), PageCacheMisses(4), PageCacheHitRatio(3.0/7), EstimatedRows(1)), Set()) - val pass = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "PASS", SingleChild(leaf2), Seq( + val pass = PlanDescriptionImpl(id, "PASS", SingleChild(leaf2), Seq( Rows(4), DbHits(0), PageCacheHits(4), PageCacheMisses(1), PageCacheHitRatio(4.0/5), EstimatedRows(4)), Set()) - val inner = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INNER", TwoChildren(leaf1, pass), Seq( + val inner = PlanDescriptionImpl(id, "INNER", TwoChildren(leaf1, pass), Seq( Rows(7), DbHits(42), PageCacheHits(5), PageCacheMisses(2), PageCacheHitRatio(5.0/7), EstimatedRows(6)), Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", TwoChildren(leaf3, inner), Seq( + val plan = PlanDescriptionImpl(id, "ROOT", TwoChildren(leaf3, inner), Seq( Rows(3), DbHits(0), PageCacheHits(7), PageCacheMisses(10), PageCacheHitRatio(7.0/17), EstimatedRows(1)), Set()) - val parent = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "PARENT", SingleChild(plan), Seq(), Set()) + val parent = PlanDescriptionImpl(id, "PARENT", SingleChild(plan), Seq(), Set()) renderAsTreeTable(parent) should equal( """+------------+----------------+------+---------+-----------------+-------------------+----------------------+ @@ -228,7 +229,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { DbHits(33), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+ @@ -245,7 +246,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { DbHits(33), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("a", "b", "c")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("a", "b", "c")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+ @@ -262,7 +263,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { DbHits(33), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("a", "b", "c", "d", "e", "f")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("a", "b", "c", "d", "e", "f")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+------------------+ @@ -276,7 +277,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("execution plan without profiler stats are not shown") { val arguments = Seq(EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+-----------+ @@ -291,8 +292,8 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { val args1 = Seq(Rows(42), DbHits(33), EstimatedRows(1)) val args2 = Seq(Rows(2), DbHits(633), Index("Label", Seq("prop")), EstimatedRows(1)) - val plan1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, args1, Set("a")) - val plan2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", SingleChild(plan1), args2, Set("b")) + val plan1 = PlanDescriptionImpl(id, "NAME", NoChildren, args1, Set("a")) + val plan2 = PlanDescriptionImpl(id, "NAME", SingleChild(plan1), args2, Set("b")) renderAsTreeTable(plan2) should equal( """+----------+----------------+------+---------+-----------+--------------+ @@ -309,8 +310,8 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { val args1 = Seq(Rows(42), DbHits(33), EstimatedRows(1)) val args2 = Seq(Rows(2), DbHits(633), Index("Label", Seq("propA", "propB")), EstimatedRows(1)) - val plan1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, args1, Set("a")) - val plan2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", SingleChild(plan1), args2, Set("b")) + val plan1 = PlanDescriptionImpl(id, "NAME", NoChildren, args1, Set("a")) + val plan2 = PlanDescriptionImpl(id, "NAME", SingleChild(plan1), args2, Set("b")) renderAsTreeTable(plan2) should equal( """+----------+----------------+------+---------+-----------+---------------------+ @@ -325,7 +326,6 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("Expand contains information about its relations") { val expandPlan = Expand(argument, IdName("from"), SemanticDirection.INCOMING, Seq.empty, IdName("to"), IdName("rel"), ExpandAll)(solved) - expandPlan.assignIds() val description = LogicalPlan2PlanDescription(true) renderAsTreeTable(description.create(expandPlan)) should equal( @@ -339,7 +339,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("Label scan should be just as pretty as you would expect") { val arguments = Seq(LabelName("Foo"), EstimatedRows(1)) - val pipe = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NodeByLabelScan", NoChildren, arguments, Set("n")) + val pipe = PlanDescriptionImpl(id, "NodeByLabelScan", NoChildren, arguments, Set("n")) renderAsTreeTable(pipe) should equal( """+------------------+----------------+-----------+-------+ @@ -355,7 +355,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { val estimatedRows = EstimatedRows(1) val arguments = Seq(estimatedRows, expandDescr) val variables = Set("rel", "to") - val planDescription = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "VarLengthExpand(All)", NoChildren, arguments, variables) + val planDescription = PlanDescriptionImpl(id, "VarLengthExpand(All)", NoChildren, arguments, variables) renderAsTreeTable(planDescription) should equal( """+-----------------------+----------------+-----------+-------------------------+ || Operator | Estimated Rows | Variables | Other | @@ -373,7 +373,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { EstimatedRows(1)) val variables = Set("n", " UNNAMED123", " FRESHID12", " AGGREGATION255") - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, variables) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, variables) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------------------------------+------------------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -390,7 +390,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { ExpandExpression("source", "through", Seq("SOME","OTHER","THING"), "target", SemanticDirection.OUTGOING, 1, Some(1)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+-------------------------------------------------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -407,7 +407,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression(Not(Equals(Variable(" UNNAMED123")(pos), Variable(" UNNAMED321")(pos))(pos))(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+-------------------------------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -425,7 +425,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression(HasLabels(Variable("x")(pos), Seq(ASTLabelName("Artist")(pos)))(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+----------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -443,7 +443,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression(FunctionInvocation(FunctionName("length")(pos), Variable("n")(pos))(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+-----------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -461,7 +461,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression(Variable(" id@23")(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set(" n@76")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set(" n@76")) val details = renderAsTreeTable(plan) details should equal( @@ -482,7 +482,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression(Variable(" id@23")(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set("n")) + val plan = PlanDescriptionImpl(id, "NAME", NoChildren, arguments, Set("n")) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+-------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -494,7 +494,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("round estimated rows to int") { val planDescr1 = PlanDescriptionImpl( - LogicalPlanId.DEFAULT, + id, "NodeByLabelScan", NoChildren, Seq( @@ -502,7 +502,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { EstimatedRows(0.00123456789)), Set("n")) val planDescr2 = PlanDescriptionImpl( - LogicalPlanId.DEFAULT, + id, "NodeByLabelScan", NoChildren, Seq( @@ -534,7 +534,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression( Property(Variable( "x" )(pos), PropertyKeyName("Artist")(pos))(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl( LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set( "n") ) + val plan = PlanDescriptionImpl( id, "NAME", NoChildren, arguments, Set( "n") ) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+----------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -551,7 +551,7 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { Expression( FunctionInvocation(FunctionName("exists")(pos), Property(Variable("x")(pos), PropertyKeyName("prop")(pos))(pos))(pos)), EstimatedRows(1)) - val plan = PlanDescriptionImpl( LogicalPlanId.DEFAULT, "NAME", NoChildren, arguments, Set( "n") ) + val plan = PlanDescriptionImpl( id, "NAME", NoChildren, arguments, Set( "n") ) renderAsTreeTable(plan) should equal( """+----------+----------------+------+---------+-----------+----------------+ || Operator | Estimated Rows | Rows | DB Hits | Variables | Other | @@ -562,9 +562,9 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("don't show unnamed variables in key names") { - val sr1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "EmptyRow", NoChildren, Seq(EstimatedRows(1)), Set.empty) - val sr2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "EmptyRow", NoChildren, Seq(EstimatedRows(1)), Set.empty) - val description = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NodeHashJoin", TwoChildren(sr1, sr2), Seq(EstimatedRows + val sr1 = PlanDescriptionImpl(id, "EmptyRow", NoChildren, Seq(EstimatedRows(1)), Set.empty) + val sr2 = PlanDescriptionImpl(id, "EmptyRow", NoChildren, Seq(EstimatedRows(1)), Set.empty) + val description = PlanDescriptionImpl(id, "NodeHashJoin", TwoChildren(sr1, sr2), Seq(EstimatedRows (42)), Set("a", " UNNAMED45", " FRESHID77")) @@ -598,8 +598,8 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { */ test("compact two identical nodes") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, Set()) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+----------+ @@ -611,8 +611,8 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("compact two similar nodes with variables") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set("a")) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, Set("b")) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set("a")) + val plan = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, Set("b")) renderAsTreeTable(plan) should equal( """+----------+-----------+ @@ -624,10 +624,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("compact two pairs of similar nodes with variables") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set("a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, Set("b")) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq.empty, Set("c")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq.empty, Set("d")) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set("a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, Set("b")) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq.empty, Set("c")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq.empty, Set("d")) renderAsTreeTable(p3) should equal( """+--------------+-----------+ @@ -641,10 +641,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("compact two pairs of similar nodes with same variables") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set("a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, Set("b")) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq.empty, Set("a")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq.empty, Set("b")) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set("a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, Set("b")) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq.empty, Set("a")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq.empty, Set("b")) renderAsTreeTable(p3) should equal( """+--------------+-----------+ @@ -658,10 +658,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("compact two pairs of similar nodes with one new variable") { - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set("a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, Set("b")) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq.empty, Set("a")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq.empty, Set("b", "c")) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set("a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, Set("b")) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq.empty, Set("a")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq.empty, Set("b", "c")) renderAsTreeTable(p3) should equal( """+--------------+-----------+ @@ -677,10 +677,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("compact two pairs of similar nodes with many repeating variables") { val repeating = ('b' to 'z').toSet[Char].map(c => s"var_$c") - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq.empty, Set("var_a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, repeating) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq.empty, Set("var_a")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq.empty, repeating + "var_A" + "var_B") + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq.empty, Set("var_a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, repeating) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq.empty, Set("var_a")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq.empty, repeating + "var_A" + "var_B") renderAsTreeTable(p3) should equal( """+--------------+--------------------------------------------------------------------------------------------------+ @@ -696,10 +696,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { test("compact only the sufficiently similar pair of two simular pairs of nodes with many repeating variables") { val repeating = ('b' to 'z').toSet[Char].map(c => s"var_$c") - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(LabelName("123")), Set("var_a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq.empty, repeating) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq.empty, repeating + "var_A" + "var_B") - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq.empty, Set("var_a")) + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(LabelName("123")), Set("var_a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq.empty, repeating) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq.empty, repeating + "var_A" + "var_B") + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq.empty, Set("var_a")) renderAsTreeTable(p3) should equal( """+--------------+--------------------------------------------------------------------------------------------------+-------+ @@ -720,10 +720,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { val t = Time(12345678) val r = Rows(2) val d = DbHits(2) - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(l, t, r, d), Set("var_a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq(t, r, d), repeating) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq(t, r, d), Set("var_a")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq(t, r, d), repeating + "var_A" + + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(l, t, r, d), Set("var_a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq(t, r, d), repeating) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq(t, r, d), Set("var_a")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq(t, r, d), repeating + "var_A" + "var_B") renderAsTreeTable(p3) should equal( @@ -745,10 +745,10 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { val t = Time(12345678) val r = Rows(2) val d = DbHits(2) - val leaf = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(l, t, r, d), Set("var_a")) - val p1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf), Seq(l, t, r, d), repeating) - val p2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p1), Seq(l, t, r, d), Set("var_a")) - val p3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "OPERATOR", SingleChild(p2), Seq(l, t, r, d), repeating + "var_A" + + val leaf = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(l, t, r, d), Set("var_a")) + val p1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf), Seq(l, t, r, d), repeating) + val p2 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p1), Seq(l, t, r, d), Set("var_a")) + val p3 = PlanDescriptionImpl(id, "OPERATOR", SingleChild(p2), Seq(l, t, r, d), repeating + "var_A" + "var_B") renderAsTreeTable(p3) should equal( @@ -767,19 +767,19 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("no compaction on complex plan with no repeated names") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("a")) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("b")) - val leaf3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("c")) - val leaf4 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "LEAF", NoChildren, Seq(), Set("d")) - val branch1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "BRANCH", SingleChild(leaf1), Seq.empty, Set("a")) - val branch2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "BRANCH", SingleChild(leaf2), Seq.empty, Set("b")) - val branch3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "BRANCH", SingleChild(leaf3), Seq.empty, Set("c")) - val branch4 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "BRANCH", SingleChild(leaf4), Seq.empty, Set("d")) - val intermediate1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", TwoChildren(branch1, branch2), Seq.empty, + val leaf1 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("a")) + val leaf2 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("b")) + val leaf3 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("c")) + val leaf4 = PlanDescriptionImpl(id, "LEAF", NoChildren, Seq(), Set("d")) + val branch1 = PlanDescriptionImpl(id, "BRANCH", SingleChild(leaf1), Seq.empty, Set("a")) + val branch2 = PlanDescriptionImpl(id, "BRANCH", SingleChild(leaf2), Seq.empty, Set("b")) + val branch3 = PlanDescriptionImpl(id, "BRANCH", SingleChild(leaf3), Seq.empty, Set("c")) + val branch4 = PlanDescriptionImpl(id, "BRANCH", SingleChild(leaf4), Seq.empty, Set("d")) + val intermediate1 = PlanDescriptionImpl(id, "INTERMEDIATE", TwoChildren(branch1, branch2), Seq.empty, Set()) - val intermediate2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "INTERMEDIATE", TwoChildren(branch3, branch4), Seq.empty, + val intermediate2 = PlanDescriptionImpl(id, "INTERMEDIATE", TwoChildren(branch3, branch4), Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "ROOT", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "ROOT", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+-----------------+-----------+ @@ -811,17 +811,17 @@ class RenderTreeTableTest extends CypherFunSuite with BeforeAndAfterAll { } test("compaction on complex plan with repeated names") { - val leaf1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(), Set()) - val leaf2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(), Set()) - val leaf3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(), Set()) - val leaf4 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", NoChildren, Seq(), Set()) - val branch1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf1), Seq.empty, Set()) - val branch2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf2), Seq.empty, Set()) - val branch3 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf3), Seq.empty, Set()) - val branch4 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", SingleChild(leaf4), Seq.empty, Set()) - val intermediate1 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", TwoChildren(branch1, branch2), Seq.empty, Set()) - val intermediate2 = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", TwoChildren(branch3, branch4), Seq.empty, Set()) - val plan = PlanDescriptionImpl(LogicalPlanId.DEFAULT, "NODE", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) + val leaf1 = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(), Set()) + val leaf2 = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(), Set()) + val leaf3 = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(), Set()) + val leaf4 = PlanDescriptionImpl(id, "NODE", NoChildren, Seq(), Set()) + val branch1 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf1), Seq.empty, Set()) + val branch2 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf2), Seq.empty, Set()) + val branch3 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf3), Seq.empty, Set()) + val branch4 = PlanDescriptionImpl(id, "NODE", SingleChild(leaf4), Seq.empty, Set()) + val intermediate1 = PlanDescriptionImpl(id, "NODE", TwoChildren(branch1, branch2), Seq.empty, Set()) + val intermediate2 = PlanDescriptionImpl(id, "NODE", TwoChildren(branch3, branch4), Seq.empty, Set()) + val plan = PlanDescriptionImpl(id, "NODE", TwoChildren(intermediate1, intermediate2), Seq.empty, Set()) renderAsTreeTable(plan) should equal( """+--------------+ diff --git a/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/Rewritable.scala b/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/Rewritable.scala index 670b54d3ffe2b..4216ad7491685 100644 --- a/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/Rewritable.scala +++ b/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/Rewritable.scala @@ -53,11 +53,6 @@ object Rewritable { def dup(children: Seq[AnyRef]): AnyRef = try { that match { - case a: RewritableWithMemory => - val result = a.dup(children) - result.rememberMe(a) - result - case a: Rewritable => a.dup(children) case p: Product => @@ -90,10 +85,6 @@ object Rewritable { implicit class DuplicatableProduct(val product: Product) extends AnyVal { def dup(children: Seq[AnyRef]): Product = product match { - case a: RewritableWithMemory => - val result = a.dup(children) - result.rememberMe(a) - result case a: Rewritable => a.dup(children) case _ => @@ -123,28 +114,16 @@ object Rewritable { implicit class RewritableAny[T <: AnyRef](val that: T) extends AnyVal { def rewrite(rewriter: Rewriter): AnyRef = { val result = rewriter.apply(that) - if (that.isInstanceOf[RewritableWithMemory]) { - val withMemory = result.asInstanceOf[RewritableWithMemory] - withMemory.rememberMe(that) - } result } def rewrite(rewriter: RewriterWithArgs, args: Seq[AnyRef]): AnyRef = { val result = rewriter.apply((that, args)) - if (that.isInstanceOf[RewritableWithMemory]) { - val withMemory = result.asInstanceOf[RewritableWithMemory] - withMemory.rememberMe(that) - } result } def endoRewrite(rewriter: Rewriter): T = rewrite(rewriter).asInstanceOf[T] } - - trait RewritableWithMemory extends Rewritable { - def rememberMe(old: AnyRef): Unit - } } case class TypedRewriter[T <: Rewritable](rewriter: Rewriter) extends (T => T) { @@ -298,4 +277,4 @@ object bottomUpWithArgs { def apply(rewriter: RewriterWithArgs, stopper: (AnyRef) => Boolean = _ => false): RewriterWithArgs = new BottomUpWithArgsRewriter(rewriter, stopper) -} \ No newline at end of file +} diff --git a/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/attribution/Ids.scala b/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/attribution/Ids.scala index a4f91345d6e7f..d3e7e681f3af1 100644 --- a/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/attribution/Ids.scala +++ b/community/cypher/util-3.4/src/main/scala/org/neo4j/cypher/internal/util/v3_4/attribution/Ids.scala @@ -26,7 +26,7 @@ trait IdGen { def id(): Id } -object SequentialIdGen extends IdGen { +class SequentialIdGen() extends IdGen { var i = 0 def id(): Id = { diff --git a/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/QueryExecutionTracer.java b/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/QueryExecutionTracer.java index 34097dba8afa0..b1a4cb89bf28e 100644 --- a/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/QueryExecutionTracer.java +++ b/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/QueryExecutionTracer.java @@ -20,11 +20,11 @@ package org.neo4j.cypher.internal.v3_4.codegen; import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.QueryExecutionEvent; -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId; +import org.neo4j.cypher.internal.util.v3_4.attribution.Id; public interface QueryExecutionTracer { - QueryExecutionEvent executeOperator( LogicalPlanId queryId ); + QueryExecutionEvent executeOperator( Id queryId ); QueryExecutionTracer NONE = queryId -> QueryExecutionEvent.NONE; } diff --git a/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracer.java b/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracer.java index b03f9c8fc71c0..2be5c286dd881 100644 --- a/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracer.java +++ b/enterprise/cypher/cypher/src/main/java/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracer.java @@ -24,8 +24,8 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.QueryExecutionEvent; import org.neo4j.cypher.internal.planner.v3_4.spi.KernelStatisticProvider; +import org.neo4j.cypher.internal.util.v3_4.attribution.Id; import org.neo4j.cypher.internal.v3_4.codegen.QueryExecutionTracer; -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId; import org.neo4j.helpers.MathUtil; public class ProfilingTracer implements QueryExecutionTracer @@ -54,7 +54,7 @@ public interface Clock private final Clock clock; private final KernelStatisticProvider statisticProvider; - private final Map data = new HashMap<>(); + private final Map data = new HashMap<>(); public ProfilingTracer( KernelStatisticProvider statisticProvider ) { @@ -67,29 +67,29 @@ public ProfilingTracer( KernelStatisticProvider statisticProvider ) this.statisticProvider = statisticProvider; } - public ProfilingInformation get( LogicalPlanId query ) + public ProfilingInformation get( Id query ) { Data value = data.get( query ); return value == null ? ZERO : value; } - public long timeOf( LogicalPlanId query ) + public long timeOf( Id query ) { return get( query ).time(); } - public long dbHitsOf( LogicalPlanId query ) + public long dbHitsOf( Id query ) { return get( query ).dbHits(); } - public long rowsOf( LogicalPlanId query ) + public long rowsOf( Id query ) { return get( query ).rows(); } @Override - public QueryExecutionEvent executeOperator( LogicalPlanId queryId ) + public QueryExecutionEvent executeOperator( Id queryId ) { Data data = this.data.get( queryId ); if ( data == null && queryId != null ) diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/BuildVectorizedExecutionPlan.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/BuildVectorizedExecutionPlan.scala index 65d336c3598f1..2e201effcb6db 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/BuildVectorizedExecutionPlan.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/BuildVectorizedExecutionPlan.scala @@ -44,7 +44,8 @@ import org.neo4j.cypher.internal.runtime.vectorized.dispatcher.{Dispatcher, Sing import org.neo4j.cypher.internal.runtime.vectorized.{Pipeline, PipelineBuilder} import org.neo4j.cypher.internal.runtime.{QueryStatistics, _} import org.neo4j.cypher.internal.util.v3_4.TaskCloser -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id +import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlan import org.neo4j.cypher.result.QueryResult.QueryResultVisitor import org.neo4j.graphdb._ import org.neo4j.values.virtual.MapValue @@ -94,7 +95,7 @@ object BuildVectorizedExecutionPlan extends Phase[EnterpriseRuntimeContext, Logi case class VectorizedExecutionPlan(plannerUsed: PlannerName, operators: Pipeline, - slots: Map[LogicalPlanId, SlotConfiguration], + slots: Map[Id, SlotConfiguration], physicalPlan: LogicalPlan, fieldNames: Array[String], dispatcher: Dispatcher, diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/DebugPrettyPrinter.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/DebugPrettyPrinter.scala index 8b470b9d5799f..2ac210ceb56d7 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/DebugPrettyPrinter.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/DebugPrettyPrinter.scala @@ -23,8 +23,9 @@ import org.bitbucket.inkytonik.kiama.output.PrettyPrinter._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration import org.neo4j.cypher.internal.compatibility.v3_4.runtime.executionplan.PipeInfo import org.neo4j.cypher.internal.compiler.v3_4.phases.LogicalPlanState +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{CypherException, InternalException} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId} +import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlan trait DebugPrettyPrinter { val PRINT_QUERY_TEXT = true @@ -52,7 +53,7 @@ trait DebugPrettyPrinter { println("\u001b[30m") } - protected def printPipeInfo(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], pipeInfo: PipeInfo) = { + protected def printPipeInfo(slotConfigurations: Map[Id, SlotConfiguration], pipeInfo: PipeInfo) = { if (PRINT_PIPELINE_INFO) { println(s"\n\u001b[36m[SLOT CONFIGURATIONS]\n") // Cyan prettyPrintPipelines(slotConfigurations) @@ -76,26 +77,26 @@ trait DebugPrettyPrinter { val planAnsiPre = "\u001b[1m\u001b[35m" // Bold on + magenta val planAnsiPost = "\u001b[21m\u001b[35m" // Restore to bold off + magenta def prettyPlanName(plan: LogicalPlan) = s"$planAnsiPre${plan.productPrefix}$planAnsiPost" - def prettyId(id: LogicalPlanId) = s"\u001b[4m\u001b[35m${id}\u001b[24m\u001b[35m" // Underlined + magenta + def prettyId(id: Id) = s"\u001b[4m\u001b[35m${id}\u001b[24m\u001b[35m" // Underlined + magenta def show(v: Any): Doc = link(v.asInstanceOf[AnyRef], v match { - case id: LogicalPlanId => + case id: Id => text(prettyId(id)) case plan: LogicalPlan => (plan.lhs, plan.rhs) match { case (None, None) => val elements = plan.productIterator.toList - list(plan.assignedId :: elements, prettyPlanName(plan), show) + list(plan.id :: elements, prettyPlanName(plan), show) case (Some(lhs), None) => val otherElements: List[Any] = plan.productIterator.toList.filter { case e: AnyRef => e ne lhs case _ => true } - list(plan.assignedId :: otherElements, prettyPlanName(plan), show) <> + list(plan.id :: otherElements, prettyPlanName(plan), show) <> line <> show(lhs) case (Some(lhs), Some(rhs)) => @@ -104,8 +105,8 @@ trait DebugPrettyPrinter { case _ => true } val lhsDoc = "[LHS]" <> line <> nest(show(lhs), 2) - val rhsDoc = s"[RHS of ${plan.getClass.getSimpleName} (${plan.assignedId})]" <> line <> nest(show(rhs), 2) - list(plan.assignedId :: otherElements, prettyPlanName(plan), show) <> + val rhsDoc = s"[RHS of ${plan.getClass.getSimpleName} (${plan.id})]" <> line <> nest(show(rhs), 2) + list(plan.id :: otherElements, prettyPlanName(plan), show) <> line <> nest(lhsDoc, 2) <> line <> nest(rhsDoc, 2) @@ -122,9 +123,9 @@ trait DebugPrettyPrinter { println(prettyDoc.layout) } - protected def prettyPrintPipelines(pipelines: Map[LogicalPlanId, SlotConfiguration]): Unit = { + protected def prettyPrintPipelines(pipelines: Map[Id, SlotConfiguration]): Unit = { val transformedPipelines = pipelines.foldLeft(Seq.empty[Any]) { - case (acc, (k: LogicalPlanId, v)) => acc :+ (k.underlying -> v) + case (acc, (k: Id, v)) => acc :+ (k.x -> v) }.sortBy { case (k: Int, _) => k } val prettyDoc = pretty(any(transformedPipelines), w = 120) println(prettyDoc.layout) diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenContext.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenContext.scala index d4c5db676341a..327e1f6c84024 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenContext.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenContext.scala @@ -22,8 +22,9 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen import org.neo4j.cypher.InternalException import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.ir.JoinData import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.ir.expressions.CodeGenType -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId} +import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlan import org.neo4j.cypher.internal.frontend.v3_4.semantics.SemanticTable +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import scala.collection.mutable @@ -36,7 +37,7 @@ class CodeGenContext(val semanticTable: SemanticTable, private val projectedVariables: mutable.Map[String, Variable] = mutable.Map.empty private val probeTables: mutable.Map[CodeGenPlan, JoinData] = mutable.Map() private val parents: mutable.Stack[CodeGenPlan] = mutable.Stack() - val operatorIds: mutable.Map[LogicalPlanId, String] = mutable.Map() + val operatorIds: mutable.Map[Id, String] = mutable.Map() def addVariable(queryVariable: String, variable: Variable) { //assert(!variables.isDefinedAt(queryVariable)) // TODO: Make the cases where overwriting the value is ok explicit (by using updateVariable) @@ -90,7 +91,7 @@ class CodeGenContext(val semanticTable: SemanticTable, def popParent(): CodeGenPlan = parents.pop() def registerOperator(plan: LogicalPlan): String = { - operatorIds.getOrElseUpdate(plan.assignedId, namer.newOpName(plan.getClass.getSimpleName)) + operatorIds.getOrElseUpdate(plan.id, namer.newOpName(plan.getClass.getSimpleName)) } } diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenerator.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenerator.scala index e88a981b17400..9d16229b4de91 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenerator.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/CodeGenerator.scala @@ -35,10 +35,11 @@ import org.neo4j.cypher.internal.planner.v3_4.spi.{InstrumentedGraphStatistics, import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription.Arguments.{Runtime, RuntimeImpl} import org.neo4j.cypher.internal.runtime.{ExecutionMode, InternalExecutionResult, QueryContext} import org.neo4j.cypher.internal.runtime.planDescription.{InternalPlanDescription, LogicalPlan2PlanDescription} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{Eagerly, TaskCloser} import org.neo4j.cypher.internal.v3_4.codegen.QueryExecutionTracer import org.neo4j.cypher.internal.v3_4.executionplan.{GeneratedQuery, GeneratedQueryExecution} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId, ProduceResult} +import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, ProduceResult} import org.neo4j.values.virtual.MapValue class CodeGenerator(val structure: CodeStructure[GeneratedQuery], clock: Clock, conf: CodeGenConfiguration = CodeGenConfiguration() ) { @@ -99,7 +100,7 @@ class CodeGenerator(val structure: CodeStructure[GeneratedQuery], clock: Clock, implicit val context = new CodeGenContext(semantics, lookup) val (_, instructions) = asCodeGenPlan(plan).produce(context) generateCode(structure)(instructions, context.operatorIds.map { - case (id: LogicalPlanId, field: String) => field -> id + case (id: Id, field: String) => field -> id }.toMap, columns, conf) } @@ -124,7 +125,7 @@ object CodeGenerator { type SourceSink = Option[(String, String) => Unit] def generateCode[T](structure: CodeStructure[T])(instructions: Seq[Instruction], - operatorIds: Map[String, LogicalPlanId], + operatorIds: Map[String, Id], columns: Seq[String], conf: CodeGenConfiguration)(implicit context: CodeGenContext): CodeStructureResult[T] = { structure.generateQuery(Namer.newClassName(), columns, operatorIds, conf) { accept => diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/spi/CodeStructure.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/spi/CodeStructure.scala index 8235524c32297..1d9216b93a97a 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/spi/CodeStructure.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/compiled/codegen/spi/CodeStructure.scala @@ -20,12 +20,12 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.spi import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.{CodeGenConfiguration, CodeGenContext} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id /** * This constitutes the SPI for code generation. */ trait CodeStructure[T] { - def generateQuery(className: String, columns: Seq[String], operatorIds: Map[String, LogicalPlanId], conf: CodeGenConfiguration) + def generateQuery(className: String, columns: Seq[String], operatorIds: Map[String, Id], conf: CodeGenConfiguration) (block: MethodStructure[_] => Unit)(implicit codeGenContext: CodeGenContext): CodeStructureResult[T] } diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala index 83500d3166fd7..c2e25db2ed8f4 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedMethodStructure.scala @@ -36,12 +36,12 @@ import org.neo4j.cypher.internal.runtime.interpreted.commands.convert.DirectionC import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.ir.expressions.{BoolType, CodeGenType, CypherCodeGenType, FloatType, ListReferenceType, LongType, ReferenceType, RepresentationType, Parameter => _} import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.spi._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.{CodeGenContext, QueryExecutionEvent} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.internal.compiler.v3_4.spi.{NodeIdWrapper, RelationshipIdWrapper} import org.neo4j.cypher.internal.frontend.v3_4.helpers._ import org.neo4j.cypher.internal.spi.v3_4.codegen.GeneratedMethodStructure.CompletableFinalizer import org.neo4j.cypher.internal.spi.v3_4.codegen.Methods._ import org.neo4j.cypher.internal.spi.v3_4.codegen.Templates._ +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection import org.neo4j.graphdb.{Direction, Node, Relationship} import org.neo4j.internal.kernel.api.IndexQuery @@ -369,7 +369,7 @@ class GeneratedMethodStructure(val fields: Fields, val generator: CodeBlock, aux private def traceEvent(planStepId: String) = invoke(tracer, executeOperator, - getStatic(FieldReference.staticField(generator.owner(), typeRef[LogicalPlanId], planStepId))) + getStatic(FieldReference.staticField(generator.owner(), typeRef[Id], planStepId))) override def incrementDbHits() = if (tracing) generator.expression(invoke(loadEvent, Methods.dbHit)) diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedQueryStructure.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedQueryStructure.scala index 690ed007b96fe..6d1dbdc602b52 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedQueryStructure.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/GeneratedQueryStructure.scala @@ -35,11 +35,11 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.ir.expressions._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.spi.{CodeStructure, CodeStructureResult, MethodStructure} import org.neo4j.cypher.internal.compatibility.v3_4.runtime.executionplan.{Completable, Provider} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.internal.frontend.v3_4.helpers.using import org.neo4j.cypher.internal.javacompat.ResultRecord import org.neo4j.cypher.internal.runtime.{ExecutionMode, QueryContext} import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.codegen.QueryExecutionTracer import org.neo4j.cypher.internal.v3_4.executionplan.{GeneratedQuery, GeneratedQueryExecution} import org.neo4j.cypher.result.QueryResult.QueryResultVisitor @@ -96,7 +96,7 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] { override def generateQuery(className: String, columns: Seq[String], - operatorIds: Map[String, LogicalPlanId], + operatorIds: Map[String, Id], conf: CodeGenConfiguration) (methodStructure: MethodStructure[_] => Unit) (implicit codeGenContext: CodeGenContext): GeneratedQueryStructureResult = { @@ -185,9 +185,9 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] { clazz.generate(Templates.FIELD_NAMES) } - private def setOperatorIds(clazz: ClassGenerator, operatorIds: Map[String, LogicalPlanId]) = { + private def setOperatorIds(clazz: ClassGenerator, operatorIds: Map[String, Id]) = { operatorIds.keys.foreach { opId => - clazz.staticField(typeRef[LogicalPlanId], opId) + clazz.staticField(typeRef[Id], opId) } } diff --git a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala index f076f4fac4027..581d309fbbaaf 100644 --- a/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala +++ b/enterprise/cypher/cypher/src/main/scala/org/neo4j/cypher/internal/spi/v3_4/codegen/Methods.scala @@ -27,8 +27,8 @@ import org.neo4j.cypher.internal.codegen._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.QueryExecutionEvent import org.neo4j.cypher.internal.compiler.v3_4.spi.{NodeIdWrapper, RelationshipIdWrapper} import org.neo4j.cypher.internal.javacompat.ResultRecord +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.codegen.QueryExecutionTracer -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.cypher.result.QueryResult.{QueryResultVisitor, Record} import org.neo4j.graphdb.Direction import org.neo4j.helpers.collection.MapUtil @@ -105,7 +105,7 @@ object Methods { val relId = method[RelationshipIdWrapper, Long]("id") val set = method[ResultRecord, Unit]("set", typeRef[Int], typeRef[AnyValue]) val visit = method[QueryResultVisitor[_], Boolean]("visit", typeRef[Record]) - val executeOperator = method[QueryExecutionTracer, QueryExecutionEvent]("executeOperator", typeRef[LogicalPlanId]) + val executeOperator = method[QueryExecutionTracer, QueryExecutionEvent]("executeOperator", typeRef[Id]) val dbHit = method[QueryExecutionEvent, Unit]("dbHit") val row = method[QueryExecutionEvent, Unit]("row") val unboxInteger = method[java.lang.Integer, Int]("intValue") diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/BuildCompiledExecutionPlanTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/BuildCompiledExecutionPlanTest.scala index 584e4e2bf8df2..b868a2fbd6512 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/BuildCompiledExecutionPlanTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/BuildCompiledExecutionPlanTest.scala @@ -36,7 +36,7 @@ import org.neo4j.kernel.monitoring.Monitors class BuildCompiledExecutionPlanTest extends CypherFunSuite { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() private val solved = CardinalityEstimation.lift(RegularPlannerQuery(QueryGraph.empty), 0.0) @@ -66,7 +66,6 @@ class BuildCompiledExecutionPlanTest extends CypherFunSuite { } private def process(monitors: WrappedMonitors, plan: LogicalPlan) = { - plan.assignIds() val context = codegen.CompiledRuntimeContextHelper.create( monitors = monitors, planContext = new NotImplementedPlanContext { diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/CodeGeneratorTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/CodeGeneratorTest.scala index 3d2c377092ba4..c314972a2170e 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/CodeGeneratorTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/CodeGeneratorTest.scala @@ -1560,7 +1560,6 @@ abstract class CodeGeneratorTest extends CypherFunSuite with LogicalPlanningTest private def param(values: (String,AnyRef)*): MapValue = ValueUtils.asMapValue(values.toMap.asJava) private def compile(plan: LogicalPlan) = { - plan.assignIds() generator.generate(plan, newMockedPlanContext, semanticTable, CostBasedPlannerName.default) } diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/BuildProbeTableInstructionsTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/BuildProbeTableInstructionsTest.scala index 8c490ca7a20fd..9a6305465cedb 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/BuildProbeTableInstructionsTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/BuildProbeTableInstructionsTest.scala @@ -34,8 +34,8 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.compiled.codegen.{Co import org.neo4j.cypher.internal.frontend.v3_4.semantics.SemanticTable import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.runtime.interpreted.TransactionalContextWrapper +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.graphdb.Node import org.neo4j.kernel.api.ReadOperations import org.neo4j.kernel.impl.core.{NodeManager, NodeProxy} @@ -206,7 +206,7 @@ class BuildProbeTableInstructionsTest extends CypherFunSuite with CodeGenSugar { private def runTest(buildInstruction: BuildProbeTable, nodes: Set[Variable]): List[Map[String, Object]] = { val instructions = buildProbeTableWithTwoAllNodeScans(buildInstruction, nodes) - val ids: Map[String, LogicalPlanId] = instructions.flatMap(_.allOperatorIds.map(id => id -> LogicalPlanId.DEFAULT)).toMap + val ids: Map[String, Id] = instructions.flatMap(_.allOperatorIds.map(id => id -> Id.INVALID_ID)).toMap evaluate(instructions, queryContext, Seq(resultRowKey), EMPTY_MAP, ids) } diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CodeGenSugar.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CodeGenSugar.scala index 169c420ebbd90..750e1fa8cb312 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CodeGenSugar.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CodeGenSugar.scala @@ -35,9 +35,10 @@ import org.neo4j.cypher.internal.runtime.{ExecutionMode, InternalExecutionResult import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription import org.neo4j.cypher.internal.spi.v3_4.codegen.GeneratedQueryStructure import org.neo4j.cypher.internal.util.v3_4.TaskCloser +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.codegen.QueryExecutionTracer import org.neo4j.cypher.internal.v3_4.executionplan.{GeneratedQuery, GeneratedQueryExecution} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId} +import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlan import org.neo4j.graphdb.GraphDatabaseService import org.neo4j.graphdb.Result.{ResultRow, ResultVisitor} import org.neo4j.internal.kernel.api.Transaction.Type @@ -97,7 +98,7 @@ trait CodeGenSugar extends MockitoSugar { qtx: QueryContext = mockQueryContext(), columns: Seq[String] = Seq.empty, params: MapValue = EMPTY_MAP, - operatorIds: Map[String, LogicalPlanId] = Map.empty): List[Map[String, Object]] = { + operatorIds: Map[String, Id] = Map.empty): List[Map[String, Object]] = { val clazz = compile(instructions, columns, operatorIds) val result = newInstance(clazz, queryContext = qtx, params = params) evaluate(result) @@ -118,7 +119,7 @@ trait CodeGenSugar extends MockitoSugar { def codeGenConfiguration = CodeGenConfiguration(mode = ByteCodeMode) def compile(instructions: Seq[Instruction], columns: Seq[String], - operatorIds: Map[String, LogicalPlanId] = Map.empty): GeneratedQuery = { + operatorIds: Map[String, Id] = Map.empty): GeneratedQuery = { //In reality the same namer should be used for construction Instruction as in generating code //these tests separate the concerns so we give this namer non-standard prefixes CodeGenerator.generateCode(GeneratedQueryStructure)(instructions, operatorIds, columns, codeGenConfiguration)( @@ -139,7 +140,7 @@ trait CodeGenSugar extends MockitoSugar { new CompiledExecutionResult(taskCloser, queryContext, generated, provider) } - def insertStatic(clazz: Class[GeneratedQueryExecution], mappings: (String, LogicalPlanId)*) = mappings.foreach { + def insertStatic(clazz: Class[GeneratedQueryExecution], mappings: (String, Id)*) = mappings.foreach { case (name, id) => setStaticField(clazz, name, id.asInstanceOf[AnyRef]) } diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CompiledProfilingTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CompiledProfilingTest.scala index 008f638b887b0..16481cbf972c8 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CompiledProfilingTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/compiled_runtime/v3_4/codegen/ir/CompiledProfilingTest.scala @@ -34,7 +34,7 @@ import org.neo4j.cypher.internal.runtime.planDescription.InternalPlanDescription import org.neo4j.cypher.internal.runtime.planDescription.{InternalPlanDescription, NoChildren, PlanDescriptionImpl, SingleChild} import org.neo4j.cypher.internal.runtime.{ProfileMode, QueryContext, QueryTransactionalContext} import org.neo4j.cypher.internal.util.v3_4.Cardinality -import org.neo4j.cypher.internal.util.v3_4.attribution.SequentialIdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, SequentialIdGen} import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite import org.neo4j.cypher.internal.v3_4.codegen.profiling.ProfilingTracer import org.neo4j.cypher.internal.v3_4.expressions.SignedDecimalIntegerLiteral @@ -49,18 +49,18 @@ import org.neo4j.test.TestGraphDatabaseFactory class CompiledProfilingTest extends CypherFunSuite with CodeGenSugar { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() test("should count db hits and rows") { // given - val id1 = new LogicalPlanId(0) - val id2 = new LogicalPlanId(1) + val id1 = new Id(0) + val id2 = new Id(1) val variable = Variable("name", CodeGenType.primitiveNode) val projectNode = NodeProjection(variable) val compiled = compile(Seq(WhileLoop(variable, ScanAllNodes("OP1"), AcceptVisitor("OP2", Map("n" -> projectNode)))), - Seq("n"), Map("OP1" -> id1, "OP2" -> id2, "X" -> LogicalPlanId.DEFAULT)) + Seq("n"), Map("OP1" -> id1, "OP2" -> id2, "X" -> Id.INVALID_ID)) val readOps = mock[ReadOperations] val entityAccessor = mock[NodeManager] @@ -118,7 +118,6 @@ class CompiledProfilingTest extends CypherFunSuite with CodeGenSugar { val join = NodeHashJoin(Set(IdName("a")), lhs, rhs)(solved) val projection = plans.Projection(join, Map("foo" -> SignedDecimalIntegerLiteral("1")(null)))(solved) val plan = plans.ProduceResult(projection, List("foo")) - plan.assignIds() // when val result = compileAndExecute(plan, graphDb, mode = ProfileMode) diff --git a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracerTest.scala b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracerTest.scala index b28314f778503..43bd3498cad84 100644 --- a/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracerTest.scala +++ b/enterprise/cypher/cypher/src/test/scala/org/neo4j/cypher/internal/v3_4/codegen/profiling/ProfilingTracerTest.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.v3_4.codegen.profiling import org.neo4j.cypher.internal.planner.v3_4.spi.{EmptyKernelStatisticProvider, KernelStatisticProvider} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite import org.neo4j.io.pagecache.tracing.cursor.DefaultPageCursorTracer @@ -35,10 +35,12 @@ class ProfilingTracerTest extends CypherFunSuite { } } + val id = Id.INVALID_ID + test("shouldReportExecutionTimeOfQueryExecution") { // given val clock = new Clock - val operatorId = new LogicalPlanId(0) + val operatorId = id val tracer = new ProfilingTracer(clock, EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) @@ -53,7 +55,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("multiple uses of the same Id should aggregate spent time") { // given val clock = new Clock - val operatorId = new LogicalPlanId(0) + val operatorId = id val tracer = new ProfilingTracer(clock, EmptyKernelStatisticProvider) // when @@ -71,7 +73,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("shouldReportDbHitsOfQueryExecution") { // given - val operatorId = new LogicalPlanId(0) + val operatorId = id val tracer = new ProfilingTracer(EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) @@ -88,7 +90,7 @@ class ProfilingTracerTest extends CypherFunSuite { test("shouldReportRowsOfQueryExecution") { // given - val operatorId = new LogicalPlanId(0) + val operatorId = id val tracer = new ProfilingTracer(EmptyKernelStatisticProvider) val event = tracer.executeOperator(operatorId) @@ -105,7 +107,7 @@ class ProfilingTracerTest extends CypherFunSuite { } test("report page cache hits as part of profiling statistics") { - val operatorId = new LogicalPlanId(0) + val operatorId = id val cursorTracer = new DefaultPageCursorTracer val tracer = new ProfilingTracer(new DelegatingKernelStatisticProvider(cursorTracer)) val event = tracer.executeOperator(operatorId) @@ -124,7 +126,7 @@ class ProfilingTracerTest extends CypherFunSuite { } test("report page cache misses as part of profiling statistics") { - val operatorId = new LogicalPlanId(0) + val operatorId = id val cursorTracer = new DefaultPageCursorTracer val tracer = new ProfilingTracer(new DelegatingKernelStatisticProvider(cursorTracer)) val event = tracer.executeOperator(operatorId) diff --git a/enterprise/cypher/morsel-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/vectorized/PipelineBuilder.scala b/enterprise/cypher/morsel-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/vectorized/PipelineBuilder.scala index 735f4275ead3b..48c148ec65ffa 100644 --- a/enterprise/cypher/morsel-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/vectorized/PipelineBuilder.scala +++ b/enterprise/cypher/morsel-runtime/src/main/scala/org/neo4j/cypher/internal/runtime/vectorized/PipelineBuilder.scala @@ -20,7 +20,7 @@ package org.neo4j.cypher.internal.runtime.vectorized import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedPipeBuilder.translateColumnOrder -import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{SlotConfiguration, RefSlot} +import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{RefSlot, SlotConfiguration} import org.neo4j.cypher.internal.compiler.v3_4.planner.CantCompileQueryException import org.neo4j.cypher.internal.frontend.v3_4.semantics.SemanticTable import org.neo4j.cypher.internal.ir.v3_4.IdName @@ -28,10 +28,11 @@ import org.neo4j.cypher.internal.runtime.interpreted.commands.convert.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.LazyTypes import org.neo4j.cypher.internal.runtime.vectorized.operators._ import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.logical.plans import org.neo4j.cypher.internal.v3_4.logical.plans._ -class PipelineBuilder(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], converters: ExpressionConverters) +class PipelineBuilder(slotConfigurations: Map[Id, SlotConfiguration], converters: ExpressionConverters) extends TreeBuilder[Pipeline] { override def create(plan: LogicalPlan): Pipeline = { @@ -40,7 +41,7 @@ class PipelineBuilder(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], } override protected def build(plan: LogicalPlan): Pipeline = { - val slots = slotConfigurations(plan.assignedId) + val slots = slotConfigurations(plan.id) val thisOp = plan match { case plans.AllNodesScan(IdName(column), _) => @@ -58,7 +59,7 @@ class PipelineBuilder(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], override protected def build(plan: LogicalPlan, from: Pipeline): Pipeline = { var source = from - val slots = slotConfigurations(plan.assignedId) + val slots = slotConfigurations(plan.id) val thisOp = plan match { case plans.ProduceResult(_, columns) => @@ -72,7 +73,7 @@ class PipelineBuilder(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], val fromOffset = slots.getLongOffsetFor(fromName) val relOffset = slots.getLongOffsetFor(relName) val toOffset = slots.getLongOffsetFor(to) - val fromPipe = slotConfigurations(lhs.assignedId) + val fromPipe = slotConfigurations(lhs.id) val lazyTypes = LazyTypes(types.toArray)(SemanticTable()) new ExpandAllOperator(slots, fromPipe, fromOffset, relOffset, toOffset, dir, lazyTypes) @@ -95,7 +96,7 @@ class PipelineBuilder(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], throw new InternalException("Weird slot found for UNWIND") } val runtimeExpression = converters.toCommandExpression(collection) - new UnwindOperator(runtimeExpression, offset, slotConfigurations(src.assignedId), slots) + new UnwindOperator(runtimeExpression, offset, slotConfigurations(src.id), slots) case p => throw new CantCompileQueryException(s"$p not supported in morsel runtime") } diff --git a/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocation.scala b/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocation.scala index 477f28a1a4939..d2a586117e2bc 100644 --- a/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocation.scala +++ b/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocation.scala @@ -23,6 +23,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration.Si import org.neo4j.cypher.internal.frontend.v3_4.ast.ProcedureResultItem import org.neo4j.cypher.internal.frontend.v3_4.semantics.SemanticTable import org.neo4j.cypher.internal.ir.v3_4.{HasHeaders, IdName, NoHeaders, ShortestPathPattern} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{InternalException, UnNamedNameGenerator} import org.neo4j.cypher.internal.util.v3_4.symbols._ import org.neo4j.cypher.internal.v3_4.expressions._ @@ -49,8 +50,8 @@ object SlotAllocation { case class SlotsAndArgument(slotConfiguration: SlotConfiguration, argumentSize: Size) - case class PhysicalPlan(slotConfigurations: Map[LogicalPlanId, SlotConfiguration], - argumentSizes: Map[LogicalPlanId, Size]) + case class PhysicalPlan(slotConfigurations: Map[Id, SlotConfiguration], + argumentSizes: Map[Id, Size]) /** * Allocate slot for every operator in the logical plan tree {@code lp}. @@ -62,8 +63,8 @@ object SlotAllocation { semanticTable: SemanticTable, initialSlotsAndArgument: Option[SlotsAndArgument] = None): PhysicalPlan = { - val allocations = new mutable.OpenHashMap[LogicalPlanId, SlotConfiguration]() - val arguments = new mutable.OpenHashMap[LogicalPlanId, Size]() + val allocations = new mutable.OpenHashMap[Id, SlotConfiguration]() + val arguments = new mutable.OpenHashMap[Id, Size]() val planStack = new mutable.Stack[(Boolean, LogicalPlan)]() val resultStack = new mutable.Stack[SlotConfiguration]() @@ -72,7 +73,7 @@ object SlotAllocation { var comingFrom = lp def recordArgument(plan: LogicalPlan, argument: SlotsAndArgument) = { - arguments += plan.assignedId -> argument.argumentSize + arguments += plan.id -> argument.argumentSize } /** @@ -105,7 +106,7 @@ object SlotAllocation { recordArgument(current, argument) val slotsIncludingExpressions = allocateExpressions(current, nullable, argument.slotConfiguration.copy(), allocations, arguments)(semanticTable) val result = allocate(current, nullable, slotsIncludingExpressions) - allocations += (current.assignedId -> result) + allocations += (current.id -> result) resultStack.push(result) case (Some(_), None) => @@ -114,7 +115,7 @@ object SlotAllocation { else argumentStack.top val slotsIncludingExpressions = allocateExpressions(current, nullable, sourceSlots, allocations, arguments)(semanticTable) val result = allocate(current, nullable, slotsIncludingExpressions, recordArgument(_, argument)) - allocations += (current.assignedId -> result) + allocations += (current.id -> result) resultStack.push(result) case (Some(left), Some(right)) if (comingFrom eq left) && isAnApplyPlan(current) => @@ -138,7 +139,7 @@ object SlotAllocation { val lhsSlotsIncludingExpressions = allocateExpressions(current, nullable, lhsSlots, allocations, arguments, shouldAllocateLhs = true)(semanticTable) val rhsSlotsIncludingExpressions = allocateExpressions(current, nullable, rhsSlots, allocations, arguments, shouldAllocateLhs = false)(semanticTable) val result = allocate(current, nullable, lhsSlotsIncludingExpressions, rhsSlotsIncludingExpressions, recordArgument(_, argument)) - allocations += (current.assignedId -> result) + allocations += (current.id -> result) if (isAnApplyPlan(current)) argumentStack.pop() resultStack.push(result) @@ -152,8 +153,8 @@ object SlotAllocation { // NOTE: If we find a NestedPlanExpression within the given LogicalPlan, the slotConfigurations and argumentSizes maps will be updated private def allocateExpressions(lp: LogicalPlan, nullable: Boolean, slots: SlotConfiguration, - slotConfigurations: mutable.Map[LogicalPlanId, SlotConfiguration], - argumentSizes: mutable.Map[LogicalPlanId, Size], + slotConfigurations: mutable.Map[Id, SlotConfiguration], + argumentSizes: mutable.Map[Id, Size], shouldAllocateLhs: Boolean = true) (semanticTable: SemanticTable): SlotConfiguration = { case class Accumulator(slots: SlotConfiguration, doNotTraverseExpression: Option[Expression]) @@ -165,7 +166,7 @@ object SlotAllocation { //----------------------------------------------------- // Logical plans //----------------------------------------------------- - case p: LogicalPlan if p.assignedId != lp.assignedId => + case p: LogicalPlan if p.id != lp.id => acc: Accumulator => (acc, DO_NOT_TRAVERSE_INTO_CHILDREN) // Do not traverse the logical plan tree! We are only looking at the given lp case ValueHashJoin(_, _, Equals(_, rhsExpression)) if shouldAllocateLhs => diff --git a/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriter.scala b/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriter.scala index 48a6e458a4f0c..b4ae5872bb198 100644 --- a/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriter.scala +++ b/enterprise/cypher/physical-planning/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriter.scala @@ -24,11 +24,11 @@ import org.neo4j.cypher.internal.compiler.v3_4.planner.CantCompileQueryException import org.neo4j.cypher.internal.planner.v3_4.spi.TokenContext import org.neo4j.cypher.internal.util.v3_4.AssertionUtils.ifAssertionsEnabled import org.neo4j.cypher.internal.util.v3_4.Foldable._ -import org.neo4j.cypher.internal.util.v3_4.attribution.SameId +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, SameId} import org.neo4j.cypher.internal.util.v3_4.symbols._ import org.neo4j.cypher.internal.util.v3_4.{InternalException, Rewriter, topDown} import org.neo4j.cypher.internal.v3_4.expressions.{FunctionInvocation, _} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId, NestedPlanExpression, Projection, VarExpand, _} +import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, NestedPlanExpression, Projection, VarExpand, _} import org.neo4j.cypher.internal.v3_4.{expressions, functions => frontendFunctions} import scala.collection.mutable @@ -48,7 +48,7 @@ class SlottedRewriter(tokenContext: TokenContext) { case _ => false } - def apply(in: LogicalPlan, slotConfigurations: Map[LogicalPlanId, SlotConfiguration]): LogicalPlan = { + def apply(in: LogicalPlan, slotConfigurations: Map[Id, SlotConfiguration]): LogicalPlan = { val newSlotConfigurations = mutable.HashMap[LogicalPlan, SlotConfiguration]() val rewritePlanWithSlots = topDown(Rewriter.lift { /* @@ -56,7 +56,7 @@ class SlottedRewriter(tokenContext: TokenContext) { would just write to the row the data that is already in it, we can just skip them */ case oldPlan@Projection(_, expressions) => - val slotConfiguration = slotConfigurations(oldPlan.assignedId) + val slotConfiguration = slotConfigurations(oldPlan.id) val rewriter = rewriteCreator(slotConfiguration, oldPlan.selfThis, slotConfigurations) val newExpressions = expressions collect { @@ -73,7 +73,7 @@ class SlottedRewriter(tokenContext: TokenContext) { The node and edge predicates will be set and evaluated on the incoming rows, not on the outgoing ones. We need to use the incoming slot configuration for predicate rewriting */ - val incomingSlotConfiguration = slotConfigurations(oldPlan.source.assignedId) + val incomingSlotConfiguration = slotConfigurations(oldPlan.source.id) val rewriter = rewriteCreator(incomingSlotConfiguration, oldPlan, slotConfigurations) val newNodePredicate = oldPlan.nodePredicate.endoRewrite(rewriter) @@ -89,21 +89,21 @@ class SlottedRewriter(tokenContext: TokenContext) { Since the logical plan SlotConfiguration is about the output rows we still need to remember the outgoing slot configuration here */ - val outgoingSlotConfiguration = slotConfigurations(oldPlan.assignedId) + val outgoingSlotConfiguration = slotConfigurations(oldPlan.id) newSlotConfigurations += (newPlan -> outgoingSlotConfiguration) newPlan case plan@ValueHashJoin(lhs, rhs, e@Equals(lhsExp, rhsExp)) => - val lhsRewriter = rewriteCreator(slotConfigurations(lhs.assignedId), plan.selfThis, slotConfigurations) - val rhsRewriter = rewriteCreator(slotConfigurations(rhs.assignedId), plan.selfThis, slotConfigurations) + val lhsRewriter = rewriteCreator(slotConfigurations(lhs.id), plan.selfThis, slotConfigurations) + val rhsRewriter = rewriteCreator(slotConfigurations(rhs.id), plan.selfThis, slotConfigurations) val lhsExpAfterRewrite = lhsExp.endoRewrite(lhsRewriter) val rhsExpAfterRewrite = rhsExp.endoRewrite(rhsRewriter) plan.copy(join = Equals(lhsExpAfterRewrite, rhsExpAfterRewrite)(e.position))(plan.solved)(SameId(plan.id)) case oldPlan: LogicalPlan if rewriteUsingIncoming(oldPlan) => val leftPlan = oldPlan.lhs.getOrElse(throw new InternalException("Leaf plans cannot be rewritten this way")) - val incomingSlotConfiguration = slotConfigurations(leftPlan.assignedId) + val incomingSlotConfiguration = slotConfigurations(leftPlan.id) val rewriter = rewriteCreator(incomingSlotConfiguration, oldPlan, slotConfigurations) val newPlan = oldPlan.endoRewrite(rewriter) @@ -111,12 +111,12 @@ class SlottedRewriter(tokenContext: TokenContext) { Since the logical plan SlotConfiguration is about the output rows we still need to remember the outgoing slot configuration here */ - val outgoingSlotConfiguration = slotConfigurations(oldPlan.assignedId) + val outgoingSlotConfiguration = slotConfigurations(oldPlan.id) newSlotConfigurations += (newPlan -> outgoingSlotConfiguration) newPlan case oldPlan: LogicalPlan => - val slotConfiguration = slotConfigurations(oldPlan.assignedId) + val slotConfiguration = slotConfigurations(oldPlan.id) val rewriter = rewriteCreator(slotConfiguration, oldPlan, slotConfigurations) val newPlan = oldPlan.endoRewrite(rewriter) newSlotConfigurations += (newPlan -> slotConfiguration) @@ -135,13 +135,13 @@ class SlottedRewriter(tokenContext: TokenContext) { resultPlan } - private def rewriteCreator(slotConfiguration: SlotConfiguration, thisPlan: LogicalPlan, slotConfigurations: Map[LogicalPlanId, SlotConfiguration]): Rewriter = { + private def rewriteCreator(slotConfiguration: SlotConfiguration, thisPlan: LogicalPlan, slotConfigurations: Map[Id, SlotConfiguration]): Rewriter = { val innerRewriter = Rewriter.lift { case e: NestedPlanExpression => // Rewrite expressions within the nested plan val rewrittenPlan = this.apply(e.plan, slotConfigurations) - val slotConfiguration = slotConfigurations.getOrElse(e.plan.assignedId, - throw new InternalException(s"Missing slot configuration for plan with ${e.plan.assignedId}")) + val slotConfiguration = slotConfigurations.getOrElse(e.plan.id, + throw new InternalException(s"Missing slot configuration for plan with ${e.plan.id}")) val rewriter = rewriteCreator(slotConfiguration, thisPlan, slotConfigurations) val rewrittenProjection = e.projection.endoRewrite(rewriter) e.copy(plan = rewrittenPlan, projection = rewrittenProjection)(e.position) diff --git a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationArgumentsTest.scala b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationArgumentsTest.scala index f134169d7c5e6..f2d7a182b84a1 100644 --- a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationArgumentsTest.scala +++ b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationArgumentsTest.scala @@ -39,40 +39,37 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes test("zero size argument for single all nodes scan") { // given val plan = AllNodesScan(x, Set.empty)(solved) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 1 - arguments(plan.assignedId) should equal(Size(0, 0)) + arguments(plan.id) should equal(Size(0, 0)) } test("zero size argument for only leaf operator") { // given val leaf = AllNodesScan(x, Set.empty)(solved) val expand = Expand(leaf, x, SemanticDirection.INCOMING, Seq.empty, z, r, ExpandAll)(solved) - expand.assignIds() // when val arguments = SlotAllocation.allocateSlots(expand, semanticTable).argumentSizes // then arguments should have size 1 - arguments(leaf.assignedId) should equal(Size(0, 0)) + arguments(leaf.id) should equal(Size(0, 0)) } test("zero size argument for argument operator") { val argument = Argument(Set.empty)(solved) - argument.assignIds() // when val arguments = SlotAllocation.allocateSlots(argument, semanticTable).argumentSizes // then arguments should have size 1 - arguments(argument.assignedId) should equal(Size(0, 0)) + arguments(argument.id) should equal(Size(0, 0)) } test("correct long size argument for rhs leaf") { @@ -80,15 +77,14 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val lhs = leaf() val rhs = leaf() val plan = applyRight(pipe(lhs, 1, 0), rhs) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 2 - arguments(lhs.assignedId) should equal(Size(0, 0)) - arguments(rhs.assignedId) should equal(Size(1, 0)) + arguments(lhs.id) should equal(Size(0, 0)) + arguments(rhs.id) should equal(Size(1, 0)) } test("correct ref size argument for rhs leaf") { @@ -96,15 +92,14 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val lhs = leaf() val rhs = leaf() val plan = applyRight(pipe(lhs, 0, 1), rhs) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 2 - arguments(lhs.assignedId) should equal(Size(0, 0)) - arguments(rhs.assignedId) should equal(Size(0, 1)) + arguments(lhs.id) should equal(Size(0, 0)) + arguments(rhs.id) should equal(Size(0, 1)) } test("correct size argument for more slots") { @@ -112,15 +107,14 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val lhs = leaf() val rhs = leaf() val plan = applyRight(pipe(lhs, 17, 11), rhs) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 2 - arguments(lhs.assignedId) should equal(Size(0, 0)) - arguments(rhs.assignedId) should equal(Size(17, 11)) + arguments(lhs.id) should equal(Size(0, 0)) + arguments(rhs.id) should equal(Size(17, 11)) } test("apply right keeps rhs slots") { @@ -137,16 +131,15 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val leaf2 = leaf() val leaf3 = leaf() val plan = applyRight(applyRight(pipe(leaf1, 1, 0), pipe(leaf2, 0, 1)), leaf3) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 3 - arguments(leaf1.assignedId) should equal(Size(0, 0)) - arguments(leaf2.assignedId) should equal(Size(1, 0)) - arguments(leaf3.assignedId) should equal(Size(1, 1)) + arguments(leaf1.id) should equal(Size(0, 0)) + arguments(leaf2.id) should equal(Size(1, 0)) + arguments(leaf3.id) should equal(Size(1, 1)) } test("apply left ignores rhs slots") { @@ -163,16 +156,15 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val leaf2 = leaf() val leaf3 = leaf() val plan = applyRight(applyLeft(pipe(leaf1, 1, 0), pipe(leaf2, 0, 1)), leaf3) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 3 - arguments(leaf1.assignedId) should equal(Size(0, 0)) - arguments(leaf2.assignedId) should equal(Size(1, 0)) - arguments(leaf3.assignedId) should equal(Size(1, 0)) + arguments(leaf1.id) should equal(Size(0, 0)) + arguments(leaf2.id) should equal(Size(1, 0)) + arguments(leaf3.id) should equal(Size(1, 0)) } test("apply left argument does not leak downstream slots") { @@ -188,15 +180,14 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val leaf1 = leaf() val leaf2 = leaf() val plan = pipe(applyLeft(pipe(leaf1, 1, 0), leaf2), 0, 1) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 2 - arguments(leaf1.assignedId) should equal(Size(0, 0)) - arguments(leaf2.assignedId) should equal(Size(1, 0)) + arguments(leaf1.id) should equal(Size(0, 0)) + arguments(leaf2.id) should equal(Size(1, 0)) } test("argument is passed over pipeline break") { @@ -212,15 +203,14 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val leaf1 = leaf() val leaf2 = leaf() val plan = applyRight(pipe(leaf1, 1, 0), pipe(break(leaf2), 0, 1)) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 2 - arguments(leaf1.assignedId) should equal(Size(0, 0)) - arguments(leaf2.assignedId) should equal(Size(1, 0)) + arguments(leaf1.id) should equal(Size(0, 0)) + arguments(leaf2.id) should equal(Size(1, 0)) } test("Optional should record argument size") { @@ -235,16 +225,15 @@ class SlotAllocationArgumentsTest extends CypherFunSuite with LogicalPlanningTes val leaf2 = leaf() val optional = Optional(leaf2, Set.empty)(solved) val plan = applyRight(pipe(leaf1, 1, 0), optional) - plan.assignIds() // when val arguments = SlotAllocation.allocateSlots(plan, semanticTable).argumentSizes // then arguments should have size 3 - arguments(leaf1.assignedId) should equal(Size(0, 0)) - arguments(leaf2.assignedId) should equal(Size(1, 0)) - arguments(optional.assignedId) should equal(Size(1, 0)) + arguments(leaf1.id) should equal(Size(0, 0)) + arguments(leaf2.id) should equal(Size(1, 0)) + arguments(optional.id) should equal(Size(1, 0)) } private def leaf() = Argument(Set.empty)(solved) diff --git a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationTest.scala b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationTest.scala index 6b62b0a92e6d8..d1779b55608f6 100644 --- a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationTest.scala +++ b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlotAllocationTest.scala @@ -44,75 +44,70 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 test("only single allnodes scan") { // given val plan = AllNodesScan(x, Set.empty)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 1 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) } test("limit should not introduce slots") { // given val plan = logicalPlans.Limit(AllNodesScan(x, Set.empty)(solved), literalInt(1), DoNotIncludeTies)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 2 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) } test("single labelscan scan") { // given val plan = NodeByLabelScan(x, LABEL, Set.empty)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 1 - allocations(plan.assignedId) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) + allocations(plan.id) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) } test("labelscan with filtering") { // given val leaf = NodeByLabelScan(x, LABEL, Set.empty)(solved) val filter = Selection(Seq(True()(pos)), leaf)(solved) - filter.assignIds() // when val allocations = SlotAllocation.allocateSlots(filter, semanticTable).slotConfigurations // then allocations should have size 2 - allocations(leaf.assignedId) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) - allocations(filter.assignedId) shouldBe theSameInstanceAs(allocations(leaf.assignedId)) + allocations(leaf.id) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) + allocations(filter.id) shouldBe theSameInstanceAs(allocations(leaf.id)) } test("single node with expand") { // given val allNodesScan = AllNodesScan(x, Set.empty)(solved) val expand = Expand(allNodesScan, x, SemanticDirection.INCOMING, Seq.empty, z, r, ExpandAll)(solved) - expand.assignIds() // when val allocations = SlotAllocation.allocateSlots(expand, semanticTable).slotConfigurations // then we'll end up with two pipelines allocations should have size 2 - val labelScanAllocations = allocations(allNodesScan.assignedId) + val labelScanAllocations = allocations(allNodesScan.id) labelScanAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -124,18 +119,17 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // given val allNodesScan = AllNodesScan(x, Set.empty)(solved) val expand = Expand(allNodesScan, x, SemanticDirection.INCOMING, Seq.empty, x, r, ExpandInto)(solved) - expand.assignIds() // when val allocations = SlotAllocation.allocateSlots(expand, semanticTable).slotConfigurations // then we'll end up with two pipelines allocations should have size 2 - val labelScanAllocations = allocations(allNodesScan.assignedId) + val labelScanAllocations = allocations(allNodesScan.id) labelScanAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode), "r" -> LongSlot(1, nullable = false, CTRelationship)), numberOfLongs = 2, numberOfReferences = 0)) @@ -145,33 +139,31 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // given val leaf = AllNodesScan(x, Set.empty)(solved) val plan = Optional(leaf)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 2 - allocations(plan.assignedId) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = true, CTNode)), 1, 0)) + allocations(plan.id) should equal(SlotConfiguration(Map("x" -> LongSlot(0, nullable = true, CTNode)), 1, 0)) } test("single node with optionalExpand ExpandAll") { // given val allNodesScan = AllNodesScan(x, Set.empty)(solved) val expand = OptionalExpand(allNodesScan, x, SemanticDirection.INCOMING, Seq.empty, z, r, ExpandAll)(solved) - expand.assignIds() // when val allocations = SlotAllocation.allocateSlots(expand, semanticTable).slotConfigurations // then we'll end up with two pipelines allocations should have size 2 - val labelScanAllocations = allocations(allNodesScan.assignedId) + val labelScanAllocations = allocations(allNodesScan.id) labelScanAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -184,18 +176,17 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // given val allNodesScan = AllNodesScan(x, Set.empty)(solved) val expand = OptionalExpand(allNodesScan, x, SemanticDirection.INCOMING, Seq.empty, x, r, ExpandInto)(solved) - expand.assignIds() // when val allocations = SlotAllocation.allocateSlots(expand, semanticTable).slotConfigurations // then we'll end up with two pipelines allocations should have size 2 - val labelScanAllocations = allocations(allNodesScan.assignedId) + val labelScanAllocations = allocations(allNodesScan.id) labelScanAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -211,14 +202,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val tempEdge = IdName("r_EDGES") val expand = VarExpand(allNodesScan, x, SemanticDirection.INCOMING, SemanticDirection.INCOMING, Seq.empty, z, r, varLength, ExpandAll, tempNode, tempEdge, True()(pos), True()(pos), Seq.empty)(solved) - expand.assignIds() // when val allocations = SlotAllocation.allocateSlots(expand, semanticTable).slotConfigurations // then we'll end up with two pipelines allocations should have size 2 - val allNodeScanAllocations = allocations(allNodesScan.assignedId) + val allNodeScanAllocations = allocations(allNodesScan.id) allNodeScanAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -226,7 +216,7 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 "r_EDGES" -> LongSlot(2, nullable = false, CTRelationship)), numberOfLongs = 3, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -243,20 +233,19 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val tempEdge = IdName("r_EDGES") val varExpand = VarExpand(expand, x, SemanticDirection.INCOMING, SemanticDirection.INCOMING, Seq.empty, y, r2, varLength, ExpandInto, tempNode, tempEdge, True()(pos), True()(pos), Seq.empty)(solved) - varExpand.assignIds() // when val allocations = SlotAllocation.allocateSlots(varExpand, semanticTable).slotConfigurations // then we'll end up with three pipelines allocations should have size 3 - val allNodeScanAllocations = allocations(allNodesScan.assignedId) + val allNodeScanAllocations = allocations(allNodesScan.id) allNodeScanAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(expand.assignedId) + val expandAllocations = allocations(expand.id) expandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -266,7 +255,7 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 "r_EDGES" -> LongSlot(4, nullable = false, CTRelationship)), numberOfLongs = 5, numberOfReferences = 0)) - val varExpandAllocations = allocations(varExpand.assignedId) + val varExpandAllocations = allocations(varExpand.id) varExpandAllocations should equal( SlotConfiguration(Map( "x" -> LongSlot(0, nullable = false, CTNode), @@ -280,18 +269,17 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // given val allNodesScan = AllNodesScan(x, Set.empty)(solved) val skip = logicalPlans.Skip(allNodesScan, literalInt(42))(solved) - skip.assignIds() // when val allocations = SlotAllocation.allocateSlots(skip, semanticTable).slotConfigurations // then allocations should have size 2 - val labelScanAllocations = allocations(allNodesScan.assignedId) + val labelScanAllocations = allocations(allNodesScan.id) labelScanAllocations should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val expandAllocations = allocations(skip.assignedId) + val expandAllocations = allocations(skip.id) expandAllocations shouldBe theSameInstanceAs(labelScanAllocations) } @@ -302,17 +290,16 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val seekExpression = SingleQueryExpression(literalInt(42)) val rhs = NodeIndexSeek(z, label, Seq.empty, seekExpression, Set(x))(solved) val apply = Apply(lhs, rhs)(solved) - apply.assignIds() // when val allocations = SlotAllocation.allocateSlots(apply, semanticTable).slotConfigurations // then allocations should have size 3 - allocations(lhs.assignedId) should equal( + allocations(lhs.id) should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), numberOfLongs = 1, numberOfReferences = 0)) - val rhsPipeline = allocations(rhs.assignedId) + val rhsPipeline = allocations(rhs.id) rhsPipeline should equal( SlotConfiguration(Map( @@ -320,14 +307,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 "z" -> LongSlot(1, nullable = false, CTNode) ), numberOfLongs = 2, numberOfReferences = 0)) - allocations(apply.assignedId) shouldBe theSameInstanceAs(rhsPipeline) + allocations(apply.id) shouldBe theSameInstanceAs(rhsPipeline) } test("aggregation used for distinct") { // given val leaf = NodeByLabelScan(x, LABEL, Set.empty)(solved) val distinct = Aggregation(leaf, Map("x" -> varFor("x")), Map.empty)(solved) - distinct.assignIds() // when val allocations = SlotAllocation.allocateSlots(distinct, semanticTable).slotConfigurations @@ -336,8 +322,8 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val expected = SlotConfiguration.empty.newLong("x", false, CTNode) allocations should have size 2 - allocations(leaf.assignedId) should equal(expected) - allocations(distinct.assignedId) should equal(expected) + allocations(leaf.id) should equal(expected) + allocations(distinct.id) should equal(expected) } test("optional travels through aggregation used for distinct") { @@ -345,7 +331,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val leaf = NodeByLabelScan(x, LABEL, Set.empty)(solved) val optional = Optional(leaf)(solved) val distinct = Distinct(optional, Map("x" -> varFor("x"), "x.propertyKey" -> prop("x", "propertyKey")))(solved) - distinct.assignIds() // when val allocations = SlotAllocation.allocateSlots(distinct, semanticTable).slotConfigurations @@ -358,9 +343,9 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 .newReference("x.propertyKey", true, CTAny) allocations should have size 3 - allocations(leaf.assignedId) should equal(leafExpected) - allocations(optional.assignedId) should equal(leafExpected) - allocations(distinct.assignedId) should equal(distinctExpected) + allocations(leaf.id) should equal(leafExpected) + allocations(optional.id) should equal(leafExpected) + allocations(distinct.id) should equal(distinctExpected) } test("optional travels through aggregation") { @@ -371,7 +356,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 groupingExpressions = Map("x" -> varFor("x"), "x.propertyKey" -> prop("x", "propertyKey")), aggregationExpression = Map("count(*)" -> CountStar()(pos)))(solved) - countStar.assignIds() // when val allocations = SlotAllocation.allocateSlots(countStar, semanticTable).slotConfigurations @@ -385,28 +369,27 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 .newReference("count(*)", true, CTAny) allocations should have size 3 - allocations(leaf.assignedId) should equal(leafExpected) + allocations(leaf.id) should equal(leafExpected) - allocations(optional.assignedId) should be theSameInstanceAs allocations(leaf.assignedId) - allocations(countStar.assignedId) should equal(aggrExpected) + allocations(optional.id) should be theSameInstanceAs allocations(leaf.id) + allocations(countStar.id) should equal(aggrExpected) } test("labelscan with projection") { // given val leaf = NodeByLabelScan(x, LABEL, Set.empty)(solved) val projection = Projection(leaf, Map("x" -> varFor("x"), "x.propertyKey" -> prop("x", "propertyKey")))(solved) - projection.assignIds() // when val allocations = SlotAllocation.allocateSlots(projection, semanticTable).slotConfigurations // then allocations should have size 2 - allocations(leaf.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 1, slots = Map( + allocations(leaf.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 1, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "x.propertyKey" -> RefSlot(0, nullable = true, CTAny) ))) - allocations(projection.assignedId) shouldBe theSameInstanceAs(allocations(leaf.assignedId)) + allocations(projection.id) shouldBe theSameInstanceAs(allocations(leaf.id)) } test("cartesian product") { @@ -414,20 +397,19 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val lhs = NodeByLabelScan(x, LabelName("label1")(pos), Set.empty)(solved) val rhs = NodeByLabelScan(y, LabelName("label2")(pos), Set.empty)(solved) val Xproduct = CartesianProduct(lhs, rhs)(solved) - Xproduct.assignIds() // when val allocations = SlotAllocation.allocateSlots(Xproduct, semanticTable).slotConfigurations // then allocations should have size 3 - allocations(lhs.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( + allocations(lhs.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode) ))) - allocations(rhs.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( + allocations(rhs.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( "y" -> LongSlot(0, nullable = false, CTNode) ))) - allocations(Xproduct.assignedId) should equal(SlotConfiguration(numberOfLongs = 2, numberOfReferences = 0, slots = Map( + allocations(Xproduct.id) should equal(SlotConfiguration(numberOfLongs = 2, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "y" -> LongSlot(1, nullable = false, CTNode) ))) @@ -439,20 +421,19 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val lhs = NodeByLabelScan(x, LabelName("label1")(pos), Set.empty)(solved) val rhs = NodeByLabelScan(x, LabelName("label2")(pos), Set.empty)(solved) val hashJoin = NodeHashJoin(Set(x), lhs, rhs)(solved) - hashJoin.assignIds() // when val allocations = SlotAllocation.allocateSlots(hashJoin, semanticTable).slotConfigurations // then allocations should have size 3 - allocations(lhs.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( + allocations(lhs.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode) ))) - allocations(rhs.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( + allocations(rhs.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode) ))) - allocations(hashJoin.assignedId) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( + allocations(hashJoin.id) should equal(SlotConfiguration(numberOfLongs = 1, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode) ))) } @@ -467,24 +448,23 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val rhsE = Expand(rhs, x, SemanticDirection.INCOMING, Seq.empty, z, r2, ExpandAll)(solved) val hashJoin = NodeHashJoin(Set(x), lhsE, rhsE)(solved) - hashJoin.assignIds() // when val allocations = SlotAllocation.allocateSlots(hashJoin, semanticTable).slotConfigurations // then allocations should have size 5 - allocations(lhsE.assignedId) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( + allocations(lhsE.id) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r" -> LongSlot(1, nullable = false, CTRelationship), "y" -> LongSlot(2, nullable = false, CTNode) ))) - allocations(rhsE.assignedId) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( + allocations(rhsE.id) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r2" -> LongSlot(1, nullable = false, CTRelationship), "z" -> LongSlot(2, nullable = false, CTNode) ))) - allocations(hashJoin.assignedId) should equal(SlotConfiguration(numberOfLongs = 5, numberOfReferences = 0, slots = Map( + allocations(hashJoin.id) should equal(SlotConfiguration(numberOfLongs = 5, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r" -> LongSlot(1, nullable = false, CTRelationship), "y" -> LongSlot(2, nullable = false, CTNode), @@ -503,24 +483,23 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val rhsE = Expand(rhs, x, SemanticDirection.INCOMING, Seq.empty, y, IdName("r2"), ExpandAll)(solved) val hashJoin = NodeHashJoin(Set(x, y), lhsE, rhsE)(solved) - hashJoin.assignIds() // when val allocations = SlotAllocation.allocateSlots(hashJoin, semanticTable).slotConfigurations // then allocations should have size 5 // One for each label-scan and expand, and one after the join - allocations(lhsE.assignedId) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( + allocations(lhsE.id) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r" -> LongSlot(1, nullable = false, CTRelationship), "y" -> LongSlot(2, nullable = false, CTNode) ))) - allocations(rhsE.assignedId) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( + allocations(rhsE.id) should equal(SlotConfiguration(numberOfLongs = 3, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r2" -> LongSlot(1, nullable = false, CTRelationship), "y" -> LongSlot(2, nullable = false, CTNode) ))) - allocations(hashJoin.assignedId) should equal(SlotConfiguration(numberOfLongs = 4, numberOfReferences = 0, slots = + allocations(hashJoin.id) should equal(SlotConfiguration(numberOfLongs = 4, numberOfReferences = 0, slots = Map( "x" -> LongSlot(0, nullable = false, CTNode), "r" -> LongSlot(1, nullable = false, CTRelationship), @@ -536,7 +515,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val rhs = Expand(arg, x, SemanticDirection.INCOMING, Seq.empty, y, r, ExpandAll)(solved) val apply = Apply(lhs, rhs)(solved) - apply.assignIds() // when val allocations = SlotAllocation.allocateSlots(apply, semanticTable).slotConfigurations @@ -553,10 +531,10 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 ), numberOfLongs = 3, numberOfReferences = 0) allocations should have size 4 - allocations(arg.assignedId) should equal(lhsPipeline) - allocations(lhs.assignedId) should equal(lhsPipeline) - allocations(apply.assignedId) should equal(rhsPipeline) - allocations(rhs.assignedId) should equal(rhsPipeline) + allocations(arg.id) should equal(lhsPipeline) + allocations(lhs.id) should equal(lhsPipeline) + allocations(apply.id) should equal(rhsPipeline) + allocations(rhs.id) should equal(rhsPipeline) } test("unwind and project") { @@ -564,20 +542,19 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val leaf = Argument()(solved) val unwind = UnwindCollection(leaf, IdName("x"), listOf(literalInt(1), literalInt(2), literalInt(3)))(solved) val produceResult = ProduceResult(unwind, Seq("x")) - produceResult.assignIds() // when val allocations = SlotAllocation.allocateSlots(produceResult, semanticTable).slotConfigurations // then allocations should have size 3 - allocations(leaf.assignedId) should equal(SlotConfiguration(Map.empty, 0, 0)) + allocations(leaf.id) should equal(SlotConfiguration(Map.empty, 0, 0)) - allocations(unwind.assignedId) should equal(SlotConfiguration(numberOfLongs = 0, numberOfReferences = 1, slots = Map( + allocations(unwind.id) should equal(SlotConfiguration(numberOfLongs = 0, numberOfReferences = 1, slots = Map( "x" -> RefSlot(0, nullable = true, CTAny) ))) - allocations(produceResult.assignedId) shouldBe theSameInstanceAs(allocations(unwind.assignedId)) + allocations(produceResult.id) shouldBe theSameInstanceAs(allocations(unwind.id)) } test("unwind and project and sort") { @@ -588,22 +565,21 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val unwind = UnwindCollection(leaf, xVarName, listOf(literalInt(1), literalInt(2), literalInt(3)))(solved) val sort = Sort(unwind, List(Ascending(xVarName)))(solved) val produceResult = ProduceResult(sort, Seq("x")) - produceResult.assignIds() // when val allocations = SlotAllocation.allocateSlots(produceResult, semanticTable).slotConfigurations // then allocations should have size 4 - allocations(leaf.assignedId) should equal(SlotConfiguration(Map.empty, 0, 0)) + allocations(leaf.id) should equal(SlotConfiguration(Map.empty, 0, 0)) val expectedPipeline = SlotConfiguration(numberOfLongs = 0, numberOfReferences = 1, slots = Map( "x" -> RefSlot(0, nullable = true, CTAny) )) - allocations(unwind.assignedId) should equal(expectedPipeline) - allocations(sort.assignedId) shouldBe theSameInstanceAs(allocations(unwind.assignedId)) - allocations(produceResult.assignedId) shouldBe theSameInstanceAs(allocations(unwind.assignedId)) + allocations(unwind.id) should equal(expectedPipeline) + allocations(sort.id) shouldBe theSameInstanceAs(allocations(unwind.id)) + allocations(produceResult.id) shouldBe theSameInstanceAs(allocations(unwind.id)) } test("semi apply") { @@ -624,7 +600,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val arg = Argument(Set(x))(solved) val rhs = Expand(arg, x, SemanticDirection.INCOMING, Seq.empty, y, r, ExpandAll)(solved) val semiApply = semiApplyBuilder(lhs, rhs)(solved) - semiApply.assignIds() val allocations = SlotAllocation.allocateSlots(semiApply, semanticTable).slotConfigurations val lhsPipeline = SlotConfiguration(Map( @@ -640,10 +615,10 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 ), numberOfLongs = 3, numberOfReferences = 0) allocations should have size 4 - allocations(semiApply.assignedId) should equal(lhsPipeline) - allocations(lhs.assignedId) should equal(lhsPipeline) - allocations(rhs.assignedId) should equal(rhsPipeline) - allocations(arg.assignedId) should equal(argumentSide) + allocations(semiApply.id) should equal(lhsPipeline) + allocations(lhs.id) should equal(lhsPipeline) + allocations(rhs.id) should equal(rhsPipeline) + allocations(arg.id) should equal(argumentSide) } test("argument on two sides of Apply") { @@ -652,7 +627,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val pr1 = Projection(arg1, Map("x" -> literalInt(42)))(solved) val pr2 = Projection(arg2, Map("y" -> literalInt(666)))(solved) val apply = Apply(pr1, pr2)(solved) - apply.assignIds() // when val allocations = SlotAllocation.allocateSlots(apply, semanticTable).slotConfigurations @@ -665,11 +639,11 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 .newReference("x", true, CTAny) .newReference("y", true, CTAny) - allocations(arg1.assignedId) should equal(lhsPipeline) - allocations(pr1.assignedId) should equal(lhsPipeline) - allocations(arg2.assignedId) should equal(rhsPipeline) - allocations(pr2.assignedId) should equal(rhsPipeline) - allocations(apply.assignedId) should equal(rhsPipeline) + allocations(arg1.id) should equal(lhsPipeline) + allocations(pr1.id) should equal(lhsPipeline) + allocations(arg2.id) should equal(rhsPipeline) + allocations(pr2.id) should equal(rhsPipeline) + allocations(apply.id) should equal(rhsPipeline) } test("should allocate aggregation") { @@ -685,19 +659,18 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 "count(r.prop)" -> FunctionInvocation(FunctionName("count")(pos), prop("r", "prop"))(pos) ) val aggregation = Aggregation(expand, grouping, aggregations)(solved) - aggregation.assignIds() // when val allocations = SlotAllocation.allocateSlots(aggregation, semanticTable).slotConfigurations allocations should have size 3 - allocations(expand.assignedId) should equal( + allocations(expand.id) should equal( SlotConfiguration.empty .newLong("x", false, CTNode) .newLong("r", false, CTRelationship) .newLong("y", false, CTNode)) - allocations(aggregation.assignedId) should equal( + allocations(aggregation.id) should equal( SlotConfiguration.empty .newLong("x", false, CTNode) .newReference("x.prop", true, CTAny) @@ -723,14 +696,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // RollUpApply(LHS, RHS, ...) val rollUp = RollUpApply(lhsLeaf, rhsProjection, IdName("c"), IdName("x"), nullableVariables = Set(IdName("r"), IdName("y")))(solved) - rollUp.assignIds() // when val allocations = SlotAllocation.allocateSlots(rollUp, semanticTable).slotConfigurations // then allocations should have size 5 - allocations(rollUp.assignedId) should equal( + allocations(rollUp.id) should equal( SlotConfiguration(Map( "c" -> RefSlot(0, nullable = false, CTList(CTAny)) ), numberOfLongs = 0, numberOfReferences = 1) @@ -742,14 +714,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val lhs = AllNodesScan(x, Set.empty)(solved) val rhs = AllNodesScan(x, Set.empty)(solved) val plan = Union(lhs, rhs)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 3 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0)) } @@ -759,14 +730,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val lhs = Expand(allNodesScan, y, SemanticDirection.INCOMING, Seq.empty, z, x, ExpandAll)(solved) val rhs = AllNodesScan(x, Set.empty)(solved) val plan = Union(lhs, rhs)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 4 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("x" -> RefSlot(0, nullable = false, CTAny)), 0, 1)) } @@ -775,14 +745,13 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val lhs = Projection(allNodesScan, Map("A" -> varFor("x")))(solved) val rhs = Projection(Argument()(solved), Map("A" -> literalInt(42)))(solved) val plan = Union(lhs, rhs)(solved) - plan.assignIds() // when val allocations = SlotAllocation.allocateSlots(plan, semanticTable).slotConfigurations // then allocations should have size 5 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("A" -> RefSlot(0, nullable = true, CTAny)), 0, 1)) } @@ -791,7 +760,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val nestedProjection = Expression val argument = Argument()(solved) val plan = Projection(argument, Map("z" -> NestedPlanExpression(nestedPlan, StringLiteral("foo")(pos))(pos)))(solved) - plan.assignIds() // when val physicalPlan = SlotAllocation.allocateSlots(plan, semanticTable) @@ -799,11 +767,11 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // then allocations should have size 3 - allocations(plan.assignedId) should equal( + allocations(plan.id) should equal( SlotConfiguration(Map("z" -> RefSlot(0, nullable = true, CTAny)), 0, 1) ) - allocations(argument.assignedId) should equal(allocations(plan.assignedId)) - allocations(nestedPlan.assignedId) should equal( + allocations(argument.id) should equal(allocations(plan.id)) + allocations(nestedPlan.id) should equal( SlotConfiguration(Map("x" -> LongSlot(0, nullable = false, CTNode)), 1, 0) ) } @@ -816,7 +784,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val list = literalIntList(1, 2, 3) val rhs = CreateNode(argument, z, Seq.empty, None)(solved) val foreach = ForeachApply(lhs, rhs, "i", list)(solved) - foreach.assignIds() val semanticTableWithList = SemanticTable(ASTAnnotationMap(list -> ExpressionTypeInfo(ListType(CTInteger), Some(ListType(CTAny))))) @@ -826,14 +793,14 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // then allocations should have size 4 - val lhsSlots = allocations(lhs.assignedId) + val lhsSlots = allocations(lhs.id) lhsSlots should equal( SlotConfiguration.empty .newLong("x", nullable = false, CTNode) .newReference("i", nullable = true, CTAny) ) - val rhsSlots = allocations(rhs.assignedId) + val rhsSlots = allocations(rhs.id) rhsSlots should equal( SlotConfiguration.empty .newLong("x", nullable = false, CTNode) @@ -841,7 +808,7 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 .newReference("i", nullable = true, CTAny) ) - allocations(foreach.assignedId) shouldBe theSameInstanceAs(lhsSlots) + allocations(foreach.id) shouldBe theSameInstanceAs(lhsSlots) } test("foreach allocates on left hand side with node list") { @@ -852,7 +819,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 val list = literalList(Variable("x")(pos)) val rhs = CreateNode(argument, z, Seq.empty, None)(solved) val foreach = ForeachApply(lhs, rhs, "i", list)(solved) - foreach.assignIds() val semanticTableWithList = SemanticTable(ASTAnnotationMap(list -> ExpressionTypeInfo(ListType(CTNode), Some(ListType(CTNode))))) @@ -862,14 +828,14 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 // then allocations should have size 4 - val lhsSlots = allocations(lhs.assignedId) + val lhsSlots = allocations(lhs.id) lhsSlots should equal( SlotConfiguration.empty .newLong("x", nullable = false, CTNode) .newLong("i", nullable = true, CTNode) ) - val rhsSlots = allocations(rhs.assignedId) + val rhsSlots = allocations(rhs.id) rhsSlots should equal( SlotConfiguration.empty .newLong("x", nullable = false, CTNode) @@ -877,6 +843,6 @@ class SlotAllocationTest extends CypherFunSuite with LogicalPlanningTestSupport2 .newLong("z", nullable = false, CTNode) ) - allocations(foreach.assignedId) shouldBe theSameInstanceAs(lhsSlots) + allocations(foreach.id) shouldBe theSameInstanceAs(lhsSlots) } } diff --git a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriterTest.scala b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriterTest.scala index b5bad9fde71d8..860af512afdef 100644 --- a/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriterTest.scala +++ b/enterprise/cypher/physical-planning/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/SlottedRewriterTest.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.ast._ import org.neo4j.cypher.internal.frontend.v3_4.ast._ import org.neo4j.cypher.internal.ir.v3_4.{CardinalityEstimation, IdName, PlannerQuery} import org.neo4j.cypher.internal.planner.v3_4.spi.TokenContext -import org.neo4j.cypher.internal.util.v3_4.attribution.SequentialIdGen +import org.neo4j.cypher.internal.util.v3_4.attribution.{Id, SequentialIdGen} import org.neo4j.cypher.internal.util.v3_4.{Cardinality, NonEmptyList} import org.neo4j.cypher.internal.util.v3_4.symbols._ import org.neo4j.cypher.internal.util.v3_4.test_helpers.CypherFunSuite @@ -32,7 +32,7 @@ import org.neo4j.cypher.internal.v3_4.expressions._ import org.neo4j.cypher.internal.v3_4.logical.plans.{AllNodesScan, ProduceResult, Selection, _} class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport { - implicit val idGen = SequentialIdGen + implicit val idGen = new SequentialIdGen() private val solved = CardinalityEstimation.lift(PlannerQuery.empty, Cardinality(1)) private def propFor(v: String, key: String) = Property(Variable(v)(pos), PropertyKeyName(key)(pos))(pos) private val xProp = propFor("x", "prop") @@ -46,14 +46,13 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val predicate = GreaterThan(prop("x", "prop"), literalInt(42))(pos) val selection = Selection(Seq(predicate), allNodes)(solved) val produceResult = ProduceResult(selection, Seq("x")) - produceResult.assignIds() val offset = 0 val slots = SlotConfiguration.empty. newLong("x", nullable = false, CTNode) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - allNodes.assignedId -> slots, - selection.assignedId -> slots, - produceResult.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + allNodes.id -> slots, + selection.id -> slots, + produceResult.id -> slots) val tokenContext = mock[TokenContext] val tokenId = 666 when(tokenContext.getOptPropertyKeyId("prop")).thenReturn(Some(tokenId)) @@ -63,7 +62,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val newPredicate = GreaterThan(NodeProperty(offset, tokenId, "x.prop")(xProp), literalInt(42))(pos) result should equal(ProduceResult(Selection(Seq(newPredicate), allNodes)(solved), Seq("x"))) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("comparing two relationship ids simpler") { @@ -77,7 +76,6 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val argument = Argument(Set(node1, node2, node3, rel1, rel2))(solved) val predicate = Not(Equals(varFor("r1"), varFor("r2"))(pos))(pos) val selection = Selection(Seq(predicate), argument)(solved) - selection.assignIds() val slots = SlotConfiguration.empty. newLong("a", nullable = false, CTNode). newLong("b", nullable = false, CTNode). @@ -85,9 +83,9 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport newLong("c", nullable = false, CTNode). newLong("r2", nullable = false, CTRelationship) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - argument.assignedId -> slots, - selection.assignedId -> slots + val lookup: Map[Id, SlotConfiguration] = Map( + argument.id -> slots, + selection.id -> slots ) val tokenContext = mock[TokenContext] val rewriter = new SlottedRewriter(tokenContext) @@ -97,7 +95,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // then result should equal(Selection(Seq(Not(PrimitiveEquals(IdFromSlot(2), IdFromSlot(4)))(pos)), argument)(solved)) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("comparing two relationship ids simpler when they are null") { @@ -111,7 +109,6 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val argument = Argument(Set(node1, node2, node3, rel1, rel2))(solved) val predicate = Not(Equals(varFor("r1"), varFor("r2"))(pos))(pos) val selection = Selection(Seq(predicate), argument)(solved) - selection.assignIds() val slots = SlotConfiguration.empty. newLong("a", nullable = false, CTNode). newLong("b", nullable = false, CTNode). @@ -119,9 +116,9 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport newLong("c", nullable = false, CTNode). newLong("r2", nullable = true, CTNode) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - argument.assignedId -> slots, - selection.assignedId -> slots + val lookup: Map[Id, SlotConfiguration] = Map( + argument.id -> slots, + selection.id -> slots ) val tokenContext = mock[TokenContext] val rewriter = new SlottedRewriter(tokenContext) @@ -138,7 +135,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport IdFromSlot(2), IdFromSlot(4)))(pos))) result should equal(Selection(Seq(rewrittenPredicate), argument)(solved)) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("comparing different types must check nulls before returning shortcut") { @@ -150,15 +147,14 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val argument = Argument(Set(node1, node2, rel))(solved) val predicate = Equals(varFor("r"), varFor("a"))(pos) val selection = Selection(Seq(predicate), argument)(solved) - selection.assignIds() val slots = SlotConfiguration.empty. newLong("a", nullable = true, CTNode). newLong("b", nullable = false, CTNode). newLong("r", nullable = true, CTRelationship) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - argument.assignedId -> slots, - selection.assignedId -> slots + val lookup: Map[Id, SlotConfiguration] = Map( + argument.id -> slots, + selection.id -> slots ) val tokenContext = mock[TokenContext] val rewriter = new SlottedRewriter(tokenContext) @@ -173,7 +169,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport False()(pos))) result should equal(Selection(Seq(rewrittenPredicate), argument)(solved)) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("return nullable node") { @@ -183,13 +179,12 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val argument = AllNodesScan(node1, Set.empty)(solved) val predicate = Equals(prop("a", "prop"), literalInt(42))(pos) val selection = Selection(Seq(predicate), argument)(solved) - selection.assignIds() val slots = SlotConfiguration.empty. newLong("a", nullable = true, CTNode) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - argument.assignedId -> slots, - selection.assignedId -> slots + val lookup: Map[Id, SlotConfiguration] = Map( + argument.id -> slots, + selection.id -> slots ) val tokenContext = mock[TokenContext] val tokenId = 666 @@ -202,7 +197,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // then val expectedPredicate = Equals(NullCheckProperty(0, NodeProperty(0, 666, "a.prop")(aProp)), literalInt(42))(pos) result should equal(Selection(Seq(expectedPredicate), argument)(solved)) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("selection with property comparison MATCH (n) WHERE n.prop > 42 RETURN n when token is unknown") { @@ -210,14 +205,13 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val predicate = GreaterThan(prop("x", "prop"), literalInt(42))(pos) val selection = Selection(Seq(predicate), allNodes)(solved) val produceResult = ProduceResult(selection, Seq("x")) - produceResult.assignIds() val offset = 0 val slots = SlotConfiguration.empty. newLong("x", nullable = false, CTNode) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - allNodes.assignedId -> slots, - selection.assignedId -> slots, - produceResult.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + allNodes.id -> slots, + selection.id -> slots, + produceResult.id -> slots) val tokenContext = mock[TokenContext] when(tokenContext.getOptPropertyKeyId("prop")).thenReturn(None) val rewriter = new SlottedRewriter(tokenContext) @@ -226,7 +220,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val newPredicate = GreaterThan(NodePropertyLate(offset, "prop", "x.prop")(xProp), literalInt(42))(pos) result should equal(ProduceResult(Selection(Seq(newPredicate), allNodes)(solved), Seq("x"))) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("reading property key when the token does not exist at compile time") { @@ -238,15 +232,14 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val argument = Argument(Set(node1, node2, edge))(solved) val predicate = Equals(prop("r", "prop"), literalInt(42))(pos) val selection = Selection(Seq(predicate), argument)(solved) - selection.assignIds() val slots = SlotConfiguration.empty. newLong("a", nullable = false, CTNode). newLong("b", nullable = false, CTNode). newLong("r", nullable = false, CTRelationship) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - argument.assignedId -> slots, - selection.assignedId -> slots + val lookup: Map[Id, SlotConfiguration] = Map( + argument.id -> slots, + selection.id -> slots ) val tokenContext = mock[TokenContext] when(tokenContext.getOptPropertyKeyId("prop")).thenReturn(None) @@ -256,7 +249,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val result = rewriter(selection, lookup) result should equal(Selection(Seq(Equals(RelationshipPropertyLate(2, "prop", "r.prop")(rProp), literalInt(42))(pos)), argument)(solved)) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("projection with map lookup MATCH (n) RETURN n.prop") { @@ -265,15 +258,14 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val allNodes = AllNodesScan(IdName.fromVariable(node), Set.empty)(solved) val projection = Projection(allNodes, Map("n.prop" -> prop("n", "prop")))(solved) val produceResult = ProduceResult(projection, Seq("n.prop")) - produceResult.assignIds() val nodeOffset = 0 val slots = SlotConfiguration.empty. newLong("n", nullable = false, CTNode). newReference("n.prop", nullable = true, CTAny) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - allNodes.assignedId -> slots, - projection.assignedId -> slots, - produceResult.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + allNodes.id -> slots, + projection.id -> slots, + produceResult.id -> slots) val tokenContext = mock[TokenContext] when(tokenContext.getOptPropertyKeyId("prop")).thenReturn(None) val rewriter = new SlottedRewriter(tokenContext) @@ -285,14 +277,13 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val newProjection = Projection(allNodes, Map("n.prop" -> NodePropertyLate(nodeOffset, "prop", "n.prop")(nProp)))(solved) result should equal( ProduceResult(newProjection, Seq("n.prop"))) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("rewriting variable should always work, even if Variable is not part of a bigger tree") { // given val leaf = NodeByLabelScan(IdName("x"), LabelName("label")(pos), Set.empty)(solved) val projection = Projection(leaf, Map("x" -> varFor("x"), "x.propertyKey" -> prop("x", "propertyKey")))(solved) - projection.assignIds() val tokenContext = mock[TokenContext] val tokenId = 2 when(tokenContext.getOptPropertyKeyId("propertyKey")).thenReturn(Some(tokenId)) @@ -302,7 +293,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // when val rewriter = new SlottedRewriter(tokenContext) - val resultPlan = rewriter(projection, Map(leaf.assignedId -> slots, projection.assignedId -> slots)) + val resultPlan = rewriter(projection, Map(leaf.id -> slots, projection.id -> slots)) // then resultPlan should equal( @@ -317,7 +308,6 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // given val leaf = NodeByLabelScan(IdName("x"), LabelName("label")(pos), Set.empty)(solved) val projection = Projection(leaf, Map("x" -> varFor("x"), "x.propertyKey" -> prop("x", "propertyKey")))(solved) - projection.assignIds() val tokenContext = mock[TokenContext] val tokenId = 2 when(tokenContext.getOptPropertyKeyId("propertyKey")).thenReturn(Some(tokenId)) @@ -327,7 +317,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // when val rewriter = new SlottedRewriter(tokenContext) - val resultPlan = rewriter(projection, Map(leaf.assignedId -> slots, projection.assignedId -> slots)) + val resultPlan = rewriter(projection, Map(leaf.id -> slots, projection.id -> slots)) // then val nodeOffset = slots.getLongOffsetFor("x") @@ -346,7 +336,6 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val pr1B = Projection(pr1A, Map("xx" -> varFor("x")))(solved) val pr2 = Projection(sr2, Map("y" -> literalInt(666)))(solved) val apply = Apply(pr1B, pr2)(solved) - apply.assignIds() val lhsPipeline = SlotConfiguration.empty. newReference("x", nullable = true, CTAny). @@ -357,8 +346,8 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // when val rewriter = new SlottedRewriter(mock[TokenContext]) - val lookup = Map(sr1.assignedId -> lhsPipeline, pr1A.assignedId -> lhsPipeline, pr1B.assignedId -> lhsPipeline, - sr2.assignedId -> rhsPipeline, pr2.assignedId -> rhsPipeline, apply.assignedId -> rhsPipeline) + val lookup = Map(sr1.id -> lhsPipeline, pr1A.id -> lhsPipeline, pr1B.id -> lhsPipeline, + sr2.id -> rhsPipeline, pr2.id -> rhsPipeline, apply.id -> rhsPipeline) val resultPlan = rewriter(apply, lookup) // then @@ -370,9 +359,9 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport applyAfterRewrite ) - lookup(resultPlan.assignedId) should equal(rhsPipeline) - lookup(sr1.assignedId) should equal(lhsPipeline) - lookup(sr2.assignedId) should equal(rhsPipeline) + lookup(resultPlan.id) should equal(rhsPipeline) + lookup(sr1.id) should equal(lhsPipeline) + lookup(sr2.id) should equal(rhsPipeline) } test("ValueHashJoin needs to execute expressions with two different slots") { @@ -384,7 +373,6 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val rhsExp = prop("b", "prop") val join = ValueHashJoin(leafA, leafB, Equals(lhsExp, rhsExp)(pos))(solved) - join.assignIds() val lhsPipeline = SlotConfiguration.empty. newLong("a", nullable = false, CTNode) @@ -402,7 +390,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // when val rewriter = new SlottedRewriter(tokenContext) - val lookup = Map(leafA.assignedId -> lhsPipeline, leafB.assignedId -> rhsPipeline, join.assignedId -> joinPipeline) + val lookup = Map(leafA.id -> lhsPipeline, leafB.id -> rhsPipeline, join.id -> joinPipeline) val resultPlan = rewriter(join, lookup) // then @@ -414,9 +402,9 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport joinAfterRewrite ) - lookup(resultPlan.assignedId) should equal(joinPipeline) - lookup(leafA.assignedId) should equal(lhsPipeline) - lookup(leafB.assignedId) should equal(rhsPipeline) + lookup(resultPlan.id) should equal(joinPipeline) + lookup(leafA.id) should equal(lhsPipeline) + lookup(leafB.id) should equal(rhsPipeline) } test("selection with null checks against a primitive LongSlot") { @@ -425,15 +413,14 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val predicate = IsNull(varFor("x"))(pos) val selection = Selection(Seq(predicate), allNodes)(solved) val produceResult = ProduceResult(selection, Seq("x")) - produceResult.assignIds() val offset = 0 val slots = SlotConfiguration.empty. newLong("x", nullable = true, CTNode) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - allNodes.assignedId -> slots, - selection.assignedId -> slots, - produceResult.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + allNodes.id -> slots, + selection.id -> slots, + produceResult.id -> slots) val tokenContext = mock[TokenContext] val rewriter = new SlottedRewriter(tokenContext) @@ -443,7 +430,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport // then val newPredicate = IsPrimitiveNull(offset) result should equal(ProduceResult(Selection(Seq(newPredicate), allNodes)(solved), Seq("x"))) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("selection between two references") { @@ -453,17 +440,16 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val predicate2 = Not(Equals(varFor("x"), varFor("z"))(pos))(pos) val selection = Selection(Seq(predicate1, predicate2), arg)(solved) val produceResult = ProduceResult(selection, Seq("x", "z")) - produceResult.assignIds() val offsetX = 0 val offsetZ = 1 val slots = SlotConfiguration.empty. newReference("x", nullable = true, CTAny). newReference("z", nullable = true, CTAny) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - arg.assignedId -> slots, - selection.assignedId -> slots, - produceResult.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + arg.id -> slots, + selection.id -> slots, + produceResult.id -> slots) val tokenContext = mock[TokenContext] val rewriter = new SlottedRewriter(tokenContext) @@ -474,7 +460,7 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val newPred1 = Equals(ReferenceFromSlot(offsetX, "x"), ReferenceFromSlot(offsetZ, "z"))(pos) val newPred2 = Not(Equals(ReferenceFromSlot(offsetX, "x"), ReferenceFromSlot(offsetZ, "z"))(pos))(pos) result should equal(ProduceResult(Selection(Seq(newPred1, newPred2), arg)(solved), Seq("x", "z"))) - lookup(result.assignedId) should equal(slots) + lookup(result.id) should equal(slots) } test("should be able to rewrite expressions declared as Variable or Property") { @@ -482,16 +468,15 @@ class SlottedRewriterTest extends CypherFunSuite with AstConstructionTestSupport val arg = Argument()(solved) val predicate = AndedPropertyInequalities(varFor("n"), nProp, NonEmptyList(LessThan(literalInt(42), varFor("z"))(pos))) val selection = Selection(Seq(predicate), arg)(solved) - selection.assignIds() val offsetN = 0 val offsetZ = 0 val slots = SlotConfiguration.empty. newLong("n", nullable = true, CTNode). newReference("z", nullable = false, CTAny) - val lookup: Map[LogicalPlanId, SlotConfiguration] = Map( - arg.assignedId -> SlotConfiguration.empty, - selection.assignedId -> slots) + val lookup: Map[Id, SlotConfiguration] = Map( + arg.id -> SlotConfiguration.empty, + selection.id -> slots) val tokenContext = mock[TokenContext] val tokenId = 666 when(tokenContext.getOptPropertyKeyId("prop")).thenReturn(Some(tokenId)) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedExecutionResultBuilderFactory.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedExecutionResultBuilderFactory.scala index 567fac9e958f3..d5738238eb952 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedExecutionResultBuilderFactory.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedExecutionResultBuilderFactory.scala @@ -21,7 +21,8 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration import org.neo4j.cypher.internal.compatibility.v3_4.runtime.executionplan.{BaseExecutionResultBuilderFactory, ExecutionResultBuilder, PipeInfo} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlan, LogicalPlanId} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id +import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlan import org.neo4j.values.virtual.MapValue import scala.collection.mutable @@ -29,7 +30,7 @@ import scala.collection.mutable class SlottedExecutionResultBuilderFactory(pipeInfo: PipeInfo, columns: List[String], logicalPlan: LogicalPlan, - pipelines: Map[LogicalPlanId, SlotConfiguration]) + pipelines: Map[Id, SlotConfiguration]) extends BaseExecutionResultBuilderFactory(pipeInfo, columns, logicalPlan) { override def create(): ExecutionResultBuilder = diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilder.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilder.scala index 9ad54851fa519..ab2dad92f3712 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilder.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilder.scala @@ -58,9 +58,9 @@ class SlottedPipeBuilder(fallback: PipeBuilder, override def build(plan: LogicalPlan): Pipe = { implicit val table: SemanticTable = context.semanticTable - val id = plan.assignedId - val slots = physicalPlan.slotConfigurations(plan.assignedId) - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val id = plan.id + val slots = physicalPlan.slotConfigurations(plan.id) + val argumentSize = physicalPlan.argumentSizes(plan.id) val pipe = plan match { case AllNodesScan(IdName(column), _) => @@ -95,8 +95,8 @@ class SlottedPipeBuilder(fallback: PipeBuilder, override def build(plan: LogicalPlan, source: Pipe): Pipe = { implicit val table: SemanticTable = context.semanticTable - val id = plan.assignedId - val slots = physicalPlan.slotConfigurations(plan.assignedId) + val id = plan.id + val slots = physicalPlan.slotConfigurations(plan.id) val pipe = plan match { case ProduceResult(_, columns) => @@ -143,7 +143,7 @@ class SlottedPipeBuilder(fallback: PipeBuilder, val toSlot = slots(toName) // The node/edge predicates are evaluated on the source pipeline, not the produced one - val sourceSlots = physicalPlan.slotConfigurations(sourcePlan.assignedId) + val sourceSlots = physicalPlan.slotConfigurations(sourcePlan.id) val tempNodeOffset = sourceSlots.getLongOffsetFor(tempNode) val tempEdgeOffset = sourceSlots.getLongOffsetFor(tempEdge) val argumentSize = SlotConfiguration.Size(sourceSlots.numberOfLongs - 2, sourceSlots.numberOfReferences) @@ -158,7 +158,7 @@ class SlottedPipeBuilder(fallback: PipeBuilder, case Optional(inner, symbols) => val nullableKeys = inner.availableSymbols -- symbols val nullableSlots: Array[Slot] = nullableKeys.map(k => slots.get(k.name).get).toArray - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) OptionalSlottedPipe(source, nullableSlots, slots, argumentSize)(id) case Projection(_, expressions) => @@ -326,8 +326,8 @@ class SlottedPipeBuilder(fallback: PipeBuilder, implicit val table: SemanticTable = context.semanticTable val slotConfigs = physicalPlan.slotConfigurations - val id = plan.assignedId - val slots = slotConfigs(plan.assignedId) + val id = plan.id + val slots = slotConfigs(plan.id) val pipe = plan match { case Apply(_, _) => @@ -338,16 +338,16 @@ class SlottedPipeBuilder(fallback: PipeBuilder, fallback.build(plan, lhs, rhs) case RollUpApply(_, rhsPlan, collectionName, identifierToCollect, nullables) => - val rhsSlots = slotConfigs(rhsPlan.assignedId) + val rhsSlots = slotConfigs(rhsPlan.id) val identifierToCollectExpression = createProjectionForIdentifier(rhsSlots)(identifierToCollect.name) val collectionRefSlotOffset = slots.getReferenceOffsetFor(collectionName.name) RollUpApplySlottedPipe(lhs, rhs, collectionRefSlotOffset, identifierToCollectExpression, nullables.map(_.name), slots)(id = id) case _: CartesianProduct => - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) val lhsPlan = plan.lhs.get - val lhsSlots = slotConfigs(lhsPlan.assignedId) + val lhsSlots = slotConfigs(lhsPlan.id) // Verify the assumption that the only shared slots we have are arguments which are identical on both lhs and rhs. // This assumption enables us to use array copy within CartesianProductSlottedPipe. @@ -356,9 +356,9 @@ class SlottedPipeBuilder(fallback: PipeBuilder, CartesianProductSlottedPipe(lhs, rhs, lhsSlots.numberOfLongs, lhsSlots.numberOfReferences, slots, argumentSize)(id) case joinPlan: NodeHashJoin => - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) val leftNodes: Array[Int] = joinPlan.nodes.map(k => slots.getLongOffsetFor(k.name)).toArray - val rhsSlots = slotConfigs(joinPlan.right.assignedId) + val rhsSlots = slotConfigs(joinPlan.right.id) val rightNodes: Array[Int] = joinPlan.nodes.map(k => rhsSlots.getLongOffsetFor(k.name)).toArray val copyLongsFromRHS = collection.mutable.ArrayBuffer.newBuilder[(Int,Int)] val copyRefsFromRHS = collection.mutable.ArrayBuffer.newBuilder[(Int,Int)] @@ -378,10 +378,10 @@ class SlottedPipeBuilder(fallback: PipeBuilder, NodeHashJoinSlottedPipe(leftNodes, rightNodes, lhs, rhs, slots, copyLongsFromRHS.result().toArray, copyRefsFromRHS.result().toArray)(id) case ValueHashJoin(lhsPlan, _, Equals(lhsAstExp, rhsAstExp)) => - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) val lhsCmdExp = convertExpressions(lhsAstExp) val rhsCmdExp = convertExpressions(rhsAstExp) - val lhsSlots = slotConfigs(lhsPlan.assignedId) + val lhsSlots = slotConfigs(lhsPlan.id) val longOffset = lhsSlots.numberOfLongs val refOffset = lhsSlots.numberOfReferences @@ -436,11 +436,11 @@ class SlottedPipeBuilder(fallback: PipeBuilder, // Verifies the assumption that all shared slots are arguments with slot offsets within the first argument size number of slots // and the number of shared slots are identical to the argument size. private def verifyOnlyArgumentsAreSharedSlots(plan: LogicalPlan, physicalPlan: PhysicalPlan) = { - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) val lhsPlan = plan.lhs.get val rhsPlan = plan.rhs.get - val lhsSlots = physicalPlan.slotConfigurations(lhsPlan.assignedId) - val rhsSlots = physicalPlan.slotConfigurations(rhsPlan.assignedId) + val lhsSlots = physicalPlan.slotConfigurations(lhsPlan.id) + val rhsSlots = physicalPlan.slotConfigurations(rhsPlan.id) val (sharedSlots, rhsUniqueSlots) = rhsSlots.partitionSlots { case (k, slot) => lhsSlots.get(k).isDefined @@ -463,11 +463,11 @@ class SlottedPipeBuilder(fallback: PipeBuilder, } private def verifyArgumentsAreTheSameOnBothSides(plan: LogicalPlan, physicalPlan: PhysicalPlan) = { - val argumentSize = physicalPlan.argumentSizes(plan.assignedId) + val argumentSize = physicalPlan.argumentSizes(plan.id) val lhsPlan = plan.lhs.get val rhsPlan = plan.rhs.get - val lhsSlots = physicalPlan.slotConfigurations(lhsPlan.assignedId) - val rhsSlots = physicalPlan.slotConfigurations(rhsPlan.assignedId) + val lhsSlots = physicalPlan.slotConfigurations(lhsPlan.id) + val rhsSlots = physicalPlan.slotConfigurations(rhsPlan.id) val (lhsLongSlots, lhsRefSlots) = lhsSlots.partitionSlots((_, slot) => slot.isLongSlot) val (rhsLongSlots, rhsRefSlots) = rhsSlots.partitionSlots((_, slot) => slot.isLongSlot) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/AllNodesScanSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/AllNodesScanSlottedPipe.scala index 0686c2a0921ac..eb65b6592019a 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/AllNodesScanSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/AllNodesScanSlottedPipe.scala @@ -25,10 +25,10 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.helpers.PrimitiveLon import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class AllNodesScanSlottedPipe(ident: String, slots: SlotConfiguration, argumentSize: Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { private val offset = slots.getLongOffsetFor(ident) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ApplySlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ApplySlottedPipe.scala index b1ac0c70f2ffa..4f367bb87683b 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ApplySlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ApplySlottedPipe.scala @@ -21,10 +21,10 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ApplySlottedPipe(lhs: Pipe, rhs: Pipe) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(lhs) with Pipe { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = input.flatMap { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ArgumentSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ArgumentSlottedPipe.scala index e75764b3f6e2c..9de0e51ba811f 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ArgumentSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ArgumentSlottedPipe.scala @@ -23,11 +23,11 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration.Size import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ArgumentSlottedPipe(slots: SlotConfiguration, argumentSize:Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends Pipe { def internalCreateResults(state: QueryState): Iterator[SlottedExecutionContext] = { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/BaseRelationshipSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/BaseRelationshipSlottedPipe.scala index 9378277945b9a..506fe7bdd6a6d 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/BaseRelationshipSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/BaseRelationshipSlottedPipe.scala @@ -27,8 +27,8 @@ import org.neo4j.cypher.internal.runtime.QueryContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{LazyType, Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, IsMap, makeValueNeoSafe} +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.util.v3_4.{CypherTypeException, InvalidSemanticsException} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.graphdb.{Node, Relationship} import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values @@ -108,7 +108,7 @@ case class CreateRelationshipSlottedPipe(src: Pipe, endNode: Slot, slots: SlotConfiguration, properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseRelationshipSlottedPipe(src, RelationshipKey, startNode, typ: LazyType, endNode, slots, properties) { override protected def handleNull(key: String) { //do nothing @@ -122,7 +122,7 @@ case class MergeCreateRelationshipSlottedPipe(src: Pipe, endNode: Slot, slots: SlotConfiguration, properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseRelationshipSlottedPipe(src, RelationshipKey, startNode, typ: LazyType, endNode, slots, properties) { override protected def handleNull(key: String) { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CartesianProductSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CartesianProductSlottedPipe.scala index 93be14f04d804..941ceeecf89d0 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CartesianProductSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CartesianProductSlottedPipe.scala @@ -23,13 +23,13 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class CartesianProductSlottedPipe(lhs: Pipe, rhs: Pipe, lhsLongCount: Int, lhsRefCount: Int, slots: SlotConfiguration, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { lhs.createResults(state) flatMap { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ConditionalApplySlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ConditionalApplySlottedPipe.scala index cb7f26aa88ef6..676a5faf41273 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ConditionalApplySlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ConditionalApplySlottedPipe.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecu import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.NullChecker import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class ConditionalApplySlottedPipe(lhs: Pipe, @@ -33,7 +33,7 @@ case class ConditionalApplySlottedPipe(lhs: Pipe, refOffsets: Seq[Int], negated: Boolean, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(lhs) with Pipe { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CreateNodeSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CreateNodeSlottedPipe.scala index b1101941732d3..da2a7428d0c70 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CreateNodeSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/CreateNodeSlottedPipe.scala @@ -27,7 +27,7 @@ import org.neo4j.cypher.internal.util.v3_4.{CypherTypeException, InvalidSemantic import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{LazyLabel, Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, IsMap, makeValueNeoSafe} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.graphdb.{Node, Relationship} import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values @@ -90,7 +90,7 @@ case class CreateNodeSlottedPipe(source: Pipe, slots: SlotConfiguration, labels: Seq[LazyLabel], properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseCreateNodeSlottedPipe(source, ident, slots, labels, properties) { override protected def handleNull(key: String) { @@ -103,7 +103,7 @@ case class MergeCreateNodeSlottedPipe(source: Pipe, slots: SlotConfiguration, labels: Seq[LazyLabel], properties: Option[Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends BaseCreateNodeSlottedPipe(source, ident, slots, labels, properties) { override protected def handleNull(key: String) { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/DistinctSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/DistinctSlottedPipe.scala index 85d155f4534cb..156b027012052 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/DistinctSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/DistinctSlottedPipe.scala @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.Slot import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.virtual.VirtualValues @@ -34,7 +34,7 @@ import scala.collection.mutable case class DistinctSlottedPipe(source: Pipe, slots: SlotConfiguration, groupingExpressions: Map[Slot, Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { //=========================================================================== diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationSlottedPipe.scala index 64aeb5050d1c1..4de00861641e8 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationSlottedPipe.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.{Aggre import org.neo4j.cypher.internal.runtime.interpreted.pipes.aggregation.AggregationFunction import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.virtual.{ListValue, MapValue, VirtualValues} @@ -40,7 +40,7 @@ case class EagerAggregationSlottedPipe(source: Pipe, slots: SlotConfiguration, groupingExpressions: Map[Slot, Expression], aggregations: Map[Int, AggregationExpression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { aggregations.values.foreach(_.registerOwningPipe(this)) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationWithoutGroupingSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationWithoutGroupingSlottedPipe.scala index 91a5a56c6d6d6..e390f5b4f4d11 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationWithoutGroupingSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerAggregationWithoutGroupingSlottedPipe.scala @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Aggreg import org.neo4j.cypher.internal.runtime.interpreted.pipes.aggregation.AggregationFunction import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id /* This pipe can be used whenever we are aggregating and not grouping on anything @@ -33,7 +33,7 @@ This pipe can be used whenever we are aggregating and not grouping on anything case class EagerAggregationWithoutGroupingSlottedPipe(source: Pipe, slots: SlotConfiguration, aggregations: Map[Int, AggregationExpression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { aggregations.values.foreach(_.registerOwningPipe(this)) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerSlottedPipe.scala index 4c39f0c0c4322..c8d09f1f2b4f2 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/EagerSlottedPipe.scala @@ -23,9 +23,9 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.SlotConfiguration import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id -case class EagerSlottedPipe(source: Pipe, slots: SlotConfiguration)(val id: LogicalPlanId = LogicalPlanId.DEFAULT) +case class EagerSlottedPipe(source: Pipe, slots: SlotConfiguration)(val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandAllSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandAllSlottedPipe.scala index 47b2a5bb2c26e..4927dac49cc01 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandAllSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandAllSlottedPipe.scala @@ -27,8 +27,8 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{Slot, SlotConfigura import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.kernel.impl.api.RelationshipVisitor import org.neo4j.kernel.impl.api.store.RelationshipIterator @@ -39,7 +39,7 @@ case class ExpandAllSlottedPipe(source: Pipe, dir: SemanticDirection, types: LazyTypes, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with Pipe { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { //=========================================================================== // Compile-time initializations diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandIntoSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandIntoSlottedPipe.scala index a9f04a79decf1..53bc8e8b04a1f 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandIntoSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ExpandIntoSlottedPipe.scala @@ -27,7 +27,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.Null import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.SlottedPipeBuilderUtils.makeGetPrimitiveNodeFromSlotFunctionFor import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection /** @@ -46,7 +46,7 @@ case class ExpandIntoSlottedPipe(source: Pipe, dir: SemanticDirection, lazyTypes: LazyTypes, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with PrimitiveCachingExpandInto { self => diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ForeachSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ForeachSlottedPipe.scala index ca6410f7d6ece..7e69fcb48572d 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ForeachSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ForeachSlottedPipe.scala @@ -24,12 +24,12 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.Slot import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, ListSupport} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import scala.collection.JavaConverters._ case class ForeachSlottedPipe(lhs: Pipe, rhs: Pipe, innerVariableSlot: Slot, expression: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(lhs) with Pipe with ListSupport { //=========================================================================== diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeHashJoinSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeHashJoinSlottedPipe.scala index bc5965495db75..e77e76d71edb9 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeHashJoinSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeHashJoinSlottedPipe.scala @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecu import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.NullChecker.entityIsNull import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class NodeHashJoinSlottedPipe(leftSide: Array[Int], rightSide: Array[Int], @@ -35,7 +35,7 @@ case class NodeHashJoinSlottedPipe(leftSide: Array[Int], slots: SlotConfiguration, longsToCopy: Array[(Int, Int)], refsToCopy: Array[(Int, Int)]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends AbstractHashJoinPipe[HashKey, Array[Int]](left, right, slots) { /** diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexScanSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexScanSlottedPipe.scala index 478b4321b1d80..0ba4206d01b02 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexScanSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexScanSlottedPipe.scala @@ -25,15 +25,15 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecu import org.neo4j.cypher.internal.planner.v3_4.spi.IndexDescriptor import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.{LabelToken, PropertyKeyToken} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId case class NodeIndexScanSlottedPipe(ident: String, label: LabelToken, propertyKey: PropertyKeyToken, slots: SlotConfiguration, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends Pipe { private val offset = slots.getLongOffsetFor(ident) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexSeekSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexSeekSlottedPipe.scala index 034ee4ff2864c..53f7f52f8e5d8 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexSeekSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodeIndexSeekSlottedPipe.scala @@ -26,8 +26,9 @@ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.commands.indexQuery import org.neo4j.cypher.internal.runtime.interpreted.pipes._ +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.{LabelToken, PropertyKeyToken} -import org.neo4j.cypher.internal.v3_4.logical.plans.{LogicalPlanId, QueryExpression} +import org.neo4j.cypher.internal.v3_4.logical.plans.QueryExpression case class NodeIndexSeekSlottedPipe(ident: String, label: LabelToken, @@ -36,7 +37,7 @@ case class NodeIndexSeekSlottedPipe(ident: String, indexMode: IndexSeekMode = IndexSeek, slots: SlotConfiguration, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { private val offset = slots.getLongOffsetFor(ident) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodesByLabelScanSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodesByLabelScanSlottedPipe.scala index 77f73e249f531..75b7342a2428a 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodesByLabelScanSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/NodesByLabelScanSlottedPipe.scala @@ -24,13 +24,13 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.helpers.PrimitiveLon import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{LazyLabel, Pipe, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class NodesByLabelScanSlottedPipe(ident: String, label: LazyLabel, slots: SlotConfiguration, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { private val offset = slots.getLongOffsetFor(ident) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandAllSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandAllSlottedPipe.scala index 62c72778909ff..011bb1a250ff0 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandAllSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandAllSlottedPipe.scala @@ -28,7 +28,7 @@ import org.neo4j.cypher.internal.util.v3_4.InternalException import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection import org.neo4j.kernel.impl.api.RelationshipVisitor import org.neo4j.kernel.impl.api.store.RelationshipIterator @@ -41,7 +41,7 @@ case class OptionalExpandAllSlottedPipe(source: Pipe, types: LazyTypes, predicate: Predicate, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with Pipe { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { //=========================================================================== // Compile-time initializations diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandIntoSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandIntoSlottedPipe.scala index d25ef2710e61f..554553b460ca6 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandIntoSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalExpandIntoSlottedPipe.scala @@ -28,7 +28,7 @@ import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.NullChecker.entityIsNull import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.helpers.SlottedPipeBuilderUtils.makeGetPrimitiveNodeFromSlotFunctionFor import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection case class OptionalExpandIntoSlottedPipe(source: Pipe, @@ -39,7 +39,7 @@ case class OptionalExpandIntoSlottedPipe(source: Pipe, lazyTypes: LazyTypes, predicate: Predicate, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with PrimitiveCachingExpandInto { self => diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalSlottedPipe.scala index 505252b779b65..e00fd6f2349c0 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/OptionalSlottedPipe.scala @@ -23,14 +23,14 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, RefSlot, import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values case class OptionalSlottedPipe(source: Pipe, nullableSlots: Seq[Slot], slots: SlotConfiguration, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { //=========================================================================== diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProduceResultSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProduceResultSlottedPipe.scala index 0f1035ba48f8f..424f39d1c7abb 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProduceResultSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProduceResultSlottedPipe.scala @@ -22,10 +22,10 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes._ import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, MutableMaps} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class ProduceResultSlottedPipe(source: Pipe, columns: Seq[(String, Expression)]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with Pipe { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with Pipe { protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = { // do not register this pipe as parent as it does not do anything except filtering of already fetched // key-value pairs and thus should not have any stats diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProjectionSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProjectionSlottedPipe.scala index 6577ef3cd229d..b95c4374976d6 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProjectionSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ProjectionSlottedPipe.scala @@ -22,14 +22,14 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id /* Projection evaluates expressions and stores their values into new slots in the execution context. It's an additive operation - nothing is lost in the execution context, the pipe simply adds new key-value pairs. */ case class ProjectionSlottedPipe(source: Pipe, introducedExpressions: Map[Int, Expression]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { introducedExpressions.values.foreach(_.registerOwningPipe(this)) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/RollUpApplySlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/RollUpApplySlottedPipe.scala index 61dec0681ea17..6e49f9d2a40ff 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/RollUpApplySlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/RollUpApplySlottedPipe.scala @@ -19,11 +19,11 @@ */ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes -import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, SlotConfiguration, RefSlot} +import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, RefSlot, SlotConfiguration} import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.Values.NO_VALUE import org.neo4j.values.virtual.VirtualValues @@ -32,7 +32,7 @@ case class RollUpApplySlottedPipe(lhs: Pipe, rhs: Pipe, identifierToCollect: (String, Expression), nullableIdentifiers: Set[String], slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(lhs) { private val getValueToCollectFunction = { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/SortSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/SortSlottedPipe.scala index 065b3e837fcc7..9fde41bec13d9 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/SortSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/SortSlottedPipe.scala @@ -21,16 +21,16 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes import java.util.Comparator -import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, SlotConfiguration, RefSlot, Slot} +import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, RefSlot, Slot, SlotConfiguration} import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.{AnyValue, AnyValues} case class SortSlottedPipe(source: Pipe, orderBy: Seq[ColumnOrder], slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { assert(orderBy.nonEmpty) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/TopSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/TopSlottedPipe.scala index f06840c529c30..8ecaf6170ccdd 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/TopSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/TopSlottedPipe.scala @@ -25,7 +25,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.DefaultCompa import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.storable.NumberValue import scala.collection.JavaConverters._ @@ -43,7 +43,7 @@ abstract class TopSlottedPipe(source: Pipe, orderBy: Seq[ColumnOrder]) } case class TopNSlottedPipe(source: Pipe, orderBy: Seq[ColumnOrder], countExpression: Expression) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends TopSlottedPipe(source, orderBy) { + (val id: Id = Id.INVALID_ID) extends TopSlottedPipe(source, orderBy) { countExpression.registerOwningPipe(this) @@ -75,7 +75,7 @@ case class TopNSlottedPipe(source: Pipe, orderBy: Seq[ColumnOrder], countExpress * an array, instead just store a single value. */ case class Top1SlottedPipe(source: Pipe, orderBy: List[ColumnOrder]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends TopSlottedPipe(source, orderBy) { protected override def internalCreateResults(input: Iterator[ExecutionContext], @@ -104,7 +104,7 @@ case class Top1SlottedPipe(source: Pipe, orderBy: List[ColumnOrder]) * Special case for when we only want one element, and all others that have the same value (tied for first place) */ case class Top1WithTiesSlottedPipe(source: Pipe, orderBy: List[ColumnOrder]) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends TopSlottedPipe(source, orderBy) { protected override def internalCreateResults(input: Iterator[ExecutionContext], diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnionSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnionSlottedPipe.scala index 435d0fa48f76f..62766a3537464 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnionSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnionSlottedPipe.scala @@ -22,12 +22,12 @@ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedPipeBuilder.RowMapping import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id case class UnionSlottedPipe(lhs: Pipe, rhs: Pipe, lhsMapping: RowMapping, rhsMapping: RowMapping) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends Pipe { + (val id: Id = Id.INVALID_ID) extends Pipe { protected def internalCreateResults(state: QueryState): Iterator[ExecutionContext] = { val left = lhs.createResults(state) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnwindSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnwindSlottedPipe.scala index 4639c2fb74c03..b2485fb3dd7b3 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnwindSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/UnwindSlottedPipe.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecu import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.{ExecutionContext, ListSupport} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import scala.annotation.tailrec @@ -34,7 +34,7 @@ case class UnwindSlottedPipe(source: Pipe, collection: Expression, offset: Int, slots: SlotConfiguration) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) with ListSupport { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) with ListSupport { override protected def internalCreateResults(input: Iterator[ExecutionContext], state: QueryState): Iterator[ExecutionContext] = new UnwindIterator(input, state) diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ValueHashJoinSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ValueHashJoinSlottedPipe.scala index c188a58c64c7f..cf14b6b0dbd5e 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ValueHashJoinSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/ValueHashJoinSlottedPipe.scala @@ -24,7 +24,7 @@ import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecu import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.expressions.Expression import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.values.AnyValue import org.neo4j.values.storable.Values.NO_VALUE @@ -36,7 +36,7 @@ case class ValueHashJoinSlottedPipe(leftSide: Expression, longOffset: Int, refsOffset: Int, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) + (val id: Id = Id.INVALID_ID) extends AbstractHashJoinPipe[AnyValue, Expression](left, right, slots) { override def computeKey(context: ExecutionContext, keyColumns: Expression, queryState: QueryState): Option[AnyValue] = { diff --git a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/VarLengthExpandSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/VarLengthExpandSlottedPipe.scala index b5d37cf5357d6..91425e09bebd4 100644 --- a/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/VarLengthExpandSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/main/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/VarLengthExpandSlottedPipe.scala @@ -27,8 +27,8 @@ import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.Predicate import org.neo4j.cypher.internal.runtime.interpreted.pipes.{LazyTypes, Pipe, PipeWithSource, QueryState} import org.neo4j.cypher.internal.util.v3_4.InternalException +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.neo4j.cypher.internal.v3_4.expressions.SemanticDirection -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId import org.neo4j.kernel.impl.api.RelationshipVisitor import org.neo4j.kernel.impl.api.store.RelationshipIterator import org.neo4j.values.storable.Values @@ -53,7 +53,7 @@ case class VarLengthExpandSlottedPipe(source: Pipe, nodePredicate: Predicate, edgePredicate: Predicate, argumentSize: SlotConfiguration.Size) - (val id: LogicalPlanId = LogicalPlanId.DEFAULT) extends PipeWithSource(source) { + (val id: Id = Id.INVALID_ID) extends PipeWithSource(source) { type LNode = Long //=========================================================================== diff --git a/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilderTest.scala b/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilderTest.scala index b0264ad692d89..4c41123f2e5bf 100644 --- a/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilderTest.scala +++ b/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/SlottedPipeBuilderTest.scala @@ -54,7 +54,6 @@ class SlottedPipeBuilderTest extends CypherFunSuite with LogicalPlanningTestSupp implicit private val table = SemanticTable() private def build(beforeRewrite: LogicalPlan): Pipe = { - beforeRewrite.assignIds() val planContext = mock[PlanContext] when(planContext.statistics).thenReturn(HardcodedGraphStatistics) when(planContext.getOptPropertyKeyId("propertyKey")).thenReturn(Some(0)) diff --git a/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/FakeSlottedPipe.scala b/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/FakeSlottedPipe.scala index ac221e10fb6a3..b453e92e43869 100644 --- a/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/FakeSlottedPipe.scala +++ b/enterprise/cypher/slotted-runtime/src/test/scala/org/neo4j/cypher/internal/compatibility/v3_4/runtime/slotted/pipes/FakeSlottedPipe.scala @@ -19,12 +19,12 @@ */ package org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.pipes -import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, SlotConfiguration, RefSlot} +import org.neo4j.cypher.internal.compatibility.v3_4.runtime.{LongSlot, RefSlot, SlotConfiguration} import org.neo4j.cypher.internal.compatibility.v3_4.runtime.slotted.SlottedExecutionContext import org.neo4j.cypher.internal.runtime.interpreted.ValueConversion.asValue import org.neo4j.cypher.internal.runtime.interpreted.pipes.{Pipe, QueryState} import org.neo4j.cypher.internal.runtime.interpreted.ExecutionContext -import org.neo4j.cypher.internal.v3_4.logical.plans.LogicalPlanId +import org.neo4j.cypher.internal.util.v3_4.attribution.Id import org.scalatest.mock.MockitoSugar case class FakeSlottedPipe(data: Iterator[Map[String, Any]], slots: SlotConfiguration) @@ -51,5 +51,5 @@ case class FakeSlottedPipe(data: Iterator[Map[String, Any]], slots: SlotConfigur } } - var id = LogicalPlanId.DEFAULT + var id: Id = Id.INVALID_ID }