Skip to content

Commit eed1bec

Browse files
committed
Deploying to gh-pages from @ f54796a 🚀
1 parent 0cb08a2 commit eed1bec

File tree

4 files changed

+12
-34
lines changed

4 files changed

+12
-34
lines changed

chapter_4/chapter_4_5.html

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -182,23 +182,12 @@ <h2 id="the-data-trait"><a class="header" href="#the-data-trait">The <code>Data<
182182
<pre><code class="language-rust ignore">#[derive(Clone)]
183183
struct YourStruct { .. }</code></pre>
184184
<h2 id="the-exchangedata-trait"><a class="header" href="#the-exchangedata-trait">The <code>ExchangeData</code> trait</a></h2>
185-
<p>The <code>ExchangeData</code> trait is more complicated, and is established in the <code>communication/</code> module. There are two options for this trait, which are determined by whether you use the <code>--bincode</code> feature at compilation, or not.</p>
186-
<ul>
187-
<li>
188-
<p>If you use <code>--bincode</code> then the trait is a synonym for</p>
185+
<p>The <code>ExchangeData</code> trait is more complicated, and is established in the <code>communication/</code> module. The trait is a synonym for</p>
189186
<pre><code class="language-rust ignore">Send+Sync+Any+serde::Serialize+for&lt;'a&gt;serde::Deserialize&lt;'a&gt;+'static</code></pre>
190187
<p>where <code>serde</code> is Rust's most popular serialization and deserialization crate. A great many types implement these traits. If your types does not, you should add these decorators to their definition:</p>
191188
<pre><code class="language-rust ignore">#[derive(Serialize, Deserialize)]</code></pre>
192189
<p>You must include the <code>serde</code> crate, and if not on Rust 2018 the <code>serde_derive</code> crate.</p>
193-
<p>The downside to the <code>--bincode</code> flag is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.</p>
194-
</li>
195-
<li>
196-
<p>If you do not use the <code>--bincode</code> feature, then the <code>Serialize</code> and <code>Deserialize</code> requirements are replaced by <code>Abomonation</code>, from the <code>abomonation</code> crate. This trait allows in-place deserialization, but is implemented for fewer types, and has the potential to be a bit scarier (due to in-place pointer correction).</p>
197-
<p>Your types likely do not implement <code>Abomonation</code> by default, but you can similarly use</p>
198-
<pre><code class="language-rust ignore">#[derive(Abomonation)]</code></pre>
199-
<p>You must include the <code>abomonation</code> and <code>abomonation_derive</code> crate for this to work correctly.</p>
200-
</li>
201-
</ul>
190+
<p>The downside to is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.</p>
202191
<h2 id="an-example"><a class="header" href="#an-example">An example</a></h2>
203192
<p>Let's imagine you would like to play around with a tree data structure as something you might send around in timely dataflow. I've written the following candidate example:</p>
204193
<pre><code class="language-rust ignore">extern crate timely;
@@ -278,7 +267,7 @@ <h3 id="exchanging-data"><a class="header" href="#exchanging-data">Exchanging da
278267
}
279268
}</code></pre>
280269
<p>We get a new error. A not especially helpful error. It says that it cannot find an <code>exchange</code> method, or more specifically that one exists but it doesn't apply to our type at hand. This is because the data need to satisfy the <code>ExchangeData</code> trait but do not. It would be better if this were clearer in the error messages, I agree.</p>
281-
<p>We can fix the problem two ways. First, if you would like to use <code>bincode</code>, then we update the source like so:</p>
270+
<p>The fix is to update the source like so:</p>
282271
<pre><code class="language-rust ignore">#[macro_use]
283272
extern crate serde_derive;
284273
extern crate serde;
@@ -288,8 +277,8 @@ <h3 id="exchanging-data"><a class="header" href="#exchanging-data">Exchanging da
288277
data: D,
289278
children: Vec&lt;TreeNode&lt;D&gt;&gt;,
290279
}</code></pre>
291-
<p>and make sure to include the <code>serde_derive</code> and <code>serde</code> crates. Now when we run things (notice the <code>--features</code> flag) we see:</p>
292-
<pre><code class="language-ignore"> Echidnatron% cargo run --example types --features bincode
280+
<p>and make sure to include the <code>serde_derive</code> and <code>serde</code> crates.</p>
281+
<pre><code class="language-ignore"> Echidnatron% cargo run --example types
293282
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
294283
Running `target/debug/examples/types`
295284
seen: TreeNode { data: 0, children: [] }

