aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Smith <smit9523@umn.edu>2020-10-05 20:23:32 -0500
committerAndrea Smith <smit9523@umn.edu>2020-10-05 20:23:32 -0500
commitce72bbe5d420797677e40e44d4529c4910bfe779 (patch)
tree93f0aac36299f5d5028e89ab54852ca06420621d
parentUpdate comments (diff)
parentMerge branch 'master' of github.umn.edu:STRAP012/csci4061Projects (diff)
downloadcsci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar.gz
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar.bz2
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar.lz
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar.xz
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.tar.zst
csci4061-ce72bbe5d420797677e40e44d4529c4910bfe779.zip
Merge branch 'master' of github.umn.edu:STRAP012/csci4061Projects
-rw-r--r--P1/include/mapper.h1
-rw-r--r--P1/include/utils.h1
-rw-r--r--P1/src/reducer.c14
3 files changed, 8 insertions, 8 deletions
diff --git a/P1/include/mapper.h b/P1/include/mapper.h
index bbc6ef1..2e3693c 100644
--- a/P1/include/mapper.h
+++ b/P1/include/mapper.h
@@ -6,7 +6,6 @@
// ###### DO NOT REMOVE ######
#define MAXKEYSZ 100
#define MAXVALUESZ 100
-#define BUFFSIZE 150
// ###### DO NOT REMOVE ######
char *mapOutDir;
diff --git a/P1/include/utils.h b/P1/include/utils.h
index cfe56f2..da5ffd8 100644
--- a/P1/include/utils.h
+++ b/P1/include/utils.h
@@ -18,6 +18,7 @@
#define MSGSIZE 1100
#define ENDTYPE 1000
#define ACKTYPE 1100
+#define BUFFSIZE 150
struct msgBuffer {
long msgType;
diff --git a/P1/src/reducer.c b/P1/src/reducer.c
index 8656629..9519fa3 100644
--- a/P1/src/reducer.c
+++ b/P1/src/reducer.c
@@ -51,20 +51,20 @@ void reduce(char *key) {
// write the contents of the final intermediate structure
// to output/ReduceOut/Reduce_reducerID.txt
void writeFinalDS(int reducerID){
-
+
finalKeyValueDS *root = &DS;
- finalKeyValueDS *tempNode = root;
+ finalKeyValueDS *tempNode = root -> next;
while(tempNode != NULL) {
- // Shove word and ones in a file named word.txt
- char filename[150];
- sprintf(filename, "output/MapOut/Map_%d/%s.txt", reducerID, tempNode -> key);
+ // Shove word and number of occurances in a file named word.txt
+ char filename[BUFFSIZE] = "";
+ sprintf(filename, "output/ReduceOut/Reduce_%d.txt", reducerID);
FILE* fptr = fopen(filename, "w");
- fprintf(fptr, "%s %d", tempNode -> key, tempNode -> value);
+ fprintf(fptr, "%s %s", tempNode -> key, tempNode -> value);
fclose(fptr);
tempNode = tempNode -> next;
}
- freeFinalDS(root);
+ freeInterDS(root -> next);
}
int main(int argc, char *argv[]) {