예제 #1
0
    {//最简单、原始的、可能的查询计划
        public Plan createPlan(QueryData data, Transaction tx)
        {
            //第一步:为每一个出现的表或者视图定义创建一个plan
            List <Plan> plans = new List <Plan>();

            foreach (string tblname in data.tables())
            {
                string viewdef = SimpleDB.mdMgr().getViewDef(tblname, tx);
                if (viewdef != null)
                {
                    plans.Add(SimpleDB.planner().createQueryPlan(viewdef, tx));
                }
                else
                {
                    plans.Add(new TablePlan(tblname, tx));
                }
            }

            //第二步:创建所有表计划的叉积运算
            Plan p = plans[0];

            plans.RemoveAt(0);
            foreach (Plan nextplan in plans)
            {
                p = new ProductPlan(p, nextplan);
            }

            //第三步:为predicate添加一个选择运算selection
            p = new SelectPlan(p, data.pred());

            //第四步:做字段名称上的投影运算
            p = new ProjectPlan(p, data.fields());
            return(p);
        }
예제 #2
0
//---------------------------------------------------------------------------------------
        public IndexInfo(string idxname, string tblname, string fldname, Transaction tx)
        {
            this.idxname = idxname;
            this.fldname = fldname;
            this.tx      = tx;
            ti           = SimpleDB.mdMgr().getTableInfo(tblname, tx);
            si           = SimpleDB.mdMgr().getStatInfo(tblname, ti, tx);
        }
예제 #3
0
 public TablePlan(string tblname, Transaction tx)
 {//根据指定表在查询树种创建一个叶子节点
     this.tx = tx;
     ti      = SimpleDB.mdMgr().getTableInfo(tblname, tx);
     si      = SimpleDB.mdMgr().getStatInfo(tblname, ti, tx);
 }
예제 #4
0
 public int executeCreateIndex(CreateIndexData data, Transaction tx)
 {
     SimpleDB.mdMgr().createIndex(data.indexName(), data.tableName(), data.fieldName(), tx);
     return(0);
 }
예제 #5
0
 public int executeCreateView(CreateViewData data, Transaction tx)
 {
     SimpleDB.mdMgr().createView(data.viewName(), data.viewDef(), tx);
     return(0);
 }
예제 #6
0
 public int executeCreateTable(CreateTableData data, Transaction tx)
 {
     SimpleDB.mdMgr().createTable(data.tableName(), data.newSchema(), tx);
     return(0);
 }