Category "scala"

Casting Any to Tuple2

I have a Scala function which passes message of type 'Any'. In most cases it will be a tuple of size 2. The function that receives this message needs to see the

Why does calling cache take a long time on a Spark Dataset?

I'm loading large datasets and then caching them for reference throughout my code. The code looks something like this: val conversations = sqlContext.read .f

Why don't Scala traits allow constructor parameters?

I'm new to Scala, coming from Java, and I was just reading about traits. One thing that gets mentioned often is that traits don't (can't? won't?) have construc

Intellij code style setting for wrapping on multi line function arguments

The Spark code style requires four character indentation for multi parameter methods. So: the following code -as presently formatted by IJ - is incorrect: def

Error when run jar Exception in thread "main" java.lang.NoSuchMethodError scala.Predef$.$conforms()Lscala/Predef$$less$colon$less;

I work on spark application using (spark 2.0.0 & scala 2.11.8) and the application works fine within intellij Idea environment. I've extracted application a

private[this] vs private

In Scala I see such feature as object-private variable. From my not very rich Java background I learnt to close everything (make it private) and open (provide a

How to use BehaviorTestKit to verify the right child was spawned

I'm trying to test determine that my actor spawned a child with the right parameters. There is testKit.expectEffect(Spawned(behavior,name,props)) But it's i

Gatling Websocket react on message

Is it possible to write a gatling script which connects to WebSocket and then performs actions (e.g. new HTTP requests) when certain messages are received (pref

TestNG Cannot find class in classpath once a new scala class is added to the suite.xml file

Seems like this is a very "popular" question on SO with no definitive way to fix it but I'm asking the question anyway because I can provide some more details.

Marshalling java.util.Date with SprayJson

I am new to Scala and Akka. I have the following case class: case class Demo(userId: String, date: java.util.Date, message: String) extends BusinessModel

Writing unit tests for tapir endpoints (API Layer) in scala

I have created tapir endpoints in scala, where the architecture of the project is such that API layer calls service layer and service layer calls repo layer. I

Scala collectFirst with function returning Option[U]

I've had this situation occur a number of times in the library I'm writing, and I'm not particularly satisfied with the solutions I've come up with so far. Let

object.type does not take parameter error

Following is the code snippet I am using from play with scala book. It works well in the framework but when I try in the commndline it gives the error error:

Gatling load testing and running scenarios

I am looking to create three scenarios: The first scenario will run a bunch of GET requests for 30s The second and third scenarios will run in parallel and wait

How do we do Spark Dataframe testing using JUnit?

We are trying to build an integration test suite using JUnit. Our pipeline (built in Spark using Scala) gives us DataFrames as output, we plan to compare them a

Failed to build request: No attribute named 'token' is defined in Gatling script

I convert HAR file to Gatling simulations script, but I have problem with extracting token from request header. After conversion I have the following code: impo

Apache Arrow in Scala: AbstractMethodError on loadBatch

I'm trying to load Arrow file into scala. But every time I call ethier arrowStreamReader.loadNextBatch() nor arrowFileReader.loadRecordBatch(arrowBlock), the JV

Get item in the list in Scala?

How in the world do you get just an element at index i from the List in scala? I tried get(i), and [i] - nothing works. Googling only returns how to "find" an

IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified

I got the error "IOException: Cannot run program "javac": CreateProcess error=2, The system cannot find the file specified" while running my scala project in pl

Multidimensional Array zip array in scala

I have two array like: val one = Array(1, 2, 3, 4) val two = Array(4, 5, 6, 7) var three = one zip two map{case(a, b) => a * b} It's ok. But I have a multid