예제 #1
0
        public Aggregator()
        {
            reduceResult = new ReduceResult();

            Receive<ReduceResult>(r => Aggregate(r));
            Receive<GetResult>(_ => Sender.Tell(reduceResult));
        }
예제 #2
0
        private void Aggregate(ReduceResult result)
        {
            foreach (var language in result.Result.Keys)
            {
                if (reduceResult.Result.ContainsKey(language))
                {
                    reduceResult.Result[language] += result.Result[language];
                }
                else
                {
                    reduceResult.Result[language] = result.Result[language];
                }
            }

            Console.WriteLine("Aggregator: {0}", reduceResult);
        }
예제 #3
0
        private void Reduce(MapResult mapResult)
        {
            var reduceResult = new ReduceResult();

            foreach (var count in mapResult.Counts)
            {
                if (reduceResult.Result.ContainsKey(count.Language))
                {
                    reduceResult.Result[count.Language] += count.Count;
                }
                else
                {
                    reduceResult.Result[count.Language] = count.Count;
                }
            }

            Console.WriteLine("Reducer [{0}/{1}]: {2}",
                Self.Path.Name, Thread.CurrentThread.ManagedThreadId, reduceResult);

            // simulate some runtime...
            Thread.Sleep(100);

            Sender.Tell(reduceResult);
        }