public synchronized List<TopicPartition> fetchablePartitions(Predicate<TopicPartition> isAvailable) {
        // Since this is in the hot-path for fetching, we do this instead of using java.util.stream API
        List<TopicPartition> result = new ArrayList<>();
        assignment.forEach((topicPartition, topicPartitionState) -> {
            // Cheap check is first to avoid evaluating the predicate if possible
            if ((subscriptionType.equals(SubscriptionType.AUTO_TOPICS_SHARE) || topicPartitionState.isFetchable())
                    && isAvailable.test(topicPartition)) {
                result.add(topicPartition);
            }
        });
        return result;
    }
Provides the number of assigned partitions in a thread safe manner.
@return the number of assigned partitions.
clients/src/main/java/org/apache/kafka/clients/consumer/internals/SubscriptionState.java