<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Processing Streams with PLINQ</title><link>http://blogs.msdn.com/pfxteam/archive/2009/07/05/9818163.aspx</link><description>In many data-parallel scenarios, all of the data to be processed is available immediately. This blog post addresses the opposite scenario: the inputs arrive gradually (as if in a stream), and we want to start producing results even before reading the</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: Processing Streams with PLINQ</title><link>http://blogs.msdn.com/pfxteam/archive/2009/07/05/9818163.aspx#9818768</link><pubDate>Mon, 06 Jul 2009 07:56:22 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9818768</guid><dc:creator>leniel</dc:creator><description>&lt;p&gt;Hi igoro,&lt;/p&gt;
&lt;p&gt;It's great to know this is possible with PLINQ! :)&lt;/p&gt;
&lt;p&gt;Thanks for sharing this advice.&lt;/p&gt;
&lt;p&gt;Leniel Macaferi&lt;/p&gt;
&lt;p&gt;&lt;a rel="nofollow" target="_new" href="http://leniel.net"&gt;http://leniel.net&lt;/a&gt;&lt;/p&gt;
</description></item><item><title>re: Processing Streams with PLINQ</title><link>http://blogs.msdn.com/pfxteam/archive/2009/07/05/9818163.aspx#9819145</link><pubDate>Mon, 06 Jul 2009 11:14:43 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9819145</guid><dc:creator>Aaron</dc:creator><description>&lt;p&gt;&amp;quot;Thus, a query that contains an OrderBy operator does not (and cannot) run in a streaming fashion&amp;quot;&lt;/p&gt;
&lt;p&gt;Um, what? &amp;nbsp;You might not _want_ to run it in a stream fashion, but maybe _I_ do. &amp;nbsp;For example, expr.OrderBy(x =&amp;gt; x).Take(3) need only partially sort the sequence. &amp;nbsp;Yes, OrderBy reads the whole input stream. &amp;nbsp;But streaming as lazy processing need not sort the whole input before providing the first result.&lt;/p&gt;
&lt;p&gt;&amp;quot;the algorithms we use are optimized for throughput rather than latency&amp;quot;&lt;/p&gt;
&lt;p&gt;In this context, OrderBy's eager behavior makes sense. &amp;nbsp;Whole-sequence sort is always going to be faster than a complete set of partial sorts, by some constant factor.&lt;/p&gt;
</description></item><item><title>re: Processing Streams with PLINQ</title><link>http://blogs.msdn.com/pfxteam/archive/2009/07/05/9818163.aspx#9819896</link><pubDate>Mon, 06 Jul 2009 17:42:12 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9819896</guid><dc:creator>Robert Westerlund</dc:creator><description>&lt;p&gt;Aaron:&lt;/p&gt;
&lt;p&gt;I might be missunderstanding something, and if I do please let me know, but as far as my understanding goes, it is correct to say that you cannot run a sorting algorithm without having all values.&lt;/p&gt;
&lt;p&gt;Given your example, expr.OrderBy(x =&amp;gt; x).Take(3) in a situation where expr would stream its return value in two chunks. Suppose that the OrderBy would:&lt;/p&gt;
&lt;p&gt;1) Sort the initial chunk before the second chunk arrives&lt;/p&gt;
&lt;p&gt;2) Return the sorted items as soon as it has sorted them (in this case, before receiving the second chunk) &lt;/p&gt;
&lt;p&gt;Given that we would get the following two chunks (3,6,5,7) and (8,1,9) the OrderBy-method would sort the first chunk (resulting in 3,5,6,7) and the Take(3) would return 3,5,6. As can be seen, this behaviour would not be correct, since a correct result in the end would have been 1,3,5. Thus, if we would have been handed the 3 as first result, it would have given us the wrong result and thus not successfully sorted the items.&lt;/p&gt;
&lt;p&gt;Therefore, OrderBy needs access to all items in order to be able sort correctly.&lt;/p&gt;
</description></item></channel></rss>