public int count() {
		HTable table = null;
		ResultScanner rs = null ;
		try {
			//default 2 minutes
			int timeout = Util.parseInt("return.timeout", 2) ; 
			long start=System.currentTimeMillis();
			table = (HTable)pool.getTable(tableName);
			Scan scan = new Scan();
			rs = table.getScanner(scan);
			
			JSONArray ret = new JSONArray();
			for (Result res : rs) {
				ret.put(toJSON(res));
				if (System.currentTimeMillis()-start > timeout*60*1000) {
					LOG.warn("scan exceeds " + timeout);
					break;
				}
			}
			LOG.info(String.format("count the table %s takes %s ms", 
					new String(table.getTableName()),
					System.currentTimeMillis()-start ));
			return ret.length();
		} catch (IOException e) {
			LOG.error(e.getMessage(), e);
			return -1;
		} finally {
			if (rs!=null) rs.close();
			if (table!=null)
				try {
					table.close();
				} catch (IOException e) {
					LOG.error("table close error", e);
				}
		}
	}