Map-reduce est une implémentation. L'interface de codage qui vous permet d'utiliser cette implémentation peut utiliser des suites; c'est vraiment une question de savoir comment le cadre et le contrôle du travail sont abstraits. Considérons des interfaces déclaratives pour Hadoop telles que Pig, ou des langages déclaratifs en général tels que SQL; la machinerie située sous l'interface peut être mise en œuvre de plusieurs façons.
Par exemple, voici un Python Abstraite carte-reduce mise en œuvre:
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)
Et voici la même mise en œuvre en utilisant coroutines, avec l'abstraction encore plus magique caché:
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')
Je pense que je dois Lisez et essayez de mieux comprendre avant de pouvoir faire d'autres commentaires sur le sujet. – Jeff