Skip to content

Instantly share code, notes, and snippets.

@natewave
Created September 17, 2015 08:52
Show Gist options
  • Save natewave/0cc1b73e814396d38ae1 to your computer and use it in GitHub Desktop.
Save natewave/0cc1b73e814396d38ae1 to your computer and use it in GitHub Desktop.
val sRule = implicitly[RuleLike[AvroValue, String]]
val drRule = implicitly[RuleLike[AvroValue, DefectResult]]
def kTransform(g: GenericRecord) = RecordTransformations.convert(g, sRule)
def vTransform(g: GenericRecord) = RecordTransformations.convert(g, drRule)
val defectResults: DStream[(String, DefectResult)] = KafkaCommons.read[String, DefectResult](consumerConfig, ssc)(kTransform, vTransform)
@natewave
Copy link
Author

object RecordTransformations {
  def convert[T](genericRecord: GenericRecord, rule: RuleLike[AvroValue, T]): VA[T] = {
    Avro.fromAvro[T](Avro.wrap(genericRecord))(rule)
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment