// Does a count on the collection for the struct that is passed in.
186339
func Count(i interface{}) (int, error) {
	s, err := GetSession()
	if err != nil {
		return 0, err
	}
	defer s.Close()

	coll := GetColl(s, typeName(i))

	return coll.Count()
}
135713
func (c *expvarStatsClient) Count(name string, value int64, rate float64) {
	c.m.Add(name, value)
}
238652
func Count(o interface{}) int {
	if o == nil {
		return 0
	}

	if cnt, ok := o.(iseq.Counted); ok {
		return cnt.Count1()
	}

	if pc, ok := o.(iseq.PCollection); ok {
		s := pc.Seq()
		i := 0
		for ; s != nil; s = s.Next() {
			if c, ok := s.(iseq.Counted); ok {
				return i + c.Count1()
			}
			i++
		}
		return i
	}

	if s, ok := o.(string); ok {
		return len(s)
	}
	// TODO: Figure out how to  handle arrays, slices, maps in a typeswitch/generic way
	panic("Count not supported on this type")
}
168143
func (a MultiStatsClient) Count(name string, value int64, rate float64) {
	for _, c := range a {
		c.Count(name, value, rate)
	}
}
1141802
func (p *pathObject) Count() (int64, error) {
	it := p.buildIteratorTree()
	return p.s.countResults(it)
}
143391
func (cb *CountBytes) Count() int {
	cb.mu.Lock()
	defer cb.mu.Unlock()
	return cb.count
}
251521
func count(s string, b byte) int {
	n := 0
	for i := 0; i < len(s); i++ {
		if s[i] == b {
			n++
		}
	}
	return n
}
114189
func (association *Association) Count() int {
	var (
		count        = 0
		relationship = association.field.Relationship
		scope        = association.scope
		fieldValue   = association.field.Field.Interface()
		query        = scope.DB()
	)

	switch relationship.Kind {
	case "many_to_many":
		query = relationship.JoinTableHandler.JoinWith(relationship.JoinTableHandler, query, scope.Value)
	case "has_many", "has_one":
		primaryKeys := scope.getColumnAsArray(relationship.AssociationForeignFieldNames, scope.Value)
		query = query.Where(
			fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relationship.ForeignDBNames), toQueryMarks(primaryKeys)),
			toQueryValues(primaryKeys)...,
		)
	case "belongs_to":
		primaryKeys := scope.getColumnAsArray(relationship.ForeignFieldNames, scope.Value)
		query = query.Where(
			fmt.Sprintf("%v IN (%v)", toQueryCondition(scope, relationship.AssociationForeignDBNames), toQueryMarks(primaryKeys)),
			toQueryValues(primaryKeys)...,
		)
	}

	if relationship.PolymorphicType != "" {
		query = query.Where(
			fmt.Sprintf("%v.%v = ?", scope.New(fieldValue).QuotedTableName(), scope.Quote(relationship.PolymorphicDBName)),
			relationship.PolymorphicValue,
		)
	}

	if err := query.Model(fieldValue).Count(&count).Error; err != nil {
		association.Error = err
	}
	return count
}
278359
func (s *sender) Count(stat string, count float64, tags ...string) {
	s.Called(stat, count, tags)
}
869925
func Count(w http.ResponseWriter, r *http.Request) {
	w.Header().Set("Cache-Control", "must-revalidate")
	w.Header().Set("Content-Type", "text/plain")
	w.Header().Set("Access-Control-Allow-Origin", "*")
	w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS")
	var col, q string
	if !Require(w, r, "col", &col) {
		return
	}
	if !Require(w, r, "q", &q) {
		return
	}
	var qJson interface{}
	if err := json.Unmarshal([]byte(q), &qJson); err != nil {
		http.Error(w, fmt.Sprintf("'%v' is not valid JSON.", q), 400)
		return
	}
	dbcol := HttpDB.Use(col)
	if dbcol == nil {
		http.Error(w, fmt.Sprintf("Collection '%s' does not exist.", col), 400)
		return
	}
	queryResult := make(map[int]struct{})
	if err := db.EvalQuery(qJson, dbcol, &queryResult); err != nil {
		http.Error(w, fmt.Sprint(err), 400)
		return
	}
	w.Write([]byte(strconv.Itoa(len(queryResult))))
}
1018164
func (c *Counters) Counts() map[string]int64 {
	c.mu.Lock()
	defer c.mu.Unlock()

	counts := make(map[string]int64, len(c.counts))
	for k, v := range c.counts {
		counts[k] = v
	}
	return counts
}
420584
func (h *Histogram) Count() (count int64) {
	for i := range h.buckets {
		count += h.buckets[i].Get()
	}
	return
}
792818
func (r *GormWorkItemRepository) Count(ctx context.Context, spaceID uuid.UUID, criteria criteria.Expression) (int, error) {
	defer goa.MeasureSince([]string{"goa", "db", "workitem", "count"}, time.Now())

	where, parameters, joins, compileError := Compile(criteria)
	if compileError != nil {
		return 0, errors.NewBadParameterError("expression", criteria)
	}
	where = where + " AND space_id = ?"
	parameters = append(parameters, spaceID)

	var count int
	db := r.db.Model(&WorkItemStorage{}).Where(where, parameters...)
	for _, j := range joins {
		if err := j.Validate(db); err != nil {
			log.Error(ctx, map[string]interface{}{"expression": criteria, "err": err}, "table join not valid")
			return 0, errors.NewBadParameterError("expression", criteria).Expected("valid table join")
		}
		db = db.Joins(j.GetJoinExpression())
	}
	db = db.Count(&count)
	if db.Error != nil {
		return 0, errors.NewInternalError(ctx, errs.Wrapf(db.Error, "failed to count work items that match this criteria: %s", criteria))
	}
	return count, nil
}
250330
func (f Index) Count() (count int, err error) {
	it := f.db.NewIterator()
	defer it.Release()

	for ok := it.Seek(f.prefix); ok; ok = it.Next() {
		key := it.Key()
		if key[0] != f.prefix[0] {
			break
		}
		count++
	}
	return count, it.Error()
}
223551
func (s *Storage) Count(project types.ProjectName, path types.StreamPath) (c int) {
	s.run(func() error {
		if st := s.getLogStreamLocked(project, path, false); st != nil {
			c = len(st.logs)
		}
		return nil
	})
	return
}
1242203
func (kv *KV) Count() (i int) {
	kv.db.View(func(txn *badger.Txn) error {
		opts := badger.DefaultIteratorOptions
		opts.PrefetchValues = false
		it := txn.NewIterator(opts)
		for it.Rewind(); it.Valid(); it.Next() {
			i++
		}
		it.Close()
		return nil
	})
	return
}
984279
func (t *txLookup) Count() int {
	t.lock.RLock()
	defer t.lock.RUnlock()

	return len(t.all)
}