MDB_env 为一个结构体,Opaque structure for a database environment.

MDB_txn :Opaque structure for a transaction handle.

typedef unsigned int MDB_dbi, A handle for an individual database in the DB environment.

struct MDB_val  :Generic structure used for passing keys and data in and out of the database.

它包含:size_t mv_size, void* mv_data;

structure MDB_cursor: Opaque structure for navigating through a database.

函数 int mdb_env_create(MDB_env** env)

它的作用就是创建一个LMDB的环境handle,就是指向一个分配了内存的地址啦,这个函数会为MDB_env结构体分配一个内存。它我们使用handle  的时候,首先要用mdb_env_open()函数打开,最后也要调用mdb_env_close()函数释放掉内存并discard handle。

参数:[out] env,The address where the new handle will be stored。

返回:如果错误,返回一个非零的值,如果正确,返回零;

函数 :mdb_env_open()

int mdb_env_open  ( MDB_env *  env,
const char * path,
unsigned int flags,
mdb_mode_t mode
)

它的作用是:打开一个环境handle。

注:如果函数失败,我们要调用 mdb_env_close() 来丢弃  MDB_env handle.

参数说明:

[in] env :就是我们的环境handle。

[in] path :数据的路径。注意:它必须存在,并且可写;

[in] flags: 对于环境的一些特别的选项,它必须被设为0 或着把不同的选项 or在一起,

常见的flag:http://104.237.133.194/doc/ group__mdb.html#ga32a193c6bf4d7d5c5d579e71f22e9340

[in] mode:对于linux来说 ,就是这个操作的对于文件权限(如:0644),windows忽略;

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数 :mdb_env_close ()

void mdb_env_close ( MDB_env * env)

作用:Close the environment and release the memory map.

函数: int mdb_env_set_mapsize()

int mdb_env_set_mapsize  ( MDB_env *  env,
size_t size
)

作用:设置环境的memory map 的大小;注意:默认大小 为:10485760 bytes,该函数用在mdb_env_create()之后,且mdb_env_open()之前,当然,在后面它也可能被调用的;

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数:int mdb_txn_begin()

int mdb_txn_begin  ( MDB_env *     env,
MDB_txn * parent,
unsigned int flags,
MDB_txn ** txn
)

作用:Create a transaction for use with the environment.

参数:[in] env:An environment handle returned by mdb_env_create()

[in] parent:可以为空,即NULL,如果不是空的话,the new transaction will be a nested transaction。

[in] flags: 指对于操作来说一些特别的选项,可以为0或着其它:如MDB_RDONLY,表示:它不会执行任何写操作;

[in] txn  ,Address where the new MDB_txn handle will be stored .

返回值:如果错误,返回一个非零的值,如果正确,返回零;

另外:The transaction handle may be discarded using mdb_txn_abort() or mdb_txn_commit().

函数:mdb_dbi_open()

int mdb_dbi_open  ( MDB_txn *  txn,
const char * name,
unsigned int flags,
MDB_dbi * dbi
)

作用:在环境里打开一个database;

注意:database handle denotes the name and parameters of a database, independently of whether such a database exists.The database handle may be discarded by calling mdb_dbi_close().

参数:

[in] txn :A transaction 的handle;

[in]  name:打开的database的名字,If only a single database is needed in the environment, this value may be NULL.

[in]  flags:Special options for this database. 可以为0或着其它选项

[out] dbi :Address where the new MDB_dbi handle will be store;

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数:int mdb_put()

int mdb_put  ( MDB_txn *  txn,
MDB_dbi dbi,
MDB_val * key,
MDB_val * data,
unsigned int flags
)

作用:store items into a datagase,也就是说,把key/data pairs存放到database里面。

注意:当键值有相同的时候,The default behavior is to enter the new key/data pair, replacing any previously existing

key if duplicates are disallowed, or adding a duplicate data item if duplicates are allowed 。

参数:

[in] txn: A transaction handle returned by mdb_txn_begin() 
[in] dbi :A database handle returned by mdb_dbi_open() 
[in] key :The key to store in the database 
[in,out] data: The data to store 
[in] flags Special options for this operation. This parameter must be set to 0 or by bitwise OR'ing together one or more of the values described here.

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数:int mdb_txn_commit()

int mdb_txn_commit  ( MDB_txn *  txn )

作用:提交所有的操作:Commit all the operations of a transaction into the database.

注意:提交完以后,The transaction handle is freed. It and its cursors must not be used again after this call, except with mdb_cursor_renew().

参数:[in] txn:即我们要提交的那个transaction的handle;

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数:int mdb_cursor_open ()

int mdb_cursor_open  ( MDB_txn *  txn,
MDB_dbi dbi,
MDB_cursor ** cursor
)

作用:创建一个cursor的handle。

备注:A cursor is associated with a specific transaction and database。

参数:

[in] txn A transaction handle returned by mdb_txn_begin()
[in] dbi A database handle returned by mdb_dbi_open()
[out] cursor Address where the new MDB_cursor handle will be stored

返回值:如果错误,返回一个非零的值,如果正确,返回零;

函数:mdb_cursor_get()

int mdb_cursor_get  ( MDB_cursor *  cursor,
MDB_val * key,
MDB_val * data,
MDB_cursor_op op
)

功能:通过cursor读取数据

参数:

[in] cursor: A cursor handle returned by mdb_cursor_open()
[in,out] key: The key for a retrieved item
[in,out] data: The data of a retrieved item
[in] op: A cursor operation MDB_cursor_op

其中:enum MDB_cursor_op,它枚举了许多Cursor Get 的操作,如下所示:

MDB_FIRST
Position at first key/data item MDB_FIRST_DUP
Position at first data item of current key. Only for MDB_DUPSORT MDB_GET_BOTH
Position at key/data pair. Only for MDB_DUPSORT MDB_GET_BOTH_RANGE
position at key, nearest data. Only for MDB_DUPSORT MDB_GET_CURRENT
Return key/data at current cursor position MDB_GET_MULTIPLE
Return key and up to a page of duplicate data items from current cursor position. Move cursor to prepare for MDB_NEXT_MULTIPLE. Only for MDB_DUPFIXED MDB_LAST
Position at last key/data item MDB_LAST_DUP
Position at last data item of current key. Only for MDB_DUPSORT MDB_NEXT
Position at next data item MDB_NEXT_DUP
Position at next data item of current key. Only for MDB_DUPSORT MDB_NEXT_MULTIPLE
Return key and up to a page of duplicate data items from next cursor position. Move cursor to prepare for MDB_NEXT_MULTIPLE. Only for MDB_DUPFIXED MDB_NEXT_NODUP
Position at first data item of next key MDB_PREV
Position at previous data item MDB_PREV_DUP
Position at previous data item of current key. Only for MDB_DUPSORT MDB_PREV_NODUP
Position at last data item of previous key MDB_SET
Position at specified key MDB_SET_KEY
Position at specified key, return key + data MDB_SET_RANGE
Position at first key greater than or equal to specified key.

先写到这里吧。。

看的时候,可以结合一个例子:http://blog.csdn.net/u012235274/article/details/51899598

还有很多:http://104.237.133.194/doc/index.html

