Class PojoConsumerRecordToTableWriterAdapter<K,V>

java.lang.Object
io.deephaven.kafka.ingest.PojoConsumerRecordToTableWriterAdapter<K,V>
Type Parameters:
K - the type of the key record
V - 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:

  1. a public method with a the same name as the column and no arguments
  2. a public method beginning with "get" followed by the name of the column, and no arguments
  3. 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.

  • Method Details

    • consumeRecord

      public void consumeRecord(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> record, DBDateTime recvTime) throws IOException
      Description copied from interface: ConsumerRecordToTableWriterAdapter
      Consume a Kafka record, producing zero or more rows in the output.
      Specified by:
      consumeRecord in interface ConsumerRecordToTableWriterAdapter
      Parameters:
      record - the record received from KafkaConsumer.poll(Duration).
      recvTime - the time the record was received from KafkaConsumer.poll(Duration).
      Throws:
      IOException - if there was an error writing to the output table