Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/beatrichartz/parallel_stream
A parallelized stream implementation for Elixir
https://github.com/beatrichartz/parallel_stream
elixir parallelism parallelize stream
Last synced: 21 days ago
JSON representation
A parallelized stream implementation for Elixir
- Host: GitHub
- URL: https://github.com/beatrichartz/parallel_stream
- Owner: beatrichartz
- License: mit
- Created: 2015-10-17T19:48:04.000Z (about 9 years ago)
- Default Branch: main
- Last Pushed: 2022-09-17T04:31:11.000Z (about 2 years ago)
- Last Synced: 2024-10-29T21:59:32.024Z (about 1 month ago)
- Topics: elixir, parallelism, parallelize, stream
- Language: Elixir
- Homepage:
- Size: 79.1 KB
- Stars: 100
- Watchers: 4
- Forks: 22
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - A parallel stream implementation for Elixir. (Algorithms and Data structures)
- fucking-awesome-elixir - parallel_stream - A parallel stream implementation for Elixir. (Algorithms and Data structures)
- awesome-elixir - parallel_stream - A parallel stream implementation for Elixir. (Algorithms and Data structures)
README
# ParallelStream [![Build Status](https://github.com/beatrichartz/csv/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/beatrichartz/parallel_stream) [![Coverage Status](https://coveralls.io/repos/github/beatrichartz/parallel_stream/badge.svg?branch=main)](https://coveralls.io/github/beatrichartz/parallel_stream?branch=main) [![Inline docs](http://inch-ci.org/github/beatrichartz/parallel_stream.svg?branch=main)](http://inch-ci.org/github/beatrichartz/parallel_stream) [![Hex pm](http://img.shields.io/hexpm/v/parallel_stream.svg?style=flat)](https://hex.pm/packages/parallel_stream) [![Downloads](https://img.shields.io/hexpm/dw/parallel_stream.svg?style=flat)](https://hex.pm/packages/parallel_stream)
Parallelized stream implementation for elixir## What does it do?
Parallelize some stream operations in Elixir whilst keeping your stream in order.
Operates with a worker pool.## How do I get it?
Add
```elixir
{:parallel_stream, "~> 1.1.0"}
```
to your deps in `mix.exs` like so:```elixir
defp deps do
[
{:parallel_stream, "~> 1.1.0"}
]
end
```Note: Elixir `1.5.0` is required
## How to use
Do this to parallelize a `map`:
````elixir
stream = 1..10 |> ParallelStream.map(fn i -> i * 2 end)
stream |> Enum.into([])
[2,4,6,8,10,12,14,16,18,20]
````The generated stream is sorted the same as the input stream.
More supported functions are `each` (to produce side-effects):
````elixir
1..100 |> ParallelStream.each(&IO.inspect/1)
`````filter`:
````elixir
stream = 1..20 |> ParallelStream.filter(fn i -> i |> rem(2) == 0 end)
stream |> Enum.into([])
[2,4,6,8,10,12,14,16,18,20]
````and `filter`'s counterpart, `reject`:
````elixir
stream = 1..20 |> ParallelStream.reject(fn i -> i |> rem(2) == 0 end)
stream |> Enum.into([])
[1,3,5,7,9,11,13,15,17,19]
````## License
MIT
## Contributions & Bugfixes are most welcome!