* build_inserttuple() -- insert a new tuple into the bitmap index * during the bitmap index construction. * * Each new tuple has an assigned number -- tidnum, called a * tid location, which represents the bit location for this tuple in * a bitmap vector. To speed up the construction, this function does not * write this tid location into its bitmap vector immediately. We maintain * a buffer
| 2276 | * for enough distinct values to disk to accommodate this new tuple. |
| 2277 | */ |
| 2278 | static void |
| 2279 | build_inserttuple(Relation rel, uint64 tidnum, |
| 2280 | ItemPointerData ht_ctid pg_attribute_unused(), TupleDesc tupDesc, |
| 2281 | Datum *attdata, bool *nulls, BMBuildState *state) |
| 2282 | { |
| 2283 | Buffer metabuf; |
| 2284 | BlockNumber lovBlock; |
| 2285 | OffsetNumber lovOffset; |
| 2286 | bool blockNull; |
| 2287 | bool offsetNull; |
| 2288 | BMTidBuildBuf *tidLocsBuffer; |
| 2289 | int attno; |
| 2290 | bool allNulls = true; |
| 2291 | BMBuildHashKey *entry; |
| 2292 | |
| 2293 | CHECK_FOR_INTERRUPTS(); |
| 2294 | |
| 2295 | tidLocsBuffer = state->bm_tidLocsBuffer; |
| 2296 | |
| 2297 | /* Check if all attributes have value of NULL. */ |
| 2298 | for (attno = 0; attno < tupDesc->natts; attno++) |
| 2299 | { |
| 2300 | if (!nulls[attno]) |
| 2301 | { |
| 2302 | allNulls = false; |
| 2303 | break; |
| 2304 | } |
| 2305 | } |
| 2306 | |
| 2307 | metabuf = _bitmap_getbuf(rel, BM_METAPAGE, BM_WRITE); |
| 2308 | |
| 2309 | /* |
| 2310 | * if the inserting tuple has the value of NULL, then |
| 2311 | * the corresponding tid array is the first. |
| 2312 | */ |
| 2313 | if (allNulls) |
| 2314 | { |
| 2315 | lovBlock = BM_LOV_STARTPAGE; |
| 2316 | lovOffset = 1; |
| 2317 | } |
| 2318 | else |
| 2319 | { |
| 2320 | bool found; |
| 2321 | BMBuildLovData *lov; |
| 2322 | |
| 2323 | if (state->lovitem_hash) |
| 2324 | { |
| 2325 | BMBuildHashKey toLookup; |
| 2326 | toLookup.attributeValueArr = attdata; |
| 2327 | toLookup.isNullArr = nulls; |
| 2328 | |
| 2329 | /* look up the hash to see if we can find the lov data that way */ |
| 2330 | entry = (BMBuildHashKey *)hash_search(state->lovitem_hash, |
| 2331 | (void*)&toLookup, |
| 2332 | HASH_ENTER, &found); |
| 2333 | if (!found) |
| 2334 | { |
| 2335 | /* Copy the key values in case someone modifies them */ |
no test coverage detected