[Checkins] SVN: Products.ZCTextIndex/trunk/ Avoid changing data, if the indexed values stayed the same.
Hanno Schlichting
hannosch at hannosch.eu
Wed May 4 04:43:30 EDT 2011
Log message for revision 121541:
Avoid changing data, if the indexed values stayed the same.
Changed:
U Products.ZCTextIndex/trunk/CHANGES.txt
U Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/BaseIndex.py
U Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/OkapiIndex.py
-=-
Modified: Products.ZCTextIndex/trunk/CHANGES.txt
===================================================================
--- Products.ZCTextIndex/trunk/CHANGES.txt 2011-05-04 08:41:27 UTC (rev 121540)
+++ Products.ZCTextIndex/trunk/CHANGES.txt 2011-05-04 08:43:29 UTC (rev 121541)
@@ -4,6 +4,7 @@
2.13.2 (unreleased)
-------------------
+- Avoid changing data, if the indexed values stayed the same.
2.13.1 (2010-10-02)
-------------------
Modified: Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/BaseIndex.py
===================================================================
--- Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/BaseIndex.py 2011-05-04 08:41:27 UTC (rev 121540)
+++ Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/BaseIndex.py 2011-05-04 08:43:29 UTC (rev 121541)
@@ -19,7 +19,6 @@
from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IIBTree
-from BTrees.IIBTree import IIBucket
from BTrees.IIBTree import IITreeSet
from BTrees.IIBTree import difference
from BTrees.IIBTree import intersection
@@ -127,9 +126,11 @@
def _reindex_doc(self, docid, text):
# Touch as few docid->w(docid, score) maps in ._wordinfo as possible.
old_wids = self.get_words(docid)
+ new_wids = self._lexicon.sourceToWordIds(text)
+ if old_wids == new_wids:
+ return 0
+
old_wid2w, old_docw = self._get_frequencies(old_wids)
-
- new_wids = self._lexicon.sourceToWordIds(text)
new_wid2w, new_docw = self._get_frequencies(new_wids)
old_widset = IITreeSet(old_wid2w.keys())
Modified: Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/OkapiIndex.py
===================================================================
--- Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/OkapiIndex.py 2011-05-04 08:41:27 UTC (rev 121540)
+++ Products.ZCTextIndex/trunk/src/Products/ZCTextIndex/OkapiIndex.py 2011-05-04 08:43:29 UTC (rev 121541)
@@ -67,9 +67,11 @@
def unindex_doc(self, docid):
self._change_doc_len(-self._docweight[docid])
BaseIndex.unindex_doc(self, docid)
-
+
def _change_doc_len(self, delta):
# Change total doc length used for scoring
+ if delta == 0:
+ return
try:
self._totaldoclen.change(delta)
except AttributeError:
More information about the checkins
mailing list