Skip to content

Commit

Permalink
Improved handling of subtransactions. Should keep memory from
Browse files Browse the repository at this point in the history
ballooning beyong the capacity of the machine.  Note: while mass
indexing, the memory footprint of Zope will get huge.  There is NO way
around this.  incrimentally index if you want your process to stay small.
  • Loading branch information
Michel Pelletier committed Jun 30, 1999
1 parent daf15c1 commit 5732dc8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Catalog.py
Expand Up @@ -274,7 +274,7 @@ def delIndex(self, name):

# the cataloging API

def catalogObject(self, object, uid):
def catalogObject(self, object, uid, threshold=None):
"""
Adds an object to the Catalog by iteratively applying it
Expand Down Expand Up @@ -304,7 +304,7 @@ def catalogObject(self, object, uid):
total = 0
for x in self.indexes.values():
if hasattr(x, 'index_object'):
blah = x.index_object(i, object)
blah = x.index_object(i, object, threshold)
__traceback_info__=(`total`, `blah`)
total = total + blah

Expand Down
24 changes: 19 additions & 5 deletions ZCatalog.py
Expand Up @@ -159,7 +159,7 @@ def __init__(self,id,title=None):
self.id=id
self.title=title
self.threshold = 1000
self.total = 0
self._v_total = 0
self._catalog = Catalog()

self._catalog.addColumn('id')
Expand All @@ -176,7 +176,17 @@ def __init__(self,id,title=None):

self._catalog.addColumn('summary')
self._catalog.addIndex('PrincipiaSearchSource', 'TextIndex')


def manage_edit(self, threshold=1000, REQUEST=None):
""" edit the catalog """
self.threshold = threshold

message = "Object changed"
return self.manage_main(self, REQUEST,
manage_tabs_message=message)



def manage_catalogObject(self, REQUEST, urls=None, blah=None):
""" index all Zope objects that 'urls' point to """
Expand Down Expand Up @@ -251,7 +261,6 @@ def manage_catalogFoundItems(self, REQUEST, obj_metatypes=None,

""" Find object according to search criteria and Catalog them
"""

results = self.ZopeFind(REQUEST.PARENTS[1],
obj_metatypes=obj_metatypes,
obj_ids=obj_ids,
Expand Down Expand Up @@ -309,10 +318,15 @@ def manage_delIndexes(self, names, REQUEST):

def catalog_object(self, obj, uid):
""" wrapper around catalog """
self.total = self.total + self._catalog.catalogObject(obj, uid)
if self.total > self.threshold:
if not hasattr(self, '_v_total'):
self._v_total = 0
self._v_total = (self._v_total +
self._catalog.catalogObject(obj, uid, self.threshold))

if self._v_total > self.threshold:
print 'commiting in ZCatalog'
get_transaction().commit(1)
self.total = 0
self._v_total = 0


def uncatalog_object(self, uid):
Expand Down

0 comments on commit 5732dc8

Please sign in to comment.