Skip to content

Instantly share code, notes, and snippets.

@dos65
Created November 27, 2018 08:23
Show Gist options
  • Save dos65/9c2f65451daa460e41dadfcda07604a7 to your computer and use it in GitHub Desktop.
Save dos65/9c2f65451daa460e41dadfcda07604a7 to your computer and use it in GitHub Desktop.
object Example extends MistFn {
// an arguments that extracts Map[String, String]
val mapArg = allArgs.andThen(params => {
val r = params.map({
case (k, v: String) => Right((k,v))
case (k, any) => Left(Failed.InvalidValue(s"$k key contains invalid value: $any"))
}).toSeq
if (r.exists(_.isLeft)) {
val all = r.collect({case Left(f) => f})
Failed.ComplexFailure(all)
} else {
val value = r.collect({case Right(v) => v}).toMap
Extracted(value)
}
})
override def handle = {
withArgs(mapArg).onSparkContext((map: Map[String, String], sc: SparkContext) => {
...
}).asHandle
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment