Series Discovery

ConsecutiveSequences

Usage

This function is used to find locally longest consecutive subsequences in strictly equispaced multidimensional data.

Strictly equispaced data is the data whose time intervals are strictly equal. Missing data, including missing rows and missing values, is allowed in it, while data redundancy and timestamp drift is not allowed.

Consecutive subsequence is the subsequence that is strictly equispaced with the standard time interval without any missing data. If a consecutive subsequence is not a proper subsequence of any consecutive subsequence, it is locally longest.

Name: CONSECUTIVESEQUENCES

Input Series: Support multiple input series. The type is arbitrary but the data is strictly equispaced.

Parameters:

  • gap: The standard time interval which is a positive number with an unit. The unit is ‘ms’ for millisecond, ‘s’ for second, ‘m’ for minute, ‘h’ for hour and ‘d’ for day. By default, it will be estimated by the mode of time intervals.

Output Series: Output a single series. The type is INT32. Each data point in the output series corresponds to a locally longest consecutive subsequence. The output timestamp is the starting timestamp of the subsequence and the output value is the number of data points in the subsequence.

Note: For input series that is not strictly equispaced, there is no guarantee on the output.

Examples

Manually Specify the Standard Time Interval

It’s able to manually specify the standard time interval by the parameter gap. It’s notable that false parameter leads to false output.

Input series:

  1. +-----------------------------+---------------+---------------+
  2. | Time|root.test.d1.s1|root.test.d1.s2|
  3. +-----------------------------+---------------+---------------+
  4. |2020-01-01T00:00:00.000+08:00| 1.0| 1.0|
  5. |2020-01-01T00:05:00.000+08:00| 1.0| 1.0|
  6. |2020-01-01T00:10:00.000+08:00| 1.0| 1.0|
  7. |2020-01-01T00:20:00.000+08:00| 1.0| 1.0|
  8. |2020-01-01T00:25:00.000+08:00| 1.0| 1.0|
  9. |2020-01-01T00:30:00.000+08:00| 1.0| 1.0|
  10. |2020-01-01T00:35:00.000+08:00| 1.0| 1.0|
  11. |2020-01-01T00:40:00.000+08:00| 1.0| null|
  12. |2020-01-01T00:45:00.000+08:00| 1.0| 1.0|
  13. |2020-01-01T00:50:00.000+08:00| 1.0| 1.0|
  14. +-----------------------------+---------------+---------------+

SQL for query:

  1. select consecutivesequences(s1,s2,'gap'='5m') from root.test.d1

Output series:

  1. +-----------------------------+------------------------------------------------------------------+
  2. | Time|consecutivesequences(root.test.d1.s1, root.test.d1.s2, "gap"="5m")|
  3. +-----------------------------+------------------------------------------------------------------+
  4. |2020-01-01T00:00:00.000+08:00| 3|
  5. |2020-01-01T00:20:00.000+08:00| 4|
  6. |2020-01-01T00:45:00.000+08:00| 2|
  7. +-----------------------------+------------------------------------------------------------------+

Automatically Estimate the Standard Time Interval

When gap is default, this function estimates the standard time interval by the mode of time intervals and gets the same results. Therefore, this usage is more recommended.

Input series is the same as above, the SQL for query is shown below:

  1. select consecutivesequences(s1,s2) from root.test.d1

Output series:

  1. +-----------------------------+------------------------------------------------------+
  2. | Time|consecutivesequences(root.test.d1.s1, root.test.d1.s2)|
  3. +-----------------------------+------------------------------------------------------+
  4. |2020-01-01T00:00:00.000+08:00| 3|
  5. |2020-01-01T00:20:00.000+08:00| 4|
  6. |2020-01-01T00:45:00.000+08:00| 2|
  7. +-----------------------------+------------------------------------------------------+

ConsecutiveWindows

Usage

This function is used to find consecutive windows of specified length in strictly equispaced multidimensional data.

Strictly equispaced data is the data whose time intervals are strictly equal. Missing data, including missing rows and missing values, is allowed in it, while data redundancy and timestamp drift is not allowed.

Consecutive window is the subsequence that is strictly equispaced with the standard time interval without any missing data.

Name: CONSECUTIVEWINDOWS

Input Series: Support multiple input series. The type is arbitrary but the data is strictly equispaced.

Parameters:

  • gap: The standard time interval which is a positive number with an unit. The unit is ‘ms’ for millisecond, ‘s’ for second, ‘m’ for minute, ‘h’ for hour and ‘d’ for day. By default, it will be estimated by the mode of time intervals.
  • length: The length of the window which is a positive number with an unit. The unit is ‘ms’ for millisecond, ‘s’ for second, ‘m’ for minute, ‘h’ for hour and ‘d’ for day. This parameter cannot be lacked.

Output Series: Output a single series. The type is INT32. Each data point in the output series corresponds to a consecutive window. The output timestamp is the starting timestamp of the window and the output value is the number of data points in the window.

Note: For input series that is not strictly equispaced, there is no guarantee on the output.

Examples

Input series:

  1. +-----------------------------+---------------+---------------+
  2. | Time|root.test.d1.s1|root.test.d1.s2|
  3. +-----------------------------+---------------+---------------+
  4. |2020-01-01T00:00:00.000+08:00| 1.0| 1.0|
  5. |2020-01-01T00:05:00.000+08:00| 1.0| 1.0|
  6. |2020-01-01T00:10:00.000+08:00| 1.0| 1.0|
  7. |2020-01-01T00:20:00.000+08:00| 1.0| 1.0|
  8. |2020-01-01T00:25:00.000+08:00| 1.0| 1.0|
  9. |2020-01-01T00:30:00.000+08:00| 1.0| 1.0|
  10. |2020-01-01T00:35:00.000+08:00| 1.0| 1.0|
  11. |2020-01-01T00:40:00.000+08:00| 1.0| null|
  12. |2020-01-01T00:45:00.000+08:00| 1.0| 1.0|
  13. |2020-01-01T00:50:00.000+08:00| 1.0| 1.0|
  14. +-----------------------------+---------------+---------------+

SQL for query:

  1. select consecutivewindows(s1,s2,'length'='10m') from root.test.d1

Output series:

  1. +-----------------------------+--------------------------------------------------------------------+
  2. | Time|consecutivewindows(root.test.d1.s1, root.test.d1.s2, "length"="10m")|
  3. +-----------------------------+--------------------------------------------------------------------+
  4. |2020-01-01T00:00:00.000+08:00| 3|
  5. |2020-01-01T00:20:00.000+08:00| 3|
  6. |2020-01-01T00:25:00.000+08:00| 3|
  7. +-----------------------------+--------------------------------------------------------------------+