GCC Code Coverage Report


Directory: src/
File: src/standalone/parallel_scan.c
Date: 2026-11-18 16:12:57
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 216 prism_parallel_scan_init(
18 PrismParallelScan *ps,
19 const float *vectors,
20 uint32_t nvecs,
21 Dimension dim)
22 {
23 216 ps->vectors = vectors;
24 216 ps->nvecs = nvecs;
25 216 ps->dim = dim;
26 216 atomic_store(&ps->cursor, 0);
27 216 }
28
29 double
30 400 prism_parallel_scan_run(
31 PrismParallelScan *ps, PrismBuildScanCb cb, void *state)
32 {
33 400 Dimension dim = ps->dim;
34 400 double scanned = 0;
35
36 for (;;)
37 872 {
38 1272 uint32_t start = atomic_fetch_add(&ps->cursor, PRISM_BUILD_SCAN_CHUNK);
39 uint32_t end;
40
41
2/2
✓ Branch 0 taken 400 times.
✓ Branch 1 taken 872 times.
1272 if (start >= ps->nvecs)
42 400 break;
43
44 872 end = start + PRISM_BUILD_SCAN_CHUNK;
45
2/2
✓ Branch 0 taken 216 times.
✓ Branch 1 taken 656 times.
872 if (end > ps->nvecs)
46 216 end = ps->nvecs;
47
48
2/2
✓ Branch 0 taken 400438 times.
✓ Branch 1 taken 872 times.
401310 for (uint32_t i = start; i < end; i++)
49 {
50 ItemPointerData tid;
51
52 /* Reversible: ItemPointerGetBlockNumber(tid) == i. */
53 400438 ItemPointerSet(&tid, i, 1);
54 400438 cb(state, tid, ps->vectors + (size_t)i * dim);
55 }
56 872 scanned += end - start;
57 }
58 400 return scanned;
59 }
60
61 #endif /* VS_STANDALONE */
62