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

Function GetAccessStrategy

src/backend/storage/buffer/freelist.c:547–594  ·  view source on GitHub ↗

* GetAccessStrategy -- create a BufferAccessStrategy object * * The object is allocated in the current memory context. */

Source from the content-addressed store, hash-verified

545 * The object is allocated in the current memory context.
546 */
547BufferAccessStrategy
548GetAccessStrategy(BufferAccessStrategyType btype)
549{
550 BufferAccessStrategy strategy;
551 int ring_size;
552
553 /*
554 * Select ring size to use. See buffer/README for rationales.
555 *
556 * Note: if you change the ring size for BAS_BULKREAD, see also
557 * SYNC_SCAN_REPORT_INTERVAL in access/heap/syncscan.c.
558 */
559 switch (btype)
560 {
561 case BAS_NORMAL:
562 /* if someone asks for NORMAL, just give 'em a "default" object */
563 return NULL;
564
565 case BAS_BULKREAD:
566 ring_size = 256 * 1024 / BLCKSZ;
567 break;
568 case BAS_BULKWRITE:
569 ring_size = 16 * 1024 * 1024 / BLCKSZ;
570 break;
571 case BAS_VACUUM:
572 ring_size = 256 * 1024 / BLCKSZ;
573 break;
574
575 default:
576 elog(ERROR, "unrecognized buffer access strategy: %d",
577 (int) btype);
578 return NULL; /* keep compiler quiet */
579 }
580
581 /* Make sure ring isn't an undue fraction of shared buffers */
582 ring_size = Min(NBuffers / 8, ring_size);
583
584 /* Allocate the object and initialize all elements to zeroes */
585 strategy = (BufferAccessStrategy)
586 palloc0(offsetof(BufferAccessStrategyData, buffers) +
587 ring_size * sizeof(Buffer));
588
589 /* Set fields that don't start out zero */
590 strategy->btype = btype;
591 strategy->ring_size = ring_size;
592
593 return strategy;
594}
595
596/*
597 * FreeAccessStrategy -- release a BufferAccessStrategy object

Callers 15

collect_visibility_dataFunction · 0.85
collect_corrupt_itemsFunction · 0.85
verify_heapamFunction · 0.85
bt_check_every_levelFunction · 0.85
pgstat_indexFunction · 0.85
pgstatindex_implFunction · 0.85
pgstathashindexFunction · 0.85
statapprox_heapFunction · 0.85
blgetbitmapFunction · 0.85
vacuumFunction · 0.85
gp_acquire_sample_rowsFunction · 0.85
do_autovacuumFunction · 0.85

Calls 1

palloc0Function · 0.50

Tested by

no test coverage detected