Skip to content

Commit

Permalink
Revert changes around Supplier in Cypher compiler code generator
Browse files Browse the repository at this point in the history
The problem is that the cypher-compiler-2.3 depends on
org.neo4j.function.Supplier and since 3.0 has a binary dependency
against the cypher-compiler-2.3 we cannot remove
org.neo4j.function.Supplier wihtout removing that dependency in 2.3.

Unfortunately, for the time being, we need to keep
org.neo4j.function.Supplier around.
  • Loading branch information
davidegrohmann committed Dec 10, 2015
1 parent cd5d1f8 commit dbe10b6
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 31 deletions.
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.cypher.internal.compiler.v3_0.executionplan;

import java.util.Map;
import java.util.function.Supplier;

import org.neo4j.cypher.internal.compiler.v3_0.ExecutionMode;
import org.neo4j.cypher.internal.compiler.v3_0.TaskCloser;
Expand All @@ -36,7 +35,7 @@ GeneratedQueryExecution execute(
Statement statement,
NodeManager nodeManager,
ExecutionMode executionMode,
Supplier<InternalPlanDescription> description,
org.neo4j.function.Supplier<InternalPlanDescription> description,
QueryExecutionTracer tracer,
Map<String,Object> params );
}
Expand Up @@ -21,7 +21,6 @@ package org.neo4j.cypher.internal.compiler.v3_0.codegen

import java.lang.Boolean.getBoolean
import java.util
import java.util.function.Supplier

