/*
public int getJoinServerCount()
{
return _joinCount;
}
331323
public void start(Consumer<UpdateRackHeartbeat> consumer,
                    Result<Integer> result)
  {
    if (_selfServer.port() < 0) {
      result.ok(0);
      return;
    }
    
    // boolean isPendingStart = false;
    
    ArrayList<ClusterHeartbeat> clusterList = new ArrayList<>();
    for (ClusterHeartbeat cluster : _root.getClusters()) {
      clusterList.add(cluster);
    }
    
    if (clusterList.size() == 0) {
      result.ok(0);
      return;
    }
    
    /*
    Result<Integer>[]resultFork = result.fork(clusterList.size(),
                                              (x,r)->addInt(x,null,r),
                                              (x,y,r)->addInt(x,y,r));
                                              */
    Fork<Integer,Integer> fork = result.fork();
    
    for (int i = 0; i < clusterList.size(); i++) {
      ClusterHeartbeat cluster = clusterList.get(i);
      
      startCluster(cluster, consumer, fork.branch()); // resultFork[i]);
    }
    
    fork.fail((v,f,r)->addInt(v,f,r));
    fork.join((v,r)->addInt(v,null,r));
    
    /*
    for (ClusterHeartbeat cluster : _root.getClusters()) {
      if (! _selfServer.getClusterId().equals(cluster.getId())) {
        startCluster(cluster, cont);
      }
    }
    */
  }
876986
@Override
    public boolean hasOuterJoin() {
        assert(m_leftNode != null && m_rightNode != null);
        return m_joinType != JoinType.INNER ||
                m_leftNode.hasOuterJoin() || m_rightNode.hasOuterJoin();
    }
1161637
public function buildJoin()
	{
		$joins = [];

		foreach ($this->join as $join)
		{
			if (isset($join['raw']))
			{
				$joins[] = strtoupper($join['type']) . ' JOIN ' . $join['table'] . ' ON ' . $join['raw'];
			}
			else
			{
				$joins[] = strtoupper($join['type']) . ' JOIN ' . $join['table'] . ' ON ' . $join['left'] . ' = ' . $join['right'];
			}
		}

		return implode("\n", $joins);
	}
658532
public int getSubscribersCount(EventPublisher source) {
	GenericEventDispatcher<?> dispatcherObject = dispatchers.get(source);
	
	if (dispatcherObject == null) {
	    return 0;
	} else {
	    return dispatcherObject.getListenersCount();
	}
    }
185166
@Override
    public boolean allInnerJoins() {
        return m_joinType == JoinType.INNER &&
               (m_leftNode == null || m_leftNode.allInnerJoins()) &&
               (m_rightNode == null || m_rightNode.allInnerJoins());
    }
862088
@Override
  public int count() {

    int listSize = getList().size();
    int pageSize = getPageSize();
    int pageCount = listSize / pageSize;

    pageCount += listSize % pageSize > 0 ? 1 : 0;

    return pageCount;
  }
242823
protected int getCount(int type, Collection<ConnectionListener> listeners)
   {
      int count = 0;

      for (ConnectionListener cl : listeners)
      {
         if (cl.getState() == type)
            count++;
      }

      return count;
   }
1126438
public function count(): ?int
    {
        // no where, count all simply
        $where = $this->query['where'] ?? null;
        if ($where == null) {
            return $this->agent->count($this->table);
        }

        $from = '';
        if ($this->query) {
            $isSub = $this->isSub;
            $this->isSub = true;
            $from = $this->toString();
            $this->isSub = $isSub; // restore
        }

        if ($from == '') {
            $from = "SELECT 1 FROM {$this->table} ". trim($this->toQueryString('where', false));
        }
        $from = trim($from);

        $query = "SELECT count(*) AS count FROM (\n\t{$from}\n) AS tmp";
        $result = $this->agent->get($query, null, 'object');

        return isset($result->count) ? intval($result->count) : null;
    }
412435
final public long getConnects() {
		long total = 0;
		synchronized(poolLock) {
			for(PooledConnection<C> conn : allConnections) {
				total += conn.connectCount.get();
			}
		}
		return total;
	}
621910
public function join()
	{
		// We do a left outer join here because we're not trying to limit the primary table's results
		// This function is primarily used when needing to sort by a field in the joined table
		$this->model->select($this->model->getQualifiedFieldName('*'))
		            ->select($this->related->getQualifiedFieldName('*'))
		            ->join($this->associativeTable,
		                   $this->model->getQualifiedFieldName($this->localKey),
		                   $this->associativeLocal,
		                   'LEFT OUTER')
		            ->join($this->related->getTableName(),
		                   $this->associativeRelated,
		                   $this->related->getQualifiedFieldName($this->relatedKey),
		                   'LEFT OUTER');

		return $this;
	}
208252
protected int getChildCount(){
		int num=0;
		LazyNode token=child;
		while(token!=null){
			num++;
			token=token.next;
		}
		return num;
	}
885846
public function getSosaCount(){
        if(!$this->is_setup) return 0;
        return Database::prepare(
            'SELECT COUNT(majs_sosa) FROM `##maj_sosa`' .
            ' WHERE majs_gedcom_id=:tree_id AND majs_user_id=:user_id')
            ->execute(array(
                'tree_id' => $this->tree->getTreeId(), 
                'user_id' => $this->user->getUserId() 
            ))->fetchOne() ?: 0;
    }
422719
public Long getCount() {
        if (count == 0L || !suppressCounts) {
                count = Convert.toLong(new DB(dbName).firstCell(countQuery, params));
            return count;
        } else {
            return count;
        }
    }
961179
@InterfaceAudience.Public
    @InterfaceStability.Experimental
    public int totalCount() {
        int total = countNonService;
        for (Map.Entry<ServiceType, Integer> entry : counts.entrySet()) {
            total += entry.getValue();
        }
        return total;
    }
748610
public final int getActiveConnectionCount() {

      if(!isActive) {
         return 0;
      }

      int count = 0;
      for(ConnectionPoolConnection conn : connections) {
         if(conn.state.get() != ConnectionPoolConnection.STATE_AVAILABLE) {
            count++;
         }
      }

      return count;
   }
249136
public Long getCount() {
        if (count == 0L || !suppressCounts) {
            if (metaModel.cached()) {
                count = (Long) QueryCache.instance().getItem(metaModel.getTableName(), countQueryFull, params);
                if (count == null || count == 0) {
                    count = doCount();
                    QueryCache.instance().addItem(metaModel.getTableName(), countQueryFull, params, count);
                }else {
                    LogFilter.logQuery(LOGGER, countQueryFull, params, System.currentTimeMillis(), true);
                }
            } else {
                count = doCount();
            }
            return count;

        } else {
            return count;
        }
    }
971253
public ServerMember getRemoteMember(int id) {
    MemberState member = membersMap.get(id);
    return member != null ? member.getMember() : null;
  }