| <!-- |
| |
| Licensed to the Apache Software Foundation (ASF) under one |
| or more contributor license agreements. See the NOTICE file |
| distributed with this work for additional information |
| regarding copyright ownership. The ASF licenses this file |
| to you under the Apache License, Version 2.0 (the |
| "License"); you may not use this file except in compliance |
| with the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, |
| software distributed under the License is distributed on an |
| "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| KIND, either express or implied. See the License for the |
| specific language governing permissions and limitations |
| under the License. |
| |
| --> |
| |
| ## 区间查询函数 |
| |
| ### 连续满足区间函数 |
| |
| 连续满足条件区间函数用来查询所有满足指定条件的连续区间。 |
| |
| 按返回值可分为两类: |
| 1. 返回满足条件连续区间的起始时间戳和时间跨度(时间跨度为0表示此处只有起始时间这一个数据点满足条件) |
| 2. 返回满足条件连续区间的起始时间戳和后面连续满足条件的点的个数(个数为1表示此处只有起始时间这一个数据点满足条件) |
| |
| | 函数名 | 输入序列类型 | 属性参数 | 输出序列类型 | 功能描述 | |
| |-------------------|--------------------------------------|------------------------------------------------|-------|------------------------------------------------------------------| |
| | ZERO_DURATION | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值0<br>`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续为0(false)的开始时间与持续时间,持续时间t(单位ms)满足`t >= min && t <= max` | |
| | NON_ZERO_DURATION | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值0<br>`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续不为0(false)的开始时间与持续时间,持续时间t(单位ms)满足`t >= min && t <= max` | | |
| | ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1<br>`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | |
| | NON_ZERO_COUNT | INT32/ INT64/ FLOAT/ DOUBLE/ BOOLEAN | `min`:可选,默认值1<br>`max`:可选,默认值`Long.MAX_VALUE` | Long | 返回时间序列连续不为0(false)的开始时间与其后数据点的个数,数据点个数n满足`n >= min && n <= max` | | |
| |
| 测试数据: |
| ``` |
| IoTDB> select s1,s2,s3,s4,s5 from root.sg.d2; |
| +-----------------------------+-------------+-------------+-------------+-------------+-------------+ |
| | Time|root.sg.d2.s1|root.sg.d2.s2|root.sg.d2.s3|root.sg.d2.s4|root.sg.d2.s5| |
| +-----------------------------+-------------+-------------+-------------+-------------+-------------+ |
| |1970-01-01T08:00:00.000+08:00| 0| 0| 0.0| 0.0| false| |
| |1970-01-01T08:00:00.001+08:00| 1| 1| 1.0| 1.0| true| |
| |1970-01-01T08:00:00.002+08:00| 1| 1| 1.0| 1.0| true| |
| |1970-01-01T08:00:00.003+08:00| 0| 0| 0.0| 0.0| false| |
| |1970-01-01T08:00:00.004+08:00| 1| 1| 1.0| 1.0| true| |
| |1970-01-01T08:00:00.005+08:00| 0| 0| 0.0| 0.0| false| |
| |1970-01-01T08:00:00.006+08:00| 0| 0| 0.0| 0.0| false| |
| |1970-01-01T08:00:00.007+08:00| 1| 1| 1.0| 1.0| true| |
| +-----------------------------+-------------+-------------+-------------+-------------+-------------+ |
| ``` |
| |
| sql: |
| ```sql |
| select s1, zero_count(s1), non_zero_count(s2), zero_duration(s3), non_zero_duration(s4) from root.sg.d2; |
| ``` |
| |
| 结果: |
| ``` |
| +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+ |
| | 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)| |
| +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+ |
| |1970-01-01T08:00:00.000+08:00| 0| 1| null| 0| null| |
| |1970-01-01T08:00:00.001+08:00| 1| null| 2| null| 1| |
| |1970-01-01T08:00:00.002+08:00| 1| null| null| null| null| |
| |1970-01-01T08:00:00.003+08:00| 0| 1| null| 0| null| |
| |1970-01-01T08:00:00.004+08:00| 1| null| 1| null| 0| |
| |1970-01-01T08:00:00.005+08:00| 0| 2| null| 1| null| |
| |1970-01-01T08:00:00.006+08:00| 0| null| null| null| null| |
| |1970-01-01T08:00:00.007+08:00| 1| null| 1| null| 0| |
| +-----------------------------+-------------+-------------------------+-----------------------------+----------------------------+--------------------------------+ |
| ``` |