Package io.github.kaststream.api.v2
Interface CoProcessor
-
- All Superinterfaces:
Serializable
public interface CoProcessor extends Serializable
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default voidclose()Tear-down method for the user code.org.apache.avro.SchemagetProducedType(org.apache.avro.Schema schema1, org.apache.avro.Schema schema2)Gets the data type (as aSchema) produced by this function or input format.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.default voidopen(Map<String,String> configuration, org.apache.avro.Schema schema1, org.apache.avro.Schema schema2, Map<String,KastOutputTag> sidesOutputTag, KastRuntimeContext rtCtx)Initialization method for the function.default voidopen(Map<String,String> configuration, org.apache.avro.Schema schema1, org.apache.avro.Schema schema2, Map<String,KastOutputTag> sidesOutputTag, KastRuntimeContext rtCtx, Map<String,Object> meta)Initialization method for the function.voidprocessElement1(KastRow kRow, KastCoProcessorContext ctx, KastCollector out, KastRowBuilder kastRowBuilder)This method is called for each element in the first of the connected streams.voidprocessElement2(KastRow kRow, KastCoProcessorContext ctx, KastCollector out, KastRowBuilder kastRowBuilder)This method is called for each element in the second of the connected streams.
-
-
-
Method Detail
-
getProducedType
org.apache.avro.Schema getProducedType(org.apache.avro.Schema schema1, org.apache.avro.Schema schema2)Gets the data type (as aSchema) produced by this function or input format.- Parameters:
schema1- the input row schema from stream 1schema2- 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
KastCollectorparameter.- Parameters:
kRow- The stream elementctx- AKastCoProcessorContextthat 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
KastCollectorparameter and also update internal state or set timers using theKastCoProcessorContextparameter.- Parameters:
kRow- The stream elementctx- AKastCoProcessorContextthat 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 contractschema1- the input row schema from stream 1schema2- the input row schema from stream 2sidesOutputTag- Side output typeinfo and tag dict if anyrtCtx- 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 contractschema1- the input row schema from stream 1schema2- the input row schema from stream 2sidesOutputTag- Side output typeinfo and tag dict if anyrtCtx- a runtime context that allow you for example to manage statemeta- 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 ExceptionTear-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.
-
-