/** * Allows sending a message to an output system. * * @param <M> type of the input message */ @InterfaceStability.Unstable @FunctionalInterface public interface SinkFunction<M> extends InitableFunction, ClosableFunction, Serializable { /** * Allows sending the provided message to an output {@link org.apache.samza.system.SystemStream} using * the provided {@link MessageCollector}. Also provides access to the {@link TaskCoordinator} to request commits * or shut the container down. * * @param message the input message to be sent to an output {@link org.apache.samza.system.SystemStream} * @param messageCollector the {@link MessageCollector} to send the message * @param taskCoordinator the {@link TaskCoordinator} to request commits or shutdown */ void apply(M message, MessageCollector messageCollector, TaskCoordinator taskCoordinator); }
@InterfaceStability.Unstable public interface StreamTableJoinFunction<K, M, R, JM> extends InitableFunction, ClosableFunction, Serializable {
@InterfaceStability.Unstable public interface ExecutionPlan {
@InterfaceStability.Unstable public interface JoinFunction<K, M, JM, RM> extends InitableFunction, ClosableFunction, Serializable {
@InterfaceStability.Unstable public interface ExecutionPlan {
@InterfaceStability.Unstable public interface ExecutionPlan {
@InterfaceStability.Unstable public interface ExecutionPlan {
/** * A {@link Table} is an abstraction for data sources that support random access by key. It is an evolution of the * existing {@link KeyValueStore} API. It offers support for both local and remote data sources and composition through * hybrid tables. For remote data sources, a {@code RemoteTable} provides optimized access with caching, rate-limiting, * and retry support. * <p> * Depending on the implementation, a {@link Table} can be a {@link ReadableTable} or a {@link ReadWriteTable}. * <p> * Use a {@link TableDescriptor} to specify the properties of a {@link Table}. For High Level API * {@link StreamApplication}s, use {@link StreamApplicationDescriptor#getTable} to obtain the {@link Table} instance for * the descriptor that can be used with the {@link MessageStream} operators like {@link MessageStream#sendTo(Table)}. * Alternatively, use {@link TaskContext#getTable(String)} in {@link InitableFunction#init} to get the table instance * for use within operator functions. For Low Level API {@link TaskApplication}s, use {@link TaskContext#getTable} * in {@link InitableTask#init} to get the table instance for use within the Task. * * @param <R> the type of records in the table */ @InterfaceStability.Unstable public interface Table<R> { }
/** * A table provider provides the implementation for a table. It ensures a table is * properly constructed and also manages its lifecycle. */ @InterfaceStability.Unstable public interface TableProvider { /** * Initialize TableProvider with container and task context * @param context context for the task */ void init(Context context); /** * Get an instance of the {@link ReadWriteTable} * @return the underlying table */ ReadWriteTable getTable(); /** * Shutdown the underlying table */ void close(); }
/** * Transforms an input message into another message, possibly of a different type. * * @param <M> type of the input message * @param <OM> type of the transformed message */ @InterfaceStability.Unstable @FunctionalInterface public interface MapFunction<M, OM> extends InitableFunction, ClosableFunction, Serializable { /** * Transforms the provided message into another message. * * @param message the input message to be transformed * @return the transformed message */ OM apply(M message); }
/** * Allows sending a message to an output system. * * @param <M> type of the input message */ @InterfaceStability.Unstable @FunctionalInterface public interface SinkFunction<M> extends InitableFunction, ClosableFunction, Serializable { /** * Allows sending the provided message to an output {@link org.apache.samza.system.SystemStream} using * the provided {@link MessageCollector}. Also provides access to the {@link TaskCoordinator} to request commits * or shut the container down. * * @param message the input message to be sent to an output {@link org.apache.samza.system.SystemStream} * @param messageCollector the {@link MessageCollector} to send the message * @param taskCoordinator the {@link TaskCoordinator} to request commits or shutdown */ void apply(M message, MessageCollector messageCollector, TaskCoordinator taskCoordinator); }
/** * A factory to build {@link SideInputsProcessor}s. * * Implementations should return a new instance for every invocation of * {@link #getSideInputsProcessor(Config, MetricsRegistry)} */ @FunctionalInterface @InterfaceStability.Unstable public interface SideInputsProcessorFactory extends Serializable { /** * Creates a new instance of a {@link SideInputsProcessor}. * * @param config the configuration * @param metricsRegistry the metrics registry * @return an instance of {@link SideInputsProcessor} */ SideInputsProcessor getSideInputsProcessor(Config config, MetricsRegistry metricsRegistry); }
/** * Function interface for providing rate limiting credits for each table record. * This interface allows callers to pass in lambda expressions which are otherwise * non-serializable as-is. * @param <K> the type of the key * @param <V> the type of the value */ @InterfaceStability.Unstable public interface CreditFunction<K, V> extends Serializable { /** * Get the number of credits required for the {@code key} and {@code value} pair. * @param key table key * @param value table record * @return number of credits */ int getCredits(K key, V value); }
/** * Function interface for providing rate limiting credits for each table record. * This interface allows callers to pass in lambda expressions which are otherwise * non-serializable as-is. * @param <K> the type of the key * @param <V> the type of the value */ @InterfaceStability.Unstable public interface CreditFunction<K, V> extends Serializable { /** * Get the number of credits required for the {@code key} and {@code value} pair. * @param key table key * @param value table record * @return number of credits */ int getCredits(K key, V value); }
/** * Specifies whether a message should be retained for further processing. * * @param <M> type of the input message */ @InterfaceStability.Unstable @FunctionalInterface public interface FilterFunction<M> extends InitableFunction, ClosableFunction, Serializable { /** * Returns a boolean indicating whether this message should be retained or filtered out. * * @param message the input message to be checked * @return true if {@code message} should be retained */ boolean apply(M message); }
/** * The processing logic for store side inputs. Accepts incoming messages from side input streams * and the current store contents, and returns the new key-value entries to be written to the store. */ @FunctionalInterface @InterfaceStability.Unstable public interface SideInputsProcessor extends Serializable { /** * Process the incoming side input message for the {@code store}. * * @param message incoming message envelope * @param store the store associated with the incoming message envelope * @return a {@link Collection} of {@link Entry}s that will be written to the {@code store}. */ Collection<Entry<?, ?>> process(IncomingMessageEnvelope message, KeyValueStore store); }
/** * A factory to build {@link SideInputsProcessor}s. * * Implementations should return a new instance for every invocation of * {@link #getSideInputsProcessor(Config, MetricsRegistry)} */ @FunctionalInterface @InterfaceStability.Unstable public interface SideInputsProcessorFactory extends Serializable { /** * Creates a new instance of a {@link SideInputsProcessor}. * * @param config the configuration * @param metricsRegistry the metrics registry * @return an instance of {@link SideInputsProcessor} */ SideInputsProcessor getSideInputsProcessor(Config config, MetricsRegistry metricsRegistry); }
/** * A {@link Table} is an abstraction for data sources that support random access by key. It is an evolution of the * existing {@link KeyValueStore} API. It offers support for both local and remote data sources and composition through * hybrid tables. For remote data sources, a {@code RemoteTable} provides optimized access with caching, rate-limiting, * and retry support. * <p> * Use a {@link TableDescriptor} to specify the properties of a {@link Table}. For High Level API * {@link StreamApplication}s, use {@link StreamApplicationDescriptor#getTable} to obtain the {@link Table} instance for * the descriptor that can be used with the {@link MessageStream} operators like {@link MessageStream#sendTo(Table)}. * Alternatively, use {@link TaskContext#getTable(String)} in {@link InitableFunction#init} to get the table instance * for use within operator functions. For Low Level API {@link TaskApplication}s, use {@link TaskContext#getTable} * in {@link InitableTask#init} to get the table instance for use within the Task. * * @param <R> the type of records in the table */ @InterfaceStability.Unstable public interface Table<R> { }
/** * Function interface for providing rate limiting credits for each table record. * This interface allows callers to pass in lambda expressions which are otherwise * non-serializable as-is. * @param <K> the type of the key * @param <V> the type of the value */ @InterfaceStability.Unstable public interface CreditFunction<K, V> extends Serializable { /** * Get the number of credits required for the {@code key} and {@code value} pair. * @param key table key * @param value table record * @return number of credits */ int getCredits(K key, V value); }
/** * Transforms an input message into a collection of 0 or more messages, possibly of a different type. * * @param <M> type of the input message * @param <OM> type of the transformed messages */ @InterfaceStability.Unstable @FunctionalInterface public interface FlatMapFunction<M, OM> extends InitableFunction, ClosableFunction, Serializable { /** * Transforms the provided message into a collection of 0 or more messages. * * @param message the input message to be transformed * @return a collection of 0 or more transformed messages */ Collection<OM> apply(M message); }