* @throws IOException
*/
public boolean getNext(EtlKey key, BytesWritable payload ,BytesWritable pKey) throws IOException {
if (hasNext()) {
MessageAndOffset msgAndOffset = messageIter.next();
Message message = msgAndOffset.message();
ByteBuffer buf = message.payload();
int origSize = buf.remaining();
byte[] bytes = new byte[origSize];
buf.get(bytes, buf.position(), origSize);
payload.set(bytes, 0, origSize);
buf = message.key();
if(buf != null){
origSize = buf.remaining();
bytes = new byte[origSize];
buf.get(bytes, buf.position(), origSize);
pKey.set(bytes, 0, origSize);
}
key.clear();
key.set(kafkaRequest.getTopic(), kafkaRequest.getLeaderId(),
kafkaRequest.getPartition(), currentOffset,
msgAndOffset.offset() + 1, message.checksum());
key.setMessageSize(msgAndOffset.message().size());
currentOffset = msgAndOffset.offset() + 1; // increase offset
currentCount++; // increase count
return true;
} else {
return false;