Skip to content

Commit c3adb9d

Browse files
committed
Deploying to gh-pages from @ 93e422e 🚀
1 parent 052ad24 commit c3adb9d

8 files changed

Lines changed: 42 additions & 42 deletions

File tree

docs/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ <h1><a class="anchor" id="autotoc_md3"></a>
169169
Saving and reloading indices</h1>
170170
<p>To save and reload Annoy indices from disk, we need to register a loading function into <b>knncolle</b>'s <code>load_prebuilt_registry()</code>. This is a little complicated as we must decide on which combinations of types and distances we want to deal with. In the example below, we only consider the obvious distance metrics and the defaults for the internal Annoy types, though more combinations could also be supported at the cost of larger binaries and longer compile times.</p>
171171
<div class="fragment"><div class="line"><span class="keyword">auto</span>&amp; reg = <a class="code hl_functionRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#aa08de1eb1a23d5e13dc11e23ad7967ea">knncolle::load_prebuilt_registry&lt;int, double, double&gt;</a>();</div>
172-
<div class="line">reg[knncolle_annoy::save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; Prebuilt&lt;int, double, double&gt;* {</div>
172+
<div class="line">reg[knncolle_annoy::annoy_prebuilt_save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; Prebuilt&lt;int, double, double&gt;* {</div>
173173
<div class="line"> <span class="keyword">auto</span> config = <a class="code hl_function" href="namespaceknncolle__annoy.html#a9eff16d6db0a482607ada4d00b00c3d1">knncolle_annoy::load_annoy_prebuilt_types</a>(dir);</div>
174174
<div class="line"> </div>
175175
<div class="line"> <span class="comment">// Checks that the AnnoyIndex_ and AnnoyData_ types are the same as the defaults.</span></div>
@@ -209,7 +209,7 @@ <h1><a class="anchor" id="autotoc_md3"></a>
209209
<div class="line">};</div>
210210
<div class="line"> </div>
211211
<div class="line"><span class="comment">// Make a new loading function that uses the saved custom information. </span></div>
212-
<div class="line">reg[knncolle_annoy::save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; Prebuilt&lt;int, double, double&gt;* {</div>
212+
<div class="line">reg[knncolle_annoy::annoy_prebuilt_save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; Prebuilt&lt;int, double, double&gt;* {</div>
213213
<div class="line"> <span class="keyword">auto</span> config = <a class="code hl_function" href="namespaceknncolle__annoy.html#a9eff16d6db0a482607ada4d00b00c3d1">knncolle_annoy::load_annoy_prebuilt_types</a>(dir);</div>
214214
<div class="line"> <span class="keywordflow">if</span> (config.index != <a class="code hl_functionRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a84e640363d9246c58008c93166021f26">knncolle::get_numeric_type&lt;int&gt;</a>()) {</div>
215215
<div class="line"> <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">&quot;unexpected type for the Annoy index&quot;</span>);</div>

docs/namespaceknncolle__annoy.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ <h2 class="memtitle"><span class="permalink"><a href="#a7869865e7f1417bd6fdcad52
259259
</table>
260260
</div><div class="memdoc">
261261
<p>Helper function to define a <code><a class="elRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a0574e57c9150cb0bfe1da0e7eff6aa01">knncolle::LoadPrebuiltFunction</a></code> for Annoy in <code><a class="elRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a2157dec9e895be903278fc6903c793e0">knncolle::load_prebuilt_raw()</a></code>.</p>
262-
<p>To load an Annoy index from disk, users are expected to define and register an Annoy-specific <code><a class="elRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a0574e57c9150cb0bfe1da0e7eff6aa01">knncolle::LoadPrebuiltFunction</a></code>. In this function, users should call <code><a class="el" href="#a9eff16d6db0a482607ada4d00b00c3d1">load_annoy_prebuilt_types()</a></code> to figure out the saved index's <code>AnnoyDistance_</code>, <code>AnnoyIndex</code> and <code>AnnoyData_</code>. Then, they should call <code><a class="el" href="#a7869865e7f1417bd6fdcad52a7a66303">load_annoy_prebuilt()</a></code> with the appropriate types to return a pointer to a <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt</a></code> object. This user-defined function should be registered in <code>load_prebuilt_registry()</code> with the key in <code>knncolle_annoy::save_name</code>.</p>
262+
<p>To load an Annoy index from disk, users are expected to define and register an Annoy-specific <code><a class="elRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a0574e57c9150cb0bfe1da0e7eff6aa01">knncolle::LoadPrebuiltFunction</a></code>. In this function, users should call <code><a class="el" href="#a9eff16d6db0a482607ada4d00b00c3d1">load_annoy_prebuilt_types()</a></code> to figure out the saved index's <code>AnnoyDistance_</code>, <code>AnnoyIndex</code> and <code>AnnoyData_</code>. Then, they should call <code><a class="el" href="#a7869865e7f1417bd6fdcad52a7a66303">load_annoy_prebuilt()</a></code> with the appropriate types to return a pointer to a <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt</a></code> object. This user-defined function should be registered in <code>load_prebuilt_registry()</code> with the key in <code>knncolle_annoy::annoy_prebuilt_save_name</code>.</p>
263263
<p>We do not define a default function for loading Annoy indices as there are too many possible combinations of types. Instead, the user is responsible for deciding which combinations of types should be handled. This avoids binary bloat from repeated instantiations of the Annoy template classes, if the user's application only deals with a certain subset of combinations.</p>
264264
<p>For unknown types or distances, users can set <code><a class="el" href="#a8525f55e793e3e117e404d324b519799">custom_save_for_annoy_index()</a></code>, <code><a class="el" href="#a8c1f7d1200d1be4a1a3403bd9a0f91e1">custom_save_for_annoy_data()</a></code> and/or <code><a class="el" href="#afbfa92fc904c2ed19bb8f51b50403881">custom_save_for_annoy_distance()</a></code>. Each custom function saves additional information about its type to disk during a <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html#add21dc74e08a6ad495c6e241fa3d5968">knncolle::Prebuilt::save()</a></code> call. That information can then be parsed in the user-defined <code><a class="elRef" href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a0574e57c9150cb0bfe1da0e7eff6aa01">knncolle::LoadPrebuiltFunction</a></code> to recover an Annoy index with the appropriate template types.</p>
265265
<dl class="tparams"><dt>Template Parameters</dt><dd>

docs/search/all_9.js

Lines changed: 15 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/search/all_b.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/search/all_f.js

Lines changed: 7 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)