import org.neo4j.cypher.internal.compiler.v3_0.codegen.CodeGenerator.SourceSink
import org.neo4j.cypher.internal.compiler.v3_0.codegen.ir._
Expand All @@ -45,7 +44,7 @@ class CodeGenerator(val structure: CodeStructure[GeneratedQuery]) {

import CodeGenerator.generateCode

type PlanDescriptionProvider = (InternalPlanDescription) => (Supplier[InternalPlanDescription], Option[QueryExecutionTracer])
type PlanDescriptionProvider = (InternalPlanDescription) => (org.neo4j.function.Supplier[InternalPlanDescription], Option[QueryExecutionTracer])

def generate(plan: LogicalPlan, planContext: PlanContext, clock: Clock, semanticTable: SemanticTable, plannerName: PlannerName) = {
plan match {
Expand Down
Expand Up @@ -21,7 +21,6 @@ package org.neo4j.cypher.internal.compiler.v3_0.executionplan

import java.io.{PrintWriter, StringWriter}
import java.util
import java.util.function.Supplier

import org.neo4j.cypher.internal.compiler.v3_0._
import org.neo4j.cypher.internal.compiler.v3_0.commands.values.KeyToken
Expand Down Expand Up @@ -51,7 +50,7 @@ trait SuccessfulCloseable {
class CompiledExecutionResult(taskCloser: TaskCloser,
statement: Statement,
compiledCode: GeneratedQueryExecution,
description: Supplier[InternalPlanDescription])
description: org.neo4j.function.Supplier[InternalPlanDescription])
extends InternalExecutionResult with SuccessfulCloseable {
self =>

Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.cypher.internal.compiler.v3_0.executionplan

import java.util.function.Supplier

import org.neo4j.cypher.internal.compiler.v3_0.codegen.QueryExecutionTracer
import org.neo4j.cypher.internal.compiler.v3_0.codegen.profiling.ProfilingTracer
import org.neo4j.cypher.internal.compiler.v3_0.commands._
Expand All @@ -38,7 +36,6 @@ import org.neo4j.cypher.internal.compiler.v3_0.{ExecutionMode, ProfileMode, _}
import org.neo4j.cypher.internal.frontend.v3_0.PeriodicCommitInOpenTransactionException
import org.neo4j.cypher.internal.frontend.v3_0.ast.Statement
import org.neo4j.cypher.internal.frontend.v3_0.notification.InternalNotification
import org.neo4j.function.Suppliers.singleton
import org.neo4j.graphdb.GraphDatabaseService
import org.neo4j.graphdb.QueryExecutionType.QueryType
import org.neo4j.helpers.Clock
Expand Down Expand Up @@ -232,12 +229,12 @@ class ExecutionPlanBuilder(graph: GraphDatabaseService, config: CypherCompilerCo
}

object ExecutionPlanBuilder {
type DescriptionProvider = (InternalPlanDescription => (Supplier[InternalPlanDescription], Option[QueryExecutionTracer]))
type DescriptionProvider = (InternalPlanDescription => (org.neo4j.function.Supplier[InternalPlanDescription], Option[QueryExecutionTracer]))

def tracer( mode: ExecutionMode ) : DescriptionProvider = mode match {
case ProfileMode =>
val tracer = new ProfilingTracer()
(description: InternalPlanDescription) => (new Supplier[InternalPlanDescription] {
(description: InternalPlanDescription) => (new org.neo4j.function.Supplier[InternalPlanDescription] {

override def get(): InternalPlanDescription = description.map {
plan: InternalPlanDescription =>
Expand All @@ -248,6 +245,8 @@ object ExecutionPlanBuilder {
addArgument(Arguments.Time(data.time()))
}
}, Some(tracer))
case _ => (description: InternalPlanDescription) => (singleton(description), None)
case _ => (description: InternalPlanDescription) => (new org.neo4j.function.Supplier[InternalPlanDescription] {
override def get(): InternalPlanDescription = description
}, None)
}
}
Expand Up @@ -21,7 +21,6 @@
package org.neo4j.cypher.internal.spi.v2_3

import java.util
import java.util.function.Supplier

import org.neo4j.codegen
import org.neo4j.codegen.CodeGeneratorOption._
Expand Down Expand Up @@ -73,7 +72,7 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] {
ro = clazz.field(typeRef[ReadOperations], "ro"),
nodeManager = clazz.field(typeRef[NodeManager], "nodeManager"),
executionMode = clazz.field(typeRef[ExecutionMode], "executionMode"),
description = clazz.field(typeRef[Supplier[InternalPlanDescription]], "description"),
description = clazz.field(typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description"),
tracer = clazz.field(typeRef[QueryExecutionTracer], "tracer"),
params = clazz.field(typeRef[util.Map[String, Object]], "params"),
closeable = clazz.field(typeRef[SuccessfulCloseable], "closeable"),
Expand Down Expand Up @@ -117,15 +116,15 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] {
param[Statement]("statement"),
param[NodeManager]("nodeManager"),
param[ExecutionMode]("executionMode"),
param[Supplier[InternalPlanDescription]]("description"),
param[org.neo4j.function.Supplier[InternalPlanDescription]]("description"),
param[QueryExecutionTracer]("tracer"),
param[util.Map[String, Object]]("params"))) { execute =>
execute.returns(Expression.invoke(Expression.newInstance(execution), MethodReference.constructorReference(execution,
typeRef[TaskCloser],
typeRef[Statement],
typeRef[NodeManager],
typeRef[ExecutionMode],
typeRef[Supplier[InternalPlanDescription]],
typeRef[org.neo4j.function.Supplier[InternalPlanDescription]],
typeRef[QueryExecutionTracer],
typeRef[util.Map[String, Object]]),
execute.load("closer"),
Expand Down Expand Up @@ -849,13 +848,13 @@ private object Templates {
param[Statement]("statement"),
param[NodeManager]("nodeManager"),
param[ExecutionMode]("executionMode"),
param[Supplier[InternalPlanDescription]]("description"),
param[org.neo4j.function.Supplier[InternalPlanDescription]]("description"),
param[QueryExecutionTracer]("tracer"),
param[util.Map[String, Object]]("params")).
put(self(), typeRef[TaskCloser], "closer", load("closer")).
put(self(), typeRef[ReadOperations], "ro", invoke(load("statement"), method[Statement, ReadOperations]("readOperations"))).
put(self(), typeRef[ExecutionMode], "executionMode", load("executionMode")).
put(self(), typeRef[Supplier[InternalPlanDescription]], "description", load("description")).
put(self(), typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description", load("description")).
put(self(), typeRef[QueryExecutionTracer], "tracer", load("tracer")).
put(self(), typeRef[util.Map[String, Object]], "params", load("params")).
put(self(), typeRef[NodeManager], "nodeManager", load("nodeManager")).
Expand All @@ -875,7 +874,7 @@ private object Templates {
returns(get(self(), typeRef[ExecutionMode], "executionMode")).
build()
val EXECUTION_PLAN_DESCRIPTION = MethodTemplate.method(typeRef[InternalPlanDescription], "executionPlanDescription").
returns(invoke(get(self(), typeRef[Supplier[InternalPlanDescription]], "description"), method[Supplier[InternalPlanDescription], InternalPlanDescription]("get"))).
returns(invoke(get(self(), typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description"), method[org.neo4j.function.Supplier[InternalPlanDescription], InternalPlanDescription]("get"))).
build()
val JAVA_COLUMNS = MethodTemplate.method(typeRef[util.List[String]], "javaColumns").
returns(get(typeRef[util.List[String]], "COLUMNS")).
Expand Down
Expand Up @@ -21,7 +21,6 @@
package org.neo4j.cypher.internal.spi.v3_0

import java.util
import java.util.function.Supplier

import org.neo4j.codegen
import org.neo4j.codegen.CodeGeneratorOption._
Expand Down Expand Up @@ -73,7 +72,7 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] {
ro = clazz.field(typeRef[ReadOperations], "ro"),
nodeManager = clazz.field(typeRef[NodeManager], "nodeManager"),
executionMode = clazz.field(typeRef[ExecutionMode], "executionMode"),
description = clazz.field(typeRef[Supplier[InternalPlanDescription]], "description"),
description = clazz.field(typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description"),
tracer = clazz.field(typeRef[QueryExecutionTracer], "tracer"),
params = clazz.field(typeRef[util.Map[String, Object]], "params"),
closeable = clazz.field(typeRef[SuccessfulCloseable], "closeable"),
Expand Down Expand Up @@ -117,15 +116,15 @@ object GeneratedQueryStructure extends CodeStructure[GeneratedQuery] {
param[Statement]("statement"),
param[NodeManager]("nodeManager"),
param[ExecutionMode]("executionMode"),
param[Supplier[InternalPlanDescription]]("description"),
param[org.neo4j.function.Supplier[InternalPlanDescription]]("description"),
param[QueryExecutionTracer]("tracer"),
param[util.Map[String, Object]]("params"))) { execute =>
execute.returns(Expression.invoke(Expression.newInstance(execution), MethodReference.constructorReference(execution,
typeRef[TaskCloser],
typeRef[Statement],
typeRef[NodeManager],
typeRef[ExecutionMode],
typeRef[Supplier[InternalPlanDescription]],
typeRef[org.neo4j.function.Supplier[InternalPlanDescription]],
typeRef[QueryExecutionTracer],
typeRef[util.Map[String, Object]]),
execute.load("closer"),
Expand Down Expand Up @@ -849,13 +848,13 @@ private object Templates {
param[Statement]("statement"),
param[NodeManager]("nodeManager"),
param[ExecutionMode]("executionMode"),
param[Supplier[InternalPlanDescription]]("description"),
param[org.neo4j.function.Supplier[InternalPlanDescription]]("description"),
param[QueryExecutionTracer]("tracer"),
param[util.Map[String, Object]]("params")).
put(self(), typeRef[TaskCloser], "closer", load("closer")).
put(self(), typeRef[ReadOperations], "ro", invoke(load("statement"), method[Statement, ReadOperations]("readOperations"))).
put(self(), typeRef[ExecutionMode], "executionMode", load("executionMode")).
put(self(), typeRef[Supplier[InternalPlanDescription]], "description", load("description")).
put(self(), typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description", load("description")).
put(self(), typeRef[QueryExecutionTracer], "tracer", load("tracer")).
put(self(), typeRef[util.Map[String, Object]], "params", load("params")).
put(self(), typeRef[NodeManager], "nodeManager", load("nodeManager")).
Expand All @@ -875,7 +874,7 @@ private object Templates {
returns(get(self(), typeRef[ExecutionMode], "executionMode")).
build()
val EXECUTION_PLAN_DESCRIPTION = MethodTemplate.method(typeRef[InternalPlanDescription], "executionPlanDescription").
returns(invoke(get(self(), typeRef[Supplier[InternalPlanDescription]], "description"), method[Supplier[InternalPlanDescription], InternalPlanDescription]("get"))).
returns(invoke(get(self(), typeRef[org.neo4j.function.Supplier[InternalPlanDescription]], "description"), method[org.neo4j.function.Supplier[InternalPlanDescription], InternalPlanDescription]("get"))).
build()
val JAVA_COLUMNS = MethodTemplate.method(typeRef[util.List[String]], "javaColumns").
returns(get(typeRef[util.List[String]], "COLUMNS")).
Expand Down
Expand Up @@ -20,7 +20,6 @@
package org.neo4j.cypher.internal.compiler.v3_0.codegen.ir

import java.util.concurrent.atomic.AtomicInteger
import java.util.function.Supplier

import org.mockito.Mockito._
import org.neo4j.cypher.internal.compiler.v3_0.codegen.{Namer, _}
Expand Down Expand Up @@ -115,7 +114,7 @@ trait CodeGenSugar extends MockitoSugar {
graphdb: GraphDatabaseService = null,
nodeManager: NodeManager = null,
executionMode: ExecutionMode = null,
supplier: Supplier[InternalPlanDescription] = null,
supplier: org.neo4j.function.Supplier[InternalPlanDescription] = null,
queryExecutionTracer: QueryExecutionTracer = QueryExecutionTracer.NONE,
params: Map[String, AnyRef] = Map.empty): InternalExecutionResult = {
val generated = clazz.execute(taskCloser, statement, nodeManager,
Expand Down
Expand Up @@ -19,8 +19,6 @@
*/
package org.neo4j.cypher.internal.compiler.v3_0.codegen.ir

import java.util.function.Supplier

import org.mockito.Matchers._
import org.mockito.Mockito._
import org.neo4j.collection.primitive.PrimitiveLongIterator
Expand Down Expand Up @@ -69,7 +67,7 @@ class CompiledProfilingTest extends CypherFunSuite with CodeGenSugar {
}
})

val supplier = new Supplier[InternalPlanDescription] {
val supplier = new org.neo4j.function.Supplier[InternalPlanDescription] {
override def get(): InternalPlanDescription =
PlanDescriptionImpl(id2, "accept", SingleChild(PlanDescriptionImpl(id1, "scanallnodes", NoChildren, Seq.empty, Set.empty)), Seq.empty, Set.empty)
}
Expand Down
30 changes: 30 additions & 0 deletions community/function/src/main/java/org/neo4j/function/Supplier.java
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2002-2015 "Neo Technology,"
* Network Engine for Objects in Lund AB [http://neotechnology.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.function;

/**
* Please do not use this interface but use {@link java.util.function.Supplier} instead.
* The only reason for this interface to be here is because cypher-compiler-{2.3,3.0} needs it
* when generating compile runtimes.
*/
@Deprecated
public interface Supplier<T> extends java.util.function.Supplier<T>
{
}

0 comments on commit dbe10b6

Please sign in to comment.