小编ymm*_*myk的帖子

Custom WritableCompare将对象引用显示为输出

我是Hadoop和Java的新手,我觉得有一些明显的东西我只是缺少了.如果这意味着什么,我正在使用Hadoop 1.0.3.

我使用hadoop的目的是获取一堆文件并一次解析一个文件(而不是逐行).每个文件将生成多个键值,但其他行的上下文很重要.键和值是多值/复合的,所以我已经为键实现了WritableCompare,为值实现了可写.因为每个文件的处理占用了一点CPU,我想保存映射器的输出,然后再运行多个reducer.

对于复合键,我跟着[http://stackoverflow.com/questions/12427090/hadoop-composite-key][1]

问题是,输出只是Java对象引用而不是复合键和值.例: LinkKeyWritable@bd2f9730 LinkValueWritable@8752408c

我不确定问题是否与根本没有减少数据有关

这是我的主要课程:

public static void main(String[] args) throws Exception {
  JobConf conf = new JobConf(Parser.class);
  conf.setJobName("raw_parser");

  conf.setOutputKeyClass(LinkKeyWritable.class);
  conf.setOutputValueClass(LinkValueWritable.class);

  conf.setMapperClass(RawMap.class);
  conf.setNumMapTasks(0);

  conf.setInputFormat(PerFileInputFormat.class);
  conf.setOutputFormat(TextOutputFormat.class);

  PerFileInputFormat.setInputPaths(conf, new Path(args[0]));
  FileOutputFormat.setOutputPath(conf, new Path(args[1]));

  JobClient.runJob(conf);
}
Run Code Online (Sandbox Code Playgroud)

而我的Mapper类:

公共类RawMap扩展MapReduceBase实现Mapper {

    public void map(NullWritable key, Text value,
            OutputCollector<LinkKeyWritable, LinkValueWritable> output,
            Reporter reporter) throws IOException {
        String json = value.toString();
        SerpyReader reader = new SerpyReader(json);
        GoogleParser parser = new GoogleParser(reader);
        for (String page : reader.getPages()) {
            String content = reader.readPageContent(page);
            parser.addPage(content);
        } …
Run Code Online (Sandbox Code Playgroud)

hadoop mapreduce

1
推荐指数
1
解决办法
2329
查看次数

标签 统计

hadoop ×1

mapreduce ×1