Data dodania Pytanie
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
2017-06-07 18:06 Scala - XML PrettyPrinter.format() giving noSuchMethodError »
I have this piece of code that should convert an XML.Elem object into a readable and properly indented text, but when I run it it keeps giving me an e...
(1) odpowiedzi
2017-06-07 16:06 Understanding mutable Seq »
I'm pretty new to Scala and try to understand mutable Seq. Since it's in package mutable I expected there is a method that allows us to append element...
(2) odpowiedzi
2017-06-06 21:06 Implementation of flatMap() for State transition »
Exercise 6.8, Chiusano and Bjarnason, Functional Programming in Scala, p. 87 asks how one might implement flatMap() for the following trait: trait RN...
(1) odpowiedzi
2017-06-06 14:06 Scala : Type Nothing with User defined classes »
In scala Nothing is a subtype of every other type. scala> class A {} defined class A scala> def x[T >: Nothing](t: T): Unit = {} x: [T](t:...
(1) odpowiedzi
2017-06-06 08:06 Shapeless find instance of Some among Nones in an Hlist of Options »
lets say I have the following class hierarchy: sealed trait Animal case class Cat(isFriendly: Boolean) extends Animal case class Dog(color: String) ...
(1) odpowiedzi
2017-06-06 04:06 Mongo scala driver 2.0 with non default akka execution context »
I have started using mongo scala driver in our scala akka-http project and it has been great help especially the case class support in v2.0.0 is very ...
(0) odpowiedzi
2017-06-05 16:06 Weird compile error involving type parameters with a wildcard »
I am sorry, I can't formulate the title (or the question for that matter) to be any more informative than this, because I have no idea what is going o...
(1) odpowiedzi
2017-06-05 13:06 How to split columns into two sets per type? »
I have a CSV input file. We read that using the following val rawdata = spark. read. format("csv"). option("header", true). option("inferSche...
(2) odpowiedzi
2017-06-05 12:06 Column name with dot spark »
I am trying to take columns from a DataFrame and convert it to an RDD[Vector]. The problem is that I have columns with a "dot" in their name as the f...
(1) odpowiedzi
2017-06-04 22:06 Shapeless not working in generic context »
I am still trying to get my head around Shapeless (and, to a lesser extent, Scala!) and I have been writing some simple code to generate random instan...
(2) odpowiedzi
2017-06-04 11:06 ADT with for comprehension »
I have an use case where I need to use for comprehension with ADT in Scala. I could write the same code using flatMaps but it seems a bit unreadable. ...
(1) odpowiedzi
2017-06-04 03:06 how to create combinations of elements in a list in scala »
I have a rdd of list of strings, like the following: (['a','b','c'],['1','2','3','4'],['e','f'],...) now I want to get the list consists of all pa...
(1) odpowiedzi
2017-06-04 03:06 How to get max and min values of an Array of Tuples »
Say I have a List of Tuples of Integers var i = Array(1->3, 5->9, 15->18) How can I return a Tuple of the highest and lowest values from t...
(2) odpowiedzi
2017-06-03 22:06 How to wrap Web Worker response messages in futures? »
Please consider a scala.js application which runs in the browser and consists of a main program and a web worker. The main thread delegates long runn...
(1) odpowiedzi
2017-06-03 13:06 Merging list of uneven length with default value for missing matches »
Im trying to pair up two lists in Scala where non matching pairs should be replaced by a default value, this is what I have so far but thy all fall sh...
(1) odpowiedzi
2017-06-03 09:06 Case object extending class with constructor in Scala »
I am a beginner in Scala and was playing around to learn more about Abstract data types. I defined the following definition to replicate Option type: ...
(3) odpowiedzi
2017-06-03 06:06 Remove one element from Scala List »
For example, if I have a list of List(1,2,1,3,2), and I want to remove only one 1, so the I get List(2,1,3,2). If the other 1 was removed it would be ...
(3) odpowiedzi
2017-06-02 16:06 Scala takeWhile Method with foldLeft and foldRight »
I need to make takeWhile() using foldLeft() and foldRight(). I've come up with this: def takeWhile(ls:List[Int], p:Int => Boolean): List[Int] = { ...
(3) odpowiedzi
2017-06-02 10:06 Problems to create DataFrame from Rows containing Option[T] »
I'm migrating some code from Spark 1.6 to Spark 2.1 and struggling with the following issue: This worked perfectly in Spark 1.6 import org.apache.sp...
(2) odpowiedzi
2017-06-02 01:06 Shapeless StringLike trait with minimal boilerplate »
I'm trying to define a general method for making string-like types. For example, I'd like case class Foo1(s: String) extends AnyVal case class Foo2(...
(1) odpowiedzi
2017-06-01 15:06 My coproduct encoding is ambiguous »
This question has come up a few times recently, so I'm FAQ-ing it here. Suppose I've got some case classes like this: import io.circe._, io.circe.gen...
(1) odpowiedzi
2017-06-01 15:06 Downloading csv file using Play Framework? »
I want to add to my app a simple button that on click will call an Action that will create a csv file from two lists I have and download it to the use...
(2) odpowiedzi
2017-06-01 13:06 scala Array[Byte] diff »
I am using diff method to compare two String's byte arrays but giving unexpected (or is it the expected behavior?) results. diff() returns true for (...
(1) odpowiedzi
2017-05-31 13:05 Why is reference assignment atomic in Java? »
As far as I know reference assignment is atomic in a 64 bit JVM. Now, I assume the jvm doesn't use atomic pointers internally to model this, since oth...
(3) odpowiedzi
2017-05-31 12:05 Scala typeclasses implicit resolution »
(Scala 2.11.8) Consider the following code: object ScalaTest extends App { class Wrapper { import Wrapper._ def init(): Unit = { //...
(2) odpowiedzi