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 | |
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')
-rw-r--r-- | P2/.vscode/launch.json | 28 | ||||
-rw-r--r-- | P2/.vscode/tasks.json | 17 | ||||
-rw-r--r-- | P2/lib/utils.c | 18 |
3 files changed, 55 insertions, 8 deletions
diff --git a/P2/.vscode/launch.json b/P2/.vscode/launch.json new file mode 100644 index 0000000..ba82be7 --- /dev/null +++ b/P2/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Build & Launch", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/mapreduce", + "args": ["5", "2", "test/T1/F1.txt"], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": false, + "MIMode": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + ], + "preLaunchTask": "Make", + }, + ] +}
\ No newline at end of file diff --git a/P2/.vscode/tasks.json b/P2/.vscode/tasks.json new file mode 100644 index 0000000..2ebd385 --- /dev/null +++ b/P2/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Make", + "type": "shell", + "command": "make", + "group": { + "kind": "build", + "isDefault": true + }, + }, + + ] +}
\ No newline at end of file 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); } |