[Zope-Checkins] CVS: Zope/lib/python/Products/ZCatalog - Catalog.py:1.98.6.4
Casey Duncan
casey@zope.com
Tue, 24 Dec 2002 11:37:07 -0500
Update of /cvs-repository/Zope/lib/python/Products/ZCatalog
In directory cvs.zope.org:/tmp/cvs-serv5490
Modified Files:
Tag: Zope-2_6-branch
Catalog.py
Log Message:
Eliminate Sort algorithm 1 (big set/small index) when not merging results since it does not play well with the mergeResults implementation. Since this algorithm is rarely used, this is a fair compromise I think, making it work would be fairly complex for a small win.
=== Zope/lib/python/Products/ZCatalog/Catalog.py 1.98.6.3 => 1.98.6.4 ===
--- Zope/lib/python/Products/ZCatalog/Catalog.py:1.98.6.3 Wed Dec 11 14:12:14 2002
+++ Zope/lib/python/Products/ZCatalog/Catalog.py Tue Dec 24 11:37:06 2002
@@ -524,7 +524,7 @@
def sortResults(self, rs, sort_index, reverse=0, limit=None, merge=1):
# Sort a result set using a sort index. Return a lazy
# result set in sorted order if merge is true otherwise
- # returns a list of (sortkey, uid, getter_function) tuples
+ # returns a sortable list of raw result tuples
#
# The two 'for' loops in here contribute a significant
# proportion of the time to perform an indexed search.
@@ -543,7 +543,8 @@
rs = rs.keys()
rlen = len(rs)
- if limit is None and (rlen > (len(sort_index) * (rlen / 100 + 1))):
+ if (merge and limit is None and
+ (rlen > (len(sort_index) * (rlen / 100 + 1)))):
# The result set is much larger than the sorted index,
# so iterate over the sorted index for speed.
# This is rarely exercised in practice...
@@ -568,14 +569,13 @@
# Is this ever true?
intset = keys()
length += len(intset)
- append((k, intset, _self__getitem__))
+ result.append((k, LazyMap(_self__getitem__, intset)))
# Note that sort keys are unique.
-
if merge:
result.sort()
if reverse:
result.reverse()
- result = LazyCat(LazyValues(result), length)
+ return LazyCat(LazyValues(result), length)
else:
return result
elif limit is None or (limit * 4 > rlen):