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); }
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)); }
public AggregatorStore(Func <TAggregator?> createAggregator) { _stateUnion = null; _cachedLookupFunc = null; _createAggregatorFunc = createAggregator; }