<br><div class="gmail_quote">On Thu, Dec 9, 2010 at 10:59 PM, Chris Muller <span dir="ltr">&lt;<a href="mailto:ma.chris.m@gmail.com">ma.chris.m@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Yes, I&#39;m not surprised that takes 3 minutes.  The first problem is<br>
that you are using an invalid operator in your where.  You must use<br>
&quot;equals:&quot;, not &quot;=&quot;.  But the bigger problem is the design.  There is<br>
overhead to using #where:, especially when using a disjuction or<br>
sorting or eliminating duplicates.  End-user search and querying is<br>
the primary use-case for the #where: operations, not using Magma as a<br>
RDBMS to &quot;look-up&quot; single objects by a key value. </blockquote><div><br></div><div>Yes, I don&#39;t need that look up when I navigate or use my model but in this case I&#39;m doing a bulk load so I don&#39;t if I can avoid the look-up by a key.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> The right<br>
collection for that job is MagmaPreallocatedDictionary, which can be<br>
large (millions) and still provide very fast #at: access to one object<br>
at a time.  I do not recommend MagmaDictionary or MagmaSet where<br>
performance is at all concerned.  For that reason these collections<br>
really deserve to be deprecated and deleted from Magma.<br></blockquote><div><br></div><div>Well to know, I&#39;m going to try it with MagmaPreallocatedDictionary.</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<br>
The right way to use Magma is to do things as object-oriented as<br>
possible, and only rely on MagmaCollections for applying<br>
value-indexing to the objects.  Is documentNumber extrinsic to the<br>
system, or is it a relational pointer to a Document object?<br></blockquote><div><br></div><div>For now, documentNumber is a vi of customer (just aString) but it could be anObject in other iteration. Maybe is a good moment to reify it to a Document object (i need find a good name for this class) with document number and sex variables instance because I need it for the key of MagmaPreallocatedDictionary since document numbers (in Argentine) aren&#39;t unique. So, I need document number and sex to find a customer.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
Regards,<br>
<font color="#888888">  Chris<br></font></blockquote><div><br></div><div>Thanks,</div><div>Facu </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><font color="#888888">
</font><div><div></div><div class="h5"><br>
<br>
<br>
On Thu, Dec 9, 2010 at 5:47 PM, Facundo Vozzi &lt;<a href="mailto:facundov79@gmail.com">facundov79@gmail.com</a>&gt; wrote:<br>
&gt; Now I&#39;m getting a performance problem.<br>
&gt; I&#39;m bulk loading transactions in sets (from a file) of 1250. Each of one has<br>
&gt; references to 3 objects, 3 numbers and 2 dates.<br>
&gt; When I test it without setting the customer it take to me 614 milliseconds<br>
&gt; to create the 1250 instances but if I look up for each client according to<br>
&gt; the client code it take to me 204158 milliseconds (3.40 minutes).<br>
&gt; Customers is a MagmaCollection and this is the method of the message that<br>
&gt; I&#39;m sending 1250 times:<br>
&gt; customerAtDocumentNumber: unString sex: otroString<br>
&gt; &quot;Devuelve un invividuo o una organizacion dependiendo de si unString<br>
&gt; corresponde a un número de documento o a un número de cuit. NOTA: se debe<br>
&gt; tener en cuenta el sexo por existir números de dni repetidos entre varones y<br>
&gt; mujeres.&quot;<br>
&gt; | aFewCustomers |<br>
&gt; aFewCustomers := self customers where: [ :each | (each documentNumber =<br>
&gt; unString)].<br>
&gt; ^customers detect: [:each | each documentNumber = unString and: [each sex =<br>
&gt; otroString]] ifNone: []<br>
&gt;<br>
&gt;<br>
&gt; Customers has an index on documentNumber. Now I go to profile it but I need<br>
&gt; to find how to do it in Pharo.<br>
&gt; I thing that I can switch customers from MagmaCollection to MagmaDictionary<br>
&gt; and set the document number + sex how the key. What do you think?<br>
&gt; See you,<br>
&gt; Facu<br>
&gt;<br>
&gt; On Thu, Dec 9, 2010 at 7:36 PM, Facundo Vozzi &lt;<a href="mailto:facundov79@gmail.com">facundov79@gmail.com</a>&gt; wrote:<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; If you do a copy, then you will be creating multiple instances of<br>
&gt;&gt;&gt; various &quot;system entities&quot;, which I&#39;m guessing don&#39;t want to do; you<br>
&gt;&gt;&gt; would rather have just one instance, referenced from multiple<br>
&gt;&gt;&gt; transactions, right?<br>
&gt;&gt;<br>
&gt;&gt; Yes, you&#39;re right I don&#39;t want multiple instances.<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; So all you need to do is just look-up the *equivalent* Code in session<br>
&gt;&gt;&gt; which is doing the loading.  It will be the one identical instance in<br>
&gt;&gt;&gt; the repository.<br>
&gt;&gt;<br>
&gt;&gt; Yes, to do that I&#39;m passing the session which is doing the loading by<br>
&gt;&gt; argument.  But I think that my error here is that I&#39;m implementing the<br>
&gt;&gt; protocol to get one entitiy instance by code or name on the Entity class<br>
&gt;&gt; side. I think is<br>
&gt;&gt; better implement it, by example #clientOfCode: aCode, in my system<br>
&gt;&gt; instance<br>
&gt;&gt; which is the root of each session. In this manner I don&#39;t need pass the<br>
&gt;&gt; user session by argument. I think that my traditional database mapping<br>
&gt;&gt; thinking betrayed me<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; But yes, this is one of the use-cases for which FP&#39;s were invented, it<br>
&gt;&gt;&gt; can be a more elegant solution, especially if the number of Codes is<br>
&gt;&gt;&gt; always changing or increasing.  See<br>
&gt;&gt;&gt; MagmaTestCase&gt;&gt;#testForwardingProxy.<br>
&gt;&gt;<br>
&gt;&gt; Yes, I will see it right now.<br>
&gt;&gt; Facu<br>
&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;  - Chris<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; &gt; Thanks for your help,<br>
&gt;&gt;&gt; &gt; Facu<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt; On Thu, Dec 9, 2010 at 4:35 PM, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>&gt;<br>
&gt;&gt;&gt; &gt; wrote:<br>
&gt;&gt;&gt; &gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt; I&#39;m not sure I fully understand the context, but a third option might<br>
&gt;&gt;&gt; &gt;&gt; be to use ForwardingProxies.  Especially if the shared objects can be<br>
&gt;&gt;&gt; &gt;&gt; updated by only one session (like a batch updater, for example).  Then<br>
&gt;&gt;&gt; &gt;&gt; every other (user client) session will share the same instances in<br>
&gt;&gt;&gt; &gt;&gt; memory.<br>
&gt;&gt;&gt; &gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt; HTH,<br>
&gt;&gt;&gt; &gt;&gt;  Chris<br>
&gt;&gt;&gt; &gt;&gt;<br>
&gt;&gt;&gt; &gt;&gt; On Wed, Dec 8, 2010 at 1:13 PM, Facundo Vozzi &lt;<a href="mailto:facundov79@gmail.com">facundov79@gmail.com</a>&gt;<br>
&gt;&gt;&gt; &gt;&gt; wrote:<br>
&gt;&gt;&gt; &gt;&gt; &gt; Hi all,<br>
&gt;&gt;&gt; &gt;&gt; &gt; I&#39;m refactoring my code and I found that I have two ways to do the<br>
&gt;&gt;&gt; &gt;&gt; &gt; same<br>
&gt;&gt;&gt; &gt;&gt; &gt; in<br>
&gt;&gt;&gt; &gt;&gt; &gt; distint parts of my system.<br>
&gt;&gt;&gt; &gt;&gt; &gt; 1) Entity class &gt;&gt; atCode: aCode<br>
&gt;&gt;&gt; &gt;&gt; &gt; &quot;Answer the receiver instance with code equal to aCode or evaluate<br>
&gt;&gt;&gt; &gt;&gt; &gt; aBlock if<br>
&gt;&gt;&gt; &gt;&gt; &gt; it doesn&#39;t exists.&quot;<br>
&gt;&gt;&gt; &gt;&gt; &gt;        ^(self all detect: [:one | one code = aCode]) copy<br>
&gt;&gt;&gt; &gt;&gt; &gt; or<br>
&gt;&gt;&gt; &gt;&gt; &gt; 2) Entity class&gt;&gt; atCode: aCode inSession: anUserSession<br>
&gt;&gt;&gt; &gt;&gt; &gt; &quot;Answer the receiver instance with code equal to aCode or evaluate<br>
&gt;&gt;&gt; &gt;&gt; &gt; aBlock if<br>
&gt;&gt;&gt; &gt;&gt; &gt; it doesn&#39;t exists.&quot;<br>
&gt;&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;&gt; &gt;        ^(self allInSession: anUserSession) detect: [:one | one code<br>
&gt;&gt;&gt; &gt;&gt; &gt; =<br>
&gt;&gt;&gt; &gt;&gt; &gt; aCode]<br>
&gt;&gt;&gt; &gt;&gt; &gt; The difference is that 1 is using the shared session so I need copy<br>
&gt;&gt;&gt; &gt;&gt; &gt; the<br>
&gt;&gt;&gt; &gt;&gt; &gt; object to be used (referenced by other object) on anUserSession. The<br>
&gt;&gt;&gt; &gt;&gt; &gt; uggly<br>
&gt;&gt;&gt; &gt;&gt; &gt; of 2 is that I have to pass anUserSession as argument.<br>
&gt;&gt;&gt; &gt;&gt; &gt; Either way works well, is really the same?<br>
&gt;&gt;&gt; &gt;&gt; &gt; Thanks in advance,<br>
&gt;&gt;&gt; &gt;&gt; &gt; Facu<br>
&gt;&gt;&gt; &gt;&gt; &gt; (*) I eliminate aBlock for absent elements for this example<br>
&gt;&gt;&gt; &gt;&gt; &gt; _______________________________________________<br>
&gt;&gt;&gt; &gt;&gt; &gt; Magma mailing list<br>
&gt;&gt;&gt; &gt;&gt; &gt; <a href="mailto:Magma@lists.squeakfoundation.org">Magma@lists.squeakfoundation.org</a><br>
&gt;&gt;&gt; &gt;&gt; &gt; <a href="http://lists.squeakfoundation.org/mailman/listinfo/magma" target="_blank">http://lists.squeakfoundation.org/mailman/listinfo/magma</a><br>
&gt;&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;<br>
&gt;<br>
</div></div></blockquote></div><br>