print.html

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,23 +1848,12 @@ <h2 id="the-data-trait"><a class="header" href="#the-data-trait">The <code>Data<
18481848
<pre><code class="language-rust ignore">#[derive(Clone)]
18491849
struct YourStruct { .. }</code></pre>
18501850
<h2 id="the-exchangedata-trait"><a class="header" href="#the-exchangedata-trait">The <code>ExchangeData</code> trait</a></h2>
1851-
<p>The <code>ExchangeData</code> trait is more complicated, and is established in the <code>communication/</code> module. There are two options for this trait, which are determined by whether you use the <code>--bincode</code> feature at compilation, or not.</p>
1852-
<ul>
1853-
<li>
1854-
<p>If you use <code>--bincode</code> then the trait is a synonym for</p>
1851+
<p>The <code>ExchangeData</code> trait is more complicated, and is established in the <code>communication/</code> module. The trait is a synonym for</p>
18551852
<pre><code class="language-rust ignore">Send+Sync+Any+serde::Serialize+for&lt;'a&gt;serde::Deserialize&lt;'a&gt;+'static</code></pre>
18561853
<p>where <code>serde</code> is Rust's most popular serialization and deserialization crate. A great many types implement these traits. If your types does not, you should add these decorators to their definition:</p>
18571854
<pre><code class="language-rust ignore">#[derive(Serialize, Deserialize)]</code></pre>
18581855
<p>You must include the <code>serde</code> crate, and if not on Rust 2018 the <code>serde_derive</code> crate.</p>
1859-
<p>The downside to the <code>--bincode</code> flag is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.</p>
1860-
</li>
1861-
<li>
1862-
<p>If you do not use the <code>--bincode</code> feature, then the <code>Serialize</code> and <code>Deserialize</code> requirements are replaced by <code>Abomonation</code>, from the <code>abomonation</code> crate. This trait allows in-place deserialization, but is implemented for fewer types, and has the potential to be a bit scarier (due to in-place pointer correction).</p>
1863-
<p>Your types likely do not implement <code>Abomonation</code> by default, but you can similarly use</p>
1864-
<pre><code class="language-rust ignore">#[derive(Abomonation)]</code></pre>
1865-
<p>You must include the <code>abomonation</code> and <code>abomonation_derive</code> crate for this to work correctly.</p>
1866-
</li>
1867-
</ul>
1856+
<p>The downside to is that deserialization will always involve a clone of the data, which has the potential to adversely impact performance. For example, if you have structures that contain lots of strings, timely dataflow will create allocations for each string even if you do not plan to use all of them.</p>
18681857
<h2 id="an-example-4"><a class="header" href="#an-example-4">An example</a></h2>
18691858
<p>Let's imagine you would like to play around with a tree data structure as something you might send around in timely dataflow. I've written the following candidate example:</p>
18701859
<pre><code class="language-rust ignore">extern crate timely;
@@ -1944,7 +1933,7 @@ <h3 id="exchanging-data"><a class="header" href="#exchanging-data">Exchanging da
19441933
}
19451934
}</code></pre>
19461935
<p>We get a new error. A not especially helpful error. It says that it cannot find an <code>exchange</code> method, or more specifically that one exists but it doesn't apply to our type at hand. This is because the data need to satisfy the <code>ExchangeData</code> trait but do not. It would be better if this were clearer in the error messages, I agree.</p>
1947-
<p>We can fix the problem two ways. First, if you would like to use <code>bincode</code>, then we update the source like so:</p>
1936+
<p>The fix is to update the source like so:</p>
19481937
<pre><code class="language-rust ignore">#[macro_use]
19491938
extern crate serde_derive;
19501939
extern crate serde;
@@ -1954,8 +1943,8 @@ <h3 id="exchanging-data"><a class="header" href="#exchanging-data">Exchanging da
19541943
data: D,
19551944
children: Vec&lt;TreeNode&lt;D&gt;&gt;,
19561945
}</code></pre>
1957-
<p>and make sure to include the <code>serde_derive</code> and <code>serde</code> crates. Now when we run things (notice the <code>--features</code> flag) we see:</p>
1958-
<pre><code class="language-ignore"> Echidnatron% cargo run --example types --features bincode
1946+
<p>and make sure to include the <code>serde_derive</code> and <code>serde</code> crates.</p>
1947+
<pre><code class="language-ignore"> Echidnatron% cargo run --example types
19591948
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
19601949
Running `target/debug/examples/types`
19611950
seen: TreeNode { data: 0, children: [] }

searchindex.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.

searchindex.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)