src/LogicalPlanner/LogicalPlan.cs
/// <summary>
/// Create logical operator tree for a given query AST tree
/// </summary>
/// <param name="treeNode"></param>
/// <returns></returns>
Create logical operator tree for a given query AST tree
Create logical operator tree for a given query AST tree
private LogicalOperator CreateLogicalTree(QueryNode treeNode, ISet<LogicalOperator> allLogicalOps)
        {
             The logical tree looks like:
                DS(a:n1)  DS(b:r1)   DS(c:n2)
                     \      /          /
                      \    /          /
                  InJoin(a:n1, b:r1) /
                            \       /
                             \     /
                           InJoin(InJoin(...), c:n2)
                                     |
                            Projection(a->c, c->a)   DS(:r2)
                                           \           /
                                            \         /
                                          LfJoin(Proj, :r2)
                                                 |
                                           Sel(a.id = 'some id')
                                                 |
                                        Projection(a.id -> Id)
             in-order walk of the tree to evaluate individual queries
            if (treeNode is SingleQueryNode)
            {
                 single query
                return CreateLogicalTree(treeNode as SingleQueryNode, allLogicalOps);
            }
            else
            {
                Debug.Assert(treeNode is InfixQueryNode);
                return CreateLogicalTree(treeNode as InfixQueryNode, allLogicalOps);
            }
        }
private LogicalOperator CreateLogicalTree ( QueryNode treeNode , ISet < LogicalOperator > allLogicalOps ) { if ( treeNode is SingleQueryNode ) { return CreateLogicalTree ( treeNode as SingleQueryNode , allLogicalOps ) ; } else { Debug . Assert ( treeNode is InfixQueryNode ) ; return CreateLogicalTree ( treeNode as InfixQueryNode , allLogicalOps ) ; } }
Create logical operator tree for a given query AST tree
Create logical operator tree for a given query AST tree
// Example of logical tree to be created: //   MATCH (a:n1)-[b:r1]-(c:n2) //   WITH a as c, c as a //   OPTIONAL MATCH (c)-[:r2]-(a) //   WHERE a.id = "some id" //   RETURN a.id as Id // // The logical tree looks like: //    DS(a:n1)  DS(b:r1)   DS(c:n2) //         \      /          / //          \    /          / //      InJoin(a:n1, b:r1) / //                \       / //                 \     / //               InJoin(InJoin(...), c:n2) //                         | //                Projection(a->c, c->a)   DS(:r2) //                               \           / //                                \         / //                              LfJoin(Proj, :r2) //                                     | //                               Sel(a.id = 'some id') //                                     | //                            Projection(a.id -> Id) // in-order walk of the tree to evaluate individual queries // single query
None
treeNode
QueryNode
None
allLogicalOps
ISet<LogicalOperator>