leveldb学习---0
来源:互联网 发布:烈焰遮天 源码 双端 编辑:程序博客网 时间:2024/06/06 01:44
阅读google c++ style
资料:
https://zh-google-styleguide.readthedocs.io/en/latest/google-cpp-styleguide/
https://google.github.io/styleguide/cppguide.html
源码:
https://github.com/google/leveldb
编译安装
on ubuntu14.04:
sudo apt-get install git-core libsnappy-dev
git clone https://github.com/google/leveldb.gitcd leveldb/makesudo scp out-static/lib* out-shared/lib* /usr/local/lib/cd include/sudo scp -r leveldb /usr/local/include/sudo ldconfig
参考:
https://github.com/google/leveldb/issues/433
参考:
https://gist.github.com/dustismo/6203329
https://stackoverflow.com/questions/21435690/g-cant-find-headers-but-i-did-include-them
学习样例:
https://github.com/dazfuller/LevelDB-Sample/blob/master/sample.cpp
sample code:
/*** Filename: testdb.cc** Author: Haibo Hao* Email : haohaibo@ncic.ac.cn* Description: ---* Create: 2017-06-17 19:39:37* Last Modified: 2017-06-17 19:39:37**/#include <iostream>#include <sstream>#include <string>#include "leveldb/db.h"int main(){ leveldb::DB* db; leveldb::Options options; options.create_if_missing = true; leveldb::Status status = leveldb::DB::Open(options, ".testdb", &db); if (false == status.ok()) { std::cerr << "Unable to open/create test database './testdb'" << std::endl; std::cerr << status.ToString() << std::endl; return -1; } // Add 256 values to the database leveldb::WriteOptions writeOptions; for(unsigned int i = 0; i < 256; ++i) { std::ostringstream keyStream; keyStream << "Key" << i; std::ostringstream valueStream; valueStream << "Test data value : " << i; db->Put(writeOptions, keyStream.str(), valueStream.str()); } // Iterate over each item in the database and print them leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions()); for(it->SeekToFirst(); it->Valid(); it->Next()) { std::cout << it->key().ToString() << " : " << it->value().ToString() << std::endl; } if(false == it->status().ok()) { std::cerr << "An error was found during the scan" << std::endl; } delete it; // Close the databse delete db; return 0;}
compile:
g++ -o testdb testdb.cc -lleveldb
阅读全文
0 0
- leveldb学习---0
- LevelDB学习
- LevelDB学习
- levelDB学习
- leveldb 源码学习
- leveldb学习记录
- LevelDb学习资料
- LevelDB学习笔记
- leveldb学习开篇
- leveldb学习:测试代码
- leveldb学习:sstable(1)
- leveldb学习:sstable(2)
- leveldb学习:Version
- leveldb学习:DBimpl
- leveldb学习:Env
- leveldb学习:skiplist
- leveldb学习:Cache
- LevelDB学习笔记
- systemctl 常用命令备忘
- android 横竖屏幕切换
- Mybatis Plugin插件安装破解及使用
- CONCAT函数的介绍及mybatis 中模糊查询
- git图形化工具GitKraken的使用——删除文件(rm)
- leveldb学习---0
- 纯虚函数与抽象类
- python decode和encode
- Oracle那些事(9)-启动与关闭
- HDU 5517 Triple (线段树)
- 搜索插入位置
- 【Gradle】eclipse导入Gradle项目
- 机器学习实战-使用朴素贝叶斯分类器来做垃圾邮件分类
- 我的网络编程学习之路——getsockname 和 getpeername 函数