lp_snapshot_holder.hpp file
LpSnapshotHolder — snapshot + codec + compression facade.
Phase 2b of the LinearInterface split.
LpSnapshotHolder owns the 2 fields that previously lived directly on LinearInterface:
m_snapshot_—LowMemorySnapshotcarrying the flat LP (uncompressed or compressed buffer) used by thecompress/snapshotreconstruct path.m_memory_codec_—CompressionCodecselected atset_low_memory()time (defaultzstd).
Plus the two compression helpers that gate purely on the snapshot's own state (without consulting m_low_memory_mode_):
compress_if_uncompressed()— first-time compress + log via a caller-supplied logger.decompress_if_compressed()— re-hydrate the flat LP buffer.
LinearInterface::enable_compression / LinearInterface::disable_compression retain their public surface but become thin facades that gate on m_low_memory_mode_ then call into this holder.
Invariants (asserted in debug, see validate_consistency()):
- S1. Default-constructed
LpSnapshotHolder{}reportshas_data() == false,is_compressed() == false,codec() == CompressionCodec::zstd. - S2.
clear()resets the snapshot to an emptyLowMemorySnapshotand leaves the codec untouched. - S3.
decompress_if_compressed()is idempotent — calling it on a non-compressed snapshot is a no-op. - S4.
compress_if_uncompressed()returnstrueiff this call performed the first compression (i.e. the snapshot transitioned from uncompressed to compressed); subsequent calls returnfalse. - S5.
set_codec(c)only changes the codec used by futurecompress_if_uncompressed()calls. An already- compressed snapshot keeps its original codec.
Namespaces
- namespace gtopt
Classes
- class gtopt::LpSnapshotHolder
- Snapshot + codec holder for
LinearInterfacelow-memory paths.