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

Function UpdateStatistics

contrib/pax_storage/src/cpp/catalog/pax_aux_table.cc:291–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

289}
290
291void UpdateStatistics(Oid aux_relid, int block_id,
292 pax::stats::MicroPartitionStatisticsInfo *mp_stats) {
293 // NameData pt_visimap_name;
294 Datum values[NATTS_PG_PAX_BLOCK_TABLES];
295 bool nulls[NATTS_PG_PAX_BLOCK_TABLES];
296 bool repls[NATTS_PG_PAX_BLOCK_TABLES];
297 ScanAuxContext context;
298 HeapTuple newtuple;
299 uint32 stats_len;
300 void *stats_out;
301
302 Assert(mp_stats);
303 stats_len = VARHDRSZ + mp_stats->ByteSizeLong();
304 stats_out = palloc(stats_len);
305 SET_VARSIZE(stats_out, stats_len);
306 mp_stats->SerializeToArray(VARDATA(stats_out), stats_len - VARHDRSZ);
307
308 context.BeginSearchMicroPartition(aux_relid, InvalidOid, NULL,
309 RowExclusiveLock, block_id);
310 auto aux_rel = context.GetRelation();
311 auto oldtuple = context.SearchMicroPartitionEntry();
312 if (!HeapTupleIsValid(oldtuple))
313 elog(ERROR,
314 "The micro partition does not exist when we updating statistics.");
315
316 memset(repls, false, sizeof(repls));
317 repls[ANUM_PG_PAX_BLOCK_TABLES_PTSTATISITICS - 1] = true;
318 nulls[ANUM_PG_PAX_BLOCK_TABLES_PTSTATISITICS - 1] = false;
319 values[ANUM_PG_PAX_BLOCK_TABLES_PTSTATISITICS - 1] =
320 PointerGetDatum(stats_out);
321 newtuple = heap_modify_tuple(oldtuple, RelationGetDescr(aux_rel), values,
322 nulls, repls);
323
324 CatalogTupleUpdate(aux_rel, &oldtuple->t_self, newtuple);
325 heap_freetuple(newtuple);
326 context.EndSearchMicroPartition(NoLock);
327
328 pfree(stats_out);
329
330 CommandCounterIncrement();
331}
332
333// We won't update the visimap in here
334// but will update visimap info in the `UpdateVisimap`

Callers 1

UpdateStatisticsMethod · 0.85

Calls 10

heap_modify_tupleFunction · 0.85
CatalogTupleUpdateFunction · 0.85
heap_freetupleFunction · 0.85
CommandCounterIncrementFunction · 0.85
pallocFunction · 0.50
pfreeFunction · 0.50
GetRelationMethod · 0.45

Tested by

no test coverage detected