diff options
author | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2021-12-20 12:54:25 +0000 |
---|---|---|
committer | Olivier Wilkinson (reivilibre) <oliverw@matrix.org> | 2021-12-20 12:54:25 +0000 |
commit | efe0059b98d8f7e73cc05b0d224f56405e0b7336 (patch) | |
tree | 4000c14bc604073bb500d59efcbbe1e44d3d0bf2 | |
parent | Newsfile (diff) | |
download | synapse-efe0059b98d8f7e73cc05b0d224f56405e0b7336.tar.xz |
Define a comparator for StateFilters
-rw-r--r-- | synapse/storage/databases/state/store.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/synapse/storage/databases/state/store.py b/synapse/storage/databases/state/store.py index 197c0bbc44..6b665cdbba 100644 --- a/synapse/storage/databases/state/store.py +++ b/synapse/storage/databases/state/store.py @@ -68,6 +68,26 @@ class _GetStateGroupDelta: return len(self.delta_ids) if self.delta_ids else 0 +# Return type of state_filter_rough_size_comparator. Must be comparable. +StateFilterRoughSizeComparator = Tuple[int, int] + + +def state_filter_rough_size_comparator( + state_filter: StateFilter, +) -> StateFilterRoughSizeComparator: + """ + Returns a comparable value that roughly indicates the relative size of this + state filter compared to others. + It should be treated as a rough guide only and should not be interpreted to + have any particular meaning. The representation may also change + + The current implementation returns a tuple of the form: + * 1 for include_others, 0 otherwise + * number of entries in state_filter.types + """ + return int(state_filter.include_others), len(state_filter.types) + + class StateGroupDataStore(StateBackgroundUpdateStore, SQLBaseStore): """A data store for fetching/storing state groups.""" |