[Glass] Can I avoid ReversedRangeIndexReadStream >> atEnd ?
Dale Henrichs via Glass
glass at lists.gemtalksystems.com
Wed Oct 25 11:07:02 PDT 2017
Mariano,
The costly code is in RangeIndexReadStream>>_atEndForStream: (when aBool
is true) and that code can be safely skipped if the values in the index
will not include nils, or if your index is on a CharacterCollection and
you do not mix Strings and Symbols or if your index is on a Float and
the values do not include NaNs.
In 3.4 we do this automatically when you create a btree plus index with
optmiizedComparison index option ... the 3.4 stream operations have been
optimized in other ways as well --- 3.4 is due to be released very soon ...
Dale
On 10/25/2017 07:01 AM, Mariano Martinez Peck via Glass wrote:
> Hi Dale,
>
> I am doing a query like this (as per your recommendation):
>
>
> nearestQueryFor: aDate on: aCollection
> | query |
> query := GsQuery fromFormula: self nearestQuery on: aCollection.
> query bind: 'targetDate' to: aDate.
> ^ query
>
> nearestQuery
> ^ nearestQuery ifNil: [
> nearestQuery := GsQueryPredicate fromQueryStatement: 'each.date <=
> targetDate'.
> nearestQuery
> ].
>
>
> And when I use it, I do this:
>
> query := self nearestQueryFor: dateToCompare on: (self indexingDict
> at: securityUniqueId).
> stream := query reversedReadStream.
> ^ stream atEnd
> ifTrue: [ nil ]
> ifFalse: [ stream next ]
>
> I am profiling some code that uses this a lot and I see that quite
> some time is spent in the #atEnd.
> I attach a part of the profiling output to see what I mean.
>
> Do you see something obvious I can speed up?
>
> Thanks in advance,
>
> --
> Mariano
> http://marianopeck.wordpress.com
>
>
> _______________________________________________
> Glass mailing list
> Glass at lists.gemtalksystems.com
> http://lists.gemtalksystems.com/mailman/listinfo/glass
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20171025/5caa26b7/attachment.html>
More information about the Glass
mailing list