[Zodb-checkins] CVS: ZODB3/bsddb3Storage/bsddb3Storage - BerkeleyBase.py:1.19.2.3
Barry Warsaw
barry@wooz.org
Thu, 19 Sep 2002 18:09:34 -0400
Update of /cvs-repository/ZODB3/bsddb3Storage/bsddb3Storage
In directory cvs.zope.org:/tmp/cvs-serv14716
Modified Files:
Tag: bdb-nolocks
BerkeleyBase.py
Log Message:
Some code cleanup, plus removal of commit log related stuff, since we
won't be needing that in the rewrites of Minimal or Full. We can also
get rid of tpc_vote() since I don't think we need to worry about b/c
with Zope 2.3.1 any more <wink>.
Added _update() which is a useful helper for both storages.
More refactoring to come later.
=== ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py 1.19.2.2 => 1.19.2.3 ===
--- ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py:1.19.2.2 Wed Sep 11 14:01:08 2002
+++ ZODB3/bsddb3Storage/bsddb3Storage/BerkeleyBase.py Thu Sep 19 18:09:34 2002
@@ -145,22 +145,12 @@
# Initialize a few other things
self._prefix = prefix
- self._commitlog = None
# Give the subclasses a chance to interpose into the database setup
# procedure
self._setupDBs()
# Initialize the object id counter.
self._init_oid()
- def _closelog(self):
- if self._commitlog:
- self._commitlog.finish()
- # JF: unlinking might be too inefficient. JH: might use mmap
- # files. BAW: maybe just truncate the file, or write a length
- # into the headers and just zero out the length.
- self._commitlog.close(unlink=1)
- self._commitlog = None
-
def _setupDB(self, name, flags=0):
"""Open an individual database with the given flags.
@@ -213,7 +203,7 @@
# BAW: the last parameter is undocumented in the UML model
if self._len is not None:
# Increment the cached length
- self._len = self._len + 1
+ self._len += 1
return BaseStorage.new_oid(self, last)
def getSize(self):
@@ -222,22 +212,8 @@
filename = os.path.join(self._env.db_home, 'zodb_pickles')
return os.path.getsize(filename)
- # BAW: this overrides BaseStorage.tpc_vote() with exactly the same
- # implementation. This is so Zope 2.3.1, which doesn't include the change
- # to BaseStorage, will work with Berkeley. Once we can ignore older
- # versions of ZODB, we can get rid of this.
- def tpc_vote(self, transaction):
- self._lock_acquire()
- try:
- if transaction is not self._transaction: return
- self._vote()
- finally:
- self._lock_release()
-
def _vote(self):
- # Make a promise to commit all the registered changes. Rewind and put
- # our commit log in the PROMISED state.
- self._commitlog.promise()
+ pass
def _finish(self, tid, user, desc, ext):
"""Called from BaseStorage.tpc_finish(), this commits the underlying
@@ -256,7 +232,6 @@
"""Called from BaseStorage.tpc_abort(), this aborts the underlying
BSDDB transaction.
"""
- self._closelog()
self._transaction.abort()
def _clear_temp(self):
@@ -295,6 +270,17 @@
if config._counter > config.interval:
self._env.txn_checkpoint(config.kbyte, config.min)
config._counter = 0
+
+ def _update(self, deltas, data, incdec):
+ refdoids = []
+ referencesf(data, refdoids)
+ for oid in refdoids:
+ rc = deltas.get(oid, 0) + incdec
+ if rc == 0:
+ # Save space in the dict by zapping zeroes
+ del deltas[oid]
+ else:
+ deltas[oid] = rc