Hi ,

In Akka Stream is it possible to create custom windows.

For example

case class Source1(id: Int, data: Int)
case class Source2(id: Int, data: Int)
case class Combined(id: Int, data: (Int,Int))

  val source1Iter = for (i <- 1 to 100) yield Source1(i, r.nextInt(11))
  val source2Iter = for (i <- 1 to 100) yield Source2(i, r.nextInt(1000))
  val source1: Source[Source1, NotUsed] = Source.fromIterator(() => 
source1Iter.iterator)
  val source2: Source[Source2, NotUsed] = Source.fromIterator(() => 
source2Iter.iterator)
  
  Required to combine this two streams and create stream window based on 
the first tuple value from 10 to next 10 and filter the second tuple 
highest value.
  
  val sink = Sink.foreach(println)
  val g = RunnableGraph.fromGraph(GraphDSL.create() { implicit builder: 
GraphDSL.Builder[NotUsed] =>
    import GraphDSL.Implicits._
    val zipWith = builder.add(ZipWith[Source1, Source2, Combined]((source: 
Source1, source0: Source2) => {
       Combined(source.id, (source.data, source0.data))
    }))

  source1 ~> zipWith.in0
  source2 ~> zipWith.in1
  zipWith.out ~> sink
  // Need to implement the block / window logic
  ClosedShape
  })
  g.run(materializer)
  
Thanks,
Dheeraj.

-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to