CNDB-18842: Fix: FusedPQ compaction should write codebook-only PQ file; add regression test #2563
All Vouch review confidence checks passed
Residual risk 0.14 = Change Risk (0.36) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.36 · 196 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.316
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #2563"
general
weight: 0.35
MarkWolters
…
What is the issue
...
When FusedPQ is enabled (version FA always; version FB with -Dcassandra.sai.vector.enable_fused=true), the compaction path writes the full PQVectors — codebook + all N×m per-vector codes — to the PQ component file unconditionally. The same per-vector codes are already embedded in TERMS_DATA by the graph writer. This duplicates N×m bytes on disk for every compacted SSTable, where N is the number of vectors and m is the compressed vector size.
The flush path (CassandraOnHeapGraph) was implemented correctly from the start: with FusedPQ it writes only the codebook to the PQ file.
###Impact
For a segment with N vectors and m bytes per PQ code, the wasted disk space per compacted SSTable is exactly N×m bytes — the same order of magnitude as the in-memory savings FusedPQ was designed to deliver. At 500M vectors with D=256 (m=100), this is ~47 GiB of duplicate data per compacted SSTable.
There is no correctness or memory impact at runtime: CassandraDiskAnn reads only the codebook from the PQ file when FUSED_PQ is present in the graph's feature set, so the duplicated codes are written but never read.
###Root cause
CompactionGraph.flush() calls compressedVectors.write(pqOutput, ...) unconditionally, writing full PQVectors regardless of whether FusedPQ is active. The equivalent branch in CassandraOnHeapGraph.writePQ() correctly switches to compressor.write() (codebook only) when writeFusedPQ=true.
What does this PR fix and why was it fixed
...
Apply the same writeFusedPQ branch in CompactionGraph.flush().