00001 00002 /* 00003 * CS 241 00004 * The University of Illinois 00005 */ 00006 00007 #ifndef _LIBMAPREDUCE_H_ 00008 #define _LIBMAPREDUCE_H_ 00009 00010 #include <pthread.h> 00011 #include "libds/libds.h" 00012 #include <sys/select.h> 00013 00014 typedef struct _mapreduce_t { 00015 void (*map)(int, const char *); 00016 const char *(*reduce)(const char *, const char *); 00017 int n; // n data sets 00018 int* fds; 00019 fd_set read_fds; // n pipes 00020 datastore_t* ds; 00021 } mapreduce_t; 00022 00023 00031 void mapreduce_init(mapreduce_t *mr, void (*mymap)(int, const char *), const char *(*myreduce)(const char *, const char *)); 00032 00033 00039 void mapreduce_map_all(mapreduce_t *mr, const char **values); 00040 00041 00045 void mapreduce_reduce_all(mapreduce_t *mr); 00046 00047 00051 const char *mapreduce_get_value(mapreduce_t *mr, const char *result_key); 00052 00053 00057 void mapreduce_destroy(mapreduce_t *mr); 00058 00059 #endif