Data dodania Pytanie
2017-10-02 16:10 Scala: type classes, default and custom implicit conversions in the same scope »
I'm wondering whether there is an elegant way to have both the default implicit conversions and some user-defined custom conversion in the same scope....
(1) odpowiedzi
2017-10-02 14:10 How to generically extract field names with Shapeless? »
Given a case class A I can extract its field names with Shapeless using the following snippet: val fieldNames: List[String] = { import shapeless._ ...
(1) odpowiedzi
2017-10-02 08:10 How to convert base64 encoded string to an image file using Apache Commons Codec in Scala »
I'm trying to decode an image which's encoded base64 string to image file using Apache Commons Codec in Scala. Converting an image file to base64-enco...
(0) odpowiedzi
2017-10-01 11:10 Scala - Spark GraphX: debug code that runs Pregel operator »
I want to performe Pregel operator on my graphX network with my custom logic to vprog, sendMsg and mergeMsg but results are wrong. So, how can I debug...
(1) odpowiedzi
2017-10-01 10:10 What exactly is a category? »
I am reading Category Theory for Programmers, and I cannot figure out what exactly a category is. Let's consider the Bool type. Is Bool a category an...
(2) odpowiedzi
2017-10-01 08:10 How do I efficiently count distinct fields in a collection? »
I am currently doing this: val count = sightings.map(_.shape).distinct.length However, map creates an intermediary collection, which in my case is...
(3) odpowiedzi
2017-09-30 20:09 Shapeless HList appender »
I'm trying to write a function that would append an HList, I found that Updater is the closest to what I want: def appender[L <: HList, V, Out &...
(2) odpowiedzi
2017-09-30 12:09 Why doesn't Play framework close the Akka Stream? »
An actor initializes an Akka stream which connects to a websocket. This is done by using a Source.actorRef to which messages can be send, which are th...
(1) odpowiedzi
2017-09-30 09:09 Storing each element from each RDD to a new List »
I am trying to store each element from each rdd into a new list. I can print the elements but I could not store elements in list or even having a stri...
(1) odpowiedzi
2017-09-29 21:09 Error Calling Generic Function In Scala »
So I'm following fpinscala and I have this Object: sealed trait List[+A] case object Nil extends List[Nothing] case class Cons[+A](head: A, tail: Lis...
(1) odpowiedzi
2017-09-29 21:09 Scala Functional Programming Generics »
I'm trying to implement a generic compose combinator Recall that the composition of two functions—f and g-- is h(x) = f(g(x)) def inc(x: Doubl...
(1) odpowiedzi
2017-09-29 20:09 Why there is no partial function chaining method other than orElse »
I ask this question, because i found myself needing functionality similar to andThen of normal function (but still conforming to semantics of partial ...
(0) odpowiedzi
2017-09-29 13:09 What is the difference of the unapply function in pattern matching and in a partial function »
I have an extractor which extracts an object from a string. case class ItemStructure(id: String, data: String) object ItemStructure { def unapply(...
(2) odpowiedzi
2017-09-28 16:09 How to replace values in RDD 1 per keys in RDD 2? »
Here are two RDDs. Table1-pair(key,value) val table1 = sc.parallelize(Seq(("1", "a"), ("2", "b"), ("3", "c"))) //RDD[(String, String)] Table2-Ar...
(3) odpowiedzi
2017-09-28 11:09 How to understand monad in scala »
I just understood what type constructor and higher kinded types states for and now I'm trying to understand Monad. Here is how Monad trait looks in sc...
(1) odpowiedzi
2017-09-28 10:09 Error while adding slick dependency using sbt »
I'm new in scala world (coming from android world), I have created scala project with play-framework, everything works fine now I need to add database...
(2) odpowiedzi
2017-09-27 22:09 Play Framework 2.6 CSRF and Session »
I got strange issue. I'm implementing cart functionality on my website and I use session to store cart positions. I have a POST action to add new posi...
(0) odpowiedzi
2017-09-27 14:09 Scala: Mock init fails with Cats IO type parameter »
While writing tests I'm confronted with the following exception: java.lang.ClassCastException: codegen.java.lang.Object$MockitoMock$641592186 cannot ...
(1) odpowiedzi
2017-09-27 08:09 Scala Tail Recursion »
So I have this recursive function that multiplies two numbers, simple enough. def mul(n: Int, m: Int):Int = if(m > 1) n + mul(n, dec(m...
(1) odpowiedzi
2017-09-27 06:09 very fast upstream followed by very slow downstream and out of memory issues »
I've been taking my experiences gathered from fiddling with akka streams to a practical level and I'm in trouble. Below is my attempt at writing a str...
(0) odpowiedzi
2017-09-26 22:09 akka-stream + akka-http lifecycle »
TLDR: is it better to materialize a stream per request (i.e. use short-lived streams) or to use a single stream materialization across requests, when ...
(1) odpowiedzi
2017-09-26 21:09 How to calculate total across columns but one? »
I want to create a "Total" row in a dataframe. This will add all rows EXCEPT the uid cell. uid val1 val2 val3 3213 1 2 3 To create this: ...
(1) odpowiedzi
2017-09-26 18:09 Pattern matching on a Try lazy val in Scala? »
Is it possible to pattern match on a lazy val, declared as a Try, like this? lazy val kafkaProducer: Try[producer.KafkaProducer[Array[Byte], Stri...
(1) odpowiedzi
2017-09-25 23:09 Missing parameter type for expanded function with underscore »
I'm trying to make function that compose itself - def genericComposition[T](f: T => T, g: T => T) = { def call(x: T) = g(f(x)) call _ }...
(2) odpowiedzi
2017-09-25 21:09 AWS Lambda - Java Beans »
I have a request that looks like the following: package pricing import scala.beans.BeanProperty class Request(@BeanProperty var name: String, @Bean...
(1) odpowiedzi
2017-09-25 17:09 How to convert a class T object into a Future[T] object in akka »
I am trying to do something with akka and scala and i am new to it. I want to append the result of an 'Any' Future into one of the fields in the class...
(2) odpowiedzi
2017-09-25 06:09 Why is match a keyword and not a function in Scala? »
I don't see why Scala has match defined as a keyword instead of a function. It could be defined through implicits (like ArrowAssoc). For example, cons...
(1) odpowiedzi
2017-09-24 22:09 Why is Scala Guice 4.1.0 is selected even though no one depends on it »
I added the plugin addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") and ran the sbt dependencyTree command I see this output ...
(0) odpowiedzi
2017-09-24 20:09 Scala- How to get a Vector's contained class? »
Does Scala have a way to get the contained class(es) of a collection? i.e. if I have: val foo = Vector[Int]() Is there a way to get back classOf[In...
(3) odpowiedzi
2017-09-24 19:09 Returning Future[Int] from Future[Option[Int]] with support of Failing the future »
I have the below block of code. My intent is to do some processing with the method params and return Future[Int] or fail the Future. I want to fail th...
(1) odpowiedzi
2017-09-24 15:09 Dataset.unpersist() unexpectedly affects count of other RDD's »
I ran into a strange problem where calling unpersist() on one Dataset affects the count of another Dataset in the same block of code. Unfortunately t...
(1) odpowiedzi
2017-09-23 22:09 Why doesn't a prism set function return an Option/Maybe »
In functional optics, a well-behaved prism (called a partial lens in scala, I believe) is supposed to have a set function of type 'subpart -> 'pare...
(2) odpowiedzi
2017-09-23 17:09 Intellij: SBT-based Scala project does not build with Java 9 »
I've tried to switch my Scala/sbt based project to Java 9. If I compile the project with sbt, it works. If I try to build the project with the Build ...
(3) odpowiedzi
2017-09-23 12:09 Is it possible to express kotlin 'with' method equivalent in Scala? »
Kotlin Standard lib contains the 'with' method that receives an object and a method of that object defined as: public inline fun <T, R> with(re...
(1) odpowiedzi
2017-09-23 11:09 take ordered n elements after groupByKey with spark »
Let's say we have an rdd like this: (uid, (factor, time)) And after a groupByKey we shall have this (uid, Iterable[(factor, time)]) Which the se...
(0) odpowiedzi