From 7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221 Mon Sep 17 00:00:00 2001 From: Matt Strapp Date: Thu, 24 Sep 2020 07:24:19 -0500 Subject: rearrange --- P1/include/mapper.h | 46 ++++++++++++++++++++++++++++++++++++++++++++ P1/include/mapreduce.h | 6 ++++++ P1/include/reducer.h | 24 +++++++++++++++++++++++ P1/include/utils.h | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 P1/include/mapper.h create mode 100644 P1/include/mapreduce.h create mode 100644 P1/include/reducer.h create mode 100644 P1/include/utils.h (limited to 'P1/include') diff --git a/P1/include/mapper.h b/P1/include/mapper.h new file mode 100644 index 0000000..2e3693c --- /dev/null +++ b/P1/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/include/mapreduce.h b/P1/include/mapreduce.h new file mode 100644 index 0000000..9b5950b --- /dev/null +++ b/P1/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/include/reducer.h b/P1/include/reducer.h new file mode 100644 index 0000000..79ea452 --- /dev/null +++ b/P1/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/include/utils.h b/P1/include/utils.h new file mode 100644 index 0000000..cfe56f2 --- /dev/null +++ b/P1/include/utils.h @@ -0,0 +1,52 @@ +#ifndef UTILS_H +#define UTILS_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#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 -- cgit v1.2.3