Data dodania Pytanie
2017-07-15 19:07 Scala flattening embedded list of lists »
I have created a Twitter datastream that is displaying hashtag, author, and mentioned users in the below format. (List(timetofly, hellocake),Shera_E...
(2) odpowiedzi
2017-07-15 13:07 Opening two KafkaStreams after each other with different StreamingContext »
I am currently trying to implement a two staged process in spark streaming. First I open a kafkaStream, read everything that is already in the topic b...
(1) odpowiedzi
2017-07-15 12:07 Akka HTTP api routes structure »
I'm writing Akka-HTTP based REST API. As I'm new to Akka and Scala, I'm not sure what could be the best way of organize code in my project. I will hav...
(1) odpowiedzi
2017-07-14 20:07 How to define multiple Custom Delimiter for input file in spark? »
The default input file delimiter while reading a file via Spark is newline character(\n). It is possible to define a custom delimiter by using "textin...
(1) odpowiedzi
2017-07-14 14:07 Scala - How AbstractSeq reduces bytecode size »
I was going through scaladocs and came across AbstractSeq class. They describe it as Explicit instantiation of the Seq trait to reduce class file siz...
(1) odpowiedzi
2017-07-14 14:07 Usage of extends keyword in a companion object definition »
I am reading this article by Odersky and Spoon. So here goes a code listing from this article with one peculiar aspect: import scala.collection.mutab...
(0) odpowiedzi
2017-07-13 19:07 How to split comma separated string and get n values in Spark Scala dataframe? »
How to take only 2 data from arraytype column in Spark Scala? I got the data like val df = spark.sqlContext.sql("select col1, col2 from test_tbl"). I...
(2) odpowiedzi
2017-07-13 17:07 Why nested FlatMaps could blow up the stack in Scala? »
I am learning the Trampoline trick in Scala by reading this paper Stackless Scala with Free Monad, by Rúnar Bjarnason. But I got stuck in section 4.3...
(1) odpowiedzi
2017-07-13 15:07 Combining Futures of different types using Cats »
I have futures of different types. import cats.Cartesian import cats.instances.future._ import cats.syntax.cartesian._ import scala.concurrent.Future...
(1) odpowiedzi
2017-07-13 14:07 "Nothing is a subclass of every other class", how to understand it? »
These days, I am reading the book "programming in scala". There is one sentence in the book on Page 246, Chapter11, first paragraph: For example, ...
(1) odpowiedzi
2017-07-12 22:07 Failing to inject Play's WSClient instance using injector »
I have a Class that has a WSClient dependancy injected: @Singleton class MyApiService @Inject() (wsclient: WSClient, conf: Configuration) { ... } a...
(1) odpowiedzi
2017-07-12 19:07 Scala generic function with parsing object »
I need a function like this (sorry I need null) def foo[T](json: JsonElement): T = json match { case x: JsonObject => gson.fromJson(x, classOf[T...
(2) odpowiedzi
2017-07-12 18:07 "Pimp my Library" in C++ »
In Scala, there's a design pattern often called "pimp my library". The basic idea is that we have some class Foo (presumably in some library that we c...
(3) odpowiedzi
2017-07-12 15:07 How to apply a function for the first certain elements of an array in Scala? »
Suppose we have an array: val arr = Array[(String, Int)](("A", 3), ("B", 5), ("C", 2), ("D", 7), ("E", 4)) I want to calculate the cumulative sum o...
(4) odpowiedzi
2017-07-11 11:07 How to sort a list of scala objects by sort order of other list? »
I am having following 2 lists in scala. case class Parents(name: String, savings: Double) case class Children(parentName: String, debt: Doub...
(2) odpowiedzi
2017-07-11 10:07 Understanding Scala Future andThen »
I'm trying to use andThen method to register action stages for the future. Like this: implicit val executionContext = ExecutionContext.global val f ...
(1) odpowiedzi
2017-07-11 02:07 Self-type does not conform to base class »
Using the following code: trait Hello[B <: Baz[_, _]] trait World[F <: Foo] { self: Hello[Baz[F, _]] => def foo: F } trait Baz[F <: F...
(1) odpowiedzi
2017-07-10 23:07 Does "Lifting" in functional programming follows strict rules? »
I have looked into "lifting" q/a's, examples it seemed to me lift function is just like any transformation function that changes the shape (like monad...
(1) odpowiedzi
2017-07-10 14:07 how to make the element contains '$' char as key, and behind the key's numbers as a List? »
there is a Array ,how to make the element contains '$' char as key, and behind the key's numbers as a List val a = Array("$A", 1234, "$B", 123, 4, 5)...
(4) odpowiedzi
2017-07-10 10:07 How setup spark sql show to output different number format? »
After show command spark prints the following: +-----------------------+---------------------------+ |NameColumn |NumberColumn ...
(3) odpowiedzi
2017-07-10 04:07 Monad's left unit law does not seem to hold for Lists in scala. Are scala Lists not monads then? »
Monads' "left unit law": unit(x) flatMap f == f(x) But: (List(1) flatMap ((x: Int) => Some[Int](x))) == List(1) // true ((x: Int) => Some[In...
(2) odpowiedzi
2017-07-09 17:07 why I cant extend playFrameworks NingWSComponents? (play 2.6.0) »
From what I understand, to use WSClient instance you need to mix NingWSComponents, like this guy answer here how to inject dependencies to a service w...
(0) odpowiedzi
2017-07-09 13:07 Public Scala constructor fields not public in Java »
The question is quite simple. When I declare a Scala field directly in a constructor, like this: class Vector2D(val x: Float, val y: Float) { } Th...
(2) odpowiedzi
2017-07-09 06:07 Can Scala classes be used in Java »
class Wish{ val s = "Hello! User. Wish you a Great day." } object Wish{ def main(args: Array[String]){ val w = new Wish() pr...
(2) odpowiedzi
2017-07-08 21:07 Scala: Is hashCode() & equals() for case classes only generated if not already specified in a non-trivial superclass? »
I tried to define an abstract class "Vertex" in such a way that all instances of all its subclasses are identified (in sets/maps/distinct, etc.) by th...
(1) odpowiedzi
2017-07-08 19:07 Force tableswitch instead of lookupswitch »
Scala 2.11 compiles a match expression over a relatively dense Int range into a lookupswitch: lookupswitch { // 21 -12: 200 -11: 200 -10:...
(2) odpowiedzi
2017-07-08 06:07 Scala: Is it legit to refer to underscore parameters as x$n »
Say I have this function: val f = (x: Int) => x + x Now, I can rewrite this expression as val f = (_: Int) + x$1 This compiles because _ expa...
(1) odpowiedzi
2017-07-07 14:07 Scala implicit conversion of container nested types »
Consider the following example: case class A() case class B() object Conversions { implicit def aToB(a: A): B = B() implicit def convert[U, T]...
(1) odpowiedzi
2017-07-07 12:07 Run scoverage from intellij »
I was wondering, is it possible to run scoverage from intellij and even better, see scoverage reports like the native coverage from intellij? Thanks ...
(0) odpowiedzi
2017-07-07 09:07 Clarification of Scala function »
I am trying to execute this function def sumofdouble[T <:Number] (as:T*): Double = as.foldLeft(0d)(_ + _.doubleValue) If I try using this functi...
(1) odpowiedzi
2017-07-06 11:07 Akka: How to combine OneForOneStrategy and AllForOneStrategy »
If I define the supervisor strategy for an actor in Scala, how can I use both the OneForOneStrategy and the AllForOneStrategy? Is there a simple way t...
(1) odpowiedzi
2017-07-06 10:07 Pass file as command line argument to Spark »
I am coding a Spark job in Scala and need to send some argument through command-line in JSON file format like the application name, master and some mo...
(1) odpowiedzi
2017-07-06 09:07 Scala tuple function composition »
Let's say we have a 3 functions with Tuple3 result: def foo(a: String, b: String, c: String): (String, String, String) = { (s"foo_$a", s"foo_$b", s...
(3) odpowiedzi
2017-07-05 16:07 Scala: Making higher kinded type with some generic type »
For example I have defined a Monad Trait like this: trait Monad[F[_]] { def unit[T](a: => T): F[T] def flatMap[A, B](fa: F[A])(f: A => F[B]...
(1) odpowiedzi
2017-07-05 09:07 Condition on rows content of dataframe in Spark scala »
I have the following dataframe: +--------+---------+------+ | value1| value2 |value3| +--------+---------+------+ | a | 2 | 3 | +----...
(2) odpowiedzi