[Zope3-checkins] CVS: Zope3/src/zope/fieldindex - fieldindex.py:1.10 ifieldindex.py:NONE
Andy Hird
andyh@ekit-inc.com
Sun, 13 Jul 2003 01:51:44 -0400
Update of /cvs-repository/Zope3/src/zope/fieldindex
In directory cvs.zope.org:/tmp/cvs-serv24050/src/zope/fieldindex
Modified Files:
fieldindex.py
Removed Files:
ifieldindex.py
Log Message:
Index-Interface-Geddon. Moving all the index interfaces to
zope.index.interfaces
As part of this we removed several duplicate interfaces and cleaned up
some existing ones. Most users of index interfaces should only need
zope.index.interfaces.index
=== Zope3/src/zope/fieldindex/fieldindex.py 1.9 => 1.10 ===
--- Zope3/src/zope/fieldindex/fieldindex.py:1.9 Tue Jun 3 11:45:09 2003
+++ Zope3/src/zope/fieldindex/fieldindex.py Sun Jul 13 01:51:08 2003
@@ -20,14 +20,16 @@
from zodb.btrees.OOBTree import OOBTree
from zodb.btrees.IIBTree import IITreeSet, IISet, union
-from zope.fieldindex.ifieldindex import IFieldIndex
from types import ListType, TupleType
from zope.interface import implements
+from zope.index.interfaces.index import IInjection, IQuerying, IStatistics, \
+ IRangeQuerying
+
class FieldIndex(Persistent):
- implements(IFieldIndex)
+ implements(IRangeQuerying, IInjection, IQuerying, IStatistics)
def __init__(self):
self.clear()
@@ -40,19 +42,25 @@
self._rev_index = IOBTree()
def documentCount(self):
- """Return the number of documents in the index."""
+ """See interface IStatistics"""
return len(self._rev_index)
+ def wordCount(self):
+ """See interface IStatistics"""
+ return len(self._fwd_index)
+
def has_doc(self, docid):
return bool(self._rev_index.has_key(docid))
def index_doc(self, docid, value):
+ """See interface IInjection"""
if self.has_doc(docid): # unindex doc if present
self.unindex_doc(docid)
self._insert_forward(docid, value)
self._insert_reverse(docid, value)
def unindex_doc(self, docid):
+ """See interface IInjection"""
try: # ignore non-existing docids, don't raise
value = self._rev_index[docid]
except KeyError:
@@ -86,6 +94,13 @@
result = IISet()
return result
+
+ def query(self, querytext, start=0, count=None):
+ """See interface IQuerying"""
+ res = self.search(querytext)
+ if start or count:
+ res = res[start:start+count]
+ return res
def rangesearch(self, minvalue, maxvalue):
return IISet(self._fwd_index.keys(minvalue, maxvalue))
=== Removed File Zope3/src/zope/fieldindex/ifieldindex.py ===