Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Slightly optimize reindexing an object by passing in information from…

… the index to the unindex method and avoiding another unindex scan.

svn path=/Products.ExtendedPathIndex/trunk/; revision=40266
  • Loading branch information...
commit 39cd18a4a9c95fdd70195fba61775517210719e3 1 parent 795a6cc
@hannosch hannosch authored
Showing with 15 additions and 8 deletions.
  1. +4 −0 CHANGES.txt
  2. +11 −8 Products/ExtendedPathIndex/ExtendedPathIndex.py
View
4 CHANGES.txt
@@ -4,6 +4,10 @@ Changelog
3.0a1 - unreleased
------------------
+* Slightly optimize reindexing an object by passing in information from the
+ index to the unindex method and avoiding another unindex scan.
+ [hannosch]
+
* Avoid an extra unindex scan for determining length changes in index_object.
[hannosch]
View
19 Products/ExtendedPathIndex/ExtendedPathIndex.py
@@ -105,7 +105,7 @@ def index_object(self, docid, obj, threshold=100):
old_path = self._unindex.get(docid, _marker)
if old_path is not _marker:
if old_path != path:
- self.unindex_object(docid)
+ self.unindex_object(docid, _old=old_path)
# unindex reduces length, we need to counter that
self._length.change(1)
else:
@@ -130,15 +130,18 @@ def index_object(self, docid, obj, threshold=100):
self._unindex[docid] = path
return 1
- def unindex_object(self, docid):
+ def unindex_object(self, docid, _old=_marker):
""" hook for (Z)Catalog """
- old_value = self._unindex.get(docid, _marker)
- if old_value is _marker:
- logger.log(logging.INFO,
- 'Attempt to unindex nonexistent object with id '
- '%s' % docid)
- return
+ if _old is not _marker:
+ old_value = _old
+ else:
+ old_value = self._unindex.get(docid, _marker)
+ if old_value is _marker:
+ logger.log(logging.INFO,
+ 'Attempt to unindex nonexistent object with id '
+ '%s' % docid)
+ return
# There is an assumption that paths start with /
comps = filter(None, old_value.split('/'))
Please sign in to comment.
Something went wrong with that request. Please try again.