Write output to multiple files in Hadoop

Possible duplicate:
MultipleOutputFormat in hadoop

I want to write files according to months using map-reduce in hadoop. If the data refers to the month of January, then the data must be recorded in a jan file, and there must be a separate file for each month.

How can I create such a file in mapoutude hasoop. I am trying to recursively shrink a map but not getting how to implement it?

Pls will offer me some solution.

Thanks.

+4
source share
1 answer

Use the MultipleOutputFormat class, the name of the output file can be inferred from the key and the output value of the gearbox from the gearbox. MultipleOutputFormat # generateFileNameForKeyValue must be implemented in the user-defined class OutputFormat.

static class MyMultipleOutputFormat extends MultipleOutputFormat<Text, Text> { protected String generateFileNameForKeyValue(Text key, Text value, String name) { String keyString = key.toString(); String valueString = value.toString(); #return a combination of keyString and valueString } } 
+5
source

Source: https://habr.com/ru/post/1388084/


All Articles