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

Function buf_extend

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

* buf_extend() -- Enlarge the memory allocated to a buffer. * Return how many bytes are added to the buffer. */

Source from the content-addressed store, hash-verified

1978 * Return how many bytes are added to the buffer.
1979 */
1980static uint16
1981buf_extend(BMTIDBuffer *buf)
1982{
1983 uint16 bytes;
1984 uint16 size;
1985
1986 if (buf->num_cwords > 0 && buf->curword < buf->num_cwords - 1)
1987 return 0; /* already large enough */
1988
1989 if(buf->num_cwords == 0)
1990 {
1991 size = BUF_INIT_WORDS;
1992 buf->cwords = (BM_HRL_WORD *)
1993 palloc0(BUF_INIT_WORDS * sizeof(BM_HRL_WORD));
1994 buf->last_tids = (uint64 *)palloc0(BUF_INIT_WORDS * sizeof(uint64));
1995 bytes = BUF_INIT_WORDS * sizeof(BM_HRL_WORD) +
1996 BUF_INIT_WORDS * sizeof(uint64);
1997 }
1998 else
1999 {
2000 size = buf->num_cwords;
2001 buf->cwords = repalloc(buf->cwords, 2 * size * sizeof(BM_HRL_WORD));
2002 MemSet(buf->cwords + size, 0, size * sizeof(BM_HRL_WORD));
2003 buf->last_tids = repalloc(buf->last_tids, 2 * size * sizeof(uint64));
2004 MemSet(buf->last_tids + size, 0, size * sizeof(uint64));
2005 bytes = 2 * size * sizeof(BM_HRL_WORD) +
2006 2 * size * sizeof(uint64);
2007 }
2008 buf->num_cwords += size;
2009 return bytes;
2010}
2011
2012/*
2013 * Spill some HRL compressed tids to disk

Callers 6

updatesetbitFunction · 0.85
updatesetbit_inwordFunction · 0.85
updatesetbit_inpageFunction · 0.85
mergewordsFunction · 0.85
buf_add_tidFunction · 0.85
buf_ensure_head_spaceFunction · 0.85

Calls 2

palloc0Function · 0.50
repallocFunction · 0.50

Tested by

no test coverage detected