Sybase CEP Eclipse plug-in enables users to write Sybase CEP applications in Continuous Computational Language (CCL).
This page provides information about two CCL statements not covered in other Sybase CEP documents: CREATE MODULE and LOAD MODULE.
Your application can contain any of the following statements, each of which is described in the Sybase CEP CCL Reference:
IMPORT
CREATE SCHEMA
CREATE FUNCTION
In addition, your application must contain one or more module definitions, using the CREATE MODULE statement described here:
create_module_statement: CREATE MODULE module_name module_statements END MODULE ; module_statements: { module_statement ; } module_statement: create_stream_statement | create_parameter_statement | create_schema_statement | create_function_statement | create_variable_statement | create_window_statement | create_public_window_statement | query_statement | database_statement | delete_statement | set_variable_statement | load_module_statement | attach_adapter_statement
Note that module definitions (CREATE MODULE statements)cannot contain other module definitions. Module definitions can contain CREATE SCHEMA and CREATE FUNCTION statements. The scope of such statements is the current module. The Sybase CEP CCL Reference describes each of the statements listed in the definition of module_statement, with the exception of the LOAD MODULE statement, which is described here:
load_module_statement: LOAD MODULE module_name AS load_name [ STREAMS module_streams_bindings_list ] [ PARAMETERS module_parameters_bindings_list ] [ PROPERTIES module_properties_list ] ; module_streams_bindings_list: stream_binding {, stream_binding } stream_binding: stream_name = stream_value module_parameters_bindings_list: parameter_binding {, parameter_binding } parameter_binding: parameter_name = parameter_value module_properties_list: module_property {, module_property } module_property: module_property_name = module_property_value
Note:
Names (module, streams, parameters, and properties) are case-insensitive.
stream_value can either be the name of a stream in the loading module or a string containing a ccl:// or http:// stream URI.
For more information about stream bindings, see the Creating Data Stream Bindings section of the Sybase CEP Studio Guide.
Valid values for module_property_value depend on the specified property, as described below:
Property |
Value |
---|---|
GUARANTEED DELIVERY |
INHERIT | ENABLE | DISABLE |
GUARANTEED DELIVERY MAXIMUM QUEUE SIZE |
integer |
GUARANTEED DELIVERY MAXIMUM AGE |
interval |
SYNCHRONIZATION |
USE SERVER TIMESTAMP|IN ORDER|OUT OF ORDER|INHERIT |
OUT OF ORDER DELAY |
interval |
MAXIMUM DELAY |
interval |
PERSISTENCE |
INHERIT | ENABLE | DISABLE |
PERSISTENCE COMMIT INTERVAL |
interval |
For more information about these properties and values, as well as additional information about bindings, see the Editing Query Module Properties section of the Sybase CEP Studio Guide.
Note: Modules cannot be loaded recursively, either directly or indirectly.
The following code defines a simple module for calculating the CCI index:
// Define CCI module CREATE MODULE CCI // Module interface CREATE INPUT STREAM Trades SCHEMA (Symbol STRING, Price FLOAT); CREATE OUTPUT STREAM Cci SCHEMA (Symbol STRING, CCI FLOAT); CREATE PARAMETER INTERVAL IntervalSize = 15 minutes; // Module implementation CREATE STREAM TypicalPrice; INSERT INTO TypicalPrice SELECT Price, Cci.CCI FROM Trades KEEP 24 HOURS, Cci WHERE Trades.Symbol = Cci.Symbol ; END MODULE; // CCI
To instantiate the module, use the LOAD MODULE statement:
/// Load the module definition /// IMPORT "Finance/CCI.ccl"; CREATE MODULE Main CREATE STREAM CciShortStream; CREATE STREAM CciLongStream; /// @name CciShort /// /// instantiate the module with "1 minute" interval /// LOAD MODULE CCI AS CCI_Short STREAMS Trades = "ccl://server:6789/Stream/Ws/Source/TradesStream", Cci = CciShortStream PARAMETERS IntervalSize = 1 minute PROPERTIES PERSISTENCE = INHERIT, GUARANTEED DELIVERY = INHERIT ; /// @name CciLong /// /// instantiate the module with "15 minutes" interval /// LOAD MODULE CCI AS CCI_Long STREAMS Trades = "ccl://server:6789/Stream/Ws/Source/TradesStream", Cci = CciLongStream PARAMETERS IntervalSize = 15 minutes PROPERTIES PERSISTENCE = INHERIT, GUARANTEED DELIVERY = INHERIT ; END MODULE;