Пример #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);

        }
Пример #2
0
        public static long Update(DataSet Data, Key K, FNodeSet Fields, Predicate BaseDataFilter)
        {

            // Check that the field indicies and the maps have the same length //
            if (K.Count != Fields.Count)
                throw new Exception(string.Format("Field collection passed [{0}] has fewer elements than the map collection passed [{0}]", K.Count, Fields.Count));

            // Create the total append count //
            long CountOf = 0;

            // Loop through each extent //
            foreach (RecordSet rs in Data.Extents)
            {

                // Open a stream //
                RecordReader rr = new RecordReader(rs, BaseDataFilter);

                // Create a register //
                Register mem = new StreamRegister(rr);

                // Assign the register to the fields //
                Fields.AssignRegister(mem);

                // Update the data //
                while (!rr.EndOfData)
                {
                    Update(rr.Read(), K, Fields);
                    CountOf++;
                    rr.Advance();
                }

                // 
                if (rs.IsAttached)
                    BinarySerializer.Flush(rs);

            }

            // No need to flush the data set //

            return CountOf;

        }
Пример #3
0
	    // Constructor //
	    public RecordReader(RecordSet From, Predicate Where)
	    {
		
		    this._ptrRecord = DEFAULT_POINTER;
		    this._Data = From;
		    this._Where = Where;
            
            // Assign the where to a register pointing to 'this' //
            StreamRegister reg = new StreamRegister(this);
            this._Where.Node.AssignRegister(reg);
            
            // Fix the default //
            if (!Where.Default)
		    {
			    this._IsFiltered = true;
                while (!this.CheckFilter && !this.EndOfData)
                    this.Advance();
		    }

            // This is used to handle the writer class that inherits the reader //
            if (From != null)
                this._columns = From.Columns;
	    }
Пример #4
0
        public static FastReadPlan RenderFastReadPlan(Workspace Home, HScriptParser.Crudam_read_fastContext 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 record register //
            StreamRegister memory = new StreamRegister(null);

            // Create expression visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(new MemoryStruct(true), 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;

            // Get the fields being returned //
            FNodeSet nodes = VisitorHelper.GetReturnStatement(exp_vis, context.return_action().expression_or_wildcard_set());

            // Get the output cursor from the return statement //
            RecordWriter writer = VisitorHelper.GetWriter(Home, nodes.Columns, context.return_action());

            return new FastReadPlan(data, where, nodes, writer);

        }