Skip to content

Instantly share code, notes, and snippets.

@l15k4
Created February 24, 2016 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l15k4/aa17cb6266efd37fa579 to your computer and use it in GitHub Desktop.
Save l15k4/aa17cb6266efd37fa579 to your computer and use it in GitHub Desktop.
trait ResponseReader[Q <: Query, R <: Response, C[X] <: TraversableOnce[X]] {
def read(response: String): C[R]
}
object ResponseReader {
implicit object SelectResponseReader extends ResponseReader[SelectQuery, SelectResponse, Option] {
def read(json: String): Option[SelectResponse] = ObjMapper.readValue[List[SelectResponse]](json).headOption
}
implicit object TimeSeriesResponseReader extends ResponseReader[TimeSeriesQuery, TimeSeriesResponse, Option] {
def read(json: String): Option[TimeSeriesResponse] = ObjMapper.readValue[List[TimeSeriesResponse]](json).headOption
}
implicit object GroupByResponseReader extends ResponseReader[GroupByQuery, GroupByResponse, IndexedSeq] {
def read(json: String): IndexedSeq[GroupByResponse] = ObjMapper.readValue[Vector[GroupByResponse]](json)
}
}
________________________________________________________________________________________________________________
type arguments [gwi.druid.client.SelectQuery,gwi.druid.client.SelectResponse,Option] do not conform to trait ResponseReader's type parameter bounds [Q <: gwi.druid.client.Query,R <: gwi.druid.client.Response,C[X] <: TraversableOnce[X]]
[error] implicit object SelectResponseReader extends ResponseReader[SelectQuery, SelectResponse, Option] {
[error] ^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment