Class BatchSink<T,​R>

  • Type Parameters:
    T - The type of data to write to target database
    R - Pulsar message type, such as GenericRecord
    All Implemented Interfaces:
    java.lang.AutoCloseable, org.apache.pulsar.io.core.Sink<R>
    Direct Known Subclasses:
    InfluxDBAbstractSink, InfluxDBSink

    public abstract class BatchSink<T,​R>
    extends java.lang.Object
    implements org.apache.pulsar.io.core.Sink<R>
    Pulsar sink which can write data to target in batch.
    • Constructor Summary

      Constructors 
      Constructor Description
      BatchSink()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      protected abstract T buildPoint​(org.apache.pulsar.functions.api.Record<R> message)  
      void close()  
      protected java.lang.Object getFiled​(org.apache.pulsar.client.api.schema.GenericRecord record, java.lang.String fieldName)  
      protected void init​(long batchTimeMs, int batchSize)  
      void write​(org.apache.pulsar.functions.api.Record<R> record)  
      protected abstract void writePoints​(java.util.List<T> points)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface org.apache.pulsar.io.core.Sink

        open
    • Constructor Detail

      • BatchSink

        public BatchSink()
    • Method Detail

      • init

        protected void init​(long batchTimeMs,
                            int batchSize)
      • write

        public final void write​(org.apache.pulsar.functions.api.Record<R> record)
        Specified by:
        write in interface org.apache.pulsar.io.core.Sink<T>
      • close

        public void close()
                   throws java.lang.Exception
        Specified by:
        close in interface java.lang.AutoCloseable
        Throws:
        java.lang.Exception
      • getFiled

        protected java.lang.Object getFiled​(org.apache.pulsar.client.api.schema.GenericRecord record,
                                            java.lang.String fieldName)
      • buildPoint

        protected abstract T buildPoint​(org.apache.pulsar.functions.api.Record<R> message)
                                 throws java.lang.Exception
        Throws:
        java.lang.Exception
      • writePoints

        protected abstract void writePoints​(java.util.List<T> points)
                                     throws java.lang.Exception
        Throws:
        java.lang.Exception