public class SimpleRecordTranslator<K,V> extends Object implements RecordTranslator<K,V>
DEFAULT_STREAM
Constructor and Description |
---|
SimpleRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>,List<Object>> func,
Fields fields) |
SimpleRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>,List<Object>> func,
Fields fields,
String stream)
Creates a SimpleRecordTranslator.
|
Modifier and Type | Method and Description |
---|---|
List<Object> |
apply(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
Translate the ConsumerRecord into a list of objects that can be emitted.
|
Fields |
getFieldsFor(String stream)
Get the fields associated with a stream.
|
List<String> |
streams()
Get the list of streams this translator will handle.
|
public SimpleRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>,List<Object>> func, Fields fields)
public SimpleRecordTranslator(Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>,List<Object>> func, Fields fields, String stream)
Creates a SimpleRecordTranslator.
func
- The mapping function responsible for translating a Kafka record to a Tuplefields
- The fields tuples constructed by this translator will containstream
- The stream tuples constructed by this translator will targetpublic List<Object> apply(org.apache.kafka.clients.consumer.ConsumerRecord<K,V> record)
RecordTranslator
Translate the ConsumerRecord into a list of objects that can be emitted.
apply
in interface Func<org.apache.kafka.clients.consumer.ConsumerRecord<K,V>,List<Object>>
apply
in interface RecordTranslator<K,V>
record
- the record to translateKafkaTuple
if you want to route the tuple to a non-default stream. Return null
to discard an invalid ConsumerRecord
if KafkaSpoutConfig.Builder.setEmitNullTuples(boolean)
is set to false
.public Fields getFieldsFor(String stream)
RecordTranslator
Get the fields associated with a stream. The streams passed in are returned by the RecordTranslator.streams()
method.
getFieldsFor
in interface RecordTranslator<K,V>
stream
- the stream the fields are forpublic List<String> streams()
RecordTranslator
Get the list of streams this translator will handle.
streams
in interface RecordTranslator<K,V>
Copyright © 2022 The Apache Software Foundation. All rights reserved.