gtopt::FlatLpDedupRegistry class

Cross-cell base registry for flat-LP snapshot dedup.

The (scene, phase) cells of one phase share the constraint matrix, costs and scales bit for bit and differ only in a few percent of the bounds (inflows, initial volumes). Measured on the CEN 2-year case: matbeg/matind/matval/objval/scales identical across scenes, ~2.5% of column and row bounds different; the compressed XOR against a sibling is 1-8 KB vs ~200-300 KB for the full buffer.

compress(key, raw, codec): the first caller per key publishes its plain compressed buffer as the base; every caller (including the first) gets back a buffer holding only the compressed XOR against the base (empty when identical). A size mismatch falls back to a plain buffer. Every buffer carries its own codec tag, so a delta and its base may use different codecs and still restore. The registry holds bases weakly, so a base is freed once the last cell referencing it drops its snapshot. Thread-safe.

Public functions

auto compress(const std::string& key, std::span<const char> raw, CompressionCodec codec) -> CompressedBuffer
auto live_bases() const -> std::size_t
Number of keys currently holding a live base.