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') ].
or if you prefer using the Smalltalk Collection protocol from this example:
#(1 15 3 10 ) with: #(5 6 7 8) collect: [:i : j | (i max: j) ]
and then we could write
aMagmaCollection1 with: aMagmaCollection2 where: [: reader1 : reader2 | (reader1 read: #name at: 'John Player') | (reader2 read: #name at: 'John Player')
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:
(readers first read: #name at: 'John Player') union: (readers second read: #name at: 'Terry McKenzie')
but I think #where: is somewhat optimized (?).
I'm using the latest Magma. Best regards. Juan M.
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
As Brent mentions, have a look at the server-side processing of where:. You may be able to generalize it to do this, but it will require some research and work as there is some complexity to the MagmaCollection's.
MaQueryExecutor is a good place to start, but note a modern Omni browser or the Tracing Messages Browser will suit you well to researching this code as there are several layers.
Couldn't what you need be accomplished "manually?"
- Chris
On 10/1/07, Burella Juan M. juan.burella@gmail.com wrote:
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') ].
or if you prefer using the Smalltalk Collection protocol from this example:
#(1 15 3 10 ) with: #(5 6 7 8) collect: [:i : j | (i max: j) ]
and then we could write
aMagmaCollection1 with: aMagmaCollection2 where: [: reader1 : reader2 | (reader1 read: #name at: 'John Player') | (reader2 read: #name at: 'John Player')
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:
(readers first read: #name at: 'John Player') union: (readers second read: #name at: 'Terry McKenzie')
but I think #where: is somewhat optimized (?).
I'm using the latest Magma. Best regards. Juan M.
Magma mailing list Magma@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/magma
magma@lists.squeakfoundation.org