[Zope-Checkins] CVS: ZODB3/ZODB - FileStorage.py:1.105.2.12

Jeremy Hylton jeremy@zope.com
Tue, 7 Jan 2003 12:44:08 -0500


Update of /cvs-repository/ZODB3/ZODB
In directory cvs.zope.org:/tmp/cvs-serv1665/ZODB

Modified Files:
      Tag: ZODB3-3_1-branch
	FileStorage.py 
Log Message:
Enable BTree-based fsIndex.


=== ZODB3/ZODB/FileStorage.py 1.105.2.11 => 1.105.2.12 ===
--- ZODB3/ZODB/FileStorage.py:1.105.2.11	Wed Dec 18 16:20:05 2002
+++ ZODB3/ZODB/FileStorage.py	Tue Jan  7 12:43:32 2003
@@ -318,7 +318,7 @@
 
     def _newIndexes(self):
         # hook to use something other than builtin dict
-        return {}, {}, {}, {}
+        return fsIndex(), {}, {}, {}
 
     _saved = 0
     def _save_index(self):
@@ -452,6 +452,24 @@
         if index is None or pos is None or oid is None or vindex is None:
             return None
         pos = long(pos)
+
+        if type(index) is type({}) and (not self._is_read_only):
+            # Convert to fsIndex
+            newindex = fsIndex()
+            if type(newindex) is not type(index):
+                # And we have fsIndex
+                newindex.update(index)
+
+                # Now save the index
+                f=open(index_name,'wb')
+                p=Pickler(f,1)
+                info['index'] = newindex
+                p.dump(info)
+                f.close()
+
+                # Now call this method again to get the new data
+                return self._restore_index()
+
         tid=self._sane(index, pos)
         if not tid: return None