[Zope-Checkins] CVS: Zope2 - PathIndex.py:1.1.2.7
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Tue, 8 May 2001 11:01:45 -0400
Update of /cvs-repository/Zope2/lib/python/SearchIndex
In directory serenade.digicool.com:/tmp/cvs-serv7816/lib/python/SearchIndex
Modified Files:
Tag: ajung-pathindex
PathIndex.py
Log Message:
internal rework
--- Updated File PathIndex.py in package Zope2 --
--- PathIndex.py 2001/05/08 14:34:38 1.1.2.6
+++ PathIndex.py 2001/05/08 15:01:44 1.1.2.7
@@ -85,7 +85,7 @@
from BTrees.IOBTree import IOBTree
from BTrees.OOBTree import OOBTree
-from BTrees.IIBTree import IISet
+from BTrees.IIBTree import IISet,difference,intersection
from Persistence import Persistent
from Acquisition import Implicit
from types import StringType
@@ -123,9 +123,9 @@
self._index[comp] = {}
if self._index[comp].has_key(level)==0:
- self._index[comp][level] = []
+ self._index[comp][level] = IISet()
- self._index[comp][level].append(id)
+ self._index[comp][level].insert(id)
# reverse index
if not self._unindex.has_key(id):
@@ -189,8 +189,9 @@
comps = self.splitPath(path)
- res = []
if level >=0:
+
+ results = []
for i in range(len(comps)):
comp = comps[i]
@@ -198,15 +199,13 @@
if not self._index.has_key(comp): return []
if not self._index[comp].has_key(level+i): return []
- if len(res)>0:
- for k in res:
- if not k in self._index[comp][level+i]:
- res.remove(k)
+ results.append( self._index[comp][level+i] )
- else:
- res.extend(self._index[comp][level+i])
+ res = results[0]
-
+ for i in range(1,len(results)):
+ res = intersection(res,results[i])
+
return res
else: