levelDB的安装与小范例
来源:互联网 发布:webstorm mac 破解版 编辑:程序博客网 时间:2024/06/03 09:25
http://blog.sina.com.cn/s/blog_560e310001015jfx.html
一、下载LevelDB包
我下载的是:leveldb-1.4.0.tar.gz
git clone https://code.google.com/p/leveldb/
有些时候 上面不要加s的http
二、我在Ubunt上编译
解压之后进入目录:leveldb-1.4.0
执行:make,生成了: libleveldb.a
三、拷贝相应头文件到:/usr/local/include目录(需要root权限)
执行命令:
sudo cp -r include/leveldb /usr/local/include
范例:
- #include <assert.h>
- #include <string.h>
- #include <leveldb/db.h>
- #include <iostream>
- int main(){
- leveldb::DB* db;
- leveldb::Options options;
- options.create_if_missing = true;
- leveldb::Status status = leveldb::DB::Open(options,"/tmp/testdb", &db);
- assert(status.ok());
- //write key1,value1
- std::string key="key";
- std::string value = "value";
- status = db->Put(leveldb::WriteOptions(), key,value);
- assert(status.ok());
- status = db->Get(leveldb::ReadOptions(), key, &value);
- assert(status.ok());
- std::cout<<value<<std::endl;
- std::string key2 = "key2";
- //move the value under key to key2
- status = db->Put(leveldb::WriteOptions(),key2,value);
- assert(status.ok());
- status = db->Delete(leveldb::WriteOptions(), key);
- assert(status.ok());
- status = db->Get(leveldb::ReadOptions(),key2, &value);
- assert(status.ok());
- std::cout<<key2<<"==="<<value<<std::endl;
- status = db->Get(leveldb::ReadOptions(),key, &value);
- if(!status.ok()) std::cerr<<key<<" "<<status.ToString()<<std::endl;
- else std::cout<<key<<"==="<<value<<std::endl;
- delete db;
- return 0;
- }
编译: g++ -o test test.cc libleveldb.a -lpthread
0 0
- levelDB的安装与小范例
- leveldb的下载安装
- LevelDB数据库的安装和测试
- leveldb之SSTable的创建与访问
- 安装xtrabackup的一次范例
- Leveldb使用小例
- javascript表单事件处理的小范例
- leveldb 安装和使用
- leveldb安装和使用
- leveldb 安装及使用
- leveldb-c++版本安装
- leveldb安装以及使用
- Ubuntu下leveldb的安装使用(C++中)
- Rhel: pygame安装与范例运行,以及中间出错问题的处理(redhat)
- LevelDB设计与实现
- LevelDB源码剖析之SSTable_1(Block的创建与读取)
- 【神经网络与深度学习】leveldb的实现原理
- 【神经网络与深度学习】Leveldb的一些具体操作说明
- 最大团问题-分支限界算法
- Filter
- MPMoviePlayerViewController 播放完不退出
- junit作为多线程环境的启动入口
- CorePlot学习一
- levelDB的安装与小范例
- c++中的继承中的问题
- 网络库总结
- struts2 常量配置及详解
- We7的区县网站群建设策略
- 使用Splatting在PowerShell中传递参数
- linux 进程间信号量管理程序之sem_timedwait使用
- 赵雅智_Android Paint
- 线程同步