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
8b47fab8
Commit
8b47fab8
authored
Aug 01, 2010
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Get us a get/set for value indexes
parent
b8f178d3
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
+27
-22
src/Products/ZCatalog/plan.py
src/Products/ZCatalog/plan.py
+27
-22
No files found.
src/Products/ZCatalog/plan.py
View file @
8b47fab8
...
...
@@ -19,6 +19,9 @@ from Acquisition import aq_base
from
Acquisition
import
aq_parent
from
Products.PluginIndexes.interfaces
import
IUniqueValueIndex
MAX_DISTINCT_VALUES
=
10
REFRESH_RATE
=
100
REPORTS_LOCK
=
allocate_lock
()
REPORTS
=
{}
...
...
@@ -28,8 +31,23 @@ PRIORITYMAP = {}
VALUE_INDEXES_LOCK
=
allocate_lock
()
VALUE_INDEXES
=
frozenset
()
MAX_DISTINCT_VALUES
=
10
REFRESH_RATE
=
100
def
get_value_indexes
():
return
VALUE_INDEXES
def
set_value_indexes
(
value
):
with
VALUE_INDEXES_LOCK
:
global
VALUE_INDEXES
VALUE_INDEXES
=
value
def
clear_value_indexes
():
set_value_indexes
(
frozenset
())
from
zope.testing.cleanup
import
addCleanUp
addCleanUp
(
clear_value_indexes
)
del
addCleanUp
def
determine_value_indexes
(
indexes
):
...
...
@@ -41,38 +59,25 @@ def determine_value_indexes(indexes):
# of unique values, where the number of items for each value differs a
# lot. If the number of items per value is similar, the duration of a
# query is likely similar as well.
global
VALUE_INDEXES
if
VALUE_INDEXES
:
value_indexes
=
get_value_indexes
()
if
value_indexes
:
# Calculating all the value indexes is quite slow, so we do this once
# for the first query. Since this is an optimization only, slightly
# outdated results based on index changes in the running process
# can be ignored.
return
VALUE_INDEXES
return
value_indexes
new_
value_indexes
=
set
()
value_indexes
=
set
()
for
name
,
index
in
indexes
.
items
():
if
IUniqueValueIndex
.
providedBy
(
index
):
values
=
index
.
uniqueValues
()
if
values
and
len
(
list
(
values
))
<
MAX_DISTINCT_VALUES
:
# Only consider indexes which actually return a number
# greater than zero
new_value_indexes
.
add
(
name
)
with
VALUE_INDEXES_LOCK
:
VALUE_INDEXES
=
frozenset
(
new_value_indexes
)
return
VALUE_INDEXES
value_indexes
.
add
(
name
)
def
clear_value_indexes
():
global
VALUE_INDEXES
with
VALUE_INDEXES_LOCK
:
VALUE_INDEXES
=
frozenset
()
from
zope.testing.cleanup
import
addCleanUp
addCleanUp
(
clear_value_indexes
)
del
addCleanUp
set_value_indexes
(
frozenset
(
value_indexes
))
return
value_indexes
def
make_key
(
catalog
,
query
):
...
...
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