diff options
Diffstat (limited to '')
-rw-r--r-- | P1/Template/include/mapper.h | 46 | ||||
-rw-r--r-- | P1/Template/include/mapreduce.h | 6 | ||||
-rw-r--r-- | P1/Template/include/reducer.h | 24 | ||||
-rw-r--r-- | P1/Template/include/utils.h | 52 |
4 files changed, 128 insertions, 0 deletions
diff --git a/P1/Template/include/mapper.h b/P1/Template/include/mapper.h new file mode 100644 index 0000000..2e3693c --- /dev/null +++ b/P1/Template/include/mapper.h @@ -0,0 +1,46 @@ +#ifndef MAPPER_H +#define MAPPER_H + +#include "utils.h" + +// ###### DO NOT REMOVE ###### +#define MAXKEYSZ 100 +#define MAXVALUESZ 100 + +// ###### DO NOT REMOVE ###### +char *mapOutDir; +int mapperID; + + +// You are free to change the intermediate data structure as it suits you +// If you do so, ensure the provided utility functions are also changed +// 1 1 1... +typedef struct valueList { + // MAXVALUESZ can be reduced to a small value as you are only storing "1" + char value[MAXVALUESZ]; + struct valueList *next; +}valueList; + +// word 1 1 1... +typedef struct intermediateDS{ + char key[MAXKEYSZ]; + valueList *value; + struct intermediateDS *next; +}intermediateDS; + +// ###### DO NOT REMOVE ###### +valueList *createNewValueListNode(char *value); +valueList *insertNewValueToList(valueList *root, char *count); +void freeValueList(valueList *root); + +// ###### DO NOT REMOVE ###### +intermediateDS *createNewInterDSNode(char *word, char *count); +intermediateDS *insertPairToInterDS(intermediateDS *root, char *word, char *count); +void freeInterDS(intermediateDS *root); + +// ###### DO NOT REMOVE ###### +void emit(char *key, char *value); +void map(char *chunkData); +void writeIntermediateDS(); + +#endif
\ No newline at end of file diff --git a/P1/Template/include/mapreduce.h b/P1/Template/include/mapreduce.h new file mode 100644 index 0000000..9b5950b --- /dev/null +++ b/P1/Template/include/mapreduce.h @@ -0,0 +1,6 @@ +#ifndef MAPREDUCE_H +#define MAPREDUCE_H + +#include "utils.h" //sendChunkData and shuffle + +#endif
\ No newline at end of file diff --git a/P1/Template/include/reducer.h b/P1/Template/include/reducer.h new file mode 100644 index 0000000..79ea452 --- /dev/null +++ b/P1/Template/include/reducer.h @@ -0,0 +1,24 @@ +#ifndef REDUCER_H +#define REDUCER_H + +#include "utils.h" + +#define MAXKEYSZ 50 + +// ###### DO NOT REMOVE ###### +typedef struct finalKeyValueDS { + char key[MAXKEYSZ]; + int value; + struct finalKeyValueDS *next; +} finalKeyValueDS; + +// ###### DO NOT REMOVE ###### +finalKeyValueDS *createFinalKeyValueNode(char *value, int count); +finalKeyValueDS *insertNewKeyValue(finalKeyValueDS *root, char *word, int count); +void freeFinalDS(finalKeyValueDS *root); + +// ###### DO NOT REMOVE ###### +void writeFinalDS(int reducerID); +void reduce(char *key); + +#endif
\ No newline at end of file diff --git a/P1/Template/include/utils.h b/P1/Template/include/utils.h new file mode 100644 index 0000000..cfe56f2 --- /dev/null +++ b/P1/Template/include/utils.h @@ -0,0 +1,52 @@ +#ifndef UTILS_H +#define UTILS_H + +#include <stdio.h> +#include <stdlib.h> +#include <errno.h> +#include <unistd.h> +#include <dirent.h> +#include <string.h> +#include <fcntl.h> +#include <sys/msg.h> +#include <sys/stat.h> +#include <sys/wait.h> +#include <sys/types.h> +#include <ctype.h> + +#define chunkSize 1024 +#define MSGSIZE 1100 +#define ENDTYPE 1000 +#define ACKTYPE 1100 + +struct msgBuffer { + long msgType; + char msgText[MSGSIZE]; +}; + +// mapper side +int validChar(char c); +// getWord usage - retrieves words from the chunk passed until it is fully traversed +// given a chunk of data chunkData, the call to getWord should look as below: +// int i = 0; +// char *buffer; +// while ((buffer = getWord(chunkData, &i)) != NULL){ +// your code +// } +char *getWord(char *chunk, int *i); +char *getChunkData(int mapperID); +void sendChunkData(char *inputFile, int nMappers); + + +// reducer side +int hashFunction(char* key, int reducers); +int getInterData(char *key, int reducerID); +void shuffle(int nMappers, int nReducers); + +// directory +void createOutputDir(); +char *createMapDir(int mapperID); +void removeOutputDir(); +void bookeepingCode(); + +#endif
\ No newline at end of file |