나는 hadoop 프레임 워크에 초보이며지도는 추상화를 줄인다.가장 작은 숫자를 찾는다. hadoop streaming python
기본적으로,이 거대한 텍스트 파일에서 가장 작은 수 (로 구분 ",") 그래서
을 찾는 생각, 여기 mapper.py
#!/usr/bin/env python
import sys
# input comes from STDIN (standard input)
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# split the line into words
numbers = line.split(",")
# increase counters
for number in numbers:
# write the results to STDOUT (standard output);
# what we output here will be the input for the
# Reduce step, i.e. the input for reducer.py
#
# tab-delimited; the trivial word count is 1
print '%s\t%s' % (number, 1)
감속기
내 코드입니다#!/usr/bin/env python
from operator import itemgetter
import sys
smallest_number = sys.float_info.max
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# parse the input we got from mapper.py
number, count = line.split('\t', 1)
try:
number = float(number)
except ValueError:
continue
if number < smallest_number:
smallest_number = number
print smallest_number <---- i think the error is here... there is no key value thingy
print smallest_number
는 오류가 나는 얻을 :
12/10/04 12:07:22 ERROR streaming.StreamJob: Job not successful. Error: NA
12/10/04 12:07:22 INFO streaming.StreamJob: killJob...
Streaming Command Failed!
어떤 결과가 나타 납니까? 뭐가 문제 야? "핵심 가치"는 무슨 소리 야? – Junuxx
@Junuxx : 안녕하세요 .. 방금 오류를 게시했습니다 .. 기본적으로 ..지도에서 텍스트 파일의 가장 작은 숫자를 찾는 추상화를 어떻게 줄일 수 있습니까?/ 오류에 대한 얘기는 .. 매퍼가 나옵니다. number, 1) 기본적으로 워드 카운트 예에서 매퍼와 동일한 형식입니다. 감속기에서 내가 신경 쓰는 것은 숫자입니다. 숫자를 가져 와서 가장 작은 현재 숫자와 비교하고 스왑을합니까? – Fraz
Hadoop없이 디버깅하는 것이 도움이 될 수 있습니다.'cat input | ./mapper.py | 정렬 | ./reducer.py' 성공적으로 실행됩니까? –