Small query to determine total number of hits
185717
def found(self):
        
        if 'ids' in self.kwargs:
            cid = self.kwargs['query']['collection']['eq']
            return len(self.items_by_id(self.kwargs['ids'], cid))
        kwargs = {
            'page': 1,
            'limit': 0
        }
        kwargs.update(self.kwargs)
        results = self.query(**kwargs)
        return results['meta']['found']
630328
def _hits_hashed_by_query(self, hits):
        ''''''
        d = {}
        for hit in hits:
            if hit.qry_name not in d:
                d[hit.qry_name] = []
            d[hit.qry_name].append(hit)
        return d
356197
def count_of_certain_kind(kind):
        '''
        
        '''

        recs = TabPost.select().where(TabPost.kind == kind)

        return recs.count()
217741
def messages_count(user)
      Message.search do
        with(:receiver_id).equal_to user.id
        with(:is_read).equal_to false
      end.hits.total_entries
    end
958246
def top_hits(hits, num, column, reverse):
    
    hits.sort(key = itemgetter(column), reverse = reverse)
    for hit in hits[0:num]:
        yield hit
1045832
def get_reviewable_hits(self, hit_type=None, status='Reviewable',
                            sort_by='Expiration', sort_direction='Ascending', 
                            page_size=10, page_number=1):
        
        params = {'Status' : status,
                  'SortProperty' : sort_by,
                  'SortDirection' : sort_direction,
                  'PageSize' : page_size,
                  'PageNumber' : page_number}

        # Handle optional hit_type argument
        if hit_type is not None:
            params.update({'HITTypeId': hit_type})

        return self._process_request('GetReviewableHITs', params, [('HIT', HIT),])
754299
def count_rows(self, table_name):
        """"""
        self.table_must_exist(table_name)
        query = "SELECT COUNT (*) FROM `%s`" % table_name.lower()
        self.own_cursor.execute(query)
        return int(self.own_cursor.fetchone()[0])
348520
def fast_count(query):
    
    count_query = (query
                   .statement.with_only_columns([func.count()]).order_by(None))
    count = query.session.execute(count_query).scalar()
    return count
988652
def get_userplaycount(self):
        """"""

        if not self.username:
            return

        params = self._get_params()
        params["username"] = self.username

        doc = self._request(self.ws_prefix + ".getInfo", True, params)
        return _number(_extract(doc, "userplaycount"))
788771
def posts_count(self):
        
        return self.obj.direct_posts_count + sum(n.posts_count for n in self.children)
70217
private void getHits() throws IOException
   {
      TopFieldCollector collector = TopFieldCollector.create(sort, numHits, false, true, false, false);
      searcher.search(query, collector);

      this.size = collector.getTotalHits();
      ScoreDoc[] docs = collector.topDocs().scoreDocs;
      for (int i = scoreDocs.size(); i < docs.length; i++)
      {
         scoreDocs.add(docs[i]);
      }
      log.debug("getHits() {}/{}", scoreDocs.size(), numHits);
      // double hits for next round
      numHits *= 2;
   }
90012
def get_count(self):
        
        params = self.get_params()
        params["offset"] = self.low_mark
        params["limit"] = 1

        r = self.resource._meta.api.http_resource("GET", self.resource._meta.resource_name, params=params)
        data = self.resource._meta.api.resource_deserialize(r.text)

        number = data["meta"]["total_count"]

        # Apply offset and limit constraints manually, since using limit/offset
        # in the API doesn't change the total_count output.
        number = max(0, number - self.low_mark)
        if self.high_mark is not None:
            number = min(number, self.high_mark - self.low_mark)

        return number
1185792
public function count(
        $query = [],
        $limit = null,
        $skip = null,
        $timeout = 2000
    ) {
        $this->getContext()->getLog()->profileStart($this->profileName . __FUNCTION__);
        $options = [
            'socketTimeoutMS' => $timeout
        ];
        if (!is_null($limit)) {
            $options['limit'] = $limit;
        }
        if (!is_null($skip)) {
            $options['skip'] = $skip;
        }
        $out = $this->mongoCollection->count($query, $options);
        if ($out === null) {
            return 0;
        }
        $this->getContext()->getLog()->profileEnd($this->profileName . __FUNCTION__);

        return $out;
    }
1009557
function count(req, res, next) {
  User.count(function(err, count){
    if (err) return next(err);
    req.count = count;
    next();
  })
}
1263489
async def count(self, query, clear_limit=False):
        
        query = self._swap_database(query)
        return (await count(query, clear_limit=clear_limit))
1061755
function count(req, res, next) {
  db.users.count(function(err, count) {
    if(err) { return next(err); }
    res.json({count: count});
  });
}
962960
def CountHuntResultsByType(self, hunt_id, cursor=None):
    """"""
    hunt_id_int = db_utils.HuntIDToInt(hunt_id)

    query = ("SELECT type, COUNT(*) FROM flow_results "
             "WHERE hunt_id = %s GROUP BY type")

    cursor.execute(query, [hunt_id_int])
    return dict(cursor.fetchall())