Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Need help with calling and returning value from anon function in scala

12 views
Skip to first unread message

tushar pandit

unread,
May 7, 2019, 4:59:45 PM5/7/19
to ScalaPB
Hi,

I am trying to call function fetchFromDruid

def main(args: Array[String]): Unit = {
val res = fetchFromDruid()
  // res comes as null here
}

def fetchFromDruid(): GroupByResponse {
implicit val executionContext = ExecutionContext.Implicits.global
val client = DruidClient("http://localhost:8082")

val query = GroupByQuery(
source = "wikipedia",
interval = new Interval(new DateTime().minusMonths(60), new DateTime()),
dimensions = Seq("countryName"),
descending = true,
granularity = Granularity.All,
aggregate = Seq(
DSL.count("row_count")
),
postAggregate = Seq(
),
limit = Some(100)
)

client(query).onComplete {
case Success(resp) =>
resp.data.foreach { row =>
println(row)
}
      return resp
println("none")
//System.exit(0)
case Failure(ex) =>
ex.printStackTrace()
      return null
//System.exit(0)
}
}

But somehow I am not able to return the response to the caller; i.e the main function. What could be the issue?

Thanks,
Tushar

Nadav Samet

unread,
May 7, 2019, 5:05:42 PM5/7/19
to tushar pandit, ScalaPB
Hi Tushar! You might want to try Stackoverflow or other Scala help forums. This question does not seem relevant to ScalaPB.

--
You received this message because you are subscribed to the Google Groups "ScalaPB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalapb+u...@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalapb/c1c0afd7-27c1-4d90-8795-d50d98947c60%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-Nadav
Reply all
Reply to author
Forward
0 new messages