summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3e0423a)
raw | patch | inline | side by side (parent: 3e0423a)
author | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 7 Oct 2010 12:02:12 +0000 (12:02 +0000) | ||
committer | schlatterbeck <schlatterbeck@57a73879-2fb5-44c3-a270-3262357dd7e2> | |
Thu, 7 Oct 2010 12:02:12 +0000 (12:02 +0000) |
backends, other backends shouldn't have that much data anyway.
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4537 57a73879-2fb5-44c3-a270-3262357dd7e2
git-svn-id: http://svn.roundup-tracker.org/svnroot/roundup/roundup/trunk@4537 57a73879-2fb5-44c3-a270-3262357dd7e2
CHANGES.txt | patch | blob | history | |
roundup/backends/rdbms_common.py | patch | blob | history |
diff --git a/CHANGES.txt b/CHANGES.txt
index 320e28d78ad12ee1588065ec64dbdce31a84f9cc..246023eee1882c5cf4773ed3ee683e416ca89a49 100644 (file)
--- a/CHANGES.txt
+++ b/CHANGES.txt
Thanks to Benni Bärmann for reporting.
- Allow search_popup macro to work with all db classes, issue2550567
(thanks John Kristensen)
+- lower memory footprint for (journal-) import -- only for rdbms
+ backends, other backends shouldn't have that much data anyway.
2010-07-12 1.4.15
index 912dd81134c06cf4b055d15b3f3ebcc03685464d..5b19850423333c96ca6dec326915f79c3a8d8b91 100644 (file)
def import_journals(self, entries):
"""Import a class's journal.
- Uses setjournal() to set the journal for each item."""
+ Uses setjournal() to set the journal for each item.
+ Strategy for import: Sort first by id, then import journals for
+ each id, this way the memory footprint is a lot smaller than the
+ initial implementation which stored everything in a big hash by
+ id and then proceeded to import journals for each id."""
properties = self.getprops()
- d = {}
+ a = []
for l in entries:
+ # first element in sorted list is the (numeric) id
+ # in python2.4 and up we would use sorted with a key...
+ a.append ((int (l [0].strip ("'")), l))
+ a.sort ()
+
+
+ last = 0
+ r = []
+ for n, l in a:
nodeid, jdate, user, action, params = map(eval, l)
- r = d.setdefault(nodeid, [])
+ assert (str(n) == nodeid)
+ if n != last:
+ if r:
+ self.db.setjournal(self.classname, nodeid, r)
+ last = n
+ r = []
+
if action == 'set':
for propname, value in params.iteritems():
prop = properties[propname]
# old tracker with data stored in the create!
params = {}
r.append((nodeid, date.Date(jdate), user, action, params))
-
- for nodeid, l in d.iteritems():
- self.db.setjournal(self.classname, nodeid, l)
+ if r:
+ self.db.setjournal(self.classname, nodeid, r)
class FileClass(hyperdb.FileClass, Class):
"""This class defines a large chunk of data. To support this, it has a