Configuring additional container pools

You can create a container pool to manage how time series data is inserted into multiple containers. You can insert data into containers in round-robin order or by using a user-defined method.

If you want to use a container pool policy other than round-robin order, you must write the user-defined container pool policy function before you insert data into the container pool. For more information, see User-defined container pool policy.

To create a container pool and store data into containers by using a container pool policy:

  1. Create containers by running the TSContainerCreate procedure.
  2. Add each container to the container pool by using the TSContainerSetPool procedure.
  3. Insert data into the time series by including the TSContainerPoolRoundRobin function with the container pool name or by including your user-defined container pool policy function in the container argument.

Example

This example uses a TimeSeries subtype named smartmeter_row that is in a column named rawreadings, which is in a table named smartmeters. Suppose you want to store the data for the time series in three containers, in a container pool you created.

The following statements create three containers for the TimeSeries subtype smartmeter_row:

EXECUTE PROCEDURE TSContainerCreate
                    ('ctn_sm0','tsspace0','smartmeter_row',0,0);
EXECUTE PROCEDURE TSContainerCreate
                    ('ctn_sm1','tsspace1','smartmeter_row',0,0);
EXECUTE PROCEDURE TSContainerCreate
                    ('ctn_sm2','tsspace2','smartmeter_row',0,0);

The following statements add the containers to a container pool named readings:

EXECUTE PROCEDURE TSContainerSetPool('ctn_sm0','readings');
EXECUTE PROCEDURE TSContainerSetPool('ctn_sm1','readings');
EXECUTE PROCEDURE TSContainerSetPool('ctn_sm2','readings');

The following statement inserts time series data into the column rawreadings. The TSContainerPoolRoundRobin function that specifies the container pool named readings is used instead of a container name in the container argument.

INSERT INTO smartmeters(meter_id,rawreadings)
     VALUES('met00001','origin(2006-01-01 00:00:00.00000),
            calendar(smartmeter),regular,threshold(0),
            container(TSContainerPoolRoundRobin(readings)),
                [(33070,-13.00,100.00,9.98e+34),
                 (19347,-4.00,100.00,1.007e+35),
                 (17782,-18.00,100.00,9.83e+34)]');

During the running of the INSERT statement, the TSContainerPoolRoundRobin function runs with the following values:

TSContainerPoolRoundRobin('smartmeters','rawreadings', 
                          'smartmeter_row',0,'readings')

The TSContainerPoolRoundRobin function sorts the container names alphabetically, returns the container name ctn_sm0 to the INSERT statement, and the data is stored in the ctn_sm0 container. The TSContainerPoolRoundRobin function specifies to store the data from the next INSERT statement in the container named ctn_sm1 and the data from the third INSERT statement in the container named ctn_sm2. For the fourth INSERT statement, the TSContainerPoolRoundRobin function returns to the beginning of the container list and specifies to store the data in the container named ctn_sm0, and so on.


Copyright© 2018 HCL Technologies Limited