を.hdfs.inverted
は、誰もがコードの修正例外は、コマンド</p> <pre><code>hadoop jar /home/edureka/Desktop/invertedindex.jar hdfs:/hdfs/inverted hdfs:/hdfs/invertedout </code></pre> <p>私は以下のエラーを取得しています実行中
例外:HDFSは:java.net.URLClassLoader $ 1.runでjava.net.URLClassLoader $ 1.runで (URLClassLoader.java:366) を.hdfs.inverted (URLClassLoader.java:355) at java.security.AccessController.doPrivileged(ネイティブメソッド) java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at java.lang .ClassLoader.loadClass(ClassLoader.java:358) 、java.lang.Class.forName0(ネイティブメソッド) 、java.lang.Class.forName(Class.java:270) 、org.apache.hadoop.util。 RunJar.main(RunJar.java:205)
私はすべての前提条件を試しましたが、まだ問題に直面していました。以下はenter code here
コードです:
import java.io.IOException;
import java.util.HashMap;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
import org.apache.hadoop.mapreduce.Reducer;
public class InvertedIndex {
public static class Map extends Mapper<LongWritable,Text,Text,Text> {
@Override
public void map(LongWritable key, Text value, Context context)
throws IOException,InterruptedException
{
String fileName = ((FileSplit) context.getInputSplit()).getPath().getName();
String line=value.toString();
String words[]=line.split(" ");
for(String s:words){
context.write(new Text(s), new Text(fileName));
}
}
}
public static class Reduce extends
Reducer<Text, Text, Text, Text> {
@Override
public void reduce(Text key, Iterable<Text> values, Context context)
throws IOException, InterruptedException {
HashMap m=new HashMap();
int count=0;
for(Text t:values){
String str=t.toString();
if(m!=null &&m.get(str)!=null){
count=(int)m.get(str);
m.put(str, ++count);
}else{`enter code here`
m.put(str, 1);
}
}
context.write(key, new Text(m.toString()));
}
}
public static void main(String[] args) throws Exception {
Configuration conf= new Configuration();
Job job = new Job(conf,"UseCase1");
//Defining the output value class for the mapper
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(Text.class);
job.setJarByClass(InvertedIndex.class);
job.setMapperClass(Map.class);
job.setReducerClass(Reduce.class);
//Defining the output value class for the mapper
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
job.setInputFormatClass(TextInputFormat.class);
job.setOutputFormatClass(TextOutputFormat.class);
Path outputPath = new Path(args[1]);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, outputPath);
//deleting the output path automatically from hdfs so that we don't have delete it explicitly
outputPath.getFileSystem(conf).delete(outputPath);
//exiting the job only if the flag value becomes false
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
ありがとうございます!それは今働いています。私は、それが含まれていない理由は、クラスの指定がないいくつかの例を見てきました。それは間違ったタイプミスかもしれません。とにかく迅速な対応のために多くのおかげで。 –
それはあなたのために働いてうれしい。これを解決済みとマークできれば幸いです。 – Amit