Questions tagged [scala]
Scala is a general-purpose programming language principally targeting the Java Virtual Machine. Designed to express common programming patterns in a concise, elegant, and type-safe way, it fuses both imperative and functional programming styles. Its key features are: an advanced static type system with type inference; function types; pattern-matching; implicit parameters and conversions; operator overloading; full interoperability with Java; concurrency
scala
112,647
questions
0
votes
0
answers
7
views
Output is not giving as Range(1,2,3,4) for val from1Until5 = 1 until 5 println(s"Range from 1 until 5 where 5 is excluded = $from1Until5")
I am executing
println("\nStep 2: Create a numeric range from 1 to 5 but excluding the last integer number 5")
val from1Until5 = 1 until 5
println(s"Range from 1 until 5 where 5 is ...
27
votes
1
answer
15k
views
Scala - Booleans - & vs. &&, | vs. ||
I just noticed that in Scala Boolean supports both & and &&. Is there a difference between these two operators? The Scala docs use the exact same description for both of them, so I wasn't ...
233
votes
5
answers
83k
views
How to clone a case class instance and change just one field in Scala?
Let's say I have a case class that represents personas, people on different social networks. Instances of that class are fully immutable, and are held in immutable collections, to be eventually ...
0
votes
1
answer
20
views
nested case class generic filter method
I have some nested case classes that may look like the following:
case class Lowest(intVal: Int, stringVal: String)
case class Mid (lowestSeq: Seq[Lowest])
case class High (midSeq: Seq[Mid])
So if ...
0
votes
0
answers
19
views
How to address the performance impact of executing multiple functions dynamically compiled with Scala 2's runtime reflection?
I have an entity that generates Scala functions compiled dynamically using Scala 2's runtime reflection. My case is slightly more convoluted, but the following showcases the issue:
import scala....
0
votes
2
answers
315
views
Spark stream to Azure cosmos DB
I am trying to stream aggregated data to Azure Cosmos DB using spark stream. The sample spark stream application take input from n/w console and then apply aggregation to it and trying write the ...
0
votes
0
answers
9
views
Create Flow[ByteString, ByteString, NotUsed] by piping through InputStream
I need decompress data using compression not supported by akka, but supported by other library which provided InputStream interface.
To make it work with akka stream, I need to implement function:
def ...
-1
votes
0
answers
14
views
How to run MySQL scripts when I run docker compose? [duplicate]
I have a Scala backend and Javascript frontend applications and MySQL database. I want to create docker images for every one of them with one docker-compose.yml file and I want to run the scripts for ...
1
vote
0
answers
22
views
Scala 3 reflection: collect all members that are singleton objects
I have a method in Scala 2 that uses reflection. It doesn't work in Scala 3, and I would like to reimplement it so it works for Scala 3. (I will no longer need it for Scala 2 anymore, so it need not ...
185
votes
17
answers
198k
views
How to turn off INFO logging in Spark?
I installed Spark using the AWS EC2 guide and I can launch the program fine using the bin/pyspark script to get to the spark prompt and can also do the Quick Start quide successfully.
However, I ...
15
votes
1
answer
20k
views
Timed out waiting for container port to open (localhost ports: [32773] should be listening)
I am trying to use testcontainers-scala that is inherent from Testcontainers as the following:
final class MessageSpec extends BddSpec
with ForAllTestContainer
with BeforeAndAfterAll {
override ...
1
vote
1
answer
47
views
multiple pattern matching on iteration
val subjectpairs = IndexedSeq((8,0),(3,4),(0,9),(6,1))
val priors = subjectpairs.map { case( f,_) => f}.filter{ _ >0.0}
val posts = subjectpairs.map { case( _,l) => l}.filter{ _ >0.0}
...
1
vote
0
answers
27
views
Chisel Template Not Functioning Windows 11 - Cannot run program "which": CreateProcess error=2, The system cannot find the file specified
After having cloned the template project for Chisel (https://github.com/chipsalliance/chisel-template) I tried running sbt test, and I got the following error in the file /src/test/scala/gcd/GCDSpec:
&...
0
votes
1
answer
17
views
Adding new Rows to Spark Partition while using forEachPartition
I am trying to add a new Row to each Partition in my Spark Job. I am using the following code to achieve this:
StructType rowType = new StructType();
rowType.add(DataTypes.createStructField("...
0
votes
0
answers
150
views
Is it safe run blocking call in OS executor when using virtual thread?
When using virtual thread, can I safely use a separate thread pool while interacting with a library we don't have a control over, such as HikariCP DB connection manager, which uses synchronized blocks,...