Skip to content

Commit

Permalink
Make parallelizer protected
Browse files Browse the repository at this point in the history
  • Loading branch information
garlontas committed Jun 26, 2023
1 parent 2a8901b commit d7da24c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions pystreamapi/_streams/__parallel_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ParallelStream(stream.BaseStream):

def __init__(self, source: Iterable[stream.K]):
super().__init__(source)
self.parallelizer = Parallelizer()
self._parallelizer = Parallelizer()

def all_match(self, predicate: Callable[[Any], bool]):
self._trigger_exec()
Expand All @@ -24,7 +24,7 @@ def all_match(self, predicate: Callable[[Any], bool]):

def _filter(self, predicate: Callable[[Any], bool]):
self._set_parallelizer_src()
self._source = self.parallelizer.filter(predicate)
self._source = self._parallelizer.filter(predicate)

def find_any(self):
self._trigger_exec()
Expand Down Expand Up @@ -77,11 +77,11 @@ def reduce(self, predicate: Callable[[Any, Any], Any], identity=_identity_missin
return identity if identity is not _identity_missing else Optional.empty()

def __reduce(self, pred, _):
return self.parallelizer.reduce(pred)
return self._parallelizer.reduce(pred)

def to_dict(self, key_mapper: Callable[[Any], Any]) -> dict:
self._trigger_exec()
return dict(self._group_to_dict(key_mapper))

def _set_parallelizer_src(self):
self.parallelizer.set_source(self._source)
self._parallelizer.set_source(self._source)
2 changes: 1 addition & 1 deletion pystreamapi/_streams/numeric/__parallel_numeric_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def sum(self) -> Union[float, int, None]:
def __sum(self):
"""Parallel sum method"""
self._set_parallelizer_src()
return self.parallelizer.reduce(lambda x, y: x + y)
return self._parallelizer.reduce(lambda x, y: x + y)

0 comments on commit d7da24c

Please sign in to comment.