aboutsummaryrefslogtreecommitdiffstats
path: root/P2
diff options
context:
space:
mode:
authorMatthew Strapp <strap012@umn.edu>2020-10-24 17:55:51 -0500
committerGitHub Enterprise <noreply-github@umn.edu>2020-10-24 17:55:51 -0500
commit8f9e0d0ad99fa2fde15516a6053e47e95175c0db (patch)
treed6a70298a5e3715e493cfaa455783513170c20ba /P2
parentsendChunk (diff)
parentGet rid of variable (diff)
downloadcsci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar.gz
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar.bz2
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar.lz
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar.xz
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.tar.zst
csci4061-8f9e0d0ad99fa2fde15516a6053e47e95175c0db.zip
Merge getChunkData() with master
Diffstat (limited to 'P2')
-rw-r--r--P2/include/utils.h2
-rw-r--r--P2/lib/utils.c18
2 files changed, 20 insertions, 0 deletions
diff --git a/P2/include/utils.h b/P2/include/utils.h
index 2c91cdf..e3f5d43 100644
--- a/P2/include/utils.h
+++ b/P2/include/utils.h
@@ -23,6 +23,7 @@ struct msgBuffer {
};
// mapper side
+
int validChar(char c);
char *getWord(char *chunk, int *i);
char *getChunkData(int mapperID);
@@ -30,6 +31,7 @@ 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);
diff --git a/P2/lib/utils.c b/P2/lib/utils.c
index 79b309e..dba63b5 100644
--- a/P2/lib/utils.c
+++ b/P2/lib/utils.c
@@ -1,6 +1,24 @@
#include "utils.h"
+//Receive from send and return the chonk
char *getChunkData(int mapperID) {
+ //Message
+ struct msgBuffer* message;
+ //Queue ID, not sure what it actually does
+ int mid;
+ //Queue Key
+ key_t key = 10;
+ mid = msgget(key, 0666);
+ if (mid < 0) {
+ perror("Cannot open queue.\n");
+ return NULL;
+ }
+ msgrcv(mid, (void *) &message, MSGSIZE, mapperID, 0);
+ if (strcmp("END", message -> msgText)) {
+ struct msgBuffer ACK = {mapperID, "ACK"};
+ msgsnd(mid, (void *) &ACK, MSGSIZE, 0);
+ }
+ return message -> msgText;
}
// sends chunks of size 1024 to the mappers in RR fashion