我在运行hadoop管道代码时遇到问题。
我的环境是:Hadoop2.7.3 Mac10.13.3单节点。
我的代码如下:
#include <algorithm>
#include <limits>
#include <stdint.h>
#include <string>
#include "Pipes.hh"
#include "TemplateFactory.hh"
#include "StringUtils.hh"
using namespace std;
class MaxTemperatureMapper : public HadoopPipes::Mapper {
public:
MaxTemperatureMapper(HadoopPipes::TaskContext& context) {
}
void map(HadoopPipes::MapContext& context) {
std::string line = context.getInputValue();
std::string year = line.substr(15, 4);
std::string airTemperature = line.substr(87, 5);
std::string q = line.substr(92, 1);
if (airTemperature != "+9999" &&
(q == "0" || q == "1" || q == "4" || q == "5" || q == "9")) {
context.emit(year, airTemperature);
}
}
};
class MapTemperatureReducer : public HadoopPipes::Reducer {
public:
MapTemperatureReducer(HadoopPipes::TaskContext& context) {
}
void reduce(HadoopPipes::ReduceContext& context) {
int maxValue = INT_MIN;
while (context.nextValue()) {
maxValue = std::max(maxValue, HadoopUtils::toInt(context.getInputValue()));
}
context.emit(context.getInputKey(), HadoopUtils::toString(maxValue));
}
};
int main(int argc, char *argv[]) {
return runTask(HadoopPipes::TemplateFactory<MaxTemperatureMapper, MapTemperatureReducer>());
}
Makefile是:
HADOOP_INSTALL = /用户/的MacBookPro /文档/ Hadoop的2.7.5
CC = g ++
CCFLAGS = -I $(HADOOP_INSTALL)/ include
wordcount:wordcount-simple.cpp
$(CC)$(CCFLAGS)$&lt; -Wall -L $(HADOOP_INSTALL)/ lib / native -lhadooppipes -lhadooputils -lpthread -lcrypto -lssl -g -O2 -o $ @
当我运行wordcount程序时,我遇到以下错误: - *
Undefined symbols for architecture x86_64:
"HadoopPipes::runTask(HadoopPipes::Factory const&)", referenced from:
_main in wordcount-simple-52c3c0.o
"HadoopUtils::toInt(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
MapTemperatureReducer::reduce(HadoopPipes::ReduceContext&) in wordcount-simple-52c3c0.o
"HadoopUtils::toString(int)", referenced from:
MapTemperatureReducer::reduce(HadoopPipes::ReduceContext&) in wordcount-simple-52c3c0.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [wordcount] Error 1
你能帮我解决这个问题吗?