blob: a8eb48f5bb81f8d45cd7b8a06b7042e071758d15 [file] [log] [blame]
"use strict";(self.webpackChunkdoris_website=self.webpackChunkdoris_website||[]).push([[9994],{15680:(e,t,a)=>{a.d(t,{xA:()=>g,yg:()=>s});var n=a(296540);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),a.push.apply(a,n)}return a}function r(e){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?i(Object(a),!0).forEach((function(t){l(e,t,a[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):i(Object(a)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(a,t))}))}return e}function p(e,t){if(null==e)return{};var a,n,l=function(e,t){if(null==e)return{};var a,n,l={},i=Object.keys(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||(l[a]=e[a]);return l}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],t.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(e,a)&&(l[a]=e[a])}return l}var u=n.createContext({}),o=function(e){var t=n.useContext(u),a=t;return e&&(a="function"==typeof e?e(t):r(r({},t),e)),a},g=function(e){var t=o(e.components);return n.createElement(u.Provider,{value:t},e.children)},m="mdxType",c={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},y=n.forwardRef((function(e,t){var a=e.components,l=e.mdxType,i=e.originalType,u=e.parentName,g=p(e,["components","mdxType","originalType","parentName"]),m=o(a),y=l,s=m["".concat(u,".").concat(y)]||m[y]||c[y]||i;return a?n.createElement(s,r(r({ref:t},g),{},{components:a})):n.createElement(s,r({ref:t},g))}));function s(e,t){var a=arguments,l=t&&t.mdxType;if("string"==typeof e||l){var i=a.length,r=new Array(i);r[0]=y;var p={};for(var u in t)hasOwnProperty.call(t,u)&&(p[u]=t[u]);p.originalType=e,p[m]="string"==typeof e?e:l,r[1]=p;for(var o=2;o<i;o++)r[o]=a[o];return n.createElement.apply(null,r)}return n.createElement.apply(null,a)}y.displayName="MDXCreateElement"},132014:(e,t,a)=>{a.r(t),a.d(t,{assets:()=>u,contentTitle:()=>r,default:()=>c,frontMatter:()=>i,metadata:()=>p,toc:()=>o});var n=a(58168),l=(a(296540),a(15680));const i={title:"BITMAP \u7cbe\u51c6\u53bb\u91cd",language:"zh-CN"},r=void 0,p={unversionedId:"query/duplicate/orthogonal-bitmap-manual",id:"version-2.0/query/duplicate/orthogonal-bitmap-manual",title:"BITMAP \u7cbe\u51c6\u53bb\u91cd",description:"\x3c!--",source:"@site/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.0/query/duplicate/orthogonal-bitmap-manual.md",sourceDirName:"query/duplicate",slug:"/query/duplicate/orthogonal-bitmap-manual",permalink:"/zh-CN/docs/2.0/query/duplicate/orthogonal-bitmap-manual",draft:!1,tags:[],version:"2.0",frontMatter:{title:"BITMAP \u7cbe\u51c6\u53bb\u91cd",language:"zh-CN"},sidebar:"docs",previous:{title:"Join Hint",permalink:"/zh-CN/docs/2.0/query/join-optimization/join-hint"},next:{title:"HLL \u8fd1\u4f3c\u53bb\u91cd",permalink:"/zh-CN/docs/2.0/query/duplicate/using-hll"}},u={},o=[{value:"\u80cc\u666f",id:"\u80cc\u666f",level:2},{value:"\u4f7f\u7528\u6307\u5357",id:"\u4f7f\u7528\u6307\u5357",level:2},{value:"Create table",id:"create-table",level:3},{value:"Data Load",id:"data-load",level:3},{value:"\u4f7f\u7528\u573a\u666f",id:"\u4f7f\u7528\u573a\u666f",level:3}],g={toc:o},m="wrapper";function c(e){let{components:t,...a}=e;return(0,l.yg)(m,(0,n.A)({},g,a,{components:t,mdxType:"MDXLayout"}),(0,l.yg)("h2",{id:"\u80cc\u666f"},"\u80cc\u666f"),(0,l.yg)("p",null,"Doris \u539f\u6709\u7684 Bitmap \u805a\u5408\u51fd\u6570\u8bbe\u8ba1\u6bd4\u8f83\u901a\u7528\uff0c\u4f46\u5bf9\u4ebf\u7ea7\u522b\u4ee5\u4e0a bitmap \u5927\u57fa\u6570\u7684\u4ea4\u5e76\u96c6\u8ba1\u7b97\u6027\u80fd\u8f83\u5dee\u3002\u6392\u67e5\u540e\u7aef be \u7684 bitmap \u805a\u5408\u51fd\u6570\u903b\u8f91\uff0c\u53d1\u73b0\u4e3b\u8981\u6709\u4e24\u4e2a\u539f\u56e0\u3002\u4e00\u662f\u5f53 bitmap \u57fa\u6570\u8f83\u5927\u65f6\uff0c\u5982 bitmap \u5927\u5c0f\u8d85\u8fc7 1g\uff0c\u7f51\u7edc/\u78c1\u76d8 IO \u5904\u7406\u65f6\u95f4\u6bd4\u8f83\u957f\uff1b\u4e8c\u662f\u540e\u7aef be \u5b9e\u4f8b\u5728 scan \u6570\u636e\u540e\u5168\u90e8\u4f20\u8f93\u5230\u9876\u5c42\u8282\u70b9\u8fdb\u884c\u6c42\u4ea4\u548c\u5e76\u8fd0\u7b97\uff0c\u7ed9\u9876\u5c42\u5355\u8282\u70b9\u5e26\u6765\u538b\u529b\uff0c\u6210\u4e3a\u5904\u7406\u74f6\u9888\u3002"),(0,l.yg)("p",null,"\u89e3\u51b3\u601d\u8def\u662f\u5c06 bitmap \u5217\u7684\u503c\u6309\u7167 range \u5212\u5206\uff0c\u4e0d\u540c range \u7684\u503c\u5b58\u50a8\u5728\u4e0d\u540c\u7684\u5206\u6876\u4e2d\uff0c\u4fdd\u8bc1\u4e86\u4e0d\u540c\u5206\u6876\u7684 bitmap \u503c\u662f\u6b63\u4ea4\u7684\u3002\u5f53\u67e5\u8be2\u65f6\uff0c\u5148\u5206\u522b\u5bf9\u4e0d\u540c\u5206\u6876\u4e2d\u7684\u6b63\u4ea4 bitmap \u8fdb\u884c\u805a\u5408\u8ba1\u7b97\uff0c\u7136\u540e\u9876\u5c42\u8282\u70b9\u76f4\u63a5\u5c06\u805a\u5408\u8ba1\u7b97\u540e\u7684\u503c\u5408\u5e76\u6c47\u603b\uff0c\u5e76\u8f93\u51fa\u3002\u5982\u6b64\u4f1a\u5927\u5927\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\uff0c\u89e3\u51b3\u4e86\u9876\u5c42\u5355\u8282\u70b9\u8ba1\u7b97\u74f6\u9888\u95ee\u9898\u3002"),(0,l.yg)("h2",{id:"\u4f7f\u7528\u6307\u5357"},"\u4f7f\u7528\u6307\u5357"),(0,l.yg)("ol",null,(0,l.yg)("li",{parentName:"ol"},(0,l.yg)("p",{parentName:"li"},"\u5efa\u8868\uff0c\u589e\u52a0 hid \u5217\uff0c\u8868\u793a bitmap \u5217\u503c id \u8303\u56f4\uff0c\u4f5c\u4e3a hash \u5206\u6876\u5217")),(0,l.yg)("li",{parentName:"ol"},(0,l.yg)("p",{parentName:"li"},"\u4f7f\u7528\u573a\u666f"))),(0,l.yg)("h3",{id:"create-table"},"Create table"),(0,l.yg)("p",null,"\u5efa\u8868\u65f6\u9700\u8981\u4f7f\u7528\u805a\u5408\u6a21\u578b\uff0c\u6570\u636e\u7c7b\u578b\u662f bitmap , \u805a\u5408\u51fd\u6570\u662f bitmap_union"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},'CREATE TABLE `user_tag_bitmap` (\n `tag` bigint(20) NULL COMMENT "\u7528\u6237\u6807\u7b7e",\n `hid` smallint(6) NULL COMMENT "\u5206\u6876id",\n `user_id` bitmap BITMAP_UNION NULL COMMENT ""\n) ENGINE=OLAP\nAGGREGATE KEY(`tag`, `hid`)\nCOMMENT "OLAP"\nDISTRIBUTED BY HASH(`hid`) BUCKETS 3\n')),(0,l.yg)("p",null,"\u8868 schema \u589e\u52a0 hid \u5217\uff0c\u8868\u793a id \u8303\u56f4\uff0c\u4f5c\u4e3a hash \u5206\u6876\u5217\u3002"),(0,l.yg)("admonition",{type:"note"},(0,l.yg)("p",{parentName:"admonition"},"\u6ce8\uff1ahid \u6570\u548c BUCKETS \u8981\u8bbe\u7f6e\u5408\u7406\uff0chid \u6570\u8bbe\u7f6e\u81f3\u5c11\u662f BUCKETS \u7684 5 \u500d\u4ee5\u4e0a\uff0c\u4ee5\u4f7f\u6570\u636e hash \u5206\u6876\u5c3d\u91cf\u5747\u8861")),(0,l.yg)("h3",{id:"data-load"},"Data Load"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},"LOAD LABEL user_tag_bitmap_test\n(\nDATA INFILE('hdfs://abc')\nINTO TABLE user_tag_bitmap\nCOLUMNS TERMINATED BY ','\n(tmp_tag, tmp_user_id)\nSET (\ntag = tmp_tag,\nhid = ceil(tmp_user_id/5000000),\nuser_id = to_bitmap(tmp_user_id)\n)\n)\n\u6ce8\u610f\uff1a5000000\u8fd9\u4e2a\u6570\u4e0d\u56fa\u5b9a\uff0c\u53ef\u6309\u9700\u8c03\u6574\n...\n")),(0,l.yg)("p",null,"\u6570\u636e\u683c\u5f0f\uff1a"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-text"},"11111111,1\n11111112,2\n11111113,3\n11111114,4\n...\n")),(0,l.yg)("admonition",{type:"note"},(0,l.yg)("p",{parentName:"admonition"},"\u6ce8\uff1a\u7b2c\u4e00\u5217\u4ee3\u8868\u7528\u6237\u6807\u7b7e\uff0c\u7531\u4e2d\u6587\u8f6c\u6362\u6210\u6570\u5b57")),(0,l.yg)("p",null,"load \u6570\u636e\u65f6\uff0c\u5bf9\u7528\u6237 bitmap \u503c range \u8303\u56f4\u7eb5\u5411\u5207\u5272\uff0c\u4f8b\u5982\uff0c\u7528\u6237 id \u5728 1-5000000 \u8303\u56f4\u5185\u7684 hid \u503c\u76f8\u540c\uff0chid \u503c\u76f8\u540c\u7684\u884c\u4f1a\u5206\u914d\u5230\u4e00\u4e2a\u5206\u6876\u5185\uff0c\u5982\u6b64\u6bcf\u4e2a\u5206\u6876\u5185\u5230\u7684 bitmap \u90fd\u662f\u6b63\u4ea4\u7684\u3002\u53ef\u4ee5\u5229\u7528\u6876\u5185 bitmap \u503c\u6b63\u4ea4\u7279\u6027\uff0c\u8fdb\u884c\u4ea4\u5e76\u96c6\u8ba1\u7b97\uff0c\u8ba1\u7b97\u7ed3\u679c\u4f1a\u88ab shuffle \u81f3 top \u8282\u70b9\u805a\u5408\u3002"),(0,l.yg)("admonition",{type:"note"},(0,l.yg)("p",{parentName:"admonition"},"\u6ce8\uff1a\u6b63\u4ea4 bitmap \u51fd\u6570\u4e0d\u80fd\u7528\u5728\u5206\u533a\u8868\uff0c\u56e0\u4e3a\u5206\u533a\u8868\u5206\u533a\u5185\u6b63\u4ea4\uff0c\u5206\u533a\u4e4b\u95f4\u7684\u6570\u636e\u662f\u65e0\u6cd5\u4fdd\u8bc1\u6b63\u4ea4\u7684\uff0c\u5219\u8ba1\u7b97\u7ed3\u679c\u4e5f\u662f\u65e0\u6cd5\u9884\u4f30\u7684\u3002")),(0,l.yg)("p",null,(0,l.yg)("strong",{parentName:"p"},"bitmap_orthogonal_intersect")),(0,l.yg)("p",null,"\u6c42 bitmap \u4ea4\u96c6\u51fd\u6570"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bed\u6cd5\uff1a")),(0,l.yg)("p",null,"orthogonal_bitmap_intersect(bitmap_column, column_to_filter, filter_values)"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u53c2\u6570\uff1a")),(0,l.yg)("p",null,"\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f Bitmap \u5217\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u7528\u6765\u8fc7\u6ee4\u7684\u7ef4\u5ea6\u5217\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u53d8\u957f\u53c2\u6570\uff0c\u542b\u4e49\u662f\u8fc7\u6ee4\u7ef4\u5ea6\u5217\u7684\u4e0d\u540c\u53d6\u503c"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bf4\u660e\uff1a")),(0,l.yg)("p",null,"\u67e5\u8be2\u89c4\u5212\u4e0a\u805a\u5408\u5206 2 \u5c42\uff0c\u5728\u7b2c\u4e00\u5c42 be \u8282\u70b9\uff08update\u3001serialize\uff09\u5148\u6309 filter_values \u4e3a key \u8fdb\u884c hash \u805a\u5408\uff0c\u7136\u540e\u5bf9\u6240\u6709 key \u7684 bitmap \u6c42\u4ea4\u96c6\uff0c\u7ed3\u679c\u5e8f\u5217\u5316\u540e\u53d1\u9001\u81f3\u7b2c\u4e8c\u5c42 be \u8282\u70b9 (merge\u3001finalize)\uff0c\u5728\u7b2c\u4e8c\u5c42 be \u8282\u70b9\u5bf9\u6240\u6709\u6765\u6e90\u4e8e\u7b2c\u4e00\u5c42\u8282\u70b9\u7684 bitmap \u503c\u5faa\u73af\u6c42\u5e76\u96c6"),(0,l.yg)("p",null,"\u6837\u4f8b\uff1a"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},"select BITMAP_COUNT(orthogonal_bitmap_intersect(user_id, tag, 13080800, 11110200)) from user_tag_bitmap where tag in (13080800, 11110200);\n")),(0,l.yg)("p",null,(0,l.yg)("strong",{parentName:"p"},"orthogonal_bitmap_intersect_count")),(0,l.yg)("p",null,"\u6c42 bitmap \u4ea4\u96c6 count \u51fd\u6570\uff0c\u8bed\u6cd5\u540c\u539f\u7248 intersect_count\uff0c\u4f46\u5b9e\u73b0\u4e0d\u540c"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bed\u6cd5\uff1a")),(0,l.yg)("p",null,"orthogonal_bitmap_intersect_count(bitmap_column, column_to_filter, filter_values)"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u53c2\u6570\uff1a")),(0,l.yg)("p",null,"\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f Bitmap \u5217\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u7528\u6765\u8fc7\u6ee4\u7684\u7ef4\u5ea6\u5217\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u5f00\u59cb\u662f\u53d8\u957f\u53c2\u6570\uff0c\u542b\u4e49\u662f\u8fc7\u6ee4\u7ef4\u5ea6\u5217\u7684\u4e0d\u540c\u53d6\u503c"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bf4\u660e\uff1a")),(0,l.yg)("p",null,"\u67e5\u8be2\u89c4\u5212\u805a\u5408\u4e0a\u5206 2 \u5c42\uff0c\u5728\u7b2c\u4e00\u5c42 be \u8282\u70b9\uff08update\u3001serialize\uff09\u5148\u6309 filter_values \u4e3a key \u8fdb\u884c hash \u805a\u5408\uff0c\u7136\u540e\u5bf9\u6240\u6709 key \u7684 bitmap \u6c42\u4ea4\u96c6\uff0c\u518d\u5bf9\u4ea4\u96c6\u7ed3\u679c\u6c42 count\uff0ccount \u503c\u5e8f\u5217\u5316\u540e\u53d1\u9001\u81f3\u7b2c\u4e8c\u5c42 be \u8282\u70b9\uff08merge\u3001finalize\uff09\uff0c\u5728\u7b2c\u4e8c\u5c42 be \u8282\u70b9\u5bf9\u6240\u6709\u6765\u6e90\u4e8e\u7b2c\u4e00\u5c42\u8282\u70b9\u7684 count \u503c\u5faa\u73af\u6c42 sum"),(0,l.yg)("p",null,(0,l.yg)("strong",{parentName:"p"},"orthogonal_bitmap_union_count")),(0,l.yg)("p",null,"\u6c42 bitmap \u5e76\u96c6 count \u51fd\u6570\uff0c\u8bed\u6cd5\u540c\u539f\u7248 bitmap_union_count\uff0c\u4f46\u5b9e\u73b0\u4e0d\u540c\u3002"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bed\u6cd5\uff1a")),(0,l.yg)("p",null,"orthogonal_bitmap_union_count(bitmap_column)"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u53c2\u6570\uff1a")),(0,l.yg)("p",null,"\u53c2\u6570\u7c7b\u578b\u662f bitmap\uff0c\u662f\u5f85\u6c42\u5e76\u96c6 count \u7684\u5217"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bf4\u660e\uff1a")),(0,l.yg)("p",null,"\u67e5\u8be2\u89c4\u5212\u4e0a\u5206 2 \u5c42\uff0c\u5728\u7b2c\u4e00\u5c42 be \u8282\u70b9\uff08update\u3001serialize\uff09\u5bf9\u6240\u6709 bitmap \u6c42\u5e76\u96c6\uff0c\u518d\u5bf9\u5e76\u96c6\u7684\u7ed3\u679c bitmap \u6c42 count\uff0ccount \u503c\u5e8f\u5217\u5316\u540e\u53d1\u9001\u81f3\u7b2c\u4e8c\u5c42 be \u8282\u70b9\uff08merge\u3001finalize\uff09\uff0c\u5728\u7b2c\u4e8c\u5c42 be \u8282\u70b9\u5bf9\u6240\u6709\u6765\u6e90\u4e8e\u7b2c\u4e00\u5c42\u8282\u70b9\u7684 count \u503c\u5faa\u73af\u6c42 sum"),(0,l.yg)("p",null,(0,l.yg)("strong",{parentName:"p"},"orthogonal_bitmap_expr_calculate")),(0,l.yg)("p",null,"\u6c42\u8868\u8fbe\u5f0f bitmap \u4ea4\u5e76\u5dee\u96c6\u5408\u8ba1\u7b97\u51fd\u6570\u3002"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bed\u6cd5\uff1a")),(0,l.yg)("p",null,"orthogonal_bitmap_expr_calculate(bitmap_column, filter_column, input_string)"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u53c2\u6570\uff1a")),(0,l.yg)("p",null,"\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f Bitmap \u5217\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u7528\u6765\u8fc7\u6ee4\u7684\u7ef4\u5ea6\u5217\uff0c\u5373\u8ba1\u7b97\u7684 key \u5217\uff0c\u7b2c\u4e09\u4e2a\u53c2\u6570\u662f\u8ba1\u7b97\u8868\u8fbe\u5f0f\u5b57\u7b26\u4e32\uff0c\u542b\u4e49\u662f\u4f9d\u636e key \u5217\u8fdb\u884c bitmap \u4ea4\u5e76\u5dee\u96c6\u8868\u8fbe\u5f0f\u8ba1\u7b97"),(0,l.yg)("p",null,"\u8868\u8fbe\u5f0f\u652f\u6301\u7684\u8ba1\u7b97\u7b26\uff1a& \u4ee3\u8868\u4ea4\u96c6\u8ba1\u7b97\uff0c| \u4ee3\u8868\u5e76\u96c6\u8ba1\u7b97\uff0c- \u4ee3\u8868\u5dee\u96c6\u8ba1\u7b97\uff0c^ \u4ee3\u8868\u5f02\u6216\u8ba1\u7b97\uff0c\\ \u4ee3\u8868\u8f6c\u4e49\u5b57\u7b26"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bf4\u660e\uff1a")),(0,l.yg)("p",null,"\u67e5\u8be2\u89c4\u5212\u4e0a\u805a\u5408\u5206 2 \u5c42\uff0c\u7b2c\u4e00\u5c42 be \u805a\u5408\u8282\u70b9\u8ba1\u7b97\u5305\u62ec init\u3001update\u3001serialize \u6b65\u9aa4\uff0c\u7b2c\u4e8c\u5c42 be \u805a\u5408\u8282\u70b9\u8ba1\u7b97\u5305\u62ec merge\u3001finalize \u6b65\u9aa4\u3002\u5728\u7b2c\u4e00\u5c42 be \u8282\u70b9\uff0cinit \u9636\u6bb5\u89e3\u6790 input_string \u5b57\u7b26\u4e32\uff0c\u8f6c\u6362\u4e3a\u540e\u7f00\u8868\u8fbe\u5f0f\uff08\u9006\u6ce2\u5170\u5f0f\uff09\uff0c\u89e3\u6790\u51fa\u8ba1\u7b97 key \u503c\uff0c\u5e76\u5728 map<key, bitmap>\u7ed3\u6784\u4e2d\u521d\u59cb\u5316\uff1bupdate \u9636\u6bb5\uff0c\u5e95\u5c42\u5185\u6838 scan \u7ef4\u5ea6\u5217\uff08filter_column\uff09\u6570\u636e\u540e\u56de\u8c03 update \u51fd\u6570\uff0c\u7136\u540e\u4ee5\u8ba1\u7b97 key \u4e3a\u5355\u4f4d\u5bf9\u4e0a\u4e00\u6b65\u7684 map \u7ed3\u6784\u4e2d\u7684 bitmap \u8fdb\u884c\u805a\u5408\uff1bserialize \u9636\u6bb5\uff0c\u6839\u636e\u540e\u7f00\u8868\u8fbe\u5f0f\uff0c\u89e3\u6790\u51fa\u8ba1\u7b97 key \u5217\u7684 bitmap\uff0c\u5229\u7528\u6808\u7ed3\u6784\u5148\u8fdb\u540e\u51fa\u539f\u5219\uff0c\u8fdb\u884c bitmap \u4ea4\u5e76\u5dee\u96c6\u5408\u8ba1\u7b97\uff0c\u7136\u540e\u5bf9\u6700\u7ec8\u7684\u7ed3\u679c bitmap \u5e8f\u5217\u5316\u540e\u53d1\u9001\u81f3\u7b2c\u4e8c\u5c42\u805a\u5408 be \u8282\u70b9\u3002\u5728\u7b2c\u4e8c\u5c42\u805a\u5408 be \u8282\u70b9\uff0c\u5bf9\u6240\u6709\u6765\u6e90\u4e8e\u7b2c\u4e00\u5c42\u8282\u70b9\u7684 bitmap \u503c\u6c42\u5e76\u96c6\uff0c\u5e76\u8fd4\u56de\u6700\u7ec8 bitmap \u7ed3\u679c"),(0,l.yg)("p",null,(0,l.yg)("strong",{parentName:"p"},"orthogonal_bitmap_expr_calculate_count")),(0,l.yg)("p",null,"\u6c42\u8868\u8fbe\u5f0f bitmap \u4ea4\u5e76\u5dee\u96c6\u5408\u8ba1\u7b97 count \u51fd\u6570\uff0c\u8bed\u6cd5\u548c\u53c2\u6570\u540c orthogonal_bitmap_expr_calculate\u3002"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bed\u6cd5\uff1a")),(0,l.yg)("p",null,"orthogonal_bitmap_expr_calculate_count(bitmap_column, filter_column, input_string)"),(0,l.yg)("ul",null,(0,l.yg)("li",{parentName:"ul"},"\u8bf4\u660e\uff1a")),(0,l.yg)("p",null,"\u67e5\u8be2\u89c4\u5212\u4e0a\u805a\u5408\u5206 2 \u5c42\uff0c\u7b2c\u4e00\u5c42 be \u805a\u5408\u8282\u70b9\u8ba1\u7b97\u5305\u62ec init\u3001update\u3001serialize \u6b65\u9aa4\uff0c\u7b2c\u4e8c\u5c42 be \u805a\u5408\u8282\u70b9\u8ba1\u7b97\u5305\u62ec merge\u3001finalize \u6b65\u9aa4\u3002\u5728\u7b2c\u4e00\u5c42 be \u8282\u70b9\uff0cinit \u9636\u6bb5\u89e3\u6790 input_string \u5b57\u7b26\u4e32\uff0c\u8f6c\u6362\u4e3a\u540e\u7f00\u8868\u8fbe\u5f0f\uff08\u9006\u6ce2\u5170\u5f0f\uff09\uff0c\u89e3\u6790\u51fa\u8ba1\u7b97 key \u503c\uff0c\u5e76\u5728 map<key, bitmap>\u7ed3\u6784\u4e2d\u521d\u59cb\u5316\uff1bupdate \u9636\u6bb5\uff0c\u5e95\u5c42\u5185\u6838 scan \u7ef4\u5ea6\u5217\uff08filter_column\uff09\u6570\u636e\u540e\u56de\u8c03 update \u51fd\u6570\uff0c\u7136\u540e\u4ee5\u8ba1\u7b97 key \u4e3a\u5355\u4f4d\u5bf9\u4e0a\u4e00\u6b65\u7684 map \u7ed3\u6784\u4e2d\u7684 bitmap \u8fdb\u884c\u805a\u5408\uff1bserialize \u9636\u6bb5\uff0c\u6839\u636e\u540e\u7f00\u8868\u8fbe\u5f0f\uff0c\u89e3\u6790\u51fa\u8ba1\u7b97 key \u5217\u7684 bitmap\uff0c\u5229\u7528\u6808\u7ed3\u6784\u5148\u8fdb\u540e\u51fa\u539f\u5219\uff0c\u8fdb\u884c bitmap \u4ea4\u5e76\u5dee\u96c6\u5408\u8ba1\u7b97\uff0c\u7136\u540e\u5bf9\u6700\u7ec8\u7684\u7ed3\u679c bitmap \u7684 count \u503c\u5e8f\u5217\u5316\u540e\u53d1\u9001\u81f3\u7b2c\u4e8c\u5c42\u805a\u5408 be \u8282\u70b9\u3002\u5728\u7b2c\u4e8c\u5c42\u805a\u5408 be \u8282\u70b9\uff0c\u5bf9\u6240\u6709\u6765\u6e90\u4e8e\u7b2c\u4e00\u5c42\u8282\u70b9\u7684 count \u503c\u6c42\u52a0\u548c\uff0c\u5e76\u8fd4\u56de\u6700\u7ec8 count \u7ed3\u679c\u3002"),(0,l.yg)("h3",{id:"\u4f7f\u7528\u573a\u666f"},"\u4f7f\u7528\u573a\u666f"),(0,l.yg)("p",null,"\u7b26\u5408\u5bf9 bitmap \u8fdb\u884c\u6b63\u4ea4\u8ba1\u7b97\u7684\u573a\u666f\uff0c\u5982\u5728\u7528\u6237\u884c\u4e3a\u5206\u6790\u4e2d\uff0c\u8ba1\u7b97\u7559\u5b58\uff0c\u6f0f\u6597\uff0c\u7528\u6237\u753b\u50cf\u7b49\u3002"),(0,l.yg)("p",null,"\u4eba\u7fa4\u5708\u9009\uff1a"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"}," select orthogonal_bitmap_intersect_count(user_id, tag, 13080800, 11110200) from user_tag_bitmap where tag in (13080800, 11110200);\n \u6ce8\uff1a13080800\u300111110200\u4ee3\u8868\u7528\u6237\u6807\u7b7e\n")),(0,l.yg)("p",null,"\u8ba1\u7b97 user_id \u7684\u53bb\u91cd\u503c\uff1a"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},"select orthogonal_bitmap_union_count(user_id) from user_tag_bitmap where tag in (13080800, 11110200);\n")),(0,l.yg)("p",null,"bitmap \u4ea4\u5e76\u5dee\u96c6\u5408\u6df7\u5408\u8ba1\u7b97\uff1a"),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},"select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(833736|999777)&(1308083|231207)&(1000|20000-30000)') from user_tag_bitmap where tag in (833736,999777,130808,231207,1000,20000,30000);\n\u6ce8\uff1a1000\u300120000\u300130000\u7b49\u6574\u5f62tag\uff0c\u4ee3\u8868\u7528\u6237\u4e0d\u540c\u6807\u7b7e\n")),(0,l.yg)("pre",null,(0,l.yg)("code",{parentName:"pre",className:"language-sql"},"select orthogonal_bitmap_expr_calculate_count(user_id, tag, '(A:a/b|B:2\\\\-4)&(C:1-D:12)&E:23') from user_str_tag_bitmap where tag in ('A:a/b', 'B:2-4', 'C:1', 'D:12', 'E:23');\n \u6ce8\uff1a'A:a/b', 'B:2-4'\u7b49\u662f\u5b57\u7b26\u4e32\u7c7b\u578btag\uff0c\u4ee3\u8868\u7528\u6237\u4e0d\u540c\u6807\u7b7e, \u5176\u4e2d'B:2-4'\u9700\u8981\u8f6c\u4e49\u6210'B:2\\\\-4'\n")))}c.isMDXComponent=!0}}]);