scala Questions
5
Solved
Are there any conversions from Either to Try and vice versa in the Scala standard library ? Maybe I am missing something but I did not find them.
Dinosaurian asked 20/3, 2014 at 12:1
1
How does spark decide how many times to replicate a cached partition?
The storage level in the storage tab on the spark UI says “Disk Serialized 1x Replicated”, but it looks like partitions get re...
Lugansk asked 9/4, 2019 at 21:44
3
Solved
As a simplified example, I tried to filter a Spark DataFrame with following code:
val xdf = sqlContext.createDataFrame(Seq(
("A", 1), ("B", 2), ("C", 3)
)).toDF("name", "cnt")
xdf.filter($"cnt" &...
Wink asked 29/11, 2015 at 9:55
2
val spark = SparkSession
.builder()
.appName("try1")
.master("local")
.getOrCreate()
val df = spark.read
.json("s3n://BUCKET-NAME/FOLDER/FILE.json")
.select($"uid").show(5)
I have given th...
Shumate asked 16/6, 2017 at 12:43
4
I'm having hard time understanding what value effect systems, like ZIO or Cats Effect.
It does not make code readable, e.g.:
val wrappedB = for {
a <- getA() // : ZIO[R, E, A]
b <- getB(a...
Morganatic asked 20/12, 2021 at 20:39
2
Solved
I'm trying to migrate a library from Scala 2.13 to Scala 3, but the existing code does not compile.
Here is a snippet
trait Identity
trait Authenticator
trait Env {
type I <: Identity
type A ...
Bernabernadene asked 22/11, 2023 at 15:52
3
Solved
I have a map of replacements
val replacements = Map( "aaa" -> "d", "bbb" -> "x", "ccc" -> "mx")
I would like to replace all occurrences of each map key in the string with the correspondi...
3
Solved
How can I convert a java.util.Set[String] to a scala.collection.Set with a generic type in Scala 2.8.1?
import scala.collection.JavaConversions._
var in : java.util.Set[String] = new java.util.Ha...
2
Solved
I am trying to query data from parquet files in Scala Spark (1.5), including a query of 2 million rows ("variants" in the following code).
val sqlContext = new org.apache.spark.sql.SQLContext(sc) ...
Laryngeal asked 22/3, 2016 at 1:1
4
Solved
I am running some tests with ScalaTest which rely on connections to test servers to be present. I currently created my own Spec similar to this:
abstract class ServerDependingSpec extends FlatSpec...
11
Solved
I try to compile a simple object in IntelliJ:
object Test02 {
def main(args: Array[String]) {
println("Hello World");
}
}
I got this message:
Error:scalac: Scala compiler JARs not found (mo...
Madel asked 31/3, 2016 at 18:45
4
Solved
I have the following:
serv match {
case "chat" => Chat_Server ! Relay_Message(serv)
case _ => null
}
The problem is that sometimes I also pass an additional param on the end of the ser...
Antislavery asked 19/3, 2012 at 12:42
5
Solved
I am using Spark 1.5.
I have two dataframes of the form:
scala> libriFirstTable50Plus3DF
res1: org.apache.spark.sql.DataFrame = [basket_id: string, family_id: int]
scala> linkPersonItemLes...
Whole asked 13/12, 2016 at 14:43
8
Solved
I am trying to inspect the SBT dependency tree as described in the documentation:
sbt inspect tree clean
But I get this error:
[error] inspect usage:
[error] inspect [uses|tree|definitions] <...
Saltish asked 27/8, 2014 at 6:0
2
Solved
I'm struggling to write back to an Azure Blob Storage Container. I'm able to read from a container using the following:
storage_account_name = "expstorage"
storage_account_key = "1VP...
Disarrange asked 11/9, 2020 at 16:36
3
Solved
How would one go about transforming an Discriminated Union in F# to Scala:
type Expr =
| Val of String
| Integer of Int32
| Lower of Expr * Expr
| Greater of Expr * Expr
| And of Expr * Expr
...
4
A promise represents a value that might become available in the future (or fails to do so).
What I am looking for is a data type which represents an available value that might become unavailable i...
Polly asked 28/9, 2014 at 11:32
3
Solved
I am writing files to disk using Scala.
To create the whole String that will be written to the file, I am currently iterating over my data and appending all the information to a StringBuilder obje...
Saxen asked 31/7, 2015 at 16:54
4
Solved
Suppose I need to convert Option[Int] to Either[String, Int] in Scala. I'd like to do it like this:
def foo(ox: Option[Int]): Either[String, Int] =
ox.fold(Left("No number")) {x => Right(x)}
...
Stipe asked 10/1, 2016 at 14:19
3
Solved
I am new to scala and I am trying out few sample codes for testing. However I am facing some issues when I run the test code. When I run the test, I am getting an error
[trace] Stack trace suppres...
3
I want my Spark application to read a table from DynamoDB, do stuff, then write the result in DynamoDB.
Read the table into a DataFrame
Right now, I can read the table from DynamoDB into Spark a...
Bertold asked 8/12, 2017 at 21:48
4
Solved
I have looked at these links
http://blog.danielwellman.com/2008/03/using-scalas-op.html
http://blog.tmorris.net/scalaoption-cheat-sheet/
I have a map of [String, Integer] and when I do a map.get...
Reptile asked 17/4, 2012 at 8:50
2
What is a singleton type? what are the applications, the implications ?
Examples are more than welcome and layman terms are even more welcome !
Sagitta asked 10/10, 2015 at 8:48
8
Solved
In scala, we cannot extend object:
object X
object Y extends X
gives an error error: not found: type X
In my case someone has defined some functionality in an object and I need to extend it (b...
Embosser asked 2/10, 2011 at 7:2
4
Solved
Specifically, what's the easiest and most idiomatic way to replace special XML characters in a string. E.g., what's the easiest and most idiomatic way to convert <Jack & Jill> to &lt;...
© 2022 - 2024 — McMap. All rights reserved.