MCPcopy Create free account
hub / github.com/apache/cloudberry / _bitmap_doinsert

Function _bitmap_doinsert

src/backend/access/bitmap/bitmapinsert.c:2544–2609  ·  view source on GitHub ↗

* _bitmap_doinsert() -- insert an index tuple for a given tuple. */

Source from the content-addressed store, hash-verified

2542 * _bitmap_doinsert() -- insert an index tuple for a given tuple.
2543 */
2544void
2545_bitmap_doinsert(Relation rel, ItemPointerData ht_ctid, Datum *attdata,
2546 bool *nulls)
2547{
2548 uint64 tidOffset;
2549 TupleDesc tupDesc;
2550 Buffer metabuf;
2551 BMMetaPage metapage;
2552 Relation lovHeap, lovIndex;
2553 ScanKey scanKeys;
2554 IndexScanDesc scanDesc;
2555 int attno;
2556
2557 tupDesc = RelationGetDescr(rel);
2558 if (tupDesc->natts <= 0)
2559 return ;
2560
2561 tidOffset = BM_IPTR_TO_INT(&ht_ctid);
2562
2563 /* insert a new bit into the corresponding bitmap using the HRL scheme */
2564 metabuf = _bitmap_getbuf(rel, BM_METAPAGE, BM_READ);
2565 metapage = _bitmap_get_metapage_data(rel, metabuf);
2566 _bitmap_open_lov_heapandindex(rel, metapage, &lovHeap, &lovIndex,
2567 RowExclusiveLock);
2568
2569 LockBuffer(metabuf, BUFFER_LOCK_UNLOCK);
2570
2571 scanKeys = (ScanKey) palloc0(tupDesc->natts * sizeof(ScanKeyData));
2572
2573 for (attno = 0; attno < tupDesc->natts; attno++)
2574 {
2575 Oid eq_opr;
2576 RegProcedure opfuncid;
2577 ScanKey scanKey;
2578
2579 get_sort_group_operators(TupleDescAttr(tupDesc, attno)->atttypid,
2580 false, true, false,
2581 NULL, &eq_opr, NULL, NULL);
2582 opfuncid = get_opcode(eq_opr);
2583
2584 scanKey = (ScanKey) (((char *)scanKeys) + attno * sizeof(ScanKeyData));
2585
2586 ScanKeyEntryInitialize(scanKey,
2587 nulls[attno] ? SK_ISNULL : 0,
2588 attno + 1,
2589 BTEqualStrategyNumber,
2590 InvalidOid,
2591 lovIndex->rd_indcollation[attno],
2592 opfuncid,
2593 attdata[attno]);
2594 }
2595
2596 scanDesc = index_beginscan(lovHeap, lovIndex, GetActiveSnapshot(),
2597 tupDesc->natts, 0);
2598 index_rescan(scanDesc, scanKeys, tupDesc->natts, NULL, 0);
2599
2600 /* insert this new tuple into the bitmap index. */
2601 inserttuple(rel, metabuf, tidOffset, ht_ctid, tupDesc, attdata, nulls,

Callers 1

bminsertFunction · 0.85

Calls 15

_bitmap_getbufFunction · 0.85
LockBufferFunction · 0.85
get_sort_group_operatorsFunction · 0.85
get_opcodeFunction · 0.85
ScanKeyEntryInitializeFunction · 0.85
index_beginscanFunction · 0.85
GetActiveSnapshotFunction · 0.85
index_rescanFunction · 0.85
inserttupleFunction · 0.85
index_endscanFunction · 0.85

Tested by

no test coverage detected