Data dodania Pytanie
2017-06-16 14:06 Shouldn’t `EitherT` be covariant? Especially in the Left? »
I have the following code def addKitten(kitten: Kitten): EitherT[Future, GenericError, UUID] = { val futureOfEither = db.run { // returns a Future[...
(2) odpowiedzi
2017-06-16 13:06 Path-dependent types without a path? »
Consider this trivial example: class Outer { case class Inner() def test(i: Inner) = {} } As expected, this doesn't compile because of a type m...
(2) odpowiedzi
2017-06-16 09:06 Function calls with returned tuple without intermediate value »
I have a function in scala that returns a tuple: private def someFunction(from: List[Any], to: List[Any]): (List[Any], List[Any]) = { // Do some s...
(3) odpowiedzi
2017-06-16 02:06 Scala partial application via underscore when composing function literals »
I am composing function literals, though unlike most examples I've seen I'm starting with a multi-argument function that is then curried. I have: //...
(1) odpowiedzi
2017-06-16 00:06 Match may not be exhaustive warning is incorrect »
So the scala compiler is complaining that a pattern match might not be exhaustive for the method foo and I wonder why. This is the code: abstract cla...
(3) odpowiedzi
2017-06-15 23:06 Scala: sort list by sum of duration »
I have the following classes: Task(id: String, time: Duration) Product(id: String, tasks: List[Task]) Then, I have a list list: List[Product] with...
(3) odpowiedzi
2017-06-15 16:06 How to get the sum of two elements in a list of Arrays in Scala »
Hello and thanks in advance for taking the time reading this. I am writing a piece of code in Scala to read a data file, and produce a couple of aggr...
(2) odpowiedzi
2017-06-15 15:06 I have a Expr value that have two child Expr in Scala, how can I execute this in tail position? »
I have a bunch of Expr class defined like this: sealed trait BoolExpr sealed trait Value[T] { def get: T } final case class AndExpr(left: Expr, ri...
(1) odpowiedzi
2017-06-14 15:06 What is the correct restriction on a type projection in Scala? »
I have a difficulty with restrictions on type projections in Scala. Assume I have the following code: sealed trait Color case object Red extends Colo...
(2) odpowiedzi
2017-06-14 08:06 How to collect tuple into separate variables »
def giveMeTuple: Tuple2[String, String] = { Tuple2("one", "two") } def testFive: Unit = { val one, two = giveMeTuple println(one) pri...
(3) odpowiedzi
2017-06-14 08:06 Why creating an actor within actor is dangerous »
The akka documentation is clearly stated that it is dangerous to create an actor within an actor like this: class ActorA extends Actor { def receiv...
(2) odpowiedzi
2017-06-13 15:06 Convert Scala Future and Promise to Java 8 ComletableFuture »
I have read the Scala Future and Promise and this post in stackoverflow, I understand the concept is that You can think of futures and promises as...
(1) odpowiedzi
2017-06-13 12:06 value split is not a member of (String, String) »
Basically i am trying to read data from Kafka and Storing into Cassandra tables through spark RDD's. Getting error while compiling the code: /root/c...
(2) odpowiedzi
2017-06-13 08:06 Does Future.traverse ensure the order of execution »
Im using Future.traverse, is the order of execution guaranteed. My function fn must be called and the future completed before it runs for the next ele...
(3) odpowiedzi
2017-06-12 18:06 Cats: Non tail recursive tailRecM method for Monads »
In cats, when a Monad is created using Monad trait, an implementation for method tailRecM should be provided. I have a scenario below that I found ...
(1) odpowiedzi
2017-06-12 12:06 Do I have to specify type variance in subtypes? »
Let's say I have a trait sealed trait Expr[-InT, +OutT] { def apply(lhs: InT): OutT } I want to create a subtype And contravariant in InT. Do I h...
(1) odpowiedzi
2017-06-12 09:06 What is the best practice for Handling Log message with using functional way »
I'm new in scala programming. I'm puzzled now for how to declare a biz method in a asynchronous and functional way, that the method implementation sho...
(1) odpowiedzi
2017-06-12 04:06 Efficient way to extract a row and do cosine similarity »
In the code below, I get a dense Matrix V after doing SVD. What I want is Given a set of values(say 3,7,9). I want to extract the 3,7 and 9th row o...
(0) odpowiedzi
2017-06-11 23:06 Converting List to Map with foldLeft »
Using below code I'm attempting to produce Map(2017-06-03 09:25:30 -> List( ("c",2190.79) , ("d",24.11), ("d",24.11), ("d",24.11) ), 2017-06...
(4) odpowiedzi
2017-06-11 12:06 Akka Streams: validation of elements being streamed »
I'm new to Akka Streams and I'm wondering how to implement some kind of mid-stream validation. Example: FileIO .fromPath(file) .via(Framing.delim...
(3) odpowiedzi
2017-06-11 06:06 Scala filter and multiple predicates reporting »
I have a 4 predicates private def pred1(ep:MyClass):Boolean = ep.attr1.contains(true) && func1(ep) private def pred2(ep:MyClass):Boolean ...
(1) odpowiedzi
2017-06-10 17:06 Distinguishing Tuple1 in quasiquote matching »
Suppose I want a macro that takes an expression and returns the arity if it's a tuple literal. Something like this works for tuples but returns Some(1...
(0) odpowiedzi
2017-06-10 15:06 spark rdd filter by element class »
I have an RDD with the elements of different types, and I want to count them by their types, for example, the code below will work correctly. scala&g...
(1) odpowiedzi
2017-06-10 14:06 Unresolved dependencies path for SBT project in IntelliJ »
I'm using IntelliJ to develop Spark application. I'm following this instruction on how to make intellij work nicely with SBT project. As my whole tea...
(0) odpowiedzi
2017-06-09 17:06 Scala: creating HashMap using two Lists »
I have two lists in Scala: val workersList = Worker1 :: Worker2 :: Worker3 :: Worker4 :: Nil // type List[Worker] val workStationsList = WS1 :: WS2 :...
(1) odpowiedzi
2017-06-09 16:06 HashMap only has one element instead of three »
I am filling a HashMap in Scala like so: val hashMap = new HashMap[P, List[T]]() { list.map(x => put(x.param1, x.param1.elements)) } The problem...
(1) odpowiedzi
2017-06-09 16:06 How to join on binary field? »
In Scala/Spark, I am trying to do the following: val portCalls_Ports = portCalls.join(ports, portCalls("port_id") === ports("id"), "inner") Howe...
(1) odpowiedzi
2017-06-09 16:06 Is it possible to do finally with Try? »
I'm new to Scala and looked at source code of Try::apply def apply[T](r: => T): Try[T] = try Success(r) catch { case NonFatal(e) => Fail...
(2) odpowiedzi
2017-06-09 07:06 scala how to reduce while n > 0 »
I am wondering if there's a way to deal with a while (n > 0) loop in a more functional way, I have a small Scala app that counts the number of digits ...
(4) odpowiedzi
2017-06-09 03:06 scala early initializer with var cause ClassCastException »
I tried the following code: class C(val g: Int => Int) object C { object A extends { var f: Int => Int = x => x } with C(x =...
(1) odpowiedzi
2017-06-08 20:06 Scala subString function »
Hi I am looking for a solution it will return a substring from string for the given indexes.For avoiding index bound exception currently using if and ...
(2) odpowiedzi
2017-06-08 13:06 How to add groupBy().count() to the source DataFrame? »
I have the following dataframe: +---------------+--------------+--------------+-----+ | column0| column1| column2|label| +--------...
(2) odpowiedzi
2017-06-08 07:06 What are the mandatory options for loading Excel file? »
I have loaded an excel file from S3 using the below syntax, but I am wondering about the options that need to be set here. Why is it mandatory to se...
(1) odpowiedzi
2017-06-08 00:06 Is it the driver or the workers who reads the text file when sc.textfile is used? »
I am wondering how is sc.textfile used in Spark. My guess is that the driver reads a portion of the file at a time, and distributes the read text to t...
(2) odpowiedzi
2017-06-07 20:06 How to suppress the "Stage 2===>" from the output console in spark? »
I have dataframe and trying to get distinct count and able to get distinct count successfully but whenever scala program is executing i'm getting this...
(1) odpowiedzi