Data dodania Pytanie
2017-07-23 13:07 Upper bounds in Scala »
I am trying to set Upper Bounds for a variable. trait Container { type A <: Number def value: A } Then when I try to get a value for my objec...
(3) odpowiedzi
2017-07-22 16:07 Shorthand to Init a Scala Enumeration ValueSet with one Value »
So I have a some Scala Enumeration object: object KnotType extends Enumeration { type KnotType = Value val STOPPER, HITCH, ENDLOOP, MIDL...
(1) odpowiedzi
2017-07-22 15:07 union types in scala with subtyping: A|B <: A|B|C »
I would like to have a A|B type to be the subtype of A|B|C. Is that possible to encode in Scala ? If yes, how ? I was hoping that I can make implicit...
(2) odpowiedzi
2017-07-22 14:07 How to synchronize Intellij and sbt builds for a scala project »
I have an sbt project that I have imported into Intellij. Sometimes I build the project at the command line using sbt, and then when I need to debug I...
(1) odpowiedzi
2017-07-21 23:07 Combining varargs and higher order functions »
Trying to use varargs with higher order functions. But the below doesn't seem to type/compile. def f(n: Any*) = {...} //compiles def f(fun: Any* =&g...
(1) odpowiedzi
2017-07-21 16:07 Scala: What'd be the idiomatic way to test equally spaced frequencies in array? »
I have a Scala application and have the following use case. Given a numberOfDates: Int and an optimalFrequencyInDays: Int I need to find the frequency...
(2) odpowiedzi
2017-07-21 06:07 replace a while loop with Future in scala »
I have a function with return value of Future[Int] def func: Future[Int] = {...} I will periodically check the return value of func until it meet s...
(1) odpowiedzi
2017-07-20 23:07 Why was NetLogo implemented in a mixture of Java and Scala? »
Why was NetLogo implemented in a mixture of Java and Scala? Was it because of better support for concurrency? I am not familiar with Scala, but I thin...
(1) odpowiedzi
2017-07-20 15:07 How to use instanceof with scala object? »
I've the following scala hierarchy: sealed trait SessionResult[+T] { def toOption: Option[T] } object SessionResult { trait SessionValue[T] exte...
(1) odpowiedzi
2017-07-20 13:07 How to display the records from Kafka to console? »
I'm learning Structured Streaming and I was not able to display the output to my console. import org.apache.spark.sql._ import org.apache.spark.sql.f...
(0) odpowiedzi
2017-07-19 14:07 Build path for different events and assign globalID »
We are working with spark 1.6 and we are trying to keep global identity for similar events. There can be few "groups"of events with identical ID (in t...
(0) odpowiedzi
2017-07-19 08:07 How do I know the type of a scala function »
I would like to know the type of a scala function in repl. In Haskell it is :t, can anyone tell what it's equivalent in scala? ...
(1) odpowiedzi
2017-07-19 05:07 Why a Thread.sleep or closing the connection is required after waiting for a remove call to complete? »
I'm again seeking you to share your wisdom with me, the scala padawan! I'm playing with reactive mongo in scala and while I was writting a test using...
(1) odpowiedzi
2017-07-18 23:07 Scala: implicitly convert Option to Option of implicit class »
How to implicitly convert Option[A] to Option[B], where B is an implicit class of A? In the following code only converter1 works, but the return type...
(0) odpowiedzi
2017-07-18 13:07 foreach loop in scala »
In scala foreach loop if I have list val a = List("a","b","c","d") I can print them without a pattern matching like this a.foreach(c => println...
(3) odpowiedzi
2017-07-18 10:07 Parquet ClassCastException:parquet.io.MessageColumnIO cannot be cast to parquet.io.PrimitiveColumnIO »
I try to write a simple Scala program that dumps data to Parquet files into HDFS. I create an Avro schema, initialize a ParquetWriter with this sche...
(0) odpowiedzi
2017-07-17 22:07 Scala: concatenating a string in a regex pattern string causing issue »
If I am doing this it is working fine: val string = "somestring;userid=someidT;otherstuffs" var pattern = """[;?&]userid=([^;&]+)?(;|&|$...
(2) odpowiedzi
2017-07-17 15:07 What is the size of empty class in scala? »
What is the size of an empty class in Scala? I used SizeEstimator to get the size of an empty class. However the size I get is 1368 (bytes) which look...
(2) odpowiedzi
2017-07-17 15:07 How can I test if a Java object is an enum in scala? »
I have a method which converts a string to an int and a Java enum to an int. For other data types, it doesn't do any conversion. def myConverter[T](a...
(2) odpowiedzi
2017-07-16 21:07 Add a custom accessor to property without renaming constructor parameter in Scala »
For example, I have the following class class Person(val name: String) { } Some code use this class invoking constructor with named parameters val...
(1) odpowiedzi
2017-07-16 16:07 Spark complex grouping »
I have this data structure in Spark: val df = Seq( ("Package 1", Seq("address1", "address2", "address3")), ("Package 2", Seq("address3", "address4", ...
(1) odpowiedzi
2017-07-16 08:07 Recursvie reading in folder spark sql »
SparkI try to use HiveContext to take advantage some windows functions in HiveQL in SparkSQL. But it cannot help me to read recursively data file in a...
(0) odpowiedzi
2017-07-15 19:07 Scala flattening embedded list of lists »
I have created a Twitter datastream that is displaying hashtag, author, and mentioned users in the below format. (List(timetofly, hellocake),Shera_E...
(2) odpowiedzi
2017-07-15 13:07 Opening two KafkaStreams after each other with different StreamingContext »
I am currently trying to implement a two staged process in spark streaming. First I open a kafkaStream, read everything that is already in the topic b...
(1) odpowiedzi
2017-07-15 12:07 Akka HTTP api routes structure »
I'm writing Akka-HTTP based REST API. As I'm new to Akka and Scala, I'm not sure what could be the best way of organize code in my project. I will hav...
(1) odpowiedzi
2017-07-14 20:07 How to define multiple Custom Delimiter for input file in spark? »
The default input file delimiter while reading a file via Spark is newline character(\n). It is possible to define a custom delimiter by using "textin...
(1) odpowiedzi
2017-07-14 14:07 Scala - How AbstractSeq reduces bytecode size »
I was going through scaladocs and came across AbstractSeq class. They describe it as Explicit instantiation of the Seq trait to reduce class file siz...
(1) odpowiedzi
2017-07-14 14:07 Usage of extends keyword in a companion object definition »
I am reading this article by Odersky and Spoon. So here goes a code listing from this article with one peculiar aspect: import scala.collection.mutab...
(0) odpowiedzi
2017-07-13 19:07 How to split comma separated string and get n values in Spark Scala dataframe? »
How to take only 2 data from arraytype column in Spark Scala? I got the data like val df = spark.sqlContext.sql("select col1, col2 from test_tbl"). I...
(2) odpowiedzi
2017-07-13 17:07 Why nested FlatMaps could blow up the stack in Scala? »
I am learning the Trampoline trick in Scala by reading this paper Stackless Scala with Free Monad, by Rúnar Bjarnason. But I got stuck in section 4.3...
(1) odpowiedzi
2017-07-13 15:07 Combining Futures of different types using Cats »
I have futures of different types. import cats.Cartesian import cats.instances.future._ import cats.syntax.cartesian._ import scala.concurrent.Future...
(1) odpowiedzi
2017-07-13 14:07 "Nothing is a subclass of every other class", how to understand it? »
These days, I am reading the book "programming in scala". There is one sentence in the book on Page 246, Chapter11, first paragraph: For example, ...
(1) odpowiedzi
2017-07-12 22:07 Failing to inject Play's WSClient instance using injector »
I have a Class that has a WSClient dependancy injected: @Singleton class MyApiService @Inject() (wsclient: WSClient, conf: Configuration) { ... } a...
(1) odpowiedzi
2017-07-12 19:07 Scala generic function with parsing object »
I need a function like this (sorry I need null) def foo[T](json: JsonElement): T = json match { case x: JsonObject => gson.fromJson(x, classOf[T...
(2) odpowiedzi
2017-07-12 18:07 "Pimp my Library" in C++ »
In Scala, there's a design pattern often called "pimp my library". The basic idea is that we have some class Foo (presumably in some library that we c...
(3) odpowiedzi