Questions tagged [scala-streams]

37 questions
0
votes
2 answers

Spark streaming checkpoint

I am reading messages from Kafka using Spark Kafka direct streaming. I want to implement zero message loss and after restarts spark, it has to read the missed messages from Kafka. I am using checkpoint to save all read offset, so that next time…
Gnana
  • 2,130
  • 5
  • 26
  • 57
0
votes
1 answer

Scala group Stream elements without evaluating the whole Stream

If I have a Sorted stream like this: Stream(1, 1, 2, 2, 2, 3, 4, 4, 5) How can group its content like this: Stream(List(1, 1), List(2, 2, 2), List(3), List(4, 4), List(5)) Without causing the stream to be completely evaluated right away?
dreigada
  • 83
  • 1
  • 7
0
votes
1 answer

Scala worksheet not working for this code , no compilation error shown

I have am trying something in scala worksheet in eclipse. This is not showing any output , and doesn't show any error or warning either. object stream { println("Welcome to the Scala worksheet") def cons[T](hd: T, t1: => Stream[T]): Stream[T] =…
Rpant
  • 974
  • 2
  • 14
  • 37
0
votes
0 answers

How to convert U => Seq[T] to Stream[U=>T]

I'm trying to solve this problem. I want to implement this function in Scala def toSeq[U,T](f: U=>Seq[T]): Stream[U=>T] = ??? I guess the solution should make use of Stream, but I don't know how to solve this. EDIT I will try to describe the use…
Mikel San Vicente
  • 3,831
  • 2
  • 21
  • 39
0
votes
1 answer

Implementing chopBy in Akka Streams

Answering this question, Odomontois showed how you can implement a lazy group-by operator that can group a pre-sorted stream by a key without having to store the whole thing in memory. Is there any way to do something like this with Akka's streams…
0
votes
1 answer

First Element of a Lazy Stream in Scala

Here is a minimal example, I can define a function that gives my the next integer via def nextInteger(input: Int): Int = input+1 I can then define a lazy stream of integers as lazy val integers: Stream[Int] = 1 #:: integers…
Lindon
  • 1,292
  • 1
  • 10
  • 21
-1
votes
1 answer

Operator or method for turning a Scala stream into a stream of streams (suffixes of given stream)

The problem is simple: Convert a stream of elements into a stream of streams of those elements where the first element is the original stream, the second is the tail of the original stream, the third is the tail of the tail, and so on... Example:…
lex82
  • 11,173
  • 2
  • 44
  • 69
1 2
3