Package io.deephaven.kafka.ingest
Class PojoConsumerRecordToTableWriterAdapter<K,V>
java.lang.Object
io.deephaven.kafka.ingest.PojoConsumerRecordToTableWriterAdapter<K,V>
- Type Parameters:
K
- the type of the key recordV
- the type of the value record
- All Implemented Interfaces:
ConsumerRecordToTableWriterAdapter
public class PojoConsumerRecordToTableWriterAdapter<K,V> extends Object implements ConsumerRecordToTableWriterAdapter
Converts a consumer record containing Java objects to a Deephaven row.
The constructor will use reflection combined with the builder parameters to automatically map fields or methods in
the key and value classes to columns in the output table and compile an appropriate adapter class. Each record is
then passed to the adapter class, requiring no per-record reflection.
This adapter is intended for use with custom deserializers or with using Avro with compiled org.apache.avro.specific.SpecificRecord objects that contain a field for each schema element.
After processing explicit mappings for fields; the value class is searched for exact matches followed by the key class using the following precedence:
- a public method with a the same name as the column and no arguments
- a public method beginning with "get" followed by the name of the column, and no arguments
- a public field with the same name as the column, and no arguments
If caseInsensitiveSearch is specified on the builder, the same precedence is followed for the remaining columns; but using case insensitive matching of method names.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PojoConsumerRecordToTableWriterAdapter.Builder
A builder for the PojoConsumerRecordToTableWriterAdapter. -
Method Summary
Modifier and Type Method Description void
consumeRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> record)
Consume a Kafka record, producing zero or more rows in the output.
-
Method Details
-
consumeRecord
public void consumeRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> record) throws IOExceptionDescription copied from interface:ConsumerRecordToTableWriterAdapter
Consume a Kafka record, producing zero or more rows in the output.- Specified by:
consumeRecord
in interfaceConsumerRecordToTableWriterAdapter
- Parameters:
record
- the record received fromKafkaConsumer.poll(Duration)
.- Throws:
IOException
- if there was an error writing to the output table
-