[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Reverse searching order; start with the presumably smaller specific set and work our way up to larger and large
Log message for revision 94047: Reverse searching order; start with the presumably smaller specific set and work our way up to larger and larger docid sets. This makes intersecting faster for most common index distributions. Changed: U Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py -=- Modified: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py === --- Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-13 23:01:27 UTC (rev 94046) +++ Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 10:42:56 UTC (rev 94047) @@ -178,7 +178,7 @@ return IISet(self._unindex.keys()) results = None -for i, comp in enumerate(comps): +for i, comp in reversed(list(enumerate(comps))): if not self._index.get(comp, {}).has_key(level+i): return IISet() results = intersection(results, self._index[comp][level+i]) return results ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Merge r94047 from trunk: speed optimisation in path index searching order
Log message for revision 94048: Merge r94047 from trunk: speed optimisation in path index searching order Changed: U Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py -=- Modified: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py === --- Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 10:42:56 UTC (rev 94047) +++ Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 10:44:26 UTC (rev 94048) @@ -181,7 +181,7 @@ return IISet(self._unindex.keys()) results = None -for i, comp in enumerate(comps): +for i, comp in reversed(list(enumerate(comps))): if not self._index.get(comp, {}).has_key(level+i): return IISet() results = intersection(results, self._index[comp][level+i]) return results ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Merge r94047 from trunk: speed optimisation in path index searching order
Log message for revision 94049: Merge r94047 from trunk: speed optimisation in path index searching order 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-14 10:44:26 UTC (rev 94048) +++ Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 10:45:29 UTC (rev 94049) @@ -184,7 +184,7 @@ return IISet(self._unindex.keys()) results = None -for i, comp in enumerate(comps): +for i, comp in reversed(list(enumerate(comps))): if not self._index.get(comp, {}).has_key(level+i): return IISet() results = intersection(results, self._index[comp][level+i]) return results ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Shortcut the case where the path searched for is longer than anything indexed.
Log message for revision 94050: Shortcut the case where the path searched for is longer than anything indexed. Changed: U Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py -=- Modified: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py === --- Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 10:45:29 UTC (rev 94049) +++ Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 13:25:30 UTC (rev 94050) @@ -173,6 +173,10 @@ for level in xrange(self._depth + 1)]) comps = filter(None, path.split('/')) + +if level + len(comps) - 1 self._depth: +# Our search is for a path longer than anything in the index +return IISet() if len(comps) == 0: return IISet(self._unindex.keys()) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Merge r94050 from trunk: shortcut for path-longer-than-anything-indexed case
Log message for revision 94051: Merge r94050 from trunk: shortcut for path-longer-than-anything-indexed case Changed: U Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py -=- Modified: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py === --- Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 13:25:30 UTC (rev 94050) +++ Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 13:27:14 UTC (rev 94051) @@ -176,6 +176,10 @@ for level in xrange(self._depth + 1)]) comps = filter(None, path.split('/')) + +if level + len(comps) - 1 self._depth: +# Our search is for a path longer than anything in the index +return IISet() if len(comps) == 0: return IISet(self._unindex.keys()) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py Merge r94050 from trunk: shortcut for path-longer-than-anything-indexed case
Log message for revision 94052: Merge r94050 from trunk: shortcut for path-longer-than-anything-indexed case 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-14 13:27:14 UTC (rev 94051) +++ Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/PathIndex.py 2008-12-14 13:27:33 UTC (rev 94052) @@ -179,6 +179,10 @@ for level in xrange(self._depth + 1)]) comps = filter(None, path.split('/')) + +if level + len(comps) - 1 self._depth: +# Our search is for a path longer than anything in the index +return IISet() if len(comps) == 0: return IISet(self._unindex.keys()) ___ Zope-Checkins maillist - Zope-Checkins@zope.org http://mail.zope.org/mailman/listinfo/zope-checkins
[Zope-Checkins] SVN: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py Simplify and cleanup the tests, including removing a double definition of the same test.
Log message for revision 94053: Simplify and cleanup the tests, including removing a double definition of the same test. Changed: U Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py -=- Modified: Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py === --- Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 13:27:33 UTC (rev 94052) +++ Zope/trunk/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 14:25:52 UTC (rev 94053) @@ -24,21 +24,13 @@ class Dummy: - -meta_type=foo - def __init__( self, path): self.path = path def getPhysicalPath(self): return self.path.split('/') -def __str__( self ): -return 'Dummy: %s' % self.path -__repr__ = __str__ - - class PathIndexTests(unittest.TestCase): Test PathIndex objects @@ -81,7 +73,7 @@ self.assertEqual(self._index.numObjects() ,0) self.assertEqual(self._index.getEntryForObject(1234), None) self._index.unindex_object( 1234 ) # nothrow -self.assertEqual(self._index._apply_index({suxpath:xxx}), None) +self.assertEqual(self._index._apply_index(dict(suxpath=xxx)), None) def testUnIndex(self): self._populateIndex() @@ -114,79 +106,49 @@ self._index.unindex_object(1) def testRoot(self): - self._populateIndex() -tests = ( (/,0, range(1,19)), ) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +queries = ( +dict(path=dict(query='/', level=0)), +dict(path=(('/', 0),)), +) +for q in queries: +res = self._index._apply_index(q) +self.assertEqual(list(res[0].keys()), range(1,19)) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -def testRoot(self): - -self._populateIndex() -tests = ( (/,0, range(1,19)), ) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - def testSimpleTests(self): - self._populateIndex() tests = [ +# component, level, expected results (aa, 0, [1,2,3,4,5,6,7,8,9]), (aa, 1, [1,2,3,10,11,12] ), (bb, 0, [10,11,12,13,14,15,16,17,18]), -(bb, 1, [4,5,6,13,14,15] ), -(bb/cc, 0, [16,17,18] ), -(bb/cc, 1, [6,15] ), -(bb/aa, 0, [10,11,12] ), -(bb/aa, 1, [4,13] ), -(aa/cc, -1, [3,7,8,9,12] ), -(bb/bb, -1, [5,13,14,15] ), -(18.html, 3, [18] ), -(18.html, -1, [18] ), -(cc/18.html, -1, [18] ), -(cc/18.html, 2, [18] ), +(bb, 1, [4,5,6,13,14,15]), +(bb/cc, 0, [16,17,18]), +(bb/cc, 1, [6,15]), +(bb/aa, 0, [10,11,12]), +(bb/aa, 1, [4,13]), +(aa/cc, -1, [3,7,8,9,12]), +(bb/bb, -1, [5,13,14,15]), +(18.html, 3, [18]), +(18.html, -1, [18]), +(cc/18.html, -1, [18]), +(cc/18.html, 2, [18]), ] -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +for comp, level, results in tests: +for path in [comp, /+comp, /+comp+/]: +# Test with the level passed in as separate parameter +res = self._index._apply_index(dict(path= +dict(query=path, level=level))) +self.assertEqual(list(res[0].keys()), results) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res =
[Zope-Checkins] SVN: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py Test cleanups from the trunk
Log message for revision 94054: Test cleanups from the trunk Changed: U Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py -=- Modified: Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py === --- Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 14:25:52 UTC (rev 94053) +++ Zope/branches/2.11/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 14:29:32 UTC (rev 94054) @@ -24,21 +24,13 @@ class Dummy: - -meta_type=foo - def __init__( self, path): self.path = path def getPhysicalPath(self): return self.path.split('/') -def __str__( self ): -return 'Dummy: %s' % self.path -__repr__ = __str__ - - class PathIndexTests(unittest.TestCase): Test PathIndex objects @@ -81,7 +73,7 @@ self.assertEqual(self._index.numObjects() ,0) self.assertEqual(self._index.getEntryForObject(1234), None) self._index.unindex_object( 1234 ) # nothrow -self.assertEqual(self._index._apply_index({suxpath:xxx}), None) +self.assertEqual(self._index._apply_index(dict(suxpath=xxx)), None) def testUnIndex(self): self._populateIndex() @@ -114,79 +106,49 @@ self._index.unindex_object(1) def testRoot(self): - self._populateIndex() -tests = ( (/,0, range(1,19)), ) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +queries = ( +dict(path=dict(query='/', level=0)), +dict(path=(('/', 0),)), +) +for q in queries: +res = self._index._apply_index(q) +self.assertEqual(list(res[0].keys()), range(1,19)) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -def testRoot(self): - -self._populateIndex() -tests = ( (/,0, range(1,19)), ) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - def testSimpleTests(self): - self._populateIndex() tests = [ +# component, level, expected results (aa, 0, [1,2,3,4,5,6,7,8,9]), (aa, 1, [1,2,3,10,11,12] ), (bb, 0, [10,11,12,13,14,15,16,17,18]), -(bb, 1, [4,5,6,13,14,15] ), -(bb/cc, 0, [16,17,18] ), -(bb/cc, 1, [6,15] ), -(bb/aa, 0, [10,11,12] ), -(bb/aa, 1, [4,13] ), -(aa/cc, -1, [3,7,8,9,12] ), -(bb/bb, -1, [5,13,14,15] ), -(18.html, 3, [18] ), -(18.html, -1, [18] ), -(cc/18.html, -1, [18] ), -(cc/18.html, 2, [18] ), +(bb, 1, [4,5,6,13,14,15]), +(bb/cc, 0, [16,17,18]), +(bb/cc, 1, [6,15]), +(bb/aa, 0, [10,11,12]), +(bb/aa, 1, [4,13]), +(aa/cc, -1, [3,7,8,9,12]), +(bb/bb, -1, [5,13,14,15]), +(18.html, 3, [18]), +(18.html, -1, [18]), +(cc/18.html, -1, [18]), +(cc/18.html, 2, [18]), ] -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +for comp, level, results in tests: +for path in [comp, /+comp, /+comp+/]: +# Test with the level passed in as separate parameter +res = self._index._apply_index(dict(path= +dict(query=path, level=level))) +self.assertEqual(list(res[0].keys()), results) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -
[Zope-Checkins] SVN: Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py Test cleanups from the trunk
Log message for revision 94055: Test cleanups from the trunk Changed: U Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py -=- Modified: Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py === --- Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 14:29:32 UTC (rev 94054) +++ Zope/branches/2.10/lib/python/Products/PluginIndexes/PathIndex/tests/testPathIndex.py 2008-12-14 14:30:03 UTC (rev 94055) @@ -24,21 +24,13 @@ class Dummy: - -meta_type=foo - def __init__( self, path): self.path = path def getPhysicalPath(self): return self.path.split('/') -def __str__( self ): -return 'Dummy: %s' % self.path -__repr__ = __str__ - - class PathIndexTests(unittest.TestCase): Test PathIndex objects @@ -81,7 +73,7 @@ self.assertEqual(self._index.numObjects() ,0) self.assertEqual(self._index.getEntryForObject(1234), None) self._index.unindex_object( 1234 ) # nothrow -self.assertEqual(self._index._apply_index({suxpath:xxx}), None) +self.assertEqual(self._index._apply_index(dict(suxpath=xxx)), None) def testUnIndex(self): self._populateIndex() @@ -114,79 +106,49 @@ self._index.unindex_object(1) def testRoot(self): - self._populateIndex() -tests = ( (/,0, range(1,19)), ) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +queries = ( +dict(path=dict(query='/', level=0)), +dict(path=(('/', 0),)), +) +for q in queries: +res = self._index._apply_index(q) +self.assertEqual(list(res[0].keys()), range(1,19)) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -def testRoot(self): - -self._populateIndex() -tests = ( (/,0, range(1,19)), ) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':( (path,level),)}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) - def testSimpleTests(self): - self._populateIndex() tests = [ +# component, level, expected results (aa, 0, [1,2,3,4,5,6,7,8,9]), (aa, 1, [1,2,3,10,11,12] ), (bb, 0, [10,11,12,13,14,15,16,17,18]), -(bb, 1, [4,5,6,13,14,15] ), -(bb/cc, 0, [16,17,18] ), -(bb/cc, 1, [6,15] ), -(bb/aa, 0, [10,11,12] ), -(bb/aa, 1, [4,13] ), -(aa/cc, -1, [3,7,8,9,12] ), -(bb/bb, -1, [5,13,14,15] ), -(18.html, 3, [18] ), -(18.html, -1, [18] ), -(cc/18.html, -1, [18] ), -(cc/18.html, 2, [18] ), +(bb, 1, [4,5,6,13,14,15]), +(bb/cc, 0, [16,17,18]), +(bb/cc, 1, [6,15]), +(bb/aa, 0, [10,11,12]), +(bb/aa, 1, [4,13]), +(aa/cc, -1, [3,7,8,9,12]), +(bb/bb, -1, [5,13,14,15]), +(18.html, 3, [18]), +(18.html, -1, [18]), +(cc/18.html, -1, [18]), +(cc/18.html, 2, [18]), ] -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -{path:{'query':path,level:level}}) -lst = list(res[0].keys()) -self.assertEqual(lst,results) +for comp, level, results in tests: +for path in [comp, /+comp, /+comp+/]: +# Test with the level passed in as separate parameter +res = self._index._apply_index(dict(path= +dict(query=path, level=level))) +self.assertEqual(list(res[0].keys()), results) -for comp,level,results in tests: -for path in [comp,/+comp,/+comp+/]: -res = self._index._apply_index( -