Operators implemented in Java

SPL offers two approaches for implementing operators in Java, Java primitive operators and the JavaOp operator.

Java primitive operators are analogous to C++ operators that use the reflection API. There is no analog to mixed-mode with Java. Although operators implemented in Java can be parameterized to a great degree, they do not have the full-flexibility of C++ operators because there is no mixed-mode available. When you implement operators in Java, you must use the Java Operator API to receive, inspect, and submit tuples. Invocations of the JavaOp operator (provided by the SPL Standard Toolkit) are a generalized call to Java. Similar to the Custom operator, JavaOp operators are useful for prototyping. Using the JavaOp operator does not require defining a model that specifies the syntactic and semantics properties of the operator. In both cases, there is an additional runtime cost to serializing and deserializing tuples across the JVM boundary. However, this cost is low unless the operator is doing very little work relative to each tuple.

Both JavaOp operators and Java primitive operators use the Java Operator API. JavaOp operators, however, are not technically primitive operators. Rather, JavaOp operators provide a general way to call Java from SPL. Developers use the operator parameter className to specify the class name that contains the tuple processing logic. Similar to writing single-use Custom operators, developers do not have to provide an operator model for JavaOp operators. JavaOp operators have no restrictions on the number of input and output streams, or on the number of constant parameters. However, JavaOp operators are intended to be an easy way to prototype Java operators in SPL. The SPL compiler has no knowledge of how the operator is used because it does not have an operator model that is specialized for each invocation. Consequently, the SPL compiler cannot check at compile time to ensure that a particular invocation of the JavaOp operator is correct.

Java primitive operators are the preferred method for implementing primitive operators in Java because they are seamlessly integrated into SPL. Similar to C++ primitive operators, Java primitive operators have a unique name. The SPL compiler can enforce compile-time checks of operator parameters, and on the number of input and output ports. Unlike the JavaOp operator that has a generic operator model, Java primitive operators use specialized operator models that describe such constraints.

Java primitive operators also provide better implementation encapsulation. A user of the operator does not need to know the name of the Java class and the required class path for the operator implementation. This information is described directly in the operator model. SPL developers that use a Java primitive operator do not need to know that the operator they are invoking is implemented in Java.