[Checkins] SVN: zc.FileStorage/dev/src/zc/FileStorage/__init__.py Added option to disable gc (temporarily by default). This will

Jim Fulton jim at zope.com
Tue Dec 18 12:44:07 EST 2007


Log message for revision 82334:
  Added option to disable gc (temporarily by default).  This will
  eventually be configurable -- somehow. :)
  

Changed:
  U   zc.FileStorage/dev/src/zc/FileStorage/__init__.py

-=-
Modified: zc.FileStorage/dev/src/zc/FileStorage/__init__.py
===================================================================
--- zc.FileStorage/dev/src/zc/FileStorage/__init__.py	2007-12-18 16:09:48 UTC (rev 82333)
+++ zc.FileStorage/dev/src/zc/FileStorage/__init__.py	2007-12-18 17:44:07 UTC (rev 82334)
@@ -292,17 +292,18 @@
         self._freecache(pos)
         return FileStoragePacker._read_txn_header(self, pos, tid)
 
-    def pack(self):
+    def pack(self, do_gc=False):
         packed, index, references, packpos = self.buildPackIndex(
-            self._stop, self.file_end)
+            self._stop, self.file_end, do_gc)
         if packed:
             # nothing to do
             self._file.close()
             return
-        
-        self.updateReferences(references, packpos, self.file_end)
-        index = self.gc(index, references)
 
+        if do_gc:
+            self.updateReferences(references, packpos, self.file_end)
+            index = self.gc(index, references)
+
         output = OptionalSeekFile(self._name + ".pack", "w+b")
         output._freecache = _freefunc(output)
         index, new_pos = self.copyToPacktime(packpos, index, output)
@@ -325,11 +326,16 @@
         self._file.close()
 
 
-    def buildPackIndex(self, stop, file_end):
-        index = ZODB.fsIndex.fsIndex()
+    def buildPackIndex(self, stop, file_end, do_gc):
+        index = ZODB.fsIndex.fsIndex()        
         references = BTrees.LOBTree.LOBTree()
         pos = 4L
         packed = True
+        if do_gc:
+            update_refs = self._update_refs
+        else:
+            update_refs = lambda dh, references: None
+            
         while pos < file_end:
             th = self._read_txn_header(pos)
             if th.tid > stop:
@@ -348,7 +354,7 @@
                 if dh.version:
                     self.fail(pos, "Versions are not supported")
                 index[dh.oid] = pos
-                self._update_refs(dh, references)
+                update_refs(dh, references)
                 pos += dh.recordlen()
 
             tlen = self._read_num(pos)



More information about the Checkins mailing list