Reading multiple indices on MagmaCollections - first working code

Brent Pinkney brent.pinkney at aircom.co.za
Sun Apr 9 20:30:47 UTC 2006


Hi Chris,

Attached is my latest Monticello which includes the first working code!

This version uses MaSimpleBitmapIndex which is for our prototyping purposes 
only. This class keeps a collection of all the OIDs satisfying the query: 
this will obviously not scale.

In addition, it does not yet support new collections or collections with 
uncommitted changes - only the persistant objects are interrogated. The 
neccessary hooks are however implemented.

For the impatient:

reader := LavaTestResource current people where:
		[ :each |
		(each familyName equals: 'Man') |
			((each familyName equals: 'Pinkney') & (each age to: 60)) ].

Transcript clear. 
reader do: [ :p | Transcript show: p; tab; show: p age; cr ]


Notes.
--------

I have refactored the client API into
	MaTerm (reader)
		MaClause (index lowKey highKey)
		MaExpression(operator terms)

I have fixed a few bugs in the building of the expression tree. I have also 
added an enumeration prototcol #do: which traverses the tree recursively.

In additon to this there is a very sophisticated tree enumerating method:

	MaExpression >>
		inject: thisValue 
		beforeConjunctionDo: beforeAndBlock 
		beforeDisjunctionDo: beforeOrBlock
		termsDo: aQuaternaryBlock 
		afterConjunctionDo: afterAndBlock
		afterDisjunctionDo: afterOrBlock

This method should be powerful enough for our purposes!

In anticipation of the conjunction work you have done, I have refactored 
MaExpression to use a collection of terms instead of just #lhs and #rhs.

The #normalize message will promote all terms to the same level if possible. 
For example, evaluate for each of the following readers:

	r := LavaTestResource current people where:
		[ :each |
		(each age to: 10) & (each age to: 20) &
			(each age to: 30) & (each age to: 40) ].

	r := LavaTestResource current people where:
		[ :each |
		(each age to: 10) | (each age to: 20) & 
		( (each age to: 30) & (each age to: 40) ) ].

The following:

	Transcript clear. 
	r expression do: [ :t | Transcript show: t; cr ].
	Transcript cr; cr.
	r expression normalize
	r expression do: [ :t | Transcript show: t; cr ].

A nice optimisation is that if the expression has only one term, the 
#normalize with convert it into a traditional MagmaCollectionReader.


Hopefully this will be useful in restricting the search.


Cheers

Brent



-------------- next part --------------
A non-text attachment was scrubbed...
Name: Magma research-brp.7.mcz
Type: application/x-zip
Size: 11998 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/magma/attachments/20060409/ef4242a3/Magmaresearch-brp.7.bin


More information about the Magma mailing list