Continuous Interval Functions

The continuous interval functions are used to query all continuous intervals that meet specified conditions. They can be divided into two categories according to return value:

  1. Returns the start timestamp and time span of the continuous interval that meets the conditions (a time span of 0 means that only the start time point meets the conditions)
  2. Returns the start timestamp of the continuous interval that meets the condition and the number of points in the interval (a number of 1 means that only the start time point meets the conditions)
Function NameInput TSDatatypeParametersOutput TSDatatypeFunction Description
ZERO_DURATIONINT32/ INT64/ FLOAT/ DOUBLE/ BOOLEANmin:Optional with default value 0L
max:Optional with default value Long.MAX_VALUE
LongReturn intervals’ start times and duration times in which the value is always 0(false), and the duration time t satisfy t >= min && t <= max. The unit of t is ms
NON_ZERO_DURATIONINT32/ INT64/ FLOAT/ DOUBLE/ BOOLEANmin:Optional with default value 0L
max:Optional with default value Long.MAX_VALUE
LongReturn intervals’ start times and duration times in which the value is always not 0, and the duration time t satisfy t >= min && t <= max. The unit of t is ms
ZERO_COUNTINT32/ INT64/ FLOAT/ DOUBLE/ BOOLEANmin:Optional with default value 1L
max:Optional with default value Long.MAX_VALUE
LongReturn intervals’ start times and the number of data points in the interval in which the value is always 0(false). Data points number n satisfy n >= min && n <= max
NON_ZERO_COUNTINT32/ INT64/ FLOAT/ DOUBLE/ BOOLEANmin:Optional with default value 1L
max:Optional with default value Long.MAX_VALUE
LongReturn intervals’ start times and the number of data points in the interval in which the value is always not 0(false). Data points number n satisfy n >= min && n <= max
Demonstrate

Example data:

  1. IoTDB> select s1,s2,s3,s4,s5 from root.sg.d2;
  2. +-----------------------------+-------------+-------------+-------------+-------------+-------------+
  3. | Time|root.sg.d2.s1|root.sg.d2.s2|root.sg.d2.s3|root.sg.d2.s4|root.sg.d2.s5|
  4. +-----------------------------+-------------+-------------+-------------+-------------+-------------+
  5. |1970-01-01T08:00:00.000+08:00| 0| 0| 0.0| 0.0| false|
  6. |1970-01-01T08:00:00.001+08:00| 1| 1| 1.0| 1.0| true|
  7. |1970-01-01T08:00:00.002+08:00| 1| 1| 1.0| 1.0| true|
  8. |1970-01-01T08:00:00.003+08:00| 0| 0| 0.0| 0.0| false|
  9. |1970-01-01T08:00:00.004+08:00| 1| 1| 1.0| 1.0| true|
  10. |1970-01-01T08:00:00.005+08:00| 0| 0| 0.0| 0.0| false|
  11. |1970-01-01T08:00:00.006+08:00| 0| 0| 0.0| 0.0| false|
  12. |1970-01-01T08:00:00.007+08:00| 1| 1| 1.0| 1.0| true|
  13. +-----------------------------+-------------+-------------+-------------+-------------+-------------+

Sql:

  1. select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2;

Result:

  1. +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+
  2. | Time|root.sg.d2.s1|zero_count(root.sg.d2.s1)|non_zero_count(root.sg.d2.s2)|zero_duration(root.sg.d2.s3)|non_zero_duration(root.sg.d2.s4)|
  3. +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+
  4. |1970-01-01T08:00:00.000+08:00| 0| 1| null| 0| null|
  5. |1970-01-01T08:00:00.001+08:00| 1| null| 2| null| 1|
  6. |1970-01-01T08:00:00.002+08:00| 1| null| null| null| null|
  7. |1970-01-01T08:00:00.003+08:00| 0| 1| null| 0| null|
  8. |1970-01-01T08:00:00.004+08:00| 1| null| 1| null| 0|
  9. |1970-01-01T08:00:00.005+08:00| 0| 2| null| 1| null|
  10. |1970-01-01T08:00:00.006+08:00| 0| null| null| null| null|
  11. |1970-01-01T08:00:00.007+08:00| 1| null| 1| null| 0|
  12. +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+