aboutsummaryrefslogtreecommitdiffstats
path: root/P1/Template/src/reducer.c
diff options
context:
space:
mode:
authorMatt Strapp <strap012@umn.edu>2020-09-24 07:24:19 -0500
committerMatt Strapp <strap012@umn.edu>2020-09-24 07:24:19 -0500
commit7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221 (patch)
tree73142dd8d25f71467fc0fa602e3caaf0f6b8b34f /P1/Template/src/reducer.c
parentAdd project 1 files (diff)
downloadcsci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar.gz
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar.bz2
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar.lz
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar.xz
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.tar.zst
csci4061-7f2f7f7c3e5d4c626d7e8d4d45fee2b11b6d5221.zip
rearrange
Diffstat (limited to 'P1/Template/src/reducer.c')
-rw-r--r--P1/Template/src/reducer.c79
1 files changed, 0 insertions, 79 deletions
diff --git a/P1/Template/src/reducer.c b/P1/Template/src/reducer.c
deleted file mode 100644
index bdf093b..0000000
--- a/P1/Template/src/reducer.c
+++ /dev/null
@@ -1,79 +0,0 @@
-#include "reducer.h"
-
-// create a key value node
-finalKeyValueDS *createFinalKeyValueNode(char *word, int count){
- finalKeyValueDS *newNode = (finalKeyValueDS *)malloc (sizeof(finalKeyValueDS));
- strcpy(newNode -> key, word);
- newNode -> value = count;
- newNode -> next = NULL;
- return newNode;
-}
-
-// insert or update an key value
-finalKeyValueDS *insertNewKeyValue(finalKeyValueDS *root, char *word, int count){
- finalKeyValueDS *tempNode = root;
- if(root == NULL)
- return createFinalKeyValueNode(word, count);
- while(tempNode -> next != NULL){
- if(strcmp(tempNode -> key, word) == 0){
- tempNode -> value += count;
- return root;
- }
- tempNode = tempNode -> next;
- }
- if(strcmp(tempNode -> key, word) == 0){
- tempNode -> value += count;
- } else{
- tempNode -> next = createFinalKeyValueNode(word, count);
- }
- return root;
-}
-
-// free the DS after usage. Call this once you are done with the writing of DS into file
-void freeFinalDS(finalKeyValueDS *root) {
- if(root == NULL) return;
-
- finalKeyValueDS *tempNode = root -> next;;
- while (tempNode != NULL){
- free(root);
- root = tempNode;
- tempNode = tempNode -> next;
- }
-}
-
-// reduce function
-void reduce(char *key) {
-
-}
-
-// write the contents of the final intermediate structure
-// to output/ReduceOut/Reduce_reducerID.txt
-void writeFinalDS(int reducerID){
-
-}
-
-int main(int argc, char *argv[]) {
-
- if(argc < 2){
- printf("Less number of arguments.\n");
- printf("./reducer reducerID");
- }
-
- // ###### DO NOT REMOVE ######
- // initialize
- int reducerID = strtol(argv[1], NULL, 10);
-
- // ###### DO NOT REMOVE ######
- // master will continuously send the word.txt files
- // alloted to the reducer
- char key[MAXKEYSZ];
- while(getInterData(key, reducerID))
- reduce(key);
-
- // You may write this logic. You can somehow store the
- // <key, value> count and write to Reduce_reducerID.txt file
- // So you may delete this function and add your logic
- writeFinalDS(reducerID);
-
- return 0;
-} \ No newline at end of file