diff options
-rw-r--r-- | P2/lib/utils.c | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 3b4f829..c0b2c67 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -23,23 +23,11 @@ char *getChunkData(int mapperID) { int mid = openQueue(); //printf("MAPPER ID:%d\n", mapperID); msgrcv(mid, &message, MSGSIZE, mapperID, 0); - // printf("\n%s\n", message.msgText); - // printf("%d\n", strncmp("END", message.msgText, 3)); if (strncmp("END", message.msgText, 3) == 0) return NULL; - // char* value = message.msgText; - // return value; - - // DEBUG! malloc a buffer/return char* value = malloc(1024); // chunkSize or MSGSIZE? strcpy(value, message.msgText); return value; - // Free memory outside of getChunkData? - - // printf("%s\n", message.msgText); - //printf("RECEIVED CHUNK:%s\nRECEIVED VALUE:%ld\n", value, message.msgType); - - //return &(message.msgText); } // sends chunks of size 1024 to the mappers in RR fashion @@ -57,14 +45,11 @@ void sendChunkData(char *inputFile, int nMappers) { int i = 1023; while(validChar(message.msgText[i])) { - message.msgText[i] = '\0'; - i--; + message.msgText[i--] = '\0'; } - // DEBUG! - fseek(file, (i - 1023), SEEK_CUR); message.msgType = (map++ % nMappers) + 1; - //printf("SENT CHUNK: %s\nSENT CHUNK MAPPER: %ld\n",message.msgText, message.msgType); + msgsnd(msgid, &message, MSGSIZE, 0); } for (int i = 1; i <= nMappers; i++) { @@ -92,7 +77,6 @@ int getInterData(char *Qkey, int reducerID) { int id = openQueue(); msgrcv(id, &message, MSGSIZE, reducerID, 0); strcpy(Qkey, message.msgText); - printf("INTER DATA: %s\nREDUCER ID:%ld\n", Qkey, message.msgType); return (strncmp("END", message.msgText, 3) != 0); } @@ -110,7 +94,6 @@ void shuffle(int nMappers, int nReducers) { if (!strcmp(".", entry->d_name) || !strcmp("..", entry->d_name)) continue; sprintf(message.msgText, "%s/%s", newpath, entry -> d_name); - printf("%s\n%d\n", entry->d_name, hashFunction(entry->d_name, nReducers)+1); message.msgType = (hashFunction(entry -> d_name, nReducers)+1); msgsnd(id, &message, MSGSIZE, 0); } |