[Zodb-checkins] SVN: ZODB/branches/fdrake-64bits/s separate 64-bit
"I" types into "L" equivalents, keeping "I" for 32-bit ints
Fred L. Drake, Jr.
fdrake at gmail.com
Mon Apr 17 15:25:21 EDT 2006
Log message for revision 67075:
separate 64-bit "I" types into "L" equivalents, keeping "I" for 32-bit ints
Changed:
U ZODB/branches/fdrake-64bits/setup.py
A ZODB/branches/fdrake-64bits/src/BTrees/LLBTree.py
A ZODB/branches/fdrake-64bits/src/BTrees/LOBTree.py
A ZODB/branches/fdrake-64bits/src/BTrees/OLBTree.py
U ZODB/branches/fdrake-64bits/src/BTrees/SetOpTemplate.c
A ZODB/branches/fdrake-64bits/src/BTrees/_LLBTree.c
A ZODB/branches/fdrake-64bits/src/BTrees/_LOBTree.c
A ZODB/branches/fdrake-64bits/src/BTrees/_OLBTree.c
U ZODB/branches/fdrake-64bits/src/BTrees/check.py
A ZODB/branches/fdrake-64bits/src/BTrees/int64keymacros.h
A ZODB/branches/fdrake-64bits/src/BTrees/int64valuemacros.h
U ZODB/branches/fdrake-64bits/src/BTrees/intkeymacros.h
U ZODB/branches/fdrake-64bits/src/BTrees/intvaluemacros.h
U ZODB/branches/fdrake-64bits/src/BTrees/sorters.c
U ZODB/branches/fdrake-64bits/src/BTrees/tests/testBTrees.py
-=-
Modified: ZODB/branches/fdrake-64bits/setup.py
===================================================================
--- ZODB/branches/fdrake-64bits/setup.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/setup.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -69,7 +69,7 @@
"src/persistent/cPersistence.h",
]
-_flavors = {"O": "object", "I": "int", "F": "float"}
+_flavors = {"O": "object", "I": "int", "F": "float", "L": "int64"}
KEY_H = "src/BTrees/%skeymacros.h"
VALUE_H = "src/BTrees/%svaluemacros.h"
@@ -88,7 +88,7 @@
return Extension(name, sources, **kwargs)
exts = [BTreeExtension(flavor)
- for flavor in ("OO", "IO", "OI", "II", "IF", "fs")]
+ for flavor in ("OO", "IO", "OI", "II", "IF", "LO", "LL", "OL", "fs")]
cPersistence = Extension(name = 'persistent.cPersistence',
include_dirs = include,
Added: ZODB/branches/fdrake-64bits/src/BTrees/LLBTree.py
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/LLBTree.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/LLBTree.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+
+# hack to overcome dynamic-linking headache.
+from _LLBTree import *
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/LLBTree.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: ZODB/branches/fdrake-64bits/src/BTrees/LOBTree.py
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/LOBTree.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/LOBTree.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+
+# hack to overcome dynamic-linking headache.
+from _LOBTree import *
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/LOBTree.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Added: ZODB/branches/fdrake-64bits/src/BTrees/OLBTree.py
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/OLBTree.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/OLBTree.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,16 @@
+##############################################################################
+#
+# 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.
+#
+##############################################################################
+
+# hack to overcome dynamic-linking headache.
+from _OLBTree import *
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/OLBTree.py
___________________________________________________________________
Name: svn:mime-type
+ text/x-python
Name: svn:eol-style
+ native
Modified: ZODB/branches/fdrake-64bits/src/BTrees/SetOpTemplate.c
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/SetOpTemplate.c 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/SetOpTemplate.c 2006-04-17 19:25:20 UTC (rev 67075)
@@ -543,7 +543,7 @@
*/
if (result->len > 0) {
size_t newlen; /* number of elements in final result set */
- newlen = sort_int8_nodups(result->keys, (size_t)result->len);
+ newlen = sort_int_nodups(result->keys, (size_t)result->len);
result->len = (int)newlen;
}
return (PyObject *)result;
Added: ZODB/branches/fdrake-64bits/src/BTrees/_LLBTree.c
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/_LLBTree.c 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/_LLBTree.c 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,34 @@
+/*############################################################################
+#
+# Copyright (c) 2004 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.
+#
+############################################################################*/
+
+#define MASTER_ID "$Id: _IIBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
+
+/* LLBTree - int64 key, int64 value BTree
+
+ Implements a collection using int64 type keys
+ and int64 type values
+*/
+
+/* Setup template macros */
+
+#define PERSISTENT
+
+#define MOD_NAME_PREFIX "LL"
+#define INITMODULE init_LLBTree
+#define DEFAULT_MAX_BUCKET_SIZE 120
+#define DEFAULT_MAX_BTREE_SIZE 500
+
+#include "int64keymacros.h"
+#include "int64valuemacros.h"
+#include "BTreeModuleTemplate.c"
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/_LLBTree.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: ZODB/branches/fdrake-64bits/src/BTrees/_LOBTree.c
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/_LOBTree.c 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/_LOBTree.c 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,32 @@
+/*############################################################################
+#
+# Copyright (c) 2004 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.
+#
+############################################################################*/
+
+#define MASTER_ID "$Id: _IOBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
+
+/* IOBTree - int64 key, object value BTree
+
+ Implements a collection using int64 type keys
+ and object type values
+*/
+
+#define PERSISTENT
+
+#define MOD_NAME_PREFIX "LO"
+#define DEFAULT_MAX_BUCKET_SIZE 60
+#define DEFAULT_MAX_BTREE_SIZE 500
+#define INITMODULE init_LOBTree
+
+#include "int64keymacros.h"
+#include "objectvaluemacros.h"
+#include "BTreeModuleTemplate.c"
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/_LOBTree.c
___________________________________________________________________
Name: svn:eol-style
+ native
Added: ZODB/branches/fdrake-64bits/src/BTrees/_OLBTree.c
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/_OLBTree.c 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/_OLBTree.c 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,32 @@
+/*############################################################################
+#
+# Copyright (c) 2004 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.
+#
+############################################################################*/
+
+#define MASTER_ID "$Id: _OIBTree.c 25186 2004-06-02 15:07:33Z jim $\n"
+
+/* OIBTree - object key, int64 value BTree
+
+ Implements a collection using object type keys
+ and int64 type values
+*/
+
+#define PERSISTENT
+
+#define MOD_NAME_PREFIX "OL"
+#define INITMODULE init_OLBTree
+#define DEFAULT_MAX_BUCKET_SIZE 60
+#define DEFAULT_MAX_BTREE_SIZE 250
+
+#include "objectkeymacros.h"
+#include "int64valuemacros.h"
+#include "BTreeModuleTemplate.c"
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/_OLBTree.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: ZODB/branches/fdrake-64bits/src/BTrees/check.py
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/check.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/check.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -39,6 +39,9 @@
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
from ZODB.utils import positive_id, oid_repr
@@ -49,24 +52,36 @@
IFBTree: (TYPE_BTREE, True),
OIBTree: (TYPE_BTREE, True),
OOBTree: (TYPE_BTREE, True),
+ LOBTree: (TYPE_BTREE, True),
+ LLBTree: (TYPE_BTREE, True),
+ OLBTree: (TYPE_BTREE, True),
IOBucket: (TYPE_BUCKET, True),
IIBucket: (TYPE_BUCKET, True),
IFBucket: (TYPE_BUCKET, True),
OIBucket: (TYPE_BUCKET, True),
OOBucket: (TYPE_BUCKET, True),
+ LOBucket: (TYPE_BUCKET, True),
+ LLBucket: (TYPE_BUCKET, True),
+ OLBucket: (TYPE_BUCKET, True),
IOTreeSet: (TYPE_BTREE, False),
IITreeSet: (TYPE_BTREE, False),
IFTreeSet: (TYPE_BTREE, False),
OITreeSet: (TYPE_BTREE, False),
OOTreeSet: (TYPE_BTREE, False),
+ LOTreeSet: (TYPE_BTREE, False),
+ LLTreeSet: (TYPE_BTREE, False),
+ OLTreeSet: (TYPE_BTREE, False),
IOSet: (TYPE_BUCKET, False),
IISet: (TYPE_BUCKET, False),
IFSet: (TYPE_BUCKET, False),
OISet: (TYPE_BUCKET, False),
OOSet: (TYPE_BUCKET, False),
+ LOSet: (TYPE_BUCKET, False),
+ LLSet: (TYPE_BUCKET, False),
+ OLSet: (TYPE_BUCKET, False),
}
# Return pair
@@ -130,8 +145,18 @@
OITreeSet: OISet,
OOBTree: OOBucket,
- OOTreeSet: OOSet}
+ OOTreeSet: OOSet,
+ LOBTree: LOBucket,
+ LOTreeSet: LOSet,
+
+ LLBTree: LLBucket,
+ LLTreeSet: LLSet,
+
+ OLBTree: OLBucket,
+ OLTreeSet: OLSet,
+ }
+
def crack_btree(t, is_mapping):
state = t.__getstate__()
if state is None:
Added: ZODB/branches/fdrake-64bits/src/BTrees/int64keymacros.h
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/int64keymacros.h 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/int64keymacros.h 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,24 @@
+
+#define KEYMACROS_H "$Id: intkeymacros.h 66936 2006-04-13 17:34:29Z fdrake $\n"
+
+#define NEED_LONG_LONG_SUPPORT
+#define KEYS_ARE_64_BITS
+
+#define KEY_TYPE PY_LONG_LONG
+#undef KEY_TYPE_IS_PYOBJECT
+#define KEY_CHECK longlong_check
+#define TEST_KEY_SET_OR(V, K, T) if ( ( (V) = (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0)) ) , 0 )
+#define DECREF_KEY(KEY)
+#define INCREF_KEY(k)
+#define COPY_KEY(KEY, E) (KEY=(E))
+#define COPY_KEY_TO_OBJECT(O, K) O=longlong_as_object(K)
+#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
+ if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else \
+ if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \
+ if (PyLong_Check(ARG)) { \
+ PyErr_SetString(PyExc_ValueError, "long integer out of range"); \
+ (STATUS)=0; (TARGET)=0; } \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "expected integer key"); \
+ (STATUS)=0; (TARGET)=0; }
+#define MULTI_INT_UNION 1
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/int64keymacros.h
___________________________________________________________________
Name: svn:eol-style
+ native
Added: ZODB/branches/fdrake-64bits/src/BTrees/int64valuemacros.h
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/int64valuemacros.h 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/int64valuemacros.h 2006-04-17 19:25:20 UTC (rev 67075)
@@ -0,0 +1,30 @@
+
+#define VALUEMACROS_H "$Id: intvaluemacros.h 66936 2006-04-13 17:34:29Z fdrake $\n"
+
+#define NEED_LONG_LONG_SUPPORT
+
+#define VALUE_TYPE PY_LONG_LONG
+#undef VALUE_TYPE_IS_PYOBJECT
+#define TEST_VALUE(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0))
+#define VALUE_SAME(VALUE, TARGET) ( (VALUE) == (TARGET) )
+#define DECLARE_VALUE(NAME) VALUE_TYPE NAME
+#define VALUE_PARSE "L"
+#define DECREF_VALUE(k)
+#define INCREF_VALUE(k)
+#define COPY_VALUE(V, E) (V=(E))
+#define COPY_VALUE_TO_OBJECT(O, K) O=longlong_as_object(K)
+#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
+ if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else \
+ if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \
+ if (PyLong_Check(ARG)) { \
+ PyErr_SetString(PyExc_ValueError, "long integer out of range"); \
+ (STATUS)=0; (TARGET)=0; } \
+ else { \
+ PyErr_SetString(PyExc_TypeError, "expected integer key"); \
+ (STATUS)=0; (TARGET)=0; }
+
+#define NORMALIZE_VALUE(V, MIN) ((MIN) > 0) ? ((V)/=(MIN)) : 0
+
+#define MERGE_DEFAULT 1
+#define MERGE(O1, w1, O2, w2) ((O1)*(w1)+(O2)*(w2))
+#define MERGE_WEIGHT(O, w) ((O)*(w))
Property changes on: ZODB/branches/fdrake-64bits/src/BTrees/int64valuemacros.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: ZODB/branches/fdrake-64bits/src/BTrees/intkeymacros.h
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/intkeymacros.h 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/intkeymacros.h 2006-04-17 19:25:20 UTC (rev 67075)
@@ -1,23 +1,16 @@
#define KEYMACROS_H "$Id$\n"
-#define NEED_LONG_LONG_SUPPORT
-
-#define KEY_TYPE PY_LONG_LONG
+#define KEY_TYPE int
#undef KEY_TYPE_IS_PYOBJECT
-#define KEY_CHECK longlong_check
+#define KEY_CHECK PyInt_Check
#define TEST_KEY_SET_OR(V, K, T) if ( ( (V) = (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0)) ) , 0 )
#define DECREF_KEY(KEY)
#define INCREF_KEY(k)
#define COPY_KEY(KEY, E) (KEY=(E))
-#define COPY_KEY_TO_OBJECT(O, K) O=longlong_as_object(K)
+#define COPY_KEY_TO_OBJECT(O, K) O=PyInt_FromLong(K)
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
- if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else \
- if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \
- if (PyLong_Check(ARG)) { \
- PyErr_SetString(PyExc_ValueError, "long integer out of range"); \
- (STATUS)=0; (TARGET)=0; } \
- else { \
- PyErr_SetString(PyExc_TypeError, "expected integer key"); \
- (STATUS)=0; (TARGET)=0; }
+ if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else { \
+ PyErr_SetString(PyExc_TypeError, "expected integer key"); \
+ (STATUS)=0; (TARGET)=0; }
#define MULTI_INT_UNION 1
Modified: ZODB/branches/fdrake-64bits/src/BTrees/intvaluemacros.h
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/intvaluemacros.h 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/intvaluemacros.h 2006-04-17 19:25:20 UTC (rev 67075)
@@ -1,28 +1,21 @@
#define VALUEMACROS_H "$Id$\n"
-#define NEED_LONG_LONG_SUPPORT
-
-#define VALUE_TYPE PY_LONG_LONG
+#define VALUE_TYPE int
#undef VALUE_TYPE_IS_PYOBJECT
#define TEST_VALUE(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0))
#define VALUE_SAME(VALUE, TARGET) ( (VALUE) == (TARGET) )
#define DECLARE_VALUE(NAME) VALUE_TYPE NAME
-#define VALUE_PARSE "L"
+#define VALUE_PARSE "i"
#define DECREF_VALUE(k)
#define INCREF_VALUE(k)
#define COPY_VALUE(V, E) (V=(E))
-#define COPY_VALUE_TO_OBJECT(O, K) O=longlong_as_object(K)
+#define COPY_VALUE_TO_OBJECT(O, K) O=PyInt_FromLong(K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
- if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else \
- if (longlong_check(ARG)) TARGET=PyLong_AsLongLong(ARG); else \
- if (PyLong_Check(ARG)) { \
- PyErr_SetString(PyExc_ValueError, "long integer out of range"); \
- (STATUS)=0; (TARGET)=0; } \
- else { \
- PyErr_SetString(PyExc_TypeError, "expected integer key"); \
- (STATUS)=0; (TARGET)=0; }
-
+ if (PyInt_Check(ARG)) TARGET=PyInt_AsLong(ARG); else { \
+ PyErr_SetString(PyExc_TypeError, "expected integer value"); \
+ (STATUS)=0; (TARGET)=0; }
+
#define NORMALIZE_VALUE(V, MIN) ((MIN) > 0) ? ((V)/=(MIN)) : 0
#define MERGE_DEFAULT 1
Modified: ZODB/branches/fdrake-64bits/src/BTrees/sorters.c
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/sorters.c 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/sorters.c 2006-04-17 19:25:20 UTC (rev 67075)
@@ -15,13 +15,13 @@
/* Revision information: $Id$ */
/* The only routine here intended to be used outside the file is
- size_t sort_int8_nodups(int *p, size_t n)
+ size_t sort_int_nodups(int *p, size_t n)
Sort the array of n ints pointed at by p, in place, and also remove
duplicates. Return the number of unique elements remaining, which occupy
a contiguous and monotonically increasing slice of the array starting at p.
- Example: If the input array is [3, 1, 2, 3, 1, 5, 2], sort_int8_nodups
+ Example: If the input array is [3, 1, 2, 3, 1, 5, 2], sort_int_nodups
returns 4, and the first 4 elements of the array are changed to
[1, 2, 3, 5]. The content of the remaining array positions is not defined.
@@ -45,7 +45,7 @@
the radix sort has to know everything about the type's internal
representation.
*/
-typedef PY_LONG_LONG element_type;
+typedef KEY_TYPE element_type;
/* The radixsort is faster than the quicksort for large arrays, but radixsort
has high fixed overhead, making it a poor choice for small arrays. The
@@ -72,11 +72,12 @@
swaps are done internally, the final result may come back in 'in' or 'work';
and that pointer is returned.
- radixsort_int8 is specific to signed 8-byte ints, with natural machine
- endianness.
+ radixsort_int is specific to signed 4-byte or 8-byte ints, with
+ natural machine endianness, depending on the setting of the
+ KEYS_ARE_64_BITS pre-processor define.
*/
static element_type*
-radixsort_int8(element_type *in, element_type *work, size_t n)
+radixsort_int(element_type *in, element_type *work, size_t n)
{
/* count[i][j] is the number of input elements that have byte value j
in byte position i, where byte position 0 is the LSB. Note that
@@ -102,10 +103,12 @@
++count[1][(x >> 8) & 0xff];
++count[2][(x >> 16) & 0xff];
++count[3][(x >> 24) & 0xff];
+#ifdef KEYS_ARE_64_BITS
++count[4][(x >> 32) & 0xff];
++count[5][(x >> 40) & 0xff];
++count[6][(x >> 48) & 0xff];
++count[7][(x >> 56) & 0xff];
+#endif
}
/* For p an element_type* cast to char*, offset is how much farther we
@@ -502,12 +505,11 @@
/* Sort p and remove duplicates, as fast as we can. */
static size_t
-sort_int8_nodups(PY_LONG_LONG *p, size_t n)
+sort_int_nodups(KEY_TYPE *p, size_t n)
{
size_t nunique;
element_type *work;
- assert(sizeof(PY_LONG_LONG) == sizeof(element_type));
assert(p);
/* Use quicksort if the array is small, OR if malloc can't find
@@ -518,7 +520,7 @@
work = (element_type *)malloc(n * sizeof(element_type));
if (work) {
- element_type *out = radixsort_int8(p, work, n);
+ element_type *out = radixsort_int(p, work, n);
nunique = uniq(p, out, n);
free(work);
}
Modified: ZODB/branches/fdrake-64bits/src/BTrees/tests/testBTrees.py
===================================================================
--- ZODB/branches/fdrake-64bits/src/BTrees/tests/testBTrees.py 2006-04-17 19:13:39 UTC (rev 67074)
+++ ZODB/branches/fdrake-64bits/src/BTrees/tests/testBTrees.py 2006-04-17 19:25:20 UTC (rev 67075)
@@ -20,6 +20,10 @@
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
+from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
+from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
+from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
+
from BTrees.check import check
import transaction
@@ -1263,6 +1267,10 @@
def _noneraises(self):
self.t[None] = 1
+class TestLOBTrees(TestIOBTrees):
+ def setUp(self):
+ self.t = LOBTree()
+
class TestOIBTrees(TypeTest):
def setUp(self):
self.t = OIBTree()
@@ -1286,6 +1294,10 @@
self.assertEqual(b.keys()[0], 30)
+class TestOLBTrees(TestOIBTrees):
+ def setUp(self):
+ self.t = OLBTree()
+
class TestIIBTrees(TestCase):
def setUp(self):
self.t = IIBTree()
@@ -1318,6 +1330,10 @@
def _noneraisesvalue(self):
self.t[1] = None
+class TestLLBTrees(TestIIBTrees):
+ def setUp(self):
+ self.t = LLBTree()
+
class TestIFBTrees(TestCase):
def setUp(self):
self.t = IFBTree()
@@ -1369,6 +1385,10 @@
def _insertnoneraises(self):
self.t.insert(None)
+class TestLOSets(TestIOSets):
+ def setUp(self):
+ self.t = LOSet()
+
class DegenerateBTree(TestCase):
# Build a degenerate tree (set). Boxes are BTree nodes. There are
# 5 leaf buckets, each containing a single int. Keys in the BTree
@@ -1552,6 +1572,15 @@
class OOBucketTest(MappingBase):
def setUp(self):
self.t = OOBucket()
+class LLBucketTest(MappingBase):
+ def setUp(self):
+ self.t = LLBucket()
+class LOBucketTest(MappingBase):
+ def setUp(self):
+ self.t = LOBucket()
+class OLBucketTest(MappingBase):
+ def setUp(self):
+ self.t = OLBucket()
class IITreeSetTest(NormalSetTests):
def setUp(self):
@@ -1568,6 +1597,15 @@
class OOTreeSetTest(NormalSetTests):
def setUp(self):
self.t = OOTreeSet()
+class LLTreeSetTest(NormalSetTests):
+ def setUp(self):
+ self.t = LLTreeSet()
+class LOTreeSetTest(NormalSetTests):
+ def setUp(self):
+ self.t = LOTreeSet()
+class OLTreeSetTest(NormalSetTests):
+ def setUp(self):
+ self.t = OLTreeSet()
class IISetTest(ExtendedSetTests):
def setUp(self):
@@ -1582,6 +1620,10 @@
# This one used to segfault.
self.assertRaises(TypeError, self.t.keys, 0, "")
+class LLSetTest(IISetTest):
+ def setUp(self):
+ self.t = LLSet()
+
class IFSetTest(ExtendedSetTests):
def setUp(self):
self.t = IFSet()
@@ -1594,29 +1636,43 @@
class OOSetTest(ExtendedSetTests):
def setUp(self):
self.t = OOSet()
+class LOSetTest(ExtendedSetTests):
+ def setUp(self):
+ self.t = LOSet()
+class OLSetTest(ExtendedSetTests):
+ def setUp(self):
+ self.t = OLSet()
-class IIBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
+class IIBTreeTest(BTreeTests):
def setUp(self):
self.t = IIBTree()
- def getTwoValues(self):
- return 1, 2
-class IFBTreeTest(BTreeTests, TestLongIntKeys):
+class IFBTreeTest(BTreeTests):
def setUp(self):
self.t = IFBTree()
- def getTwoValues(self):
- return 0.5, 1.5
-class IOBTreeTest(BTreeTests, TestLongIntKeys):
+class IOBTreeTest(BTreeTests):
def setUp(self):
self.t = IOBTree()
-class OIBTreeTest(BTreeTests, TestLongIntValues):
+class OIBTreeTest(BTreeTests):
def setUp(self):
self.t = OIBTree()
- def getTwoKeys(self):
- return object(), object()
class OOBTreeTest(BTreeTests):
def setUp(self):
self.t = OOBTree()
+class LLBTreeTest(BTreeTests, TestLongIntKeys, TestLongIntValues):
+ def setUp(self):
+ self.t = LLBTree()
+ def getTwoValues(self):
+ return 1, 2
+class LOBTreeTest(BTreeTests, TestLongIntKeys):
+ def setUp(self):
+ self.t = LOBTree()
+class OLBTreeTest(BTreeTests, TestLongIntValues):
+ def setUp(self):
+ self.t = OLBTree()
+ def getTwoKeys(self):
+ return object(), object()
+
# cmp error propagation tests
class DoesntLikeBeingCompared:
@@ -1644,11 +1700,15 @@
IOBucketTest, IOBTreeTest, IOSetTest, IOTreeSetTest,
OOBucketTest, OOBTreeTest, OOSetTest, OOTreeSetTest,
OIBucketTest, OIBTreeTest, OISetTest, OITreeSetTest,
+ LLBucketTest, LLBTreeTest, LLSetTest, LLTreeSetTest,
+ LOBucketTest, LOBTreeTest, LOSetTest, LOTreeSetTest,
+ OLBucketTest, OLBTreeTest, OLSetTest, OLTreeSetTest,
# Note: there is no TestOOBTrees. The next three are
# checking for assorted TypeErrors, and when both keys
# and values oare objects (OO), there's nothing to test.
- TestIIBTrees, TestIFBTrees, TestIOBTrees, TestOIBTrees,
+ TestIIBTrees, TestIFBTrees, TestIOBTrees, TestOIBTrees,
+ TestLLBTrees, TestLOBTrees, TestOLBTrees,
TestIOSets,
DegenerateBTree,
TestCmpError):
More information about the Zodb-checkins
mailing list