// Count returns the number of duplicates for the current key.
//
// See mdb_cursor_count.
514739
func (c *Cursor) Count() (uint64, error) {
	var _size C.size_t
	ret := C.mdb_cursor_count(c._c, &_size)
	if ret != success {
		return 0, operrno("mdb_cursor_count", ret)
	}
	return uint64(_size), nil
}
1119703
func (session *Session) Count(bean interface{}) (int64, error) {
	defer session.resetStatement()
	if session.IsAutoClose {
		defer session.Close()
	}

	var sqlStr string
	var args []interface{}
	if session.Statement.RawSQL == "" {
		sqlStr, args = session.Statement.genCountSQL(bean)
	} else {
		sqlStr = session.Statement.RawSQL
		args = session.Statement.RawParams
	}

	session.queryPreprocess(&sqlStr, args...)

	var err error
	var total int64
	if session.IsAutoCommit {
		err = session.DB().QueryRow(sqlStr, args...).Scan(&total)
	} else {
		err = session.Tx.QueryRow(sqlStr, args...).Scan(&total)
	}
	if err != nil {
		return 0, err
	}

	return total, nil
}
503259
func (kv *KV) Count() (i int) {
	iter := kv.db.NewIterator(nil, nil)
	for iter.Next() {
		i++
	}
	iter.Release()
	return
}
389560
func (kv *KV) Count() (i int) {
	kv.db.View(func(tx *buntdb.Tx) error {
		err := tx.Ascend("", func(key, value string) bool {
			i++
			return true
		})
		return err
	})
	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
}
835657
func (op *op) count() int {
	switch op.typ {
	case 0, 1:
		return 1
	case 2, 3:
		return len(op.values)
	default:
		panic(fmt.Sprintf("unknown operation type: %d", op.typ))
	}
}
356671
func (kv *KV) Count() (i int) {
	kv.db.View(func(tx *bolt.Tx) error {
		c := tx.Bucket(kv.table).Cursor()
		for k, _ := c.First(); k != nil; k, _ = c.Next() {
			i++
		}
		return nil
	})
	return
}
189164
func (r *Release) Count(db *sql.DB) (int, error) {
	tx, err := db.Begin()
	if err != nil {
		return 0, err
	}
	defer tx.Rollback()

	err = r.Select(tx)
	if err != nil {
		if err == sql.ErrNoRows {
			err = errors.New("model/certdb: release doesn't exist")
		}
		return 0, err
	}

	var count int
	q := fmt.Sprintf("SELECT count(*) FROM %ss WHERE release = ?", r.table())
	row := tx.QueryRow(q, r.Version)
	err = row.Scan(&count)
	if err == nil {
		err = tx.Commit()
	}
	return count, err
}
395742
func (cache *Cache) Count() int {
	cache.mutex.RLock()
	count := len(cache.items)
	cache.mutex.RUnlock()
	return count
}
435354
func (c *ChannelsHistoryCall) Count(count int) *ChannelsHistoryCall {
	c.count = count
	return c
}
328588
func (c *Cacher) Count(pathPrefix string) (int64, error) {
	return c.storage.Count(pathPrefix)
}
87496
func (f *FileStore) Count() int {
	f.mu.RLock()
	defer f.mu.RUnlock()
	return len(f.files)
}
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
}
436643
func (h *sqlHelper) Count(
	logger lager.Logger,
	q Queryable,
	table string,
	wheres string,
	whereBindings ...interface{},
) (int, error) {
	query := fmt.Sprintf("SELECT COUNT(*) FROM %s\n", table)

	if len(wheres) > 0 {
		query += "WHERE " + wheres
	}

	var count int
	err := q.QueryRow(h.Rebind(query), whereBindings...).Scan(&count)
	return count, err
}
848639
func (rs *Resources) Count() int {
	rs.mu.Lock()
	defer rs.mu.Unlock()
	return len(rs.resources)
}
899849
func (mp *TxPool) Count() int {
	mp.mtx.RLock()
	count := len(mp.pool)
	mp.mtx.RUnlock()

	return count
}
369441
func (s *Semaphore) Count() int64 {
	s.lock.RLock()
	defer s.lock.RUnlock()
	return s.count
}