gtopt/linear_interface_labels_codec.hpp file

Byte-level (de)serializer for LP column / row label metadata.

Internal helpers used by the low-memory snapshot pipeline in gtopt::LinearInterface to compress/decompress the per-cell label metadata (SparseColLabel, SparseRowLabel). Extracted from the anonymous namespace of source/linear_interface.cpp so the codec can be unit-tested in isolation.

Layout, per entry:

u16  class_name_len
N    class_name bytes
u16  second_string_len   (variable_name or constraint_name)
M    second_string bytes
8    variable_uid (memcpy of Uid)
sizeof(LpContext)  context bytes (memcpy of std::variant<...>)

LpContext is a std::variant of tuples of strong-int-typed UIDs — trivially copyable, so a direct memcpy round-trips correctly. The string_view content is copied inline so the compressed form is self-contained (no dangling pointers into the original string storage). Decompression re-materialises each string into a per-LinearInterface string_pool whose stable addresses back the revived string_views; the pool MUST be reserved to at least 2 * num_entries before calling deserialize_labels_meta so push_back never reallocates.

Namespaces

namespace gtopt