---------------------------------------------------------------- * MultiExecBitmapOr * * BitmapOr node gets the bitmaps generated from BitmapIndexScan * nodes and outputs a bitmap that ORs all input bitmaps. * * The first input bitmap is utilized to store the result of the * OR and returned to the caller. In addition, the output points * to a newly created OpStream node o
| 117 | * ---------------------------------------------------------------- |
| 118 | */ |
| 119 | Node * |
| 120 | MultiExecBitmapOr(BitmapOrState *node) |
| 121 | { |
| 122 | PlanState **bitmapplans; |
| 123 | int nplans; |
| 124 | int i; |
| 125 | /* |
| 126 | * Cloudberry uses result for TIDBitmap result, and node->bitmap for |
| 127 | * StreamBitmap result if there is any StreamBitmap. |
| 128 | * |
| 129 | * At last it will union them and return. |
| 130 | */ |
| 131 | TIDBitmap *result = NULL; |
| 132 | |
| 133 | /* must provide our own instrumentation support */ |
| 134 | if (node->ps.instrument) |
| 135 | InstrStartNode(node->ps.instrument); |
| 136 | |
| 137 | /* |
| 138 | * get information from the node |
| 139 | */ |
| 140 | bitmapplans = node->bitmapplans; |
| 141 | nplans = node->nplans; |
| 142 | |
| 143 | /* |
| 144 | * Scan all the subplans and OR their result bitmaps |
| 145 | */ |
| 146 | for (i = 0; i < nplans; i++) |
| 147 | { |
| 148 | PlanState *subnode = bitmapplans[i]; |
| 149 | Node *subresult = NULL; |
| 150 | |
| 151 | /* |
| 152 | * Note for further merge iteration: |
| 153 | * Cloudberry's BitmapIndexScan returns a StreamBitmap |
| 154 | */ |
| 155 | subresult = MultiExecProcNode(subnode); |
| 156 | |
| 157 | if (subresult == NULL) |
| 158 | continue; |
| 159 | |
| 160 | if (!(IsA(subresult, TIDBitmap) || |
| 161 | IsA(subresult, StreamBitmap))) |
| 162 | elog(ERROR, "unrecognized result from subplan"); |
| 163 | |
| 164 | if (IsA(subresult, TIDBitmap)) |
| 165 | { |
| 166 | /* if it's a TIDBitmap, union into result */ |
| 167 | if (result == NULL) |
| 168 | result = (TIDBitmap *)subresult; |
| 169 | else |
| 170 | { |
| 171 | tbm_union(result, (TIDBitmap *)subresult); |
| 172 | tbm_generic_free(subresult); |
| 173 | } |
| 174 | } |
| 175 | else |
| 176 | { |
no test coverage detected