private void button2_Click(object sender, RoutedEventArgs e) { g = new FlourishingTreeGenerator(); r = new LowRender(xCanvas); xCanvas.Children.Clear(); r.Draw(g.Generate()); }
private void button3_Click(object sender, RoutedEventArgs e) { g = new SampleTree(); r = new LowRender(xCanvas); xCanvas.Children.Clear(); r.Draw(g.Generate()); }
private void button1_Click(object sender, RoutedEventArgs e) { g = new SensitivePlantGenerator(); r = new LowRender(xCanvas); xCanvas.Children.Clear(); r.Draw(g.Generate()); }
private void Initialize() { DbQueryCommandTree ctree = this.m_ctree as DbQueryCommandTree; System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(ctree != null, "Unexpected command tree kind. Only query command tree is supported."); this.m_command = ITreeGenerator.Generate(ctree); System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(this.m_command != null, "Unable to generate internal tree from Command Tree"); }
/// <summary> /// Converts the CTree into an ITree, and initializes the plan /// </summary> private void Initialize() { // Only support queries for now cqt.DbQueryCommandTree cqtree = m_ctree as cqt.DbQueryCommandTree; PlanCompiler.Assert(cqtree != null, "Unexpected command tree kind. Only query command tree is supported."); // Generate the ITree m_command = ITreeGenerator.Generate(cqtree); PlanCompiler.Assert(m_command != null, "Unable to generate internal tree from Command Tree"); }
internal System.Data.Entity.Core.Query.InternalTrees.Node GetInternalTree( Command targetIqtCommand) { if (this.m_internalTreeNode == null) { Command command = ITreeGenerator.Generate(this.GetCommandTree(), this.m_discriminatorMap); System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(command.Root.Op.OpType == OpType.PhysicalProject, "Expected a physical projectOp at the root of the tree - found " + (object)command.Root.Op.OpType); command.DisableVarVecEnumCaching(); this.m_internalTreeNode = command.Root.Child0; } return(OpCopier.Copy(targetIqtCommand, this.m_internalTreeNode)); }
void canvas_Draw( CanvasControl sender, CanvasDrawEventArgs args) { var r = new LowRender(sender, args); var tree = g?.Generate(); if (tree != null) { r?.Draw(tree); } }
internal Node GetInternalTree(Command targetIqtCommand) { Debug.Assert(m_extent.EntityContainer.DataSpace == DataSpace.CSpace, "Internal Tree should be asked only for query view"); if (m_internalTreeNode == null) { DbQueryCommandTree tree = GetCommandTree(); // Convert this into an ITree first Command itree = ITreeGenerator.Generate(tree, m_discriminatorMap); // Pull out the root physical project-op, and copy this itree into our own itree PlanCompiler.Assert(itree.Root.Op.OpType == OpType.PhysicalProject, "Expected a physical projectOp at the root of the tree - found " + itree.Root.Op.OpType); // #554756: VarVec enumerators are not cached on the shared Command instance. itree.DisableVarVecEnumCaching(); m_internalTreeNode = itree.Root.Child0; } Debug.Assert(m_internalTreeNode != null, "m_internalTreeNode != null"); return(OpCopier.Copy(targetIqtCommand, m_internalTreeNode)); }
internal System.Data.Entity.Core.Query.InternalTrees.Node GetInternalTree( Command targetIqtCommand, IList <System.Data.Entity.Core.Query.InternalTrees.Node> targetIqtArguments) { if (this.m_internalTreeNode == null) { DiscriminatorMap discriminatorMap; Command command = ITreeGenerator.Generate(this.GenerateFunctionView(out discriminatorMap), discriminatorMap); System.Data.Entity.Core.Query.InternalTrees.Node root = command.Root; System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Assert(root.Op.OpType == OpType.PhysicalProject, "Expected a physical projectOp at the root of the tree - found " + (object)root.Op.OpType); PhysicalProjectOp op = (PhysicalProjectOp)root.Op; System.Data.Entity.Core.Query.InternalTrees.Node child0 = root.Child0; command.DisableVarVecEnumCaching(); System.Data.Entity.Core.Query.InternalTrees.Node relOpNode = child0; Var computedVar = op.Outputs[0]; if (!Command.EqualTypes(op.ColumnMap.Type, this.FunctionImport.ReturnParameter.TypeUsage)) { TypeUsage typeUsage = ((CollectionType)this.FunctionImport.ReturnParameter.TypeUsage.EdmType).TypeUsage; System.Data.Entity.Core.Query.InternalTrees.Node node1 = command.CreateNode((Op)command.CreateVarRefOp(computedVar)); System.Data.Entity.Core.Query.InternalTrees.Node node2 = command.CreateNode((Op)command.CreateSoftCastOp(typeUsage), node1); System.Data.Entity.Core.Query.InternalTrees.Node varDefListNode = command.CreateVarDefListNode(node2, out computedVar); ProjectOp projectOp = command.CreateProjectOp(computedVar); relOpNode = command.CreateNode((Op)projectOp, relOpNode, varDefListNode); } this.m_internalTreeNode = command.BuildCollect(relOpNode, computedVar); } Dictionary <string, System.Data.Entity.Core.Query.InternalTrees.Node> viewArguments = new Dictionary <string, System.Data.Entity.Core.Query.InternalTrees.Node>(this.m_commandParameters.Length); for (int index = 0; index < this.m_commandParameters.Length; ++index) { DbParameterReferenceExpression commandParameter = this.m_commandParameters[index]; System.Data.Entity.Core.Query.InternalTrees.Node node = targetIqtArguments[index]; if (TypeSemantics.IsEnumerationType(node.Op.Type)) { node = targetIqtCommand.CreateNode((Op)targetIqtCommand.CreateSoftCastOp(TypeHelpers.CreateEnumUnderlyingTypeUsage(node.Op.Type)), node); } viewArguments.Add(commandParameter.ParameterName, node); } return(FunctionImportMappingComposable.FunctionViewOpCopier.Copy(targetIqtCommand, this.m_internalTreeNode, viewArguments)); }
internal Node GetInternalTree(Command targetIqtCommand, IList <Node> targetIqtArguments) { if (m_internalTreeNode == null) { DiscriminatorMap discriminatorMap; var tree = GenerateFunctionView(out discriminatorMap); Debug.Assert(tree != null, "tree != null"); // Convert this into an ITree first var itree = ITreeGenerator.Generate(tree, discriminatorMap); var rootProject = itree.Root; // PhysicalProject(RelInput) PlanCompiler.Assert( rootProject.Op.OpType == OpType.PhysicalProject, "Expected a physical projectOp at the root of the tree - found " + rootProject.Op.OpType); var rootProjectOp = (PhysicalProjectOp)rootProject.Op; Debug.Assert(rootProjectOp.Outputs.Count == 1, "rootProjectOp.Outputs.Count == 1"); var rootInput = rootProject.Child0; // the RelInput in PhysicalProject(RelInput) // #554756: VarVec enumerators are not cached on the shared Command instance. itree.DisableVarVecEnumCaching(); // Function import returns a collection, so convert it to a scalar by wrapping into CollectOp. var relNode = rootInput; var relVar = rootProjectOp.Outputs[0]; // ProjectOp does not implement Type property, so get the type from the column map. var functionViewType = rootProjectOp.ColumnMap.Type; if (!Command.EqualTypes(functionViewType, FunctionImport.ReturnParameter.TypeUsage)) { Debug.Assert( TypeSemantics.IsPromotableTo(functionViewType, FunctionImport.ReturnParameter.TypeUsage), "Mapping expression result type must be promotable to the c-space function return type."); // Build "relNode = Project(relNode, SoftCast(relVar))" var expectedCollectionType = (CollectionType)FunctionImport.ReturnParameter.TypeUsage.EdmType; var expectedElementType = expectedCollectionType.TypeUsage; var varRefNode = itree.CreateNode(itree.CreateVarRefOp(relVar)); var castNode = itree.CreateNode(itree.CreateSoftCastOp(expectedElementType), varRefNode); var varDefListNode = itree.CreateVarDefListNode(castNode, out relVar); var projectOp = itree.CreateProjectOp(relVar); relNode = itree.CreateNode(projectOp, relNode, varDefListNode); } // Build "Collect(PhysicalProject(relNode)) m_internalTreeNode = itree.BuildCollect(relNode, relVar); } Debug.Assert(m_internalTreeNode != null, "m_internalTreeNode != null"); // Prepare argument replacement dictionary Debug.Assert(m_commandParameters.Length == targetIqtArguments.Count, "m_commandParameters.Length == targetIqtArguments.Count"); var viewArguments = new Dictionary <string, Node>(m_commandParameters.Length); for (var i = 0; i < m_commandParameters.Length; ++i) { var commandParam = m_commandParameters[i]; var argumentNode = targetIqtArguments[i]; // If function import parameter is of enum type, the argument value for it will be of enum type. We however have // converted enum types to underlying types for m_commandParameters. So we now need to softcast the argument // expression to the underlying type as well. if (TypeSemantics.IsEnumerationType(argumentNode.Op.Type)) { argumentNode = targetIqtCommand.CreateNode( targetIqtCommand.CreateSoftCastOp(TypeHelpers.CreateEnumUnderlyingTypeUsage(argumentNode.Op.Type)), argumentNode); } Debug.Assert( TypeSemantics.IsPromotableTo(argumentNode.Op.Type, commandParam.ResultType), "Argument type must be promotable to parameter type."); viewArguments.Add(commandParam.ParameterName, argumentNode); } return(FunctionViewOpCopier.Copy(targetIqtCommand, m_internalTreeNode, viewArguments)); }