小编Chr*_*phe的帖子

如何在运行Hadoop MapReduce作业时将文件名/文件内容作为MAP的键/值输入?

我正在创建一个分析PDF,DOC和DOCX文件的程序.这些文件存储在HDFS中.

当我启动MapReduce作业时,我希望map函数将Filename作为键,将Binary Contents作为值.然后我想创建一个流阅读器,我可以将其传递给PDF解析器库.如何实现Map Phase的键/值对是filename/filecontents?

我正在使用Hadoop 0.20.2

这是开始工作的旧代码:

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

 conf.setOutputKeyClass(Text.class);
 conf.setOutputValueClass(IntWritable.class);

 conf.setMapperClass(Map.class);
 conf.setReducerClass(Reduce.class);

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

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

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

我知道还有其他inputformat类型.但有没有一个完全符合我的要求?我觉得文档很模糊.如果有一个可用,那么Map函数输入类型应该如何?

提前致谢!

java hadoop mapreduce distributed-system

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

Boost自动链接库不是由Boost构建的,但是构建了预期的库

我正在开发一个Math应用程序,可以通过编写python脚本来扩展它.

我使用Qt 4.6.3(构建为静态库,调试和发布版本)和Boost 1.43.0(构建为静态库,运行时链接也设置为静态,多线程版本,调试和发布).一切都是用MSVC++ 2008构建的.Boost构建了以下库:

  • libboost_python-VC90-MT-S-1_43.lib
  • libboost_python-VC90-MT-s.lib
  • libboost_python-VC90-MT-SGD-1_43.lib
  • libboost_python-VC90-MT-sgd.lib

我的项目编译,但在链接阶段给出以下错误:

1>Linking...
1>LINK : fatal error LNK1104: cannot open file 'boost_python-vc90-mt-gd-1_43.lib'
Run Code Online (Sandbox Code Playgroud)

为什么不选择我编译的库之一?

我认为库名中的s代表静态,但是自动链接功能似乎选择了一个动态库,我希望它在一个可执行文件中静态链接.

regex库也是如此:我编译了相同的4个正则表达式库并且快速测试显示了这个链接错误:

1>LINK : fatal error LNK1104: cannot open file 'libboost_regex-vc90-mt-gd-1_43.lib'
Run Code Online (Sandbox Code Playgroud)

该怎么办?

c++ boost static-linking visual-studio-2008 boost-python

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

C++使用类模板参数作为另一种类型的模板参数

我在编写自己的HashTable时遇到了这个问题.这一切都有效,但当我试图模仿这件事时,它给了我错误.我重新创建了如下问题:

本代码的工作原理:

typedef double Item;

class A
{
public:
    A()
    {
        v.push_back(pair<string, Item>("hey", 5.0));
    }

    void iterate()
    {
        for(Iterator iter = v.begin(); iter != v.end(); ++iter)
            cout << iter->first << ", " << iter->second << endl;
    }

private:
    vector<pair<string, double> > v;
    typedef vector< pair<string, double> >::iterator Iterator;
};
Run Code Online (Sandbox Code Playgroud)

这个代码不是:

template<typename ValueType>
class B
{
public:
    B(){}

    void iterate()
    {
        for(Iterator iter = v.begin(); iter != v.end(); ++iter)
            cout << iter->first << ", " << iter->second << endl;
    }

private: …
Run Code Online (Sandbox Code Playgroud)

c++ templates

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