Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 16:54
    som-snytt closed #9674
  • 16:46
    som-snytt synchronize #9674
  • 05:03
    scala-jenkins milestoned #9674
  • 05:03
    som-snytt opened #9674
  • 05:02
    retronym labeled #9673
  • 05:01
    retronym review_requested #9673
  • 05:01
    scala-jenkins milestoned #9673
  • 05:01
    retronym opened #9673
  • Jun 18 07:24
    dwijnand edited #9672
  • Jun 18 02:50
    som-snytt edited #9672
  • Jun 18 02:48
    som-snytt converted_to_draft #9672
  • Jun 18 02:42
    som-snytt edited #9672
  • Jun 18 02:11
    scala-jenkins milestoned #9672
  • Jun 18 02:11
    som-snytt opened #9672
  • Jun 18 01:10
    SethTisue commented #9488
  • Jun 17 08:02

    lrytz on 2.12.x

    Backport strip parens on future… Merge pull request #9670 from s… (compare)

  • Jun 17 08:02
    lrytz closed #9670
  • Jun 17 08:01
    lrytz commented #9670
  • Jun 17 06:55
    som-snytt synchronize #9670
  • Jun 17 06:30
    som-snytt commented #9670
AmirSarvestani
@AmirSarvestani
I want to create an xml node like this.
<Income s"${income.`type`}Amount=${income.amount} ${income.`type`}Frequency=${income.frequency}"}"/>
so income type is an Enum and each income type has an income frequency
how would i be able to change the sequence of Income to one Income node in xml?
ehsanshah
@ehsanshah
Hi every one I need to use RPC protocol but I don't know which library has good performance ! in Scala. can guide me ?
thanks.
Abdhesh Kumar
@abdheshkumar
@ehsanshah Use finagle https://twitter.github.io/finagle/
Emperor-less
@Emperor-less
hello
who are you
anbutech17
@anbutech17
hello
Ramesh Thamizhselvan
@ramesh004

can anyone help me to get rid of the task not serializable exception
even i had implemented the Serializable trait

var structFieldArr = SchemaFileRDD.map(m=> StructField(m.split(Pattern.quote("|"))(1),types(m.split(Pattern.quote("|"))(2)))).collect()

Karan Barai
@BaraiKaran
Hi, I am trying to unit test some functions which use slick to interact with database. Can anyone explain me right way to do this? Also, if you can share some mocking examples it would be great. I have looked up for the examples but didn't find any good solution. Thanks!
Pradeep Sonaimuthu
@pradeepert
I come across with one use case. I want to write one function I will pass two types to that function. It should return it can be convert able from first type to second type or not. Any suggestions?
Eg: if I pass int and string to the function as an input parameters, it should return true.
Karan Barai
@BaraiKaran
Can you elaborate a little bit, not quite sure what you are trying to achieve. @pradeepert
Pradeep Sonaimuthu
@pradeepert
I want to pack avro library dependencies along with my project jar. What I have to do for this. What changes I have to do in SBT level?
agamjain14
@agamjain14

I have sort function defined as below:

case class Country(name: String, id: Int)
def sortT(compare: (T, T) => Boolean): List[T] = {

}
My question is, How do I sort the list of Country based on the name?

and How do I call this function having multiple parameter lists?

case class Country(name: String, id: Int)
def sort(list: List[T])(compare: (T, T) => Boolean): List[T] = {

}

Deshbandhu Mishra
@deshbandhumishra
I am solving/explaining famous 99-scala-Algo over voice chat on Skype with 4-5 scala freshers. You may also join this voice group chat.
Pradeep Sonaimuthu
@pradeepert
I m getting this character issue when reading spark dataframe from csv,
'\uFEFF'. I want to check as a business logic df.columns.contains("Id") eventhough Id column is there because of this special character type it fails
Pradeep Sonaimuthu
@pradeepert

