<br>Hey Sebastian<br><br><div class="gmail_quote">On Mon, May 31, 2010 at 4:19 PM, Sebastian Trüg <span dir="ltr">&lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi Vishesh,<br>
<div class="im"><br>
On 05/31/2010 11:03 AM, Vishesh Handa wrote:<br>
&gt;     I also moved store() and load() calls back into ResourceData. This is<br>
&gt;     rather trivial. But then you mentioned how ugly it was that ResourceData<br>
&gt;     could delete itself and how one would have to take care of which methods<br>
&gt;     to call.<br>
&gt;     So I changed determineUri() so that it returns the actual ResourceData<br>
&gt;     to use instead of deleting itself. That way Resource *could* simply do:<br>
&gt;<br>
&gt;     m_data = m_data-&gt;determineUri()<br>
&gt;<br>
&gt;     and it would be enough. And we would not even need the m_resources list.<br>
&gt;     But then the same thing would have to be done for each copy of that<br>
&gt;     resource using the ResourceData in question. Thus, I added the method<br>
&gt;     Resource::determineFInalResourceData which basically does what<br>
&gt;     ResourceData::replaceWith did before.<br>
&gt;<br>
&gt;<br>
&gt; Alright. Just so that we both are on the same page, I&#39;m going to tell<br>
&gt; what my plans were after this humongous patch.<br>
&gt; 1. Possible merge both the lists (If you allow!)<br>
<br>
</div>This I still do not understand. How is that possible?<br></blockquote><div><br>Resources are identified by one of these 3 ways -<br>1. nao:identifier<br>2. nie:url (includes the whole filex:/ part)<br>3. nepomuk:/res/<br>
<br>m_kickOffId uses 1, 2 (minus the filex:/) &amp; 3. And m_kickOffUri uses 2 &amp; 3. I say, we scrap the m_kickOffId, and store the nao:identifier in the m_kickOffUri ( perhaps name it to something else? ) <br><br>The determineUri code would become a lot simpler -<br>
<br>if( m_kickOffUri.isValid() ) {<br>   // Either 2 or 3<br>}<br>else {<br>   // nao:identifier<br>}<br><br>The would even clear one of the odd cases where someone tries to initialize a Resource by providing its nepomuk:/res/ uri as a QString instead a QUrl.<br>
<br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
&gt; 2. Convert the ResourceData m_kickOffUri into a list AND make sure that<br>
&gt; while determining one URI it adds all other cases to the lists as well.<br>
&gt;<br>
&gt; Number 1 is more of a convenience, but *2* is really important. You&#39;ve<br>
&gt; done half the job ( I thought we&#39;ll take care of it in another patch )<br>
&gt;<br>
&gt; Now, about the comments in determineFinalResourceData(). The flaw with<br>
&gt; our, not so little, proxy removal plan was that if -<br>
&gt; Resource r1(&quot;foo&quot;);<br>
&gt; r1.determineUri()<br>
&gt;<br>
&gt; Resource r2( foo&#39;s nie:url );<br>
&gt; r2.determineUri() // The proxy thing would be activated ( could be<br>
&gt; avoided via 2 )<br>
&gt;<br>
&gt; Resource r3( foo&#39;s nie:url );<br>
&gt; r3.determineUri() // The proxy thing is AGAIN activated as the nie:url<br>
&gt; wasn&#39;t added to the list.<br>
&gt;<br>
&gt; With your patch you seem to have fixed the problem. But I would have<br>
&gt; preferred the more concrete solution via 2.<br>
<br>
</div>Agreed.<br></blockquote><div><br>How about converting them into hash tables instead of lists? That way we could easily check if addProperty() or removeProperty() updates any of the identifying properties in m_kickOddUri. We could then even potentially stop clearing up the cache after ever metadata move operation.   <br>
</div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
&gt;     So far so good and already confusing enough. But then there is the<br>
&gt;     problem of the kickoff lists. With proxies we did not have to care about<br>
&gt;     the old kickoff ids and uris since the ResourceDatas using proxies were<br>
&gt;     still there &quot;redirecting&quot; to the proxies. Now we delete these old ones.<br>
&gt;     Thus, if another Resource would be created with the same kickoff id or<br>
&gt;     uri the whole process would be restarted. That is why I changed the<br>
&gt;     kickoff id and uri in ResourceData into lists and simply added the new<br>
&gt;     ResourceData multiple times to the kickoff lists in<br>
&gt;     ResourceManagerPrivate.<br>
&gt;<br>
&gt;<br>
&gt; Yup ^^<br>
&gt;<br>
&gt; BTW, we&#39;ll need to fix cleanUpCache as well. Currently, (haven&#39;t tested)<br>
&gt; it should crash. This is because it would try to remove the same<br>
&gt; ResourceData multiple times. The fix is a simple conversion of the list<br>
&gt; into a set. :)<br>
<br>
</div>right.<br>
<div class="im"><br>
&gt; Another problem would be determineAllUris(). It could crash cause<br>
&gt; determineUri may delete one of the members to be accessed.<br>
<br>
</div>man, this code is too scattered. I already tried to implement<br>
determineFinalResourceData by using the Resource constructor but that<br>
would crash since the ResourceData would be deleted before I unlocked<br>
its mutex...<br></blockquote><div><br>Yea. It is really scattered. :-/<br> <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div class="im"><br>
&gt;     I hope that you are not completely confused now. :P<br>
&gt;     I am still not totally happy with it since it it still rather complex<br>
&gt;     although having no proxies is already nice...<br>
&gt;<br>
&gt;<br>
&gt; I&#39;m kinda having second thoughts about this patch. We&#39;re completely<br>
&gt; removing proxies but in the process we&#39;ve imploded the code into a<br>
&gt; rather complex (actually it isn&#39;t that much) solution. But then I never<br>
&gt; liked the idea of proxies.<br>
&gt;<br>
&gt; So, then my question to you is - &quot;How big of a overhead would it be to<br>
</div>&gt; derive ResourceData from *QObject*?&quot;<br>
<br>
what for? IMHO there is no reason to do that.<br></blockquote><div><br>Cancel that. I&#39;d forgotten about the multi-threading problem.<br><br>- Vishesh Handa<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">

<div class="im"><br>
&gt; BTW, Should I incorporate 1 or 2 in the patch and fix determineAll and<br>
&gt; cleanUpCache?<br>
<br>
</div>2 can go into the patch, yes. As for 1: first I need to understand how<br>
that can be done. :)<br>
<br>
Cheers,<br>
<font color="#888888">Sebastian<br>
</font><div class="im"><br>
&gt; - Vishesh Handa<br>
&gt;<br>
&gt;<br>
&gt;     Cheers,<br>
&gt;     Sebastian<br>
&gt;<br>
&gt;<br>
&gt;     On 05/29/2010 04:37 PM, Vishesh Handa wrote:<br>
&gt;     &gt;<br>
&gt;     &gt; I think it should work now. I removed the MutexLocker from the<br>
&gt;     inside of<br>
&gt;     &gt; determineUri().<br>
&gt;     &gt;<br>
&gt;     &gt; - Vishesh Handa<br>
&gt;     &gt;<br>
&gt;     &gt; On Sat, May 29, 2010 at 7:32 PM, Vishesh Handa<br>
&gt;     &lt;<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a> &lt;mailto:<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a>&gt;<br>
</div><div class="im">&gt;     &gt; &lt;mailto:<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a> &lt;mailto:<a href="mailto:handa.vish@gmail.com">handa.vish@gmail.com</a>&gt;&gt;&gt; wrote:<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;     On Sat, May 29, 2010 at 7:17 PM, Sebastian Trüg &lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a><br>
&gt;     &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;<br>
</div><div><div></div><div class="h5">&gt;     &gt;     &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;&gt;&gt; wrote:<br>
&gt;     &gt;<br>
&gt;     &gt;         On 05/29/2010 03:34 PM, Vishesh Handa wrote:<br>
&gt;     &gt;         &gt; On Sat, May 29, 2010 at 5:46 PM, Sebastian Trüg<br>
&gt;     &lt;<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;<br>
&gt;     &gt;         &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;&gt;<br>
&gt;     &gt;         &gt; &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;<br>
&gt;     &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a> &lt;mailto:<a href="mailto:trueg@kde.org">trueg@kde.org</a>&gt;&gt;&gt;&gt; wrote:<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt;     Hehe, this does not help at all. Think about it: in my<br>
&gt;     &gt;         example there are<br>
&gt;     &gt;         &gt;     2 Resource instances involved. Thus: 2 mutexes which are<br>
&gt;     &gt;         locked<br>
&gt;     &gt;         &gt;     independent of each other. :)<br>
&gt;     &gt;         &gt;     The mutex is already there in ResourceData. It simply<br>
&gt;     &gt;         needs to be locked<br>
&gt;     &gt;         &gt;     in Resource instead of ResourceData::determineUri.<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt; Uhh I&#39;m confused. Why don&#39;t you handle the multi-threading?<br>
&gt;     &gt;<br>
&gt;     &gt;         Sure, I can do that. :)<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;     Wait! Please don&#39;t. Let me try. I understand it now. (I think)<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;         &gt; I should really learn about multi-threading. If you have a<br>
&gt;     &gt;         couple of<br>
&gt;     &gt;         &gt; spare minutes could you explain why my method won&#39;t work?<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt; My rationale -<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt; Thread 1 :<br>
&gt;     &gt;         &gt; Resource r1(&quot;foo&quot;);<br>
&gt;     &gt;         &gt; r1.property( nao:numericRating )<br>
&gt;     &gt;         &gt; -&gt; the mutex is locked<br>
&gt;     &gt;         &gt; -&gt; performs whatever and determines the uri<br>
&gt;     &gt;         &gt;<br>
&gt;     &gt;         &gt; Thread 2 :<br>
&gt;     &gt;         &gt; Resource r2(&quot;foo&quot;);<br>
&gt;     &gt;         &gt; r2.setProperty( whatever )<br>
&gt;     &gt;         &gt; -&gt; the mutex can&#39;t get locked so it waits till it does<br>
&gt;     &gt;         &gt; -&gt; mutex now locked. Thread 1 should have determined the uri<br>
&gt;     &gt;         by now<br>
&gt;     &gt;         &gt; -&gt; perform operation<br>
&gt;     &gt;<br>
&gt;     &gt;         Simple: r1 and r2 have different mutex intances. Thus, locking<br>
&gt;     &gt;         one does<br>
&gt;     &gt;         not prevent the other from being locked. The idea is that both<br>
&gt;     &gt;         threads<br>
&gt;     &gt;         need to lock the same mutex. And that is only possible if the<br>
&gt;     &gt;         mutex is<br>
&gt;     &gt;         stored in ResourceData.<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;     Oh. Of course. Thanks for explanation. :-)<br>
&gt;     &gt;<br>
&gt;     &gt;     - Vishesh Handa<br>
&gt;     &gt;<br>
&gt;     &gt;         Cheers,<br>
&gt;     &gt;         Sebastian<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;     &gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>