Skip to content

Commit

Permalink
Introduce StandardInternalExecutionResult as a refactoring of Accepti…
Browse files Browse the repository at this point in the history
…ngInternalExecutionResult

o Move procedure eagerization to ProcedureMode.call
o Extracting scala <-> java value conversion and result value text support for future refactoring
  • Loading branch information
boggle committed Feb 8, 2016
1 parent 0f0a2af commit 88ba820
Show file tree
Hide file tree
Showing 23 changed files with 695 additions and 588 deletions.
Expand Up @@ -27,6 +27,13 @@ import scala.collection.JavaConverters._

class MatchAcceptanceTest extends ExecutionEngineFunSuite with QueryStatisticsTestSupport with NewPlannerTestSupport {

test("paths are printed correctly") {
val n1 = createNode()
val n2 = createNode()
val r = relate(n1, n2)
println(executeWithAllPlannersAndCompatibilityMode("match p = (a)-[*]->(b) return p").dumpToString())
}

test("make sure non-existing nodes are not returned") {
executeWithAllPlannersAndCompatibilityMode("match (n) where id(n) = 10 return n") should be(empty)
executeWithAllPlannersAndCompatibilityMode("match ()-[r]->() where id(r) = 10 return r") should be(empty)
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -30,10 +30,16 @@

public class ResultRowImpl implements InternalResultRow
{
private Map<String, Object> results = new HashMap<>();
private Map<String, Object> results;

public ResultRowImpl( Map<String, Object> results )
{
this.results = results;
}

public ResultRowImpl( )
{
this( new HashMap<>() );
}

public void set( String k, Object value)
Expand Down
Expand Up @@ -28,7 +28,7 @@ import org.neo4j.cypher.internal.compiler.v3_0.pipes.QueryState
import org.neo4j.cypher.internal.compiler.v3_0.planDescription.InternalPlanDescription
import org.neo4j.cypher.internal.compiler.v3_0.spi.{InternalResultVisitor, QueryContext}
import org.neo4j.cypher.internal.frontend.v3_0.helpers.Eagerly
import org.neo4j.cypher.internal.frontend.v3_0.helpers.JavaCompatibility._
import org.neo4j.cypher.internal.frontend.v3_0.helpers.JavaValueCompatibility._
import org.neo4j.cypher.internal.frontend.v3_0.notification.InternalNotification
import org.neo4j.graphdb.{NotFoundException, ResourceIterator}

Expand Down Expand Up @@ -56,7 +56,7 @@ class PipeExecutionResult(val result: ResultIterator,

def javaColumnAs[T](column: String): ResourceIterator[T] = new WrappingResourceIterator[T] {
def hasNext = self.hasNext
def next() = asJavaCompatible(getAnyColumn(column, self.next())).asInstanceOf[T]
def next() = asDeepJavaValue(getAnyColumn(column, self.next())).asInstanceOf[T]
}

def columnAs[T](column: String): Iterator[T] =
Expand All @@ -65,7 +65,7 @@ class PipeExecutionResult(val result: ResultIterator,

def javaIterator: ResourceIterator[java.util.Map[String, Any]] = new WrappingResourceIterator[util.Map[String, Any]] {
def hasNext = self.hasNext
def next() = Eagerly.immutableMapValues(self.next(), asJavaCompatible).asJava
def next() = Eagerly.immutableMapValues(self.next(), asDeepJavaValue).asJava
}

override def toList: List[Predef.Map[String, Any]] = result.toList
Expand Down
Expand Up @@ -169,6 +169,8 @@ case object plannerDocGen extends CustomDocGen[Any] {
case queryProjection: QueryProjection =>
val projectionPrefix = query.tail.fold("RETURN")(_ => "WITH")
section(projectionPrefix)(queryProjection.unquote)
case _ =>
???
}
group(graphDoc :/: projectionDoc)
}
Expand All @@ -185,6 +187,9 @@ case object plannerDocGen extends CustomDocGen[Any] {

case queryProjection: UnwindProjection =>
section("UNWIND")(generateDoc(Map(queryProjection.variable.name -> queryProjection.exp), QueryShuffle.empty))

case _ =>
???
}

def generateDoc(projections: Map[String, Expression], queryShuffle: QueryShuffle): RecipeAppender[Any] = {
Expand Down

This file was deleted.

Expand Up @@ -39,7 +39,9 @@ class CompiledExecutionResult(taskCloser: TaskCloser,
context: QueryContext,
compiledCode: GeneratedQueryExecution,
description: Provider[InternalPlanDescription])
extends AcceptingExecutionResult(context, Some(taskCloser)) with SuccessfulCloseable {
extends StandardInternalExecutionResult(context, Some(taskCloser))
with StandardInternalExecutionResult.IterateByAccepting {

compiledCode.setSuccessfulCloseable(this)

// *** Delegate to compiled code
Expand Down
Expand Up @@ -28,22 +28,31 @@ import org.neo4j.cypher.internal.frontend.v3_0.notification.InternalNotification
import org.neo4j.graphdb.ResourceIterator

trait InternalExecutionResult extends Iterator[Map[String, Any]] {

def columns: List[String]
def columnAs[T](column: String): Iterator[T]

def javaColumns: java.util.List[String]
def javaColumnAs[T](column: String): ResourceIterator[T]
def columnAs[T](column: String): Iterator[T]
def javaIterator: ResourceIterator[java.util.Map[String, Any]]

def dumpToString(writer: PrintWriter)
def dumpToString(): String

def queryStatistics(): InternalQueryStatistics
def executionPlanDescription(): InternalPlanDescription
def close()

def planDescriptionRequested: Boolean
def executionPlanDescription(): InternalPlanDescription

def executionType: InternalQueryType
def executionMode: ExecutionMode

def notifications: Iterable[InternalNotification]

@throws(classOf[Exception])
def accept[EX <: Exception](visitor: InternalResultVisitor[EX])

def close()
}


0 comments on commit 88ba820

Please sign in to comment.