<div dir="ltr"><div><div><div><div>Radim, this is how our M/R algorithm works (Hadoop may do it differently):<br><br>* The mapping phase generates a Map&lt;IntKey, Collection&lt;IntValue&gt;&gt; on each node (Int meaning intermediate).<br>

* In the combine (local reduce) phase, a combine operation takes as input an IntKey and a Collection&lt;IntValue&gt; with only the values that were produced on that node.<br>* In the (global) reduce phase, all the intermediate values for each key are merged, and a reduce operation takes an intermediate key and a sequence of *all* the intermediate values generated for that key. These reduce operations are completely independent, so each intermediate key can be mapped to a different node (distributed reduce), while still having access to all the intermediate values at once.<br>

</div><div>* In the end, the collator takes the Map&lt;IntKey, IntValue&gt; from the reduce phase and produces a single value. <br></div><div><br>If a combiner can be used, then I believe it can also be run in parallel
 with a LinkedBlockingQueue between the mapper and the combiner. But sometimes the reduce algorithm can only be run on the entire collection of values (e.g if you want to find the median, or a percentile).<br></div><br></div>

The limitation we have now is that in the reduce phase, the entire list of values for one intermediate key must be in memory at once. I think Hadoop only loads a block of intermediate values in memory at once, and can even sort the intermediate values (with a user-supplied comparison function) so that the reduce function can work on a sorted list without loading the values in memory itself.<br>

<br></div>Cheers<br></div>Dan<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 18, 2014 at 10:59 AM, Radim Vansa <span dir="ltr">&lt;<a href="mailto:rvansa@redhat.com" target="_blank">rvansa@redhat.com</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Etienne,<br>
<br>
how does the requirement for all data provided to Reducer as a whole<br>
work for distributed caches? There you&#39;d get only a subset of the whole<br>
mapped set on each node (afaik each node maps the nodes locally and<br>
performs a reduction before executing the &quot;global&quot; reduction). Or are<br>
these M/R jobs applicable only to local caches?<br>
I have to admit I have only a limited knowledge of M/R, could you give<br>
me an example where the algorithm works in distributed environment and<br>
still cannot be parallelized?<br>
<br>
Thanks<br>
<span class="HOEnZb"><font color="#888888"><br>
Radim<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On 02/17/2014 09:18 AM, Etienne Riviere wrote:<br>
&gt; Hi Radim,<br>
&gt;<br>
&gt; I might misunderstand your suggestion but many M/R jobs actually require to run the two phases one after the other, and henceforth to store the intermediate results somewhere. While some may slightly reduce intermediate memory usage by using a combiner function (e.g., the word-count example), I don&rsquo;t see how we can avoid intermediate storage altogether.<br>


