Beispiel #1
0
        public TableInfo getTableInfo(string tblname, Transaction tx)
        {
            RecordFile tcatfile = new RecordFile(tcatInfo, tx);
            int        reclen   = -1;

            while (tcatfile.next())
            {
                if (tcatfile.getString("tblname").Equals(tblname))
                {//获取到指定表名称的一条记录长度
                    reclen = tcatfile.getInt("reclength");
                    break;
                }
            }
            tcatfile.close();

            RecordFile fcatfile = new RecordFile(fcatInfo, tx);
            Schema     sch      = new Schema();
            Dictionary <string, int> offsets = new Dictionary <string, int>();

            while (fcatfile.next())
            {//每次取fcatfile中的一条记录
                if (fcatfile.getString("tblname").Equals(tblname))
                {
                    string fldname = fcatfile.getString("fldname");
                    int    fldtype = fcatfile.getInt("type");
                    int    fldlen  = fcatfile.getInt("length");
                    int    offset  = fcatfile.getInt("offset");
                    offsets.Add(fldname, offset);           //获取一张表中每个字段名称的偏移量
                    sch.addField(fldname, fldtype, fldlen); //获取一张表的模式信息
                }
            }
            fcatfile.close();
            return(new TableInfo(tblname, sch, offsets, reclen));
        }
Beispiel #2
0
 public Constant getVal(string fldname)
 {//以常量形式返回指定字段名称的值
     if (sch.type(fldname) == Schema.INTEGER)
     {
         return(new IntConstant(rf.getInt(fldname)));
     }
     else
     {
         return(new StringConstant(rf.getString(fldname)));
     }
 }