Log message for revision 94036: Port improvements from ExtendedPathIndex: - The level < 0 case is basically the union of all searches for levels 0 through to max. Just call search() for each level and use multiunion on all the results. - Shorten the 'no-such-path' detection to one test.
Changed: U Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py -=- Modified: Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py =================================================================== --- Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-13 18:48:01 UTC (rev 94035) +++ Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-13 18:48:34 UTC (rev 94036) @@ -22,7 +22,7 @@ from OFS.SimpleItem import SimpleItem from BTrees.IOBTree import IOBTree from BTrees.OOBTree import OOBTree -from BTrees.IIBTree import IITreeSet, IISet, intersection, union +from BTrees.IIBTree import IITreeSet, IISet, intersection, union, multiunion from BTrees.Length import Length from zope.interface import implements @@ -171,6 +171,12 @@ else: level = int(path[1]) path = path[0] + + if level < 0: + # Search at every level, return the union of all results + return multiunion( + [self.search(path, level) + for level in xrange(self._depth + 1)]) comps = filter(None, path.split('/')) @@ -178,22 +184,9 @@ return IISet(self._unindex.keys()) results = None - if level >= 0: - for i, comp in enumerate(comps): - if not self._index.has_key(comp): return IISet() - if not self._index[comp].has_key(level+i): return IISet() - results = intersection(results, self._index[comp][level+i]) - - else: - for level in range(self._depth + 1): - ids = None - for i, comp in enumerate(comps): - try: - ids = intersection(ids, self._index[comp][level+i]) - except KeyError: - break - else: - results = union(results, ids) + for i, comp in enumerate(comps): + if not self._index.get(comp, {}).has_key(level+i): return IISet() + results = intersection(results, self._index[comp][level+i]) return results def numObjects(self): _______________________________________________ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins