Indexes when objects have collection instance variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Indexes when objects have collection instance variables

Tim Krieg
Hello,
My name it Tim Krieg, and I'm a first time poster.

I have a question about creating an equality index on an identity set of objects that also contain another collection in one of its instance variables.

My application example is this:

A WorkOrder list returns a collection of WorkOrders.  A WorkOrder has an instance variable called startStopTimes (anOrderedCollection) and that returns a collection of TPTimeStampRange objects that keeps track of the startingTimeStamp and endingTimeStamp along with its duration.

Because a workOrder can be started and stopped multiple times, it's very common that the WorkOrder>>startStopTimes collection returns multiple instances, but I'd like the UI to support fast WorkOrder queries by the earliest startTimeStamp and the latestStopTime as well.

I'm not sure of the syntax when creating an equalityIndex on the startingTimeStamp and endingTimeStamp variables starting with the WorkOrder objects.

I've seen examples in the manual for the select path that goes something like this:
select: { :wo | wo.startStopTimes.*.startingTimeStamp >= aTimestamp }.

How would you create an index on this IdentitySet to speed up this query?

WorkOrder list
        createEqualityIndexOn: 'startStopTimes.*.startingTimeStamp'
        withLastElementClass: TimeStamp.

I tried the above (along with a few variations), but obviously it didn't work.  I could also use advice on the select for retrieving the earliest startTimestamp and latest endingTimeStamp as well.  I have it working using select with Smalltalk syntax, but not with Gemstone index path syntax as I need the query to be fast.

Thanks in advance,
Tim