Created
November 27, 2018 08:23
-
-
Save dos65/9c2f65451daa460e41dadfcda07604a7 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
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