-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmapreduce.h
More file actions
28 lines (24 loc) · 924 Bytes
/
mapreduce.h
File metadata and controls
28 lines (24 loc) · 924 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#ifndef MAPREDUCE_H
#define MAPREDUCE_H
/***
* Map-reduce!
*
*
*/
/**
* Convert one of the values into the output type. This is a simple
* map on the data. The context is passed in as the context to
* mapreduce.
*/
typedef void *(*map_fn_t)(void *context, void *value);
/**
* Your own function to combine results. You either combine the
* `newdata` into the `aggregate`, or if `newdata == NULL &&
* aggregate2 != NULL`, you combine the aggregates together. The
* context is passed in as the context to mapreduce.
*/
typedef void (*reduce_fn_t)(void *context, void *aggregate, void *newdata);
typedef void (*combine_fn_t)(void *context, void *aggto, void *aggfrom);
typedef void *(*reduce_init_fn_t)(void *context);
void *mapreduce(int parallelism, void *input[], size_t data_sz, void *context, map_fn_t map, reduce_init_fn_t reduce_init, reduce_fn_t reduce, combine_fn_t combine);
#endif /* MAPREDUCE_H */