2013-10-11 5 views
6

मैं विभिन्न फ़ोल्डर के कम करने से मेरी उत्पादन अलग करने के लिए कोशिश कर रहा हूँ ..हडूप में एकाधिक फ़ोल्डरों को लिखना?

My dirver has the following code: 
FileOutputFormat.setOutputPath(job, new Path(output)); 
      //MultipleOutputs.addNamedOutput(job, namedOutput, outputFormatClass, keyClass, valueClass) 
      //MultipleOutputs.addNamedOutput(job, namedOutput, outputFormatClass, keyClass, valueClass) 
      MultipleOutputs.addNamedOutput(job, "foo", TextOutputFormat.class, NullWritable.class, Text.class); 
      MultipleOutputs.addNamedOutput(job, "bar", TextOutputFormat.class, Text.class,NullWritable.class); 
      MultipleOutputs.addNamedOutput(job, "foobar", TextOutputFormat.class, Text.class, NullWritable.class); 

And then my reducer has the following code: 
mos.write("foo",NullWritable.get(),new Text(jsn.toString())); 
mos.write("bar", key,NullWritable.get()); 
mos.write("foobar", key,NullWritable.get()); 

But in the output, I see: 

output/foo-r-0001 
output/foo-r-0002 
output/foobar-r-0001 
output/bar-r-0001 


But what I am trying is : 

output/foo/part-r-0001 
output/foo/part-r-0002 
output/bar/part-r-0001 

उत्पादन/foobar/भाग-R-0001

मैं यह करने के लिए कैसे करते हैं? धन्यवाद

+1

हाडोप का कौन सा संस्करण यह है? –

उत्तर

4

आप इस MultipleOutputs मतलब है, तो सबसे आसान तरीका निम्नलिखित आप से कम करने से कोई एक कार्य के लिए होगा -

  1. एक आधार उत्पादन पथ के साथ नामित किया गया उत्पादन का उपयोग करना। See this function
  2. नामित उत्पादन और केवल एक आधार उत्पादन पथ का उपयोग कर के बिना
  3. , See this function

आपके मामले में, यह बात 1 है, तो कृपया नीचे दिए गए बदल -,

mos.write("foo",NullWritable.get(),new Text(jsn.toString())); 
mos.write("bar", key,NullWritable.get()); 
mos.write("foobar", key,NullWritable.get()); 

को

mos.write("foo",NullWritable.get(),new Text(jsn.toString()), "foo/part"); 
mos.write("bar", key,NullWritable.get(), "bar/part"); 
mos.write("foobar", key,NullWritable.get(), "foobar/part"); 

कहाँ, "foo/भाग", "बार/भाग" और "foobar/part" baseOutputPath से मेल खाता है। इसलिए, निर्देशिका foo, bar और foobar बनाया जाएगा और part-r-xxxxx फ़ाइलों के अंदर।

आप उपरोक्त बिंदु 2 को भी आजमा सकते हैं, जिसे वास्तव में किसी नामित आउटपुट की आवश्यकता नहीं है।

यदि आवश्यक हो, तो कृपया आगे स्पष्टीकरण के लिए मेरे पास वापस आएं।

संबंधित मुद्दे