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
b4d28123
Commit
b4d28123
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include query time reporting for the sort step
parent
0dc031aa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
29 deletions
+40
-29
src/Products/ZCatalog/Catalog.py
src/Products/ZCatalog/Catalog.py
+36
-29
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+4
-0
No files found.
src/Products/ZCatalog/Catalog.py
View file @
b4d28123
...
@@ -543,8 +543,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -543,8 +543,6 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
else
:
else
:
cr
.
stop_split
(
i
,
None
)
cr
.
stop_split
(
i
,
None
)
cr
.
stop
()
if
rs
is
None
:
if
rs
is
None
:
# None of the indexes found anything to do with the query
# None of the indexes found anything to do with the query
# We take this to mean that the query was empty (an empty filter)
# We take this to mean that the query was empty (an empty filter)
...
@@ -556,10 +554,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -556,10 +554,12 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
DeprecationWarning
,
stacklevel
=
3
)
DeprecationWarning
,
stacklevel
=
3
)
if
sort_index
is
None
:
if
sort_index
is
None
:
re
turn
LazyMap
(
self
.
instantiate
,
self
.
data
.
items
(),
len
(
self
))
re
sult
=
LazyMap
(
self
.
instantiate
,
self
.
data
.
items
(),
len
(
self
))
else
:
else
:
return
self
.
sortResults
(
cr
.
start_split
(
'sort_on'
)
result
=
self
.
sortResults
(
self
.
data
,
sort_index
,
reverse
,
limit
,
merge
)
self
.
data
,
sort_index
,
reverse
,
limit
,
merge
)
cr
.
stop_split
(
'sort_on'
,
None
)
elif
rs
:
elif
rs
:
# We got some results from the indexes.
# We got some results from the indexes.
# Sort and convert to sequences.
# Sort and convert to sequences.
...
@@ -576,44 +576,51 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
...
@@ -576,44 +576,51 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# note that data_record_normalized_score_ cannot be
# note that data_record_normalized_score_ cannot be
# calculated and will always be 1 in this case
# calculated and will always be 1 in this case
getitem
=
self
.
__getitem__
getitem
=
self
.
__getitem__
re
turn
[(
score
,
(
1
,
score
,
rid
),
getitem
)
re
sult
=
[(
score
,
(
1
,
score
,
rid
),
getitem
)
for
rid
,
score
in
rs
.
items
()]
for
rid
,
score
in
rs
.
items
()]
else
:
rs
=
rs
.
byValue
(
0
)
# sort it by score
cr
.
start_split
(
'sort_on'
)
max
=
float
(
rs
[
0
][
0
])
rs
=
rs
.
byValue
(
0
)
# sort it by score
# Here we define our getter function inline so that
max
=
float
(
rs
[
0
][
0
])
# we can conveniently store the max value as a default arg
# and make the normalized score computation lazy
# Here we define our getter function inline so that
def
getScoredResult
(
item
,
max
=
max
,
self
=
self
):
# we can conveniently store the max value as a default arg
"""
# and make the normalized score computation lazy
Returns instances of self._v_brains, or whatever is passed
def
getScoredResult
(
item
,
max
=
max
,
self
=
self
):
into self.useBrains.
"""
"""
Returns instances of self._v_brains, or whatever is
score
,
key
=
item
passed into self.useBrains.
r
=
self
.
_v_result_class
(
self
.
data
[
key
])
\
"""
.
__of__
(
aq_parent
(
self
))
score
,
key
=
item
r
.
data_record_id_
=
key
r
=
self
.
_v_result_class
(
self
.
data
[
key
])
\
r
.
data_record_score_
=
score
.
__of__
(
aq_parent
(
self
))
r
.
data_record_normalized_score_
=
int
(
100.
*
score
/
max
)
r
.
data_record_id_
=
key
return
r
r
.
data_record_score_
=
score
r
.
data_record_normalized_score_
=
int
(
100.
*
score
/
max
)
return
LazyMap
(
getScoredResult
,
rs
,
len
(
rs
))
return
r
result
=
LazyMap
(
getScoredResult
,
rs
,
len
(
rs
))
cr
.
stop_split
(
'sort_on'
,
None
)
elif
sort_index
is
None
and
not
hasattr
(
rs
,
'values'
):
elif
sort_index
is
None
and
not
hasattr
(
rs
,
'values'
):
# no scores
# no scores
if
hasattr
(
rs
,
'keys'
):
if
hasattr
(
rs
,
'keys'
):
rs
=
rs
.
keys
()
rs
=
rs
.
keys
()
re
turn
LazyMap
(
self
.
__getitem__
,
rs
,
len
(
rs
))
re
sult
=
LazyMap
(
self
.
__getitem__
,
rs
,
len
(
rs
))
else
:
else
:
# sort. If there are scores, then this block is not
# sort. If there are scores, then this block is not
# reached, therefore 'sort-on' does not happen in the
# reached, therefore 'sort-on' does not happen in the
# context of a text index query. This should probably
# context of a text index query. This should probably
# sort by relevance first, then the 'sort-on' attribute.
# sort by relevance first, then the 'sort-on' attribute.
return
self
.
sortResults
(
rs
,
sort_index
,
reverse
,
limit
,
merge
)
cr
.
start_split
(
'sort_on'
)
result
=
self
.
sortResults
(
rs
,
sort_index
,
reverse
,
limit
,
merge
)
cr
.
stop_split
(
'sort_on'
,
None
)
else
:
else
:
# Empty result set
# Empty result set
return
LazyCat
([])
result
=
LazyCat
([])
cr
.
stop
()
return
result
def
sortResults
(
self
,
rs
,
sort_index
,
reverse
=
0
,
limit
=
None
,
merge
=
1
):
def
sortResults
(
self
,
rs
,
sort_index
,
reverse
=
0
,
limit
=
None
,
merge
=
1
):
# Sort a result set using a sort index. Return a lazy
# Sort a result set using a sort index. Return a lazy
...
...
src/Products/ZCatalog/plan.py
View file @
b4d28123
...
@@ -234,6 +234,10 @@ class CatalogPlan(object):
...
@@ -234,6 +234,10 @@ class CatalogPlan(object):
self
.
res
.
append
(
IndexMeasurement
(
self
.
res
.
append
(
IndexMeasurement
(
name
=
name
,
duration
=
current
-
start_time
,
num
=
length
))
name
=
name
,
duration
=
current
-
start_time
,
num
=
length
))
if
name
==
'sort_on'
:
# sort_on isn't an index. We only do time reporting on it
return
# remember index's hits, search time and calls
# remember index's hits, search time and calls
benchmark
=
self
.
benchmark
benchmark
=
self
.
benchmark
if
name
not
in
benchmark
:
if
name
not
in
benchmark
:
...
...
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