class NodeQueryExecutor(val client: ReactiveNeo4jClient, val mappingContext: Neo4jMappingContext, val renderer: Renderer)

Generates Cypher-DSL queries based on a NodeQuery, executes it and parses the result

Parameters

client

used to execute the query

mappingContext

used to transform the result into a node

renderer

used to render the Cypher-DSL queries

Constructors

Link copied to clipboard
constructor(client: ReactiveNeo4jClient, mappingContext: Neo4jMappingContext, renderer: Renderer)

Properties

Link copied to clipboard
private val client: ReactiveNeo4jClient
Link copied to clipboard

lookup for generated ExtensionFields

Link copied to clipboard
private val mappingContext: Neo4jMappingContext
Link copied to clipboard
private var nameCounter: Int

Counter for unique name generation

Link copied to clipboard
private val nodeLookup: HashMap<String, Node>

Lookup table for already created nodes

Link copied to clipboard
private val renderer: Renderer
Link copied to clipboard

Map of all nodes that were returned by a query

Link copied to clipboard

lookup for generated SubQueries

Functions

Link copied to clipboard
private fun applyAfterAndBefore(options: NodeQueryOptions, nodeAlias: SymbolicName, builder: StatementBuilder.OngoingReading): Pair<StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, OrderContext?>

Adds before and after filters to the builder

Link copied to clipboard
private fun applyFilterConditions(filters: List<CypherConditionGenerator>, builder: StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, node: Node): StatementBuilder.OrderableOngoingReadingAndWith?

Applies all filter conditions to a builder and returns the resulting builder

Link copied to clipboard
private fun applyResultLimiters(orderContext: OrderContext?, options: NodeQueryOptions, builder: StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, nodeAlias: SymbolicName): StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere

Adds first and last filters, and adds skip. Requires that the nodes are already correctly ordered

private fun applySubQueryMatchWithAuthorizationConditions(builder: StatementBuilder.OrderableOngoingReadingAndWithWithWhere, node: Node, relatedNode: Node, relationshipDefinitions: List<AuthorizedRelationDefinition>): StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere

Matches the relationships defined in relationshipDefinitions and applies authorization conditions

Link copied to clipboard
private fun applySubQueryUnwind(allNodes: SymbolicName, unwindCount: Int, parentNodeDefinition: NodeDefinition): Pair<StatementBuilder.OngoingReading, Node>

Starts a new SubQuery builder and applies the specified amount of unwinds to allNodes

Link copied to clipboard
private fun applyTotalCount(builder: StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, allNodesCollected: SymbolicName, additionalNames: List<SymbolicName>, totalCount: SymbolicName): StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere?

If necessary, adds a with statement to the builder which fetches totalCount

Link copied to clipboard
private fun applyTotalCountIfRequired(options: NodeQueryOptions, builder: StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, allNodesCollected: SymbolicName, additionalNames: List<SymbolicName>): Pair<StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere?, SymbolicName?>

Wraps the builder with applyTotalCount if required by the options

Link copied to clipboard
private fun createEntriesSubQueriesRecursive(builder: StatementBuilder.OngoingReading, nodeQuery: QueryBase<*>, allNodes: SymbolicName, unwindCount: Int): Pair<StatementBuilder.OngoingReading, List<SymbolicName>>

Creates SubQueries for each SubQuery in the provided nodeQuery Generates recursively depth first.

Link copied to clipboard

Creates a query based on nodeQuery Must only be used for the root query Does only include nodes in nodes and does only fetch the id of these nodes

Link copied to clipboard
private fun createPartialRootReturnStatement(builder: StatementBuilder.OngoingReading, resultNodesCollected: SymbolicName, otherResults: List<SymbolicName>): StatementWithSymbolicName

Creates the return statement and builds the query. This does NOT include total count and is meant for partial results

Link copied to clipboard

Generates a query based on nodeQuery Must only be used for the root query

Link copied to clipboard
private fun createRootReturnStatement(builder: StatementBuilder.OngoingReading, resultNodesCollected: SymbolicName, otherResults: List<SymbolicName>, totalCount: SymbolicName?): StatementWithSymbolicName

Creates the return statement and builds the query. If totalCount is not fetched, null is set as value for totalCount Must only be used for the root query

Link copied to clipboard

Generates a search root query based

