I found an asymmetrical behaviour in recurrent use where:distinct:sortedBy:descending: compare to the use of recurrent where:
I get use to take a MagmaCollection and extract from it a small subset in a reader. Then I get the reader passed from one object to another one and eventually refined it with another where: message.
Being able to apply recursively where: query from one initial collection is very very handy.
As long as you do that with where: it is fined. You can repeat over and over where query with the same indexes of the initial collection. However when applying with where:distinct:sortedBy:descending: then indexes of the initial collection are lost (expect the one used for the sort). It happens because the sort create a new MagmaCollection
I enclosed there a small fix. I expect it slows down a bit the sort because of the recreated indexes in the new collection. In the other hand, asymmetrical behaviour is not great at all. May be we should have a fast sort (what we have now) and slower sort but with the expected behaviour.
I am curious to read what Chris think about the issue.
Hilaire
'From Squeak3.9 of 26 December 2007 [latest update: #7068] on 4 April 2008 at 3:43:10 pm'!
!MagmaCollectionReader methodsFor: 'private' stamp: 'HilaireFernandes 4/4/2008 15:41'! newReducedReaderOn: attribute makeDistinct: aBoolean | newMc index | "index := self indexNamed: attribute." newMc := MagmaCollection new. "newMc addIndex: index." collection indexesDo: [:each | newMc addIndex: each]. collection isNewCollection ifTrue: [aBoolean ifTrue: [self asSet do: [:each | newMc add: each]] ifFalse: [self do: [:each | newMc add: each]]] ifFalse: [collection load: newMc from: self makeDistinct: aBoolean]. ^ newMc read: attribute! !