{"id":253856,"date":"2022-10-06T08:06:33","date_gmt":"2022-10-06T00:06:33","guid":{"rendered":"https:\/\/gulass.cn\/?p=253856"},"modified":"2022-09-28T11:06:57","modified_gmt":"2022-09-28T03:06:57","slug":"redis-hyperloglog-linux","status":"publish","type":"post","link":"https:\/\/gulass.cn\/redis-hyperloglog-linux.html","title":{"rendered":"\u7b80\u5355\u4ecb\u7ecdRedis\u4e2dHyperLogLog\u7684\u4f7f\u7528\u8be6\u60c5"},"content":{"rendered":"
\u5bfc\u8bfb<\/td>\n | \u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4ecb\u7ecd\u4e86Redis\u4e2dHyperLogLog\u7684\u4f7f\u7528\u8be6\u60c5\uff0c\u6587\u7ae0\u56f4\u7ed5\u4e3b\u9898\u5c55\u5f00\u8be6\u7ec6\u7684\u5185\u5bb9\u4ecb\u7ecd\uff0c\u5177\u6709\u4e00\u5b9a\u7684\u53c2\u8003\u4ef7\u503c\uff0c\u9700\u8981\u7684\u5c0f\u4f19\u4f34\u53ef\u4ee5\u53c2\u8003\u4e00\u4e0b<\/strong><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n \u524d\u8a00<\/strong><\/div>\n HyperLogLog \uff0c\u57fa\u6570\u7edf\u8ba1\uff1b<\/p>\n \u90a3\u4ec0\u4e48\u662f\u57fa\u6570\uff1f<\/p>\n \u6bd4\u5982\u6709\u4e24\u4e2a\u6570\u7ec4<\/p>\n \u6570\u7ec4A = [1,2,3,4,5];<\/p>\n \u6570\u7ec4B = [3,4,5,6,7];<\/p>\n \u8fd9\u65f6\u5019\u57fa\u6570\u5c31\u662f [1,2,3,4,5,6,7]\uff0c\u603b\u5171\u67097\u4e2a\u6570\uff1b<\/p>\n \u5c31\u662f\u53bb\u91cd\u4e4b\u540e\u7684\u6570\u636e\uff1b<\/p>\n HyperLogLog \u5c31\u662f\u7528\u6765\u505a\u53bb\u91cd\u590d\u7edf\u8ba1\u7684\uff1b<\/p>\n bitmap \u5728\u505a\u7edf\u8ba1\u65f6\uff0c\u867d\u7136\u4f7f\u7528\u7684\u662f bit \u6765\u505a\u8bb0\u5f55\uff0c\u5df2\u7ecf\u5f88\u8282\u7701\u7a7a\u95f4\u4e86\uff1b<\/p>\n \u4f46\u662f\u5728\u968f\u7740\u6570\u636e\u91cf\u5feb\u901f\u589e\u957f\u7684\u60c5\u51b5\u4e0b\uff0cbitmap \u4e5f\u662f\u5f88\u5360\u5185\u5b58\u7a7a\u95f4\u7684\uff1b<\/p>\n \u800c HyperLogLog \u5c31\u4e0d\u540c\u4e86\uff0cHyperLogLog \u7684\u6bcf\u4e2a key \u53ea\u5360\u7528 12kb \u7684\u5185\u5b58\uff0c<\/p>\n \u5c31\u53ef\u4ee5\u7edf\u8ba1 2\u768464 \u6b21\u65b9\u4e2a\u57fa\u6570\uff1b<\/p>\n \u800c\u4e14\u4e0d\u4f1a\u968f\u7740\u6570\u636e\u91cf\u7684\u589e\u591a\u800c\u53d8\u5927\uff0c\u5c31\u662f\u56fa\u5b9a\u7684 12kb\uff1b<\/p>\n \u8fd9\u662f\u56e0\u4e3a HyperLogLog \u6bcf\u6b21\u53ea\u4f1a\u6839\u636e\u6dfb\u52a0\u7684\u6570\u636e\u53bb\u8ba1\u7b97\u57fa\u6570\uff0c\u800c\u4e0d\u4fdd\u5b58\u6dfb\u52a0\u7684\u6570\u636e\u672c\u8eab\uff1b<\/p>\n \u4f46\u8fd9\u4e5f\u9020\u6210\u4e86\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f HyperLogLog \u57fa\u6570\u7edf\u8ba1\u7684\u51c6\u786e\u7387\u4e0d\u662f100%\uff0c\u4f1a\u6709 0.81% \u7684\u8bef\u5dee\uff1b<\/p>\n \u4f46\u5bf9\u4e8e\u4ebf\u7ea7\u6570\u636e\u7684\u7edf\u8ba1\uff0c\u8fd9\u70b9\u8bef\u5dee\u4f3c\u4e4e\u53ef\u4ee5\u5ffd\u7565\u4e0d\u8ba1\uff1b<\/p>\n \u540c\u6837\u7684\uff0cbitmap \u8bb0\u5f55\u6570\u636e\u672c\u8eab\uff0c\u5b83\u7684\u8ba1\u7b97\u662f\u7cbe\u786e\u7684\uff1b<\/p>\n \u6240\u6709\uff0c\u4e5f\u53ef\u4ee5\u8bf4 HyperLogLog \u662f\u4e00\u79cd\u6982\u7387\u8ba1\u7b97\uff0c\u4f46\u662f\u8bef\u5dee\u662f\u5f88\u5c0f\u7684\u3002<\/p>\n \u8fd9\u662freidis\u4f5c\u8005\u5199\u7684\u5173\u4e8eHyperLogLog\u7684\u6587\u7ae0<\/p>\n HyperLogLog \u7684\u4f7f\u7528\u4e5f\u975e\u5e38\u7b80\u5355\uff0c\u5c313\u4e2a\u64cd\u4f5capi<\/p>\n \u6dfb\u52a0\u5143\u7d20<\/strong><\/div>\n pfadd key value [value ...]<\/pre>\npfadd 20220628:uv ip1 ip2 ip3\r\npfadd 20220629:uv ip1 ip2 ip3 ip4 ip5\r\npfadd 20220630:uv ip2 ip4 ip5 ip6 ip7 ip8<\/pre>\n |