Map-reduce - это реализация. Интерфейс кодирования, который позволяет использовать эту реализацию, может использовать продолжения; это действительно вопрос о том, как структура и контроль заданий абстрагируются. Рассмотрим декларативные интерфейсы для Hadoop, такие как Pig или декларативные языки в целом, такие как SQL; оборудование под интерфейсом может быть реализовано многими способами.
Например, вот отведенной Python Map-Reduce реализация:
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