src/LogicalPlanner/LogicalPlan.cs
/// <summary>
/// Create an instance of LogicalPlanner with a given query AST tree
/// </summary>
/// <param name="treeRoot"></param>
/// <param name="graphDef"></param>
/// <returns></returns>
Create an instance of LogicalPlanner with a given query AST tree
Create an instance of LogicalPlanner with a given query AST tree
public static LogicalPlan ProcessQueryTree(QueryNode treeRoot, IGraphSchemaProvider graphDef, ILoggable logger = null)
        {
            var logicalPlanner = new LogicalPlan(logger);
            var allLogicalOps = new HashSet<LogicalOperator>();
            var logicalRoot = logicalPlanner.CreateLogicalTree(treeRoot, allLogicalOps);
            logicalPlanner.StartingOperators = logicalRoot.GetAllUpstreamOperatorsOfType<StartLogicalOperator>().ToList();
            logicalPlanner.TerminalOperators = new List<LogicalOperator>(1) { logicalRoot };
            var i = 0;
            foreach (var op in allLogicalOps)
            {
                op.OperatorDebugId = ++i;
            }
            var bindableStartingOp = logicalPlanner.StartingOperators.Where(op => op is IBindable);
            bindableStartingOp.ToList().ForEach(op => (op as IBindable).Bind(graphDef));
            logicalPlanner.PropagateDataTypes();
            logicalPlanner.UpdateActualFieldReferencesForEntityFields();
            var allOpsFromTraversal = logicalPlanner.StartingOperators.SelectMany(op => op.GetAllDownstreamOperatorsOfType<LogicalOperator>()).Distinct().OrderBy(op => op.OperatorDebugId).ToList();
            var allOpsFromBuildingTree = allLogicalOps.OrderBy(op => op.OperatorDebugId).ToList();
            Debug.Assert(allOpsFromTraversal.Count == allOpsFromBuildingTree.Count);
            return logicalPlanner;
        }
public static LogicalPlan ProcessQueryTree ( QueryNode treeRoot , IGraphSchemaProvider graphDef , ILoggable logger = null ) { var logicalPlanner = new LogicalPlan ( logger ) ; var allLogicalOps = new HashSet < LogicalOperator > ( ) ; var logicalRoot = logicalPlanner . CreateLogicalTree ( treeRoot , allLogicalOps ) ; logicalPlanner . StartingOperators = logicalRoot . GetAllUpstreamOperatorsOfType < StartLogicalOperator > ( ) . ToList ( ) ; logicalPlanner . TerminalOperators = new List < LogicalOperator > ( 1 ) { logicalRoot } ; var i = 0 ; foreach ( var op in allLogicalOps ) { op . OperatorDebugId = ++ i ; } var bindableStartingOp = logicalPlanner . StartingOperators . Where ( op => op is IBindable ) ; bindableStartingOp . ToList ( ) . ForEach ( op => ( op as IBindable ) . Bind ( graphDef ) ) ; logicalPlanner . PropagateDataTypes ( ) ; logicalPlanner . UpdateActualFieldReferencesForEntityFields ( ) ; var allOpsFromTraversal = logicalPlanner . StartingOperators . SelectMany ( op => op . GetAllDownstreamOperatorsOfType < LogicalOperator > ( ) ) . Distinct ( ) . OrderBy ( op => op . OperatorDebugId ) . ToList ( ) ; var allOpsFromBuildingTree = allLogicalOps . OrderBy ( op => op . OperatorDebugId ) . ToList ( ) ; Debug . Assert ( allOpsFromTraversal . Count == allOpsFromBuildingTree . Count ) ; return logicalPlanner ; }
Create an instance of LogicalPlanner with a given query AST tree
Create an instance of LogicalPlanner with a given query AST tree
// from AST, create the logical plan // populate the ids for operators (for debugging purpose) // bind logical tree with the graph schema // propagate down the schema from starting operator and data types (top down) // expand and optimize out columns not used (bottom up)
None
treeRoot
QueryNode
None
graphDef
IGraphSchemaProvider
None
logger
ILoggable