void retainAll(final Set<TopicPartition> partitions) {
        try {
            lock.lock();

            completedFetches.removeIf(cf -> maybeDrain(partitions, cf));

            if (maybeDrain(partitions, nextInLineFetch))
                nextInLineFetch = null;
        } finally {
            lock.unlock();
        }
    }
Updates the buffer to retain only the fetch data that corresponds to the given partitions. Any previously
{@link CompletedFetch fetched data} is removed if its partition is not in the given set of partitions.

@param partitions {@link Set} of {@link TopicPartition}s for which any buffered data should be kept
clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchBuffer.java