Newbie Questions
Chris Muller
asqueaker at gmail.com
Mon Mar 23 19:43:00 UTC 2009
> I'm still wondering about the previous question.
>
> http://wiki.squeak.org/squeak/5722 lists Date but not DateAndTime as
> explicitly supported Magnitudes; presumably both qualify under "any
> class that inherits from Object with only named instance variables."
That is not an exhaustive list. DateAndTimes are supported.
> http://wiki.squeak.org/squeak/2639 says "There are also an [sic] index
> types for Dates, DateAndTimes, UUID's, Integers, and more." Dates are
> now TimeSpans, though perhaps they were not when the page was written.
>
> There are at least two scenarios where the width of the item being
> indexed could be problematic. Suppose the index is on intervals that
> are TimeSpans. For simplicity, I'll assume everthing is on the same
> day. Suppose one has a collection indexed on the TimeSpan with object a
> having TimeSpan from 1 to 2 am. If you ask for values at DateAndTime
> 1:30am, do you get a back? Do you get an error about the query having
> the wrong type?
>
> Alternately, suppose you ask for values at a TimeSpan from 1:30-2:30am.
> What happens?
Magma does not include a generic Timespan index, the DateIndex is just
for objects with a Duration of 1 day, so testing equality or greater
or less than on an exact Date just works. DateAndTime is not a
Timespan.
Depending on your application requirements, you may be able to employ
two DateAndTime indexes; #startTime and #endTime. Your app could then
query
where:
[ : each |
(each startTime > someTime)
& (each endTime <= someTime) ]
If that won't work you may need to make your own subclass of
MagmaCollectionIndex..
More information about the Magma
mailing list