GCC Code Coverage Report


Directory: src/
File: src/standalone/parallel_scan.c
Date: 2026-10-23 09:17:32
Exec Total Coverage
Lines: 21 21 100.0%
Functions: 2 2 100.0%
Branches: 6 6 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 * parallel_scan_standalone.c - Work-stealing vector scan over an array
6 *
7 * Standalone implementation of the parallel build scan (see
8 * prism_build_scan.h). PG builds scan the heap via table_index_build_scan
9 * instead, so this file is compiled only for standalone.
10 */
11
12 #ifdef VS_STANDALONE
13
14 #include "standalone/parallel_scan.h"
15
16 void
17 176 prism_parallel_scan_init(
18 PrismParallelScan *ps,
19 const float *vectors,
20 uint32_t nvecs,
21 Dimension dim)
22 {
23 176 ps->vectors = vectors;
24 176 ps->nvecs = nvecs;
25 176 ps->dim = dim;
26 176 atomic_store(&ps->cursor, 0);
27 176 }
28
29 double
30 316 prism_parallel_scan_run(
31 PrismParallelScan *ps, PrismBuildScanCb cb, void *state)
32 {
33 316 Dimension dim = ps->dim;
34 316 double scanned = 0;
35
36 for (;;)
37 804 {
38 1120 uint32_t start = atomic_fetch_add(&ps->cursor, PRISM_BUILD_SCAN_CHUNK);
39 uint32_t end;
40
41
2/2
✓ Branch 0 taken 316 times.
✓ Branch 1 taken 804 times.
1120 if (start >= ps->nvecs)
42 316 break;
43
44 804 end = start + PRISM_BUILD_SCAN_CHUNK;
45
2/2
✓ Branch 0 taken 176 times.
✓ Branch 1 taken 628 times.
804 if (end > ps->nvecs)
46 176 end = ps->nvecs;
47
48
2/2
✓ Branch 0 taken 375078 times.
✓ Branch 1 taken 804 times.
375882 for (uint32_t i = start; i < end; i++)
49 {
50 ItemPointerData tid;
51
52 /* Reversible: ItemPointerGetBlockNumber(tid) == i. */
53 375078 ItemPointerSet(&tid, i, 1);
54 375078 cb(state, tid, ps->vectors + (size_t)i * dim);
55 }
56 804 scanned += end - start;
57 }
58 316 return scanned;
59 }
60
61 #endif /* VS_STANDALONE */
62