지도 축소는 구현입니다. 해당 구현을 사용할 수있는 코딩 인터페이스는 연속성을 사용할 수 있습니다. 프레임 워크와 작업 제어가 추상화되는 방식에 관한 문제입니다. Pig와 같은 Hadoop 용 선언적 인터페이스 또는 SQL과 같은 선언적 언어를 고려하십시오. 인터페이스 아래의 기계는 많은 방법으로 구현 될 수 있습니다. 예를 들어
, 여기 추상화 파이썬 맵 줄일 구현의 :
def mapper(input_tuples):
"Return a generator of items with qualifying keys, keyed by item.key"
# we are seeing a partition of input_tuples
return (item.key, item) for (key, item) in input_items if key > 1)
def reducer(input_tuples):
"Return a generator of items with qualifying keys"
# we are seeing a partition of input_tuples
return (item for (key, item) in input_items if key != 'foo')
def run_mapreduce(input_tuples):
# partitioning is magically run across boxes
mapper_inputs = partition(input_tuples)
# each mapper is magically run on separate box
mapper_outputs = (mapper(input) for input in mapper_inputs)
# partitioning and sorting is magically run across boxes
reducer_inputs = partition(
sort(mapper_output for output in mapper_outputs))
# each reducer is magically run on a separate box
reducer_outputs = (reducer(input) for input in reducer_inputs)
그리고 여기에 숨겨 더 많은 마법의 추상화, 코 루틴을 사용하여 동일한 구현의 :
def mapper_reducer(input_tuples):
# we are seeing a partition of input_tuples
# yield mapper output to caller, get reducer input
reducer_input = yield (
item.key, item) for (key, item) in input_items if key > 1)
# we are seeing a partition of reducer_input tuples again, but the
# caller of this continuation has partitioned and sorted
# yield reducer output to caller
yield (item for (key, item) in input_items if key != 'foo')
은 내가 필요가 있다고 생각 읽고 주제에 대해 더 이상의 의견을 나눌 수 있기 전에 더 많은 것을 이해하려고 노력하십시오. – Jeff