Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
9ed982a4
Commit
9ed982a4
authored
Apr 25, 2007
by
Gary Poster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add integer family conveniences
parent
1f20f799
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
108 additions
and
1 deletion
+108
-1
src/BTrees/Interfaces.py
src/BTrees/Interfaces.py
+27
-0
src/BTrees/__init__.py
src/BTrees/__init__.py
+12
-1
src/BTrees/tests/testBTrees.py
src/BTrees/tests/testBTrees.py
+69
-0
No files found.
src/BTrees/Interfaces.py
View file @
9ed982a4
...
@@ -440,10 +440,27 @@ class IMergeIntegerKey(IMerge):
...
@@ -440,10 +440,27 @@ class IMergeIntegerKey(IMerge):
linear-time pass.
linear-time pass.
"""
"""
class
IIntegerFamily
(
Interface
):
"""the 64-bit or 32-bit family"""
IOModule
=
Attribute
(
'The IIntegerObjectBTreeModule for this family'
)
OIModule
=
Attribute
(
'The IObjectIntegerBTreeModule for this family'
)
IIModule
=
Attribute
(
'The IIntegerIntegerBTreeModule for this family'
)
IFModule
=
Attribute
(
'The IIntegerFloatBTreeModule for this family'
)
maxint
=
Attribute
(
'The maximum integer storable in this family'
)
minint
=
Attribute
(
'The minimum integer storable in this family'
)
class
IIntegerObjectBTreeModule
(
IBTreeModule
,
IMerge
):
class
IIntegerObjectBTreeModule
(
IBTreeModule
,
IMerge
):
"""keys, or set values, are integers; values are objects.
"""keys, or set values, are integers; values are objects.
describes IOBTree and LOBTree"""
describes IOBTree and LOBTree"""
family
=
Attribute
(
'The IIntegerFamily of this module'
)
class
IObjectIntegerBTreeModule
(
IBTreeModule
,
IIMerge
):
class
IObjectIntegerBTreeModule
(
IBTreeModule
,
IIMerge
):
"""keys, or set values, are objects; values are integers.
"""keys, or set values, are objects; values are integers.
...
@@ -452,11 +469,17 @@ class IObjectIntegerBTreeModule(IBTreeModule, IIMerge):
...
@@ -452,11 +469,17 @@ class IObjectIntegerBTreeModule(IBTreeModule, IIMerge):
object id)! Homogenous key types recommended.
object id)! Homogenous key types recommended.
describes OIBTree and LOBTree"""
describes OIBTree and LOBTree"""
family
=
Attribute
(
'The IIntegerFamily of this module'
)
class
IIntegerIntegerBTreeModule
(
IBTreeModule
,
IIMerge
,
IMergeIntegerKey
):
class
IIntegerIntegerBTreeModule
(
IBTreeModule
,
IIMerge
,
IMergeIntegerKey
):
"""keys, or set values, are integers; values are also integers.
"""keys, or set values, are integers; values are also integers.
describes IIBTree and LLBTree"""
describes IIBTree and LLBTree"""
family
=
Attribute
(
'The IIntegerFamily of this module'
)
class
IObjectObjectBTreeModule
(
IBTreeModule
,
IMerge
):
class
IObjectObjectBTreeModule
(
IBTreeModule
,
IMerge
):
"""keys, or set values, are objects; values are also objects.
"""keys, or set values, are objects; values are also objects.
...
@@ -466,10 +489,14 @@ class IObjectObjectBTreeModule(IBTreeModule, IMerge):
...
@@ -466,10 +489,14 @@ class IObjectObjectBTreeModule(IBTreeModule, IMerge):
describes OOBTree"""
describes OOBTree"""
class
IIntegerFloatBTreeModule
(
IBTreeModule
,
IMerge
):
class
IIntegerFloatBTreeModule
(
IBTreeModule
,
IMerge
):
"""keys, or set values, are integers; values are floats.
"""keys, or set values, are integers; values are floats.
describes IFBTree and LFBTree"""
describes IFBTree and LFBTree"""
family
=
Attribute
(
'The IIntegerFamily of this module'
)
###############################################################
###############################################################
# IMPORTANT NOTE
# IMPORTANT NOTE
...
...
src/BTrees/__init__.py
View file @
9ed982a4
# This is a Python package.
import
BTrees.family64
import
BTrees.family32
BTrees
.
family64
.
IOModule
.
family
=
BTrees
.
family64
BTrees
.
family64
.
OIModule
.
family
=
BTrees
.
family64
BTrees
.
family64
.
IFModule
.
family
=
BTrees
.
family64
BTrees
.
family64
.
IIModule
.
family
=
BTrees
.
family64
BTrees
.
family32
.
IOModule
.
family
=
BTrees
.
family32
BTrees
.
family32
.
OIModule
.
family
=
BTrees
.
family32
BTrees
.
family32
.
IFModule
.
family
=
BTrees
.
family32
BTrees
.
family32
.
IIModule
.
family
=
BTrees
.
family32
src/BTrees/tests/testBTrees.py
View file @
9ed982a4
...
@@ -26,6 +26,8 @@ from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
...
@@ -26,6 +26,8 @@ from BTrees.LLBTree import LLBTree, LLBucket, LLSet, LLTreeSet
from
BTrees.LFBTree
import
LFBTree
,
LFBucket
,
LFSet
,
LFTreeSet
from
BTrees.LFBTree
import
LFBTree
,
LFBucket
,
LFSet
,
LFTreeSet
from
BTrees.OLBTree
import
OLBTree
,
OLBucket
,
OLSet
,
OLTreeSet
from
BTrees.OLBTree
import
OLBTree
,
OLBucket
,
OLSet
,
OLTreeSet
import
BTrees.family32
import
BTrees.family64
import
BTrees.OOBTree
import
BTrees.OOBTree
import
BTrees.IOBTree
import
BTrees.IOBTree
import
BTrees.IIBTree
import
BTrees.IIBTree
...
@@ -1676,6 +1678,72 @@ class ModuleTest(TestCase):
...
@@ -1676,6 +1678,72 @@ class ModuleTest(TestCase):
self
.
assert_
(
self
.
assert_
(
zope
.
interface
.
verify
.
verifyObject
(
self
.
iface
,
self
.
module
))
zope
.
interface
.
verify
.
verifyObject
(
self
.
iface
,
self
.
module
))
def
testFamily
(
self
):
if
self
.
prefix
==
'OO'
:
self
.
assert_
(
getattr
(
self
.
module
,
'family'
,
self
)
is
self
)
elif
'L'
in
self
.
prefix
:
self
.
assert_
(
self
.
module
.
family
is
BTrees
.
family64
)
elif
'I'
in
self
.
prefix
:
self
.
assert_
(
self
.
module
.
family
is
BTrees
.
family32
)
class
FamilyTest
(
TestCase
):
def
test32
(
self
):
self
.
assert_
(
zope
.
interface
.
verify
.
verifyObject
(
BTrees
.
Interfaces
.
IIntegerFamily
,
BTrees
.
family32
))
self
.
assertEquals
(
BTrees
.
family32
.
IOModule
,
BTrees
.
IOBTree
)
self
.
assertEquals
(
BTrees
.
family32
.
OIModule
,
BTrees
.
OIBTree
)
self
.
assertEquals
(
BTrees
.
family32
.
IIModule
,
BTrees
.
IIBTree
)
self
.
assertEquals
(
BTrees
.
family32
.
IFModule
,
BTrees
.
IFBTree
)
s
=
IOTreeSet
()
s
.
insert
(
BTrees
.
family32
.
maxint
)
self
.
assert_
(
BTrees
.
family32
.
maxint
in
s
)
s
=
IOTreeSet
()
s
.
insert
(
BTrees
.
family32
.
minint
)
self
.
assert_
(
BTrees
.
family32
.
minint
in
s
)
s
=
IOTreeSet
()
# this next bit illustrates an, um, "interesting feature". If
# the characteristics change to match the 64 bit version, please
# feel free to change.
big
=
BTrees
.
family32
.
maxint
+
1
if
isinstance
(
big
,
long
):
self
.
assertRaises
(
TypeError
,
s
.
insert
,
big
)
self
.
assertRaises
(
TypeError
,
s
.
insert
,
BTrees
.
family32
.
minint
-
1
)
else
:
# 64 bit Python
s
.
insert
(
BTrees
.
family32
.
maxint
+
1
)
self
.
assert_
(
BTrees
.
family32
.
maxint
+
1
not
in
s
)
# yeah, it's len of 1 now...don't look...don't look...
s
=
IOTreeSet
()
s
.
insert
(
BTrees
.
family32
.
minint
-
1
)
self
.
assert_
(
BTrees
.
family32
.
minint
-
1
not
in
s
)
def
test64
(
self
):
self
.
assert_
(
zope
.
interface
.
verify
.
verifyObject
(
BTrees
.
Interfaces
.
IIntegerFamily
,
BTrees
.
family64
))
self
.
assertEquals
(
BTrees
.
family64
.
IOModule
,
BTrees
.
LOBTree
)
self
.
assertEquals
(
BTrees
.
family64
.
OIModule
,
BTrees
.
OLBTree
)
self
.
assertEquals
(
BTrees
.
family64
.
IIModule
,
BTrees
.
LLBTree
)
self
.
assertEquals
(
BTrees
.
family64
.
IFModule
,
BTrees
.
LFBTree
)
s
=
LOTreeSet
()
s
.
insert
(
BTrees
.
family64
.
maxint
)
self
.
assert_
(
BTrees
.
family64
.
maxint
in
s
)
s
=
LOTreeSet
()
s
.
insert
(
BTrees
.
family64
.
minint
)
self
.
assert_
(
BTrees
.
family64
.
minint
in
s
)
s
=
LOTreeSet
()
self
.
assertRaises
(
ValueError
,
s
.
insert
,
BTrees
.
family64
.
maxint
+
1
)
self
.
assertRaises
(
ValueError
,
s
.
insert
,
BTrees
.
family64
.
minint
-
1
)
def
test_suite
():
def
test_suite
():
s
=
TestSuite
()
s
=
TestSuite
()
...
@@ -1723,6 +1791,7 @@ def test_suite():
...
@@ -1723,6 +1791,7 @@ def test_suite():
DegenerateBTree
,
DegenerateBTree
,
TestCmpError
,
TestCmpError
,
BugFixes
,
BugFixes
,
FamilyTest
,
):
):
s
.
addTest
(
makeSuite
(
klass
))
s
.
addTest
(
makeSuite
(
klass
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment