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

Function hashagg_tapeinfo_init

src/backend/executor/nodeAgg.c:3135–3165  ·  view source on GitHub ↗

* Initialize HashTapeInfo */

Source from the content-addressed store, hash-verified

3133 * Initialize HashTapeInfo
3134 */
3135static void
3136hashagg_tapeinfo_init(AggState *aggstate)
3137{
3138 HashTapeInfo *tapeinfo = palloc(sizeof(HashTapeInfo));
3139 int init_tapes = 16; /* expanded dynamically */
3140
3141 tapeinfo->tapeset = LogicalTapeSetCreate(init_tapes, true, NULL, NULL, -1);
3142 tapeinfo->ntapes = init_tapes;
3143 tapeinfo->nfreetapes = init_tapes;
3144 tapeinfo->freetapes_alloc = init_tapes;
3145 tapeinfo->freetapes = palloc(init_tapes * sizeof(int));
3146 for (int i = 0; i < init_tapes; i++)
3147 tapeinfo->freetapes[i] = i;
3148
3149 aggstate->hash_tapeinfo = tapeinfo;
3150
3151#ifdef FAULT_INJECTOR
3152 if (SIMPLE_FAULT_INJECTOR("hashagg_spill_temp_files") == FaultInjectorTypeSkip) {
3153 const char *filename = LogicalTapeGetBufFilename(tapeinfo->tapeset);
3154 if (!filename)
3155 ereport(NOTICE, (errmsg("hashagg: buffilename is null")));
3156 else if (strstr(filename, "base/" PG_TEMP_FILES_DIR) == filename)
3157 ereport(NOTICE, (errmsg("hashagg: Use default tablespace")));
3158 else if (strstr(filename, "pg_tblspc/") == filename)
3159 ereport(NOTICE, (errmsg("hashagg: Use temp tablespace")));
3160 else
3161 ereport(NOTICE, (errmsg("hashagg: Unexpected prefix of the tablespace path")));
3162
3163 }
3164#endif
3165}
3166
3167/*
3168 * Assign unused tapes to spill partitions, extending the tape set if

Callers 1

Calls 4

LogicalTapeSetCreateFunction · 0.85
pallocFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected