当前位置: 首页>>代码示例>>C#>>正文


C# ExpressionVisitor.AddSchema方法代码示例

本文整理汇总了C#中ExpressionVisitor.AddSchema方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionVisitor.AddSchema方法的具体用法?C# ExpressionVisitor.AddSchema怎么用?C# ExpressionVisitor.AddSchema使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ExpressionVisitor的用法示例。


在下文中一共展示了ExpressionVisitor.AddSchema方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseFNode

        public static FNode ParseFNode(string Text, MemoryStruct LocalHeap, Workspace Home, string Alias, Schema Columns, Register Memory)
        {

            // Build text stream //
            AntlrInputStream ais = new AntlrInputStream(Text);
            HScriptLexer lex = new HScriptLexer(ais);

            // Build token tree //
            CommonTokenStream cts = new CommonTokenStream(lex);
            HScriptParser par = new HScriptParser(cts);

            // Build AST //
            IParseTree tree = par.expression();

            // Visit each node getting the final node //
            ExpressionVisitor v = new ExpressionVisitor(LocalHeap, Home);
            v.AddSchema(Alias, Columns, Memory);

            return v.Visit(tree);

        }
开发者ID:pwdlugosz,项目名称:Horse,代码行数:21,代码来源:DataFactory.cs

示例2: RenderMergePlan

        // Merge //
        public static MergePlan RenderMergePlan(Workspace Home, HScriptParser.Crudam_mergeContext context)
        {

            // Get the data sources //
            DataSet data1 = VisitorHelper.GetData(Home, context.merge_source()[0].full_table_name());
            DataSet data2 = VisitorHelper.GetData(Home, context.merge_source()[1].full_table_name());

            // Get the aliases //
            string alias1 = (context.merge_source()[0].IDENTIFIER() ?? context.merge_source()[0].full_table_name().table_name().IDENTIFIER()).GetText();
            string alias2 = (context.merge_source()[1].IDENTIFIER() ?? context.merge_source()[1].full_table_name().table_name().IDENTIFIER()).GetText();

            // Build the registers; the join functions only use static registers //
            StaticRegister mem1 = new StaticRegister(null);
            StaticRegister mem2 = new StaticRegister(null);

            // Create our expression builder //
            ExpressionVisitor exp_vis = new ExpressionVisitor(null, Home);
            exp_vis.AddSchema(alias1, data1.Columns, mem1);
            exp_vis.AddSchema(alias2, data2.Columns, mem2);

            // Get the equality keys //
            Key eq1 = new Key();
            Key eq2 = new Key();
            foreach (HScriptParser.Merge_equi_predicateContext ctx in context.merge_equi_predicate())
            {

                string a1 = ctx.table_variable()[0].IDENTIFIER()[0].GetText();
                string a2 = ctx.table_variable()[1].IDENTIFIER()[0].GetText();
                string c1 = ctx.table_variable()[0].IDENTIFIER()[1].GetText();
                string c2 = ctx.table_variable()[1].IDENTIFIER()[1].GetText();
                int idx1 = -1;
                int idx2 = -1;

                if (a1 == alias1 && a2 == alias2)
                {

                    // Look up indicides //
                    idx1 = data1.Columns.ColumnIndex(c1);
                    idx2 = data2.Columns.ColumnIndex(c2);

                    // Check for invalid keys //
                    if (idx1 == -1)
                        throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", c1, alias1));
                    if (idx2 == -1)
                        throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", c2, alias2));

                }
                else if (a1 == alias2 && a2 == alias1)
                {

                    // Look up indicides //
                    idx1 = data1.Columns.ColumnIndex(c2);
                    idx2 = data2.Columns.ColumnIndex(c1);

                    // Check for invalid keys //
                    if (idx1 == -1)
                        throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", c2, idx1));
                    if (idx2 == -1)
                        throw new Exception(string.Format("Column '{0}' does not exist in '{1}'", c1, idx2));

                }
                else
                    throw new Exception("Aliases passed are invalid");

                // add the keys //
                eq1.Add(idx1);
                eq2.Add(idx2);

            }

            // Get the predicate //
            Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause());

            // Get the list of expressions //
            FNodeSet nodes = VisitorHelper.GetReturnStatement(exp_vis, context.return_action().expression_or_wildcard_set());

            // Get the output cursor //
            RecordWriter out_data = VisitorHelper.GetWriter(Home, nodes.Columns, context.return_action());

            // Get the join method //
            MergeMethod method = VisitorHelper.GetMergeMethod(context.merge_type());

            // Find the best algorithm //
            MergeAlgorithm alg = MergeAlgorithm.SortMerge;
            if (context.merge_algorithm() != null)
            {
                string suggest_alg = exp_vis.ToNode(context.merge_algorithm().expression()).Evaluate().valueSTRING.ToUpper();
                if (suggest_alg == "NL")
                    alg = MergeAlgorithm.NestedLoop;
                else if (suggest_alg == "SM")
                    alg = MergeAlgorithm.SortMerge;
                else if (suggest_alg == "HT")
                    alg = MergeAlgorithm.HashTable;
            }
            if (eq1.Count == 0)
                alg = MergeAlgorithm.NestedLoop;

            return new MergePlan(method, alg, out_data, nodes, where, data1, data2, eq1, eq2, mem1, mem2);

//.........这里部分代码省略.........
开发者ID:pwdlugosz,项目名称:Horse,代码行数:101,代码来源:CommandCompiler.cs

示例3: ParseFNodeSet

        public static FNodeSet ParseFNodeSet(string Text, MemoryStruct LocalHeap, Workspace Home, string Alias, Schema Columns, Register Memory)
        {

            // Build text stream //
            AntlrInputStream ais = new AntlrInputStream(Text);
            HScriptLexer lex = new HScriptLexer(ais);

            // Build token tree //
            CommonTokenStream cts = new CommonTokenStream(lex);
            HScriptParser par = new HScriptParser(cts);

            // Build AST //
            IParseTree tree = par.expression_alias_list();
            if (tree == null)
                tree = par.expression_or_wildcard_set();
            
            // Visit each node getting the final node //
            ExpressionVisitor v = new ExpressionVisitor(LocalHeap, Home);
            v.AddSchema(Alias, Columns, Memory);

            if (tree is HScriptParser.Expression_or_wildcard_setContext)
            {
                HScriptParser.Expression_or_wildcard_setContext a = tree as HScriptParser.Expression_or_wildcard_setContext;
                return VisitorHelper.GetReturnStatement(v, a);
            }
            else if (tree is HScriptParser.Expression_alias_listContext)
            {
                HScriptParser.Expression_alias_listContext b = tree as HScriptParser.Expression_alias_listContext;
                return v.ToNodes(b);
            }

            throw new Exception("Expression is not an expression set: " + Text);

        }
开发者ID:pwdlugosz,项目名称:Horse,代码行数:34,代码来源:DataFactory.cs


注:本文中的ExpressionVisitor.AddSchema方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。