Skip to content

Instantly share code, notes, and snippets.

@sosuren
sosuren / GraphDSL.scala
Created May 4, 2017 17:10
broadcast to two sinks one being delayed
val g = RunnableGraph.fromGraph(GraphDSL.create() {
implicit builder =>
import GraphDSL.Implicits._
val so = builder.add(Source.fromIterator(() => List(1, 2, 3).iterator)).out
val p1 = builder.add(Flow[Int].scan(0)((acc, next) => acc + next))
val p2 = builder.add(Flow[Int].delay(1.second))
val b = builder.add(Broadcast[Int](2))
val sa = builder.add(Sink.foreach[Int](item => {
@sosuren
sosuren / AkkaStreamingSample.scala
Created January 30, 2017 09:24
Akka Streaming Sample to find distribution of Patients' Health based on Age and Gender
import akka.stream.stage.{InHandler, GraphStageLogic, GraphStage}
import sample.stream.AkkaStreamingSample.Gender.Gender
import scala.util.Random
object AkkaStreamingSample {
import akka.actor.ActorSystem
import akka.stream._
import akka.stream.scaladsl._
package wrappers
import play.api._
import play.api.mvc._
import scala.concurrent._
import scala.concurrent.Future
import play.mvc.Http.Status
import ExecutionContext.Implicits.global
import play.libs.Akka
import akka.actor.{Actor, Props}
package wrappers
import play.api._
import play.api.mvc._
import scala.concurrent._
import scala.concurrent.Future
import play.mvc.Http.Status
import ExecutionContext.Implicits.global
import play.libs.Akka
import akka.actor.{Actor, Props}
@sosuren
sosuren / MyAggregator
Created April 7, 2014 12:04
Aggregator to populate multiple tuples
package com.deerwalk.das.scrub;
import cascading.flow.FlowProcess;
import cascading.operation.Aggregator;
import cascading.operation.AggregatorCall;
import cascading.operation.BaseOperation;
import cascading.tuple.Fields;
import cascading.tuple.Tuple;
import cascading.tuple.TupleEntry;