Don't return unknown entities in get_entities_changed

The stream cache keeps track of all entities that have changed since
a particular stream position, so get_entities_changed does not need to
return unknown entites when given a larger stream position.

This makes it consistent with the behaviour of has_entity_changed.
This commit is contained in:
Erik Johnston 2018-07-13 15:26:10 +01:00
parent ba22b6a456
commit 77b692e65d
1 changed files with 1 additions and 8 deletions

View File

@ -74,19 +74,12 @@ class StreamChangeCache(object):
assert type(stream_pos) is int assert type(stream_pos) is int
if stream_pos >= self._earliest_known_stream_pos: if stream_pos >= self._earliest_known_stream_pos:
changed_entities = { result = {
self._cache[k] for k in self._cache.islice( self._cache[k] for k in self._cache.islice(
start=self._cache.bisect_right(stream_pos), start=self._cache.bisect_right(stream_pos),
) )
} }
# we need to include entities which we don't know about, as well as
# those which are known to have changed since the stream pos.
result = {
e for e in entities
if e in changed_entities or e not in self._entity_to_key
}
self.metrics.inc_hits() self.metrics.inc_hits()
else: else:
result = set(entities) result = set(entities)