[Zodb-checkins] CVS: ZODB4/src/zodb/storage - file.py:1.8.4.2

Barry Warsaw barry@wooz.org
Mon, 10 Mar 2003 14:36:52 -0500


Update of /cvs-repository/ZODB4/src/zodb/storage
In directory cvs.zope.org:/tmp/cvs-serv14790

Modified Files:
      Tag: opaque-pickles-branch
	file.py 
Log Message:
More implementation efforts toward fragrance-free pickles.

This doesn't work yet.


=== ZODB4/src/zodb/storage/file.py 1.8.4.1 => 1.8.4.2 === (929/1029 lines abridged)
--- ZODB4/src/zodb/storage/file.py:1.8.4.1	Mon Feb 10 18:12:47 2003
+++ ZODB4/src/zodb/storage/file.py	Mon Mar 10 14:36:51 2003
@@ -19,7 +19,7 @@
 
   In this section, the first two bytes are the characters F and S.
 
-  The next two bytes are a storage format version id, currently "01".
+  The next two bytes are a storage format version id, currently "42".
 
   The next section is a four-byte database version string, encoded as
   byte 0: major version number
@@ -67,6 +67,8 @@
 
   - 2-byte version length
 
+  - 4-byte number of object references (oids)
+
   - 8-byte data length
 
   ? 8-byte position of non-version data
@@ -75,11 +77,11 @@
   ? 8-byte position of previous record in this version
     (if version length > 0)
 
-  ?   version string
-    (if version length > 0)
+  ? version string (if version length > 0)
 
-  ?   data
-    (data length > 0)
+  ? reference oids (length == # of oids * 8)
+
+  ? data (if data length > 0)
 
   ? 8-byte position of data record containing data
     (data length == 0)
@@ -146,11 +148,10 @@
     fsync = None
 
 import zodb.db
-from zodb.storage.base import BaseStorage
+from zodb.storage.base import BaseStorage, splitrefs
 from zodb import conflict
 from zodb import interfaces
 from zodb.interfaces import UndoError, POSKeyError, MultipleUndoErrors
-from zodb.serialize import findrefs
 from zodb.timestamp import TimeStamp, newTimeStamp, timeStampFromTime
 from zodb.lockfile import lock_file
 from zodb.utils import p64, u64, cp
@@ -161,11 +162,11 @@

[-=- -=- -=- 929 lines omitted -=- -=- -=-]

-    
-    def __init__(self, *args):
-        self.oid, self.serial, self.version, self.data, self.data_txn = args
+
+    def __init__(self, oid, serial, version, data, data_txn, refs):
+        self.oid = oid
+        self.serial = serial
+        self.version = version
+        self.data = data
+        self.data_txn = data_txn
+        self.refs = refs
 
 class UndoSearch:
 
@@ -2446,19 +2168,21 @@
 class DataHeader:
     """Header for a data record."""
 
-    __slots__ = ("oid", "serial", "prev", "tloc", "vlen", "plen", "back",
-                 # These three attributes are only defined when vlen > 0
-                 "pnv", "vprev", "version")
+    __slots__ = (
+        "oid", "serial", "prev", "tloc", "vlen", "plen", "nrefs", "back",
+        # These three attributes are only defined when vlen > 0
+        "pnv", "vprev", "version")
 
     version = ""
     back = 0
 
-    def __init__(self, oid, serial, prev, tloc, vlen, plen):
+    def __init__(self, oid, serial, prev, tloc, vlen, nrefs, plen):
         self.oid = oid
         self.serial = serial
         self.prev = prev
         self.tloc = tloc
         self.vlen = vlen
+        self.nrefs = nrefs
         self.plen = plen
 
     def fromString(cls, s):
@@ -2469,6 +2193,9 @@
     def parseVersion(self, buf):
         self.pnv, self.vprev = struct.unpack(">QQ", buf[:16])
         self.version = buf[16:]
+
+    def datalen(self):
+        return DATA_HDR_LEN + (self.nrefs * 8) + (self.plen or 8)
 
 
 def cleanup(filename):