You can do this using flatMap which return a Seq of (key, value) pairs.

Sincerely,

DB Tsai
-------------------------------------------------------
My Blog: https://www.dbtsai.com
LinkedIn: https://www.linkedin.com/in/dbtsai

On Mon, Oct 20, 2014 at 9:31 AM, HARIPRIYA AYYALASOMAYAJULA <
aharipriy...@gmail.com> wrote:

> Hello,
>
> I am facing a problem with implementing this - My mapper should emit
> multiple keys for the same value -> for every input (k, v) it should emit
> (k, v), (k+1, v),(k+2,v).... (k+n,v).
> In MapReduce, it was pretty straight forward - I used a for loop and
> performed Context write within that.
>
> This is the code I am using in the map function of MR job:
>
> for (int k = 0; k <  8; k++)
>
>  {
>
>      key = date + ": " + k;
>
>  context.write(new Text(key), new DoubleWritable(value));
>
>    }
>
>   I tried using the map function, but i'm stuck in understanding how I can
> use the loop within it.
>
> It would be great if someone can suggest me what could be possible ways to
> do it.
>
> Thanks in advance.
>
> --
> Regards,
> Haripriya Ayyalasomayajula
>
>

Reply via email to