Link copied to clipboard
private fun createSubNodeQuery(nodeQuery: NodeQuery, builder: StatementBuilder.OrderableOngoingReadingAndWithWithoutWhere, node: Node, parentNode: Node): StatementWithResultNodesAndNodes

Generates a query based on nodeQuery Must only be used for SubQueries and not for the root query

Link copied to clipboard
private fun createSubQuery(subQuery: NodeSubQuery, parentNodeDefinition: NodeDefinition, allNodes: SymbolicName, unwindCount: Int): StatementWithResultNodesAndNodes

Creates a SubQuery using a Cypher SubQuery Uses NodeSubQuery.onlyOnTypes to only fetch related nodes when necessary

Link copied to clipboard
private fun createSubReturnStatement(builder: StatementBuilder.OngoingReadingWithoutWhere, resultNodesCollected: SymbolicName, nodesCollected: SymbolicName, parentNodeId: Expression, totalCount: SymbolicName?): StatementWithResultNodesAndNodes

Creates the return statement and builds the query. If totalCount is not fetched, null is set as value for totalCount Must only be used for SubQueries and not for the root query

Link copied to clipboard
suspend fun execute(query: NodeQuery): NodeQueryResult<*>
suspend fun execute(query: SearchQuery): SearchQueryResult<*>

Executes the query

Link copied to clipboard
suspend fun executePartial(query: PartialNodeQuery, nodes: Collection<Node>)

Executes a partial query and registers the results in nodes

Link copied to clipboard
private fun generateCursorFilterExpression(cursor: Map<String, Any?>, orderContext: OrderContext, forwards: Boolean): Condition

Generates a Condition which can be used to filter for items before/after a specific cursor

Link copied to clipboard

Generates a subquery res which return no nodes

Link copied to clipboard
private fun generateExtensionFields(nodeQuery: QueryBase<*>, nodeAlias: SymbolicName): Map<String, Expression>

Generate a map to fetch extension fields for a NodeQuery. Registers all extension fields in extensionFieldLookup

Link copied to clipboard
private fun generateLabelCondition(node: Node, entry: NodeQueryEntry<*>): Condition

Creates a condition to check that node has all labels specified in entry onlyOnTypes

Link copied to clipboard
private fun generateMainSubQuery(nodeQuery: NodeQuery, node: Node, allNodesCollected: SymbolicName): StatementWithResultNodesAndNodes

Generates a Cypher SubQuery which gets the list of all nodes, and applies pagination filtering, related nodes SubQueries, ordering and result aggregation

Link copied to clipboard
private fun generateMainSubQueryResultStatement(nodeDefinition: NodeDefinition, builder: StatementBuilder.OngoingReading, nodeAlias: SymbolicName, orderContext: OrderContext?, nodeQuery: NodeQuery): StatementWithResultNodesAndNodes

Generates the result statement for the query generated by generateMainSubQuery. Also orders the nodes, and builds a statement out of the builder

Link copied to clipboard
private fun generateOrderFields(orderContext: OrderContext, reversed: Boolean = false): List<SortItem>

Transforms an Order into a list of SortItem

Link copied to clipboard
private fun generateResultNodeExpression(nodeExpression: Expression, nodeQuery: QueryBase<*>, nodeAlias: SymbolicName, orderContext: OrderContext?): MapExpression

Generates the expression for the result node, including the node itself and extension fields

Link copied to clipboard
private fun generateUniqueName(): SymbolicName?

Generates a new unique name

Link copied to clipboard
private fun parseNode(value: Value, nodeQuery: QueryBase<*>, entriesResults: Map<NodeSubQuery, Map<String, Value>>): Node

Parses a single node Parses SubQueries recursively

Link copied to clipboard
private fun parseNodeEntries(nodeQuery: QueryBase<*>, node: Node, entriesResults: Map<NodeSubQuery, Map<String, Value>>, value: Value)

Parses the entries of a node based on the provided nodeQuery

Link copied to clipboard
private fun parseQueryResultInternal(record: Record, returnNodeName: SymbolicName, nodeQuery: QueryBase<*>): PartialNodeQueryResult

Parses the result of a query (a list of nodes, and optional a totalCount). Parses recursively

private fun parseQueryResultInternal(value: Value, nodeQuery: QueryBase<*>, entriesResults: Map<NodeSubQuery, Map<String, Value>>): PartialNodeQueryResult

Parses the result of a query (a list of nodes, and optional a totalCount) Parses recursively