You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ro...@apache.org on 2022/10/13 03:02:46 UTC

[iotdb] branch research/descend updated: Artifact in Research/descend (#7570)

This is an automated email from the ASF dual-hosted git repository.

rong pushed a commit to branch research/descend
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/research/descend by this push:
     new 0c23ddef09 Artifact in Research/descend (#7570)
0c23ddef09 is described below

commit 0c23ddef09db4c971613c2bc2280c77c566aa2ea
Author: Haoyu Wang <37...@users.noreply.github.com>
AuthorDate: Thu Oct 13 11:02:41 2022 +0800

    Artifact in Research/descend (#7570)
    
    * Add the method size() to Row in UDF
    
    * [IOTDB-3025] add permission check (#5699)
    
    Co-authored-by: renyuhua <ry...@163.com>
    Co-authored-by: Jinrui.Zhang <xi...@gmail.com>
    
    * [IOTDB-3046] Fix port binding error in ClientManagerTest (#5736)
    
    * [IOTDB-3018] Fix compation bugs on handling deleted target file and service shutdown deadlock (#5693)
    
    * [IOTDB-3026] fix cannot load tsfile correctly after restart iotdb (#5702)
    
    * [IOTDB-3039] Add standalone recovery (#5731)
    
    * add standalone recovery
    
    * add standalone recovery
    
    * add standalone recovery
    
    * add standalone recovery
    
    * add standalone recovery
    
    * add standalone recovery
    
    * add standalone recovery
    
    * [IOTDB-2993] Support IN, LIKE, and REGEXP expressions in Transform Operator (#5739)
    
    * [IOTDB-2803] support AlterTimeseries sql (#5735)
    
    * [IoTDB-2991] Equal size bucket sampling UDFs: EQUAL_SIZE_BUCKET_OUTLIER_SAMPLE (#5682)
    
    * Move time partition calculation from StorageEngine to StorageEngineV2 (#5708)
    
    * [IOTDB-3020][IOTDB-3022]Multi-thread MLog recovery & Fix SchemaFile dirty page loses (#5695)
    
    * [IOTDB-3042] ConfigNode stop process (#5755)
    
    * fix restart lossing data when sender shutdonws with data remain in memtable (#5740)
    
    * Finish Descend Encoding
    
    * [IOTDB-3048] Refactor binary transformer (#5744)
    
    Co-authored-by: Steve Yurong Su <ro...@apache.org>
    
    * [IOTDB-3056] triggers support multi-level documents (#5759)
    
    Co-authored-by: wenhua.gongwh <we...@alibaba-inc.com>
    
    * [IOTDB-2972] implement local sink/source handle (#5732)
    
    * move columnToTsBlockIndexMap from LogicalPlanner to DistributionPlanner (#5733)
    
    * [IOTDB-2981] Modify antlr, IoTDBSqlVisitor and ASTVisitor for new syntax convention (#5696)
    
    changelist:
    
    node name can not be STRING_LITERAL now.
    change propertyClause to attributePair. Attributes in tag, attribute, udf, trigger, pipe...... are attributePair now.
    attributeKey and attributeValue can be both identifer and constant.
    remove suffixPathCanInExpr, nodeNameCanInExpr.
    change suffixPath in expression to FullPathInExpression.
    alias can be both identifier and constant now.
    user, role, pipe, pipeSink are identifier now.
    specified usage of identifier and STRING_LITERAL in user docs.
    
    * rename package of mpp and confignode (#5758)
    
    As this PR is used to change packages and there is no code level change, we merge it once the CI succeed
    
    * [IOTDB-3075] RatisConsensus UUID bugfix (#5765)
    
    * consensus group to ratis id bugfix
    
    * fix
    
    * format
    
    * [IOTDB-2870] Unit test of spliting insert node in new cluster (#5769)
    
    * Add SyncThriftClientErrorHandler for proxy to clean the code (#5710)
    
    * [IOTDB-2993][Bugfix] Support IN, LIKE, and REGEXP expressions in Transform Operator (#5766)
    
    * Modify Descend with choosing beta adaptively
    
    * Modify the encodings and compressions according to comments
    
    * Finish the artifact
    
    Co-authored-by: 任宇华 <79...@users.noreply.github.com>
    Co-authored-by: renyuhua <ry...@163.com>
    Co-authored-by: Jinrui.Zhang <xi...@gmail.com>
    Co-authored-by: BaiJian <er...@hotmail.com>
    Co-authored-by: Chen YZ <43...@users.noreply.github.com>
    Co-authored-by: SzyWilliam <48...@users.noreply.github.com>
    Co-authored-by: Steve Yurong Su <ro...@apache.org>
    Co-authored-by: Yifu Zhou <ef...@outlook.com>
    Co-authored-by: AACEPT <34...@users.noreply.github.com>
    Co-authored-by: Haonan <hh...@outlook.com>
    Co-authored-by: ZhaoXin <x_...@163.com>
    Co-authored-by: YongzaoDan <33...@users.noreply.github.com>
    Co-authored-by: yschengzi <87...@users.noreply.github.com>
    Co-authored-by: flashzxi <39...@users.noreply.github.com>
    Co-authored-by: gongning <is...@gmail.com>
    Co-authored-by: wenhua.gongwh <we...@alibaba-inc.com>
    Co-authored-by: Zhong Wang <wa...@alibaba-inc.com>
    Co-authored-by: liuminghui233 <36...@users.noreply.github.com>
    Co-authored-by: Liao Lanyu <48...@users.noreply.github.com>
    Co-authored-by: Jialin Qiao <qj...@mails.tsinghua.edu.cn>
    Co-authored-by: Mrquan <50...@users.noreply.github.com>
    Co-authored-by: JiaXin Zhang <37...@users.noreply.github.com>
---
 README.md                                          | 430 +----------
 README.md => README_EN.md                          |   0
 .../antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4  |   8 +-
 artifact/pom.xml                                   |  54 ++
 .../java/org/apache/iotdb/artifact/Experiment.java | 133 ++++
 .../main/java/org/apache/iotdb/artifact/Main.java  |  89 +++
 .../iotdb/artifact/ShortTimeFourierTransform.java  |  63 ++
 .../main/java/org/apache/iotdb/artifact/Utils.java |  82 ++
 library-udf/pom.xml                                |  30 +-
 .../org/apache/iotdb/library/dmatch/UDAFCov.java   |  26 +-
 .../org/apache/iotdb/library/dmatch/UDAFDtw.java   |  26 +-
 .../apache/iotdb/library/dmatch/UDAFPearson.java   |  26 +-
 .../apache/iotdb/library/dmatch/UDTFPtnSym.java    |  23 +-
 .../org/apache/iotdb/library/dmatch/UDTFXCorr.java |  24 +-
 .../iotdb/library/dprofile/UDAFIntegral.java       |  20 +-
 .../iotdb/library/dprofile/UDAFIntegralAvg.java    |  23 +-
 .../org/apache/iotdb/library/dprofile/UDAFMad.java |  23 +-
 .../apache/iotdb/library/dprofile/UDAFMedian.java  |  23 +-
 .../apache/iotdb/library/dprofile/UDAFMode.java    |  18 +-
 .../iotdb/library/dprofile/UDAFPercentile.java     |  21 +-
 .../apache/iotdb/library/dprofile/UDAFPeriod.java  |  25 +-
 .../apache/iotdb/library/dprofile/UDAFSkew.java    |  23 +-
 .../apache/iotdb/library/dprofile/UDAFSpread.java  |  21 +-
 .../apache/iotdb/library/dprofile/UDAFStddev.java  |  23 +-
 .../org/apache/iotdb/library/dprofile/UDTFACF.java |  23 +-
 .../iotdb/library/dprofile/UDTFDistinct.java       |  26 +-
 .../iotdb/library/dprofile/UDTFHistogram.java      |  23 +-
 .../apache/iotdb/library/dprofile/UDTFMinMax.java  |  23 +-
 .../apache/iotdb/library/dprofile/UDTFMvAvg.java   |  25 +-
 .../apache/iotdb/library/dprofile/UDTFPACF.java    |  24 +-
 .../org/apache/iotdb/library/dprofile/UDTFQLB.java |  23 +-
 .../iotdb/library/dprofile/UDTFResample.java       |  23 +-
 .../apache/iotdb/library/dprofile/UDTFSample.java  |  24 +-
 .../apache/iotdb/library/dprofile/UDTFSegment.java |  23 +-
 .../apache/iotdb/library/dprofile/UDTFSpline.java  |  23 +-
 .../apache/iotdb/library/dprofile/UDTFZScore.java  |  23 +-
 .../dprofile/util/ExactOrderStatistics.java        |  20 +-
 .../iotdb/library/dprofile/util/MADSketch.java     |   5 +-
 .../iotdb/library/dquality/UDTFCompleteness.java   |  18 +-
 .../iotdb/library/dquality/UDTFConsistency.java    |  18 +-
 .../iotdb/library/dquality/UDTFTimeliness.java     |  18 +-
 .../iotdb/library/dquality/UDTFValidity.java       |  18 +-
 .../library/dquality/util/TimeSeriesQuality.java   |   4 +-
 .../iotdb/library/drepair/UDTFTimestampRepair.java |  19 +-
 .../iotdb/library/drepair/UDTFValueFill.java       |  19 +-
 .../iotdb/library/drepair/UDTFValueRepair.java     |  19 +-
 .../apache/iotdb/library/drepair/util/ARFill.java  |   2 +-
 .../iotdb/library/drepair/util/LikelihoodFill.java |   2 +-
 .../iotdb/library/drepair/util/LinearFill.java     |   2 +-
 .../iotdb/library/drepair/util/LsGreedy.java       |   2 +-
 .../apache/iotdb/library/drepair/util/MAFill.java  |   2 +-
 .../iotdb/library/drepair/util/MeanFill.java       |   2 +-
 .../iotdb/library/drepair/util/PreviousFill.java   |   2 +-
 .../apache/iotdb/library/drepair/util/Screen.java  |   2 +-
 .../iotdb/library/drepair/util/ScreenFill.java     |   2 +-
 .../library/drepair/util/TimestampInterval.java    |   6 +-
 .../library/drepair/util/TimestampRepair.java      |   6 +-
 .../iotdb/library/drepair/util/ValueFill.java      |   4 +-
 .../iotdb/library/drepair/util/ValueRepair.java    |   4 +-
 .../apache/iotdb/library/frequency/UDTFConv.java   |  26 +-
 .../apache/iotdb/library/frequency/UDTFDWT.java    |  23 +-
 .../apache/iotdb/library/frequency/UDTFDeconv.java |  26 +-
 .../apache/iotdb/library/frequency/UDTFFFT.java    |  23 +-
 .../iotdb/library/frequency/UDTFHighPass.java      |  23 +-
 .../apache/iotdb/library/frequency/UDTFIDWT.java   |  23 +-
 .../apache/iotdb/library/frequency/UDTFIFFT.java   |  23 +-
 .../iotdb/library/frequency/UDTFLowPass.java       |  23 +-
 .../apache/iotdb/library/frequency/UDTFSTFT.java   | 132 ++++
 .../iotdb/library/frequency/util/FFTUtil.java      |   2 +-
 .../library/series/UDTFConsecutiveSequences.java   |  20 +-
 .../library/series/UDTFConsecutiveWindows.java     |  20 +-
 .../iotdb/library/series/util/ConsecutiveUtil.java |   4 +-
 .../iotdb/library/string/UDTFRegexMatch.java       |  22 +-
 .../iotdb/library/string/UDTFRegexReplace.java     |  22 +-
 .../iotdb/library/string/UDTFRegexSplit.java       |  22 +-
 .../iotdb/library/string/UDTFStrReplace.java       |  22 +-
 .../java/org/apache/iotdb/library/util/Util.java   |   9 +-
 .../apache/iotdb/library/dmatch/DMatchTests.java   | 826 ---------------------
 .../iotdb/library/dprofile/DProfileTests.java      | 629 ----------------
 .../iotdb/library/dquality/DQualityTests.java      | 385 ----------
 .../apache/iotdb/library/drepair/DRepairTests.java | 317 --------
 .../iotdb/library/frequency/FrequencyTests.java    | 300 --------
 .../apache/iotdb/library/series/SeriesTest.java    | 467 ------------
 .../apache/iotdb/library/string/StringTests.java   | 258 -------
 .../org/apache/iotdb/db/utils/SchemaUtils.java     |   3 +
 .../apache/iotdb/tsfile/compress/ICompressor.java  |  60 +-
 .../iotdb/tsfile/compress/IUnCompressor.java       |  54 +-
 .../arithmetic/AdaptiveArithmeticCompress.java     |  77 ++
 .../arithmetic/AdaptiveArithmeticDecompress.java   |  71 ++
 .../compress/arithmetic/ArithmeticCoderBase.java   | 189 +++++
 .../compress/arithmetic/ArithmeticDecoder.java     | 127 ++++
 .../compress/arithmetic/ArithmeticEncoder.java     | 115 +++
 .../tsfile/compress/arithmetic/BitInputStream.java | 106 +++
 .../compress/arithmetic/BitOutputStream.java       |  89 +++
 .../compress/arithmetic/CheckedFrequencyTable.java | 106 +++
 .../compress/arithmetic/FlatFrequencyTable.java    | 144 ++++
 .../tsfile/compress/arithmetic/FrequencyTable.java |  94 +++
 .../compress/arithmetic/SimpleFrequencyTable.java  | 229 ++++++
 .../iotdb/tsfile/encoding/decoder/BuffDecoder.java | 160 ++++
 .../iotdb/tsfile/encoding/decoder/Decoder.java     |   2 +
 .../tsfile/encoding/decoder/DescendDecoder.java    |   3 +-
 .../iotdb/tsfile/encoding/encoder/BuffEncoder.java | 225 ++++++
 .../tsfile/encoding/encoder/DescendEncoder.java    |  16 +-
 .../tsfile/encoding/encoder/TSEncodingBuilder.java |  29 +
 .../file/metadata/enums/CompressionType.java       |   6 +-
 .../tsfile/file/metadata/enums/TSEncoding.java     |   5 +-
 .../iotdb/tsfile/read/reader/page/PageReader.java  |   5 +
 .../apache/iotdb/tsfile/write/page/PageWriter.java |   4 +
 108 files changed, 3026 insertions(+), 4253 deletions(-)

diff --git a/README.md b/README.md
index 928c85950c..fa97ac6da8 100644
--- a/README.md
+++ b/README.md
@@ -1,421 +1,55 @@
-<!--
+# Artifact Guideline
 
-    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
+## Minimum Artifact
 
-        http://www.apache.org/licenses/LICENSE-2.0
+To simplify the reproducing, the minimum artifact bypasses the IoTDB server, writes and reads the tsfile directly.
 
-    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.
+### Requirements
 
--->
-[English](./README.md) | [中文](./README_ZH.md)
++ JDK >= 1.8
++ Maven >= 3.6
 
-# IoTDB
-[![Main Mac and Linux](https://github.com/apache/iotdb/actions/workflows/main-unix.yml/badge.svg)](https://github.com/apache/iotdb/actions/workflows/main-unix.yml)
-[![Main Win](https://github.com/apache/iotdb/actions/workflows/main-win.yml/badge.svg)](https://github.com/apache/iotdb/actions/workflows/main-win.yml)
-[![coveralls](https://coveralls.io/repos/github/apache/iotdb/badge.svg?branch=master)](https://coveralls.io/repos/github/apache/iotdb/badge.svg?branch=master)
-[![GitHub release](https://img.shields.io/github/release/apache/iotdb.svg)](https://github.com/apache/iotdb/releases)
-[![License](https://img.shields.io/badge/license-Apache%202-4EB1BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
-![](https://github-size-badge.herokuapp.com/apache/iotdb.svg)
-![](https://img.shields.io/github/downloads/apache/iotdb/total.svg)
-![](https://img.shields.io/badge/platform-win%20%7C%20macos%20%7C%20linux-yellow.svg)
-![](https://img.shields.io/badge/java--language-1.8%20%7C%2011%20%7C%2017-blue.svg)
-[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/apache/iotdb.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/apache/iotdb/context:java)
-[![IoTDB Website](https://img.shields.io/website-up-down-green-red/https/shields.io.svg?label=iotdb-website)](https://iotdb.apache.org/)
-[![Maven Version](https://maven-badges.herokuapp.com/maven-central/org.apache.iotdb/iotdb-parent/badge.svg)](http://search.maven.org/#search|gav|1|g:"org.apache.iotdb")
-[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/apache/iotdb)
-[![Slack Status](https://img.shields.io/badge/slack-join_chat-white.svg?logo=slack&style=social)](https://join.slack.com/t/apacheiotdb/shared_invite/zt-qvso1nj8-7715TpySZtZqmyG5qXQwpg)
 
-# Overview
+### Example Invocation
 
-IoTDB (Internet of Things Database) is a data management system for time series data, which can provide users specific services, such as, data collection, storage and analysis. Due to its light weight structure, high performance and usable features together with its seamless integration with the Hadoop and Spark ecology, IoTDB meets the requirements of massive dataset storage, high throughput data input, and complex data analysis in the industrial IoT field.
 
-# Main Features
+1. [Download](https://cloud.tsinghua.edu.cn/f/4602e518f32a4ceda877/) the datasets and put all CSV files into the directory `artifact/dataset`;
 
-Main features of IoTDB are as follows:
-
-1. Flexible deployment strategy. IoTDB provides users a one-click installation tool on either the cloud platform or the terminal devices, and a data synchronization tool bridging the data on cloud platform and terminals.
-2. Low cost on hardware. IoTDB can reach a high compression ratio of disk storage.
-3. Efficient directory structure. IoTDB supports efficient organization for complex time series data structure from intelligent networking devices, organization for time series data from devices of the same type, fuzzy searching strategy for massive and complex directory of time series data.
-4. High-throughput read and write. IoTDB supports millions of low-power devices' strong connection data access, high-speed data read and write for intelligent networking devices and mixed devices mentioned above.
-5. Rich query semantics. IoTDB supports time alignment for time series data across devices and measurements, computation in time series field (frequency domain transformation) and rich aggregation function support in time dimension.
-6. Easy to get started. IoTDB supports SQL-Like language, JDBC standard API and import/export tools which is easy to use.
-7. Seamless integration with state-of-the-practice Open Source Ecosystem. IoTDB supports analysis ecosystems such as, Hadoop, Spark, and visualization tool, such as, Grafana.
-
-For the latest information about IoTDB, please visit [IoTDB official website](https://iotdb.apache.org/). If you encounter any problems or identify any bugs while using IoTDB, please report an issue in [jira](https://issues.apache.org/jira/projects/IOTDB/issues).
-
-<!-- TOC -->
-
-## Outline
-
-- [IoTDB](#iotdb)
-- [Overview](#overview)
-- [Main Features](#main-features)
-  - [Outline](#outline)
-- [Quick Start](#quick-start)
-  - [Prerequisites](#prerequisites)
-  - [Installation](#installation)
-    - [Build from source](#build-from-source)
-    - [Configurations](#configurations)
-  - [Start](#start)
-    - [Start IoTDB](#start-iotdb)
-    - [Use IoTDB](#use-iotdb)
-      - [Use Cli](#use-cli)
-      - [Basic commands for IoTDB](#basic-commands-for-iotdb)
-    - [Stop IoTDB](#stop-iotdb)
-  - [Only build server](#only-build-server)
-  - [Only build cli](#only-build-cli)
-  - [Usage of CSV Import and Export Tool](#usage-of-csv-import-and-export-tool)
-
-<!-- /TOC -->
-
-# Quick Start
-
-This short guide will walk you through the basic process of using IoTDB. For a more detailed introduction, please visit our website's [User Guide](https://iotdb.apache.org/UserGuide/Master/QuickStart/QuickStart.html).
-
-## Prerequisites
-
-To use IoTDB, you need to have:
-
-1. Java >= 1.8 (1.8, 11 to 17 are verified. Please make sure the environment path has been set accordingly).
-2. Maven >= 3.6 (If you want to compile and install IoTDB from source code).
-3. Set the max open files num as 65535 to avoid "too many open files" error.
-4. (Optional) Set the somaxconn as 65535 to avoid "connection reset" error when the system is under high load.
-    ```
-    # Linux
-    > sudo sysctl -w net.core.somaxconn=65535
-   
-    # FreeBSD or Darwin
-    > sudo sysctl -w kern.ipc.somaxconn=65535
-    ```
-
-## Installation
-
-IoTDB provides three installation methods, you can refer to the following suggestions, choose the one fits you best:
-
-* Installation from source code. If you need to modify the code yourself, you can use this method.
-* Installation from binary files. Download the binary files from the official website. This is the recommended method, in which you will get a binary released package which is out-of-the-box.
-* Using Docker:The path to the dockerfile is https://github.com/apache/iotdb/tree/master/docker/src/main
-
-
-Here in the Quick Start, we give a brief introduction of using source code to install IoTDB. For further information, please refer to [User Guide](https://iotdb.apache.org/UserGuide/Master/QuickStart/QuickStart.html).
-
-## Build from source
-
-### Prepare Thrift compiler
-
-Skip this chapter if you are using Windows. 
-
-As we use Thrift for our RPC module (communication and
-protocol definition), we involve Thrift during the compilation, so Thrift compiler 0.13.0 (or
-higher) is required to generate Thrift Java code. Thrift officially provides binary compiler for
-Windows, but unfortunately, they do not provide that for Unix OSs. 
-
-If you have permission to install new softwares, use `apt install` or `yum install` or `brew install`
-to install the Thrift compiler (If you already have installed the thrift compiler, skip this step).
-Then, you may add the following parameter
-when running Maven: `-Dthrift.download-url=http://apache.org/licenses/LICENSE-2.0.txt -Dthrift.exec.absolute.path=<YOUR LOCAL THRIFT BINARY FILE>`.
-
-If not, then you have to compile the thrift compiler, and it requires you install a boost library first.
-Therefore, we compiled a Unix  compiler ourselves and put it onto GitHub, and with the help of a
-maven plugin, it will be  downloaded automatically during compilation. 
-This compiler works fine with gcc8 or later, Ubuntu  MacOS, and CentOS, but previous versions 
-and other OSs are not guaranteed.
-
-If you can not download the thrift compiler automatically because of network problem, you can download 
-it yourself, and then either:
-rename your thrift file to `{project_root}\thrift\target\tools\thrift_0.12.0_0.13.0_linux.exe`;
-or, add Maven commands:
-`-Dthrift.download-url=http://apache.org/licenses/LICENSE-2.0.txt -Dthrift.exec.absolute.path=<YOUR LOCAL THRIFT BINARY FILE>`.
-
-### Compile IoTDB
-
-You can download the source code from:
-
-```
-git clone https://github.com/apache/iotdb.git
-```
-
-The default dev branch is the master branch, If you want to use a released version x.x.x:
-
-```
-git checkout release/x.x.x
-```
-
-From v0.11.3 on, the tag name format is change to: vx.x.x:
-
-```
-git checkout vx.x.x
-```
-
-Under the root path of iotdb:
-
-```
-> mvn clean package -DskipTests
-```
-
-Using `-P compile-cpp` for compiling cpp client (For more details, read client-cpp's Readme file.)
-
-Then the binary version (including both server and cli) can be found at **distribution/target/apache-iotdb-{project.version}-all-bin.zip**
-
-**NOTE: Directories "`thrift/target/generated-sources/thrift`", "`thrift-sync/target/generated-sources/thrift`",
-"`thrift-cluster/target/generated-sources/thrift`", "`thrift-influxdb/target/generated-sources/thrift`" 
-and "`antlr/target/generated-sources/antlr4`" need to be added to sources roots to avoid compilation errors in the IDE.**
-
-**In IDEA, you just need to right click on the root project name and choose "`Maven->Reload Project`" after 
-you run `mvn package` successfully.**
-
-### Configurations
-
-configuration files are under "conf" folder
-
-  * environment config module (`iotdb-env.bat`, `iotdb-env.sh`),
-  * system config module (`iotdb-engine.properties`)
-  * log config module (`logback.xml`).
-
-For more information, please see [Config Manual](https://iotdb.apache.org/UserGuide/Master/Reference/Config-Manual.html).
-
-## Start
-
-You can go through the following steps to test the installation, if there is no error returned after execution, the installation is completed.
-
-### Start IoTDB
-
-Users can start IoTDB by the start-server script under the sbin folder.
-
-```
-# Unix/OS X
-> nohup sbin/start-server.sh >/dev/null 2>&1 &
-or
-> nohup sbin/start-server.sh -c <conf_path> -rpc_port <rpc_port> >/dev/null 2>&1 &
-
-# Windows
-> sbin\start-server.bat -c <conf_path> -rpc_port <rpc_port>
-```
-
-- "-c" and "-rpc_port" are optional.
-- option "-c" specifies the system configuration file directory.
-- option "-rpc_port" specifies the rpc port.
-- if both option specified, the *rpc_port* will overrides the rpc_port in *conf_path*.
-
-
-### Use IoTDB
-
-#### Use Cli
-
-IoTDB offers different ways to interact with server, here we introduce the basic steps of using Cli tool to insert and query data.
-
-After installing IoTDB, there is a default user 'root', its default password is also 'root'. Users can use this
-default user to login Cli to use IoTDB. The startup script of Cli is the start-cli script in the folder sbin. When executing the script, user should assign
-IP, PORT, USER_NAME and PASSWORD. The default parameters are "-h 127.0.0.1 -p 6667 -u root -pw -root".
-
-Here is the command for starting the Cli:
-
-```
-# Unix/OS X
-> sbin/start-cli.sh -h 127.0.0.1 -p 6667 -u root -pw root
-
-# Windows
-> sbin\start-cli.bat -h 127.0.0.1 -p 6667 -u root -pw root
-```
-
-The command line cli is interactive, so you should see the welcome logo and statements if everything is ready:
+2. Install the dependencies into local repository: 
 
+```sh
+cd tsfile
+mvn install -DskipTests
+cd ..
 ```
- _____       _________  ______   ______
-|_   _|     |  _   _  ||_   _ `.|_   _ \
-  | |   .--.|_/ | | \_|  | | `. \ | |_) |
-  | | / .'`\ \  | |      | |  | | |  __'.
- _| |_| \__. | _| |_    _| |_.' /_| |__) |
-|_____|'.__.' |_____|  |______.'|_______/  version x.x.x
 
+3. Compile and package the artifact:
 
-IoTDB> login successfully
-IoTDB>
+```sh
+cd artifact
+mvn compile assembly:single
 ```
 
-#### Basic commands for IoTDB
+4. Run the artifact and find the experimental results in the directory `artifact/result`:
 
-Now, let us introduce the way of creating timeseries, inserting data and querying data.
-
-The data in IoTDB is organized as timeseries. Each timeseries includes multiple data-time pairs, and is owned by a storage group. Before defining a timeseries, we should define a storage group using SET STORAGE GROUP first, and here is an example:
-
-```
-IoTDB> SET STORAGE GROUP TO root.ln
-```
-
-We can also use SHOW STORAGE GROUP to check the storage group being created:
-
-```
-IoTDB> SHOW STORAGE GROUP
-+-------------+
-|storage group|
-+-------------+
-|      root.ln|
-+-------------+
-Total line number = 1
-```
-
-After the storage group is set, we can use CREATE TIMESERIES to create a new timeseries. When creating a timeseries, we should define its data type and the encoding scheme. Here We create two timeseries:
-
-```
-IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.status WITH DATATYPE=BOOLEAN, ENCODING=PLAIN
-IoTDB> CREATE TIMESERIES root.ln.wf01.wt01.temperature WITH DATATYPE=FLOAT, ENCODING=RLE
-```
-
-In order to query the specific timeseries, we can use SHOW TIMESERIES <Path>. <Path> represent the location of the timeseries. The default value is "null", which queries all the timeseries in the system(the same as using "SHOW TIMESERIES root"). Here are some examples:
-
-1. Querying all timeseries in the system:
-
-```
-IoTDB> SHOW TIMESERIES
-+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
-|                   timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
-+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
-|root.ln.wf01.wt01.temperature| null|      root.ln|   FLOAT|     RLE|     SNAPPY|null|      null|
-|     root.ln.wf01.wt01.status| null|      root.ln| BOOLEAN|   PLAIN|     SNAPPY|null|      null|
-+-----------------------------+-----+-------------+--------+--------+-----------+----+----------+
-Total line number = 2
-```
-
-2. Querying a specific timeseries(root.ln.wf01.wt01.status):
-
-```
-IoTDB> SHOW TIMESERIES root.ln.wf01.wt01.status
-+------------------------+-----+-------------+--------+--------+-----------+----+----------+
-|              timeseries|alias|storage group|dataType|encoding|compression|tags|attributes|
-+------------------------+-----+-------------+--------+--------+-----------+----+----------+
-|root.ln.wf01.wt01.status| null|      root.ln| BOOLEAN|   PLAIN|     SNAPPY|null|      null|
-+------------------------+-----+-------------+--------+--------+-----------+----+----------+
-Total line number = 1
-```
-
-Insert timeseries data is a basic operation of IoTDB, you can use ‘INSERT’ command to finish this. Before insertion, you should assign the timestamp and the suffix path name:
-
-```
-IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status) values(100,true);
-IoTDB> INSERT INTO root.ln.wf01.wt01(timestamp,status,temperature) values(200,false,20.71)
-```
-
-The data that you have just inserted will display as follows:
-
-```
-IoTDB> SELECT status FROM root.ln.wf01.wt01
-+------------------------+------------------------+
-|                    Time|root.ln.wf01.wt01.status|
-+------------------------+------------------------+
-|1970-01-01T00:00:00.100Z|                    true|
-|1970-01-01T00:00:00.200Z|                   false|
-+------------------------+------------------------+
-Total line number = 2
-```
-
-You can also query several timeseries data using one SQL statement:
-
-```
-IoTDB> SELECT * FROM root.ln.wf01.wt01
-+------------------------+-----------------------------+------------------------+
-|                    Time|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
-+------------------------+-----------------------------+------------------------+
-|1970-01-01T00:00:00.100Z|                         null|                    true|
-|1970-01-01T00:00:00.200Z|                        20.71|                   false|
-+------------------------+-----------------------------+------------------------+
-Total line number = 2
-```
-
-To change the time zone in Cli, you can use the following SQL:
-
-```
-IoTDB> SET time_zone=+08:00
-Time zone has set to +08:00
-IoTDB> SHOW time_zone
-Current time zone: Asia/Shanghai
-```
-
-Add then the query result will show using the new time zone.
-
-```
-IoTDB> SELECT * FROM root.ln.wf01.wt01
-+-----------------------------+-----------------------------+------------------------+
-|                         Time|root.ln.wf01.wt01.temperature|root.ln.wf01.wt01.status|
-+-----------------------------+-----------------------------+------------------------+
-|1970-01-01T08:00:00.100+08:00|                         null|                    true|
-|1970-01-01T08:00:00.200+08:00|                        20.71|                   false|
-+-----------------------------+-----------------------------+------------------------+
-Total line number = 2
-```
-
-The commands to exit the Cli are:
-
-```
-IoTDB> quit
-or
-IoTDB> exit
-```
-
-For more information about the commands supported by IoTDB SQL, please see [User Guide](https://iotdb.apache.org/UserGuide/Master/QuickStart/QuickStart.html).
-
-### Stop IoTDB
-
-The server can be stopped with "ctrl-C" or the following script:
-
-```
-# Unix/OS X
-> sbin/stop-server.sh
-
-# Windows
-> sbin\stop-server.bat
+```sh
+java -jar target\artifact-0.14.0-SNAPSHOT-jar-with-dependencies.jar
 ```
 
-## Only build server
-
-Under the root path of iotdb:
-
-```
-> mvn clean package -pl server -am -DskipTests
-```
-
-After being built, the IoTDB server is located at the folder: "server/target/iotdb-server-{project.version}".
-
-
-## Only build cli
-
-Under the root path of iotdb:
-
-```
-> mvn clean package -pl cli -am -DskipTests
-```
-
-After being built, the IoTDB cli is located at the folder "cli/target/iotdb-cli-{project.version}".
-
-# Usage of CSV Import and Export Tool
-
-see [Usage of CSV Import and Export Tool](https://iotdb.apache.org/UserGuide/Master/Write-And-Delete-Data/CSV-Tool.html)
-
-# Frequent Questions for Compiling
-see [Frequent Questions when Compiling the Source Code](https://iotdb.apache.org/Development/ContributeGuide.html#_Frequent-Questions-when-Compiling-the-Source-Code)
-
-# Contact Us
-### QQ Group
-
-* Apache IoTDB User Group: 659990460
+## Key Source Codes
 
-### Wechat Group
++ `library-udf\src\main\java\org\apache\iotdb\library\frequency\UDTFSTFT.java` is the source of Fourier transform and quantization (Section 2.2) 
++ `tsfile\src\main\java\org\apache\iotdb\tsfile\encoding\encoder\DescendEncoder.java` is the source of the encoder of descending bit-packing (Section 2.3-2.4)
++ `tsfile\src\main\java\org\apache\iotdb\tsfile\encoding\decoder\DescendDecoder.java` is the source of the decoder of descending bit-packing (Section 2.5-2.6)
++ `tsfile\src\main\java\org\apache\iotdb\tsfile\encoding\encoder\FreqEncoder.java` is the source of the encoder of time domain data encoding (Appendix D.1 in [full version](https://sxsong.github.io/doc/frequency.pdf))
++ `tsfile\src\main\java\org\apache\iotdb\tsfile\encoding\decoder\FreqDecoder.java` is the source of the decoder of time domain data encoding (Appendix D.1 in [full version](https://sxsong.github.io/doc/frequency.pdf))
 
-* Add friend: `tietouqiao` or `liutaohua001`, and then we'll invite you to the group.
 
-### Slack
+## Usage in Apache IoTDB
 
-* https://join.slack.com/t/apacheiotdb/shared_invite/zt-qvso1nj8-7715TpySZtZqmyG5qXQwpg
+Trying frequency domain data encoding in Apache IoTDB is a little more complex. 
 
-see [Join the community](https://github.com/apache/iotdb/issues/1995) for more!
+1. Deploy Apache IoTDB (see [Quick Start](https://iotdb.apache.org/UserGuide/V0.13.x/QuickStart/QuickStart.html) in detail);
+2. Register the UDF **STFT** (see [UDF](https://iotdb.apache.org/UserGuide/V0.13.x/Process-Data/UDF-User-Defined-Function.html) in detail);
+3. Load the time series into IoTDB (see [CSV Tool](https://iotdb.apache.org/UserGuide/V0.12.x/System-Tools/CSV-Tool.html) in detail);
+4. Write back the results of **STFT** to a time series (see Appendix B in [full version](https://sxsong.github.io/doc/frequency.pdf) in details).
diff --git a/README.md b/README_EN.md
similarity index 100%
copy from README.md
copy to README_EN.md
diff --git a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4 b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
index 270d8c27f8..c2337ac8a8 100644
--- a/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
+++ b/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/SqlLexer.g4
@@ -653,7 +653,7 @@ TEXT
 // Encoding Type Keywords
 
 ENCODING_VALUE
-    : DICTIONARY | DIFF | GORILLA | PLAIN | REGULAR | RLE | TS_2DIFF | ZIGZAG | FREQ | DESCEND | SIMPLE8B | SIMPLE8B_SPARSE
+    : DICTIONARY | DIFF | GORILLA | PLAIN | REGULAR | RLE | TS_2DIFF | ZIGZAG | FREQ | DESCEND | SIMPLE8B | SIMPLE8B_SPARSE | BUFF
     ;
 
 DICTIONARY
@@ -705,6 +705,12 @@ SIMPLE8B_SPARSE
 	;
 
 
+BUFF
+	: B U F F
+	;
+
+
+
 // Compressor Type Keywords
 
 COMPRESSOR_VALUE
diff --git a/artifact/pom.xml b/artifact/pom.xml
new file mode 100644
index 0000000000..f84e6db100
--- /dev/null
+++ b/artifact/pom.xml
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>iotdb-parent</artifactId>
+        <groupId>org.apache.iotdb</groupId>
+        <version>0.14.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>artifact</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.eclipse.collections</groupId>
+            <artifactId>eclipse-collections-api</artifactId>
+            <version>11.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.collections</groupId>
+            <artifactId>eclipse-collections</artifactId>
+            <version>11.1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.iotdb</groupId>
+            <artifactId>tsfile</artifactId>
+            <version>0.14.0-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>com.github.wendykierp</groupId>
+            <artifactId>JTransforms</artifactId>
+            <version>3.1</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-assembly-plugin</artifactId>
+                <configuration>
+                    <archive>
+                        <manifest>
+                            <mainClass>org.apache.iotdb.artifact.Main</mainClass>
+                        </manifest>
+                    </archive>
+                    <descriptorRefs>
+                        <descriptorRef>jar-with-dependencies</descriptorRef>
+                    </descriptorRefs>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/artifact/src/main/java/org/apache/iotdb/artifact/Experiment.java b/artifact/src/main/java/org/apache/iotdb/artifact/Experiment.java
new file mode 100644
index 0000000000..298912303e
--- /dev/null
+++ b/artifact/src/main/java/org/apache/iotdb/artifact/Experiment.java
@@ -0,0 +1,133 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.artifact;
+
+import org.apache.iotdb.tsfile.exception.write.WriteProcessException;
+import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.read.TsFileReader;
+import org.apache.iotdb.tsfile.read.TsFileSequenceReader;
+import org.apache.iotdb.tsfile.read.common.Path;
+import org.apache.iotdb.tsfile.read.expression.QueryExpression;
+import org.apache.iotdb.tsfile.read.query.dataset.QueryDataSet;
+import org.apache.iotdb.tsfile.read.reader.page.PageReader;
+import org.apache.iotdb.tsfile.write.TsFileWriter;
+import org.apache.iotdb.tsfile.write.page.PageWriter;
+import org.apache.iotdb.tsfile.write.record.Tablet;
+import org.apache.iotdb.tsfile.write.schema.MeasurementSchema;
+
+import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class Experiment {
+
+  private static int MAX_ROW_NUM = 8192;
+  private static String TEMP_FILE = "temp";
+  private static String DEVICE = "root.group0.d0";
+  private static String SENSOR = "s1";
+
+  private long space = 0;
+  private long encodeTime = 0;
+  private long decodeTime = 0;
+
+  public Experiment() {}
+
+  public void test(DoubleArrayList data, TSEncoding encoding) {
+    try {
+      writeTest(data, encoding);
+      DoubleArrayList decoded = readTest();
+      assert check(data, decoded);
+    } catch (IOException | WriteProcessException e) {
+      e.printStackTrace();
+    }
+  }
+
+  private void writeTest(DoubleArrayList data, TSEncoding encoding)
+      throws IOException, WriteProcessException {
+    File f = new File(TEMP_FILE);
+    TsFileWriter writer = new TsFileWriter(f);
+    List<MeasurementSchema> measurements = new ArrayList<>();
+    measurements.add(
+        new MeasurementSchema(SENSOR, TSDataType.DOUBLE, encoding, CompressionType.UNCOMPRESSED));
+    writer.registerTimeseries(new Path(DEVICE), measurements);
+    PageWriter.encodeTimeCost = 0;
+    Tablet tablet = new Tablet(DEVICE, measurements, MAX_ROW_NUM);
+    for (int i = 0; i < data.size(); i++) {
+      tablet.rowSize++;
+      tablet.addTimestamp(i % MAX_ROW_NUM, i);
+      tablet.addValue(SENSOR, i % MAX_ROW_NUM, data.get(i));
+      if (tablet.rowSize == MAX_ROW_NUM) {
+        writer.write(tablet);
+        tablet.reset();
+      }
+    }
+    if (tablet.rowSize > 0) {
+      writer.write(tablet);
+      tablet.reset();
+    }
+    writer.close();
+    this.space = f.length();
+    this.encodeTime = PageWriter.encodeTimeCost;
+  }
+
+  private DoubleArrayList readTest() throws IOException {
+    DoubleArrayList data = new DoubleArrayList();
+    TsFileReader reader = new TsFileReader(new TsFileSequenceReader(TEMP_FILE));
+    Path path = new Path(DEVICE, SENSOR);
+    List<Path> paths = new ArrayList<>();
+    paths.add(path);
+    PageReader.decodeTimeCost = 0;
+    QueryDataSet dataSet = reader.query(QueryExpression.create(paths, null));
+    while (dataSet.hasNext()) {
+      data.add(dataSet.next().getFields().get(0).getDoubleV());
+    }
+    this.decodeTime += PageReader.decodeTimeCost;
+    return data;
+  }
+
+  private boolean check(DoubleArrayList a, DoubleArrayList b) {
+    if (a.size() != b.size()) {
+      return false;
+    }
+    boolean ans = true;
+    for (int i = 0; i < a.size(); i++) {
+      if (a.get(i) != b.get(i)) {
+        ans = false;
+      }
+    }
+    return ans;
+  }
+
+  public long getSpace() {
+    return space;
+  }
+
+  public long getEncodeTime() {
+    return encodeTime;
+  }
+
+  public long getDecodeTime() {
+    return decodeTime;
+  }
+}
diff --git a/artifact/src/main/java/org/apache/iotdb/artifact/Main.java b/artifact/src/main/java/org/apache/iotdb/artifact/Main.java
new file mode 100644
index 0000000000..ea5b110393
--- /dev/null
+++ b/artifact/src/main/java/org/apache/iotdb/artifact/Main.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.artifact;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+
+import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
+
+import java.io.File;
+import java.io.IOException;
+
+public class Main {
+
+  private static final String CSV_SUFFIX = ".csv";
+  private static final String DATASET_PATH = "dataset";
+  private static final int REPEAT_TIMES = 100;
+  private static final int BLOCK_SIZE = 1024;
+  private static final double BETA = 0;
+  private static final TSEncoding[] ENCODINGS = {
+    TSEncoding.PLAIN,
+    TSEncoding.DESCEND,
+    TSEncoding.GORILLA,
+    TSEncoding.TS_2DIFF,
+    TSEncoding.RLE,
+    TSEncoding.BUFF
+  };
+  private static final String SPACE_RESULT_PATH = "result/space.csv";
+  private static final String ENCODE_TIME_RESULT_PATH = "result/encode_time.csv";
+  private static final String DECODE_TIME_RESULT_PATH = "result/decode_time.csv";
+
+  public static void main(String[] args) throws IOException {
+
+    // prepare datasets for encodings
+    File dir = new File(DATASET_PATH);
+    if (!dir.isDirectory()) {
+      System.out.println("Cannot find directory artifact/dataset");
+      return;
+    }
+    File[] files = dir.listFiles((s) -> s.getName().endsWith(CSV_SUFFIX));
+
+    // variables for results
+    double[][] space = new double[files.length][ENCODINGS.length];
+    double[][] encodeTime = new double[files.length][ENCODINGS.length];
+    double[][] decodeTime = new double[files.length][ENCODINGS.length];
+
+    // traverse all datasets
+    for (int i = 0; i < files.length; i++) {
+      // transform to frequency domain
+      DoubleArrayList timeDomain = Utils.loadFile(files[i]);
+      DoubleArrayList frequencyDomain =
+          ShortTimeFourierTransform.transform(timeDomain, BLOCK_SIZE, BETA);
+
+      // traverse all encodings for multiple times and record the average results
+      for (int j = 0; j < ENCODINGS.length; j++) {
+        for (int k = 0; k < REPEAT_TIMES; k++) {
+          Experiment experiment = new Experiment();
+          experiment.test(frequencyDomain, ENCODINGS[j]);
+          space[i][j] += experiment.getSpace();
+          encodeTime[i][j] += experiment.getEncodeTime() * 1e-9;
+          decodeTime[i][j] += experiment.getDecodeTime() * 1e-9;
+        }
+        space[i][j] /= REPEAT_TIMES;
+        encodeTime[i][j] /= REPEAT_TIMES;
+        decodeTime[i][j] /= REPEAT_TIMES;
+      }
+    }
+
+    // print the results
+    Utils.printTable(SPACE_RESULT_PATH, space, ENCODINGS, files);
+    Utils.printTable(ENCODE_TIME_RESULT_PATH, encodeTime, ENCODINGS, files);
+    Utils.printTable(DECODE_TIME_RESULT_PATH, decodeTime, ENCODINGS, files);
+  }
+}
diff --git a/artifact/src/main/java/org/apache/iotdb/artifact/ShortTimeFourierTransform.java b/artifact/src/main/java/org/apache/iotdb/artifact/ShortTimeFourierTransform.java
new file mode 100644
index 0000000000..428eda0b25
--- /dev/null
+++ b/artifact/src/main/java/org/apache/iotdb/artifact/ShortTimeFourierTransform.java
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.artifact;
+
+import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
+import org.jtransforms.fft.DoubleFFT_1D;
+
+/** Short time Fourier transform (STFT) with quantization */
+public class ShortTimeFourierTransform {
+
+  /**
+   * transform given time domain data to frequency domain with quantization
+   *
+   * @param timeDomain given time domain data
+   * @param blockSize block size for STFT
+   * @param beta quantization level
+   * @return quantized frequency domain
+   */
+  public static DoubleArrayList transform(DoubleArrayList timeDomain, int blockSize, double beta) {
+    DoubleArrayList frequencyDomain = new DoubleArrayList(timeDomain.size());
+    for (int i = 0; i < timeDomain.size(); i += blockSize) {
+      double[] x = transformBlock(timeDomain, i, Math.min(timeDomain.size(), i + blockSize), beta);
+      frequencyDomain.addAll(x);
+    }
+    return frequencyDomain;
+  }
+
+  private static double[] transformBlock(
+      DoubleArrayList timeDomain, int from, int to, double beta) {
+    int n = to - from;
+    DoubleFFT_1D fft = new DoubleFFT_1D(n);
+    double[] a = new double[2 * n];
+    for (int i = 0; i < n; i++) {
+      a[2 * i] = timeDomain.get(i + from);
+      a[2 * i + 1] = 0;
+    }
+    fft.complexForward(a);
+    double[] frequencyDomain = new double[n];
+    double eps = Math.pow(2, beta);
+    for (int i = 0; i < n; i++) {
+      double v = Math.sqrt(a[2 * i] * a[2 * i] + a[2 * i + 1] * a[2 * i + 1]);
+      v /= n;
+      frequencyDomain[i] = (int) Math.round(v / eps) * eps;
+    }
+    return frequencyDomain;
+  }
+}
diff --git a/artifact/src/main/java/org/apache/iotdb/artifact/Utils.java b/artifact/src/main/java/org/apache/iotdb/artifact/Utils.java
new file mode 100644
index 0000000000..76507d41cf
--- /dev/null
+++ b/artifact/src/main/java/org/apache/iotdb/artifact/Utils.java
@@ -0,0 +1,82 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.artifact;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+
+import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Scanner;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Utils {
+
+  /**
+   * load data from a given file
+   *
+   * @param f given file
+   * @return DoubleArrayList loaded data
+   * @throws FileNotFoundException
+   */
+  public static DoubleArrayList loadFile(File f) throws FileNotFoundException {
+    Scanner sc = new Scanner(f);
+    DoubleArrayList data = new DoubleArrayList();
+    while (sc.hasNext()) {
+      data.add(sc.nextDouble());
+    }
+    sc.close();
+    return data;
+  }
+
+  /**
+   * print the table into a CSV file
+   *
+   * @param path name of the CSV file
+   * @param table table content in the M * N array
+   * @param columns array of columns whose length is N
+   * @param rows array of rows whose length is M
+   */
+  public static void printTable(String path, double[][] table, TSEncoding[] columns, File[] rows) {
+    try {
+      File f = new File(path);
+      PrintWriter writer = new PrintWriter(f);
+      // print the header
+      for (TSEncoding r : columns) {
+        writer.print("," + r);
+      }
+      writer.println();
+      // print the body
+      for (int i = 0; i < table.length; i++) {
+        writer.print(rows[i]);
+        for (int j = 0; j < table[i].length; j++) {
+          writer.print("," + table[i][j]);
+        }
+        writer.println();
+      }
+      writer.close();
+    } catch (IOException ex) {
+      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
+    }
+  }
+}
diff --git a/library-udf/pom.xml b/library-udf/pom.xml
index 632b73f634..a0c6f4d959 100644
--- a/library-udf/pom.xml
+++ b/library-udf/pom.xml
@@ -40,20 +40,8 @@
         </dependency>
         <dependency>
             <groupId>org.apache.iotdb</groupId>
-            <artifactId>iotdb-server</artifactId>
-            <version>${project.parent.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.iotdb</groupId>
-            <artifactId>tsfile</artifactId>
-            <version>${project.parent.version}</version>
-            <scope>provided</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.iotdb</groupId>
-            <artifactId>iotdb-session</artifactId>
-            <version>${project.parent.version}</version>
+            <artifactId>udf-api</artifactId>
+            <version>0.14.0-preview2</version>
         </dependency>
         <dependency>
             <groupId>org.apache.commons</groupId>
@@ -65,18 +53,6 @@
             <artifactId>commons-lang3</artifactId>
             <version>3.9</version>
         </dependency>
-        <!-- TimeStampRepair -->
-        <dependency>
-            <groupId>gov.nist.math</groupId>
-            <artifactId>jama</artifactId>
-            <version>1.0.3</version>
-        </dependency>
-        <!-- LOF -->
-        <dependency>
-            <groupId>com.github.chen0040</groupId>
-            <artifactId>java-local-outlier-factor</artifactId>
-            <version>1.0.4</version>
-        </dependency>
         <!-- FFT, IFFT, LowPass, HighPass -->
         <dependency>
             <groupId>com.github.wendykierp</groupId>
@@ -103,7 +79,7 @@
         <dependency>
             <groupId>org.apache.iotdb</groupId>
             <artifactId>integration</artifactId>
-            <version>0.13.0-SNAPSHOT</version>
+            <version>0.14.0-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
         <dependency>
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFCov.java b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFCov.java
index bf61929ac3..9f8a8e845f 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFCov.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFCov.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dmatch;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function calculates Covariance between two input series. */
 public class UDAFCov implements UDTF {
@@ -41,18 +41,14 @@ public class UDAFCov implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
-        .validateInputSeriesDataType(
-            1, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
+        .validateInputSeriesDataType(1, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     count = 0;
     sum_x = 0;
     sum_y = 0;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFDtw.java b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFDtw.java
index 90fae2816e..37645f3d6a 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFDtw.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFDtw.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dmatch;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 
@@ -42,10 +42,8 @@ public class UDAFDtw implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
-        .validateInputSeriesDataType(
-            1, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
+        .validateInputSeriesDataType(1, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
@@ -53,7 +51,7 @@ public class UDAFDtw implements UDTF {
       throws Exception {
     configurations
         .setAccessStrategy(new SlidingSizeWindowAccessStrategy(Integer.MAX_VALUE))
-        .setOutputDataType(TSDataType.DOUBLE);
+        .setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFPearson.java b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFPearson.java
index 3a8e97ac1a..714a789f67 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFPearson.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDAFPearson.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dmatch;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function calculates Pearson's r between two input series. */
 public class UDAFPearson implements UDTF {
@@ -43,18 +43,14 @@ public class UDAFPearson implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
-        .validateInputSeriesDataType(
-            1, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
+        .validateInputSeriesDataType(1, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     count = 0;
     sum_x = 0.0;
     sum_y = 0.0;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFPtnSym.java b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFPtnSym.java
index 98478e751b..b4e886e893 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFPtnSym.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFPtnSym.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dmatch;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 
@@ -42,8 +42,7 @@ public class UDTFPtnSym implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             x -> (int) x > 0,
             "window has to be a positive integer.",
@@ -60,7 +59,7 @@ public class UDTFPtnSym implements UDTF {
     window = parameters.getIntOrDefault("window", 10);
     configurations
         .setAccessStrategy(new SlidingSizeWindowAccessStrategy(window, 1))
-        .setOutputDataType(TSDataType.DOUBLE);
+        .setOutputDataType(Type.DOUBLE);
     threshold = parameters.getDoubleOrDefault("threshold", Double.MAX_VALUE);
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFXCorr.java b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFXCorr.java
index b72a3a276d..ce47f3613e 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFXCorr.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dmatch/UDTFXCorr.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dmatch;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dmatch.util.CrossCorrelation;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -43,7 +43,7 @@ public class UDTFXCorr implements UDTF {
       throws Exception {
     udtfConfigurations
         .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+        .setOutputDataType(Type.DOUBLE);
     valueArrayList0.clear();
     valueArrayList1.clear();
   }
@@ -72,10 +72,8 @@ public class UDTFXCorr implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
-        .validateInputSeriesDataType(
-            1, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
+        .validateInputSeriesDataType(1, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegral.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegral.java
index 87fa45a63a..5b1f22957d 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegral.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegral.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /**
  * calculate the integral or the area under the curve of input series $unit$ is the time scale for
@@ -65,9 +65,7 @@ public class UDAFIntegral implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     switch (parameters.getStringOrDefault(TIME_UNIT_KEY, TIME_UNIT_S)) {
       case TIME_UNIT_MS:
         unitTime = 1L;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegralAvg.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegralAvg.java
index 2250ca9816..c94146dbe7 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegralAvg.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFIntegralAvg.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /**
  * calculate the integral or the area under the curve of input series $unit$ is the time scale for
@@ -44,16 +44,13 @@ public class UDAFIntegralAvg implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMad.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMad.java
index 9164198c35..b817644989 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMad.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMad.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.ExactOrderStatistics;
 import org.apache.iotdb.library.dprofile.util.MADSketch;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** calculate the exact or approximate median absolute deviation (mad) */
 public class UDAFMad implements UDTF {
@@ -42,8 +42,7 @@ public class UDAFMad implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             error -> (double) error >= 0 && (double) error < 1,
             "error has to be greater than or equal to 0 and less than 1.",
@@ -53,9 +52,7 @@ public class UDAFMad implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     double error = parameters.getDoubleOrDefault("error", 0);
     exact = (error == 0);
     if (exact) {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMedian.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMedian.java
index 00b45af92c..c3710ac8a0 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMedian.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMedian.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.ExactOrderStatistics;
 import org.apache.iotdb.library.dprofile.util.GKArray;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** calculate the exact or approximate median */
 public class UDAFMedian implements UDTF {
@@ -42,8 +42,7 @@ public class UDAFMedian implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             error -> (double) error >= 0 && (double) error < 1,
             "error has to be greater than or equal to 0 and less than 1.",
@@ -53,9 +52,7 @@ public class UDAFMedian implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     double error = parameters.getDoubleOrDefault("error", 0);
     exact = (error == 0);
     if (exact) {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMode.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMode.java
index e19cce850a..032581c0b2 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMode.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFMode.java
@@ -18,15 +18,15 @@
  */
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.MaxSelector;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.map.mutable.primitive.DoubleIntHashMap;
 import org.eclipse.collections.impl.map.mutable.primitive.DoubleLongHashMap;
@@ -54,7 +54,7 @@ public class UDAFMode implements UDTF {
   private int booleanCnt;
   private HashMap<String, Integer> stringMap;
   private HashMap<String, Long> stMap;
-  private TSDataType dataType;
+  private Type dataType;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPercentile.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPercentile.java
index 6eebfee988..1ef44817b6 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPercentile.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPercentile.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.ExactOrderStatistics;
 import org.apache.iotdb.library.dprofile.util.GKArray;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.HashMap;
 
@@ -43,14 +43,13 @@ public class UDAFPercentile implements UDTF {
   private GKArray sketch;
   private boolean exact;
   private double rank;
-  private TSDataType dataType;
+  private Type dataType;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             error -> (double) error >= 0 && (double) error < 1,
             "error has to be greater than or equal to 0 and less than 1.",
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPeriod.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPeriod.java
index 892e553f79..d3f6d67ffa 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPeriod.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFPeriod.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.math3.util.Pair;
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
@@ -41,8 +41,7 @@ public class UDAFPeriod implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64);
+        .validateInputSeriesDataType(0, Type.FLOAT, Type.DOUBLE, Type.INT32, Type.INT64);
   }
 
   @Override
@@ -50,7 +49,7 @@ public class UDAFPeriod implements UDTF {
       throws Exception {
     configurations
         .setAccessStrategy(new SlidingSizeWindowAccessStrategy(Integer.MAX_VALUE))
-        .setOutputDataType(TSDataType.INT32);
+        .setOutputDataType(Type.INT32);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSkew.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSkew.java
index 559f1cc857..7f58314296 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSkew.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSkew.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function calculates skew of input series. */
 public class UDAFSkew implements UDTF {
@@ -40,16 +40,13 @@ public class UDAFSkew implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSpread.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSpread.java
index 414ff37c0a..cef155181f 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSpread.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFSpread.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.NoNumberException;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /**
  * This function is used to calculate the spread of time series, that is, the maximum value minus
@@ -39,14 +39,13 @@ public class UDAFSpread implements UDTF {
   long longMin = Long.MAX_VALUE, longMax = Long.MIN_VALUE;
   float floatMin = Float.MAX_VALUE, floatMax = -Float.MAX_VALUE;
   double doubleMin = Double.MAX_VALUE, doubleMax = -Double.MAX_VALUE;
-  TSDataType dataType;
+  Type dataType;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFStddev.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFStddev.java
index 5611c0116c..f2c05968d1 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFStddev.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDAFStddev.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function is used to calculate the population standard deviation. */
 public class UDAFStddev implements UDTF {
@@ -39,16 +39,13 @@ public class UDAFStddev implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFACF.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFACF.java
index 3bc410c816..6a88b95222 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFACF.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFACF.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.CrossCorrelation;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -41,16 +41,13 @@ public class UDTFACF implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     valueArrayList.clear();
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFDistinct.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFDistinct.java
index 5f0ab6c89d..c53c930df7 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFDistinct.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFDistinct.java
@@ -19,14 +19,14 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.api.iterator.MutableBooleanIterator;
 import org.eclipse.collections.api.iterator.MutableDoubleIterator;
@@ -50,20 +50,14 @@ public class UDTFDistinct implements UDTF {
   private DoubleHashSet doubleSet;
   private BooleanHashSet booleanSet;
   private HashSet<String> stringSet;
-  private TSDataType dataType;
+  private Type dataType;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
         .validateInputSeriesDataType(
-            0,
-            TSDataType.INT32,
-            TSDataType.INT64,
-            TSDataType.FLOAT,
-            TSDataType.DOUBLE,
-            TSDataType.TEXT,
-            TSDataType.BOOLEAN);
+            0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE, Type.TEXT, Type.BOOLEAN);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFHistogram.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFHistogram.java
index 4f0c4ce529..ab5fe3c4af 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFHistogram.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFHistogram.java
@@ -18,15 +18,15 @@
  */
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /**
  * This function is used to calculate the distribution histogram of a single column of numerical
@@ -43,8 +43,7 @@ public class UDTFHistogram implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             count -> (int) count > 0,
             "parameter $count$ should be larger than 0",
@@ -59,9 +58,7 @@ public class UDTFHistogram implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.INT32);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.INT32);
     // input param min is var start, param max is var end
     start = parameters.getDoubleOrDefault("min", -Double.MAX_VALUE);
     double end = parameters.getDoubleOrDefault("max", Double.MAX_VALUE);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMinMax.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMinMax.java
index a7812c0c4a..6cd9851084 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMinMax.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMinMax.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -44,8 +44,7 @@ public class UDTFMinMax implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             x -> ((String) x).equalsIgnoreCase("batch") || ((String) x).equalsIgnoreCase("stream"),
             "Parameter \"compute\" is illegal. Please use \"batch\" (for default) or \"stream\".",
@@ -65,9 +64,7 @@ public class UDTFMinMax implements UDTF {
     min = 0.0d;
     max = 0.0d;
     flag = true;
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     compute = parameters.getStringOrDefault("compute", "batch");
     if (compute.equalsIgnoreCase("stream")) {
       min = parameters.getDouble("min");
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMvAvg.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMvAvg.java
index 4226354db8..ab9c84578a 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMvAvg.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFMvAvg.java
@@ -19,29 +19,28 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.DoubleCircularQueue;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function calculates moving average of given window length of input series. */
 public class UDTFMvAvg implements UDTF {
   int windowSize;
-  TSDataType dataType;
+  Type dataType;
   DoubleCircularQueue v;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             x -> (int) x > 0,
             "Window size should be larger than 0.",
@@ -51,9 +50,7 @@ public class UDTFMvAvg implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     dataType = parameters.getDataType(0);
     windowSize = parameters.getIntOrDefault("window", 10);
     v = new DoubleCircularQueue(windowSize);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFPACF.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFPACF.java
index b444739183..0f0bdd3dac 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFPACF.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFPACF.java
@@ -18,18 +18,17 @@
  */
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.YuleWalker;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
-import org.apache.commons.math3.linear.*;
 import org.apache.commons.math3.stat.StatUtils;
 
 import java.util.ArrayList;
@@ -46,8 +45,7 @@ public class UDTFPACF implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
   }
 
   @Override
@@ -55,9 +53,7 @@ public class UDTFPACF implements UDTF {
       throws Exception {
     value.clear();
     timestamp.clear();
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     lag = parameters.getIntOrDefault("lag", -1);
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFQLB.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFQLB.java
index 953fb2edb9..0fd11b7831 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFQLB.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFQLB.java
@@ -18,15 +18,15 @@
  */
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.math3.distribution.ChiSquaredDistribution;
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
@@ -42,8 +42,7 @@ public class UDTFQLB implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             x -> (int) x >= 0,
             "Parameter $lag$ should be an positive integer, or '0' for default value.",
@@ -53,9 +52,7 @@ public class UDTFQLB implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     m = parameters.getIntOrDefault("lag", 0);
     valueArrayList.clear();
   }
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java
index 229dbef8c6..4179bccdef 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFResample.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.Resampler;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.text.SimpleDateFormat;
 
@@ -41,8 +41,7 @@ public class UDTFResample implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x -> (long) x > 0,
             "gap should be a time period whose unit is ms, s, m, h, d.",
@@ -79,9 +78,7 @@ public class UDTFResample implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     long newPeriod = Util.parseTime(parameters.getString("every"));
     String aggregator = parameters.getStringOrDefault("aggr", "mean").toLowerCase();
     String interpolator = parameters.getStringOrDefault("interp", "nan").toLowerCase();
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSample.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSample.java
index 370e244143..b46a14feb0 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSample.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSample.java
@@ -19,18 +19,18 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.lang3.tuple.Pair;
 
@@ -46,7 +46,7 @@ public class UDTFSample implements UDTF {
   private Pair<Long, Object>[] samples; // sampled data
   private int num = 0; // number of points already sampled
   private Random random;
-  private TSDataType dataType;
+  private Type dataType;
 
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSegment.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSegment.java
index dbdfc08011..b9e6254c38 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSegment.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSegment.java
@@ -18,16 +18,16 @@
  */
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.dprofile.util.Segment;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -44,8 +44,7 @@ public class UDTFSegment implements UDTF {
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
-        .validateInputSeriesDataType(
-            0, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE)
+        .validateInputSeriesDataType(0, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE)
         .validate(
             x -> (int) x > 0,
             "Window size should be a positive integer.",
@@ -68,9 +67,7 @@ public class UDTFSegment implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     timestamp.clear();
     value.clear();
     this.windowSize = parameters.getIntOrDefault("window", 10);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSpline.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSpline.java
index cf6925e5db..d9c214033a 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSpline.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFSpline.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.math3.analysis.interpolation.AkimaSplineInterpolator;
@@ -48,16 +48,13 @@ public class UDTFSpline implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64);
+        .validateInputSeriesDataType(0, Type.FLOAT, Type.DOUBLE, Type.INT32, Type.INT64);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     samplePoints = parameters.getInt("points");
     timestamp.clear();
     xDouble.clear();
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFZScore.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFZScore.java
index 1f1a8ead60..75115e5b65 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFZScore.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/UDTFZScore.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.dprofile;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -48,8 +48,7 @@ public class UDTFZScore implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.FLOAT, Type.DOUBLE, Type.INT32, Type.INT64)
         .validate(
             x -> ((String) x).equalsIgnoreCase("batch") || ((String) x).equalsIgnoreCase("stream"),
             "Parameter \"compute\" is illegal. Please use \"batch\" (for default) or \"stream\".",
@@ -67,9 +66,7 @@ public class UDTFZScore implements UDTF {
     timestamp.clear();
     sum = 0.0d;
     squareSum = 0.0d;
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     compute = parameters.getStringOrDefault("compute", "batch");
     if (compute.equalsIgnoreCase("stream")) {
       avg = parameters.getDouble("avg");
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/ExactOrderStatistics.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/ExactOrderStatistics.java
index e6aa0e9d3a..00ea12bd12 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/ExactOrderStatistics.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/ExactOrderStatistics.java
@@ -18,9 +18,9 @@
  */
 package org.apache.iotdb.library.dprofile.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.exception.UDFInputSeriesDataTypeNotValidException;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.exception.UDFInputSeriesDataTypeNotValidException;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 import org.eclipse.collections.impl.list.mutable.primitive.FloatArrayList;
@@ -33,13 +33,13 @@ import java.util.NoSuchElementException;
 /** Util for computing median, MAD, percentile */
 public class ExactOrderStatistics {
 
-  private final TSDataType dataType;
+  private final Type dataType;
   private FloatArrayList floatArrayList;
   private DoubleArrayList doubleArrayList;
   private IntArrayList intArrayList;
   private LongArrayList longArrayList;
 
-  public ExactOrderStatistics(TSDataType type) throws UDFInputSeriesDataTypeNotValidException {
+  public ExactOrderStatistics(Type type) throws UDFInputSeriesDataTypeNotValidException {
     this.dataType = type;
     switch (dataType) {
       case INT32:
@@ -57,7 +57,7 @@ public class ExactOrderStatistics {
       default:
         // This will not happen.
         throw new UDFInputSeriesDataTypeNotValidException(
-            0, dataType, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+            0, dataType, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
     }
   }
 
@@ -84,7 +84,7 @@ public class ExactOrderStatistics {
       default:
         // This will not happen.
         throw new UDFInputSeriesDataTypeNotValidException(
-            0, dataType, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+            0, dataType, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
     }
   }
 
@@ -101,7 +101,7 @@ public class ExactOrderStatistics {
       default:
         // This will not happen.
         throw new UDFInputSeriesDataTypeNotValidException(
-            0, dataType, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+            0, dataType, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
     }
   }
 
@@ -118,7 +118,7 @@ public class ExactOrderStatistics {
       default:
         // This will not happen.
         throw new UDFInputSeriesDataTypeNotValidException(
-            0, dataType, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+            0, dataType, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
     }
   }
 
@@ -135,7 +135,7 @@ public class ExactOrderStatistics {
       default:
         // This will not happen.
         throw new UDFInputSeriesDataTypeNotValidException(
-            0, dataType, TSDataType.INT32, TSDataType.INT64, TSDataType.FLOAT, TSDataType.DOUBLE);
+            0, dataType, Type.INT32, Type.INT64, Type.FLOAT, Type.DOUBLE);
     }
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/MADSketch.java b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/MADSketch.java
index 2004f9e588..76bad325f0 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/MADSketch.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dprofile/util/MADSketch.java
@@ -20,7 +20,10 @@ package org.apache.iotdb.library.dprofile.util;
 
 import org.eclipse.collections.impl.map.mutable.UnifiedMap;
 
-import java.util.*;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+import java.util.NoSuchElementException;
 
 public class MADSketch {
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFCompleteness.java b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFCompleteness.java
index db1d356632..5d2f4436aa 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFCompleteness.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFCompleteness.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.dquality;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
 import org.apache.iotdb.library.dquality.util.TimeSeriesQuality;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.io.IOException;
 import java.util.logging.Level;
@@ -56,7 +56,7 @@ public class UDTFCompleteness implements UDTF {
     } else {
       udtfc.setAccessStrategy(new SlidingSizeWindowAccessStrategy((int) window));
     }
-    udtfc.setOutputDataType(TSDataType.DOUBLE);
+    udtfc.setOutputDataType(Type.DOUBLE);
     downtime = udfp.getBooleanOrDefault("downtime", true);
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFConsistency.java b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFConsistency.java
index b01a7f35a3..af269be8bd 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFConsistency.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFConsistency.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dquality;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
 import org.apache.iotdb.library.dquality.util.TimeSeriesQuality;
 import org.apache.iotdb.library.util.NoNumberException;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.io.IOException;
 import java.util.logging.Level;
@@ -56,7 +56,7 @@ public class UDTFConsistency implements UDTF {
     } else {
       udtfc.setAccessStrategy(new SlidingSizeWindowAccessStrategy((int) window));
     }
-    udtfc.setOutputDataType(TSDataType.DOUBLE);
+    udtfc.setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFTimeliness.java b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFTimeliness.java
index 89552f4b16..e1ea42dc09 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFTimeliness.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFTimeliness.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dquality;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
 import org.apache.iotdb.library.dquality.util.TimeSeriesQuality;
 import org.apache.iotdb.library.util.NoNumberException;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.io.IOException;
 import java.util.logging.Level;
@@ -55,7 +55,7 @@ public class UDTFTimeliness implements UDTF {
     } else {
       udtfc.setAccessStrategy(new SlidingSizeWindowAccessStrategy((int) window));
     }
-    udtfc.setOutputDataType(TSDataType.DOUBLE);
+    udtfc.setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFValidity.java b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFValidity.java
index 99e3345c72..dc848fd24f 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFValidity.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dquality/UDTFValidity.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.dquality;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
 import org.apache.iotdb.library.dquality.util.TimeSeriesQuality;
 import org.apache.iotdb.library.util.NoNumberException;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingTimeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.io.IOException;
 import java.util.logging.Level;
@@ -55,7 +55,7 @@ public class UDTFValidity implements UDTF {
     } else {
       udtfc.setAccessStrategy(new SlidingSizeWindowAccessStrategy((int) window));
     }
-    udtfc.setOutputDataType(TSDataType.DOUBLE);
+    udtfc.setOutputDataType(Type.DOUBLE);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/dquality/util/TimeSeriesQuality.java b/library-udf/src/main/java/org/apache/iotdb/library/dquality/util/TimeSeriesQuality.java
index dfc31d21f6..4902be229d 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/dquality/util/TimeSeriesQuality.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/dquality/util/TimeSeriesQuality.java
@@ -19,9 +19,9 @@
 
 package org.apache.iotdb.library.dquality.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import org.apache.commons.math3.stat.descriptive.rank.Median;
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFTimestampRepair.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFTimestampRepair.java
index 85bcbc3bb0..4c244ebae3 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFTimestampRepair.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFTimestampRepair.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.drepair;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.drepair.util.TimestampRepair;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function is used for timestamp repair. */
 public class UDTFTimestampRepair implements UDTF {
@@ -39,8 +39,7 @@ public class UDTFTimestampRepair implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x -> (Integer) x >= 0,
             "Interval should be a positive integer.",
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueFill.java
index 9d148b573b..e663cd9d4b 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueFill.java
@@ -18,13 +18,6 @@
  */
 package org.apache.iotdb.library.drepair;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.drepair.util.ARFill;
 import org.apache.iotdb.library.drepair.util.LikelihoodFill;
 import org.apache.iotdb.library.drepair.util.LinearFill;
@@ -32,7 +25,14 @@ import org.apache.iotdb.library.drepair.util.MeanFill;
 import org.apache.iotdb.library.drepair.util.PreviousFill;
 import org.apache.iotdb.library.drepair.util.ScreenFill;
 import org.apache.iotdb.library.drepair.util.ValueFill;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function is used to interpolate time series. */
 public class UDTFValueFill implements UDTF {
@@ -42,8 +42,7 @@ public class UDTFValueFill implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64);
+        .validateInputSeriesDataType(0, Type.FLOAT, Type.DOUBLE, Type.INT32, Type.INT64);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueRepair.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueRepair.java
index a7cd8ca774..3b2b4988f9 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueRepair.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/UDTFValueRepair.java
@@ -19,17 +19,17 @@
 
 package org.apache.iotdb.library.drepair;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.RowWindow;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
 import org.apache.iotdb.library.drepair.util.LsGreedy;
 import org.apache.iotdb.library.drepair.util.Screen;
 import org.apache.iotdb.library.drepair.util.ValueRepair;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function is used to repair the value of the time series. */
 public class UDTFValueRepair implements UDTF {
@@ -43,8 +43,7 @@ public class UDTFValueRepair implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.FLOAT, TSDataType.DOUBLE, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.FLOAT, Type.DOUBLE, Type.INT32, Type.INT64)
         .validate(
             x -> (double) x > 0,
             "Parameter $sigma$ should be larger than 0.",
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ARFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ARFill.java
index 90e5b7c783..2ae3400f2c 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ARFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ARFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 public class ARFill extends ValueFill {
   // TODO Higer order AR regression
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LikelihoodFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LikelihoodFill.java
index f293a16734..5a5725e898 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LikelihoodFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LikelihoodFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import java.util.ArrayList;
 import java.util.List;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LinearFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LinearFill.java
index 8c8a41b29b..2698f2341f 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LinearFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LinearFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 public class LinearFill extends ValueFill {
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LsGreedy.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LsGreedy.java
index 276841c76f..94e157e7e0 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LsGreedy.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/LsGreedy.java
@@ -18,8 +18,8 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import java.util.PriorityQueue;
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MAFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MAFill.java
index c1e90d5382..bb8316ca67 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MAFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MAFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 public class MAFill extends ValueFill {
   int window_size = 5;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MeanFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MeanFill.java
index f7d8d6377b..a3ad5c0c34 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MeanFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/MeanFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 public class MeanFill extends ValueFill {
   public MeanFill(RowIterator dataIterator) throws Exception {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/PreviousFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/PreviousFill.java
index a424d50b99..5e985ed337 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/PreviousFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/PreviousFill.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 public class PreviousFill extends ValueFill {
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/Screen.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/Screen.java
index 9bc3c93c75..9e8dd0d16a 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/Screen.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/Screen.java
@@ -18,8 +18,8 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.math3.stat.descriptive.rank.Median;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ScreenFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ScreenFill.java
index 6badf0446f..586b71778a 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ScreenFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ScreenFill.java
@@ -18,8 +18,8 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.math3.stat.descriptive.rank.Median;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampInterval.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampInterval.java
index ed1414b039..626e6b51fe 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampInterval.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampInterval.java
@@ -18,7 +18,11 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
 
 public class TimestampInterval {
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampRepair.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampRepair.java
index 54e7769401..aec782ea95 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampRepair.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/TimestampRepair.java
@@ -18,11 +18,11 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
-import java.util.*;
+import java.util.ArrayList;
 
 public class TimestampRepair {
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueFill.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueFill.java
index b3bdb33eec..ec494a08cc 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueFill.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueFill.java
@@ -18,9 +18,9 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import java.util.ArrayList;
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueRepair.java b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueRepair.java
index 5b47ac776c..b6c86eed5b 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueRepair.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/drepair/util/ValueRepair.java
@@ -18,9 +18,9 @@
  */
 package org.apache.iotdb.library.drepair.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.access.RowIterator;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.access.RowIterator;
 
 import java.io.File;
 import java.text.SimpleDateFormat;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFConv.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFConv.java
index e756f794fb..68e708bd60 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFConv.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFConv.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -41,18 +41,14 @@ public class UDTFConv implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
-        .validateInputSeriesDataType(
-            1, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64);
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
+        .validateInputSeriesDataType(1, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64);
   }
 
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     list1.clear();
     list2.clear();
   }
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDWT.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDWT.java
index 615de54b4c..23f4ab73ec 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDWT.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDWT.java
@@ -18,16 +18,16 @@
  */
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.frequency.util.DWTUtil;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -45,8 +45,7 @@ public class UDTFDWT implements UDTF {
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x ->
                 ((String) x).equalsIgnoreCase("Haar")
@@ -66,9 +65,7 @@ public class UDTFDWT implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     s = parameters.getStringOrDefault("coef", "");
     method = parameters.getStringOrDefault("method", "");
     layer = parameters.getIntOrDefault("layer", 1);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDeconv.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDeconv.java
index 7f6e743486..d1db57d890 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDeconv.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFDeconv.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -42,10 +42,8 @@ public class UDTFDeconv implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
-        .validateInputSeriesDataType(
-            1, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
+        .validateInputSeriesDataType(1, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x ->
                 ((String) x).equalsIgnoreCase("quotient")
@@ -57,9 +55,7 @@ public class UDTFDeconv implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     list1.clear();
     list2.clear();
     this.result = parameters.getStringOrDefault("result", "quotient");
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFFFT.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFFFT.java
index 2aae08c477..5ef46a1efa 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFFFT.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFFFT.java
@@ -19,16 +19,16 @@
 
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.frequency.util.FFTUtil;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 import org.jtransforms.fft.DoubleFFT_1D;
@@ -44,8 +44,7 @@ public class UDTFFFT implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x ->
                 ((String) x).equalsIgnoreCase("uniform")
@@ -69,9 +68,7 @@ public class UDTFFFT implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     String result = parameters.getStringOrDefault("result", "abs");
     this.compressed = parameters.hasAttribute("compress");
     double compressRate = parameters.getDoubleOrDefault("compress", 1);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFHighPass.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFHighPass.java
index 070f193041..c2af7d6d03 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFHighPass.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFHighPass.java
@@ -18,15 +18,15 @@
  */
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
@@ -43,8 +43,7 @@ public class UDTFHighPass implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validateRequiredAttribute("wpass")
         .validate(
             x -> (double) x > 0 && (double) x < 1,
@@ -55,9 +54,7 @@ public class UDTFHighPass implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     this.wpass = parameters.getDouble("wpass");
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIDWT.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIDWT.java
index 38d75b24a4..f7f987dcda 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIDWT.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIDWT.java
@@ -18,16 +18,16 @@
  */
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.frequency.util.DWTUtil;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.ArrayList;
 
@@ -46,8 +46,7 @@ public class UDTFIDWT implements UDTF {
   @Override
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x ->
                 ((String) x).equalsIgnoreCase("Haar")
@@ -67,9 +66,7 @@ public class UDTFIDWT implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     s = parameters.getStringOrDefault("coef", "");
     method = parameters.getStringOrDefault("method", "");
     layer = parameters.getIntOrDefault("layer", 1);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIFFT.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIFFT.java
index bf2ddb95fa..d90108af25 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIFFT.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFIFFT.java
@@ -19,15 +19,15 @@
 
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
@@ -48,8 +48,7 @@ public class UDTFIFFT implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(2)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validate(
             x -> (long) x > 0,
             "interval should be a time period whose unit is ms, s, m, h, d.",
@@ -66,9 +65,7 @@ public class UDTFIFFT implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     this.interval = Util.parseTime(parameters.getStringOrDefault("interval", "1s"));
     SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     this.start = 0;
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFLowPass.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFLowPass.java
index 855d17041e..b5d6c7ad86 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFLowPass.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFLowPass.java
@@ -18,15 +18,15 @@
  */
 package org.apache.iotdb.library.frequency;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.DoubleArrayList;
 import org.eclipse.collections.impl.list.mutable.primitive.LongArrayList;
@@ -43,8 +43,7 @@ public class UDTFLowPass implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(
-            0, TSDataType.DOUBLE, TSDataType.FLOAT, TSDataType.INT32, TSDataType.INT64)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
         .validateRequiredAttribute("wpass")
         .validate(
             x -> (double) x > 0 && (double) x < 1,
@@ -55,9 +54,7 @@ public class UDTFLowPass implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.DOUBLE);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.DOUBLE);
     this.wpass = parameters.getDouble("wpass");
   }
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFSTFT.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFSTFT.java
new file mode 100644
index 0000000000..3464464601
--- /dev/null
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/UDTFSTFT.java
@@ -0,0 +1,132 @@
+/*
+ * Copyright © 2021 iotdb-quality developer group (iotdb-quality@protonmail.com)
+ *
+ * Licensed 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.
+ */
+package org.apache.iotdb.library.frequency;
+
+import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.RowWindow;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.SlidingSizeWindowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
+
+import org.apache.commons.math3.util.Pair;
+import org.jtransforms.fft.DoubleFFT_1D;
+
+/** This function does Short Time Fourier Transform for input series. */
+public class UDTFSTFT implements UDTF {
+
+  private int nfft;
+  private int beta;
+  private double snr;
+
+  @Override
+  public void validate(UDFParameterValidator validator) throws Exception {
+    validator
+        .validateInputSeriesNumber(1)
+        .validateInputSeriesDataType(0, Type.DOUBLE, Type.FLOAT, Type.INT32, Type.INT64)
+        .validate(
+            x -> (int) x > 0,
+            "Nfft should be a positive integer.",
+            validator.getParameters().getIntOrDefault("nfft", Integer.MAX_VALUE));
+  }
+
+  @Override
+  public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
+      throws Exception {
+    this.nfft = parameters.getIntOrDefault("nfft", Integer.MAX_VALUE);
+    this.beta = parameters.getIntOrDefault("beta", 0);
+    this.snr = parameters.getDoubleOrDefault("T_SNR", Double.NaN);
+    configurations
+        .setAccessStrategy(new SlidingSizeWindowAccessStrategy(nfft))
+        .setOutputDataType(Type.DOUBLE);
+  }
+
+  @Override
+  public void transform(RowWindow rowWindow, PointCollector collector) throws Exception {
+    int n = rowWindow.windowSize();
+    DoubleFFT_1D fft = new DoubleFFT_1D(n);
+    double[] a = new double[2 * n];
+    for (int i = 0; i < n; i++) {
+      a[2 * i] = Util.getValueAsDouble(rowWindow.getRow(i));
+      a[2 * i + 1] = 0;
+    }
+    fft.complexForward(a);
+    double b[] = new double[n];
+    for (int i = 0; i < n; i++) {
+      double v = Math.sqrt(a[2 * i] * a[2 * i] + a[2 * i + 1] * a[2 * i + 1]);
+      v /= n;
+      b[i] = v;
+    }
+    if (Double.isNaN(this.snr)) {
+      double eps = Math.pow(2, beta);
+      for (int i = 0; i < n; i++) {
+        b[i] = Math.round(b[i] / eps) * eps;
+      }
+    } else {
+      b = quantize(b);
+    }
+    for (int i = 0; i < n; i++) {
+      collector.putDouble(rowWindow.getRow(i).getTime(), b[i]);
+    }
+  }
+
+  private double[] quantize(double a[]) {
+    int beta = initBeta(a);
+    while (true) {
+      Pair<Integer, Double> p = quantizeWithBeta(a, beta);
+      if (p.getSecond() < this.snr) {
+        break;
+      }
+      beta++;
+    }
+    beta--;
+    double eps = Math.pow(2, beta);
+    double[] b = new double[a.length];
+    for (int i = 0; i < a.length; i++) {
+      b[i] = (long) Math.round(a[i] / eps) * eps;
+    }
+    return b;
+  }
+
+  private int initBeta(double a[]) {
+    double sum = 0;
+    for (int i = 0; i < a.length; i++) {
+      sum += a[i] * a[i];
+    }
+    sum = sum * 1e-6 / a.length;
+    return (int) (Math.floor(0.5 * Math.log(sum) / Math.log(2)) + 1);
+  }
+
+  private Pair<Integer, Double> quantizeWithBeta(double a[], int beta) {
+    double eps = Math.pow(2, beta);
+    int cnt = 0;
+    double noise = 0, signal = 0;
+    for (int i = 0; i < a.length; i++) {
+      int t = (int) Math.round(a[i] / eps);
+      double x = a[i] - t * eps;
+      if (t > 0) {
+        cnt++;
+      }
+      signal += a[i] * a[i];
+      noise += x * x;
+    }
+    double snr = 10 * Math.log10(signal / noise);
+    return Pair.create(cnt, snr);
+  }
+}
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/frequency/util/FFTUtil.java b/library-udf/src/main/java/org/apache/iotdb/library/frequency/util/FFTUtil.java
index e3fde4e7de..acecdbc649 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/frequency/util/FFTUtil.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/frequency/util/FFTUtil.java
@@ -18,7 +18,7 @@
  */
 package org.apache.iotdb.library.frequency.util;
 
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.collector.PointCollector;
 
 /** Util for UDFFFT */
 public class FFTUtil {
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveSequences.java b/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveSequences.java
index 66d5abb24d..e084ce45ad 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveSequences.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveSequences.java
@@ -16,16 +16,16 @@
 
 package org.apache.iotdb.library.series;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.series.util.ConsecutiveUtil;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.lang3.tuple.Pair;
 
@@ -44,9 +44,7 @@ public class UDTFConsecutiveSequences implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.INT32);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.INT32);
     long gap = Util.parseTime(parameters.getStringOrDefault("gap", "0ms"));
     consUtil = new ConsecutiveUtil(-gap, -gap, gap);
   }
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveWindows.java b/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveWindows.java
index 9424a7ac26..60ada1f0e3 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveWindows.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/series/UDTFConsecutiveWindows.java
@@ -16,16 +16,16 @@
 
 package org.apache.iotdb.library.series;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
 import org.apache.iotdb.library.series.util.ConsecutiveUtil;
 import org.apache.iotdb.library.util.Util;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.lang3.tuple.Pair;
 
@@ -51,9 +51,7 @@ public class UDTFConsecutiveWindows implements UDTF {
   @Override
   public void beforeStart(UDFParameters parameters, UDTFConfigurations configurations)
       throws Exception {
-    configurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.INT32);
+    configurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.INT32);
     long gap = Util.parseTime(parameters.getStringOrDefault("gap", "0ms"));
     len = Util.parseTime(parameters.getString("length"));
     int count = gap == 0 ? 0 : (int) (len / gap + 1);
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/series/util/ConsecutiveUtil.java b/library-udf/src/main/java/org/apache/iotdb/library/series/util/ConsecutiveUtil.java
index a5e085b46f..e31b082724 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/series/util/ConsecutiveUtil.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/series/util/ConsecutiveUtil.java
@@ -15,9 +15,9 @@
  */
 package org.apache.iotdb.library.series.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
 import org.apache.iotdb.library.util.Util;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
 
 import org.apache.commons.lang3.tuple.Pair;
 
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexMatch.java b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexMatch.java
index cbe4ef62cf..22e8128c56 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexMatch.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexMatch.java
@@ -19,14 +19,14 @@
 
 package org.apache.iotdb.library.string;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -40,7 +40,7 @@ public class UDTFRegexMatch implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(0, TSDataType.TEXT)
+        .validateInputSeriesDataType(0, Type.TEXT)
         .validate(
             regex -> ((String) regex).length() > 0,
             "regexp has to be a valid regular expression.",
@@ -56,9 +56,7 @@ public class UDTFRegexMatch implements UDTF {
       throws Exception {
     pattern = Pattern.compile(udfParameters.getString("regex"));
     group = udfParameters.getIntOrDefault("group", 0);
-    udtfConfigurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.TEXT);
+    udtfConfigurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.TEXT);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexReplace.java b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexReplace.java
index 2af3bbbc7c..6e44f5a02c 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexReplace.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexReplace.java
@@ -19,14 +19,14 @@
 
 package org.apache.iotdb.library.string;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.eclipse.collections.impl.list.mutable.primitive.IntArrayList;
 
@@ -47,7 +47,7 @@ public class UDTFRegexReplace implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(0, TSDataType.TEXT)
+        .validateInputSeriesDataType(0, Type.TEXT)
         .validate(
             regex -> ((String) regex).length() > 0,
             "regex should not be empty",
@@ -72,9 +72,7 @@ public class UDTFRegexReplace implements UDTF {
     limit = udfParameters.getIntOrDefault("limit", -1);
     offset = udfParameters.getIntOrDefault("offset", 0);
     reverse = udfParameters.getBooleanOrDefault("reverse", false);
-    udtfConfigurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.TEXT);
+    udtfConfigurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.TEXT);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexSplit.java b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexSplit.java
index 45a9c79d1e..368541dc9e 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexSplit.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFRegexSplit.java
@@ -19,14 +19,14 @@
 
 package org.apache.iotdb.library.string;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function splits string from an input series according to given regex. */
 public class UDTFRegexSplit implements UDTF {
@@ -41,9 +41,9 @@ public class UDTFRegexSplit implements UDTF {
     index = udfParameters.getIntOrDefault("index", -1);
     udtfConfigurations.setAccessStrategy(new RowByRowAccessStrategy());
     if (index == -1) {
-      udtfConfigurations.setOutputDataType(TSDataType.INT32);
+      udtfConfigurations.setOutputDataType(Type.INT32);
     } else {
-      udtfConfigurations.setOutputDataType(TSDataType.TEXT);
+      udtfConfigurations.setOutputDataType(Type.TEXT);
     }
   }
 
@@ -63,7 +63,7 @@ public class UDTFRegexSplit implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(0, TSDataType.TEXT)
+        .validateInputSeriesDataType(0, Type.TEXT)
         .validate(
             regex -> ((String) regex).length() > 0,
             "regexp has to be a valid regular expression.",
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFStrReplace.java b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFStrReplace.java
index b6b19f4bcc..013ed08168 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFStrReplace.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/string/UDTFStrReplace.java
@@ -19,14 +19,14 @@
 
 package org.apache.iotdb.library.string;
 
-import org.apache.iotdb.db.query.udf.api.UDTF;
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.db.query.udf.api.customizer.config.UDTFConfigurations;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameterValidator;
-import org.apache.iotdb.db.query.udf.api.customizer.parameter.UDFParameters;
-import org.apache.iotdb.db.query.udf.api.customizer.strategy.RowByRowAccessStrategy;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.UDTF;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.customizer.config.UDTFConfigurations;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameterValidator;
+import org.apache.iotdb.udf.api.customizer.parameter.UDFParameters;
+import org.apache.iotdb.udf.api.customizer.strategy.RowByRowAccessStrategy;
+import org.apache.iotdb.udf.api.type.Type;
 
 /** This function does limited times of replacement of substring from an input series. */
 public class UDTFStrReplace implements UDTF {
@@ -41,7 +41,7 @@ public class UDTFStrReplace implements UDTF {
   public void validate(UDFParameterValidator validator) throws Exception {
     validator
         .validateInputSeriesNumber(1)
-        .validateInputSeriesDataType(0, TSDataType.TEXT)
+        .validateInputSeriesDataType(0, Type.TEXT)
         .validate(
             target -> ((String) target).length() > 0,
             "target should not be empty",
@@ -65,9 +65,7 @@ public class UDTFStrReplace implements UDTF {
     limit = udfParameters.getIntOrDefault("limit", -1);
     offset = udfParameters.getIntOrDefault("offset", 0);
     reverse = udfParameters.getBooleanOrDefault("reverse", false);
-    udtfConfigurations
-        .setAccessStrategy(new RowByRowAccessStrategy())
-        .setOutputDataType(TSDataType.TEXT);
+    udtfConfigurations.setAccessStrategy(new RowByRowAccessStrategy()).setOutputDataType(Type.TEXT);
   }
 
   @Override
diff --git a/library-udf/src/main/java/org/apache/iotdb/library/util/Util.java b/library-udf/src/main/java/org/apache/iotdb/library/util/Util.java
index 0329628119..01377e8346 100644
--- a/library-udf/src/main/java/org/apache/iotdb/library/util/Util.java
+++ b/library-udf/src/main/java/org/apache/iotdb/library/util/Util.java
@@ -18,9 +18,9 @@
  */
 package org.apache.iotdb.library.util;
 
-import org.apache.iotdb.db.query.udf.api.access.Row;
-import org.apache.iotdb.db.query.udf.api.collector.PointCollector;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
+import org.apache.iotdb.udf.api.access.Row;
+import org.apache.iotdb.udf.api.collector.PointCollector;
+import org.apache.iotdb.udf.api.type.Type;
 
 import org.apache.commons.math3.stat.descriptive.rank.Median;
 import org.eclipse.collections.api.tuple.primitive.LongIntPair;
@@ -115,8 +115,7 @@ public class Util {
    * @param t timestamp
    * @param o value in Object type
    */
-  public static void putValue(PointCollector pc, TSDataType type, long t, Object o)
-      throws Exception {
+  public static void putValue(PointCollector pc, Type type, long t, Object o) throws Exception {
     switch (type) {
       case INT32:
         pc.putInt(t, (Integer) o);
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/dmatch/DMatchTests.java b/library-udf/src/test/java/org/apache/iotdb/library/dmatch/DMatchTests.java
deleted file mode 100644
index 435a7631e6..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/dmatch/DMatchTests.java
+++ /dev/null
@@ -1,826 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.dmatch;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class DMatchTests {
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.schemaEngine.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s3"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s4"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s5"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s6"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s7"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s8"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s3"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s4"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s5"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s6"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s7"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s8"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d3.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d3.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d3.s3"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d3.s4"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s3"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s4"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s5"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s6"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s7"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d4.s8"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              100, 100, 100, 100, 100, 101, 101, 101, 101));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              100, 100, 100, 100, 100, 101, 101, 101, 101));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              200, 102, 102, 102, 102, 101, 101, 101, 101));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              300, 104, 104, 104, 104, 102, 102, 102, 102));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              400, 126, 126, 126, 126, 102, 102, 102, 102));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              500, 108, 108, 108, 108, 103, 103, 103, 103));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              600, 112, 112, 112, 112, 104, 104, 104, 104));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              700, 114, 114, 114, 114, 104, 104, 104, 104));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              800, 116, 116, 116, 116, 105, 105, 105, 105));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              900, 118, 118, 118, 118, 105, 105, 105, 105));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              1000, 100, 100, 100, 100, 106, 106, 106, 106));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              1100, 124, 124, 124, 124, 108, 108, 108, 108));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              1200, 126, 126, 126, 126, 108, 108, 108, 108));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              1300, 116, 116, 116, 116, 105, 105, 105, 105));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              100, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              200, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              300, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              400, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              500, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              600, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              700, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              800, 1, 1, 1, 1, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              100, 1, 1, 1, 1));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              200, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              300, 3, 3, 3, 3));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              400, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              500, 1, 1, 1, 1));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              600, 1, 1, 1, 1));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              700, 1, 1, 1, 1));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              800, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              900, 3, 3, 3, 3));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              1000, 2, 2, 2, 2));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d3(timestamp,s1,s2,s3,s4) values(%d,%d,%d,%d,%d)",
-              1100, 1, 1, 1, 1));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d4(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              100, 0, 0, 0, 0, 6, 6, 6, 6));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d4(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              200, 2, 2, 2, 2, 7, 7, 7, 7));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d4(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              300, 3, 3, 3, 3, 0, 0, 0, 0));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d4(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              400, 4, 4, 4, 4, 9, 9, 9, 9));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d4(timestamp,s1,s2,s3,s4,s5,s6,s7,s8) values(%d,%d,%d,%d,%d,%d,%d,%d,%d))",
-              500, 5, 5, 5, 5, 10, 10, 10, 10));
-      statement.executeBatch();
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute("create function cov as 'org.apache.iotdb.library.dmatch.UDAFCov'");
-      statement.execute("create function dtw as 'org.apache.iotdb.library.dmatch.UDAFDtw'");
-      statement.execute("create function pearson as 'org.apache.iotdb.library.dmatch.UDAFPearson'");
-      statement.execute("create function ptnsym as 'org.apache.iotdb.library.dmatch.UDTFPtnSym'");
-      statement.execute("create function xcorr as 'org.apache.iotdb.library.dmatch.UDTFXcorr'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testCov1() {
-    String sqlStr = "select cov(d1.s1,d1.s5) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(12.291666666666666, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCov2() {
-    String sqlStr = "select cov(d1.s2,d1.s6) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(12.291666666666666, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCov3() {
-    String sqlStr = "select cov(d1.s3,d1.s7) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(12.291666666666666, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCov4() {
-    String sqlStr = "select cov(d1.s4,d1.s8) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(12.291666666666666, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDtw1() {
-    String sqlStr = "select dtw(d2.s1,d2.s5) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(8.0, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDtw2() {
-    String sqlStr = "select dtw(d2.s2,d2.s6) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(8.0, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDtw3() {
-    String sqlStr = "select dtw(d2.s3,d2.s7) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(8.0, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDtw4() {
-    String sqlStr = "select dtw(d2.s4,d2.s8) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(8.0, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPearson1() {
-    String sqlStr = "select pearson(d1.s1,d1.s5) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(0.5630881927754872, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPearson2() {
-    String sqlStr = "select pearson(d1.s2,d1.s6) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(0.5630881927754872, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPearson3() {
-    String sqlStr = "select pearson(d1.s3,d1.s7) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(0.5630881927754872, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPearson4() {
-    String sqlStr = "select pearson(d1.s4,d1.s8) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      Assert.assertEquals(0.5630881927754872, result1, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPthSym1() {
-    String sqlStr = "select ptnsym(d1.s1, 'window'='3', 'threshold'='0') from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(0.0, result2, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPtnSym2() {
-    String sqlStr = "select ptnsym(d1.s2, 'window'='3', 'threshold'='0') from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(0.0, result2, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPtnSym3() {
-    String sqlStr = "select ptnsym(d2.s1, 'window'='3', 'threshold'='0') from";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(0.0, result2, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPtnSym4() {
-    String sqlStr = "select ptnsym(d2.s2, 'window'='3', 'threshold'='0') from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(0.0, result2, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testXCorr1() {
-    String sqlStr = "select xcorr(d4.s1,d4.s5) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      resultSet.next();
-      double result3 = resultSet.getDouble(1);
-      resultSet.next();
-      double result4 = resultSet.getDouble(1);
-      resultSet.next();
-      double result5 = resultSet.getDouble(1);
-      resultSet.next();
-      double result6 = resultSet.getDouble(1);
-      resultSet.next();
-      double result7 = resultSet.getDouble(1);
-      resultSet.next();
-      double result8 = resultSet.getDouble(1);
-      resultSet.next();
-      double result9 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(4.0, result2, 0.01);
-      Assert.assertEquals(9.6, result3, 0.01);
-      Assert.assertEquals(13.4, result4, 0.01);
-      Assert.assertEquals(20.0, result5, 0.01);
-      Assert.assertEquals(15.6, result6, 0.01);
-      Assert.assertEquals(9.2, result7, 0.01);
-      Assert.assertEquals(11.8, result8, 0.01);
-      Assert.assertEquals(6.0, result9, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testXCorr2() {
-    String sqlStr = "select xcorr(d4.s2, d4.s6) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      resultSet.next();
-      double result3 = resultSet.getDouble(1);
-      resultSet.next();
-      double result4 = resultSet.getDouble(1);
-      resultSet.next();
-      double result5 = resultSet.getDouble(1);
-      resultSet.next();
-      double result6 = resultSet.getDouble(1);
-      resultSet.next();
-      double result7 = resultSet.getDouble(1);
-      resultSet.next();
-      double result8 = resultSet.getDouble(1);
-      resultSet.next();
-      double result9 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(4.0, result2, 0.01);
-      Assert.assertEquals(9.6, result3, 0.01);
-      Assert.assertEquals(13.4, result4, 0.01);
-      Assert.assertEquals(20.0, result5, 0.01);
-      Assert.assertEquals(15.6, result6, 0.01);
-      Assert.assertEquals(9.2, result7, 0.01);
-      Assert.assertEquals(11.8, result8, 0.01);
-      Assert.assertEquals(6.0, result9, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testXCorr3() {
-    String sqlStr = "select xcorr(d4.s3, d4.s7) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      resultSet.next();
-      double result3 = resultSet.getDouble(1);
-      resultSet.next();
-      double result4 = resultSet.getDouble(1);
-      resultSet.next();
-      double result5 = resultSet.getDouble(1);
-      resultSet.next();
-      double result6 = resultSet.getDouble(1);
-      resultSet.next();
-      double result7 = resultSet.getDouble(1);
-      resultSet.next();
-      double result8 = resultSet.getDouble(1);
-      resultSet.next();
-      double result9 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(4.0, result2, 0.01);
-      Assert.assertEquals(9.6, result3, 0.01);
-      Assert.assertEquals(13.4, result4, 0.01);
-      Assert.assertEquals(20.0, result5, 0.01);
-      Assert.assertEquals(15.6, result6, 0.01);
-      Assert.assertEquals(9.2, result7, 0.01);
-      Assert.assertEquals(11.8, result8, 0.01);
-      Assert.assertEquals(6.0, result9, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testXCorr4() {
-    String sqlStr = "select xcorr(d4.s4,d4.s8) from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      double result1 = resultSet.getDouble(1);
-      resultSet.next();
-      double result2 = resultSet.getDouble(1);
-      resultSet.next();
-      double result3 = resultSet.getDouble(1);
-      resultSet.next();
-      double result4 = resultSet.getDouble(1);
-      resultSet.next();
-      double result5 = resultSet.getDouble(1);
-      resultSet.next();
-      double result6 = resultSet.getDouble(1);
-      resultSet.next();
-      double result7 = resultSet.getDouble(1);
-      resultSet.next();
-      double result8 = resultSet.getDouble(1);
-      resultSet.next();
-      double result9 = resultSet.getDouble(1);
-      Assert.assertEquals(0.0, result1, 0.01);
-      Assert.assertEquals(4.0, result2, 0.01);
-      Assert.assertEquals(9.6, result3, 0.01);
-      Assert.assertEquals(13.4, result4, 0.01);
-      Assert.assertEquals(20.0, result5, 0.01);
-      Assert.assertEquals(15.6, result6, 0.01);
-      Assert.assertEquals(9.2, result7, 0.01);
-      Assert.assertEquals(11.8, result8, 0.01);
-      Assert.assertEquals(6.0, result9, 0.01);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/dprofile/DProfileTests.java b/library-udf/src/test/java/org/apache/iotdb/library/dprofile/DProfileTests.java
deleted file mode 100644
index 513b0abdee..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/dprofile/DProfileTests.java
+++ /dev/null
@@ -1,629 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.dprofile;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class DProfileTests {
-  protected static final int ITERATION_TIMES = 10_000;
-
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.metaManager.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s2"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    double x = -100d, y = 100d; // borders of random value
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      for (int i = 1; i <= ITERATION_TIMES; ++i) {
-        statement.execute(
-            String.format(
-                "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)",
-                i * 1000,
-                (int) Math.floor(x + Math.random() * y % (y - x + 1)),
-                (int) Math.floor(x + Math.random() * y % (y - x + 1))));
-        statement.execute(
-            (String.format(
-                "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%f,%f)",
-                i * 1000,
-                x + Math.random() * y % (y - x + 1),
-                x + Math.random() * y % (y - x + 1))));
-      }
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute(
-          "create function distinct as 'org.apache.iotdb.library.dprofile.UDTFDistinct'");
-      statement.execute(
-          "create function histogram as 'org.apache.iotdb.library.dprofile.UDTFHistogram'");
-      statement.execute(
-          "create function integral as 'org.apache.iotdb.library.dprofile.UDAFIntegral'");
-      statement.execute(
-          "create function integralavg as 'org.apache.iotdb.library.dprofile.UDAFIntegralAvg'");
-      statement.execute("create function mad as 'org.apache.iotdb.library.dprofile.UDAFMad'");
-      statement.execute("create function median as 'org.apache.iotdb.library.dprofile.UDAFMedian'");
-      statement.execute("create function mode as 'org.apache.iotdb.library.dprofile.UDAFMode'");
-      statement.execute(
-          "create function percentile as 'org.apache.iotdb.library.dprofile.UDAFPercentile'");
-      statement.execute("create function period as 'org.apache.iotdb.library.dprofile.UDAFPeriod'");
-      statement.execute("create function qlb as 'org.apache.iotdb.library.dprofile.UDTFQLB'");
-      statement.execute(
-          "create function resample as 'org.apache.iotdb.library.dprofile.UDTFResample'");
-      statement.execute("create function sample as 'org.apache.iotdb.library.dprofile.UDTFSample'");
-      statement.execute(
-          "create function segment as 'org.apache.iotdb.library.dprofile.UDTFSegment'");
-      statement.execute("create function skew as 'org.apache.iotdb.library.dprofile.UDAFSkew'");
-      statement.execute("create function spread as 'org.apache.iotdb.library.dprofile.UDAFSpread'");
-      statement.execute("create function stddev as 'org.apache.iotdb.library.dprofile.UDAFStddev'");
-      statement.execute("create function minmax as 'org.apache.iotdb.library.dprofile.UDTFMinMax'");
-      statement.execute("create function zscore as 'org.apache.iotdb.library.dprofile.UDTFZScore'");
-      statement.execute("create function spline as 'org.apache.iotdb.library.dprofile.UDTFSpline'");
-      statement.execute("create function mvavg as 'org.apache.iotdb.library.dprofile.UDTFMvAvg'");
-      statement.execute("create function acf as 'org.apache.iotdb.library.dprofile.UDTFACF'");
-      statement.execute("create function pacf as 'org.apache.iotdb.library.dprofile.UDTFPACF'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testIntegral1() {
-    String sqlStr = "select integral(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testIntegral2() {
-    String sqlStr = "select completeness(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testIntegralAvg1() {
-    String sqlStr = "select integralavg(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testIntegralAvg2() {
-    String sqlStr = "select integralavg(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMad1() {
-    String sqlStr = "select mad(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMad2() {
-    String sqlStr = "select timeliness(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMedian1() {
-    String sqlStr = "select median(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMedian2() {
-    String sqlStr = "select median(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMode1() {
-    String sqlStr = "select consistency(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPercentile1() {
-    String sqlStr = "select percentile(d1.s2,'rank'='0.7') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPercentile2() {
-    String sqlStr = "select percentile(d2.s2,'rank'='0.3') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPeriod1() {
-    String sqlStr = "select period(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSkew1() {
-    String sqlStr = "select skew(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSkew2() {
-    String sqlStr = "select skew(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSpread1() {
-    String sqlStr = "select spread(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSpread2() {
-    String sqlStr = "select spread(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSddev1() {
-    String sqlStr = "select stddev(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testStddev2() {
-    String sqlStr = "select stddev(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testACF1() {
-    String sqlStr = "select acf(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDistinct1() {
-    String sqlStr = "select distinct(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testHistogram1() {
-    String sqlStr =
-        String.format(
-            "select histogram(d1.s1,'min'='%f','max'='%f','count'='20') from root.vehicle",
-            -100d, 100d);
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMinMax1() {
-    String sqlStr =
-        String.format("select minmax(d2.s2,'min'='%f','max'='%f') from root.vehicle", -100d, 100d);
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMvAvg1() {
-    String sqlStr = "select mvavg(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testMvAvg2() {
-    String sqlStr = "select mvavg(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testPACF1() {
-    String sqlStr = "select pacf(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testQLB1() {
-    String sqlStr = "select qlb(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testResample1() {
-    String sqlStr = "select resample(d2.s1, 'every'='5s') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testResample2() {
-    String sqlStr = "select resample(d2.s2, 'every'='10s', 'aggr'='median') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSample1() {
-    String sqlStr = "select resample(d2.s1, 'method'='reservoir','k'='5') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testsample2() {
-    String sqlStr = "select resample(d1.s2, 'method'='isometric','k'='5') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSegment1() {
-    String sqlStr = "select segment(d2.s2,'error'='10') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testSpline1() {
-    String sqlStr = "select spline(d2.s1, 'points'='100') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testZScore1() {
-    String sqlStr = "select zscore(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testZScore2() {
-    String sqlStr = "select zscore(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/dquality/DQualityTests.java b/library-udf/src/test/java/org/apache/iotdb/library/dquality/DQualityTests.java
deleted file mode 100644
index 1ef1f213c0..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/dquality/DQualityTests.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.dquality;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class DQualityTests {
-  protected static final int ITERATION_TIMES = 10_000;
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.metaManager.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s2"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    double x = -100d, y = 100d; // borders of random value
-    long a = 0, b = 1000000000;
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      for (int i = 1; i <= ITERATION_TIMES; ++i) {
-        statement.execute(
-            String.format(
-                "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)",
-                (int) Math.floor(a + Math.random() * b % (b - a + 1)),
-                (int) Math.floor(x + Math.random() * y % (y - x + 1)),
-                (int) Math.floor(x + Math.random() * y % (y - x + 1))));
-        statement.execute(
-            (String.format(
-                "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%f,%f)",
-                (int) Math.floor(a + Math.random() * b % (b - a + 1)),
-                x + Math.random() * y % (y - x + 1),
-                x + Math.random() * y % (y - x + 1))));
-      }
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute(
-          "create function completeness as 'org.apache.iotdb.library.dquality.UDTFCompleteness'");
-      statement.execute(
-          "create function timeliness as 'org.apache.iotdb.library.dquality.UDTFTimeliness'");
-      statement.execute(
-          "create function consistency as 'org.apache.iotdb.library.dquality.UDTFConsistency'");
-      statement.execute(
-          "create function validity as 'org.apache.iotdb.library.dquality.UDTFValidity'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testCompleteness1() {
-    String sqlStr = "select completeness(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCompleteness2() {
-    String sqlStr = "select completeness(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCompleteness3() {
-    String sqlStr = "select completeness(d2.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testCompleteness4() {
-    String sqlStr = "select completeness(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimeliness1() {
-    String sqlStr = "select timeliness(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimeliness2() {
-    String sqlStr = "select timeliness(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimeliness3() {
-    String sqlStr = "select timeliness(d2.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimeliness4() {
-    String sqlStr = "select timeliness(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsistency1() {
-    String sqlStr = "select consistency(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsistency2() {
-    String sqlStr = "select consistency(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsistency3() {
-    String sqlStr = "select consistency(d2.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsistency4() {
-    String sqlStr = "select consistency(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValidity1() {
-    String sqlStr = "select validity(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValidity2() {
-    String sqlStr = "select validity(d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValidity3() {
-    String sqlStr = "select validity(d2.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValidity4() {
-    String sqlStr = "select validity(d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(result >= -0.0D && result <= 1.0D);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/drepair/DRepairTests.java b/library-udf/src/test/java/org/apache/iotdb/library/drepair/DRepairTests.java
deleted file mode 100644
index 4bf48b4b37..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/drepair/DRepairTests.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.drepair;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class DRepairTests {
-  protected static final int ITERATION_TIMES = 100_000;
-  protected static final int DELTA_T = 100;
-
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.metaManager.setStorageGroup(new PartialPath("root.vehicle"));
-    // test series for TimeStampRepair
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    // test series for ValueFill
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    // test series for ValueRepair
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d3.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    double x = -100d, y = 100d; // borders of random value
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      for (int i = 1; i <= ITERATION_TIMES; ++i) {
-        if (Math.random() < 0.99) {
-          statement.execute(
-              String.format(
-                  "insert into root.vehicle.d1(timestamp,s1) values(%d,%f)",
-                  (long) i * DELTA_T, Math.floor(x + Math.random() * y % (y - x + 1))));
-        } else {
-          statement.execute(
-              String.format(
-                  "insert into root.vehicle.d1(timestamp,s1) values(%d,%f)",
-                  (long) i * DELTA_T + (long) Math.floor((Math.random() - 0.5) * DELTA_T),
-                  Math.floor(x + Math.random() * y % (y - x + 1))));
-        }
-      }
-      for (int i = 1; i <= ITERATION_TIMES; ++i) {
-        if (Math.random() < 0.97) {
-          statement.execute(
-              String.format(
-                  "insert into root.vehicle.d2(timestamp,s1) values(%d,%f)",
-                  (long) i * DELTA_T, Math.floor(x + Math.random() * y % (y - x + 1))));
-        } else {
-          statement.execute(
-              String.format(
-                  "insert into root.vehicle.d2(timestamp,s1) values(%d,%f)",
-                  (long) i * DELTA_T, Double.NaN));
-        }
-      }
-      for (int i = 1; i <= ITERATION_TIMES; ++i) {
-        statement.execute(
-            String.format(
-                "insert into root.vehicle.d3(timestamp,s1) values(%d,%f)",
-                (long) i * DELTA_T,
-                i / (double) ITERATION_TIMES * (y - x) + (Math.random() - 0.5) * (y - x)));
-      }
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute(
-          "create function timestamprepair as 'org.apache.iotdb.library.dquality.UDTFTimestampRepair'");
-      statement.execute(
-          "create function valuefill as 'org.apache.iotdb.library.dquality.UDTFValueFill'");
-      statement.execute(
-          "create function valuerepair as 'org.apache.iotdb.library.dquality.UDTFValueRepair'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testTimestampRepair1() {
-    String sqlStr =
-        String.format("select timestamprepair(d1.s1,'interval'='%d') from root.vehicle", DELTA_T);
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimestampRepair2() {
-    String sqlStr = "select timestamprepair(d1.s1,'method'='median') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimestampRepair3() {
-    String sqlStr = "select timestamprepair(d1.s1,'method'='mode') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testTimestampRepair4() {
-    String sqlStr = "select timestamprepair(d1.s1,'method'='cluster') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill1() {
-    String sqlStr = "select valuefill(d2.s1,'method'='previous') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill2() {
-    String sqlStr = "select valuefill(d2.s1,'method'='linear') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill3() {
-    String sqlStr = "select valuefill(d2.s1,'method'='likelihood') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill4() {
-    String sqlStr = "select valuefill(d2.s1,'method'='ar') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill5() {
-    String sqlStr = "select valuefill(d2.s1,'method'='ma') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueFill6() {
-    String sqlStr = "select valuefill(d2.s1,'method'='screen') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueRepair1() {
-    String sqlStr = "select valuerepair(d3.s1,'method'='screen') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testValueRepair2() {
-    String sqlStr = "select valuerepair(d3.s1,'method'='lsgreedy') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/frequency/FrequencyTests.java b/library-udf/src/test/java/org/apache/iotdb/library/frequency/FrequencyTests.java
deleted file mode 100644
index 9d3f1b5f55..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/frequency/FrequencyTests.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.frequency;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.jdbc.Config;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.*;
-
-import static org.junit.Assert.fail;
-
-public class FrequencyTests {
-  protected static final int ITERATION_TIMES = 16384;
-  protected static final int DELTA_T = 100;
-  protected static final int PERIOD_1 = 10;
-  protected static final int PEROID_2 = 200;
-  protected static final double pi = Math.PI;
-
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.metaManager.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s3"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s2"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    double x = -100d, y = 100d; // borders of random value
-    long a = 0, b = 1000000000;
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      for (int i = 0; i < ITERATION_TIMES; ++i) {
-        statement.execute(
-            String.format(
-                "insert into root.vehicle.d1(timestamp,s1,s2,s3) values(%d,%f,%f,%f)",
-                (long) (i + 1) * DELTA_T,
-                Math.sin(i % PERIOD_1 * 2 * pi / (double) PERIOD_1),
-                Math.sin(i % PEROID_2 * 2 * pi / (double) PEROID_2),
-                0.5 * Math.sin(i % PERIOD_1 * pi) + Math.sin(i % PEROID_2 * pi)));
-      }
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s1) values(%d, 2)", DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s1) values(%d, 7)", 2 * DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s1) values(%d, 4)", 3 * DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s1) values(%d, 9)", 4 * DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s2) values(%d, 1)", DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s2) values(%d, 0)", 2 * DELTA_T));
-      statement.execute(
-          String.format("insert into root.vehicle.d2(timestamp,s2) values(%d, 1)", 3 * DELTA_T));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute("create function conv as 'org.apache.iotdb.library.dquality.UDTFConv'");
-      statement.execute("create function deconv as 'org.apache.iotdb.library.dquality.UDTFDeconv'");
-      statement.execute("create function dwt as 'org.apache.iotdb.library.dquality.UDTFDWT'");
-      statement.execute("create function fft as 'org.apache.iotdb.library.dquality.UDTFFFT'");
-      statement.execute(
-          "create function highpass as 'org.apache.iotdb.library.dquality.UDTFHighPass'");
-      statement.execute("create function idwt as 'org.apache.iotdb.library.dquality.UDTFIDWT'");
-      statement.execute(
-          "create function lowpass as 'org.apache.iotdb.library.dquality.UDTFLowPass'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  // No possible tests for IDWT, IFFT
-  @Test
-  public void testConv1() {
-    String sqlStr = "select conv(d1.s1, d1.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result = Double.parseDouble(resultSet.getString(1));
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDeconv1() {
-    String sqlStr = "select deconv(d2.s1,d2.s2) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result1 = Double.parseDouble(resultSet.getString(1));
-      resultSet.next();
-      Double result2 = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(Math.abs(result1 - 2d) < 1e-5 && Math.abs(result2 - 7d) < 1e-5);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDeconv2() {
-    String sqlStr = "select deconv(d2.s1,d2.s2,'result'='remainder') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      Double result1 = Double.parseDouble(resultSet.getString(1));
-      resultSet.next();
-      Double result2 = Double.parseDouble(resultSet.getString(1));
-      resultSet.next();
-      Double result3 = Double.parseDouble(resultSet.getString(1));
-      resultSet.next();
-      Double result4 = Double.parseDouble(resultSet.getString(1));
-      Assert.assertTrue(
-          Math.abs(result1) < 1e-5
-              && Math.abs(result2) < 1e-5
-              && Math.abs(result3 - 2d) < 1e-5
-              && Math.abs(result4 - 2d) < 1e-5);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDWT1() {
-    String sqlStr = "select dwt(d2.s3,'method'='haar') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testDWT2() {
-    String sqlStr = "select dwt(d2.s3,'method'='DB4') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testFFT1() {
-    String sqlStr = "select fft(d1.s1) from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testHighPass1() {
-    String sqlStr = "select highpass(d1.s3,'wpass'='0.5') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet1 = statement.executeQuery(sqlStr);
-      ResultSet resultSet2 = statement.executeQuery("select d1.s1 from root.vehicle");
-      for (int i = 1; i < ITERATION_TIMES; ++i) {
-        Double result1 = Double.parseDouble(resultSet1.getString(1));
-        Double result2 = Double.parseDouble(resultSet2.getString(1));
-        resultSet1.next();
-        resultSet2.next();
-        Assert.assertTrue(Math.abs(result1 - 0.5 * result2) < 1e-2);
-      }
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testLowPass1() {
-    String sqlStr = "select lowpass(d1.s3,'wpass'='0.5') from root.vehicle";
-    try (Connection connection =
-            DriverManager.getConnection(
-                Config.IOTDB_URL_PREFIX + "127.0.0.1:6667/", "root", "root");
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet1 = statement.executeQuery(sqlStr);
-      ResultSet resultSet2 = statement.executeQuery("select d1.s2 from root.vehicle");
-      for (int i = 1; i < ITERATION_TIMES; ++i) {
-        Double result1 = Double.parseDouble(resultSet1.getString(1));
-        Double result2 = Double.parseDouble(resultSet2.getString(1));
-        resultSet1.next();
-        resultSet2.next();
-        Assert.assertTrue(Math.abs(result1 - result2) < 1e-2);
-      }
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/series/SeriesTest.java b/library-udf/src/test/java/org/apache/iotdb/library/series/SeriesTest.java
deleted file mode 100644
index afb09147d2..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/series/SeriesTest.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.series;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class SeriesTest {
-  protected static final int ITERATION_TIMES = 10_000;
-
-  protected static final long TIMESTAMP_INTERVAL = 60; // gap = 60ms
-
-  protected static final long START_TIMESTAMP = 0;
-
-  protected static final long END_TIMESTAMP = START_TIMESTAMP + ITERATION_TIMES * ITERATION_TIMES;
-
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.metaManager.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.INT32,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d1.s2"),
-        TSDataType.INT64,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.FLOAT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.metaManager.createTimeseries(
-        new PartialPath("root.vehicle.d2.s2"),
-        TSDataType.DOUBLE,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      // d1
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577808000, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577808300, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577808600, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577809200, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577809500, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577809800, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577810100, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%d)",
-              1577810400, 1)); // s2 == null
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577810700, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1,s2) values(%d,%d,%d)", 1577811000, 1, 1));
-      // d2
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577808000, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577808300, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577808600, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577809200, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577809500, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577809800, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577810100, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1) values(%d,%d)",
-              1577810400, 1)); // s2 == null
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577810700, 1, 1));
-      statement.execute(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1,s2) values(%d,%d,%d)", 1577811000, 1, 1));
-
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute(
-          "create function ConsecutiveSequences as 'org.apache.iotdb.library.series.UDTFConsecutiveSequences'");
-      statement.execute(
-          "create function ConsecutiveWindows as 'org.apache.iotdb.library.series.UDTFConsecutiveWindows'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testConsecutiveSequences1() {
-    String sqlStr = "select ConsecutiveSequences(d1.s1,d1.s2) from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 4);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577810700);
-      Assert.assertEquals(value, 2);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveSequences2() {
-    String sqlStr = "select ConsecutiveSequences(d2.s1,d2.s2) from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 4);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577810700);
-      Assert.assertEquals(value, 2);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveSequences3() {
-    String sqlStr = "select ConsecutiveSequences(d1.s1,d1.s2,'gap'='5m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 4);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577810700);
-      Assert.assertEquals(value, 2);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveSequences4() {
-    String sqlStr = "select ConsecutiveSequences(d2.s1,d2.s2,'gap'='5m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 4);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577810700);
-      Assert.assertEquals(value, 2);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveWindows1() {
-    String sqlStr = "select ConsecutiveWindows(d1.s1,d1.s2,'length'='10m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809500);
-      Assert.assertEquals(value, 3);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveWindows2() {
-    String sqlStr = "select ConsecutiveWindows(d2.s1,d2.s2,'length'='10m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809500);
-      Assert.assertEquals(value, 3);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveWindows3() {
-    String sqlStr =
-        "select ConsecutiveWindows(d1.s1,d1.s2,'length'='10m','gap'='5m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809500);
-      Assert.assertEquals(value, 3);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testConsecutiveWindows4() {
-    String sqlStr =
-        "select ConsecutiveWindows(d2.s1,d2.s2,'length'='10m','gap'='5m') from root.vehicle";
-    long timeStamp = 0;
-    int value = 0;
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      int resultSetLength = resultSet.getRow();
-      Assert.assertEquals(resultSetLength, 3);
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577808000);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809200);
-      Assert.assertEquals(value, 3);
-
-      resultSet.next();
-
-      timeStamp = Long.parseLong(resultSet.getString(0));
-      value = Integer.parseInt(resultSet.getString(1));
-      Assert.assertEquals(timeStamp, 1577809500);
-      Assert.assertEquals(value, 3);
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/library-udf/src/test/java/org/apache/iotdb/library/string/StringTests.java b/library-udf/src/test/java/org/apache/iotdb/library/string/StringTests.java
deleted file mode 100644
index 6950677bcf..0000000000
--- a/library-udf/src/test/java/org/apache/iotdb/library/string/StringTests.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.iotdb.library.string;
-
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
-import org.apache.iotdb.db.exception.metadata.MetadataException;
-import org.apache.iotdb.db.metadata.path.PartialPath;
-import org.apache.iotdb.db.service.IoTDB;
-import org.apache.iotdb.integration.env.ConfigFactory;
-import org.apache.iotdb.integration.env.EnvFactory;
-import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
-import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import java.sql.Connection;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import static org.junit.Assert.fail;
-
-public class StringTests {
-  private static final float oldUdfCollectorMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfCollectorMemoryBudgetInMB();
-  private static final float oldUdfTransformerMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfTransformerMemoryBudgetInMB();
-  private static final float oldUdfReaderMemoryBudgetInMB =
-      IoTDBDescriptor.getInstance().getConfig().getUdfReaderMemoryBudgetInMB();
-
-  @BeforeClass
-  public static void setUp() throws Exception {
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(5)
-        .setUdfTransformerMemoryBudgetInMB(5)
-        .setUdfReaderMemoryBudgetInMB(5);
-    EnvFactory.getEnv().initBeforeClass();
-    createTimeSeries();
-    generateData();
-    registerUDF();
-  }
-
-  private static void createTimeSeries() throws MetadataException {
-    IoTDB.schemaEngine.setStorageGroup(new PartialPath("root.vehicle"));
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d1.s1"),
-        TSDataType.TEXT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-    IoTDB.schemaEngine.createTimeseries(
-        new PartialPath("root.vehicle.d2.s1"),
-        TSDataType.TEXT,
-        TSEncoding.PLAIN,
-        CompressionType.UNCOMPRESSED,
-        null);
-  }
-
-  private static void generateData() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%s)",
-              100, "[192.168.0.1] [SUCCESS]"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%s)",
-              200, "[192.168.0.24] [SUCCESS]"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%s)",
-              300, "[192.168.0.2] [FAIL]"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%s)",
-              400, "[192.168.0.5] [SUCCESS]"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d1(timestamp,s1) values(%d,%s)",
-              500, "[192.168.0.124] [SUCCESS]"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1) values(%d,%s)", 100, "A,B,A+,B-"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1) values(%d,%s)", 200, "A,A+,A,B+"));
-      statement.addBatch(
-          String.format("insert into root.vehicle.d2(timestamp,s1) values(%d,%s)", 300, "B+,B,B"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1) values(%d,%s)", 400, "A+,A,A+,A"));
-      statement.addBatch(
-          String.format(
-              "insert into root.vehicle.d2(timestamp,s1) values(%d,%s)", 500, "A,B-,B,B"));
-      statement.executeBatch();
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  private static void registerUDF() {
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      statement.execute(
-          "create function regexmatch as 'org.apache.iotdb.library.string.UDTFRegexMatch'");
-      statement.execute(
-          "create function regexreplace as 'org.apache.iotdb.library.string.UDTFRegexReplace'");
-      statement.execute(
-          "create function regexsplit as 'org.apache.iotdb.library.string.UDTFRegexSplit'");
-      statement.execute(
-          "create function strreplace as 'org.apache.iotdb.library.string.UDTFStrReplace'");
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @AfterClass
-  public static void tearDown() throws Exception {
-    EnvFactory.getEnv().cleanAfterClass();
-    ConfigFactory.getConfig()
-        .setUdfCollectorMemoryBudgetInMB(oldUdfCollectorMemoryBudgetInMB)
-        .setUdfTransformerMemoryBudgetInMB(oldUdfTransformerMemoryBudgetInMB)
-        .setUdfReaderMemoryBudgetInMB(oldUdfReaderMemoryBudgetInMB);
-  }
-
-  @Test
-  public void testRegexMatch1() {
-    String sqlStr =
-        "select regexmatch(d1.s1,\"regex\"=\"\\d+\\.\\d+\\.\\d+\\.\\d+\", \"group\"=\"0\") from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      String result1 = resultSet.getString(1);
-      resultSet.next();
-      String result2 = resultSet.getString(1);
-      resultSet.next();
-      String result3 = resultSet.getString(1);
-      resultSet.next();
-      String result4 = resultSet.getString(1);
-      resultSet.next();
-      String result5 = resultSet.getString(1);
-      Assert.assertEquals("192.168.0.1", result1);
-      Assert.assertEquals("192.168.0.24", result2);
-      Assert.assertEquals("192.168.0.2", result3);
-      Assert.assertEquals("192.168.0.5", result4);
-      Assert.assertEquals("192.168.0.124", result5);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testRegexReplace1() {
-    String sqlStr =
-        "select regexreplace(d1.s1,\"regex\"=\"192\\.168\\.0\\.(\\d+)\", \"replace\"=\"cluster-$1\") from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      String result1 = resultSet.getString(1);
-      resultSet.next();
-      String result2 = resultSet.getString(1);
-      resultSet.next();
-      String result3 = resultSet.getString(1);
-      resultSet.next();
-      String result4 = resultSet.getString(1);
-      resultSet.next();
-      String result5 = resultSet.getString(1);
-      Assert.assertEquals("[cluster-1] [SUCCESS]", result1);
-      Assert.assertEquals("[cluster-24] [SUCCESS]", result2);
-      Assert.assertEquals("[cluster-2] [FAIL]", result3);
-      Assert.assertEquals("[cluster-5] [SUCCESS]", result4);
-      Assert.assertEquals("[cluster-124] [SUCCESS]", result5);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testRegexSplit1() {
-    String sqlStr = "select regexsplit(d2.s1, \"regex\"=\",\", \"index\"=\"-1\") from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      int result1 = resultSet.getInt(1);
-      resultSet.next();
-      int result2 = resultSet.getInt(1);
-      resultSet.next();
-      int result3 = resultSet.getInt(1);
-      resultSet.next();
-      int result4 = resultSet.getInt(1);
-      resultSet.next();
-      int result5 = resultSet.getInt(1);
-      Assert.assertEquals(4, result1);
-      Assert.assertEquals(4, result2);
-      Assert.assertEquals(3, result3);
-      Assert.assertEquals(4, result4);
-      Assert.assertEquals(4, result5);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-
-  @Test
-  public void testStrReplace1() {
-    String sqlStr =
-        "select strreplace(d2.s1,\"target\"=\",\", \"replace\"=\"/\", \"limit\"=\"2\") from root.vehicle";
-    try (Connection connection = EnvFactory.getEnv().getConnection();
-        Statement statement = connection.createStatement()) {
-      ResultSet resultSet = statement.executeQuery(sqlStr);
-      resultSet.next();
-      String result1 = resultSet.getString(1);
-      resultSet.next();
-      String result2 = resultSet.getString(1);
-      resultSet.next();
-      String result3 = resultSet.getString(1);
-      resultSet.next();
-      String result4 = resultSet.getString(1);
-      resultSet.next();
-      String result5 = resultSet.getString(1);
-      Assert.assertEquals("A/B/A+,B-", result1);
-      Assert.assertEquals("A/A+/A,B+", result2);
-      Assert.assertEquals("B+/B/B", result3);
-      Assert.assertEquals("A+/A/A+,A", result4);
-      Assert.assertEquals("A/B-/B,B", result5);
-      Assert.assertFalse(resultSet.next());
-    } catch (SQLException throwable) {
-      fail(throwable.getMessage());
-    }
-  }
-}
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
index 3281a02f66..a2d567a1f6 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/SchemaUtils.java
@@ -73,6 +73,8 @@ public class SchemaUtils {
     intSet.add(TSEncoding.DESCEND);
     intSet.add(TSEncoding.SIMPLE8B);
     intSet.add(TSEncoding.SIMPLE8B_SPARSE);
+    intSet.add(TSEncoding.BUFF);
+
     schemaChecker.put(TSDataType.INT32, intSet);
     schemaChecker.put(TSDataType.INT64, intSet);
 
@@ -86,6 +88,7 @@ public class SchemaUtils {
     floatSet.add(TSEncoding.DESCEND);
     floatSet.add(TSEncoding.SIMPLE8B);
     floatSet.add(TSEncoding.SIMPLE8B_SPARSE);
+    floatSet.add(TSEncoding.BUFF);
     schemaChecker.put(TSDataType.FLOAT, floatSet);
     schemaChecker.put(TSDataType.DOUBLE, floatSet);
 
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/ICompressor.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/ICompressor.java
index 9243e53417..5e2546223f 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/ICompressor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/ICompressor.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.iotdb.tsfile.compress;
 
+import org.apache.iotdb.tsfile.compress.arithmetic.AdaptiveArithmeticCompress;
 import org.apache.iotdb.tsfile.exception.compress.CompressionTypeNotSupportedException;
 import org.apache.iotdb.tsfile.exception.compress.GZIPCompressOverflowException;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
@@ -65,6 +65,8 @@ public interface ICompressor extends Serializable {
         return new IOTDBLZ4Compressor();
       case GZIP:
         return new GZIPCompressor();
+      case ARITHMETIC:
+        return new ArithmeticCompressor();
       default:
         throw new CompressionTypeNotSupportedException(name.toString());
     }
@@ -188,6 +190,7 @@ public interface ICompressor extends Serializable {
   }
 
   class IOTDBLZ4Compressor implements ICompressor {
+
     private LZ4Compressor compressor;
 
     public IOTDBLZ4Compressor() {
@@ -232,6 +235,7 @@ public interface ICompressor extends Serializable {
   }
 
   class GZIPCompress {
+
     public static byte[] compress(byte[] data) throws IOException {
       ByteArrayOutputStream out = new ByteArrayOutputStream();
       GZIPOutputStream gzip = new GZIPOutputStream(out);
@@ -257,6 +261,7 @@ public interface ICompressor extends Serializable {
   }
 
   class GZIPCompressor implements ICompressor {
+
     @Override
     public byte[] compress(byte[] data) throws IOException {
       if (null == data) {
@@ -311,4 +316,57 @@ public interface ICompressor extends Serializable {
       return GZIP;
     }
   }
+
+  class ArithmeticCompressor implements ICompressor {
+
+    @Override
+    public byte[] compress(byte[] data) throws IOException {
+      if (null == data) {
+        return new byte[0];
+      }
+      return AdaptiveArithmeticCompress.compress(data);
+    }
+
+    @Override
+    public byte[] compress(byte[] data, int offset, int length) throws IOException {
+      byte[] dataBefore = new byte[length];
+      System.arraycopy(data, offset, dataBefore, 0, length);
+
+      return AdaptiveArithmeticCompress.compress(dataBefore);
+    }
+
+    @Override
+    public int compress(byte[] data, int offset, int length, byte[] compressed) throws IOException {
+      byte[] res = compress(data, offset, length);
+      if (res.length > compressed.length) {
+        throw new GZIPCompressOverflowException();
+      }
+
+      System.arraycopy(res, 0, compressed, 0, res.length);
+      return res.length;
+    }
+
+    @Override
+    public int compress(ByteBuffer data, ByteBuffer compressed) throws IOException {
+      int length = data.remaining();
+      byte[] dataBefore = new byte[length];
+      data.get(dataBefore, 0, length);
+      byte[] res = compress(dataBefore);
+      if (res.length > compressed.capacity()) {
+        throw new GZIPCompressOverflowException();
+      }
+      compressed.put(res);
+      return res.length;
+    }
+
+    @Override
+    public int getMaxBytesForCompression(int uncompressedDataSize) {
+      return uncompressedDataSize;
+    }
+
+    @Override
+    public CompressionType getType() {
+      return CompressionType.ARITHMETIC;
+    }
+  }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
index b4b333e949..c5d5b76b1f 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/IUnCompressor.java
@@ -16,9 +16,9 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-
 package org.apache.iotdb.tsfile.compress;
 
+import org.apache.iotdb.tsfile.compress.arithmetic.AdaptiveArithmeticCompress;
 import org.apache.iotdb.tsfile.exception.compress.CompressionTypeNotSupportedException;
 import org.apache.iotdb.tsfile.file.metadata.enums.CompressionType;
 
@@ -54,6 +54,8 @@ public interface IUnCompressor {
         return new LZ4UnCompressor();
       case GZIP:
         return new GZIPUnCompressor();
+      case ARITHMETIC:
+        return new ArithmeticUncompressor();
       default:
         throw new CompressionTypeNotSupportedException(name.toString());
     }
@@ -312,4 +314,54 @@ public interface IUnCompressor {
       return CompressionType.GZIP;
     }
   }
+
+  class ArithmeticUncompressor implements IUnCompressor {
+
+    @Override
+    public int getUncompressedLength(byte[] array, int offset, int length) throws IOException {
+      throw new UnsupportedOperationException(
+          "Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public int getUncompressedLength(ByteBuffer buffer) throws IOException {
+      throw new UnsupportedOperationException(
+          "Not supported yet."); // To change body of generated methods, choose Tools | Templates.
+    }
+
+    @Override
+    public byte[] uncompress(byte[] byteArray) throws IOException {
+      if (null == byteArray) {
+        return new byte[0];
+      }
+      return AdaptiveArithmeticCompress.decompress(byteArray);
+    }
+
+    @Override
+    public int uncompress(byte[] byteArray, int offset, int length, byte[] output, int outOffset)
+        throws IOException {
+      byte[] dataBefore = new byte[length];
+      System.arraycopy(byteArray, offset, dataBefore, 0, length);
+      byte[] res = uncompress(dataBefore);
+      System.arraycopy(res, 0, output, outOffset, res.length);
+      return res.length;
+    }
+
+    @Override
+    public int uncompress(ByteBuffer compressed, ByteBuffer uncompressed) throws IOException {
+      int length = compressed.remaining();
+      byte[] dataBefore = new byte[length];
+      compressed.get(dataBefore, 0, length);
+
+      byte[] res = uncompress(dataBefore);
+      uncompressed.put(res);
+
+      return res.length;
+    }
+
+    @Override
+    public CompressionType getCodecName() {
+      return CompressionType.ARITHMETIC;
+    }
+  }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticCompress.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticCompress.java
new file mode 100644
index 0000000000..41cc7981f3
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticCompress.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * Compression application using adaptive arithmetic coding.
+ *
+ * <p>Usage: java AdaptiveArithmeticCompress InputFile OutputFile
+ *
+ * <p>Then use the corresponding "AdaptiveArithmeticDecompress" application to recreate the original
+ * input file.
+ *
+ * <p>Note that the application starts with a flat frequency table of 257 symbols (all set to a
+ * frequency of 1), and updates it after each byte encoded. The corresponding decompressor program
+ * also starts with a flat frequency table and updates it after each byte decoded. It is by design
+ * that the compressor and decompressor have synchronized states, so that the data can be
+ * decompressed properly.
+ */
+public class AdaptiveArithmeticCompress {
+
+  public static byte[] compress(byte[] input) throws IOException {
+    InputStream in = new ByteArrayInputStream(input);
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    BitOutputStream outStream = new BitOutputStream(out);
+    compress(in, outStream);
+    outStream.close();
+    return out.toByteArray();
+  }
+
+  public static byte[] decompress(byte[] input) throws IOException {
+
+    BitInputStream in = new BitInputStream(new ByteArrayInputStream(input));
+    ByteArrayOutputStream out = new ByteArrayOutputStream();
+    AdaptiveArithmeticDecompress.decompress(in, out);
+    out.close();
+    return out.toByteArray();
+  }
+
+  // To allow unit testing, this method is package-private instead of private.
+  static void compress(InputStream in, BitOutputStream out) throws IOException {
+    FlatFrequencyTable initFreqs = new FlatFrequencyTable(257);
+    FrequencyTable freqs = new SimpleFrequencyTable(initFreqs);
+    ArithmeticEncoder enc = new ArithmeticEncoder(32, out);
+    while (true) {
+      // Read and encode one byte
+      int symbol = in.read();
+      if (symbol == -1) {
+        break;
+      }
+      enc.write(freqs, symbol);
+      freqs.increment(symbol);
+    }
+    enc.write(freqs, 256); // EOF
+    enc.finish(); // Flush remaining code bits
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticDecompress.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticDecompress.java
new file mode 100644
index 0000000000..faf6e0a08a
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/AdaptiveArithmeticDecompress.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Decompression application using adaptive arithmetic coding.
+ *
+ * <p>Usage: java AdaptiveArithmeticDecompress InputFile OutputFile
+ *
+ * <p>This decompresses files generated by the "AdaptiveArithmeticCompress" application.
+ */
+public class AdaptiveArithmeticDecompress {
+
+  public static void main(String[] args) throws IOException {
+    // Handle command line arguments
+    if (args.length != 2) {
+      System.err.println("Usage: java AdaptiveArithmeticDecompress InputFile OutputFile");
+      System.exit(1);
+      return;
+    }
+    File inputFile = new File(args[0]);
+    File outputFile = new File(args[1]);
+
+    // Perform file decompression
+    try (BitInputStream in =
+            new BitInputStream(new BufferedInputStream(new FileInputStream(inputFile)));
+        OutputStream out = new BufferedOutputStream(new FileOutputStream(outputFile))) {
+      decompress(in, out);
+    }
+  }
+
+  // To allow unit testing, this method is package-private instead of private.
+  static void decompress(BitInputStream in, OutputStream out) throws IOException {
+    FlatFrequencyTable initFreqs = new FlatFrequencyTable(257);
+    FrequencyTable freqs = new SimpleFrequencyTable(initFreqs);
+    ArithmeticDecoder dec = new ArithmeticDecoder(32, in);
+    while (true) {
+      // Decode and write one byte
+      int symbol = dec.read(freqs);
+      if (symbol == 256) // EOF symbol
+      break;
+      out.write(symbol);
+      freqs.increment(symbol);
+    }
+    out.flush();
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticCoderBase.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticCoderBase.java
new file mode 100644
index 0000000000..e98cd24171
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticCoderBase.java
@@ -0,0 +1,189 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.IOException;
+
+/**
+ * Provides the state and behaviors that arithmetic coding encoders and decoders share.
+ *
+ * @see ArithmeticEncoder
+ * @see ArithmeticDecoder
+ */
+public abstract class ArithmeticCoderBase {
+
+  /*---- Configuration fields ----*/
+
+  /**
+   * Number of bits for the 'low' and 'high' state variables. Must be in the range [1, 62].
+   *
+   * <ul>
+   *   <li>For state sizes less than the midpoint of around 32, larger values are generally better -
+   *       they allow a larger maximum frequency total (maximumTotal), and they reduce the
+   *       approximation error inherent in adapting fractions to integers; both effects reduce the
+   *       data encoding loss and asymptotically approach the efficiency of arithmetic coding using
+   *       exact fractions.
+   *   <li>But for state sizes greater than the midpoint, because intermediate computations are
+   *       limited to the long integer type's 63-bit unsigned precision, larger state sizes will
+   *       decrease the maximum frequency total, which might constrain the user-supplied probability
+   *       model.
+   *   <li>Therefore numStateBits=32 is recommended as the most versatile setting because it
+   *       maximizes maximumTotal (which ends up being slightly over 2^30).
+   *   <li>Note that numStateBits=62 is legal but useless because it implies maximumTotal=1, which
+   *       means a frequency table can only support one symbol with non-zero frequency.
+   * </ul>
+   */
+  protected final int numStateBits;
+
+  /** Maximum range (high+1-low) during coding (trivial), which is 2^numStateBits = 1000...000. */
+  protected final long fullRange;
+
+  /** The top bit at width numStateBits, which is 0100...000. */
+  protected final long halfRange;
+
+  /**
+   * The second highest bit at width numStateBits, which is 0010...000. This is zero when
+   * numStateBits=1.
+   */
+  protected final long quarterRange;
+
+  /** Minimum range (high+1-low) during coding (non-trivial), which is 0010...010. */
+  protected final long minimumRange;
+
+  /** Maximum allowed total from a frequency table at all times during coding. */
+  protected final long maximumTotal;
+
+  /** Bit mask of numStateBits ones, which is 0111...111. */
+  protected final long stateMask;
+
+  /*---- State fields ----*/
+
+  /**
+   * Low end of this arithmetic coder's current range. Conceptually has an infinite number of
+   * trailing 0s.
+   */
+  protected long low;
+
+  /**
+   * High end of this arithmetic coder's current range. Conceptually has an infinite number of
+   * trailing 1s.
+   */
+  protected long high;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs an arithmetic coder, which initializes the code range.
+   *
+   * @param numBits the number of bits for the arithmetic coding range
+   * @throws IllegalArgumentException if stateSize is outside the range [1, 62]
+   */
+  public ArithmeticCoderBase(int numBits) {
+    if (!(1 <= numBits && numBits <= 62))
+      throw new IllegalArgumentException("State size out of range");
+    numStateBits = numBits;
+    fullRange = 1L << numStateBits;
+    halfRange = fullRange >>> 1; // Non-zero
+    quarterRange = halfRange >>> 1; // Can be zero
+    minimumRange = quarterRange + 2; // At least 2
+    maximumTotal = Math.min(Long.MAX_VALUE / fullRange, minimumRange);
+    stateMask = fullRange - 1;
+
+    low = 0;
+    high = stateMask;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Updates the code range (low and high) of this arithmetic coder as a result of processing the
+   * specified symbol with the specified frequency table.
+   *
+   * <p>Invariants that are true before and after encoding/decoding each symbol (letting fullRange =
+   * 2<sup>numStateBits</sup>):
+   *
+   * <ul>
+   *   <li>0 &le; low &le; code &le; high &lt; fullRange. ('code' exists only in the decoder.)
+   *       Therefore these variables are unsigned integers of numStateBits bits.
+   *   <li>low &lt; 1/2 &times; fullRange &le; high. In other words, they are in different halves of
+   *       the full range.
+   *   <li>(low &lt; 1/4 &times; fullRange) || (high &ge; 3/4 &times; fullRange). In other words,
+   *       they are not both in the middle two quarters.
+   *   <li>Let range = high &minus; low + 1, then fullRange/4 &lt; minimumRange &le; range &le;
+   *       fullRange. These invariants for 'range' essentially dictate the maximum total that the
+   *       incoming frequency table can have, such that intermediate calculations don't overflow.
+   * </ul>
+   *
+   * @param freqs the frequency table to use
+   * @param symbol the symbol that was processed
+   * @throws IllegalArgumentException if the symbol has zero frequency or the frequency table's
+   *     total is too large
+   */
+  protected void update(CheckedFrequencyTable freqs, int symbol) throws IOException {
+    // State check
+    if (low >= high || (low & stateMask) != low || (high & stateMask) != high)
+      throw new AssertionError("Low or high out of range");
+    long range = high - low + 1;
+    if (!(minimumRange <= range && range <= fullRange))
+      throw new AssertionError("Range out of range");
+
+    // Frequency table values check
+    long total = freqs.getTotal();
+    long symLow = freqs.getLow(symbol);
+    long symHigh = freqs.getHigh(symbol);
+    if (symLow == symHigh) throw new IllegalArgumentException("Symbol has zero frequency");
+    if (total > maximumTotal)
+      throw new IllegalArgumentException("Cannot code symbol because total is too large");
+
+    // Update range
+    long newLow = low + symLow * range / total;
+    long newHigh = low + symHigh * range / total - 1;
+    low = newLow;
+    high = newHigh;
+
+    // While low and high have the same top bit value, shift them out
+    while (((low ^ high) & halfRange) == 0) {
+      shift();
+      low = ((low << 1) & stateMask);
+      high = ((high << 1) & stateMask) | 1;
+    }
+    // Now low's top bit must be 0 and high's top bit must be 1
+
+    // While low's top two bits are 01 and high's are 10, delete the second highest bit of both
+    while ((low & ~high & quarterRange) != 0) {
+      underflow();
+      low = (low << 1) ^ halfRange;
+      high = ((high ^ halfRange) << 1) | halfRange | 1;
+    }
+  }
+
+  /**
+   * Called to handle the situation when the top bit of {@code low} and {@code high} are equal.
+   *
+   * @throws IOException if an I/O exception occurred
+   */
+  protected abstract void shift() throws IOException;
+
+  /**
+   * Called to handle the situation when low=01(...) and high=10(...).
+   *
+   * @throws IOException if an I/O exception occurred
+   */
+  protected abstract void underflow() throws IOException;
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticDecoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticDecoder.java
new file mode 100644
index 0000000000..6afa2555c1
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticDecoder.java
@@ -0,0 +1,127 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * Reads from an arithmetic-coded bit stream and decodes symbols. Not thread-safe.
+ *
+ * @see ArithmeticEncoder
+ */
+public final class ArithmeticDecoder extends ArithmeticCoderBase {
+
+  /*---- Fields ----*/
+
+  // The underlying bit input stream (not null).
+  private BitInputStream input;
+
+  // The current raw code bits being buffered, which is always in the range [low, high].
+  private long code;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs an arithmetic coding decoder based on the specified bit input stream, and fills the
+   * code bits.
+   *
+   * @param numBits the number of bits for the arithmetic coding range
+   * @param in the bit input stream to read from
+   * @throws NullPointerException if the input steam is {@code null}
+   * @throws IllegalArgumentException if stateSize is outside the range [1, 62]
+   * @throws IOException if an I/O exception occurred
+   */
+  public ArithmeticDecoder(int numBits, BitInputStream in) throws IOException {
+    super(numBits);
+    input = Objects.requireNonNull(in);
+    code = 0;
+    for (int i = 0; i < numStateBits; i++) code = code << 1 | readCodeBit();
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Decodes the next symbol based on the specified frequency table and returns it. Also updates
+   * this arithmetic coder's state and may read in some bits.
+   *
+   * @param freqs the frequency table to use
+   * @return the next symbol
+   * @throws NullPointerException if the frequency table is {@code null}
+   * @throws IOException if an I/O exception occurred
+   */
+  public int read(FrequencyTable freqs) throws IOException {
+    return read(new CheckedFrequencyTable(freqs));
+  }
+
+  /**
+   * Decodes the next symbol based on the specified frequency table and returns it. Also updates
+   * this arithmetic coder's state and may read in some bits.
+   *
+   * @param freqs the frequency table to use
+   * @return the next symbol
+   * @throws NullPointerException if the frequency table is {@code null}
+   * @throws IllegalArgumentException if the frequency table's total is too large
+   * @throws IOException if an I/O exception occurred
+   */
+  public int read(CheckedFrequencyTable freqs) throws IOException {
+    // Translate from coding range scale to frequency table scale
+    long total = freqs.getTotal();
+    if (total > maximumTotal)
+      throw new IllegalArgumentException("Cannot decode symbol because total is too large");
+    long range = high - low + 1;
+    long offset = code - low;
+    long value = ((offset + 1) * total - 1) / range;
+    if (value * range / total > offset) throw new AssertionError();
+    if (!(0 <= value && value < total)) throw new AssertionError();
+
+    // A kind of binary search. Find highest symbol such that freqs.getLow(symbol) <= value.
+    int start = 0;
+    int end = freqs.getSymbolLimit();
+    while (end - start > 1) {
+      int middle = (start + end) >>> 1;
+      if (freqs.getLow(middle) > value) end = middle;
+      else start = middle;
+    }
+    if (start + 1 != end) throw new AssertionError();
+
+    int symbol = start;
+    if (!(freqs.getLow(symbol) * range / total <= offset
+        && offset < freqs.getHigh(symbol) * range / total)) throw new AssertionError();
+    update(freqs, symbol);
+    if (!(low <= code && code <= high)) throw new AssertionError("Code out of range");
+    return symbol;
+  }
+
+  protected void shift() throws IOException {
+    code = ((code << 1) & stateMask) | readCodeBit();
+  }
+
+  protected void underflow() throws IOException {
+    code = (code & halfRange) | ((code << 1) & (stateMask >>> 1)) | readCodeBit();
+  }
+
+  // Returns the next bit (0 or 1) from the input stream. The end
+  // of stream is treated as an infinite number of trailing zeros.
+  private int readCodeBit() throws IOException {
+    int temp = input.read();
+    if (temp == -1) temp = 0;
+    return temp;
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticEncoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticEncoder.java
new file mode 100644
index 0000000000..fcfe0c874f
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/ArithmeticEncoder.java
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.IOException;
+import java.util.Objects;
+
+/**
+ * Encodes symbols and writes to an arithmetic-coded bit stream. Not thread-safe.
+ *
+ * @see ArithmeticDecoder
+ */
+public final class ArithmeticEncoder extends ArithmeticCoderBase {
+
+  /*---- Fields ----*/
+
+  // The underlying bit output stream (not null).
+  private BitOutputStream output;
+
+  // Number of saved underflow bits. This value can grow without bound,
+  // so a truly correct implementation would use a BigInteger.
+  private int numUnderflow;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs an arithmetic coding encoder based on the specified bit output stream.
+   *
+   * @param numBits the number of bits for the arithmetic coding range
+   * @param out the bit output stream to write to
+   * @throws NullPointerException if the output stream is {@code null}
+   * @throws IllegalArgumentException if stateSize is outside the range [1, 62]
+   */
+  public ArithmeticEncoder(int numBits, BitOutputStream out) {
+    super(numBits);
+    output = Objects.requireNonNull(out);
+    numUnderflow = 0;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Encodes the specified symbol based on the specified frequency table. This updates this
+   * arithmetic coder's state and may write out some bits.
+   *
+   * @param freqs the frequency table to use
+   * @param symbol the symbol to encode
+   * @throws NullPointerException if the frequency table is {@code null}
+   * @throws IllegalArgumentException if the symbol has zero frequency or the frequency table's
+   *     total is too large
+   * @throws IOException if an I/O exception occurred
+   */
+  public void write(FrequencyTable freqs, int symbol) throws IOException {
+    write(new CheckedFrequencyTable(freqs), symbol);
+  }
+
+  /**
+   * Encodes the specified symbol based on the specified frequency table. Also updates this
+   * arithmetic coder's state and may write out some bits.
+   *
+   * @param freqs the frequency table to use
+   * @param symbol the symbol to encode
+   * @throws NullPointerException if the frequency table is {@code null}
+   * @throws IllegalArgumentException if the symbol has zero frequency or the frequency table's
+   *     total is too large
+   * @throws IOException if an I/O exception occurred
+   */
+  public void write(CheckedFrequencyTable freqs, int symbol) throws IOException {
+    update(freqs, symbol);
+  }
+
+  /**
+   * Terminates the arithmetic coding by flushing any buffered bits, so that the output can be
+   * decoded properly. It is important that this method must be called at the end of the each
+   * encoding process.
+   *
+   * <p>Note that this method merely writes data to the underlying output stream but does not close
+   * it.
+   *
+   * @throws IOException if an I/O exception occurred
+   */
+  public void finish() throws IOException {
+    output.write(1);
+  }
+
+  protected void shift() throws IOException {
+    int bit = (int) (low >>> (numStateBits - 1));
+    output.write(bit);
+
+    // Write out the saved underflow bits
+    for (; numUnderflow > 0; numUnderflow--) output.write(bit ^ 1);
+  }
+
+  protected void underflow() {
+    if (numUnderflow == Integer.MAX_VALUE)
+      throw new ArithmeticException("Maximum underflow reached");
+    numUnderflow++;
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitInputStream.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitInputStream.java
new file mode 100644
index 0000000000..b6ad18395b
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitInputStream.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Objects;
+
+/**
+ * A stream of bits that can be read. Because they come from an underlying byte stream, the total
+ * number of bits is always a multiple of 8. The bits are read in big endian. Mutable and not
+ * thread-safe.
+ *
+ * @see BitOutputStream
+ */
+public final class BitInputStream implements AutoCloseable {
+
+  /*---- Fields ----*/
+
+  // The underlying byte stream to read from (not null).
+  private InputStream input;
+
+  // Either in the range [0x00, 0xFF] if bits are available, or -1 if end of stream is reached.
+  private int currentByte;
+
+  // Number of remaining bits in the current byte, always between 0 and 7 (inclusive).
+  private int numBitsRemaining;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs a bit input stream based on the specified byte input stream.
+   *
+   * @param in the byte input stream
+   * @throws NullPointerException if the input stream is {@code null}
+   */
+  public BitInputStream(InputStream in) {
+    input = Objects.requireNonNull(in);
+    currentByte = 0;
+    numBitsRemaining = 0;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Reads a bit from this stream. Returns 0 or 1 if a bit is available, or -1 if the end of stream
+   * is reached. The end of stream always occurs on a byte boundary.
+   *
+   * @return the next bit of 0 or 1, or -1 for the end of stream
+   * @throws IOException if an I/O exception occurred
+   */
+  public int read() throws IOException {
+    if (currentByte == -1) return -1;
+    if (numBitsRemaining == 0) {
+      currentByte = input.read();
+      if (currentByte == -1) return -1;
+      numBitsRemaining = 8;
+    }
+    if (numBitsRemaining <= 0) throw new AssertionError();
+    numBitsRemaining--;
+    return (currentByte >>> numBitsRemaining) & 1;
+  }
+
+  /**
+   * Reads a bit from this stream. Returns 0 or 1 if a bit is available, or throws an {@code
+   * EOFException} if the end of stream is reached. The end of stream always occurs on a byte
+   * boundary.
+   *
+   * @return the next bit of 0 or 1
+   * @throws IOException if an I/O exception occurred
+   * @throws EOFException if the end of stream is reached
+   */
+  public int readNoEof() throws IOException {
+    int result = read();
+    if (result != -1) return result;
+    else throw new EOFException();
+  }
+
+  /**
+   * Closes this stream and the underlying input stream.
+   *
+   * @throws IOException if an I/O exception occurred
+   */
+  public void close() throws IOException {
+    input.close();
+    currentByte = -1;
+    numBitsRemaining = 0;
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitOutputStream.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitOutputStream.java
new file mode 100644
index 0000000000..2d0abb4fa3
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/BitOutputStream.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Objects;
+
+/**
+ * A stream where bits can be written to. Because they are written to an underlying byte stream, the
+ * end of the stream is padded with 0's up to a multiple of 8 bits. The bits are written in big
+ * endian. Mutable and not thread-safe.
+ *
+ * @see BitInputStream
+ */
+public final class BitOutputStream implements AutoCloseable {
+
+  /*---- Fields ----*/
+
+  // The underlying byte stream to write to (not null).
+  private OutputStream output;
+
+  // The accumulated bits for the current byte, always in the range [0x00, 0xFF].
+  private int currentByte;
+
+  // Number of accumulated bits in the current byte, always between 0 and 7 (inclusive).
+  private int numBitsFilled;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs a bit output stream based on the specified byte output stream.
+   *
+   * @param out the byte output stream
+   * @throws NullPointerException if the output stream is {@code null}
+   */
+  public BitOutputStream(OutputStream out) {
+    output = Objects.requireNonNull(out);
+    currentByte = 0;
+    numBitsFilled = 0;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Writes a bit to the stream. The specified bit must be 0 or 1.
+   *
+   * @param b the bit to write, which must be 0 or 1
+   * @throws IOException if an I/O exception occurred
+   */
+  public void write(int b) throws IOException {
+    if (b != 0 && b != 1) throw new IllegalArgumentException("Argument must be 0 or 1");
+    currentByte = (currentByte << 1) | b;
+    numBitsFilled++;
+    if (numBitsFilled == 8) {
+      output.write(currentByte);
+      currentByte = 0;
+      numBitsFilled = 0;
+    }
+  }
+
+  /**
+   * Closes this stream and the underlying output stream. If called when this bit stream is not at a
+   * byte boundary, then the minimum number of "0" bits (between 0 and 7 of them) are written as
+   * padding to reach the next byte boundary.
+   *
+   * @throws IOException if an I/O exception occurred
+   */
+  public void close() throws IOException {
+    while (numBitsFilled != 0) write(0);
+    output.close();
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/CheckedFrequencyTable.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/CheckedFrequencyTable.java
new file mode 100644
index 0000000000..13ebbf7bce
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/CheckedFrequencyTable.java
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.util.Objects;
+
+/**
+ * A wrapper that checks the preconditions (arguments) and postconditions (return value) of all the
+ * frequency table methods. Useful for finding faults in a frequency table implementation. However,
+ * arithmetic overflow conditions are not checked.
+ */
+public final class CheckedFrequencyTable implements FrequencyTable {
+
+  /*---- Fields ----*/
+
+  // The underlying frequency table that holds the data (not null).
+  private FrequencyTable freqTable;
+
+  /*---- Constructor ----*/
+
+  public CheckedFrequencyTable(FrequencyTable freq) {
+    freqTable = Objects.requireNonNull(freq);
+  }
+
+  /*---- Methods ----*/
+
+  public int getSymbolLimit() {
+    int result = freqTable.getSymbolLimit();
+    if (result <= 0) throw new AssertionError("Non-positive symbol limit");
+    return result;
+  }
+
+  public int get(int symbol) {
+    int result = freqTable.get(symbol);
+    if (!isSymbolInRange(symbol)) throw new AssertionError("IllegalArgumentException expected");
+    if (result < 0) throw new AssertionError("Negative symbol frequency");
+    return result;
+  }
+
+  public int getTotal() {
+    int result = freqTable.getTotal();
+    if (result < 0) throw new AssertionError("Negative total frequency");
+    return result;
+  }
+
+  public int getLow(int symbol) {
+    if (isSymbolInRange(symbol)) {
+      int low = freqTable.getLow(symbol);
+      int high = freqTable.getHigh(symbol);
+      if (!(0 <= low && low <= high && high <= freqTable.getTotal()))
+        throw new AssertionError("Symbol low cumulative frequency out of range");
+      return low;
+    } else {
+      freqTable.getLow(symbol);
+      throw new AssertionError("IllegalArgumentException expected");
+    }
+  }
+
+  public int getHigh(int symbol) {
+    if (isSymbolInRange(symbol)) {
+      int low = freqTable.getLow(symbol);
+      int high = freqTable.getHigh(symbol);
+      if (!(0 <= low && low <= high && high <= freqTable.getTotal()))
+        throw new AssertionError("Symbol high cumulative frequency out of range");
+      return high;
+    } else {
+      freqTable.getHigh(symbol);
+      throw new AssertionError("IllegalArgumentException expected");
+    }
+  }
+
+  public String toString() {
+    return "CheckedFrequencyTable (" + freqTable.toString() + ")";
+  }
+
+  public void set(int symbol, int freq) {
+    freqTable.set(symbol, freq);
+    if (!isSymbolInRange(symbol) || freq < 0)
+      throw new AssertionError("IllegalArgumentException expected");
+  }
+
+  public void increment(int symbol) {
+    freqTable.increment(symbol);
+    if (!isSymbolInRange(symbol)) throw new AssertionError("IllegalArgumentException expected");
+  }
+
+  private boolean isSymbolInRange(int symbol) {
+    return 0 <= symbol && symbol < getSymbolLimit();
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FlatFrequencyTable.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FlatFrequencyTable.java
new file mode 100644
index 0000000000..df68c564b3
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FlatFrequencyTable.java
@@ -0,0 +1,144 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+/**
+ * An immutable frequency table where every symbol has the same frequency of 1. Useful as a fallback
+ * model when no statistics are available.
+ */
+public final class FlatFrequencyTable implements FrequencyTable {
+
+  /*---- Fields ----*/
+
+  // Total number of symbols, which is at least 1.
+  private final int numSymbols;
+
+  /*---- Constructor ----*/
+
+  /**
+   * Constructs a flat frequency table with the specified number of symbols.
+   *
+   * @param numSyms the number of symbols, which must be at least 1
+   * @throws IllegalArgumentException if the number of symbols is less than 1
+   */
+  public FlatFrequencyTable(int numSyms) {
+    if (numSyms < 1) throw new IllegalArgumentException("Number of symbols must be positive");
+    numSymbols = numSyms;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Returns the number of symbols in this table, which is at least 1.
+   *
+   * @return the number of symbols in this table
+   */
+  public int getSymbolLimit() {
+    return numSymbols;
+  }
+
+  /**
+   * Returns the frequency of the specified symbol, which is always 1.
+   *
+   * @param symbol the symbol to query
+   * @return the frequency of the symbol, which is 1
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int get(int symbol) {
+    checkSymbol(symbol);
+    return 1;
+  }
+
+  /**
+   * Returns the total of all symbol frequencies, which is always equal to the number of symbols in
+   * this table.
+   *
+   * @return the total of all symbol frequencies, which is {@code getSymbolLimit()}
+   */
+  public int getTotal() {
+    return numSymbols;
+  }
+
+  /**
+   * Returns the sum of the frequencies of all the symbols strictly below the specified symbol
+   * value. The returned value is equal to {@code symbol}.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of all the symbols below {@code symbol}, which is {@code
+   *     symbol}
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int getLow(int symbol) {
+    checkSymbol(symbol);
+    return symbol;
+  }
+
+  /**
+   * Returns the sum of the frequencies of the specified symbol and all the symbols below. The
+   * returned value is equal to {@code symbol + 1}.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of {@code symbol} and all symbols below, which is {@code
+   *     symbol + 1}
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int getHigh(int symbol) {
+    checkSymbol(symbol);
+    return symbol + 1;
+  }
+
+  // Returns silently if 0 <= symbol < numSymbols, otherwise throws an exception.
+  private void checkSymbol(int symbol) {
+    if (!(0 <= symbol && symbol < numSymbols))
+      throw new IllegalArgumentException("Symbol out of range");
+  }
+
+  /**
+   * Returns a string representation of this frequency table. The format is subject to change.
+   *
+   * @return a string representation of this frequency table
+   */
+  public String toString() {
+    return "FlatFrequencyTable=" + numSymbols;
+  }
+
+  /**
+   * Unsupported operation, because this frequency table is immutable.
+   *
+   * @param symbol ignored
+   * @param freq ignored
+   * @throws UnsupportedOperationException because this frequency table is immutable
+   */
+  public void set(int symbol, int freq) {
+    throw new UnsupportedOperationException();
+  }
+
+  /**
+   * Unsupported operation, because this frequency table is immutable.
+   *
+   * @param symbol ignored
+   * @throws UnsupportedOperationException because this frequency table is immutable
+   */
+  public void increment(int symbol) {
+    throw new UnsupportedOperationException();
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FrequencyTable.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FrequencyTable.java
new file mode 100644
index 0000000000..659e61e30d
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/FrequencyTable.java
@@ -0,0 +1,94 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+/**
+ * A table of symbol frequencies. The table holds data for symbols numbered from 0 to
+ * getSymbolLimit()&minus;1. Each symbol has a frequency, which is a non-negative integer.
+ *
+ * <p>Frequency table objects are primarily used for getting cumulative symbol frequencies. These
+ * objects can be mutable depending on the implementation. The total of all symbol frequencies must
+ * not exceed Integer.MAX_VALUE.
+ */
+public interface FrequencyTable {
+
+  /**
+   * Returns the number of symbols in this frequency table, which is a positive number.
+   *
+   * @return the number of symbols in this frequency table
+   */
+  public int getSymbolLimit();
+
+  /**
+   * Returns the frequency of the specified symbol. The returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the frequency of the symbol
+   * @throws IllegalArgumentException if the symbol is out of range
+   */
+  public int get(int symbol);
+
+  /**
+   * Sets the frequency of the specified symbol to the specified value. The frequency value must be
+   * at least 0.
+   *
+   * @param symbol the symbol to set
+   * @param freq the frequency value to set
+   * @throws IllegalArgumentException if the frequency is negative or the symbol is out of range
+   * @throws ArithmeticException if an arithmetic overflow occurs
+   */
+  public void set(int symbol, int freq);
+
+  /**
+   * Increments the frequency of the specified symbol.
+   *
+   * @param symbol the symbol whose frequency to increment
+   * @throws IllegalArgumentException if the symbol is out of range
+   * @throws ArithmeticException if an arithmetic overflow occurs
+   */
+  public void increment(int symbol);
+
+  /**
+   * Returns the total of all symbol frequencies. The returned value is at least 0 and is always
+   * equal to {@code getHigh(getSymbolLimit() - 1)}.
+   *
+   * @return the total of all symbol frequencies
+   */
+  public int getTotal();
+
+  /**
+   * Returns the sum of the frequencies of all the symbols strictly below the specified symbol
+   * value. The returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of all the symbols below {@code symbol}
+   * @throws IllegalArgumentException if the symbol is out of range
+   */
+  public int getLow(int symbol);
+
+  /**
+   * Returns the sum of the frequencies of the specified symbol and all the symbols below. The
+   * returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of {@code symbol} and all symbols below
+   * @throws IllegalArgumentException if the symbol is out of range
+   */
+  public int getHigh(int symbol);
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/SimpleFrequencyTable.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/SimpleFrequencyTable.java
new file mode 100644
index 0000000000..c3ddea7434
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/compress/arithmetic/SimpleFrequencyTable.java
@@ -0,0 +1,229 @@
+/*
+ * 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.
+ */
+package org.apache.iotdb.tsfile.compress.arithmetic;
+
+import java.util.Objects;
+
+/**
+ * A mutable table of symbol frequencies. The number of symbols cannot be changed after
+ * construction. The current algorithm for calculating cumulative frequencies takes linear time, but
+ * there exist faster algorithms such as Fenwick trees.
+ */
+public final class SimpleFrequencyTable implements FrequencyTable {
+
+  /*---- Fields ----*/
+
+  // The frequency for each symbol. Its length is at least 1, and each element is non-negative.
+  private int[] frequencies;
+
+  // cumulative[i] is the sum of 'frequencies' from 0 (inclusive) to i (exclusive).
+  // Initialized lazily. When this is not null, the data is valid.
+  private int[] cumulative;
+
+  // Always equal to the sum of 'frequencies'.
+  private int total;
+
+  /*---- Constructors ----*/
+
+  /**
+   * Constructs a frequency table from the specified array of symbol frequencies. There must be at
+   * least 1 symbol, no symbol has a negative frequency, and the total must not exceed {@code
+   * Integer.MAX_VALUE}.
+   *
+   * @param freqs the array of symbol frequencies
+   * @throws NullPointerException if the array is {@code null}
+   * @throws IllegalArgumentException if {@code freqs.length} &lt; 1, {@code freqs.length} = {@code
+   *     Integer.MAX_VALUE}, or any element {@code freqs[i]} &lt; 0
+   * @throws ArithmeticException if the total of {@code freqs} exceeds {@code Integer.MAX_VALUE}
+   */
+  public SimpleFrequencyTable(int[] freqs) {
+    Objects.requireNonNull(freqs);
+    if (freqs.length < 1) throw new IllegalArgumentException("At least 1 symbol needed");
+    if (freqs.length > Integer.MAX_VALUE - 1)
+      throw new IllegalArgumentException("Too many symbols");
+
+    frequencies = freqs.clone(); // Make copy
+    total = 0;
+    for (int x : frequencies) {
+      if (x < 0) throw new IllegalArgumentException("Negative frequency");
+      total = Math.addExact(x, total);
+    }
+    cumulative = null;
+  }
+
+  /**
+   * Constructs a frequency table by copying the specified frequency table.
+   *
+   * @param freqs the frequency table to copy
+   * @throws NullPointerException if {@code freqs} is {@code null}
+   * @throws IllegalArgumentException if {@code freqs.getSymbolLimit()} &lt; 1 or any element {@code
+   *     freqs.get(i)} &lt; 0
+   * @throws ArithmeticException if the total of all {@code freqs} elements exceeds {@code
+   *     Integer.MAX_VALUE}
+   */
+  public SimpleFrequencyTable(FrequencyTable freqs) {
+    Objects.requireNonNull(freqs);
+    int numSym = freqs.getSymbolLimit();
+    if (numSym < 1) throw new IllegalArgumentException("At least 1 symbol needed");
+
+    frequencies = new int[numSym];
+    total = 0;
+    for (int i = 0; i < frequencies.length; i++) {
+      int x = freqs.get(i);
+      if (x < 0) throw new IllegalArgumentException("Negative frequency");
+      frequencies[i] = x;
+      total = Math.addExact(x, total);
+    }
+    cumulative = null;
+  }
+
+  /*---- Methods ----*/
+
+  /**
+   * Returns the number of symbols in this frequency table, which is at least 1.
+   *
+   * @return the number of symbols in this frequency table
+   */
+  public int getSymbolLimit() {
+    return frequencies.length;
+  }
+
+  /**
+   * Returns the frequency of the specified symbol. The returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the frequency of the specified symbol
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int get(int symbol) {
+    checkSymbol(symbol);
+    return frequencies[symbol];
+  }
+
+  /**
+   * Sets the frequency of the specified symbol to the specified value. The frequency value must be
+   * at least 0. If an exception is thrown, then the state is left unchanged.
+   *
+   * @param symbol the symbol to set
+   * @param freq the frequency value to set
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   * @throws ArithmeticException if this set request would cause the total to exceed {@code
+   *     Integer.MAX_VALUE}
+   */
+  public void set(int symbol, int freq) {
+    checkSymbol(symbol);
+    if (freq < 0) throw new IllegalArgumentException("Negative frequency");
+
+    int temp = total - frequencies[symbol];
+    if (temp < 0) throw new AssertionError();
+    total = Math.addExact(temp, freq);
+    frequencies[symbol] = freq;
+    cumulative = null;
+  }
+
+  /**
+   * Increments the frequency of the specified symbol.
+   *
+   * @param symbol the symbol whose frequency to increment
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public void increment(int symbol) {
+    checkSymbol(symbol);
+    if (frequencies[symbol] == Integer.MAX_VALUE)
+      throw new ArithmeticException("Arithmetic overflow");
+    total = Math.addExact(total, 1);
+    frequencies[symbol]++;
+    cumulative = null;
+  }
+
+  /**
+   * Returns the total of all symbol frequencies. The returned value is at least 0 and is always
+   * equal to {@code getHigh(getSymbolLimit() - 1)}.
+   *
+   * @return the total of all symbol frequencies
+   */
+  public int getTotal() {
+    return total;
+  }
+
+  /**
+   * Returns the sum of the frequencies of all the symbols strictly below the specified symbol
+   * value. The returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of all the symbols below {@code symbol}
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int getLow(int symbol) {
+    checkSymbol(symbol);
+    if (cumulative == null) initCumulative();
+    return cumulative[symbol];
+  }
+
+  /**
+   * Returns the sum of the frequencies of the specified symbol and all the symbols below. The
+   * returned value is at least 0.
+   *
+   * @param symbol the symbol to query
+   * @return the sum of the frequencies of {@code symbol} and all symbols below
+   * @throws IllegalArgumentException if {@code symbol} &lt; 0 or {@code symbol} &ge; {@code
+   *     getSymbolLimit()}
+   */
+  public int getHigh(int symbol) {
+    checkSymbol(symbol);
+    if (cumulative == null) initCumulative();
+    return cumulative[symbol + 1];
+  }
+
+  // Recomputes the array of cumulative symbol frequencies.
+  private void initCumulative() {
+    cumulative = new int[frequencies.length + 1];
+    int sum = 0;
+    for (int i = 0; i < frequencies.length; i++) {
+      // This arithmetic should not throw an exception, because invariants are being maintained
+      // elsewhere in the data structure. This implementation is just a defensive measure.
+      sum = Math.addExact(frequencies[i], sum);
+      cumulative[i + 1] = sum;
+    }
+    if (sum != total) throw new AssertionError();
+  }
+
+  // Returns silently if 0 <= symbol < frequencies.length, otherwise throws an exception.
+  private void checkSymbol(int symbol) {
+    if (!(0 <= symbol && symbol < frequencies.length))
+      throw new IllegalArgumentException("Symbol out of range");
+  }
+
+  /**
+   * Returns a string representation of this frequency table, useful for debugging only, and the
+   * format is subject to change.
+   *
+   * @return a string representation of this frequency table
+   */
+  public String toString() {
+    StringBuilder sb = new StringBuilder();
+    for (int i = 0; i < frequencies.length; i++)
+      sb.append(String.format("%d\t%d%n", i, frequencies[i]));
+    return sb.toString();
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/BuffDecoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/BuffDecoder.java
new file mode 100644
index 0000000000..6e47ef72d0
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/BuffDecoder.java
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2022 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.iotdb.tsfile.encoding.decoder;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.utils.BitReader;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+/** @author Wang Haoyu */
+public class BuffDecoder extends Decoder {
+
+  private double data[];
+
+  private int readTotalCount = 0;
+
+  private int nextReadIndex = 0;
+
+  public BuffDecoder() {
+    super(TSEncoding.BUFF);
+  }
+
+  @Override
+  public double readDouble(ByteBuffer buffer) {
+    if (nextReadIndex == readTotalCount) {
+      loadBlock(buffer);
+      nextReadIndex = 0;
+    }
+    return data[nextReadIndex++];
+  }
+
+  @Override
+  public float readFloat(ByteBuffer buffer) {
+    return (float) readDouble(buffer);
+  }
+
+  @Override
+  public int readInt(ByteBuffer buffer) {
+    return (int) Math.round(readDouble(buffer));
+  }
+
+  @Override
+  public long readLong(ByteBuffer buffer) {
+    return (long) Math.round(readDouble(buffer));
+  }
+
+  @Override
+  public boolean hasNext(ByteBuffer buffer) throws IOException {
+    return (nextReadIndex < readTotalCount) || buffer.hasRemaining();
+  }
+
+  @Override
+  public void reset() {
+    nextReadIndex = 0;
+    readTotalCount = 0;
+  }
+
+  private void loadBlock(ByteBuffer buffer) {
+    BitReader reader = new BitReader(buffer);
+    // Meta
+    int n = (int) reader.next(32);
+    int p = (int) reader.next(32);
+    int min = (int) reader.next(32);
+    int max = (int) reader.next(32);
+    // Subcolumns
+    long[] fixed = new long[n];
+    int totalWidth = getValueWidth(max - min) + p;
+    for (int i = totalWidth; i > 0; i -= 8) {
+      int len = Math.min(8, i);
+      byte[] bytes = decodeSubColumn(reader, n, len);
+      for (int j = 0; j < n; j++) {
+        fixed[j] = (fixed[j] << len) | (bytes[j] & 0xff);
+      }
+    }
+    reader.skip();
+    // Fiexed point to floating point
+    data = new double[n];
+    double eps1 = Math.pow(2, -p);
+    for (int i = 0; i < n; i++) {
+      data[i] = fixed[i] * eps1 + min;
+    }
+    this.readTotalCount = n;
+  }
+
+  private byte[] decodeSubColumn(BitReader reader, int n, int len) {
+    int sparseFlag = (int) reader.next(8);
+    switch (sparseFlag) {
+      case 0:
+        return decodeDenseSubColumn(reader, n, len);
+      case 1:
+        return decodeSparseSubColumn(reader, n, len);
+      default:
+        throw new RuntimeException("It cannot be reached.");
+    }
+  }
+
+  private byte[] decodeDenseSubColumn(BitReader reader, int n, int len) {
+    byte[] bytes = new byte[n];
+    for (int i = 0; i < n; i++) {
+      bytes[i] = (byte) reader.next(len);
+    }
+    return bytes;
+  }
+
+  private byte[] decodeSparseSubColumn(BitReader reader, int n, int len) {
+    // Mode
+    byte frequentValue = (byte) reader.next(len);
+    // RLE
+    reader.skip();
+    int rleByteSize = (int) reader.next(32);
+    boolean vector[] = decodeRLEVector(reader.nextBytes(rleByteSize), n);
+    // Outliers
+    int cnt = (int) reader.next(32);
+    byte[] bytes = new byte[n];
+    for (int i = 0; i < n; i++) {
+      if (vector[i]) {
+        bytes[i] = (byte) reader.next(len);
+      } else {
+        bytes[i] = frequentValue;
+      }
+    }
+    return bytes;
+  }
+
+  private boolean[] decodeRLEVector(byte[] bytes, int n) {
+
+    BitReader reader = new BitReader(ByteBuffer.wrap(bytes));
+    boolean[] vector = new boolean[n];
+    int width = getValueWidth(n);
+    int i = 0;
+    boolean bit = false;
+    while (i < n) {
+      int run = (int) reader.next(width);
+      int j = i + run;
+      for (; i < j; i++) {
+        vector[i] = bit;
+      }
+      bit = !bit;
+    }
+    return vector;
+  }
+
+  public int getValueWidth(long x) {
+    return 64 - Long.numberOfLeadingZeros(x);
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
index fff655c3aa..9e4a6b7340 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/Decoder.java
@@ -146,6 +146,8 @@ public abstract class Decoder {
           default:
             throw new TsFileDecodingException(String.format(ERROR_MSG, encoding, dataType));
         }
+      case BUFF:
+        return new BuffDecoder();
       default:
         throw new TsFileDecodingException(String.format(ERROR_MSG, encoding, dataType));
     }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/DescendDecoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/DescendDecoder.java
index 4d263785ee..fbddaf2b42 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/DescendDecoder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/decoder/DescendDecoder.java
@@ -73,10 +73,9 @@ public class DescendDecoder extends Decoder {
     BitReader reader = new BitReader(buffer);
     // Block size with 32 bits
     this.readTotalCount = (int) reader.next(32);
-    //        System.out.println("Decoder N:" + this.readTotalCount);
     // Number of nonzero values with 32 bits
     int m = (int) reader.next(32);
-    //        System.out.println("Decoder M:"+ m);
+    // Quantization level
     int beta = (int) reader.next(32);
     // Decode index sequence
     int[] index = decodeIndex(m, reader);
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BuffEncoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BuffEncoder.java
new file mode 100644
index 0000000000..f600749b73
--- /dev/null
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/BuffEncoder.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright 2022 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+package org.apache.iotdb.tsfile.encoding.encoder;
+
+import org.apache.iotdb.tsfile.file.metadata.enums.TSEncoding;
+import org.apache.iotdb.tsfile.utils.BitConstructor;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** @author Wang Haoyu */
+public class BuffEncoder extends Encoder {
+
+  protected static final int BLOCK_DEFAULT_SIZE = 1024;
+  protected static final int DEFAULT_PRECISION = 0;
+  private static final Logger logger = LoggerFactory.getLogger(FreqEncoder.class);
+  private int blockSize;
+  protected int writeIndex = 0;
+  private final double sparseThreshold = 0.9;
+  private int precision = 0;
+  private double[] dataBuffer;
+
+  public BuffEncoder() {
+    this(BLOCK_DEFAULT_SIZE, DEFAULT_PRECISION);
+  }
+
+  public BuffEncoder(int size, int precision) {
+    super(TSEncoding.BUFF);
+    this.blockSize = size;
+    this.precision = precision;
+    this.dataBuffer = new double[blockSize];
+  }
+
+  @Override
+  public void encode(double value, ByteArrayOutputStream out) {
+    dataBuffer[writeIndex] = value;
+    writeIndex++;
+    if (writeIndex == blockSize) {
+      flush(out);
+    }
+  }
+
+  @Override
+  public void encode(float value, ByteArrayOutputStream out) {
+    encode((double) value, out);
+  }
+
+  @Override
+  public void encode(int value, ByteArrayOutputStream out) {
+    encode((double) value, out);
+  }
+
+  @Override
+  public void encode(long value, ByteArrayOutputStream out) {
+    encode((double) value, out);
+  }
+
+  @Override
+  public void flush(ByteArrayOutputStream out) {
+    try {
+      flushBlock(out);
+    } catch (IOException e) {
+      logger.error("flush data to stream failed!", e);
+    }
+  }
+
+  private void flushBlock(ByteArrayOutputStream out) throws IOException {
+    if (writeIndex > 0) {
+      encodeBlock(out);
+      writeIndex = 0;
+    }
+  }
+
+  public void encodeBlock(ByteArrayOutputStream out) throws IOException {
+    // Get the range of integer part
+    int min = Integer.MAX_VALUE, max = Integer.MIN_VALUE;
+    for (int i = 0; i < writeIndex; i++) {
+      min = Math.min(min, (int) Math.floor(dataBuffer[i]));
+      max = Math.max(max, (int) Math.floor(dataBuffer[i]));
+    }
+    // Meta
+    BitConstructor constructor = new BitConstructor();
+    constructor.add(writeIndex, 32);
+    constructor.add(this.precision, 32);
+    constructor.add(min, 32);
+    constructor.add(max, 32);
+    // Floating point to fixed point
+    long[] fixed = new long[writeIndex];
+    double eps = Math.pow(2, -precision);
+    for (int i = 0; i < fixed.length; i++) {
+      fixed[i] = (long) (Math.round((dataBuffer[i] - min) / eps));
+    }
+    // Store by subcolumns
+    int[] masks = {0, 0x0001, 0x0003, 0x0007, 0x000f, 0x001f, 0x003f, 0x007f, 0x00ff};
+    int totalWidth = getValueWidth(max - min) + precision;
+    for (int i = totalWidth; i > 0; i -= 8) {
+      int shift = Math.max(0, i - 8), len = Math.min(8, i);
+      byte[] bytes = new byte[fixed.length];
+      for (int j = 0; j < fixed.length; j++) {
+        bytes[j] = (byte) ((fixed[j] >> shift) & masks[len]);
+      }
+      encodeSubColumn(constructor, bytes, len);
+    }
+    constructor.pad();
+    out.write(constructor.toByteArray());
+  }
+
+  private void encodeSubColumn(BitConstructor constructor, byte[] bytes, int len) {
+    // Count and decide whether sparse
+    Byte frequentValue = count(bytes, new HashMap<>());
+    if (frequentValue == null) {
+      constructor.add(0, 8);
+      encodeDenseSubColumn(constructor, bytes, len);
+    } else {
+      constructor.add(1, 8);
+      encodeSparseSubColumn(constructor, bytes, frequentValue, len);
+    }
+  }
+
+  private void encodeDenseSubColumn(BitConstructor constructor, byte[] bytes, int len) {
+    for (byte b : bytes) {
+      constructor.add(b, len);
+    }
+  }
+
+  private void encodeSparseSubColumn(
+      BitConstructor constructor, byte[] bytes, byte frequentValue, int len) {
+    // Mode
+    constructor.add(frequentValue, len);
+    // RLE
+    BitConstructor rle = new BitConstructor();
+    int cnt = encodeRLEVector(rle, bytes, frequentValue);
+    byte[] rleBytes = rle.toByteArray();
+    constructor.pad();
+    constructor.add(rleBytes.length, 32);
+    constructor.add(rleBytes);
+    // Outliers
+    constructor.add(cnt, 32);
+    for (byte b : bytes) {
+      if (b != frequentValue) {
+        constructor.add(b, len);
+      }
+    }
+  }
+
+  private int encodeRLEVector(BitConstructor constructor, byte[] bytes, byte frequentValue) {
+    int width = getValueWidth(bytes.length);
+    boolean outlier = false;
+    int run = 0;
+    int cnt = 0;
+    for (byte b : bytes) {
+      if ((b != frequentValue) == outlier) {
+        run++;
+      } else {
+        outlier = !outlier;
+        constructor.add(run, width);
+        run = 1;
+      }
+      if (b != frequentValue) {
+        cnt++;
+      }
+    }
+    constructor.add(run, width);
+    return cnt;
+  }
+
+  private Byte count(byte[] bytes, HashMap<Byte, Integer> map) {
+    for (byte x : bytes) {
+      map.put(x, map.getOrDefault(x, 0) + 1);
+    }
+    Byte maxByte = null;
+    int maxTimes = 0;
+    for (Map.Entry<Byte, Integer> entry : map.entrySet()) {
+      Byte key = entry.getKey();
+      Integer value = entry.getValue();
+      if (value > maxTimes) {
+        maxTimes = value;
+        maxByte = key;
+      }
+    }
+    if (maxTimes > sparseThreshold * bytes.length) {
+      return maxByte;
+    } else {
+      return null;
+    }
+  }
+
+  @Override
+  public int getOneItemMaxSize() {
+    return 13;
+  }
+
+  @Override
+  public long getMaxByteSize() {
+    return 8 + 13 * writeIndex;
+  }
+
+  /**
+   * Get the valid bit width of x
+   *
+   * @param x
+   * @return valid bit width
+   */
+  public int getValueWidth(long x) {
+    return 64 - Long.numberOfLeadingZeros(x);
+  }
+}
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DescendEncoder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DescendEncoder.java
index 210745998d..7fe5c5c62b 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DescendEncoder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/DescendEncoder.java
@@ -117,19 +117,17 @@ public class DescendEncoder extends Encoder {
       value[i] = array[i].quantize(beta);
     }
     BitConstructor constructor = new BitConstructor();
-    // 32位数据点个数
+    // Number of data points
     constructor.add(writeIndex, 32);
-    System.out.println("N:" + writeIndex);
-    // 32位有效数据点个数
+    // Number of reserved data points
     constructor.add(m, 32);
-    System.out.println("M:" + m);
+    // Quantization level
     constructor.add(beta, 32);
-    // 分组位压缩编码index序列
+    // Group bit-backing
     encodeIndex(index, constructor);
-    // 降序位压缩编码value序列
+    // Descend bit-packing
     encodeValue(value, constructor);
     constructor.pad();
-    //        System.out.println("Encoder Size:" + constructor.sizeInBytes());
     return constructor.toByteArray();
   }
 
@@ -151,10 +149,10 @@ public class DescendEncoder extends Encoder {
     if (value.length == 0) {
       return;
     }
-    // 8位,第一个数的位数
+    // Bit width of the first value
     int bits = getValueWidth(Math.abs(value[0]));
     constructor.add(bits, 8);
-    // 存储所有数据
+    // Encode all values
     for (int i = 0; i < value.length; i++) {
       constructor.add(value[i], bits);
       bits = getValueWidth(value[i]);
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
index 098b441dfe..517ab9cc84 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/encoding/encoder/TSEncodingBuilder.java
@@ -79,6 +79,8 @@ public abstract class TSEncodingBuilder {
         return new Simple8b();
       case SIMPLE8B_SPARSE:
         return new SparseSimple8b();
+      case BUFF:
+        return new Buff();
       default:
         throw new UnsupportedOperationException(type.toString());
     }
@@ -561,4 +563,31 @@ public abstract class TSEncodingBuilder {
       return JsonFormatConstant.MAX_POINT_NUMBER + ":" + maxPointNumber;
     }
   }
+
+  /** for INT32, INT64, FLOAT, DOUBLE. */
+  public static class Buff extends TSEncodingBuilder {
+
+    @Override
+    public Encoder getEncoder(TSDataType type) {
+      switch (type) {
+        case INT32:
+        case INT64:
+        case FLOAT:
+        case DOUBLE:
+          return new BuffEncoder();
+        default:
+          throw new UnSupportedDataTypeException(
+              "SIMPLE8B_SPARSE doesn't support data type: " + type);
+      }
+    }
+
+    @Override
+    /**
+     * Descend could specify <b>max_point_number</b> in given JSON Object, which means the maximum
+     * decimal digits for float or double data.
+     */
+    public void initFromProps(Map<String, String> props) {
+      // set max error from initialized map or default value if not set
+    }
+  }
 }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
index 85893e7bd1..ce36f04753 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/CompressionType.java
@@ -41,7 +41,9 @@ public enum CompressionType {
   PLA(".pla", (byte) 6),
 
   /** LZ4 */
-  LZ4(".lz4", (byte) 7);
+  LZ4(".lz4", (byte) 7),
+
+  ARITHMETIC(".arithmetic", (byte) 8);
 
   private final String extensionName;
   private final byte index;
@@ -75,6 +77,8 @@ public enum CompressionType {
         return CompressionType.PLA;
       case 7:
         return CompressionType.LZ4;
+      case 8:
+        return CompressionType.ARITHMETIC;
       default:
         throw new IllegalArgumentException("Invalid input: " + compressor);
     }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
index 977bbb9d84..b5c9a73086 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/file/metadata/enums/TSEncoding.java
@@ -32,7 +32,8 @@ public enum TSEncoding {
   FREQ((byte) 10),
   DESCEND((byte) 11),
   SIMPLE8B((byte) 12),
-  SIMPLE8B_SPARSE((byte) 13);
+  SIMPLE8B_SPARSE((byte) 13),
+  BUFF((byte) 14);
 
   private final byte type;
 
@@ -80,6 +81,8 @@ public enum TSEncoding {
         return TSEncoding.SIMPLE8B;
       case 13:
         return TSEncoding.SIMPLE8B_SPARSE;
+      case 14:
+        return TSEncoding.BUFF;
       default:
         throw new IllegalArgumentException("Invalid input: " + encoding);
     }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java
index b54278451a..1bda3ab90f 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/read/reader/page/PageReader.java
@@ -43,6 +43,8 @@ import java.util.List;
 
 public class PageReader implements IPageReader {
 
+  public static long decodeTimeCost = 0;
+
   private PageHeader pageHeader;
 
   protected TSDataType dataType;
@@ -139,7 +141,10 @@ public class PageReader implements IPageReader {
             }
             break;
           case DOUBLE:
+            long before = System.nanoTime();
             double aDouble = valueDecoder.readDouble(valueBuffer);
+            long after = System.nanoTime();
+            decodeTimeCost += after - before;
             if (!isDeleted(timestamp) && (filter == null || filter.satisfy(timestamp, aDouble))) {
               pageData.putDouble(timestamp, aDouble);
             }
diff --git a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
index 0401908477..632b2fc1a2 100644
--- a/tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
+++ b/tsfile/src/main/java/org/apache/iotdb/tsfile/write/page/PageWriter.java
@@ -42,6 +42,7 @@ import java.nio.channels.WritableByteChannel;
  * encoder and respective OutputStream.
  */
 public class PageWriter {
+  public static long encodeTimeCost = 0;
 
   private static final Logger logger = LoggerFactory.getLogger(PageWriter.class);
 
@@ -115,7 +116,10 @@ public class PageWriter {
   /** write a time value pair into encoder */
   public void write(long time, double value) {
     timeEncoder.encode(time, timeOut);
+    long before = System.nanoTime();
     valueEncoder.encode(value, valueOut);
+    long after = System.nanoTime();
+    encodeTimeCost += after - before;
     statistics.update(time, value);
   }