LOAD MODULE Statement

The LOAD MODULE statement loads a previously created module into the project. The CREATE MODULE statement can either be in the current CCL file or in an imported CCL file (see IMPORT statement).

Syntax

LOAD MODULE modulename AS moduleIdentifier
	in-clause
	out-clause
	[parameters-clause]
	[stores-clause];

Components

moduleName

The name of the module, which must match the name of the previously created module.

module identifier

The name used to identify this instance of the module: it must be unique within the parent scope.

IN clause

Binds the input streams or windows defined in the module to previously-created streams or windows in the parent scope.

OUT clause

Exposes one or more output streams defined within the module to the parent scope using unique identifiers.

PARAMETERS clause

Binds one or more parameters defined inside the module to an expression at load time, or binds parameters inside the module to another parameter within the main project. If the parameter has a default value defined, then no parameter binding is required.

STORES clause

Binds a store in the module to a store within the parent scope.

Usage

The LOAD MODULE statement is used to create a instance of a previously defined module in the current project. The IN, OUT and optional PARAMETERS and STORES clauses bind the module to elements in the calling project. The same module may be "loaded" multiple times in a single project.

Before a module can be loaded, it must be defined in a CREATE MODULE statement in either the same project or an imported CCL file.

All streams in a loaded module have local visibility at runtime, meaning they cannot be subscribed to, published from, or queried. When a module is loaded on the server, all of the streams and windows within the module, and the output streams and windows created by exposing outputs to the parent scope, behave as if they have local visibility. Therefore, the streams and windows within a module and the exposed outputs of the module cannot be queried externally or subscribed to.

LOAD MODULE supports:
  • IN clause
  • OUT clause
  • PARAMETERS clause
  • STORES clause
Note: All LOAD MODULE statement compilation errors are fatal.

Example

This example defines a module that processes raw stock trade information and outputs a list of trades with a price exceeding 1.00. The project then creates an instance of the module using the LOAD MODULE statement. The LOAD MODULE statement binds the project input stream "NYSEData" to the input stream of the module (TradeData) and creates a local stream called "NYSEPriceOver1Data" that is bound to the output stream of the module (FilteredTradeData).

CREATE MODULE FilterByPrice IN TradeData OUT FilteredTradeData
BEGIN 
	CREATE SCHEMA TradesSchema (
	Id integer, 
	TradeTime date,
	Venue string,  
	Symbol string, 
	Price float, 
	Shares integer
);

	CREATE INPUT STREAM TradeData SCHEMA TradesSchema;
	CREATE OUTPUT STREAM FilteredTradeData SCHEMA TradesSchema 
	AS SELECT * FROM TradeData WHERE TradeData.Price > 1.00;
END;

CREATE INPUT STREAM NYSEData SCHEMA TradesSchema;

LOAD MODULE FilterByPrice AS FilterOver1 IN TradeData = NYSEData OUT FilteredTradeData = NYSEPriceOver1Data;