Hi,
I've this code:
It works ok and with good perfomance but "customers" is a magma collection so I would like use where: because the collection has a index on #name attribute.
It works but I had two problems, the first one is that the meaningfulCharacters of MaSearchStringIndex is 5 and then it works if I write exactly the 5 firsts letter of the name. The second problem is that I can't send asUppercase beacuse name is a MaClause.
So, my question is: Can I use where: for this funcionality or I need use select:? If you think that where: is appropiate, Do I need create a new king of index to reach that? Thank you,
Facu p.s.: I'm using the first code in the method of customersOfNameBeginsWith: selector and i used it on a autocompletation jquery input control.
_______________________________________________ Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
Facu,
> So, my question is: Can I use where: for this funcionality or I need use > select:? If you think that where: is appropiate, Do I need create a new > king of index to reach that? I added the following method in MagmaCollectionReader which should fullfill your needs: read: attributeSymbol beginsWith: aKey ^ self read: attributeSymbol from: aKey upTo: aKey maAlphabeticalNext This allows you to write your original select: based call as self customers where: [:reader | reader read: #name beginsWith: firstsLetterOfName asUppercase] CU, Udo _______________________________________________ Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
Udo,
I works perfectly with new customers but It doesn't with old customers that I was added before add the MaSearchStringIndex on #name attribute. Can I rebuild index on MagmaCollection? Thanks you,
Facu
On Sun, Nov 14, 2010 at 5:49 AM, Udo Schneider <[hidden email]> wrote: Facu, _______________________________________________ Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
Facu,
Can't check at the moment. But take a look at http://wiki.squeak.org/squeak/2639 IMHO using MagmaSession>>#noteOldKeysFor: (check "Index updating" on the webpage) and (if needed) MagmaCollection>>#slowlyDo:commitEvery: (check "Batch operations" on the webpage) should do the trick. CU, Udo On 14.11.10 20:54, Facundo Vozzi wrote: > Udo, > I works perfectly with new customers but It doesn't with old customers > that I was added before add the MaSearchStringIndex on #name attribute. > Can I rebuild index on MagmaCollection? > > Thanks you, > Facu > > On Sun, Nov 14, 2010 at 5:49 AM, Udo Schneider > <[hidden email] <mailto:[hidden email]>> wrote: > > Facu, > > > So, my question is: Can I use where: for this funcionality or I > need use > select:? If you think that where: is appropiate, Do I need > create a new > king of index to reach that? > > I added the following method in MagmaCollectionReader which should > fullfill your needs: > > read: attributeSymbol beginsWith: aKey > ^ self read: attributeSymbol from: aKey upTo: aKey > maAlphabeticalNext > > This allows you to write your original select: based call as > > self customers where: [:reader | reader read: #name beginsWith: > firstsLetterOfName asUppercase] > > > CU, > > Udo > > _______________________________________________ > Magma mailing list > [hidden email] > <mailto:[hidden email]> > http://lists.squeakfoundation.org/mailman/listinfo/magma > > > > > _______________________________________________ > Magma mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/magma _______________________________________________ Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
Udo,
yes I understand you. My problem is that my magma collection wasn't empty when I added the index. So now I need send noteOldKesFor: to each and set again its name (each name: each name), I think.
CU, Facu On Mon, Nov 15, 2010 at 7:04 AM, Udo Schneider <[hidden email]> wrote: Facu, _______________________________________________ Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
In reply to this post by fvozzi
Hi Facundo,
> self customers select: [:aCustomer | aCustomer name asUppercase beginsWith: > firstsLetterOfName asUppercase] > > It works ok and with good perfomance but "customers" is a magma collection Please do not do this. Linear enumeration of an entire large MagmaCollection is something that never performs well. > so I would like use where: because the collection has a index on #name > attribute. > > self customers where: [:each | aCustomer name > = firstsLetterOfName asUppercase] > > It works but I had two problems, the first one is that the > meaningfulCharacters of MaSearchStringIndex is 5 and then it works if I > write exactly the 5 firsts letter of the name. When you use where: you will get back a MagmaCollectionReader. The reader can be thought of as a "collection" with the items narrowed down to the first-five matching characters. Sending #select: to that reader will only enumerate those items, which are much fewer than the entire collection. I prefer to favor small key-sizes on my own MagmaCollections; usually 32 bits and less is "blazing" compared to 64, 128 and larger. I think Magma deserves criticism for letting users use larger than 256-bit, because there is too much LI arithmetic-processing to achieve very good performance at those larger sizes.. You may want to consider an index that allows a precise, unique-identification of each customer. You have 20K customers, you could get away with a 16-bit index! While, at the same time solving the issue of two customers with potentially the same name. A system-generated account #..? - Chris > The second problem is that I > can't send asUppercase beacuse name is a MaClause. The answer to this is here: http://wiki.squeak.org/squeak/5859 > So, my question is: Can I use where: for this funcionality or I need use > select:? If you think that where: is appropiate, Do I need create a new king > of index to reach that? > Thank you, > Facu > p.s.: I'm using the first code in the method of customersOfNameBeginsWith: > selector and i used it on a autocompletation jquery input control. > _______________________________________________ > Magma mailing list > [hidden email] > http://lists.squeakfoundation.org/mailman/listinfo/magma > > Magma mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/magma |
Free forum by Nabble | Edit this page |