aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrea Smith <smit9523@umn.edu>2020-10-04 13:55:08 -0500
committerAndrea Smith <smit9523@umn.edu>2020-10-04 13:55:08 -0500
commit88799a8650380943c596b63e9e6de9084d89b687 (patch)
tree5c5ef089d4cd375f1b38ce7d3deb6ac7d0b17649
parentMerge branch 'master' of github.umn.edu:STRAP012/csci4061Projects (diff)
downloadcsci4061-88799a8650380943c596b63e9e6de9084d89b687.tar
csci4061-88799a8650380943c596b63e9e6de9084d89b687.tar.gz
csci4061-88799a8650380943c596b63e9e6de9084d89b687.tar.bz2
csci4061-88799a8650380943c596b63e9e6de9084d89b687.tar.lz
csci4061-88799a8650380943c596b63e9e6de9084d89b687.tar.xz
csci4061-88799a8650380943c596b63e9e6de9084d89b687.tar.zst
csci4061-88799a8650380943c596b63e9e6de9084d89b687.zip
Update mapper.c pls word dear god
Diffstat (limited to '')
-rw-r--r--P1/src/mapper.c36
1 files changed, 16 insertions, 20 deletions
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 <word, value list>
-
- 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[]) {