Пример #1
0
        protected virtual Report ReportSumByPrefixRound(IList <TaskStats> taskStats)
        {
            // aggregate by task name and by round
            int reported = 0;
            LinkedHashMap <string, TaskStats> p2 = new LinkedHashMap <string, TaskStats>();

            foreach (TaskStats stat1 in taskStats)
            {
                if (stat1.Elapsed >= 0 && stat1.Task.GetName().StartsWith(m_prefix, StringComparison.Ordinal))
                { // only ended tasks with proper name
                    reported++;
                    string    name  = stat1.Task.GetName();
                    string    rname = stat1.Round + "." + name; // group by round
                    TaskStats stat2;
                    if (!p2.TryGetValue(rname, out stat2) || stat2 == null)
                    {
                        stat2 = (TaskStats)stat1.Clone();

                        p2[rname] = stat2;
                    }
                    else
                    {
                        stat2.Add(stat1);
                    }
                }
            }
            // now generate report from secondary list p2
            return(GenPartialReport(reported, p2, taskStats.Count));
        }
Пример #2
0
        /// <summary>
        /// Report statistics as a string, aggregate for tasks named the same.
        /// </summary>
        /// <param name="taskStats"></param>
        /// <returns>The report.</returns>
        protected virtual Report ReportSumByName(IList <TaskStats> taskStats)
        {
            // aggregate by task name
            int reported = 0;
            LinkedHashMap <string, TaskStats> p2 = new LinkedHashMap <string, TaskStats>();

            foreach (TaskStats stat1 in taskStats)
            {
                if (stat1.Elapsed >= 0)
                { // consider only tasks that ended
                    reported++;
                    string    name = stat1.Task.GetName();
                    TaskStats stat2;
                    if (!p2.TryGetValue(name, out stat2) || stat2 == null)
                    {
                        stat2    = (TaskStats)stat1.Clone();
                        p2[name] = stat2;
                    }
                    else
                    {
                        stat2.Add(stat1);
                    }
                }
            }
            // now generate report from secondary list p2
            return(GenPartialReport(reported, p2, taskStats.Count));
        }
Пример #3
0
        /**
         * Get {@code #} labels. The keys of the map are the labels applied to outer
         * alternatives of a lexer rule, and the values are collections of pairs
         * (alternative number and {@link AltAST}) identifying the alternatives with
         * this label. Unlabeled alternatives are not included in the result.
         */
        public virtual IDictionary <string, IList <System.Tuple <int, AltAST> > > GetAltLabels()
        {
            IDictionary <string, IList <System.Tuple <int, AltAST> > > labels = new LinkedHashMap <string, IList <System.Tuple <int, AltAST> > >();

            for (int i = 1; i <= numberOfAlts; i++)
            {
                GrammarAST altLabel = alt[i].ast.altLabel;
                if (altLabel != null)
                {
                    IList <System.Tuple <int, AltAST> > list;
                    if (!labels.TryGetValue(altLabel.Text, out list) || list == null)
                    {
                        list = new List <System.Tuple <int, AltAST> >();
                        labels[altLabel.Text] = list;
                    }

                    list.Add(Tuple.Create(i, alt[i].ast));
                }
            }
            if (labels.Count == 0)
            {
                return(null);
            }
            return(labels);
        }
        public Object EvaluateEnumMethod(EventBean[] eventsLambda, ICollection <object> target, bool isNewData, ExprEvaluatorContext context)
        {
            var items  = new LinkedHashMap <Object, int?>();
            var values = target;

            var resultEvent = new ObjectArrayEventBean(new Object[1], _resultEventType);

            foreach (Object next in values)
            {
                resultEvent.Properties[0]     = next;
                eventsLambda[StreamNumLambda] = resultEvent;

                var item = InnerExpression.Evaluate(new EvaluateParams(eventsLambda, isNewData, context));

                int?existing;
                if (!items.TryGetValue(item, out existing))
                {
                    existing = 1;
                }
                else
                {
                    existing++;
                }
                items.Put(item, existing);
            }

            return(EnumEvalMostLeastFrequentEvent.GetResult(items, _isMostFrequent));
        }
Пример #5
0
        public virtual Attribute Get(string name)
        {
            Attribute result;

            if (!attributes.TryGetValue(name, out result))
            {
                return(null);
            }

            return(result);
        }
Пример #6
0
        public void ApplyEnter(EventBean[] eventsPerStream)
        {
            EventBean theEvent = eventsPerStream[streamId];

            if (theEvent == null)
            {
                return;
            }
            _array = null;

            int value;

            if (!refSet.TryGetValue(theEvent, out value))
            {
                refSet.Put(theEvent, 1);
                return;
            }

            value++;
            refSet.Put(theEvent, value);
        }
Пример #7
0
            public bool TryGetValue(string key, out string value)
            {
                string    dataKey = Attributes.DataKey(key);
                Attribute attr    = null;

                if (enclosingAttributes.TryGetValue(dataKey, out attr))
                {
                    value = attr.Value;
                    return(true);
                }
                value = null;
                return(false);
            }
Пример #8
0
        public virtual ISymbol Resolve(string name)
        {
            symbols.TryGetValue(name, out ISymbol s);
            if (s != null)
            {
                return(s);
            }
            if (Linker != null)
            {
                s = Linker.Resolve(this.ToQualifierString("."), name);
            }
            if (s != null)
            {
                return(s);
            }
            // if not here, check any enclosing scope
            IScope parent = GetEnclosingScope();

            if (parent != null)
            {
                return(parent.Resolve(name));
            }
            return(null); // not found
        }
Пример #9
0
        /**
         * Get {@code #} labels. The keys of the map are the labels applied to outer
         * alternatives of a lexer rule, and the values are collections of pairs
         * (alternative number and {@link AltAST}) identifying the alternatives with
         * this label. Unlabeled alternatives are not included in the result.
         */
        public virtual IDictionary<string, IList<System.Tuple<int, AltAST>>> GetAltLabels()
        {
            IDictionary<string, IList<System.Tuple<int, AltAST>>> labels = new LinkedHashMap<string, IList<System.Tuple<int, AltAST>>>();
            for (int i = 1; i <= numberOfAlts; i++)
            {
                GrammarAST altLabel = alt[i].ast.altLabel;
                if (altLabel != null)
                {
                    IList<System.Tuple<int, AltAST>> list;
                    if (!labels.TryGetValue(altLabel.Text, out list) || list == null)
                    {
                        list = new List<System.Tuple<int, AltAST>>();
                        labels[altLabel.Text] = list;
                    }

                    list.Add(Tuple.Create(i, alt[i].ast));
                }
            }
            if (labels.Count == 0)
                return null;
            return labels;
        }