<buttonid="sidebar-toggle"class="icon-button"type="button"title="Toggle Table of Contents"aria-label="Toggle Table of Contents"aria-controls="sidebar">
<ahref="../print.html"title="Print this book"aria-label="Print this book">
<iid="print-button"class="fa fa-print"></i>
</a>
</div>
</div>
<divid="search-wrapper"class="hidden">
<formid="searchbar-outer"class="searchbar-outer">
<inputtype="search"id="searchbar"name="searchbar"placeholder="Search this book ..."aria-controls="searchresults-outer"aria-describedby="searchresults-header">
<pre><codeclass="language-rust no_run noplayground"> /// True if the value of `input`, which must be from this query, may have
/// changed after the given revision ended.
///
/// This function should only be invoked with a revision less than the current
/// revision.
fn maybe_changed_after(
&self,
db: &<Q as QueryDb<'_>>::DynDb,
input: DatabaseKeyIndex,
revision: Revision,
) -> bool;
</code></pre>
<p>The <code>maybe_changed_after</code> operation computes whether a query's value <em>may have changed</em><strong>after</strong> the given revision. In other words, <code>Q.maybe_change_since(R)</code> is true if the value of the query <code>Q</code> may have changed in the revisions <code>(R+1)..R_now</code>, where <code>R_now</code> is the current revision. Note that it doesn't make sense to ask <code>maybe_changed_after(R_now)</code>.</p>
<p>Input queries are set explicitly by the user. <code>maybe_changed_after</code> can therefore just check when the value was last set and compare.</p>
<p>The logic for derived queries is more complex. We summarize the high-level ideas here, but you may find the <ahref="./derived_flowchart.html">flowchart</a> useful to dig deeper. The <ahref="./terminology.html">terminology</a> section may also be useful; in some cases, we link to that section on the first usage of a word.</p>
<ul>
<li>If an existing <ahref="./terminology/memo.html">memo</a> is found, then we check if the memo was <ahref="./terminology/verified.html">verified</a> in the current <ahref="./terminology/revision.html">revision</a>. If so, we can compare its <ahref="./terminology/changed_at.html">changed at</a> revision and return true or false appropriately.</li>
<li>Otherwise, we must check whether <ahref="./terminology/dependency.html">dependencies</a> have been modified:
<ul>
<li>Let R be the revision in which the memo was last verified; we wish to know if any of the dependencies have changed since revision R.</li>
<li>First, we check the <ahref="./terminology/durability.html">durability</a>. For each memo, we track the minimum durability of the memo's dependencies. If the memo has durability D, and there have been no changes to an input with durability D since the last time the memo was verified, then we can consider the memo verified without any further work.</li>
<li>If the durability check is not sufficient, then we must check the dependencies individually. For this, we iterate over each dependency D and invoke the <ahref="./maybe_changed_after.html">maybe changed after</a> operation to check whether D has changed since the revision R.</li>
<li>If no dependency was modified:
<ul>
<li>We can mark the memo as verified and use its <ahref="./terminology/changed_at.html">changed at</a> revision to return true or false.</li>
</ul>
</li>
</ul>
</li>
<li>Assuming dependencies have been modified:
<ul>
<li>Then we execute the user's query function (same as in <ahref="./fetch.html">fetch</a>), which potentially <ahref="./terminology/backdate.html">backdates</a> the resulting value.</li>
<li>Compare the <ahref="./terminology/changed_at.html">changed at</a> revision in the resulting memo and return true or false.</li>