* Insert all matching tuples into a bitmap. */
| 78 | * Insert all matching tuples into a bitmap. |
| 79 | */ |
| 80 | int64 |
| 81 | blgetbitmap(IndexScanDesc scan, Node **bmNodeP) |
| 82 | { |
| 83 | int64 ntids = 0; |
| 84 | BlockNumber blkno = BLOOM_HEAD_BLKNO, |
| 85 | npages; |
| 86 | int i; |
| 87 | TIDBitmap *tbm; |
| 88 | BufferAccessStrategy bas; |
| 89 | BloomScanOpaque so = (BloomScanOpaque) scan->opaque; |
| 90 | |
| 91 | /* |
| 92 | * GPDB specific code. Since GPDB also support StreamBitmap |
| 93 | * in bitmap index. So normally we need to create specific bitmap |
| 94 | * node in the amgetbitmap AM. |
| 95 | */ |
| 96 | Assert(bmNodeP); |
| 97 | if (*bmNodeP == NULL) |
| 98 | { |
| 99 | /* XXX should we use less than work_mem for this? */ |
| 100 | tbm = tbm_create(work_mem * 1024L, scan->dsa); |
| 101 | *bmNodeP = (Node *) tbm; |
| 102 | } |
| 103 | else if (!IsA(*bmNodeP, TIDBitmap)) |
| 104 | elog(ERROR, "non bloom bitmap"); |
| 105 | else |
| 106 | tbm = (TIDBitmap *)*bmNodeP; |
| 107 | |
| 108 | if (so->sign == NULL) |
| 109 | { |
| 110 | /* New search: have to calculate search signature */ |
| 111 | ScanKey skey = scan->keyData; |
| 112 | |
| 113 | so->sign = palloc0(sizeof(BloomSignatureWord) * so->state.opts.bloomLength); |
| 114 | |
| 115 | for (i = 0; i < scan->numberOfKeys; i++) |
| 116 | { |
| 117 | /* |
| 118 | * Assume bloom-indexable operators to be strict, so nothing could |
| 119 | * be found for NULL key. |
| 120 | */ |
| 121 | if (skey->sk_flags & SK_ISNULL) |
| 122 | { |
| 123 | pfree(so->sign); |
| 124 | so->sign = NULL; |
| 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | /* Add next value to the signature */ |
| 129 | signValue(&so->state, so->sign, skey->sk_argument, |
| 130 | skey->sk_attno - 1); |
| 131 | |
| 132 | skey++; |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | /* |
| 137 | * We're going to read the whole index. This is why we use appropriate |
nothing calls this directly
no test coverage detected