Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daggerrz/druid-scala-client
A Scala client for Druid
https://github.com/daggerrz/druid-scala-client
Last synced: 3 months ago
JSON representation
A Scala client for Druid
- Host: GitHub
- URL: https://github.com/daggerrz/druid-scala-client
- Owner: daggerrz
- Created: 2013-09-07T06:00:24.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-12T15:44:20.000Z (almost 8 years ago)
- Last Synced: 2024-02-14T21:34:56.127Z (9 months ago)
- Language: Scala
- Size: 16.6 KB
- Stars: 16
- Watchers: 5
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Getting started (requires the Wikipedia example to be running):
See also https://github.com/daggerrz/druid-scala-client/blob/master/src/test/scala/com/tapad/druid/client/WikipediaExample.scala
```scala
import scala.concurrent.ExecutionContext
import org.joda.time.{DateTime, Interval}
import scala.util.{Failure, Success}implicit val executionContext = ExecutionContext.Implicits.global
val client = DruidClient("http://localhost:8083")import com.tapad.druid.client.DSL._
val query = GroupByQuery(
source = "wikipedia",
interval = new Interval(new DateTime().minusDays(1), new DateTime()),
dimensions = Seq("page"),
granularity = Granularity.All,
aggregate = Seq(
sum("count") as "edits",
sum("added") as "chars_added"
),
postAggregate = Seq(
"chars_added" / "edits" as "chars_per_edit"
),
filter = "namespace" === "article" and "country" === "United States",
orderBy = Seq(
"chars_added" desc
),
limit = Some(100)
)client(query).onComplete {
case Success(resp) =>
resp.data.foreach { row =>
println("Page %s, %s edits, %s chars added, %s per edit".format(
row("page"), row("edits"), row("chars_added"), row("chars_per_edit")
))
}
case Failure(ex) =>
ex.printStackTrace()
}
```