Querying multiple collections with #where:

Brent Pinkney brent at zamail.co.za
Mon Oct 1 19:51:07 UTC 2007


Ah,

Ye Olde Index Reader...

> Hi Chris. I need to do something like this:
> { aMagmaCollection1 . aMagmaCollection2 } where: 
> 	[ :readers | 
> 	(readers first read: #name at: 'John Player') | (readers second read: #name at: 'Terry McKenzie') ].
> 
> but this one would be limited to allow only two magma collections. We haven't found yet a simple way to do it and will be very glad if you could suggest how you would face the solution.
> I suppose this can be done this way:

I too have laboured over this issue back when I was implementing jins in Magma's Lava SQL layer.

My solution for small Smalltalk collections was to introduce a new abstract collection class called Medley which holds an array of other collections. 
Prudent implementation of to:do:by:do: (I recall) made it easy to build this single collection of collections.

You will note that your request is merely a hop skip and a jump away from supporting SQL joins. I have pondered this as part of my Lava efforts: 
What is required to start with is some nifty footwork in Array>>where: which processes the query clauses. Have a look at the implementers of #where: !

The Magma backend would also have to be modified to process conjunctions and possible duplicates, as well a intersections (i.e joins). 
The good news is that the infrastructure on the server processes complex #where: clauses for a single collection and it should be reasonable to genralise the logic.

Indeed the single collection query reduces to a special case of multiple collection query!

I would like to follow this thread and possibly help as it has major implications for the simplification and scalability of Lava.

Cheers

Brent



More information about the Magma mailing list