Commit 539ea3a2 authored by Casey Duncan's avatar Casey Duncan

Port performance fix for UnIndex.numObjects()

parent 92b5652c
......@@ -12,7 +12,6 @@
##############################################################################
import os, sys, unittest
import ZODB
from Products.PluginIndexes.FieldIndex.FieldIndex import FieldIndex
......@@ -93,6 +92,7 @@ class TestCase( unittest.TestCase ):
assert len( self._index ) == 0
assert len( self._index.referencedObjects() ) == 0
self.assertEqual(self._index.numObjects(), 0)
assert self._index.getEntryForObject( 1234 ) is None
assert ( self._index.getEntryForObject( 1234, self._marker )
......@@ -116,6 +116,7 @@ class TestCase( unittest.TestCase ):
assert len( self._index ) == len( values )-1 #'abce' is duplicate
assert len( self._index.referencedObjects() ) == len( values )
self.assertEqual(self._index.numObjects(), len( values )-1)
assert self._index.getEntryForObject( 1234 ) is None
assert ( self._index.getEntryForObject( 1234, self._marker )
......
......@@ -114,6 +114,7 @@ class TestKeywordIndex( unittest.TestCase ):
def testEmpty( self ):
assert len( self._index ) == 0
assert len( self._index.referencedObjects() ) == 0
self.assertEqual(self._index.numObjects(), 0)
assert self._index.getEntryForObject( 1234 ) is None
assert ( self._index.getEntryForObject( 1234, self._marker )
......@@ -141,6 +142,7 @@ class TestKeywordIndex( unittest.TestCase ):
assert ( self._index.getEntryForObject( 1234, self._marker )
is self._marker )
self._index.unindex_object( 1234 ) # nothrow
self.assertEqual(self._index.numObjects(), len( values )-1)
for k, v in values:
entry = self._index.getEntryForObject( k )
......
......@@ -12,16 +12,13 @@
##############################################################################
"""Base for bi-directional indexes
$Id: UnIndex.py,v 1.24 2004/04/23 15:04:24 caseman Exp $"""
$Id: UnIndex.py,v 1.25 2004/04/23 15:47:33 caseman Exp $"""
import sys
from cgi import escape
from logging import getLogger
from types import StringType, ListType, IntType, TupleType
from Globals import Persistent
from Acquisition import Implicit
from BTrees.OOBTree import OOBTree, OOSet
from BTrees.IOBTree import IOBTree
from BTrees.IIBTree import IITreeSet, IISet, union, intersection
......@@ -34,7 +31,7 @@ from Products.PluginIndexes.common import safe_callable
_marker = []
LOG = getLogger('Zope.UnIndex')
class UnIndex(Persistent, Implicit, SimpleItem):
class UnIndex(SimpleItem):
"""Simple forward and reverse index"""
def __init__(
......@@ -292,7 +289,7 @@ class UnIndex(Persistent, Implicit, SimpleItem):
def numObjects(self):
""" return number of indexed objects """
return len(self._unindex)
return len(self)
def unindex_object(self, documentId):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment