<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 8, 2014 at 5:03 PM, Mircea Markus <span dir="ltr">&lt;<a href="mailto:mmarkus@redhat.com" target="_blank">mmarkus@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"><div class="HOEnZb"><div class="h5">On Oct 3, 2014, at 9:30, Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt; wrote:<br>
<br>
&gt; Hi,<br>
&gt;<br>
&gt; recently we had a discussion about what size() returns, but I&#39;ve<br>
&gt; realized there are more things that users would like to know. My<br>
&gt; question is whether you think that they would really appreciate it, or<br>
&gt; whether it&#39;s just my QA point of view where I sometimes compute the<br>
&gt; &#39;checksums&#39; of cache to see if I didn&#39;t lost anything.<br>
&gt;<br>
&gt; There are those sizes:<br>
&gt; A) number of owned entries<br>
&gt; B) number of entries stored locally in memory<br>
&gt; C) number of entries stored in each local cache store<br>
&gt; D) number of entries stored in each shared cache store<br>
&gt; E) total number of entries in cache<br>
&gt;<br>
&gt; So far, we can get<br>
&gt; B via withFlags(SKIP_CACHE_LOAD).size()<br>
&gt; (passivation ? B : 0) + firstNonZero(C, D) via size()<br>
&gt; E via distributed iterators / MR<br>
&gt; A via data container iteration + distribution manager query, but only<br>
&gt; without cache store<br>
&gt; C or D through<br>
&gt; getComponentRegistry().getLocalComponent(PersistenceManager.class).getStores()<br>
&gt;<br>
&gt; I think that it would go along with users&#39; expectations if size()<br>
&gt; returned E and for the rest we should have special methods on<br>
&gt; AdvancedCache. That would of course change the meaning of size(), but<br>
&gt; I&#39;d say that finally to something that has firm meaning.<br>
&gt;<br>
&gt; WDYT?<br>
<br>
</div></div>There was a lot of arguments in past whether size() and other methods that operate over all the elements (keySet, values) are useful because:<br>
- they are approximate (data changes during iteration)<br>
- they are very resource consuming and might be miss-used (this is the reason we chosen to use size() with its current local semantic)<br>
<br>
These methods (size, keys, values) are useful for people and I think we were not wise to implement them only on top of the local data: this is like preferring efficiency over correctness. This also created a lot of confusion with our users, question like size() doesn&#39;t return the correct value being asked regularly. I totally agree that size() returns E (i.e. everything that is stored within the grid, including persistence) and it&#39;s performance implications to be documented accordingly. For keySet and values - we should stop implementing them (throw exception) and point users to Will&#39;s distributed iterator which is a nicer way to achieve the desired behavior.<br></blockquote><div><br></div><div>We can also implement keySet() and values() on top of the distributed entry iterator and document that using the iterator directly is better.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class=""><br>
<br>
&gt;<br>
&gt; Radim<br>
&gt;<br>
&gt; --<br>
&gt; Radim Vansa &lt;<a href="mailto:rvansa@redhat.com">rvansa@redhat.com</a>&gt;<br>
&gt; JBoss DataGrid QA<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>
</span>Cheers,<br>
<span class="HOEnZb"><font color="#888888">--<br>
Mircea Markus<br>
Infinispan lead (<a href="http://www.infinispan.org" target="_blank">www.infinispan.org</a>)<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
<br>
<br>
<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></div>