From 88799a8650380943c596b63e9e6de9084d89b687 Mon Sep 17 00:00:00 2001 From: Andrea Smith Date: Sun, 4 Oct 2020 13:55:08 -0500 Subject: Update mapper.c pls word dear god --- P1/src/mapper.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) (limited to 'P1/src/mapper.c') diff --git a/P1/src/mapper.c b/P1/src/mapper.c index d0db9a0..2379264 100644 --- a/P1/src/mapper.c +++ b/P1/src/mapper.c @@ -99,28 +99,24 @@ void map(char *chunkData){ // Each file will have only one line : word 1 1 1 1 1 ... // poops the data out into separate .txt files named after the word void writeIntermediateDS() { - // Iterate through intermediate DS - // Create new word.txt - // Insert - - intermediateDS *tempNode = DS; - intermediateDS *tempNode2 = DS; + intermediateDS *tempNode = &DS; + valueList *tempNode2; + + while(tempNode != NULL) { + // Get string of 1's associated with the word + char ones[100]; + tempNode2 = tempNode2 -> value; + while(tempNode2 != NULL) { + strcat(ones, "1 "); + tempNode2 = tempNode -> next; + } - // Traverse valueList - tempNode2 = tempNode2 -> value; - while(tempNode2 != NULL) { - - tempNode2 = tempNode -> next; + // Shove word and ones in a file named word.txt + char filename[20]; + sprintf(filename, "output/map_%d/%s.txt", mapperID, tempNode -> key); + FILE* fptr = fopen(filename, "w"); + tempNode = tempNode -> next; } - - - // while(tempNode != NULL) { - // char filename[20]; - // sprintf(filename, "%s.txt", foo); - // FILE* fptr = fopen("%s.txt", "w"); - - // tempNode = tempNode -> next; - // } } int main(int argc, char *argv[]) { -- cgit v1.2.3