Esempio n. 1
0
        public static CreateChunkPlan RenderCreateChunk(Workspace Home, HScriptParser.Crudam_create_tableContext context)
        {

            ExpressionVisitor exp_vis = new ExpressionVisitor(null, Home);

            // Build the schema //
            Schema columns = new Schema();
            foreach (HScriptParser.Create_table_unitContext ctx in context.create_table_unit())
            {
                columns.Add(
                    ctx.IDENTIFIER().GetText(),
                    VisitorHelper.GetAffinity(ctx.type()),
                    (ctx.expression() == null) ? true : exp_vis.ToNode(ctx.expression()).Evaluate().valueBOOL,
                    VisitorHelper.GetSize(ctx.type(), true));
            }

            string name = context.full_table_name().table_name().IDENTIFIER().GetText();

            return new CreateChunkPlan(name, columns, Home);

        }
Esempio n. 2
0
        // Create //
        public static CreateTablePlan RenderCreatePlan(Workspace Home, HScriptParser.Crudam_create_tableContext context)
        {

            // Build visitor //
            ExpressionVisitor exp_vis = new ExpressionVisitor(null, Home);
            
            // Build the schema //
            Schema columns = new Schema();
            foreach (HScriptParser.Create_table_unitContext ctx in context.create_table_unit())
            {
                columns.Add(
                    ctx.IDENTIFIER().GetText(),
                    VisitorHelper.GetAffinity(ctx.type()),
                    (ctx.expression() == null) ? true : exp_vis.ToNode(ctx.expression()).Evaluate().valueBOOL,
                    VisitorHelper.GetSize(ctx.type(), true));
            }

            string name = context.full_table_name().table_name().GetText();
            string db = context.full_table_name().database_name().GetText();
            string db_path = Home.Connections[db];
            long chunk_size =
                (context.create_table_size() == null)
                ? RecordSet.EstimateMaxRecords(columns)
                : exp_vis.ToNode(context.create_table_size().expression()).Evaluate().valueINT;

            return new CreateTablePlan(db_path, name, columns, (int)chunk_size);

        }