private IEnumerable <IGrouping <CounterGroup, UniversalValue> > GroupCounters(IEnumerable <LogEventArgs> input) { return(input.GroupBy(k => CreateCounterGroupByMask("111", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value)) .Concat( input.GroupBy(k => CreateCounterGroupByMask("001", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value))) .Concat( input.GroupBy(k => CreateCounterGroupByMask("101", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value))) .Concat( input.GroupBy(k => CreateCounterGroupByMask("010", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value))) .Concat( input.GroupBy(k => CreateCounterGroupByMask("110", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value))) .Concat( input.GroupBy(k => CreateCounterGroupByMask("100", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value))) .Concat( input.GroupBy(k => CreateCounterGroupByMask("000", k), k => UniversalValue.ParseFromString(InputType, k.LogEvent.Value)))); }
public CounterAggregator(string counterCategory, string counterName, AggregationType aggregationType, Type inputType, string percentileAndDistributionParameters) { if (String.IsNullOrEmpty(counterCategory) || String.IsNullOrEmpty(counterName)) { throw new ArgumentException("counterCategory and counterName must not be empty"); } switch (aggregationType) { case AggregationType.Percentile: { _percentileParameters = percentileAndDistributionParameters.Split('|').Select(Double.Parse).ToList(); break; } case AggregationType.ValueDistributionGroups: { var t1 = percentileAndDistributionParameters.Split('|'); if (t1.All(t => t.Contains("-"))) { _distributionParameters = t1.Select( t => new Tuple <UniversalValue, UniversalValue>( UniversalValue.ParseFromString(inputType, t.Split('-')[0]), UniversalValue.ParseFromString(inputType, t.Split('-')[1]))).ToList(); } else { _distributionParameters = FromListToGroup(t1.Select(t => UniversalValue.ParseFromString(inputType, t)).ToList()); } break; } } //_percentileParameters = new List<double>() { 25, 50, 75 }; CounterCategory = counterCategory; CounterName = counterName; AggregationType = aggregationType; EventSelector = CreateEventSelector(); AggregationAction = CreateAggregationAction(); InputType = inputType; _onResult = OnResult(); }
public DistributionGroupAggregationOperation(Type valuesDataType, string parameters) { _valuesDataType = UniversalValue.UniversalClassTypeByType(valuesDataType); var boundaries = parameters.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Select(t => UniversalValue.ParseFromString(valuesDataType, t)).ToList(); if (boundaries.Count == 0) { throw new Exception("boundaries list is empty"); } List <DistributionGroup> distributionGroups = new List <DistributionGroup>(); UniversalValue minBound, maxBound; switch (_valuesDataType) { case UniversalValue.UniversalClassType.Numeric: minBound = new UniversalValue(Double.MinValue); maxBound = new UniversalValue(Double.MaxValue); break; case UniversalValue.UniversalClassType.TimeSpan: minBound = new UniversalValue(TimeSpan.MinValue); maxBound = new UniversalValue(TimeSpan.MaxValue); break; default: throw new Exception("Type " + _valuesDataType + " not supported for interval distribution groupping"); } distributionGroups.Add(new DistributionGroup(minBound, boundaries.First())); for (int i = 0; i < boundaries.Count - 1; i++) { distributionGroups.Add(new DistributionGroup(boundaries[i], boundaries[i + 1])); } distributionGroups.Add(new DistributionGroup(boundaries.Last(), maxBound)); _distributionGroups = distributionGroups; }
private IEnumerable <IGrouping <CounterGroup, UniversalValue> > GroupCounters(IEnumerable <LogEvent> input) { var groups = new List <CounterGroup.GroupBy>() { CounterGroup.GroupBy.NoGrpopping, CounterGroup.GroupBy.Source, CounterGroup.GroupBy.Instance, CounterGroup.GroupBy.ExtendedData, CounterGroup.GroupBy.Source | CounterGroup.GroupBy.Instance, CounterGroup.GroupBy.Source | CounterGroup.GroupBy.ExtendedData, CounterGroup.GroupBy.Instance | CounterGroup.GroupBy.ExtendedData, CounterGroup.GroupBy.Source | CounterGroup.GroupBy.Instance | CounterGroup.GroupBy.ExtendedData }; IEnumerable <IGrouping <CounterGroup, UniversalValue> > result = groups.SelectMany(group => input.GroupBy(logEvent => CreateCounterGroup(group, logEvent), logEvent => UniversalValue.ParseFromString(_valuesDataType, logEvent.Value))); return(result); }