[Zope-Checkins] CVS: Zope/lib/python/Products/ZCTextIndex - Lexicon.py:1.18.26.3

Casey Duncan casey@zope.com
Thu, 5 Jun 2003 11:01:41 -0400


Update of /cvs-repository/Zope/lib/python/Products/ZCTextIndex
In directory cvs.zope.org:/tmp/cvs-serv12170

Modified Files:
      Tag: casey-zctextindex-fewer-conflicts-branch
	Lexicon.py 
Log Message:
Further minimize the chance of write conflicts in the lexicon by making sure the length counter gets reloaded from the database when a new batch of words is added. Another option would be to generate randomized wids, but this would undo a core optimization of the indexes.
Improved the tests to exercise this improvement and make sure the data gets saved as expected.


=== Zope/lib/python/Products/ZCTextIndex/Lexicon.py 1.18.26.2 => 1.18.26.3 ===
--- Zope/lib/python/Products/ZCTextIndex/Lexicon.py:1.18.26.2	Wed Jun  4 23:51:53 2003
+++ Zope/lib/python/Products/ZCTextIndex/Lexicon.py	Thu Jun  5 11:01:11 2003
@@ -59,6 +59,10 @@
         last = _text2list(text)
         for element in self._pipeline:
             last = element.process(last)
+        # Strategically unload the length value so that we get the most
+        # recent value written to the database to minimize conflicting wids
+        # XXX this will not work when MVCC is implemented in the ZODB...
+        self.length._p_deactivate()
         return map(self._getWordIdCreate, last)
 
     def termToWordIds(self, text):
@@ -124,7 +128,7 @@
                 wids.append(self._wids[key])
         return wids
 
-    def _getWordIdCreate(self, word):
+    def _getWordIdCreate(self, word):k
         wid = self._wids.get(word)
         if wid is None:
             wid = self._new_wid()