पर टेक्स्ट फ़ाइल को पढ़ने के लिए मुझे टेक्स्ट फ़ाइल से डेटा को कम करने की आवश्यकता है, मैं कई दिनों से गोगलिंग कर रहा हूं लेकिन मुझे अपने काम के लिए कोई सही समाधान नहीं मिला। क्या कोई विधि या कक्षा है जो किसी सिस्टम से टेक्स्ट/सीएसवी फ़ाइल पढ़ती है और डेटा को एचबीएएसई तालिका में संग्रहीत करती है। यह वास्तव में मेरे लिए बहुत जरूरी है कृपया कोई भी MapReduce F/w को जानने में मेरी सहायता कर सकता है।सिस्टम से Hbase MapReduce
5
A
उत्तर
2
टेक्स्ट फ़ाइल से पढ़ने के लिए सभी टेक्स्ट फ़ाइल में से पहले hdfs में होना चाहिए। आप नौकरी के लिए इनपुट प्रारूप और outputformat निर्दिष्ट करने की आवश्यकता
Job job = new Job(conf, "example");
FileInputFormat.addInputPath(job, new Path("PATH to text file"));
job.setInputFormatClass(TextInputFormat.class);
job.setMapperClass(YourMapper.class);
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
TableMapReduceUtil.initTableReducerJob("hbase_table_name", YourReducer.class, job);
job.waitForCompletion(true);
YourReducer
चाहिए फैली org.apache.hadoop.hbase.mapreduce.TableReducer<Text, Text, Text>
नमूना कम करने कोड
public class YourReducer extends TableReducer<Text, Text, Text> {
private byte[] rawUpdateColumnFamily = Bytes.toBytes("colName");
/**
* Called once at the beginning of the task.
*/
@Override
protected void setup(Context context) throws IOException, InterruptedException {
// something that need to be done at start of reducer
}
@Override
public void reduce(Text keyin, Iterable<Text> values, Context context) throws IOException, InterruptedException {
// aggregate counts
int valuesCount = 0;
for (Text val : values) {
valuesCount += 1;
// put date in table
Put put = new Put(keyin.toString().getBytes());
long explicitTimeInMs = new Date().getTime();
put.add(rawUpdateColumnFamily, Bytes.toBytes("colName"), explicitTimeInMs,val.toString().getBytes());
context.write(keyin, put);
}
}
}
नमूना नक्शाकार वर्ग
public static class YourMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
String line = value.toString();
StringTokenizer tokenizer = new StringTokenizer(line);
while (tokenizer.hasMoreTokens()) {
word.set(tokenizer.nextToken());
context.write(word, one);
}
}
}
संबंधित मुद्दे
- 1. HDFS से HBase (cdh3u2)
- 2. hbase
- 3. hbase.MasterNotRunningException Hbase
- 4. Hbase क्लाइंट कनेक्शन कनेक्शन/hbase त्रुटि
- 5. Hadoop mapreduce है त्रुटि
- 6. MapReduce
- 7. MapReduce
- 8. MapReduce
- 9. hbase shell
- 10. hbase row
- 11. वहाँ HBase
- 12. MapReduce रैखिक प्रोग्रामिंग
- 13. लोचदार MapReduce
- 14. hbase कनेक्शन से इनकार कर दिया
- 15. MapReduce विकल्प
- 16. MapReduce/Hadoop
- 17. Hbase put shell कमांड
- 18. hbase स्कैन परिणाम
- 19. Hbase/Hadoop Query सहायता
- 20. MongoDB: mapReduce दुष्प्रभाव
- 21. Hadoop MapReduce काम इनपुट
- 22. अमेज़ॅन लोचदार MapReduce - SIGTERM
- 23. MongoDB MapReduce PHP
- 24. "Combiner" एक mapreduce काम
- 25. MongoDB: भयानक MapReduce प्रदर्शन
- 26. MapReduce मेरे लिए सही है?
- 27. hbase मौजूदा तालिका नहीं मिला
- 28. हडोप में त्रुटि MapReduce
- 29. फास्ट फूरियर MapReduce
- 30. HBase कैसे स्कैन करने के लिए पंक्तियाँ कुशलतापूर्वक