Rules for rolling window containers

Rolling window containers store data in partitions by date intervals and can automatically delete old data. The active window and the dormant window have a set of behaviors that affect how the data is handled and how you can interact with the data.

To create a rolling window container, run the TSContainerCreate function. Specify the size of a partition. Specify maximum sizes for the active and dormant windows. Enable the automatic deletion of old partitions. Specify multiple dbspaces in which to store partitions.

To change the properties or the layout of rolling window containers, run the TSContainerManage function. You can change the window sizes, attach or detach partitions, destroy partitions, change whether partitions are destroyed automatically, and change the extent sizes of partitions.

To take advantage of rolling windows, set the sizes of the active and dormant windows to positive integers. If you set the size of the active window to 0, the active window size is unlimited and you must manually detach partitions into the dormant window. If you set the size of the dormant window to 0, you must manually destroy partitions, regardless of whether you enable the automatic destroying of partitions.

Set the active window size to the same or larger than the time range of data that you plan to load. If the range of data is larger than the active window size, the load might fail. For example, suppose that you are storing meter data and choose an interval of one week and an active window size of four weeks. When you add a month of data for the first meter ID, five partitions are created because a month is usually longer than four weeks. The partition that stores the data for the first week of the month is moved to the dormant window. When you attempt to insert a month of data for the next meter ID, the insert fails because some of the data does not fit into the active window.

In general, set the size of the dormant window larger than the size of the active window. The dormant window provides a staging area for data that you no longer need but that you do not yet want to delete.

If you enable the automatic destroying of partitions, test your system under realistic conditions before you implement it. Consider the size of your active and dormant windows and how you insert data. For example, the active and dormant windows each have a maximum size of three intervals. If you insert data that has a timestamp of seven intervals later than the most recent original data, all of your original data is destroyed.

The following list of rules describe the behavior of the active window and dormant windows if you set both the window sizes to positive numbers. The examples that are provided assume that the active window has a monthly interval, has a maximum size of 6 partitions, and contains partitions for January, February, and March. The dormant window has a maximum size of 3 partitions.

Rules for querying, inserting, and modifying data:

  • You cannot query, insert, update, or delete data from a partition in a dormant window.
  • You can query, insert, update, and delete the data in the partitions that are in the active window. For example, you can insert, update, or delete an element for February 28.
  • If you add data with timestamps that are after the latest partition, new partitions are created automatically in the active window. For example, you insert an element for March 2. A new partition is created for March.
  • You can add data that is earlier than the oldest partition if both of the following conditions are met:
    • The data does not have timestamps that are before the origin of the rolling window container.
    • The active window has space for the new partition, which is created automatically.
    • The dormant window does not have data that has the same or a more recent timestamp than the data that is being added. For example, the dormant window is empty, and you insert an element for December 31 of the previous year. A new partition is created for December in the active window.
  • If you add data that is more than one interval later than the latest partition, intermediate empty partitions are also created. Empty partitions are counted in the window size. For example, you insert an element for May 15. New partitions are created for April and May. The April partition remains empty until you insert data for April. The active window has 6 partitions.
  • When you add data for a new partition and the active window is full, the oldest partition automatically moves to the dormant window. For example, you add data for July. Partitions are created automatically for June and July. The partitions for December and January are moved to the dormant window.

Rules for managing partitions:

  • You can manually detach partitions from the active window to the dormant window. Any partitions older than the partition you choose to detach are also detached. For example, if you detach the March partition to the dormant window, the February partition is detached automatically. However, if the dormant window is full and partitions are not destroyed automatically, that detach operation fails. You must first manually destroy the appropriate number of partitions.
  • You can attach partitions into the active window from the dormant window. The active window must have room for that partition and any partitions that belong in between that partition and the oldest partition in the active window. For example, you attach the January partition to the active window. The February partition is attached automatically to the active window.
  • You can change the size of the active window. If you make the size of the active window larger, you can attach partitions from the dormant window. For example, you change the active window size to 9 and attach the December partition to the active window. The January partition also attaches to the active window. If you make the size of the active window smaller, the oldest partitions that exceed the new maximum size are detached to the dormant window. However, if the dormant window is full and partitions are not destroyed automatically, the resizing operation fails. You must first manually destroy the appropriate number of partitions.
  • You can limit the number of partitions for future dates. Limiting partitions for future data protects the partition for current data from being destroyed. For example, if the current month is March, and a malicious user enters data for October of the same year, the March partition is moved to the dormant window. When the user enters data for January of the next year, the March partition is destroyed. To limit future partitions, set the window_control parameter to include the value 4 and set the future_count parameter to the maximum number of future partitions.

Rules for destroying data:

  • When you add data and one or more new active partitions are created so that the number of active partitions exceeds the active window size, the appropriate number of older active partitions are detached and moved to the dormant window. How the partitions that are being moved to the dormant window are handled depends on the number of partitions that are being moved and the window_control parameter:
    • If the number of active partitions that are being detached is less than or equal to the dormant window size, then the active partitions are moved to the dormant window. If the number of dormant partitions exceeds the dormant window size, the older partitions are destroyed.
    • If the number of partitions that must be detached is greater than the dormant windows size, you specify the action taken by setting the window_control parameter:
      • To allow as any dormant partitions as necessary to be destroyed but prevent any active partitions from being destroyed, set the window_control parameter to 0. An operation fails if it requires active partitions to be destroyed.
      • To allow as many as necessary active and dormant partitions to be destroyed, set the window_control parameter to 1.
      • To prevent active partitions from being destroyed and limit the number of dormant partitions that can be destroyed, set the window control flag to 2 and set the destroy_count parameter to a positive integer.
      • To allow a specific number of active and dormant partitions to be destroyed, set the window_control parameter to 3 and the destroy_count parameter to a positive integer.
  • You can manually destroy partitions in the dormant window. Any partitions that are older than the date that you specify are destroyed. For example, the dormant window contains partitions for January, February, and March. You specify to destroy partitions before March. The February and January partitions are destroyed.
  • You can change the size of the dormant window. If you make it smaller, the action that is taken depends on the window_control parameter. The behavior is the same as when you add partitions.
  • You can change the type and number of partitions that can be destroyed.

Copyright© 2018 HCL Technologies Limited