Run Graql compute count query

@return a Answer object containing the count value
5190
private Stream<Numeric> runComputeCount(GraqlCompute.Statistics.Count query) {
        if (!scopeContainsInstance(query)) {
            LOG.debug("Count = 0");
            return Stream.of(new Numeric(0));
        }

        Set<LabelId> scopeTypeLabelIDs = convertLabelsToIds(scopeTypeLabels(query));
        Set<LabelId> scopeTypeAndImpliedPlayersLabelIDs = convertLabelsToIds(scopeTypeLabelsImplicitPlayers(query));
        scopeTypeAndImpliedPlayersLabelIDs.addAll(scopeTypeLabelIDs);

        Map<Integer, Long> count;

        ComputerResult result = compute(
                new CountVertexProgram(),
                new CountMapReduceWithAttribute(),
                scopeTypeAndImpliedPlayersLabelIDs, false);
        count = result.memory().get(CountMapReduceWithAttribute.class.getName());

        long finalCount = count.keySet().stream()
                .filter(id -> scopeTypeLabelIDs.contains(LabelId.of(id)))
                .mapToLong(count::get).sum();
        if (count.containsKey(GraknMapReduce.RESERVED_TYPE_LABEL_KEY)) {
            finalCount += count.get(GraknMapReduce.RESERVED_TYPE_LABEL_KEY);
        }

        LOG.debug("Count = {}", finalCount);
        return Stream.of(new Numeric(finalCount));
    }
1176184
public int getCount() {
        Lock lock = this.lock.readLock();
        lock.lock();
        try {
            return this.count;
        } finally {
            lock.unlock();
        }
    }
532658
function count()
    {
        $realm = $this->getRealm();


        try {
            $sql = "SELECT COUNT(*) as has_key FROM `KVStore` WHERE `realm` = '$realm';";
            $stm = $this->pdo->prepare($sql);
            $stm->execute();
            $stm->setFetchMode(\PDO::FETCH_ASSOC);

            $count = $stm->fetch();
            $count = (int) $count['has_key'];

        } catch (\Exception $e) {
            throw new exReadError($e->getMessage(), $e->getCode(), $e);
        }

        return $count;
    }
469962
@Override
    public long count(String tableName, String familyName, XPath condition) throws IOException {
	logger.debug("NATIVE Begin count");
	// clone the current conf
	org.apache.hadoop.conf.Configuration customConf = new org.apache.hadoop.conf.Configuration(super.getHbcfg());
	// Increase RPC timeout, in case of a slow computation
        customConf.setLong("hbase.rpc.timeout", 600000);
        // Default is 1, set to a higher value for faster scanner.next(..)
        customConf.setLong("hbase.client.scanner.caching", 1000);

	/*
        System.out.println("HBaseUtils begin of |customConf|");
	Configuration.dumpConfiguration(customConf, new PrintWriter(System.out));
	System.out.println("\nHBaseUtils end of |customConf|");
	*/

        AggregationClient agClient = new AggregationClient(customConf);
	long rowCount = 0;
	byte[] tName = Bytes.toBytes(tableName);
	try {
	    Scan scan = getScan(tableName, familyName);
	    rowCount = agClient.rowCount(tName, null, scan);
	} catch (Throwable e) {
            throw new IOException(e.toString());
	}
        return rowCount;
    }
706182
def get_count_query(self):
        
        query_copy = self.copy()
        if not query_copy.tables:
            raise Exception('No tables specified to do a count')

        for table in query_copy.tables:
            del table.fields[:]

        query_copy.tables[0].add_field(CountField('*'))
        del query_copy.sorters[:]
        return query_copy
669212
public function count()
    {
        if ($this->isInitialized()) {
            return $this->collection->count();
        }

        // Return cached result in case count query was already executed
        if ($this->count !== null) {
            return $this->count;
        }

        return $this->count = $this->entityPersister->count($this->criteria);
    }
