Git Product home page Git Product logo

streaming's Introduction

Streaming

Streaming abstractions that combine, transform and reduce large amounts of sequential data efficiently, in constant space and without leaking resources.

Overview

Streaming uses composable stream producers (sources), consumers (sinks) and transformers (flows). The central model that abstracts over them is a Stream.

The following features are provided:

  • Constant memory usage: large or infinite streams can be computed in constant and small space. Buffering of the input is possible when needed.
  • Excellent performance: all models were designed with performance at the core. See benchmarks for detailed comparison with other libraries.
  • Resource safety: resources in effectful streaming pipelines are allocated lazily and released as early as possible. Resources are guaranteed to be terminated even when streams rise exceptions.
  • Flexibility: both push-based and pull-based models are implemented to allow efficient zipping, concatenation and other streaming operations.
  • Streaming notation: build streams and sinks using a convenient comprehension and applicative notations.

Read the library documenation for more details.

Acknowledgements

This library is based on ideas found in other libraries and research projects such as: Haskell's Pipes and Foldl libraries, Scala's ZIO Streams, Clojure's Transducers and the Iteratees streaming model by Oleg Kiselyov.

streaming's People

Contributors

314eter avatar nicotolly avatar pveber avatar rizo avatar rseymour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

streaming's Issues

Adding filter_map to API

How would you feel about having a filter_map: ('a -> 'b option) -> 'a t -> 'b t function in Stream and Flow ? It's not really difficult, something along the line of :

let filter_map f =
  let flow (Sink k) =
    let push r x = match f x with Some x -> k.push r x 
                                | None -> r in
    Sink { k with push } in
  { flow }

(Based on Flow.filter implementation).

I really like this function, sometimes it can avoid some awkward assumptions when composing filter and map - for example I find that :

let map_inverse l =  List.filter ((<>) 0.) l |> List.map (fun x -> 1. /. x)

less elegant than that :

let map_inverse = List.filter_map (fun x -> if x <> 0. then Some (1. /. x) else None)

Because in the first version, we have to assume that map takes a list that contains only non-zero number.

API renaming: of_file

How about renaming of_file to something like file_lines (which conveys its meaning more explicitly), and letting of_file return just chunks read by input to enable other segmentations/primary parsing?

Bug in Stream.partition

version: 0.8.0

https://odis-labs.github.io/streaming/streaming/Streaming/Stream/index.html

val partition : int -> 'a t -> 'a t t
partition n partitions the stream into sub-streams of size n.

#require "streaming";;
open Streaming.Stream;;

of_array [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9|]
|> partition 10
|> map (fun x -> x |> to_list)
|> to_list;;
- : int list list = []

of_array [|0; 1; 2; 3; 4; 5; 6; 7; 8; 9|]
|> partition 9
|> map (fun x -> x |> to_list)
|> to_list;;
- : int list list = [[0; 1; 2; 3; 4; 5; 6; 7; 8]; [9]]

of_array ([|0; 1; 2; 3; 4; 5; 6; 7; 8; 9; 10; 11; 12; 13; 14; 15; 16; 17; 18; 19|])
|> partition 10
|> map (fun x -> x |> to_list)
|> to_list;;
- : int list list = [[0; 1; 2; 3; 4; 5; 6; 7; 8; 9]]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.