[Zodb-checkins] CVS: ZODB4/bsddb3Storage - BDBFullStorage.py:1.57 BDBMinimalStorage.py:1.21 BerkeleyBase.py:1.30

Barry Warsaw barry@wooz.org
Wed, 4 Dec 2002 12:11:23 -0500


Update of /cvs-repository/ZODB4/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv16518

Modified Files:
	BDBFullStorage.py BDBMinimalStorage.py BerkeleyBase.py 
Log Message:
Affect all the cosmetic changes from zodb3 -> zodb4, such as:

- referencesf is replaced by Serializ.findrefs

- U64 -> u64

- remove the referencesf argument from pack()

- PersistentMapping -> PersistentDict

Also, make the class names mirror the change to the module name.


=== ZODB4/bsddb3Storage/BDBFullStorage.py 1.56 => 1.57 ===
--- ZODB4/bsddb3Storage/BDBFullStorage.py:1.56	Tue Dec  3 14:12:34 2002
+++ ZODB4/bsddb3Storage/BDBFullStorage.py	Wed Dec  4 12:11:22 2002
@@ -29,8 +29,8 @@
 from bsddb3 import db
 
 from ZODB import POSException
-from ZODB.utils import p64, U64
-from ZODB.referencesf import referencesf
+from ZODB.utils import p64, u64
+from ZODB.Serialize import findrefs
 from ZODB.TimeStamp import TimeStamp
 from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
 
@@ -56,7 +56,7 @@
 except ImportError:
     # Python 2.1
     def incr(refcount, delta):
-        return p64(U64(refcount) + delta)
+        return p64(u64(refcount) + delta)
 
 try:
     True, False
@@ -66,7 +66,7 @@
 
 
 
-class Full(BerkeleyBase, ConflictResolvingStorage):
+class BDBFullStorage(BerkeleyBase, ConflictResolvingStorage):
     def _setupDBs(self):
         # Data Type Assumptions:
         #
@@ -241,7 +241,7 @@
         # Set up the autopacking thread
         config = self._config
         if config.frequency > 0:
-            lastpacktime = U64(self._last_packtime())
+            lastpacktime = u64(self._last_packtime())
             self._autopacker = _Autopack(
                 self, config.frequency,
                 config.packtime, config.classicpack,
@@ -288,7 +288,7 @@
             # Convert to a Python long integer.  Note that cursor.last()
             # returns key/value, and we want the key (which for the
             # versions table is the vid).
-            self.__nextvid = U64(rec[0])
+            self.__nextvid = u64(rec[0])
         else:
             self.__nextvid = 0L
         # Initialize the last transaction
@@ -518,7 +518,7 @@
                 # than the version the current revision is on.  Nuh uh.
                 raise POSException.VersionLockError(
                     'version mismatch for object %s (was: %s, got: %s)' %
-                    tuple(map(U64, (oid, ovid, vid))))
+                    tuple(map(u64, (oid, ovid, vid))))
             else:
                 # We're making another change to this object on this version.
                 # The non-version revid is the same as for the previous
@@ -1332,12 +1332,7 @@
     #
 
     # First, the public API for classic pack
-    def pack(self, t, zreferencesf):
-        # For all intents and purposes, referencesf here is always going to be
-        # the same as ZODB.referencesf.referencesf.  It's too much of a PITA
-        # to pass that around to the helper methods, so just assert they're
-        # the same.
-        assert zreferencesf == referencesf
+    def pack(self, t):
         self.log('classic pack started')
         # A simple wrapper around the bulk of packing, but which acquires a
         # lock that prevents multiple packs from running at the same time.
@@ -1477,7 +1472,7 @@
             # There is no pickle data
             return
         key = oid + lrevid
-        refcount = U64(self._pickleRefcounts.get(key, ZERO)) - 1
+        refcount = u64(self._pickleRefcounts.get(key, ZERO)) - 1
         assert refcount >= 0
         if refcount == 0:
             # We can collect this pickle
@@ -1492,7 +1487,7 @@
 
     def _decref(self, deltas, txn):
         for oid, delta in deltas.items():
-            refcount = U64(self._refcounts.get(oid, ZERO)) + delta
+            refcount = u64(self._refcounts.get(oid, ZERO)) + delta
             if refcount > 0:
                 self._refcounts.put(oid, p64(refcount), txn=txn)
             else:
@@ -1624,10 +1619,7 @@
                     data = self._pickles[oid+lrevid]
                     # Now get the oids of all the objects referenced by this
                     # pickle
