// CreateAggregateFromMessageCountMap converts MessageCountMap Aggregate
764035
func CreateAggregateFromMessageCountMap(m MessageCountMap) Aggregate {
	if m == nil {
		return nil
	}
	result := make([]error, 0, len(m))
	for errStr, count := range m {
		var countStr string
		if count > 1 {
			countStr = fmt.Sprintf(" (repeated %v times)", count)
		}
		result = append(result, fmt.Errorf("%v%v", errStr, countStr))
	}
	return NewAggregate(result)
}
244509
func (ar AggregatedSendResult) AckCount() int {
	c := 0
	for _, ack := range ar {
		if ack.error == nil {
			c++
		}
	}
	return c
}
368735
func NewMessageSentSizeStatsHandler(sub Subsystem, vec *prometheus.HistogramVec) *MessageSentSizeStatsHandler {
	return &MessageSentSizeStatsHandler{
		baseStatsHandler: baseStatsHandler{
			subsystem: sub,
			collector: vec,
		},
		vec: vec,
	}
}
717987
func MatchAggregate(t AggregateType) EventMatcher {
	return func(e Event) bool {
		return e != nil && e.AggregateType() == t
	}
}
580729
func NewEventAggregator(lruCacheSize int, keyFunc EventAggregatorKeyFunc, messageFunc EventAggregatorMessageFunc,
	maxEvents int, maxIntervalInSeconds int, clock clock.Clock) *EventAggregator {
	return &EventAggregator{
		cache:                lru.New(lruCacheSize),
		keyFunc:              keyFunc,
		messageFunc:          messageFunc,
		maxEvents:            uint(maxEvents),
		maxIntervalInSeconds: uint(maxIntervalInSeconds),
		clock:                clock,
	}
}
937024
func (r *RecordAccess) SubAggregateQuery(query *Query, groupBy ...string) ([]*AggregateResult, error) {
	return aggregateQuery(r.tx, r.record, query, groupBy...)
}
685301
func NewMessage() *Message {
	return &Message{
		payload: lane.NewStack(),
		Reports: lane.NewStack(),
		Opts:    cmap.New(),
	}
}
933030
func AppendStatsAggregate(a, b StatsAggregate) (aggregate StatsAggregate) {
	if (a.Count == 0) {
		return b
	}

	if (b.Count == 0) {
		return a
	}

	aggregate.Average = ( (a.Average * float64(a.Count)) + (b.Average * float64(b.Count)) ) / float64(a.Count + b.Count)
	aggregate.Min     = math.Min(a.Min, b.Min)
	aggregate.Max     = math.Max(a.Max, b.Max)
	aggregate.Count   = a.Count + b.Count
	return
}
1257301
func (_m *FacadeInterface) GetAggregateServices(ctx datastore.Context, since time.Time, serviceids []string) ([]service.AggregateService, error) {
	ret := _m.Called(ctx, since, serviceids)

	var r0 []service.AggregateService
	if rf, ok := ret.Get(0).(func(datastore.Context, time.Time, []string) []service.AggregateService); ok {
		r0 = rf(ctx, since, serviceids)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]service.AggregateService)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(datastore.Context, time.Time, []string) error); ok {
		r1 = rf(ctx, since, serviceids)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1193970
func NewLogAggregatorDecorator(
	kinesisResource *gocf.KinesisStream,
	kinesisMapping *sparta.EventSourceMapping,
	relay *sparta.LambdaAWSInfo) *LogAggregatorDecorator {

	return &LogAggregatorDecorator{
		kinesisStreamResourceName: logAggregatorResName("Kinesis"),
		kinesisResource:           kinesisResource,
		kinesisMapping:            kinesisMapping,
		iamRoleNameResourceName:   logAggregatorResName("IAMRole"),
		logRelay:                  relay,
	}
}
562252
func NewAggregationController(downloader *aggregator.Downloader, openAPIAggregationManager aggregator.SpecAggregator) *AggregationController {
	c := &AggregationController{
		openAPIAggregationManager: openAPIAggregationManager,
		queue: workqueue.NewNamedRateLimitingQueue(
			workqueue.NewItemExponentialFailureRateLimiter(successfulUpdateDelay, failedUpdateMaxExpDelay), "APIServiceOpenAPIAggregationControllerQueue1"),
		downloader: downloader,
	}

	c.syncHandler = c.sync

	// update each service at least once, also those which are not coming from APIServices, namely local services
	for _, name := range openAPIAggregationManager.GetAPIServiceNames() {
		c.queue.AddAfter(name, time.Second)
	}

	return c
}
433327
func MessageConversion(vals []interface{}) []schema.Message {
	msgs := make([]schema.Message, len(vals))
	for i, v := range vals {
		msgs[i] = v.(schema.Message)
	}
	return msgs
}
1219961
func (o *MultiCastChannelMap) CreateMultiCastRange(child *MultiCastRange) *bambou.Error {

	return bambou.CurrentSession().CreateChild(o, child)
}
1190188
func NewMessageImagemapAction(text string, area ImagemapArea) *MessageImagemapAction {
	return &MessageImagemapAction{
		Text: text,
		Area: area,
	}
}
822840
func (tm intInterfaceMap) PackMap(buf BufferEx) (int, error) {
	size := 0
	for k, v := range tm {
		n, err := PackInt64(buf, int64(k))
		size += n
		if err != nil {
			return size, err
		}

		n, err = packObject(buf, v, false)
		size += n
		if err != nil {
			return size, err
		}
	}
	return size, nil
}
52920
func (tc *TabletStatsCache) GetAggregateStats(target *querypb.Target) (*querypb.AggregateStats, error) {
	e := tc.getEntry(target.Keyspace, target.Shard, target.TabletType)
	if e == nil {
		return nil, topo.NewError(topo.NoNode, topotools.TargetIdent(target))
	}

	e.mu.RLock()
	defer e.mu.RUnlock()
	if target.TabletType == topodatapb.TabletType_MASTER {
		if len(e.aggregates) == 0 {
			return nil, topo.NewError(topo.NoNode, topotools.TargetIdent(target))
		}
		for _, agg := range e.aggregates {
			return agg, nil
		}
	}
	targetAlias := tc.getAliasByCell(target.Cell)
	agg, ok := e.aggregates[targetAlias]
	if !ok {
		return nil, topo.NewError(topo.NoNode, topotools.TargetIdent(target))
	}
	return agg, nil
}
181656
func NewEventForAggregate(eventType EventType, data EventData, timestamp time.Time,
	aggregateType AggregateType, aggregateID uuid.UUID, version int) Event {
	return event{
		eventType:     eventType,
		data:          data,
		timestamp:     timestamp,
		aggregateType: aggregateType,
		aggregateID:   aggregateID,
		version:       version,
	}
}