一种分布式布隆过滤器设计
Posted 腾讯大讲堂
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了一种分布式布隆过滤器设计相关的知识,希望对你有一定的参考价值。
interface BloomProxyObj
{
int helloTest(out string rsp);
int add(AddReq req, out AddRsp rsp);
int addCond(AddCondReq req, out AddCondRsp rsp);
int mAdd(MAddReq req, out MAddRsp rsp);
int check(CheckReq req, out CheckRsp rsp);
int mCheck(MCheckReq req, out MCheckRsp rsp);
int createBloom(CreateBloomReq req, out CreateBloomRsp rsp);
int getBloomInfo(GetBloomInfoReq req, out GetBloomInfoRsp rsp);
};
struct Router
{
0 optional string filter;
1 optional string master;
2 optional string slave;
3 optional int status; //路由状态
4 optional int enable; //0:禁用 1:启用
};
struct GetRouterTabReq
{
0 optional long routerTabUpTime = 0; //路由表最后更新时间
};
struct GetRouterTabRsp
{
0 optional int code = 0;
1 optional string msg = "success";
2 optional bool isUpdate = true;
3 optional vector<Router> routerTab;
4 optional long routerTabUpTime = 0;
};
interface BloomRouterObj
{
int getRouterTab(GetRouterTabReq req, out GetRouterTabRsp rsp);
int createBloom(THBFProxy::CreateBloomReq req, out THBFProxy::CreateBloomRsp rsp);
};
|
|
|
|
|
|
|
|
|
|
|
|
struct Ident{
0 optional string filter;
1 optional long initSize;
2 optional double errRate;
3 optional int ident; //主,备
4 optional string master; //布隆过滤器的主节点地址
};
interface BloomFilterObj
{
int add(AddReq req, out AddRsp rsp);
int addCond(AddCondReq req, out AddCondRsp rsp);
int mAdd(MAddReq req, out MAddRsp rsp);
int check(CheckReq req, out CheckRsp rsp);
int mCheck(MCheckReq req, out MCheckRsp rsp);
int helloTest(out string rsp);
int createBloom(CreateBloomReq req, out CommRsp rsp);
int delBloom(string filter, out CommRsp rsp);
int getBloomIndex(string filter, out GetIndexRsp rsp);
int getBloomChunk(string filter, long iter, out GetChunkRsp rsp);
int syncBloomIdent(vector<Ident> idents);
int getNodeStatus(out GetNodeStatusRsp rsp);
int getBloomInfo(GetBloomInfoReq req, out GetBloomInfoRsp rsp);
};
struct Head
{
0 optional string headPath;
1 optional long headLen;
2 optional string md5;
};
struct Chunk
{
0 optional string chunkPath;
1 optional long iter;
2 optional long chunkLen;
3 optional string md5;
};
struct BloomDumpIndex
{
0 optional string filterName;
1 optional long items = 0;
2 optional long cfgChunkSize = 0;
3 optional Head head;
4 optional vector< Chunk> chunks;
};
[mqq@9-22-34-91 ~/taf/app_log]$ ll index/
index/:
total 32
- rw-rw-r-- 1 mqq mqq 2302 Jul 12 12:22 1014- rw-rw-r-- 1 mqq mqq 2302 Jul 12 12:22 1015- rw-rw-r-- 1 mqq mqq 2302 Jul 12 12:23 1016- rw-rw-r-- 1 mqq mqq 2302 Jul 12 12:26 1019- rw-rw-r-- 1 mqq mqq 2302 Jul 11 16:08 1020- rw-rw-r-- 1 mqq mqq 2302 Jul 11 17:08 1021- rw-rw-r-- 1 mqq mqq 2302 Jul 11 20:02 1022- rw-rw-r-- 1 mqq mqq 2302 Jul 12 12:22 1023
[mqq@9- 22- 34- 91 ~ /taf/app_log]$ cat index/ 1014
{ "filterName" :"1014", "items" : 0, "cfgChunkSize" : 2097152, "head" :{ "headPath" :"/usr/local/app/taf/app_log/dump//1014//head", "headLen" : 35141, "md5" :"9634183C403C6F9DD58EEF3E1AC51B48"}, "chunks" :[{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/0", "iter" : 2097153, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/1", "iter" : 4194305, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/2", "iter" : 6291457, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/3", "iter" : 8388609, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/4", "iter" : 10485761, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/5", "iter" : 12582913, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/6", "iter" : 14680065, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/7", "iter" : 16777217, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/8", "iter" : 18874369, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/9", "iter" : 20971521, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/10", "iter" : 23068673, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/11", "iter" : 25165825, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/12", "iter" : 27262977, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/13", "iter" : 29360129, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/14", "iter" : 31457281, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"},{ "chunkPath" :"/usr/local/app/taf/app_log/dump//1014/15", "iter" : 33554433, "chunkLen" : 2097152, "md5" :"B2D1236C286A3C0704224FE4105ECA49"}]}
[mqq@9-22-34-91 ~/taf/app_log]$ ll dump/1014/
total 32804
- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 0- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 1- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 10- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 11- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 12- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 13- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 14- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 15- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 2- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 3- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 4- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 5- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 6- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 7- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 8- rw-rw-r-- 1 mqq mqq 2097152 Jul 12 12:22 9- rw-rw-r-- 1 mqq mqq 35141 Jul 12 12:22 head
以上是关于一种分布式布隆过滤器设计的主要内容,如果未能解决你的问题,请参考以下文章
BloomFilter怎么用?使用布隆过滤器来判断key是否存在?