联系站长
加入收藏
会员登陆
 您的位置: 情长在线 >> 文章文献 >> 情长原创 >> By 情长在线(F.N.S.T)
   □  eXtremeSQL数据库研究学习笔记    3星级
eXtremeSQL数据库研究学习笔记
[作者:佚名    转贴自:F.N.S.T    点击数:    更新时间:2005-11-25    文章录入:一生情长]
【字体:

eXtremeSQL数据库研究学习笔记 

  
信息来源:[F.N.S.T]Www.Fineacer.Org Www.Fineacer.Com 
此文原始发布:http://www.fineacer.org/SHtml/Article/4342.shtml  
此文讨论地址:http://bbs.fineacer.org/ShowPost.asp?id=3411 
本文作者:damocles 

eXtremeDB内存式实时数据库是为实时系统及嵌入式系统而特别设计的数据库。与同类产品不同,eXtremeDB不是通过 对企业数据库面向实时嵌入式应用进行剪裁而来;而是总结了30年来McObject公司在编译器、实时编程、数据管理、内核级驱 动软件等领域的经验,面向实时嵌入式应用从头开发的最新实时数据管理技术。  
  eXtremeDB满足了您对实时数据库的一切期待:高级数据定义语言、并行访问、基于交易及灵活的索引… …等等。不仅如此,出乎您的意外,eXtremeDB在紧凑的引擎中还提供诸如事件触发、目标历史等等功能。 
以下是在C中的调用 

eXtremeDB运行时环境是通过调用mco_runtime_start()函数来完成初始化的。这个函数初始 
化一个信号量来同步多个进程对数据字典的访问。每个进程必须调用mco_runtime_start()一次, 
而且只能调用一次。  
  
  MCO_RET mco_runtime_start (void);  
  
在应用程序结束阶段,从数据库断开连接并关闭数据库之后,必须调用mco_runtime_stop() 
来清除该信号量,否则需要按照顺序来关闭eXtremeDB运行时。  
   MCO_RET mco_runtime_stop(void);  
  
通过调用mco_db_open()函数可以创建数据库。该函数有五个参数:  
MCO_RET    mco_db_open( const char * dbname, mco_dictionary_h dict,  void * ptr,uint4 total_size, uint2 page_size);  
 1>数据库名称,最多16字节长  
 2>co_dictionary_h,通常由编译器生成的dbname_get_dictionary函获得。 
 3>数据库内存的起始地址,运行时创建的内存(页)管理器处理所有存储数据的分配请求。  
 4>数据库运行时所占据的最大尺寸,该参数指定了内存管理器的管理的尺寸。 eX 
 5>eXremeDB页管理器使用的页空间(字节为单位)。 
最多可同时创建16个数据库。如果创建成功,函数返回MCO_S_OK (0)。  
eg: 
mco_runtime_start(); 
mco_db_open(DATABASE_NAME, ctestdb_get_dictionary(), start_addr, DATABASE_SIZE, PAGE_SIZE); 
函数mco_db_close()来销毁(关闭)由之前的mco_db_open()调用创建的数据库 
MCO_RET    mco_db_close(const char * dbname);  
mco_db_connect()连接到数据库 
MCO_RET    mco_db_connect(  const char * dbname, /*OUT*/ mco_db_h *handle);  
应用程序通过传递数据库名称到mco_db_connect()函数连接到数据库上 (创建一个数据库 
实例)。该数据库必须由之前的mco_db_open()调用创建。每个数据库允许同时最多64个连接。 
如果连接成功,该函数返回一个数据库句柄,该句柄被用于随后的数据库运行时调用,例如事 
务函数。  
  
MCO_RET    mco_db_disconnect( co_db_h db); 断开连接 
 应用程序通过调用mco_db_disconnect()函数与数据库断开连接。该函数使用数据库句柄作 
为参数。为该数据库实例创建的所有事务句柄全部失效。  
  
以下例子在VC6.0下编译通过 


#include  
#include  
#include  
#include "mcowrap.h" 
#include "mco.h" 
#define PAGE_SIZE       128 
#define DATABASE_SIZE   4*1024*1024 
#define DATABASE_NAME   "cccc" 
#define ALLOC_QUANTUM   1024*1024 
#define ALLOC_RETAIN    8*1024*1024  
// 


mco_dictionary_h ctestdb_get_dictionary(void) 
{  
  
  static mco_dictionary_t  dict;  
  static int dictionary_ready = 0; 
   
  if( ! dictionary_ready )  
  { 
    static mco_dict_field_t v_field_info[7] = {  
    /* Mask */ 
    {"mask", {4, 4, 0, 4, 4, 0}, 3, 0, 0, -1, 4, -1, 0, 0,  0}, 
    {"nbits", {1, 1, 4, 1, 1, 4}, 1, 0, 0, -1, 1, -1, 0, 1,  0}, 
    /* Route */ 
    {"dest", {4, 4, 0, 4, 4, 0}, 3, 0, 0, -1, 4, -1, 0, 0,  0}, 
    {"gateway", {4, 4, 4, 4, 4, 4}, 3, 0, 0, -1, 4, -1, 0, 2,  0}, 
    {"interf", {4, 4, 8, 4, 4, 8}, 3, 0, 0, -1, 4, -1, 0, 3,  0}, 
    {"mask", {4, 4, 12, 4, 4, 12}, 3, 0, 0, -1, 4, -1, 0, 1,  0}, 
    {"metric", {2, 2, 16, 2, 2, 16}, 2, 0, 0, -1, 2, -1, 0, 4,  0} 
    }; 
    static mco_dict_struct_t v_struct_info[2] = {  
    { "Mask", 0, 2, (v_field_info + 0), 5, 4, 5, 4 }, 
    { "Route", 0, 5, (v_field_info + 2), 18, 4, 18, 4 } 
    }; 
    dictionary_ready = 1; 
    { 
      static const char * v_class_names[] =  
      { 
        0,  
        "Mask"        , /* [1] */ 
        "Route"       , /* [2] */ 
        0 
      }; 
      dict.str_class_names = v_class_names; 
    } 

    { 
      static const char * v_index_names[] =  
      { 
        "Mask.all"               , /* [0] */ 
        "Route.byMaskDest"       , /* [1] */ 
        0 
      }; 
      dict.str_index_names = v_index_names; 
    } 
    { 
      static  mco_dict_class_info_t class_inf[3] = {  
        { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },  
        { 0, 0, -1, -1, 5, 0, -1, 0, 0, -1, -2, 16, (v_struct_info + 0), 5, 0, 0 }  /* Mask */ ,  
        { 1, 1, -1, -1, 18, 0, -1, 0, 0, -1, -2, 16, (v_struct_info + 1), 18, 0, 0 }  /* Route */  
      }; 
      dict.v_class_info = class_inf; 
    } 

    dict.v_desc_events = (mco_dict_event_t *)0; 
     
    dict.v_all_struct = v_struct_info; 
    { 
      static mco_dict_index_field_t v_all_index_fields[ 4] = { 
          { 4, -1, 1, 1, 0 } /* [0] */ 
        , { 0, -1, 4, 3, 0 } /* [1] */ 
        , { 12, -1, 4, 3, 0 } /* [2] */ 
        , { 0, -1, 4, 3, 0 } /* [3] */ 
      };  
      static mco_dict_index_t v_all_indexes_info[ 2] = { 
          { 1, 2, -1, 2051, & v_all_index_fields[0], 0 } /* Mask.all [0] */ 
        , { 2, 2, -1, 2050, & v_all_index_fields[2], 2000000 } /* Route.byMaskDest [1] */ 
      };  
      dict.v_desc_indexes = v_all_indexes_info; 

[1] [2]  下一页

  • 上一篇文章:给cmd.exe的使用加上口令(使用perl脚本)
  • 下一篇文章:服务器安全设置之防溢出提权攻击解决办法
  • 发表评论   □ 告诉好友   □ 打印此文  □ 关闭窗口
     最新10篇热点文章
    SQL SERVER2000安全解决方…[206]
    Linux集群在银行信息化中的…[210]
    巧用Linux2.6内核新功能配…[313]
    Linux DHCP网络故障排除事…[158]
    手把手教您配置Liunx目录服…[389]
    Linux下安装和使用杀毒软件…[263]
    (MS06-007)IGMP v3 DoS Ex…[256]
    FarsiNews Remote File In…[158]
    Apple Mac OS X File Rewr…[189]
    BomberClone Buffer Overf…[267]
     
     最新10篇推荐文章
    手把手教您配置Liunx目录服…[03-25]
    Linux下安装和使用杀毒软件…[03-25]
    (MS06-007)IGMP v3 DoS Ex…[03-25]
    BomberClone Buffer Overf…[03-25]
    vBulletin ImpEx模块远程文…[03-24]
    网络安全论文专题[03-23]
    服务器、网络安全解决方案…[03-23]
    服务器常见故障的诊断与解…[02-26]
    探寻适合小型企业的网络安…[02-26]
    交换机配置中的安全性[02-26]
     
     相 关 文 章
      ◇  网友评论:(只显示最新5条。评论内容只代表网友观点,与本站立场无关!)
     设为首页  加入收藏  关于本站  免费服务  广告服务   归档中心   站点地图  版权申明  联系站长  友情链接
    Copyright© 2001-2005 F.N.S.T Fineacer.Org .All Rights Reserved ICP备案:粤ICP备05002156号