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
Kirill Smelkov
ZODB
Commits
c22307fb
Commit
c22307fb
authored
Jun 25, 2002
by
Tim Peters
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enabled multiunion() for the IOBTree package too. There isn't a good
reason for it not being enabled before.
parent
ad85dfb9
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
24 deletions
+37
-24
src/BTrees/Maintainer.txt
src/BTrees/Maintainer.txt
+2
-2
src/BTrees/_IIBTree.c
src/BTrees/_IIBTree.c
+1
-2
src/BTrees/intkeymacros.h
src/BTrees/intkeymacros.h
+3
-2
src/BTrees/tests/testSetOps.py
src/BTrees/tests/testSetOps.py
+31
-18
No files found.
src/BTrees/Maintainer.txt
View file @
c22307fb
...
...
@@ -138,8 +138,8 @@ mappings. If left undefined, MERGE_WEIGHT defaults to
MULTI_INT_UNION
The value doesn't matter. If defined, SetOpTemplate.c compiles
code for a multiunion() function (compute a union of many input sets
at high speed). This currently makes sense only for
II sets, so
only _IIBTree.c defines it
.
at high speed). This currently makes sense only for
structures with
integer keys
.
BTree Clues
...
...
src/BTrees/_IIBTree.c
View file @
c22307fb
/* Setup template macros */
#define MASTER_ID "$Id: _IIBTree.c,v 1.
6 2002/05/30 21:00:30
tim_one Exp $\n"
#define MASTER_ID "$Id: _IIBTree.c,v 1.
7 2002/06/25 02:00:55
tim_one Exp $\n"
#define PERSISTENT
...
...
@@ -8,7 +8,6 @@
#define INITMODULE init_IIBTree
#define DEFAULT_MAX_BUCKET_SIZE 120
#define DEFAULT_MAX_BTREE_SIZE 500
#define MULTI_INT_UNION 1
#include "intkeymacros.h"
#include "intvaluemacros.h"
...
...
src/BTrees/intkeymacros.h
View file @
c22307fb
#define KEYMACROS_H "$Id: intkeymacros.h,v 1.
8 2002/05/31 09:41:07 htrd
Exp $\n"
#define KEYMACROS_H "$Id: intkeymacros.h,v 1.
9 2002/06/25 02:00:55 tim_one
Exp $\n"
#define KEY_TYPE int
#define KEY_CHECK PyInt_Check
...
...
@@ -11,4 +11,5 @@
#define COPY_KEY_FROM_ARG(TARGET, ARG, STATUS) \
if (PyInt_Check(ARG)) TARGET=PyInt_AS_LONG(ARG); else { \
PyErr_SetString(PyExc_TypeError, "expected integer key"); \
(STATUS)=0; (TARGET)=0; }
(STATUS)=0; (TARGET)=0; }
#define MULTI_INT_UNION 1
src/BTrees/tests/testSetOps.py
View file @
c22307fb
...
...
@@ -19,8 +19,6 @@ from BTrees.IOBTree import IOBTree, IOBucket, IOSet, IOTreeSet
from
BTrees.IIBTree
import
IIBTree
,
IIBucket
,
IISet
,
IITreeSet
from
BTrees.OIBTree
import
OIBTree
,
OIBucket
,
OISet
,
OITreeSet
from
BTrees.IIBTree
import
multiunion
# XXX TODO Needs more tests.
# This file was created when multiunion was added. The other set operations
# don't appear to be tested anywhere yet.
...
...
@@ -195,10 +193,14 @@ class PureOI(SetResult):
from
BTrees.OIBTree
import
union
,
intersection
,
difference
builders
=
OISet
,
OITreeSet
,
makeBuilder
(
OIBTree
),
makeBuilder
(
OIBucket
)
class
TestMultiUnion
(
TestCase
):
# Subclasses must set up (as class variables):
# multiunion, union
# mkset, mktreeset
# mkbucket, mkbtree
class
MultiUnion
(
TestCase
):
def
testEmpty
(
self
):
self
.
assertEqual
(
len
(
multiunion
([])),
0
)
self
.
assertEqual
(
len
(
self
.
multiunion
([])),
0
)
def
testOne
(
self
):
for
sequence
in
[
3
],
range
(
20
),
range
(
-
10
,
0
,
2
)
+
range
(
1
,
10
,
2
):
...
...
@@ -208,22 +210,22 @@ class TestMultiUnion(TestCase):
seqsorted
=
sequence
[:]
seqsorted
.
sort
()
for
seq
in
seq1
,
seq2
,
seqsorted
:
for
builder
in
IISet
,
IITreeS
et
:
for
builder
in
self
.
mkset
,
self
.
mktrees
et
:
input
=
builder
(
seq
)
output
=
multiunion
([
input
])
output
=
self
.
multiunion
([
input
])
self
.
assertEqual
(
len
(
seq
),
len
(
output
))
self
.
assertEqual
(
seqsorted
,
list
(
output
))
def
testValuesIgnored
(
self
):
for
builder
in
IIBucket
,
IIBT
ree
:
for
builder
in
self
.
mkbucket
,
self
.
mkbt
ree
:
input
=
builder
([(
1
,
2
),
(
3
,
4
),
(
5
,
6
)])
output
=
multiunion
([
input
])
output
=
self
.
multiunion
([
input
])
self
.
assertEqual
([
1
,
3
,
5
],
list
(
output
))
def
testBigInput
(
self
):
N
=
100000
input
=
IIS
et
(
range
(
N
))
output
=
multiunion
([
input
]
*
10
)
input
=
self
.
mks
et
(
range
(
N
))
output
=
self
.
multiunion
([
input
]
*
10
)
self
.
assertEqual
(
len
(
output
),
N
)
self
.
assertEqual
(
output
.
minKey
(),
0
)
self
.
assertEqual
(
output
.
maxKey
(),
N
-
1
)
...
...
@@ -233,32 +235,43 @@ class TestMultiUnion(TestCase):
from
random
import
shuffle
N
=
5000
inputs
=
[]
mkset
,
mktreeset
=
self
.
mkset
,
self
.
mktreeset
for
i
in
range
(
N
):
base
=
i
*
4
-
N
inputs
.
append
(
IIS
et
([
base
,
base
+
1
]))
inputs
.
append
(
IITreeS
et
([
base
+
2
,
base
+
3
]))
inputs
.
append
(
mks
et
([
base
,
base
+
1
]))
inputs
.
append
(
mktrees
et
([
base
+
2
,
base
+
3
]))
shuffle
(
inputs
)
output
=
multiunion
(
inputs
)
output
=
self
.
multiunion
(
inputs
)
self
.
assertEqual
(
len
(
output
),
N
*
4
)
self
.
assertEqual
(
list
(
output
),
range
(
-
N
,
3
*
N
))
def
testFunkyKeyIteration
(
self
):
# The internal set iteration protocol allows "iterating over" a
# a single key as if it were a set.
from
BTrees.IIBTree
import
union
N
=
100
slow
=
IISet
()
union
,
mkset
=
self
.
union
,
self
.
mkset
slow
=
mkset
()
for
i
in
range
(
N
):
slow
=
union
(
slow
,
IIS
et
([
i
]))
fast
=
multiunion
(
range
(
N
))
# acts like N distinct singleton sets
slow
=
union
(
slow
,
mks
et
([
i
]))
fast
=
self
.
multiunion
(
range
(
N
))
# acts like N distinct singleton sets
self
.
assertEqual
(
len
(
slow
),
N
)
self
.
assertEqual
(
len
(
fast
),
N
)
self
.
assertEqual
(
list
(
slow
.
keys
()),
list
(
fast
.
keys
()))
self
.
assertEqual
(
list
(
fast
.
keys
()),
range
(
N
))
class
TestIIMultiUnion
(
MultiUnion
):
from
BTrees.IIBTree
import
multiunion
,
union
from
BTrees.IIBTree
import
IISet
as
mkset
,
IITreeSet
as
mktreeset
from
BTrees.IIBTree
import
IIBucket
as
mkbucket
,
IIBTree
as
mkbtree
class
TestIOMultiUnion
(
MultiUnion
):
from
BTrees.IOBTree
import
multiunion
,
union
from
BTrees.IOBTree
import
IOSet
as
mkset
,
IOTreeSet
as
mktreeset
from
BTrees.IOBTree
import
IOBucket
as
mkbucket
,
IOBTree
as
mkbtree
def
test_suite
():
s
=
TestSuite
()
for
klass
in
(
TestMultiUnion
,
for
klass
in
(
Test
IIMultiUnion
,
TestIO
MultiUnion
,
PureII
,
PureIO
,
PureOI
,
PureOO
):
s
.
addTest
(
makeSuite
(
klass
))
return
s
...
...
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