• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

kyamagu/matlab-lmdb: Matlab LMDB wrapper

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kyamagu/matlab-lmdb

开源软件地址(OpenSource Url):

https://github.com/kyamagu/matlab-lmdb

开源编程语言(OpenSource Language):

C 77.0%

开源软件介绍(OpenSource Introduction):

Matlab LMDB

Matlab LMDB wrapper for UNIX environment.

See also matlab-leveldb.

The package does not contain any data serialization. Use char for storing keys and values. You will need to serialize any Matlab variables to directly save in the database. For example, using num2str and str2double. There are different serialization options, such as this serialization package or JSON format. Those using Caffe might want to use a Datum converter in the caffe-extension branch.

Build

Specify the MATLABDIR path.

make MATLABDIR=/usr/local/MATLAB/R2015a
make test

Edit Makefile to customize the build process.

In the caffe-extension branch, also specify the path to caffe.

make MATLABDIR=/usr/local/MATLAB/R2015a CAFFEDIR=../caffe

Example

% Open and close.
database = lmdb.DB('./db', 'MAPSIZE', 1024^3);
clear database;
readonly_database = lmdb.DB('./db', 'RDONLY', true, 'NOLOCK', true);
clear readonly_database;

% Read and write.
database.put('key1', 'value1');
database.put('key2', 'value2');
value1 = database.get('key1');
database.remove('key1');

% Iterator.
database.each(@(key, value) disp([key, ': ', value]));
count = database.reduce(@(key, value, count) count + 1, 0);

% Cursor.
cursor = database.cursor('RDONLY', true);
while cursor.next()
  key = cursor.key;
  value = cursor.value;
end
clear cursor;

% Transaction.
transaction = database.begin();
try
  transaction.put('key1', 'value1');
  transaction.put('key2', 'value2');
  transaction.commit();
catch exception
  transaction.abort();
end
clear transaction;

% Dump.
keys = database.keys();
values = database.values();

See help documentation of each function, or visit LMDB documentation to understand the flags.

Caffe extension

The caffe-extension branch includes utilities to convert Datum protocol buffer.

% Make plain datum.
image = imread('peppers.png');
label = 1;
datum = caffe_pb.toDatum(image, label);

% Make encoded datum.
fid = fopen('peppers.png', 'r');
png_image = fread(fid, inf, 'uint8=>uint8');
fclose(fid);
label = 1;
datum = caffe_pb.toEncodedDatum(png_image, label);

% Read datum.
[png_image, label] = caffe_pb.fromDatum(datum);

TODO

  • Finer transaction API.



鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap