Class KafkaInputRecordReader
java.lang.Object
com.linkedin.venice.hadoop.input.kafka.KafkaInputRecordReader
- All Implemented Interfaces:
AutoCloseable
,org.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
public class KafkaInputRecordReader
extends Object
implements org.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,KafkaInputMapperValue>, AutoCloseable
We borrowed some idea from the open-sourced attic-crunch lib:
https://github.com/apache/attic-crunch/blob/master/crunch-kafka/src/main/java/org/apache/crunch/kafka/record/KafkaRecordReader.java
This class is used to read data off a Kafka topic partition.
It will return the key bytes as unchanged, and extract the following fields and wrap them
up as
KafkaInputMapperValue
as the value:
1. Value bytes.
2. Schema Id.
3. Offset.
4. Value type, which could be 'PUT' or 'DELETE'.-
Field Summary
-
Constructor Summary
ConstructorDescriptionKafkaInputRecordReader
(org.apache.hadoop.mapred.InputSplit split, org.apache.hadoop.mapred.JobConf job, DataWriterTaskTracker taskTracker) KafkaInputRecordReader
(org.apache.hadoop.mapred.InputSplit split, org.apache.hadoop.mapred.JobConf job, DataWriterTaskTracker taskTracker, PubSubConsumerAdapter consumer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
long
getPos()
float
boolean
next
(KafkaInputMapperKey key, KafkaInputMapperValue value) This function will skip all the Control Messages right now.
-
Field Details
-
KIF_RECORD_READER_KAFKA_CONFIG_PREFIX
- See Also:
-
-
Constructor Details
-
KafkaInputRecordReader
public KafkaInputRecordReader(org.apache.hadoop.mapred.InputSplit split, org.apache.hadoop.mapred.JobConf job, DataWriterTaskTracker taskTracker) -
KafkaInputRecordReader
public KafkaInputRecordReader(org.apache.hadoop.mapred.InputSplit split, org.apache.hadoop.mapred.JobConf job, DataWriterTaskTracker taskTracker, PubSubConsumerAdapter consumer)
-
-
Method Details
-
next
This function will skip all the Control Messages right now.- Specified by:
next
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue> - Throws:
IOException
-
createKey
- Specified by:
createKey
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
-
createValue
- Specified by:
createValue
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
-
getPos
public long getPos()- Specified by:
getPos
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
-
getProgress
public float getProgress()- Specified by:
getProgress
in interfaceorg.apache.hadoop.mapred.RecordReader<KafkaInputMapperKey,
KafkaInputMapperValue>
-