/// <summary> /// Records with the same Key are consolidated into a single record using /// this method. /// </summary> /// <param name="record"></param> public void ReduceData(IReducableRecord record) { DataRecord localRecord = (DataRecord)record; MemoryStream stream = new MemoryStream(localRecord.Data); Dictionary<string, int> edgeRecord = Serializer.Deserialize(stream); Dictionary<string, int>.Enumerator iter = edgeRecord.GetEnumerator(); while (iter.MoveNext()) { if (Value.ContainsKey(iter.Current.Key)) { Value[iter.Current.Key] += iter.Current.Value; } else { Value.Add(iter.Current.Key, iter.Current.Value); } } }
/// <summary> /// This method performs reduction for a string record. The string data /// of the two records are appended. /// </summary> /// <param name="record">Record to be reduced with.</param> public void ReduceData(IReducableRecord record) { StringRecord inRecord = (StringRecord)record; Value += inRecord.Value; }
/// <summary> /// Method used to reduce CountRecords. /// </summary> /// <param name="record">Record to be reduced.</param> public void ReduceData(IReducableRecord record) { Count += ((CountRecord)record).Count; }