Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
7d9fb886
Commit
7d9fb886
authored
6 years ago
by
Matthew Hodgson
Browse files
Options
Downloads
Patches
Plain Diff
incorporate more review.
parent
cb5c37a5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
synapse/storage/state.py
+14
-16
14 additions, 16 deletions
synapse/storage/state.py
with
14 additions
and
16 deletions
synapse/storage/state.py
+
14
−
16
View file @
7d9fb886
...
@@ -493,12 +493,6 @@ class StateGroupWorkerStore(SQLBaseStore):
...
@@ -493,12 +493,6 @@ class StateGroupWorkerStore(SQLBaseStore):
def
_get_some_state_from_cache
(
self
,
group
,
types
,
filtered_types
=
None
):
def
_get_some_state_from_cache
(
self
,
group
,
types
,
filtered_types
=
None
):
"""
Checks if group is in cache. See `_get_state_for_groups`
"""
Checks if group is in cache. See `_get_state_for_groups`
Returns 3-tuple (`state_dict`, `missing_types`, `got_all`).
`missing_types` is the list of types that aren
'
t in the cache for that
group. `got_all` is a bool indicating if we successfully retrieved all
requests state from the cache, if False we need to query the DB for the
missing state.
Args:
Args:
group(int): The state group to lookup
group(int): The state group to lookup
types(list[str, str|None]): List of 2-tuples of the form
types(list[str, str|None]): List of 2-tuples of the form
...
@@ -507,6 +501,11 @@ class StateGroupWorkerStore(SQLBaseStore):
...
@@ -507,6 +501,11 @@ class StateGroupWorkerStore(SQLBaseStore):
filtered_types(list[str]|None): Only apply filtering via `types` to this
filtered_types(list[str]|None): Only apply filtering via `types` to this
list of event types. Other types of events are returned unfiltered.
list of event types. Other types of events are returned unfiltered.
If None, `types` filtering is applied to all events.
If None, `types` filtering is applied to all events.
Returns 2-tuple (`state_dict`, `got_all`).
`got_all` is a bool indicating if we successfully retrieved all
requests state from the cache, if False we need to query the DB for the
missing state.
"""
"""
is_all
,
known_absent
,
state_dict_ids
=
self
.
_state_group_cache
.
get
(
group
)
is_all
,
known_absent
,
state_dict_ids
=
self
.
_state_group_cache
.
get
(
group
)
...
@@ -520,7 +519,7 @@ class StateGroupWorkerStore(SQLBaseStore):
...
@@ -520,7 +519,7 @@ class StateGroupWorkerStore(SQLBaseStore):
if
(
if
(
state_key
is
None
or
state_key
is
None
or
filtered_types
is
not
None
and
typ
not
in
filtered_types
(
filtered_types
is
not
None
and
typ
not
in
filtered_types
)
):
):
type_to_key
[
typ
]
=
None
type_to_key
[
typ
]
=
None
# we mark the type as missing from the cache because
# we mark the type as missing from the cache because
...
@@ -547,18 +546,17 @@ class StateGroupWorkerStore(SQLBaseStore):
...
@@ -547,18 +546,17 @@ class StateGroupWorkerStore(SQLBaseStore):
return
True
return
True
return
False
return
False
if
types
==
[]
and
filtered_types
is
not
None
:
got_all
=
is_all
# special wildcard case for empty type-list but an explicit filtered_types
if
not
got_all
:
# which means that we'll try to return all types which aren't in the
# the cache is incomplete. We may still have got all the results we need, if
# filtered_types list. missing_types will always be empty, so we ignore it.
# we don't have any wildcards in the match list.
got_all
=
is_all
if
not
missing_types
and
filtered_types
is
None
:
else
:
got_all
=
True
got_all
=
is_all
or
not
missing_types
return
{
return
{
k
:
v
for
k
,
v
in
iteritems
(
state_dict_ids
)
k
:
v
for
k
,
v
in
iteritems
(
state_dict_ids
)
if
include
(
k
[
0
],
k
[
1
])
if
include
(
k
[
0
],
k
[
1
])
},
missing_types
,
got_all
},
got_all
def
_get_all_state_from_cache
(
self
,
group
):
def
_get_all_state_from_cache
(
self
,
group
):
"""
Checks if group is in cache. See `_get_state_for_groups`
"""
Checks if group is in cache. See `_get_state_for_groups`
...
@@ -603,7 +601,7 @@ class StateGroupWorkerStore(SQLBaseStore):
...
@@ -603,7 +601,7 @@ class StateGroupWorkerStore(SQLBaseStore):
missing_groups
=
[]
missing_groups
=
[]
if
types
is
not
None
:
if
types
is
not
None
:
for
group
in
set
(
groups
):
for
group
in
set
(
groups
):
state_dict_ids
,
_
,
got_all
=
self
.
_get_some_state_from_cache
(
state_dict_ids
,
got_all
=
self
.
_get_some_state_from_cache
(
group
,
types
,
filtered_types
group
,
types
,
filtered_types
)
)
results
[
group
]
=
state_dict_ids
results
[
group
]
=
state_dict_ids
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment