Skip to content

Commit 825f391

Browse files
committed
Deploying to gh-pages from @ a80fc93 🚀
1 parent c3adb9d commit 825f391

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

docs/index.html

Lines changed: 4 additions & 3 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::annoy_prebuilt_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; <a class="code hl_classRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt&lt;int, double, double&gt;</a>* {</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>
@@ -187,11 +187,12 @@ <h1><a class="anchor" id="autotoc_md3"></a>
187187
<div class="line"> }</div>
188188
<div class="line"> <span class="keywordflow">return</span> <a class="code hl_function" href="namespaceknncolle__annoy.html#a7869865e7f1417bd6fdcad52a7a66303">knncolle_annoy::load_annoy_prebuilt&lt;int, double, double, Annoy::Manhattan&gt;</a>(dir);</div>
189189
<div class="line">};</div>
190+
<div class="ttc" id="aclassknncolle_1_1Prebuilt_html"><div class="ttname"><a href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt</a></div></div>
190191
<div class="ttc" id="anamespaceknncolle__annoy_html_a7869865e7f1417bd6fdcad52a7a66303"><div class="ttname"><a href="namespaceknncolle__annoy.html#a7869865e7f1417bd6fdcad52a7a66303">knncolle_annoy::load_annoy_prebuilt</a></div><div class="ttdeci">auto load_annoy_prebuilt(const std::filesystem::path &amp;dir)</div><div class="ttdef"><b>Definition</b> load_annoy_prebuilt.hpp:107</div></div>
191192
<div class="ttc" id="anamespaceknncolle__annoy_html_a9eff16d6db0a482607ada4d00b00c3d1"><div class="ttname"><a href="namespaceknncolle__annoy.html#a9eff16d6db0a482607ada4d00b00c3d1">knncolle_annoy::load_annoy_prebuilt_types</a></div><div class="ttdeci">AnnoyPrebuiltTypes load_annoy_prebuilt_types(const std::filesystem::path &amp;dir)</div><div class="ttdef"><b>Definition</b> load_annoy_prebuilt.hpp:50</div></div>
192193
<div class="ttc" id="anamespaceknncolle_html_a84e640363d9246c58008c93166021f26"><div class="ttname"><a href="https://knncolle.github.io/knncolle/namespaceknncolle.html#a84e640363d9246c58008c93166021f26">knncolle::get_numeric_type</a></div><div class="ttdeci">NumericType get_numeric_type()</div></div>
193194
<div class="ttc" id="anamespaceknncolle_html_aa08de1eb1a23d5e13dc11e23ad7967ea"><div class="ttname"><a href="https://knncolle.github.io/knncolle/namespaceknncolle.html#aa08de1eb1a23d5e13dc11e23ad7967ea">knncolle::load_prebuilt_registry</a></div><div class="ttdeci">std::unordered_map&lt; std::string, LoadPrebuiltFunction&lt; Index_, Data_, Distance_ &gt; &gt; &amp; load_prebuilt_registry()</div></div>
194-
</div><!-- fragment --><p>Then we can save and reload the <code>Prebuilt</code> Annoy indices. Note the caveats on <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html#add21dc74e08a6ad495c6e241fa3d5968">knncolle::Prebuilt::save()</a></code> - specifically, the files are not guaranteed to be portable between machines or even different versions of <b><a class="el" href="namespaceknncolle__annoy.html" title="Approximate nearest neighbor search with Annoy.">knncolle_annoy</a></b>.</p>
195+
</div><!-- fragment --><p>Then we can save and reload the <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt</a></code> Annoy indices. Note the caveats on <code><a class="elRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html#add21dc74e08a6ad495c6e241fa3d5968">knncolle::Prebuilt::save()</a></code> - specifically, the files are not guaranteed to be portable between machines or even different versions of <b><a class="el" href="namespaceknncolle__annoy.html" title="Approximate nearest neighbor search with Annoy.">knncolle_annoy</a></b>.</p>
195196
<div class="fragment"><div class="line">std::filesystem::path save_loc = <span class="stringliteral">&quot;annoy/location/here&quot;</span>;</div>
196197
<div class="line">std::filesystem::create_directory(save_loc);</div>
197198
<div class="line">an_index.save(save_loc);</div>
@@ -209,7 +210,7 @@ <h1><a class="anchor" id="autotoc_md3"></a>
209210
<div class="line">};</div>
210211
<div class="line"> </div>
211212
<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::annoy_prebuilt_save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; Prebuilt&lt;int, double, double&gt;* {</div>
213+
<div class="line">reg[knncolle_annoy::annoy_prebuilt_save_name] = [](<span class="keyword">const</span> std::filesystem::path&amp; dir) -&gt; <a class="code hl_classRef" href="https://knncolle.github.io/knncolle/classknncolle_1_1Prebuilt.html">knncolle::Prebuilt&lt;int, double, double&gt;</a>* {</div>
213214
<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>
214215
<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>
215216
<div class="line"> <span class="keywordflow">throw</span> std::runtime_error(<span class="stringliteral">&quot;unexpected type for the Annoy index&quot;</span>);</div>

0 commit comments

Comments
 (0)