In Spark I am not able to filter by existing column:
Exception in thread "main" org.apache.spark.sql.AnalysisException: cannot resolve 'Inv. Pty' given input columns: [ο»ΏPstng Date, Name 1, Inv. Pty, Year]

Through Inv. Pty I am trying to filter. This column already in the dataframe input file you can see inside []

Pradeep Sonaimuthu
@pradeepert

Here I have used dense_rank() as the analytical function, I want to pass this function as a argument incase if I want to pass any other function tomorrow,

val indexLatName = df.withColumn("LatestNameOrder", dense_rank() .over(Window.partitionBy("`" + partBy + "`") .orderBy(desc("`" + ordBy + "`"))))

How to pass the argument, if the variable has the value
val winFunc = "dense_rank"
Harsh Maheshwari
@harshmah

HiπŸ‘‹ Everyone, I am new to Scala. I am struggling with a existing piece of scala code so need your help.

We (i.e. in my org) are using Gatling for perf testing. So we are using following piece of code:

ScenarioBuilder = scenario(scn).during(config.duration) { exec(session => { val daysFromNow = nextInt(180) + 1 //avoid daysFromNow = 0 because current date is invalid for some locale half a world away val siteAndLang = chooseFrom(siteLangs) session.set("siteId", siteAndLang.substring(0, siteAndLang.indexOf("/"))) .set("locale", siteAndLang.substring(siteAndLang.indexOf("/")+1)) .set("hotelId", hotelIds) .set("startDate", computeDateString(daysFromNow)) .set("endDate", computeDateString(daysFromNow + lengthOfStay(nextInt(lengthOfStay.length)))) .set("regionId", regionIds) .set("adults", chooseFrom(adultCounts)) }).exec(addCookie(Cookie("DUAID", DUAID))) .exec(http(scn) .get(s"$endpoint/$path") .header("Trace-ID", session => getTraceID()) .signatureCalculator(new CommonSignatureCalculator(DUAID)) .check(status is 200) .check(validator) ) }

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”-

This is what we are passing as validator:

private def validator = (jsonPath("$.hotelId").exists)

So API which this script is hitting start sending compressed data and then it get following error:

19:44:50 14:14:50.084 [gatling-http-thread-1-3] ERROR io.gatling.http.response.StringResponseBody$ - Response body is not valid UTF-8 bytes

My question - how to unzip GZip response before pass to validator.

Harsh Maheshwari
@harshmah
Here is correct code snippet which is more clean:
import java.time.LocalDate
import java.time.format.DateTimeFormatter._
import java.util.UUID

import config.RunConfiguration
import io.gatling.core.Predef._
import io.gatling.core.structure.ScenarioBuilder
import io.gatling.http.Predef._
import io.gatling.http.check.HttpCheck
import signature.CommonSignatureCalculator

import scala.io.Source
import scala.util.Random._

def buildScenario(
    endpoint: String,
    path: String,
    scn: String,
    validator: HttpCheck
): ScenarioBuilder =
  scenario(scn).during(config.duration) {
    exec(session => {
      val daysFromNow = nextInt(180) + 1 //avoid daysFromNow = 0 because current date is invalid for some locale half a world away
      val siteAndLang = chooseFrom(siteLangs)
      session
        .set("siteId", siteAndLang.substring(0, siteAndLang.indexOf("/")))
        .set("locale", siteAndLang.substring(siteAndLang.indexOf("/") + 1))
        .set("htlId", hotelIds)
        .set("startDate", computeDateString(daysFromNow))
        .set(
          "endDate",
          computeDateString(
            daysFromNow + lengthOfStay(nextInt(lengthOfStay.length))
          )
        )
        .set("regionId", regionIds)
        .set("adults", chooseFrom(adultCounts))
    }).exec(addCookie(Cookie("DUAID", DUAID)))
      .exec(
        http(scn)
          .get(s"$endpoint/$path")
          .header("Trace-ID", session => getTraceID())
          .signatureCalculator(new CommonSignatureCalculator(DUAID))
          .check(status is 200)
          .check(validator)
      )
  }

private def validator = (jsonPath("$.hotelId").exists)

buildScenario(
  "a_get_end_point",
  "some scenario",
  validator
)
sachin407
@sachin407
hello developers here i am coming to join the room
Deshbandhu Mishra
@deshbandhumishra
hi @sachin407 welcome to this scala room
Archit Kapoor
@archit47
Hey guys!
It's almost the end of 2019. Just wanted to catch-up with y'all, who are still using Scala here in India?
How are things been at your end? Have you tried building a community of Scala developers outside of this channel?
Deshbandhu Mishra
@deshbandhumishra
Hi All
can we have a regular group discussion over voice call by using skype/gotomeeting etc.. Please suggest.
I have created one group to discuss scala over skype call. you may also join: https://join.skype.com/dLdTEMogQwrq
Sherwin Mascarenhas
@sherwinfarrell
Hey Everyone, Just joined this group. Great to see a room full of scala developers from India.
Sherwin Mascarenhas
@sherwinfarrell
Is anyone here stepping into category theory?
And would like to maybe have a few group discussions?
mghildiy
@mghildiy

And would like to maybe have a few group discussions?

would like to get initiated

Sanjeev Ranjan
@coolsanjeev1606_twitter
@sherwinfarrell i would be interested too
Sherwin Mascarenhas
@sherwinfarrell
Yeah it would be great to have some active collaboration
steven-taiyang-yang
@steven-taiyang-yang
Hello everybody, I'm from China. I'm eating Curry food as my lunch these days. It's so fascinating.
Srinath
@srinathji
Do we have any schema.json validation for scala version-2.11 , i have tried it using https://github.com/circe/circe-json-schema but this is supporting scala 2.12 and above?
rajforum
@rajforum

Hi, @all,

import scala.reflect.runtime.universe
import scala.reflect.runtime.universe._

def getType[T: TypeTag](obj: T) = typeOf[T]

case class Thing(
  val id: Int,
  var name: String
)
val thing = Thing(1, "Apple")

val dataType = getType(thing).decl(TermName("id")).asTerm.typeSignature

dataType match {
 case t if t =:= typeOf[Int] => println("I am Int")
 case t if t =:= typeOf[String] => println("String, Do some stuff")
 case _ => println("Absurd")
}

Not able to digest why result is Absurd instead of I am Int?

My aim is to know data-type of class parameter at runtime and match it to predefined types.
Please help me what I am missing

ehsanshah
@ehsanshah

hi every one
this is my code

def selectFromArgs(args: UUID*): Future[List[CompanyEntity]] = {
    selectInExample.flatMap(_.bind(ListValue(args: _*)).fetch())
  }

I v got this error :
Warning:(32, 35) Auto-application to () is deprecated. Supply the empty argument list () explicitly to invoke method list,
or remove the empty argument list from its definition (Java-defined methods are exempt).
In Scala 3, an unapplied method like this will be eta-expanded into a function.
selectInExample.flatMap(_.bind(ListValue(values)).fetch())
how can fix it

Ayush
@ayushworks

@ehsanshah : In Scala 2.12 and below the following syntax was valid without any warnings

def test(): A = ???

 test // is automatically expanded to test()

However from Scala 2.13 this gives a warning

Auto-application to `()` is deprecated. Supply the empty argument list `()` explicitly to invoke method test

And in Scala 3 that syntax would be illegal.

In your case the phantom-dsl library has a class with methods with empty parameter list - https://github.com/outworkers/phantom/blob/v2.59.0/phantom-dsl/src/main/scala/com/outworkers/phantom/builder/primitives/Primitives.scala#L166 (one of them) .. once they fix the outworkers/phantom#923 you already reported the warnings should be gone.

skum123
@skum123
Hi everyone,
def sum(a: Int, b: Int)(f: Int => Int): Int = {
if (a>=b) f(b) else f(a) + sum(a+1, b)(f)
}
sumi(2,3)// is this call correct or how do I have to call sum with function?
Ayush
@ayushworks
@skum123 : you need to call sum using two parameter list. The first parameter list contains two int's as you already have.. the second parameter list contains a single parameter which is a function that takes an int and returns an int
def sum(a: Int, b: Int)(f: Int => Int): Int = {
    if (a>=b) f(b) 
    else f(a) + sum(a+1, b)(f)
  }

  def f(x: Int): Int = x + 1

  sum(2,3)(f) 
  sum(2,3)(x => x +1) // or inline the function definition
Jai Pradeesh
@jai-deepsource

Hello Scala India :wave:, DeepSource is looking for a Scala developer. The role is remote within India. Here's more info about the role - https://deepsource.io/jobs/software-engineer-language-scala-in/

I'm at jai@deepsource.io for any questions.

manjoosh12
@manjoosh12
hi everyone i have one json {
"kind": "sql#tiersList",
"items": [
{
"tier": "db-f1-micro",
"RAM": "644245094",
"kind": "sql#tier",
"DiskQuota": "3279207530496",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"europe-north1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"northamerica-northeast1",
"southamerica-east1",
"us-central1",
"us-east1",
"us-east4",
"us-west1",
"us-west2",
"us-west3",
"us-west4"
]
},
{
"tier": "db-g1-small",
"RAM": "1825361100",
"kind": "sql#tier",
"DiskQuota": "3279207530496",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"europe-north1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"northamerica-northeast1",
"southamerica-east1",
"us-central1",
"us-east1",
"us-east4",
"us-west1",
"us-west2",
"us-west3",
"us-west4"
]
},
{
"tier": "db-n1-standard-1",
"RAM": "4026531840",
"kind": "sql#tier",
"DiskQuota": "32985348833280",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"europe-north1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"northamerica-northeast1",
"southamerica-east1",
"us-central1",
"us-east1",
"us-east4",
"us-west1",
"us-west2",
"us-west3",
"us-west4"
]
},
{
"tier": "db-n1-standard-2",
"RAM": "8053063680",
"kind": "sql#tier",
"DiskQuota": "32985348833280",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"europe-north1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"northamerica-northeast1",
"southamerica-east1",
"us-central1",
"us-east1",
"us-east4",
"us-west1",
"us-west2",
"us-west3",
"us-west4"
]
},
{
"tier": "db-n1-standard-4",
"RAM": "16106127360",
"kind": "sql#tier",
"DiskQuota": "32985348833280",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-south1",
"asia-southeast1",
"asia-southeast2",
"australia-southeast1",
"europe-north1",
"europe-west1",
"europe-west2",
"europe-west3",
"europe-west4",
"europe-west6",
"northamerica-northeast1",
"southamerica-east1",
"us-central1",
"us-east1",
"us-east4",
"us-west1",
"us-west2",
"us-west3",
"us-west4"
]
},
{
"tier": "db-n1-standard-8",
"RAM": "32212254720",
"kind": "sql#tier",
"DiskQuota": "32985348833280",
"region": [
"asia-east1",
"asia-east2",
"asia-northeast1",
"asia-northeast2",
"asia-northeast3",
"asia-sout
i would like to filter this json on the basis of regions
and output should be like {
"items": [
{
"region": "asia-east1",
"tier": [
"db-n1-standard-2,etc"
]``
},
{
"region": "asia-east2",
"tier": [
"db-n1-standard-2",
"db-g1-small,etc"
]
},
{
"region": "asia-northeast1",
"tier": [
"db-n1-standard-2",
"db-g1-small,etc"
]
}
    ]
}
looking for scala code for this
can someone help me on this
@sharmitaa_twitter
@shivampanjeta