Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.2' into 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
craigtaverner committed May 24, 2017
2 parents 140b63b + 7a9f9ae commit ecc3e3d
Show file tree
Hide file tree
Showing 36 changed files with 249 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ private CodeBlock generate( MethodDeclaration declaration )
return new CodeBlock( this, emitter.method( declaration ), declaration.parameters() );
}

public FieldReference getField( String name )
FieldReference getField( String name )
{
return fields == null ? null : fields.get( name );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ class TaskCloser {
}
}

def isClosed: Boolean = closed
def isClosed = closed
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ case class DefaultExecutionResultBuilderFactory(pipeInfo: PipeInfo,

def build(queryId: AnyRef, planType: ExecutionMode, params: Map[String, Any], notificationLogger: InternalNotificationLogger): InternalExecutionResult = {
taskCloser.addTask(queryContext.transactionalContext.close)
taskCloser.addTask(queryContext.resources.close)
val state = new QueryState(queryContext, externalResource, params, pipeDecorator, queryId = queryId,
triadicState = mutable.Map.empty, repeatableReads = mutable.Map.empty,
typeConverter = typeConverter)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ class DelegatingQueryContext(val inner: QueryContext) extends QueryContext {

type EntityAccessor = inner.EntityAccessor

override def resources: CloseableResource = inner.resources

override def transactionalContext: QueryTransactionalContext = inner.transactionalContext

override def entityAccessor: EntityAccessor = inner.entityAccessor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ trait QueryContext extends TokenContext {

def entityAccessor: EntityAccessor

def resources: CloseableResource

def transactionalContext: QueryTransactionalContext

def nodeOps: Operations[Node]
Expand Down Expand Up @@ -215,7 +213,7 @@ trait Operations[T <: PropertyContainer] {
def releaseExclusiveLock(obj: Long): Unit
}

trait QueryTransactionalContext extends CloseableResource {
trait QueryTransactionalContext {

type ReadOps
type DbmsOps
Expand All @@ -226,14 +224,12 @@ trait QueryTransactionalContext extends CloseableResource {

def isTopLevelTx: Boolean

def close(success: Boolean)

def commitAndRestartTx()

def kernelStatisticProvider: KernelStatisticProvider

def databaseInfo: DatabaseInfo
}

trait CloseableResource {
def close(success: Boolean)
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import org.neo4j.cypher.internal.compiler.v3_3.helpers.IdentityTypeConverter
import org.neo4j.cypher.internal.compiler.v3_3.pipes.Pipe
import org.neo4j.cypher.internal.compiler.v3_3.planner.execution.FakeIdMap
import org.neo4j.cypher.internal.compiler.v3_3.planner.logical.plans.SingleRow
import org.neo4j.cypher.internal.compiler.v3_3.spi.{CloseableResource, QueryContext, QueryTransactionalContext}
import org.neo4j.cypher.internal.compiler.v3_3.spi.{QueryContext, QueryTransactionalContext}
import org.neo4j.cypher.internal.frontend.v3_3.phases.devNullLogger
import org.neo4j.cypher.internal.frontend.v3_3.test_helpers.CypherFunSuite
import org.neo4j.cypher.internal.ir.v3_3.{Cardinality, CardinalityEstimation, PlannerQuery}
Expand All @@ -42,7 +42,6 @@ class ExecutionWorkflowBuilderTest extends CypherFunSuite {
when(pipe.createResults(any())).thenReturn(Iterator.empty)
val context = mock[QueryContext]
when(context.transactionalContext).thenReturn(mock[QueryTransactionalContext])
when(context.resources).thenReturn(mock[CloseableResource])

val pipeInfo = PipeInfo(pipe, updating = true, None, None, PlannerName)
val builderFactory = DefaultExecutionResultBuilderFactory(pipeInfo, List.empty, IdentityTypeConverter, logicalPlan, new FakeIdMap)
Expand Down Expand Up @@ -81,7 +80,6 @@ class ExecutionWorkflowBuilderTest extends CypherFunSuite {
when(pipe.createResults(any())).thenReturn(Iterator.empty)
val context = mock[QueryContext]
when(context.transactionalContext).thenReturn(mock[QueryTransactionalContext])
when(context.resources).thenReturn(mock[CloseableResource])
val pipeInfo = PipeInfo(pipe, updating = false, None, None, PlannerName)
val builderFactory = DefaultExecutionResultBuilderFactory(pipeInfo, List.empty, IdentityTypeConverter, logicalPlan, new FakeIdMap)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ trait QueryContextAdaptation {

override type EntityAccessor = this.type

override def resources: CloseableResource = ???

override def indexScanByContains(index: IndexDescriptor, value: String): scala.Iterator[Node] = ???

override def indexScanByEndsWith(index: IndexDescriptor, value: String): Iterator[Node] = ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,6 @@ protected boolean fetchNext()

return false;
}

@Override
public void close()
{
allRelationships.close();
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ import scala.collection.Iterator
class ExceptionTranslatingQueryContext(val inner: QueryContext) extends QueryContext with ExceptionTranslationSupport {
override type EntityAccessor = inner.EntityAccessor

override def entityAccessor = inner.entityAccessor

override def resources: CloseableResource = inner.resources
override def entityAccessor: EntityAccessor = inner.entityAccessor

override def transactionalContext =
new ExceptionTranslatingTransactionalContext(inner.transactionalContext)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,17 @@ import org.neo4j.kernel.impl.core.NodeManager
* Converts a RelationshipIterator coming from the Kernel API into an Iterator[Relationship] while
* still sticking to the fact that each relationship record is only loaded once.
*/
class BeansAPIRelationshipIterator(relationships: RelationshipIterator, nodeManager: NodeManager, resourceManager: ResourceManager)
extends Iterator[Relationship] with AutoCloseable {
class BeansAPIRelationshipIterator(relationships: RelationshipIterator,
nodeManager: NodeManager) extends Iterator[Relationship] {

private var closed = false

resourceManager.trace(relationships)

private var nextRelationship: Relationship = _
private var nextRelationship: Relationship = null
private val visitor = new RelationshipVisitor[RuntimeException] {
override def visit(relationshipId: Long, typeId: Int, startNodeId: Long, endNodeId: Long) {
nextRelationship = nodeManager.newRelationshipProxy(relationshipId, startNodeId, typeId, endNodeId)
}
}

override def hasNext: Boolean = {
val hasNext = relationships.hasNext
if (!hasNext) close()
hasNext
}
override def hasNext: Boolean = relationships.hasNext

override def next(): Relationship = {
if (hasNext) {
Expand All @@ -57,9 +49,4 @@ class BeansAPIRelationshipIterator(relationships: RelationshipIterator, nodeMana
throw new NoSuchElementException
}
}

override def close(): Unit = if (!closed) {
closed = true
resourceManager.release(relationships)
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.neo4j.cypher.internal.compiler.v2_3.helpers.JavaConversionSupport._
import org.neo4j.cypher.internal.compiler.v2_3.pipes.matching.PatternNode
import org.neo4j.cypher.internal.compiler.v2_3.spi._
import org.neo4j.cypher.internal.frontend.v2_3.{Bound, EntityNotFoundException, FailedIndexException, SemanticDirection}
import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, ResourceManager}
import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator
import org.neo4j.cypher.internal.spi.v3_3.TransactionalContextWrapper
import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService
import org.neo4j.graphalgo.impl.path.ShortestPath
Expand All @@ -59,7 +59,6 @@ import scala.collection.{Iterator, mutable}
final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
extends TransactionBoundTokenContext(tc.statement) with QueryContext with SchemaDescriptorTranslation {

val resources = new ResourceManager
override val nodeOps = new NodeOperations
override val relationshipOps = new RelationshipOperations
private val nodeManager = tc.graph.getDependencyResolver.resolveDependency(classOf[NodeManager])
Expand Down Expand Up @@ -126,7 +125,7 @@ final class TransactionBoundQueryContext(tc: TransactionalContextWrapper)
case Some(typeIds) =>
tc.statement.readOperations().nodeGetRelationships(node.getId, toGraphDb(dir), typeIds.toArray)
}
new BeansAPIRelationshipIterator(relationships, nodeManager, resources)
new BeansAPIRelationshipIterator(relationships, nodeManager)
}

def indexSeek(index: SchemaTypes.IndexDescriptor, value: Any) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import org.neo4j.cypher.internal.compiler.v3_1.pipes.matching.PatternNode
import org.neo4j.cypher.internal.compiler.v3_1.spi.SchemaTypes.{IndexDescriptor, NodePropertyExistenceConstraint, RelationshipPropertyExistenceConstraint, UniquenessConstraint}
import org.neo4j.cypher.internal.compiler.v3_1.spi._
import org.neo4j.cypher.internal.frontend.v3_1.{Bound, EntityNotFoundException, FailedIndexException, SemanticDirection}
import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator
import org.neo4j.cypher.internal.spi.v3_1.TransactionBoundQueryContext.IndexSearchMonitor
import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, ResourceManager}
import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService
import org.neo4j.cypher.{InternalException, internal}
import org.neo4j.graphalgo.impl.path.ShortestPath
Expand All @@ -53,9 +53,9 @@ import org.neo4j.kernel.api.exceptions.ProcedureException
import org.neo4j.kernel.api.exceptions.schema.{AlreadyConstrainedException, AlreadyIndexedException}
import org.neo4j.kernel.api.index.InternalIndexState
import org.neo4j.kernel.api.proc.{QualifiedName => KernelQualifiedName}
import org.neo4j.kernel.api.schema.constaints.ConstraintDescriptorFactory
import org.neo4j.kernel.api.schema.{IndexQuery, RelationTypeSchemaDescriptor, SchemaDescriptorFactory}
import org.neo4j.kernel.api.schema.constaints.{ConstraintDescriptor, ConstraintDescriptorFactory, UniquenessConstraintDescriptor}
import org.neo4j.kernel.api.schema.index.IndexDescriptorFactory
import org.neo4j.kernel.api.schema.{IndexQuery, SchemaDescriptorFactory}
import org.neo4j.kernel.impl.core.NodeManager
import org.neo4j.kernel.impl.locking.ResourceTypes

Expand All @@ -67,9 +67,8 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper)

type EntityAccessor = NodeManager

val resources: ResourceManager = new ResourceManager
override val nodeOps = new NodeOperations
override val relationshipOps = new RelationshipOperations
val nodeOps = new NodeOperations
val relationshipOps = new RelationshipOperations

override lazy val entityAccessor = txContext.graph.getDependencyResolver.resolveDependency(classOf[NodeManager])

Expand Down Expand Up @@ -129,14 +128,14 @@ final class TransactionBoundQueryContext(txContext: TransactionalContextWrapper)
override def getOrCreateLabelId(labelName: String) =
txContext.statement.tokenWriteOperations().labelGetOrCreateForName(labelName)

def getRelationshipsForIds(node: Node, dir: SemanticDirection, types: Option[Seq[Int]]): Iterator[Relationship] with AutoCloseable = {
def getRelationshipsForIds(node: Node, dir: SemanticDirection, types: Option[Seq[Int]]): Iterator[Relationship] = {
val relationships = types match {
case None =>
txContext.statement.readOperations().nodeGetRelationships(node.getId, toGraphDb(dir))
case Some(typeIds) =>
txContext.statement.readOperations().nodeGetRelationships(node.getId, toGraphDb(dir), typeIds.toArray)
}
new BeansAPIRelationshipIterator(relationships, entityAccessor, resources)
new BeansAPIRelationshipIterator(relationships, entityAccessor)
}

override def indexSeek(index: IndexDescriptor, value: Any) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.neo4j.cypher.internal.compiler.v3_2.helpers.JavaConversionSupport._
import org.neo4j.cypher.internal.compiler.v3_2.pipes.matching.PatternNode
import org.neo4j.cypher.internal.compiler.v3_2.spi.{IdempotentResult, Operations, QualifiedName, QueryContext}
import org.neo4j.cypher.internal.frontend.v3_2._
import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, ResourceManager}
import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator
import org.neo4j.cypher.internal.spi.v3_2.TransactionBoundQueryContext.IndexSearchMonitor
import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService
import org.neo4j.cypher.{InternalException, internal}
Expand All @@ -60,20 +60,15 @@ import org.neo4j.kernel.impl.locking.ResourceTypes
import scala.collection.Iterator
import scala.collection.JavaConverters._



final class TransactionBoundQueryContext(val transactionalContext: TransactionalContextWrapper)(implicit indexSearchMonitor: IndexSearchMonitor)
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext with IndexDescriptorCompatibility {


class WhenYouGetACompilationErrorOnTheUseOfThisClassYouShouldRemoveTheClassAndAddOverrideToTheFieldDeclaredAsResourceManager extends ResourceManager

override type EntityAccessor = NodeManager
val resources: WhenYouGetACompilationErrorOnTheUseOfThisClassYouShouldRemoveTheClassAndAddOverrideToTheFieldDeclaredAsResourceManager = new WhenYouGetACompilationErrorOnTheUseOfThisClassYouShouldRemoveTheClassAndAddOverrideToTheFieldDeclaredAsResourceManager

override val nodeOps = new NodeOperations
override val relationshipOps = new RelationshipOperations

override lazy val entityAccessor = transactionalContext.graph.getDependencyResolver.resolveDependency(classOf[NodeManager])
override lazy val entityAccessor: NodeManager =
transactionalContext.graph.getDependencyResolver.resolveDependency(classOf[NodeManager])

override def setLabelsOnNode(node: Long, labelIds: Iterator[Int]): Int = labelIds.foldLeft(0) {
case (count, labelId) => if (transactionalContext.statement.dataWriteOperations().nodeAddLabel(node, labelId)) count + 1 else count
Expand Down Expand Up @@ -138,7 +133,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
case Some(typeIds) =>
transactionalContext.statement.readOperations().nodeGetRelationships(node.getId, toGraphDb(dir), typeIds.toArray)
}
new BeansAPIRelationshipIterator(relationships, entityAccessor, new ResourceManager)
new BeansAPIRelationshipIterator(relationships, entityAccessor)
}

override def indexSeek(index: IndexDescriptor, values: Seq[Any]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.neo4j.cypher.internal.compiler.v3_3.helpers.JavaConversionSupport._
import org.neo4j.cypher.internal.compiler.v3_3.pipes.matching.PatternNode
import org.neo4j.cypher.internal.compiler.v3_3.spi.{IdempotentResult, Operations, QualifiedName, QueryContext}
import org.neo4j.cypher.internal.frontend.v3_3._
import org.neo4j.cypher.internal.spi.{BeansAPIRelationshipIterator, ResourceManager}
import org.neo4j.cypher.internal.spi.BeansAPIRelationshipIterator
import org.neo4j.cypher.internal.spi.v3_3.TransactionBoundQueryContext.IndexSearchMonitor
import org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService
import org.neo4j.cypher.{InternalException, internal}
Expand Down Expand Up @@ -64,7 +64,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
extends TransactionBoundTokenContext(transactionalContext.statement) with QueryContext with IndexDescriptorCompatibility {

override type EntityAccessor = NodeManager
override val resources = new ResourceManager

override val nodeOps = new NodeOperations
override val relationshipOps = new RelationshipOperations
override lazy val entityAccessor: NodeManager =
Expand Down Expand Up @@ -133,7 +133,7 @@ final class TransactionBoundQueryContext(val transactionalContext: Transactional
case Some(typeIds) =>
transactionalContext.statement.readOperations().nodeGetRelationships(node.getId, toGraphDb(dir), typeIds.toArray)
}
new BeansAPIRelationshipIterator(relationships, entityAccessor, resources)
new BeansAPIRelationshipIterator(relationships, entityAccessor)
}

override def indexSeek(index: IndexDescriptor, values: Seq[Any]) = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class TriadicIntegrationTest extends ExecutionEngineFunSuite {
test("triadic should not handle complex incoming predicates for now") {
// given
graph.createIndex( "Person", "name")

execute( """CREATE (a:Person{name:"a"}), (b:Person{name:"b"}), (c:Person{name:"c",age:39}), (d:Person{name:"d"}), (e:Person{name:"e"})
|CREATE (a)-[:FRIEND]->(b), (b)-[:FRIEND]->(c), (b)-[:FRIEND]->(d), (b)-[:FRIEND]->(e)
|CREATE (a)-[:FRIEND]->(c), (a)-[:FRIEND]->(d), (c)-[:FRIEND]->(d)""".stripMargin)
Expand Down

0 comments on commit ecc3e3d

Please sign in to comment.