leveldb实例
来源:互联网 发布:Sql中not in的效率 编辑:程序博客网 时间:2024/04/30 01:59
- #include <iostream>
- #include "db.h"
- #include "iterator.h"
- #include <stdio.h>
- using namespace std;
- int main()
- {
- leveldb::DB* db;
- leveldb::Options options;
- options.create_if_missing = true;
- std::string dbpath = "testdb";
- leveldb::Status status = leveldb::DB::Open(options, dbpath, &db);
- assert(status.ok());
- std::string key1 = "lyc";
- std::string value1 = "liyc7711@gamil.com";
- //cout<<"Open db OK"<<std::endl;
- string key2 = "haha";
- string value2 = "segfwaga";
- std::string v1 = "";
- string v2 = "";
- leveldb::Status s ;
- s = db->Put(leveldb::WriteOptions(), key1, value1);/*key1和key2作为一对key-value对插入*/
- s = db->Get(leveldb::ReadOptions(), key1, &v1);/*根据key返回对应的value值*/
- db->Put(leveldb::WriteOptions(), key2, value2);
- db->Get(leveldb::ReadOptions(), key2, &v2);
- cout<<v1<< " "<< v2<<std::endl;
- leveldb::Iterator* it = db->NewIterator(leveldb::ReadOptions());
- for(it->SeekToFirst(); it->Valid(); it->Next()){
- cout<< it->key().ToString() << ":" << it->value().ToString()<<endl;
- }
- delete it;
- delete db;/*删除数据库*/
- }
0 0
- leveldb实例
- leveldb实例
- LevelDb
- LevelDb
- LevelDb
- leveldb
- leveldb
- leveldb
- leveldb
- LevelDb
- LevelDb
- Leveldb
- Leveldb
- levelDB
- LevelDb
- leveldb
- LevelDb
- LevelDb
- [基础] -- static用法探究
- 蓝桥杯 算法训练 P1103
- linux-shell命令之mv(move)【移动或者改名】
- 变态跳台阶
- 利用ansible-playbook从测试环境获取tomcat中java项目新版本发布到生产环境
- leveldb实例
- python 中的None
- Codeforces Round #257 (Div. 1) A - Jzzhu and Chocolate 2017/1/11
- Android6.0 如何添加更改系统设置权限
- 树状数组逆序对
- Maven精华文章收录
- Three.JS学习 5:了解相机
- linux-shell命令之rm(remove)【删除文件或目录】
- GMssl -- 1