1186822
def count(self):
        """"""

        # count queries shouldn't care about sorting
        fields_sort = self.fields_sort
        self.fields_sort = self.fields_sort_class()

        self.default_val = 0
        ret = self._query('count')

        # restore previous values now that count is done
        self.fields_sort = fields_sort

        return ret
228756
def count(self):
        
        if self._result_cache is not None and not self._iter:
            return len(self._result_cache)

        return self.query.get_count()
882759
def count(cls, where_clause="", qb=None):
        
        if not qb:
            qb = QuickBooks()

        if where_clause:
            where_clause = "WHERE " + where_clause

        select = "SELECT COUNT(*) FROM {0} {1}".format(
            cls.qbo_object_name, where_clause)

        json_data = qb.query(select)

        if "totalCount" in json_data["QueryResponse"]:
            return json_data["QueryResponse"]["totalCount"]
        else:
            return None
739381
public int count() {
		Integer result = null;
		if (result == null) {
			SimpleQuery q = this.isKeysOnly()? this : this.clone().keysOnly();
			result = getDatastoreService().prepare(q.getQuery()).countEntities(fetchOptions);
		}
		return result;
	}
869366
def count(self):
        
        # Save the existing rows and start parameters to see how many results were actually expected
        _rows = self._solr_params.get('rows', None)
        _start = self._solr_params.get('start', 0)
        if not self._solr_cache:
            # Get the count for everything
            self.set_params(rows=0)
            self._exec_query()
        number = self._solr_cache.get('num_found', -1)

        # If start value is bigger or equal than solr results' count, should return 0
        # If there are 10 results, but if start value is specified as 30, should return 0.
        if _start >= number:
            return 0
        else:
            # If 'start' is specified, then this many results from the start will not be accessible.
            number -= _start
            # If 'rows' is NOT specified, then all results are accessible
            # (minus the ones skipped with 'start')
            if _rows is None:
                return number
            # If 'rows' is specified, then this many results at most will be accessible. If we have
            # more than this many results found, then we can say that this many results are
            # accessible. If there are less results found than rows, then we can't give more
            # than found results.
            return number if number < _rows else _rows
685700
public int getCount(G g) {
        Pair<Integer> orderAndSize = new Pair<Integer>(g.order(), g.size());
        Map<G,Integer> graphs = orderAndSizeToGraphs.get(orderAndSize);
        if (graphs == null) 
            return 0;
        for (Map.Entry<G,Integer> e : graphs.entrySet()) {
            if (isoTest.areIsomorphic(g, e.getKey())) 
                return e.getValue();
        }
        return 0;
    }
837715
public function count()
    {
        $this->assembleQueryWithJoins();
        $q = clone $this->source;
        $q = $q->resetDQLPart('orderBy')->select('COUNT(' . $this->currentAlias . ')')->getQuery();
        return $q->getSingleScalarResult();
    }
705830
public long countQuery(SearchRequestBuilder countRequestBuilder,
            long timeoutMillis) {
        countRequestBuilder.setSize(0);
        return searchQuery("countQuery", countRequestBuilder, timeoutMillis)
                .getHits().getTotalHits();
    }
1316467
public org.grails.datastore.mapping.query.api.ProjectionList rowCount() {
        return rowCount(null);
    }
594349
def count(self, query=None, indices=None, doc_types=None, **query_params):
        
        from .query import MatchAllQuery

        if query is None:
            query = MatchAllQuery()
        body = {"query": query.serialize()}
        path = self._make_path(indices, doc_types, "_count")
        return self._send_request('GET', path, body, params=query_params)
1275448
function count()
    {
        if ( $this->count !== null )
            return $this->count;

        if ( $this->query === null )
        {
            $this->query = $this->generateSQL();
        }
        if ( $this->query === false )
            return 0;
        $query = "SELECT count(*) AS count {$this->query}";
        $db = eZDB::instance();
        $rows = $db->arrayQuery( $query );
        if ( count( $rows ) == 0 )
            $this->count = 0;
        else
            $this->count = $rows[0]['count'];
        return $this->count;
    }