Indexes when objects have collection instance variables

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages 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 equalityIndex on an IdentitySet 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 latest stopTimeStamp 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 WorkOrder class>>list 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 the usual select: method with Smalltalk syntax, but not with Gemstone indexed path syntax as I need the query to be fast.

Thanks in advance,
Tim
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Indexes when objects have collection instance variables

Dale Henrichs-3
Hello Tim,

Well it turns out that you are using an index feature (using `*` as a path term; set valued path terms) that is not supported in the current 64bit products. It is a supported feature in the 32 bit product and is planned for re-introduction in 3.2.

In the absense of set-valued path terms, I think you have to think in terms of doing a little restructuring of your data structures ... possibly consolidating the startStopTimes collections into a single collection that can be indexed on the startingTimeStamp ... presumably you'd then need a reference back to the parent workorder (a primary predicate against a workorder id and secondary predicate against the startingTimestamp might do the trick) ...

Dale

----- Original Message -----
| From: "Tim Krieg" <[hidden email]>
| To: [hidden email]
| Sent: Tuesday, November 19, 2013 7:48:42 AM
| Subject: [Glass] Indexes when objects have collection instance variables
|
|
|
| Hello,
| My name it Tim Krieg, and I'm a first time poster.
|
| I have a question about creating an equalityIndex on an IdentitySet
| 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 latest stopTimeStamp 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 WorkOrder class>>list
| 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
| the usual select: method with Smalltalk syntax, but not with Gemstone
| indexed path syntax as I need the query to be fast.
|
| Thanks in advance,
| Tim
|
|
|
| --
| View this message in context:
| http://forum.world.st/Indexes-when-objects-have-collection-instance-variables-tp4723419.html
| Sent from the GLASS mailing list archive at Nabble.com.
| _______________________________________________
| Glass mailing list
| [hidden email]
| http://lists.gemtalksystems.com/mailman/listinfo/glass
|
_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: [Glass] Indexes when objects have collection instance variables

Tim Krieg
This post was updated on .
Hi Dale,
Thanks for the tip.  I didn't think of having all the TPTimeStampRange objects in their own collection then indexing their workOrder owner.  Good idea!

Thanks again,
Tim