예제 #1
0
        private static void Foo(object data)
        {
            MapReduceService.ServiceClient ser  = new MapReduceService.ServiceClient();
            Tuple <int, String[]>          temp = (Tuple <int, String[]>)data;

            threadResults[temp.Item1] = ser.MapReduce(temp.Item2);
            ser.Close();
        }
예제 #2
0
        async Task <Dictionary <string, int> > getCombined(List <Dictionary <string, int> > reduced)
        {
            MapReduceService.ServiceClient ser = new MapReduceService.ServiceClient();

            Dictionary <string, int> result = await ser.CombineAsync(reduced.ToArray());

            Debug.WriteLine("Combining Done");
            ser.Close();
            return(result);
        }
예제 #3
0
        /*
         *
         * All of this down here is old and a testament to my stupidity, just look at some of those return values
         *
         */



        async Task <List <List <Tuple <string, int> > > > getMapping(List <String[]> dividedWords)
        {
            MapReduceService.ServiceClient ser = new MapReduceService.ServiceClient();

            //start all tasks in parallel
            List <Task <Tuple <string, int>[]> > mappings = new List <Task <Tuple <string, int>[]> >();

            for (int i = 0; i < dividedWords.Count(); i++)
            {
                Debug.WriteLine("Starting strange task");
                Task <Tuple <string, int>[]> temp = Task <Tuple <string, int>[]> .Factory.StartNew(() => ser.Map(dividedWords[i]));

                Debug.WriteLine("Ending strange task and adding");
                mappings.Add(temp);
                Debug.WriteLine("Adding");
                //Debug.WriteLine("Starting Async Map");
                //mappings.Add(ser.MapAsync(dividedWords[i]));
            }

            //wait for all tasks to finish
            List <List <Tuple <string, int> > > result = new List <List <Tuple <string, int> > >();

            for (int i = 0; i < mappings.Count(); i++)
            {
                Debug.WriteLine("About to await");
                var temp = mappings[i].Result;
                Debug.WriteLine("Awaited");
                List <Tuple <string, int> > res = new List <Tuple <string, int> >();
                for (int j = 0; j < temp.Length; j++)
                {
                    res.Add(temp[j]);
                }

                result.Add(res);
                Debug.WriteLine("Added one map");
            }
            Debug.WriteLine("Mapping Done");

            ser.Close();
            return(result);
        }
예제 #4
0
        async Task <List <Dictionary <string, int> > > getReduced(List <List <Tuple <string, int> > > mapped)
        {
            MapReduceService.ServiceClient ser = new MapReduceService.ServiceClient();

            //start all tasks in parallel
            List <Task <Dictionary <string, int> > > reducings = new List <Task <Dictionary <string, int> > >();

            for (int i = 0; i < mapped.Count(); i++)
            {
                reducings.Add(ser.ReduceAsync(mapped[i].ToArray()));
            }

            List <Dictionary <string, int> > result = new List <Dictionary <string, int> >();

            for (int i = 0; i < reducings.Count(); i++)
            {
                result.Add(await reducings[i]);
            }
            Debug.WriteLine("Reducing Done");
            ser.Close();
            return(result);
        }