示例#1
0
        public void GroupedMapReduce()
        {
            var query = testTable.GroupedMapReduce(
                to => to.Name,                                    // group
                to => 1.0,                                        // map
                (leftCount, rightCount) => leftCount + rightCount // reduce
                );

            int count = 0;

            foreach (var record in connection.Run(query))
            {
                var groupName   = record.Item1;
                var reduceCount = record.Item2;

                switch (groupName)
                {
                case "1":
                case "3":
                case "6":
                    Assert.That(reduceCount, Is.EqualTo(2));
                    break;

                case "2":
                    Assert.That(reduceCount, Is.EqualTo(3));
                    break;

                case "4":
                case "5":
                case "7":
                    Assert.That(reduceCount, Is.EqualTo(1));
                    break;
                }

                ++count;
            }

            Assert.That(count, Is.EqualTo(7));
        }