[Zope-Checkins] CVS: Zope/lib/python/Products/PluginIndexes/common - PluggableIndex.py:1.7.30.2 UnIndex.py:1.15.14.4

Andreas Jung andreas@andreas-jung.com
Thu, 23 Jan 2003 12:33:13 -0500


Update of /cvs-repository/Zope/lib/python/Products/PluginIndexes/common
In directory cvs.zope.org:/tmp/cvs-serv17553/common

Modified Files:
      Tag: ajung-oneindex-multipleattributes-branch
	PluggableIndex.py UnIndex.py 
Log Message:
merge from HEAD

=== Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py 1.7.30.1 => 1.7.30.2 ===
--- Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py:1.7.30.1	Sun Nov 17 03:17:38 2002
+++ Zope/lib/python/Products/PluginIndexes/common/PluggableIndex.py	Thu Jan 23 12:33:09 2003
@@ -11,7 +11,7 @@
 #
 ##############################################################################
 
-"""Pluggable Index Base Class """
+"""Pluggable Index Interface"""
 __version__='$Revision$'[11:-2]
 
 import Interface
@@ -41,14 +41,6 @@
     def unindex_object(documentId):
         """Remove the documentId from the index."""
 
-    # XXX TextIndex does not implement uniqueValues().
-    def uniqueValues(name=None, withLengths=0):
-        """Returns the unique values for name.
-
-        If 'withLengths' is true, returns a sequence of tuples of
-        (value, length).
-        """
-
     def _apply_index(request, cid=''):
         """Apply the index to query parameters given in 'request'.
 
@@ -72,3 +64,34 @@
         records.  The second object is a tuple containing the names of
         all data fields used.
         """
+    
+    def numObjects():
+        """Return the number of indexed objects"""
+    
+    def clear():
+        """Empty the index"""
+        
+class UniqueValueIndex(PluggableIndexInterface):
+    """An index which can return lists of unique values contained in it"""
+    
+    def hasUniqueValuesFor(name):
+        """Return true if the index can return the unique values for name"""
+        
+    def uniqueValues(name=None, withLengths=0):
+        """Return the unique values for name.
+
+        If 'withLengths' is true, returns a sequence of tuples of
+        (value, length)."""
+
+class SortIndex(PluggableIndexInterface):
+    """An index which may be used to sort a set of document ids"""
+    
+    def keyForDocument(documentId):
+        """Return the sort key that cooresponds to the specified document id
+        
+        This method is no longer used by ZCatalog, but is left for backwards 
+        compatibility."""
+        
+    def documentToKeyMap():
+        """Return an object that supports __getitem__ and may be used to quickly
+        lookup the sort key given a document id"""


=== Zope/lib/python/Products/PluginIndexes/common/UnIndex.py 1.15.14.3 => 1.15.14.4 ===
--- Zope/lib/python/Products/PluginIndexes/common/UnIndex.py:1.15.14.3	Wed Nov 27 11:24:36 2002
+++ Zope/lib/python/Products/PluginIndexes/common/UnIndex.py	Thu Jan 23 12:33:09 2003
@@ -409,7 +409,7 @@
             return r, (self.id,)
 
     def hasUniqueValuesFor(self, name):
-        ' has unique values for column NAME '
+        """has unique values for column name"""
         if name == self.id:
             return 1
         else:
@@ -450,11 +450,15 @@
                 else:
                     l = len(set)
                 rl.append((i, l))
-            return tuple(rl)
+            return tuple(rl)        
 
     def keyForDocument(self, id):
+        # This method is superceded by documentToKeyMap
         return self._unindex[id]
-
+    
+    def documentToKeyMap(self):
+        return self._unindex
+    
     def items(self):
         items = []
         for k,v in self._index.items():