synapse/storage/state.py
def _get_state_for_groups(self, groups, types=None):
        """Given list of groups returns dict of group -> list of state events
        with matching types. `types` is a list of `(type, state_key)`, where
        a `state_key` of None matches all state_keys. If `types` is None then
        all events are returned.
        """
        if types:
            types = frozenset(types)
        results = {}
        missing_groups = []
        if types is not None:
            for group in set(groups):
                state_dict_ids, _, got_all = self._get_some_state_from_cache(
                    group, types
                )
                results[group] = state_dict_ids

                if not got_all:
                    missing_groups.append(group)
        else:
            for group in set(groups):
                state_dict_ids, got_all = self._get_all_state_from_cache(
                    group
                )

                results[group] = state_dict_ids

                if not got_all:
                    missing_groups.append(group)

        if missing_groups:
            # Okay, so we have some missing_types, lets fetch them.
            cache_seq_num = self._state_group_cache.sequence

            group_to_state_dict = yield self._get_state_groups_from_groups(
                missing_groups, types
            )

            # Now we want to update the cache with all the things we fetched
            # from the database.
            for group, group_state_dict in group_to_state_dict.iteritems():
                state_dict = results[group]

                state_dict.update(
                    ((intern_string(k[0]), intern_string(k[1])), to_ascii(v))
                    for k, v in group_state_dict.iteritems()
                )

                self._state_group_cache.update(
                    cache_seq_num,
                    key=group,
                    value=state_dict,
                    full=(types is None),
                    known_absent=types,
                )

        defer.returnValue(results)
Given list of groups returns dict of group -> list of state events
        with matching types. `types` is a list of `(type, state_key)`, where
        a `state_key` of None matches all state_keys. If `types` is None then
        all events are returned.
        
Given list of groups returns dict of group -> list of state events
with matching types.
Given list of groups returns dict of group - > list of state events with matching types .
def _get_state_for_groups(self, groups, types=None):
        if types:
            types = frozenset(types)
        results = {}
        missing_groups = []
        if types is not None:
            for group in set(groups):
                state_dict_ids, _, got_all = self._get_some_state_from_cache(
                    group, types
                )
                results[group] = state_dict_ids
                if not got_all:
                    missing_groups.append(group)
        else:
            for group in set(groups):
                state_dict_ids, got_all = self._get_all_state_from_cache(
                    group
                )
                results[group] = state_dict_ids
                if not got_all:
                    missing_groups.append(group)
        if missing_groups:
            cache_seq_num = self._state_group_cache.sequence
            group_to_state_dict = yield self._get_state_groups_from_groups(
                missing_groups, types
            )
            for group, group_state_dict in group_to_state_dict.iteritems():
                state_dict = results[group]
                state_dict.update(
                    ((intern_string(k[0]), intern_string(k[1])), to_ascii(v))
                    for k, v in group_state_dict.iteritems()
                )
                self._state_group_cache.update(
                    cache_seq_num,
                    key=group,
                    value=state_dict,
                    full=(types is None),
                    known_absent=types,
                )
        defer.returnValue(results)
def _get_state_for_groups ( self , groups , types = None ) : if types : types = frozenset ( types ) results = { } missing_groups = [ ] if types is not None : for group in set ( groups ) : state_dict_ids , _ , got_all = self . _get_some_state_from_cache ( group , types ) results [ group ] = state_dict_ids if not got_all : missing_groups . append ( group ) else : for group in set ( groups ) : state_dict_ids , got_all = self . _get_all_state_from_cache ( group ) results [ group ] = state_dict_ids if not got_all : missing_groups . append ( group ) if missing_groups : cache_seq_num = self . _state_group_cache . sequence group_to_state_dict = yield self . _get_state_groups_from_groups ( missing_groups , types ) for group , group_state_dict in group_to_state_dict . iteritems ( ) : state_dict = results [ group ] state_dict . update ( ( ( intern_string ( k [ 0 ] ) , intern_string ( k [ 1 ] ) ) , to_ascii ( v ) ) for k , v in group_state_dict . iteritems ( ) ) self . _state_group_cache . update ( cache_seq_num , key = group , value = state_dict , full = ( types is None ) , known_absent = types , ) defer . returnValue ( results )
Given list of groups returns dict of group -> list of state events
with matching types.
Given list of groups returns dict of group - > list of state events with matching types .
"""Given list of groups returns dict of group -> list of state events
        with matching types. `types` is a list of `(type, state_key)`, where
        a `state_key` of None matches all state_keys. If `types` is None then
        all events are returned.
        """ # Okay, so we have some missing_types, lets fetch them. # Now we want to update the cache with all the things we fetched # from the database.
self
groups
types