Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6089960
  • 博文数量: 2759
  • 博客积分: 1021
  • 博客等级: 中士
  • 技术积分: 4091
  • 用 户 组: 普通用户
  • 注册时间: 2012-03-11 14:14
文章分类

全部博文(2759)

文章存档

2019年(1)

2017年(84)

2016年(196)

2015年(204)

2014年(636)

2013年(1176)

2012年(463)

分类: NOSQL

2014-09-11 12:23:14

原文地址:eXtremeDB API使用演示 作者:rob005

    这里写了一段code,加深对eXtremeDB API的使用方法的认识。

点击(此处)折叠或打开

  1. #define DATABASE_SEGMENT_SIZE 300 * 1024
  2. #define MEMORY_PAGE_SIZE 128
  3. const char * db_name = "SimpleDb";
  4. void main()
  5. {
  6. RC rc;
  7. mco_device_t dev;
  8. mco_db_params_t db_params;
  9. /* start eXtremeDB runtime */
  10. mco_runtime_start();
  11. /* setup memory device as a plain conventional memory region */
  12. dev.type = MCO_MEMORY_CONV;
  13. dev.assignment = MCO_MEMORY_ASSIGN_DATABASE;
  14. dev.size = DATABASE_SEGMENT_SIZE;
  15. dev.dev.conv.ptr = (void*)malloc( DATABASE_SEGMENT_SIZE );
  16. /* initialize and customize the database parameters */
  17. mco_db_params_init ( &db_params );
  18. db_params.mem_page_size = MEMORY_PAGE_SIZE;
  19. db_params.disk_page_size = 0;
  20. db_params.db_max_connections = 1;
  21. /* open a database on the device with given params */
  22. rc = mco_db_open_dev(db_name,SimpleDb_get_dictionary(),&dev,1,&db_params );
  23. if ( MCO_S_OK == rc ) {
  24. mco_db_close(db_name); /* close the database */
  25. } else {
  26. printf("\tError %d opening database", rc );
  27. }
  28. mco_runtime_stop();
  29. free( dev.dev.conv.ptr );
  30. return 0;
  31. }


阅读(1117) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~