MapReduce项目的Mapper部分中出现多个错误

时间:2019-04-28 16:36:05

标签: java windows eclipse mapreduce

我是一个非常新手的程序员,项目合作伙伴无法编写代码,需要在今晚进行的一个学校项目中获得帮助(从事该项目超过一周)。我是   试图找到所有带有该词的视频的描述    “要塞(Fortnite)”,并且有超过10000个顶( https://www.kaggle.com/datasnaek/youtube-new)。我正在从CSV文件访问数据,在代码的Mapper部分遇到了多个错误,并且在解决之前无法继续。这是我的第一个Java / MapReduce / Hadoop项目,我只是不明白自己在做什么错。

在Windows 10 64位上运行Java 1.8和Eclipse IDE 2019-03。 我的两台计算机上都存在相同的问题,因此我很确定这是用户错误。我已经在这里待了一个多星期了,我想不通。

 Clean code:
 package mapreduce,project;

 import java.io.IOException;
 import java.util.StringTokenizer;
 import org.apache.hadoop.io.IntWritable;
 import org.apache.hadoop.io.LongWritable;
 import org.apache.hadoop.io.Text;
 import org.apache.hadoop.mapreduce.Reducer;
 import org.apache.hadoop.mapreduce.Job;
 import org.apache.hadoop.mapreduce.Mapper;
 import org.apache.hadoop.mapreduce.lib.input.TextInputFormat;
 import org.apache.hadoop.mapreduce.lib.output.TextOutputFormat;
 import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
 import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
 import org.apache.hadoop.fs.Path;


 public class project extends Mapper<LongWritable, Text, Text, 
 IntWritable> 
 {

  public Text description = new Text();
  private IntWritable likes = new IntWritable(); 
  @Override
  public void map(LongWritable key, Text value, Context context)

  throws IOException, InterruptedException{

    String line = value.toString();
    String str[] = line.split("\t");
    if(str.length >= 9){
        description.set(str[8]);
    }
        likes = Integer.parseInt(str[8]); 
        if (likes >= 10000) {
       context.write("Fornite", count);
        } 
    } else  {
        return; 
      StringTokenizer itr = new StringTokenizer(line);

      while(itr.hasMoreTokens()){
       String token = itr.nextToken();
       if(token.contains("Fortnite")){
       word.set("Fortnite Count");
     context.write(word, new IntWritable(1));
       }
      }



  ````````````````````````````````````````````````
  Code with Errors:

  package mapreduce.project;
   ----> (Error: Main method not found in class 
  mapreduce.project.project, please define the main method as:
  public static void main(String[] args)


  public class project extends Mapper<LongWritable, Text, Text, 
  IntWritable> 
  {

  public Text description = new Text();
  private IntWritable likes = new IntWritable(); 
  @Override


  public void map(LongWritable key, Text value, Context context)
  -----> (ERROR: This sorce attachment does not contain the source for 
  the file Mapper.class. Change Attached Source....)

  throws IOException, InterruptedException{

    String line = value.toString();
    String str[] = line.split("\t");
    if(str.length >= 9){
        description.set(str[8]);
    }

        likes = Integer.parseInt(str[8]); ----> ( ERROR: Type mismatch: 
  cannot convert from int to INTWritable)



   if (likes >= 10000) {  ----->(ERROR: the operator >= is undefined for 
   the argument type(0) IntWriteable, int)

   context.write("Fornite", count);   (ERROR------> count cannot be 
   resolved to a variable)
        } 
    } else { ----->syntax error on "else" delete this token)
        return; 
      StringTokenizer itr = new StringTokenizer(line);

      while(itr.hasMoreTokens()){ 

       String token = itr.nextToken();
       if(token.contains("Fortnite")){
       word.set("Fortnite Count");
       context.write(word, new IntWritable(1));
       }
      }








Running the YouTube data through the MapReduce program, we expect to 
obtain a list of YouTube videos that mention Fortnite in the description 
have over 10,000 views.

0 个答案:

没有答案