Class PinSession

Class Documentation

class PinSession

Replays one RootRecord through sequant::optimize_result: hand it to the optimizer via OptimizeOptions::pinned. Every summand looks its record up by key; a miss is remembered (and the summand left unoptimized), and finish reports every miss, unused record and duplicate key at once. take and bind are thread-safe (summands are optimized in parallel).

Public Functions

explicit PinSession(eval::schedule::RootRecord const &root)
PinSession(PinSession const&) = delete
PinSession &operator=(PinSession const&) = delete
eval::schedule::TermRecord const *take(std::string const &key)

thread-safe; returns nullptr on a miss (recorded) and records a duplicate hit (a key taken more than once)

std::optional<std::size_t> document_position(std::string const &key) const

position of key in the document order, for callers assembling their own Sum

void finish() const
Throws:

sequant::Exception – listing “missing: …”, “unused: …”, “duplicate: …” (all keys) if any key was missed, any record was not taken, or any key was taken twice (or occurs twice in the record)

Post:

the session is finished: a session is single-use, and take and bind throw from now on (calling finish again is fine)

void bind(Expr const *optimized, std::string key)

Called by the optimizer: remembers that optimized is the summand it produced for key, so the Sum can be assembled in document order. A repeated address (freed by a per-summand caller and reused) is overwritten: the newest binding wins. Thread-safe.

std::optional<std::string> key_of(Expr const *optimized) const

the key bind associated with optimized, if any. Only meaningful while that result is alive (the optimizer reads it only for the summands of the whole Sum it is assembling); a freed address may since have been reused.