[Checkins] SVN: Products.ZCatalog/trunk/ Optimize DateRangeIndex for better conflict resolution handling. It always starts out with storing an IITreeSet of the value instead of special casing storing an int for a single value. The `single value as int` optimization should be provided via a separate API to be called periodically outside the context of a normal request.

Hanno Schlichting hannosch at hannosch.eu
Mon May 2 08:05:28 EDT 2011


Log message for revision 121504:
  Optimize DateRangeIndex for better conflict resolution handling. It always starts out with storing an IITreeSet of the value instead of special casing storing an int for a single value. The `single value as int` optimization should be provided via a separate API to be called periodically outside the context of a normal request.
  

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

-=-
Modified: Products.ZCatalog/trunk/CHANGES.txt
===================================================================
--- Products.ZCatalog/trunk/CHANGES.txt	2011-05-02 11:02:32 UTC (rev 121503)
+++ Products.ZCatalog/trunk/CHANGES.txt	2011-05-02 12:05:27 UTC (rev 121504)
@@ -4,6 +4,12 @@
 2.13.12 (unreleased)
 --------------------
 
+- Optimize DateRangeIndex for better conflict resolution handling. It always
+  starts out with storing an IITreeSet of the value instead of special casing
+  storing an int for a single value. The `single value as int` optimization
+  should be provided via a separate API to be called periodically outside the
+  context of a normal request.
+
 - Replaced `weightedIntersection` and `weightedUnion` calls with their
   non-weighted version, as we didn't pass in weights.
 

Modified: Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py
===================================================================
--- Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py	2011-05-02 11:02:32 UTC (rev 121503)
+++ Products.ZCatalog/trunk/src/Products/PluginIndexes/DateRangeIndex/DateRangeIndex.py	2011-05-02 12:05:27 UTC (rev 121504)
@@ -26,7 +26,6 @@
 from Acquisition import aq_parent
 from App.Common import package_home
 from App.special_dtml import DTMLFile
-from BTrees.IIBTree import IISet
 from BTrees.IIBTree import IITreeSet
 from BTrees.IIBTree import difference
 from BTrees.IIBTree import intersection
@@ -346,15 +345,15 @@
     def _insert_migrate(self, tree, key, value):
         treeset = tree.get(key, None)
         if treeset is None:
-            tree[key] = value
+            tree[key] = IITreeSet((value, ))
         else:
-            if isinstance(treeset, int):
+            if isinstance(treeset, IITreeSet):
+                treeset.insert(value)
+            elif isinstance(treeset, int):
                 tree[key] = IITreeSet((treeset, value))
-            elif isinstance(treeset, IISet):
+            else:
                 tree[key] = IITreeSet(treeset)
                 tree[key].insert(value)
-            else:
-                treeset.insert(value)
 
     def _insertForwardIndexEntry(self, since, until, documentId):
         """Insert 'documentId' into the appropriate set based on 'datum'.



More information about the checkins mailing list