Skip to content

Commit 1a24c74

Browse files
authored
add udf function idwt (#1066)
1 parent e3d7de2 commit 1a24c74

17 files changed

Lines changed: 1500 additions & 5462 deletions

src/UserGuide/Master/Tree/SQL-Manual/UDF-Libraries_apache.md

Lines changed: 94 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,7 +3280,97 @@ Output series:
32803280
+-----------------------------+-------------------------------------+
32813281
```
32823282

3283-
### 5.4 FFT
3283+
### 5.4 IDWT
3284+
3285+
#### Registration statement
3286+
3287+
```sql
3288+
create function dwt as 'org.apache.iotdb.library.frequency.UDTFIDWT'
3289+
```
3290+
3291+
#### Usage
3292+
3293+
This function performs one-dimensional inverse discrete wavelet transform on the input series, reconstructing the original data from DWT decomposed wavelet coefficients.
3294+
3295+
**Name:** IDWT
3296+
3297+
**Input:** Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.
3298+
3299+
**Parameters:**
3300+
3301+
+ `method`: The type of wavelet. May select 'Haar', 'DB4', 'DB6', 'DB8', where DB means Daubechies. User may offer coefficients of wavelet transform and ignore this parameter. Case ignored.
3302+
+ `coef`: Coefficients of wavelet transform. When providing this parameter, use comma ',' to split them, and leave no spaces or other punctuations.
3303+
+ `layer`: Times to transform. The number of output vectors equals $layer+1$. Default is 1.
3304+
3305+
**Output:** Output a single series. The type is DOUBLE. The length is the same as the input.
3306+
3307+
**Note:**
3308+
* The length of input series must be an integer number power of 2.
3309+
* The parameter settings of the IDWT function (method/coef/layer) should be consistent with the corresponding DWT transformation to correctly reconstruct the original data.
3310+
* Typically, the input of IDWT is the output result of the DWT function.
3311+
3312+
#### Examples
3313+
3314+
##### Haar wavelet transform
3315+
3316+
Input series:
3317+
3318+
```
3319+
+-----------------------------+--------------------+
3320+
| Time| root.test.d1.s2|
3321+
+-----------------------------+--------------------+
3322+
|1970-01-01T08:00:00.000+08:00| 0.1414213562373095|
3323+
|1970-01-01T08:00:00.100+08:00| 1.909188309203678|
3324+
|1970-01-01T08:00:00.200+08:00| 1.6263455967290592|
3325+
|1970-01-01T08:00:00.300+08:00| 1.979898987322333|
3326+
|1970-01-01T08:00:00.400+08:00| 3.2526911934581184|
3327+
|1970-01-01T08:00:00.500+08:00| 1.414213562373095|
3328+
|1970-01-01T08:00:00.600+08:00| 2.1213203435596424|
3329+
|1970-01-01T08:00:00.700+08:00| 1.8384776310850235|
3330+
|1970-01-01T08:00:00.800+08:00| -0.1414213562373095|
3331+
|1970-01-01T08:00:00.900+08:00| 0.21213203435596428|
3332+
|1970-01-01T08:00:01.000+08:00| -0.7778174593052022|
3333+
|1970-01-01T08:00:01.100+08:00| -0.8485281374238569|
3334+
|1970-01-01T08:00:01.200+08:00| 0.2828427124746189|
3335+
|1970-01-01T08:00:01.300+08:00| -1.414213562373095|
3336+
|1970-01-01T08:00:01.400+08:00| 0.42426406871192857|
3337+
|1970-01-01T08:00:01.500+08:00|-0.42426406871192857|
3338+
+-----------------------------+--------------------+
3339+
```
3340+
3341+
SQL for query:
3342+
3343+
```sql
3344+
select idwt(s2,"method"="haar") from root.test.d1
3345+
```
3346+
3347+
Output series:
3348+
3349+
```
3350+
+-----------------------------+--------------------------------------+
3351+
| Time|idwt(root.test.d1.s2, "method"="haar")|
3352+
+-----------------------------+--------------------------------------+
3353+
|1970-01-01T08:00:00.000+08:00| 0.0|
3354+
|1970-01-01T08:00:00.100+08:00| 0.19999999999999998|
3355+
|1970-01-01T08:00:00.200+08:00| 1.4999999999999996|
3356+
|1970-01-01T08:00:00.300+08:00| 1.1999999999999997|
3357+
|1970-01-01T08:00:00.400+08:00| 0.6|
3358+
|1970-01-01T08:00:00.500+08:00| 1.6999999999999997|
3359+
|1970-01-01T08:00:00.600+08:00| 0.7999999999999998|
3360+
|1970-01-01T08:00:00.700+08:00| 1.9999999999999996|
3361+
|1970-01-01T08:00:00.800+08:00| 2.4999999999999996|
3362+
|1970-01-01T08:00:00.900+08:00| 2.1|
3363+
|1970-01-01T08:00:01.000+08:00| 0.0|
3364+
|1970-01-01T08:00:01.100+08:00| 1.9999999999999996|
3365+
|1970-01-01T08:00:01.200+08:00| 1.7999999999999998|
3366+
|1970-01-01T08:00:01.300+08:00| 1.1999999999999997|
3367+
|1970-01-01T08:00:01.400+08:00| 0.9999999999999998|
3368+
|1970-01-01T08:00:01.500+08:00| 1.5999999999999999|
3369+
+-----------------------------+--------------------------------------+
3370+
```
3371+
3372+
3373+
### 5.5 FFT
32843374

32853375
#### Registration statement
32863376

@@ -3410,7 +3500,7 @@ Note: Based on the conjugation of the Fourier transform result, only the first h
34103500
According to the given parameter, data points are reserved from low frequency to high frequency until the reserved energy ratio exceeds it.
34113501
The last data point is reserved to indicate the length of the series.
34123502

3413-
### 5.5 HighPass
3503+
### 5.6 HighPass
34143504

34153505
#### Registration statement
34163506

@@ -3503,7 +3593,7 @@ Output series:
35033593

35043594
Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, the output is $y=sin(2\pi t/4)$ after high-pass filtering.
35053595

3506-
### 5.6 IFFT
3596+
### 5.7 IFFT
35073597

35083598
#### Registration statement
35093599

@@ -3586,7 +3676,7 @@ Output series:
35863676
+-----------------------------+-------------------------------------------------------+
35873677
```
35883678

3589-
### 5.7 LowPass
3679+
### 5.8 LowPass
35903680

35913681
#### Registration statement
35923682

@@ -3679,26 +3769,7 @@ Output series:
36793769

36803770
Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, the output is $y=2sin(2\pi t/5)$ after low-pass filtering.
36813771

3682-
<!--
3683-
3684-
​ Licensed to the Apache Software Foundation (ASF) under one
3685-
​ or more contributor license agreements. See the NOTICE file
3686-
​ distributed with this work for additional information
3687-
​ regarding copyright ownership. The ASF licenses this file
3688-
​ to you under the Apache License, Version 2.0 (the
3689-
​ "License"); you may not use this file except in compliance
3690-
​ with the License. You may obtain a copy of the License at
3691-
3692-
​ http://www.apache.org/licenses/LICENSE-2.0
3693-
3694-
​ Unless required by applicable law or agreed to in writing,
3695-
​ software distributed under the License is distributed on an
3696-
​ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3697-
​ KIND, either express or implied. See the License for the
3698-
​ specific language governing permissions and limitations
3699-
​ under the License.
37003772

3701-
-->
37023773

37033774
## 6. Data Matching
37043775

src/UserGuide/Master/Tree/SQL-Manual/UDF-Libraries_timecho.md

Lines changed: 97 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,7 +3280,99 @@ Output series:
32803280
+-----------------------------+-------------------------------------+
32813281
```
32823282

3283-
### 5.4 FFT
3283+
3284+
### 5.4 IDWT
3285+
3286+
#### Registration statement
3287+
3288+
```sql
3289+
create function dwt as 'org.apache.iotdb.library.frequency.UDTFIDWT'
3290+
```
3291+
3292+
#### Usage
3293+
3294+
This function performs one-dimensional inverse discrete wavelet transform on the input series, reconstructing the original data from DWT decomposed wavelet coefficients.
3295+
3296+
**Name:** IDWT
3297+
3298+
**Input:** Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.
3299+
3300+
**Parameters:**
3301+
3302+
+ `method`: The type of wavelet. May select 'Haar', 'DB4', 'DB6', 'DB8', where DB means Daubechies. User may offer coefficients of wavelet transform and ignore this parameter. Case ignored.
3303+
+ `coef`: Coefficients of wavelet transform. When providing this parameter, use comma ',' to split them, and leave no spaces or other punctuations.
3304+
+ `layer`: Times to transform. The number of output vectors equals $layer+1$. Default is 1.
3305+
3306+
**Output:** Output a single series. The type is DOUBLE. The length is the same as the input.
3307+
3308+
**Note:**
3309+
* The length of input series must be an integer number power of 2.
3310+
* The parameter settings of the IDWT function (method/coef/layer) should be consistent with the corresponding DWT transformation to correctly reconstruct the original data.
3311+
* Typically, the input of IDWT is the output result of the DWT function.
3312+
3313+
#### Examples
3314+
3315+
##### Haar wavelet transform
3316+
3317+
Input series:
3318+
3319+
```
3320+
+-----------------------------+--------------------+
3321+
| Time| root.test.d1.s2|
3322+
+-----------------------------+--------------------+
3323+
|1970-01-01T08:00:00.000+08:00| 0.1414213562373095|
3324+
|1970-01-01T08:00:00.100+08:00| 1.909188309203678|
3325+
|1970-01-01T08:00:00.200+08:00| 1.6263455967290592|
3326+
|1970-01-01T08:00:00.300+08:00| 1.979898987322333|
3327+
|1970-01-01T08:00:00.400+08:00| 3.2526911934581184|
3328+
|1970-01-01T08:00:00.500+08:00| 1.414213562373095|
3329+
|1970-01-01T08:00:00.600+08:00| 2.1213203435596424|
3330+
|1970-01-01T08:00:00.700+08:00| 1.8384776310850235|
3331+
|1970-01-01T08:00:00.800+08:00| -0.1414213562373095|
3332+
|1970-01-01T08:00:00.900+08:00| 0.21213203435596428|
3333+
|1970-01-01T08:00:01.000+08:00| -0.7778174593052022|
3334+
|1970-01-01T08:00:01.100+08:00| -0.8485281374238569|
3335+
|1970-01-01T08:00:01.200+08:00| 0.2828427124746189|
3336+
|1970-01-01T08:00:01.300+08:00| -1.414213562373095|
3337+
|1970-01-01T08:00:01.400+08:00| 0.42426406871192857|
3338+
|1970-01-01T08:00:01.500+08:00|-0.42426406871192857|
3339+
+-----------------------------+--------------------+
3340+
```
3341+
3342+
SQL for query:
3343+
3344+
```sql
3345+
select idwt(s2,"method"="haar") from root.test.d1
3346+
```
3347+
3348+
Output series:
3349+
3350+
```
3351+
+-----------------------------+--------------------------------------+
3352+
| Time|idwt(root.test.d1.s2, "method"="haar")|
3353+
+-----------------------------+--------------------------------------+
3354+
|1970-01-01T08:00:00.000+08:00| 0.0|
3355+
|1970-01-01T08:00:00.100+08:00| 0.19999999999999998|
3356+
|1970-01-01T08:00:00.200+08:00| 1.4999999999999996|
3357+
|1970-01-01T08:00:00.300+08:00| 1.1999999999999997|
3358+
|1970-01-01T08:00:00.400+08:00| 0.6|
3359+
|1970-01-01T08:00:00.500+08:00| 1.6999999999999997|
3360+
|1970-01-01T08:00:00.600+08:00| 0.7999999999999998|
3361+
|1970-01-01T08:00:00.700+08:00| 1.9999999999999996|
3362+
|1970-01-01T08:00:00.800+08:00| 2.4999999999999996|
3363+
|1970-01-01T08:00:00.900+08:00| 2.1|
3364+
|1970-01-01T08:00:01.000+08:00| 0.0|
3365+
|1970-01-01T08:00:01.100+08:00| 1.9999999999999996|
3366+
|1970-01-01T08:00:01.200+08:00| 1.7999999999999998|
3367+
|1970-01-01T08:00:01.300+08:00| 1.1999999999999997|
3368+
|1970-01-01T08:00:01.400+08:00| 0.9999999999999998|
3369+
|1970-01-01T08:00:01.500+08:00| 1.5999999999999999|
3370+
+-----------------------------+--------------------------------------+
3371+
```
3372+
3373+
3374+
3375+
### 5.5 FFT
32843376

32853377
#### Registration statement
32863378

@@ -3410,7 +3502,7 @@ Note: Based on the conjugation of the Fourier transform result, only the first h
34103502
According to the given parameter, data points are reserved from low frequency to high frequency until the reserved energy ratio exceeds it.
34113503
The last data point is reserved to indicate the length of the series.
34123504

3413-
### 5.5 HighPass
3505+
### 5.6 HighPass
34143506

34153507
#### Registration statement
34163508

@@ -3503,7 +3595,7 @@ Output series:
35033595

35043596
Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, the output is $y=sin(2\pi t/4)$ after high-pass filtering.
35053597

3506-
### 5.6 IFFT
3598+
### 5.7 IFFT
35073599

35083600
#### Registration statement
35093601

@@ -3586,7 +3678,7 @@ Output series:
35863678
+-----------------------------+-------------------------------------------------------+
35873679
```
35883680

3589-
### 5.7 LowPass
3681+
### 5.8 LowPass
35903682

35913683
#### Registration statement
35923684

@@ -3680,7 +3772,7 @@ Output series:
36803772
Note: The input is $y=sin(2\pi t/4)+2sin(2\pi t/5)$ with a length of 20. Thus, the output is $y=2sin(2\pi t/5)$ after low-pass filtering.
36813773

36823774

3683-
### 5.8 Envelope
3775+
### 5.9 Envelope
36843776

36853777
#### Registration statement
36863778

src/UserGuide/V1.3.x/SQL-Manual/UDF-Libraries_apache.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3283,6 +3283,98 @@ Output series:
32833283
+-----------------------------+-------------------------------------+
32843284
```
32853285

3286+
3287+
3288+
### IDWT
3289+
3290+
#### Registration statement
3291+
3292+
```sql
3293+
create function dwt as 'org.apache.iotdb.library.frequency.UDTFIDWT'
3294+
```
3295+
3296+
#### Usage
3297+
3298+
This function performs one-dimensional inverse discrete wavelet transform on the input series, reconstructing the original data from DWT decomposed wavelet coefficients.
3299+
3300+
**Name:** IDWT
3301+
3302+
**Input:** Only support a single input series. The type is INT32 / INT64 / FLOAT / DOUBLE.
3303+
3304+
**Parameters:**
3305+
3306+
+ `method`: The type of wavelet. May select 'Haar', 'DB4', 'DB6', 'DB8', where DB means Daubechies. User may offer coefficients of wavelet transform and ignore this parameter. Case ignored.
3307+
+ `coef`: Coefficients of wavelet transform. When providing this parameter, use comma ',' to split them, and leave no spaces or other punctuations.
3308+
+ `layer`: Times to transform. The number of output vectors equals $layer+1$. Default is 1.
3309+
3310+
**Output:** Output a single series. The type is DOUBLE. The length is the same as the input.
3311+
3312+
**Note:**
3313+
* The length of input series must be an integer number power of 2.
3314+
* The parameter settings of the IDWT function (method/coef/layer) should be consistent with the corresponding DWT transformation to correctly reconstruct the original data.
3315+
* Typically, the input of IDWT is the output result of the DWT function.
3316+
3317+
#### Examples
3318+
3319+
##### Haar wavelet transform
3320+
3321+
Input series:
3322+
3323+
```
3324+
+-----------------------------+--------------------+
3325+
| Time| root.test.d1.s2|
3326+
+-----------------------------+--------------------+
3327+
|1970-01-01T08:00:00.000+08:00| 0.1414213562373095|
3328+
|1970-01-01T08:00:00.100+08:00| 1.909188309203678|
3329+
|1970-01-01T08:00:00.200+08:00| 1.6263455967290592|
3330+
|1970-01-01T08:00:00.300+08:00| 1.979898987322333|
3331+
|1970-01-01T08:00:00.400+08:00| 3.2526911934581184|
3332+
|1970-01-01T08:00:00.500+08:00| 1.414213562373095|
3333+
|1970-01-01T08:00:00.600+08:00| 2.1213203435596424|
3334+
|1970-01-01T08:00:00.700+08:00| 1.8384776310850235|
3335+
|1970-01-01T08:00:00.800+08:00| -0.1414213562373095|
3336+
|1970-01-01T08:00:00.900+08:00| 0.21213203435596428|
3337+
|1970-01-01T08:00:01.000+08:00| -0.7778174593052022|
3338+
|1970-01-01T08:00:01.100+08:00| -0.8485281374238569|
3339+
|1970-01-01T08:00:01.200+08:00| 0.2828427124746189|
3340+
|1970-01-01T08:00:01.300+08:00| -1.414213562373095|
3341+
|1970-01-01T08:00:01.400+08:00| 0.42426406871192857|
3342+
|1970-01-01T08:00:01.500+08:00|-0.42426406871192857|
3343+
+-----------------------------+--------------------+
3344+
```
3345+
3346+
SQL for query:
3347+
3348+
```sql
3349+
select idwt(s2,"method"="haar") from root.test.d1
3350+
```
3351+
3352+
Output series:
3353+
3354+
```
3355+
+-----------------------------+--------------------------------------+
3356+
| Time|idwt(root.test.d1.s2, "method"="haar")|
3357+
+-----------------------------+--------------------------------------+
3358+
|1970-01-01T08:00:00.000+08:00| 0.0|
3359+
|1970-01-01T08:00:00.100+08:00| 0.19999999999999998|
3360+
|1970-01-01T08:00:00.200+08:00| 1.4999999999999996|
3361+
|1970-01-01T08:00:00.300+08:00| 1.1999999999999997|
3362+
|1970-01-01T08:00:00.400+08:00| 0.6|
3363+
|1970-01-01T08:00:00.500+08:00| 1.6999999999999997|
3364+
|1970-01-01T08:00:00.600+08:00| 0.7999999999999998|
3365+
|1970-01-01T08:00:00.700+08:00| 1.9999999999999996|
3366+
|1970-01-01T08:00:00.800+08:00| 2.4999999999999996|
3367+
|1970-01-01T08:00:00.900+08:00| 2.1|
3368+
|1970-01-01T08:00:01.000+08:00| 0.0|
3369+
|1970-01-01T08:00:01.100+08:00| 1.9999999999999996|
3370+
|1970-01-01T08:00:01.200+08:00| 1.7999999999999998|
3371+
|1970-01-01T08:00:01.300+08:00| 1.1999999999999997|
3372+
|1970-01-01T08:00:01.400+08:00| 0.9999999999999998|
3373+
|1970-01-01T08:00:01.500+08:00| 1.5999999999999999|
3374+
+-----------------------------+--------------------------------------+
3375+
```
3376+
3377+
32863378
### FFT
32873379

32883380
#### Registration statement

0 commit comments

Comments
 (0)