GCC Code Coverage Report


Directory: src/
File: src/index/build_progress.c
Date: 2026-09-30 11:11:31
Exec Total Coverage
Lines: 15 19 78.9%
Functions: 6 8 75.0%
Branches: 4 4 100.0%

Line Branch Exec Source
1 /*
2 * Copyright (c) 2026 Tiger Data, Inc.
3 * Licensed under the PostgreSQL License. See LICENSE for details.
4 *
5 * build_progress.c - Canonical index-build phase names (see header)
6 */
7
8 #include <stddef.h>
9
10 #include "index/build_progress.h"
11
12 /*
13 * Phase name table, indexed by phase value. Index 0 is unused (phases start at
14 * 1) and any gap stays NULL. These strings are what
15 * pg_stat_progress_create_index reports (via prism_buildphasename) and what
16 * the build logs print, so the two back-ends can never drift.
17 */
18 static const char *const phase_names[] = {
19 [PRISM_BUILD_PHASE_INITIALIZE] = "initializing",
20 [PRISM_BUILD_PHASE_SAMPLE] = "sampling vectors",
21 [PRISM_BUILD_PHASE_KMEANS] = "clustering (k-means)",
22 [PRISM_BUILD_PHASE_SETUP] = "preparing RaBitQ encoding",
23 [PRISM_BUILD_PHASE_SCAN] = "scanning table",
24 [PRISM_BUILD_PHASE_POSTING] = "finalizing posting lists",
25 [PRISM_BUILD_PHASE_CENTROID] = "writing centroid pages",
26 [PRISM_BUILD_PHASE_WAL] = "WAL logging",
27 [PRISM_BUILD_PHASE_SCAN_PARALLEL] = "scanning table (parallel)",
28 [PRISM_BUILD_PHASE_SUBTREES] = "clustering (subtrees)",
29 [PRISM_BUILD_PHASE_REFINE] = "refining centroids",
30 };
31
32 const char *
33 47 prism_build_phase_name(int phase)
34 {
35
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 2 times.
47 if (phase < 0 ||
36
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 28 times.
30 (size_t)phase >= sizeof(phase_names) / sizeof(phase_names[0]))
37 4 return NULL;
38 43 return phase_names[phase];
39 }
40
41 #ifdef VS_STANDALONE
42
43 /*
44 * Standalone build-progress seam: no-op stubs. Standalone introspection is
45 * deferred; these exist so the shared build driver links. The PostgreSQL build
46 * gets the real bodies from src/pg/build_progress.c instead.
47 */
48 void
49 ✗ prism_build_progress_begin(
50 PrismBuildProgress *p,
51 bool is_parallel,
52 bool log_stats,
53 void *heap_ctx,
54 struct PrismBuildStats *stats,
55 double tuples_total)
56 {
57 (void)p;
58 (void)is_parallel;
59 (void)log_stats;
60 (void)heap_ctx;
61 (void)stats;
62 (void)tuples_total;
63 ✗ }
64
65 void
66 522 prism_build_report_phase(PrismBuildProgress *p, int phase)
67 {
68 (void)p;
69 (void)phase;
70 522 }
71
72 void
73 545 prism_build_progress_incr_tuples(int64_t n)
74 {
75 (void)n;
76 545 }
77
78 void
79 82 prism_build_report_progress(PrismBuildProgress *p, double done)
80 {
81 (void)p;
82 (void)done;
83 82 }
84
85 void
86 82 prism_build_report_dsm_bytes(PrismBuildProgress *p, uint64_t dsm_bytes)
87 {
88 (void)p;
89 (void)dsm_bytes;
90 82 }
91
92 void
93 82 prism_build_report_planned_alloc(
94 PrismBuildProgress *p,
95 uint64_t sample_bytes,
96 uint64_t centroid_tree_bytes,
97 uint64_t dsm_total_bytes)
98 {
99 (void)p;
100 (void)sample_bytes;
101 (void)centroid_tree_bytes;
102 (void)dsm_total_bytes;
103 82 }
104
105 void
106 ✗ prism_build_progress_end(PrismBuildProgress *p)
107 {
108 (void)p;
109 ✗ }
110
111 #endif /* VS_STANDALONE */
112