diff options
author | Matt Strapp <strap012@umn.edu> | 2020-10-27 16:32:46 -0500 |
---|---|---|
committer | Matt Strapp <strap012@umn.edu> | 2020-10-27 16:32:46 -0500 |
commit | 95c60cd2692a0793f3d817098f4c2261c5993857 (patch) | |
tree | aec1482ccbad09eb2db2156a1b308f640da6dd8b /P2/lib | |
parent | Change comma placement (diff) | |
download | csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar.gz csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar.bz2 csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar.lz csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar.xz csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.tar.zst csci4061-95c60cd2692a0793f3d817098f4c2261c5993857.zip |
I've lost my marbles
Diffstat (limited to 'P2/lib')
-rw-r--r-- | P2/lib/utils.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/P2/lib/utils.c b/P2/lib/utils.c index 195f0ae..9693268 100644 --- a/P2/lib/utils.c +++ b/P2/lib/utils.c @@ -5,7 +5,7 @@ int openQueue() { if (id < 0) { perror("Cannot open queue.\n"); - return NULL; + return -1; }; return id; } @@ -21,7 +21,8 @@ char *getChunkData(int mapperID) { struct msgBuffer ACK = {mapperID, "ACK"}; msgsnd(mid, &ACK, MSGSIZE, 0); } - return message.msgText; + char* value = message.msgText; + return value; } // sends chunks of size 1024 to the mappers in RR fashion @@ -30,17 +31,18 @@ void sendChunkData(char *inputFile, int nMappers) { // open message queue int msgid = openQueue(); // message.msgText = 1; - FILE *fptr = fopen(inputFile, "r"); - + int fd = open(inputFile, O_RDONLY); // construct chunks of 1024 bytes - while(fgets(&message, chunkSize, fptr) != EOF) { - + char* buf[chunkSize]; + memset(buf, '\0', chunkSize); + while(read(fd, buf, chunkSize) != 0) { + printf("%s\n", buf); /* Go to the end of the chunk, check if final character is a space if character is a space, do nothing else cut off before that word and put back file */ // TODO! help - msgsnd(msgid, &message, mapperID, 0); + msgsnd(msgid, &message, 1, 0); } for (int i = 1; i < nMappers; i++) { @@ -88,7 +90,7 @@ void shuffle(int nMappers, int nReducers) { for (int i = 1; i <= nMappers; i++) { //Extra for loop traversing directory - message.msgType = hashFunction(/* SOMETHING ,*/ nReducers); + //message.msgType = hashFunction(/* SOMETHING ,*/ nReducers); msgsnd(id, &message, chunkSize, 0); } |