spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sean Owen <so...@cloudera.com>
Subject Re: Converting Apache log string into map using delimiter
Date Wed, 12 Nov 2014 04:05:07 GMT
I think it would be faster/more compact as:

z.map(_.map { element =>
    val tokens = element.split("=")
    (tokens(0), tokens(1))
  }.toMap)

(That's probably 95% right but I didn't compile or test it.)

On Wed, Nov 12, 2014 at 12:18 AM, YaoPau <jonrgregg@gmail.com> wrote:

> OK I got it working with:
>
> z.map(row => (row.map(element => element.split("=")(0)) zip row.map(element
> => element.split("=")(1))).toMap)
>
> But I'm guessing there is a more efficient way than to create two separate
> lists and then zip them together and then convert the result into a map.
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/Converting-Apache-log-string-into-map-using-delimiter-tp18641p18643.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> For additional commands, e-mail: user-help@spark.apache.org
>
>

Mime
View raw message