Commit 37382150 authored by Jason Madden's avatar Jason Madden

WIP towards unsigned keys and values.

test__UUBTree.py is complete and passing on Python 3
parent 87599a74
......@@ -78,11 +78,40 @@ static void PyVar_Assign(PyObject **v, PyObject *e) { Py_XDECREF(*v); *v=e;}
#endif
#ifdef NEED_LONG_LONG_KEYS
#if defined(ZODB_UNSIGNED_VALUE_INTS) || defined(ZODB_UNSIGNED_KEY_INTS)
static int
ulonglong_check(PyObject *ob)
{
#ifndef PY3K
if (PyInt_Check(ob))
{
long tmp;
tmp = PyInt_AS_LONG(ob);
if (tmp < 0) {
PyErr_SetString(PyExc_OverflowError, "unsigned value less than 0");
return 0;
}
return 1;
}
#endif
if (!PyLong_Check(ob))
return 0;
if (PyLong_AsUnsignedLongLong(ob) == (unsigned long long)-1 && PyErr_Occurred())
return 0;
return 1;
}
#endif /* defined(ZODB_UNSIGNED_VALUE_INTS) || defined(ZODB_UNSIGNED_KEY_INTS) */
static int
longlong_check(PyObject *ob)
{
if (INT_CHECK(ob))
#ifndef PY3K
/* Python's small integers can always fit into a long long. */
if (PyInt_Check(ob))
return 1;
#endif
if (PyLong_Check(ob)) {
int overflow;
......@@ -97,8 +126,50 @@ overflow:
"longlong_check: long integer out of range");
return 0;
}
#endif
#if defined(ZODB_UNSIGNED_VALUE_INTS) || defined(ZODB_UNSIGNED_KEY_INTS)
static PyObject *
ulonglong_as_object(unsigned PY_LONG_LONG val)
{
if ((val > LONG_MAX))
return PyLong_FromUnsignedLongLong(val);
return UINT_FROM_LONG((unsigned long)val);
}
static int
ulonglong_convert(PyObject *ob, unsigned PY_LONG_LONG *value)
{
#ifndef PY3K
if (PyInt_Check(ob))
{
long tmp;
tmp = PyInt_AS_LONG(ob);
if (tmp < 0) {
PyErr_SetString(PyExc_OverflowError, "unsigned value less than 0");
return 0;
}
(*value) = (unsigned PY_LONG_LONG)tmp;
return 1;
}
#endif
if (!PyLong_Check(ob))
{
PyErr_SetString(PyExc_TypeError, "expected integer key");
return 0;
}
unsigned PY_LONG_LONG val;
val = PyLong_AsUnsignedLongLong(ob);
if (val == (unsigned long long)-1 && PyErr_Occurred())
return 0;
(*value) = val;
return 1;
}
#endif /* defined(ZODB_UNSIGNED_VALUE_INTS) || defined(ZODB_UNSIGNED_KEY_INTS) */
static PyObject *
longlong_as_object(PY_LONG_LONG val)
{
......@@ -107,7 +178,6 @@ longlong_as_object(PY_LONG_LONG val)
return INT_FROM_LONG((long)val);
}
static int
longlong_convert(PyObject *ob, PY_LONG_LONG *value)
{
......@@ -138,6 +208,7 @@ overflow:
PyErr_SetString(PyExc_ValueError, "long integer out of range");
return 0;
}
#endif /* NEED_LONG_LONG_SUPPORT */
......
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'IUBucket', 'IUSet', 'IUBTree', 'IUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_int as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class IUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class IUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
IUBucketPy._mapping_type = IUBucketPy._bucket_type = IUBucketPy
IUBucketPy._set_type = IUSetPy
IUSetPy._mapping_type = IUBucketPy
IUSetPy._set_type = IUSetPy._bucket_type = IUSetPy
IUBTreePy._mapping_type = IUBTreePy._bucket_type = IUBucketPy
IUBTreePy._set_type = IUSetPy
IUTreeSetPy._mapping_type = IUBucketPy
IUTreeSetPy._set_type = IUTreeSetPy._bucket_type = IUSetPy
differencePy = _set_operation(_difference, IUSetPy)
unionPy = _set_operation(_union, IUSetPy)
intersectionPy = _set_operation(_intersection, IUSetPy)
multiunionPy = _set_operation(_multiunion, IUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, IUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, IUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
......@@ -451,40 +451,78 @@ class IMergeIntegerKey(IMerge):
class IBTreeFamily(Interface):
"""the 64-bit or 32-bit family"""
IF = Attribute('The IIntegerFloatBTreeModule for this family')
II = Attribute('The IIntegerIntegerBTreeModule for this family')
IO = Attribute('The IIntegerObjectBTreeModule for this family')
IU = Attribute('The IIntegerUnsignedBTreeModule for this family')
UF = Attribute('The IUnsignedFloatBTreeModule for this family')
UI = Attribute('The IUnsignedIntegerBTreeModule for this family')
UO = Attribute('The IUnsignedObjectBTreeModule for this family')
UU = Attribute('The IUnsignedUnsignedBTreeModule for this family')
OI = Attribute('The IObjectIntegerBTreeModule for this family')
II = Attribute('The IIntegerIntegerBTreeModule for this family')
IF = Attribute('The IIntegerFloatBTreeModule for this family')
OO = Attribute('The IObjectObjectBTreeModule for this family')
maxint = Attribute('The maximum integer storable in this family')
minint = Attribute('The minimum integer storable in this family')
OU = Attribute('The IObjectUnsignedBTreeModule for this family')
maxint = Attribute('The maximum signed integer storable in this family')
maxuint = Attribute('The maximum unsigned integer storable in this family')
minint = Attribute('The minimum signed integer storable in this family')
class IIntegerObjectBTreeModule(IBTreeModule, IMerge):
"""keys, or set values, are integers; values are objects.
class _IMergeBTreeModule(IBTreeModule, IMerge):
family = Attribute('The IBTreeFamily of this module')
class IIntegerObjectBTreeModule(_IMergeBTreeModule):
"""keys, or set values, are signed integers; values are objects.
describes IOBTree and LOBTree"""
family = Attribute('The IBTreeFamily of this module')
class IUnsignedObjectBTreeModule(_IMergeBTreeModule):
"""
As for `IIntegerObjectBTreeModule` with unsigned integers.
"""
class IObjectIntegerBTreeModule(IBTreeModule, IIMerge):
"""keys, or set values, are objects; values are integers.
class IObjectIntegerBTreeModule(_IMergeBTreeModule):
"""keys, or set values, are objects; values are signed integers.
Object keys (and set values) must sort reliably (for instance, *not* on
object id)! Homogenous key types recommended.
describes OIBTree and LOBTree"""
family = Attribute('The IBTreeFamily of this module')
class IObjectUnsignedBTreeModule(_IMergeBTreeModule):
"""
As for `IObjectIntegerBTreeModule` with unsigned integers.
"""
class IIntegerIntegerBTreeModule(IBTreeModule, IIMerge, IMergeIntegerKey):
"""keys, or set values, are integers; values are also integers.
class IIntegerIntegerBTreeModule(_IMergeBTreeModule, IMergeIntegerKey):
"""keys, or set values, are signed integers; values are also signed integers.
describes IIBTree and LLBTree"""
family = Attribute('The IBTreeFamily of this module')
class IUnsignedUnsignedBTreeModule(_IMergeBTreeModule, IMergeIntegerKey):
"""
As for `IIntegerIntegerBTreeModule` with unsigned integers.
"""
class IUnsignedIntegerBTreeModule(_IMergeBTreeModule, IMergeIntegerKey):
"""
As for `IIntegerIntegerBTreeModule` with unsigned integers for keys only.
"""
class IIntegerUnsignedBTreeModule(_IMergeBTreeModule, IMergeIntegerKey):
"""
As for `IIntegerIntegerBTreeModule` with unsigned integers for values only.
"""
class IObjectObjectBTreeModule(IBTreeModule, IMerge):
......@@ -499,12 +537,15 @@ class IObjectObjectBTreeModule(IBTreeModule, IMerge):
# the OO flavor of BTrees.
class IIntegerFloatBTreeModule(IBTreeModule, IMerge):
"""keys, or set values, are integers; values are floats.
class IIntegerFloatBTreeModule(_IMergeBTreeModule):
"""keys, or set values, are signed integers; values are floats.
describes IFBTree and LFBTree"""
family = Attribute('The IBTreeFamily of this module')
class IUnsignedFloatBTreeModule(_IMergeBTreeModule):
"""
As for `IIntegerFloatBTreeModule` with unsigned integers.
"""
try:
......
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'LQBucket', 'LQSet', 'LQBTree', 'LQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IIntegerUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_long as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class LQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class LQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
LQBucketPy._mapping_type = LQBucketPy._bucket_type = LQBucketPy
LQBucketPy._set_type = LQSetPy
LQSetPy._mapping_type = LQBucketPy
LQSetPy._set_type = LQSetPy._bucket_type = LQSetPy
LQBTreePy._mapping_type = LQBTreePy._bucket_type = LQBucketPy
LQBTreePy._set_type = LQSetPy
LQTreeSetPy._mapping_type = LQBucketPy
LQTreeSetPy._set_type = LQTreeSetPy._bucket_type = LQSetPy
differencePy = _set_operation(_difference, LQSetPy)
unionPy = _set_operation(_union, LQSetPy)
intersectionPy = _set_operation(_intersection, LQSetPy)
multiunionPy = _set_operation(_multiunion, LQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, LQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, LQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IIntegerUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OQBucket', 'OQSet', 'OQBTree', 'OQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_ulong as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class OQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OQBucketPy._mapping_type = OQBucketPy._bucket_type = OQBucketPy
OQBucketPy._set_type = OQSetPy
OQSetPy._mapping_type = OQBucketPy
OQSetPy._set_type = OQSetPy._bucket_type = OQSetPy
OQBTreePy._mapping_type = OQBTreePy._bucket_type = OQBucketPy
OQBTreePy._set_type = OQSetPy
OQTreeSetPy._mapping_type = OQBucketPy
OQTreeSetPy._set_type = OQTreeSetPy._bucket_type = OQSetPy
differencePy = _set_operation(_difference, OQSetPy)
unionPy = _set_operation(_union, OQSetPy)
intersectionPy = _set_operation(_intersection, OQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'OUBucket', 'OUSet', 'OUBTree', 'OUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection',
)
from zope.interface import moduleProvides
from .Interfaces import IObjectUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import set_operation as _set_operation
from ._base import to_ob as _to_key
from ._base import to_uint as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 250
using64bits = True
class OUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class OUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
OUBucketPy._mapping_type = OUBucketPy._bucket_type = OUBucketPy
OUBucketPy._set_type = OUSetPy
OUSetPy._mapping_type = OUBucketPy
OUSetPy._set_type = OUSetPy._bucket_type = OUSetPy
OUBTreePy._mapping_type = OUBTreePy._bucket_type = OUBucketPy
OUBTreePy._set_type = OUSetPy
OUTreeSetPy._mapping_type = OUBucketPy
OUTreeSetPy._set_type = OUTreeSetPy._bucket_type = OUSetPy
differencePy = _set_operation(_difference, OUSetPy)
unionPy = _set_operation(_union, OUSetPy)
intersectionPy = _set_operation(_intersection, OUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, OUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, OUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IObjectUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QFBucket', 'QFSet', 'QFBTree', 'QFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class QFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QFBucketPy._mapping_type = QFBucketPy._bucket_type = QFBucketPy
QFBucketPy._set_type = QFSetPy
QFSetPy._mapping_type = QFBucketPy
QFSetPy._set_type = QFSetPy._bucket_type = QFSetPy
QFBTreePy._mapping_type = QFBTreePy._bucket_type = QFBucketPy
QFBTreePy._set_type = QFSetPy
QFTreeSetPy._mapping_type = QFBucketPy
QFTreeSetPy._set_type = QFTreeSetPy._bucket_type = QFSetPy
differencePy = _set_operation(_difference, QFSetPy)
unionPy = _set_operation(_union, QFSetPy)
intersectionPy = _set_operation(_intersection, QFSetPy)
multiunionPy = _set_operation(_multiunion, QFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QLBucket', 'QLSet', 'QLBTree', 'QLTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_long as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QLBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QLTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QLBucketPy._mapping_type = QLBucketPy._bucket_type = QLBucketPy
QLBucketPy._set_type = QLSetPy
QLSetPy._mapping_type = QLBucketPy
QLSetPy._set_type = QLSetPy._bucket_type = QLSetPy
QLBTreePy._mapping_type = QLBTreePy._bucket_type = QLBucketPy
QLBTreePy._set_type = QLSetPy
QLTreeSetPy._mapping_type = QLBucketPy
QLTreeSetPy._set_type = QLTreeSetPy._bucket_type = QLSetPy
differencePy = _set_operation(_difference, QLSetPy)
unionPy = _set_operation(_union, QLSetPy)
intersectionPy = _set_operation(_intersection, QLSetPy)
multiunionPy = _set_operation(_multiunion, QLSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QLSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QLSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QOBucket', 'QOSet', 'QOBTree', 'QOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = True
class QOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOSetPy(Set):
_to_key = _to_key
class QOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class QOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class QOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QOBucketPy._mapping_type = QOBucketPy._bucket_type = QOBucketPy
QOBucketPy._set_type = QOSetPy
QOSetPy._mapping_type = QOBucketPy
QOSetPy._set_type = QOSetPy._bucket_type = QOSetPy
QOBTreePy._mapping_type = QOBTreePy._bucket_type = QOBucketPy
QOBTreePy._set_type = QOSetPy
QOTreeSetPy._mapping_type = QOBucketPy
QOTreeSetPy._set_type = QOTreeSetPy._bucket_type = QOSetPy
differencePy = _set_operation(_difference, QOSetPy)
unionPy = _set_operation(_union, QOSetPy)
intersectionPy = _set_operation(_intersection, QOSetPy)
multiunionPy = _set_operation(_multiunion, QOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'QQBucket', 'QQSet', 'QQBTree', 'QQTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_ulong as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = True
class QQBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class QQTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
QQBucketPy._mapping_type = QQBucketPy._bucket_type = QQBucketPy
QQBucketPy._set_type = QQSetPy
QQSetPy._mapping_type = QQBucketPy
QQSetPy._set_type = QQSetPy._bucket_type = QQSetPy
QQBTreePy._mapping_type = QQBTreePy._bucket_type = QQBucketPy
QQBTreePy._set_type = QQSetPy
QQTreeSetPy._mapping_type = QQBucketPy
QQTreeSetPy._set_type = QQTreeSetPy._bucket_type = QQSetPy
differencePy = _set_operation(_difference, QQSetPy)
unionPy = _set_operation(_union, QQSetPy)
intersectionPy = _set_operation(_intersection, QQSetPy)
multiunionPy = _set_operation(_multiunion, QQSetPy)
weightedUnionPy = _set_operation(_weightedUnion, QQSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, QQSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UFBucket', 'UFSet', 'UFBTree', 'UFTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedFloatBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_float
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_float as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UFBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_float
class UFTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UFBucketPy._mapping_type = UFBucketPy._bucket_type = UFBucketPy
UFBucketPy._set_type = UFSetPy
UFSetPy._mapping_type = UFBucketPy
UFSetPy._set_type = UFSetPy._bucket_type = UFSetPy
UFBTreePy._mapping_type = UFBTreePy._bucket_type = UFBucketPy
UFBTreePy._set_type = UFSetPy
UFTreeSetPy._mapping_type = UFBucketPy
UFTreeSetPy._set_type = UFTreeSetPy._bucket_type = UFSetPy
differencePy = _set_operation(_difference, UFSetPy)
unionPy = _set_operation(_union, UFSetPy)
intersectionPy = _set_operation(_intersection, UFSetPy)
multiunionPy = _set_operation(_multiunion, UFSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UFSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UFSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedFloatBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UIBucket', 'UISet', 'UIBTree', 'UITreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedIntegerBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_int as _to_value
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UIBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UISetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UIBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UITreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UIBucketPy._mapping_type = UIBucketPy._bucket_type = UIBucketPy
UIBucketPy._set_type = UISetPy
UISetPy._mapping_type = UIBucketPy
UISetPy._set_type = UISetPy._bucket_type = UISetPy
UIBTreePy._mapping_type = UIBTreePy._bucket_type = UIBucketPy
UIBTreePy._set_type = UISetPy
UITreeSetPy._mapping_type = UIBucketPy
UITreeSetPy._set_type = UITreeSetPy._bucket_type = UISetPy
differencePy = _set_operation(_difference, UISetPy)
unionPy = _set_operation(_union, UISetPy)
intersectionPy = _set_operation(_intersection, UISetPy)
multiunionPy = _set_operation(_multiunion, UISetPy)
weightedUnionPy = _set_operation(_weightedUnion, UISetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UISetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedIntegerBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UOBucket', 'UOSet', 'UOBTree', 'UOTreeSet',
'union', 'intersection', 'difference', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedObjectBTreeModule
from ._base import Bucket
from ._base import MERGE_WEIGHT_default
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
from ._base import to_ob as _to_value
from ._base import union as _union
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 60
_TREE_SIZE = 500
using64bits = False
class UOBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOSetPy(Set):
_to_key = _to_key
class UOBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE_WEIGHT = MERGE_WEIGHT_default
class UOTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
class UOTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UOBucketPy._mapping_type = UOBucketPy._bucket_type = UOBucketPy
UOBucketPy._set_type = UOSetPy
UOSetPy._mapping_type = UOBucketPy
UOSetPy._set_type = UOSetPy._bucket_type = UOSetPy
UOBTreePy._mapping_type = UOBTreePy._bucket_type = UOBucketPy
UOBTreePy._set_type = UOSetPy
UOTreeSetPy._mapping_type = UOBucketPy
UOTreeSetPy._set_type = UOTreeSetPy._bucket_type = UOSetPy
differencePy = _set_operation(_difference, UOSetPy)
unionPy = _set_operation(_union, UOSetPy)
intersectionPy = _set_operation(_intersection, UOSetPy)
multiunionPy = _set_operation(_multiunion, UOSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedObjectBTreeModule)
##############################################################################
#
# Copyright (c) 2001-2012 Zope Foundation 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
#
##############################################################################
__all__ = ('Bucket', 'Set', 'BTree', 'TreeSet',
'UUBucket', 'UUSet', 'UUBTree', 'UUTreeSet',
'union', 'intersection', 'difference',
'weightedUnion', 'weightedIntersection', 'multiunion',
)
from zope.interface import moduleProvides
from .Interfaces import IUnsignedUnsignedBTreeModule
from ._base import Bucket
from ._base import MERGE
from ._base import MERGE_WEIGHT_numeric
from ._base import MERGE_DEFAULT_int
from ._base import Set
from ._base import Tree as BTree
from ._base import TreeSet
from ._base import _TreeIterator
from ._base import difference as _difference
from ._base import intersection as _intersection
from ._base import multiunion as _multiunion
from ._base import set_operation as _set_operation
from ._base import to_uint as _to_key
_to_value = _to_key
from ._base import union as _union
from ._base import weightedIntersection as _weightedIntersection
from ._base import weightedUnion as _weightedUnion
from ._base import _fix_pickle
from ._compat import import_c_extension
_BUCKET_SIZE = 120
_TREE_SIZE = 500
using64bits = False
class UUBucketPy(Bucket):
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUSetPy(Set):
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUBTreePy(BTree):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
_to_value = _to_value
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeSetPy(TreeSet):
max_leaf_size = _BUCKET_SIZE
max_internal_size = _TREE_SIZE
_to_key = _to_key
MERGE = MERGE
MERGE_WEIGHT = MERGE_WEIGHT_numeric
MERGE_DEFAULT = MERGE_DEFAULT_int
class UUTreeIteratorPy(_TreeIterator):
pass
# Can't declare forward refs, so fix up afterwards:
UUBucketPy._mapping_type = UUBucketPy._bucket_type = UUBucketPy
UUBucketPy._set_type = UUSetPy
UUSetPy._mapping_type = UUBucketPy
UUSetPy._set_type = UUSetPy._bucket_type = UUSetPy
UUBTreePy._mapping_type = UUBTreePy._bucket_type = UUBucketPy
UUBTreePy._set_type = UUSetPy
UUTreeSetPy._mapping_type = UUBucketPy
UUTreeSetPy._set_type = UUTreeSetPy._bucket_type = UUSetPy
differencePy = _set_operation(_difference, UUSetPy)
unionPy = _set_operation(_union, UUSetPy)
intersectionPy = _set_operation(_intersection, UUSetPy)
multiunionPy = _set_operation(_multiunion, UUSetPy)
weightedUnionPy = _set_operation(_weightedUnion, UUSetPy)
weightedIntersectionPy = _set_operation(_weightedIntersection, UUSetPy)
import_c_extension(globals())
_fix_pickle(globals(), __name__)
moduleProvides(IUnsignedUnsignedBTreeModule)
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* IIBTree - int32_t key, uint32_t value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "IU"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__IUBTree
#else
#define INITMODULE init_IUBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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"
/* IIBTree - int64_t key, uint64_t value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "LQ"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__LQBTree
#else
#define INITMODULE init_LQBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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"
/* OQBTree - object key, uint64_t value BTree
Implements a collection using object type keys
and int type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "OQ"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 250
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__OQBTree
#else
#define INITMODULE init_OQBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* OUBTree - object key, uint32_t value BTree
Implements a collection using object type keys
and int type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "OU"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 250
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "objectkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__OUBTree
#else
#define INITMODULE init_OUBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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: _IFBTree.c 67074 2006-04-17 19:13:39Z fdrake $\n"
/* QFBTree - uint64_t key, float value BTree
Implements a collection using int type keys
and float type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "QF"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "floatvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__QFBTree
#else
#define INITMODULE init_QFBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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"
/* QLBTree - uint64_t key, int64_t value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "QL"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__QLBTree
#else
#define INITMODULE init_QLBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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"
/* QOBTree - uint64_t key, object value BTree
Implements a collection using int type keys
and object type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "QO"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__QOBTree
#else
#define INITMODULE init_QOBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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"
/* QQBTree - uint64_t key, uint64_t value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "QQ"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_64BIT_INTS
#define ZODB_UNSIGNED_KEY_INTS
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__QQBTree
#else
#define INITMODULE init_QQBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* IFBTree - unsigned int key, float value BTree
Implements a collection using int type keys
and float type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "UF"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "floatvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__UFBTree
#else
#define INITMODULE init_UFBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* IIBTree - unsigned int key, int value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "UI"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__UIBTree
#else
#define INITMODULE init_UIBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* UOBTree - unsigned int key, object value BTree
Implements a collection using unsigned int type keys
and object type values
*/
#define PERSISTENT
#define MOD_NAME_PREFIX "UO"
#define DEFAULT_MAX_BUCKET_SIZE 60
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_UNSIGNED_KEY_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "objectvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__UOBTree
#else
#define INITMODULE init_UOBTree
#endif
#include "BTreeModuleTemplate.c"
/*############################################################################
#
# Copyright (c) 2004 Zope Foundation 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$\n"
/* IIBTree - unsigned int key, unsigned int value BTree
Implements a collection using int type keys
and int type values
*/
/* Setup template macros */
#define PERSISTENT
#define MOD_NAME_PREFIX "UU"
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define ZODB_UNSIGNED_KEY_INTS
#define ZODB_UNSIGNED_VALUE_INTS
#include "_compat.h"
#include "intkeymacros.h"
#include "intvaluemacros.h"
#ifdef PY3K
#define INITMODULE PyInit__UUBTree
#else
#define INITMODULE init_UUBTree
#endif
#include "BTreeModuleTemplate.c"
......@@ -18,15 +18,23 @@ import BTrees.Interfaces
@zope.interface.implementer(BTrees.Interfaces.IBTreeFamily)
class _Family(object):
from BTrees import OOBTree as OO
class _Family32(_Family):
from BTrees import OIBTree as OI
from BTrees import OUBTree as OU
from BTrees import IFBTree as IF
from BTrees import IIBTree as II
from BTrees import IOBTree as IO
from BTrees import IFBTree as IF
from BTrees import IUBTree as IU
from BTrees import UFBTree as UF
from BTrees import UIBTree as UI
from BTrees import UOBTree as UO
from BTrees import UUBTree as UU
maxuint = int(2**32)
maxint = int(2**31-1)
minint = -maxint - 1
......@@ -35,10 +43,19 @@ class _Family32(_Family):
class _Family64(_Family):
from BTrees import OLBTree as OI
from BTrees import OQBTree as OU
from BTrees import LFBTree as IF
from BTrees import LLBTree as II
from BTrees import LOBTree as IO
from BTrees import LFBTree as IF
from BTrees import LQBTree as IU
from BTrees import QFBTree as UF
from BTrees import QLBTree as UI
from BTrees import QOBTree as UO
from BTrees import QQBTree as UU
maxuint = 2**64
maxint = 2**63-1
minint = -maxint - 1
......@@ -57,13 +74,10 @@ _family64.__safe_for_unpickling__ = True
family32 = _Family32()
family64 = _Family64()
BTrees.family64.IO.family = family64
BTrees.family64.OI.family = family64
BTrees.family64.IF.family = family64
BTrees.family64.II.family = family64
BTrees.family32.IO.family = family32
BTrees.family32.OI.family = family32
BTrees.family32.IF.family = family32
BTrees.family32.II.family = family32
for _family in family32, family64:
for _mod_name in (
"OI", "OU",
'IO', "II", "IF", "IU",
"UO", "UU", "UF", "UI",
):
getattr(_family, _mod_name).family = _family
......@@ -1509,6 +1509,18 @@ def to_int(self, v):
return int(v)
uint_pack, uint_unpack = _packer_unpacker('I')
def to_uint(self, v):
try:
uint_pack(index(v))
except (struct_error, TypeError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 32-bit integer expected')
return int(v)
float_pack = _packer_unpacker('f')[0]
def to_float(self, v):
......@@ -1526,11 +1538,24 @@ def to_long(self, v):
long_pack(index(v))
except (struct_error, TypeError):
if isinstance(v, int_types):
raise ValueError("Value out of range", v)
raise OverflowError("Value out of range", v)
raise TypeError('64-bit integer expected')
return int(v)
ulong_pack, ulong_unpack = _packer_unpacker('Q')
def to_ulong(self, v):
try:
ulong_pack(index(v))
except (struct_error, TypeError):
if isinstance(v, int_types):
raise OverflowError("Value out of range", v)
raise TypeError('non-negative 64-bit integer expected')
return int(v)
def to_bytes(l):
def to(self, v):
if not (isinstance(v, bytes) and len(v) == l):
......@@ -1538,7 +1563,7 @@ def to_bytes(l):
return v
return to
tos = dict(I=to_int, L=to_long, F=to_float, O=to_ob)
tos = dict(I=to_int, L=to_long, F=to_float, O=to_ob, U=to_uint, Q=to_ulong)
MERGE_DEFAULT_int = 1
MERGE_DEFAULT_float = 1.0
......
......@@ -23,7 +23,15 @@
#define INTERN PyUnicode_InternFromString
#define INT_FROM_LONG(x) PyLong_FromLong(x)
#define INT_CHECK(x) PyLong_Check(x)
/* PyLong_AS_LONG isn't a documnted API function. But because of
* an issue in persistent/_compat.h, if we define it to be
* the documented function, PyLong_AsLong, we get
* warnings about macro redefinition. See
* https://github.com/zopefoundation/persistent/issues/125
*/
#define INT_AS_LONG(x) PyLong_AS_LONG(x)
#define UINT_FROM_LONG(x) PyLong_FromUnsignedLong(x)
#define UINT_AS_LONG(x) PyLong_AsUnsignedLong(x)
#define TEXT_FROM_STRING PyUnicode_FromString
#define TEXT_FORMAT PyUnicode_Format
......@@ -43,6 +51,8 @@
#define INT_FROM_LONG(x) PyInt_FromLong(x)
#define INT_CHECK(x) PyInt_Check(x)
#define INT_AS_LONG(x) PyInt_AS_LONG(x)
#define UINT_FROM_LONG(x) PyInt_FromSize_t(x)
#define UINT_AS_LONG(x) PyInt_AsUnsignedLongMask(x)
#define TEXT_FROM_STRING PyString_FromString
#define TEXT_FORMAT PyString_Format
......
......@@ -32,24 +32,57 @@ addresses and/or object identity (the synthesized bucket has an address
that doesn't exist in the actual BTree).
"""
# 32-bit signed int
from BTrees.IFBTree import IFBTree, IFBucket, IFSet, IFTreeSet
from BTrees.IFBTree import IFBTreePy, IFBucketPy, IFSetPy, IFTreeSetPy
from BTrees.IIBTree import IIBTree, IIBucket, IISet, IITreeSet
from BTrees.IIBTree import IIBTreePy, IIBucketPy, IISetPy, IITreeSetPy
from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from BTrees.IOBTree import IOBTreePy, IOBucketPy, IOSetPy, IOTreeSetPy
from BTrees.IUBTree import IUBTree, IUBucket, IUSet, IUTreeSet
from BTrees.IUBTree import IUBTreePy, IUBucketPy, IUSetPy, IUTreeSetPy
# 32-bit unsigned int
from BTrees.UFBTree import UFBTree, UFBucket, UFSet, UFTreeSet
from BTrees.UFBTree import UFBTreePy, UFBucketPy, UFSetPy, UFTreeSetPy
from BTrees.UIBTree import UIBTree, UIBucket, UISet, UITreeSet
from BTrees.UIBTree import UIBTreePy, UIBucketPy, UISetPy, UITreeSetPy
from BTrees.UOBTree import UOBTree, UOBucket, UOSet, UOTreeSet
from BTrees.UOBTree import UOBTreePy, UOBucketPy, UOSetPy, UOTreeSetPy
from BTrees.UUBTree import UUBTree, UUBucket, UUSet, UUTreeSet
from BTrees.UUBTree import UUBTreePy, UUBucketPy, UUSetPy, UUTreeSetPy
# 64-bit signed int
from BTrees.LFBTree import LFBTree, LFBucket, LFSet, LFTreeSet
from BTrees.LFBTree import LFBTreePy, LFBucketPy, LFSetPy, LFTreeSetPy
from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
from BTrees.LLBTree import LLBTreePy, LLBucketPy, LLSetPy, LLTreeSetPy
from BTrees.LOBTree import LOBTree, LOBucket, LOSet, LOTreeSet
from BTrees.LOBTree import LOBTreePy, LOBucketPy, LOSetPy, LOTreeSetPy
from BTrees.LQBTree import LQBTree, LQBucket, LQSet, LQTreeSet
from BTrees.LQBTree import LQBTreePy, LQBucketPy, LQSetPy, LQTreeSetPy
# 64-bit unsigned int
from BTrees.QFBTree import QFBTree, QFBucket, QFSet, QFTreeSet
from BTrees.QFBTree import QFBTreePy, QFBucketPy, QFSetPy, QFTreeSetPy
from BTrees.QLBTree import QLBTree, QLBucket, QLSet, QLTreeSet
from BTrees.QLBTree import QLBTreePy, QLBucketPy, QLSetPy, QLTreeSetPy
from BTrees.QOBTree import QOBTree, QOBucket, QOSet, QOTreeSet
from BTrees.QOBTree import QOBTreePy, QOBucketPy, QOSetPy, QOTreeSetPy
from BTrees.QQBTree import QQBTree, QQBucket, QQSet, QQTreeSet
from BTrees.QQBTree import QQBTreePy, QQBucketPy, QQSetPy, QQTreeSetPy
from BTrees.OIBTree import OIBTree, OIBucket, OISet, OITreeSet
from BTrees.OIBTree import OIBTreePy, OIBucketPy, OISetPy, OITreeSetPy
from BTrees.OLBTree import OLBTree, OLBucket, OLSet, OLTreeSet
from BTrees.OLBTree import OLBTreePy, OLBucketPy, OLSetPy, OLTreeSetPy
from BTrees.OOBTree import OOBTree, OOBucket, OOSet, OOTreeSet
from BTrees.OOBTree import OOBTreePy, OOBucketPy, OOSetPy, OOTreeSetPy
from BTrees.OUBTree import OUBTree, OUBucket, OUSet, OUTreeSet
from BTrees.OUBTree import OUBTreePy, OUBucketPy, OUSetPy, OUTreeSetPy
from BTrees.OQBTree import OQBTree, OQBucket, OQSet, OQTreeSet
from BTrees.OQBTree import OQBTreePy, OQBucketPy, OQSetPy, OQTreeSetPy
from BTrees.utils import positive_id
from BTrees.utils import oid_repr
......@@ -59,17 +92,22 @@ TYPE_UNKNOWN, TYPE_BTREE, TYPE_BUCKET = range(3)
from ._compat import compare
_type2kind = {}
for kv in ('OO',
'II', 'IO', 'OI', 'IF',
'LL', 'LO', 'OL', 'LF',
):
_FAMILIES = (
'OO', 'OI', 'OU', 'OL', 'OQ',
'II', 'IO', 'IF', 'IU',
'LL', 'LO', 'LF', 'LQ',
'UU', 'UO', 'UF', 'UI',
'QQ', 'QO', 'QF', 'QL',
# Note that fs is missing from this list.
)
for kv in _FAMILIES:
for name, kind in (
('BTree', (TYPE_BTREE, True)),
('Bucket', (TYPE_BUCKET, True)),
('TreeSet', (TYPE_BTREE, False)),
('Set', (TYPE_BUCKET, False)),
):
_type2kind[globals()[kv+name]] = kind
('BTree', (TYPE_BTREE, True)),
('Bucket', (TYPE_BUCKET, True)),
('TreeSet', (TYPE_BTREE, False)),
('Set', (TYPE_BUCKET, False)),
):
_type2kind[globals()[kv + name]] = kind
py = kv + name + 'Py'
_type2kind[globals()[py]] = kind
......@@ -122,10 +160,7 @@ BTREE_EMPTY, BTREE_ONE, BTREE_NORMAL = range(3)
# )
_btree2bucket = {}
for kv in ('OO',
'II', 'IO', 'OI', 'IF',
'LL', 'LO', 'OL', 'LF',
):
for kv in _FAMILIES:
_btree2bucket[globals()[kv+'BTree']] = globals()[kv+'Bucket']
py = kv + 'BTreePy'
_btree2bucket[globals()[py]] = globals()[kv+'BucketPy']
......
#define KEYMACROS_H "$Id$\n"
#ifndef ZODB_UNSIGNED_KEY_INTS
/* signed keys */
#ifdef ZODB_64BIT_INTS
/* PY_LONG_LONG as key */
#define NEED_LONG_LONG_SUPPORT
......@@ -12,7 +14,7 @@
if (!longlong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
}
#else
/* C int as key */
#define KEY_TYPE int
......@@ -31,6 +33,43 @@
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
(STATUS)=0; (TARGET)=0; }
#endif
#else
/* Unsigned keys */
#ifdef ZODB_64BIT_INTS
/* PY_LONG_LONG as key */
#define NEED_LONG_LONG_SUPPORT
#define NEED_LONG_LONG_KEYS
#define KEY_TYPE unsigned PY_LONG_LONG
#define KEY_CHECK ulonglong_check
#define COPY_KEY_TO_OBJECT(O, K) O=ulonglong_as_object(K)
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (!ulonglong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
#else
/* C int as key */
#define KEY_TYPE unsigned int
#define KEY_CHECK INT_CHECK
#define COPY_KEY_TO_OBJECT(O, K) O=UINT_FROM_LONG(K)
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (INT_CHECK(ARG)) { \
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if (vcopy < 0) { \
PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); \
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
} else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
(STATUS)=0; (TARGET)=0; }
#endif
#endif /* ZODB_SIGNED_KEY_INTS */
#undef KEY_TYPE_IS_PYOBJECT
#define TEST_KEY_SET_OR(V, K, T) if ( ( (V) = (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0)) ) , 0 )
......
#define VALUEMACROS_H "$Id$\n"
/*
VALUE_PARSE is used exclusively in SetOpTemplate.c to accept the weight
values for merging. The PyArg_ParseTuple function it uses has no trivial way
to express "unsigned with check", so in the unsigned case, passing negative
values as weights will produce weird output no matter what VALUE_PARSE we
use (because it will immediately get cast to an unsigned).
*/
#ifndef ZODB_UNSIGNED_VALUE_INTS
/*signed values */
#ifdef ZODB_64BIT_INTS
#define NEED_LONG_LONG_SUPPORT
#define VALUE_TYPE PY_LONG_LONG
......@@ -10,7 +20,7 @@
if (!longlong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
}
#else
#define VALUE_TYPE int
#define VALUE_PARSE "i"
......@@ -30,9 +40,47 @@
(STATUS)=0; (TARGET)=0; }
#endif
#else
/* unsigned values */
#ifdef ZODB_64BIT_INTS
/* unsigned, 64-bit values */
#define NEED_LONG_LONG_SUPPORT
#define VALUE_TYPE unsigned PY_LONG_LONG
#define VALUE_PARSE "K"
#define COPY_VALUE_TO_OBJECT(O, K) O=ulonglong_as_object(K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
if (!ulonglong_convert((ARG), &TARGET)) \
{ \
(STATUS)=0; (TARGET)=0; \
}
#else
/* unsigned, 32-bit values */
#define VALUE_TYPE unsigned int
#define VALUE_PARSE "I"
#define COPY_VALUE_TO_OBJECT(O, K) O=UINT_FROM_LONG(K)
#define COPY_VALUE_FROM_ARG(TARGET, ARG, STATUS) \
if (INT_CHECK(ARG)) { \
long vcopy = INT_AS_LONG(ARG); \
if (PyErr_Occurred()) { (STATUS)=0; (TARGET)=0; } \
else if (vcopy < 0) { \
PyErr_SetString(PyExc_OverflowError, "can't convert negative value to unsigned int"); \
(STATUS)=0; (TARGET)=0; \
} \
else if ((unsigned int)vcopy != vcopy) { \
PyErr_SetString(PyExc_TypeError, "integer out of range"); \
(STATUS)=0; (TARGET)=0; \
} \
else TARGET = vcopy; \
} else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
(STATUS)=0; (TARGET)=0; }
#endif
#endif
#undef VALUE_TYPE_IS_PYOBJECT
#define TEST_VALUE(K, T) (((K) < (T)) ? -1 : (((K) > (T)) ? 1: 0))
#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 DECREF_VALUE(k)
......
This diff is collapsed.
......@@ -484,8 +484,8 @@ class FamilyTest(unittest.TestCase):
self.assertTrue(BTrees.family64.minint in s)
s = LOTreeSet()
# XXX why oh why do we expect ValueError here, but TypeError in test32?
self.assertRaises(ValueError, s.insert, BTrees.family64.maxint + 1)
self.assertRaises(ValueError, s.insert, BTrees.family64.minint - 1)
self.assertRaises((TypeError, OverflowError), s.insert, BTrees.family64.maxint + 1)
self.assertRaises((TypeError, OverflowError), s.insert, BTrees.family64.minint - 1)
self.check_pickling(BTrees.family64)
def check_pickling(self, family):
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -2963,7 +2963,7 @@ class Test_helpers(unittest.TestCase):
def test_to_long_w_overflow(self):
from BTrees._base import to_long
faux_self = object()
self.assertRaises(ValueError, to_long, faux_self, 2**64)
self.assertRaises(OverflowError, to_long, faux_self, 2**64)
def test_to_long_w_invalid(self):
from BTrees._base import to_long
......
......@@ -2,10 +2,13 @@
BTrees Changelog
==================
4.6.2 (unreleased)
4.7.0 (unreleased)
==================
- Nothing changed yet.
- Add unsigned variants of the trees. These use the initial "U" for
32-bit data and "Q" for 64-bit data (for "quad", which is similar to
what the C ``printf`` function uses and the Python struct module
uses).
- Fix the value for ``BTrees.OIBTree.using64bits`` when using the pure Python
implementation (PyPy and when ``PURE_PYTHON`` is in the environment).
......
......@@ -104,9 +104,44 @@ base_btrees_depends = [
"BTrees/sorters.c",
]
FLAVORS = {"O": "object", "I": "int", "F": "float", 'L': 'int'}
FLAVORS = {
"O": "object",
"F": "float",
"I": "int", # Signed 32-bit
"L": "int", # Signed 64-bit
"U": "int", # Unsigned 32-bit
"Q": "int" # Unsigned 64-bit (from the printf "q" modifier for quad_t)
}
# XXX should 'fs' be in ZODB instead?
FAMILIES = ("OO", "IO", "OI", "II", "IF", "fs", "LO", "OL", "LL", "LF")
FAMILIES = (
# Signed 32-bit keys
"IO", # object value
"II", # self value
"IF", # float value
"IU", # opposite sign value
# Unsigned 32-bit keys
"UO", # object value
"UU", # self value
"UF", # float value
"UI", # opposite sign value
# Signed 64-bit keys
"LO", # object value
"LL", # self value
"LF", # float value
"LQ", # opposite sign value
# Unsigned 64-bit keys
"QO", # object value
"QQ", # self value
"QF", # float value
"QL", # opposite sign value
# Object keys
"OO", # object
"OI", # 32-bit signed
"OU", # 32-bit unsigned
"OL", # 64-bit signed
"OQ", # 64-bit unsigned
"fs",
)
KEY_H = "BTrees/%skeymacros.h"
VALUE_H = "BTrees/%svaluemacros.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment