Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
Zope
Commits
8669d107
Commit
8669d107
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify key handling
parent
aa7d9cb8
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
17 deletions
+11
-17
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+11
-17
No files found.
src/Products/ZCatalog/plan.py
View file @
8669d107
...
@@ -77,6 +77,9 @@ del addCleanUp
...
@@ -77,6 +77,9 @@ del addCleanUp
def
make_key
(
catalog
,
query
):
def
make_key
(
catalog
,
query
):
if
not
query
:
return
None
indexes
=
catalog
.
indexes
indexes
=
catalog
.
indexes
valueindexes
=
determine_value_indexes
(
indexes
)
valueindexes
=
determine_value_indexes
(
indexes
)
key
=
keys
=
query
.
keys
()
key
=
keys
=
query
.
keys
()
...
@@ -108,10 +111,10 @@ class CatalogPlan(object):
...
@@ -108,10 +111,10 @@ class CatalogPlan(object):
"""
"""
def
__init__
(
self
,
catalog
,
query
=
None
,
threshold
=
0.1
):
def
__init__
(
self
,
catalog
,
query
=
None
,
threshold
=
0.1
):
self
.
init
()
self
.
init
_timer
()
self
.
catalog
=
catalog
self
.
catalog
=
catalog
self
.
query
=
query
self
.
query
=
query
self
.
_key
=
None
self
.
key
=
make_key
(
catalog
,
query
)
self
.
threshold
=
threshold
self
.
threshold
=
threshold
parent
=
aq_parent
(
catalog
)
parent
=
aq_parent
(
catalog
)
...
@@ -122,7 +125,7 @@ class CatalogPlan(object):
...
@@ -122,7 +125,7 @@ class CatalogPlan(object):
path
=
tuple
(
parent
.
getPhysicalPath
())
path
=
tuple
(
parent
.
getPhysicalPath
())
self
.
cid
=
path
self
.
cid
=
path
def
init
(
self
):
def
init
_timer
(
self
):
self
.
res
=
[]
self
.
res
=
[]
self
.
start_time
=
None
self
.
start_time
=
None
self
.
interim
=
{}
self
.
interim
=
{}
...
@@ -138,7 +141,7 @@ class CatalogPlan(object):
...
@@ -138,7 +141,7 @@ class CatalogPlan(object):
def
benchmark
(
self
):
def
benchmark
(
self
):
# holds the benchmark of each index
# holds the benchmark of each index
return
self
.
prioritymap
().
get
(
self
.
key
()
,
None
)
return
self
.
prioritymap
().
get
(
self
.
key
,
None
)
def
plan
(
self
):
def
plan
(
self
):
benchmark
=
self
.
benchmark
()
benchmark
=
self
.
benchmark
()
...
@@ -151,11 +154,11 @@ class CatalogPlan(object):
...
@@ -151,11 +154,11 @@ class CatalogPlan(object):
return
[
i
[
1
]
for
i
in
ranking
]
return
[
i
[
1
]
for
i
in
ranking
]
def
start
(
self
):
def
start
(
self
):
self
.
init
()
self
.
init
_timer
()
self
.
start_time
=
time
.
time
()
self
.
start_time
=
time
.
time
()
benchmark
=
self
.
benchmark
()
benchmark
=
self
.
benchmark
()
if
benchmark
is
None
:
if
benchmark
is
None
:
self
.
prioritymap
()[
self
.
key
()
]
=
{}
self
.
prioritymap
()[
self
.
key
]
=
{}
def
start_split
(
self
,
label
,
result
=
None
):
def
start_split
(
self
,
label
,
result
=
None
):
self
.
interim
[
label
]
=
(
time
.
time
(),
None
)
self
.
interim
[
label
]
=
(
time
.
time
(),
None
)
...
@@ -189,7 +192,7 @@ class CatalogPlan(object):
...
@@ -189,7 +192,7 @@ class CatalogPlan(object):
self
.
end_time
=
time
.
time
()
self
.
end_time
=
time
.
time
()
self
.
duration
=
self
.
end_time
-
self
.
start_time
self
.
duration
=
self
.
end_time
-
self
.
start_time
key
=
self
.
key
()
key
=
self
.
key
benchmark
=
self
.
benchmark
()
benchmark
=
self
.
benchmark
()
prioritymap
=
self
.
prioritymap
()
prioritymap
=
self
.
prioritymap
()
prioritymap
[
key
]
=
benchmark
prioritymap
[
key
]
=
benchmark
...
@@ -213,22 +216,13 @@ class CatalogPlan(object):
...
@@ -213,22 +216,13 @@ class CatalogPlan(object):
def
result
(
self
):
def
result
(
self
):
return
(
self
.
duration
,
tuple
(
self
.
res
))
return
(
self
.
duration
,
tuple
(
self
.
res
))
def
key
(
self
):
if
not
self
.
_key
:
self
.
_key
=
make_key
(
self
.
catalog
,
self
.
query
)
return
self
.
_key
def
log
(
self
):
def
log
(
self
):
# result of stopwatch
# result of stopwatch
res
=
self
.
result
()
res
=
self
.
result
()
if
res
[
0
]
<
self
.
threshold
:
if
res
[
0
]
<
self
.
threshold
:
return
return
# The key calculation takes a bit itself, we want to avoid that for
key
=
self
.
key
# any fast queries. This does mean that slow queries get the key
# calculation overhead added to their runtime.
key
=
self
.
key
()
reports_lock
.
acquire
()
reports_lock
.
acquire
()
try
:
try
:
if
self
.
cid
not
in
reports
:
if
self
.
cid
not
in
reports
:
...
...
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