Class ConsumerRecords<K,V>
- java.lang.Object
 - 
- org.apache.kafka.clients.consumer.ConsumerRecords<K,V>
 
 
- 
- All Implemented Interfaces:
 java.lang.Iterable<ConsumerRecord<K,V>>
public class ConsumerRecords<K,V> extends java.lang.Object implements java.lang.Iterable<ConsumerRecord<K,V>>
A container that holds the listConsumerRecordper partition for a particular topic. There is oneConsumerRecordlist for every topic partition returned by aConsumer.poll(java.time.Duration)operation. 
- 
- 
Field Summary
Fields Modifier and Type Field Description static ConsumerRecords<java.lang.Object,java.lang.Object>EMPTY 
- 
Constructor Summary
Constructors Constructor Description ConsumerRecords(java.util.Map<TopicPartition,java.util.List<ConsumerRecord<K,V>>> records) 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intcount()The number of records for all topicsstatic <K,V>
ConsumerRecords<K,V>empty()booleanisEmpty()java.util.Iterator<ConsumerRecord<K,V>>iterator()java.util.Set<TopicPartition>partitions()Get the partitions which have records contained in this record set.java.lang.Iterable<ConsumerRecord<K,V>>records(java.lang.String topic)Get just the records for the given topicjava.util.List<ConsumerRecord<K,V>>records(TopicPartition partition)Get just the records for the given partition 
 - 
 
- 
- 
Field Detail
- 
EMPTY
public static final ConsumerRecords<java.lang.Object,java.lang.Object> EMPTY
 
 - 
 
- 
Constructor Detail
- 
ConsumerRecords
public ConsumerRecords(java.util.Map<TopicPartition,java.util.List<ConsumerRecord<K,V>>> records)
 
 - 
 
- 
Method Detail
- 
records
public java.util.List<ConsumerRecord<K,V>> records(TopicPartition partition)
Get just the records for the given partition- Parameters:
 partition- The partition to get records for
 
- 
records
public java.lang.Iterable<ConsumerRecord<K,V>> records(java.lang.String topic)
Get just the records for the given topic 
- 
partitions
public java.util.Set<TopicPartition> partitions()
Get the partitions which have records contained in this record set.- Returns:
 - the set of partitions with data in this record set (may be empty if no data was returned)
 
 
- 
iterator
public java.util.Iterator<ConsumerRecord<K,V>> iterator()
- Specified by:
 iteratorin interfacejava.lang.Iterable<K>
 
- 
count
public int count()
The number of records for all topics 
- 
isEmpty
public boolean isEmpty()
 
- 
empty
public static <K,V> ConsumerRecords<K,V> empty()
 
 - 
 
 -