&gt;<br>
&gt; Thanks,<br>
&gt; Etienne (leads project &mdash; as Evangelos who initiated the thread)<br>
&gt;<br>
&gt; On 17 Feb 2014, at 08:48, Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt; wrote:<br>
&gt;<br>
&gt;&gt; I think that the intermediate cache is not required at all. The M/R<br>
&gt;&gt; algorithm itself can (and should!) run with memory occupied by the<br>
&gt;&gt; result of reduction. The current implementation with Map first and<br>
&gt;&gt; Reduce after that will always have these problems, using a cache for<br>
&gt;&gt; temporary caching the result is only a workaround.<br>
&gt;&gt;<br>
&gt;&gt; The only situation when temporary cache could be useful is when the<br>
&gt;&gt; result grows linearly (or close to that or even more) with the amount of<br>
&gt;&gt; reduced entries. This would be the case for groupBy producing Map&lt;Color,<br>
&gt;&gt; List&lt;Entry&gt;&gt; from all entries in cache. Then the task does not scale and<br>
&gt;&gt; should be redesigned anyway, but flushing the results into cache backed<br>
&gt;&gt; by cache store could help.<br>
&gt;&gt;<br>
&gt;&gt; Radim<br>
&gt;&gt;<br>
&gt;&gt; On 02/14/2014 04:54 PM, Vladimir Blagojevic wrote:<br>
&gt;&gt;&gt; Tristan,<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Actually they are not addressed in this pull request but the feature<br>
&gt;&gt;&gt; where custom output cache is used instead of results being returned is<br>
&gt;&gt;&gt; next in the implementation pipeline.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Evangelos, indeed, depending on a reducer function all intermediate<br>
&gt;&gt;&gt; KOut/VOut pairs might be moved to a single node. How would custom cache<br>
&gt;&gt;&gt; help in this case?<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt; Vladimir<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; On 2/14/2014, 10:16 AM, Tristan Tarrant wrote:<br>
&gt;&gt;&gt;&gt; Hi Evangelos,<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; you might be interested in looking into a current pull request which<br>
&gt;&gt;&gt;&gt; addresses some (all?) of these issues<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; <a href="https://github.com/infinispan/infinispan/pull/2300" target="_blank">https://github.com/infinispan/infinispan/pull/2300</a><br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; Tristan<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; On 14/02/2014 16:10, Evangelos Vazaios wrote:<br>
&gt;&gt;&gt;&gt;&gt; Hello everyone,<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I started using the MapReduce implementation of Infinispan and I came<br>
&gt;&gt;&gt;&gt;&gt; across some possible limitations. Thus, &nbsp;I want to make some suggestions<br>
&gt;&gt;&gt;&gt;&gt; about the MapReduce (MR) implementation of Infinispan.<br>
&gt;&gt;&gt;&gt;&gt; Depending on the algorithm, &nbsp;there might be some memory problems,<br>
&gt;&gt;&gt;&gt;&gt; especially for intermediate results.<br>
&gt;&gt;&gt;&gt;&gt; An example of such a case is &nbsp;group by. Suppose that we have a cluster<br>
&gt;&gt;&gt;&gt;&gt; of 2 nodes with 2 GB &nbsp;available. Let a distributed cache, where simple<br>
&gt;&gt;&gt;&gt;&gt; car objects (id,brand,colour) are stored and the total size of data is<br>
&gt;&gt;&gt;&gt;&gt; 3.5GB. If all objects have the same colour , then all 3.5 GB would go to<br>
&gt;&gt;&gt;&gt;&gt; only one reducer, as a result an OutOfMemoryException will be thrown.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; To overcome these limitations, I propose to add as parameter the name of<br>
&gt;&gt;&gt;&gt;&gt; the intermediate cache to be used. This will enable the creation of a<br>
&gt;&gt;&gt;&gt;&gt; custom configured cache that deals with the memory limitations.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Another feature that I would like to have is to set the name of the<br>
&gt;&gt;&gt;&gt;&gt; output cache. The reasoning behind this is similar to the one mentioned<br>
&gt;&gt;&gt;&gt;&gt; above.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; I wait for your thoughts on these two suggestions.<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt; Regards,<br>
&gt;&gt;&gt;&gt;&gt; Evangelos<br>
&gt;&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt;<br>
&gt;&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;&gt; _______________________________________________<br>
&gt;&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;&gt;<br>
&gt;&gt; --<br>
&gt;&gt; Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt;<br>
&gt;&gt; JBoss DataGrid QA<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; infinispan-dev mailing list<br>
&gt;&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt;&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; infinispan-dev mailing list<br>
&gt; <a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
&gt; <a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
<br>
<br>
--<br>
Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt;<br>
JBoss DataGrid QA<br>
<br>
_______________________________________________<br>
infinispan-dev mailing list<br>
<a href="mailto:infinispan-dev@lists.jboss.org">infinispan-dev@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/infinispan-dev" target="_blank">https://lists.jboss.org/mailman/listinfo/infinispan-dev</a><br>
</div></div></blockquote></div><br></div>