-                    refdoids = []
-                    referencesf(data, refdoids)
-                    # And append them to the queue for later
-                    for oid in refdoids:
+                    for oid in findrefs(data):
                         self._oidqueue.append(oid, txn)
             # Pop the next oid off the queue and do it all again
             rec = self._oidqueue.consume(txn)


=== ZODB4/bsddb3Storage/BDBMinimalStorage.py 1.20 => 1.21 ===
--- ZODB4/bsddb3Storage/BDBMinimalStorage.py:1.20	Tue Dec  3 14:10:09 2002
+++ ZODB4/bsddb3Storage/BDBMinimalStorage.py	Wed Dec  4 12:11:22 2002
@@ -26,8 +26,8 @@
 from bsddb3 import db
 
 from ZODB import POSException
-from ZODB.utils import U64, p64
-from ZODB.referencesf import referencesf
+from ZODB.utils import u64, p64
+from ZODB.Serialize import findrefs
 from ZODB.ConflictResolution import ConflictResolvingStorage, ResolvedSerial
 
 # BerkeleyBase class provides some common functionality for BerkeleyDB-based
@@ -54,7 +54,7 @@
 
 
 
-class Minimal(BerkeleyBase, ConflictResolvingStorage):
+class BDBMinimalStorage(BerkeleyBase, ConflictResolvingStorage):
     def _setupDBs(self):
         # Data Type Assumptions:
         #
@@ -216,7 +216,7 @@
     def _update_refcounts(self, deltas, txn):
         newdeltas = {}
         for oid, delta in deltas.items():
-            refcount = U64(self._refcounts.get(oid, ZERO, txn=txn)) + delta
+            refcount = u64(self._refcounts.get(oid, ZERO, txn=txn)) + delta
             assert refcount >= 0
             if refcount == 0:
                 # The reference count for this object has just gone to zero,
@@ -358,12 +358,7 @@
     # object cycles, since there are no old object revisions.
     #
 
-    def pack(self, t, zreferencesf):
-        # For all intents and purposes, referencesf here is always going to be
-        # the same as ZODB.referencesf.referencesf.  It's too much of a PITA
-        # to pass that around to the helper methods, so just assert they're
-        # the same.
-        assert zreferencesf == referencesf
+    def pack(self, t):
         self.log('classic pack started')
         # A simple wrapper around the bulk of packing, but which acquires a
         # lock that prevents multiple packs from running at the same time.
@@ -435,12 +430,7 @@
                 # will be None.
                 if tid is not None:
                     data = self._pickles[oid+tid]
-                    # Now get the oids of all the objects referenced by this
-                    # pickle
-                    refdoids = []
-                    referencesf(data, refdoids)
-                    # And append them to the queue for later
-                    for oid in refdoids:
+                    for oid in findrefs(data):
                         self._oidqueue.append(oid, txn)
             # Pop the next oid off the queue and do it all again
             rec = self._oidqueue.consume(txn)
@@ -509,7 +499,7 @@
                     deltas = {}
                     self._update(deltas, data, -1)
                     for oid, delta in deltas.items():
-                        refcount = U64(self._refcounts.get(oid, ZERO)) + delta
+                        refcount = u64(self._refcounts.get(oid, ZERO)) + delta
                         if refcount <= 0:
                             self._oidqueue.append(oid, txn)
                         else:
@@ -553,4 +543,4 @@
 
     def _dowork(self, now):
         # Run the autopack phase
-        self._storage.pack('ignored', referencesf)
+        self._storage.pack('ignored')


=== ZODB4/bsddb3Storage/BerkeleyBase.py 1.29 => 1.30 ===
--- ZODB4/bsddb3Storage/BerkeleyBase.py:1.29	Tue Dec  3 14:13:42 2002
+++ ZODB4/bsddb3Storage/BerkeleyBase.py	Wed Dec  4 12:11:22 2002
@@ -31,7 +31,7 @@
 from ZODB import POSException
 from ZODB.lock_file import lock_file
 from ZODB.BaseStorage import BaseStorage
-from ZODB.referencesf import referencesf
+from ZODB.Serialize import findrefs
 import ThreadLock
 import zLOG
 
@@ -361,9 +361,7 @@
         os.unlink(lockfile)
 
     def _update(self, deltas, data, incdec):
-        refdoids = []
-        referencesf(data, refdoids)
-        for oid in refdoids:
+        for oid in findrefs(data):
             rc = deltas.get(oid, 0) + incdec
             if rc == 0:
                 # Save space in the dict by zapping zeroes