aboutsummaryrefslogtreecommitdiffstats
path: root/P1/src
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-10-05 20:23:15 -0500
committerMatt Strapp <strap012@umn.edu>2020-10-05 20:23:15 -0500
commite9dcff49cadd8a1a0e698851d3bc97c4b0f03b43 (patch)
treec6ceb905d5a89b9cc5ed46e47c115d703f747354 /P1/src
parentGet rid of comment (diff)
downloadcsci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar.gz
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar.bz2
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar.lz
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar.xz
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.tar.zst
csci4061-e9dcff49cadd8a1a0e698851d3bc97c4b0f03b43.zip
Edit reducer (#6)
Diffstat (limited to '')
-rw-r--r--P1/src/reducer.c14
1 files changed, 7 insertions, 7 deletions
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[]) {