[Zodb-checkins] SVN: Ovulation.

Chris McDonough chrism at plope.com
Thu Mar 2 23:13:33 EST 2006


Log message for revision 65765:
  Ovulation.
  

Changed:
  A   Sandbox/chrism/zodb/3.6.0/BTrees/setup.py
  U   ZODB/tags/3.6.0/src/BTrees/BTreeModuleTemplate.c
  A   ZODB/tags/3.6.0/src/BTrees/cPersistence.h
  A   ZODB/tags/3.6.0/src/BTrees/ring.h

-=-
Added: Sandbox/chrism/zodb/3.6.0/BTrees/setup.py
===================================================================
--- Sandbox/chrism/zodb/3.6.0/BTrees/setup.py	2006-03-03 02:27:15 UTC (rev 65764)
+++ Sandbox/chrism/zodb/3.6.0/BTrees/setup.py	2006-03-03 04:13:32 UTC (rev 65765)
@@ -0,0 +1,100 @@
+##############################################################################
+#
+# Copyright (c) 2006 Zope Corporation and Contributors.
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+"""Zope Object Database: object database and persistence
+
+The Zope Object Database provides an object-oriented database for
+Python that provides a high-degree of transparency. Applications can
+take advantage of object database features with few, if any, changes
+to application logic.  ZODB includes features such as a plugable storage
+interface, rich transaction support, and undo.
+
+This distribution includes the BTrees (B+ Tree) implementation for ZODB.
+"""
+
+# The (non-obvious!) choices for the Trove Development Status line:
+# Development Status :: 5 - Production/Stable
+# Development Status :: 4 - Beta
+# Development Status :: 3 - Alpha
+
+
+import os
+from setuptools import setup, Extension
+
+classifiers = """\
+Development Status :: 3 - Alpha
+Intended Audience :: Developers
+License :: OSI Approved :: Zope Public License
+Programming Language :: Python
+Topic :: Database
+Topic :: Software Development :: Libraries :: Python Modules
+Operating System :: Microsoft :: Windows
+Operating System :: Unix
+"""
+
+# Set up dependencies for the BTrees package
+base_btrees_depends = [
+    "src/BTreeItemsTemplate.c",
+    "src/BTreeModuleTemplate.c",
+    "src/BTreeTemplate.c",
+    "src/BucketTemplate.c",
+    "src/MergeTemplate.c",
+    "src/SetOpTemplate.c",
+    "src/SetTemplate.c",
+    "src/TreeSetTemplate.c",
+    "src/sorters.c",
+    "src/cPersistence.h",
+    ]
+
+_flavors = {"O": "object", "I": "int", "F": "float"}
+
+KEY_H = "src/%skeymacros.h"
+VALUE_H = "src/%svaluemacros.h"
+
+def BTreeExtension(flavor):
+    key = flavor[0]
+    value = flavor[1]
+    name = "BTrees._%sBTree" % flavor
+    sources = ["src/_%sBTree.c" % flavor]
+    kwargs = {"include_dirs": ['src']}
+    if flavor != "fs":
+        kwargs["depends"] = (base_btrees_depends + [KEY_H % _flavors[key],
+                                                    VALUE_H % _flavors[value]])
+    if key != "O":
+        kwargs["define_macros"] = [('EXCLUDE_INTSET_SUPPORT', None)]
+    return Extension(name, sources, **kwargs)
+
+setup(name='BTrees',
+      version='3.6.0',
+      url='http://svn.zope.org/ZODB',
+      download_url = "http://www.zope.org/Products/ZODB3.6",
+      license='ZPL 2.1',
+      description='ZODB BTrees implementation',
+      author='Zope Corporation and Contributors',
+      maintainer='Zope Corporation and Contributors',
+      author_email='zodb-dev at zope.org',
+      maintainer_email='zodb-dev at zope.org',
+      headers = ['src/cPersistence.h'],
+      platforms = ['any'],
+      classifiers = filter(None, classifiers.split("\n")),
+      long_description = __doc__,
+      packages=['BTrees',],
+      package_dir = {'BTrees': 'src'},
+      ext_modules=[BTreeExtension(flavor) for flavor in
+                   ("OO", "IO", "OI", "II", "IF", "fs")],
+      tests_require = [],
+      install_requires=[],
+      include_package_data = True,
+      zip_safe = True,
+      )
+


Property changes on: Sandbox/chrism/zodb/3.6.0/BTrees/setup.py
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: ZODB/tags/3.6.0/src/BTrees/BTreeModuleTemplate.c
===================================================================
--- ZODB/tags/3.6.0/src/BTrees/BTreeModuleTemplate.c	2006-03-03 02:27:15 UTC (rev 65764)
+++ ZODB/tags/3.6.0/src/BTrees/BTreeModuleTemplate.c	2006-03-03 04:13:32 UTC (rev 65765)
@@ -17,7 +17,7 @@
 #include "structmember.h"
 
 #ifdef PERSISTENT
-#include "persistent/cPersistence.h"
+#include "cPersistence.h"
 #else
 #define PER_USE_OR_RETURN(self, NULL)
 #define PER_ALLOW_DEACTIVATION(self)

Added: ZODB/tags/3.6.0/src/BTrees/cPersistence.h
===================================================================
--- ZODB/tags/3.6.0/src/BTrees/cPersistence.h	2006-03-03 02:27:15 UTC (rev 65764)
+++ ZODB/tags/3.6.0/src/BTrees/cPersistence.h	2006-03-03 04:13:32 UTC (rev 65765)
@@ -0,0 +1,128 @@
+/*****************************************************************************
+
+  Copyright (c) 2001, 2002 Zope Corporation and Contributors.
+  All Rights Reserved.
+
+  This software is subject to the provisions of the Zope Public License,
+  Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+  WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+  FOR A PARTICULAR PURPOSE
+
+ ****************************************************************************/
+
+#ifndef CPERSISTENCE_H
+#define CPERSISTENCE_H
+
+#include "Python.h"
+#include "ring.h"
+
+#define CACHE_HEAD \
+    PyObject_HEAD \
+    CPersistentRing ring_home; \
+    int non_ghost_count;
+
+struct ccobject_head_struct;
+
+typedef struct ccobject_head_struct PerCache;
+
+/* How big is a persistent object?
+
+   12  PyGC_Head is two pointers and an int
+    8  PyObject_HEAD is an int and a pointer
+ 
+   12  jar, oid, cache pointers
+    8  ring struct
+    8  serialno
+    4  state + extra
+
+  (52) so far
+
+    4  dict ptr
+    4  weaklist ptr
+  -------------------------
+   64  only need 62, but obmalloc rounds up to multiple of eight
+
+  Even a ghost requires 64 bytes.  It's possible to make a persistent
+  instance with slots and no dict, which changes the storage needed.
+
+*/
+
+#define cPersistent_HEAD \
+    PyObject_HEAD \
+    PyObject *jar; \
+    PyObject *oid; \
+    PerCache *cache; \
+    CPersistentRing ring; \
+    char serial[8]; \
+    signed char state; \
+    unsigned char reserved[3];
+
+#define cPersistent_GHOST_STATE -1
+#define cPersistent_UPTODATE_STATE 0
+#define cPersistent_CHANGED_STATE 1
+#define cPersistent_STICKY_STATE 2
+
+typedef struct {
+    cPersistent_HEAD
+} cPersistentObject;
+
+typedef void (*percachedelfunc)(PerCache *, PyObject *);
+
+typedef struct {
+    PyTypeObject *pertype;
+    getattrofunc getattro;
+    setattrofunc setattro;
+    int (*changed)(cPersistentObject*);
+    void (*accessed)(cPersistentObject*);
+    void (*ghostify)(cPersistentObject*);
+    int (*setstate)(PyObject*);
+    percachedelfunc percachedel;
+} cPersistenceCAPIstruct;
+
+#define cPersistenceType cPersistenceCAPI->pertype
+
+#ifndef DONT_USE_CPERSISTENCECAPI
+static cPersistenceCAPIstruct *cPersistenceCAPI;
+#endif
+
+#define cPersistanceModuleName "cPersistence"
+
+#define PER_TypeCheck(O) PyObject_TypeCheck((O), cPersistenceCAPI->pertype)
+
+#define PER_USE_OR_RETURN(O,R) {if((O)->state==cPersistent_GHOST_STATE && cPersistenceCAPI->setstate((PyObject*)(O)) < 0) return (R); else if ((O)->state==cPersistent_UPTODATE_STATE) (O)->state=cPersistent_STICKY_STATE;}
+
+#define PER_CHANGED(O) (cPersistenceCAPI->changed((cPersistentObject*)(O)))
+
+#define PER_GHOSTIFY(O) (cPersistenceCAPI->ghostify((cPersistentObject*)(O)))
+
+/* If the object is sticky, make it non-sticky, so that it can be ghostified.
+   The value is not meaningful
+ */
+#define PER_ALLOW_DEACTIVATION(O) ((O)->state==cPersistent_STICKY_STATE && ((O)->state=cPersistent_UPTODATE_STATE))
+
+#define PER_PREVENT_DEACTIVATION(O)  ((O)->state==cPersistent_UPTODATE_STATE && ((O)->state=cPersistent_STICKY_STATE))
+
+/* 
+   Make a persistent object usable from C by:
+
+   - Making sure it is not a ghost
+
+   - Making it sticky.
+
+   IMPORTANT: If you call this and don't call PER_ALLOW_DEACTIVATION, 
+              your object will not be ghostified.
+
+   PER_USE returns a 1 on success and 0 failure, where failure means
+   error.
+ */
+#define PER_USE(O) \
+(((O)->state != cPersistent_GHOST_STATE \
+  || (cPersistenceCAPI->setstate((PyObject*)(O)) >= 0)) \
+ ? (((O)->state==cPersistent_UPTODATE_STATE) \
+    ? ((O)->state=cPersistent_STICKY_STATE) : 1) : 0)
+
+#define PER_ACCESSED(O)  (cPersistenceCAPI->accessed((cPersistentObject*)(O)))
+
+#endif

Added: ZODB/tags/3.6.0/src/BTrees/ring.h
===================================================================
--- ZODB/tags/3.6.0/src/BTrees/ring.h	2006-03-03 02:27:15 UTC (rev 65764)
+++ ZODB/tags/3.6.0/src/BTrees/ring.h	2006-03-03 04:13:32 UTC (rev 65765)
@@ -0,0 +1,66 @@
+/*****************************************************************************
+
+  Copyright (c) 2003 Zope Corporation and Contributors.
+  All Rights Reserved.
+
+  This software is subject to the provisions of the Zope Public License,
+  Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+  THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+  WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+  WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+  FOR A PARTICULAR PURPOSE
+
+ ****************************************************************************/
+
+/* Support routines for the doubly-linked list of cached objects.
+
+The cache stores a headed, doubly-linked, circular list of persistent
+objects, with space for the pointers allocated in the objects themselves.
+The cache stores the distinguished head of the list, which is not a valid
+persistent object.  The other list members are non-ghost persistent
+objects, linked in LRU (least-recently used) order.
+
+The r_next pointers traverse the ring starting with the least recently used
+object.  The r_prev pointers traverse the ring starting with the most
+recently used object.
+
+Obscure:  While each object is pointed at twice by list pointers (once by
+its predecessor's r_next, again by its successor's r_prev), the refcount
+on the object is bumped only by 1.  This leads to some possibly surprising
+sequences of incref and decref code.  Note that since the refcount is
+bumped at least once, the list does hold a strong reference to each
+object in it.
+*/
+
+typedef struct CPersistentRing_struct
+{
+    struct CPersistentRing_struct *r_prev;
+    struct CPersistentRing_struct *r_next;
+} CPersistentRing;
+
+/* The list operations here take constant time independent of the
+ * number of objects in the list:
+ */
+
+/* Add elt as the most recently used object.  elt must not already be
+ * in the list, although this isn't checked.
+ */
+void ring_add(CPersistentRing *ring, CPersistentRing *elt);
+
+/* Remove elt from the list.  elt must already be in the list, although
+ * this isn't checked.
+ */
+void ring_del(CPersistentRing *elt);
+
+/* elt must already be in the list, although this isn't checked.  It's
+ * unlinked from its current position, and relinked into the list as the
+ * most recently used object (which is arguably the tail of the list
+ * instead of the head -- but the name of this function could be argued
+ * either way).  This is equivalent to
+ *
+ *     ring_del(elt);
+ *     ring_add(ring, elt);
+ *
+ * but may be a little quicker.
+ */
+void ring_move_to_head(CPersistentRing *ring, CPersistentRing *elt);



More information about the Zodb-checkins mailing list