How to generate UUID in Mapreduce?

Viewed 615

I want to write a MapReduce java Program where I need to create UUID for a set of data in csv/txt file. The data will be a customer data with set of rows and column. The input csv is located in the HDFS directory.

Just need to generate UUID using Mapreduce. I have an input file which has colums a, b and c and has 5 rows. I need a column d with UUID with 5 rows i.e. 5 different UUIDs

How can i go about it?

Here is the code for Mapper class:

public class MapRed_Mapper extends Mapper{

public void map(Text key, Text value, Context context) throws IOException, InterruptedException
{
     Text uuid = new Text(UUID.randomUUID().toString());
    context.write(key, uuid);
}

}

2 Answers
Related