#read: for magma reader
Sebastian Sastre
ssastre at seaswork.com
Tue Feb 12 14:55:55 UTC 2008
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 at lists.squeakfoundation.org
> [mailto:magma-bounces at lists.squeakfoundation.org] En nombre
> de Sebastian Sastre
> Enviado el: Martes, 12 de Febrero de 2008 12:40
> Para: magma at 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 at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/magma
More information about the Magma
mailing list