Пример #1
0
        private TAggregator?GetAggregatorSlow(ReadOnlySpan <KeyValuePair <string, object?> > labels)
        {
            AggregatorLookupFunc <TAggregator> lookupFunc = LabelInstructionCompiler.Create(ref this, _createAggregatorFunc, labels);

            _cachedLookupFunc = lookupFunc;
            bool match = lookupFunc(labels, out TAggregator? aggregator);

            Debug.Assert(match);
            return(aggregator);
        }
Пример #2
0
        public TAggregator?GetAggregator(ReadOnlySpan <KeyValuePair <string, object?> > labels)
        {
            AggregatorLookupFunc <TAggregator>?lookupFunc = _cachedLookupFunc;

            if (lookupFunc != null)
            {
                if (lookupFunc(labels, out TAggregator? aggregator))
                {
                    return(aggregator);
                }
            }

            // slow path, label names have changed from what the lookupFunc cached so we need to
            // rebuild it
            return(GetAggregatorSlow(labels));
        }
Пример #3
0
 public AggregatorStore(Func <TAggregator?> createAggregator)
 {
     _stateUnion           = null;
     _cachedLookupFunc     = null;
     _createAggregatorFunc = createAggregator;
 }