0

I have a problem in running hadoop pipes code.

My environment is: Hadoop2.7.3 Mac10.13.3 single node.

My code is following:

#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>());
}

The Makefile is:

HADOOP_INSTALL=/Users/macbookpro/Documents/hadoop-2.7.5

CC = g++

CCFLAGS = -I$(HADOOP_INSTALL)/include

wordcount :wordcount-simple.cpp

$(CC) $(CCFLAGS) $< -Wall -L$(HADOOP_INSTALL)/lib/native -lhadooppipes -lhadooputils -lpthread -lcrypto -lssl -g -O2 -o $@

when i run wordcount program i am getting following errors:-- *

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

Can you help me solve this?

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Joon
  • 63
  • 5

0 Answers0