Last active
June 6, 2016 10:14
-
-
Save l15k4/dc9bfb67215322f675271dc77e8d7425 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Storage | |
case class ViewId(id: String, access: String = "rw", base: Boolean = false) | |
case class S3Storage(bucket: String, path: String) extends Storage | |
case class DruidStorage(coordinatorHost: String, overlordHost: String, dataSource: String) extends Storage | |
sealed trait Partitioning | |
case class TimePartitioning(granularity: String) extends Partitioning | |
case class Partition(p: String) | |
sealed trait View[+S <: Storage, +P <: Partitioning] { | |
def viewId: ViewId | |
def storage: S | |
def partitioning: P | |
} | |
case class S3TimeView(viewId: ViewId, storage: S3Storage, partitioning: TimePartitioning) extends View[S3Storage, TimePartitioning] | |
case class DruidTimeView(viewId: ViewId, storage: DruidStorage, partitioning: TimePartitioning) extends View[DruidStorage, TimePartitioning] | |
case class InputMessage[S<:Storage,P<:Partitioning](fromView: View[S,P], toView: View[S,P], partition: Partition) | |
ObjMapper.readValue[InputMessage[S3Storage, TimePartitioning]](json, new TypeReference[InputMessage[S3Storage, TimePartitioning]]() {}) | |
_____________________________________________________________ | |
[info] com.fasterxml.jackson.databind.JsonMappingException: Can not construct instance of gwi.gwiq.pm.View, problem: abstract types either need to be mapped to concrete types, have custom deserializer, or be instantiated with additional type information | |
[info] at [Source: {"fromView":{"viewId":{"id":"firstLevelHourlyView","access":"ro","base":true},"storage":{"bucket":"gwiq-views-t","path":"partition-manager/firstLevelHourlyView"},"partitioning":{"granularity":"HOUR"}},"toView":{"viewId":{"id":"firstLevelHourlyView","access":"ro","base":true},"storage":{"bucket":"gwiq-views-t","path":"partition-manager/firstLevelHourlyView"},"partitioning":{"granularity":"HOUR"}},"partition":{"p":""}}; line: 1, column: 13] (through reference chain: gwi.gwiq.pm.InputMessage["fromView"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Possible solution but that is very inconvenient because one has to create concrete View types like
S3TimeView
: