Declaring a Partitioning Global Parameter

Automatic partitioning is the creation of parallel instances of an element and splitting input data across these instances. This can improve the performance of an element and complex projects, which perform computationally expensive operations such as aggregation and joins. This example demonstrates how to create a global parameter to indicate the number of partitions you wish to create.

You can create parallel instances of a delta stream, stream, window, or module. Reference streams, unions, inputs, adapters, splitters, and error streams cannot use partitioning.

You can specify the number of partitions by using the PARTITIONS keyword or by providing a global parameter. To manually create a global parameter in your CCL file and set a default value, specify:
DECLARE 
    PARAMETER integer <NameofParameter> := 3 ;
END;
Alternatively, you can create a global parameter using the SAP Sybase ESP Authoring perspective in the SAP Sybase Event Stream Processor Studio. To do this:
  1. In the Outline view, right-click Statements or one of its child folders and select Modify > Edit Global Declaration(s).
  2. Enter the new parameter. To see a list of datatypes, press Ctrl+Space.
Here is an example of CUSTOM partitioning on a CCL query with one input window (InputWin):
DECLARE 
    PARAMETER integer NoOfPartitions := 3 ;
END;

CREATE INPUT WINDOW InputWin SCHEMA (
	id integer ,
	name string ,
	price double ) 
PRIMARY KEY ( id ) ;
	
CREATE OUTPUT DELTA STREAM PartitionedWin PRIMARY KEY DEDUCED 
PARTITION BY InputWin {
    return InputWin.id % PartitionedWin_partitions;
} 
PARTITIONS NoOfPartitions 
AS SELECT * FROM InputWin ;
where NoOfPartitions is the global parameter you created prior to creating the input window (InputWin) and delta stream (PartitionedWin).
If you change the value of this parameter in your CCL file, save the file and recompile your ESP project. To avoid doing this every time you change the value, you can override the value in the CCL file by specifying a value for this parameter within your project configuration (.ccr) file. To do this using ESP Studio:
  1. In the Project Explorer view, right-click the .ccr file for your project to open the Project Configurations editor.
  2. Select the Parameters tab in the CCR Project Configuration editor.
  3. Select the parameter you created to indicate the number of partitions and change the value in the Parameter Details pane.