???C#????MapReduce
???????????? ???????[ 2015/5/25 11:24:13 ] ???????????????
?????????????????????????????С????????? (???????????????)??
?????????????С?????????????????
????С??ο?MapReduce???????Map??Reduce???£?
????Map???
????Mapping
????Mapping???????????????key??value?????С???????<????????????(1)>??<word??1>??
????public IEnumerable<Tuple<T?? int>> Mapping(IEnumerable<T> list)
????{
????foreach (T sourceVal in list)
????yield return Tuple.Create(sourceVal?? 1);
????}
????????????(brow?? 1)?? (brow?? 1)?? (sorrow?? 1)?? (sorrow?? 1):
????var spit = hamlet.Split(new[] { " "?? Environment.NewLine }?? StringSplitOptions.RemoveEmptyEntries);
????var mp = new MicroMapReduce<string>(new Master<string>());
????var result= mp.Mapping(spit);
????Combine
??????????????????????mapping???????????????????????reduce??????????????????????????????????????????????????????? ???????(brow?? 2)?? (sorrow?? 2):
public Dictionary<T?? int> Combine(IEnumerable<Tuple<T?? int>> list)
{
Dictionary<T?? int> dt = new Dictionary<T?? int>();
foreach (var val in list)
{
if (dt.ContainsKey(val.Item1))
dt[val.Item1] += val.Item2;
else
dt.Add(val.Item1?? val.Item2);
}
return dt;
}
????Partitioner
????Partitioner??????????黮?????????????????????key???з??顣
??????????????? (brow?? {(brow??2)}??(brow??3))?? (sorrow?? {(sorrow??10)}??(brow??11)):
????public IEnumerable<Group<T?? int>> Partitioner(Dictionary<T?? int> list)
????{
????var dict = new Dictionary<T?? Group<T?? int>>();
????foreach (var val in list)
????{
????if (!dict.ContainsKey(val.Key))
????dict[val.Key] = new Group<T?? int>(val.Key);
????dict[val.Key].Values.Add(val.Value);
????}
????return dict.Values;
????}
????Group????:
public class Group<TKey?? TValue> : Tuple<TKey?? List<TValue>>
{
public Group(TKey key)
: base(key?? new List<TValue>())
{
}
public TKey Key
{
get
{
return base.Item1;
}
}
public List<TValue> Values
{
get
{
return base.Item2;
}
}
}
????Reduce???
????Reducing?????????????????????к????????
????public Dictionary<T?? int> Reducing(IEnumerable<Group<T?? int>> groups)
????{
????Dictionary<T?? int> result=new Dictionary<T?? int>();
????foreach (var sourceVal in groups)
????{
????result.Add(sourceVal.Key?? sourceVal.Values.Sum());
????}
????return result;
????}
??????????????£?
????public IEnumerable<Group<T?? int>> Map(IEnumerable<T> list)
????{
????var step1 = Mapping(list);
????var step2 = Combine(step1);
????var step3 = Partitioner(step2);
????return step3;
????}
????public Dictionary<T?? int> Reduce(IEnumerable<Group<T?? int>> groups)
????{
????var step1 = Reducing(groups);
????return step1;
????}
????public Dictionary<T?? int> MapReduce(IEnumerable<T> list)
????{
????var map = Map(list);
????var reduce = Reduce(map);
????return reduce;
????}
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???????C#?е?StringC# Socket???????????????????C#?????????????????????????C#???????C#????????????Log4net??????δ????C#?????????????C#?????????????????C#???????????????C#????????????????C#7 ?е?Tuple??????C#??TypeScript - GeneratorC# ?????????細(xì)??????????C#?е???н???C#??MySQL?????????μ??Ч?????д??C#????C++??dll???C#??VS2010????е??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????