Beispiel #1
0
 public ListAggregateConditionVariable(AggregationMode aggregation, Variable list, Comparison comparison, Variable value)
 {
     aggregationMode = aggregation;
     expectedList    = list;
     comparator      = new PrimitiveComparator(comparison);
     comparisonValue = value;
 }
 public AggregatedProfilerResult(string name, string units, AggregationMode mode)
 {
     Name       = name;
     Units      = units;
     Mode       = mode;
     RawResults = new List <double>();
 }
 public ProfilerResult(string name, double value, string units, AggregationMode aggregationType)
 {
     Name            = name;
     Value           = value;
     Units           = units;
     AggregationMode = aggregationType;
 }
Beispiel #4
0
        public static bool Evaluate(int count, int matches, AggregationMode aggregation)
        {
            switch (aggregation)
            {
            case AggregationMode.ALL: return(count > 0 && matches == count);

            case AggregationMode.ANY: return(matches > 0);

            case AggregationMode.NONE: return(matches == 0);

            default: throw new Exception("Unsupported Aggregation Mode");
            }
        }
Beispiel #5
0
        public static String getAggregationModeName(AggregationMode mode)
        {
            switch (mode)
            {
            case AggregationMode.ALL: return("All");

            case AggregationMode.ANY: return("Any");

            case AggregationMode.NONE: return("None");

            default: throw new Exception("Unsupported Aggregation Mode");
            }
        }
Beispiel #6
0
        private static string GetSQLAggregationFunction(AggregationMode mode)
        {
            switch (mode)
            {
            case AggregationMode.Max:
                return("Max");

            case AggregationMode.Min:
                return("Min");

            case AggregationMode.Sum:
                return("Sum");

            case AggregationMode.Avg:
                return("Avg");

            default:
                throw new ArgumentOutOfRangeException("Unknown AggregationMode");
            }
        }
Beispiel #7
0
 public AggregateConditionVariable(AggregationMode aggregationMode, BlockCondition blockCondition, EntityProvider entityProvider)
 {
     this.aggregationMode = aggregationMode;
     this.blockCondition  = blockCondition;
     this.entityProvider  = entityProvider;
 }
        public static List <SingleResult> GetAggregatedValues(TimeSeriesReader reader, RangeGroup rangeSpec, AggregationMode mode)
        {
            var aggStates = new TimeSeriesAggregation(mode); // we always will aggregate here by Min, Max, First, Last, Sum, Count, Mean
            var results   = new List <SingleResult>();

            foreach (var it in reader.SegmentsOrValues())
            {
                if (it.IndividualValues != null)
                {
                    AggregateIndividualItems(it.IndividualValues);
                }
                else
                {
                    //We might need to close the old aggregation range and start a new one
                    MaybeMoveToNextRange(it.Segment.Start);

                    // now we need to see if we can consume the whole segment, or
                    // if the range it cover needs to be broken up to multiple ranges.
                    // For example, if the segment covers 3 days, but we have group by 1 hour,
                    // we still have to deal with the individual values
                    if (it.Segment.End > rangeSpec.End)
                    {
                        AggregateIndividualItems(it.Segment.Values);
                    }
                    else
                    {
                        var span = it.Segment.Summary.SegmentValues.Span;
                        aggStates.Segment(span);
                    }
                }
            }

            if (aggStates.Any)
            {
                var result = new SingleResult
                {
                    Timestamp = rangeSpec.Start,
                    Values    = new Memory <double>(aggStates.Values.ToArray()),
                    Status    = TimeSeriesValuesSegment.Live,
                    Type      = SingleResultType.RolledUp
                                // TODO: Tag = ""
                };
                TimeSeriesStorage.AssertNoNanValue(result);
                results.Add(result);
            }

            return(results);

            void MaybeMoveToNextRange(DateTime ts)
            {
                if (rangeSpec.WithinRange(ts))
                {
                    return;
                }

                if (aggStates.Any)
                {
                    var result = new SingleResult
                    {
                        Timestamp = rangeSpec.Start,
                        Values    = new Memory <double>(aggStates.Values.ToArray()),
                        Status    = TimeSeriesValuesSegment.Live,
                        Type      = SingleResultType.RolledUp
                                    // TODO: Tag = ""
                    };
                    TimeSeriesStorage.AssertNoNanValue(result);
                    results.Add(result);
                }

                rangeSpec.MoveToNextRange(ts);
                aggStates.Init();
            }

            void AggregateIndividualItems(IEnumerable <SingleResult> items)
            {
                foreach (var cur in items)
                {
                    if (cur.Status == TimeSeriesValuesSegment.Dead)
                    {
                        continue;
                    }

                    MaybeMoveToNextRange(cur.Timestamp);

                    aggStates.Step(cur.Values.Span);
                }
            }
        }
            private void AggregateOnceByItem(AggregationType aggregation, int i, double val, AggregationMode mode)
            {
                switch (aggregation)
                {
                case AggregationType.Min:
                    if (double.IsNaN(Values[i]))
                    {
                        Values[i] = val;
                    }
                    else
                    {
                        Values[i] = Math.Min(Values[i], val);
                    }
                    break;

                case AggregationType.Max:
                    if (double.IsNaN(Values[i]))
                    {
                        Values[i] = val;
                    }
                    else
                    {
                        Values[i] = Math.Max(Values[i], val);
                    }
                    break;

                case AggregationType.Sum:
                case AggregationType.Average:
                    if (double.IsNaN(Values[i]))
                    {
                        Values[i] = 0;
                    }
                    Values[i] = Values[i] + val;
                    break;

                case AggregationType.First:
                    if (double.IsNaN(Values[i]))
                    {
                        Values[i] = val;
                    }
                    break;

                case AggregationType.Last:
                    Values[i] = val;
                    break;

                case AggregationType.Count:
                    if (double.IsNaN(Values[i]))
                    {
                        Values[i] = 0;
                    }

                    if (mode == AggregationMode.FromAggregated)
                    {
                        Values[i] += val;
                    }
                    else
                    {
                        Values[i]++;
                    }
                    break;

                default:
                    throw new ArgumentOutOfRangeException("Unknown aggregation operation: " + aggregation);
                }
            }
 public TimeSeriesAggregation(AggregationMode mode)
 {
     _mode  = mode;
     Values = new List <double>();
 }
Beispiel #11
0
 public TAggregate AggregateRowsInViewport <T, TAggregate>(IProjection <int, T> projection, AggregationMode aggregationMode)
 {
     return(default(TAggregate));
 }
Beispiel #12
0
 private static string GetColumnName(AggregationMode mode)
 {
     return(mode.Description());
 }
        private static Microsoft.Performance.SDK.Processing.AggregationMode ConvertToSdk(this AggregationMode dtoEnum)
        {
            switch (dtoEnum)
            {
            case AggregationMode.None:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.None);

            case AggregationMode.Average:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Average);

            case AggregationMode.Sum:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Sum);

            case AggregationMode.Count:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Count);

            case AggregationMode.Min:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Min);

            case AggregationMode.Max:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Max);

            case AggregationMode.UniqueCount:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.UniqueCount);

            case AggregationMode.Peak:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.Peak);

            case AggregationMode.WeightedAverage:
                return(Microsoft.Performance.SDK.Processing.AggregationMode.WeightedAverage);

            default:
                //Looks like an unsupported version of the DTO, we shouldn't have got here
                throw new InvalidOperationException();
            }
        }