GsQuery executing on SortedCollection ...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GsQuery executing on SortedCollection ...

GLASS mailing list

The following code might not work. We have domain objects, which do not respond to #<= method.

  • We have a sortedCollection of these domain object, but sorted by an attribute of an instance variable (sub-attribute).
  • GsQuery now tries to build the result and creates a SortedCollection and the domain objects are sorted by #<= and this might fail, because the domain objects do not #<=
sortedObjects := SortedCollection 
sortBlock: [ :a :b | a getAddress get importNumber < b getAddress get importNumber ].
possibleObject addAll: (lots of objects).
(aGsQuery :=GsQuery fromString: 'each.address.importNumber = 10') on: sortedObjects.
aGsQuery asArray

_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass
Reply | Threaded
Open this post in threaded view
|

Re: GsQuery executing on SortedCollection ...

GLASS mailing list
The index/query subsystems pretty much expects a close to full complement of comparison operators and I agree that you might see failures depending upon which code paths get taken ..

The the query and indexing code actually uses a set of _idxForCompare and _idxForSort methods to evaluate queries, so you should take a look at the following methods in Object:

_classSortOrdinal
_classSortsGreaterThan:
_classSortsLessThan:
_idxForCompareEqualTo:
_idxForCompareGreaterThan:
_idxForCompareGreaterThanOrEqualTo:
_idxForCompareLessThan:
_idxForCompareLessThanOrEqualTo:
_idxForCompareNotEqualTo:
_idxForSortEqualTo:
_idxForSortGreaterThan:
_idxForSortGreaterThanOrEqualTo:
_idxForSortLessThan:
_idxForSortLessThanOrEqualTo:
_idxForSortNotEqualTo:


 and consider implementing the appropriate _idxFor methods in your classes to avoid MNU on queries.

Dale

On 05/25/2016 03:16 AM, Marten Feldtmann via Glass wrote:

The following code might not work. We have domain objects, which do not respond to #<= method.

  • We have a sortedCollection of these domain object, but sorted by an attribute of an instance variable (sub-attribute).
  • GsQuery now tries to build the result and creates a SortedCollection and the domain objects are sorted by #<= and this might fail, because the domain objects do not #<=
sortedObjects := SortedCollection 
   sortBlock: [ :a :b | a getAddress get importNumber < b getAddress get importNumber ].
possibleObject addAll: (lots of objects).
(aGsQuery :=GsQuery fromString: 'each.address.importNumber = 10') on: sortedObjects.
aGsQuery asArray


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass


_______________________________________________
Glass mailing list
[hidden email]
http://lists.gemtalksystems.com/mailman/listinfo/glass