my guess Seq by default is the scala.collection.Seq, you need to use scala.collection.immutable.Seq
-- Cheers, √ On 9 Sep 2015 09:33, "Ivan Baisi" <[email protected]> wrote: > Sorry for the delay, I had to attend a training yesterday. > > So, that mapConcat is my friend as far as I use it with a Source, but when > I try to do something similar with a flow, nothing works. To simplify it, > I've made this self containing example with these 2 options: > > > it should "mapConcat test" in { > Given("a source of int 1 to 10") > val source = Source(1 to 10).grouped(2) > val flattened: Source[Int, Unit] = source.mapConcat(identity) > 1) val flow = Flow[Seq[Int]].mapConcat[Int](identity) // type > mismatch, expected: (Seq[Int] => Iterable[Int]), actual: (Nothing) => > Nothing > 2) val flow = Flow[Seq[Int]].mapConcat[Int](seq => > seq.iterator.toIterable) // this gives a comilation error: Expression of > type Iterable[Int] doesn't conform expected type Iterable[Int] > val sink = Sink.fold[Int, Int](0)(_ + _) > > val runnable: RunnableGraph[Future[Int]] = > source.via(flow).toMat(sink)(Keep.right) > val sum: Future[Int] = runnable.run() > > Then("55 is the sum") > val res = Await.result(sum, Duration.Inf) > assert(res == 55) > } > > Am I missing something? Any clue what could be going on? > > Thanks in advance again! > > On Monday, September 7, 2015 at 4:48:13 PM UTC+2, Konrad Malawski wrote: >> >> Ok so you have the seq at that point still, yup then mapConcat(identity) >> is your friend. >> On Sep 7, 2015 3:39 PM, "Endre Varga" <[email protected]> wrote: >> >>> Isn't it mapConcat what you are looking for? >>> >>> -Endre >>> >>> On Mon, Sep 7, 2015 at 4:13 PM, Ivan Baisi <[email protected]> >>> wrote: >>> >>>> I'm doing something like that for now: >>>> >>>> .map({ x => x.foldLeft("")((fStr, str) => fStr + str + "\r\n") }) >>>> >>>> but this ends up in many json in one kafka message, and what I'd like >>>> to achieve is having one json per message being pushed to kafka >>>> >>>> On Monday, September 7, 2015 at 3:53:38 PM UTC+2, Konrad Malawski wrote: >>>>> >>>>> Why not .map(json => makeTheString(json))? >>>>> On Sep 7, 2015 13:30, "Ivan Baisi" <[email protected]> wrote: >>>>> >>>>>> Hi all, >>>>>> >>>>>> So I have a problem I cannot find out how to solve. >>>>>> >>>>>> I have a flow that receives many elements, and as I have to access a >>>>>> db with that data, I have to group them so I query the db once instead of >>>>>> 1000 times: >>>>>> >>>>>> deleteActivityFlow.grouped(1000) >>>>>> >>>>>> The problem is that after doing all the processing required, I end up >>>>>> with a Seq[String] that represent the domain event in a json format I >>>>>> have >>>>>> to push to the kafka Sink: >>>>>> >>>>>> Sink(kafka.publish(producerProperties)) >>>>>> >>>>>> This sink expects a String, not a Seq[String], so I was wondering if >>>>>> there's any way of achieving this grouped(1000) inverse >>>>>> >>>>>> Thanks in advance! >>>>>> >>>>>> -- >>>>>> >>>>>>>>>> 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 http://groups.google.com/group/akka-user. >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> -- >>>> >>>>>>>>>> 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 http://groups.google.com/group/akka-user. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> >>>>>>>>>> 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 http://groups.google.com/group/akka-user. >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- > >>>>>>>>>> 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 http://groups.google.com/group/akka-user. > For more options, visit https://groups.google.com/d/optout. > -- >>>>>>>>>> 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 http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
