[Checkins] SVN: Products.ZCatalog/trunk/ Put back the `weightedIntersection` optimization but guard against results with values and do the appropriate fallback to the weighted version.

Hanno Schlichting hannosch at hannosch.eu
Fri Jul 29 04:50:24 EDT 2011


Log message for revision 122409:
  Put back the `weightedIntersection` optimization but guard against results with values and do the appropriate fallback to the weighted version.
  

Changed:
  U   Products.ZCatalog/trunk/CHANGES.txt
  U   Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2011-07-29 06:58:02 UTC (rev 122408)
+++ Products.ZCatalog/trunk/CHANGES.txt	2011-07-29 08:50:24 UTC (rev 122409)
@@ -4,6 +4,8 @@
 2.13.17 (unreleased)
 --------------------
 
+- Put back the `weightedIntersection` optimization but guard against results
+  with values and do the appropriate fallback to the weighted version.
 
 2.13.16 (2011-07-24)
 --------------------

Modified: Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py	2011-07-29 06:58:02 UTC (rev 122408)
+++ Products.ZCatalog/trunk/src/Products/ZCatalog/Catalog.py	2011-07-29 08:50:24 UTC (rev 122409)
@@ -543,7 +543,11 @@
                 cr.start_split(intersect_id)
                 # weightedIntersection preserves the values from any mappings
                 # we get, as some indexes don't return simple sets
-                _, rs = weightedIntersection(rs, r)
+                if hasattr(rs, 'items'):
+                    _, rs = weightedIntersection(rs, r)
+                else:
+                    rs = intersection(rs, r)
+
                 cr.stop_split(intersect_id)
 
                 # consider the time it takes to intersect the index result with
@@ -594,8 +598,8 @@
             # XXX: The check for 'values' is really stupid since we call
             # items() and *not* values()
             rlen = len(rs)
-            if sort_index is None and hasattr(rs, 'values'):
-                # having a 'values' means we have a data structure with
+            if sort_index is None and hasattr(rs, 'items'):
+                # having a 'items' means we have a data structure with
                 # scores.  Build a new result set, sort it by score, reverse
                 # it, compute the normalized score, and Lazify it.
 



More information about the checkins mailing list