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
bb5b83eb
Commit
bb5b83eb
authored
Aug 02, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respect the ILimitedResultIndex interface in the query plan
parent
445e294b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
12 deletions
+14
-12
src/Products/ZCatalog/Catalog.py
src/Products/ZCatalog/Catalog.py
+5
-4
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+9
-8
No files found.
src/Products/ZCatalog/Catalog.py
View file @
bb5b83eb
...
...
@@ -521,7 +521,8 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
continue
cr
.
start_split
(
i
)
if
ILimitedResultIndex
.
providedBy
(
index
):
limit_result
=
ILimitedResultIndex
.
providedBy
(
index
)
if
limit_result
:
r
=
_apply_index
(
query
,
rs
)
else
:
r
=
_apply_index
(
query
)
...
...
@@ -533,15 +534,15 @@ class Catalog(Persistent, Acquisition.Implicit, ExtensionClass.Base):
# once we don't need to support the "return everything" case
# anymore
if
r
is
not
None
and
not
r
:
cr
.
stop_split
(
i
,
None
)
cr
.
stop_split
(
i
,
result
=
None
,
limit
=
limit_result
)
return
LazyCat
([])
cr
.
stop_split
(
i
,
r
)
cr
.
stop_split
(
i
,
r
esult
=
r
,
limit
=
limit_result
)
w
,
rs
=
weightedIntersection
(
rs
,
r
)
if
not
rs
:
break
else
:
cr
.
stop_split
(
i
,
None
)
cr
.
stop_split
(
i
,
result
=
None
,
limit
=
limit_result
)
if
rs
is
None
:
# None of the indexes found anything to do with the query
...
...
src/Products/ZCatalog/plan.py
View file @
bb5b83eb
...
...
@@ -27,8 +27,8 @@ REFRESH_RATE = 100
Duration
=
namedtuple
(
'Duration'
,
[
'start'
,
'end'
])
IndexMeasurement
=
namedtuple
(
'IndexMeasurement'
,
[
'name'
,
'duration'
,
'num'
])
Benchmark
=
namedtuple
(
'Benchmark'
,
[
'num'
,
'duration'
,
'hits'
])
[
'name'
,
'duration'
,
'num'
,
'limit'
])
Benchmark
=
namedtuple
(
'Benchmark'
,
[
'num'
,
'duration'
,
'hits'
,
'limit'
])
RecentQuery
=
namedtuple
(
'RecentQuery'
,
[
'duration'
,
'details'
])
Report
=
namedtuple
(
'Report'
,
[
'hits'
,
'duration'
,
'last'
])
...
...
@@ -237,7 +237,7 @@ class CatalogPlan(object):
return
None
# sort indexes on (mean result length, mean search time)
ranking
=
[((
value
.
num
,
value
.
duration
),
name
)
ranking
=
[((
value
.
limit
,
value
.
num
,
value
.
duration
),
name
)
for
name
,
value
in
benchmark
.
items
()]
ranking
.
sort
()
return
[
r
[
1
]
for
r
in
ranking
]
...
...
@@ -249,7 +249,7 @@ class CatalogPlan(object):
def
start_split
(
self
,
name
,
result
=
None
):
self
.
interim
[
name
]
=
Duration
(
time
.
time
(),
None
)
def
stop_split
(
self
,
name
,
result
=
None
):
def
stop_split
(
self
,
name
,
result
=
None
,
limit
=
False
):
current
=
time
.
time
()
start_time
,
stop_time
=
self
.
interim
.
get
(
name
,
Duration
(
None
,
None
))
length
=
0
...
...
@@ -259,7 +259,7 @@ class CatalogPlan(object):
self
.
interim
[
name
]
=
Duration
(
start_time
,
current
)
dt
=
current
-
start_time
self
.
res
.
append
(
IndexMeasurement
(
name
=
name
,
duration
=
current
-
start_time
,
num
=
length
))
name
=
name
,
duration
=
dt
,
num
=
length
,
limit
=
limit
))
if
name
==
'sort_on'
:
# sort_on isn't an index. We only do time reporting on it
...
...
@@ -268,16 +268,17 @@ class CatalogPlan(object):
# remember index's hits, search time and calls
benchmark
=
self
.
benchmark
if
name
not
in
benchmark
:
benchmark
[
name
]
=
Benchmark
(
num
=
length
,
duration
=
dt
,
hits
=
1
)
benchmark
[
name
]
=
Benchmark
(
num
=
length
,
duration
=
dt
,
hits
=
1
,
limit
=
limit
)
else
:
num
,
duration
,
hits
=
benchmark
[
name
]
num
,
duration
,
hits
,
limit
=
benchmark
[
name
]
num
=
int
(((
num
*
hits
)
+
length
)
/
float
(
hits
+
1
))
duration
=
((
duration
*
hits
)
+
dt
)
/
float
(
hits
+
1
)
# reset adaption
if
hits
%
REFRESH_RATE
==
0
:
hits
=
0
hits
+=
1
benchmark
[
name
]
=
Benchmark
(
num
,
duration
,
hits
)
benchmark
[
name
]
=
Benchmark
(
num
,
duration
,
hits
,
limit
)
def
stop
(
self
):
self
.
end_time
=
time
.
time
()
...
...
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