lmdb存储的一些库相关函数的更多相关文章

  1. C语言操作WINDOWS系统存储区数字证书相关函数详解及实例

     C语言操作WINDOWS系统存储区数字证书相关函数详解及实例 以下代码使用C++实现遍历存储区证书及使用UI选择一个证书 --使用CertOpenSystemStore打开证书存储区. --在循环中 ...

  2. python 存储引擎 mysql(库,表, 行) 单表多表操作 (foreign key) sql_mode pymysql模块讲解

    ##################总结############### mysql 常用数据类型 整型:tinyint  int(42亿条左右)  bigint 小数:float double dec ...

  3. python开发mysql:mysql安装(windows)&密码找回&存储引擎简介&库表的增删改查

    一,mysql安装 下载地址 https://dev.mysql.com/downloads/file/?id=471342 解压后,将目录C:\mysql-5.7.19-winx64\bin添加到计 ...

  4. 突破本地离线存储的JS库 localforage

    localforage 简介 项目地址 https://github.com/localForage/localForage API中文地址 https://localforage.docschina ...

  5. C语言多线程pthread库相关函数说明

    线程相关操作说明 一 pthread_t pthread_t在头文件/usr/include/bits/pthreadtypes.h中定义: typedef unsigned long int pth ...

  6. RTSP客户端接收存储数据(live555库中的openRTSP实例)

    一.openRTSP编译运行 a)windows下编译运行 还是以mediaServer作为服务端,openRTSP作为客户端 b)Linux下编译运行 转自http://kuafu80.blog.1 ...

  7. RTSP客户端接收存储数据(live555库中的testRTSPClient实例)

    1.testRTSPClient简介 testRTSPClient是个简单的客户端实例,这个实例对rtsp数据交互作了详细的描述,其中涉及到rtsp会话的两个概念Source和Sink. Source ...

  8. 批量导出存储在msdb库的SSIS包

    http://blog.51cto.com/ultrasql/1924464 use msdb go IF OBJECT_ID('msdb.dbo.usp_ExportSSISPkgs') IS NO ...

  9. caffe 根据txt生成多标签LMDB数据

    1. 前提: 已经准备好train.txt, test.txt文件, 格式如下 此处有坑, 如果是windows下生成txt, 换行符为\r\n, 需要替换成 \n才能在linux运行. 可以使用se ...

随机推荐

  1. 20145227 《Java程序设计》第4周学习总结

    20145227 <Java程序设计>第4周学习总结 教材学习内容总结 第六章 继承与多态 6.1 何谓继承 1.继承共同行为 多个类中存在相同属性和行为时,将这些内容抽取到单独一个类中, ...

  2. [Unity3D][Vuforia][IOS]vuforia在unity3d中添加自己的动态模型,识别自己的图片,添加GUI,播放视频

    使用环境 unity3D 5 pro vuforia 4 ios 8.1(6.1) xcode 6.1(6.2) 1.新建unity3d工程,添加vuforia 4.0的工程包 Hierarchy中 ...

  3. C#利用POST实现杭电oj的AC自动机器人,AC率高达50%~~

    暑假集训虽然很快乐,偶尔也会比较枯燥,,这个时候就需要自娱自乐... 然后看hdu的排行榜发现,除了一些是虚拟测评机的账号以外,有几个都是AC自动机器人 然后发现有一位作者是用网页填表然后按钮模拟,, ...

  4. ASP.NET生成缩略图的代码

    01.        // <summary> 02.        /// 生成缩略图 03.        /// </summary> 04.        /// &l ...

  5. UML类图几种关系的总结(转)

    原文:http://gjhappyyy.iteye.com/blog/1422515 在UML类图中,常见的有以下几种关系: 泛化(Generalization),  实现(Realization), ...

  6. HTTP缓存机制

    缓存对于移动端是非常重要的存在. 减少请求次数,减小服务器压力. 本地数据读取速度更快,让页面不会空白几百毫秒. 在无网络的情况下提供数据. 缓存一般由服务器控制(通过某些方式可以本地控制缓存,比如向 ...

  7. 【Java】集合(List、Set)遍历、判断、删除元素时的小陷阱

    开发中,常有场景:遍历集合,依次判断是否符合条件,如符合条件则删除当前元素. 不知不觉中,有些陷阱,不知你有没有犯. 一.漏网之鱼-for循环递增下标方式遍历集合,并删除元素 如果你用for循环递增下 ...

  8. HDU 2289 CUP 二分

    Cup Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  9. Python3基础 ,= 一个等式给多个变量赋值

    镇场诗:---大梦谁觉,水月中建博客.百千磨难,才知世事无常.---今持佛语,技术无量愿学.愿尽所学,铸一良心博客.------------------------------------------ ...

  10. 三HttpServletResponse对象介绍(1)

    转载自http://www.cnblogs.com/xdp-gacl/p/3789624.html Web服务器收到客户端的http请求,会针对每一次请求,分别创建一个用于代表请求的request对象 ...