leveldb-expand接口设计
来源:互联网 发布:阿里云服务器怎么续费 编辑:程序博客网 时间:2024/06/06 05:00
leveldb-expand接口设计
接口设计
- 前缀匹配:
virtual Status GetPrefix( const Slice& prefix, std::map<std::string, std::string>&entry_list );
接口名
:GetPrefix
接口功能
:根据prefix指定的前缀,获取匹配该前缀的所有k-v pair,结果存储在entry_list当中。
参数说明
:
- prefix:传入参数,指定要匹配的前缀
- entry_list:传出参数,存储匹配该前缀的所有k-v pair.
返回值
:返回Status对象
- 前缀匹配(指定数量):
virtual Status GetNPrefix( const Slice& prefix, int n, std::map<std::string, std::string>&entry_list );
接口名:GetPrefix
接口功能:根据prefix指定的前缀,以及获取记录条数n, 获取匹配该前缀的所有k-v pair,并将结果存储在entry_list当中。
参数说明:
- prefix:传入参数,指定要匹配的前缀
- n:传入参数,指定匹配的记录条数。
- entry_list:传出参数,存储匹配指定数量前缀的所有k-v pair.
返回值:返回Status对象
- 多feature匹配:
virtual Status GetFeature( std::vector<std::string>& feature_list, std::vector<int>& offset_list, std::map<std::string, std::string>&entry_list );
接口名
:GetFeature();
接口功能
:根据feature_list指定的feature,以及offset_list当中指定的feature偏移,获取匹配指定偏移feature的所有k-v pair,将结果存储在entry_list当中。
参数说明
:
- feature_list:传入参数,指定要匹配的feature
- offset:传入参数,指定匹配feature的偏移
- entry_list:传出参数,存储匹配feature的所有k-v pair.
返回值
:返回Status对象
- 多feature匹配(指定数量):
virtual Status GetNFeature( std::vector<std::string>& feature_list, std::vector<int>& offset_list, int n, std::map<std::string, std::string>&entry_list );
接口名
:GetNFeature();
接口功能
:根据feature_list指定的feature,以及offset_list当中指定的feature偏移,以及要匹配的记录数量,获取匹配指定偏移feature的所有k-v pair,将结果存储在entry_list当中。
参数说明
:
- feature_list:传入参数,指定要匹配的feature
- offset:传入参数,指定匹配feature的偏移
- n:传入参数,指定匹配的记录数量
- entry_list:传出参数,存储匹配feature的所有k-v pair.
返回值
:返回Status对象
测试程序
- 前缀匹配
使用场景:当DB中key由多个feature构成时,eg: key = uid__::__timestamp,按照前缀进行匹配,获取存储记录
key value 5205266179__::__20170304 李易峰 5205266179__::__20171204 杨幂 5205266179__::__20170804 杜兰特
#include <cassert>#include "leveldb/db.h"leveldb::DB* db;leveldb::Options options;options.create_if_missing = true;leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);assert(status.ok());leveldb::Slice prefix = "5205266179";std::map< std::string, std::string > entry_list;status = level::DB::GetPrefix( prefix, entry_list );// assess the entry_list// code remain to finish
- 前缀匹配(指定数量):
使用场景:当DB中key由多个feature构成时,eg: key = uid__::__timestamp,按照前缀进行匹配,指定要获取的记录数量n,获取指定数量的存储记录。DB样例如上。
#include <cassert>#include "leveldb/db.h"leveldb::DB* db;leveldb::Options options;options.create_if_missing = true;leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);assert(status.ok());leveldb::Slice prefix = "5205266179";int n = 8;std::map< std::string, std::string > entry_list;status = level::DB::GetPrefix( prefix, n, entry_list );// assess the entry_list// code remain to finish
- 多feature匹配:
使用场景:当DB中key由多个feature构成时,eg: key = uid__::__timestamp__query,按照指定位置的feature进行匹配,获取历史记录,DB样例如下。比如,可以按照第二个和第三个feature进行检索,检索在20170804查询词为杜兰特的记录
key value 5205266179__::20170304::__李易峰 李易峰 5205266179__::20171204::__杨幂 杨幂 5205266179__::20170804::__杜兰特 杜兰特 3656728192__::20170804::__李易峰 李易峰 2938271928__::20170804::__杜兰特 李易峰
#include <cassert>#include "leveldb/db.h"leveldb::DB* db;leveldb::Options options;options.create_if_missing = true;leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);assert(status.ok());std::string timestamp = "20170804";int offset_timestamp = 1;std::string query = "杜兰特";int offset_query = "2";std::vector<std::string> feature_list;feature_list.push_back( timestamp );feature_list.push_back(query);std::vector<int> offset_list;off_set.push_back( offset_timestamp );off_set.push_back( offset_query );std::map< std::string, std::string > entry_list;status = level::DB::GetFeature( feature_list, offset_list, entry_list );// assess the entry_list// code remain to finish
- 多feature匹配(指定数量):
使用场景:当DB中key由多个feature构成时,eg: key = uid__::__timestamp__query,按照指定位置的feature进行匹配,获取指定数量的历史记录,DB样例如下。比如,可以按照第二个和第三个feature进行检索,检索在20170804查询词为杜兰特的记录
key value 5205266179__::20170304::__李易峰 李易峰 5205266179__::20171204::__杨幂 杨幂 5205266179__::20170804::__杜兰特 杜兰特 3656728192__::20170804::__李易峰 李易峰 2938271928__::20170804::__杜兰特 李易峰
#include <cassert>#include "leveldb/db.h"leveldb::DB* db;leveldb::Options options;options.create_if_missing = true;leveldb::Status status = leveldb::DB::Open(options, "/tmp/testdb", &db);assert(status.ok());std::string timestamp = "20170804";int offset_timestamp = 1;std::string query = "杜兰特";int offset_query = "2";std::vector<std::string> feature_list;feature_list.push_back( timestamp );feature_list.push_back(query);std::vector<int> offset_list;off_set.push_back( offset_timestamp );off_set.push_back( offset_query );int n = 2; // 获取两条std::map< std::string, std::string > entry_list;status = level::DB::GetFeature( feature_list, offset_list, n, entry_list );// assess the entry_list// code remain to finish
- leveldb-expand接口设计
- leveldb-expand接口设计V2
- leveldb-expand文档
- leveldb接口概览
- LevelDB设计与实现
- leveldb设计分析之memtable
- leveldb设计分析之log
- LevelDB 设计模式 Iterator模式
- leveldb源码剖析---迭代器设计
- 【转载】leveldb中的LRUCache设计
- leveldb头文件的接口介绍
- LevelDb
- LevelDb
- LevelDb
- leveldb
- leveldb
- leveldb
- leveldb
- 用注解实现简单的框架 避免频繁调用FindViewById
- Matlab 读入txt文档数据,画出二维矩阵的直方图
- VuMark Design Guide VuMark设计指南
- Python笔记(十一)--for循环语句
- Android自定义SeekBar,带开始值结束值和Thumb上方滑动的Text
- leveldb-expand接口设计
- NAMP安装 (七) yum安装MySQL5.6
- Android无需权限显示悬浮窗, 兼谈逆向分析app
- Redis入门教程(二)—基本数据类型
- OpenCV中用Canny算子进行边缘检测
- Error:All flavors must now belong to a named flavor dimension
- Dubbo与Zookeeper、SpringMVC整合和使用(负载均衡、容错)
- C语言中向屏幕写数据的诸多方式
- python 读取excel文件