Esempio n. 1
0
        // Reads //
        public static StagedReadName RenderStagedReadPlan(Workspace Home, HScriptParser.Crudam_readContext context)
        {

            // Get the data source //
            DataSet data = VisitorHelper.GetData(Home, context.full_table_name());
            string alias =
                (context.K_AS() != null)
                ? context.IDENTIFIER().GetText()
                : data.Name;

            // Create a local heap to work off of //
            MemoryStruct local_heap = new MemoryStruct(true);

            // Create a record register //
            StreamRegister memory = new StreamRegister(null);

            // Create expression visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(local_heap, Home, alias, data.Columns, memory);

            // Where clause //
            Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause());

            // Create a reader //
            RecordReader reader = data.OpenReader(where);

            // Attach the reader to the register //
            memory.BaseStream = reader;

            // Create the action visitor //
            ActionVisitor act_vis = new ActionVisitor(Home, local_heap, exp_vis);

            // Get the declarations //
            if (context.crudam_declare_many() != null)
            {
                VisitorHelper.AllocateMemory(Home, local_heap, exp_vis, context.crudam_declare_many());
            }

            // Get the initial actionset //
            TNode pre_run =
                (context.init_action() != null)
                ? act_vis.ToNode(context.init_action().query_action())
                : new TNodeNothing(null);

            // Get the main actionset //
            TNode run = act_vis.ToNode(context.main_action().query_action());

            // Get the final actionset //
            TNode post_run =
                (context.final_action() != null)
                ? act_vis.ToNode(context.final_action().query_action())
                : new TNodeNothing(null);

            return new StagedReadName(reader, pre_run, run, post_run);

        }
Esempio n. 2
0
        internal static ReadMapNode RenderMapNode(Workspace Home, int PartitionID, HScriptParser.Crudam_read_maprContext context)
        {

            // Get the data source //
            DataSet data = VisitorHelper.GetData(Home, context.full_table_name());
            string alias =
                (context.K_AS() != null)
                ? context.IDENTIFIER().GetText()
                : data.Name;

            // Create a local heap to work off of //
            MemoryStruct local_heap = new MemoryStruct(true);

            // Create a record register //
            StaticRegister memory = new StaticRegister(null);

            // Create expression visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(local_heap, Home, alias, data.Columns, memory);

            // Where clause //
            Predicate where = VisitorHelper.GetWhere(exp_vis, context.where_clause());

            // Create a reader //
            RecordReader reader = data.OpenReader(where);

            // Get the declarations //
            if (context.crudam_declare_many() != null)
            {
                VisitorHelper.AllocateMemory(Home, local_heap, exp_vis, context.crudam_declare_many());
            }

            // Get the map actions //
            ActionVisitor act_vis = new ActionVisitor(Home, local_heap, exp_vis);
            act_vis.IsAsync = true;
            TNode map = act_vis.ToNode(context.map_action().query_action());

            // Get the reduce actions //
            act_vis = new ActionVisitor(Home, local_heap, exp_vis);
            act_vis.IsAsync = false;
            TNode red = act_vis.ToNode(context.reduce_action().query_action());

            ReadMapNode node = new ReadMapNode(PartitionID, map, red, memory, where);

            return node;

        }