This is an automated email from the ASF dual-hosted git repository.
github-bot pushed a commit to branch asf-site
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/asf-site by this push:
new e2878c85ec deploy: 0ded0ce1be928ac8a74ce8e791febda95e01c05e
e2878c85ec is described below
commit e2878c85ecd73b8e382c4af4e11e1881c11ab192
Author: alamb <[email protected]>
AuthorDate: Tue Aug 8 20:38:56 2023 +0000
deploy: 0ded0ce1be928ac8a74ce8e791febda95e01c05e
---
arrow_row/interner/index.html | 2 +-
arrow_row/interner/struct.Bucket.html | 8 +-
search-index.js | 2 +-
src/arrow_row/interner.rs.html | 186 ++++++++++++++++++++++++++++++++++
4 files changed, 193 insertions(+), 5 deletions(-)
diff --git a/arrow_row/interner/index.html b/arrow_row/interner/index.html
index 79f713cd25..80f79717ff 100644
--- a/arrow_row/interner/index.html
+++ b/arrow_row/interner/index.html
@@ -1,2 +1,2 @@
-<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta
name="viewport" content="width=device-width, initial-scale=1.0"><meta
name="generator" content="rustdoc"><meta name="description" content="API
documentation for the Rust `interner` mod in crate
`arrow_row`."><title>arrow_row::interner - Rust</title><link rel="preload"
as="font" type="font/woff2" crossorigin
href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link
rel="preload" as="font" type="font/wof [...]
+<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta
name="viewport" content="width=device-width, initial-scale=1.0"><meta
name="generator" content="rustdoc"><meta name="description" content="API
documentation for the Rust `interner` mod in crate
`arrow_row`."><title>arrow_row::interner - Rust</title><link rel="preload"
as="font" type="font/woff2" crossorigin
href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link
rel="preload" as="font" type="font/wof [...]
to the interned values, e.g. <code>inter(a) < intern(b) => a <
b</code></div></li><li><div class="item-name"><a class="struct"
href="struct.Slot.html" title="struct arrow_row::interner::Slot">Slot</a><span
title="Restricted Visibility"> 🔒</span> </div><div class="desc
docblock-short">A slot corresponds to a single byte-value in the generated
normalized key</div></li></ul></section></div></main></body></html>
\ No newline at end of file
diff --git a/arrow_row/interner/struct.Bucket.html
b/arrow_row/interner/struct.Bucket.html
index 71f3681ad1..6729bcdb90 100644
--- a/arrow_row/interner/struct.Bucket.html
+++ b/arrow_row/interner/struct.Bucket.html
@@ -1,4 +1,4 @@
-<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta
name="viewport" content="width=device-width, initial-scale=1.0"><meta
name="generator" content="rustdoc"><meta name="description" content="Bucket is
the root of the data-structure used to allocate normalized keys"><title>Bucket
in arrow_row::interner - Rust</title><link rel="preload" as="font"
type="font/woff2" crossorigin
href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link
rel="preload" as="font [...]
+<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta
name="viewport" content="width=device-width, initial-scale=1.0"><meta
name="generator" content="rustdoc"><meta name="description" content="Bucket is
the root of the data-structure used to allocate normalized keys"><title>Bucket
in arrow_row::interner - Rust</title><link rel="preload" as="font"
type="font/woff2" crossorigin
href="../../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link
rel="preload" as="font [...]
slots: <a class="struct"
href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html"
title="struct alloc::vec::Vec">Vec</a><<a class="struct"
href="struct.Slot.html" title="struct arrow_row::interner::Slot">Slot</a>>,
next: <a class="enum"
href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html"
title="enum core::option::Option">Option</a><<a class="struct"
href="https://doc.rust-lang.org/nightly/alloc/boxed/struct.Box.html"
title="struct alloc::boxed::Box">Box</a><<a class="struct"
href="struct.Bucket.html" title="struct
arrow_row::interner::Bucket">Bucket</a>>>,
}</code></pre><details class="toggle top-doc" open><summary
class="hideme"><span>Expand description</span></summary><div
class="docblock"><p>Bucket is the root of the data-structure used to allocate
normalized keys</p>
@@ -30,7 +30,7 @@ with the final value incremented by 2, followed by a null
terminator.</p>
<span class="number">7</span>: <span class="kw-2">&</span>[<span
class="number">1</span>, <span class="number">3</span>, <span
class="number">0</span>]</code></pre></div>
<p>Note: this allocation strategy is optimised for interning values in sorted
order</p>
</div></details><h2 id="fields" class="fields small-section-header">Fields<a
href="#fields" class="anchor">§</a></h2><span id="structfield.slots"
class="structfield small-section-header"><a href="#structfield.slots"
class="anchor field">§</a><code>slots: <a class="struct"
href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html"
title="struct alloc::vec::Vec">Vec</a><<a class="struct"
href="struct.Slot.html" title="struct
arrow_row::interner::Slot">Slot</a>></code></span>< [...]
-</div><h2 id="implementations" class="small-section-header">Implementations<a
href="#implementations" class="anchor">§</a></h2><div
id="implementations-list"><details class="toggle implementors-toggle"
open><summary><section id="impl-Bucket" class="impl"><a class="src rightside"
href="../../src/arrow_row/interner.rs.html#293-348">source</a><a
href="#impl-Bucket" class="anchor">§</a><h3 class="code-header">impl <a
class="struct" href="struct.Bucket.html" title="struct arrow_row::interner:
[...]
+</div><h2 id="implementations" class="small-section-header">Implementations<a
href="#implementations" class="anchor">§</a></h2><div
id="implementations-list"><details class="toggle implementors-toggle"
open><summary><section id="impl-Bucket" class="impl"><a class="src rightside"
href="../../src/arrow_row/interner.rs.html#293-359">source</a><a
href="#impl-Bucket" class="anchor">§</a><h3 class="code-header">impl <a
class="struct" href="struct.Bucket.html" title="struct arrow_row::interner:
[...]
&mut self,
values_buf: &mut <a class="struct" href="struct.InternBuffer.html"
title="struct arrow_row::interner::InternBuffer">InternBuffer</a>,
data: &[<a class="primitive"
href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>],
@@ -39,7 +39,9 @@ with the final value incremented by 2, followed by a null
terminator.</p>
normalized key to <code>out</code> as it is constructed</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>Panics if the value already exists</p>
-</div></details><details class="toggle method-toggle" open><summary><section
id="method.size" class="method"><a class="src rightside"
href="../../src/arrow_row/interner.rs.html#343-347">source</a><h4
class="code-header">fn <a href="#method.size" class="fn">size</a>(&self)
-> <a class="primitive"
href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><div
class="docblock"><p>Returns the size of this instance in bytes</p>
+</div></details><details class="toggle method-toggle" open><summary><section
id="method.size" class="method"><a class="src rightside"
href="../../src/arrow_row/interner.rs.html#343-349">source</a><h4
class="code-header">fn <a href="#method.size" class="fn">size</a>(&self)
-> <a class="primitive"
href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><div
class="docblock"><p>Returns the size of this instance in bytes</p>
+</div></details><details class="toggle method-toggle" open><summary><section
id="method.slot_child_bucket_size" class="method"><a class="src rightside"
href="../../src/arrow_row/interner.rs.html#353-358">source</a><h4
class="code-header">fn <a href="#method.slot_child_bucket_size"
class="fn">slot_child_bucket_size</a>(&self) -> <a class="primitive"
href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a></h4></section></summary><div
class="docblock"><p>returns t [...]
+in self.slots. This does not include the size of the child Slot itself</p>
</div></details></div></details></div><h2 id="trait-implementations"
class="small-section-header">Trait Implementations<a
href="#trait-implementations" class="anchor">§</a></h2><div
id="trait-implementations-list"><details class="toggle implementors-toggle"
open><summary><section id="impl-Clone-for-Bucket" class="impl"><a class="src
rightside" href="../../src/arrow_row/interner.rs.html#277">source</a><a
href="#impl-Clone-for-Bucket" class="anchor">§</a><h3 class="code-header">impl
<a cla [...]
T: 'static + ?<a class="trait"
href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html"
title="trait
core::marker::Sized">Sized</a>,</span></h3></section></summary><div
class="impl-items"><details class="toggle method-toggle" open><summary><section
id="method.type_id" class="method trait-impl"><a class="src rightside"
href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#202">source</a><a
href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a hre
[...]
T: ?<a class="trait"
href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html"
title="trait
core::marker::Sized">Sized</a>,</span></h3></section></summary><div
class="impl-items"><details class="toggle method-toggle" open><summary><section
id="method.borrow" class="method trait-impl"><a class="src rightside"
href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a
href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a
href="https: [...]
diff --git a/search-index.js b/search-index.js
index d3a8920401..3a037d528d 100644
--- a/search-index.js
+++ b/search-index.js
@@ -14,7 +14,7 @@ var searchIndex = JSON.parse('{\
"arrow_json":{"doc":"Transfer data between the Arrow memory format and JSON
…","t":"CICCCCKOAAIDDDDMMALLLLLLLLLLLLMAKLMMLLLLLLLLLFFFLLLLMAFAMLLAAOLMMMALMMLAMAAAMALLLLLLLLLLLLDLLLLLLLLLLLDLLLLLLLLMMMLLLDLLLMLMLLLMLMLLLDLLLMLLLLMMLLLLMDLLLLLLLLLLLIDLLLMLLLLLKMOLLLNNENNDLLLLLLLLFFLLLLLLFFFFFFFFFFLLLMMLLLMMFLLLLLLLDDDDLLLLLLLLMLLLLLMLLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLLLLLLLLLLLLOLLLLLLLLLLLLLLLLMMMMLLLLLLLLLLLLLRDRLLLMLLLLLMLLLDLLLMLMLLLMLMFLLLDNENNNNNNENNNNNNNNNNDDENNNNLLLLLMLLLLLLLLLLLLLMLL
[...]
"arrow_json_integration_test":{"doc":"","t":"DNNENMFLLLLLLFLLLLLLLLLLLLLLLLMLLLLMFFMLLLLLLLLLLFLMLL","n":["Args","ArrowToJson","JsonToArrow","Mode","Validate","arrow","arrow_to_json","augment_args","augment_args_for_update","borrow","borrow","borrow_mut","borrow_mut","canonicalize_schema","cast","cast","clone","clone_into","command","command_for_update","fmt","fmt","from","from","from_arg_matches","from_arg_matches_mut","from_cast","from_cast","from_ref","group_id","integration","into","
[...]
"arrow_ord":{"doc":"Arrow ordering
kernels","t":"AAAAAFFFFFFFFFFFOOFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFOFOOOOOOFFFGFFOFFFFFDLLLLLFLLLLLLFFLLLLLFFFFDGDDLLLLLLLLLFLLLLLLMLMLLLLLLLLLLLLLLLFFLMMLFFFFFFFFFFFFFFFFFFFLLLLLLLLLLLLM","n":["comparison","ord","partition","rank","sort","cmp_dict","cmp_dict_binary","cmp_dict_binary_array","cmp_dict_bool","cmp_dict_boolean_array","cmp_dict_primitive","cmp_dict_string_array","cmp_dict_utf8","cmp_primitive
[...]
-"arrow_row":{"doc":"A comparable row-oriented representation of a collection
…","t":"ENNNNENNDDDDDDDDNNNNLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLLLLLLLLLLLLLMMMMMLLLMMMFOOALFLMLLLLLLLLLMMALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLALLLLLLLLLLLLLLALLLLLLLFLMMLLLLLLMLLLFMLLLLLMLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMAFFFFFFOFFFSQIIKFFFFFFKFOOFKFDDDDDLLLLLLLLLLLMLLLLLLMLLLLLLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLMLMMLMLLMLLLLLLLLLLLLLLLLLLLMMMFFFFFRRRRFFFFFFF","n":["Codec","Dictionary","Dictionary","DictionaryValues"
[...]
+"arrow_row":{"doc":"A comparable row-oriented representation of a collection
…","t":"ENNNNENNDDDDDDDDNNNNLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLLLLLLLLLLLLLMMMMMLLLMMMFOOALFLMLLLLLLLLLMMALLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLALLLLLLLLLLLLLLALLLLLLLFLMMLLLLLLMLLLFMLLLLLMLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLMAFFFFFFOFFFSQIIKFFFFFFKFOOFKFDDDDDLLLLLLLLLLLMLLLLLLMLLLLLLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLLLMLMMLMLLLMLLLLLLLLLLLLLLLLLLLMMMFFFFFRRRRFFFFFFF","n":["Codec","Dictionary","Dictionary","DictionaryValues
[...]
"arrow_schema":{"doc":"Arrow logical
types","t":"ENNNNNNRRRRRENNNNNNNNNNNDGDNNNNNNNNNNENNNNNNNNNNNNNNNNNNNDDNGNDNNNNENNNNNNDENNLLLLLMALMMMLLAAAAMMLLLLMMMLMMLALLLLNNRRRRRENNNNNNNNNNNNNNNNNNENNNNNNNNNNNNNNNNENNNNNNENNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLENNNNNNNNNNNNNNNNLLLLLLLLLLLLLLLLDDDLLLLLLMMLMMLLLALMLLMLLFLLLLMMMLMLMMFLLLLLLLLLLLLLLLLLSDSSLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLDGLLLLLLLLMLLMLMLLLLLLLLLLLMLMLLLLLLLLMLLLLLLLL
[...]
"arrow_select":{"doc":"Arrow selection
kernels","t":"AAAAAAAFFFNRGDDDDNNENNDNLLLLLLLLLLLLLFLLLLLLLMMMLMMLLFLMMFFFFFFFFFLLLLLLLLLLLLLLLLLLLLLLLLLLMLLLLLLLFMLMMMMLLLLLLLLLLLLLLLLLLDMLLLLLFFFFLLMMOLLLFDLLLMLLLLLLLFFFFFFFFFFFFFFFFLLLLFF","n":["concat","filter","interleave","nullif","take","window","zip","binary_capacity","concat","concat_batches","All","FILTER_SLICES_SELECTIVITY_THRESHOLD","Filter","FilterBuilder","FilterBytes","FilterPredicate","IndexIterator","IndexIterator","Indices","Ite
[...]
"arrow_stream_to_file":{"doc":"","t":"F","n":["main"],"q":[[0,"arrow_stream_to_file"]],"d":[""],"i":[0],"f":[[[],1]],"c":[],"p":[[6,"Result"]]},\
diff --git a/src/arrow_row/interner.rs.html b/src/arrow_row/interner.rs.html
index b776fd01e5..2734f41bff 100644
--- a/src/arrow_row/interner.rs.html
+++ b/src/arrow_row/interner.rs.html
@@ -428,6 +428,99 @@
<a href="#428" id="428">428</a>
<a href="#429" id="429">429</a>
<a href="#430" id="430">430</a>
+<a href="#431" id="431">431</a>
+<a href="#432" id="432">432</a>
+<a href="#433" id="433">433</a>
+<a href="#434" id="434">434</a>
+<a href="#435" id="435">435</a>
+<a href="#436" id="436">436</a>
+<a href="#437" id="437">437</a>
+<a href="#438" id="438">438</a>
+<a href="#439" id="439">439</a>
+<a href="#440" id="440">440</a>
+<a href="#441" id="441">441</a>
+<a href="#442" id="442">442</a>
+<a href="#443" id="443">443</a>
+<a href="#444" id="444">444</a>
+<a href="#445" id="445">445</a>
+<a href="#446" id="446">446</a>
+<a href="#447" id="447">447</a>
+<a href="#448" id="448">448</a>
+<a href="#449" id="449">449</a>
+<a href="#450" id="450">450</a>
+<a href="#451" id="451">451</a>
+<a href="#452" id="452">452</a>
+<a href="#453" id="453">453</a>
+<a href="#454" id="454">454</a>
+<a href="#455" id="455">455</a>
+<a href="#456" id="456">456</a>
+<a href="#457" id="457">457</a>
+<a href="#458" id="458">458</a>
+<a href="#459" id="459">459</a>
+<a href="#460" id="460">460</a>
+<a href="#461" id="461">461</a>
+<a href="#462" id="462">462</a>
+<a href="#463" id="463">463</a>
+<a href="#464" id="464">464</a>
+<a href="#465" id="465">465</a>
+<a href="#466" id="466">466</a>
+<a href="#467" id="467">467</a>
+<a href="#468" id="468">468</a>
+<a href="#469" id="469">469</a>
+<a href="#470" id="470">470</a>
+<a href="#471" id="471">471</a>
+<a href="#472" id="472">472</a>
+<a href="#473" id="473">473</a>
+<a href="#474" id="474">474</a>
+<a href="#475" id="475">475</a>
+<a href="#476" id="476">476</a>
+<a href="#477" id="477">477</a>
+<a href="#478" id="478">478</a>
+<a href="#479" id="479">479</a>
+<a href="#480" id="480">480</a>
+<a href="#481" id="481">481</a>
+<a href="#482" id="482">482</a>
+<a href="#483" id="483">483</a>
+<a href="#484" id="484">484</a>
+<a href="#485" id="485">485</a>
+<a href="#486" id="486">486</a>
+<a href="#487" id="487">487</a>
+<a href="#488" id="488">488</a>
+<a href="#489" id="489">489</a>
+<a href="#490" id="490">490</a>
+<a href="#491" id="491">491</a>
+<a href="#492" id="492">492</a>
+<a href="#493" id="493">493</a>
+<a href="#494" id="494">494</a>
+<a href="#495" id="495">495</a>
+<a href="#496" id="496">496</a>
+<a href="#497" id="497">497</a>
+<a href="#498" id="498">498</a>
+<a href="#499" id="499">499</a>
+<a href="#500" id="500">500</a>
+<a href="#501" id="501">501</a>
+<a href="#502" id="502">502</a>
+<a href="#503" id="503">503</a>
+<a href="#504" id="504">504</a>
+<a href="#505" id="505">505</a>
+<a href="#506" id="506">506</a>
+<a href="#507" id="507">507</a>
+<a href="#508" id="508">508</a>
+<a href="#509" id="509">509</a>
+<a href="#510" id="510">510</a>
+<a href="#511" id="511">511</a>
+<a href="#512" id="512">512</a>
+<a href="#513" id="513">513</a>
+<a href="#514" id="514">514</a>
+<a href="#515" id="515">515</a>
+<a href="#516" id="516">516</a>
+<a href="#517" id="517">517</a>
+<a href="#518" id="518">518</a>
+<a href="#519" id="519">519</a>
+<a href="#520" id="520">520</a>
+<a href="#521" id="521">521</a>
+<a href="#522" id="522">522</a>
+<a href="#523" id="523">523</a>
</pre></div><pre class="rust"><code><span class="comment">// Licensed to the
Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
@@ -773,8 +866,19 @@
</span><span class="kw">fn </span>size(<span
class="kw-2">&</span><span class="self">self</span>) -> usize {
std::mem::size_of::<<span class="self">Self</span>>()
+ <span class="self">self</span>.slots.capacity() *
std::mem::size_of::<Slot>()
+ <span class="comment">// and account for the size of any embedded
buckets in the slots
+ </span>+ <span class="self">self</span>.slot_child_bucket_size()
+ <span class="self">self</span>.next.as_ref().map(|x|
x.size()).unwrap_or_default()
}
+
+ <span class="doccomment">/// returns the total size of any recursively
allocated `Bucket`s
+ /// in self.slots. This does not include the size of the child Slot itself
+ </span><span class="kw">fn </span>slot_child_bucket_size(<span
class="kw-2">&</span><span class="self">self</span>) -> usize {
+ <span class="self">self</span>.slots
+ .iter()
+ .map(|slot| slot.child.as_ref().map(|x|
x.size()).unwrap_or_default())
+ .sum()
+ }
}
<span class="attr">#[cfg(test)]
@@ -857,5 +961,87 @@
interner.normalized_key(interned[<span class="number">3</span>])
< interner.normalized_key(interned[<span class="number">2</span>])
);
}
+
+ <span class="attr">#[test]
+ </span><span class="kw">fn </span>test_intern_sizes() {
+ <span class="kw">let </span><span class="kw-2">mut </span>interner =
OrderPreservingInterner::default();
+
+ <span class="comment">// Intern a 1K values each 8 bytes large
+ </span><span class="kw">let </span>num_items = <span
class="number">1000</span>;
+ <span class="kw">let </span><span class="kw-2">mut </span>values:
Vec<usize> = (<span class="number">0</span>..num_items).collect();
+ values.reverse();
+
+ <span class="comment">// intern these values 1 at a time (otherwise
the interner
+ // will sort them first);
+ </span><span class="kw">for </span>v <span class="kw">in </span>values
{
+ interner.intern([<span
class="prelude-val">Some</span>(v.to_be_bytes())]);
+ }
+
+ <span class="kw">let </span>reported = interner.size();
+
+ <span class="comment">// Figure out the expected size (this is a second
+ // implementation of size()) as a double check
+ </span><span class="kw">let </span>min_expected = BucketWalker::new()
+ .visit_bucket(interner.bucket.as_ref())
+ .memory_estimate()
+ <span class="comment">// hash table size
+ </span>+ interner.lookup.capacity() *
std::mem::size_of::<Interned>()
+ <span class="comment">// key/value storage
+ </span>+ interner.keys.buffer_size()
+ + interner.values.buffer_size();
+
+ <span class="macro">assert!</span>(
+ reported > min_expected,
+ <span class="string">"reported size {reported} not larger
than min expected size: {min_expected}"
+ </span>)
+ }
+
+ <span class="comment">// Walks over the buckets / slots counting counting
them all
+ </span><span class="kw">struct </span>BucketWalker {
+ num_buckets: usize,
+ num_slots: usize,
+ }
+
+ <span class="kw">impl </span>BucketWalker {
+ <span class="kw">fn </span>new() -> <span class="self">Self </span>{
+ <span class="self">Self </span>{
+ num_buckets: <span class="number">0</span>,
+ num_slots: <span class="number">0</span>,
+ }
+ }
+
+ <span class="comment">// recursively visit the bucket and any
slots/buckets contained
+ </span><span class="kw">fn </span>visit_bucket(<span class="kw-2">mut
</span><span class="self">self</span>, bucket: <span
class="kw-2">&</span>Bucket) -> <span class="self">Self </span>{
+ <span class="self">self</span>.num_buckets += <span
class="number">1</span>;
+ <span class="kw">let </span>acc = bucket
+ .slots
+ .iter()
+ .fold(<span class="self">self</span>, |acc, slot|
acc.visit_slot(slot));
+
+ <span class="kw">if let </span><span
class="prelude-val">Some</span>(next) = bucket.next.as_ref() {
+ acc.visit_bucket(next.as_ref())
+ } <span class="kw">else </span>{
+ acc
+ }
+ }
+
+ <span class="comment">// recursively visit slot and any slots/buckets
+ </span><span class="kw">fn </span>visit_slot(<span class="kw-2">mut
</span><span class="self">self</span>, slot: <span
class="kw-2">&</span>Slot) -> <span class="self">Self </span>{
+ <span class="self">self</span>.num_slots += <span
class="number">1</span>;
+ <span class="kw">if let </span><span
class="prelude-val">Some</span>(child) = slot.child.as_ref() {
+ <span class="self">self</span>.visit_bucket(child.as_ref())
+ } <span class="kw">else </span>{
+ <span class="self">self
+ </span>}
+ }
+
+ <span class="comment">// estimate how much memory is used just for
Buckets / Slots
+ // (an underestimate of the total memory used for the
+ // interner as it doesn't contain any actual values)
+ </span><span class="kw">fn </span>memory_estimate(<span
class="self">self</span>) -> usize {
+ <span class="self">self</span>.num_buckets *
std::mem::size_of::<Bucket>()
+ + <span class="self">self</span>.num_slots *
std::mem::size_of::<Slot>()
+ }
+ }
}
</code></pre></div></section></main></body></html>
\ No newline at end of file