diff options
author | Andrea Smith <smit9523@umn.edu> | 2020-10-05 20:23:24 -0500 |
---|---|---|
committer | Andrea Smith <smit9523@umn.edu> | 2020-10-05 20:23:24 -0500 |
commit | 21bd21bbdffdf0a911133416e6125801118a0e8b (patch) | |
tree | 80cf12cc1b545f579e9480c74627d7c8a5166071 /P1/src | |
parent | Comments (diff) | |
download | csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar.gz csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar.bz2 csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar.lz csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar.xz csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.tar.zst csci4061-21bd21bbdffdf0a911133416e6125801118a0e8b.zip |
Update comments
Diffstat (limited to '')
-rw-r--r-- | P1/src/mapper.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/P1/src/mapper.c b/P1/src/mapper.c index 3e50170..3a197e0 100644 --- a/P1/src/mapper.c +++ b/P1/src/mapper.c @@ -80,7 +80,7 @@ void freeInterDS(intermediateDS *root) { } // emit the <key, value> into intermediate DS -// eats the data into the DS +// Eats data into the intermediate DS void emit(char *key, char *value) { insertPairToInterDS(&DS, key, value); } @@ -90,7 +90,7 @@ void map(char *chunkData){ int i = 0; char *buffer; while ((buffer = getWord(chunkData, &i)) != NULL){ - // get words from buffer & give it to emitter to be put into intermediateDS + // Get words from buffer & give it to emitter to be put into intermediateDS emit(buffer, "1"); } // you can use getWord to retrieve words from the @@ -99,25 +99,27 @@ void map(char *chunkData){ // write intermediate data to separate word.txt files // 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 +// Yeets the data out into separate [the word].txt files void writeIntermediateDS() { intermediateDS *root = &DS; intermediateDS *tempNode = root -> next; + // Traverse the intermediate DS while(tempNode != NULL) { // Get string of 1's associated with the word char ones[BUFFSIZE]= ""; valueList *tempNode2 = tempNode -> value; + // Traverse nested valueList // Kinda jank way to deal with collecting the word's corresponding 1's while(tempNode2 != NULL) { strcat(ones, "1 "); tempNode2 = tempNode2 -> next; } - // Put words and their corresponding 1's in a file named word.txt + + // Put words and their corresponding 1's in a file named [the word].txt char filename[BUFFSIZE] = ""; - //sprintf(filename, "output/MapOut/Map_%d/%s.txt", mapperID, tempNode -> key); sprintf(filename, "%s/%s.txt", mapOutDir, tempNode -> key); FILE* fptr = fopen(filename, "w"); fprintf(fptr, "%s %s", tempNode -> key, ones); |