Returns the total number of state entries across all keys/namespaces.
173086
@VisibleForTesting
	@SuppressWarnings("unchecked")
	@Override
	public int numKeyValueStateEntries() {
		int sum = 0;
		for (StateSnapshotRestore state : registeredKVStates.values()) {
			sum += ((StateTable<?, ?, ?>) state).size();
		}
		return sum;
	}
428427
def rpc_get_num_names_in_namespace( self, namespace_id, **con_info ):
        
        if not check_namespace(namespace_id):
            return {'error': 'Invalid name or namespace', 'http_status': 400}

        db = get_db_state(self.working_dir)
        num_names = db.get_num_names_in_namespace( namespace_id )
        db.close()

        return self.success_response( {'count': num_names} )
1141079
public function count()
    {
        $rawKeys = array_keys($this->rawData);
        $typeKeys = array_keys($this->typeData);
        $keys = array_merge($rawKeys, $typeKeys);
        $uniqueKeys = array_unique($keys);
        return count($uniqueKeys);
    }
635710
public int computeNextStatementStartKeywordCount() {
        int result = 0;

        if (isNextKeyWord()) {
            for (String[] nextStmtStart : registeredStatementStartPhrases) {
                if (this.matches(nextStmtStart)) {
                    return nextStmtStart.length;
                }
            }
        }

        return result;
    }
1220117
public int getCount (K key)
    {
        CountEntry<K> entry = _backing.get(key);
        return (entry == null) ? 0 : entry.count;
    }
1080163
public int count() {
        int n = 0;
        for (ConcurrentMap<?, ?> bag : registry.values()) {
            n += bag.size();
        }
        return n;
    }
163462
def numKeys(self) -> int:
        
        chunks = self._listChunks()
        num_chunks = len(chunks)
        if num_chunks == 0:
            return 0
        count = (num_chunks-1)*self.chunkSize
        last_chunk = self._openChunk(chunks[-1])
        count += sum(1 for _ in last_chunk._lines())
        last_chunk.close()
        return count
1235960
def calculate_keys_by_mapreduce_state(cls, mapreduce_state):
    
    if mapreduce_state is None:
      return []

    keys = []
    for i in range(mapreduce_state.mapreduce_spec.mapper.shard_count):
      shard_id = cls.shard_id_from_number(mapreduce_state.key().name(), i)
      keys.append(cls.get_key_by_shard_id(shard_id))
    return keys
297885
def state_length(state, size):
    """"""
    if len(state) != size:
        raise ValueError('Invalid state: there must be one entry per '
                         'node in the network; this state has {} entries, but '
                         'there are {} nodes.'.format(len(state), size))
    return True
463820
def calculate_size(name, entry_processor, keys):
    
    data_size = 0
    data_size += calculate_size_str(name)
    data_size += calculate_size_data(entry_processor)
    data_size += INT_SIZE_IN_BYTES
    for keys_item in keys:
        data_size += calculate_size_data(keys_item)
    return data_size
1065630
def GET_namespace_num_names(self, path_info, namespace_id):
        
        if not check_namespace(namespace_id):
            return self._reply_json({'error': 'Invalid namespace'}, status_code=400)

        blockstackd_url = get_blockstackd_url()
        name_count = blockstackd_client.get_num_names_in_namespace(namespace_id, hostport=blockstackd_url)
        if json_is_error(name_count):
            log.error("Failed to load namespace count for {}: {}".format(namespace_id, name_count['error']))
            return self._reply_json({'error': 'Failed to load namespace count: {}'.format(name_count['error'])}, status_code=404)

        self._reply_json({'names_count': name_count})
1219022
def get_state_batch(keys, namespace=None, consistent=True):
    """"""

    ukeys = set(keys)

    if namespace:
        ns_keys = ["{}:{}".format(namespace, key) for key in ukeys]

    uvalues = {k: v for k, v
               in zip(ukeys, get_item_batch(ns_keys, consistent=consistent))}
    return list(zip(keys, (uvalues[k] for k in keys)))
453227
private static int getNumberOfInserts(String messageKey) {

        String unInsertedMessage = nls.getString(messageKey);
        int numInserts = 0;
        // Not much point in going any further than 20 inserts!
        for (int i = 0; i < 20; i++) {
            if (unInsertedMessage.indexOf("{" + i + "}") != -1) {
                numInserts++;
            }
            else {
                // This message insert was not found
                break;
            }
        }

        return numInserts;
    }
763770
def entries(self):
		
		table = self.get_table()
		entries_array = self.row_structure * table.num_entries
		pointer_type = ctypes.POINTER(entries_array)
		return ctypes.cast(table.entries, pointer_type).contents
237135
def get_count(self, prefix=''):
        """"""
        return sum([self.counters[key]
                    for key in self.messages if key.startswith(prefix)])
1177250
public synchronized int getPartitionStoreCount() {
        int count = 0;
        for (String store : storeToPartitionIds.keySet()) {
            count += storeToPartitionIds.get(store).size();
        }
        return count;
    }
1253659
def used_states(self):
        ''
        c = itertools.count()
        canonical_ids = collections.defaultdict(lambda: next(c))
        for s in self.states_list:
            for state in s.stateseq:
                canonical_ids[state]
        return list(map(operator.itemgetter(0),
                sorted(canonical_ids.items(),key=operator.itemgetter(1))))