Skip to content

Commit

Permalink
Added subtransactions and word counting. Every n words, the Catalog
Browse files Browse the repository at this point in the history
will commit to a subtransaction, thus keeping memory consumption
down.
  • Loading branch information
Michel Pelletier committed Jun 30, 1999
1 parent d2932fe commit 3b91851
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
7 changes: 6 additions & 1 deletion Catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,16 @@ def catalogObject(self, object, uid):
# meta_data is stored as a tuple for efficiency
data[i] = self.recordify(object)

total = 0
for x in self.indexes.values():
if hasattr(x, 'index_object'):
x.index_object(i, object)
blah = x.index_object(i, object)
__traceback_info__=(`total`, `blah`)
total = total + blah

self.data = data

return total


def uncatalogObject(self, uid):
Expand Down
12 changes: 9 additions & 3 deletions ZCatalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ class ZCatalog(Folder, FindSupport, Persistent, Implicit):
def __init__(self,id,title=None):
self.id=id
self.title=title
self.threshold = 1000
self.total = 0
self._catalog = Catalog()

self._catalog.addColumn('id')
Expand Down Expand Up @@ -250,7 +252,7 @@ def manage_catalogFoundItems(self, REQUEST, obj_metatypes=None,
""" Find object according to search criteria and Catalog them
"""

results = self.ZopeFind(REQUEST.PARENTS[-1],
results = self.ZopeFind(REQUEST.PARENTS[1],
obj_metatypes=obj_metatypes,
obj_ids=obj_ids,
obj_searchterm=obj_searchterm,
Expand Down Expand Up @@ -307,8 +309,12 @@ def manage_delIndexes(self, names, REQUEST):

def catalog_object(self, obj, uid):
""" wrapper around catalog """

self._catalog.catalogObject(obj, uid)
print 'about to catalog %s' % uid
self.total = self.total + self._catalog.catalogObject(obj, uid)
if self.total > self.threshold:
print 'about to commit'
get_transaction().commit(1)
self.total = 0


def uncatalog_object(self, uid):
Expand Down

0 comments on commit 3b91851

Please sign in to comment.