Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
B
BTrees
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
BTrees
Commits
2383c68a
Commit
2383c68a
authored
Dec 12, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factor out common iterator prep.
Skip looking up unused MERGE WEIGHT for weightedIntersection.
parent
8ccd3b40
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
19 deletions
+14
-19
BTrees/_base.py
BTrees/_base.py
+14
-19
No files found.
BTrees/_base.py
View file @
2383c68a
...
@@ -1272,6 +1272,18 @@ def intersection(set_type, o1, o2):
...
@@ -1272,6 +1272,18 @@ def intersection(set_type, o1, o2):
i2
.
advance
()
i2
.
advance
()
return
result
return
result
def
_prepMergeIterators
(
o1
,
o2
):
MERGE_DEFAULT
=
getattr
(
o1
,
'MERGE_DEFAULT'
,
None
)
i1
=
_SetIteration
(
o1
,
True
,
MERGE_DEFAULT
)
i2
=
_SetIteration
(
o2
,
True
,
MERGE_DEFAULT
)
if
MERGE_DEFAULT
is
None
:
if
i1
.
useValues
:
if
(
not
i2
.
useValues
):
raise
TypeError
(
"invalid set operation"
)
else
:
raise
TypeError
(
"invalid set operation"
)
return
i1
,
i2
def
weightedUnion
(
set_type
,
o1
,
o2
,
w1
=
1
,
w2
=
1
):
def
weightedUnion
(
set_type
,
o1
,
o2
,
w1
=
1
,
w2
=
1
):
if
o1
is
None
:
if
o1
is
None
:
if
o2
is
None
:
if
o2
is
None
:
...
@@ -1279,9 +1291,7 @@ def weightedUnion(set_type, o1, o2, w1=1, w2=1):
...
@@ -1279,9 +1291,7 @@ def weightedUnion(set_type, o1, o2, w1=1, w2=1):
return
w2
,
o2
return
w2
,
o2
if
o2
is
None
:
if
o2
is
None
:
return
w1
,
o1
return
w1
,
o1
MERGE_DEFAULT
=
getattr
(
o1
,
'MERGE_DEFAULT'
,
None
)
i1
,
i2
=
_prepMergeIterators
(
o1
,
o2
)
i1
=
_SetIteration
(
o1
,
True
,
MERGE_DEFAULT
)
i2
=
_SetIteration
(
o2
,
True
,
MERGE_DEFAULT
)
MERGE
=
getattr
(
o1
,
'MERGE'
,
None
)
MERGE
=
getattr
(
o1
,
'MERGE'
,
None
)
if
MERGE
is
None
and
i1
.
useValues
and
i2
.
useValues
:
if
MERGE
is
None
and
i1
.
useValues
and
i2
.
useValues
:
raise
TypeError
(
"invalid set operation"
)
raise
TypeError
(
"invalid set operation"
)
...
@@ -1289,12 +1299,6 @@ def weightedUnion(set_type, o1, o2, w1=1, w2=1):
...
@@ -1289,12 +1299,6 @@ def weightedUnion(set_type, o1, o2, w1=1, w2=1):
if
(
not
i1
.
useValues
)
and
i2
.
useValues
:
if
(
not
i1
.
useValues
)
and
i2
.
useValues
:
i1
,
i2
=
i2
,
i1
i1
,
i2
=
i2
,
i1
w1
,
w2
=
w2
,
w1
w1
,
w2
=
w2
,
w1
if
MERGE_DEFAULT
is
None
:
if
i1
.
useValues
:
if
(
not
i2
.
useValues
):
raise
TypeError
(
"invalid set operation"
)
else
:
raise
TypeError
(
"invalid set operation"
)
_merging
=
i1
.
useValues
or
i2
.
useValues
_merging
=
i1
.
useValues
or
i2
.
useValues
if
_merging
:
if
_merging
:
result
=
o1
.
_mapping_type
()
result
=
o1
.
_mapping_type
()
...
@@ -1335,22 +1339,13 @@ def weightedIntersection(set_type, o1, o2, w1=1, w2=1):
...
@@ -1335,22 +1339,13 @@ def weightedIntersection(set_type, o1, o2, w1=1, w2=1):
return
w2
,
o2
return
w2
,
o2
if
o2
is
None
:
if
o2
is
None
:
return
w1
,
o1
return
w1
,
o1
MERGE_DEFAULT
=
getattr
(
o1
,
'MERGE_DEFAULT'
,
None
)
i1
,
i2
=
_prepMergeIterators
(
o1
,
o2
)
i1
=
_SetIteration
(
o1
,
True
,
MERGE_DEFAULT
)
i2
=
_SetIteration
(
o2
,
True
,
MERGE_DEFAULT
)
MERGE
=
getattr
(
o1
,
'MERGE'
,
None
)
MERGE
=
getattr
(
o1
,
'MERGE'
,
None
)
if
MERGE
is
None
and
i1
.
useValues
and
i2
.
useValues
:
if
MERGE
is
None
and
i1
.
useValues
and
i2
.
useValues
:
raise
TypeError
(
"invalid set operation"
)
raise
TypeError
(
"invalid set operation"
)
MERGE_WEIGHT
=
getattr
(
o1
,
'MERGE_WEIGHT'
)
if
(
not
i1
.
useValues
)
and
i2
.
useValues
:
if
(
not
i1
.
useValues
)
and
i2
.
useValues
:
i1
,
i2
=
i2
,
i1
i1
,
i2
=
i2
,
i1
w1
,
w2
=
w2
,
w1
w1
,
w2
=
w2
,
w1
if
MERGE_DEFAULT
is
None
:
if
i1
.
useValues
:
if
(
not
i2
.
useValues
):
raise
TypeError
(
"invalid set operation"
)
else
:
raise
TypeError
(
"invalid set operation"
)
_merging
=
i1
.
useValues
or
i2
.
useValues
_merging
=
i1
.
useValues
or
i2
.
useValues
if
_merging
:
if
_merging
:
result
=
o1
.
_mapping_type
()
result
=
o1
.
_mapping_type
()
...
...
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