Skip to content

Developing custom operators

Before you begin

Check out the Types of operators page in the product documentation to evaluate options before proceeding.

If existing operators, including the Custom operator, are insufficent to implement application logic, you can create your own primitive operators using a lower-level programming language like C++, Java, or Python.

Additionally, if you have duplicate sets of operators within one or more applications, you may want to create a composite operator.

Primitive operators

The extension provides convenient commands to create primitive operators within your workspace.

Creating a C++ operator

  1. Right-click in an editor or File Explorer
  2. Hover over SPL Project
  3. Click Create C++ Primitive Operator to open a wizard form
  4. Fill in the namespace, name, and whether to make the operator generic or not
  5. Click the Create Operator button

A namespace and operator directory will be created containing an operator model XML file and C++ code generation templates for your operator.

Proceed to implement the code and modify the operator model using these references:

Creating a Java operator

  1. Right-click in an editor or File Explorer
  2. Hover over SPL Project
  3. Click Create Java Primitive Operator to open a wizard form
  4. Fill in the namespace, name, and processing pattern
  5. Click the Create Operator button

An implementation directory will be created containing the operator Java file.

Proceed to implement the code using these references:

Important

Unlike C++ and Python, Java primitive operators must be compiled before they can be used by the SPL compiler. The extension creates a Makefile with a javac command to demonstrate this, but any build system can be used.

Creating a Python operator

  1. Right-click in an editor or File Explorer
  2. Hover over SPL Project
  3. Click Create Python Primitive Operator to open a wizard form
  4. Fill in the name and processing pattern
  5. Click the Create Operator button

An implementation directory will be created containing the operator Python file.

Proceed to implement the code using these references:

Using custom operators in your application

After implementing your operator logic, invoke the operator directly in your SPL application. For an example, see the C++ primitive operator at work application.

  1. After implementing your operator logic, compile the Java operator source code
  2. Invoke the operator directly in your SPL application

After implementing your operator logic, it is easiest to use a PythonOp operator in your SPL application to call the module. For an example, see the PythonOpScoring application.

Composite operators

Composite operators are defined in SPL files and can utilize the SPL language server.

Creating a composite operator

  1. Create or open an SPL file you want the composite operator in
  2. Activate IntelliSense: enter Ctrl+Space (Windows/Linux) or Cmd+Space (macOS)
  3. Type Add new composite with ports
  4. Hit Enter

Tip

Composite operators can have parameters similar to primitive operators. See the Composite operators tutorial in the product documentation and the Multiple composites at work sample for examples.

Using a composite operator in your application

After implementing your composite operator, invoke the operator directly in your SPL application. For an example, see the Multiple composites at work application.