Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
reintern.hpp File Reference

Re-intern deserialized node DAGs into the live hash-consing tables (ADR-0042). More...

#include <map>
#include <memory>
#include "bertini2/function_tree/node.hpp"
Include dependency graph for reintern.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  bertini
namespace  bertini::node

Typedefs

using bertini::node::ReinternMemo = std::map<Node const*, std::shared_ptr<Node>>
 Memo for one re-interning pass: loaded node -> its interned replacement.

Functions

std::shared_ptr< Node > bertini::node::Reintern (std::shared_ptr< Node > const &root, ReinternMemo &memo)
 Rebuild the DAG rooted at root through the interning factories (memoized, post-order), returning the canonical interned equivalent.
std::shared_ptr< Node > bertini::node::Reintern (std::shared_ptr< Node > const &root)
 Convenience overload with a private memo (single-root use).

Detailed Description

Re-intern deserialized node DAGs into the live hash-consing tables (ADR-0042).

Deserialization deliberately constructs nodes WITHOUT going through Make/Intern (node.hpp), so a freshly loaded tree does not share with structurally equal live nodes – and on a System-intern miss the loaded nodes would fork the intern universe: nothing built afterward, and nothing loaded from a second archive, would unify with them. Reintern() repairs that: a memoized post-order rebuild of the loaded DAG through the ordinary interning factories, so every subtree collapses onto its live canonical representative (or becomes it).

Runs ONLY at deserialization time. The pointer-keyed memo preserves the archive's internal sharing (each loaded object rebuilt once; the pass is linear). Rebuilding re-runs construction-time canonicalization, so it assumes the session canonicalization settings match those the tree was authored under – which the System digest header records (ADR-0042). Rebuilt nodes acquire fresh memoized state (structural hash, compiled-evaluator cache). Content is never changed: reinterning a tree leaves its canonical encoding, and hence any digest over it, bit-identical.