Interface CoProcessor

    • Method Detail

      • getProducedType

        org.apache.avro.Schema getProducedType​(org.apache.avro.Schema schema1,
                                               org.apache.avro.Schema schema2)
        Gets the data type (as a Schema) produced by this function or input format.
        Parameters:
        schema1 - the input row schema from stream 1
        schema2 - the input row schema from stream 2
        Returns:
        The data type produced by this function or input format.
      • getSidesOutProducedType

        default Map<String,​org.apache.avro.Schema> getSidesOutProducedType​(org.apache.avro.Schema schema1,
                                                                                 org.apache.avro.Schema schema2)
        Declare the data type information of the sides out data produced by your function.
        Returns:
        the sides output type information
      • processElement1

        void processElement1​(KastRow kRow,
                             KastCoProcessorContext ctx,
                             KastCollector out,
                             KastRowBuilder kastRowBuilder)
                      throws Exception
        This method is called for each element in the first of the connected streams.

        This function can output zero or more elements using the KastCollector parameter.

        Parameters:
        kRow - The stream element
        ctx - A KastCoProcessorContext that allows querying the timestamp of the element. The context is only valid during the invocation of this method, do not store it.
        out - The collector to emit resulting elements to
        Throws:
        Exception - The function may throw exceptions which cause the streaming program to fail and go into recovery.
      • processElement2

        void processElement2​(KastRow kRow,
                             KastCoProcessorContext ctx,
                             KastCollector out,
                             KastRowBuilder kastRowBuilder)
                      throws Exception
        This method is called for each element in the second of the connected streams.

        This function can output zero or more elements using the KastCollector parameter and also update internal state or set timers using the KastCoProcessorContext parameter.

        Parameters:
        kRow - The stream element
        ctx - A KastCoProcessorContext that allows querying the timestamp of the element. The context is only valid during the invocation of this method, do not store it.
        out - The collector to emit resulting elements to
        Throws:
        Exception - The function may throw exceptions which cause the streaming program to fail and go into recovery.
      • open

        default void open​(Map<String,​String> configuration,
                          org.apache.avro.Schema schema1,
                          org.apache.avro.Schema schema2,
                          Map<String,​KastOutputTag> sidesOutputTag,
                          KastRuntimeContext rtCtx)
                   throws Exception
        Initialization method for the function.
        Parameters:
        configuration - The configuration containing the parameters attached to the contract
        schema1 - the input row schema from stream 1
        schema2 - the input row schema from stream 2
        sidesOutputTag - Side output typeinfo and tag dict if any
        rtCtx - a runtime context that allow you for example to manage state
        Throws:
        Exception - The function may throw exceptions which cause the streaming program to fail and go into recovery.
      • open

        default void open​(Map<String,​String> configuration,
                          org.apache.avro.Schema schema1,
                          org.apache.avro.Schema schema2,
                          Map<String,​KastOutputTag> sidesOutputTag,
                          KastRuntimeContext rtCtx,
                          Map<String,​Object> meta)
                   throws Exception
        Initialization method for the function.
        Parameters:
        configuration - The configuration containing the parameters attached to the contract
        schema1 - the input row schema from stream 1
        schema2 - the input row schema from stream 2
        sidesOutputTag - Side output typeinfo and tag dict if any
        rtCtx - a runtime context that allow you for example to manage state
        meta - the udf configuration parameters
        Throws:
        Exception - The function may throw exceptions which cause the streaming program to fail and go into recovery.
      • close

        default void close()
                    throws Exception
        Tear-down method for the user code. It is called after the last call to the main working methods. For functions that are part of an iteration, this method will be invoked after each iteration superstep.

        This method can be used for clean up work.

        Throws:
        Exception - The function may throw exceptions which cause the streaming program to fail and go into recovery.