Hi there,
I have a kind of object stored on magmacollections which has been indexed by an attribute which returns N dates. I've made an index which is pretty much like MaKeywordIndex but for DateAndTimes.
It works well. Now I need a metric on those objects to score them regarding to the number of ocurrences of the dates they will be found on the odb. So I have:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| (reader read: #relevantDates from: (Date today subtractDays: self daysBack) asDateAndTime to: DateAndTime now)]) distinct: true) size
by now I've set 2 years by answering 360*2 in daysBack but what if I want the socing for whole thing?
I've tried #read: without parameters other than the index name but then I've realized is not implemented in magma reader. I wish I can do something to count occurrences of my query like:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| reader read: #relevantDates]) distinct: true) size
So taking a look in the reader and indexes I figured I put in my *MagmaExtensions this method:
MagmaCollectionReader>>read: attributeSymbol "Answers a MaLargeCollectionReader with access to all its elements. NOTE: warning, is the whole thing, use smartly"
^ [:index| self readIndex: index fromHash: index lowestPossibleKey toHash: index highestPossibleKey] value: (self indexNamed: attributeSymbol)
But this it's returning a MaClause and no a reader as expected? Any clue on whats happening?
thanks,
Sebastian Sastre
Never mind. The #distinct: message was introducing the nose here. Now it seems to work fine. Anybody see any problem with that #read: implementation to be able to count magma things?
thanks,
Sebastian Sastre
-----Mensaje original----- De: magma-bounces@lists.squeakfoundation.org [mailto:magma-bounces@lists.squeakfoundation.org] En nombre de Sebastian Sastre Enviado el: Martes, 12 de Febrero de 2008 12:40 Para: magma@lists.squeakfoundation.org Asunto: #read: for magma reader
Hi there,
I have a kind of object stored on magmacollections which has been indexed by an attribute which returns N dates. I've made an index which is pretty much like MaKeywordIndex but for DateAndTimes.
It works well. Now I need a metric on those objects to score them regarding to the number of ocurrences of the dates they will be found on the odb. So I have:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| (reader read: #relevantDates from: (Date today subtractDays: self daysBack) asDateAndTime to: DateAndTime now)]) distinct: true) size
by now I've set 2 years by answering 360*2 in daysBack but what if I want the socing for whole thing?
I've tried #read: without parameters other than the index name but then I've realized is not implemented in magma reader. I wish I can do something to count occurrences of my query like:
scoringLevel "Answers the quantity of dates of some relevance for the receiver."
^ ((self elements where:[:reader| reader read: #relevantDates]) distinct: true) size
So taking a look in the reader and indexes I figured I put in my *MagmaExtensions this method:
MagmaCollectionReader>>read: attributeSymbol "Answers a MaLargeCollectionReader with access to all its elements. NOTE: warning, is the whole thing, use smartly"
^ [:index| self readIndex: index fromHash: index lowestPossibleKey toHash: index highestPossibleKey] value: (self indexNamed: attributeSymbol)
But this it's returning a MaClause and no a reader as expected? Any clue on whats happening?
thanks,
Sebastian Sastre
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
Anybody see any problem with that #read: implementation to be able to count magma things?
Hi Sebastian, are you wanting to tally the number of dates for each *unique* date, a la classic "control-break" reporting?
Or, are you simply wanting all elements in a MagmaCollection sorted by date, in which case there is MagmaCollection>>#read:..?
But I see you want to extend #read: on MagmaCollectionReader, so I'm not sure what that is for..
magma@lists.squeakfoundation.org