Using Scalding, Type Safe API, this code works, where dictForKeys
and dictForValues
are both ValuePipe[Map[String,String]]
:
SomeKeyValueTypedPipe
.mapWithValue(dictForKeys) { case ((key, value), dictForKeys) =>
(dictForKeys.get.getOrElse(key, key), value) }
.mapWithValue(dictForValues) { case ((key, value), dictForValues) =>
(key, dictForValues.get.getOrElse(value, value)) }
I was just wondering whether there's a more compact way of writing this, i.e. use only 1 mapWithValue step with 2 separate ValuePipes.
You could create a ValuePipe of a tuple of Maps, like ValuePipe[(Map[String, String], Map[String, String])]
, and then use it like so:
SomeKeyValueTypedPipe
.mapWithValue(dict) { case ((key, value), (dictForKeys, dictForValues)) =>
(dictForKeys.get.getOrElse(key, key), dictForValues.get.getOrElse(value, value)) }