diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0c7e31bfbb..90e841d5e0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -34,7 +34,7 @@ endif(${BUILD_TEST})
add_subdirectory(source)
add_subdirectory(tools)
-add_subdirectory(tests)
+add_subdirectory(utils)
add_subdirectory(examples/c)
# docs
diff --git a/cmake/cmake.platform b/cmake/cmake.platform
index 3aa1ffc07e..e4d440d76e 100644
--- a/cmake/cmake.platform
+++ b/cmake/cmake.platform
@@ -87,7 +87,7 @@ IF ("${CPUTYPE}" STREQUAL "")
SET(TD_ARM_32 TRUE)
ADD_DEFINITIONS("-D_TD_ARM_")
ADD_DEFINITIONS("-D_TD_ARM_32")
- ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+ ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(aarch64)|(arm64)")
MESSAGE(STATUS "The current platform is aarch64")
SET(PLATFORM_ARCH_STR "arm64")
SET(TD_ARM_64 TRUE)
diff --git a/cmake/cmake.version b/cmake/cmake.version
index db29644b38..7c895b12ff 100644
--- a/cmake/cmake.version
+++ b/cmake/cmake.version
@@ -2,7 +2,7 @@
IF (DEFINED VERNUMBER)
SET(TD_VER_NUMBER ${VERNUMBER})
ELSE ()
- SET(TD_VER_NUMBER "3.0.0.1")
+ SET(TD_VER_NUMBER "3.0.1.0")
ENDIF ()
IF (DEFINED VERCOMPATIBLE)
diff --git a/cmake/taosadapter_CMakeLists.txt.in b/cmake/taosadapter_CMakeLists.txt.in
index f182beed33..eb0faf6d5d 100644
--- a/cmake/taosadapter_CMakeLists.txt.in
+++ b/cmake/taosadapter_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosadapter
ExternalProject_Add(taosadapter
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
- GIT_TAG abed566
+ GIT_TAG 71e7ccf
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/cmake/taostools_CMakeLists.txt.in b/cmake/taostools_CMakeLists.txt.in
index 3c7067a9f8..c273e9889f 100644
--- a/cmake/taostools_CMakeLists.txt.in
+++ b/cmake/taostools_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taos-tools
ExternalProject_Add(taos-tools
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
- GIT_TAG f169c0f
+ GIT_TAG 2dba49c
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/cmake/taosws_CMakeLists.txt.in b/cmake/taosws_CMakeLists.txt.in
index 54e898ecc0..04b1262caf 100644
--- a/cmake/taosws_CMakeLists.txt.in
+++ b/cmake/taosws_CMakeLists.txt.in
@@ -2,7 +2,7 @@
# taosws-rs
ExternalProject_Add(taosws-rs
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
- GIT_TAG 6fc47d7
+ GIT_TAG e771403
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
BINARY_DIR ""
#BUILD_IN_SOURCE TRUE
diff --git a/docs/en/04-concept/index.md b/docs/en/04-concept/index.md
index b0a0c25d85..0b1b226c17 100644
--- a/docs/en/04-concept/index.md
+++ b/docs/en/04-concept/index.md
@@ -6,101 +6,100 @@ In order to explain the basic concepts and provide some sample code, the TDengin
-
- Device ID
- Time Stamp
- Collected Metrics
- Tags
+
+
+ Device ID
+ Timestamp
+ Collected Metrics
+ Tags
-
-Device ID
-Time Stamp
-current
-voltage
-phase
-location
-groupId
-
-
-
-
-d1001
-1538548685000
-10.3
-219
-0.31
-California.SanFrancisco
-2
-
-
-d1002
-1538548684000
-10.2
-220
-0.23
-California.SanFrancisco
-3
-
-
-d1003
-1538548686500
-11.5
-221
-0.35
-California.LosAngeles
-3
-
-
-d1004
-1538548685500
-13.4
-223
-0.29
-California.LosAngeles
-2
-
-
-d1001
-1538548695000
-12.6
-218
-0.33
-California.SanFrancisco
-2
-
-
-d1004
-1538548696600
-11.8
-221
-0.28
-California.LosAngeles
-2
-
-
-d1002
-1538548696650
-10.3
-218
-0.25
-California.SanFrancisco
-3
-
-
-d1001
-1538548696800
-12.3
-221
-0.31
-California.SanFrancisco
-2
-
-
+
+ current
+ voltage
+ phase
+ location
+ groupid
+
+
+
+
+ d1001
+ 1538548685000
+ 10.3
+ 219
+ 0.31
+ California.SanFrancisco
+ 2
+
+
+ d1002
+ 1538548684000
+ 10.2
+ 220
+ 0.23
+ California.SanFrancisco
+ 3
+
+
+ d1003
+ 1538548686500
+ 11.5
+ 221
+ 0.35
+ California.LosAngeles
+ 3
+
+
+ d1004
+ 1538548685500
+ 13.4
+ 223
+ 0.29
+ California.LosAngeles
+ 2
+
+
+ d1001
+ 1538548695000
+ 12.6
+ 218
+ 0.33
+ California.SanFrancisco
+ 2
+
+
+ d1004
+ 1538548696600
+ 11.8
+ 221
+ 0.28
+ California.LosAngeles
+ 2
+
+
+ d1002
+ 1538548696650
+ 10.3
+ 218
+ 0.25
+ California.SanFrancisco
+ 3
+
+
+ d1001
+ 1538548696800
+ 12.3
+ 221
+ 0.31
+ California.SanFrancisco
+ 2
+
+
Table 1: Smart meter example data
-Each row contains the device ID, time stamp, collected metrics (current, voltage, phase as above), and static tags (location and groupId in Table 1) associated with the devices. Each smart meter generates a row (measurement) in a pre-defined time interval or triggered by an external event. The device produces a sequence of measurements with associated time stamps.
+Each row contains the device ID, timestamp, collected metrics (`current`, `voltage`, `phase` as above), and static tags (`location` and `groupid` in Table 1) associated with the devices. Each smart meter generates a row (measurement) in a pre-defined time interval or triggered by an external event. The device produces a sequence of measurements with associated timestamps.
## Metric
@@ -112,22 +111,22 @@ Label/Tag refers to the static properties of sensors, equipment or other types o
## Data Collection Point
-Data Collection Point (DCP) refers to hardware or software that collects metrics based on preset time periods or triggered by events. A data collection point can collect one or multiple metrics, but these metrics are collected at the same time and have the same time stamp. For some complex equipment, there are often multiple data collection points, and the sampling rate of each collection point may be different, and fully independent. For example, for a car, there could be a data collection point to collect GPS position metrics, a data collection point to collect engine status metrics, and a data collection point to collect the environment metrics inside the car. So in this example the car would have three data collection points. In the smart meters example, d1001, d1002, d1003, and d1004 are the data collection points.
+Data Collection Point (DCP) refers to hardware or software that collects metrics based on preset time periods or triggered by events. A data collection point can collect one or multiple metrics, but these metrics are collected at the same time and have the same timestamp. For some complex equipment, there are often multiple data collection points, and the sampling rate of each collection point may be different, and fully independent. For example, for a car, there could be a data collection point to collect GPS position metrics, a data collection point to collect engine status metrics, and a data collection point to collect the environment metrics inside the car. So in this example the car would have three data collection points. In the smart meters example, d1001, d1002, d1003, and d1004 are the data collection points.
## Table
Since time-series data is most likely to be structured data, TDengine adopts the traditional relational database model to process them with a short learning curve. You need to create a database, create tables, then insert data points and execute queries to explore the data.
-To make full use of time-series data characteristics, TDengine adopts a strategy of "**One Table for One Data Collection Point**". TDengine requires the user to create a table for each data collection point (DCP) to store collected time-series data. For example, if there are over 10 million smart meters, it means 10 million tables should be created. For the table above, 4 tables should be created for devices D1001, D1002, D1003, and D1004 to store the data collected. This design has several benefits:
+To make full use of time-series data characteristics, TDengine adopts a strategy of "**One Table for One Data Collection Point**". TDengine requires the user to create a table for each data collection point (DCP) to store collected time-series data. For example, if there are over 10 million smart meters, it means 10 million tables should be created. For the table above, 4 tables should be created for devices d1001, d1002, d1003, and d1004 to store the data collected. This design has several benefits:
1. Since the metric data from different DCP are fully independent, the data source of each DCP is unique, and a table has only one writer. In this way, data points can be written in a lock-free manner, and the writing speed can be greatly improved.
2. For a DCP, the metric data generated by DCP is ordered by timestamp, so the write operation can be implemented by simple appending, which further greatly improves the data writing speed.
3. The metric data from a DCP is continuously stored, block by block. If you read data for a period of time, it can greatly reduce random read operations and improve read and query performance by orders of magnitude.
4. Inside a data block for a DCP, columnar storage is used, and different compression algorithms are used for different data types. Metrics generally don't vary as significantly between themselves over a time range as compared to other metrics, which allows for a higher compression rate.
-If the metric data of multiple DCPs are traditionally written into a single table, due to uncontrollable network delays, the timing of the data from different DCPs arriving at the server cannot be guaranteed, write operations must be protected by locks, and metric data from one DCP cannot be guaranteed to be continuously stored together. ** One table for one data collection point can ensure the best performance of insert and query of a single data collection point to the greatest possible extent.**
+If the metric data of multiple DCPs are traditionally written into a single table, due to uncontrollable network delays, the timing of the data from different DCPs arriving at the server cannot be guaranteed, write operations must be protected by locks, and metric data from one DCP cannot be guaranteed to be continuously stored together. **One table for one data collection point can ensure the best performance of insert and query of a single data collection point to the greatest possible extent.**
-TDengine suggests using DCP ID as the table name (like D1001 in the above table). Each DCP may collect one or multiple metrics (like the current, voltage, phase as above). Each metric has a corresponding column in the table. The data type for a column can be int, float, string and others. In addition, the first column in the table must be a timestamp. TDengine uses the time stamp as the index, and won’t build the index on any metrics stored. Column wise storage is used.
+TDengine suggests using DCP ID as the table name (like d1001 in the above table). Each DCP may collect one or multiple metrics (like the `current`, `voltage`, `phase` as above). Each metric has a corresponding column in the table. The data type for a column can be int, float, string and others. In addition, the first column in the table must be a timestamp. TDengine uses the timestamp as the index, and won’t build the index on any metrics stored. Column wise storage is used.
Complex devices, such as connected cars, may have multiple DCPs. In this case, multiple tables are created for a single device, one table per DCP.
@@ -156,9 +155,16 @@ The relationship between a STable and the subtables created based on this STable
Queries can be executed on both a table (subtable) and a STable. For a query on a STable, TDengine will treat the data in all its subtables as a whole data set for processing. TDengine will first find the subtables that meet the tag filter conditions, then scan the time-series data of these subtables to perform aggregation operation, which reduces the number of data sets to be scanned which in turn greatly improves the performance of data aggregation across multiple DCPs. In essence, querying a supertable is a very efficient aggregate query on multiple DCPs of the same type.
-In TDengine, it is recommended to use a subtable instead of a regular table for a DCP. In the smart meters example, we can create subtables like d1001, d1002, d1003, and d1004 under super table meters.
+In TDengine, it is recommended to use a subtable instead of a regular table for a DCP. In the smart meters example, we can create subtables like d1001, d1002, d1003, and d1004 under super table `meters`.
-To better understand the data model using metri, tags, super table and subtable, please refer to the diagram below which demonstrates the data model of the smart meters example. 
+To better understand the data model using metrics, tags, super table and subtable, please refer to the diagram below which demonstrates the data model of the smart meters example.
+
+
+
+
+
+Figure 1. Meters Data Model Diagram
+
## Database
@@ -172,4 +178,4 @@ FQDN (Fully Qualified Domain Name) is the full domain name of a specific compute
Each node of a TDengine cluster is uniquely identified by an End Point, which consists of an FQDN and a Port, such as h1.tdengine.com:6030. In this way, when the IP changes, we can still use the FQDN to dynamically find the node without changing any configuration of the cluster. In addition, FQDN is used to facilitate unified access to the same cluster from the Intranet and the Internet.
-TDengine does not recommend using an IP address to access the cluster. FQDN is recommended for cluster management.
+TDengine does not recommend using an IP address to access the cluster. FQDN is recommended for cluster management.
diff --git a/docs/en/05-get-started/01-docker.md b/docs/en/05-get-started/01-docker.md
index de5b620a77..66f7d5d594 100644
--- a/docs/en/05-get-started/01-docker.md
+++ b/docs/en/05-get-started/01-docker.md
@@ -13,7 +13,7 @@ If Docker is already installed on your computer, run the following command:
docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
```
-Note that TDengine Server uses TCP port 6030. Port 6041 is used by taosAdapter for the REST API service. Ports 6043 through 6049 are used by taosAdapter for other connectors. You can open these ports as needed.
+Note that TDengine Server 3.0 uses TCP port 6030. Port 6041 is used by taosAdapter for the REST API service. Ports 6043 through 6049 are used by taosAdapter for other connectors. You can open these ports as needed.
Run the following command to ensure that your container is running:
@@ -21,7 +21,7 @@ Run the following command to ensure that your container is running:
docker ps
```
-Enter the container and open the bash shell:
+Enter the container and open the `bash` shell:
```shell
docker exec -it bash
@@ -31,68 +31,68 @@ You can now access TDengine or run other Linux commands.
Note: For information about installing docker, see the [official documentation](https://docs.docker.com/get-docker/).
-## Insert Data into TDengine
-
-You can use the `taosBenchmark` tool included with TDengine to write test data into your deployment.
-
-To do so, run the following command:
-
- ```bash
- $ taosBenchmark
-
- ```
-
-This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
-
- The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required depends on the hardware specifications of the local system.
-
- You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](/reference/taosbenchmark).
-
## Open the TDengine CLI
-On the container, run the following command to open the TDengine CLI:
+On the container, run the following command to open the TDengine CLI:
```
$ taos
-taos>
+taos>
```
-## Query Data in TDengine
+## Test data insert performance
-After using taosBenchmark to create your test deployment, you can run queries in the TDengine CLI to test its performance. For example:
+After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
-From the TDengine CLI query the number of rows in the `meters` supertable:
+Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a Linux or Windows terminal.
+
+```bash
+taosBenchmark
+```
+
+This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
+
+The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required to create the deployment depends on your hardware. On most modern servers, the deployment is created in ten to twenty seconds.
+
+You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](../../reference/taosbenchmark).
+
+## Test data query performance
+
+After using `taosBenchmark` to create your test deployment, you can run queries in the TDengine CLI to test its performance:
+
+From the TDengine CLI (taos) query the number of rows in the `meters` supertable:
```sql
-select count(*) from test.meters;
+SELECT COUNT(*) FROM test.meters;
```
Query the average, maximum, and minimum values of all 100 million rows of data:
```sql
-select avg(current), max(voltage), min(phase) from test.meters;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
```
Query the number of rows whose `location` tag is `San Francisco`:
```sql
-select count(*) from test.meters where location="San Francisco";
+SELECT COUNT(*) FROM test.meters WHERE location = "San Francisco";
```
Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
```sql
-select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
```
-Query the average, maximum, and minimum values for table `d10` in 1 second intervals:
+Query the average, maximum, and minimum values for table `d10` in 10 second intervals:
```sql
-select first(ts), avg(current), max(voltage), min(phase) from test.d10 interval(1s);
+SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
```
-In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be _wstart which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
+
+In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be `\_wstart` which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
## Additional Information
diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md
index 88096a759c..7257fccc80 100644
--- a/docs/en/05-get-started/03-package.md
+++ b/docs/en/05-get-started/03-package.md
@@ -9,23 +9,24 @@ import PkgListV3 from "/components/PkgListV3";
For information about installing TDengine on Docker, see [Quick Install on Docker](../../get-started/docker). If you want to view the source code, build TDengine yourself, or contribute to the project, see the [TDengine GitHub repository](https://github.com/taosdata/TDengine).
-The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface, and some tools. Note that taosAdapter supports Linux only. In addition to connectors for multiple languages, TDengine also provides a [REST API](../../reference/rest-api) through [taosAdapter](../../reference/taosadapter).
+The full package of TDengine includes the TDengine Server (`taosd`), TDengine Client (`taosc`), taosAdapter for connecting with third-party systems and providing a RESTful interface, a command-line interface (CLI, taos), and some tools. Note that taosAdapter supports Linux only. In addition to connectors for multiple languages, TDengine also provides a [REST API](../../reference/rest-api) through [taosAdapter](../../reference/taosadapter).
-The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download a lite package that includes only `taosd` and the C/C++ connector.
+The standard server installation package includes `taos`, `taosd`, `taosAdapter`, `taosBenchmark`, and sample code. You can also download the Lite package that includes only `taosd` and the C/C++ connector.
-The TDengine Community Edition is released as .deb and .rpm packages. The .deb package can be installed on Debian, Ubuntu, and derivative systems. The .rpm package can be installed on CentOS, RHEL, SUSE, and derivative systems. A .tar.gz package is also provided for enterprise customers, and you can install TDengine over `apt-get` as well. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the .deb or .rpm package, download and install taosTools separately. TDengine can also be installed on 64-bit Windows servers.
+The TDengine Community Edition is released as Deb and RPM packages. The Deb package can be installed on Debian, Ubuntu, and derivative systems. The RPM package can be installed on CentOS, RHEL, SUSE, and derivative systems. A .tar.gz package is also provided for enterprise customers, and you can install TDengine over `apt-get` as well. The .tar.tz package includes `taosdump` and the TDinsight installation script. If you want to use these utilities with the Deb or RPM package, download and install taosTools separately. TDengine can also be installed on 64-bit Windows.
## Installation
-1. Download the .deb installation package.
-
+1. Download the Deb installation package.
+
2. In the directory where the package is located, use `dpkg` to install the package:
+> Please replace `` with the corresponding version of the package downloaded
+
```bash
-# Enter the name of the package that you downloaded.
sudo dpkg -i TDengine-server--Linux-x64.deb
```
@@ -34,11 +35,12 @@ sudo dpkg -i TDengine-server--Linux-x64.deb
1. Download the .rpm installation package.
-
+
2. In the directory where the package is located, use rpm to install the package:
+> Please replace `` with the corresponding version of the package downloaded
+
```bash
-# Enter the name of the package that you downloaded.
sudo rpm -ivh TDengine-server--Linux-x64.rpm
```
@@ -47,11 +49,12 @@ sudo rpm -ivh TDengine-server--Linux-x64.rpm
1. Download the .tar.gz installation package.
-
+
2. In the directory where the package is located, use `tar` to decompress the package:
+> Please replace `` with the corresponding version of the package downloaded
+
```bash
-# Enter the name of the package that you downloaded.
tar -zxvf TDengine-server--Linux-x64.tar.gz
```
@@ -96,23 +99,23 @@ sudo apt-get install tdengine
This installation method is supported only for Debian and Ubuntu.
::::
-
+
-Note: TDengine only supports Windows Server 2016/2019 and windows 10/11 system versions on the windows platform.
+Note: TDengine only supports Windows Server 2016/2019 and Windows 10/11 on the Windows platform.
1. Download the Windows installation package.
-
+
2. Run the downloaded package to install TDengine.
:::info
-For information about TDengine releases, see [Release History](../../releases).
+For information about TDengine releases, see [Release History](../../releases).
:::
:::note
-On the first node in your TDengine cluster, leave the `Enter FQDN:` prompt blank and press **Enter**. On subsequent nodes, you can enter the end point of the first dnode in the cluster. You can also configure this setting after you have finished installing TDengine.
+On the first node in your TDengine cluster, leave the `Enter FQDN:` prompt blank and press **Enter**. On subsequent nodes, you can enter the endpoint of the first dnode in the cluster. You can also configure this setting after you have finished installing TDengine.
:::
@@ -147,7 +150,7 @@ Active: inactive (dead)
After confirming that TDengine is running, run the `taos` command to access the TDengine CLI.
-The following `systemctl` commands can help you manage TDengine:
+The following `systemctl` commands can help you manage TDengine service:
- Start TDengine Server: `systemctl start taosd`
@@ -159,7 +162,7 @@ The following `systemctl` commands can help you manage TDengine:
:::info
-- The `systemctl` command requires _root_ privileges. If you are not logged in as the `root` user, use the `sudo` command.
+- The `systemctl` command requires _root_ privileges. If you are not logged in as the _root_ user, use the `sudo` command.
- The `systemctl stop taosd` command does not instantly stop TDengine Server. The server is stopped only after all data in memory is flushed to disk. The time required depends on the cache size.
- If your system does not include `systemd`, you can run `/usr/local/taos/bin/taosd` to start TDengine manually.
@@ -174,23 +177,9 @@ After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengin
-## Test data insert performance
+## Command Line Interface (CLI)
-After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
-
-```bash
-taosBenchmark
-```
-
-This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
-
-The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required to create the deployment depends on your hardware. On most modern servers, the deployment is created in less than a minute.
-
-You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](../../reference/taosbenchmark).
-
-## Command Line Interface
-
-You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, run the following command:
+You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in the Linux terminal where TDengine is installed, or you can run `taos.exe` in the `C:\TDengine` directory of the Windows terminal where TDengine is installed to start the TDengine command line.
```bash
taos
@@ -205,52 +194,71 @@ taos>
For example, you can create and delete databases and tables and run all types of queries. Each SQL command must be end with a semicolon (;). For example:
```sql
-create database demo;
-use demo;
-create table t (ts timestamp, speed int);
-insert into t values ('2019-07-15 00:00:00', 10);
-insert into t values ('2019-07-15 01:00:00', 20);
-select * from t;
+CREATE DATABASE demo;
+USE demo;
+CREATE TABLE t (ts TIMESTAMP, speed INT);
+INSERT INTO t VALUES ('2019-07-15 00:00:00', 10);
+INSERT INTO t VALUES ('2019-07-15 01:00:00', 20);
+SELECT * FROM t;
+
ts | speed |
========================================
2019-07-15 00:00:00.000 | 10 |
2019-07-15 01:00:00.000 | 20 |
+
Query OK, 2 row(s) in set (0.003128s)
```
You can also can monitor the deployment status, add and remove user accounts, and manage running instances. You can run the TDengine CLI on either Linux or Windows machines. For more information, see [TDengine CLI](../../reference/taos-shell/).
-
+
+## Test data insert performance
+
+After your TDengine Server is running normally, you can run the taosBenchmark utility to test its performance:
+
+Start TDengine service and execute `taosBenchmark` (formerly named `taosdemo`) in a Linux or Windows terminal.
+
+```bash
+taosBenchmark
+```
+
+This command creates the `meters` supertable in the `test` database. In the `meters` supertable, it then creates 10,000 subtables named `d0` to `d9999`. Each table has 10,000 rows and each row has four columns: `ts`, `current`, `voltage`, and `phase`. The timestamps of the data in these columns range from 2017-07-14 10:40:00 000 to 2017-07-14 10:40:09 999. Each table is randomly assigned a `groupId` tag from 1 to 10 and a `location` tag of either `Campbell`, `Cupertino`, `Los Angeles`, `Mountain View`, `Palo Alto`, `San Diego`, `San Francisco`, `San Jose`, `Santa Clara` or `Sunnyvale`.
+
+The `taosBenchmark` command creates a deployment with 100 million data points that you can use for testing purposes. The time required to create the deployment depends on your hardware. On most modern servers, the deployment is created in ten to twenty seconds.
+
+You can customize the test deployment that taosBenchmark creates by specifying command-line parameters. For information about command-line parameters, run the `taosBenchmark --help` command. For more information about taosBenchmark, see [taosBenchmark](../../reference/taosbenchmark).
+
## Test data query performance
-After using taosBenchmark to create your test deployment, you can run queries in the TDengine CLI to test its performance:
+After using `taosBenchmark` to create your test deployment, you can run queries in the TDengine CLI to test its performance:
-From the TDengine CLI query the number of rows in the `meters` supertable:
+From the TDengine CLI (taos) query the number of rows in the `meters` supertable:
```sql
-select count(*) from test.meters;
+SELECT COUNT(*) FROM test.meters;
```
Query the average, maximum, and minimum values of all 100 million rows of data:
```sql
-select avg(current), max(voltage), min(phase) from test.meters;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
```
Query the number of rows whose `location` tag is `San Francisco`:
```sql
-select count(*) from test.meters where location="San Francisco";
+SELECT COUNT(*) FROM test.meters WHERE location = "San Francisco";
```
Query the average, maximum, and minimum values of all rows whose `groupId` tag is `10`:
```sql
-select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
```
-Query the average, maximum, and minimum values for table `d10` in 1 second intervals:
+Query the average, maximum, and minimum values for table `d10` in 10 second intervals:
```sql
-select first(ts), avg(current), max(voltage), min(phase) from test.d10 interval(1s);
+SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
```
-In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be _wstart which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
+
+In the query above you are selecting the first timestamp (ts) in the interval, another way of selecting this would be `\_wstart` which will give the start of the time window. For more information about windowed queries, see [Time-Series Extensions](../../taos-sql/distinguished/).
diff --git a/docs/examples/csharp/SQLInsertExample.cs b/docs/examples/csharp/SQLInsertExample.cs
index 192ea96d57..3ce70fe914 100644
--- a/docs/examples/csharp/SQLInsertExample.cs
+++ b/docs/examples/csharp/SQLInsertExample.cs
@@ -23,6 +23,7 @@ namespace TDengineExample
CheckRes(conn, res, "failed to insert data");
int affectedRows = TDengine.AffectRows(res);
Console.WriteLine("affectedRows " + affectedRows);
+ TDengine.FreeResult(res);
ExitProgram(conn, 0);
}
diff --git a/docs/zh/02-intro.md b/docs/zh/02-intro.md
index 9a0a6fb547..47bfd3f96b 100644
--- a/docs/zh/02-intro.md
+++ b/docs/zh/02-intro.md
@@ -48,7 +48,7 @@ TDengine 的主要功能如下:
- 多种[数据导出](../operation/export)方式
9. 工具
- 提供[交互式命令行程序(CLI)](../reference/taos-shell),便于管理集群,检查系统状态,做即席查询
- - 提供压力测试工具[taosBenchmark](../reference/taosbenchmark),用于测试 TDengine 的性能
+ - 提供压力测试工具 [taosBenchmark](../reference/taosbenchmark),用于测试 TDengine 的性能
10. 编程
- 提供各种语言的[连接器(Connector)](../connector): 如 [C/C++](../connector/cpp)、[Java](../connector/java)、[Go](../connector/go)、[Node.js](../connector/node)、[Rust](../connector/rust)、[Python](../connector/python)、[C#](../connector/csharp) 等
- 支持 [REST 接口](../connector/rest-api/)
diff --git a/docs/zh/04-concept/index.md b/docs/zh/04-concept/index.md
index 89d3df9c97..2cba68edcd 100644
--- a/docs/zh/04-concept/index.md
+++ b/docs/zh/04-concept/index.md
@@ -4,119 +4,118 @@ title: 数据模型和基本概念
description: TDengine 的数据模型和基本概念
---
-为了便于解释基本概念,便于撰写示例程序,整个 TDengine 文档以智能电表作为典型时序数据场景。假设每个智能电表采集电流、电压、相位三个量,有多个智能电表,每个电表有位置 location 和分组 group ID 的静态属性. 其采集的数据类似如下的表格:
+为了便于解释基本概念,便于撰写示例程序,整个 TDengine 文档以智能电表作为典型时序数据场景。假设每个智能电表采集电流、电压、相位三个量,有多个智能电表,每个电表有位置 Location 和分组 Group ID 的静态属性. 其采集的数据类似如下的表格:
-
- Device ID
- Time Stamp
- Collected Metrics
- Tags
+
+
+ Device ID
+ Timestamp
+ Collected Metrics
+ Tags
-
-Device ID
-Time Stamp
-current
-voltage
-phase
-location
-groupId
-
-
-
-
-d1001
-1538548685000
-10.3
-219
-0.31
-California.SanFrancisco
-2
-
-
-d1002
-1538548684000
-10.2
-220
-0.23
-California.SanFrancisco
-3
-
-
-d1003
-1538548686500
-11.5
-221
-0.35
-California.LosAngeles
-3
-
-
-d1004
-1538548685500
-13.4
-223
-0.29
-California.LosAngeles
-2
-
-
-d1001
-1538548695000
-12.6
-218
-0.33
-California.SanFrancisco
-2
-
-
-d1004
-1538548696600
-11.8
-221
-0.28
-California.LosAngeles
-2
-
-
-d1002
-1538548696650
-10.3
-218
-0.25
-California.SanFrancisco
-3
-
-
-d1001
-1538548696800
-12.3
-221
-0.31
-California.SanFrancisco
-2
-
-
+
+ current
+ voltage
+ phase
+ location
+ groupid
+
+
+
+
+ d1001
+ 1538548685000
+ 10.3
+ 219
+ 0.31
+ California.SanFrancisco
+ 2
+
+
+ d1002
+ 1538548684000
+ 10.2
+ 220
+ 0.23
+ California.SanFrancisco
+ 3
+
+
+ d1003
+ 1538548686500
+ 11.5
+ 221
+ 0.35
+ California.LosAngeles
+ 3
+
+
+ d1004
+ 1538548685500
+ 13.4
+ 223
+ 0.29
+ California.LosAngeles
+ 2
+
+
+ d1001
+ 1538548695000
+ 12.6
+ 218
+ 0.33
+ California.SanFrancisco
+ 2
+
+
+ d1004
+ 1538548696600
+ 11.8
+ 221
+ 0.28
+ California.LosAngeles
+ 2
+
+
+ d1002
+ 1538548696650
+ 10.3
+ 218
+ 0.25
+ California.SanFrancisco
+ 3
+
+
+ d1001
+ 1538548696800
+ 12.3
+ 221
+ 0.31
+ California.SanFrancisco
+ 2
+
+
-
表 1:智能电表数据示例
+
表 1. 智能电表数据示例
-每一条记录都有设备 ID,时间戳,采集的物理量以及每个设备相关的静态标签。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。
+每一条记录都有设备 ID、时间戳、采集的物理量(如上表中的 `current`、`voltage` 和 `phase`)以及每个设备相关的静态标签(`location` 和 `groupid`)。每个设备是受外界的触发,或按照设定的周期采集数据。采集的数据点是时序的,是一个数据流。
-## 采集量 (Metric)
+## 采集量(Metric)
采集量是指传感器、设备或其他类型采集点采集的物理量,比如电流、电压、温度、压力、GPS 位置等,是随时间变化的,数据类型可以是整型、浮点型、布尔型,也可是字符串。随着时间的推移,存储的采集量的数据量越来越大。智能电表示例中的电流、电压、相位就是采集量。
-## 标签 (Label/Tag)
+## 标签(Label/Tag)
-标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但 TDengine 容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。智能电表示例中的location与groupId就是标签。
+标签是指传感器、设备或其他类型采集点的静态属性,不是随时间变化的,比如设备型号、颜色、设备的所在地等,数据类型可以是任何类型。虽然是静态的,但 TDengine 容许用户修改、删除或增加标签值。与采集量不一样的是,随时间的推移,存储的标签的数据量不会有什么变化。智能电表示例中的 `location` 与 `groupid` 就是标签。
-## 数据采集点 (Data Collection Point)
+## 数据采集点(Data Collection Point)
-数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个采集量,**但这些采集量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个数据采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集 GPS 位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。智能电表示例中的d1001, d1002, d1003, d1004等就是数据采集点。
+数据采集点是指按照预设时间周期或受事件触发采集物理量的硬件或软件。一个数据采集点可以采集一个或多个采集量,**但这些采集量都是同一时刻采集的,具有相同的时间戳**。对于复杂的设备,往往有多个数据采集点,每个数据采集点采集的周期都可能不一样,而且完全独立,不同步。比如对于一台汽车,有数据采集点专门采集 GPS 位置,有数据采集点专门采集发动机状态,有数据采集点专门采集车内的环境,这样一台汽车就有三个数据采集点。智能电表示例中的 d1001、d1002、d1003、d1004 等就是数据采集点。
-## 表 (Table)
+## 表(Table)
因为采集量一般是结构化数据,同时为降低学习门槛,TDengine 采用传统的关系型数据库模型管理数据。用户需要先创建库,然后创建表,之后才能插入或查询数据。
@@ -129,50 +128,56 @@ description: TDengine 的数据模型和基本概念
如果采用传统的方式,将多个数据采集点的数据写入一张表,由于网络延时不可控,不同数据采集点的数据到达服务器的时序是无法保证的,写入操作是要有锁保护的,而且一个数据采集点的数据是难以保证连续存储在一起的。**采用一个数据采集点一张表的方式,能最大程度的保证单个数据采集点的插入和查询的性能是最优的。**
-TDengine 建议用数据采集点的名字(如上表中的 D1001)来做表名。每个数据采集点可能同时采集多个采集量(如上表中的 current,voltage,phase),每个采集量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 timestamp。对采集量,TDengine 将自动按照时间戳建立索引,但对采集量本身不建任何索引。数据用列式存储方式保存。
+TDengine 建议用数据采集点的名字(如上表中的 d1001)来做表名。每个数据采集点可能同时采集多个采集量(如上表中的 `current`、`voltage` 和 `phase`),每个采集量对应一张表中的一列,数据类型可以是整型、浮点型、字符串等。除此之外,表的第一列必须是时间戳,即数据类型为 Timestamp。对采集量,TDengine 将自动按照时间戳建立索引,但对采集量本身不建任何索引。数据用列式存储方式保存。
-对于复杂的设备,比如汽车,它有多个数据采集点,那么就需要为一台汽车建立多张表。
+对于复杂的设备,比如汽车,它有多个数据采集点,那么就需要为一辆汽车建立多张表。
-
-## 超级表 (STable)
+## 超级表(STable)
由于一个数据采集点一张表,导致表的数量巨增,难以管理,而且应用经常需要做采集点之间的聚合操作,聚合的操作也变得复杂起来。为解决这个问题,TDengine 引入超级表(Super Table,简称为 STable)的概念。
-超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 schema,标签的数据类型可以是整数、浮点数、字符串,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。
+超级表是指某一特定类型的数据采集点的集合。同一类型的数据采集点,其表的结构是完全一样的,但每个表(数据采集点)的静态属性(标签)是不一样的。描述一个超级表(某一特定类型的数据采集点的集合),除需要定义采集量的表结构之外,还需要定义其标签的 Schema,标签的数据类型可以是整数、浮点数、字符串、JSON,标签可以有多个,可以事后增加、删除或修改。如果整个系统有 N 个不同类型的数据采集点,就需要建立 N 个超级表。
-在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。智能电表示例中,我们可以创建一个超级表meters.
+在 TDengine 的设计里,**表用来代表一个具体的数据采集点,超级表用来代表一组相同类型的数据采集点集合**。智能电表示例中,我们可以创建一个超级表 `meters`.
-## 子表 (Subtable)
+## 子表(Subtable)
当为某个具体数据采集点创建表时,用户可以使用超级表的定义做模板,同时指定该具体采集点(表)的具体标签值来创建该表。**通过超级表创建的表称之为子表**。正常的表与子表的差异在于:
-1. 子表就是表,因此所有正常表的SQL操作都可以在子表上执行。
+1. 子表就是表,因此所有正常表的 SQL 操作都可以在子表上执行。
2. 子表在正常表的基础上有扩展,它是带有静态标签的,而且这些标签可以事后增加、删除、修改,而正常的表没有。
3. 子表一定属于一张超级表,但普通表不属于任何超级表
4. 普通表无法转为子表,子表也无法转为普通表。
超级表与与基于超级表建立的子表之间的关系表现在:
-1. 一张超级表包含有多张子表,这些子表具有相同的采集量 schema,但带有不同的标签值。
+1. 一张超级表包含有多张子表,这些子表具有相同的采集量 Schema,但带有不同的标签值。
2. 不能通过子表调整数据或标签的模式,对于超级表的数据模式修改立即对所有的子表生效。
3. 超级表只定义一个模板,自身不存储任何数据或标签信息。因此,不能向一个超级表写入数据,只能将数据写入子表中。
查询既可以在表上进行,也可以在超级表上进行。针对超级表的查询,TDengine 将把所有子表中的数据视为一个整体数据集进行处理,会先把满足标签过滤条件的表从超级表中找出来,然后再扫描这些表的时序数据,进行聚合操作,这样需要扫描的数据集会大幅减少,从而显著提高查询的性能。本质上,TDengine 通过对超级表查询的支持,实现了多个同类数据采集点的高效聚合。
-TDengine系统建议给一个数据采集点建表,需要通过超级表建表,而不是建普通表。在智能电表的示例中,我们可以通过超级表meters创建子表d1001, d1002, d1003, d1004等。
+TDengine 系统建议给一个数据采集点建表,需要通过超级表建表,而不是建普通表。在智能电表的示例中,我们可以通过超级表 meters 创建子表 d1001、d1002、d1003、d1004 等。
-为了更好地理解超级与子表的关系,可以参考下面关于智能电表数据模型的示意图。 
+为了更好地理解采集量、标签、超级与子表的关系,可以参考下面关于智能电表数据模型的示意图。
-## 库 (database)
+
+
+
+
+图 1. 智能电表数据模型示意图
+
+
+## 库(Database)
库是指一组表的集合。TDengine 容许一个运行实例有多个库,而且每个库可以配置不同的存储策略。不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的超级表创建在不同的库里。
一个库里,可以有一到多个超级表,但一个超级表只属于一个库。一个超级表所拥有的子表全部存在一个库里。
-## FQDN & End Point
+## FQDN & Endpoint
-FQDN (fully qualified domain name, 完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN 由两部分组成:主机名和域名。例如,假设邮件服务器的 FQDN 可能是 mail.tdengine.com。主机名是 mail,主机位于域名 tdengine.com 中。DNS(Domain Name System),负责将 FQDN 翻译成 IP,是互联网应用的寻址方式。对于没有 DNS 的系统,可以通过配置 hosts 文件来解决。
+FQDN(Fully Qualified Domain Name,完全限定域名)是 Internet 上特定计算机或主机的完整域名。FQDN 由两部分组成:主机名和域名。例如,假设邮件服务器的 FQDN 可能是 mail.tdengine.com。主机名是 mail,主机位于域名 tdengine.com 中。DNS(Domain Name System),负责将 FQDN 翻译成 IP,是互联网应用的寻址方式。对于没有 DNS 的系统,可以通过配置 hosts 文件来解决。
-TDengine 集群的每个节点是由 End Point 来唯一标识的,End Point 是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当 IP 发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。
+TDengine 集群的每个节点是由 Endpoint 来唯一标识的,Endpoint 是由 FQDN 外加 Port 组成,比如 h1.tdengine.com:6030。这样当 IP 发生变化的时候,我们依然可以使用 FQDN 来动态找到节点,不需要更改集群的任何配置。而且采用 FQDN,便于内网和外网对同一个集群的统一访问。
TDengine 不建议采用直接的 IP 地址访问集群,不利于管理。不了解 FQDN 概念,请看博文[《一篇文章说清楚 TDengine 的 FQDN》](https://www.taosdata.com/blog/2020/09/11/1824.html)。
diff --git a/docs/zh/05-get-started/01-docker.md b/docs/zh/05-get-started/01-docker.md
index e2be419517..e3345fed96 100644
--- a/docs/zh/05-get-started/01-docker.md
+++ b/docs/zh/05-get-started/01-docker.md
@@ -4,11 +4,11 @@ title: 通过 Docker 快速体验 TDengine
description: 使用 Docker 快速体验 TDengine 的高效写入和查询
---
-本节首先介绍如何通过 Docker 快速体验 TDengine,然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。如果你不熟悉 Docker,请使用[安装包的方式快速体验](../../get-started/package/)。如果您希望为 TDengine 贡献代码或对内部技术实现感兴趣,请参考 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
+本节首先介绍如何通过 Docker 快速体验 TDengine,然后介绍如何在 Docker 环境下体验 TDengine 的写入和查询功能。如果你不熟悉 Docker,请使用[安装包的方式快速体验](../../get-started/package/)。如果您希望为 TDengine 贡献代码或对内部技术实现感兴趣,请参考 [TDengine GitHub 主页](https://github.com/taosdata/TDengine)下载源码构建和安装。
## 启动 TDengine
-如果已经安装了 docker, 只需执行下面的命令。
+如果已经安装了 Docker,只需执行下面的命令:
```shell
docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043-6049/udp tdengine/tdengine
@@ -16,84 +16,84 @@ docker run -d -p 6030:6030 -p 6041:6041 -p 6043-6049:6043-6049 -p 6043-6049:6043
注意:TDengine 3.0 服务端仅使用 6030 TCP 端口。6041 为 taosAdapter 所使用提供 REST 服务端口。6043-6049 为 taosAdapter 提供第三方应用接入所使用端口,可根据需要选择是否打开。
-确定该容器已经启动并且在正常运行
+确定该容器已经启动并且在正常运行。
```shell
docker ps
```
-进入该容器并执行 bash
+进入该容器并执行 `bash`
```shell
docker exec -it bash
```
-然后就可以执行相关的 Linux 命令操作和访问 TDengine
+然后就可以执行相关的 Linux 命令操作和访问 TDengine。
-注: Docker 工具自身的下载和使用请参考 [Docker 官网文档](https://docs.docker.com/get-docker/)。
+注:Docker 工具自身的下载和使用请参考 [Docker 官网文档](https://docs.docker.com/get-docker/)。
## 运行 TDengine CLI
-进入容器,执行 taos
+进入容器,执行 `taos`:
```
$ taos
-taos>
-
+taos>
```
-## 写入数据
+## 使用 taosBenchmark 体验写入速度
-可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入。
+可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。
-进入容器,启动 taosBenchmark:
+启动 TDengine 的服务,在 Linux 或 Windows 终端执行 `taosBenchmark`(曾命名为 `taosdemo`):
- ```bash
- $ taosBenchmark
-
- ```
+```bash
+$ taosBenchmark
+```
- 该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "San Francisco" 或者 "Los Angeles"等城市名称。
+该命令将在数据库 `test` 下面自动创建一张超级表 `meters`,该超级表下有 1 万张表,表名为 `d0` 到 `d9999`,每张表有 1 万条记录,每条记录有 `ts`、`current`、`voltage`、`phase` 四个字段,时间戳从 2017-07-14 10:40:00 000 到 2017-07-14 10:40:09 999,每张表带有标签 `location` 和 `groupId`,groupId 被设置为 1 到 10,location 被设置为 `Campbell`、`Cupertino`、`Los Angeles`、`Mountain View`、`Palo Alto`、`San Diego`、`San Francisco`、`San Jose`、`Santa Clara` 或者 `Sunnyvale`。
- 这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能。
+这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
- taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [taosBenchmark 参考手册](../../reference/taosbenchmark)。
+taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照[如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)和 [taosBenchmark 参考手册](../../reference/taosbenchmark)。
-## 体验查询
+## 使用 TDengine CLI 体验查询速度
-使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。。
+使用上述 `taosBenchmark` 插入数据后,可以在 TDengine CLI(taos)输入查询命令,体验查询速度。
-查询超级表下记录总条数:
+查询超级表 `meters` 下的记录总条数:
```sql
-taos> select count(*) from test.meters;
+SELECT COUNT(*) FROM test.meters;
```
查询 1 亿条记录的平均值、最大值、最小值等:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
```
-查询 location="San Francisco" 的记录总条数:
+查询 location = "San Francisco" 的记录总条数:
```sql
-taos> select count(*) from test.meters where location="San Francisco";
+SELECT COUNT(*) FROM test.meters WHERE location = "San Francisco";
```
-查询 groupId=10 的所有记录的平均值、最大值、最小值等:
+查询 groupId = 10 的所有记录的平均值、最大值、最小值等:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
```
-对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
+对表 `d10` 按 10 每秒进行平均值、最大值和最小值聚合统计:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
+SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
```
+在上面的查询中,你选择的是区间内的第一个时间戳(ts),另一种选择方式是 `\_wstart`,它将给出时间窗口的开始。关于窗口查询的更多信息,参见[特色查询](../../taos-sql/distinguished/)。
+
## 其它
-更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [在 Docker 下使用 TDengine](../../reference/docker)
+更多关于在 Docker 环境下使用 TDengine 的细节,请参考 [在 Docker 下使用 TDengine](../../reference/docker)。
diff --git a/docs/zh/05-get-started/03-package.md b/docs/zh/05-get-started/03-package.md
index 3e0fb056a5..cb2553a0bf 100644
--- a/docs/zh/05-get-started/03-package.md
+++ b/docs/zh/05-get-started/03-package.md
@@ -10,23 +10,24 @@ import PkgListV3 from "/components/PkgListV3";
您可以[用 Docker 立即体验](../../get-started/docker/) TDengine。如果您希望对 TDengine 贡献代码或对内部实现感兴趣,请参考我们的 [TDengine GitHub 主页](https://github.com/taosdata/TDengine) 下载源码构建和安装.
-TDengine 完整的软件包包括服务端(taosd)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、应用驱动(taosc)、命令行程序 (CLI,taos) 和一些工具软件。目前 taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../../reference/taosadapter/) 提供 [RESTful 接口](../../connector/rest-api/)。
+TDengine 完整的软件包包括服务端(taosd)、应用驱动(taosc)、用于与第三方系统对接并提供 RESTful 接口的 taosAdapter、命令行程序(CLI,taos)和一些工具软件。目前 taosAdapter 仅在 Linux 系统上安装和运行,后续将支持 Windows、macOS 等系统。TDengine 除了提供多种语言的连接器之外,还通过 [taosAdapter](../../reference/taosadapter/) 提供 [RESTful 接口](../../connector/rest-api/)。
-为方便使用,标准的服务端安装包包含了 taosd、taosAdapter、taosc、taos、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 lite 版本的安装包。
+为方便使用,标准的服务端安装包包含了 taosd、taosAdapter、taosc、taos、taosdump、taosBenchmark、TDinsight 安装脚本和示例代码;如果您只需要用到服务端程序和客户端连接的 C/C++ 语言支持,也可以仅下载 Lite 版本的安装包。
-在 Linux 系统上,TDengine 开源版本提供 deb 和 rpm 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 deb 支持 Debian/Ubuntu 及衍生系统,rpm 支持 CentOS/RHEL/SUSE 及衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。需要注意的是,rpm 和 deb 包不含 taosdump 和 TDinsight 安装脚本,这些工具需要通过安装 taosTool 包获得。TDengine 也提供 Windows x64 平台的安装包。
+在 Linux 系统上,TDengine 社区版提供 Deb 和 RPM 格式安装包,用户可以根据自己的运行环境选择合适的安装包。其中 Deb 支持 Debian/Ubuntu 及其衍生系统,RPM 支持 CentOS/RHEL/SUSE 及其衍生系统。同时我们也为企业用户提供 tar.gz 格式安装包,也支持通过 `apt-get` 工具从线上进行安装。需要注意的是,RPM 和 Deb 包不含 `taosdump` 和 TDinsight 安装脚本,这些工具需要通过安装 taosTool 包获得。TDengine 也提供 Windows x64 平台的安装包。
## 安装
-1. 从列表中下载获得 deb 安装包;
-
+1. 从列表中下载获得 Deb 安装包;
+
2. 进入到安装包所在目录,执行如下的安装命令:
+> 请将 `` 替换为下载的安装包版本
+
```bash
-# 替换为下载的安装包版本
sudo dpkg -i TDengine-server--Linux-x64.deb
```
@@ -34,12 +35,13 @@ sudo dpkg -i TDengine-server--Linux-x64.deb
-1. 从列表中下载获得 rpm 安装包;
-
+1. 从列表中下载获得 RPM 安装包;
+
2. 进入到安装包所在目录,执行如下的安装命令:
+> 请将 `` 替换为下载的安装包版本
+
```bash
-# 替换为下载的安装包版本
sudo rpm -ivh TDengine-server--Linux-x64.rpm
```
@@ -48,44 +50,46 @@ sudo rpm -ivh TDengine-server--Linux-x64.rpm
1. 从列表中下载获得 tar.gz 安装包;
-
-2. 进入到安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本:
+
+2. 进入到安装包所在目录,使用 `tar` 解压安装包;
+3. 进入到安装包所在目录,先解压文件后,进入子目录,执行其中的 install.sh 安装脚本。
+
+> 请将 `` 替换为下载的安装包版本
```bash
-# 替换为下载的安装包版本
tar -zxvf TDengine-server--Linux-x64.tar.gz
```
-解压后进入相应路径,执行
+解压文件后,进入相应子目录,执行其中的 `install.sh` 安装脚本:
```bash
sudo ./install.sh
```
:::info
-install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以用 -e no 参数来执行 install.sh 脚本。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
+install.sh 安装脚本在执行过程中,会通过命令行交互界面询问一些配置信息。如果希望采取无交互安装方式,那么可以运行 `./install.sh -e no`。运行 `./install.sh -h` 指令可以查看所有参数的详细说明信息。
:::
-可以使用 apt-get 工具从官方仓库安装。
+可以使用 `apt-get` 工具从官方仓库安装。
-**安装包仓库**
+**配置包仓库**
```bash
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-stable stable main" | sudo tee /etc/apt/sources.list.d/tdengine-stable.list
```
-如果安装 Beta 版需要安装包仓库
+如果安装 Beta 版需要安装包仓库:
```bash
wget -qO - http://repos.taosdata.com/tdengine.key | sudo apt-key add -
echo "deb [arch=amd64] http://repos.taosdata.com/tdengine-beta beta main" | sudo tee /etc/apt/sources.list.d/tdengine-beta.list
```
-**使用 apt-get 命令安装**
+**使用 `apt-get` 命令安装**
```bash
sudo apt-get update
@@ -94,26 +98,26 @@ sudo apt-get install tdengine
```
:::tip
-apt-get 方式只适用于 Debian 或 Ubuntu 系统
+apt-get 方式只适用于 Debian 或 Ubuntu 系统。
::::
-
+
-注意:目前 TDengine 在 Windows 平台上只支持 Windows server 2016/2019 和 Windows 10/11 系统版本。
+注意:目前 TDengine 在 Windows 平台上只支持 Windows Server 2016/2019 和 Windows 10/11。
1. 从列表中下载获得 exe 安装程序;
-
+
2. 运行可执行程序来安装 TDengine。
:::info
-下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](../../releases/tdengine)
+下载其他组件、最新 Beta 版及之前版本的安装包,请点击[发布历史页面](../../releases/tdengine)。
:::
:::note
-当安装第一个节点时,出现 Enter FQDN:提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
+当安装第一个节点时,出现 `Enter FQDN:` 提示的时候,不需要输入任何内容。只有当安装第二个或以后更多的节点时,才需要输入已有集群中任何一个可用节点的 FQDN,支持该新节点加入集群。当然也可以不输入,而是在新节点启动前,配置到新节点的配置文件中。
:::
@@ -148,7 +152,7 @@ Active: inactive (dead)
如果 TDengine 服务正常工作,那么您可以通过 TDengine 的命令行程序 `taos` 来访问并体验 TDengine。
-systemctl 命令汇总:
+如下 `systemctl` 命令可以帮助你管理 TDengine 服务:
- 启动服务进程:`systemctl start taosd`
@@ -160,7 +164,7 @@ systemctl 命令汇总:
:::info
-- systemctl 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 sudo 。
+- `systemctl` 命令需要 _root_ 权限来运行,如果您非 _root_ 用户,请在命令前添加 `sudo`。
- `systemctl stop taosd` 指令在执行后并不会马上停止 TDengine 服务,而是会等待系统中必要的落盘工作正常完成。在数据量很大的情况下,这可能会消耗较长时间。
- 如果系统中不支持 `systemd`,也可以用手动运行 `/usr/local/taos/bin/taosd` 方式启动 TDengine 服务。
@@ -170,87 +174,93 @@ systemctl 命令汇总:
-安装后,在 C:\TDengine 目录下,运行 taosd.exe 来启动 TDengine 服务进程。
+安装后,在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。
-## TDengine 命令行 (CLI)
+## TDengine 命令行(CLI)
-为便于检查 TDengine 的状态,执行数据库 (Database) 的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI) taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可,也可以在安装有 TDengine 的 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。
+为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux 终端执行 `taos` 即可,也可以在安装有 TDengine 的 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。
```bash
taos
```
-如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。 TDengine CLI 的提示符号如下:
+如果连接服务成功,将会打印出欢迎消息和版本信息。如果失败,则会打印错误消息出来(请参考 [FAQ](/train-faq/faq) 来解决终端连接服务端失败的问题)。TDengine CLI 的提示符号如下:
```cmd
taos>
```
-在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(database)插入查询操作。在终端中运行的 SQL 语句需要以分号结束来运行。示例:
+在 TDengine CLI 中,用户可以通过 SQL 命令来创建/删除数据库、表等,并进行数据库(Database)插入查询操作。在终端中运行的 SQL 语句需要以分号(;)结束来运行。示例:
```sql
-create database demo;
-use demo;
-create table t (ts timestamp, speed int);
-insert into t values ('2019-07-15 00:00:00', 10);
-insert into t values ('2019-07-15 01:00:00', 20);
-select * from t;
+CREATE DATABASE demo;
+USE demo;
+CREATE TABLE t (ts TIMESTAMP, speed INT);
+INSERT INTO t VALUES ('2019-07-15 00:00:00', 10);
+INSERT INTO t VALUES ('2019-07-15 01:00:00', 20);
+SELECT * FROM t;
+
ts | speed |
========================================
2019-07-15 00:00:00.000 | 10 |
2019-07-15 01:00:00.000 | 20 |
+
Query OK, 2 row(s) in set (0.003128s)
```
-除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [这里](../../reference/taos-shell/)
+除执行 SQL 语句外,系统管理员还可以从 TDengine CLI 进行检查系统运行状态、添加删除用户账号等操作。TDengine CLI 连同应用驱动也可以独立安装在 Linux 或 Windows 机器上运行,更多细节请参考 [TDengine 命令行](../../reference/taos-shell/)。
## 使用 taosBenchmark 体验写入速度
-启动 TDengine 的服务,在 Linux 或 windows 终端执行 `taosBenchmark` (曾命名为 `taosdemo`):
+可以使用 TDengine 的自带工具 taosBenchmark 快速体验 TDengine 的写入速度。
+
+启动 TDengine 的服务,在 Linux 或 Windows 终端执行 `taosBenchmark`(曾命名为 `taosdemo`):
```bash
-taosBenchmark
+$ taosBenchmark
```
-该命令将在数据库 test 下面自动创建一张超级表 meters,该超级表下有 1 万张表,表名为 "d0" 到 "d9999",每张表有 1 万条记录,每条记录有 (ts, current, voltage, phase) 四个字段,时间戳从 "2017-07-14 10:40:00 000" 到 "2017-07-14 10:40:09 999",每张表带有标签 location 和 groupId,groupId 被设置为 1 到 10, location 被设置为 "California.SanFrancisco" 或者 "California.LosAngeles"。
+该命令将在数据库 `test` 下面自动创建一张超级表 `meters`,该超级表下有 1 万张表,表名为 `d0` 到 `d9999`,每张表有 1 万条记录,每条记录有 `ts`、`current`、`voltage`、`phase` 四个字段,时间戳从 2017-07-14 10:40:00 000 到 2017-07-14 10:40:09 999,每张表带有标签 `location` 和 `groupId`,groupId 被设置为 1 到 10,location 被设置为 `Campbell`、`Cupertino`、`Los Angeles`、`Mountain View`、`Palo Alto`、`San Diego`、`San Francisco`、`San Jose`、`Santa Clara` 或者 `Sunnyvale`。
这条命令很快完成 1 亿条记录的插入。具体时间取决于硬件性能,即使在一台普通的 PC 服务器往往也仅需十几秒。
-taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照 [如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)。
+taosBenchmark 命令本身带有很多选项,配置表的数目、记录条数等等,您可以设置不同参数进行体验,请执行 `taosBenchmark --help` 详细列出。taosBenchmark 详细使用方法请参照[如何使用 taosBenchmark 对 TDengine 进行性能测试](https://www.taosdata.com/2021/10/09/3111.html)和 [taosBenchmark 参考手册](../../reference/taosbenchmark)。
## 使用 TDengine CLI 体验查询速度
-使用上述 taosBenchmark 插入数据后,可以在 TDengine CLI 输入查询命令,体验查询速度。
+使用上述 `taosBenchmark` 插入数据后,可以在 TDengine CLI(taos)输入查询命令,体验查询速度。
-查询超级表下记录总条数:
+查询超级表 `meters` 下的记录总条数:
```sql
-taos> select count(*) from test.meters;
+SELECT COUNT(*) FROM test.meters;
```
查询 1 亿条记录的平均值、最大值、最小值等:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters;
```
-查询 location="California.SanFrancisco" 的记录总条数:
+查询 location = "San Francisco" 的记录总条数:
```sql
-taos> select count(*) from test.meters where location="California.SanFrancisco";
+SELECT COUNT(*) FROM test.meters WHERE location = "San Francisco";
```
-查询 groupId=10 的所有记录的平均值、最大值、最小值等:
+查询 groupId = 10 的所有记录的平均值、最大值、最小值等:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.meters where groupId=10;
+SELECT AVG(current), MAX(voltage), MIN(phase) FROM test.meters WHERE groupId = 10;
```
-对表 d10 按 10s 进行平均值、最大值和最小值聚合统计:
+对表 `d10` 按 10 每秒进行平均值、最大值和最小值聚合统计:
```sql
-taos> select avg(current), max(voltage), min(phase) from test.d10 interval(10s);
+SELECT FIRST(ts), AVG(current), MAX(voltage), MIN(phase) FROM test.d10 INTERVAL(10s);
```
+
+在上面的查询中,你选择的是区间内的第一个时间戳(ts),另一种选择方式是 `\_wstart`,它将给出时间窗口的开始。关于窗口查询的更多信息,参见[特色查询](../../taos-sql/distinguished/)。
diff --git a/docs/zh/07-develop/09-udf.md b/docs/zh/07-develop/09-udf.md
index ef1cd4797a..3239eae49b 100644
--- a/docs/zh/07-develop/09-udf.md
+++ b/docs/zh/07-develop/09-udf.md
@@ -116,7 +116,7 @@ aggfn为函数名的占位符,需要修改为自己的函数名,如l2norm。
参数的具体含义是:
- inputDataBlock: 输入的数据块
- - resultColumn: 输出列。输出列
+ - resultColumn: 输出列
### 聚合接口函数
diff --git a/docs/zh/07-develop/_sub_java.mdx b/docs/zh/07-develop/_sub_java.mdx
index d14b5fd609..e7de158cc8 100644
--- a/docs/zh/07-develop/_sub_java.mdx
+++ b/docs/zh/07-develop/_sub_java.mdx
@@ -1,7 +1,5 @@
```java
{{#include docs/examples/java/src/main/java/com/taos/example/SubscribeDemo.java}}
-{{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}}
-{{#include docs/examples/java/src/main/java/com/taos/example/Meters.java}}
```
```java
{{#include docs/examples/java/src/main/java/com/taos/example/MetersDeserializer.java}}
diff --git a/docs/zh/12-taos-sql/03-table.md b/docs/zh/12-taos-sql/03-table.md
index 2337f2a272..f6790e3c69 100644
--- a/docs/zh/12-taos-sql/03-table.md
+++ b/docs/zh/12-taos-sql/03-table.md
@@ -23,10 +23,7 @@ create_subtable_clause: {
}
create_definition:
- col_name column_definition
-
-column_definition:
- type_name [comment 'string_value']
+ col_name column_type
table_options:
table_option ...
diff --git a/docs/zh/12-taos-sql/20-keywords.md b/docs/zh/12-taos-sql/20-keywords.md
index 92c814067e..09fea45b7a 100644
--- a/docs/zh/12-taos-sql/20-keywords.md
+++ b/docs/zh/12-taos-sql/20-keywords.md
@@ -6,7 +6,8 @@ description: TDengine 保留关键字的详细列表
## 保留关键字
-目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写均不可以用作库名、表名、STable 名、数据列名及标签列名等。这些关键字列表如下:
+目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写如果需要用作库名、表名、STable 名、数据列名及标签列名等,需要使用符合``将关键字括起来使用,例如`ADD`。
+关键字列表如下:
### A
@@ -239,6 +240,7 @@ description: TDengine 保留关键字的详细列表
- TOPICS
- TRIGGER
- TSERIES
+- TTL
### U
diff --git a/docs/zh/28-releases/01-tdengine.md b/docs/zh/28-releases/01-tdengine.md
index e3e1463131..a6ec560d3c 100644
--- a/docs/zh/28-releases/01-tdengine.md
+++ b/docs/zh/28-releases/01-tdengine.md
@@ -6,11 +6,7 @@ description: TDengine 发布历史、Release Notes 及下载链接
import Release from "/components/ReleaseV3";
-## 3.0.0.1
+## 3.0.1.0
-
-
-
+
diff --git a/docs/zh/28-releases/02-tools.md b/docs/zh/28-releases/02-tools.md
index 61129d74e5..9e8757cc4e 100644
--- a/docs/zh/28-releases/02-tools.md
+++ b/docs/zh/28-releases/02-tools.md
@@ -6,6 +6,6 @@ description: taosTools 的发布历史、Release Notes 和下载链接
import Release from "/components/ReleaseV3";
-## 2.1.2
+## 2.1.3
-
\ No newline at end of file
+
diff --git a/include/common/taosdef.h b/include/common/taosdef.h
index 9bfee56e29..bf4de9d4de 100644
--- a/include/common/taosdef.h
+++ b/include/common/taosdef.h
@@ -65,13 +65,6 @@ typedef enum {
TSDB_STATIS_NONE = 1, // statis part not exist
} ETsdbStatisStatus;
-typedef enum {
- TSDB_SMA_STAT_UNKNOWN = -1, // unknown
- TSDB_SMA_STAT_OK = 0, // ready to provide service
- TSDB_SMA_STAT_EXPIRED = 1, // not ready or expired
- TSDB_SMA_STAT_DROPPED = 2, // sma dropped
-} ETsdbSmaStat; // bit operation
-
typedef enum {
TSDB_SMA_TYPE_BLOCK = 0, // Block-wise SMA
TSDB_SMA_TYPE_TIME_RANGE = 1, // Time-range-wise SMA
diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h
index 410fa02ded..73d043b2d0 100644
--- a/include/common/tdatablock.h
+++ b/include/common/tdatablock.h
@@ -184,7 +184,8 @@ static FORCE_INLINE void colDataAppendDouble(SColumnInfoData* pColumnInfoData, u
int32_t getJsonValueLen(const char* data);
int32_t colDataAppend(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, bool isNull);
-int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows);
+int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
+ uint32_t numOfRows);
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
const SColumnInfoData* pSource, int32_t numOfRow2);
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
@@ -225,15 +226,16 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize);
int32_t blockDataTrimFirstNRows(SSDataBlock* pBlock, size_t n);
int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n);
-int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
-int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src);
+int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
+int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src);
SSDataBlock* createDataBlock();
void* blockDataDestroy(SSDataBlock* pBlock);
void blockDataFreeRes(SSDataBlock* pBlock);
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
+SSDataBlock* createSpecialDataBlock(EStreamType type);
-int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
+int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColInfoData);
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index);
@@ -249,7 +251,6 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf);
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlocks, STSchema* pTSchema, int32_t vgId,
tb_uid_t suid);
-
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
static FORCE_INLINE int32_t blockGetEncodeSize(const SSDataBlock* pBlock) {
diff --git a/include/common/tmsg.h b/include/common/tmsg.h
index 879f8c6928..9f919fa250 100644
--- a/include/common/tmsg.h
+++ b/include/common/tmsg.h
@@ -785,6 +785,8 @@ typedef struct {
int32_t walRollPeriod;
int64_t walSegmentSize;
int32_t sstTrigger;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
} SCreateDbReq;
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
@@ -843,6 +845,8 @@ typedef struct {
int64_t uid;
int32_t vgVersion;
int32_t vgNum;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
int8_t hashMethod;
SArray* pVgroupInfos; // Array of SVgroupInfo
} SUseDbRsp;
@@ -1068,6 +1072,7 @@ typedef struct {
typedef struct {
int32_t vgId;
int32_t syncState;
+ int64_t cacheUsage;
int64_t numOfTables;
int64_t numOfTimeSeries;
int64_t totalStorage;
@@ -1193,6 +1198,8 @@ typedef struct {
int32_t walRollPeriod;
int64_t walSegmentSize;
int16_t sstTrigger;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
} SCreateVnodeReq;
int32_t tSerializeSCreateVnodeReq(void* buf, int32_t bufLen, SCreateVnodeReq* pReq);
diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h
index 006ba7f21b..3f917ff0d1 100644
--- a/include/common/tmsgdef.h
+++ b/include/common/tmsgdef.h
@@ -272,6 +272,8 @@ enum {
TD_DEF_MSG_TYPE(TDMT_SYNC_LEADER_TRANSFER, "sync-leader-transfer", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_MNODE_STANDBY, "set-mnode-standby", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL)
+ TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
+ TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
#if defined(TD_MSG_NUMBER_)
diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h
index 5bc0fc82e3..c7cce6a183 100644
--- a/include/common/ttokendef.h
+++ b/include/common/ttokendef.h
@@ -103,224 +103,226 @@
#define TK_WAL_ROLL_PERIOD 85
#define TK_WAL_SEGMENT_SIZE 86
#define TK_SST_TRIGGER 87
-#define TK_NK_COLON 88
-#define TK_TABLE 89
-#define TK_NK_LP 90
-#define TK_NK_RP 91
-#define TK_STABLE 92
-#define TK_ADD 93
-#define TK_COLUMN 94
-#define TK_MODIFY 95
-#define TK_RENAME 96
-#define TK_TAG 97
-#define TK_SET 98
-#define TK_NK_EQ 99
-#define TK_USING 100
-#define TK_TAGS 101
-#define TK_COMMENT 102
-#define TK_BOOL 103
-#define TK_TINYINT 104
-#define TK_SMALLINT 105
-#define TK_INT 106
-#define TK_INTEGER 107
-#define TK_BIGINT 108
-#define TK_FLOAT 109
-#define TK_DOUBLE 110
-#define TK_BINARY 111
-#define TK_TIMESTAMP 112
-#define TK_NCHAR 113
-#define TK_UNSIGNED 114
-#define TK_JSON 115
-#define TK_VARCHAR 116
-#define TK_MEDIUMBLOB 117
-#define TK_BLOB 118
-#define TK_VARBINARY 119
-#define TK_DECIMAL 120
-#define TK_MAX_DELAY 121
-#define TK_WATERMARK 122
-#define TK_ROLLUP 123
-#define TK_TTL 124
-#define TK_SMA 125
-#define TK_FIRST 126
-#define TK_LAST 127
-#define TK_SHOW 128
-#define TK_DATABASES 129
-#define TK_TABLES 130
-#define TK_STABLES 131
-#define TK_MNODES 132
-#define TK_MODULES 133
-#define TK_QNODES 134
-#define TK_FUNCTIONS 135
-#define TK_INDEXES 136
-#define TK_ACCOUNTS 137
-#define TK_APPS 138
-#define TK_CONNECTIONS 139
-#define TK_LICENCES 140
-#define TK_GRANTS 141
-#define TK_QUERIES 142
-#define TK_SCORES 143
-#define TK_TOPICS 144
-#define TK_VARIABLES 145
-#define TK_BNODES 146
-#define TK_SNODES 147
-#define TK_CLUSTER 148
-#define TK_TRANSACTIONS 149
-#define TK_DISTRIBUTED 150
-#define TK_CONSUMERS 151
-#define TK_SUBSCRIPTIONS 152
-#define TK_VNODES 153
-#define TK_LIKE 154
-#define TK_INDEX 155
-#define TK_FUNCTION 156
-#define TK_INTERVAL 157
-#define TK_TOPIC 158
-#define TK_AS 159
-#define TK_WITH 160
-#define TK_META 161
-#define TK_CONSUMER 162
-#define TK_GROUP 163
-#define TK_DESC 164
-#define TK_DESCRIBE 165
-#define TK_RESET 166
-#define TK_QUERY 167
-#define TK_CACHE 168
-#define TK_EXPLAIN 169
-#define TK_ANALYZE 170
-#define TK_VERBOSE 171
-#define TK_NK_BOOL 172
-#define TK_RATIO 173
-#define TK_NK_FLOAT 174
-#define TK_OUTPUTTYPE 175
-#define TK_AGGREGATE 176
-#define TK_BUFSIZE 177
-#define TK_STREAM 178
-#define TK_INTO 179
-#define TK_TRIGGER 180
-#define TK_AT_ONCE 181
-#define TK_WINDOW_CLOSE 182
-#define TK_IGNORE 183
-#define TK_EXPIRED 184
-#define TK_KILL 185
-#define TK_CONNECTION 186
-#define TK_TRANSACTION 187
-#define TK_BALANCE 188
-#define TK_VGROUP 189
-#define TK_MERGE 190
-#define TK_REDISTRIBUTE 191
-#define TK_SPLIT 192
-#define TK_DELETE 193
-#define TK_INSERT 194
-#define TK_NULL 195
-#define TK_NK_QUESTION 196
-#define TK_NK_ARROW 197
-#define TK_ROWTS 198
-#define TK_TBNAME 199
-#define TK_QSTART 200
-#define TK_QEND 201
-#define TK_QDURATION 202
-#define TK_WSTART 203
-#define TK_WEND 204
-#define TK_WDURATION 205
-#define TK_CAST 206
-#define TK_NOW 207
-#define TK_TODAY 208
-#define TK_TIMEZONE 209
-#define TK_CLIENT_VERSION 210
-#define TK_SERVER_VERSION 211
-#define TK_SERVER_STATUS 212
-#define TK_CURRENT_USER 213
-#define TK_COUNT 214
-#define TK_LAST_ROW 215
-#define TK_BETWEEN 216
-#define TK_IS 217
-#define TK_NK_LT 218
-#define TK_NK_GT 219
-#define TK_NK_LE 220
-#define TK_NK_GE 221
-#define TK_NK_NE 222
-#define TK_MATCH 223
-#define TK_NMATCH 224
-#define TK_CONTAINS 225
-#define TK_IN 226
-#define TK_JOIN 227
-#define TK_INNER 228
-#define TK_SELECT 229
-#define TK_DISTINCT 230
-#define TK_WHERE 231
-#define TK_PARTITION 232
-#define TK_BY 233
-#define TK_SESSION 234
-#define TK_STATE_WINDOW 235
-#define TK_SLIDING 236
-#define TK_FILL 237
-#define TK_VALUE 238
-#define TK_NONE 239
-#define TK_PREV 240
-#define TK_LINEAR 241
-#define TK_NEXT 242
-#define TK_HAVING 243
-#define TK_RANGE 244
-#define TK_EVERY 245
-#define TK_ORDER 246
-#define TK_SLIMIT 247
-#define TK_SOFFSET 248
-#define TK_LIMIT 249
-#define TK_OFFSET 250
-#define TK_ASC 251
-#define TK_NULLS 252
-#define TK_ABORT 253
-#define TK_AFTER 254
-#define TK_ATTACH 255
-#define TK_BEFORE 256
-#define TK_BEGIN 257
-#define TK_BITAND 258
-#define TK_BITNOT 259
-#define TK_BITOR 260
-#define TK_BLOCKS 261
-#define TK_CHANGE 262
-#define TK_COMMA 263
-#define TK_COMPACT 264
-#define TK_CONCAT 265
-#define TK_CONFLICT 266
-#define TK_COPY 267
-#define TK_DEFERRED 268
-#define TK_DELIMITERS 269
-#define TK_DETACH 270
-#define TK_DIVIDE 271
-#define TK_DOT 272
-#define TK_EACH 273
-#define TK_END 274
-#define TK_FAIL 275
-#define TK_FILE 276
-#define TK_FOR 277
-#define TK_GLOB 278
-#define TK_ID 279
-#define TK_IMMEDIATE 280
-#define TK_IMPORT 281
-#define TK_INITIALLY 282
-#define TK_INSTEAD 283
-#define TK_ISNULL 284
-#define TK_KEY 285
-#define TK_NK_BITNOT 286
-#define TK_NK_SEMI 287
-#define TK_NOTNULL 288
-#define TK_OF 289
-#define TK_PLUS 290
-#define TK_PRIVILEGE 291
-#define TK_RAISE 292
-#define TK_REPLACE 293
-#define TK_RESTRICT 294
-#define TK_ROW 295
-#define TK_SEMI 296
-#define TK_STAR 297
-#define TK_STATEMENT 298
-#define TK_STRING 299
-#define TK_TIMES 300
-#define TK_UPDATE 301
-#define TK_VALUES 302
-#define TK_VARIABLE 303
-#define TK_VIEW 304
-#define TK_WAL 305
+#define TK_TABLE_PREFIX 88
+#define TK_TABLE_SUFFIX 89
+#define TK_NK_COLON 90
+#define TK_TABLE 91
+#define TK_NK_LP 92
+#define TK_NK_RP 93
+#define TK_STABLE 94
+#define TK_ADD 95
+#define TK_COLUMN 96
+#define TK_MODIFY 97
+#define TK_RENAME 98
+#define TK_TAG 99
+#define TK_SET 100
+#define TK_NK_EQ 101
+#define TK_USING 102
+#define TK_TAGS 103
+#define TK_COMMENT 104
+#define TK_BOOL 105
+#define TK_TINYINT 106
+#define TK_SMALLINT 107
+#define TK_INT 108
+#define TK_INTEGER 109
+#define TK_BIGINT 110
+#define TK_FLOAT 111
+#define TK_DOUBLE 112
+#define TK_BINARY 113
+#define TK_TIMESTAMP 114
+#define TK_NCHAR 115
+#define TK_UNSIGNED 116
+#define TK_JSON 117
+#define TK_VARCHAR 118
+#define TK_MEDIUMBLOB 119
+#define TK_BLOB 120
+#define TK_VARBINARY 121
+#define TK_DECIMAL 122
+#define TK_MAX_DELAY 123
+#define TK_WATERMARK 124
+#define TK_ROLLUP 125
+#define TK_TTL 126
+#define TK_SMA 127
+#define TK_FIRST 128
+#define TK_LAST 129
+#define TK_SHOW 130
+#define TK_DATABASES 131
+#define TK_TABLES 132
+#define TK_STABLES 133
+#define TK_MNODES 134
+#define TK_MODULES 135
+#define TK_QNODES 136
+#define TK_FUNCTIONS 137
+#define TK_INDEXES 138
+#define TK_ACCOUNTS 139
+#define TK_APPS 140
+#define TK_CONNECTIONS 141
+#define TK_LICENCES 142
+#define TK_GRANTS 143
+#define TK_QUERIES 144
+#define TK_SCORES 145
+#define TK_TOPICS 146
+#define TK_VARIABLES 147
+#define TK_BNODES 148
+#define TK_SNODES 149
+#define TK_CLUSTER 150
+#define TK_TRANSACTIONS 151
+#define TK_DISTRIBUTED 152
+#define TK_CONSUMERS 153
+#define TK_SUBSCRIPTIONS 154
+#define TK_VNODES 155
+#define TK_LIKE 156
+#define TK_INDEX 157
+#define TK_FUNCTION 158
+#define TK_INTERVAL 159
+#define TK_TOPIC 160
+#define TK_AS 161
+#define TK_WITH 162
+#define TK_META 163
+#define TK_CONSUMER 164
+#define TK_GROUP 165
+#define TK_DESC 166
+#define TK_DESCRIBE 167
+#define TK_RESET 168
+#define TK_QUERY 169
+#define TK_CACHE 170
+#define TK_EXPLAIN 171
+#define TK_ANALYZE 172
+#define TK_VERBOSE 173
+#define TK_NK_BOOL 174
+#define TK_RATIO 175
+#define TK_NK_FLOAT 176
+#define TK_OUTPUTTYPE 177
+#define TK_AGGREGATE 178
+#define TK_BUFSIZE 179
+#define TK_STREAM 180
+#define TK_INTO 181
+#define TK_TRIGGER 182
+#define TK_AT_ONCE 183
+#define TK_WINDOW_CLOSE 184
+#define TK_IGNORE 185
+#define TK_EXPIRED 186
+#define TK_KILL 187
+#define TK_CONNECTION 188
+#define TK_TRANSACTION 189
+#define TK_BALANCE 190
+#define TK_VGROUP 191
+#define TK_MERGE 192
+#define TK_REDISTRIBUTE 193
+#define TK_SPLIT 194
+#define TK_DELETE 195
+#define TK_INSERT 196
+#define TK_NULL 197
+#define TK_NK_QUESTION 198
+#define TK_NK_ARROW 199
+#define TK_ROWTS 200
+#define TK_TBNAME 201
+#define TK_QSTART 202
+#define TK_QEND 203
+#define TK_QDURATION 204
+#define TK_WSTART 205
+#define TK_WEND 206
+#define TK_WDURATION 207
+#define TK_CAST 208
+#define TK_NOW 209
+#define TK_TODAY 210
+#define TK_TIMEZONE 211
+#define TK_CLIENT_VERSION 212
+#define TK_SERVER_VERSION 213
+#define TK_SERVER_STATUS 214
+#define TK_CURRENT_USER 215
+#define TK_COUNT 216
+#define TK_LAST_ROW 217
+#define TK_BETWEEN 218
+#define TK_IS 219
+#define TK_NK_LT 220
+#define TK_NK_GT 221
+#define TK_NK_LE 222
+#define TK_NK_GE 223
+#define TK_NK_NE 224
+#define TK_MATCH 225
+#define TK_NMATCH 226
+#define TK_CONTAINS 227
+#define TK_IN 228
+#define TK_JOIN 229
+#define TK_INNER 230
+#define TK_SELECT 231
+#define TK_DISTINCT 232
+#define TK_WHERE 233
+#define TK_PARTITION 234
+#define TK_BY 235
+#define TK_SESSION 236
+#define TK_STATE_WINDOW 237
+#define TK_SLIDING 238
+#define TK_FILL 239
+#define TK_VALUE 240
+#define TK_NONE 241
+#define TK_PREV 242
+#define TK_LINEAR 243
+#define TK_NEXT 244
+#define TK_HAVING 245
+#define TK_RANGE 246
+#define TK_EVERY 247
+#define TK_ORDER 248
+#define TK_SLIMIT 249
+#define TK_SOFFSET 250
+#define TK_LIMIT 251
+#define TK_OFFSET 252
+#define TK_ASC 253
+#define TK_NULLS 254
+#define TK_ABORT 255
+#define TK_AFTER 256
+#define TK_ATTACH 257
+#define TK_BEFORE 258
+#define TK_BEGIN 259
+#define TK_BITAND 260
+#define TK_BITNOT 261
+#define TK_BITOR 262
+#define TK_BLOCKS 263
+#define TK_CHANGE 264
+#define TK_COMMA 265
+#define TK_COMPACT 266
+#define TK_CONCAT 267
+#define TK_CONFLICT 268
+#define TK_COPY 269
+#define TK_DEFERRED 270
+#define TK_DELIMITERS 271
+#define TK_DETACH 272
+#define TK_DIVIDE 273
+#define TK_DOT 274
+#define TK_EACH 275
+#define TK_END 276
+#define TK_FAIL 277
+#define TK_FILE 278
+#define TK_FOR 279
+#define TK_GLOB 280
+#define TK_ID 281
+#define TK_IMMEDIATE 282
+#define TK_IMPORT 283
+#define TK_INITIALLY 284
+#define TK_INSTEAD 285
+#define TK_ISNULL 286
+#define TK_KEY 287
+#define TK_NK_BITNOT 288
+#define TK_NK_SEMI 289
+#define TK_NOTNULL 290
+#define TK_OF 291
+#define TK_PLUS 292
+#define TK_PRIVILEGE 293
+#define TK_RAISE 294
+#define TK_REPLACE 295
+#define TK_RESTRICT 296
+#define TK_ROW 297
+#define TK_SEMI 298
+#define TK_STAR 299
+#define TK_STATEMENT 300
+#define TK_STRING 301
+#define TK_TIMES 302
+#define TK_UPDATE 303
+#define TK_VALUES 304
+#define TK_VARIABLE 305
+#define TK_VIEW 306
+#define TK_WAL 307
#define TK_NK_SPACE 300
#define TK_NK_COMMENT 301
diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h
index f47c309330..ea70a42147 100644
--- a/include/libs/nodes/cmdnodes.h
+++ b/include/libs/nodes/cmdnodes.h
@@ -82,6 +82,8 @@ typedef struct SDatabaseOptions {
bool walRetentionSizeIsSet;
bool walRollPeriodIsSet;
int32_t sstTrigger;
+ int32_t tablePrefix;
+ int32_t tableSuffix;
} SDatabaseOptions;
typedef struct SCreateDatabaseStmt {
diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h
index 9c2fdf587b..6500d3d183 100644
--- a/include/libs/nodes/nodes.h
+++ b/include/libs/nodes/nodes.h
@@ -320,6 +320,9 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode);
int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen);
int32_t nodesStringToList(const char* pStr, SNodeList** pList);
+int32_t nodesNodeToMsg(const SNode* pNode, char** pMsg, int32_t* pLen);
+int32_t nodesMsgToNode(const char* pStr, int32_t len, SNode** pNode);
+
int32_t nodesNodeToSQL(SNode* pNode, char* buf, int32_t bufSize, int32_t* len);
char* nodesGetNameFromColumnNode(SNode* pNode);
int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots);
diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h
index 1fa7dca7dc..44a9e10679 100644
--- a/include/libs/qcom/query.h
+++ b/include/libs/qcom/query.h
@@ -116,6 +116,8 @@ typedef struct STableMeta {
typedef struct SDBVgInfo {
int32_t vgVersion;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
int8_t hashMethod;
int32_t numOfTable; // DB's table num, unit is TSDB_TABLE_NUM_UNIT
SHashObj* vgHash; // key:vgId, value:SVgroupInfo
diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h
index 2c27509008..afd8de6b1c 100644
--- a/include/libs/stream/tstream.h
+++ b/include/libs/stream/tstream.h
@@ -554,6 +554,8 @@ typedef struct {
int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
+int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
+int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal);
void streamFreeVal(void* val);
SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key);
diff --git a/include/libs/sync/syncTools.h b/include/libs/sync/syncTools.h
index 6c95c3c6d7..de2271554d 100644
--- a/include/libs/sync/syncTools.h
+++ b/include/libs/sync/syncTools.h
@@ -444,6 +444,70 @@ void syncAppendEntriesReplyPrint2(char* s, const SyncAppendEntriesReply* pMsg);
void syncAppendEntriesReplyLog(const SyncAppendEntriesReply* pMsg);
void syncAppendEntriesReplyLog2(char* s, const SyncAppendEntriesReply* pMsg);
+// ---------------------------------------------
+typedef struct SyncHeartbeat {
+ uint32_t bytes;
+ int32_t vgId;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+
+ // private data
+ SyncTerm term;
+ SyncIndex commitIndex;
+ SyncTerm privateTerm;
+} SyncHeartbeat;
+
+SyncHeartbeat* syncHeartbeatBuild(int32_t vgId);
+void syncHeartbeatDestroy(SyncHeartbeat* pMsg);
+void syncHeartbeatSerialize(const SyncHeartbeat* pMsg, char* buf, uint32_t bufLen);
+void syncHeartbeatDeserialize(const char* buf, uint32_t len, SyncHeartbeat* pMsg);
+char* syncHeartbeatSerialize2(const SyncHeartbeat* pMsg, uint32_t* len);
+SyncHeartbeat* syncHeartbeatDeserialize2(const char* buf, uint32_t len);
+void syncHeartbeat2RpcMsg(const SyncHeartbeat* pMsg, SRpcMsg* pRpcMsg);
+void syncHeartbeatFromRpcMsg(const SRpcMsg* pRpcMsg, SyncHeartbeat* pMsg);
+SyncHeartbeat* syncHeartbeatFromRpcMsg2(const SRpcMsg* pRpcMsg);
+cJSON* syncHeartbeat2Json(const SyncHeartbeat* pMsg);
+char* syncHeartbeat2Str(const SyncHeartbeat* pMsg);
+
+// for debug ----------------------
+void syncHeartbeatPrint(const SyncHeartbeat* pMsg);
+void syncHeartbeatPrint2(char* s, const SyncHeartbeat* pMsg);
+void syncHeartbeatLog(const SyncHeartbeat* pMsg);
+void syncHeartbeatLog2(char* s, const SyncHeartbeat* pMsg);
+
+// ---------------------------------------------
+typedef struct SyncHeartbeatReply {
+ uint32_t bytes;
+ int32_t vgId;
+ uint32_t msgType;
+ SRaftId srcId;
+ SRaftId destId;
+
+ // private data
+ SyncTerm term;
+ SyncTerm privateTerm;
+ int64_t startTime;
+} SyncHeartbeatReply;
+
+SyncHeartbeatReply* syncHeartbeatReplyBuild(int32_t vgId);
+void syncHeartbeatReplyDestroy(SyncHeartbeatReply* pMsg);
+void syncHeartbeatReplySerialize(const SyncHeartbeatReply* pMsg, char* buf, uint32_t bufLen);
+void syncHeartbeatReplyDeserialize(const char* buf, uint32_t len, SyncHeartbeatReply* pMsg);
+char* syncHeartbeatReplySerialize2(const SyncHeartbeatReply* pMsg, uint32_t* len);
+SyncHeartbeatReply* syncHeartbeatReplyDeserialize2(const char* buf, uint32_t len);
+void syncHeartbeatReply2RpcMsg(const SyncHeartbeatReply* pMsg, SRpcMsg* pRpcMsg);
+void syncHeartbeatReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncHeartbeatReply* pMsg);
+SyncHeartbeatReply* syncHeartbeatReplyFromRpcMsg2(const SRpcMsg* pRpcMsg);
+cJSON* syncHeartbeatReply2Json(const SyncHeartbeatReply* pMsg);
+char* syncHeartbeatReply2Str(const SyncHeartbeatReply* pMsg);
+
+// for debug ----------------------
+void syncHeartbeatReplyPrint(const SyncHeartbeatReply* pMsg);
+void syncHeartbeatReplyPrint2(char* s, const SyncHeartbeatReply* pMsg);
+void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg);
+void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg);
+
// ---------------------------------------------
typedef struct SyncApplyMsg {
uint32_t bytes;
diff --git a/include/util/taoserror.h b/include/util/taoserror.h
index e39172d74e..d16a599811 100644
--- a/include/util/taoserror.h
+++ b/include/util/taoserror.h
@@ -616,6 +616,7 @@ int32_t* taosGetErrno();
#define TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP TAOS_DEF_ERROR_CODE(0, 0x3155)
#define TSDB_CODE_RSMA_EMPTY_INFO TAOS_DEF_ERROR_CODE(0, 0x3156)
#define TSDB_CODE_RSMA_INVALID_SCHEMA TAOS_DEF_ERROR_CODE(0, 0x3157)
+#define TSDB_CODE_RSMA_REGEX_MATCH TAOS_DEF_ERROR_CODE(0, 0x3158)
//index
#define TSDB_CODE_INDEX_REBUILDING TAOS_DEF_ERROR_CODE(0, 0x3200)
diff --git a/include/util/tdef.h b/include/util/tdef.h
index 48f37fca28..21f879cd93 100644
--- a/include/util/tdef.h
+++ b/include/util/tdef.h
@@ -359,9 +359,15 @@ typedef enum ELogicConditionType {
#define TSDB_DB_SCHEMALESS_ON 1
#define TSDB_DB_SCHEMALESS_OFF 0
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
-#define TSDB_MIN_SST_TRIGGER 1
-#define TSDB_MAX_SST_TRIGGER 128
+#define TSDB_MIN_STT_TRIGGER 1
+#define TSDB_MAX_STT_TRIGGER 16
#define TSDB_DEFAULT_SST_TRIGGER 8
+#define TSDB_MIN_HASH_PREFIX 0
+#define TSDB_MAX_HASH_PREFIX 128
+#define TSDB_DEFAULT_HASH_PREFIX 0
+#define TSDB_MIN_HASH_SUFFIX 0
+#define TSDB_MAX_HASH_SUFFIX 128
+#define TSDB_DEFAULT_HASH_SUFFIX 0
#define TSDB_DB_MIN_WAL_RETENTION_PERIOD -1
#define TSDB_REP_DEF_DB_WAL_RET_PERIOD 0
diff --git a/include/util/trbtree.h b/include/util/trbtree.h
new file mode 100644
index 0000000000..f6d37e3d75
--- /dev/null
+++ b/include/util/trbtree.h
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#ifndef _TD_UTIL_RBTREE_H_
+#define _TD_UTIL_RBTREE_H_
+
+#include "os.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct SRBTree SRBTree;
+typedef struct SRBTreeNode SRBTreeNode;
+typedef struct SRBTreeIter SRBTreeIter;
+
+typedef int32_t (*tRBTreeCmprFn)(const void *, const void *);
+
+// SRBTree =============================================
+#define tRBTreeMin(T) ((T)->min == ((T)->NIL) ? NULL : (T)->min)
+#define tRBTreeMax(T) ((T)->max == ((T)->NIL) ? NULL : (T)->max)
+
+void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn);
+SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z);
+void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z);
+SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey);
+SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey);
+
+// SRBTreeIter =============================================
+#define tRBTreeIterCreate(tree, ascend) \
+ (SRBTreeIter) { .asc = (ascend), .pTree = (tree), .pNode = (ascend) ? (tree)->min : (tree)->max }
+
+SRBTreeNode *tRBTreeIterNext(SRBTreeIter *pIter);
+
+// STRUCT =============================================
+typedef enum { RED, BLACK } ECOLOR;
+struct SRBTreeNode {
+ ECOLOR color;
+ SRBTreeNode *parent;
+ SRBTreeNode *left;
+ SRBTreeNode *right;
+};
+
+#define RBTREE_NODE_PAYLOAD(N) ((const void *)&(N)[1])
+
+struct SRBTree {
+ tRBTreeCmprFn cmprFn;
+ int64_t n;
+ SRBTreeNode *root;
+ SRBTreeNode *min;
+ SRBTreeNode *max;
+ SRBTreeNode *NIL;
+ SRBTreeNode NILNODE;
+};
+
+struct SRBTreeIter {
+ int8_t asc;
+ SRBTree *pTree;
+ SRBTreeNode *pNode;
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_TD_UTIL_RBTREE_H_*/
\ No newline at end of file
diff --git a/include/util/tutil.h b/include/util/tutil.h
index 6a1a40f14c..32a88b37ec 100644
--- a/include/util/tutil.h
+++ b/include/util/tutil.h
@@ -20,6 +20,7 @@
#include "tcrc32c.h"
#include "tdef.h"
#include "tmd5.h"
+#include "thash.h"
#ifdef __cplusplus
extern "C" {
@@ -68,6 +69,19 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
memcpy(target, buf, TSDB_PASSWORD_LEN);
}
+static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, int32_t method, int32_t prefix,
+ int32_t suffix) {
+ if (prefix == 0 && suffix == 0) {
+ return MurmurHash3_32(tbname, tblen);
+ } else {
+ if (tblen <= (prefix + suffix)) {
+ return MurmurHash3_32(tbname, tblen);
+ } else {
+ return MurmurHash3_32(tbname + prefix, tblen - prefix - suffix);
+ }
+ }
+}
+
#ifdef __cplusplus
}
#endif
diff --git a/packaging/MPtestJenkinsfile b/packaging/MPtestJenkinsfile
index 77f642180a..5b79345916 100644
--- a/packaging/MPtestJenkinsfile
+++ b/packaging/MPtestJenkinsfile
@@ -5,13 +5,6 @@ def sync_source(branch_name) {
echo ''' + branch_name + '''
'''
sh '''
- cd ${TDINTERNAL_ROOT_DIR}
- git reset --hard
- git fetch || git fetch
- git checkout ''' + branch_name + ''' -f
- git branch
- git pull || git pull
- git log | head -n 20
cd ${TDENGINE_ROOT_DIR}
git reset --hard
git fetch || git fetch
@@ -64,17 +57,12 @@ pipeline {
defaultValue:'2.1.2',
description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1'
)
- string (
- name:'nasPassword',
- defaultValue:'password',
- description: 'the pasword of the NAS server which has installPackage-192.168.1.131'
- )
}
environment{
WORK_DIR = '/var/lib/jenkins/workspace'
TDINTERNAL_ROOT_DIR = '/var/lib/jenkins/workspace/TDinternal'
TDENGINE_ROOT_DIR = '/var/lib/jenkins/workspace/TDinternal/community'
- BRANCH_NAME = '3.0'
+ BRANCH_NAME = 'test/chr/TD-14699'
TD_SERVER_TAR = "TDengine-server-${version}-Linux-x64.tar.gz"
BASE_TD_SERVER_TAR = "TDengine-server-${baseVersion}-Linux-x64.tar.gz"
@@ -107,7 +95,7 @@ pipeline {
}
stages {
- stage ('RUN') {
+ stage ('Test Server') {
parallel {
stage('ubuntu16') {
agent{label " ubuntu16 "}
@@ -116,17 +104,17 @@ pipeline {
sync_source("${BRANCH_NAME}")
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
}
@@ -139,24 +127,21 @@ pipeline {
sync_source("${BRANCH_NAME}")
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
- python3 checkPackageRuning.py
- '''
- sh '''
- cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_CLIENT_TAR} ${version} ${BASE_TD_CLIENT_TAR} ${baseVersion} client ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
+ dpkg -r tdengine
'''
+
}
}
}
@@ -167,17 +152,17 @@ pipeline {
sync_source("${BRANCH_NAME}")
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
}
@@ -190,28 +175,23 @@ pipeline {
sync_source("${BRANCH_NAME}")
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server
python3 checkPackageRuning.py
- '''
- sh '''
- cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_CLIENT_LITE_TAR} ${version} ${BASE_TD_CLIENT_LITE_TAR} ${baseVersion} client ${nasPassword}
- python3 checkPackageRuning.py
- '''
+ sudo rpm -e tdengine
+ '''
}
}
- }
-
+ }
stage('arm64') {
agent{label 'linux_arm64'}
steps {
@@ -219,18 +199,53 @@ pipeline {
sync_source("${BRANCH_NAME}")
sh '''
cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_SERVER_ARM_TAR} ${version} ${BASE_TD_SERVER_ARM_TAR} ${baseVersion} server ${nasPassword}
+ bash testpackage.sh ${TD_SERVER_ARM_TAR} ${version} ${BASE_TD_SERVER_ARM_TAR} ${baseVersion} server
python3 checkPackageRuning.py
'''
- sh '''
- cd ${TDENGINE_ROOT_DIR}/packaging
- bash testpackage.sh ${TD_CLIENT_ARM_TAR} ${version} ${BASE_TD_CLIENT_ARM_TAR} ${baseVersion} client ${nasPassword}
- python3 checkPackageRuning.py
- '''
}
}
}
}
}
- }
+ stage ('Test Client') {
+ parallel {
+ stage('ubuntu18') {
+ agent{label " ubuntu18 "}
+ steps {
+ timeout(time: 30, unit: 'MINUTES'){
+ sh '''
+ cd ${TDENGINE_ROOT_DIR}/packaging
+ bash testpackage.sh ${TD_CLIENT_TAR} ${version} ${BASE_TD_CLIENT_TAR} ${baseVersion} client
+ python3 checkPackageRuning.py 192.168.0.21
+ '''
+ }
+ }
+ }
+ stage('centos8') {
+ agent{label " centos8_3 "}
+ steps {
+ timeout(time: 30, unit: 'MINUTES'){
+ sh '''
+ cd ${TDENGINE_ROOT_DIR}/packaging
+ bash testpackage.sh ${TD_CLIENT_LITE_TAR} ${version} ${BASE_TD_CLIENT_LITE_TAR} ${baseVersion} client
+ python3 checkPackageRuning.py 192.168.0.24
+ '''
+ }
+ }
+ }
+ }
+ }
+ stage('arm64-client') {
+ agent{label " linux_arm64 "}
+ steps {
+ timeout(time: 30, unit: 'MINUTES'){
+ sh '''
+ cd ${TDENGINE_ROOT_DIR}/packaging
+ bash testpackage.sh ${TD_CLIENT_ARM_TAR} ${version} ${BASE_TD_CLIENT_ARM_TAR} ${baseVersion} client
+ python3 checkPackageRuning.py 192.168.0.21
+ '''
+ }
+ }
+ }
+ }
}
\ No newline at end of file
diff --git a/packaging/checkPackageRuning.py b/packaging/checkPackageRuning.py
index c0d1e8b86c..2edeeb6dbb 100755
--- a/packaging/checkPackageRuning.py
+++ b/packaging/checkPackageRuning.py
@@ -19,12 +19,19 @@ import subprocess
# from this import d
import time
+
+if( len(sys.argv)>1 ):
+ serverHost=sys.argv[1]
+else:
+ serverHost="localhost"
+
+
# install taospy
out = subprocess.getoutput("pip3 show taospy|grep Version| awk -F ':' '{print $2}' ")
print("taospy version %s "%out)
if (out == "" ):
- os.system("pip install git+https://github.com/taosdata/taos-connector-python.git")
+ os.system("pip3 install git+https://github.com/taosdata/taos-connector-python.git")
print("install taos python connector")
else:
os.system("pip3 install --upgrade taospy ")
@@ -32,19 +39,19 @@ else:
# start taosd prepare
-os.system("rm -rf /var/lib/taos/*")
-os.system("systemctl restart taosd ")
+# os.system("rm -rf /var/lib/taos/*")
+# os.system("systemctl restart taosd ")
# wait a moment ,at least 5 seconds
time.sleep(5)
# prepare data by taosBenchmark
-os.system("taosBenchmark -y -n 100 -t 100")
+os.system("taosBenchmark -y -n 100 -t 100 -h %s "%serverHost )
import taos
-conn = taos.connect(host="localhost",
+conn = taos.connect(host="%s"%serverHost,
user="root",
password="taosdata",
database="test",
@@ -80,15 +87,15 @@ os.system("rm -rf /tmp/dumpdata/*")
# dump data out
print("taosdump dump out data")
-os.system("taosdump -o /tmp/dumpdata -D test -y ")
+os.system("taosdump -o /tmp/dumpdata -D test -y -h %s "%serverHost)
# drop database of test
print("drop database test")
-os.system(" taos -s ' drop database test ;' ")
+os.system(" taos -s ' drop database test ;' -h %s "%serverHost)
# dump data in
print("taosdump dump data in")
-os.system("taosdump -i /tmp/dumpdata -y ")
+os.system("taosdump -i /tmp/dumpdata -y -h %s "%serverHost)
result = conn.query("SELECT count(*) from test.meters")
diff --git a/packaging/debRpmAutoInstall.sh b/packaging/debRpmAutoInstall.sh
index 1f51378c91..3579f813e5 100755
--- a/packaging/debRpmAutoInstall.sh
+++ b/packaging/debRpmAutoInstall.sh
@@ -11,3 +11,5 @@ expect "*one:"
send "\r"
expect "*skip:"
send "\r"
+
+expect eof
\ No newline at end of file
diff --git a/packaging/testpackage.sh b/packaging/testpackage.sh
index 56da9e59be..794b3968fe 100755
--- a/packaging/testpackage.sh
+++ b/packaging/testpackage.sh
@@ -7,7 +7,6 @@ originPackageName=$3
originversion=$4
testFile=$5
subFile="taos.tar.gz"
-password=$6
# Color setting
RED='\033[41;30m'
@@ -68,11 +67,37 @@ fi
}
+function wgetFile {
+
+file=$1
+
+if [ ! -f ${file} ];then
+ echoColor BD "wget https://www.taosdata.com/assets-download/3.0/${file}"
+ wget https://www.taosdata.com/assets-download/3.0/${file}
+else
+ echoColor YD "${file} already exists "
+fi
+}
+
+function newPath {
+
+buildPath=$1
+
+if [ ! -d ${buildPath} ] ;then
+ echoColor BD "mkdir -p ${buildPath}"
+ mkdir -p ${buildPath}
+else
+ echoColor YD "${buildPath} already exists"
+fi
+
+}
+
+
echoColor G "===== install basesoft ====="
cmdInstall tree
cmdInstall wget
-cmdInstall sshpass
+cmdInstall expect
echoColor G "===== Uninstall all components of TDeingne ====="
@@ -97,11 +122,14 @@ echoColor G "===== new workroom path ====="
installPath="/usr/local/src/packageTest"
oriInstallPath="/usr/local/src/packageTest/3.1"
-if [ ! -d ${installPath} ] ;then
- echoColor BD "mkdir -p ${installPath}"
- mkdir -p ${installPath}
-else
- echoColor YD "${installPath} already exists"
+newPath ${installPath}
+
+newPath ${oriInstallPath}
+
+
+if [ -d ${oriInstallPath}/${originTdpPath} ] ;then
+ echoColor BD "rm -rf ${oriInstallPath}/${originTdpPath}/*"
+ rm -rf ${oriInstallPath}/${originTdpPath}/*
fi
if [ -d ${installPath}/${tdPath} ] ;then
@@ -109,33 +137,13 @@ if [ -d ${installPath}/${tdPath} ] ;then
rm -rf ${installPath}/${tdPath}/*
fi
-if [ ! -d ${oriInstallPath} ] ;then
- echoColor BD "mkdir -p ${oriInstallPath}"
- mkdir -p ${oriInstallPath}
-else
- echoColor YD "${oriInstallPath} already exists"
-fi
-
-if [ -d ${oriInstallPath}/${originTdpPath} ] ;then
- echoColor BD "rm -rf ${oriInstallPath}/${originTdpPath}/*"
- rm -rf ${oriInstallPath}/${originTdpPath}/*
-fi
-
-
echoColor G "===== download installPackage ====="
-# cd ${installPath}
-# wget https://www.taosdata.com/assets-download/3.0/${packgeName}
-# cd ${oriInstallPath}
-# wget https://www.taosdata.com/assets-download/3.0/${originPackageName}
+cd ${installPath} && wgetFile ${packgeName}
+cd ${oriInstallPath} && wgetFile ${originPackageName}
cd ${installPath}
cp -r ${scriptDir}/debRpmAutoInstall.sh .
-if [ ! -f {packgeName} ];then
- echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} ."
- sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/${packgeName} .
-fi
-
packageSuffix=$(echo ${packgeName} | awk -F '.' '{print $NF}')
@@ -181,8 +189,7 @@ elif [[ ${packgeName} =~ "tar" ]];then
cd ${oriInstallPath}
if [ ! -f {originPackageName} ];then
echoColor YD "download base installPackage"
- echoColor BD "sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} ."
- sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${originversion}/community/${originPackageName} .
+ wgetFile ${originPackageName}
fi
echoColor YD "unzip the base installation package"
echoColor BD "tar -xf ${originPackageName}" && tar -xf ${originPackageName}
@@ -222,24 +229,45 @@ fi
cd ${installPath}
-if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then
+if [[ ${packgeName} =~ "Lite" ]] || ([[ ${packgeName} =~ "x64" ]] && [[ ${packgeName} =~ "client" ]]) || ([[ ${packgeName} =~ "deb" ]] && [[ ${packgeName} =~ "server" ]]) || ([[ ${packgeName} =~ "rpm" ]] && [[ ${packgeName} =~ "server" ]]) ;then
echoColor G "===== install taos-tools when package is lite or client ====="
cd ${installPath}
- sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
- # wget https://www.taosdata.com/assets-download/3.0/taosTools-2.1.2-Linux-x64.tar.gz
- tar xf taosTools-2.1.2-Linux-x64.tar.gz
- cd taosTools-2.1.2 && bash install-taostools.sh
-elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then
- echoColor G "===== install taos-tools when package is lite or client ====="
+ wgetFile taosTools-2.1.3-Linux-x64.tar.gz .
+ tar xf taosTools-2.1.3-Linux-x64.tar.gz
+ cd taosTools-2.1.3 && bash install-taostools.sh
+elif ([[ ${packgeName} =~ "arm64" ]] && [[ ${packgeName} =~ "client" ]]);then
+ echoColor G "===== install taos-tools arm when package is arm64-client ====="
cd ${installPath}
- sshpass -p ${password} scp -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
- tar xf taosTools-2.1.2-Linux-x64.tar.gz
- cd taosTools-2.1.2 && bash install-taostools.sh
-elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then
- echoColor G "===== install taos-tools when package is lite or client ====="
- cd ${installPath}
- sshpass -p ${password} scp -oStrictHostKeyChecking=no -oStrictHostKeyChecking=no 192.168.1.131:/nas/TDengine3/v${version}/community/taosTools-2.1.2-Linux-x64.tar.gz .
- tar xf taosTools-2.1.2-Linux-x64.tar.gz
- cd taosTools-2.1.2 && bash install-taostools.sh
+ wgetFile taosTools-2.1.3-Linux-arm64.tar.gz .
+ tar xf taosTools-2.1.3-Linux-arm64.tar.gz
+ cd taosTools-2.1.3 && bash install-taostools.sh
fi
+echoColor G "===== start TDengine ====="
+
+if [[ ${packgeName} =~ "server" ]] ;then
+ echoColor BD " rm -rf /var/lib/taos/* && systemctl restart taosd "
+ rm -rf /var/lib/taos/*
+ systemctl restart taosd
+fi
+
+# if ([[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "tar" ]]) || [[ ${packgeName} =~ "client" ]] ;then
+# echoColor G "===== install taos-tools when package is lite or client ====="
+# cd ${installPath}
+# wgetFile taosTools-2.1.2-Linux-x64.tar.gz .
+# tar xf taosTools-2.1.2-Linux-x64.tar.gz
+# cd taosTools-2.1.2 && bash install-taostools.sh
+# elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "deb" ]] ;then
+# echoColor G "===== install taos-tools when package is lite or client ====="
+# cd ${installPath}
+# wgetFile taosTools-2.1.2-Linux-x64.tar.gz .
+# tar xf taosTools-2.1.2-Linux-x64.tar.gz
+# cd taosTools-2.1.2 && bash install-taostools.sh
+# elif [[ ${packgeName} =~ "Lite" ]] && [[ ${packgeName} =~ "rpm" ]] ;then
+# echoColor G "===== install taos-tools when package is lite or client ====="
+# cd ${installPath}
+# wgetFile taosTools-2.1.2-Linux-x64.tar.gz .
+# tar xf taosTools-2.1.2-Linux-x64.tar.gz
+# cd taosTools-2.1.2 && bash install-taostools.sh
+# fi
+
diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c
index bf92a9ba6a..b739aedca0 100644
--- a/source/client/src/clientEnv.c
+++ b/source/client/src/clientEnv.c
@@ -488,7 +488,7 @@ int taos_options_imp(TSDB_OPTION option, const char *str) {
*/
uint64_t generateRequestId() {
static uint64_t hashId = 0;
- static int32_t requestSerialId = 0;
+ static uint32_t requestSerialId = 0;
if (hashId == 0) {
char uid[64] = {0};
@@ -507,7 +507,8 @@ uint64_t generateRequestId() {
while (true) {
int64_t ts = taosGetTimestampMs();
uint64_t pid = taosGetPId();
- int32_t val = atomic_add_fetch_32(&requestSerialId, 1);
+ uint32_t val = atomic_add_fetch_32(&requestSerialId, 1);
+ if (val >= 0xFFFF) atomic_store_32(&requestSerialId, 0);
id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
if (id) {
diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c
index 56e3527f96..84a827ed78 100644
--- a/source/client/src/clientHb.c
+++ b/source/client/src/clientHb.c
@@ -73,6 +73,8 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog
vgInfo->vgVersion = rsp->vgVersion;
vgInfo->hashMethod = rsp->hashMethod;
+ vgInfo->hashPrefix = rsp->hashPrefix;
+ vgInfo->hashSuffix = rsp->hashSuffix;
vgInfo->vgHash = taosHashInit(rsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
if (NULL == vgInfo->vgHash) {
taosMemoryFree(vgInfo);
diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c
index f91ceb3184..5ebc2729f8 100644
--- a/source/client/src/clientImpl.c
+++ b/source/client/src/clientImpl.c
@@ -1672,7 +1672,12 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
break;
}
}
- if (!needConvert) return TSDB_CODE_SUCCESS;
+
+ if (!needConvert) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ tscDebug("start to convert form json format string");
char* p = (char*)pResultInfo->pData;
int32_t dataLen = estimateJsonLen(pResultInfo, numOfCols, numOfRows);
diff --git a/source/client/src/taosx.c b/source/client/src/clientRawBlockWrite.c
similarity index 98%
rename from source/client/src/taosx.c
rename to source/client/src/clientRawBlockWrite.c
index cc3a2a198a..c135965f07 100644
--- a/source/client/src/taosx.c
+++ b/source/client/src/clientRawBlockWrite.c
@@ -767,22 +767,23 @@ static int32_t taosCreateTable(TAOS* taos, void* meta, int32_t metaLen) {
pCreateReq->flags |= TD_CREATE_IF_NOT_EXISTS;
// change tag cid to new cid
- if(pCreateReq->type == TSDB_CHILD_TABLE){
+ if (pCreateReq->type == TSDB_CHILD_TABLE) {
STableMeta* pTableMeta = NULL;
SName sName = {0};
toName(pTscObj->acctId, pRequest->pDb, pCreateReq->ctb.name, &sName);
code = catalogGetTableMeta(pCatalog, &conn, &sName, &pTableMeta);
- if(code != TSDB_CODE_SUCCESS){
+ if (code != TSDB_CODE_SUCCESS) {
uError("taosCreateTable:catalogGetTableMeta failed. table name: %s", pCreateReq->ctb.name);
goto end;
}
- for(int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++){
+ for (int32_t i = 0; i < taosArrayGetSize(pCreateReq->ctb.tagName); i++) {
char* tName = taosArrayGet(pCreateReq->ctb.tagName, i);
- for(int32_t j = pTableMeta->tableInfo.numOfColumns; j < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; j++){
- SSchema *tag = &pTableMeta->schema[j];
- if(strcmp(tag->name, tName) == 0 && tag->type != TSDB_DATA_TYPE_JSON){
- tTagSetCid((STag *)pCreateReq->ctb.pTag, i, tag->colId);
+ for (int32_t j = pTableMeta->tableInfo.numOfColumns;
+ j < pTableMeta->tableInfo.numOfColumns + pTableMeta->tableInfo.numOfTags; j++) {
+ SSchema* tag = &pTableMeta->schema[j];
+ if (strcmp(tag->name, tName) == 0 && tag->type != TSDB_DATA_TYPE_JSON) {
+ tTagSetCid((STag*)pCreateReq->ctb.pTag, i, tag->colId);
}
}
}
@@ -1323,12 +1324,12 @@ end:
return code;
}
-static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
- int32_t code = TSDB_CODE_SUCCESS;
- SHashObj* pVgHash = NULL;
- SQuery* pQuery = NULL;
- SMqRspObj rspObj = {0};
- SDecoder decoder = {0};
+static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ SHashObj* pVgHash = NULL;
+ SQuery* pQuery = NULL;
+ SMqRspObj rspObj = {0};
+ SDecoder decoder = {0};
STableMeta* pTableMeta = NULL;
terrno = TSDB_CODE_SUCCESS;
@@ -1406,7 +1407,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
}
code = catalogGetTableMeta(pCatalog, &conn, &pName, &pTableMeta);
- if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST){
+ if (code == TSDB_CODE_PAR_TABLE_NOT_EXIST) {
uError("WriteRaw:catalogGetTableMeta table not exist. table name: %s", tbName);
code = TSDB_CODE_SUCCESS;
continue;
@@ -1467,7 +1468,7 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
}
// pSW->pSchema should be same as pTableMeta->schema
-// ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns);
+ // ASSERT(pSW->nCols == pTableMeta->tableInfo.numOfColumns);
uint64_t suid = (TSDB_NORMAL_TABLE == pTableMeta->tableType ? 0 : pTableMeta->suid);
uint64_t uid = pTableMeta->uid;
int16_t sver = pTableMeta->sversion;
@@ -1495,10 +1496,10 @@ static int32_t tmqWriteRaw(TAOS* taos, void* data, int32_t dataLen) {
int32_t offset = 0;
for (int32_t k = 0; k < pTableMeta->tableInfo.numOfColumns; k++) {
const SSchema* pColumn = &pTableMeta->schema[k];
- int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name));
- if(!index){
+ int32_t* index = taosHashGet(schemaHash, pColumn->name, strlen(pColumn->name));
+ if (!index) {
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
- }else{
+ } else {
char* colData = rspObj.resInfo.row[*index];
if (!colData) {
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, offset, k);
@@ -1669,7 +1670,7 @@ int32_t tmq_write_raw(TAOS* taos, tmq_raw_data raw) {
} else if (raw.raw_type == TDMT_VND_DELETE) {
return taosDeleteData(taos, raw.raw, raw.raw_len);
} else if (raw.raw_type == RES_TYPE__TMQ) {
- return tmqWriteRaw(taos, raw.raw, raw.raw_len);
+ return tmqWriteRawDataImpl(taos, raw.raw, raw.raw_len);
}
return TSDB_CODE_INVALID_PARA;
}
diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c
index c6ba2d6892..f2493f6c57 100644
--- a/source/client/src/clientSml.c
+++ b/source/client/src/clientSml.c
@@ -547,6 +547,8 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
goto end;
}
needCheckMeta = true;
+ taosHashCleanup(hashTmp);
+ hashTmp = NULL;
} else {
uError("SML:0x%" PRIx64 " load table meta error: %s", info->id, tstrerror(code));
goto end;
@@ -576,7 +578,6 @@ static int32_t smlModifyDBSchemas(SSmlHandle *info) {
sTableData->tableMeta = pTableMeta;
tableMetaSml = (SSmlSTableMeta **)taosHashIterate(info->superTables, tableMetaSml);
- taosHashCleanup(hashTmp);
}
return 0;
diff --git a/source/client/src/tmq.c b/source/client/src/clientTmq.c
similarity index 100%
rename from source/client/src/tmq.c
rename to source/client/src/clientTmq.c
diff --git a/source/common/src/systable.c b/source/common/src/systable.c
index fdacfa55b8..f77320c5ac 100644
--- a/source/common/src/systable.c
+++ b/source/common/src/systable.c
@@ -90,7 +90,7 @@ static const SSysDbTableSchema userDBSchema[] = {
{.name = "minrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "maxrows", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "comp", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
- {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
+ {.name = "precision", .bytes = 2 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "retentions", .bytes = 60 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "single_stable", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = true},
@@ -103,6 +103,8 @@ static const SSysDbTableSchema userDBSchema[] = {
{.name = "wal_roll_period", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "wal_segment_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
{.name = "sst_trigger", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
+ {.name = "table_prefix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
+ {.name = "table_suffix", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT, .sysInfo = true},
};
static const SSysDbTableSchema userFuncSchema[] = {
@@ -207,6 +209,7 @@ static const SSysDbTableSchema vgroupsSchema[] = {
{.name = "v3_dnode", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "v3_status", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "status", .bytes = 12 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
+ {.name = "cacheload", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "nfiles", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "file_size", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
{.name = "tsma", .bytes = 1, .type = TSDB_DATA_TYPE_TINYINT, .sysInfo = true},
diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c
index c7f372f17b..16b8e55cf7 100644
--- a/source/common/src/tdatablock.c
+++ b/source/common/src/tdatablock.c
@@ -140,7 +140,8 @@ int32_t colDataReserve(SColumnInfoData* pColumnInfoData, size_t newSize) {
return TSDB_CODE_SUCCESS;
}
-static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData, int32_t itemLen, int32_t numOfRows) {
+static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t currentRow, const char* pData,
+ int32_t itemLen, int32_t numOfRows) {
ASSERT(pColumnInfoData->info.bytes >= itemLen);
size_t start = 1;
@@ -148,21 +149,23 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren
memcpy(pColumnInfoData->pData, pData, itemLen);
int32_t t = 0;
- int32_t count = log(numOfRows)/log(2);
- while(t < count) {
+ int32_t count = log(numOfRows) / log(2);
+ while (t < count) {
int32_t xlen = 1 << t;
- memcpy(pColumnInfoData->pData + start * itemLen + pColumnInfoData->varmeta.length, pColumnInfoData->pData, xlen * itemLen);
+ memcpy(pColumnInfoData->pData + start * itemLen + pColumnInfoData->varmeta.length, pColumnInfoData->pData,
+ xlen * itemLen);
t += 1;
start += xlen;
}
// the tail part
if (numOfRows > start) {
- memcpy(pColumnInfoData->pData + start * itemLen + currentRow * itemLen, pColumnInfoData->pData, (numOfRows - start) * itemLen);
+ memcpy(pColumnInfoData->pData + start * itemLen + currentRow * itemLen, pColumnInfoData->pData,
+ (numOfRows - start) * itemLen);
}
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
- for(int32_t i = 0; i < numOfRows; ++i) {
+ for (int32_t i = 0; i < numOfRows; ++i) {
pColumnInfoData->varmeta.offset[i + currentRow] = pColumnInfoData->varmeta.length + i * itemLen;
}
@@ -170,7 +173,8 @@ static void doCopyNItems(struct SColumnInfoData* pColumnInfoData, int32_t curren
}
}
-int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows) {
+int32_t colDataAppendNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
+ uint32_t numOfRows) {
ASSERT(pData != NULL && pColumnInfoData != NULL);
int32_t len = pColumnInfoData->info.bytes;
@@ -278,7 +282,7 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int
} else {
if (finalNumOfRows > *capacity || (numOfRow1 == 0 && pColumnInfoData->info.bytes != 0)) {
// all data may be null, when the pColumnInfoData->info.type == 0, bytes == 0;
-// ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
+ // ASSERT(finalNumOfRows * pColumnInfoData->info.bytes);
char* tmp = taosMemoryRealloc(pColumnInfoData->pData, finalNumOfRows * pColumnInfoData->info.bytes);
if (tmp == NULL) {
return TSDB_CODE_VND_OUT_OF_MEMORY;
@@ -557,7 +561,7 @@ int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock) {
}
int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) {
- int32_t numOfRows = *(int32_t*) buf;
+ int32_t numOfRows = *(int32_t*)buf;
blockDataEnsureCapacity(pBlock, numOfRows);
pBlock->info.rows = numOfRows;
@@ -676,7 +680,8 @@ size_t blockDataGetRowSize(SSDataBlock* pBlock) {
* @return
*/
size_t blockDataGetSerialMetaSize(uint32_t numOfCols) {
- // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column length |
+ // | version | total length | total rows | total columns | flag seg| block group id | column schema | each column
+ // length |
return sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(int32_t) + sizeof(uint64_t) +
numOfCols * (sizeof(int8_t) + sizeof(int32_t)) + numOfCols * sizeof(int32_t);
}
@@ -1302,6 +1307,40 @@ int32_t copyDataBlock(SSDataBlock* dst, const SSDataBlock* src) {
return TSDB_CODE_SUCCESS;
}
+SSDataBlock* createSpecialDataBlock(EStreamType type) {
+ SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
+ pBlock->info.hasVarCol = false;
+ pBlock->info.groupId = 0;
+ pBlock->info.rows = 0;
+ pBlock->info.type = type;
+ pBlock->info.rowSize =
+ sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY);
+ pBlock->info.watermark = INT64_MIN;
+
+ pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData));
+ SColumnInfoData infoData = {0};
+ infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP;
+ infoData.info.bytes = sizeof(TSKEY);
+ // window start ts
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+ // window end ts
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+
+ infoData.info.type = TSDB_DATA_TYPE_UBIGINT;
+ infoData.info.bytes = sizeof(uint64_t);
+ // uid
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+ // group id
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+
+ // calculate start ts
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+ // calculate end ts
+ taosArrayPush(pBlock->pDataBlock, &infoData);
+
+ return pBlock;
+}
+
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
if (pDataBlock == NULL) {
return NULL;
@@ -1426,7 +1465,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) {
}
void colDataDestroy(SColumnInfoData* pColData) {
- if(!pColData) return;
+ if (!pColData) return;
if (IS_VAR_DATA_TYPE(pColData->info.type)) {
taosMemoryFreeClear(pColData->varmeta.offset);
} else {
@@ -1693,7 +1732,7 @@ static char* formatTimestamp(char* buf, int64_t val, int precision) {
}
struct tm ptm = {0};
taosLocalTime(&tt, &ptm);
- size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
+ size_t pos = strftime(buf, 35, "%Y-%m-%d %H:%M:%S", &ptm);
if (precision == TSDB_TIME_PRECISION_NANO) {
sprintf(buf + pos, ".%09d", ms);
@@ -1847,20 +1886,20 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
break;
case TSDB_DATA_TYPE_VARCHAR: {
memset(pBuf, 0, sizeof(pBuf));
- char* pData = colDataGetVarData(pColInfoData, j);
+ char* pData = colDataGetVarData(pColInfoData, j);
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
memcpy(pBuf, varDataVal(pData), dataSize);
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
if (len >= size - 1) return dumpBuf;
- } break;
+ } break;
case TSDB_DATA_TYPE_NCHAR: {
- char* pData = colDataGetVarData(pColInfoData, j);
+ char* pData = colDataGetVarData(pColInfoData, j);
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
memset(pBuf, 0, sizeof(pBuf));
- taosUcs4ToMbs((TdUcs4 *)varDataVal(pData), dataSize, pBuf);
+ taosUcs4ToMbs((TdUcs4*)varDataVal(pData), dataSize, pBuf);
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
if (len >= size - 1) return dumpBuf;
- } break;
+ } break;
}
}
len += snprintf(dumpBuf + len, size - len, "\n");
@@ -1877,7 +1916,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
* @param pDataBlocks
* @param vgId
* @param suid
- *
+ *
*/
int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataBlock, STSchema* pTSchema, int32_t vgId,
tb_uid_t suid) {
@@ -1904,8 +1943,8 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
tdSRowInit(&rb, pTSchema->version);
for (int32_t i = 0; i < sz; ++i) {
- int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
- int32_t rows = pDataBlock->info.rows;
+ int32_t colNum = taosArrayGetSize(pDataBlock->pDataBlock);
+ int32_t rows = pDataBlock->info.rows;
// int32_t rowSize = pDataBlock->info.rowSize;
// int64_t groupId = pDataBlock->info.groupId;
@@ -1926,7 +1965,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
msgLen += sizeof(SSubmitBlk);
int32_t dataLen = 0;
- for (int32_t j = 0; j < rows; ++j) { // iterate by row
+ for (int32_t j = 0; j < rows; ++j) { // iterate by row
tdSRowResetBuf(&rb, POINTER_SHIFT(pDataBuf, msgLen + dataLen)); // set row buf
bool isStartKey = false;
int32_t offset = 0;
@@ -2081,6 +2120,7 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
int32_t* rows = (int32_t*)data;
*rows = pBlock->info.rows;
data += sizeof(int32_t);
+ ASSERT(*rows > 0);
int32_t* cols = (int32_t*)data;
*cols = numOfCols;
@@ -2089,7 +2129,7 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
// flag segment.
// the inital bit is for column info
int32_t* flagSegment = (int32_t*)data;
- *flagSegment = (1<<31);
+ *flagSegment = (1 << 31);
data += sizeof(int32_t);
@@ -2144,12 +2184,14 @@ void blockEncode(const SSDataBlock* pBlock, char* data, int32_t* dataLen, int32_
*actualLen = *dataLen;
*groupId = pBlock->info.groupId;
+ ASSERT(*dataLen > 0);
+ uDebug("build data block, actualLen:%d, rows:%d, cols:%d", *dataLen, *rows, *cols);
}
const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
const char* pStart = pData;
- int32_t version = *(int32_t*) pStart;
+ int32_t version = *(int32_t*)pStart;
pStart += sizeof(int32_t);
ASSERT(version == 1);
@@ -2158,7 +2200,7 @@ const char* blockDecode(SSDataBlock* pBlock, const char* pData) {
pStart += sizeof(int32_t);
// total rows sizeof(int32_t)
- int32_t numOfRows = *(int32_t*)pStart;
+ int32_t numOfRows = *(int32_t*)pStart;
pStart += sizeof(int32_t);
// total columns sizeof(int32_t)
diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c
index 908f7c014e..c436e4ffd2 100644
--- a/source/common/src/tglobal.c
+++ b/source/common/src/tglobal.c
@@ -129,10 +129,6 @@ int32_t tsMinIntervalTime = 1;
int32_t tsQueryBufferSize = -1;
int64_t tsQueryBufferSizeBytes = -1;
-// tsdb config
-// For backward compatibility
-bool tsdbForceKeepFile = false;
-
int32_t tsDiskCfgNum = 0;
SDiskCfg tsDiskCfg[TFS_MAX_DISKS] = {0};
diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c
index 9947d0e3b2..ea25094d10 100644
--- a/source/common/src/tmsg.c
+++ b/source/common/src/tmsg.c
@@ -994,6 +994,7 @@ int32_t tSerializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
SVnodeLoad *pload = taosArrayGet(pReq->pVloads, i);
if (tEncodeI32(&encoder, pload->vgId) < 0) return -1;
if (tEncodeI32(&encoder, pload->syncState) < 0) return -1;
+ if (tEncodeI64(&encoder, pload->cacheUsage) < 0) return -1;
if (tEncodeI64(&encoder, pload->numOfTables) < 0) return -1;
if (tEncodeI64(&encoder, pload->numOfTimeSeries) < 0) return -1;
if (tEncodeI64(&encoder, pload->totalStorage) < 0) return -1;
@@ -1063,6 +1064,7 @@ int32_t tDeserializeSStatusReq(void *buf, int32_t bufLen, SStatusReq *pReq) {
SVnodeLoad vload = {0};
if (tDecodeI32(&decoder, &vload.vgId) < 0) return -1;
if (tDecodeI32(&decoder, &vload.syncState) < 0) return -1;
+ if (tDecodeI64(&decoder, &vload.cacheUsage) < 0) return -1;
if (tDecodeI64(&decoder, &vload.numOfTables) < 0) return -1;
if (tDecodeI64(&decoder, &vload.numOfTimeSeries) < 0) return -1;
if (tDecodeI64(&decoder, &vload.totalStorage) < 0) return -1;
@@ -2025,6 +2027,8 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1;
if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1;
if (tEncodeI32(&encoder, pReq->sstTrigger) < 0) return -1;
+ if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1;
+ if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1;
if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1;
if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1;
for (int32_t i = 0; i < pReq->numOfRetensions; ++i) {
@@ -2072,6 +2076,8 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1;
if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->sstTrigger) < 0) return -1;
+ if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1;
+ if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1;
if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1;
if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1;
pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention));
@@ -2457,6 +2463,8 @@ int32_t tSerializeSUseDbRspImp(SEncoder *pEncoder, const SUseDbRsp *pRsp) {
if (tEncodeI64(pEncoder, pRsp->uid) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->vgVersion) < 0) return -1;
if (tEncodeI32(pEncoder, pRsp->vgNum) < 0) return -1;
+ if (tEncodeI16(pEncoder, pRsp->hashPrefix) < 0) return -1;
+ if (tEncodeI16(pEncoder, pRsp->hashSuffix) < 0) return -1;
if (tEncodeI8(pEncoder, pRsp->hashMethod) < 0) return -1;
for (int32_t i = 0; i < pRsp->vgNum; ++i) {
@@ -2508,6 +2516,8 @@ int32_t tDeserializeSUseDbRspImp(SDecoder *pDecoder, SUseDbRsp *pRsp) {
if (tDecodeI64(pDecoder, &pRsp->uid) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->vgVersion) < 0) return -1;
if (tDecodeI32(pDecoder, &pRsp->vgNum) < 0) return -1;
+ if (tDecodeI16(pDecoder, &pRsp->hashPrefix) < 0) return -1;
+ if (tDecodeI16(pDecoder, &pRsp->hashSuffix) < 0) return -1;
if (tDecodeI8(pDecoder, &pRsp->hashMethod) < 0) return -1;
if (pRsp->vgNum <= 0) {
@@ -3767,6 +3777,8 @@ int32_t tSerializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *pR
if (tEncodeI32(&encoder, pReq->walRollPeriod) < 0) return -1;
if (tEncodeI64(&encoder, pReq->walSegmentSize) < 0) return -1;
if (tEncodeI16(&encoder, pReq->sstTrigger) < 0) return -1;
+ if (tEncodeI16(&encoder, pReq->hashPrefix) < 0) return -1;
+ if (tEncodeI16(&encoder, pReq->hashSuffix) < 0) return -1;
tEndEncode(&encoder);
@@ -3840,6 +3852,8 @@ int32_t tDeserializeSCreateVnodeReq(void *buf, int32_t bufLen, SCreateVnodeReq *
if (tDecodeI32(&decoder, &pReq->walRollPeriod) < 0) return -1;
if (tDecodeI64(&decoder, &pReq->walSegmentSize) < 0) return -1;
if (tDecodeI16(&decoder, &pReq->sstTrigger) < 0) return -1;
+ if (tDecodeI16(&decoder, &pReq->hashPrefix) < 0) return -1;
+ if (tDecodeI16(&decoder, &pReq->hashSuffix) < 0) return -1;
tEndDecode(&decoder);
tDecoderClear(&decoder);
diff --git a/source/common/src/trow.c b/source/common/src/trow.c
index 565498a47b..9880fe362e 100644
--- a/source/common/src/trow.c
+++ b/source/common/src/trow.c
@@ -538,12 +538,12 @@ bool tdSTSRowIterGetTpVal(STSRowIter *pIter, col_type_t colType, int32_t offset,
} else {
pVal->val = POINTER_SHIFT(TD_ROW_DATA(pRow), offset);
}
- return TSDB_CODE_SUCCESS;
+ return true;
}
if (tdGetBitmapValType(pIter->pBitmap, pIter->colIdx - 1, &pVal->valType, 0) != TSDB_CODE_SUCCESS) {
pVal->valType = TD_VTYPE_NONE;
- return terrno;
+ return true;
}
if (pVal->valType == TD_VTYPE_NORM) {
diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
index c684683ee9..981576efec 100644
--- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
+++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c
@@ -167,10 +167,12 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
pCfg->walCfg.segSize = pCreate->walSegmentSize;
pCfg->walCfg.level = pCreate->walLevel;
- pCfg->sstTrigger = pCreate->sstTrigger;
+ pCfg->sttTrigger = pCreate->sstTrigger;
pCfg->hashBegin = pCreate->hashBegin;
pCfg->hashEnd = pCreate->hashEnd;
pCfg->hashMethod = pCreate->hashMethod;
+ pCfg->hashPrefix = pCreate->hashPrefix;
+ pCfg->hashSuffix = pCreate->hashSuffix;
pCfg->standby = pCfg->standby;
pCfg->syncCfg.myIndex = pCreate->selfIndex;
@@ -220,9 +222,11 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return -1;
}
- dDebug("vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d",
- createReq.vgId, createReq.isTsma, createReq.standby, createReq.cacheLast, createReq.cacheLastSize,
- createReq.sstTrigger);
+ dInfo("vgId:%d, start to create vnode, tsma:%d standby:%d cacheLast:%d cacheLastSize:%d sstTrigger:%d",
+ createReq.vgId, createReq.isTsma, createReq.standby, createReq.cacheLast, createReq.cacheLastSize,
+ createReq.sstTrigger);
+ dInfo("vgId:%d, hashMethod:%d begin:%u end:%u prefix:%d surfix:%d", createReq.vgId, createReq.hashMethod,
+ createReq.hashBegin, createReq.hashEnd, createReq.hashPrefix, createReq.hashSuffix);
vmGenerateVnodeCfg(&createReq, &vnodeCfg);
if (vmTsmaAdjustDays(&vnodeCfg, &createReq) < 0) {
diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h
index 179e7f4448..9632be1b24 100644
--- a/source/dnode/mnode/impl/inc/mndDef.h
+++ b/source/dnode/mnode/impl/inc/mndDef.h
@@ -305,13 +305,15 @@ typedef struct {
int8_t hashMethod; // default is 1
int8_t cacheLast;
int8_t schemaless;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
+ int16_t sstTrigger;
int32_t numOfRetensions;
SArray* pRetensions;
int32_t walRetentionPeriod;
- int64_t walRetentionSize;
int32_t walRollPeriod;
+ int64_t walRetentionSize;
int64_t walSegmentSize;
- int16_t sstTrigger;
} SDbCfg;
typedef struct {
@@ -341,6 +343,7 @@ typedef struct {
uint32_t hashEnd;
char dbName[TSDB_DB_FNAME_LEN];
int64_t dbUid;
+ int64_t cacheUsage;
int64_t numOfTables;
int64_t numOfTimeSeries;
int64_t totalStorage;
diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c
index d1313d5a17..9e58b74017 100644
--- a/source/dnode/mnode/impl/src/mndDb.c
+++ b/source/dnode/mnode/impl/src/mndDb.c
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDb.h"
+#include "mndCluster.h"
#include "mndDnode.h"
#include "mndOffset.h"
#include "mndPrivilege.h"
@@ -30,7 +31,7 @@
#include "systable.h"
#define DB_VER_NUMBER 1
-#define DB_RESERVE_SIZE 62
+#define DB_RESERVE_SIZE 58
static SSdbRaw *mndDbActionEncode(SDbObj *pDb);
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
@@ -125,6 +126,8 @@ static SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.walRollPeriod, _OVER)
SDB_SET_INT64(pRaw, dataPos, pDb->cfg.walSegmentSize, _OVER)
SDB_SET_INT16(pRaw, dataPos, pDb->cfg.sstTrigger, _OVER)
+ SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashPrefix, _OVER)
+ SDB_SET_INT16(pRaw, dataPos, pDb->cfg.hashSuffix, _OVER)
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
@@ -209,6 +212,8 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.walRollPeriod, _OVER)
SDB_GET_INT64(pRaw, dataPos, &pDb->cfg.walSegmentSize, _OVER)
SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.sstTrigger, _OVER)
+ SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashPrefix, _OVER)
+ SDB_GET_INT16(pRaw, dataPos, &pDb->cfg.hashSuffix, _OVER)
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
taosInitRWLatch(&pDb->lock);
@@ -333,7 +338,9 @@ static int32_t mndCheckDbCfg(SMnode *pMnode, SDbCfg *pCfg) {
if (pCfg->walRetentionSize < TSDB_DB_MIN_WAL_RETENTION_SIZE) return -1;
if (pCfg->walRollPeriod < TSDB_DB_MIN_WAL_ROLL_PERIOD) return -1;
if (pCfg->walSegmentSize < TSDB_DB_MIN_WAL_SEGMENT_SIZE) return -1;
- if (pCfg->sstTrigger < TSDB_MIN_SST_TRIGGER || pCfg->sstTrigger > TSDB_MAX_SST_TRIGGER) return -1;
+ if (pCfg->sstTrigger < TSDB_MIN_STT_TRIGGER || pCfg->sstTrigger > TSDB_MAX_STT_TRIGGER) return -1;
+ if (pCfg->hashPrefix < TSDB_MIN_HASH_PREFIX || pCfg->hashPrefix > TSDB_MAX_HASH_PREFIX) return -1;
+ if (pCfg->hashSuffix < TSDB_MIN_HASH_SUFFIX || pCfg->hashSuffix > TSDB_MAX_HASH_SUFFIX) return -1;
terrno = 0;
return terrno;
@@ -368,6 +375,8 @@ static void mndSetDefaultDbCfg(SDbCfg *pCfg) {
if (pCfg->walRollPeriod < 0) pCfg->walRollPeriod = TSDB_REPS_DEF_DB_WAL_ROLL_PERIOD;
if (pCfg->walSegmentSize < 0) pCfg->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE;
if (pCfg->sstTrigger <= 0) pCfg->sstTrigger = TSDB_DEFAULT_SST_TRIGGER;
+ if (pCfg->hashPrefix < 0) pCfg->hashPrefix = TSDB_DEFAULT_HASH_PREFIX;
+ if (pCfg->hashSuffix < 0) pCfg->hashSuffix = TSDB_DEFAULT_HASH_SUFFIX;
}
static int32_t mndSetCreateDbRedoLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SVgObj *pVgroups) {
@@ -485,6 +494,8 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
.walRollPeriod = pCreate->walRollPeriod,
.walSegmentSize = pCreate->walSegmentSize,
.sstTrigger = pCreate->sstTrigger,
+ .hashPrefix = pCreate->hashPrefix,
+ .hashSuffix = pCreate->hashSuffix,
};
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
@@ -502,6 +513,12 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
return -1;
}
+ if (dbObj.cfg.hashPrefix > 0) {
+ int32_t dbLen = strlen(dbObj.name) + 1;
+ mInfo("db:%s, hashPrefix adjust from %d to %d", dbObj.name, dbObj.cfg.hashPrefix, dbObj.cfg.hashPrefix + dbLen);
+ dbObj.cfg.hashPrefix += dbLen;
+ }
+
SVgObj *pVgroups = NULL;
if (mndAllocVgroup(pMnode, &dbObj, &pVgroups) != 0) {
mError("db:%s, failed to create since %s", pCreate->db, terrstr());
@@ -1161,6 +1178,8 @@ int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUs
pRsp->vgVersion = pDb->vgVersion;
pRsp->vgNum = taosArrayGetSize(pRsp->pVgroupInfos);
pRsp->hashMethod = pDb->cfg.hashMethod;
+ pRsp->hashPrefix = pDb->cfg.hashPrefix;
+ pRsp->hashSuffix = pDb->cfg.hashSuffix;
return 0;
}
@@ -1293,6 +1312,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbVgVersion *pDbs, int32_t numOfDbs,
usedbRsp.vgVersion = pDb->vgVersion;
usedbRsp.vgNum = (int32_t)taosArrayGetSize(usedbRsp.pVgroupInfos);
usedbRsp.hashMethod = pDb->cfg.hashMethod;
+ usedbRsp.hashPrefix = pDb->cfg.hashPrefix;
+ usedbRsp.hashSuffix = pDb->cfg.hashSuffix;
taosArrayPush(batchUseRsp.pArray, &usedbRsp);
mndReleaseDb(pMnode, pDb);
@@ -1542,6 +1563,24 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
STR_WITH_MAXSIZE_TO_VARSTR(buf, "NULL", bytes);
}
+ const char *precStr = NULL;
+ switch (pDb->cfg.precision) {
+ case TSDB_TIME_PRECISION_MILLI:
+ precStr = TSDB_TIME_PRECISION_MILLI_STR;
+ break;
+ case TSDB_TIME_PRECISION_MICRO:
+ precStr = TSDB_TIME_PRECISION_MICRO_STR;
+ break;
+ case TSDB_TIME_PRECISION_NANO:
+ precStr = TSDB_TIME_PRECISION_NANO_STR;
+ break;
+ default:
+ precStr = "none";
+ break;
+ }
+ char precVstr[10] = {0};
+ STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2);
+
char *statusStr = "ready";
if (objStatus == SDB_STATUS_CREATING) {
statusStr = "creating";
@@ -1552,7 +1591,6 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
statusStr = "unsynced";
}
}
-
char statusVstr[24] = {0};
STR_WITH_SIZE_TO_VARSTR(statusVstr, statusStr, strlen(statusStr));
@@ -1561,8 +1599,12 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, i);
if (i == 0) {
colDataAppend(pColInfo, rows, buf, false);
+ } else if (i == 1) {
+ colDataAppend(pColInfo, rows, (const char *)&pDb->createdTime, false);
} else if (i == 3) {
colDataAppend(pColInfo, rows, (const char *)&numOfTables, false);
+ } else if (i == 14) {
+ colDataAppend(pColInfo, rows, precVstr, false);
} else if (i == 15) {
colDataAppend(pColInfo, rows, statusVstr, false);
} else {
@@ -1627,23 +1669,6 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.compression, false);
- const char *precStr = NULL;
- switch (pDb->cfg.precision) {
- case TSDB_TIME_PRECISION_MILLI:
- precStr = TSDB_TIME_PRECISION_MILLI_STR;
- break;
- case TSDB_TIME_PRECISION_MICRO:
- precStr = TSDB_TIME_PRECISION_MICRO_STR;
- break;
- case TSDB_TIME_PRECISION_NANO:
- precStr = TSDB_TIME_PRECISION_NANO_STR;
- break;
- default:
- precStr = "none";
- break;
- }
- char precVstr[10] = {0};
- STR_WITH_SIZE_TO_VARSTR(precVstr, precStr, 2);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)precVstr, false);
@@ -1691,23 +1716,33 @@ static void mndDumpDbInfoData(SMnode *pMnode, SSDataBlock *pBlock, SDbObj *pDb,
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.sstTrigger, false);
+
+ pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
+ int16_t hashPrefix = pDb->cfg.hashPrefix;
+ if (hashPrefix > 0) {
+ hashPrefix = pDb->cfg.hashPrefix - strlen(pDb->name) - 1;
+ }
+ colDataAppend(pColInfo, rows, (const char *)&hashPrefix, false);
+
+ pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
+ colDataAppend(pColInfo, rows, (const char *)&pDb->cfg.hashSuffix, false);
}
taosMemoryFree(buf);
}
-static void setInformationSchemaDbCfg(SDbObj *pDbObj) {
+static void setInformationSchemaDbCfg(SMnode *pMnode, SDbObj *pDbObj) {
tstrncpy(pDbObj->name, TSDB_INFORMATION_SCHEMA_DB, tListLen(pDbObj->name));
- pDbObj->createdTime = 0;
+ pDbObj->createdTime = mndGetClusterCreateTime(pMnode);
pDbObj->cfg.numOfVgroups = 0;
pDbObj->cfg.strict = 1;
pDbObj->cfg.replications = 1;
pDbObj->cfg.precision = TSDB_TIME_PRECISION_MILLI;
}
-static void setPerfSchemaDbCfg(SDbObj *pDbObj) {
+static void setPerfSchemaDbCfg(SMnode *pMnode, SDbObj *pDbObj) {
tstrncpy(pDbObj->name, TSDB_PERFORMANCE_SCHEMA_DB, tListLen(pDbObj->name));
- pDbObj->createdTime = 0;
+ pDbObj->createdTime = mndGetClusterCreateTime(pMnode);
pDbObj->cfg.numOfVgroups = 0;
pDbObj->cfg.strict = 1;
pDbObj->cfg.replications = 1;
@@ -1738,7 +1773,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
// Append the information_schema database into the result.
if (!pShow->sysDbRsp) {
SDbObj infoschemaDb = {0};
- setInformationSchemaDbCfg(&infoschemaDb);
+ setInformationSchemaDbCfg(pMnode, &infoschemaDb);
size_t numOfTables = 0;
getVisibleInfosTablesNum(sysinfo, &numOfTables);
mndDumpDbInfoData(pMnode, pBlock, &infoschemaDb, pShow, numOfRows, numOfTables, true, 0, 1);
@@ -1746,7 +1781,7 @@ static int32_t mndRetrieveDbs(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc
numOfRows += 1;
SDbObj perfschemaDb = {0};
- setPerfSchemaDbCfg(&perfschemaDb);
+ setPerfSchemaDbCfg(pMnode, &perfschemaDb);
numOfTables = 0;
getPerfDbMeta(NULL, &numOfTables);
mndDumpDbInfoData(pMnode, pBlock, &perfschemaDb, pShow, numOfRows, numOfTables, true, 0, 1);
diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c
index fc5e20ef28..26b4080d14 100644
--- a/source/dnode/mnode/impl/src/mndDnode.c
+++ b/source/dnode/mnode/impl/src/mndDnode.c
@@ -347,6 +347,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) {
SVgObj *pVgroup = mndAcquireVgroup(pMnode, pVload->vgId);
if (pVgroup != NULL) {
if (pVload->syncState == TAOS_SYNC_STATE_LEADER) {
+ pVgroup->cacheUsage = pVload->cacheUsage;
pVgroup->numOfTables = pVload->numOfTables;
pVgroup->numOfTimeSeries = pVload->numOfTimeSeries;
pVgroup->totalStorage = pVload->totalStorage;
@@ -853,8 +854,8 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
}
int32_t code = -1;
- SSdb *pSdb = pMnode->pSdb;
- void *pIter = NULL;
+ SSdb *pSdb = pMnode->pSdb;
+ void *pIter = NULL;
while (1) {
SDnodeObj *pDnode = NULL;
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
@@ -877,7 +878,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
sdbRelease(pSdb, pDnode);
}
-
+
if (code == -1) {
terrno = TSDB_CODE_MND_DNODE_NOT_EXIST;
}
diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c
index f54e831b0b..de29dea511 100644
--- a/source/dnode/mnode/impl/src/mndVgroup.c
+++ b/source/dnode/mnode/impl/src/mndVgroup.c
@@ -235,6 +235,8 @@ void *mndBuildCreateVnodeReq(SMnode *pMnode, SDnodeObj *pDnode, SDbObj *pDb, SVg
createReq.walRollPeriod = pDb->cfg.walRollPeriod;
createReq.walSegmentSize = pDb->cfg.walSegmentSize;
createReq.sstTrigger = pDb->cfg.sstTrigger;
+ createReq.hashPrefix = pDb->cfg.hashPrefix;
+ createReq.hashSuffix = pDb->cfg.hashSuffix;
for (int32_t v = 0; v < pVgroup->replica; ++v) {
SReplica *pReplica = &createReq.replicas[v];
@@ -694,6 +696,9 @@ static int32_t mndRetrieveVgroups(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *p
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppendNULL(pColInfo, numOfRows);
+ pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
+ colDataAppend(pColInfo, numOfRows, (const char *)&pVgroup->cacheUsage, false);
+
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
colDataAppendNULL(pColInfo, numOfRows);
diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt
index a3e17f5377..7a99d26683 100644
--- a/source/dnode/vnode/CMakeLists.txt
+++ b/source/dnode/vnode/CMakeLists.txt
@@ -29,6 +29,7 @@ target_sources(
# sma
"src/sma/smaEnv.c"
"src/sma/smaUtil.c"
+ "src/sma/smaFS.c"
"src/sma/smaOpen.c"
"src/sma/smaCommit.c"
"src/sma/smaRollup.c"
@@ -49,6 +50,10 @@ target_sources(
"src/tsdb/tsdbSnapshot.c"
"src/tsdb/tsdbCacheRead.c"
"src/tsdb/tsdbRetention.c"
+ "src/tsdb/tsdbDiskData.c"
+ "src/tsdb/tsdbCompress.c"
+ "src/tsdb/tsdbCompact.c"
+ "src/tsdb/tsdbMergeTree.c"
# tq
"src/tq/tq.c"
diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h
index a1c2265c2e..6ba10641f5 100644
--- a/source/dnode/vnode/inc/vnode.h
+++ b/source/dnode/vnode/inc/vnode.h
@@ -125,6 +125,9 @@ int32_t metaTbCursorNext(SMTbCursor *pTbCur);
// typedef struct STsdb STsdb;
typedef struct STsdbReader STsdbReader;
+#define TSDB_DEFAULT_STT_FILE 8
+#define TSDB_DEFAULT_PAGE_SIZE 4096
+
#define TIMEWINDOW_RANGE_CONTAINED 1
#define TIMEWINDOW_RANGE_EXTERNAL 2
@@ -155,6 +158,7 @@ int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int6
void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity);
size_t tsdbCacheGetCapacity(SVnode *pVnode);
+size_t tsdbCacheGetUsage(SVnode *pVnode);
// tq
typedef struct SMetaTableInfo {
@@ -287,7 +291,10 @@ struct SVnodeCfg {
SVnodeStats vndStats;
uint32_t hashBegin;
uint32_t hashEnd;
- int16_t sstTrigger;
+ int16_t sttTrigger;
+ int16_t hashPrefix;
+ int16_t hashSuffix;
+ int32_t tsdbPageSize;
};
typedef struct {
diff --git a/source/dnode/vnode/src/inc/sma.h b/source/dnode/vnode/src/inc/sma.h
index c29c4cb6c4..9931462e5f 100644
--- a/source/dnode/vnode/src/inc/sma.h
+++ b/source/dnode/vnode/src/inc/sma.h
@@ -38,9 +38,10 @@ typedef struct SSmaEnv SSmaEnv;
typedef struct SSmaStat SSmaStat;
typedef struct STSmaStat STSmaStat;
typedef struct SRSmaStat SRSmaStat;
-typedef struct SSmaKey SSmaKey;
+typedef struct SRSmaRef SRSmaRef;
typedef struct SRSmaInfo SRSmaInfo;
typedef struct SRSmaInfoItem SRSmaInfoItem;
+typedef struct SRSmaFS SRSmaFS;
typedef struct SQTaskFile SQTaskFile;
typedef struct SQTaskFReader SQTaskFReader;
typedef struct SQTaskFWriter SQTaskFWriter;
@@ -54,10 +55,21 @@ struct SSmaEnv {
#define SMA_ENV_FLG_CLOSE ((int8_t)0x1)
+struct SRSmaRef {
+ int64_t refId; // for SRSmaStat
+ int64_t suid;
+};
+
typedef struct {
int8_t inited;
int32_t rsetId;
void *tmrHandle; // shared by all fetch tasks
+ /**
+ * @brief key: void* of SRSmaInfoItem, value: SRSmaRef
+ * N.B. Although there is a very small possibility that "void*" point to different objects while with the same
+ * address after release/renew, the functionality is not affected as it just used to fetch the rsma results.
+ */
+ SHashObj *refHash; // shared by all vgroups
} SSmaMgmt;
#define SMA_ENV_LOCK(env) (&(env)->lock)
@@ -73,20 +85,25 @@ struct STSmaStat {
struct SQTaskFile {
volatile int32_t nRef;
- int64_t commitID;
+ int32_t padding;
+ int64_t version;
int64_t size;
};
struct SQTaskFReader {
- SSma *pSma;
- SQTaskFile fTask;
- TdFilePtr pReadH;
+ SSma *pSma;
+ int64_t version;
+ TdFilePtr pReadH;
};
struct SQTaskFWriter {
- SSma *pSma;
- SQTaskFile fTask;
- TdFilePtr pWriteH;
- char *fname;
+ SSma *pSma;
+ int64_t version;
+ TdFilePtr pWriteH;
+ char *fname;
+};
+
+struct SRSmaFS {
+ SArray *aQTaskInf; // array of SQTaskFile
};
struct SRSmaStat {
@@ -96,9 +113,10 @@ struct SRSmaStat {
volatile int64_t nBufItems; // number of items in queue buffer
SRWLatch lock; // r/w lock for rsma fs(e.g. qtaskinfo)
volatile int32_t nFetchAll; // active number of fetch all
- int8_t triggerStat; // shared by fetch tasks
- int8_t commitStat; // 0 not in committing, 1 in committing
- SArray *aTaskFile; // qTaskFiles committed recently(for recovery/snapshot r/w)
+ volatile int8_t triggerStat; // shared by fetch tasks
+ volatile int8_t commitStat; // 0 not in committing, 1 in committing
+ volatile int8_t delFlag; // 0 no deleted SRSmaInfo, 1 has deleted SRSmaInfo
+ SRSmaFS fs; // for recovery/snapshot r/w
SHashObj *infoHash; // key: suid, value: SRSmaInfo
tsem_t notEmpty; // has items in queue buffer
};
@@ -118,21 +136,22 @@ struct SSmaStat {
#define RSMA_TRIGGER_STAT(r) (&(r)->triggerStat)
#define RSMA_COMMIT_STAT(r) (&(r)->commitStat)
#define RSMA_REF_ID(r) ((r)->refId)
+#define RSMA_FS(r) (&(r)->fs)
#define RSMA_FS_LOCK(r) (&(r)->lock)
struct SRSmaInfoItem {
int8_t level : 4;
int8_t fetchLevel : 4;
int8_t triggerStat;
- uint16_t nSkipped;
+ uint16_t nScanned;
int32_t maxDelay; // ms
tmr_h tmrId;
};
struct SRSmaInfo {
+ SSma *pSma;
STSchema *pTSchema;
int64_t suid;
- int64_t refId; // refId of SRSmaStat
int64_t lastRecv; // ms
int8_t assigned; // 0 idle, 1 assgined for exec
int8_t delFlag;
@@ -163,14 +182,6 @@ enum {
TASK_TRIGGER_STAT_DROPPED = 5,
};
-enum {
- RSMA_ROLE_CREATE = 0,
- RSMA_ROLE_DROP = 1,
- RSMA_ROLE_SUBMIT = 2,
- RSMA_ROLE_FETCH = 3,
- RSMA_ROLE_ITERATE = 4,
-};
-
enum {
RSMA_RESTORE_REBOOT = 1,
RSMA_RESTORE_SYNC = 2,
@@ -182,89 +193,49 @@ typedef enum {
RSMA_EXEC_COMMIT = 3, // triggered by commit
} ERsmaExecType;
-void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
-void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
-
-int32_t tdDropTSma(SSma *pSma, char *pMsg);
-int32_t tdDropTSmaData(SSma *pSma, int64_t indexUid);
-int32_t tdInsertRSmaData(SSma *pSma, char *msg);
-
-int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat);
-int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat);
-int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
-int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo);
-
+// sma
+int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
+void tdDestroySmaEnv(SSmaEnv *pSmaEnv);
+void *tdFreeSmaEnv(SSmaEnv *pSmaEnv);
+int32_t tdLockSma(SSma *pSma);
+int32_t tdUnLockSma(SSma *pSma);
void *tdAcquireSmaRef(int32_t rsetId, int64_t refId);
int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId);
-int32_t tdCheckAndInitSmaEnv(SSma *pSma, int8_t smaType);
-
-int32_t tdLockSma(SSma *pSma);
-int32_t tdUnLockSma(SSma *pSma);
-
-static FORCE_INLINE int8_t tdSmaStat(STSmaStat *pTStat) {
- if (pTStat) {
- return atomic_load_8(&pTStat->state);
- }
- return TSDB_SMA_STAT_UNKNOWN;
+static FORCE_INLINE void tdRefSmaStat(SSma *pSma, SSmaStat *pStat) {
+ int32_t ref = T_REF_INC(pStat);
+ smaDebug("vgId:%d, ref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref);
+}
+static FORCE_INLINE void tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
+ int32_t ref = T_REF_DEC(pStat);
+ smaDebug("vgId:%d, unref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref);
}
-static FORCE_INLINE bool tdSmaStatIsOK(STSmaStat *pTStat, int8_t *state) {
- if (!pTStat) {
- return false;
- }
+// rsma
+void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
+int32_t tdRSmaFSOpen(SSma *pSma, int64_t version);
+void tdRSmaFSClose(SRSmaFS *fs);
+int32_t tdRSmaFSRef(SSma *pSma, SRSmaStat *pStat, int64_t version);
+void tdRSmaFSUnRef(SSma *pSma, SRSmaStat *pStat, int64_t version);
+int64_t tdRSmaFSMaxVer(SSma *pSma, SRSmaStat *pStat);
+int32_t tdRSmaFSUpsertQTaskFile(SRSmaFS *pFS, SQTaskFile *qTaskFile);
+int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer);
+int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
+int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type);
+int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
+int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer);
+void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName);
+void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName);
- if (state) {
- *state = atomic_load_8(&pTStat->state);
- return *state == TSDB_SMA_STAT_OK;
- }
- return atomic_load_8(&pTStat->state) == TSDB_SMA_STAT_OK;
+static FORCE_INLINE void tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
+ int32_t ref = T_REF_INC(pRSmaInfo);
+ smaDebug("vgId:%d, ref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
}
-
-static FORCE_INLINE bool tdSmaStatIsExpired(STSmaStat *pTStat) {
- return pTStat ? (atomic_load_8(&pTStat->state) & TSDB_SMA_STAT_EXPIRED) : true;
+static FORCE_INLINE void tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
+ int32_t ref = T_REF_DEC(pRSmaInfo);
+ smaDebug("vgId:%d, unref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
}
-static FORCE_INLINE bool tdSmaStatIsDropped(STSmaStat *pTStat) {
- return pTStat ? (atomic_load_8(&pTStat->state) & TSDB_SMA_STAT_DROPPED) : true;
-}
-
-static FORCE_INLINE void tdSmaStatSetOK(STSmaStat *pTStat) {
- if (pTStat) {
- atomic_store_8(&pTStat->state, TSDB_SMA_STAT_OK);
- }
-}
-
-static FORCE_INLINE void tdSmaStatSetExpired(STSmaStat *pTStat) {
- if (pTStat) {
- atomic_or_fetch_8(&pTStat->state, TSDB_SMA_STAT_EXPIRED);
- }
-}
-
-static FORCE_INLINE void tdSmaStatSetDropped(STSmaStat *pTStat) {
- if (pTStat) {
- atomic_or_fetch_8(&pTStat->state, TSDB_SMA_STAT_DROPPED);
- }
-}
-
-void tdRSmaQTaskInfoGetFileName(int32_t vid, int64_t version, char *outputName);
-void tdRSmaQTaskInfoGetFullName(int32_t vid, int64_t version, const char *path, char *outputName);
-int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pInfo);
-void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
-static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
-void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
-void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree);
-int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash);
-int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type);
-
-int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName);
-int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer);
-int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer);
-
-int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg);
-int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg);
-int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
-
// smaFileUtil ================
#define TD_FILE_HEAD_SIZE 512
diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h
index d1f5cfb122..a836fa2bc5 100644
--- a/source/dnode/vnode/src/inc/tsdb.h
+++ b/source/dnode/vnode/src/inc/tsdb.h
@@ -42,15 +42,15 @@ typedef struct SMemTable SMemTable;
typedef struct STbDataIter STbDataIter;
typedef struct SMapData SMapData;
typedef struct SBlockIdx SBlockIdx;
-typedef struct SBlock SBlock;
-typedef struct SBlockL SBlockL;
+typedef struct SDataBlk SDataBlk;
+typedef struct SSttBlk SSttBlk;
typedef struct SColData SColData;
typedef struct SDiskDataHdr SDiskDataHdr;
typedef struct SBlockData SBlockData;
typedef struct SDelFile SDelFile;
typedef struct SHeadFile SHeadFile;
typedef struct SDataFile SDataFile;
-typedef struct SLastFile SLastFile;
+typedef struct SSttFile SSttFile;
typedef struct SSmaFile SSmaFile;
typedef struct SDFileSet SDFileSet;
typedef struct SDataFWriter SDataFWriter;
@@ -64,6 +64,8 @@ typedef struct STsdbReadSnap STsdbReadSnap;
typedef struct SBlockInfo SBlockInfo;
typedef struct SSmaInfo SSmaInfo;
typedef struct SBlockCol SBlockCol;
+typedef struct SVersionRange SVersionRange;
+typedef struct SLDataIter SLDataIter;
#define TSDB_FILE_DLMT ((uint32_t)0xF00AFA0F)
#define TSDB_MAX_SUBBLOCKS 8
@@ -79,6 +81,27 @@ typedef struct SBlockCol SBlockCol;
#define TSDBKEY_MIN ((TSDBKEY){.ts = TSKEY_MIN, .version = VERSION_MIN})
#define TSDBKEY_MAX ((TSDBKEY){.ts = TSKEY_MAX, .version = VERSION_MAX})
+#define TABLE_SAME_SCHEMA(SUID1, UID1, SUID2, UID2) ((SUID1) ? (SUID1) == (SUID2) : (UID1) == (UID2))
+
+#define PAGE_CONTENT_SIZE(PAGE) ((PAGE) - sizeof(TSCKSUM))
+#define LOGIC_TO_FILE_OFFSET(LOFFSET, PAGE) \
+ ((LOFFSET) / PAGE_CONTENT_SIZE(PAGE) * (PAGE) + (LOFFSET) % PAGE_CONTENT_SIZE(PAGE))
+#define FILE_TO_LOGIC_OFFSET(OFFSET, PAGE) ((OFFSET) / (PAGE)*PAGE_CONTENT_SIZE(PAGE) + (OFFSET) % (PAGE))
+#define PAGE_OFFSET(PGNO, PAGE) (((PGNO)-1) * (PAGE))
+#define OFFSET_PGNO(OFFSET, PAGE) ((OFFSET) / (PAGE) + 1)
+
+static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
+ int64_t fOffSet = LOGIC_TO_FILE_OFFSET(lSize, szPage);
+ int64_t pgno = OFFSET_PGNO(fOffSet, szPage);
+ int32_t szPageCont = PAGE_CONTENT_SIZE(szPage);
+
+ if (fOffSet % szPageCont == 0) {
+ pgno--;
+ }
+
+ return pgno * szPage;
+}
+
// tsdbUtil.c ==============================================================================================
// TSDBROW
#define TSDBROW_TS(ROW) (((ROW)->type == 0) ? (ROW)->pTSRow->ts : (ROW)->pBlockData->aTSKEY[(ROW)->iRow])
@@ -111,15 +134,15 @@ int32_t tTABLEIDCmprFn(const void *p1, const void *p2);
int32_t tPutBlockCol(uint8_t *p, void *ph);
int32_t tGetBlockCol(uint8_t *p, void *ph);
int32_t tBlockColCmprFn(const void *p1, const void *p2);
-// SBlock
-void tBlockReset(SBlock *pBlock);
-int32_t tPutBlock(uint8_t *p, void *ph);
-int32_t tGetBlock(uint8_t *p, void *ph);
-int32_t tBlockCmprFn(const void *p1, const void *p2);
-bool tBlockHasSma(SBlock *pBlock);
-// SBlockL
-int32_t tPutBlockL(uint8_t *p, void *ph);
-int32_t tGetBlockL(uint8_t *p, void *ph);
+// SDataBlk
+void tDataBlkReset(SDataBlk *pBlock);
+int32_t tPutDataBlk(uint8_t *p, void *ph);
+int32_t tGetDataBlk(uint8_t *p, void *ph);
+int32_t tDataBlkCmprFn(const void *p1, const void *p2);
+bool tDataBlkHasSma(SDataBlk *pDataBlk);
+// SSttBlk
+int32_t tPutSttBlk(uint8_t *p, void *ph);
+int32_t tGetSttBlk(uint8_t *p, void *ph);
// SBlockIdx
int32_t tPutBlockIdx(uint8_t *p, void *ph);
int32_t tGetBlockIdx(uint8_t *p, void *ph);
@@ -170,6 +193,7 @@ int32_t tGetDelData(uint8_t *p, void *ph);
void tMapDataReset(SMapData *pMapData);
void tMapDataClear(SMapData *pMapData);
int32_t tMapDataPutItem(SMapData *pMapData, void *pItem, int32_t (*tPutItemFn)(uint8_t *, void *));
+int32_t tMapDataCopy(SMapData *pFrom, SMapData *pTo);
void tMapDataGetItemByIdx(SMapData *pMapData, int32_t idx, void *pItem, int32_t (*tGetItemFn)(uint8_t *, void *));
int32_t tMapDataSearch(SMapData *pMapData, void *pSearchItem, int32_t (*tGetItemFn)(uint8_t *, void *),
int32_t (*tItemCmprFn)(const void *, const void *), void *pItem);
@@ -191,7 +215,6 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
uint8_t **ppBuf);
int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, int32_t nVal, SColData *pColData,
uint8_t **ppBuf);
-int32_t tsdbReadAndCheck(TdFilePtr pFD, int64_t offset, uint8_t **ppOut, int32_t size, int8_t toCheck);
// tsdbMemTable ==============================================================================================
// SMemTable
int32_t tsdbMemTableCreate(STsdb *pTsdb, SMemTable **ppMemTable);
@@ -215,7 +238,7 @@ bool tsdbDelFileIsSame(SDelFile *pDelFile1, SDelFile *pDelFile2);
int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype);
int32_t tPutHeadFile(uint8_t *p, SHeadFile *pHeadFile);
int32_t tPutDataFile(uint8_t *p, SDataFile *pDataFile);
-int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile);
+int32_t tPutSttFile(uint8_t *p, SSttFile *pSttFile);
int32_t tPutSmaFile(uint8_t *p, SSmaFile *pSmaFile);
int32_t tPutDelFile(uint8_t *p, SDelFile *pDelFile);
int32_t tGetDelFile(uint8_t *p, SDelFile *pDelFile);
@@ -224,7 +247,7 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet);
void tsdbHeadFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SHeadFile *pHeadF, char fname[]);
void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF, char fname[]);
-void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]);
+void tsdbSttFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSttFile *pSttF, char fname[]);
void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]);
// SDelFile
void tsdbDelFileName(STsdb *pTsdb, SDelFile *pFile, char fname[]);
@@ -249,8 +272,8 @@ int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pS
int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync);
int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter);
int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx);
-int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *pMapData, SBlockIdx *pBlockIdx);
-int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL);
+int32_t tsdbWriteDataBlk(SDataFWriter *pWriter, SMapData *mDataBlk, SBlockIdx *pBlockIdx);
+int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk);
int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlockInfo *pBlkInfo, SSmaInfo *pSmaInfo,
int8_t cmprAlg, int8_t toLast);
@@ -259,11 +282,11 @@ int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo);
int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet);
int32_t tsdbDataFReaderClose(SDataFReader **ppReader);
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx);
-int32_t tsdbReadBlock(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *pMapData);
-int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL);
-int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnDataAgg);
-int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBlockData);
-int32_t tsdbReadLastBlock(SDataFReader *pReader, SBlockL *pBlockL, SBlockData *pBlockData);
+int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mDataBlk);
+int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk);
+int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pBlock, SArray *aColumnDataAgg);
+int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pBlock, SBlockData *pBlockData);
+int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData);
// SDelFWriter
int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb);
int32_t tsdbDelFWriterClose(SDelFWriter **ppWriter, int8_t sync);
@@ -278,6 +301,8 @@ int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx);
// tsdbRead.c ==============================================================================================
int32_t tsdbTakeReadSnap(STsdb *pTsdb, STsdbReadSnap **ppSnap);
void tsdbUntakeReadSnap(STsdb *pTsdb, STsdbReadSnap *pSnap);
+// tsdbMerge.c ==============================================================================================
+int32_t tsdbMerge(STsdb *pTsdb);
#define TSDB_CACHE_NO(c) ((c).cacheLast == 0)
#define TSDB_CACHE_LAST_ROW(c) (((c).cacheLast & 1) > 0)
@@ -324,6 +349,11 @@ struct TSDBKEY {
TSKEY ts;
};
+struct SVersionRange {
+ uint64_t minVer;
+ uint64_t maxVer;
+};
+
typedef struct SMemSkipListNode SMemSkipListNode;
struct SMemSkipListNode {
int8_t level;
@@ -416,7 +446,7 @@ struct SSmaInfo {
int32_t size;
};
-struct SBlock {
+struct SDataBlk {
TSDBKEY minKey;
TSDBKEY maxKey;
int64_t minVer;
@@ -428,7 +458,7 @@ struct SBlock {
SSmaInfo smaInfo;
};
-struct SBlockL {
+struct SSttBlk {
int64_t suid;
int64_t minUid;
int64_t maxUid;
@@ -467,12 +497,6 @@ struct SBlockData {
SArray *aColData; // SArray
};
-// ================== TSDB global config
-extern bool tsdbForceKeepFile;
-
-#define TSDB_FS_ITER_FORWARD TSDB_ORDER_ASC
-#define TSDB_FS_ITER_BACKWARD TSDB_ORDER_DESC
-
struct TABLEID {
tb_uid_t suid;
tb_uid_t uid;
@@ -536,7 +560,7 @@ struct SDataFile {
int64_t size;
};
-struct SLastFile {
+struct SSttFile {
volatile int32_t nRef;
int64_t commitID;
@@ -556,8 +580,9 @@ struct SDFileSet {
int32_t fid;
SHeadFile *pHeadF;
SDataFile *pDataF;
- SLastFile *pLastF;
SSmaFile *pSmaF;
+ uint8_t nSttF;
+ SSttFile *aSttF[TSDB_MAX_STT_TRIGGER];
};
struct SRowIter {
@@ -572,37 +597,99 @@ struct SRowMerger {
SArray *pArray; // SArray
};
+typedef struct {
+ char *path;
+ int32_t szPage;
+ int32_t flag;
+ TdFilePtr pFD;
+ int64_t pgno;
+ uint8_t *pBuf;
+ int64_t szFile;
+} STsdbFD;
+
struct SDelFWriter {
- STsdb *pTsdb;
- SDelFile fDel;
- TdFilePtr pWriteH;
-
+ STsdb *pTsdb;
+ SDelFile fDel;
+ STsdbFD *pWriteH;
uint8_t *aBuf[1];
};
-struct SDataFWriter {
- STsdb *pTsdb;
- SDFileSet wSet;
-
- TdFilePtr pHeadFD;
- TdFilePtr pDataFD;
- TdFilePtr pLastFD;
- TdFilePtr pSmaFD;
-
- SHeadFile fHead;
- SDataFile fData;
- SLastFile fLast;
- SSmaFile fSma;
-
- uint8_t *aBuf[4];
-};
-
struct STsdbReadSnap {
SMemTable *pMem;
SMemTable *pIMem;
STsdbFS fs;
};
+struct SDataFWriter {
+ STsdb *pTsdb;
+ SDFileSet wSet;
+
+ STsdbFD *pHeadFD;
+ STsdbFD *pDataFD;
+ STsdbFD *pSmaFD;
+ STsdbFD *pSttFD;
+
+ SHeadFile fHead;
+ SDataFile fData;
+ SSmaFile fSma;
+ SSttFile fStt[TSDB_MAX_STT_TRIGGER];
+
+ uint8_t *aBuf[4];
+};
+
+struct SDataFReader {
+ STsdb *pTsdb;
+ SDFileSet *pSet;
+ STsdbFD *pHeadFD;
+ STsdbFD *pDataFD;
+ STsdbFD *pSmaFD;
+ STsdbFD *aSttFD[TSDB_MAX_STT_TRIGGER];
+ uint8_t *aBuf[3];
+};
+
+typedef struct {
+ int64_t suid;
+ int64_t uid;
+ TSDBROW row;
+} SRowInfo;
+
+typedef struct SSttBlockLoadInfo {
+ SBlockData blockData[2];
+ SArray *aSttBlk;
+ int32_t blockIndex[2]; // to denote the loaded block in the corresponding position.
+ int32_t currentLoadBlockIndex;
+ int32_t loadBlocks;
+ double elapsedTime;
+} SSttBlockLoadInfo;
+
+typedef struct SMergeTree {
+ int8_t backward;
+ SRBTree rbt;
+ SArray *pIterList;
+ SLDataIter *pIter;
+ bool destroyLoadInfo;
+ SSttBlockLoadInfo *pLoadInfo;
+ const char *idStr;
+} SMergeTree;
+
+typedef struct {
+ int64_t suid;
+ int64_t uid;
+ STSchema *pTSchema;
+} SSkmInfo;
+
+int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid,
+ STimeWindow *pTimeWindow, SVersionRange *pVerRange, void *pLoadInfo, const char *idStr);
+void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter);
+bool tMergeTreeNext(SMergeTree *pMTree);
+TSDBROW tMergeTreeGetRow(SMergeTree *pMTree);
+void tMergeTreeClose(SMergeTree *pMTree);
+
+SSttBlockLoadInfo *tCreateLastBlockLoadInfo();
+void resetLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
+void getLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo, int64_t *blocks, double *el);
+void *destroyLastBlockLoadInfo(SSttBlockLoadInfo *pLoadInfo);
+
// ========== inline functions ==========
static FORCE_INLINE int32_t tsdbKeyCmprFn(const void *p1, const void *p2) {
TSDBKEY *pKey1 = (TSDBKEY *)p1;
diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h
index 9b252df58b..0e85e7bfb6 100644
--- a/source/dnode/vnode/src/inc/vnodeInt.h
+++ b/source/dnode/vnode/src/inc/vnodeInt.h
@@ -36,6 +36,7 @@
#include "tlosertree.h"
#include "tlrucache.h"
#include "tmsgcb.h"
+#include "trbtree.h"
#include "tref.h"
#include "tskiplist.h"
#include "tstream.h"
@@ -70,8 +71,8 @@ typedef struct SStreamTaskReader SStreamTaskReader;
typedef struct SStreamTaskWriter SStreamTaskWriter;
typedef struct SStreamStateReader SStreamStateReader;
typedef struct SStreamStateWriter SStreamStateWriter;
-typedef struct SRsmaSnapReader SRsmaSnapReader;
-typedef struct SRsmaSnapWriter SRsmaSnapWriter;
+typedef struct SRSmaSnapReader SRSmaSnapReader;
+typedef struct SRSmaSnapWriter SRSmaSnapWriter;
typedef struct SSnapDataHdr SSnapDataHdr;
#define VNODE_META_DIR "meta"
@@ -102,8 +103,8 @@ int metaCommit(SMeta* pMeta);
int metaCreateSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
int metaAlterSTable(SMeta* pMeta, int64_t version, SVCreateStbReq* pReq);
int metaDropSTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq, SArray* tbUidList);
-int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp **pMetaRsp);
-int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids);
+int metaCreateTable(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** pMetaRsp);
+int metaDropTable(SMeta* pMeta, int64_t version, SVDropTbReq* pReq, SArray* tbUids, int64_t* tbUid);
int metaTtlDropTable(SMeta* pMeta, int64_t ttl, SArray* tbUids);
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
SSchemaWrapper* metaGetTableSchema(SMeta* pMeta, tb_uid_t uid, int32_t sver, bool isinline);
@@ -173,7 +174,8 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg);
// tq-stream
int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
int32_t tqProcessTaskDropReq(STQ* pTq, int64_t version, char* msg, int32_t msgLen);
-int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* data, int64_t ver);
+int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* data, int64_t ver);
+int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver);
int32_t tqProcessTaskRunReq(STQ* pTq, SRpcMsg* pMsg);
int32_t tqProcessTaskDispatchReq(STQ* pTq, SRpcMsg* pMsg, bool exec);
int32_t tqProcessTaskRecoverReq(STQ* pTq, SRpcMsg* pMsg);
@@ -206,7 +208,7 @@ int32_t tdProcessRSmaCreate(SSma* pSma, SVCreateStbReq* pReq);
int32_t tdProcessRSmaSubmit(SSma* pSma, void* pMsg, int32_t inputType);
int32_t tdProcessRSmaDrop(SSma* pSma, SVDropStbReq* pReq);
int32_t tdFetchTbUidList(SSma* pSma, STbUidStore** ppStore, tb_uid_t suid, tb_uid_t uid);
-int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore);
+int32_t tdUpdateTbUidList(SSma* pSma, STbUidStore* pUidStore, bool isAdd);
void tdUidStoreDestory(STbUidStore* pStore);
void* tdUidStoreFree(STbUidStore* pStore);
@@ -246,14 +248,14 @@ int32_t tqOffsetSnapWrite(STqOffsetWriter* pWriter, uint8_t* pData, uint32_t nDa
// SStreamTaskReader ======================================
// SStreamStateWriter =====================================
// SStreamStateReader =====================================
-// SRsmaSnapReader ========================================
-int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader);
-int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader);
-int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData);
-// SRsmaSnapWriter ========================================
-int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter);
-int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
-int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback);
+// SRSmaSnapReader ========================================
+int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapReader** ppReader);
+int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader);
+int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData);
+// SRSmaSnapWriter ========================================
+int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWriter** ppWriter);
+int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
+int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback);
typedef struct {
int8_t streamType; // sma or other
diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c
index c282f17116..a34569b08e 100644
--- a/source/dnode/vnode/src/meta/metaQuery.c
+++ b/source/dnode/vnode/src/meta/metaQuery.c
@@ -129,10 +129,16 @@ _err:
bool metaIsTableExist(SMeta *pMeta, tb_uid_t uid) {
// query uid.idx
+ metaRLock(pMeta);
+
if (tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), NULL, NULL) < 0) {
+ metaULock(pMeta);
+
return false;
}
+ metaULock(pMeta);
+
return true;
}
@@ -182,9 +188,14 @@ tb_uid_t metaGetTableEntryUidByName(SMeta *pMeta, const char *name) {
}
int metaGetTableNameByUid(void *meta, uint64_t uid, char *tbName) {
+ int code = 0;
SMetaReader mr = {0};
metaReaderInit(&mr, (SMeta *)meta, 0);
- metaGetTableEntryByUid(&mr, uid);
+ code = metaGetTableEntryByUid(&mr, uid);
+ if (code < 0) {
+ metaReaderClear(&mr);
+ return -1;
+ }
STR_TO_VARSTR(tbName, mr.me.name);
metaReaderClear(&mr);
diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c
index 583a2e098f..92cf90d328 100644
--- a/source/dnode/vnode/src/meta/metaTable.c
+++ b/source/dnode/vnode/src/meta/metaTable.c
@@ -416,20 +416,22 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
me.ctbEntry.pTags = pReq->ctb.pTag;
#ifdef TAG_FILTER_DEBUG
- SArray* pTagVals = NULL;
- int32_t code = tTagToValArray((STag*)pReq->ctb.pTag, &pTagVals);
+ SArray *pTagVals = NULL;
+ int32_t code = tTagToValArray((STag *)pReq->ctb.pTag, &pTagVals);
for (int i = 0; i < taosArrayGetSize(pTagVals); i++) {
- STagVal* pTagVal = (STagVal*)taosArrayGet(pTagVals, i);
+ STagVal *pTagVal = (STagVal *)taosArrayGet(pTagVals, i);
if (IS_VAR_DATA_TYPE(pTagVal->type)) {
- char* buf = taosMemoryCalloc(pTagVal->nData + 1, 1);
+ char *buf = taosMemoryCalloc(pTagVal->nData + 1, 1);
memcpy(buf, pTagVal->pData, pTagVal->nData);
- metaDebug("metaTag table:%s varchar index:%d cid:%d type:%d value:%s", pReq->name, i, pTagVal->cid, pTagVal->type, buf);
+ metaDebug("metaTag table:%s varchar index:%d cid:%d type:%d value:%s", pReq->name, i, pTagVal->cid,
+ pTagVal->type, buf);
taosMemoryFree(buf);
} else {
double val = 0;
GET_TYPED_DATA(val, double, pTagVal->type, &pTagVal->i64);
- metaDebug("metaTag table:%s number index:%d cid:%d type:%d value:%f", pReq->name, i, pTagVal->cid, pTagVal->type, val);
+ metaDebug("metaTag table:%s number index:%d cid:%d type:%d value:%f", pReq->name, i, pTagVal->cid,
+ pTagVal->type, val);
}
}
#endif
@@ -474,7 +476,7 @@ _err:
return -1;
}
-int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids) {
+int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids, tb_uid_t *tbUid) {
void *pData = NULL;
int nData = 0;
int rc = 0;
@@ -496,6 +498,10 @@ int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUi
taosArrayPush(tbUids, &uid);
}
+ if ((type == TSDB_CHILD_TABLE) && tbUid) {
+ *tbUid = uid;
+ }
+
tdbFree(pData);
return 0;
}
diff --git a/source/dnode/vnode/src/sma/smaCommit.c b/source/dnode/vnode/src/sma/smaCommit.c
index 3cf50a035a..07ec7d0694 100644
--- a/source/dnode/vnode/src/sma/smaCommit.c
+++ b/source/dnode/vnode/src/sma/smaCommit.c
@@ -15,13 +15,15 @@
#include "sma.h"
+extern SSmaMgmt smaMgmt;
+
static int32_t tdProcessRSmaSyncPreCommitImpl(SSma *pSma);
static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma);
static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma);
static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma);
static int32_t tdProcessRSmaAsyncCommitImpl(SSma *pSma);
static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma);
-static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
+static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat);
/**
* @brief Only applicable to Rollup SMA
@@ -166,114 +168,65 @@ static int32_t tdProcessRSmaSyncCommitImpl(SSma *pSma) {
return TSDB_CODE_SUCCESS;
}
-static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
- SVnode *pVnode = pSma->pVnode;
- int64_t committed = pRSmaStat->commitAppliedVer;
- TdDirPtr pDir = NULL;
- TdDirEntryPtr pDirEntry = NULL;
- char dir[TSDB_FILENAME_LEN];
- const char *pattern = "v[0-9]+qinf\\.v([0-9]+)?$";
- regex_t regex;
- int code = 0;
-
- tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir);
-
- // Resource allocation and init
- if ((code = regcomp(®ex, pattern, REG_EXTENDED)) != 0) {
- char errbuf[128];
- regerror(code, ®ex, errbuf, sizeof(errbuf));
- smaWarn("vgId:%d, rsma post commit, regcomp for %s failed since %s", TD_VID(pVnode), dir, errbuf);
- return TSDB_CODE_FAILED;
- }
-
- if ((pDir = taosOpenDir(dir)) == NULL) {
- regfree(®ex);
- terrno = TAOS_SYSTEM_ERROR(errno);
- smaDebug("vgId:%d, rsma post commit, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr());
- return TSDB_CODE_FAILED;
- }
-
- int32_t dirLen = strlen(dir);
- char *dirEnd = POINTER_SHIFT(dir, dirLen);
- regmatch_t regMatch[2];
- while ((pDirEntry = taosReadDir(pDir)) != NULL) {
- char *entryName = taosGetDirEntryName(pDirEntry);
- if (!entryName) {
- continue;
- }
-
- code = regexec(®ex, entryName, 2, regMatch, 0);
-
- if (code == 0) {
- // match
- int64_t version = -1;
- sscanf((const char *)POINTER_SHIFT(entryName, regMatch[1].rm_so), "%" PRIi64, &version);
- if ((version < committed) && (version > -1)) {
- strncpy(dirEnd, entryName, TSDB_FILENAME_LEN - dirLen);
- if (taosRemoveFile(dir) != 0) {
- terrno = TAOS_SYSTEM_ERROR(errno);
- smaWarn("vgId:%d, committed version:%" PRIi64 ", failed to remove %s since %s", TD_VID(pVnode), committed,
- dir, terrstr());
- } else {
- smaDebug("vgId:%d, committed version:%" PRIi64 ", success to remove %s", TD_VID(pVnode), committed, dir);
- }
- }
- } else if (code == REG_NOMATCH) {
- // not match
- smaTrace("vgId:%d, rsma post commit, not match %s", TD_VID(pVnode), entryName);
- continue;
- } else {
- // has other error
- char errbuf[128];
- regerror(code, ®ex, errbuf, sizeof(errbuf));
- smaWarn("vgId:%d, rsma post commit, regexec failed since %s", TD_VID(pVnode), errbuf);
-
- taosCloseDir(&pDir);
- regfree(®ex);
- return TSDB_CODE_FAILED;
- }
- }
-
- taosCloseDir(&pDir);
- regfree(®ex);
-
- return TSDB_CODE_SUCCESS;
-}
-
// SQTaskFile ======================================================
-// int32_t tCmprQTaskFile(void const *lhs, void const *rhs) {
-// int64_t *lCommitted = *(int64_t *)lhs;
-// SQTaskFile *rQTaskF = (SQTaskFile *)rhs;
-// if (lCommitted < rQTaskF->commitID) {
-// return -1;
-// } else if (lCommitted > rQTaskF->commitID) {
-// return 1;
-// }
-
-// return 0;
-// }
-
-#if 0
/**
* @brief At most time, there is only one qtaskinfo file committed latest in aTaskFile. Sometimes, there would be
* multiple qtaskinfo files supporting snapshot replication.
*
* @param pSma
- * @param pRSmaStat
+ * @param pStat
* @return int32_t
*/
-static int32_t tdCleanupQTaskInfoFiles(SSma *pSma, SRSmaStat *pRSmaStat) {
- SVnode *pVnode = pSma->pVnode;
- int64_t committed = pRSmaStat->commitAppliedVer;
- SArray *aTaskFile = pRSmaStat->aTaskFile;
+static int32_t tdUpdateQTaskInfoFiles(SSma *pSma, SRSmaStat *pStat) {
+ SVnode *pVnode = pSma->pVnode;
+ SRSmaFS *pFS = RSMA_FS(pStat);
+ int64_t committed = pStat->commitAppliedVer;
+ int64_t fsMaxVer = -1;
+ char qTaskInfoFullName[TSDB_FILENAME_LEN];
- void *qTaskFile = taosArraySearch(aTaskFile, committed, tCmprQTaskFile, TD_LE);
-
+ taosWLockLatch(RSMA_FS_LOCK(pStat));
+ for (int32_t i = 0; i < taosArrayGetSize(pFS->aQTaskInf);) {
+ SQTaskFile *pTaskF = taosArrayGet(pFS->aQTaskInf, i);
+ int32_t oldVal = atomic_fetch_sub_32(&pTaskF->nRef, 1);
+ if ((oldVal <= 1) && (pTaskF->version < committed)) {
+ tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->version, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
+ if (taosRemoveFile(qTaskInfoFullName) < 0) {
+ smaWarn("vgId:%d, cleanup qinf, committed %" PRIi64 ", failed to remove %s since %s", TD_VID(pVnode), committed,
+ qTaskInfoFullName, tstrerror(TAOS_SYSTEM_ERROR(errno)));
+ } else {
+ smaDebug("vgId:%d, cleanup qinf, committed %" PRIi64 ", success to remove %s", TD_VID(pVnode), committed,
+ qTaskInfoFullName);
+ }
+ taosArrayRemove(pFS->aQTaskInf, i);
+ continue;
+ }
+ ++i;
+ }
+
+ if (taosArrayGetSize(pFS->aQTaskInf) > 0) {
+ fsMaxVer = ((SQTaskFile *)taosArrayGetLast(pFS->aQTaskInf))->version;
+ }
+
+ if (fsMaxVer < committed) {
+ tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), committed, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
+ if (taosCheckExistFile(qTaskInfoFullName)) {
+ SQTaskFile qFile = {.nRef = 1, .padding = 0, .version = committed, .size = 0};
+ if (taosArrayPush(pFS->aQTaskInf, &qFile) < 0) {
+ taosWUnLockLatch(RSMA_FS_LOCK(pStat));
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return TSDB_CODE_FAILED;
+ }
+ }
+ } else {
+ smaDebug("vgId:%d, update qinf, no need as committed %" PRIi64 " not larger than fsMaxVer %" PRIi64, TD_VID(pVnode),
+ committed, fsMaxVer);
+ }
+
+ taosWUnLockLatch(RSMA_FS_LOCK(pStat));
return TSDB_CODE_SUCCESS;
}
-#endif
/**
* @brief post-commit for rollup sma
@@ -290,8 +243,7 @@ static int32_t tdProcessRSmaSyncPostCommitImpl(SSma *pSma) {
SRSmaStat *pRSmaStat = SMA_RSMA_STAT(pSma);
- // cleanup outdated qtaskinfo files
- tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
+ tdUpdateQTaskInfoFiles(pSma, pRSmaStat);
return TSDB_CODE_SUCCESS;
}
@@ -365,12 +317,12 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
if (tdRSmaPersistExecImpl(pRSmaStat, RSMA_INFO_HASH(pRSmaStat)) < 0) {
return TSDB_CODE_FAILED;
}
- smaInfo("vgId:%d, rsma commit, operator state commited, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
+ smaInfo("vgId:%d, rsma commit, operator state committed, TID:%p", SMA_VID(pSma), (void *)taosGetSelfPthreadId());
#if 0 // consuming task of qTaskInfo clone
// step 4: swap queue/qall and iQueue/iQall
// lock
- // taosWLockLatch(SMA_ENV_LOCK(pEnv));
+ taosWLockLatch(SMA_ENV_LOCK(pEnv));
ASSERT(RSMA_INFO_HASH(pRSmaStat));
@@ -386,7 +338,7 @@ static int32_t tdProcessRSmaAsyncPreCommitImpl(SSma *pSma) {
}
// unlock
- // taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
+ taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
#endif
return TSDB_CODE_SUCCESS;
@@ -428,33 +380,29 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
}
SRSmaStat *pRSmaStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
- SArray *rsmaDeleted = NULL;
// step 1: merge qTaskInfo and iQTaskInfo
// lock
- // taosWLockLatch(SMA_ENV_LOCK(pEnv));
+ if (1 == atomic_val_compare_exchange_8(&pRSmaStat->delFlag, 1, 0)) {
+ taosWLockLatch(SMA_ENV_LOCK(pEnv));
- void *pIter = NULL;
- while ((pIter = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), pIter))) {
- tb_uid_t *pSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
- SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)pIter;
- if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
- int32_t refVal = T_REF_VAL_GET(pRSmaInfo);
- if (refVal == 0) {
- if (!rsmaDeleted) {
- if ((rsmaDeleted = taosArrayInit(1, sizeof(tb_uid_t)))) {
- taosArrayPush(rsmaDeleted, pSuid);
- }
+ void *pIter = NULL;
+ while ((pIter = taosHashIterate(RSMA_INFO_HASH(pRSmaStat), pIter))) {
+ tb_uid_t *pSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
+ SRSmaInfo *pRSmaInfo = *(SRSmaInfo **)pIter;
+ if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
+ int32_t refVal = T_REF_VAL_GET(pRSmaInfo);
+ if (refVal == 0) {
+ taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(*pSuid));
+ } else {
+ smaDebug(
+ "vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
+ "table:%" PRIi64,
+ SMA_VID(pSma), refVal, *pSuid);
}
- } else {
- smaDebug(
- "vgId:%d, rsma async post commit, not free rsma info since ref is %d although already deleted for "
- "table:%" PRIi64,
- SMA_VID(pSma), refVal, *pSuid);
- }
- continue;
- }
+ continue;
+ }
#if 0
if (pRSmaInfo->taskInfo[0]) {
if (pRSmaInfo->iTaskInfo[0]) {
@@ -469,27 +417,13 @@ static int32_t tdProcessRSmaAsyncPostCommitImpl(SSma *pSma) {
taosHashPut(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t), pIter, sizeof(pIter));
smaDebug("vgId:%d, rsma async post commit, migrated from iRsmaInfoHash for table:%" PRIi64, SMA_VID(pSma), *pSuid);
#endif
- }
-
- for (int32_t i = 0; i < taosArrayGetSize(rsmaDeleted); ++i) {
- tb_uid_t *pSuid = taosArrayGet(rsmaDeleted, i);
- void *pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t));
- if ((pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
- tdFreeRSmaInfo(pSma, pRSmaInfo, true);
- smaDebug(
- "vgId:%d, rsma async post commit, free rsma info since already deleted and ref is 0 for "
- "table:%" PRIi64,
- SMA_VID(pSma), *pSuid);
}
- taosHashRemove(RSMA_INFO_HASH(pRSmaStat), pSuid, sizeof(tb_uid_t));
+
+ // unlock
+ taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
}
- taosArrayDestroy(rsmaDeleted);
- // unlock
- // taosWUnLockLatch(SMA_ENV_LOCK(pEnv));
-
- // step 2: cleanup outdated qtaskinfo files
- tdCleanupQTaskInfoFiles(pSma, pRSmaStat);
+ tdUpdateQTaskInfoFiles(pSma, pRSmaStat);
atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0);
diff --git a/source/dnode/vnode/src/sma/smaEnv.c b/source/dnode/vnode/src/sma/smaEnv.c
index 32a419022a..b870ea1b62 100644
--- a/source/dnode/vnode/src/sma/smaEnv.c
+++ b/source/dnode/vnode/src/sma/smaEnv.c
@@ -28,6 +28,8 @@ static int32_t tdInitSmaEnv(SSma *pSma, int8_t smaType, SSmaEnv **ppEnv);
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma);
static int32_t tdRsmaStartExecutor(const SSma *pSma);
static int32_t tdRsmaStopExecutor(const SSma *pSma);
+static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType);
+static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType);
static void *tdFreeTSmaStat(STSmaStat *pStat);
static void tdDestroyRSmaStat(void *pRSmaStat);
@@ -59,12 +61,23 @@ int32_t smaInit() {
return TSDB_CODE_FAILED;
}
+ int32_t type = (8 == POINTER_BYTES) ? TSDB_DATA_TYPE_UBIGINT : TSDB_DATA_TYPE_UINT;
+ smaMgmt.refHash = taosHashInit(64, taosGetDefaultHashFunction(type), true, HASH_ENTRY_LOCK);
+ if (!smaMgmt.refHash) {
+ taosCloseRef(smaMgmt.rsetId);
+ atomic_store_8(&smaMgmt.inited, 0);
+ smaError("failed to init sma tmr hanle since %s", terrstr());
+ return TSDB_CODE_FAILED;
+ }
+
// init fetch timer handle
smaMgmt.tmrHandle = taosTmrInit(10000, 100, 10000, "RSMA");
if (!smaMgmt.tmrHandle) {
taosCloseRef(smaMgmt.rsetId);
+ taosHashCleanup(smaMgmt.refHash);
+ smaMgmt.refHash = NULL;
atomic_store_8(&smaMgmt.inited, 0);
- smaError("failed to init sma tmr hanle since %s", terrstr());
+ smaError("failed to init sma tmr handle since %s", terrstr());
return TSDB_CODE_FAILED;
}
@@ -93,6 +106,8 @@ void smaCleanUp() {
if (old == 1) {
taosCloseRef(smaMgmt.rsetId);
+ taosHashCleanup(smaMgmt.refHash);
+ smaMgmt.refHash = NULL;
taosTmrCleanUp(smaMgmt.tmrHandle);
smaInfo("sma mgmt env is cleaned up, rsetId:%d, tmrHandle:%p", smaMgmt.rsetId, smaMgmt.tmrHandle);
atomic_store_8(&smaMgmt.inited, 0);
@@ -162,37 +177,19 @@ void *tdFreeSmaEnv(SSmaEnv *pSmaEnv) {
return NULL;
}
-int32_t tdRefSmaStat(SSma *pSma, SSmaStat *pStat) {
- if (!pStat) return 0;
+static void tRSmaInfoHashFreeNode(void *data) {
+ SRSmaInfo *pRSmaInfo = NULL;
+ SRSmaInfoItem *pItem = NULL;
- int ref = T_REF_INC(pStat);
- smaDebug("vgId:%d, ref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref);
- return 0;
-}
-
-int32_t tdUnRefSmaStat(SSma *pSma, SSmaStat *pStat) {
- if (!pStat) return 0;
-
- int ref = T_REF_DEC(pStat);
- smaDebug("vgId:%d, unref sma stat:%p, val:%d", SMA_VID(pSma), pStat, ref);
- return 0;
-}
-
-int32_t tdRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
- if (!pRSmaInfo) return 0;
-
- int ref = T_REF_INC(pRSmaInfo);
- smaDebug("vgId:%d, ref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
- return 0;
-}
-
-int32_t tdUnRefRSmaInfo(SSma *pSma, SRSmaInfo *pRSmaInfo) {
- if (!pRSmaInfo) return 0;
-
- int ref = T_REF_DEC(pRSmaInfo);
- smaDebug("vgId:%d, unref rsma info:%p, val:%d", SMA_VID(pSma), pRSmaInfo, ref);
-
- return 0;
+ if ((pRSmaInfo = *(SRSmaInfo **)data)) {
+ if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 0)) && pItem->level) {
+ taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
+ }
+ if ((pItem = RSMA_INFO_ITEM((SRSmaInfo *)pRSmaInfo, 1)) && pItem->level) {
+ taosHashRemove(smaMgmt.refHash, &pItem, POINTER_BYTES);
+ }
+ tdFreeRSmaInfo(pRSmaInfo->pSma, pRSmaInfo, true);
+ }
}
static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pSma) {
@@ -240,10 +237,16 @@ static int32_t tdInitSmaStat(SSmaStat **pSmaStat, int8_t smaType, const SSma *pS
if (!RSMA_INFO_HASH(pRSmaStat)) {
return TSDB_CODE_FAILED;
}
+ taosHashSetFreeFp(RSMA_INFO_HASH(pRSmaStat), tRSmaInfoHashFreeNode);
if (tdRsmaStartExecutor(pSma) < 0) {
return TSDB_CODE_FAILED;
}
+
+ if (!(RSMA_FS(pRSmaStat)->aQTaskInf = taosArrayInit(1, sizeof(SQTaskFile)))) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return TSDB_CODE_FAILED;
+ }
} else if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
// TODO
} else {
@@ -278,14 +281,6 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
tsem_destroy(&(pStat->notEmpty));
// step 2: destroy the rsma info and associated fetch tasks
- if (taosHashGetSize(RSMA_INFO_HASH(pStat)) > 0) {
- void *infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), NULL);
- while (infoHash) {
- SRSmaInfo *pSmaInfo = *(SRSmaInfo **)infoHash;
- tdFreeRSmaInfo(pSma, pSmaInfo, true);
- infoHash = taosHashIterate(RSMA_INFO_HASH(pStat), infoHash);
- }
- }
taosHashCleanup(RSMA_INFO_HASH(pStat));
// step 3: wait for all triggered fetch tasks to finish
@@ -307,12 +302,15 @@ static void tdDestroyRSmaStat(void *pRSmaStat) {
// step 4:
tdRsmaStopExecutor(pSma);
- // step 5: free pStat
+ // step 5:
+ tdRSmaFSClose(RSMA_FS(pStat));
+
+ // step 6: free pStat
taosMemoryFreeClear(pStat);
}
}
-void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
+static void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
tdDestroySmaState(pSmaStat, smaType);
if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
taosMemoryFreeClear(pSmaStat);
@@ -329,7 +327,7 @@ void *tdFreeSmaState(SSmaStat *pSmaStat, int8_t smaType) {
* @return int32_t
*/
-int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
+static int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
if (pSmaStat) {
if (smaType == TSDB_SMA_TYPE_TIME_RANGE) {
tdDestroyTSmaStat(SMA_STAT_TSMA(pSmaStat));
@@ -337,7 +335,7 @@ int32_t tdDestroySmaState(SSmaStat *pSmaStat, int8_t smaType) {
SRSmaStat *pRSmaStat = &pSmaStat->rsmaStat;
int32_t vid = SMA_VID(pRSmaStat->pSma);
int64_t refId = RSMA_REF_ID(pRSmaStat);
- if (taosRemoveRef(smaMgmt.rsetId, RSMA_REF_ID(pRSmaStat)) < 0) {
+ if (taosRemoveRef(smaMgmt.rsetId, refId) < 0) {
smaError("vgId:%d, remove refId:%" PRIi64 " from rsmaRef:%" PRIi32 " failed since %s", vid, refId,
smaMgmt.rsetId, terrstr());
} else {
@@ -461,6 +459,8 @@ static int32_t tdRsmaStopExecutor(const SSma *pSma) {
taosThreadJoin(pthread[i], NULL);
}
}
+
+ smaInfo("vgId:%d, rsma executor stopped, number:%d", SMA_VID(pSma), tsNumOfVnodeRsmaThreads);
}
return 0;
}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c
new file mode 100644
index 0000000000..8e8611f0e8
--- /dev/null
+++ b/source/dnode/vnode/src/sma/smaFS.c
@@ -0,0 +1,264 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "sma.h"
+
+// =================================================================================================
+
+static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **output);
+static int32_t tdQTaskInfCmprFn1(const void *p1, const void *p2);
+static int32_t tdQTaskInfCmprFn2(const void *p1, const void *p2);
+/**
+ * @brief Open RSma FS from qTaskInfo files
+ *
+ * @param pSma
+ * @param version
+ * @return int32_t
+ */
+int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) {
+ SVnode *pVnode = pSma->pVnode;
+ int64_t commitID = pVnode->state.commitID;
+ SSmaEnv *pEnv = SMA_RSMA_ENV(pSma);
+ SRSmaStat *pStat = NULL;
+ SArray *output = NULL;
+
+ terrno = TSDB_CODE_SUCCESS;
+
+ if (!pEnv) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ if (tdFetchQTaskInfoFiles(pSma, version, &output) < 0) {
+ goto _end;
+ }
+
+ pStat = (SRSmaStat *)SMA_ENV_STAT(pEnv);
+
+ for (int32_t i = 0; i < taosArrayGetSize(output); ++i) {
+ int32_t vid = 0;
+ int64_t version = -1;
+ sscanf((const char *)taosArrayGetP(output, i), "v%dqinf.v%" PRIi64, &vid, &version);
+ SQTaskFile qTaskFile = {.version = version, .nRef = 1};
+ if ((terrno = tdRSmaFSUpsertQTaskFile(RSMA_FS(pStat), &qTaskFile)) < 0) {
+ goto _end;
+ }
+ smaInfo("vgId:%d, open fs, version:%" PRIi64 ", ref:%" PRIi64, TD_VID(pVnode), qTaskFile.version, qTaskFile.nRef);
+ }
+
+_end:
+ for (int32_t i = 0; i < taosArrayGetSize(output); ++i) {
+ void *ptr = taosArrayGetP(output, i);
+ taosMemoryFreeClear(ptr);
+ }
+ taosArrayDestroy(output);
+
+ if (terrno != TSDB_CODE_SUCCESS) {
+ smaError("vgId:%d, open rsma fs failed since %s", TD_VID(pVnode), terrstr());
+ return TSDB_CODE_FAILED;
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
+void tdRSmaFSClose(SRSmaFS *fs) { taosArrayDestroy(fs->aQTaskInf); }
+
+static int32_t tdQTaskInfCmprFn1(const void *p1, const void *p2) {
+ if (*(int64_t *)p1 < ((SQTaskFile *)p2)->version) {
+ return -1;
+ } else if (*(int64_t *)p1 > ((SQTaskFile *)p2)->version) {
+ return 1;
+ }
+ return 0;
+}
+
+int32_t tdRSmaFSRef(SSma *pSma, SRSmaStat *pStat, int64_t version) {
+ SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf;
+ SQTaskFile *pTaskF = NULL;
+ int32_t oldVal = 0;
+
+ taosRLockLatch(RSMA_FS_LOCK(pStat));
+ if ((pTaskF = taosArraySearch(aQTaskInf, &version, tdQTaskInfCmprFn1, TD_EQ))) {
+ oldVal = atomic_fetch_add_32(&pTaskF->nRef, 1);
+ ASSERT(oldVal > 0);
+ }
+ taosRUnLockLatch(RSMA_FS_LOCK(pStat));
+ return oldVal;
+}
+
+int64_t tdRSmaFSMaxVer(SSma *pSma, SRSmaStat *pStat) {
+ SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf;
+ int64_t version = -1;
+
+ taosRLockLatch(RSMA_FS_LOCK(pStat));
+ if (taosArrayGetSize(aQTaskInf) > 0) {
+ version = ((SQTaskFile *)taosArrayGetLast(aQTaskInf))->version;
+ }
+ taosRUnLockLatch(RSMA_FS_LOCK(pStat));
+ return version;
+}
+
+void tdRSmaFSUnRef(SSma *pSma, SRSmaStat *pStat, int64_t version) {
+ SVnode *pVnode = pSma->pVnode;
+ SArray *aQTaskInf = RSMA_FS(pStat)->aQTaskInf;
+ char qTaskFullName[TSDB_FILENAME_LEN];
+ SQTaskFile *pTaskF = NULL;
+ int32_t idx = -1;
+
+ taosWLockLatch(RSMA_FS_LOCK(pStat));
+ if ((idx = taosArraySearchIdx(aQTaskInf, &version, tdQTaskInfCmprFn1, TD_EQ)) >= 0) {
+ ASSERT(idx < taosArrayGetSize(aQTaskInf));
+ pTaskF = taosArrayGet(aQTaskInf, idx);
+ if (atomic_sub_fetch_32(&pTaskF->nRef, 1) <= 0) {
+ tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), pTaskF->version, tfsGetPrimaryPath(pVnode->pTfs), qTaskFullName);
+ if (taosRemoveFile(qTaskFullName) < 0) {
+ smaWarn("vgId:%d, failed to remove %s since %s", TD_VID(pVnode), qTaskFullName,
+ tstrerror(TAOS_SYSTEM_ERROR(errno)));
+ } else {
+ smaDebug("vgId:%d, success to remove %s", TD_VID(pVnode), qTaskFullName);
+ }
+ taosArrayRemove(aQTaskInf, idx);
+ }
+ }
+ taosWUnLockLatch(RSMA_FS_LOCK(pStat));
+}
+
+/**
+ * @brief Fetch qtaskfiles LE than version
+ *
+ * @param pSma
+ * @param version
+ * @param output
+ * @return int32_t
+ */
+static int32_t tdFetchQTaskInfoFiles(SSma *pSma, int64_t version, SArray **output) {
+ SVnode *pVnode = pSma->pVnode;
+ TdDirPtr pDir = NULL;
+ TdDirEntryPtr pDirEntry = NULL;
+ char dir[TSDB_FILENAME_LEN];
+ const char *pattern = "v[0-9]+qinf\\.v([0-9]+)?$";
+ regex_t regex;
+ int code = 0;
+
+ tdGetVndDirName(TD_VID(pVnode), tfsGetPrimaryPath(pVnode->pTfs), VNODE_RSMA_DIR, true, dir);
+
+ if (!taosCheckExistFile(dir)) {
+ smaDebug("vgId:%d, fetch qtask files, no need as dir %s not exist", TD_VID(pVnode), dir);
+ return TSDB_CODE_SUCCESS;
+ }
+
+ // Resource allocation and init
+ if ((code = regcomp(®ex, pattern, REG_EXTENDED)) != 0) {
+ terrno = TSDB_CODE_RSMA_REGEX_MATCH;
+ char errbuf[128];
+ regerror(code, ®ex, errbuf, sizeof(errbuf));
+ smaWarn("vgId:%d, fetch qtask files, regcomp for %s failed since %s", TD_VID(pVnode), dir, errbuf);
+ return TSDB_CODE_FAILED;
+ }
+
+ if (!(pDir = taosOpenDir(dir))) {
+ regfree(®ex);
+ terrno = TAOS_SYSTEM_ERROR(errno);
+ smaError("vgId:%d, fetch qtask files, open dir %s failed since %s", TD_VID(pVnode), dir, terrstr());
+ return TSDB_CODE_FAILED;
+ }
+
+ int32_t dirLen = strlen(dir);
+ char *dirEnd = POINTER_SHIFT(dir, dirLen);
+ regmatch_t regMatch[2];
+ while ((pDirEntry = taosReadDir(pDir))) {
+ char *entryName = taosGetDirEntryName(pDirEntry);
+ if (!entryName) {
+ continue;
+ }
+
+ code = regexec(®ex, entryName, 2, regMatch, 0);
+
+ if (code == 0) {
+ // match
+ smaInfo("vgId:%d, fetch qtask files, max ver:%" PRIi64 ", %s found", TD_VID(pVnode), version, entryName);
+
+ int64_t ver = -1;
+ sscanf((const char *)POINTER_SHIFT(entryName, regMatch[1].rm_so), "%" PRIi64, &ver);
+ if ((ver <= version) && (ver > -1)) {
+ if (!(*output)) {
+ if (!(*output = taosArrayInit(1, POINTER_BYTES))) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ goto _end;
+ }
+ }
+ char *entryDup = strdup(entryName);
+ if (!entryDup) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ goto _end;
+ }
+ if (!taosArrayPush(*output, &entryDup)) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ goto _end;
+ }
+ } else {
+ }
+ } else if (code == REG_NOMATCH) {
+ // not match
+ smaTrace("vgId:%d, fetch qtask files, not match %s", TD_VID(pVnode), entryName);
+ continue;
+ } else {
+ // has other error
+ char errbuf[128];
+ regerror(code, ®ex, errbuf, sizeof(errbuf));
+ smaWarn("vgId:%d, fetch qtask files, regexec failed since %s", TD_VID(pVnode), errbuf);
+ terrno = TSDB_CODE_RSMA_REGEX_MATCH;
+ goto _end;
+ }
+ }
+_end:
+ taosCloseDir(&pDir);
+ regfree(®ex);
+ return terrno == 0 ? TSDB_CODE_SUCCESS : TSDB_CODE_FAILED;
+}
+
+static int32_t tdQTaskFileCmprFn2(const void *p1, const void *p2) {
+ if (((SQTaskFile *)p1)->version < ((SQTaskFile *)p2)->version) {
+ return -1;
+ } else if (((SQTaskFile *)p1)->version > ((SQTaskFile *)p2)->version) {
+ return 1;
+ }
+
+ return 0;
+}
+
+int32_t tdRSmaFSUpsertQTaskFile(SRSmaFS *pFS, SQTaskFile *qTaskFile) {
+ int32_t code = 0;
+ int32_t idx = taosArraySearchIdx(pFS->aQTaskInf, qTaskFile, tdQTaskFileCmprFn2, TD_GE);
+
+ if (idx < 0) {
+ idx = taosArrayGetSize(pFS->aQTaskInf);
+ } else {
+ SQTaskFile *pTaskF = (SQTaskFile *)taosArrayGet(pFS->aQTaskInf, idx);
+ int32_t c = tdQTaskFileCmprFn2(pTaskF, qTaskFile);
+ if (c == 0) {
+ pTaskF->nRef = qTaskFile->nRef;
+ pTaskF->version = qTaskFile->version;
+ pTaskF->size = qTaskFile->size;
+ goto _exit;
+ }
+ }
+
+ if (taosArrayInsert(pFS->aQTaskInf, idx, qTaskFile) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+_exit:
+ return code;
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c
index 3c3097bb2f..d9ffda279f 100644
--- a/source/dnode/vnode/src/sma/smaOpen.c
+++ b/source/dnode/vnode/src/sma/smaOpen.c
@@ -150,7 +150,7 @@ int32_t smaOpen(SVnode *pVnode) {
}
// restore the rsma
- if (tdRsmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed) < 0) {
+ if (tdRSmaRestore(pSma, RSMA_RESTORE_REBOOT, pVnode->state.committed) < 0) {
goto _err;
}
}
@@ -181,8 +181,8 @@ int32_t smaClose(SSma *pSma) {
* @param committedVer
* @return int32_t
*/
-int32_t tdRsmaRestore(SSma *pSma, int8_t type, int64_t committedVer) {
+int32_t tdRSmaRestore(SSma *pSma, int8_t type, int64_t committedVer) {
ASSERT(VND_IS_RSMA(pSma->pVnode));
- return tdProcessRSmaRestoreImpl(pSma, type, committedVer);
+ return tdRSmaProcessRestoreImpl(pSma, type, committedVer);
}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c
index f2063e3067..ec8fcb2932 100644
--- a/source/dnode/vnode/src/sma/smaRollup.c
+++ b/source/dnode/vnode/src/sma/smaRollup.c
@@ -19,8 +19,8 @@
#define RSMA_QTASKINFO_HEAD_LEN (sizeof(int32_t) + sizeof(int8_t) + sizeof(int64_t)) // len + type + suid
#define RSMA_QTASKEXEC_SMOOTH_SIZE (100) // cnt
#define RSMA_SUBMIT_BATCH_SIZE (1024) // cnt
-#define RSMA_FETCH_DELAY_MAX (900000) // ms
-#define RSMA_FETCH_ACTIVE_MAX (1800) // ms
+#define RSMA_FETCH_DELAY_MAX (120000) // ms
+#define RSMA_FETCH_ACTIVE_MAX (1000) // ms
#define RSMA_FETCH_INTERVAL (5000) // ms
SSmaMgmt smaMgmt = {
@@ -34,7 +34,7 @@ typedef struct SRSmaQTaskInfoItem SRSmaQTaskInfoItem;
typedef struct SRSmaQTaskInfoIter SRSmaQTaskInfoIter;
static int32_t tdUidStorePut(STbUidStore *pStore, tb_uid_t suid, tb_uid_t *uid);
-static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids);
+static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids, bool isAdd);
static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat *pStat, SRSmaInfo *pRSmaInfo,
int8_t idx);
static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize, int32_t inputType, SRSmaInfo *pInfo,
@@ -42,10 +42,12 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSiz
static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid);
static void tdReleaseRSmaInfo(SSma *pSma, SRSmaInfo *pInfo);
static void tdFreeRSmaSubmitItems(SArray *pItems);
-static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmitArr);
+static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo);
static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSmaInfoItem *pItem, STSchema *pTSchema,
int64_t suid);
static void tdRSmaFetchTrigger(void *param, void *tmrId);
+static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo);
+static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level);
static int32_t tdRSmaQTaskInfoIterInit(SRSmaQTaskInfoIter *pIter, STFile *pTFile);
static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isFinish);
static int32_t tdRSmaQTaskInfoRestore(SSma *pSma, int8_t type, SRSmaQTaskInfoIter *pIter);
@@ -96,7 +98,7 @@ static FORCE_INLINE int32_t tdRSmaQTaskInfoContLen(int32_t lenWithHead) {
static FORCE_INLINE void tdRSmaQTaskInfoIterDestroy(SRSmaQTaskInfoIter *pIter) { taosMemoryFreeClear(pIter->pBuf); }
-void tdFreeQTaskInfo(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
+static void tdRSmaQTaskInfoFree(qTaskInfo_t *taskHandle, int32_t vgId, int32_t level) {
// Note: free/kill may in RC
if (!taskHandle || !(*taskHandle)) return;
qTaskInfo_t otaskHandle = atomic_load_ptr(taskHandle);
@@ -123,20 +125,20 @@ void *tdFreeRSmaInfo(SSma *pSma, SRSmaInfo *pInfo, bool isDeepFree) {
SRSmaInfoItem *pItem = &pInfo->items[i];
if (isDeepFree && pItem->tmrId) {
- smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pInfo->suid,
- pItem->tmrId, i + 1);
+ smaDebug("vgId:%d, stop fetch timer %p for table %" PRIi64 " level %d", SMA_VID(pSma), pItem->tmrId,
+ pInfo->suid, i + 1);
taosTmrStopA(&pItem->tmrId);
}
if (isDeepFree && pInfo->taskInfo[i]) {
- tdFreeQTaskInfo(&pInfo->taskInfo[i], SMA_VID(pSma), i + 1);
+ tdRSmaQTaskInfoFree(&pInfo->taskInfo[i], SMA_VID(pSma), i + 1);
} else {
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty taskInfo", SMA_VID(pSma),
pInfo->suid, i + 1);
}
if (pInfo->iTaskInfo[i]) {
- tdFreeQTaskInfo(&pInfo->iTaskInfo[i], SMA_VID(pSma), i + 1);
+ tdRSmaQTaskInfoFree(&pInfo->iTaskInfo[i], SMA_VID(pSma), i + 1);
} else {
smaDebug("vgId:%d, table %" PRIi64 " no need to destroy rsma info level %d since empty iTaskInfo",
SMA_VID(pSma), pInfo->suid, i + 1);
@@ -173,7 +175,7 @@ static FORCE_INLINE int32_t tdUidStoreInit(STbUidStore **pStore) {
return TSDB_CODE_SUCCESS;
}
-static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids) {
+static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids, bool isAdd) {
SRSmaInfo *pRSmaInfo = NULL;
if (!suid || !tbUids) {
@@ -197,7 +199,7 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
if (pRSmaInfo->taskInfo[i]) {
- if (((terrno = qUpdateQualifiedTableId(pRSmaInfo->taskInfo[i], tbUids, true)) < 0)) {
+ if (((terrno = qUpdateQualifiedTableId(pRSmaInfo->taskInfo[i], tbUids, isAdd)) < 0)) {
tdReleaseRSmaInfo(pSma, pRSmaInfo);
smaError("vgId:%d, update tbUidList failed for uid:%" PRIi64 " level %d since %s", SMA_VID(pSma), *suid, i,
terrstr());
@@ -213,12 +215,12 @@ static int32_t tdUpdateTbUidListImpl(SSma *pSma, tb_uid_t *suid, SArray *tbUids)
return TSDB_CODE_SUCCESS;
}
-int32_t tdUpdateTbUidList(SSma *pSma, STbUidStore *pStore) {
+int32_t tdUpdateTbUidList(SSma *pSma, STbUidStore *pStore, bool isAdd) {
if (!pStore || (taosArrayGetSize(pStore->tbUids) == 0)) {
return TSDB_CODE_SUCCESS;
}
- if (tdUpdateTbUidListImpl(pSma, &pStore->suid, pStore->tbUids) != TSDB_CODE_SUCCESS) {
+ if (tdUpdateTbUidListImpl(pSma, &pStore->suid, pStore->tbUids, isAdd) != TSDB_CODE_SUCCESS) {
return TSDB_CODE_FAILED;
}
@@ -227,7 +229,7 @@ int32_t tdUpdateTbUidList(SSma *pSma, STbUidStore *pStore) {
tb_uid_t *pTbSuid = (tb_uid_t *)taosHashGetKey(pIter, NULL);
SArray *pTbUids = *(SArray **)pIter;
- if (tdUpdateTbUidListImpl(pSma, pTbSuid, pTbUids) != TSDB_CODE_SUCCESS) {
+ if (tdUpdateTbUidListImpl(pSma, pTbSuid, pTbUids, isAdd) != TSDB_CODE_SUCCESS) {
taosHashCancelIterate(pStore->uidHash, pIter);
return TSDB_CODE_FAILED;
}
@@ -300,7 +302,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
return TSDB_CODE_FAILED;
}
SRSmaInfoItem *pItem = &(pRSmaInfo->items[idx]);
- pItem->triggerStat = TASK_TRIGGER_STAT_INACTIVE;
+ pItem->triggerStat = TASK_TRIGGER_STAT_ACTIVE; // fetch the data when reboot
if (param->maxdelay[idx] < TSDB_MIN_ROLLUP_MAX_DELAY) {
int64_t msInterval =
convertTimeFromPrecisionToUnit(pRetention[idx + 1].freq, pTsdbCfg->precision, TIME_UNIT_MILLISECOND);
@@ -313,10 +315,19 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
}
pItem->level = idx == 0 ? TSDB_RETENTION_L1 : TSDB_RETENTION_L2;
- taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
- smaInfo("vgId:%d, table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
+ ASSERT(pItem->level > 0);
+
+ SRSmaRef rsmaRef = {.refId = pStat->refId, .suid = pRSmaInfo->suid};
+ taosHashPut(smaMgmt.refHash, &pItem, POINTER_BYTES, &rsmaRef, sizeof(rsmaRef));
+
+ pItem->fetchLevel = pItem->level;
+ taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
+
+
+ smaInfo("vgId:%d, item:%p table:%" PRIi64 " level:%" PRIi8 " maxdelay:%" PRIi64 " watermark:%" PRIi64
", finally maxdelay:%" PRIi32,
- TD_VID(pVnode), pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx], pItem->maxDelay);
+ TD_VID(pVnode), pItem, pRSmaInfo->suid, idx + 1, param->maxdelay[idx], param->watermark[idx],
+ pItem->maxDelay);
}
return TSDB_CODE_SUCCESS;
}
@@ -330,7 +341,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat
* @param tbName
* @return int32_t
*/
-int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) {
+int32_t tdRSmaProcessCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, const char *tbName) {
if ((param->qmsgLen[0] == 0) && (param->qmsgLen[1] == 0)) {
smaDebug("vgId:%d, no qmsg1/qmsg2 for rollup table %s %" PRIi64, SMA_VID(pSma), tbName, suid);
return TSDB_CODE_SUCCESS;
@@ -368,7 +379,10 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
terrno = TSDB_CODE_TDB_IVD_TB_SCHEMA_VERSION;
goto _err;
}
+ pRSmaInfo->pSma = pSma;
pRSmaInfo->pTSchema = pTSchema;
+ pRSmaInfo->suid = suid;
+ T_REF_INIT_VAL(pRSmaInfo, 1);
if (!(pRSmaInfo->queue = taosOpenQueue())) {
goto _err;
}
@@ -382,9 +396,6 @@ int32_t tdProcessRSmaCreateImpl(SSma *pSma, SRSmaParam *param, int64_t suid, con
if (!(pRSmaInfo->iQall = taosAllocateQall())) {
goto _err;
}
- pRSmaInfo->suid = suid;
- pRSmaInfo->refId = RSMA_REF_ID(pStat);
- T_REF_INIT_VAL(pRSmaInfo, 1);
if (tdSetRSmaInfoItemParams(pSma, param, pStat, pRSmaInfo, 0) < 0) {
goto _err;
@@ -427,7 +438,7 @@ int32_t tdProcessRSmaCreate(SSma *pSma, SVCreateStbReq *pReq) {
return TSDB_CODE_SUCCESS;
}
- return tdProcessRSmaCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name);
+ return tdRSmaProcessCreateImpl(pSma, &pReq->rsmaParam, pReq->suid, pReq->name);
}
/**
@@ -461,6 +472,7 @@ int32_t tdProcessRSmaDrop(SSma *pSma, SVDropStbReq *pReq) {
}
// set del flag for data in mem
+ atomic_store_8(&pRSmaStat->delFlag, 1);
RSMA_INFO_SET_DEL(pRSmaInfo);
tdUnRefRSmaInfo(pSma, pRSmaInfo);
@@ -654,15 +666,15 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
if (taosArrayGetSize(pResList) == 0) {
if (terrno == 0) {
- // smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
+ // smaDebug("vgId:%d, no rsma level %" PRIi8 " data fetched yet", SMA_VID(pSma), pItem->level);
} else {
- smaDebug("vgId:%d, no rsma %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
+ smaDebug("vgId:%d, no rsma level %" PRIi8 " data fetched since %s", SMA_VID(pSma), pItem->level, terrstr());
goto _err;
}
break;
} else {
- smaDebug("vgId:%d, rsma %" PRIi8 " data fetched", SMA_VID(pSma), pItem->level);
+ smaDebug("vgId:%d, rsma level %" PRIi8 " data fetched", SMA_VID(pSma), pItem->level);
}
#if 0
char flag[10] = {0};
@@ -676,21 +688,22 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
// TODO: the schema update should be handled later(TD-17965)
if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) {
- smaError("vgId:%d, build submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s",
- SMA_VID(pSma), suid, pItem->level, terrstr());
+ smaError("vgId:%d, build submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma),
+ suid, pItem->level, terrstr());
goto _err;
}
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
taosMemoryFreeClear(pReq);
- smaError("vgId:%d, process submit req for rsma stable %" PRIi64 " level %" PRIi8 " failed since %s",
+ smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s",
SMA_VID(pSma), suid, pItem->level, terrstr());
goto _err;
}
- taosMemoryFreeClear(pReq);
- smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " version:%" PRIi64,
- SMA_VID(pSma), suid, pItem->level, output->info.version);
+ smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " ver %" PRIi64 " len %" PRIu32,
+ SMA_VID(pSma), suid, pItem->level, output->info.version, htonl(pReq->header.contLen));
+
+ taosMemoryFreeClear(pReq);
}
}
@@ -817,6 +830,95 @@ static int32_t tdExecuteRSmaImpl(SSma *pSma, const void *pMsg, int32_t msgSize,
return TSDB_CODE_SUCCESS;
}
+static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param,
+ tb_uid_t suid, int8_t idx) {
+ SVnode *pVnode = pSma->pVnode;
+ char *pOutput = NULL;
+ int32_t len = 0;
+
+ if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) {
+ smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid,
+ terrstr());
+ goto _err;
+ }
+
+ SReadHandle handle = {
+ .meta = pVnode->pMeta,
+ .vnode = pVnode,
+ .initTqReader = 1,
+ };
+ ASSERT(!dstTaskInfo);
+ dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
+ if (!dstTaskInfo) {
+ terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
+ goto _err;
+ }
+
+ if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) {
+ smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
+ terrstr());
+ goto _err;
+ }
+
+ smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid);
+
+ taosMemoryFreeClear(pOutput);
+ return TSDB_CODE_SUCCESS;
+_err:
+ taosMemoryFreeClear(pOutput);
+ tdRSmaQTaskInfoFree(dstTaskInfo, TD_VID(pVnode), idx + 1);
+ smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
+ terrstr());
+ return TSDB_CODE_FAILED;
+}
+
+/**
+ * @brief Clone qTaskInfo of SRSmaInfo
+ *
+ * @param pSma
+ * @param pInfo
+ * @return int32_t
+ */
+static int32_t tdRSmaInfoClone(SSma *pSma, SRSmaInfo *pInfo) {
+ SRSmaParam *param = NULL;
+ if (!pInfo) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ SMetaReader mr = {0};
+ metaReaderInit(&mr, SMA_META(pSma), 0);
+ smaDebug("vgId:%d, rsma clone qTaskInfo for suid:%" PRIi64, SMA_VID(pSma), pInfo->suid);
+ if (metaGetTableEntryByUid(&mr, pInfo->suid) < 0) {
+ smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid,
+ terrstr());
+ goto _err;
+ }
+ ASSERT(mr.me.type == TSDB_SUPER_TABLE);
+ ASSERT(mr.me.uid == pInfo->suid);
+ if (TABLE_IS_ROLLUP(mr.me.flags)) {
+ param = &mr.me.stbEntry.rsmaParam;
+ for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
+ if (!pInfo->iTaskInfo[i]) {
+ continue;
+ }
+ if (tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i) < 0) {
+ goto _err;
+ }
+ }
+ smaDebug("vgId:%d, rsma clone env success for %" PRIi64, SMA_VID(pSma), pInfo->suid);
+ } else {
+ terrno = TSDB_CODE_RSMA_INVALID_SCHEMA;
+ goto _err;
+ }
+
+ metaReaderClear(&mr);
+ return TSDB_CODE_SUCCESS;
+_err:
+ metaReaderClear(&mr);
+ smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, terrstr());
+ return TSDB_CODE_FAILED;
+}
+
/**
* @brief During async commit, the SRSmaInfo object would be COW from iRSmaInfoHash and write lock should be applied.
*
@@ -840,25 +942,25 @@ static SRSmaInfo *tdAcquireRSmaInfoBySuid(SSma *pSma, int64_t suid) {
return NULL;
}
- // taosRLockLatch(SMA_ENV_LOCK(pEnv));
+ taosRLockLatch(SMA_ENV_LOCK(pEnv));
pRSmaInfo = taosHashGet(RSMA_INFO_HASH(pStat), &suid, sizeof(tb_uid_t));
if (pRSmaInfo && (pRSmaInfo = *(SRSmaInfo **)pRSmaInfo)) {
if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
- // taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
+ taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
return NULL;
}
if (!pRSmaInfo->taskInfo[0]) {
- if (tdCloneRSmaInfo(pSma, pRSmaInfo) < 0) {
- // taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
+ if (tdRSmaInfoClone(pSma, pRSmaInfo) < 0) {
+ taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
return NULL;
}
}
tdRefRSmaInfo(pSma, pRSmaInfo);
- // taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
+ taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
ASSERT(pRSmaInfo->suid == suid);
return pRSmaInfo;
}
- // taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
+ taosRUnLockLatch(SMA_ENV_LOCK(pEnv));
return NULL;
}
@@ -1006,7 +1108,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) {
" qmsgLen:%" PRIi32,
TD_VID(pVnode), suid, i, param->maxdelay[i], param->watermark[i], param->qmsgLen[i]);
}
- if (tdProcessRSmaCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) {
+ if (tdRSmaProcessCreateImpl(pSma, &mr.me.stbEntry.rsmaParam, suid, mr.me.name) < 0) {
smaError("vgId:%d, rsma restore env failed for %" PRIi64 " since %s", TD_VID(pVnode), suid, terrstr());
goto _err;
}
@@ -1019,7 +1121,7 @@ static int32_t tdRSmaRestoreQTaskInfoInit(SSma *pSma, int64_t *nTables) {
goto _err;
}
- if (tdUpdateTbUidList(pVnode->pSma, &uidStore) < 0) {
+ if (tdUpdateTbUidList(pVnode->pSma, &uidStore, true) < 0) {
smaError("vgId:%d, rsma restore, update tb uid list failed for %" PRIi64 " since %s", TD_VID(pVnode), suid,
terrstr());
goto _err;
@@ -1118,7 +1220,7 @@ static int32_t tdRSmaRestoreTSDataReload(SSma *pSma) {
return TSDB_CODE_SUCCESS;
}
-int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) {
+int32_t tdRSmaProcessRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer) {
// step 1: iterate all stables to restore the rsma env
int64_t nTables = 0;
if (tdRSmaRestoreQTaskInfoInit(pSma, &nTables) < 0) {
@@ -1139,6 +1241,12 @@ int32_t tdProcessRSmaRestoreImpl(SSma *pSma, int8_t type, int64_t qtaskFileVer)
if (tdRSmaRestoreTSDataReload(pSma) < 0) {
goto _err;
}
+
+ // step 4: open SRSmaFS for qTaskFiles
+ if (tdRSmaFSOpen(pSma, qtaskFileVer) < 0) {
+ goto _err;
+ }
+
smaInfo("vgId:%d, restore rsma task %" PRIi8 " from qtaskf %" PRIi64 " succeed", SMA_VID(pSma), type, qtaskFileVer);
return TSDB_CODE_SUCCESS;
_err:
@@ -1237,29 +1345,31 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
return TSDB_CODE_FAILED;
}
- if (tdReadTFile(pTFile, pIter->qBuf, nBytes) != nBytes) {
+ if (tdReadTFile(pTFile, pIter->pBuf, nBytes) != nBytes) {
return TSDB_CODE_FAILED;
}
int32_t infoLen = 0;
- taosDecodeFixedI32(pIter->qBuf, &infoLen);
+ taosDecodeFixedI32(pIter->pBuf, &infoLen);
if (infoLen > nBytes) {
if (infoLen <= RSMA_QTASKINFO_BUFSIZE) {
terrno = TSDB_CODE_RSMA_FILE_CORRUPTED;
smaError("iterate rsma qtaskinfo file %s failed since %s", TD_TFILE_FULL_NAME(pIter->pTFile), terrstr());
return TSDB_CODE_FAILED;
}
- pIter->nAlloc = infoLen;
- void *pBuf = taosMemoryRealloc(pIter->pBuf, infoLen);
- if (!pBuf) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- return TSDB_CODE_FAILED;
+ if (pIter->nAlloc < infoLen) {
+ pIter->nAlloc = infoLen;
+ void *pBuf = taosMemoryRealloc(pIter->pBuf, infoLen);
+ if (!pBuf) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return TSDB_CODE_FAILED;
+ }
+ pIter->pBuf = pBuf;
}
- pIter->pBuf = pBuf;
- pIter->qBuf = pIter->pBuf;
+
nBytes = infoLen;
- if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET)) {
+ if (tdSeekTFile(pTFile, pIter->offset, SEEK_SET) < 0) {
return TSDB_CODE_FAILED;
}
@@ -1268,6 +1378,7 @@ static int32_t tdRSmaQTaskInfoIterNextBlock(SRSmaQTaskInfoIter *pIter, bool *isF
}
}
+ pIter->qBuf = pIter->pBuf;
pIter->offset += nBytes;
pIter->nBytes = nBytes;
pIter->nBufPos = 0;
@@ -1345,17 +1456,24 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
return TSDB_CODE_SUCCESS;
}
+ int64_t fsMaxVer = tdRSmaFSMaxVer(pSma, pRSmaStat);
+ if (pRSmaStat->commitAppliedVer <= fsMaxVer) {
+ smaDebug("vgId:%d, rsma persist, no need as applied %" PRIi64 " not larger than fsMaxVer %" PRIi64, vid,
+ pRSmaStat->commitAppliedVer, fsMaxVer);
+ return TSDB_CODE_SUCCESS;
+ }
+
STFile tFile = {0};
#if 0
if (pRSmaStat->commitAppliedVer > 0) {
char qTaskInfoFName[TSDB_FILENAME_LEN];
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
- smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
+ smaError("vgId:%d, rsma persist, init %s failed since %s", vid, qTaskInfoFName, terrstr());
goto _err;
}
if (tdCreateTFile(&tFile, true, TD_FTYPE_RSMA_QTASKINFO) < 0) {
- smaError("vgId:%d, rsma persit, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
+ smaError("vgId:%d, rsma persist, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
goto _err;
}
smaDebug("vgId:%d, rsma, serialize qTaskInfo, file %s created", vid, TD_TFILE_FULL_NAME(&tFile));
@@ -1405,11 +1523,11 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
char qTaskInfoFName[TSDB_FILENAME_LEN];
tdRSmaQTaskInfoGetFileName(vid, pRSmaStat->commitAppliedVer, qTaskInfoFName);
if (tdInitTFile(&tFile, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFName) < 0) {
- smaError("vgId:%d, rsma persit, init %s failed since %s", vid, qTaskInfoFName, terrstr());
+ smaError("vgId:%d, rsma persist, init %s failed since %s", vid, qTaskInfoFName, terrstr());
goto _err;
}
if (tdCreateTFile(&tFile, true, TD_FTYPE_RSMA_QTASKINFO) < 0) {
- smaError("vgId:%d, rsma persit, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
+ smaError("vgId:%d, rsma persist, create %s failed since %s", vid, TD_TFILE_FULL_NAME(&tFile), terrstr());
goto _err;
}
smaDebug("vgId:%d, rsma, table %" PRIi64 " serialize qTaskInfo, file %s created", vid, pRSmaInfo->suid,
@@ -1453,7 +1571,7 @@ int32_t tdRSmaPersistExecImpl(SRSmaStat *pRSmaStat, SHashObj *pInfoHash) {
}
return TSDB_CODE_SUCCESS;
_err:
- smaError("vgId:%d, rsma persit failed since %s", vid, terrstr());
+ smaError("vgId:%d, rsma persist failed since %s", vid, terrstr());
if (isFileCreated) {
tdRemoveTFile(&tFile);
tdDestroyTFile(&tFile);
@@ -1468,26 +1586,46 @@ _err:
* @param tmrId
*/
static void tdRSmaFetchTrigger(void *param, void *tmrId) {
- SRSmaInfoItem *pItem = param;
+ SRSmaRef *pRSmaRef = NULL;
SSma *pSma = NULL;
- SRSmaInfo *pRSmaInfo = tdGetRSmaInfoByItem(pItem);
+ SRSmaStat *pStat = NULL;
+ SRSmaInfo *pRSmaInfo = NULL;
+ SRSmaInfoItem *pItem = NULL;
- if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
- smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
- pRSmaInfo->refId);
+ if (!(pRSmaRef = taosHashGet(smaMgmt.refHash, ¶m, POINTER_BYTES))) {
+ smaDebug("rsma fetch task not start since rsma info item:%p not exist in refHash:%p, rsetId:%" PRIi64, param,
+ *(int64_t *)¶m, smaMgmt.refHash, smaMgmt.rsetId);
return;
}
- SRSmaStat *pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
-
- if (!pStat) {
+ if (!(pStat = (SRSmaStat *)tdAcquireSmaRef(smaMgmt.rsetId, pRSmaRef->refId))) {
smaDebug("rsma fetch task not start since rsma stat already destroyed, rsetId:%" PRIi64 " refId:%d)",
- smaMgmt.rsetId, pRSmaInfo->refId);
+ smaMgmt.rsetId, pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
+ taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
return;
}
pSma = pStat->pSma;
+ if (!(pRSmaInfo = tdAcquireRSmaInfoBySuid(pSma, pRSmaRef->suid))) {
+ smaDebug("rsma fetch task not start since rsma info not exist, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
+ pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
+ tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
+ taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
+ return;
+ }
+
+ if (RSMA_INFO_IS_DEL(pRSmaInfo)) {
+ smaDebug("rsma fetch task not start since rsma info already deleted, rsetId:%" PRIi64 " refId:%d)", smaMgmt.rsetId,
+ pRSmaRef->refId); // pRSmaRef freed in taosHashRemove
+ tdReleaseRSmaInfo(pSma, pRSmaInfo);
+ tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
+ taosHashRemove(smaMgmt.refHash, ¶m, POINTER_BYTES);
+ return;
+ }
+
+ pItem = *(SRSmaInfoItem **)¶m;
+
// if rsma trigger stat in paused, cancelled or finished, not start fetch task
int8_t rsmaTriggerStat = atomic_load_8(RSMA_TRIGGER_STAT(pStat));
switch (rsmaTriggerStat) {
@@ -1495,11 +1633,12 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
case TASK_TRIGGER_STAT_CANCELLED: {
smaDebug("vgId:%d, rsma fetch task not start for level %" PRIi8 " since stat is %" PRIi8
", rsetId rsetId:%" PRIi64 " refId:%d",
- SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaInfo->refId);
+ SMA_VID(pSma), pItem->level, rsmaTriggerStat, smaMgmt.rsetId, pRSmaRef->refId);
if (rsmaTriggerStat == TASK_TRIGGER_STAT_PAUSED) {
taosTmrReset(tdRSmaFetchTrigger, RSMA_FETCH_INTERVAL, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
}
- tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
+ tdReleaseRSmaInfo(pSma, pRSmaInfo);
+ tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
return;
}
default:
@@ -1544,11 +1683,11 @@ static void tdRSmaFetchTrigger(void *param, void *tmrId) {
_end:
taosTmrReset(tdRSmaFetchTrigger, pItem->maxDelay, pItem, smaMgmt.tmrHandle, &pItem->tmrId);
- tdReleaseSmaRef(smaMgmt.rsetId, pRSmaInfo->refId);
+ tdReleaseRSmaInfo(pSma, pRSmaInfo);
+ tdReleaseSmaRef(smaMgmt.rsetId, pRSmaRef->refId);
}
static void tdFreeRSmaSubmitItems(SArray *pItems) {
- ASSERT(taosArrayGetSize(pItems) > 0);
for (int32_t i = 0; i < taosArrayGetSize(pItems); ++i) {
taosFreeQitem(*(void **)taosArrayGet(pItems, i));
}
@@ -1560,10 +1699,9 @@ static void tdFreeRSmaSubmitItems(SArray *pItems) {
*
* @param pSma
* @param pInfo
- * @param pSubmitArr
* @return int32_t
*/
-static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmitArr) {
+static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo) {
SSDataBlock dataBlock = {.info.type = STREAM_GET_ALL};
for (int8_t i = 1; i <= TSDB_RETENTION_L2; ++i) {
SRSmaInfoItem *pItem = RSMA_INFO_ITEM(pInfo, i - 1);
@@ -1574,21 +1712,23 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmi
continue;
}
- int64_t curMs = taosGetTimestampMs();
- if ((pItem->nSkipped * pItem->maxDelay) > RSMA_FETCH_DELAY_MAX) {
- smaInfo("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nSkipped:%" PRIi8 " maxDelay:%d, fetch executed",
- SMA_VID(pSma), pInfo->suid, i, pItem->nSkipped, pItem->maxDelay);
- } else if (((curMs - pInfo->lastRecv) < RSMA_FETCH_ACTIVE_MAX)) {
- ++pItem->nSkipped;
- smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch skipped ",
- SMA_VID(pSma), pInfo->suid, i, curMs, pInfo->lastRecv);
- continue;
+ if ((++pItem->nScanned * pItem->maxDelay) > RSMA_FETCH_DELAY_MAX) {
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch executed",
+ SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay);
} else {
- smaInfo("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch executed ",
- SMA_VID(pSma), pInfo->suid, i, curMs, pInfo->lastRecv);
+ int64_t curMs = taosGetTimestampMs();
+ if ((curMs - pInfo->lastRecv) < RSMA_FETCH_ACTIVE_MAX) {
+ smaTrace("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch skipped ",
+ SMA_VID(pSma), pInfo->suid, i, curMs, pInfo->lastRecv);
+ atomic_store_8(&pItem->triggerStat, TASK_TRIGGER_STAT_ACTIVE); // restore the active stat
+ continue;
+ } else {
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " curMs:%" PRIi64 " lastRecv:%" PRIi64 ", fetch executed ",
+ SMA_VID(pSma), pInfo->suid, i, curMs, pInfo->lastRecv);
+ }
}
- pItem->nSkipped = 0;
+ pItem->nScanned = 0;
if ((terrno = qSetMultiStreamInput(taskInfo, &dataBlock, 1, STREAM_INPUT__DATA_BLOCK)) < 0) {
goto _err;
@@ -1599,20 +1739,18 @@ static int32_t tdRSmaFetchAllResult(SSma *pSma, SRSmaInfo *pInfo, SArray *pSubmi
}
tdCleanupStreamInputDataBlock(taskInfo);
- smaInfo("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nSkipped:%" PRIi8 " maxDelay:%d, fetch finished",
- SMA_VID(pSma), pInfo->suid, i, pItem->nSkipped, pItem->maxDelay);
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8 " maxDelay:%d, fetch finished",
+ SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay);
} else {
- smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nSkipped:%" PRIi8
+ smaDebug("vgId:%d, suid:%" PRIi64 " level:%" PRIi8 " nScanned:%" PRIi8
" maxDelay:%d, fetch not executed as fetch level is %" PRIi8,
- SMA_VID(pSma), pInfo->suid, i, pItem->nSkipped, pItem->maxDelay, pItem->fetchLevel);
+ SMA_VID(pSma), pInfo->suid, i, pItem->nScanned, pItem->maxDelay, pItem->fetchLevel);
}
}
_end:
- tdReleaseRSmaInfo(pSma, pInfo);
return TSDB_CODE_SUCCESS;
_err:
- tdReleaseRSmaInfo(pSma, pInfo);
return TSDB_CODE_FAILED;
}
@@ -1696,6 +1834,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
bool occupied = (batchMax <= 1);
if (batchMax > 1) {
batchMax = 100 / batchMax;
+ batchMax = TMAX(batchMax, 4);
}
while (occupied || (++batchCnt < batchMax)) { // greedy mode
taosReadAllQitems(pInfo->queue, pInfo->qall); // queue has mutex lock
@@ -1705,13 +1844,15 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
smaDebug("vgId:%d, batchSize:%d, execType:%" PRIi8, SMA_VID(pSma), qallItemSize, type);
}
- int8_t oldStat = atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 2);
- if (oldStat == 0 ||
- ((oldStat == 2) && atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)) < TASK_TRIGGER_STAT_PAUSED)) {
- atomic_fetch_add_32(&pRSmaStat->nFetchAll, 1);
- tdRSmaFetchAllResult(pSma, pInfo, pSubmitArr);
- if (0 == atomic_sub_fetch_32(&pRSmaStat->nFetchAll, 1)) {
- atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0);
+ if (RSMA_INFO_ITEM(pInfo, 0)->fetchLevel || RSMA_INFO_ITEM(pInfo, 1)->fetchLevel) {
+ int8_t oldStat = atomic_val_compare_exchange_8(RSMA_COMMIT_STAT(pRSmaStat), 0, 2);
+ if (oldStat == 0 ||
+ ((oldStat == 2) && atomic_load_8(RSMA_TRIGGER_STAT(pRSmaStat)) < TASK_TRIGGER_STAT_PAUSED)) {
+ atomic_fetch_add_32(&pRSmaStat->nFetchAll, 1);
+ tdRSmaFetchAllResult(pSma, pInfo);
+ if (0 == atomic_sub_fetch_32(&pRSmaStat->nFetchAll, 1)) {
+ atomic_store_8(RSMA_COMMIT_STAT(pRSmaStat), 0);
+ }
}
}
@@ -1784,7 +1925,7 @@ int32_t tdRSmaProcessExecImpl(SSma *pSma, ERsmaExecType type) {
tsem_wait(&pRSmaStat->notEmpty);
if ((pEnv->flag & SMA_ENV_FLG_CLOSE) && (atomic_load_64(&pRSmaStat->nBufItems) <= 0)) {
- smaInfo("vgId:%d, exec task end, flag:%" PRIi8 ", nBufItems:%" PRIi64, SMA_VID(pSma), pEnv->flag,
+ smaDebug("vgId:%d, exec task end, flag:%" PRIi8 ", nBufItems:%" PRIi64, SMA_VID(pSma), pEnv->flag,
atomic_load_64(&pRSmaStat->nBufItems));
break;
}
diff --git a/source/dnode/vnode/src/sma/smaSnapshot.c b/source/dnode/vnode/src/sma/smaSnapshot.c
index 335c15a539..5a0167a75f 100644
--- a/source/dnode/vnode/src/sma/smaSnapshot.c
+++ b/source/dnode/vnode/src/sma/smaSnapshot.c
@@ -15,11 +15,13 @@
#include "sma.h"
-static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppData);
-static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
+static int32_t rsmaSnapReadQTaskInfo(SRSmaSnapReader* pReader, uint8_t** ppData);
+static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData);
+static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t version);
+static int32_t rsmaQTaskInfSnapReaderClose(SQTaskFReader** ppReader);
-// SRsmaSnapReader ========================================
-struct SRsmaSnapReader {
+// SRSmaSnapReader ========================================
+struct SRSmaSnapReader {
SSma* pSma;
int64_t sver;
int64_t ever;
@@ -33,13 +35,13 @@ struct SRsmaSnapReader {
SQTaskFReader* pQTaskFReader;
};
-int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapReader** ppReader) {
+int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapReader** ppReader) {
int32_t code = 0;
SVnode* pVnode = pSma->pVnode;
- SRsmaSnapReader* pReader = NULL;
+ SRSmaSnapReader* pReader = NULL;
// alloc
- pReader = (SRsmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
+ pReader = (SRSmaSnapReader*)taosMemoryCalloc(1, sizeof(*pReader));
if (pReader == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
@@ -48,7 +50,7 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead
pReader->sver = sver;
pReader->ever = ever;
- // rsma1/rsma2
+ // open rsma1/rsma2
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
if (pSma->pRSmaTsdb[i]) {
code = tsdbSnapReaderOpen(pSma->pRSmaTsdb[i], sver, ever, i == 0 ? SNAP_DATA_RSMA1 : SNAP_DATA_RSMA2,
@@ -59,51 +61,112 @@ int32_t rsmaSnapReaderOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapRead
}
}
- // qtaskinfo
- // 1. add ref to qtaskinfo.v${ever} if exists and then start to replicate
- char qTaskInfoFullName[TSDB_FILENAME_LEN];
- tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), ever, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
-
- if (!taosCheckExistFile(qTaskInfoFullName)) {
- smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo not need as %s not exists", TD_VID(pVnode),
- qTaskInfoFullName);
- } else {
- pReader->pQTaskFReader = taosMemoryCalloc(1, sizeof(SQTaskFReader));
- if (!pReader->pQTaskFReader) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
-
- TdFilePtr qTaskF = taosOpenFile(qTaskInfoFullName, TD_FILE_READ);
- if (!qTaskF) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- pReader->pQTaskFReader->pReadH = qTaskF;
-#if 0
- SQTaskFile* pQTaskF = &pReader->pQTaskFReader->fTask;
- pQTaskF->nRef = 1;
-#endif
+ // open qtaskinfo
+ if ((code = rsmaQTaskInfSnapReaderOpen(pReader, ever)) < 0) {
+ goto _err;
}
*ppReader = pReader;
- smaInfo("vgId:%d, vnode snapshot rsma reader opened %s succeed", TD_VID(pVnode), qTaskInfoFullName);
+
return TSDB_CODE_SUCCESS;
_err:
- smaError("vgId:%d, vnode snapshot rsma reader opened failed since %s", TD_VID(pVnode), tstrerror(code));
+ smaError("vgId:%d, vnode snapshot rsma reader open failed since %s", TD_VID(pVnode), tstrerror(code));
return TSDB_CODE_FAILED;
}
-static int32_t rsmaSnapReadQTaskInfo(SRsmaSnapReader* pReader, uint8_t** ppBuf) {
+static int32_t rsmaQTaskInfSnapReaderOpen(SRSmaSnapReader* pReader, int64_t version) {
+ int32_t code = 0;
+ SSma* pSma = pReader->pSma;
+ SVnode* pVnode = pSma->pVnode;
+ SSmaEnv* pEnv = NULL;
+ SRSmaStat* pStat = NULL;
+
+ if (!(pEnv = SMA_RSMA_ENV(pSma))) {
+ smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as env is NULL",
+ TD_VID(pVnode), version);
+ return TSDB_CODE_SUCCESS;
+ }
+
+ pStat = (SRSmaStat*)SMA_ENV_STAT(pEnv);
+
+ int32_t ref = tdRSmaFSRef(pReader->pSma, pStat, version);
+ if (ref < 1) {
+ smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as ref is %d",
+ TD_VID(pVnode), version, ref);
+ return TSDB_CODE_SUCCESS;
+ }
+
+ char qTaskInfoFullName[TSDB_FILENAME_LEN];
+ tdRSmaQTaskInfoGetFullName(TD_VID(pVnode), version, tfsGetPrimaryPath(pVnode->pTfs), qTaskInfoFullName);
+
+ if (!taosCheckExistFile(qTaskInfoFullName)) {
+ tdRSmaFSUnRef(pSma, pStat, version);
+ smaInfo("vgId:%d, vnode snapshot rsma reader for qtaskinfo version %" PRIi64 " not need as %s not exists",
+ TD_VID(pVnode), qTaskInfoFullName);
+ return TSDB_CODE_SUCCESS;
+ }
+
+ pReader->pQTaskFReader = taosMemoryCalloc(1, sizeof(SQTaskFReader));
+ if (!pReader->pQTaskFReader) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _end;
+ }
+
+ TdFilePtr fp = taosOpenFile(qTaskInfoFullName, TD_FILE_READ);
+ if (!fp) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ taosMemoryFreeClear(pReader->pQTaskFReader);
+ goto _end;
+ }
+
+ pReader->pQTaskFReader->pReadH = fp;
+ pReader->pQTaskFReader->pSma = pSma;
+ pReader->pQTaskFReader->version = pReader->ever;
+
+_end:
+ if (code < 0) {
+ tdRSmaFSUnRef(pSma, pStat, version);
+ smaError("vgId:%d, vnode snapshot rsma reader open %s succeed", TD_VID(pVnode), qTaskInfoFullName);
+ return TSDB_CODE_FAILED;
+ }
+
+ smaInfo("vgId:%d, vnode snapshot rsma reader open %s succeed", TD_VID(pVnode), qTaskInfoFullName);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t rsmaQTaskInfSnapReaderClose(SQTaskFReader** ppReader) {
+ if (!(*ppReader)) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ SSma* pSma = (*ppReader)->pSma;
+ SRSmaStat* pStat = SMA_RSMA_STAT(pSma);
+ int64_t version = (*ppReader)->version;
+
+ taosCloseFile(&(*ppReader)->pReadH);
+ tdRSmaFSUnRef(pSma, pStat, version);
+ taosMemoryFreeClear(*ppReader);
+ smaInfo("vgId:%d, vnode snapshot rsma reader closed for qTaskInfo version %" PRIi64, SMA_VID(pSma), version);
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t rsmaSnapReadQTaskInfo(SRSmaSnapReader* pReader, uint8_t** ppBuf) {
int32_t code = 0;
SSma* pSma = pReader->pSma;
int64_t n = 0;
uint8_t* pBuf = NULL;
SQTaskFReader* qReader = pReader->pQTaskFReader;
+ if (!qReader) {
+ *ppBuf = NULL;
+ smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, qTaskReader is NULL", SMA_VID(pSma));
+ return 0;
+ }
+
if (!qReader->pReadH) {
*ppBuf = NULL;
- smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, readh is empty", SMA_VID(pSma));
+ smaInfo("vgId:%d, vnode snapshot rsma reader qtaskinfo, readh is NULL", SMA_VID(pSma));
return 0;
}
@@ -153,7 +216,7 @@ _err:
return code;
}
-int32_t rsmaSnapRead(SRsmaSnapReader* pReader, uint8_t** ppData) {
+int32_t rsmaSnapRead(SRSmaSnapReader* pReader, uint8_t** ppData) {
int32_t code = 0;
*ppData = NULL;
@@ -205,9 +268,9 @@ _err:
return code;
}
-int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) {
+int32_t rsmaSnapReaderClose(SRSmaSnapReader** ppReader) {
int32_t code = 0;
- SRsmaSnapReader* pReader = *ppReader;
+ SRSmaSnapReader* pReader = *ppReader;
for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
if (pReader->pDataReader[i]) {
@@ -215,11 +278,7 @@ int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) {
}
}
- if (pReader->pQTaskFReader) {
- taosCloseFile(&pReader->pQTaskFReader->pReadH);
- taosMemoryFreeClear(pReader->pQTaskFReader);
- smaInfo("vgId:%d, vnode snapshot rsma reader closed for qTaskInfo", SMA_VID(pReader->pSma));
- }
+ rsmaQTaskInfSnapReaderClose(&pReader->pQTaskFReader);
smaInfo("vgId:%d, vnode snapshot rsma reader closed", SMA_VID(pReader->pSma));
@@ -227,8 +286,8 @@ int32_t rsmaSnapReaderClose(SRsmaSnapReader** ppReader) {
return code;
}
-// SRsmaSnapWriter ========================================
-struct SRsmaSnapWriter {
+// SRSmaSnapWriter ========================================
+struct SRSmaSnapWriter {
SSma* pSma;
int64_t sver;
int64_t ever;
@@ -244,13 +303,13 @@ struct SRsmaSnapWriter {
SQTaskFWriter* pQTaskFWriter;
};
-int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRsmaSnapWriter** ppWriter) {
+int32_t rsmaSnapWriterOpen(SSma* pSma, int64_t sver, int64_t ever, SRSmaSnapWriter** ppWriter) {
int32_t code = 0;
- SRsmaSnapWriter* pWriter = NULL;
+ SRSmaSnapWriter* pWriter = NULL;
SVnode* pVnode = pSma->pVnode;
// alloc
- pWriter = (SRsmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
+ pWriter = (SRSmaSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
if (pWriter == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
@@ -301,9 +360,9 @@ _err:
return code;
}
-int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) {
+int32_t rsmaSnapWriterClose(SRSmaSnapWriter** ppWriter, int8_t rollback) {
int32_t code = 0;
- SRsmaSnapWriter* pWriter = *ppWriter;
+ SRSmaSnapWriter* pWriter = *ppWriter;
SVnode* pVnode = pWriter->pSma->pVnode;
if (rollback) {
@@ -332,7 +391,7 @@ int32_t rsmaSnapWriterClose(SRsmaSnapWriter** ppWriter, int8_t rollback) {
pWriter->pQTaskFWriter->fname, qTaskInfoFullName);
// rsma restore
- if ((code = tdRsmaRestore(pWriter->pSma, RSMA_RESTORE_SYNC, pWriter->ever)) < 0) {
+ if ((code = tdRSmaRestore(pWriter->pSma, RSMA_RESTORE_SYNC, pWriter->ever)) < 0) {
goto _err;
}
smaInfo("vgId:%d, vnode snapshot rsma writer restore from %s succeed", SMA_VID(pWriter->pSma), qTaskInfoFullName);
@@ -349,7 +408,7 @@ _err:
return code;
}
-int32_t rsmaSnapWrite(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
+int32_t rsmaSnapWrite(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
int32_t code = 0;
SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
@@ -377,7 +436,7 @@ _err:
return code;
}
-static int32_t rsmaSnapWriteQTaskInfo(SRsmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
+static int32_t rsmaSnapWriteQTaskInfo(SRSmaSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
int32_t code = 0;
SQTaskFWriter* qWriter = pWriter->pQTaskFWriter;
diff --git a/source/dnode/vnode/src/sma/smaTimeRange.c b/source/dnode/vnode/src/sma/smaTimeRange.c
index 1687cd46a0..e2cb51f586 100644
--- a/source/dnode/vnode/src/sma/smaTimeRange.c
+++ b/source/dnode/vnode/src/sma/smaTimeRange.c
@@ -20,6 +20,10 @@
#define SMA_STORAGE_MINUTES_DAY 1440
#define SMA_STORAGE_SPLIT_FACTOR 14400 // least records in tsma file
+static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg);
+static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg);
+static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days);
+
// TODO: Who is responsible for resource allocate and release?
int32_t tdProcessTSmaInsert(SSma *pSma, int64_t indexUid, const char *msg) {
int32_t code = TSDB_CODE_SUCCESS;
@@ -59,7 +63,7 @@ int32_t smaGetTSmaDays(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *
* @param days unit is minute
* @return int32_t
*/
-int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) {
+static int32_t tdProcessTSmaGetDaysImpl(SVnodeCfg *pCfg, void *pCont, uint32_t contLen, int32_t *days) {
SDecoder coder = {0};
tDecoderInit(&coder, pCont, contLen);
@@ -106,7 +110,7 @@ _err:
* @param pMsg
* @return int32_t
*/
-int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
+static int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
SSmaCfg *pCfg = (SSmaCfg *)pMsg;
if (TD_VID(pSma->pVnode) == pCfg->dstVgId) {
@@ -145,7 +149,7 @@ int32_t tdProcessTSmaCreateImpl(SSma *pSma, int64_t version, const char *pMsg) {
* @param msg
* @return int32_t
*/
-int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
+static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
const SArray *pDataBlocks = (const SArray *)msg;
// TODO: destroy SSDataBlocks(msg)
if (!pDataBlocks) {
@@ -174,7 +178,6 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
return TSDB_CODE_FAILED;
}
- tdRefSmaStat(pSma, pStat);
pTsmaStat = SMA_STAT_TSMA(pStat);
if (!pTsmaStat->pTSma) {
@@ -226,9 +229,7 @@ int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char *msg) {
goto _err;
}
- tdUnRefSmaStat(pSma, pStat);
return TSDB_CODE_SUCCESS;
_err:
- tdUnRefSmaStat(pSma, pStat);
return TSDB_CODE_FAILED;
}
diff --git a/source/dnode/vnode/src/sma/smaUtil.c b/source/dnode/vnode/src/sma/smaUtil.c
index d771797963..a4ba0a61a5 100644
--- a/source/dnode/vnode/src/sma/smaUtil.c
+++ b/source/dnode/vnode/src/sma/smaUtil.c
@@ -305,93 +305,4 @@ int32_t tdReleaseSmaRef(int32_t rsetId, int64_t refId) {
smaDebug("rsma release ref for rsetId:%" PRIi64 " refId:%d success", rsetId, refId);
return TSDB_CODE_SUCCESS;
-}
-
-static int32_t tdCloneQTaskInfo(SSma *pSma, qTaskInfo_t dstTaskInfo, qTaskInfo_t srcTaskInfo, SRSmaParam *param,
- tb_uid_t suid, int8_t idx) {
- SVnode *pVnode = pSma->pVnode;
- char *pOutput = NULL;
- int32_t len = 0;
-
- if ((terrno = qSerializeTaskStatus(srcTaskInfo, &pOutput, &len)) < 0) {
- smaError("vgId:%d, rsma clone, table %" PRIi64 " serialize qTaskInfo failed since %s", TD_VID(pVnode), suid,
- terrstr());
- goto _err;
- }
-
- SReadHandle handle = {
- .meta = pVnode->pMeta,
- .vnode = pVnode,
- .initTqReader = 1,
- };
- ASSERT(!dstTaskInfo);
- dstTaskInfo = qCreateStreamExecTaskInfo(param->qmsg[idx], &handle);
- if (!dstTaskInfo) {
- terrno = TSDB_CODE_RSMA_QTASKINFO_CREATE;
- goto _err;
- }
-
- if (qDeserializeTaskStatus(dstTaskInfo, pOutput, len) < 0) {
- smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
- terrstr());
- goto _err;
- }
-
- smaDebug("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " succeed", TD_VID(pVnode), suid);
-
- taosMemoryFreeClear(pOutput);
- return TSDB_CODE_SUCCESS;
-_err:
- taosMemoryFreeClear(pOutput);
- tdFreeQTaskInfo(dstTaskInfo, TD_VID(pVnode), idx + 1);
- smaError("vgId:%d, rsma clone, restore rsma task for table:%" PRIi64 " failed since %s", TD_VID(pVnode), suid,
- terrstr());
- return TSDB_CODE_FAILED;
-}
-
-/**
- * @brief Clone qTaskInfo of SRSmaInfo
- *
- * @param pSma
- * @param pInfo
- * @return int32_t
- */
-int32_t tdCloneRSmaInfo(SSma *pSma, SRSmaInfo *pInfo) {
- SRSmaParam *param = NULL;
- if (!pInfo) {
- return TSDB_CODE_SUCCESS;
- }
-
- SMetaReader mr = {0};
- metaReaderInit(&mr, SMA_META(pSma), 0);
- smaDebug("vgId:%d, rsma clone qTaskInfo for suid:%" PRIi64, SMA_VID(pSma), pInfo->suid);
- if (metaGetTableEntryByUid(&mr, pInfo->suid) < 0) {
- smaError("vgId:%d, rsma clone, failed to get table meta for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid,
- terrstr());
- goto _err;
- }
- ASSERT(mr.me.type == TSDB_SUPER_TABLE);
- ASSERT(mr.me.uid == pInfo->suid);
- if (TABLE_IS_ROLLUP(mr.me.flags)) {
- param = &mr.me.stbEntry.rsmaParam;
- for (int32_t i = 0; i < TSDB_RETENTION_L2; ++i) {
- if (!pInfo->iTaskInfo[i]) {
- continue;
- }
- if (tdCloneQTaskInfo(pSma, pInfo->taskInfo[i], pInfo->iTaskInfo[i], param, pInfo->suid, i) < 0) {
- goto _err;
- }
- }
- smaDebug("vgId:%d, rsma clone env success for %" PRIi64, SMA_VID(pSma), pInfo->suid);
- } else {
- terrno = TSDB_CODE_RSMA_INVALID_SCHEMA;
- goto _err;
- }
-
- metaReaderClear(&mr);
- return TSDB_CODE_SUCCESS;
-_err:
- metaReaderClear(&mr);
- smaError("vgId:%d, rsma clone env failed for %" PRIi64 " since %s", SMA_VID(pSma), pInfo->suid, terrstr());
- return TSDB_CODE_FAILED;
}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c
index 3f42d8360e..f9c2757c37 100644
--- a/source/dnode/vnode/src/tq/tq.c
+++ b/source/dnode/vnode/src/tq/tq.c
@@ -816,7 +816,86 @@ int32_t tqProcessTaskDeployReq(STQ* pTq, int64_t version, char* msg, int32_t msg
return streamMetaAddSerializedTask(pTq->pStreamMeta, version, msg, msgLen);
}
-int32_t tqProcessStreamTrigger(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
+int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
+ bool failed = false;
+ SDecoder* pCoder = &(SDecoder){0};
+ SDeleteRes* pRes = &(SDeleteRes){0};
+
+ pRes->uidList = taosArrayInit(0, sizeof(tb_uid_t));
+ if (pRes->uidList == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ failed = true;
+ }
+
+ tDecoderInit(pCoder, pReq, len);
+ tDecodeDeleteRes(pCoder, pRes);
+ tDecoderClear(pCoder);
+
+ int32_t sz = taosArrayGetSize(pRes->uidList);
+ if (sz == 0) {
+ taosArrayDestroy(pRes->uidList);
+ return 0;
+ }
+ SSDataBlock* pDelBlock = createSpecialDataBlock(STREAM_DELETE_DATA);
+ blockDataEnsureCapacity(pDelBlock, sz);
+ pDelBlock->info.rows = sz;
+ pDelBlock->info.version = ver;
+
+ for (int32_t i = 0; i < sz; i++) {
+ // start key column
+ SColumnInfoData* pStartCol = taosArrayGet(pDelBlock->pDataBlock, START_TS_COLUMN_INDEX);
+ colDataAppend(pStartCol, i, (const char*)&pRes->skey, false); // end key column
+ SColumnInfoData* pEndCol = taosArrayGet(pDelBlock->pDataBlock, END_TS_COLUMN_INDEX);
+ colDataAppend(pEndCol, i, (const char*)&pRes->ekey, false);
+ // uid column
+ SColumnInfoData* pUidCol = taosArrayGet(pDelBlock->pDataBlock, UID_COLUMN_INDEX);
+ int64_t* pUid = taosArrayGet(pRes->uidList, i);
+ colDataAppend(pUidCol, i, (const char*)pUid, false);
+
+ colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, GROUPID_COLUMN_INDEX), i);
+ colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX), i);
+ colDataAppendNULL(taosArrayGet(pDelBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX), i);
+ }
+
+ taosArrayDestroy(pRes->uidList);
+
+ void* pIter = NULL;
+ while (1) {
+ pIter = taosHashIterate(pTq->pStreamMeta->pTasks, pIter);
+ if (pIter == NULL) break;
+ SStreamTask* pTask = *(SStreamTask**)pIter;
+ if (pTask->taskLevel != TASK_LEVEL__SOURCE) continue;
+
+ qDebug("delete req enqueue stream task: %d, ver: %" PRId64, pTask->taskId, ver);
+
+ SStreamDataBlock* pStreamBlock = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM);
+ pStreamBlock->type = STREAM_INPUT__DATA_BLOCK;
+ pStreamBlock->blocks = taosArrayInit(0, sizeof(SSDataBlock));
+ SSDataBlock block = {0};
+ assignOneDataBlock(&block, pDelBlock);
+ block.info.type = STREAM_DELETE_DATA;
+ taosArrayPush(pStreamBlock->blocks, &block);
+
+ if (!failed) {
+ if (streamTaskInput(pTask, (SStreamQueueItem*)pStreamBlock) < 0) {
+ qError("stream task input del failed, task id %d", pTask->taskId);
+ continue;
+ }
+
+ if (streamSchedExec(pTask) < 0) {
+ qError("stream task launch failed, task id %d", pTask->taskId);
+ continue;
+ }
+ } else {
+ streamTaskInputFail(pTask);
+ }
+ }
+ blockDataDestroy(pDelBlock);
+
+ return 0;
+}
+
+int32_t tqProcessSubmitReq(STQ* pTq, SSubmitReq* pReq, int64_t ver) {
void* pIter = NULL;
bool failed = false;
SStreamDataSubmit* pSubmit = NULL;
diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c
index ed7fa80c47..a57e8174fe 100644
--- a/source/dnode/vnode/src/tq/tqPush.c
+++ b/source/dnode/vnode/src/tq/tqPush.c
@@ -213,20 +213,25 @@ int32_t tqPushMsgNew(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_
#endif
int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver) {
- if (vnodeIsRoleLeader(pTq->pVnode) && msgType == TDMT_VND_SUBMIT) {
- if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
+ if (vnodeIsRoleLeader(pTq->pVnode)) {
+ if (msgType == TDMT_VND_SUBMIT) {
+ if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
- void* data = taosMemoryMalloc(msgLen);
- if (data == NULL) {
- terrno = TSDB_CODE_OUT_OF_MEMORY;
- tqError("failed to copy data for stream since out of memory");
- return -1;
+ void* data = taosMemoryMalloc(msgLen);
+ if (data == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ tqError("failed to copy data for stream since out of memory");
+ return -1;
+ }
+ memcpy(data, msg, msgLen);
+ SSubmitReq* pReq = (SSubmitReq*)data;
+ pReq->version = ver;
+
+ tqProcessSubmitReq(pTq, data, ver);
+ }
+ if (msgType == TDMT_VND_DELETE) {
+ tqProcessDelReq(pTq, POINTER_SHIFT(msg, sizeof(SMsgHead)), msgLen - sizeof(SMsgHead), ver);
}
- memcpy(data, msg, msgLen);
- SSubmitReq* pReq = (SSubmitReq*)data;
- pReq->version = ver;
-
- tqProcessStreamTrigger(pTq, data, ver);
}
return 0;
diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c
index 61c6877555..8da783a5bd 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCache.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCache.c
@@ -418,31 +418,17 @@ typedef enum {
} SFSLASTNEXTROWSTATES;
typedef struct {
- SFSLASTNEXTROWSTATES state; // [input]
- STsdb *pTsdb; // [input]
- SBlockIdx *pBlockIdxExp; // [input]
- STSchema *pTSchema; // [input]
+ SFSLASTNEXTROWSTATES state; // [input]
+ STsdb *pTsdb; // [input]
tb_uid_t suid;
tb_uid_t uid;
int32_t nFileSet;
int32_t iFileSet;
SArray *aDFileSet;
SDataFReader *pDataFReader;
- SArray *aBlockL;
- SBlockL *pBlockL;
- SBlockData *pBlockDataL;
- SBlockData blockDataL;
- int32_t nRow;
- int32_t iRow;
TSDBROW row;
- /*
- SArray *aBlockIdx;
- SBlockIdx *pBlockIdx;
- SMapData blockMap;
- int32_t nBlock;
- int32_t iBlock;
- SBlock block;
- */
+
+ SMergeTree mergeTree;
} SFSLastNextRowIter;
static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
@@ -451,22 +437,16 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
switch (state->state) {
case SFSLASTNEXTROW_FS:
- // state->aDFileSet = state->pTsdb->pFS->cState->aDFileSet;
state->nFileSet = taosArrayGetSize(state->aDFileSet);
state->iFileSet = state->nFileSet;
- state->pBlockDataL = NULL;
-
case SFSLASTNEXTROW_FILESET: {
SDFileSet *pFileSet = NULL;
_next_fileset:
if (--state->iFileSet >= 0) {
pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet);
} else {
- if (state->pBlockDataL) {
- tBlockDataDestroy(state->pBlockDataL, 1);
- state->pBlockDataL = NULL;
- }
+ // tMergeTreeClose(&state->mergeTree);
*ppRow = NULL;
return code;
@@ -475,68 +455,24 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) {
code = tsdbDataFReaderOpen(&state->pDataFReader, state->pTsdb, pFileSet);
if (code) goto _err;
- if (!state->aBlockL) {
- state->aBlockL = taosArrayInit(0, sizeof(SBlockL));
- } else {
- taosArrayClear(state->aBlockL);
- }
-
- code = tsdbReadBlockL(state->pDataFReader, state->aBlockL);
- if (code) goto _err;
-
- // SBlockL *pBlockL = (SBlockL *)taosArrayGet(state->aBlockL, state->iBlockL);
-
- state->pBlockL = taosArraySearch(state->aBlockL, state->pBlockIdxExp, tCmprBlockL, TD_EQ);
- if (!state->pBlockL) {
+ tMergeTreeOpen(&state->mergeTree, 1, state->pDataFReader, state->suid, state->uid,
+ &(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX},
+ &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, NULL, NULL);
+ bool hasVal = tMergeTreeNext(&state->mergeTree);
+ if (!hasVal) {
+ state->state = SFSLASTNEXTROW_FILESET;
+ // tMergeTreeClose(&state->mergeTree);
goto _next_fileset;
}
-
- int64_t suid = state->pBlockL->suid;
- int64_t uid = state->pBlockL->maxUid;
-
- if (!state->pBlockDataL) {
- state->pBlockDataL = &state->blockDataL;
-
- tBlockDataCreate(state->pBlockDataL);
- }
- code = tBlockDataInit(state->pBlockDataL, suid, suid ? 0 : uid, state->pTSchema);
- if (code) goto _err;
- }
- case SFSLASTNEXTROW_BLOCKDATA:
- code = tsdbReadLastBlock(state->pDataFReader, state->pBlockL, state->pBlockDataL);
- if (code) goto _err;
-
- state->nRow = state->blockDataL.nRow;
- state->iRow = state->nRow - 1;
-
- if (!state->pBlockDataL->uid) {
- while (state->pBlockIdxExp->uid != state->pBlockDataL->aUid[state->iRow]) {
- --state->iRow;
- }
- }
-
state->state = SFSLASTNEXTROW_BLOCKROW;
+ }
case SFSLASTNEXTROW_BLOCKROW:
- if (state->pBlockDataL->uid) {
- if (state->iRow >= 0) {
- state->row = tsdbRowFromBlockData(state->pBlockDataL, state->iRow);
- *ppRow = &state->row;
-
- if (--state->iRow < 0) {
- state->state = SFSLASTNEXTROW_FILESET;
- }
- }
- } else {
- if (state->iRow >= 0 && state->pBlockIdxExp->uid == state->pBlockDataL->aUid[state->iRow]) {
- state->row = tsdbRowFromBlockData(state->pBlockDataL, state->iRow);
- *ppRow = &state->row;
-
- if (--state->iRow < 0 || state->pBlockIdxExp->uid != state->pBlockDataL->aUid[state->iRow]) {
- state->state = SFSLASTNEXTROW_FILESET;
- }
- }
+ state->row = tMergeTreeGetRow(&state->mergeTree);
+ *ppRow = &state->row;
+ bool hasVal = tMergeTreeNext(&state->mergeTree);
+ if (!hasVal) {
+ state->state = SFSLASTNEXTROW_FILESET;
}
-
return code;
default:
ASSERT(0);
@@ -548,15 +484,6 @@ _err:
tsdbDataFReaderClose(&state->pDataFReader);
state->pDataFReader = NULL;
}
- if (state->aBlockL) {
- taosArrayDestroy(state->aBlockL);
- state->aBlockL = NULL;
- }
- if (state->pBlockDataL) {
- tBlockDataDestroy(state->pBlockDataL, 1);
- state->pBlockDataL = NULL;
- }
-
*ppRow = NULL;
return code;
@@ -574,14 +501,6 @@ int32_t clearNextRowFromFSLast(void *iter) {
tsdbDataFReaderClose(&state->pDataFReader);
state->pDataFReader = NULL;
}
- if (state->aBlockL) {
- taosArrayDestroy(state->aBlockL);
- state->aBlockL = NULL;
- }
- if (state->pBlockDataL) {
- tBlockDataDestroy(state->pBlockDataL, 1);
- state->pBlockDataL = NULL;
- }
return code;
}
@@ -609,7 +528,7 @@ typedef struct SFSNextRowIter {
SMapData blockMap;
int32_t nBlock;
int32_t iBlock;
- SBlock block;
+ SDataBlk block;
SBlockData blockData;
SBlockData *pBlockData;
int32_t nRow;
@@ -670,7 +589,7 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
}
tMapDataReset(&state->blockMap);
- code = tsdbReadBlock(state->pDataFReader, state->pBlockIdx, &state->blockMap);
+ code = tsdbReadDataBlk(state->pDataFReader, state->pBlockIdx, &state->blockMap);
if (code) goto _err;
state->nBlock = state->blockMap.nItem;
@@ -684,13 +603,13 @@ static int32_t getNextRowFromFS(void *iter, TSDBROW **ppRow) {
}
case SFSNEXTROW_BLOCKDATA:
if (state->iBlock >= 0) {
- SBlock block = {0};
+ SDataBlk block = {0};
- tBlockReset(&block);
+ tDataBlkReset(&block);
// tBlockDataReset(&state->blockData);
tBlockDataReset(state->pBlockData);
- tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetBlock);
+ tMapDataGetItemByIdx(&state->blockMap, state->iBlock, &block, tGetDataBlk);
/* code = tsdbReadBlockData(state->pDataFReader, &state->blockIdx, &block, &state->blockData, NULL, NULL); */
tBlockDataReset(state->pBlockData);
code = tBlockDataInit(state->pBlockData, state->suid, state->uid, state->pTSchema);
@@ -878,7 +797,7 @@ static bool tsdbKeyDeleted(TSDBKEY *key, SArray *pSkyline, int64_t *iSkyline) {
if (key->ts > pItemBack->ts) {
return false;
} else if (key->ts >= pItemFront->ts && key->ts <= pItemBack->ts) {
- if ((key->version <= pItemFront->version || key->ts == pItemBack->ts && key->version <= pItemBack->version)) {
+ if (key->version <= pItemFront->version || (key->ts == pItemBack->ts && key->version <= pItemBack->version)) {
return true;
} else {
return false;
@@ -972,8 +891,6 @@ static int32_t nextRowIterOpen(CacheNextRowIter *pIter, tb_uid_t uid, STsdb *pTs
pIter->fsLastState.state = (SFSLASTNEXTROWSTATES)SFSNEXTROW_FS;
pIter->fsLastState.pTsdb = pTsdb;
pIter->fsLastState.aDFileSet = pIter->pReadSnap->fs.aDFileSet;
- pIter->fsLastState.pBlockIdxExp = &pIter->idx;
- pIter->fsLastState.pTSchema = pTSchema;
pIter->fsLastState.suid = suid;
pIter->fsLastState.uid = uid;
@@ -1372,25 +1289,33 @@ int32_t tsdbCacheGetLastH(SLRUCache *pCache, tb_uid_t uid, STsdb *pTsdb, LRUHand
// getTableCacheKeyS(uid, "l", key, &keyLen);
getTableCacheKey(uid, 1, key, &keyLen);
LRUHandle *h = taosLRUCacheLookup(pCache, key, keyLen);
- if (h) {
- } else {
- SArray *pLastArray = NULL;
- code = mergeLast(uid, pTsdb, &pLastArray);
- // if table's empty or error, return code of -1
- // if (code < 0 || pRow == NULL) {
- if (code < 0 || pLastArray == NULL) {
- *handle = NULL;
- return 0;
- }
-
- _taos_lru_deleter_t deleter = deleteTableCacheLast;
- LRUStatus status =
- taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL, TAOS_LRU_PRIORITY_LOW);
- if (status != TAOS_LRU_STATUS_OK) {
- code = -1;
- }
+ if (!h) {
+ taosThreadMutexLock(&pTsdb->lruMutex);
h = taosLRUCacheLookup(pCache, key, keyLen);
+ if (!h) {
+ SArray *pLastArray = NULL;
+ code = mergeLast(uid, pTsdb, &pLastArray);
+ // if table's empty or error, return code of -1
+ // if (code < 0 || pRow == NULL) {
+ if (code < 0 || pLastArray == NULL) {
+ *handle = NULL;
+ return 0;
+ }
+
+ _taos_lru_deleter_t deleter = deleteTableCacheLast;
+ LRUStatus status = taosLRUCacheInsert(pCache, key, keyLen, pLastArray, pLastArray->capacity, deleter, NULL,
+ TAOS_LRU_PRIORITY_LOW);
+ if (status != TAOS_LRU_STATUS_OK) {
+ code = -1;
+ }
+
+ taosThreadMutexUnlock(&pTsdb->lruMutex);
+
+ h = taosLRUCacheLookup(pCache, key, keyLen);
+ } else {
+ taosThreadMutexUnlock(&pTsdb->lruMutex);
+ }
}
*handle = h;
@@ -1411,3 +1336,5 @@ void tsdbCacheSetCapacity(SVnode *pVnode, size_t capacity) {
}
size_t tsdbCacheGetCapacity(SVnode *pVnode) { return taosLRUCacheGetCapacity(pVnode->pTsdb->lruCache); }
+
+size_t tsdbCacheGetUsage(SVnode *pVnode) { return taosLRUCacheGetUsage(pVnode->pTsdb->lruCache); }
diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c
index 04a6de8472..a619b9f2e4 100644
--- a/source/dnode/vnode/src/tsdb/tsdbCommit.c
+++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c
@@ -14,17 +14,27 @@
*/
#include "tsdb.h"
-typedef struct {
- int64_t suid;
- int64_t uid;
- STSchema *pTSchema;
-} SSkmInfo;
+
+typedef enum { MEMORY_DATA_ITER = 0, STT_DATA_ITER } EDataIterT;
typedef struct {
- int64_t suid;
- int64_t uid;
- TSDBROW row;
-} SRowInfo;
+ SRBTreeNode n;
+ SRowInfo r;
+ EDataIterT type;
+ union {
+ struct {
+ int32_t iTbDataP;
+ STbDataIter iter;
+ }; // memory data iter
+ struct {
+ int32_t iStt;
+ SArray *aSttBlk;
+ int32_t iSttBlk;
+ SBlockData bData;
+ int32_t iRow;
+ }; // stt file data iter
+ };
+} SDataIter;
typedef struct {
STsdb *pTsdb;
@@ -35,8 +45,9 @@ typedef struct {
int32_t minRow;
int32_t maxRow;
int8_t cmprAlg;
- SArray *aTbDataP;
- STsdbFS fs;
+ int8_t sttTrigger;
+ SArray *aTbDataP; // memory
+ STsdbFS fs; // disk
// --------------
TSKEY nextKey; // reset by each table commit
int32_t commitFid;
@@ -45,25 +56,24 @@ typedef struct {
// commit file data
struct {
SDataFReader *pReader;
- // data
- SArray *aBlockIdx; // SArray
- int32_t iBlockIdx;
- SBlockIdx *pBlockIdx;
- SMapData mBlock; // SMapData
- SBlockData bData;
- // last
- SArray *aBlockL; // SArray
- int32_t iBlockL;
- SBlockData bDatal;
- int32_t iRow;
- SRowInfo *pRowInfo;
- SRowInfo rowInfo;
+ SArray *aBlockIdx; // SArray
+ int32_t iBlockIdx;
+ SBlockIdx *pBlockIdx;
+ SMapData mBlock; // SMapData
+ SBlockData bData;
} dReader;
+ struct {
+ SDataIter *pIter;
+ SRBTree rbt;
+ SDataIter dataIter;
+ SDataIter aDataIter[TSDB_MAX_STT_TRIGGER];
+ int8_t toLastOnly;
+ };
struct {
SDataFWriter *pWriter;
SArray *aBlockIdx; // SArray
- SArray *aBlockL; // SArray
- SMapData mBlock; // SMapData
+ SArray *aSttBlk; // SArray
+ SMapData mBlock; // SMapData
SBlockData bData;
SBlockData bDatal;
} dWriter;
@@ -82,6 +92,26 @@ static int32_t tsdbCommitData(SCommitter *pCommitter);
static int32_t tsdbCommitDel(SCommitter *pCommitter);
static int32_t tsdbCommitCache(SCommitter *pCommitter);
static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno);
+static int32_t tsdbNextCommitRow(SCommitter *pCommitter);
+
+int32_t tRowInfoCmprFn(const void *p1, const void *p2) {
+ SRowInfo *pInfo1 = (SRowInfo *)p1;
+ SRowInfo *pInfo2 = (SRowInfo *)p2;
+
+ if (pInfo1->suid < pInfo2->suid) {
+ return -1;
+ } else if (pInfo1->suid > pInfo2->suid) {
+ return 1;
+ }
+
+ if (pInfo1->uid < pInfo2->uid) {
+ return -1;
+ } else if (pInfo1->uid > pInfo2->uid) {
+ return 1;
+ }
+
+ return tsdbRowCmprFn(&pInfo1->row, &pInfo2->row);
+}
int32_t tsdbBegin(STsdb *pTsdb) {
int32_t code = 0;
@@ -290,19 +320,22 @@ _err:
return code;
}
-static int32_t tsdbCommitterUpdateTableSchema(SCommitter *pCommitter, int64_t suid, int64_t uid) {
+int32_t tsdbUpdateTableSchema(SMeta *pMeta, int64_t suid, int64_t uid, SSkmInfo *pSkmInfo) {
int32_t code = 0;
if (suid) {
- if (pCommitter->skmTable.suid == suid) goto _exit;
+ if (pSkmInfo->suid == suid) {
+ pSkmInfo->uid = uid;
+ goto _exit;
+ }
} else {
- if (pCommitter->skmTable.uid == uid) goto _exit;
+ if (pSkmInfo->uid == uid) goto _exit;
}
- pCommitter->skmTable.suid = suid;
- pCommitter->skmTable.uid = uid;
- tTSchemaDestroy(pCommitter->skmTable.pTSchema);
- code = metaGetTbTSchemaEx(pCommitter->pTsdb->pVnode->pMeta, suid, uid, -1, &pCommitter->skmTable.pTSchema);
+ pSkmInfo->suid = suid;
+ pSkmInfo->uid = uid;
+ tTSchemaDestroy(pSkmInfo->pTSchema);
+ code = metaGetTbTSchemaEx(pMeta, suid, uid, -1, &pSkmInfo->pTSchema);
if (code) goto _exit;
_exit:
@@ -334,54 +367,6 @@ _exit:
return code;
}
-static int32_t tsdbCommitterNextLastRow(SCommitter *pCommitter) {
- int32_t code = 0;
-
- ASSERT(pCommitter->dReader.pReader);
- ASSERT(pCommitter->dReader.pRowInfo);
-
- SBlockData *pBlockDatal = &pCommitter->dReader.bDatal;
- pCommitter->dReader.iRow++;
- if (pCommitter->dReader.iRow < pBlockDatal->nRow) {
- if (pBlockDatal->uid) {
- pCommitter->dReader.pRowInfo->uid = pBlockDatal->uid;
- } else {
- pCommitter->dReader.pRowInfo->uid = pBlockDatal->aUid[pCommitter->dReader.iRow];
- }
- pCommitter->dReader.pRowInfo->row = tsdbRowFromBlockData(pBlockDatal, pCommitter->dReader.iRow);
- } else {
- pCommitter->dReader.iBlockL++;
- if (pCommitter->dReader.iBlockL < taosArrayGetSize(pCommitter->dReader.aBlockL)) {
- SBlockL *pBlockL = (SBlockL *)taosArrayGet(pCommitter->dReader.aBlockL, pCommitter->dReader.iBlockL);
- int64_t suid = pBlockL->suid;
- int64_t uid = pBlockL->maxUid;
-
- code = tsdbCommitterUpdateTableSchema(pCommitter, suid, uid);
- if (code) goto _exit;
-
- code = tBlockDataInit(pBlockDatal, suid, suid ? 0 : uid, pCommitter->skmTable.pTSchema);
- if (code) goto _exit;
-
- code = tsdbReadLastBlock(pCommitter->dReader.pReader, pBlockL, pBlockDatal);
- if (code) goto _exit;
-
- pCommitter->dReader.iRow = 0;
- pCommitter->dReader.pRowInfo->suid = pBlockDatal->suid;
- if (pBlockDatal->uid) {
- pCommitter->dReader.pRowInfo->uid = pBlockDatal->uid;
- } else {
- pCommitter->dReader.pRowInfo->uid = pBlockDatal->aUid[0];
- }
- pCommitter->dReader.pRowInfo->row = tsdbRowFromBlockData(pBlockDatal, pCommitter->dReader.iRow);
- } else {
- pCommitter->dReader.pRowInfo = NULL;
- }
- }
-
-_exit:
- return code;
-}
-
static int32_t tsdbCommitterNextTableData(SCommitter *pCommitter) {
int32_t code = 0;
@@ -392,7 +377,7 @@ static int32_t tsdbCommitterNextTableData(SCommitter *pCommitter) {
pCommitter->dReader.pBlockIdx =
(SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, pCommitter->dReader.iBlockIdx);
- code = tsdbReadBlock(pCommitter->dReader.pReader, pCommitter->dReader.pBlockIdx, &pCommitter->dReader.mBlock);
+ code = tsdbReadDataBlk(pCommitter->dReader.pReader, pCommitter->dReader.pBlockIdx, &pCommitter->dReader.mBlock);
if (code) goto _exit;
ASSERT(pCommitter->dReader.mBlock.nItem > 0);
@@ -404,6 +389,85 @@ _exit:
return code;
}
+static int32_t tsdbOpenCommitIter(SCommitter *pCommitter) {
+ int32_t code = 0;
+
+ pCommitter->pIter = NULL;
+ tRBTreeCreate(&pCommitter->rbt, tRowInfoCmprFn);
+
+ // memory
+ TSDBKEY tKey = {.ts = pCommitter->minKey, .version = VERSION_MIN};
+ SDataIter *pIter = &pCommitter->dataIter;
+ pIter->type = MEMORY_DATA_ITER;
+ pIter->iTbDataP = 0;
+ for (; pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP); pIter->iTbDataP++) {
+ STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, pIter->iTbDataP);
+ tsdbTbDataIterOpen(pTbData, &tKey, 0, &pIter->iter);
+ TSDBROW *pRow = tsdbTbDataIterGet(&pIter->iter);
+ if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
+ pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow));
+ pRow = NULL;
+ }
+
+ if (pRow == NULL) continue;
+
+ pIter->r.suid = pTbData->suid;
+ pIter->r.uid = pTbData->uid;
+ pIter->r.row = *pRow;
+ break;
+ }
+ ASSERT(pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP));
+ tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pIter);
+
+ // disk
+ pCommitter->toLastOnly = 0;
+ SDataFReader *pReader = pCommitter->dReader.pReader;
+ if (pReader) {
+ if (pReader->pSet->nSttF >= pCommitter->sttTrigger) {
+ int8_t iIter = 0;
+ for (int32_t iStt = 0; iStt < pReader->pSet->nSttF; iStt++) {
+ pIter = &pCommitter->aDataIter[iIter];
+ pIter->type = STT_DATA_ITER;
+ pIter->iStt = iStt;
+
+ code = tsdbReadSttBlk(pCommitter->dReader.pReader, iStt, pIter->aSttBlk);
+ if (code) goto _err;
+
+ if (taosArrayGetSize(pIter->aSttBlk) == 0) continue;
+
+ pIter->iSttBlk = 0;
+ SSttBlk *pSttBlk = (SSttBlk *)taosArrayGet(pIter->aSttBlk, 0);
+ code = tsdbReadSttBlock(pCommitter->dReader.pReader, iStt, pSttBlk, &pIter->bData);
+ if (code) goto _err;
+
+ pIter->iRow = 0;
+ pIter->r.suid = pIter->bData.suid;
+ pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[0];
+ pIter->r.row = tsdbRowFromBlockData(&pIter->bData, 0);
+
+ tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pIter);
+ iIter++;
+ }
+ } else {
+ for (int32_t iStt = 0; iStt < pReader->pSet->nSttF; iStt++) {
+ SSttFile *pSttFile = pReader->pSet->aSttF[iStt];
+ if (pSttFile->size > pSttFile->offset) {
+ pCommitter->toLastOnly = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ code = tsdbNextCommitRow(pCommitter);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ return code;
+}
+
static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
int32_t code = 0;
STsdb *pTsdb = pCommitter->pTsdb;
@@ -416,8 +480,8 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
pCommitter->nextKey = TSKEY_MAX;
// Reader
- pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &(SDFileSet){.fid = pCommitter->commitFid},
- tDFileSetCmprFn, TD_EQ);
+ SDFileSet tDFileSet = {.fid = pCommitter->commitFid};
+ pRSet = (SDFileSet *)taosArraySearch(pCommitter->fs.aDFileSet, &tDFileSet, tDFileSetCmprFn, TD_EQ);
if (pRSet) {
code = tsdbDataFReaderOpen(&pCommitter->dReader.pReader, pTsdb, pRSet);
if (code) goto _err;
@@ -427,68 +491,58 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
if (code) goto _err;
pCommitter->dReader.iBlockIdx = 0;
- if (pCommitter->dReader.iBlockIdx < taosArrayGetSize(pCommitter->dReader.aBlockIdx)) {
- pCommitter->dReader.pBlockIdx =
- (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, pCommitter->dReader.iBlockIdx);
-
- code = tsdbReadBlock(pCommitter->dReader.pReader, pCommitter->dReader.pBlockIdx, &pCommitter->dReader.mBlock);
+ if (taosArrayGetSize(pCommitter->dReader.aBlockIdx) > 0) {
+ pCommitter->dReader.pBlockIdx = (SBlockIdx *)taosArrayGet(pCommitter->dReader.aBlockIdx, 0);
+ code = tsdbReadDataBlk(pCommitter->dReader.pReader, pCommitter->dReader.pBlockIdx, &pCommitter->dReader.mBlock);
if (code) goto _err;
} else {
pCommitter->dReader.pBlockIdx = NULL;
}
tBlockDataReset(&pCommitter->dReader.bData);
-
- // last
- code = tsdbReadBlockL(pCommitter->dReader.pReader, pCommitter->dReader.aBlockL);
- if (code) goto _err;
-
- pCommitter->dReader.iBlockL = -1;
- pCommitter->dReader.iRow = -1;
- pCommitter->dReader.pRowInfo = &pCommitter->dReader.rowInfo;
- tBlockDataReset(&pCommitter->dReader.bDatal);
- code = tsdbCommitterNextLastRow(pCommitter);
- if (code) goto _err;
} else {
pCommitter->dReader.pBlockIdx = NULL;
- pCommitter->dReader.pRowInfo = NULL;
}
// Writer
- SHeadFile fHead;
- SDataFile fData;
- SLastFile fLast;
- SSmaFile fSma;
- SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma};
+ SHeadFile fHead = {.commitID = pCommitter->commitID};
+ SDataFile fData = {.commitID = pCommitter->commitID};
+ SSmaFile fSma = {.commitID = pCommitter->commitID};
+ SSttFile fStt = {.commitID = pCommitter->commitID};
+ SDFileSet wSet = {.fid = pCommitter->commitFid, .pHeadF = &fHead, .pDataF = &fData, .pSmaF = &fSma};
if (pRSet) {
- wSet.diskId = pRSet->diskId;
- wSet.fid = pCommitter->commitFid;
- fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
+ ASSERT(pRSet->nSttF <= pCommitter->sttTrigger);
fData = *pRSet->pDataF;
- fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
fSma = *pRSet->pSmaF;
+ wSet.diskId = pRSet->diskId;
+ if (pRSet->nSttF < pCommitter->sttTrigger) {
+ for (int32_t iStt = 0; iStt < pRSet->nSttF; iStt++) {
+ wSet.aSttF[iStt] = pRSet->aSttF[iStt];
+ }
+ wSet.nSttF = pRSet->nSttF + 1;
+ } else {
+ wSet.nSttF = 1;
+ }
} else {
SDiskID did = {0};
-
tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did);
-
tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
-
wSet.diskId = did;
- wSet.fid = pCommitter->commitFid;
- fHead = (SHeadFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
- fData = (SDataFile){.commitID = pCommitter->commitID, .size = 0};
- fLast = (SLastFile){.commitID = pCommitter->commitID, .size = 0, .offset = 0};
- fSma = (SSmaFile){.commitID = pCommitter->commitID, .size = 0};
+ wSet.nSttF = 1;
}
+ wSet.aSttF[wSet.nSttF - 1] = &fStt;
code = tsdbDataFWriterOpen(&pCommitter->dWriter.pWriter, pTsdb, &wSet);
if (code) goto _err;
taosArrayClear(pCommitter->dWriter.aBlockIdx);
- taosArrayClear(pCommitter->dWriter.aBlockL);
+ taosArrayClear(pCommitter->dWriter.aSttBlk);
tMapDataReset(&pCommitter->dWriter.mBlock);
tBlockDataReset(&pCommitter->dWriter.bData);
tBlockDataReset(&pCommitter->dWriter.bDatal);
+ // open iter
+ code = tsdbOpenCommitIter(pCommitter);
+ if (code) goto _err;
+
_exit:
return code;
@@ -497,50 +551,45 @@ _err:
return code;
}
-static int32_t tsdbCommitDataBlock(SCommitter *pCommitter, SBlock *pBlock) {
- int32_t code = 0;
- SBlockData *pBlockData = &pCommitter->dWriter.bData;
- SBlock block;
+int32_t tsdbWriteDataBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SMapData *mDataBlk, int8_t cmprAlg) {
+ int32_t code = 0;
- ASSERT(pBlockData->nRow > 0);
+ if (pBlockData->nRow == 0) return code;
- if (pBlock) {
- block = *pBlock; // as a subblock
- } else {
- tBlockReset(&block); // as a new block
- }
+ SDataBlk dataBlk;
+ tDataBlkReset(&dataBlk);
// info
- block.nRow += pBlockData->nRow;
+ dataBlk.nRow += pBlockData->nRow;
for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
TSDBKEY key = {.ts = pBlockData->aTSKEY[iRow], .version = pBlockData->aVersion[iRow]};
if (iRow == 0) {
- if (tsdbKeyCmprFn(&block.minKey, &key) > 0) {
- block.minKey = key;
+ if (tsdbKeyCmprFn(&dataBlk.minKey, &key) > 0) {
+ dataBlk.minKey = key;
}
} else {
if (pBlockData->aTSKEY[iRow] == pBlockData->aTSKEY[iRow - 1]) {
- block.hasDup = 1;
+ dataBlk.hasDup = 1;
}
}
- if (iRow == pBlockData->nRow - 1 && tsdbKeyCmprFn(&block.maxKey, &key) < 0) {
- block.maxKey = key;
+ if (iRow == pBlockData->nRow - 1 && tsdbKeyCmprFn(&dataBlk.maxKey, &key) < 0) {
+ dataBlk.maxKey = key;
}
- block.minVer = TMIN(block.minVer, key.version);
- block.maxVer = TMAX(block.maxVer, key.version);
+ dataBlk.minVer = TMIN(dataBlk.minVer, key.version);
+ dataBlk.maxVer = TMAX(dataBlk.maxVer, key.version);
}
// write
- block.nSubBlock++;
- code = tsdbWriteBlockData(pCommitter->dWriter.pWriter, pBlockData, &block.aSubBlock[block.nSubBlock - 1],
- ((block.nSubBlock == 1) && !block.hasDup) ? &block.smaInfo : NULL, pCommitter->cmprAlg, 0);
+ dataBlk.nSubBlock++;
+ code = tsdbWriteBlockData(pWriter, pBlockData, &dataBlk.aSubBlock[dataBlk.nSubBlock - 1],
+ ((dataBlk.nSubBlock == 1) && !dataBlk.hasDup) ? &dataBlk.smaInfo : NULL, cmprAlg, 0);
if (code) goto _err;
- // put SBlock
- code = tMapDataPutItem(&pCommitter->dWriter.mBlock, &block, tPutBlock);
+ // put SDataBlk
+ code = tMapDataPutItem(mDataBlk, &dataBlk, tPutDataBlk);
if (code) goto _err;
// clear
@@ -549,39 +598,38 @@ static int32_t tsdbCommitDataBlock(SCommitter *pCommitter, SBlock *pBlock) {
return code;
_err:
- tsdbError("vgId:%d tsdb commit data block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d tsdb commit data block failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
return code;
}
-static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
- int32_t code = 0;
- SBlockL blockL;
- SBlockData *pBlockData = &pCommitter->dWriter.bDatal;
+int32_t tsdbWriteSttBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SArray *aSttBlk, int8_t cmprAlg) {
+ int32_t code = 0;
+ SSttBlk sstBlk;
- ASSERT(pBlockData->nRow > 0);
+ if (pBlockData->nRow == 0) return code;
// info
- blockL.suid = pBlockData->suid;
- blockL.nRow = pBlockData->nRow;
- blockL.minKey = TSKEY_MAX;
- blockL.maxKey = TSKEY_MIN;
- blockL.minVer = VERSION_MAX;
- blockL.maxVer = VERSION_MIN;
+ sstBlk.suid = pBlockData->suid;
+ sstBlk.nRow = pBlockData->nRow;
+ sstBlk.minKey = TSKEY_MAX;
+ sstBlk.maxKey = TSKEY_MIN;
+ sstBlk.minVer = VERSION_MAX;
+ sstBlk.maxVer = VERSION_MIN;
for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
- blockL.minKey = TMIN(blockL.minKey, pBlockData->aTSKEY[iRow]);
- blockL.maxKey = TMAX(blockL.maxKey, pBlockData->aTSKEY[iRow]);
- blockL.minVer = TMIN(blockL.minVer, pBlockData->aVersion[iRow]);
- blockL.maxVer = TMAX(blockL.maxVer, pBlockData->aVersion[iRow]);
+ sstBlk.minKey = TMIN(sstBlk.minKey, pBlockData->aTSKEY[iRow]);
+ sstBlk.maxKey = TMAX(sstBlk.maxKey, pBlockData->aTSKEY[iRow]);
+ sstBlk.minVer = TMIN(sstBlk.minVer, pBlockData->aVersion[iRow]);
+ sstBlk.maxVer = TMAX(sstBlk.maxVer, pBlockData->aVersion[iRow]);
}
- blockL.minUid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[0];
- blockL.maxUid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[pBlockData->nRow - 1];
+ sstBlk.minUid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[0];
+ sstBlk.maxUid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[pBlockData->nRow - 1];
// write
- code = tsdbWriteBlockData(pCommitter->dWriter.pWriter, pBlockData, &blockL.bInfo, NULL, pCommitter->cmprAlg, 1);
+ code = tsdbWriteBlockData(pWriter, pBlockData, &sstBlk.bInfo, NULL, cmprAlg, 1);
if (code) goto _err;
- // push SBlockL
- if (taosArrayPush(pCommitter->dWriter.aBlockL, &blockL) == NULL) {
+ // push SSttBlk
+ if (taosArrayPush(aSttBlk, &sstBlk) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
@@ -592,502 +640,7 @@ static int32_t tsdbCommitLastBlock(SCommitter *pCommitter) {
return code;
_err:
- tsdbError("vgId:%d tsdb commit last block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static int32_t tsdbMergeCommitData(SCommitter *pCommitter, STbDataIter *pIter, SBlock *pBlock) {
- int32_t code = 0;
- STbData *pTbData = pIter->pTbData;
- SBlockData *pBlockDataR = &pCommitter->dReader.bData;
- SBlockData *pBlockDataW = &pCommitter->dWriter.bData;
-
- code = tsdbReadDataBlock(pCommitter->dReader.pReader, pBlock, pBlockDataR);
- if (code) goto _err;
-
- tBlockDataClear(pBlockDataW);
- int32_t iRow = 0;
- TSDBROW row;
- TSDBROW *pRow1 = tsdbTbDataIterGet(pIter);
- TSDBROW *pRow2 = &row;
- *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow);
- while (pRow1 && pRow2) {
- int32_t c = tsdbRowCmprFn(pRow1, pRow2);
-
- if (c < 0) {
- code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow1));
- if (code) goto _err;
-
- code = tBlockDataAppendRow(pBlockDataW, pRow1, pCommitter->skmRow.pTSchema, pTbData->uid);
- if (code) goto _err;
-
- // next
- tsdbTbDataIterNext(pIter);
- pRow1 = tsdbTbDataIterGet(pIter);
- } else if (c > 0) {
- code = tBlockDataAppendRow(pBlockDataW, pRow2, NULL, pTbData->uid);
- if (code) goto _err;
-
- iRow++;
- if (iRow < pBlockDataR->nRow) {
- *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow);
- } else {
- pRow2 = NULL;
- }
- } else {
- ASSERT(0);
- }
-
- // check
- if (pBlockDataW->nRow >= pCommitter->maxRow * 4 / 5) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- }
- }
-
- while (pRow2) {
- code = tBlockDataAppendRow(pBlockDataW, pRow2, NULL, pTbData->uid);
- if (code) goto _err;
-
- iRow++;
- if (iRow < pBlockDataR->nRow) {
- *pRow2 = tsdbRowFromBlockData(pBlockDataR, iRow);
- } else {
- pRow2 = NULL;
- }
-
- // check
- if (pBlockDataW->nRow >= pCommitter->maxRow * 4 / 5) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- }
- }
-
- // check
- if (pBlockDataW->nRow > 0) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb merge commit data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static int32_t tsdbCommitTableMemData(SCommitter *pCommitter, STbDataIter *pIter, TSDBKEY toKey) {
- int32_t code = 0;
- STbData *pTbData = pIter->pTbData;
- SBlockData *pBlockData = &pCommitter->dWriter.bData;
-
- tBlockDataClear(pBlockData);
- TSDBROW *pRow = tsdbTbDataIterGet(pIter);
- while (true) {
- if (pRow == NULL) {
- if (pBlockData->nRow > 0) {
- goto _write_block;
- } else {
- break;
- }
- }
-
- // update schema
- code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
- if (code) goto _err;
-
- // append
- code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
- if (code) goto _err;
-
- tsdbTbDataIterNext(pIter);
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow) {
- TSDBKEY rowKey = TSDBROW_KEY(pRow);
- if (tsdbKeyCmprFn(&rowKey, &toKey) >= 0) {
- pRow = NULL;
- }
- }
-
- if (pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
- _write_block:
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- }
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb commit table mem data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static int32_t tsdbGetNumOfRowsLessThan(STbDataIter *pIter, TSDBKEY key) {
- int32_t nRow = 0;
-
- STbDataIter iter = *pIter;
- while (true) {
- TSDBROW *pRow = tsdbTbDataIterGet(&iter);
- if (pRow == NULL) break;
-
- int32_t c = tsdbKeyCmprFn(&TSDBROW_KEY(pRow), &key);
- if (c < 0) {
- nRow++;
- tsdbTbDataIterNext(&iter);
- } else if (c > 0) {
- break;
- } else {
- ASSERT(0);
- }
- }
-
- return nRow;
-}
-
-static int32_t tsdbMergeAsSubBlock(SCommitter *pCommitter, STbDataIter *pIter, SBlock *pBlock) {
- int32_t code = 0;
- STbData *pTbData = pIter->pTbData;
- SBlockData *pBlockData = &pCommitter->dWriter.bData;
-
- tBlockDataClear(pBlockData);
- TSDBROW *pRow = tsdbTbDataIterGet(pIter);
- while (true) {
- if (pRow == NULL) break;
-
- code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
- if (code) goto _err;
-
- code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
- if (code) goto _err;
-
- tsdbTbDataIterNext(pIter);
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow) {
- TSDBKEY rowKey = TSDBROW_KEY(pRow);
- if (tsdbKeyCmprFn(&rowKey, &pBlock->maxKey) > 0) {
- pRow = NULL;
- }
- }
- }
-
- ASSERT(pBlockData->nRow > 0 && pBlock->nRow + pBlockData->nRow <= pCommitter->maxRow);
-
- code = tsdbCommitDataBlock(pCommitter, pBlock);
- if (code) goto _err;
-
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb merge as subblock failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static int32_t tsdbMergeCommitLast(SCommitter *pCommitter, STbDataIter *pIter) {
- int32_t code = 0;
- STbData *pTbData = pIter->pTbData;
- int32_t nRow = tsdbGetNumOfRowsLessThan(pIter, (TSDBKEY){.ts = pCommitter->maxKey + 1, .version = VERSION_MIN});
-
- if (pCommitter->dReader.pRowInfo && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pRowInfo) == 0) {
- if (pCommitter->dReader.pRowInfo->suid) { // super table
- for (int32_t iRow = pCommitter->dReader.iRow; iRow < pCommitter->dReader.bDatal.nRow; iRow++) {
- if (pTbData->uid != pCommitter->dReader.bDatal.aUid[iRow]) break;
- nRow++;
- }
- } else { // normal table
- ASSERT(pCommitter->dReader.iRow == 0);
- nRow += pCommitter->dReader.bDatal.nRow;
- }
- }
-
- if (nRow == 0) goto _exit;
-
- TSDBROW *pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
-
- SRowInfo *pRowInfo = pCommitter->dReader.pRowInfo;
- if (pRowInfo && pRowInfo->uid != pTbData->uid) {
- pRowInfo = NULL;
- }
-
- while (nRow) {
- SBlockData *pBlockData;
- int8_t toData;
-
- if (nRow < pCommitter->minRow) { // to .last
- toData = 0;
- pBlockData = &pCommitter->dWriter.bDatal;
-
- // commit and reset block data schema if need
- // QUESTION: Is there a case that pBlockData->nRow == 0 but need to change schema ?
- if (pBlockData->suid || pBlockData->uid) {
- if (pBlockData->suid != pTbData->suid || pBlockData->suid == 0) {
- if (pBlockData->nRow > 0) {
- code = tsdbCommitLastBlock(pCommitter);
- if (code) goto _err;
- }
-
- tBlockDataReset(pBlockData);
- }
- }
-
- // set block data schema if need
- if (pBlockData->suid == 0 && pBlockData->uid == 0) {
- code = tsdbCommitterUpdateTableSchema(pCommitter, pTbData->suid, pTbData->uid);
- if (code) goto _err;
-
- code =
- tBlockDataInit(pBlockData, pTbData->suid, pTbData->suid ? 0 : pTbData->uid, pCommitter->skmTable.pTSchema);
- if (code) goto _err;
- }
-
- if (pBlockData->nRow + nRow > pCommitter->maxRow) {
- code = tsdbCommitLastBlock(pCommitter);
- if (code) goto _err;
- }
- } else { // to .data
- toData = 1;
- pBlockData = &pCommitter->dWriter.bData;
- ASSERT(pBlockData->nRow == 0);
- }
-
- while (pRow && pRowInfo) {
- int32_t c = tsdbRowCmprFn(pRow, &pRowInfo->row);
- if (c < 0) {
- code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
- if (code) goto _err;
-
- code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
- if (code) goto _err;
-
- tsdbTbDataIterNext(pIter);
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
- } else if (c > 0) {
- code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid);
- if (code) goto _err;
-
- code = tsdbCommitterNextLastRow(pCommitter);
- if (code) goto _err;
-
- pRowInfo = pCommitter->dReader.pRowInfo;
- if (pRowInfo && pRowInfo->uid != pTbData->uid) {
- pRowInfo = NULL;
- }
- } else {
- ASSERT(0);
- }
-
- nRow--;
- if (toData) {
- if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- goto _outer_break;
- }
- }
- }
-
- while (pRow) {
- code = tsdbCommitterUpdateRowSchema(pCommitter, pTbData->suid, pTbData->uid, TSDBROW_SVERSION(pRow));
- if (code) goto _err;
-
- code = tBlockDataAppendRow(pBlockData, pRow, pCommitter->skmRow.pTSchema, pTbData->uid);
- if (code) goto _err;
-
- tsdbTbDataIterNext(pIter);
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
-
- nRow--;
- if (toData) {
- if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- goto _outer_break;
- }
- }
- }
-
- while (pRowInfo) {
- code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pTbData->uid);
- if (code) goto _err;
-
- code = tsdbCommitterNextLastRow(pCommitter);
- if (code) goto _err;
-
- pRowInfo = pCommitter->dReader.pRowInfo;
- if (pRowInfo && pRowInfo->uid != pTbData->uid) {
- pRowInfo = NULL;
- }
-
- nRow--;
- if (toData) {
- if (nRow == 0 || pBlockData->nRow >= pCommitter->maxRow * 4 / 5) {
- code = tsdbCommitDataBlock(pCommitter, NULL);
- if (code) goto _err;
- goto _outer_break;
- }
- }
- }
-
- _outer_break:
- ASSERT(nRow >= 0);
- }
-
-_exit:
- return code;
-
-_err:
- tsdbError("vgId:%d tsdb merge commit last failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static int32_t tsdbCommitTableData(SCommitter *pCommitter, STbData *pTbData) {
- int32_t code = 0;
-
- ASSERT(pCommitter->dReader.pBlockIdx == NULL || tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, pTbData) >= 0);
- ASSERT(pCommitter->dReader.pRowInfo == NULL || tTABLEIDCmprFn(pCommitter->dReader.pRowInfo, pTbData) >= 0);
-
- // merge commit table data
- STbDataIter iter = {0};
- STbDataIter *pIter = &iter;
- TSDBROW *pRow;
-
- tsdbTbDataIterOpen(pTbData, &(TSDBKEY){.ts = pCommitter->minKey, .version = VERSION_MIN}, 0, pIter);
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
-
- if (pRow == NULL) {
- if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, pTbData) == 0) {
- SBlockIdx blockIdx = {.suid = pTbData->suid, .uid = pTbData->uid};
- code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx);
- if (code) goto _err;
-
- if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- }
-
- goto _exit;
- }
-
- int32_t iBlock = 0;
- SBlock block;
- SBlock *pBlock = █
- if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pBlockIdx) == 0) {
- tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock);
- } else {
- pBlock = NULL;
- }
-
- code = tsdbCommitterUpdateTableSchema(pCommitter, pTbData->suid, pTbData->uid);
- if (code) goto _err;
-
- tMapDataReset(&pCommitter->dWriter.mBlock);
- code = tBlockDataInit(&pCommitter->dReader.bData, pTbData->suid, pTbData->uid, pCommitter->skmTable.pTSchema);
- if (code) goto _err;
- code = tBlockDataInit(&pCommitter->dWriter.bData, pTbData->suid, pTbData->uid, pCommitter->skmTable.pTSchema);
- if (code) goto _err;
-
- // .data merge
- while (pBlock && pRow) {
- int32_t c = tBlockCmprFn(pBlock, &(SBlock){.minKey = TSDBROW_KEY(pRow), .maxKey = TSDBROW_KEY(pRow)});
- if (c < 0) { // disk
- code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock);
- if (code) goto _err;
-
- // next
- iBlock++;
- if (iBlock < pCommitter->dReader.mBlock.nItem) {
- tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock);
- } else {
- pBlock = NULL;
- }
- } else if (c > 0) { // memory
- code = tsdbCommitTableMemData(pCommitter, pIter, pBlock->minKey);
- if (code) goto _err;
-
- // next
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
- } else { // merge
- int32_t nOvlp = tsdbGetNumOfRowsLessThan(pIter, pBlock->maxKey);
-
- ASSERT(nOvlp > 0);
-
- if (pBlock->nRow + nOvlp <= pCommitter->maxRow && pBlock->nSubBlock < TSDB_MAX_SUBBLOCKS) {
- code = tsdbMergeAsSubBlock(pCommitter, pIter, pBlock);
- if (code) goto _err;
- } else {
- code = tsdbMergeCommitData(pCommitter, pIter, pBlock);
- if (code) goto _err;
- }
-
- // next
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
- pRow = NULL;
- }
- iBlock++;
- if (iBlock < pCommitter->dReader.mBlock.nItem) {
- tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock);
- } else {
- pBlock = NULL;
- }
- }
- }
-
- while (pBlock) {
- code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pBlock, tPutBlock);
- if (code) goto _err;
-
- // next
- iBlock++;
- if (iBlock < pCommitter->dReader.mBlock.nItem) {
- tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pBlock, tGetBlock);
- } else {
- pBlock = NULL;
- }
- }
-
- // .data append and .last merge
- code = tsdbMergeCommitLast(pCommitter, pIter);
- if (code) goto _err;
-
- // end
- if (pCommitter->dWriter.mBlock.nItem > 0) {
- SBlockIdx blockIdx = {.suid = pTbData->suid, .uid = pTbData->uid};
- code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dWriter.mBlock, &blockIdx);
- if (code) goto _err;
-
- if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- }
-
-_exit:
- pRow = tsdbTbDataIterGet(pIter);
- if (pRow) {
- pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow));
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d tsdb commit table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d tsdb commit last block failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
return code;
}
@@ -1098,8 +651,8 @@ static int32_t tsdbCommitFileDataEnd(SCommitter *pCommitter) {
code = tsdbWriteBlockIdx(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockIdx);
if (code) goto _err;
- // write aBlockL
- code = tsdbWriteBlockL(pCommitter->dWriter.pWriter, pCommitter->dWriter.aBlockL);
+ // write aSttBlk
+ code = tsdbWriteSttBlk(pCommitter->dWriter.pWriter, pCommitter->dWriter.aSttBlk);
if (code) goto _err;
// update file header
@@ -1130,12 +683,9 @@ _err:
static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) {
int32_t code = 0;
- // .data
- while (true) {
- if (pCommitter->dReader.pBlockIdx == NULL || tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, &toTable) >= 0) break;
-
+ while (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pCommitter->dReader.pBlockIdx, &toTable) < 0) {
SBlockIdx blockIdx = *pCommitter->dReader.pBlockIdx;
- code = tsdbWriteBlock(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx);
+ code = tsdbWriteDataBlk(pCommitter->dWriter.pWriter, &pCommitter->dReader.mBlock, &blockIdx);
if (code) goto _err;
if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) {
@@ -1147,71 +697,6 @@ static int32_t tsdbMoveCommitData(SCommitter *pCommitter, TABLEID toTable) {
if (code) goto _err;
}
- // .last
- while (true) {
- if (pCommitter->dReader.pRowInfo == NULL || tTABLEIDCmprFn(pCommitter->dReader.pRowInfo, &toTable) >= 0) break;
-
- SBlockData *pBlockDataR = &pCommitter->dReader.bDatal;
- SBlockData *pBlockDataW = &pCommitter->dWriter.bDatal;
- tb_uid_t suid = pCommitter->dReader.pRowInfo->suid;
- tb_uid_t uid = pCommitter->dReader.pRowInfo->uid;
-
- ASSERT((pBlockDataR->suid && !pBlockDataR->uid) || (!pBlockDataR->suid && pBlockDataR->uid));
- ASSERT(pBlockDataR->nRow > 0);
-
- // commit and reset block data schema if need
- if (pBlockDataW->suid || pBlockDataW->uid) {
- if (pBlockDataW->suid != suid || pBlockDataW->suid == 0) {
- if (pBlockDataW->nRow > 0) {
- code = tsdbCommitLastBlock(pCommitter);
- if (code) goto _err;
- }
- tBlockDataReset(pBlockDataW);
- }
- }
-
- // set block data schema if need
- if (pBlockDataW->suid == 0 && pBlockDataW->uid == 0) {
- code = tsdbCommitterUpdateTableSchema(pCommitter, suid, uid);
- if (code) goto _err;
-
- code = tBlockDataInit(pBlockDataW, suid, suid ? 0 : uid, pCommitter->skmTable.pTSchema);
- if (code) goto _err;
- }
-
- // check if it can make sure that one table data in one block
- int32_t nRow = 0;
- if (pBlockDataR->suid) {
- int32_t iRow = pCommitter->dReader.iRow;
- while ((iRow < pBlockDataR->nRow) && (pBlockDataR->aUid[iRow] == uid)) {
- nRow++;
- iRow++;
- }
- } else {
- ASSERT(pCommitter->dReader.iRow == 0);
- nRow = pBlockDataR->nRow;
- }
-
- ASSERT(nRow > 0 && nRow < pCommitter->minRow);
-
- if (pBlockDataW->nRow + nRow > pCommitter->maxRow) {
- ASSERT(pBlockDataW->nRow > 0);
-
- code = tsdbCommitLastBlock(pCommitter);
- if (code) goto _err;
- }
-
- while (nRow > 0) {
- code = tBlockDataAppendRow(pBlockDataW, &pCommitter->dReader.pRowInfo->row, NULL, uid);
- if (code) goto _err;
-
- code = tsdbCommitterNextLastRow(pCommitter);
- if (code) goto _err;
-
- nRow--;
- }
- }
-
return code;
_err:
@@ -1219,6 +704,7 @@ _err:
return code;
}
+static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter);
static int32_t tsdbCommitFileData(SCommitter *pCommitter) {
int32_t code = 0;
STsdb *pTsdb = pCommitter->pTsdb;
@@ -1228,33 +714,10 @@ static int32_t tsdbCommitFileData(SCommitter *pCommitter) {
code = tsdbCommitFileDataStart(pCommitter);
if (code) goto _err;
- // commit file data impl
- for (int32_t iTbData = 0; iTbData < taosArrayGetSize(pCommitter->aTbDataP); iTbData++) {
- STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, iTbData);
-
- // move commit until current (suid, uid)
- code = tsdbMoveCommitData(pCommitter, *(TABLEID *)pTbData);
- if (code) goto _err;
-
- // commit current table data
- code = tsdbCommitTableData(pCommitter, pTbData);
- if (code) goto _err;
-
- // move next reader table data if need
- if (pCommitter->dReader.pBlockIdx && tTABLEIDCmprFn(pTbData, pCommitter->dReader.pBlockIdx) == 0) {
- code = tsdbCommitterNextTableData(pCommitter);
- if (code) goto _err;
- }
- }
-
- code = tsdbMoveCommitData(pCommitter, (TABLEID){.suid = INT64_MAX, .uid = INT64_MAX});
+ // impl
+ code = tsdbCommitFileDataImpl(pCommitter);
if (code) goto _err;
- if (pCommitter->dWriter.bDatal.nRow > 0) {
- code = tsdbCommitLastBlock(pCommitter);
- if (code) goto _err;
- }
-
// commit file data end
code = tsdbCommitFileDataEnd(pCommitter);
if (code) goto _err;
@@ -1287,12 +750,12 @@ static int32_t tsdbStartCommit(STsdb *pTsdb, SCommitter *pCommitter) {
pCommitter->minRow = pTsdb->pVnode->config.tsdbCfg.minRows;
pCommitter->maxRow = pTsdb->pVnode->config.tsdbCfg.maxRows;
pCommitter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
+ pCommitter->sttTrigger = pTsdb->pVnode->config.sttTrigger;
pCommitter->aTbDataP = tsdbMemTableGetTbDataArray(pTsdb->imem);
if (pCommitter->aTbDataP == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
-
code = tsdbFSCopy(pTsdb, &pCommitter->fs);
if (code) goto _err;
@@ -1306,7 +769,7 @@ _err:
static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
int32_t code = 0;
- // Reader
+ // reader
pCommitter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
if (pCommitter->dReader.aBlockIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -1316,24 +779,28 @@ static int32_t tsdbCommitDataStart(SCommitter *pCommitter) {
code = tBlockDataCreate(&pCommitter->dReader.bData);
if (code) goto _exit;
- pCommitter->dReader.aBlockL = taosArrayInit(0, sizeof(SBlockL));
- if (pCommitter->dReader.aBlockL == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
+ // merger
+ for (int32_t iStt = 0; iStt < TSDB_MAX_STT_TRIGGER; iStt++) {
+ SDataIter *pIter = &pCommitter->aDataIter[iStt];
+ pIter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
+ if (pIter->aSttBlk == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+ code = tBlockDataCreate(&pIter->bData);
+ if (code) goto _exit;
}
- code = tBlockDataCreate(&pCommitter->dReader.bDatal);
- if (code) goto _exit;
-
- // Writer
+ // writer
pCommitter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
if (pCommitter->dWriter.aBlockIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
- pCommitter->dWriter.aBlockL = taosArrayInit(0, sizeof(SBlockL));
- if (pCommitter->dWriter.aBlockL == NULL) {
+ pCommitter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
+ if (pCommitter->dWriter.aSttBlk == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
@@ -1349,16 +816,21 @@ _exit:
}
static void tsdbCommitDataEnd(SCommitter *pCommitter) {
- // Reader
+ // reader
taosArrayDestroy(pCommitter->dReader.aBlockIdx);
tMapDataClear(&pCommitter->dReader.mBlock);
tBlockDataDestroy(&pCommitter->dReader.bData, 1);
- taosArrayDestroy(pCommitter->dReader.aBlockL);
- tBlockDataDestroy(&pCommitter->dReader.bDatal, 1);
- // Writer
+ // merger
+ for (int32_t iStt = 0; iStt < TSDB_MAX_STT_TRIGGER; iStt++) {
+ SDataIter *pIter = &pCommitter->aDataIter[iStt];
+ taosArrayDestroy(pIter->aSttBlk);
+ tBlockDataDestroy(&pIter->bData, 1);
+ }
+
+ // writer
taosArrayDestroy(pCommitter->dWriter.aBlockIdx);
- taosArrayDestroy(pCommitter->dWriter.aBlockL);
+ taosArrayDestroy(pCommitter->dWriter.aSttBlk);
tMapDataClear(&pCommitter->dWriter.mBlock);
tBlockDataDestroy(&pCommitter->dWriter.bData, 1);
tBlockDataDestroy(&pCommitter->dWriter.bDatal, 1);
@@ -1389,7 +861,7 @@ static int32_t tsdbCommitData(SCommitter *pCommitter) {
tsdbCommitDataEnd(pCommitter);
_exit:
- tsdbDebug("vgId:%d, commit data done, nRow:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nRow);
+ tsdbInfo("vgId:%d, commit data done, nRow:%" PRId64, TD_VID(pTsdb->pVnode), pMemTable->nRow);
return code;
_err:
@@ -1515,6 +987,11 @@ static int32_t tsdbEndCommit(SCommitter *pCommitter, int32_t eno) {
tsdbFSDestroy(&pCommitter->fs);
taosArrayDestroy(pCommitter->aTbDataP);
+ // if (pCommitter->toMerge) {
+ // code = tsdbMerge(pTsdb);
+ // if (code) goto _err;
+ // }
+
tsdbInfo("vgId:%d, tsdb end commit", TD_VID(pTsdb->pVnode));
return code;
@@ -1522,3 +999,473 @@ _err:
tsdbError("vgId:%d, tsdb end commit failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
return code;
}
+
+// ================================================================================
+
+static FORCE_INLINE SRowInfo *tsdbGetCommitRow(SCommitter *pCommitter) {
+ return (pCommitter->pIter) ? &pCommitter->pIter->r : NULL;
+}
+
+static int32_t tsdbNextCommitRow(SCommitter *pCommitter) {
+ int32_t code = 0;
+
+ if (pCommitter->pIter) {
+ SDataIter *pIter = pCommitter->pIter;
+ if (pCommitter->pIter->type == MEMORY_DATA_ITER) { // memory
+ tsdbTbDataIterNext(&pIter->iter);
+ TSDBROW *pRow = tsdbTbDataIterGet(&pIter->iter);
+ while (true) {
+ if (pRow && TSDBROW_TS(pRow) > pCommitter->maxKey) {
+ pCommitter->nextKey = TMIN(pCommitter->nextKey, TSDBROW_TS(pRow));
+ pRow = NULL;
+ }
+
+ if (pRow) {
+ pIter->r.suid = pIter->iter.pTbData->suid;
+ pIter->r.uid = pIter->iter.pTbData->uid;
+ pIter->r.row = *pRow;
+ break;
+ }
+
+ pIter->iTbDataP++;
+ if (pIter->iTbDataP < taosArrayGetSize(pCommitter->aTbDataP)) {
+ STbData *pTbData = (STbData *)taosArrayGetP(pCommitter->aTbDataP, pIter->iTbDataP);
+ TSDBKEY keyFrom = {.ts = pCommitter->minKey, .version = VERSION_MIN};
+ tsdbTbDataIterOpen(pTbData, &keyFrom, 0, &pIter->iter);
+ pRow = tsdbTbDataIterGet(&pIter->iter);
+ continue;
+ } else {
+ pCommitter->pIter = NULL;
+ break;
+ }
+ }
+ } else if (pCommitter->pIter->type == STT_DATA_ITER) { // last file
+ pIter->iRow++;
+ if (pIter->iRow < pIter->bData.nRow) {
+ pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
+ pIter->r.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
+ } else {
+ pIter->iSttBlk++;
+ if (pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk)) {
+ SSttBlk *pSttBlk = (SSttBlk *)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
+
+ code = tsdbReadSttBlock(pCommitter->dReader.pReader, pIter->iStt, pSttBlk, &pIter->bData);
+ if (code) goto _exit;
+
+ pIter->iRow = 0;
+ pIter->r.suid = pIter->bData.suid;
+ pIter->r.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[0];
+ pIter->r.row = tsdbRowFromBlockData(&pIter->bData, 0);
+ } else {
+ pCommitter->pIter = NULL;
+ }
+ }
+ } else {
+ ASSERT(0);
+ }
+
+ // compare with min in RB Tree
+ pIter = (SDataIter *)tRBTreeMin(&pCommitter->rbt);
+ if (pCommitter->pIter && pIter) {
+ int32_t c = tRowInfoCmprFn(&pCommitter->pIter->r, &pIter->r);
+ if (c > 0) {
+ tRBTreePut(&pCommitter->rbt, (SRBTreeNode *)pCommitter->pIter);
+ pCommitter->pIter = NULL;
+ } else {
+ ASSERT(c);
+ }
+ }
+ }
+
+ if (pCommitter->pIter == NULL) {
+ pCommitter->pIter = (SDataIter *)tRBTreeMin(&pCommitter->rbt);
+ if (pCommitter->pIter) {
+ tRBTreeDrop(&pCommitter->rbt, (SRBTreeNode *)pCommitter->pIter);
+ }
+ }
+
+_exit:
+ return code;
+}
+
+static int32_t tsdbCommitAheadBlock(SCommitter *pCommitter, SDataBlk *pDataBlk) {
+ int32_t code = 0;
+ SBlockData *pBlockData = &pCommitter->dWriter.bData;
+ SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter);
+ TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid};
+
+ tBlockDataClear(pBlockData);
+ while (pRowInfo) {
+ ASSERT(pRowInfo->row.type == 0);
+ code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row));
+ if (code) goto _err;
+
+ code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, pCommitter->skmRow.pTSchema, id.uid);
+ if (code) goto _err;
+
+ code = tsdbNextCommitRow(pCommitter);
+ if (code) goto _err;
+
+ pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo) {
+ if (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid) {
+ pRowInfo = NULL;
+ } else {
+ TSDBKEY tKey = TSDBROW_KEY(&pRowInfo->row);
+ if (tsdbKeyCmprFn(&tKey, &pDataBlk->minKey) >= 0) pRowInfo = NULL;
+ }
+ }
+
+ if (pBlockData->nRow >= pCommitter->maxRow) {
+ code =
+ tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBlockData, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+ }
+ }
+
+ code = tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBlockData, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d, tsdb commit ahead block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbCommitMergeBlock(SCommitter *pCommitter, SDataBlk *pDataBlk) {
+ int32_t code = 0;
+ SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter);
+ TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid};
+ SBlockData *pBDataR = &pCommitter->dReader.bData;
+ SBlockData *pBDataW = &pCommitter->dWriter.bData;
+
+ code = tsdbReadDataBlock(pCommitter->dReader.pReader, pDataBlk, pBDataR);
+ if (code) goto _err;
+
+ tBlockDataClear(pBDataW);
+ int32_t iRow = 0;
+ TSDBROW row = tsdbRowFromBlockData(pBDataR, 0);
+ TSDBROW *pRow = &row;
+
+ while (pRow && pRowInfo) {
+ int32_t c = tsdbRowCmprFn(pRow, &pRowInfo->row);
+ if (c < 0) {
+ code = tBlockDataAppendRow(pBDataW, pRow, NULL, id.uid);
+ if (code) goto _err;
+
+ iRow++;
+ if (iRow < pBDataR->nRow) {
+ row = tsdbRowFromBlockData(pBDataR, iRow);
+ } else {
+ pRow = NULL;
+ }
+ } else if (c > 0) {
+ ASSERT(pRowInfo->row.type == 0);
+ code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row));
+ if (code) goto _err;
+
+ code = tBlockDataAppendRow(pBDataW, &pRowInfo->row, pCommitter->skmRow.pTSchema, id.uid);
+ if (code) goto _err;
+
+ code = tsdbNextCommitRow(pCommitter);
+ if (code) goto _err;
+
+ pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo) {
+ if (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid) {
+ pRowInfo = NULL;
+ } else {
+ TSDBKEY tKey = TSDBROW_KEY(&pRowInfo->row);
+ if (tsdbKeyCmprFn(&tKey, &pDataBlk->maxKey) > 0) pRowInfo = NULL;
+ }
+ }
+ } else {
+ ASSERT(0);
+ }
+
+ if (pBDataW->nRow >= pCommitter->maxRow) {
+ code = tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBDataW, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+ }
+ }
+
+ while (pRow) {
+ code = tBlockDataAppendRow(pBDataW, pRow, NULL, id.uid);
+ if (code) goto _err;
+
+ iRow++;
+ if (iRow < pBDataR->nRow) {
+ row = tsdbRowFromBlockData(pBDataR, iRow);
+ } else {
+ pRow = NULL;
+ }
+
+ if (pBDataW->nRow >= pCommitter->maxRow) {
+ code = tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBDataW, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+ }
+ }
+
+ code = tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBDataW, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d, tsdb commit merge block failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbMergeTableData(SCommitter *pCommitter, TABLEID id) {
+ int32_t code = 0;
+ SBlockIdx *pBlockIdx = pCommitter->dReader.pBlockIdx;
+
+ ASSERT(pBlockIdx == NULL || tTABLEIDCmprFn(pBlockIdx, &id) >= 0);
+ if (pBlockIdx && pBlockIdx->suid == id.suid && pBlockIdx->uid == id.uid) {
+ int32_t iBlock = 0;
+ SDataBlk block;
+ SDataBlk *pDataBlk = █
+ SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter);
+
+ ASSERT(pRowInfo->suid == id.suid && pRowInfo->uid == id.uid);
+
+ tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk);
+ while (pDataBlk && pRowInfo) {
+ SDataBlk tBlock = {.minKey = TSDBROW_KEY(&pRowInfo->row), .maxKey = TSDBROW_KEY(&pRowInfo->row)};
+ int32_t c = tDataBlkCmprFn(pDataBlk, &tBlock);
+
+ if (c < 0) {
+ code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pDataBlk, tPutDataBlk);
+ if (code) goto _err;
+
+ iBlock++;
+ if (iBlock < pCommitter->dReader.mBlock.nItem) {
+ tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk);
+ } else {
+ pDataBlk = NULL;
+ }
+ } else if (c > 0) {
+ code = tsdbCommitAheadBlock(pCommitter, pDataBlk);
+ if (code) goto _err;
+
+ pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) pRowInfo = NULL;
+ } else {
+ code = tsdbCommitMergeBlock(pCommitter, pDataBlk);
+ if (code) goto _err;
+
+ iBlock++;
+ if (iBlock < pCommitter->dReader.mBlock.nItem) {
+ tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk);
+ } else {
+ pDataBlk = NULL;
+ }
+ pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) pRowInfo = NULL;
+ }
+ }
+
+ while (pDataBlk) {
+ code = tMapDataPutItem(&pCommitter->dWriter.mBlock, pDataBlk, tPutDataBlk);
+ if (code) goto _err;
+
+ iBlock++;
+ if (iBlock < pCommitter->dReader.mBlock.nItem) {
+ tMapDataGetItemByIdx(&pCommitter->dReader.mBlock, iBlock, pDataBlk, tGetDataBlk);
+ } else {
+ pDataBlk = NULL;
+ }
+ }
+
+ code = tsdbCommitterNextTableData(pCommitter);
+ if (code) goto _err;
+ }
+
+_exit:
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb merge table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbInitLastBlockIfNeed(SCommitter *pCommitter, TABLEID id) {
+ int32_t code = 0;
+
+ SBlockData *pBDatal = &pCommitter->dWriter.bDatal;
+ if (pBDatal->suid || pBDatal->uid) {
+ if ((pBDatal->suid != id.suid) || (id.suid == 0)) {
+ code = tsdbWriteSttBlock(pCommitter->dWriter.pWriter, pBDatal, pCommitter->dWriter.aSttBlk, pCommitter->cmprAlg);
+ if (code) goto _exit;
+ tBlockDataReset(pBDatal);
+ }
+ }
+
+ if (!pBDatal->suid && !pBDatal->uid) {
+ ASSERT(pCommitter->skmTable.suid == id.suid);
+ ASSERT(pCommitter->skmTable.uid == id.uid);
+ code = tBlockDataInit(pBDatal, id.suid, id.suid ? 0 : id.uid, pCommitter->skmTable.pTSchema);
+ if (code) goto _exit;
+ }
+
+_exit:
+ return code;
+}
+
+static int32_t tsdbAppendLastBlock(SCommitter *pCommitter) {
+ int32_t code = 0;
+
+ SBlockData *pBData = &pCommitter->dWriter.bData;
+ SBlockData *pBDatal = &pCommitter->dWriter.bDatal;
+
+ TABLEID id = {.suid = pBData->suid, .uid = pBData->uid};
+ code = tsdbInitLastBlockIfNeed(pCommitter, id);
+ if (code) goto _err;
+
+ for (int32_t iRow = 0; iRow < pBData->nRow; iRow++) {
+ TSDBROW row = tsdbRowFromBlockData(pBData, iRow);
+ code = tBlockDataAppendRow(pBDatal, &row, NULL, pBData->uid);
+ if (code) goto _err;
+
+ if (pBDatal->nRow >= pCommitter->maxRow) {
+ code = tsdbWriteSttBlock(pCommitter->dWriter.pWriter, pBDatal, pCommitter->dWriter.aSttBlk, pCommitter->cmprAlg);
+ if (code) goto _err;
+ }
+ }
+
+ return code;
+
+_err:
+ return code;
+}
+
+static int32_t tsdbCommitTableData(SCommitter *pCommitter, TABLEID id) {
+ int32_t code = 0;
+
+ SRowInfo *pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) {
+ pRowInfo = NULL;
+ }
+
+ if (pRowInfo == NULL) goto _exit;
+
+ SBlockData *pBData;
+ if (pCommitter->toLastOnly) {
+ pBData = &pCommitter->dWriter.bDatal;
+ code = tsdbInitLastBlockIfNeed(pCommitter, id);
+ if (code) goto _err;
+ } else {
+ pBData = &pCommitter->dWriter.bData;
+ ASSERT(pBData->nRow == 0);
+ }
+
+ while (pRowInfo) {
+ STSchema *pTSchema = NULL;
+ if (pRowInfo->row.type == 0) {
+ code = tsdbCommitterUpdateRowSchema(pCommitter, id.suid, id.uid, TSDBROW_SVERSION(&pRowInfo->row));
+ if (code) goto _err;
+ pTSchema = pCommitter->skmRow.pTSchema;
+ }
+
+ code = tBlockDataAppendRow(pBData, &pRowInfo->row, pTSchema, id.uid);
+ if (code) goto _err;
+
+ code = tsdbNextCommitRow(pCommitter);
+ if (code) goto _err;
+
+ pRowInfo = tsdbGetCommitRow(pCommitter);
+ if (pRowInfo && (pRowInfo->suid != id.suid || pRowInfo->uid != id.uid)) {
+ pRowInfo = NULL;
+ }
+
+ if (pBData->nRow >= pCommitter->maxRow) {
+ if (pCommitter->toLastOnly) {
+ code = tsdbWriteSttBlock(pCommitter->dWriter.pWriter, pBData, pCommitter->dWriter.aSttBlk, pCommitter->cmprAlg);
+ if (code) goto _err;
+ } else {
+ code =
+ tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBData, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+ }
+ }
+ }
+
+ if (!pCommitter->toLastOnly && pBData->nRow) {
+ if (pBData->nRow > pCommitter->minRow) {
+ code = tsdbWriteDataBlock(pCommitter->dWriter.pWriter, pBData, &pCommitter->dWriter.mBlock, pCommitter->cmprAlg);
+ if (code) goto _err;
+ } else {
+ code = tsdbAppendLastBlock(pCommitter);
+ if (code) goto _err;
+ }
+ }
+
+_exit:
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb commit table data failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbCommitFileDataImpl(SCommitter *pCommitter) {
+ int32_t code = 0;
+
+ SRowInfo *pRowInfo;
+ TABLEID id = {0};
+ while ((pRowInfo = tsdbGetCommitRow(pCommitter)) != NULL) {
+ ASSERT(pRowInfo->suid != id.suid || pRowInfo->uid != id.uid);
+ id.suid = pRowInfo->suid;
+ id.uid = pRowInfo->uid;
+
+ code = tsdbMoveCommitData(pCommitter, id);
+ if (code) goto _err;
+
+ // start
+ tMapDataReset(&pCommitter->dWriter.mBlock);
+
+ // impl
+ code = tsdbUpdateTableSchema(pCommitter->pTsdb->pVnode->pMeta, id.suid, id.uid, &pCommitter->skmTable);
+ if (code) goto _err;
+ code = tBlockDataInit(&pCommitter->dReader.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema);
+ if (code) goto _err;
+ code = tBlockDataInit(&pCommitter->dWriter.bData, id.suid, id.uid, pCommitter->skmTable.pTSchema);
+ if (code) goto _err;
+
+ /* merge with data in .data file */
+ code = tsdbMergeTableData(pCommitter, id);
+ if (code) goto _err;
+
+ /* handle remain table data */
+ code = tsdbCommitTableData(pCommitter, id);
+ if (code) goto _err;
+
+ // end
+ if (pCommitter->dWriter.mBlock.nItem > 0) {
+ SBlockIdx blockIdx = {.suid = id.suid, .uid = id.uid};
+ code = tsdbWriteDataBlk(pCommitter->dWriter.pWriter, &pCommitter->dWriter.mBlock, &blockIdx);
+ if (code) goto _err;
+
+ if (taosArrayPush(pCommitter->dWriter.aBlockIdx, &blockIdx) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ }
+ }
+
+ id.suid = INT64_MAX;
+ id.uid = INT64_MAX;
+ code = tsdbMoveCommitData(pCommitter, id);
+ if (code) goto _err;
+
+ code = tsdbWriteSttBlock(pCommitter->dWriter.pWriter, &pCommitter->dWriter.bDatal, pCommitter->dWriter.aSttBlk,
+ pCommitter->cmprAlg);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb commit file data impl failed since %s", TD_VID(pCommitter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
diff --git a/source/dnode/vnode/src/tsdb/tsdbCompact.c b/source/dnode/vnode/src/tsdb/tsdbCompact.c
new file mode 100644
index 0000000000..fb3917be64
--- /dev/null
+++ b/source/dnode/vnode/src/tsdb/tsdbCompact.c
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tsdb.h"
+
+typedef struct {
+ STsdb *pTsdb;
+ STsdbFS fs;
+} STsdbCompactor;
+
+int32_t tsdbCompact(STsdb *pTsdb) {
+ int32_t code = 0;
+ // TODO
+ return code;
+}
diff --git a/source/dnode/vnode/src/tsdb/tsdbCompress.c b/source/dnode/vnode/src/tsdb/tsdbCompress.c
new file mode 100644
index 0000000000..76be7c1070
--- /dev/null
+++ b/source/dnode/vnode/src/tsdb/tsdbCompress.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tsdb.h"
+
+// Integer =====================================================
+typedef struct {
+ int8_t rawCopy;
+ int64_t prevVal;
+ int32_t nVal;
+ int32_t nBuf;
+ uint8_t *pBuf;
+} SIntCompressor;
+
+#define I64_SAFE_ADD(a, b) (((a) >= 0 && (b) <= INT64_MAX - (b)) || ((a) < 0 && (b) >= INT64_MIN - (a)))
+#define SIMPLE8B_MAX ((uint64_t)1152921504606846974LL)
+
+static int32_t tsdbCmprI64(SIntCompressor *pCompressor, int64_t val) {
+ int32_t code = 0;
+
+ // raw copy
+ if (pCompressor->rawCopy) {
+ memcpy(pCompressor->pBuf + pCompressor->nBuf, &val, sizeof(val));
+ pCompressor->nBuf += sizeof(val);
+ pCompressor->nVal++;
+ goto _exit;
+ }
+
+ if (!I64_SAFE_ADD(val, pCompressor->prevVal)) {
+ pCompressor->rawCopy = 1;
+ // TODO: decompress and copy
+ pCompressor->nVal++;
+ goto _exit;
+ }
+
+ int64_t diff = val - pCompressor->prevVal;
+ uint8_t zigzag = ZIGZAGE(int64_t, diff);
+
+ if (zigzag >= SIMPLE8B_MAX) {
+ pCompressor->rawCopy = 1;
+ // TODO: decompress and copy
+ pCompressor->nVal++;
+ goto _exit;
+ }
+
+_exit:
+ return code;
+}
+
+// Timestamp =====================================================
+
+// Float =====================================================
\ No newline at end of file
diff --git a/source/dnode/vnode/src/tsdb/tsdbDiskData.c b/source/dnode/vnode/src/tsdb/tsdbDiskData.c
new file mode 100644
index 0000000000..3bd71f0ea6
--- /dev/null
+++ b/source/dnode/vnode/src/tsdb/tsdbDiskData.c
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tsdb.h"
+
+typedef struct SDiskColBuilder SDiskColBuilder;
+struct SDiskColBuilder {
+ uint8_t flags;
+ uint8_t *pBitMap;
+ int32_t *aOffset;
+ int32_t nData;
+ uint8_t *pData;
+};
+
+int32_t tDiskColAddVal(SDiskColBuilder *pBuilder, SColVal *pColVal) {
+ int32_t code = 0;
+ // TODO
+ return code;
+}
+
+// ================================================================
+typedef struct SDiskDataBuilder SDiskDataBuilder;
+struct SDiskDataBuilder {
+ SDiskDataHdr hdr;
+ SArray *aBlockCol; // SArray
+};
+
+int32_t tDiskDataBuilderCreate(SDiskDataBuilder **ppBuilder) {
+ int32_t code = 0;
+ // TODO
+ return code;
+}
+
+void tDiskDataBuilderDestroy(SDiskDataBuilder *pBuilder) {
+ // TODO
+}
+
+void tDiskDataBuilderInit(SDiskDataBuilder *pBuilder, int64_t suid, int64_t uid, STSchema *pTSchema, int8_t cmprAlg) {
+ pBuilder->hdr = (SDiskDataHdr){.delimiter = TSDB_FILE_DLMT, //
+ .fmtVer = 0,
+ .suid = suid,
+ .uid = uid,
+ .cmprAlg = cmprAlg};
+}
+
+void tDiskDataBuilderReset(SDiskDataBuilder *pBuilder) {
+ // TODO
+}
+
+int32_t tDiskDataBuilderAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTSchema, int64_t uid) {
+ int32_t code = 0;
+
+ // uid (todo)
+
+ // version (todo)
+
+ // TSKEY (todo)
+
+ SRowIter iter = {0};
+ tRowIterInit(&iter, pRow, pTSchema);
+
+ for (int32_t iDiskCol = 0; iDiskCol < 0; iDiskCol++) {
+ }
+
+ return code;
+}
+
+int32_t tDiskDataBuilderGet(SDiskDataBuilder *pBuilder, uint8_t **ppData) {
+ int32_t code = 0;
+ // TODO
+ return code;
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/tsdb/tsdbFS.c b/source/dnode/vnode/src/tsdb/tsdbFS.c
index 247de99338..6b4134f416 100644
--- a/source/dnode/vnode/src/tsdb/tsdbFS.c
+++ b/source/dnode/vnode/src/tsdb/tsdbFS.c
@@ -21,6 +21,9 @@ static int32_t tsdbEncodeFS(uint8_t *p, STsdbFS *pFS) {
int8_t hasDel = pFS->pDelFile ? 1 : 0;
uint32_t nSet = taosArrayGetSize(pFS->aDFileSet);
+ // version
+ n += tPutI8(p ? p + n : p, 0);
+
// SDelFile
n += tPutI8(p ? p + n : p, hasDel);
if (hasDel) {
@@ -110,7 +113,7 @@ _err:
// taosRemoveFile(fname);
// }
-// // last
+// // stt
// if (isSameDisk && pFrom->pLastF->commitID == pTo->pLastF->commitID) {
// if (pFrom->pLastF->size > pTo->pLastF->size) {
// code = tsdbDFileRollback(pFS->pTsdb, pTo, TSDB_LAST_FILE);
@@ -140,7 +143,7 @@ _err:
// tsdbDataFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pDataF, fname);
// taosRemoveFile(fname);
-// // last
+// // stt
// tsdbLastFileName(pFS->pTsdb, pFrom->diskId, pFrom->fid, pFrom->pLastF, fname);
// taosRemoveFile(fname);
@@ -254,8 +257,10 @@ void tsdbFSDestroy(STsdbFS *pFS) {
SDFileSet *pSet = (SDFileSet *)taosArrayGet(pFS->aDFileSet, iSet);
taosMemoryFree(pSet->pHeadF);
taosMemoryFree(pSet->pDataF);
- taosMemoryFree(pSet->pLastF);
taosMemoryFree(pSet->pSmaF);
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ taosMemoryFree(pSet->aSttF[iStt]);
+ }
}
taosArrayDestroy(pFS->aDFileSet);
@@ -290,7 +295,7 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
- if (size != pSet->pHeadF->size) {
+ if (size != tsdbLogicToFileSize(pSet->pHeadF->size, pTsdb->pVnode->config.tsdbPageSize)) {
code = TSDB_CODE_FILE_CORRUPTED;
goto _err;
}
@@ -301,38 +306,40 @@ static int32_t tsdbScanAndTryFixFS(STsdb *pTsdb) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
- if (size < pSet->pDataF->size) {
+ if (size < tsdbLogicToFileSize(pSet->pDataF->size, pTsdb->pVnode->config.tsdbPageSize)) {
code = TSDB_CODE_FILE_CORRUPTED;
goto _err;
- } else if (size > pSet->pDataF->size) {
+ } else if (size > tsdbLogicToFileSize(pSet->pDataF->size, pTsdb->pVnode->config.tsdbPageSize)) {
code = tsdbDFileRollback(pTsdb, pSet, TSDB_DATA_FILE);
if (code) goto _err;
}
- // last ===========
- tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname);
- if (taosStatFile(fname, &size, NULL)) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- if (size != pSet->pLastF->size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
// sma =============
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
if (taosStatFile(fname, &size, NULL)) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
- if (size < pSet->pSmaF->size) {
+ if (size < tsdbLogicToFileSize(pSet->pSmaF->size, pTsdb->pVnode->config.tsdbPageSize)) {
code = TSDB_CODE_FILE_CORRUPTED;
goto _err;
- } else if (size > pSet->pSmaF->size) {
+ } else if (size > tsdbLogicToFileSize(pSet->pSmaF->size, pTsdb->pVnode->config.tsdbPageSize)) {
code = tsdbDFileRollback(pTsdb, pSet, TSDB_SMA_FILE);
if (code) goto _err;
}
+
+ // stt ===========
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
+ if (taosStatFile(fname, &size, NULL)) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ if (size != tsdbLogicToFileSize(pSet->aSttF[iStt]->size, pTsdb->pVnode->config.tsdbPageSize)) {
+ code = TSDB_CODE_FILE_CORRUPTED;
+ goto _err;
+ }
+ }
}
{
@@ -360,10 +367,12 @@ static int32_t tsdbRecoverFS(STsdb *pTsdb, uint8_t *pData, int64_t nData) {
int32_t code = 0;
int8_t hasDel;
uint32_t nSet;
- int32_t n;
+ int32_t n = 0;
+
+ // version
+ n += tGetI8(pData + n, NULL);
// SDelFile
- n = 0;
n += tGetI8(pData + n, &hasDel);
if (hasDel) {
pTsdb->fs.pDelFile = (SDelFile *)taosMemoryMalloc(sizeof(SDelFile));
@@ -382,41 +391,15 @@ static int32_t tsdbRecoverFS(STsdb *pTsdb, uint8_t *pData, int64_t nData) {
taosArrayClear(pTsdb->fs.aDFileSet);
n += tGetU32v(pData + n, &nSet);
for (uint32_t iSet = 0; iSet < nSet; iSet++) {
- SDFileSet fSet;
+ SDFileSet fSet = {0};
- // head
- fSet.pHeadF = (SHeadFile *)taosMemoryCalloc(1, sizeof(SHeadFile));
- if (fSet.pHeadF == NULL) {
+ int32_t nt = tGetDFileSet(pData + n, &fSet);
+ if (nt < 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
- fSet.pHeadF->nRef = 1;
- // data
- fSet.pDataF = (SDataFile *)taosMemoryCalloc(1, sizeof(SDataFile));
- if (fSet.pDataF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- fSet.pDataF->nRef = 1;
-
- // last
- fSet.pLastF = (SLastFile *)taosMemoryCalloc(1, sizeof(SLastFile));
- if (fSet.pLastF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- fSet.pLastF->nRef = 1;
-
- // sma
- fSet.pSmaF = (SSmaFile *)taosMemoryCalloc(1, sizeof(SSmaFile));
- if (fSet.pSmaF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- fSet.pSmaF->nRef = 1;
-
- n += tGetDFileSet(pData + n, &fSet);
+ n += nt;
if (taosArrayPush(pTsdb->fs.aDFileSet, &fSet) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -532,13 +515,15 @@ int32_t tsdbFSClose(STsdb *pTsdb) {
ASSERT(pSet->pDataF->nRef == 1);
taosMemoryFree(pSet->pDataF);
- // last
- ASSERT(pSet->pLastF->nRef == 1);
- taosMemoryFree(pSet->pLastF);
-
// sma
ASSERT(pSet->pSmaF->nRef == 1);
taosMemoryFree(pSet->pSmaF);
+
+ // stt
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ ASSERT(pSet->aSttF[iStt]->nRef == 1);
+ taosMemoryFree(pSet->aSttF[iStt]);
+ }
}
taosArrayDestroy(pTsdb->fs.aDFileSet);
@@ -586,15 +571,7 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) {
}
*fSet.pDataF = *pSet->pDataF;
- // data
- fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile));
- if (fSet.pLastF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
- }
- *fSet.pLastF = *pSet->pLastF;
-
- // last
+ // sma
fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile));
if (fSet.pSmaF == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -602,6 +579,16 @@ int32_t tsdbFSCopy(STsdb *pTsdb, STsdbFS *pFS) {
}
*fSet.pSmaF = *pSet->pSmaF;
+ // stt
+ for (fSet.nSttF = 0; fSet.nSttF < pSet->nSttF; fSet.nSttF++) {
+ fSet.aSttF[fSet.nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (fSet.aSttF[fSet.nSttF] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+ *fSet.aSttF[fSet.nSttF] = *pSet->aSttF[fSet.nSttF];
+ }
+
if (taosArrayPush(pFS->aDFileSet, &fSet) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
@@ -651,14 +638,38 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
if (c == 0) {
*pDFileSet->pHeadF = *pSet->pHeadF;
*pDFileSet->pDataF = *pSet->pDataF;
- *pDFileSet->pLastF = *pSet->pLastF;
*pDFileSet->pSmaF = *pSet->pSmaF;
+ // stt
+ if (pSet->nSttF > pDFileSet->nSttF) {
+ ASSERT(pSet->nSttF == pDFileSet->nSttF + 1);
+
+ pDFileSet->aSttF[pDFileSet->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (pDFileSet->aSttF[pDFileSet->nSttF] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+ *pDFileSet->aSttF[pDFileSet->nSttF] = *pSet->aSttF[pSet->nSttF - 1];
+ pDFileSet->nSttF++;
+ } else if (pSet->nSttF < pDFileSet->nSttF) {
+ ASSERT(pSet->nSttF == 1);
+ for (int32_t iStt = 1; iStt < pDFileSet->nSttF; iStt++) {
+ taosMemoryFree(pDFileSet->aSttF[iStt]);
+ }
+
+ *pDFileSet->aSttF[0] = *pSet->aSttF[0];
+ pDFileSet->nSttF = 1;
+ } else {
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ *pDFileSet->aSttF[iStt] = *pSet->aSttF[iStt];
+ }
+ }
goto _exit;
}
}
- SDFileSet fSet = {.diskId = pSet->diskId, .fid = pSet->fid};
+ ASSERT(pSet->nSttF == 1);
+ SDFileSet fSet = {.diskId = pSet->diskId, .fid = pSet->fid, .nSttF = 1};
// head
fSet.pHeadF = (SHeadFile *)taosMemoryMalloc(sizeof(SHeadFile));
@@ -676,15 +687,7 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
}
*fSet.pDataF = *pSet->pDataF;
- // data
- fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile));
- if (fSet.pLastF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _exit;
- }
- *fSet.pLastF = *pSet->pLastF;
-
- // last
+ // sma
fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile));
if (fSet.pSmaF == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -692,6 +695,14 @@ int32_t tsdbFSUpsertFSet(STsdbFS *pFS, SDFileSet *pSet) {
}
*fSet.pSmaF = *pSet->pSmaF;
+ // stt
+ fSet.aSttF[0] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (fSet.aSttF[0] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+ *fSet.aSttF[0] = *pSet->aSttF[0];
+
if (taosArrayInsert(pFS->aDFileSet, idx, &fSet) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
@@ -836,27 +847,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
pSetOld->pDataF->size = pSetNew->pDataF->size;
}
- // last
- fSet.pLastF = pSetOld->pLastF;
- if ((!sameDisk) || (pSetOld->pLastF->commitID != pSetNew->pLastF->commitID)) {
- pSetOld->pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile));
- if (pSetOld->pLastF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- *pSetOld->pLastF = *pSetNew->pLastF;
- pSetOld->pLastF->nRef = 1;
-
- nRef = atomic_sub_fetch_32(&fSet.pLastF->nRef, 1);
- if (nRef == 0) {
- tsdbLastFileName(pTsdb, pSetOld->diskId, pSetOld->fid, fSet.pLastF, fname);
- taosRemoveFile(fname);
- taosMemoryFree(fSet.pLastF);
- }
- } else {
- ASSERT(pSetOld->pLastF->size == pSetNew->pLastF->size);
- }
-
// sma
fSet.pSmaF = pSetOld->pSmaF;
if ((!sameDisk) || (pSetOld->pSmaF->commitID != pSetNew->pSmaF->commitID)) {
@@ -879,6 +869,84 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
pSetOld->pSmaF->size = pSetNew->pSmaF->size;
}
+ // stt
+ if (sameDisk) {
+ if (pSetNew->nSttF > pSetOld->nSttF) {
+ ASSERT(pSetNew->nSttF = pSetOld->nSttF + 1);
+ pSetOld->aSttF[pSetOld->nSttF] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (pSetOld->aSttF[pSetOld->nSttF] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ *pSetOld->aSttF[pSetOld->nSttF] = *pSetNew->aSttF[pSetOld->nSttF];
+ pSetOld->aSttF[pSetOld->nSttF]->nRef = 1;
+ pSetOld->nSttF++;
+ } else if (pSetNew->nSttF < pSetOld->nSttF) {
+ ASSERT(pSetNew->nSttF == 1);
+ for (int32_t iStt = 0; iStt < pSetOld->nSttF; iStt++) {
+ SSttFile *pSttFile = pSetOld->aSttF[iStt];
+ nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
+ if (nRef == 0) {
+ tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
+ taosRemoveFile(fname);
+ taosMemoryFree(pSttFile);
+ }
+ pSetOld->aSttF[iStt] = NULL;
+ }
+
+ pSetOld->nSttF = 1;
+ pSetOld->aSttF[0] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (pSetOld->aSttF[0] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ *pSetOld->aSttF[0] = *pSetNew->aSttF[0];
+ pSetOld->aSttF[0]->nRef = 1;
+ } else {
+ for (int32_t iStt = 0; iStt < pSetOld->nSttF; iStt++) {
+ if (pSetOld->aSttF[iStt]->commitID != pSetNew->aSttF[iStt]->commitID) {
+ SSttFile *pSttFile = pSetOld->aSttF[iStt];
+ nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
+ if (nRef == 0) {
+ tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
+ taosRemoveFile(fname);
+ taosMemoryFree(pSttFile);
+ }
+
+ pSetOld->aSttF[iStt] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (pSetOld->aSttF[iStt] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ *pSetOld->aSttF[iStt] = *pSetNew->aSttF[iStt];
+ pSetOld->aSttF[iStt]->nRef = 1;
+ } else {
+ ASSERT(pSetOld->aSttF[iStt]->size == pSetOld->aSttF[iStt]->size);
+ ASSERT(pSetOld->aSttF[iStt]->offset == pSetOld->aSttF[iStt]->offset);
+ }
+ }
+ }
+ } else {
+ ASSERT(pSetOld->nSttF == pSetNew->nSttF);
+ for (int32_t iStt = 0; iStt < pSetOld->nSttF; iStt++) {
+ SSttFile *pSttFile = pSetOld->aSttF[iStt];
+ nRef = atomic_sub_fetch_32(&pSttFile->nRef, 1);
+ if (nRef == 0) {
+ tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSttFile, fname);
+ taosRemoveFile(fname);
+ taosMemoryFree(pSttFile);
+ }
+
+ pSetOld->aSttF[iStt] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (pSetOld->aSttF[iStt] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ *pSetOld->aSttF[iStt] = *pSetNew->aSttF[iStt];
+ pSetOld->aSttF[iStt]->nRef = 1;
+ }
+ }
+
if (!sameDisk) {
pSetOld->diskId = pSetNew->diskId;
}
@@ -902,13 +970,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
taosMemoryFree(pSetOld->pDataF);
}
- nRef = atomic_sub_fetch_32(&pSetOld->pLastF->nRef, 1);
- if (nRef == 0) {
- tsdbLastFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->pLastF, fname);
- taosRemoveFile(fname);
- taosMemoryFree(pSetOld->pLastF);
- }
-
nRef = atomic_sub_fetch_32(&pSetOld->pSmaF->nRef, 1);
if (nRef == 0) {
tsdbSmaFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->pSmaF, fname);
@@ -916,12 +977,20 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
taosMemoryFree(pSetOld->pSmaF);
}
+ for (int8_t iStt = 0; iStt < pSetOld->nSttF; iStt++) {
+ nRef = atomic_sub_fetch_32(&pSetOld->aSttF[iStt]->nRef, 1);
+ if (nRef == 0) {
+ tsdbSttFileName(pTsdb, pSetOld->diskId, pSetOld->fid, pSetOld->aSttF[iStt], fname);
+ taosRemoveFile(fname);
+ taosMemoryFree(pSetOld->aSttF[iStt]);
+ }
+ }
+
taosArrayRemove(pTsdb->fs.aDFileSet, iOld);
continue;
_add_new:
- fSet.diskId = pSetNew->diskId;
- fSet.fid = pSetNew->fid;
+ fSet = (SDFileSet){.diskId = pSetNew->diskId, .fid = pSetNew->fid, .nSttF = 1};
// head
fSet.pHeadF = (SHeadFile *)taosMemoryMalloc(sizeof(SHeadFile));
@@ -941,15 +1010,6 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
*fSet.pDataF = *pSetNew->pDataF;
fSet.pDataF->nRef = 1;
- // last
- fSet.pLastF = (SLastFile *)taosMemoryMalloc(sizeof(SLastFile));
- if (fSet.pLastF == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- *fSet.pLastF = *pSetNew->pLastF;
- fSet.pLastF->nRef = 1;
-
// sma
fSet.pSmaF = (SSmaFile *)taosMemoryMalloc(sizeof(SSmaFile));
if (fSet.pSmaF == NULL) {
@@ -959,6 +1019,16 @@ int32_t tsdbFSCommit2(STsdb *pTsdb, STsdbFS *pFSNew) {
*fSet.pSmaF = *pSetNew->pSmaF;
fSet.pSmaF->nRef = 1;
+ // stt
+ ASSERT(pSetNew->nSttF == 1);
+ fSet.aSttF[0] = (SSttFile *)taosMemoryMalloc(sizeof(SSttFile));
+ if (fSet.aSttF[0] == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ *fSet.aSttF[0] = *pSetNew->aSttF[0];
+ fSet.aSttF[0]->nRef = 1;
+
if (taosArrayInsert(pTsdb->fs.aDFileSet, iOld, &fSet) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
@@ -1002,12 +1072,14 @@ int32_t tsdbFSRef(STsdb *pTsdb, STsdbFS *pFS) {
nRef = atomic_fetch_add_32(&pSet->pDataF->nRef, 1);
ASSERT(nRef > 0);
- nRef = atomic_fetch_add_32(&pSet->pLastF->nRef, 1);
- ASSERT(nRef > 0);
-
nRef = atomic_fetch_add_32(&pSet->pSmaF->nRef, 1);
ASSERT(nRef > 0);
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ nRef = atomic_fetch_add_32(&pSet->aSttF[iStt]->nRef, 1);
+ ASSERT(nRef > 0);
+ }
+
if (taosArrayPush(pFS->aDFileSet, &fSet) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
@@ -1053,15 +1125,6 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
taosMemoryFree(pSet->pDataF);
}
- // last
- nRef = atomic_sub_fetch_32(&pSet->pLastF->nRef, 1);
- ASSERT(nRef >= 0);
- if (nRef == 0) {
- tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname);
- taosRemoveFile(fname);
- taosMemoryFree(pSet->pLastF);
- }
-
// sma
nRef = atomic_sub_fetch_32(&pSet->pSmaF->nRef, 1);
ASSERT(nRef >= 0);
@@ -1070,6 +1133,18 @@ void tsdbFSUnref(STsdb *pTsdb, STsdbFS *pFS) {
taosRemoveFile(fname);
taosMemoryFree(pSet->pSmaF);
}
+
+ // stt
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ nRef = atomic_sub_fetch_32(&pSet->aSttF[iStt]->nRef, 1);
+ ASSERT(nRef >= 0);
+ if (nRef == 0) {
+ tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
+ taosRemoveFile(fname);
+ taosMemoryFree(pSet->aSttF[iStt]);
+ /* code */
+ }
+ }
}
taosArrayDestroy(pFS->aDFileSet);
diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c
index 00d2ac848f..3c944584de 100644
--- a/source/dnode/vnode/src/tsdb/tsdbFile.c
+++ b/source/dnode/vnode/src/tsdb/tsdbFile.c
@@ -53,22 +53,22 @@ static int32_t tGetDataFile(uint8_t *p, SDataFile *pDataFile) {
return n;
}
-int32_t tPutLastFile(uint8_t *p, SLastFile *pLastFile) {
+int32_t tPutSttFile(uint8_t *p, SSttFile *pSttFile) {
int32_t n = 0;
- n += tPutI64v(p ? p + n : p, pLastFile->commitID);
- n += tPutI64v(p ? p + n : p, pLastFile->size);
- n += tPutI64v(p ? p + n : p, pLastFile->offset);
+ n += tPutI64v(p ? p + n : p, pSttFile->commitID);
+ n += tPutI64v(p ? p + n : p, pSttFile->size);
+ n += tPutI64v(p ? p + n : p, pSttFile->offset);
return n;
}
-static int32_t tGetLastFile(uint8_t *p, SLastFile *pLastFile) {
+static int32_t tGetSttFile(uint8_t *p, SSttFile *pSttFile) {
int32_t n = 0;
- n += tGetI64v(p + n, &pLastFile->commitID);
- n += tGetI64v(p + n, &pLastFile->size);
- n += tGetI64v(p + n, &pLastFile->offset);
+ n += tGetI64v(p + n, &pSttFile->commitID);
+ n += tGetI64v(p + n, &pSttFile->size);
+ n += tGetI64v(p + n, &pSttFile->offset);
return n;
}
@@ -102,9 +102,9 @@ void tsdbDataFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SDataFile *pDataF,
TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pDataF->commitID, ".data");
}
-void tsdbLastFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SLastFile *pLastF, char fname[]) {
+void tsdbSttFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSttFile *pSttF, char fname[]) {
snprintf(fname, TSDB_FILENAME_LEN - 1, "%s%s%s%sv%df%dver%" PRId64 "%s", tfsGetDiskPath(pTsdb->pVnode->pTfs, did),
- TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pLastF->commitID, ".last");
+ TD_DIRSEP, pTsdb->path, TD_DIRSEP, TD_VID(pTsdb->pVnode), fid, pSttF->commitID, ".stt");
}
void tsdbSmaFileName(STsdb *pTsdb, SDiskID did, int32_t fid, SSmaFile *pSmaF, char fname[]) {
@@ -148,7 +148,7 @@ int32_t tsdbDFileRollback(STsdb *pTsdb, SDFileSet *pSet, EDataFileT ftype) {
}
// ftruncate
- if (taosFtruncateFile(pFD, size) < 0) {
+ if (taosFtruncateFile(pFD, tsdbLogicToFileSize(size, pTsdb->pVnode->config.tsdbPageSize)) < 0) {
code = TAOS_SYSTEM_ERROR(errno);
goto _err;
}
@@ -194,9 +194,11 @@ int32_t tPutDFileSet(uint8_t *p, SDFileSet *pSet) {
n += tPutDataFile(p ? p + n : p, pSet->pDataF);
n += tPutSmaFile(p ? p + n : p, pSet->pSmaF);
- // last
- n += tPutU8(p ? p + n : p, 1); // for future compatibility
- n += tPutLastFile(p ? p + n : p, pSet->pLastF);
+ // stt
+ n += tPutU8(p ? p + n : p, pSet->nSttF);
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ n += tPutSttFile(p ? p + n : p, pSet->aSttF[iStt]);
+ }
return n;
}
@@ -208,15 +210,40 @@ int32_t tGetDFileSet(uint8_t *p, SDFileSet *pSet) {
n += tGetI32v(p + n, &pSet->diskId.id);
n += tGetI32v(p + n, &pSet->fid);
- // data
+ // head
+ pSet->pHeadF = (SHeadFile *)taosMemoryCalloc(1, sizeof(SHeadFile));
+ if (pSet->pHeadF == NULL) {
+ return -1;
+ }
+ pSet->pHeadF->nRef = 1;
n += tGetHeadFile(p + n, pSet->pHeadF);
+
+ // data
+ pSet->pDataF = (SDataFile *)taosMemoryCalloc(1, sizeof(SDataFile));
+ if (pSet->pDataF == NULL) {
+ return -1;
+ }
+ pSet->pDataF->nRef = 1;
n += tGetDataFile(p + n, pSet->pDataF);
+
+ // sma
+ pSet->pSmaF = (SSmaFile *)taosMemoryCalloc(1, sizeof(SSmaFile));
+ if (pSet->pSmaF == NULL) {
+ return -1;
+ }
+ pSet->pSmaF->nRef = 1;
n += tGetSmaFile(p + n, pSet->pSmaF);
- // last
- uint8_t nLast;
- n += tGetU8(p + n, &nLast);
- n += tGetLastFile(p + n, pSet->pLastF);
+ // stt
+ n += tGetU8(p + n, &pSet->nSttF);
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ pSet->aSttF[iStt] = (SSttFile *)taosMemoryCalloc(1, sizeof(SSttFile));
+ if (pSet->aSttF[iStt] == NULL) {
+ return -1;
+ }
+ pSet->aSttF[iStt]->nRef = 1;
+ n += tGetSttFile(p + n, pSet->aSttF[iStt]);
+ }
return n;
}
diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
new file mode 100644
index 0000000000..45fe29f0fa
--- /dev/null
+++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c
@@ -0,0 +1,561 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "tsdb.h"
+
+// SLDataIter =================================================
+struct SLDataIter {
+ SRBTreeNode node;
+ SSttBlk *pSttBlk;
+ SDataFReader *pReader;
+ int32_t iStt;
+ int8_t backward;
+ int32_t iSttBlk;
+ int32_t iRow;
+ SRowInfo rInfo;
+ uint64_t uid;
+ STimeWindow timeWindow;
+ SVersionRange verRange;
+
+ SSttBlockLoadInfo* pBlockLoadInfo;
+};
+
+SSttBlockLoadInfo* tCreateLastBlockLoadInfo() {
+ SSttBlockLoadInfo* pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo));
+ if (pLoadInfo == NULL) {
+ terrno = TSDB_CODE_OUT_OF_MEMORY;
+ return NULL;
+ }
+
+ for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
+ pLoadInfo[i].blockIndex[0] = -1;
+ pLoadInfo[i].blockIndex[1] = -1;
+ pLoadInfo[i].currentLoadBlockIndex = 1;
+
+ int32_t code = tBlockDataCreate(&pLoadInfo[i].blockData[0]);
+ if (code) {
+ terrno = code;
+ }
+
+ code = tBlockDataCreate(&pLoadInfo[i].blockData[1]);
+ if (code) {
+ terrno = code;
+ }
+
+ pLoadInfo[i].aSttBlk = taosArrayInit(4, sizeof(SSttBlk));
+ }
+
+ return pLoadInfo;
+}
+
+void resetLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) {
+ for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
+ pLoadInfo[i].currentLoadBlockIndex = 1;
+ pLoadInfo[i].blockIndex[0] = -1;
+ pLoadInfo[i].blockIndex[1] = -1;
+
+ taosArrayClear(pLoadInfo[i].aSttBlk);
+
+ pLoadInfo[i].elapsedTime = 0;
+ pLoadInfo[i].loadBlocks = 0;
+ }
+}
+
+void getLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo, int64_t* blocks, double* el) {
+ for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
+ *el += pLoadInfo[i].elapsedTime;
+ *blocks += pLoadInfo[i].loadBlocks;
+ }
+}
+
+void* destroyLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) {
+ for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) {
+ pLoadInfo[i].currentLoadBlockIndex = 1;
+ pLoadInfo[i].blockIndex[0] = -1;
+ pLoadInfo[i].blockIndex[1] = -1;
+
+ tBlockDataDestroy(&pLoadInfo[i].blockData[0], true);
+ tBlockDataDestroy(&pLoadInfo[i].blockData[1], true);
+
+ taosArrayDestroy(pLoadInfo[i].aSttBlk);
+ }
+
+ taosMemoryFree(pLoadInfo);
+ return NULL;
+}
+
+static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) {
+ int32_t code = 0;
+
+ SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo;
+ if (pInfo->blockIndex[0] == pIter->iSttBlk) {
+ return &pInfo->blockData[0];
+ }
+
+ if (pInfo->blockIndex[1] == pIter->iSttBlk) {
+ return &pInfo->blockData[1];
+ }
+
+ pInfo->currentLoadBlockIndex ^= 1;
+ if (pIter->pSttBlk != NULL) { // current block not loaded yet
+ int64_t st = taosGetTimestampUs();
+ code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, &pInfo->blockData[pInfo->currentLoadBlockIndex]);
+ double el = (taosGetTimestampUs() - st)/ 1000.0;
+ pInfo->elapsedTime += el;
+ pInfo->loadBlocks += 1;
+
+ tsdbDebug("read last block, index:%d, last file index:%d, elapsed time:%.2f ms, %s", pIter->iSttBlk, pIter->iStt, el, idStr);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _exit;
+ }
+
+ pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk;
+ pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1;
+ }
+
+ return &pInfo->blockData[pInfo->currentLoadBlockIndex];
+
+ _exit:
+ if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ }
+
+ return NULL;
+}
+
+// find the earliest block that contains the required records
+static FORCE_INLINE int32_t findEarliestIndex(int32_t index, uint64_t uid, const SSttBlk* pBlockList, int32_t num, int32_t backward) {
+ int32_t i = index;
+ int32_t step = backward? 1:-1;
+ while (i >= 0 && i < num && uid >= pBlockList[i].minUid && uid <= pBlockList[i].maxUid) {
+ i += step;
+ }
+ return i - step;
+}
+
+static int32_t binarySearchForStartBlock(SSttBlk*pBlockList, int32_t num, uint64_t uid, int32_t backward) {
+ int32_t midPos = -1;
+ if (num <= 0) {
+ return -1;
+ }
+
+ int32_t firstPos = 0;
+ int32_t lastPos = num - 1;
+
+ // find the first position which is bigger than the key
+ if ((uid > pBlockList[lastPos].maxUid) || (uid < pBlockList[firstPos].minUid)) {
+ return -1;
+ }
+
+ while (1) {
+ if (uid >= pBlockList[firstPos].minUid && uid <= pBlockList[firstPos].maxUid) {
+ return findEarliestIndex(firstPos, uid, pBlockList, num, backward);
+ }
+
+ if (uid > pBlockList[lastPos].maxUid || uid < pBlockList[firstPos].minUid) {
+ return -1;
+ }
+
+ int32_t numOfRows = lastPos - firstPos + 1;
+ midPos = (numOfRows >> 1u) + firstPos;
+
+ if (uid < pBlockList[midPos].minUid) {
+ lastPos = midPos - 1;
+ } else if (uid > pBlockList[midPos].maxUid) {
+ firstPos = midPos + 1;
+ } else {
+ return findEarliestIndex(midPos, uid, pBlockList, num, backward);
+ }
+ }
+}
+
+static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t* uidList, int32_t num, int32_t backward) {
+ int32_t i = index;
+ int32_t step = backward? 1:-1;
+ while (i >= 0 && i < num && uid == uidList[i]) {
+ i += step;
+ }
+ return i - step;
+}
+
+static int32_t binarySearchForStartRowIndex(uint64_t* uidList, int32_t num, uint64_t uid, int32_t backward) {
+ int32_t firstPos = 0;
+ int32_t lastPos = num - 1;
+
+ // find the first position which is bigger than the key
+ if ((uid > uidList[lastPos]) || (uid < uidList[firstPos])) {
+ return -1;
+ }
+
+ while (1) {
+ if (uid == uidList[firstPos]) {
+ return findEarliestRow(firstPos, uid, uidList, num, backward);
+ }
+
+ if (uid > uidList[lastPos] || uid < uidList[firstPos]) {
+ return -1;
+ }
+
+ int32_t numOfRows = lastPos - firstPos + 1;
+ int32_t midPos = (numOfRows >> 1u) + firstPos;
+
+ if (uid < uidList[midPos]) {
+ lastPos = midPos - 1;
+ } else if (uid > uidList[midPos]) {
+ firstPos = midPos + 1;
+ } else {
+ return findEarliestRow(midPos, uid, uidList, num, backward);
+ }
+ }
+}
+
+int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t iStt, int8_t backward, uint64_t suid,
+ uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo* pBlockLoadInfo) {
+ int32_t code = 0;
+ *pIter = taosMemoryCalloc(1, sizeof(SLDataIter));
+ if (*pIter == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+ (*pIter)->uid = uid;
+ (*pIter)->pReader = pReader;
+ (*pIter)->iStt = iStt;
+ (*pIter)->backward = backward;
+ (*pIter)->verRange = *pRange;
+ (*pIter)->timeWindow = *pTimeWindow;
+
+ (*pIter)->pBlockLoadInfo = pBlockLoadInfo;
+ if (taosArrayGetSize(pBlockLoadInfo->aSttBlk) == 0) {
+ code = tsdbReadSttBlk(pReader, iStt, pBlockLoadInfo->aSttBlk);
+ if (code) {
+ goto _exit;
+ } else {
+ size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
+ SArray* pTmp = taosArrayInit(size, sizeof(SSttBlk));
+ for(int32_t i = 0; i < size; ++i) {
+ SSttBlk* p = taosArrayGet(pBlockLoadInfo->aSttBlk, i);
+ if (p->suid == suid) {
+ taosArrayPush(pTmp, p);
+ }
+ }
+
+ taosArrayDestroy(pBlockLoadInfo->aSttBlk);
+ pBlockLoadInfo->aSttBlk = pTmp;
+ }
+ }
+
+ size_t size = taosArrayGetSize(pBlockLoadInfo->aSttBlk);
+
+ // find the start block
+ (*pIter)->iSttBlk = binarySearchForStartBlock(pBlockLoadInfo->aSttBlk->pData, size, uid, backward);
+ if ((*pIter)->iSttBlk != -1) {
+ (*pIter)->pSttBlk = taosArrayGet(pBlockLoadInfo->aSttBlk, (*pIter)->iSttBlk);
+ (*pIter)->iRow = ((*pIter)->backward) ? (*pIter)->pSttBlk->nRow : -1;
+ }
+
+_exit:
+ return code;
+}
+
+void tLDataIterClose(SLDataIter *pIter) {
+ taosMemoryFree(pIter);
+}
+
+void tLDataIterNextBlock(SLDataIter *pIter) {
+ int32_t step = pIter->backward ? -1 : 1;
+ pIter->iSttBlk += step;
+
+ int32_t index = -1;
+ size_t size = pIter->pBlockLoadInfo->aSttBlk->size;
+ for (int32_t i = pIter->iSttBlk; i < size && i >= 0; i += step) {
+ SSttBlk *p = taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, i);
+ if ((!pIter->backward) && p->minUid > pIter->uid) {
+ break;
+ }
+
+ if (pIter->backward && p->maxUid < pIter->uid) {
+ break;
+ }
+
+ // check uid firstly
+ if (p->minUid <= pIter->uid && p->maxUid >= pIter->uid) {
+ if ((!pIter->backward) && p->minKey > pIter->timeWindow.ekey) {
+ break;
+ }
+
+ if (pIter->backward && p->maxKey < pIter->timeWindow.skey) {
+ break;
+ }
+
+ // check time range secondly
+ if (p->minKey <= pIter->timeWindow.ekey && p->maxKey >= pIter->timeWindow.skey) {
+ if ((!pIter->backward) && p->minVer > pIter->verRange.maxVer) {
+ break;
+ }
+
+ if (pIter->backward && p->maxVer < pIter->verRange.minVer) {
+ break;
+ }
+
+ if (p->minVer <= pIter->verRange.maxVer && p->maxVer >= pIter->verRange.minVer) {
+ index = i;
+ break;
+ }
+ }
+ }
+ }
+
+ pIter->pSttBlk = NULL;
+ if (index != -1) {
+ pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk);
+ }
+}
+
+static void findNextValidRow(SLDataIter *pIter, const char* idStr) {
+ int32_t step = pIter->backward ? -1 : 1;
+
+ bool hasVal = false;
+ int32_t i = pIter->iRow;
+
+ SBlockData *pBlockData = loadLastBlock(pIter, idStr);
+
+ // mostly we only need to find the start position for a given table
+ if ((((i == 0) && (!pIter->backward)) || (i == pBlockData->nRow - 1 && pIter->backward)) && pBlockData->aUid != NULL) {
+ i = binarySearchForStartRowIndex((uint64_t*)pBlockData->aUid, pBlockData->nRow, pIter->uid, pIter->backward);
+ if (i == -1) {
+ pIter->iRow = -1;
+ return;
+ }
+ }
+
+ for (; i < pBlockData->nRow && i >= 0; i += step) {
+ if (pBlockData->aUid != NULL) {
+ if (!pIter->backward) {
+ /*if (pBlockData->aUid[i] < pIter->uid) {
+ continue;
+ } else */if (pBlockData->aUid[i] > pIter->uid) {
+ break;
+ }
+ } else {
+ /*if (pBlockData->aUid[i] > pIter->uid) {
+ continue;
+ } else */if (pBlockData->aUid[i] < pIter->uid) {
+ break;
+ }
+ }
+ }
+
+ int64_t ts = pBlockData->aTSKEY[i];
+ if (!pIter->backward) { // asc
+ if (ts > pIter->timeWindow.ekey) { // no more data
+ break;
+ } else if (ts < pIter->timeWindow.skey) {
+ continue;
+ }
+ } else {
+ if (ts < pIter->timeWindow.skey) {
+ break;
+ } else if (ts > pIter->timeWindow.ekey) {
+ continue;
+ }
+ }
+
+ int64_t ver = pBlockData->aVersion[i];
+ if (ver < pIter->verRange.minVer) {
+ continue;
+ }
+
+ // todo opt handle desc case
+ if (ver > pIter->verRange.maxVer) {
+ continue;
+ }
+
+ hasVal = true;
+ break;
+ }
+
+ pIter->iRow = (hasVal) ? i : -1;
+}
+
+bool tLDataIterNextRow(SLDataIter *pIter, const char* idStr) {
+ int32_t code = 0;
+ int32_t step = pIter->backward ? -1 : 1;
+
+ // no qualified last file block in current file, no need to fetch row
+ if (pIter->pSttBlk == NULL) {
+ return false;
+ }
+
+ int32_t iBlockL = pIter->iSttBlk;
+ SBlockData *pBlockData = loadLastBlock(pIter, idStr);
+ pIter->iRow += step;
+
+ while (1) {
+ findNextValidRow(pIter, idStr);
+
+ if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) {
+ tLDataIterNextBlock(pIter);
+ if (pIter->pSttBlk == NULL) { // no more data
+ goto _exit;
+ }
+ } else {
+ break;
+ }
+
+ if (iBlockL != pIter->iSttBlk) {
+ pBlockData = loadLastBlock(pIter, idStr);
+ pIter->iRow += step;
+ }
+ }
+
+ pIter->rInfo.suid = pBlockData->suid;
+ pIter->rInfo.uid = pBlockData->uid;
+ pIter->rInfo.row = tsdbRowFromBlockData(pBlockData, pIter->iRow);
+
+_exit:
+ if (code != TSDB_CODE_SUCCESS) {
+ terrno = code;
+ }
+
+ return (code == TSDB_CODE_SUCCESS) && (pIter->pSttBlk != NULL);
+}
+
+SRowInfo *tLDataIterGet(SLDataIter *pIter) { return &pIter->rInfo; }
+
+// SMergeTree =================================================
+static FORCE_INLINE int32_t tLDataIterCmprFn(const void *p1, const void *p2) {
+ SLDataIter *pIter1 = (SLDataIter *)(((uint8_t *)p1) - sizeof(SRBTreeNode));
+ SLDataIter *pIter2 = (SLDataIter *)(((uint8_t *)p2) - sizeof(SRBTreeNode));
+
+ TSDBKEY key1 = TSDBROW_KEY(&pIter1->rInfo.row);
+ TSDBKEY key2 = TSDBROW_KEY(&pIter2->rInfo.row);
+
+ if (key1.ts < key2.ts) {
+ return -1;
+ } else if (key1.ts > key2.ts) {
+ return 1;
+ } else {
+ if (key1.version < key2.version) {
+ return -1;
+ } else if (key1.version > key2.version) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+}
+
+int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFReader, uint64_t suid, uint64_t uid,
+ STimeWindow *pTimeWindow, SVersionRange *pVerRange, void* pBlockLoadInfo, const char* idStr) {
+ pMTree->backward = backward;
+ pMTree->pIter = NULL;
+ pMTree->pIterList = taosArrayInit(4, POINTER_BYTES);
+ if (pMTree->pIterList == NULL) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+
+ pMTree->idStr = idStr;
+
+ tRBTreeCreate(&pMTree->rbt, tLDataIterCmprFn);
+ int32_t code = TSDB_CODE_SUCCESS;
+
+ SSttBlockLoadInfo* pLoadInfo = NULL;
+ if (pBlockLoadInfo == NULL) {
+ if (pMTree->pLoadInfo == NULL) {
+ pMTree->destroyLoadInfo = true;
+ pMTree->pLoadInfo = tCreateLastBlockLoadInfo();
+ }
+
+ pLoadInfo = pMTree->pLoadInfo;
+ } else {
+ pLoadInfo = pBlockLoadInfo;
+ }
+
+ for (int32_t i = 0; i < pFReader->pSet->nSttF; ++i) { // open all last file
+ struct SLDataIter* pIter = NULL;
+ code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, &pLoadInfo[i]);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _end;
+ }
+
+ bool hasVal = tLDataIterNextRow(pIter, pMTree->idStr);
+ if (hasVal) {
+ taosArrayPush(pMTree->pIterList, &pIter);
+ tMergeTreeAddIter(pMTree, pIter);
+ } else {
+ tLDataIterClose(pIter);
+ }
+ }
+
+ return code;
+
+_end:
+ tMergeTreeClose(pMTree);
+ return code;
+}
+
+void tMergeTreeAddIter(SMergeTree *pMTree, SLDataIter *pIter) { tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pIter); }
+
+bool tMergeTreeNext(SMergeTree *pMTree) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ if (pMTree->pIter) {
+ SLDataIter *pIter = pMTree->pIter;
+
+ bool hasVal = tLDataIterNextRow(pIter, pMTree->idStr);
+ if (!hasVal) {
+ pMTree->pIter = NULL;
+ }
+
+ // compare with min in RB Tree
+ pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt);
+ if (pMTree->pIter && pIter) {
+ int32_t c = pMTree->rbt.cmprFn(RBTREE_NODE_PAYLOAD(&pMTree->pIter->node), RBTREE_NODE_PAYLOAD(&pIter->node));
+ if (c > 0) {
+ tRBTreePut(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
+ pMTree->pIter = NULL;
+ } else {
+ ASSERT(c);
+ }
+ }
+ }
+
+ if (pMTree->pIter == NULL) {
+ pMTree->pIter = (SLDataIter *)tRBTreeMin(&pMTree->rbt);
+ if (pMTree->pIter) {
+ tRBTreeDrop(&pMTree->rbt, (SRBTreeNode *)pMTree->pIter);
+ }
+ }
+
+ return pMTree->pIter != NULL;
+}
+
+TSDBROW tMergeTreeGetRow(SMergeTree *pMTree) { return pMTree->pIter->rInfo.row; }
+
+void tMergeTreeClose(SMergeTree *pMTree) {
+ size_t size = taosArrayGetSize(pMTree->pIterList);
+ for (int32_t i = 0; i < size; ++i) {
+ SLDataIter *pIter = taosArrayGetP(pMTree->pIterList, i);
+ tLDataIterClose(pIter);
+ }
+
+ pMTree->pIterList = taosArrayDestroy(pMTree->pIterList);
+ pMTree->pIter = NULL;
+
+ if (pMTree->destroyLoadInfo) {
+ pMTree->pLoadInfo = destroyLastBlockLoadInfo(pMTree->pLoadInfo);
+ pMTree->destroyLoadInfo = false;
+ }
+}
diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c
index f60ceab163..60d967681b 100644
--- a/source/dnode/vnode/src/tsdb/tsdbRead.c
+++ b/source/dnode/vnode/src/tsdb/tsdbRead.c
@@ -16,9 +16,7 @@
#include "osDef.h"
#include "tsdb.h"
-#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
-#define ALL_ROWS_CHECKED_INDEX (INT16_MIN)
-#define INITIAL_ROW_INDEX_VAL (-1)
+#define ASCENDING_TRAVERSE(o) (o == TSDB_ORDER_ASC)
typedef enum {
EXTERNAL_ROWS_PREV = 0x1,
@@ -34,21 +32,20 @@ typedef struct {
typedef struct {
int32_t numOfBlocks;
- int32_t numOfLastBlocks;
+ int32_t numOfLastFiles;
} SBlockNumber;
typedef struct STableBlockScanInfo {
uint64_t uid;
TSKEY lastKey;
- SMapData mapData; // block info (compressed)
- SArray* pBlockList; // block data index list
- SIterInfo iter; // mem buffer skip list iterator
- SIterInfo iiter; // imem buffer skip list iterator
- SArray* delSkyline; // delete info for this table
- int32_t fileDelIndex; // file block delete index
- int32_t lastBlockDelIndex;// delete index for last block
- bool iterInit; // whether to initialize the in-memory skip list iterator or not
- int16_t indexInBlockL;// row position in last block
+ SMapData mapData; // block info (compressed)
+ SArray* pBlockList; // block data index list
+ SIterInfo iter; // mem buffer skip list iterator
+ SIterInfo iiter; // imem buffer skip list iterator
+ SArray* delSkyline; // delete info for this table
+ int32_t fileDelIndex; // file block delete index
+ int32_t lastBlockDelIndex; // delete index for last block
+ bool iterInit; // whether to initialize the in-memory skip list iterator or not
} STableBlockScanInfo;
typedef struct SBlockOrderWrapper {
@@ -73,6 +70,8 @@ typedef struct SIOCostSummary {
double smaLoadTime;
int64_t lastBlockLoad;
double lastBlockLoadTime;
+ int64_t composedBlocks;
+ double buildComposedBlockTime;
} SIOCostSummary;
typedef struct SBlockLoadSuppInfo {
@@ -83,28 +82,21 @@ typedef struct SBlockLoadSuppInfo {
char** buildBuf; // build string tmp buffer, todo remove it later after all string format being updated.
} SBlockLoadSuppInfo;
-typedef struct SVersionRange {
- uint64_t minVer;
- uint64_t maxVer;
-} SVersionRange;
-
typedef struct SLastBlockReader {
- SArray* pBlockL;
- int32_t currentBlockIndex;
- SBlockData lastBlockData;
- STimeWindow window;
- SVersionRange verRange;
- int32_t order;
- uint64_t uid;
- int16_t* rowIndex; // row index ptr, usually from the STableBlockScanInfo->indexInBlockL
+ STimeWindow window;
+ SVersionRange verRange;
+ int32_t order;
+ uint64_t uid;
+ SMergeTree mergeTree;
+ SSttBlockLoadInfo* pInfo;
} SLastBlockReader;
typedef struct SFilesetIter {
- int32_t numOfFiles; // number of total files
- int32_t index; // current accessed index in the list
- SArray* pFileList; // data file list
+ int32_t numOfFiles; // number of total files
+ int32_t index; // current accessed index in the list
+ SArray* pFileList; // data file list
int32_t order;
- SLastBlockReader* pLastBlockReader; // last file block reader
+ SLastBlockReader* pLastBlockReader; // last file block reader
} SFilesetIter;
typedef struct SFileDataBlockInfo {
@@ -116,9 +108,9 @@ typedef struct SFileDataBlockInfo {
typedef struct SDataBlockIter {
int32_t numOfBlocks;
int32_t index;
- SArray* blockList; // SArray
+ SArray* blockList; // SArray
int32_t order;
- SBlock block; // current SBlock data
+ SDataBlk block; // current SDataBlk data
SHashObj* pTableMap;
} SDataBlockIter;
@@ -130,8 +122,8 @@ typedef struct SFileBlockDumpInfo {
} SFileBlockDumpInfo;
typedef struct SUidOrderCheckInfo {
- uint64_t* tableUidList; // access table uid list in uid ascending order list
- int32_t currentIndex; // index in table uid list
+ uint64_t* tableUidList; // access table uid list in uid ascending order list
+ int32_t currentIndex; // index in table uid list
} SUidOrderCheckInfo;
typedef struct SReaderStatus {
@@ -139,9 +131,9 @@ typedef struct SReaderStatus {
bool composedDataBlock; // the returned data block is a composed block or not
SHashObj* pTableMap; // SHash
STableBlockScanInfo* pTableIter; // table iterator used in building in-memory buffer data blocks.
- SUidOrderCheckInfo uidCheckInfo; // check all table in uid order
+ SUidOrderCheckInfo uidCheckInfo; // check all table in uid order
SFileBlockDumpInfo fBlockDumpInfo;
- SDFileSet* pCurrentFileset; // current opened file set
+ SDFileSet* pCurrentFileset; // current opened file set
SBlockData fileBlockData;
SFilesetIter fileIter;
SDataBlockIter blockIter;
@@ -175,29 +167,34 @@ static int buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, i
static TSDBROW* getValidMemRow(SIterInfo* pIter, const SArray* pDelList, STsdbReader* pReader);
static int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pScanInfo, STsdbReader* pReader,
SRowMerger* pMerger);
-static int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, SRowMerger* pMerger);
+static int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts,
+ SRowMerger* pMerger);
static int32_t doMergeRowsInBuf(SIterInfo* pIter, uint64_t uid, int64_t ts, SArray* pDelList, SRowMerger* pMerger,
STsdbReader* pReader);
static int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow* pTSRow, uint64_t uid);
static int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData,
- int32_t rowIndex);
+ int32_t rowIndex);
static void setComposedBlockFlag(STsdbReader* pReader, bool composed);
static bool hasBeenDropped(const SArray* pDelList, int32_t* index, TSDBKEY* pKey, int32_t order);
-static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList, STSRow** pTSRow,
- STsdbReader* pReader, bool* freeTSRow);
-static int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader,
- STSRow** pTSRow);
-static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader);
+static int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter, SArray* pDelList,
+ STSRow** pTSRow, STsdbReader* pReader, bool* freeTSRow);
+static int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo,
+ STsdbReader* pReader, STSRow** pTSRow);
+static int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key,
+ STsdbReader* pReader);
static int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData,
STbData* piMemTbData);
static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* retentions, const char* idstr,
int8_t* pLevel);
static SVersionRange getQueryVerRange(SVnode* pVnode, SQueryTableDataCond* pCond, int8_t level);
-static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader);
-static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
-static int32_t doBuildDataBlock(STsdbReader* pReader);
+static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader);
+static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader);
+static int32_t doBuildDataBlock(STsdbReader* pReader);
+static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader);
+
+static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
static int32_t setColumnIdSlotList(STsdbReader* pReader, SSDataBlock* pBlock) {
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
@@ -234,15 +231,13 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
}
for (int32_t j = 0; j < numOfTables; ++j) {
- STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid, .indexInBlockL = INITIAL_ROW_INDEX_VAL};
+ STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid};
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
- if (info.lastKey == INT64_MIN || info.lastKey < pTsdbReader->window.skey) {
- info.lastKey = pTsdbReader->window.skey;
- }
-
- ASSERT(info.lastKey >= pTsdbReader->window.skey && info.lastKey <= pTsdbReader->window.ekey);
+ int64_t skey = pTsdbReader->window.skey;
+ info.lastKey = (skey > INT64_MIN) ? (skey - 1) : skey;
} else {
- info.lastKey = pTsdbReader->window.skey;
+ int64_t ekey = pTsdbReader->window.ekey;
+ info.lastKey = (ekey < INT64_MAX) ? (ekey + 1) : ekey;
}
taosHashPut(pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
@@ -256,7 +251,7 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
return pTableMap;
}
-static void resetDataBlockScanInfo(SHashObj* pTableMap) {
+static void resetDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
STableBlockScanInfo* p = NULL;
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
@@ -266,9 +261,8 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap) {
p->iter.iter = tsdbTbDataIterDestroy(p->iter.iter);
}
- p->fileDelIndex = -1;
- p->delSkyline = taosArrayDestroy(p->delSkyline);
- p->lastBlockDelIndex = INITIAL_ROW_INDEX_VAL;
+ p->delSkyline = taosArrayDestroy(p->delSkyline);
+ p->lastKey = ts;
}
}
@@ -330,7 +324,7 @@ static void limitOutputBufferSize(const SQueryTableDataCond* pCond, int32_t* cap
}
// init file iterator
-static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdbReader* pReader/*int32_t order, const char* idstr*/) {
+static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdbReader* pReader) {
size_t numOfFileset = taosArrayGetSize(aDFileSet);
pIter->index = ASCENDING_TRAVERSE(pReader->order) ? -1 : numOfFileset;
@@ -345,17 +339,21 @@ static int32_t initFilesetIterator(SFilesetIter* pIter, SArray* aDFileSet, STsdb
tsdbError("failed to prepare the last block iterator, code:%d %s", tstrerror(code), pReader->idStr);
return code;
}
+ }
- SLastBlockReader* pLReader = pIter->pLastBlockReader;
- pLReader->pBlockL = taosArrayInit(4, sizeof(SBlockL));
- pLReader->order = pReader->order;
- pLReader->window = pReader->window;
- pLReader->verRange = pReader->verRange;
- pLReader->currentBlockIndex = -1;
+ SLastBlockReader* pLReader = pIter->pLastBlockReader;
+ pLReader->order = pReader->order;
+ pLReader->window = pReader->window;
+ pLReader->verRange = pReader->verRange;
- int32_t code = tBlockDataCreate(&pLReader->lastBlockData);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
+ pLReader->uid = 0;
+ tMergeTreeClose(&pLReader->mergeTree);
+
+ if (pLReader->pInfo == NULL) {
+ pLReader->pInfo = tCreateLastBlockLoadInfo();
+ if (pLReader->pInfo == NULL) {
+ tsdbDebug("init fileset iterator failed, code:%s %s", tstrerror(terrno), pReader->idStr);
+ return terrno;
}
}
@@ -372,6 +370,13 @@ static bool filesetIteratorNext(SFilesetIter* pIter, STsdbReader* pReader) {
return false;
}
+ SIOCostSummary* pSum = &pReader->cost;
+ getLastBlockLoadInfo(pIter->pLastBlockReader->pInfo, &pSum->lastBlockLoad, &pReader->cost.lastBlockLoadTime);
+
+ pIter->pLastBlockReader->uid = 0;
+ tMergeTreeClose(&pIter->pLastBlockReader->mergeTree);
+ resetLastBlockLoadInfo(pIter->pLastBlockReader->pInfo);
+
// check file the time range of coverage
STimeWindow win = {0};
@@ -580,14 +585,12 @@ static void cleanupTableScanInfo(SHashObj* pTableMap) {
}
// reset the index in last block when handing a new file
- px->indexInBlockL = INITIAL_ROW_INDEX_VAL;
tMapDataClear(&px->mapData);
taosArrayClear(px->pBlockList);
}
}
-static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray* pLastBlockIndex,
- SBlockNumber * pBlockNum, SArray* pQualifiedLastBlock) {
+static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SBlockNumber* pBlockNum) {
int32_t numOfQTable = 0;
size_t sizeInDisk = 0;
size_t numOfTables = taosArrayGetSize(pIndexList);
@@ -601,12 +604,12 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray*
STableBlockScanInfo* pScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockIdx->uid, sizeof(int64_t));
tMapDataReset(&pScanInfo->mapData);
- tsdbReadBlock(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData);
+ tsdbReadDataBlk(pReader->pFileReader, pBlockIdx, &pScanInfo->mapData);
sizeInDisk += pScanInfo->mapData.nData;
for (int32_t j = 0; j < pScanInfo->mapData.nItem; ++j) {
- SBlock block = {0};
- tMapDataGetItemByIdx(&pScanInfo->mapData, j, &block, tGetBlock);
+ SDataBlk block = {0};
+ tMapDataGetItemByIdx(&pScanInfo->mapData, j, &block, tGetDataBlk);
// 1. time range check
if (block.minKey.ts > pReader->window.ekey || block.maxKey.ts < pReader->window.skey) {
@@ -632,36 +635,14 @@ static int32_t doLoadFileBlock(STsdbReader* pReader, SArray* pIndexList, SArray*
}
}
- size_t numOfLast = taosArrayGetSize(pLastBlockIndex);
- for(int32_t i = 0; i < numOfLast; ++i) {
- SBlockL* pLastBlock = taosArrayGet(pLastBlockIndex, i);
- if (pLastBlock->suid != pReader->suid) {
- continue;
- }
-
- {
- // 1. time range check
- if (pLastBlock->minKey > pReader->window.ekey || pLastBlock->maxKey < pReader->window.skey) {
- continue;
- }
-
- // 2. version range check
- if (pLastBlock->minVer > pReader->verRange.maxVer || pLastBlock->maxVer < pReader->verRange.minVer) {
- continue;
- }
-
- pBlockNum->numOfLastBlocks += 1;
- taosArrayPush(pQualifiedLastBlock, pLastBlock);
- }
- }
-
- int32_t total = pBlockNum->numOfLastBlocks + pBlockNum->numOfBlocks;
+ pBlockNum->numOfLastFiles = pReader->pFileReader->pSet->nSttF;
+ int32_t total = pBlockNum->numOfLastFiles + pBlockNum->numOfBlocks;
double el = (taosGetTimestampUs() - st) / 1000.0;
tsdbDebug(
- "load block of %d tables completed, blocks:%d in %d tables, lastBlock:%d, block-info-size:%.2f Kb, elapsed "
+ "load block of %d tables completed, blocks:%d in %d tables, last-files:%d, block-info-size:%.2f Kb, elapsed "
"time:%.2f ms %s",
- numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastBlocks, sizeInDisk / 1000.0, el,
+ numOfTables, pBlockNum->numOfBlocks, numOfQTable, pBlockNum->numOfLastFiles, sizeInDisk / 1000.0, el,
pReader->idStr);
pReader->cost.numOfBlocks += total;
@@ -702,15 +683,156 @@ static SFileDataBlockInfo* getCurrentBlockInfo(SDataBlockIter* pBlockIter) {
return pBlockInfo;
}
-static SBlock* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; }
+static SDataBlk* getCurrentBlock(SDataBlockIter* pBlockIter) { return &pBlockIter->block; }
+
+int32_t binarySearchForTs(char* pValue, int num, TSKEY key, int order) {
+ int32_t midPos = -1;
+ int32_t numOfRows;
+
+ ASSERT(order == TSDB_ORDER_ASC || order == TSDB_ORDER_DESC);
+
+ TSKEY* keyList = (TSKEY*)pValue;
+ int32_t firstPos = 0;
+ int32_t lastPos = num - 1;
+
+ if (order == TSDB_ORDER_DESC) {
+ // find the first position which is smaller than the key
+ while (1) {
+ if (key >= keyList[firstPos]) return firstPos;
+ if (key == keyList[lastPos]) return lastPos;
+
+ if (key < keyList[lastPos]) {
+ lastPos += 1;
+ if (lastPos >= num) {
+ return -1;
+ } else {
+ return lastPos;
+ }
+ }
+
+ numOfRows = lastPos - firstPos + 1;
+ midPos = (numOfRows >> 1) + firstPos;
+
+ if (key < keyList[midPos]) {
+ firstPos = midPos + 1;
+ } else if (key > keyList[midPos]) {
+ lastPos = midPos - 1;
+ } else {
+ break;
+ }
+ }
+
+ } else {
+ // find the first position which is bigger than the key
+ while (1) {
+ if (key <= keyList[firstPos]) return firstPos;
+ if (key == keyList[lastPos]) return lastPos;
+
+ if (key > keyList[lastPos]) {
+ lastPos = lastPos + 1;
+ if (lastPos >= num)
+ return -1;
+ else
+ return lastPos;
+ }
+
+ numOfRows = lastPos - firstPos + 1;
+ midPos = (numOfRows >> 1u) + firstPos;
+
+ if (key < keyList[midPos]) {
+ lastPos = midPos - 1;
+ } else if (key > keyList[midPos]) {
+ firstPos = midPos + 1;
+ } else {
+ break;
+ }
+ }
+ }
+
+ return midPos;
+}
+
+static int doBinarySearchKey(TSKEY* keyList, int num, int pos, TSKEY key, int order) {
+ // start end position
+ int s, e;
+ s = pos;
+
+ // check
+ assert(pos >=0 && pos < num);
+ assert(num > 0);
+
+ if (order == TSDB_ORDER_ASC) {
+ // find the first position which is smaller than the key
+ e = num - 1;
+ if (key < keyList[pos])
+ return -1;
+ while (1) {
+ // check can return
+ if (key >= keyList[e])
+ return e;
+ if (key <= keyList[s])
+ return s;
+ if (e - s <= 1)
+ return s;
+
+ // change start or end position
+ int mid = s + (e - s + 1)/2;
+ if (keyList[mid] > key)
+ e = mid;
+ else if(keyList[mid] < key)
+ s = mid;
+ else
+ return mid;
+ }
+ } else { // DESC
+ // find the first position which is bigger than the key
+ e = 0;
+ if (key > keyList[pos])
+ return -1;
+ while (1) {
+ // check can return
+ if (key <= keyList[e])
+ return e;
+ if (key >= keyList[s])
+ return s;
+ if (s - e <= 1)
+ return s;
+
+ // change start or end position
+ int mid = s - (s - e + 1)/2;
+ if (keyList[mid] < key)
+ e = mid;
+ else if(keyList[mid] > key)
+ s = mid;
+ else
+ return mid;
+ }
+ }
+}
+
+int32_t getEndPosInDataBlock(STsdbReader* pReader, SBlockData* pBlockData, SDataBlk* pBlock, int32_t pos) {
+ // NOTE: reverse the order to find the end position in data block
+ int32_t endPos = -1;
+ bool asc = ASCENDING_TRAVERSE(pReader->order);
+
+ if (asc && pReader->window.ekey >= pBlock->maxKey.ts) {
+ endPos = pBlock->nRow - 1;
+ } else if (!asc && pReader->window.skey <= pBlock->minKey.ts) {
+ endPos = 0;
+ } else {
+ endPos = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.ekey, pReader->order);
+ }
+
+ return endPos;
+}
static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo) {
SReaderStatus* pStatus = &pReader->status;
SDataBlockIter* pBlockIter = &pStatus->blockIter;
SBlockData* pBlockData = &pStatus->fileBlockData;
- SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(pBlockIter);
- SBlock* pBlock = getCurrentBlock(pBlockIter);
+ SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
+ SDataBlk* pBlock = getCurrentBlock(pBlockIter);
SSDataBlock* pResBlock = pReader->pResBlock;
int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock);
@@ -722,23 +844,42 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
bool asc = ASCENDING_TRAVERSE(pReader->order);
int32_t step = asc ? 1 : -1;
- int32_t rowIndex = 0;
- int32_t remain = asc ? (pBlockData->nRow - pDumpInfo->rowIndex) : (pDumpInfo->rowIndex + 1);
-
- int32_t endIndex = 0;
- if (remain <= pReader->capacity) {
- endIndex = pBlockData->nRow;
+ if (asc && pReader->window.skey <= pBlock->minKey.ts) {
+ pDumpInfo->rowIndex = 0;
+ } else if (!asc && pReader->window.ekey >= pBlock->maxKey.ts) {
+ pDumpInfo->rowIndex = pBlock->nRow - 1;
} else {
- endIndex = pDumpInfo->rowIndex + step * pReader->capacity;
+ int32_t pos = asc? pBlock->nRow-1:0;
+ int32_t order = (pReader->order == TSDB_ORDER_ASC)? TSDB_ORDER_DESC:TSDB_ORDER_ASC;
+ pDumpInfo->rowIndex = doBinarySearchKey(pBlockData->aTSKEY, pBlock->nRow, pos, pReader->window.skey, order);
+ }
+
+ // time window check
+ int32_t endIndex = getEndPosInDataBlock(pReader, pBlockData, pBlock, pDumpInfo->rowIndex);
+ if (endIndex == -1) {
+ setBlockAllDumped(pDumpInfo, pReader->window.ekey, pReader->order);
+ return TSDB_CODE_SUCCESS;
+ }
+
+ endIndex += step;
+ int32_t remain = asc ? (endIndex - pDumpInfo->rowIndex) : (pDumpInfo->rowIndex - endIndex);
+ if (remain > pReader->capacity) { // output buffer check
remain = pReader->capacity;
}
- int32_t i = 0;
+ int32_t rowIndex = 0;
+
+ int32_t i = 0;
SColumnInfoData* pColData = taosArrayGet(pResBlock->pDataBlock, i);
if (pColData->info.colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
- for (int32_t j = pDumpInfo->rowIndex; j < endIndex && j >= 0; j += step) {
- colDataAppend(pColData, rowIndex++, (const char*)&pBlockData->aTSKEY[j], false);
+ if (asc) {
+ memcpy(pColData->pData, &pBlockData->aTSKEY[pDumpInfo->rowIndex], remain * sizeof(int64_t));
+ } else {
+ for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step) {
+ colDataAppendInt64(pColData, rowIndex++, &pBlockData->aTSKEY[j]);
+ }
}
+
i += 1;
}
@@ -752,13 +893,32 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
if (pData->cid < pColData->info.colId) {
colIndex += 1;
} else if (pData->cid == pColData->info.colId) {
- for (int32_t j = pDumpInfo->rowIndex; j < endIndex && j >= 0; j += step) {
- tColDataGetValue(pData, j, &cv);
- doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
+ if (pData->flag == HAS_NONE || pData->flag == HAS_NULL) {
+ colDataAppendNNULL(pColData, 0, remain);
+ } else {
+ if (IS_NUMERIC_TYPE(pColData->info.type) && asc) {
+ uint8_t* p = pData->pData + tDataTypes[pData->type].bytes * pDumpInfo->rowIndex;
+ memcpy(pColData->pData, p, remain * tDataTypes[pData->type].bytes);
+
+ // null value exists, check one-by-one
+ if (pData->flag != HAS_VALUE) {
+ for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step, rowIndex++) {
+ uint8_t v = GET_BIT2(pData->pBitMap, j);
+ if (v == 0 || v == 1) {
+ colDataSetNull_f(pColData->nullbitmap, rowIndex);
+ }
+ }
+ }
+ } else {
+ for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step) {
+ tColDataGetValue(pData, j, &cv);
+ doCopyColVal(pColData, rowIndex++, i, &cv, pSupInfo);
+ }
+ }
}
+
colIndex += 1;
i += 1;
- ASSERT(rowIndex == remain);
} else { // the specified column does not exist in file block, fill with null data
colDataAppendNNULL(pColData, 0, remain);
i += 1;
@@ -774,7 +934,13 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
pResBlock->info.rows = remain;
pDumpInfo->rowIndex += step * remain;
- setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
+ if (pDumpInfo->rowIndex >= 0 && pDumpInfo->rowIndex < pBlock->nRow) {
+ int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex];
+ setBlockAllDumped(pDumpInfo, ts, pReader->order);
+ } else {
+ int64_t k = asc? pBlock->maxKey.ts:pBlock->minKey.ts;
+ setBlockAllDumped(pDumpInfo, k, pReader->order);
+ }
double elapsedTime = (taosGetTimestampUs() - st) / 1000.0;
pReader->cost.blockLoadTime += elapsedTime;
@@ -782,7 +948,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
int32_t unDumpedRows = asc ? pBlock->nRow - pDumpInfo->rowIndex : pDumpInfo->rowIndex + 1;
tsdbDebug("%p copy file block to sdatablock, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
", rows:%d, remain:%d, minVer:%" PRId64 ", maxVer:%" PRId64 ", elapsed time:%.2f ms, %s",
- pReader, pBlockIter->index, pFBlock->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain, unDumpedRows,
+ pReader, pBlockIter->index, pBlockInfo->tbBlockIdx, pBlock->minKey.ts, pBlock->maxKey.ts, remain, unDumpedRows,
pBlock->minVer, pBlock->maxVer, elapsedTime, pReader->idStr);
return TSDB_CODE_SUCCESS;
@@ -795,8 +961,8 @@ static int32_t doLoadFileBlockData(STsdbReader* pReader, SDataBlockIter* pBlockI
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
ASSERT(pBlockInfo != NULL);
- SBlock* pBlock = getCurrentBlock(pBlockIter);
- int32_t code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData);
+ SDataBlk* pBlock = getCurrentBlock(pBlockIter);
+ int32_t code = tsdbReadDataBlock(pReader->pFileReader, pBlock, pBlockData);
if (code != TSDB_CODE_SUCCESS) {
tsdbError("%p error occurs in loading file block, global index:%d, table index:%d, brange:%" PRId64 "-%" PRId64
", rows:%d, code:%s %s",
@@ -872,8 +1038,8 @@ static int32_t doSetCurrentBlock(SDataBlockIter* pBlockIter) {
SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(pBlockIter);
if (pBlockInfo != NULL) {
STableBlockScanInfo* pScanInfo = taosHashGet(pBlockIter->pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
- int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx);
- tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetBlock);
+ int32_t* mapDataIndex = taosArrayGet(pScanInfo->pBlockList, pBlockInfo->tbBlockIdx);
+ tMapDataGetItemByIdx(&pScanInfo->mapData, *mapDataIndex, &pBlockIter->block, tGetDataBlk);
}
#if 0
@@ -924,12 +1090,12 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
}
sup.pDataBlockInfo[sup.numOfTables] = (SBlockOrderWrapper*)buf;
- SBlock block = {0};
+ SDataBlk block = {0};
for (int32_t k = 0; k < num; ++k) {
SBlockOrderWrapper wrapper = {0};
int32_t* mapDataIndex = taosArrayGet(pTableScanInfo->pBlockList, k);
- tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetBlock);
+ tMapDataGetItemByIdx(&pTableScanInfo->mapData, *mapDataIndex, &block, tGetDataBlk);
wrapper.uid = pTableScanInfo->uid;
wrapper.offset = block.aSubBlock[0].offset;
@@ -990,8 +1156,8 @@ static int32_t initBlockIterator(STsdbReader* pReader, SDataBlockIter* pBlockIte
}
int64_t et = taosGetTimestampUs();
- tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, numOfBlocks, (et - st) / 1000.0,
- pReader->idStr);
+ tsdbDebug("%p %d data blocks access order completed, elapsed time:%.2f ms %s", pReader, numOfBlocks,
+ (et - st) / 1000.0, pReader->idStr);
cleanupBlockOrderSupporter(&sup);
taosMemoryFree(pTree);
@@ -1018,15 +1184,15 @@ static bool blockIteratorNext(SDataBlockIter* pBlockIter) {
/**
* This is an two rectangles overlap cases.
*/
-static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* pVerRange, SBlock* pBlock) {
+static int32_t dataBlockPartiallyRequired(STimeWindow* pWindow, SVersionRange* pVerRange, SDataBlk* pBlock) {
return (pWindow->ekey < pBlock->maxKey.ts && pWindow->ekey >= pBlock->minKey.ts) ||
(pWindow->skey > pBlock->minKey.ts && pWindow->skey <= pBlock->maxKey.ts) ||
(pVerRange->minVer > pBlock->minVer && pVerRange->minVer <= pBlock->maxVer) ||
(pVerRange->maxVer < pBlock->maxVer && pVerRange->maxVer >= pBlock->minVer);
}
-static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo,
- int32_t* nextIndex, int32_t order) {
+static SDataBlk* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STableBlockScanInfo* pTableBlockScanInfo,
+ int32_t* nextIndex, int32_t order) {
bool asc = ASCENDING_TRAVERSE(order);
if (asc && pFBlockInfo->tbBlockIdx >= taosArrayGetSize(pTableBlockScanInfo->pBlockList) - 1) {
return NULL;
@@ -1039,10 +1205,10 @@ static SBlock* getNeighborBlockOfSameTable(SFileDataBlockInfo* pFBlockInfo, STab
int32_t step = asc ? 1 : -1;
*nextIndex = pFBlockInfo->tbBlockIdx + step;
- SBlock* pBlock = taosMemoryCalloc(1, sizeof(SBlock));
- int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex);
+ SDataBlk* pBlock = taosMemoryCalloc(1, sizeof(SDataBlk));
+ int32_t* indexInMapdata = taosArrayGet(pTableBlockScanInfo->pBlockList, *nextIndex);
- tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetBlock);
+ tMapDataGetItemByIdx(&pTableBlockScanInfo->mapData, *indexInMapdata, pBlock, tGetDataBlk);
return pBlock;
}
@@ -1085,7 +1251,7 @@ static int32_t setFileBlockActiveInBlockIter(SDataBlockIter* pBlockIter, int32_t
return TSDB_CODE_SUCCESS;
}
-static bool overlapWithNeighborBlock(SBlock* pBlock, SBlock* pNeighbor, int32_t order) {
+static bool overlapWithNeighborBlock(SDataBlk* pBlock, SDataBlk* pNeighbor, int32_t order) {
// it is the last block in current file, no chance to overlap with neighbor blocks.
if (ASCENDING_TRAVERSE(order)) {
return pBlock->maxKey.ts == pNeighbor->minKey.ts;
@@ -1094,19 +1260,19 @@ static bool overlapWithNeighborBlock(SBlock* pBlock, SBlock* pNeighbor, int32_t
}
}
-static bool bufferDataInFileBlockGap(int32_t order, TSDBKEY key, SBlock* pBlock) {
+static bool bufferDataInFileBlockGap(int32_t order, TSDBKEY key, SDataBlk* pBlock) {
bool ascScan = ASCENDING_TRAVERSE(order);
return (ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts <= pBlock->minKey.ts)) ||
(!ascScan && (key.ts != TSKEY_INITIAL_VAL && key.ts >= pBlock->maxKey.ts));
}
-static bool keyOverlapFileBlock(TSDBKEY key, SBlock* pBlock, SVersionRange* pVerRange) {
+static bool keyOverlapFileBlock(TSDBKEY key, SDataBlk* pBlock, SVersionRange* pVerRange) {
return (key.ts >= pBlock->minKey.ts && key.ts <= pBlock->maxKey.ts) && (pBlock->maxVer >= pVerRange->minVer) &&
(pBlock->minVer <= pVerRange->maxVer);
}
-static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock) {
+static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock) {
size_t num = taosArrayGetSize(pBlockScanInfo->delSkyline);
for (int32_t i = pBlockScanInfo->fileDelIndex; i < num; i += 1) {
@@ -1140,7 +1306,7 @@ static bool doCheckforDatablockOverlap(STableBlockScanInfo* pBlockScanInfo, cons
return false;
}
-static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBlock* pBlock, int32_t order) {
+static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SDataBlk* pBlock, int32_t order) {
if (pBlockScanInfo->delSkyline == NULL) {
return false;
}
@@ -1170,53 +1336,84 @@ static bool overlapWithDelSkyline(STableBlockScanInfo* pBlockScanInfo, const SBl
}
}
+typedef struct {
+ bool overlapWithNeighborBlock;
+ bool hasDupTs;
+ bool overlapWithDelInfo;
+ bool overlapWithLastBlock;
+ bool overlapWithKeyInBuf;
+ bool partiallyRequired;
+ bool moreThanCapcity;
+} SDataBlockToLoadInfo;
+
+static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo* pBlockInfo, SDataBlk* pBlock,
+ STableBlockScanInfo* pScanInfo, TSDBKEY keyInBuf, SLastBlockReader* pLastBlockReader,
+ STsdbReader* pReader) {
+ int32_t neighborIndex = 0;
+ SDataBlk* pNeighbor = getNeighborBlockOfSameTable(pBlockInfo, pScanInfo, &neighborIndex, pReader->order);
+
+ // overlap with neighbor
+ if (pNeighbor) {
+ pInfo->overlapWithNeighborBlock = overlapWithNeighborBlock(pBlock, pNeighbor, pReader->order);
+ taosMemoryFree(pNeighbor);
+ }
+
+ // has duplicated ts of different version in this block
+ pInfo->hasDupTs = (pBlock->nSubBlock == 1) ? pBlock->hasDup : true;
+ pInfo->overlapWithDelInfo = overlapWithDelSkyline(pScanInfo, pBlock, pReader->order);
+
+ // todo here we need to each key in the last files to identify if it is really overlapped with last block
+ // todo
+ bool overlapWithlastBlock = false;
+#if 0
+ if (taosArrayGetSize(pLastBlockReader->pSstBlk) > 0 && (pLastBlockReader->currentBlockIndex != -1)) {
+ SSttBlk* pSstBlk = taosArrayGet(pLastBlockReader->pSstBlk, pLastBlockReader->currentBlockIndex);
+ overlapWithlastBlock = !(pBlock->maxKey.ts < pSstBlk->minKey || pBlock->minKey.ts > pSstBlk->maxKey);
+ }
+#endif
+
+ pInfo->moreThanCapcity = pBlock->nRow > pReader->capacity;
+ pInfo->partiallyRequired = dataBlockPartiallyRequired(&pReader->window, &pReader->verRange, pBlock);
+ pInfo->overlapWithKeyInBuf = keyOverlapFileBlock(keyInBuf, pBlock, &pReader->verRange);
+}
+
// 1. the version of all rows should be less than the endVersion
// 2. current block should not overlap with next neighbor block
// 3. current timestamp should not be overlap with each other
// 4. output buffer should be large enough to hold all rows in current block
// 5. delete info should not overlap with current block data
-static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pFBlock, SBlock* pBlock,
- STableBlockScanInfo* pScanInfo, TSDBKEY key, SLastBlockReader* pLastBlockReader) {
- int32_t neighborIndex = 0;
- SBlock* pNeighbor = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &neighborIndex, pReader->order);
+// 6. current block should not contain the duplicated ts
+static bool fileBlockShouldLoad(STsdbReader* pReader, SFileDataBlockInfo* pBlockInfo, SDataBlk* pBlock,
+ STableBlockScanInfo* pScanInfo, TSDBKEY keyInBuf, SLastBlockReader* pLastBlockReader) {
+ SDataBlockToLoadInfo info = {0};
+ getBlockToLoadInfo(&info, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader, pReader);
- // overlap with neighbor
- bool overlapWithNeighbor = false;
- if (pNeighbor) {
- overlapWithNeighbor = overlapWithNeighborBlock(pBlock, pNeighbor, pReader->order);
- taosMemoryFree(pNeighbor);
- }
-
- // has duplicated ts of different version in this block
- bool hasDup = (pBlock->nSubBlock == 1) ? pBlock->hasDup : true;
- bool overlapWithDel = overlapWithDelSkyline(pScanInfo, pBlock, pReader->order);
-
- // todo here we need to each key in the last files to identify if it is really overlapped with last block
- bool overlapWithlastBlock = false;
- if (taosArrayGetSize(pLastBlockReader->pBlockL) > 0 && (pLastBlockReader->currentBlockIndex != -1)) {
- SBlockL *pBlockL = taosArrayGet(pLastBlockReader->pBlockL, pLastBlockReader->currentBlockIndex);
- overlapWithlastBlock = !(pBlock->maxKey.ts < pBlockL->minKey || pBlock->minKey.ts > pBlockL->maxKey);
- }
-
- bool moreThanOutputCapacity = pBlock->nRow > pReader->capacity;
- bool partiallyRequired = dataBlockPartiallyRequired(&pReader->window, &pReader->verRange, pBlock);
- bool overlapWithKey = keyOverlapFileBlock(key, pBlock, &pReader->verRange);
-
- bool loadDataBlock = (overlapWithNeighbor || hasDup || partiallyRequired || overlapWithKey ||
- moreThanOutputCapacity || overlapWithDel || overlapWithlastBlock);
+ bool loadDataBlock =
+ (info.overlapWithNeighborBlock || info.hasDupTs || info.partiallyRequired || info.overlapWithKeyInBuf ||
+ info.moreThanCapcity || info.overlapWithDelInfo || info.overlapWithLastBlock);
// log the reason why load the datablock for profile
if (loadDataBlock) {
tsdbDebug("%p uid:%" PRIu64
" need to load the datablock, overlapwithneighborblock:%d, hasDup:%d, partiallyRequired:%d, "
"overlapWithKey:%d, greaterThanBuf:%d, overlapWithDel:%d, overlapWithlastBlock:%d, %s",
- pReader, pFBlock->uid, overlapWithNeighbor, hasDup, partiallyRequired, overlapWithKey,
- moreThanOutputCapacity, overlapWithDel, overlapWithlastBlock, pReader->idStr);
+ pReader, pBlockInfo->uid, info.overlapWithNeighborBlock, info.hasDupTs, info.partiallyRequired,
+ info.overlapWithKeyInBuf, info.moreThanCapcity, info.overlapWithDelInfo, info.overlapWithLastBlock,
+ pReader->idStr);
}
return loadDataBlock;
}
+static bool isCleanFileDataBlock(STsdbReader* pReader, SFileDataBlockInfo* pBlockInfo, SDataBlk* pBlock,
+ STableBlockScanInfo* pScanInfo, TSDBKEY keyInBuf, SLastBlockReader* pLastBlockReader) {
+ SDataBlockToLoadInfo info = {0};
+ getBlockToLoadInfo(&info, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader, pReader);
+ bool isCleanFileBlock = !(info.overlapWithNeighborBlock || info.hasDupTs || info.overlapWithKeyInBuf ||
+ info.overlapWithDelInfo || info.overlapWithLastBlock);
+ return isCleanFileBlock;
+}
+
static int32_t buildDataBlockFromBuf(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo, int64_t endKey) {
if (!(pBlockScanInfo->iiter.hasVal || pBlockScanInfo->iter.hasVal)) {
return TSDB_CODE_SUCCESS;
@@ -1262,6 +1459,38 @@ static bool tryCopyDistinctRowFromFileBlock(STsdbReader* pReader, SBlockData* pB
return false;
}
+static bool nextRowFromLastBlocks(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pBlockScanInfo) {
+ while (1) {
+ bool hasVal = tMergeTreeNext(&pLastBlockReader->mergeTree);
+ if (!hasVal) {
+ return false;
+ }
+
+ TSDBROW row = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
+ TSDBKEY k = TSDBROW_KEY(&row);
+ if (!hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) {
+ return true;
+ }
+ }
+}
+
+static bool tryCopyDistinctRowFromSttBlock(TSDBROW* fRow, SLastBlockReader* pLastBlockReader,
+ STableBlockScanInfo* pScanInfo, int64_t ts, STsdbReader* pReader) {
+ bool hasVal = nextRowFromLastBlocks(pLastBlockReader, pScanInfo);
+ if (hasVal) {
+ int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader);
+ if (next1 != ts) {
+ doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow);
+ return true;
+ }
+ } else {
+ doAppendRowFromFileBlock(pReader->pResBlock, pReader, fRow->pBlockData, fRow->iRow);
+ return true;
+ }
+
+ return false;
+}
+
static FORCE_INLINE STSchema* doGetSchemaForTSRow(int32_t sversion, STsdbReader* pReader, uint64_t uid) {
// always set the newest schema version in pReader->pSchema
if (pReader->pSchema == NULL) {
@@ -1295,18 +1524,16 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
int64_t tsLast = INT64_MIN;
- if ((pLastBlockReader->lastBlockData.nRow > 0) && hasDataInLastBlock(pLastBlockReader)) {
+ if (hasDataInLastBlock(pLastBlockReader)) {
tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
}
- TSDBKEY k = TSDBROW_KEY(pRow);
- TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
-
- SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
+ TSDBKEY k = TSDBROW_KEY(pRow);
+ TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
int64_t minKey = 0;
if (pReader->order == TSDB_ORDER_ASC) {
- minKey = INT64_MAX; // chosen the minimum value
+ minKey = INT64_MAX; // chosen the minimum value
if (minKey > tsLast && hasDataInLastBlock(pLastBlockReader)) {
minKey = tsLast;
}
@@ -1336,7 +1563,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
bool init = false;
// ASC: file block ---> last block -----> imem -----> mem
- //DESC: mem -----> imem -----> last block -----> file block
+ // DESC: mem -----> imem -----> last block -----> file block
if (pReader->order == TSDB_ORDER_ASC) {
if (minKey == key) {
init = true;
@@ -1345,7 +1572,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
}
if (minKey == tsLast) {
- TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
if (init) {
tRowMerge(&merge, &fRow1);
} else {
@@ -1374,7 +1601,7 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
}
if (minKey == tsLast) {
- TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
if (init) {
tRowMerge(&merge, &fRow1);
} else {
@@ -1410,31 +1637,55 @@ static int32_t doMergeBufAndFileRows(STsdbReader* pReader, STableBlockScanInfo*
static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, STsdbReader* pReader,
STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData,
bool mergeBlockData) {
- SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
- int64_t tsLastBlock = getCurrentKeyInLastBlock(pLastBlockReader);
+ SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
+ int64_t tsLastBlock = getCurrentKeyInLastBlock(pLastBlockReader);
STSRow* pTSRow = NULL;
SRowMerger merge = {0};
+ TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
- TSDBROW fRow = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex);
+ // only last block exists
+ if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) {
+ if (tryCopyDistinctRowFromSttBlock(&fRow, pLastBlockReader, pBlockScanInfo, tsLastBlock, pReader)) {
+ return TSDB_CODE_SUCCESS;
+ } else {
+ tRowMergerInit(&merge, &fRow, pReader->pSchema);
- tRowMergerInit(&merge, &fRow, pReader->pSchema);
- doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
+ tRowMerge(&merge, &fRow1);
+ doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge);
- // merge with block data if ts == key
- if (mergeBlockData) {
- doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
+ int32_t code = tRowMergerGetRow(&merge, &pTSRow);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+
+ doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo->uid);
+
+ taosMemoryFree(pTSRow);
+ tRowMergerClear(&merge);
+ }
+ } else { // not merge block data
+ tRowMergerInit(&merge, &fRow, pReader->pSchema);
+ doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, tsLastBlock, &merge);
+ ASSERT(mergeBlockData);
+
+ // merge with block data if ts == key
+ if (tsLastBlock == pBlockData->aTSKEY[pDumpInfo->rowIndex]) {
+ doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
+ }
+
+ int32_t code = tRowMergerGetRow(&merge, &pTSRow);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+
+ doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo->uid);
+
+ taosMemoryFree(pTSRow);
+ tRowMergerClear(&merge);
}
- int32_t code = tRowMergerGetRow(&merge, &pTSRow);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo->uid);
-
- taosMemoryFree(pTSRow);
- tRowMergerClear(&merge);
return TSDB_CODE_SUCCESS;
}
@@ -1444,7 +1695,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
if (pBlockData->nRow > 0) {
// no last block available, only data block exists
- if (pLastBlockReader->lastBlockData.nRow == 0 || (!hasDataInLastBlock(pLastBlockReader))) {
+ if (!hasDataInLastBlock(pLastBlockReader)) {
return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader);
}
@@ -1454,7 +1705,7 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
ASSERT(ts >= key);
if (ASCENDING_TRAVERSE(pReader->order)) {
- if (key < ts) { // imem, mem are all empty, file blocks (data blocks and last block) exist
+ if (key < ts) { // imem, mem are all empty, file blocks (data blocks and last block) exist
return mergeRowsInFileBlocks(pBlockData, pBlockScanInfo, key, pReader);
} else if (key == ts) {
STSRow* pTSRow = NULL;
@@ -1462,6 +1713,10 @@ static int32_t mergeFileBlockAndLastBlock(STsdbReader* pReader, SLastBlockReader
tRowMergerInit(&merge, &fRow, pReader->pSchema);
doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
+
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
+ tRowMerge(&merge, &fRow1);
+
doMergeRowsInLastBlock(pLastBlockReader, pBlockScanInfo, ts, &merge);
int32_t code = tRowMergerGetRow(&merge, &pTSRow);
@@ -1498,7 +1753,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader);
ASSERT(pRow != NULL && piRow != NULL);
- SBlockData* pLastBlockData = &pLastBlockReader->lastBlockData;
int64_t tsLast = INT64_MIN;
if (hasDataInLastBlock(pLastBlockReader)) {
tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
@@ -1528,7 +1782,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
minKey = tsLast;
}
} else {
- minKey = INT64_MIN; // let find the maximum ts value
+ minKey = INT64_MIN; // let find the maximum ts value
if (minKey < k.ts) {
minKey = k.ts;
}
@@ -1559,7 +1813,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
}
if (minKey == tsLast) {
- TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
if (init) {
tRowMerge(&merge, &fRow1);
} else {
@@ -1609,7 +1863,7 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
}
if (minKey == tsLast) {
- TSDBROW fRow1 = tsdbRowFromBlockData(pLastBlockData, *pLastBlockReader->rowIndex);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
if (init) {
tRowMerge(&merge, &fRow1);
} else {
@@ -1787,261 +2041,6 @@ static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo*
}
#endif
-static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDumpInfo,
- STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
- // it is an multi-table data block
- if (pBlockData->aUid != NULL) {
- uint64_t uid = pBlockData->aUid[pDumpInfo->rowIndex];
- if (uid != pBlockScanInfo->uid) { // move to next row
- return false;
- }
- }
-
- // check for version and time range
- int64_t ver = pBlockData->aVersion[pDumpInfo->rowIndex];
- if (ver > pReader->verRange.maxVer || ver < pReader->verRange.minVer) {
- return false;
- }
-
- int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex];
- if (ts > pReader->window.ekey || ts < pReader->window.skey) {
- return false;
- }
-
- TSDBKEY k = {.ts = ts, .version = ver};
- if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, &k, pReader->order)) {
- return false;
- }
-
- return true;
-}
-
-static bool outOfTimeWindow(int64_t ts, STimeWindow* pWindow) { return (ts > pWindow->ekey) || (ts < pWindow->skey); }
-
-static void initLastBlockReader(SLastBlockReader* pLastBlockReader, uint64_t uid, int16_t* startPos) {
- pLastBlockReader->uid = uid;
- pLastBlockReader->rowIndex = startPos;
-
- if (*startPos == -1) {
- if (ASCENDING_TRAVERSE(pLastBlockReader->order)) {
- // do nothing
- } else {
- *startPos = pLastBlockReader->lastBlockData.nRow;
- }
- }
-}
-
-static void setAllRowsChecked(SLastBlockReader *pLastBlockReader) {
- *pLastBlockReader->rowIndex = ALL_ROWS_CHECKED_INDEX;
-}
-
-static bool nextRowInLastBlock(SLastBlockReader *pLastBlockReader, STableBlockScanInfo* pBlockScanInfo) {
- bool asc = ASCENDING_TRAVERSE(pLastBlockReader->order);
- int32_t step = (asc) ? 1 : -1;
- if (*pLastBlockReader->rowIndex == ALL_ROWS_CHECKED_INDEX) {
- return false;
- }
-
- *(pLastBlockReader->rowIndex) += step;
-
- SBlockData* pBlockData = &pLastBlockReader->lastBlockData;
- for(int32_t i = *(pLastBlockReader->rowIndex); i < pBlockData->nRow && i >= 0; i += step) {
- if (pBlockData->aUid != NULL) {
- if (asc) {
- if (pBlockData->aUid[i] < pLastBlockReader->uid) {
- continue;
- } else if (pBlockData->aUid[i] > pLastBlockReader->uid) {
- break;
- }
- } else {
- if (pBlockData->aUid[i] > pLastBlockReader->uid) {
- continue;
- } else if (pBlockData->aUid[i] < pLastBlockReader->uid) {
- break;
- }
- }
- }
-
- int64_t ts = pBlockData->aTSKEY[i];
- if (ts < pLastBlockReader->window.skey) {
- continue;
- }
-
- int64_t ver = pBlockData->aVersion[i];
- if (ver < pLastBlockReader->verRange.minVer) {
- continue;
- }
-
- // no data any more, todo opt handle desc case
- if (ts > pLastBlockReader->window.ekey) {
- continue;
- }
-
- // todo opt handle desc case
- if (ver > pLastBlockReader->verRange.maxVer) {
- continue;
- }
-
- TSDBKEY k = {.ts = ts, .version = ver};
- if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->lastBlockDelIndex, &k, pLastBlockReader->order)) {
- continue;
- }
-
- *(pLastBlockReader->rowIndex) = i;
- return true;
- }
-
- // set all data is consumed in last block
- setAllRowsChecked(pLastBlockReader);
- return false;
-}
-
-static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
- SBlockData* pBlockData = &pLastBlockReader->lastBlockData;
- return pBlockData->aTSKEY[*pLastBlockReader->rowIndex];
-}
-
-static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) {
- if (*pLastBlockReader->rowIndex == ALL_ROWS_CHECKED_INDEX) {
- return false;
- }
-
- ASSERT(pLastBlockReader->lastBlockData.nRow > 0);
- return true;
-}
-
-int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key, STsdbReader* pReader) {
- SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
-
- TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
-
- if (tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo)) {
- return TSDB_CODE_SUCCESS;
- } else {
- STSRow* pTSRow = NULL;
- SRowMerger merge = {0};
-
- tRowMergerInit(&merge, &fRow, pReader->pSchema);
- doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
- int32_t code = tRowMergerGetRow(&merge, &pTSRow);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo->uid);
-
- taosMemoryFree(pTSRow);
- tRowMergerClear(&merge);
- return TSDB_CODE_SUCCESS;
- }
-
- return TSDB_CODE_SUCCESS;
-}
-
-static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo,
- SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) {
- SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
-
- int64_t key = (pBlockData->nRow > 0)? pBlockData->aTSKEY[pDumpInfo->rowIndex]:INT64_MIN;
- TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader);
- TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader);
-
- if (pBlockScanInfo->iter.hasVal && pBlockScanInfo->iiter.hasVal) {
- return doMergeMultiLevelRows(pReader, pBlockScanInfo, pBlockData, pLastBlockReader);
- } else {
- // imem + file + last block
- if (pBlockScanInfo->iiter.hasVal) {
- return doMergeBufAndFileRows(pReader, pBlockScanInfo, piRow, &pBlockScanInfo->iiter, key, pLastBlockReader);
- }
-
- // mem + file + last block
- if (pBlockScanInfo->iter.hasVal) {
- return doMergeBufAndFileRows(pReader, pBlockScanInfo, pRow, &pBlockScanInfo->iter, key, pLastBlockReader);
- }
-
- // files data blocks + last block
- return mergeFileBlockAndLastBlock(pReader, pLastBlockReader, key, pBlockScanInfo, pBlockData);
- }
-}
-
-static int32_t buildComposedDataBlock(STsdbReader* pReader) {
- SSDataBlock* pResBlock = pReader->pResBlock;
-
- SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter);
-
- STableBlockScanInfo* pBlockScanInfo = NULL;
- if (pBlockInfo != NULL) {
- pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
- } else {
- pBlockScanInfo = pReader->status.pTableIter;
- }
-
- SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
- SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
- SBlockData* pBlockData = &pReader->status.fileBlockData;
- int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
-
- int64_t st = taosGetTimestampUs();
-
- while (1) {
- // todo check the validate of row in file block
- bool hasBlockData = false;
- {
- while (pBlockData->nRow > 0) { // find the first qualified row in data block
- if (isValidFileBlockRow(pBlockData, pDumpInfo, pBlockScanInfo, pReader)) {
- hasBlockData = true;
- break;
- }
-
- pDumpInfo->rowIndex += step;
-
- SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter);
- if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
- setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
- break;
- }
- }
- }
-
- bool hasBlockLData = hasDataInLastBlock(pLastBlockReader);
-
- // no data in last block and block, no need to proceed.
- if ((hasBlockData == false) && (hasBlockLData == false)) {
- break;
- }
-
- buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader);
-
- // currently loaded file data block is consumed
- if ((pBlockData->nRow > 0) && (pDumpInfo->rowIndex >= pBlockData->nRow || pDumpInfo->rowIndex < 0)) {
- SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter);
- setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
- break;
- }
-
- if (pResBlock->info.rows >= pReader->capacity) {
- break;
- }
- }
-
- pResBlock->info.uid = pBlockScanInfo->uid;
- blockDataUpdateTsWindow(pResBlock, 0);
-
- setComposedBlockFlag(pReader, true);
- int64_t et = taosGetTimestampUs();
-
- if (pResBlock->info.rows > 0) {
- tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64
- " rows:%d, elapsed time:%.2f ms %s",
- pReader, pBlockScanInfo->uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
- pResBlock->info.rows, (et - st) / 1000.0, pReader->idStr);
- }
-
- return TSDB_CODE_SUCCESS;
-}
-
-void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; }
-
static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
if (pBlockScanInfo->iterInit) {
return TSDB_CODE_SUCCESS;
@@ -2106,6 +2105,222 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
return TSDB_CODE_SUCCESS;
}
+static bool isValidFileBlockRow(SBlockData* pBlockData, SFileBlockDumpInfo* pDumpInfo,
+ STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
+ // it is an multi-table data block
+ if (pBlockData->aUid != NULL) {
+ uint64_t uid = pBlockData->aUid[pDumpInfo->rowIndex];
+ if (uid != pBlockScanInfo->uid) { // move to next row
+ return false;
+ }
+ }
+
+ // check for version and time range
+ int64_t ver = pBlockData->aVersion[pDumpInfo->rowIndex];
+ if (ver > pReader->verRange.maxVer || ver < pReader->verRange.minVer) {
+ return false;
+ }
+
+ int64_t ts = pBlockData->aTSKEY[pDumpInfo->rowIndex];
+ if (ts > pReader->window.ekey || ts < pReader->window.skey) {
+ return false;
+ }
+
+ TSDBKEY k = {.ts = ts, .version = ver};
+ if (hasBeenDropped(pBlockScanInfo->delSkyline, &pBlockScanInfo->fileDelIndex, &k, pReader->order)) {
+ return false;
+ }
+
+ return true;
+}
+
+static bool initLastBlockReader(SLastBlockReader* pLBlockReader, STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
+ // the last block reader has been initialized for this table.
+ if (pLBlockReader->uid == pScanInfo->uid) {
+ return true;
+ }
+
+ if (pLBlockReader->uid != 0) {
+ tMergeTreeClose(&pLBlockReader->mergeTree);
+ }
+
+ initMemDataIterator(pScanInfo, pReader);
+ pLBlockReader->uid = pScanInfo->uid;
+
+ int32_t step = ASCENDING_TRAVERSE(pLBlockReader->order) ? 1 : -1;
+ STimeWindow w = pLBlockReader->window;
+ if (ASCENDING_TRAVERSE(pLBlockReader->order)) {
+ w.skey = pScanInfo->lastKey + step;
+ } else {
+ w.ekey = pScanInfo->lastKey + step;
+ }
+
+ int32_t code =
+ tMergeTreeOpen(&pLBlockReader->mergeTree, (pLBlockReader->order == TSDB_ORDER_DESC), pReader->pFileReader,
+ pReader->suid, pScanInfo->uid, &w, &pLBlockReader->verRange, pLBlockReader->pInfo, pReader->idStr);
+ if (code != TSDB_CODE_SUCCESS) {
+ return false;
+ }
+
+ return nextRowFromLastBlocks(pLBlockReader, pScanInfo);
+}
+
+static int64_t getCurrentKeyInLastBlock(SLastBlockReader* pLastBlockReader) {
+ TSDBROW row = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
+ return TSDBROW_TS(&row);
+}
+
+static bool hasDataInLastBlock(SLastBlockReader* pLastBlockReader) { return pLastBlockReader->mergeTree.pIter != NULL; }
+
+int32_t mergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pBlockScanInfo, int64_t key,
+ STsdbReader* pReader) {
+ SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
+ if (tryCopyDistinctRowFromFileBlock(pReader, pBlockData, key, pDumpInfo)) {
+ return TSDB_CODE_SUCCESS;
+ } else {
+ TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
+
+ STSRow* pTSRow = NULL;
+ SRowMerger merge = {0};
+
+ tRowMergerInit(&merge, &fRow, pReader->pSchema);
+ doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
+ int32_t code = tRowMergerGetRow(&merge, &pTSRow);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+
+ doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, pBlockScanInfo->uid);
+
+ taosMemoryFree(pTSRow);
+ tRowMergerClear(&merge);
+ return TSDB_CODE_SUCCESS;
+ }
+}
+
+static int32_t buildComposedDataBlockImpl(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo,
+ SBlockData* pBlockData, SLastBlockReader* pLastBlockReader) {
+ SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
+
+ int64_t key = (pBlockData->nRow > 0) ? pBlockData->aTSKEY[pDumpInfo->rowIndex] : INT64_MIN;
+ if (pBlockScanInfo->iter.hasVal && pBlockScanInfo->iiter.hasVal) {
+ return doMergeMultiLevelRows(pReader, pBlockScanInfo, pBlockData, pLastBlockReader);
+ } else {
+ TSDBROW *pRow = NULL, *piRow = NULL;
+ if (pBlockScanInfo->iter.hasVal) {
+ pRow = getValidMemRow(&pBlockScanInfo->iter, pBlockScanInfo->delSkyline, pReader);
+ }
+
+ if (pBlockScanInfo->iiter.hasVal) {
+ piRow = getValidMemRow(&pBlockScanInfo->iiter, pBlockScanInfo->delSkyline, pReader);
+ }
+
+ // imem + file + last block
+ if (pBlockScanInfo->iiter.hasVal) {
+ return doMergeBufAndFileRows(pReader, pBlockScanInfo, piRow, &pBlockScanInfo->iiter, key, pLastBlockReader);
+ }
+
+ // mem + file + last block
+ if (pBlockScanInfo->iter.hasVal) {
+ return doMergeBufAndFileRows(pReader, pBlockScanInfo, pRow, &pBlockScanInfo->iter, key, pLastBlockReader);
+ }
+
+ // files data blocks + last block
+ return mergeFileBlockAndLastBlock(pReader, pLastBlockReader, key, pBlockScanInfo, pBlockData);
+ }
+}
+
+static int32_t buildComposedDataBlock(STsdbReader* pReader) {
+ SSDataBlock* pResBlock = pReader->pResBlock;
+
+ SFileDataBlockInfo* pBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter);
+ SLastBlockReader* pLastBlockReader = pReader->status.fileIter.pLastBlockReader;
+
+ int64_t st = taosGetTimestampUs();
+
+ STableBlockScanInfo* pBlockScanInfo = NULL;
+ if (pBlockInfo != NULL) {
+ pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &pBlockInfo->uid, sizeof(pBlockInfo->uid));
+ SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
+ TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader);
+
+ // it is a clean block, load it directly
+ if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader)) {
+ copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
+ goto _end;
+ }
+ } else { // file blocks not exist
+ pBlockScanInfo = pReader->status.pTableIter;
+ }
+
+ SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
+ SBlockData* pBlockData = &pReader->status.fileBlockData;
+ int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
+
+
+ while (1) {
+ // todo check the validate of row in file block
+ bool hasBlockData = false;
+ {
+ while (pBlockData->nRow > 0) { // find the first qualified row in data block
+ if (isValidFileBlockRow(pBlockData, pDumpInfo, pBlockScanInfo, pReader)) {
+ hasBlockData = true;
+ break;
+ }
+
+ pDumpInfo->rowIndex += step;
+
+ SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
+ if (pDumpInfo->rowIndex >= pBlock->nRow || pDumpInfo->rowIndex < 0) {
+ setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
+ break;
+ }
+ }
+ }
+
+ bool hasBlockLData = hasDataInLastBlock(pLastBlockReader);
+
+ // no data in last block and block, no need to proceed.
+ if ((hasBlockData == false) && (hasBlockLData == false)) {
+ break;
+ }
+
+ buildComposedDataBlockImpl(pReader, pBlockScanInfo, pBlockData, pLastBlockReader);
+
+ // currently loaded file data block is consumed
+ if ((pBlockData->nRow > 0) && (pDumpInfo->rowIndex >= pBlockData->nRow || pDumpInfo->rowIndex < 0)) {
+ SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
+ setBlockAllDumped(pDumpInfo, pBlock->maxKey.ts, pReader->order);
+ break;
+ }
+
+ if (pResBlock->info.rows >= pReader->capacity) {
+ break;
+ }
+ }
+
+ _end:
+ pResBlock->info.uid = pBlockScanInfo->uid;
+ blockDataUpdateTsWindow(pResBlock, 0);
+
+ setComposedBlockFlag(pReader, true);
+ double el = (taosGetTimestampUs() - st)/1000.0;
+
+ pReader->cost.composedBlocks += 1;
+ pReader->cost.buildComposedBlockTime += el;
+
+ if (pResBlock->info.rows > 0) {
+ tsdbDebug("%p uid:%" PRIu64 ", composed data block created, brange:%" PRIu64 "-%" PRIu64
+ " rows:%d, elapsed time:%.2f ms %s",
+ pReader, pBlockScanInfo->uid, pResBlock->info.window.skey, pResBlock->info.window.ekey,
+ pResBlock->info.rows, el, pReader->idStr);
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
+void setComposedBlockFlag(STsdbReader* pReader, bool composed) { pReader->status.composedDataBlock = composed; }
+
int32_t initDelSkylineIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader, STbData* pMemTbData,
STbData* piMemTbData) {
if (pBlockScanInfo->delSkyline != NULL) {
@@ -2188,10 +2403,8 @@ _err:
return code;
}
-static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
- TSDBKEY key = {.ts = TSKEY_INITIAL_VAL};
-
- initMemDataIterator(pScanInfo, pReader);
+TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* pReader) {
+ TSDBKEY key = {.ts = TSKEY_INITIAL_VAL};
TSDBROW* pRow = getValidMemRow(&pScanInfo->iter, pScanInfo->delSkyline, pReader);
if (pRow != NULL) {
key = TSDBROW_KEY(pRow);
@@ -2211,12 +2424,10 @@ static TSDBKEY getCurrentKeyInBuf(STableBlockScanInfo* pScanInfo, STsdbReader* p
static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
SReaderStatus* pStatus = &pReader->status;
pBlockNum->numOfBlocks = 0;
- pBlockNum->numOfLastBlocks = 0;
+ pBlockNum->numOfLastFiles = 0;
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
SArray* pIndexList = taosArrayInit(numOfTables, sizeof(SBlockIdx));
- SArray* pLastBlocks = pStatus->fileIter.pLastBlockReader->pBlockL;
- taosArrayClear(pLastBlocks);
while (1) {
bool hasNext = filesetIteratorNext(&pStatus->fileIter, pReader);
@@ -2231,32 +2442,16 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
return code;
}
- code = tsdbReadBlockL(pReader->pFileReader, pLastBlocks);
- if (code != TSDB_CODE_SUCCESS) {
- taosArrayDestroy(pIndexList);
- return code;
- }
-
- if (taosArrayGetSize(pIndexList) > 0 || taosArrayGetSize(pLastBlocks) > 0) {
- SArray* pQLastBlock = taosArrayInit(4, sizeof(SBlockL));
-
- code = doLoadFileBlock(pReader, pIndexList, pLastBlocks, pBlockNum, pQLastBlock);
+ if (taosArrayGetSize(pIndexList) > 0 || pReader->pFileReader->pSet->nSttF > 0) {
+ code = doLoadFileBlock(pReader, pIndexList, pBlockNum);
if (code != TSDB_CODE_SUCCESS) {
taosArrayDestroy(pIndexList);
- taosArrayDestroy(pQLastBlock);
return code;
}
- if (pBlockNum->numOfBlocks + pBlockNum->numOfLastBlocks > 0) {
- ASSERT(taosArrayGetSize(pQLastBlock) == pBlockNum->numOfLastBlocks);
- taosArrayClear(pLastBlocks);
- taosArrayAddAll(pLastBlocks, pQLastBlock);
-
- taosArrayDestroy(pQLastBlock);
+ if (pBlockNum->numOfBlocks + pBlockNum->numOfLastFiles > 0) {
break;
}
-
- taosArrayDestroy(pQLastBlock);
}
// no blocks in current file, try next files
@@ -2266,81 +2461,22 @@ static int32_t moveToNextFile(STsdbReader* pReader, SBlockNumber* pBlockNum) {
return TSDB_CODE_SUCCESS;
}
-static int32_t doLoadRelatedLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo *pBlockScanInfo, STsdbReader* pReader) {
- SArray* pBlocks = pLastBlockReader->pBlockL;
- SBlockL* pBlock = NULL;
-
- uint64_t uid = pBlockScanInfo->uid;
- int32_t totalLastBlocks = (int32_t)taosArrayGetSize(pBlocks);
-
- initMemDataIterator(pBlockScanInfo, pReader);
-
- // find the correct SBlockL. todo binary search
- int32_t index = -1;
- for (int32_t i = 0; i < totalLastBlocks; ++i) {
- SBlockL* p = taosArrayGet(pBlocks, i);
- if (p->minUid <= uid && p->maxUid >= uid) {
- index = i;
- pBlock = p;
- break;
- }
- }
-
- if (index == -1) {
- pLastBlockReader->currentBlockIndex = index;
- tBlockDataReset(&pLastBlockReader->lastBlockData);
- return TSDB_CODE_SUCCESS;
- }
-
- // the required last datablock has already loaded
- if (index == pLastBlockReader->currentBlockIndex) {
- return TSDB_CODE_SUCCESS;
- }
-
- int64_t st = taosGetTimestampUs();
- int32_t code = tBlockDataInit(&pLastBlockReader->lastBlockData, pReader->suid, pReader->suid ? 0 : uid, pReader->pSchema);
- if (code != TSDB_CODE_SUCCESS) {
- tsdbError("%p init block data failed, code:%s %s", pReader, tstrerror(code), pReader->idStr);
- return code;
- }
-
- code = tsdbReadLastBlock(pReader->pFileReader, pBlock, &pLastBlockReader->lastBlockData);
-
- double el = (taosGetTimestampUs() - st) / 1000.0;
- if (code != TSDB_CODE_SUCCESS) {
- tsdbError("%p error occurs in loading last block into buffer, last block index:%d, total:%d code:%s %s", pReader,
- pLastBlockReader->currentBlockIndex, totalLastBlocks, tstrerror(code), pReader->idStr);
- } else {
- tsdbDebug("%p load last block completed, uid:%" PRIu64
- " last block index:%d, total:%d rows:%d, minVer:%d, maxVer:%d, brange:%" PRId64 "-%" PRId64
- " elapsed time:%.2f ms, %s",
- pReader, uid, index, totalLastBlocks, pBlock->nRow, pBlock->minVer, pBlock->maxVer, pBlock->minKey,
- pBlock->maxKey, el, pReader->idStr);
- }
-
- pLastBlockReader->currentBlockIndex = index;
- pReader->cost.lastBlockLoad += 1;
- pReader->cost.lastBlockLoadTime += el;
-
- return TSDB_CODE_SUCCESS;
-}
-
static int32_t uidComparFunc(const void* p1, const void* p2) {
- uint64_t pu1 = *(uint64_t*) p1;
- uint64_t pu2 = *(uint64_t*) p2;
+ uint64_t pu1 = *(uint64_t*)p1;
+ uint64_t pu2 = *(uint64_t*)p2;
if (pu1 == pu2) {
return 0;
} else {
- return (pu1 < pu2)? -1:1;
+ return (pu1 < pu2) ? -1 : 1;
}
}
-static void extractOrderedTableUidList(SUidOrderCheckInfo *pOrderCheckInfo, SReaderStatus* pStatus) {
+static void extractOrderedTableUidList(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) {
int32_t index = 0;
int32_t total = taosHashGetSize(pStatus->pTableMap);
void* p = taosHashIterate(pStatus->pTableMap, NULL);
- while(p != NULL) {
+ while (p != NULL) {
STableBlockScanInfo* pScanInfo = p;
pOrderCheckInfo->tableUidList[index++] = pScanInfo->uid;
p = taosHashIterate(pStatus->pTableMap, p);
@@ -2350,9 +2486,12 @@ static void extractOrderedTableUidList(SUidOrderCheckInfo *pOrderCheckInfo, SRea
}
static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderStatus* pStatus) {
- if (pOrderCheckInfo->tableUidList == NULL) {
- int32_t total = taosHashGetSize(pStatus->pTableMap);
+ int32_t total = taosHashGetSize(pStatus->pTableMap);
+ if (total == 0) {
+ return TSDB_CODE_SUCCESS;
+ }
+ if (pOrderCheckInfo->tableUidList == NULL) {
pOrderCheckInfo->currentIndex = 0;
pOrderCheckInfo->tableUidList = taosMemoryMalloc(total * sizeof(uint64_t));
if (pOrderCheckInfo->tableUidList == NULL) {
@@ -2360,20 +2499,17 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt
}
extractOrderedTableUidList(pOrderCheckInfo, pStatus);
-
uint64_t uid = pOrderCheckInfo->tableUidList[0];
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
} else {
if (pStatus->pTableIter == NULL) { // it is the last block of a new file
-// ASSERT(pOrderCheckInfo->currentIndex == taosHashGetSize(pStatus->pTableMap));
-
pOrderCheckInfo->currentIndex = 0;
uint64_t uid = pOrderCheckInfo->tableUidList[pOrderCheckInfo->currentIndex];
pStatus->pTableIter = taosHashGet(pStatus->pTableMap, &uid, sizeof(uid));
// the tableMap has already updated
if (pStatus->pTableIter == NULL) {
- void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, taosHashGetSize(pStatus->pTableMap)*sizeof(uint64_t));
+ void* p = taosMemoryRealloc(pOrderCheckInfo->tableUidList, total * sizeof(uint64_t));
if (p == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@@ -2390,7 +2526,7 @@ static int32_t initOrderCheckInfo(SUidOrderCheckInfo* pOrderCheckInfo, SReaderSt
return TSDB_CODE_SUCCESS;
}
-static bool moveToNextTable(SUidOrderCheckInfo *pOrderedCheckInfo, SReaderStatus* pStatus) {
+static bool moveToNextTable(SUidOrderCheckInfo* pOrderedCheckInfo, SReaderStatus* pStatus) {
pOrderedCheckInfo->currentIndex += 1;
if (pOrderedCheckInfo->currentIndex >= taosHashGetSize(pStatus->pTableMap)) {
pStatus->pTableIter = NULL;
@@ -2404,38 +2540,20 @@ static bool moveToNextTable(SUidOrderCheckInfo *pOrderedCheckInfo, SReaderStatus
}
static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
- SReaderStatus* pStatus = &pReader->status;
+ SReaderStatus* pStatus = &pReader->status;
SLastBlockReader* pLastBlockReader = pStatus->fileIter.pLastBlockReader;
- SUidOrderCheckInfo *pOrderedCheckInfo = &pStatus->uidCheckInfo;
- int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus);
+ SUidOrderCheckInfo* pOrderedCheckInfo = &pStatus->uidCheckInfo;
+ int32_t code = initOrderCheckInfo(pOrderedCheckInfo, pStatus);
if (code != TSDB_CODE_SUCCESS || (taosHashGetSize(pStatus->pTableMap) == 0)) {
return code;
}
- while(1) {
+ while (1) {
// load the last data block of current table
STableBlockScanInfo* pScanInfo = pStatus->pTableIter;
- code = doLoadRelatedLastBlock(pLastBlockReader, pScanInfo, pReader);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- if (pLastBlockReader->currentBlockIndex != -1) {
- initLastBlockReader(pLastBlockReader, pScanInfo->uid, &pScanInfo->indexInBlockL);
- int32_t index = pScanInfo->indexInBlockL;
-
- if (index == INITIAL_ROW_INDEX_VAL || index == pLastBlockReader->lastBlockData.nRow) {
- bool hasData = nextRowInLastBlock(pLastBlockReader, pScanInfo);
- if (!hasData) { // current table does not have rows in last block, try next table
- bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
- if (!hasNexTable) {
- return TSDB_CODE_SUCCESS;
- }
- continue;
- }
- }
- } else { // no data in last block, try next table
+ bool hasVal = initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
+ if (!hasVal) {
bool hasNexTable = moveToNextTable(pOrderedCheckInfo, pStatus);
if (!hasNexTable) {
return TSDB_CODE_SUCCESS;
@@ -2461,9 +2579,8 @@ static int32_t doLoadLastBlockSequentially(STsdbReader* pReader) {
}
static int32_t doBuildDataBlock(STsdbReader* pReader) {
- TSDBKEY key = {0};
- int32_t code = TSDB_CODE_SUCCESS;
- SBlock* pBlock = NULL;
+ int32_t code = TSDB_CODE_SUCCESS;
+ SDataBlk* pBlock = NULL;
SReaderStatus* pStatus = &pReader->status;
SDataBlockIter* pBlockIter = &pStatus->blockIter;
@@ -2481,26 +2598,13 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
pBlock = getCurrentBlock(pBlockIter);
}
- {
- key = getCurrentKeyInBuf(pScanInfo, pReader);
-
- // load the last data block of current table
- code = doLoadRelatedLastBlock(pLastBlockReader, pScanInfo, pReader);
- if (code != TSDB_CODE_SUCCESS) {
- return code;
- }
-
- // note: the lastblock may be null here
- initLastBlockReader(pLastBlockReader, pScanInfo->uid, &pScanInfo->indexInBlockL);
- if (pScanInfo->indexInBlockL == INITIAL_ROW_INDEX_VAL || pScanInfo->indexInBlockL == pLastBlockReader->lastBlockData.nRow) {
- bool hasData = nextRowInLastBlock(pLastBlockReader, pScanInfo);
- }
- }
+ initLastBlockReader(pLastBlockReader, pScanInfo, pReader);
+ TSDBKEY keyInBuf = getCurrentKeyInBuf(pScanInfo, pReader);
if (pBlockInfo == NULL) { // build data block from last data file
ASSERT(pBlockIter->numOfBlocks == 0);
code = buildComposedDataBlock(pReader);
- } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, key, pLastBlockReader)) {
+ } else if (fileBlockShouldLoad(pReader, pBlockInfo, pBlock, pScanInfo, keyInBuf, pLastBlockReader)) {
tBlockDataReset(&pStatus->fileBlockData);
code = tBlockDataInit(&pStatus->fileBlockData, pReader->suid, pScanInfo->uid, pReader->pSchema);
if (code != TSDB_CODE_SUCCESS) {
@@ -2514,7 +2618,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
// build composed data block
code = buildComposedDataBlock(pReader);
- } else if (bufferDataInFileBlockGap(pReader->order, key, pBlock)) {
+ } else if (bufferDataInFileBlockGap(pReader->order, keyInBuf, pBlock)) {
// data in memory that are earlier than current file block
// todo rows in buffer should be less than the file block in asc, greater than file block in desc
int64_t endKey = (ASCENDING_TRAVERSE(pReader->order)) ? pBlock->minKey.ts : pBlock->maxKey.ts;
@@ -2523,11 +2627,11 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
if (hasDataInLastBlock(pLastBlockReader) && !ASCENDING_TRAVERSE(pReader->order)) {
// only return the rows in last block
int64_t tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
- ASSERT (tsLast >= pBlock->maxKey.ts);
+ ASSERT(tsLast >= pBlock->maxKey.ts);
tBlockDataReset(&pReader->status.fileBlockData);
code = buildComposedDataBlock(pReader);
- } else { // whole block is required, return it directly
+ } else { // whole block is required, return it directly
SDataBlockInfo* pInfo = &pReader->pResBlock->info;
pInfo->rows = pBlock->nRow;
pInfo->uid = pScanInfo->uid;
@@ -2574,7 +2678,7 @@ static int32_t buildBlockFromBufferSequentially(STsdbReader* pReader) {
// set the correct start position in case of the first/last file block, according to the query time window
static void initBlockDumpInfo(STsdbReader* pReader, SDataBlockIter* pBlockIter) {
- SBlock* pBlock = getCurrentBlock(pBlockIter);
+ SDataBlk* pBlock = getCurrentBlock(pBlockIter);
SReaderStatus* pStatus = &pReader->status;
@@ -2594,7 +2698,7 @@ static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBl
}
// all data files are consumed, try data in buffer
- if (num.numOfBlocks + num.numOfLastBlocks == 0) {
+ if (num.numOfBlocks + num.numOfLastFiles == 0) {
pReader->status.loadFromFile = false;
return code;
}
@@ -2602,14 +2706,11 @@ static int32_t initForFirstBlockInFile(STsdbReader* pReader, SDataBlockIter* pBl
// initialize the block iterator for a new fileset
if (num.numOfBlocks > 0) {
code = initBlockIterator(pReader, pBlockIter, num.numOfBlocks);
- } else { // no block data, only last block exists
+ } else { // no block data, only last block exists
tBlockDataReset(&pReader->status.fileBlockData);
resetDataBlockIterator(pBlockIter, pReader->order);
}
- SLastBlockReader* pLReader = pReader->status.fileIter.pLastBlockReader;
- pLReader->currentBlockIndex = -1;
-
// set the correct start position according to the query time window
initBlockDumpInfo(pReader, pBlockIter);
return code;
@@ -2627,7 +2728,7 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
if (pBlockIter->numOfBlocks == 0) {
- _begin:
+ _begin:
code = doLoadLastBlockSequentially(pReader);
if (code != TSDB_CODE_SUCCESS) {
return code;
@@ -2674,21 +2775,24 @@ static int32_t buildBlockFromFiles(STsdbReader* pReader) {
bool hasNext = blockIteratorNext(&pReader->status.blockIter);
if (hasNext) { // check for the next block in the block accessed order list
initBlockDumpInfo(pReader, pBlockIter);
- } else if (taosArrayGetSize(pReader->status.fileIter.pLastBlockReader->pBlockL) > 0) { // data blocks in current file are exhausted, let's try the next file now
- tBlockDataReset(&pReader->status.fileBlockData);
- resetDataBlockIterator(pBlockIter, pReader->order);
- goto _begin;
} else {
- code = initForFirstBlockInFile(pReader, pBlockIter);
-
- // error happens or all the data files are completely checked
- if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) {
- return code;
- }
-
- // this file does not have blocks, let's start check the last block file
- if (pBlockIter->numOfBlocks == 0) {
+ if (pReader->status.pCurrentFileset->nSttF > 0) {
+ // data blocks in current file are exhausted, let's try the next file now
+ tBlockDataReset(&pReader->status.fileBlockData);
+ resetDataBlockIterator(pBlockIter, pReader->order);
goto _begin;
+ } else {
+ code = initForFirstBlockInFile(pReader, pBlockIter);
+
+ // error happens or all the data files are completely checked
+ if ((code != TSDB_CODE_SUCCESS) || (pReader->status.loadFromFile == false)) {
+ return code;
+ }
+
+ // this file does not have blocks, let's start check the last block file
+ if (pBlockIter->numOfBlocks == 0) {
+ goto _begin;
+ }
}
}
}
@@ -2711,6 +2815,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
if (VND_IS_RSMA(pVnode)) {
int8_t level = 0;
int64_t now = taosGetTimestamp(pVnode->config.tsdbCfg.precision);
+ int64_t offset = TSDB_TICK_PER_SECOND(pVnode->config.tsdbCfg.precision);
for (int8_t i = 0; i < TSDB_RETENTION_MAX; ++i) {
SRetention* pRetention = retentions + level;
@@ -2720,7 +2825,7 @@ static STsdb* getTsdbByRetentions(SVnode* pVnode, TSKEY winSKey, SRetention* ret
}
break;
}
- if ((now - pRetention->keep) <= winSKey) {
+ if ((now - pRetention->keep) <= (winSKey + offset)) {
break;
}
++level;
@@ -2947,7 +3052,7 @@ typedef enum {
CHECK_FILEBLOCK_QUIT = 0x2,
} CHECK_FILEBLOCK_STATE;
-static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanInfo* pScanInfo, SBlock* pBlock,
+static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanInfo* pScanInfo, SDataBlk* pBlock,
SFileDataBlockInfo* pFBlock, SRowMerger* pMerger, int64_t key,
CHECK_FILEBLOCK_STATE* state) {
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
@@ -2956,8 +3061,8 @@ static int32_t checkForNeighborFileBlock(STsdbReader* pReader, STableBlockScanIn
*state = CHECK_FILEBLOCK_QUIT;
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
- int32_t nextIndex = -1;
- SBlock* pNeighborBlock = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order);
+ int32_t nextIndex = -1;
+ SDataBlk* pNeighborBlock = getNeighborBlockOfSameTable(pFBlock, pScanInfo, &nextIndex, pReader->order);
if (pNeighborBlock == NULL) { // do nothing
return 0;
}
@@ -3021,7 +3126,7 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
CHECK_FILEBLOCK_STATE st;
SFileDataBlockInfo* pFileBlockInfo = getCurrentBlockInfo(&pReader->status.blockIter);
- SBlock* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter);
+ SDataBlk* pCurrentBlock = getCurrentBlock(&pReader->status.blockIter);
checkForNeighborFileBlock(pReader, pScanInfo, pCurrentBlock, pFileBlockInfo, pMerger, key, &st);
if (st == CHECK_FILEBLOCK_QUIT) {
break;
@@ -3032,11 +3137,13 @@ int32_t doMergeRowsInFileBlocks(SBlockData* pBlockData, STableBlockScanInfo* pSc
return TSDB_CODE_SUCCESS;
}
-int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts, SRowMerger* pMerger) {
- while(nextRowInLastBlock(pLastBlockReader, pScanInfo)) {
+int32_t doMergeRowsInLastBlock(SLastBlockReader* pLastBlockReader, STableBlockScanInfo* pScanInfo, int64_t ts,
+ SRowMerger* pMerger) {
+ pScanInfo->lastKey = ts;
+ while (nextRowFromLastBlocks(pLastBlockReader, pScanInfo)) {
int64_t next1 = getCurrentKeyInLastBlock(pLastBlockReader);
if (next1 == ts) {
- TSDBROW fRow1 = tsdbRowFromBlockData(&pLastBlockReader->lastBlockData, *pLastBlockReader->rowIndex);
+ TSDBROW fRow1 = tMergeTreeGetRow(&pLastBlockReader->mergeTree);
tRowMerge(pMerger, &fRow1);
} else {
break;
@@ -3100,7 +3207,7 @@ int32_t doMergeMemTableMultiRows(TSDBROW* pRow, uint64_t uid, SIterInfo* pIter,
}
int32_t doMergeMemIMemRows(TSDBROW* pRow, TSDBROW* piRow, STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader,
- STSRow** pTSRow) {
+ STSRow** pTSRow) {
SRowMerger merge = {0};
TSDBKEY k = TSDBROW_KEY(pRow);
@@ -3174,7 +3281,8 @@ int32_t tsdbGetNextRowInMem(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pR
}
if (pBlockScanInfo->iter.hasVal && pRow != NULL) {
- return doMergeMemTableMultiRows(pRow, pBlockScanInfo->uid, &pBlockScanInfo->iter, pDelList, pTSRow, pReader, freeTSRow);
+ return doMergeMemTableMultiRows(pRow, pBlockScanInfo->uid, &pBlockScanInfo->iter, pDelList, pTSRow, pReader,
+ freeTSRow);
}
if (pBlockScanInfo->iiter.hasVal && piRow != NULL) {
@@ -3228,7 +3336,8 @@ int32_t doAppendRowFromTSRow(SSDataBlock* pBlock, STsdbReader* pReader, STSRow*
return TSDB_CODE_SUCCESS;
}
-int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData, int32_t rowIndex) {
+int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, SBlockData* pBlockData,
+ int32_t rowIndex) {
int32_t i = 0, j = 0;
int32_t outputRowIndex = pResBlock->info.rows;
@@ -3241,18 +3350,23 @@ int32_t doAppendRowFromFileBlock(SSDataBlock* pResBlock, STsdbReader* pReader, S
}
SColVal cv = {0};
- int32_t numOfInputCols = taosArrayGetSize(pBlockData->aIdx);
- int32_t numOfOutputCols = blockDataGetNumOfCols(pResBlock);
+ int32_t numOfInputCols = pBlockData->aIdx->size;
+ int32_t numOfOutputCols = pResBlock->pDataBlock->size;
while (i < numOfOutputCols && j < numOfInputCols) {
- SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i);
+ SColumnInfoData* pCol = TARRAY_GET_ELEM(pResBlock->pDataBlock, i);
SColData* pData = tBlockDataGetColDataByIdx(pBlockData, j);
+ if (pData->cid < pCol->info.colId) {
+ j += 1;
+ continue;
+ }
+
if (pData->cid == pCol->info.colId) {
tColDataGetValue(pData, rowIndex, &cv);
doCopyColVal(pCol, outputRowIndex, i, &cv, pSupInfo);
j += 1;
- } else { // the specified column does not exist in file block, fill with null data
+ } else if (pData->cid > pCol->info.colId) { // the specified column does not exist in file block, fill with null data
colDataAppendNULL(pCol, outputRowIndex);
}
@@ -3305,7 +3419,7 @@ int32_t tsdbSetTableId(STsdbReader* pReader, int64_t uid) {
ASSERT(pReader != NULL);
taosHashClear(pReader->status.pTableMap);
- STableBlockScanInfo info = {.lastKey = 0, .uid = uid, .indexInBlockL = INITIAL_ROW_INDEX_VAL};
+ STableBlockScanInfo info = {.lastKey = 0, .uid = uid};
taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
return TDB_CODE_SUCCESS;
}
@@ -3326,7 +3440,6 @@ void* tsdbGetIvtIdx(SMeta* pMeta) {
uint64_t getReaderMaxVersion(STsdbReader* pReader) { return pReader->verRange.maxVer; }
-
// ====================================== EXPOSED APIs ======================================
int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader,
const char* idstr) {
@@ -3375,11 +3488,18 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
}
}
+ // NOTE: the endVersion in pCond is the data version not schema version, so pCond->endVersion is not correct here.
if (pCond->suid != 0) {
- pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, pCond->endVersion);
+ pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pReader->suid, /*pCond->endVersion*/ -1);
+ if (pReader->pSchema == NULL) {
+ tsdbError("failed to get table schema, suid:%"PRIu64", ver:%"PRId64" , %s", pReader->suid, -1, pReader->idStr);
+ }
} else if (taosArrayGetSize(pTableList) > 0) {
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
- pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, pCond->endVersion);
+ pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, /*pCond->endVersion*/ -1);
+ if (pReader->pSchema == NULL) {
+ tsdbError("failed to get table schema, uid:%"PRIu64", ver:%"PRId64" , %s", pKey->uid, -1, pReader->idStr);
+ }
}
int32_t numOfTables = taosArrayGetSize(pTableList);
@@ -3449,7 +3569,6 @@ void tsdbReaderClose(STsdbReader* pReader) {
}
SBlockLoadSuppInfo* pSupInfo = &pReader->suppInfo;
- tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap);
taosMemoryFreeClear(pSupInfo->plist);
taosMemoryFree(pSupInfo->colIds);
@@ -3460,6 +3579,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
taosMemoryFreeClear(pSupInfo->buildBuf[i]);
}
}
+
taosMemoryFree(pSupInfo->buildBuf);
tBlockDataDestroy(&pReader->status.fileBlockData, true);
@@ -3473,25 +3593,30 @@ void tsdbReaderClose(STsdbReader* pReader) {
tsdbDataFReaderClose(&pReader->pFileReader);
}
+ tsdbUntakeReadSnap(pReader->pTsdb, pReader->pReadSnap);
+
taosMemoryFree(pReader->status.uidCheckInfo.tableUidList);
+ SIOCostSummary* pCost = &pReader->cost;
SFilesetIter* pFilesetIter = &pReader->status.fileIter;
if (pFilesetIter->pLastBlockReader != NULL) {
- tBlockDataDestroy(&pFilesetIter->pLastBlockReader->lastBlockData, true);
- taosArrayDestroy(pFilesetIter->pLastBlockReader->pBlockL);
- taosMemoryFree(pFilesetIter->pLastBlockReader);
+ SLastBlockReader* pLReader = pFilesetIter->pLastBlockReader;
+ tMergeTreeClose(&pLReader->mergeTree);
+
+ getLastBlockLoadInfo(pLReader->pInfo, &pCost->lastBlockLoad, &pCost->lastBlockLoadTime);
+
+ pLReader->pInfo = destroyLastBlockLoadInfo(pLReader->pInfo);
+ taosMemoryFree(pLReader);
}
- SIOCostSummary* pCost = &pReader->cost;
-
- tsdbDebug("%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
- " SMA-time:%.2f ms, fileBlocks:%" PRId64
- ", fileBlocks-time:%.2f ms, "
- "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64
- ", lastBlocks-time:%.2f ms, STableBlockScanInfo size:%.2f Kb %s",
- pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime,
- pCost->numOfBlocks, pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad,
- pCost->lastBlockLoadTime, numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pReader->idStr);
+ tsdbDebug(
+ "%p :io-cost summary: head-file:%" PRIu64 ", head-file time:%.2f ms, SMA:%" PRId64
+ " SMA-time:%.2f ms, fileBlocks:%" PRId64 ", fileBlocks-load-time:%.2f ms, "
+ "build in-memory-block-time:%.2f ms, lastBlocks:%" PRId64 ", lastBlocks-time:%.2f ms, composed-blocks:%" PRId64
+ ", composed-blocks-time:%.2fms, STableBlockScanInfo size:%.2f Kb %s",
+ pReader, pCost->headFileLoad, pCost->headFileLoadTime, pCost->smaDataLoad, pCost->smaLoadTime, pCost->numOfBlocks,
+ pCost->blockLoadTime, pCost->buildmemBlock, pCost->lastBlockLoad, pCost->lastBlockLoadTime, pCost->composedBlocks,
+ pCost->buildComposedBlockTime, numOfTables * sizeof(STableBlockScanInfo) / 1000.0, pReader->idStr);
taosMemoryFree(pReader->idStr);
taosMemoryFree(pReader->pSchema);
@@ -3602,12 +3727,12 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
SFileDataBlockInfo* pFBlock = getCurrentBlockInfo(&pReader->status.blockIter);
- SBlock* pBlock = getCurrentBlock(&pReader->status.blockIter);
- int64_t stime = taosGetTimestampUs();
+ SDataBlk* pBlock = getCurrentBlock(&pReader->status.blockIter);
+ int64_t stime = taosGetTimestampUs();
SBlockLoadSuppInfo* pSup = &pReader->suppInfo;
- if (tBlockHasSma(pBlock)) {
+ if (tDataBlkHasSma(pBlock)) {
code = tsdbReadBlockSma(pReader->pFileReader, pBlock, pSup->pColAgg);
if (code != TSDB_CODE_SUCCESS) {
tsdbDebug("vgId:%d, failed to load block SMA for uid %" PRIu64 ", code:%s, %s", 0, pFBlock->uid, tstrerror(code),
@@ -3722,11 +3847,12 @@ int32_t tsdbReaderReset(STsdbReader* pReader, SQueryTableDataCond* pCond) {
tsdbDataFReaderClose(&pReader->pFileReader);
int32_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
- tsdbDataFReaderClose(&pReader->pFileReader);
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
- resetDataBlockScanInfo(pReader->status.pTableMap);
+
+ int64_t ts = ASCENDING_TRAVERSE(pReader->order) ? pReader->window.skey - 1 : pReader->window.ekey + 1;
+ resetDataBlockScanInfo(pReader->status.pTableMap, ts);
int32_t code = 0;
SDataBlockIter* pBlockIter = &pReader->status.blockIter;
@@ -3784,7 +3910,7 @@ int32_t tsdbGetFileBlocksDistInfo(STsdbReader* pReader, STableBlockDistInfo* pTa
while (true) {
if (hasNext) {
- SBlock* pBlock = getCurrentBlock(pBlockIter);
+ SDataBlk* pBlock = getCurrentBlock(pBlockIter);
int32_t numOfRows = pBlock->nRow;
pTableBlockInfo->totalRows += numOfRows;
@@ -3952,4 +4078,4 @@ void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap) {
}
tsdbTrace("vgId:%d, untake read snapshot", TD_VID(pTsdb->pVnode));
-}
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
index c8f3862071..5fe0b408b1 100644
--- a/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
+++ b/source/dnode/vnode/src/tsdb/tsdbReaderWriter.c
@@ -15,399 +15,706 @@
#include "tsdb.h"
-// SDelFWriter ====================================================
-int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb) {
- int32_t code = 0;
- char fname[TSDB_FILENAME_LEN];
- char hdr[TSDB_FHDR_SIZE] = {0};
- SDelFWriter *pDelFWriter;
- int64_t n;
-
- // alloc
- pDelFWriter = (SDelFWriter *)taosMemoryCalloc(1, sizeof(*pDelFWriter));
- if (pDelFWriter == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- pDelFWriter->pTsdb = pTsdb;
- pDelFWriter->fDel = *pFile;
-
- tsdbDelFileName(pTsdb, pFile, fname);
- pDelFWriter->pWriteH = taosOpenFile(fname, TD_FILE_WRITE | TD_FILE_CREATE);
- if (pDelFWriter->pWriteH == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // update header
- n = taosWriteFile(pDelFWriter->pWriteH, &hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- pDelFWriter->fDel.size = TSDB_FHDR_SIZE;
- pDelFWriter->fDel.offset = 0;
-
- *ppWriter = pDelFWriter;
- return code;
-
-_err:
- tsdbError("vgId:%d, failed to open del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
- *ppWriter = NULL;
- return code;
-}
-
-int32_t tsdbDelFWriterClose(SDelFWriter **ppWriter, int8_t sync) {
- int32_t code = 0;
- SDelFWriter *pWriter = *ppWriter;
- STsdb *pTsdb = pWriter->pTsdb;
-
- // sync
- if (sync && taosFsyncFile(pWriter->pWriteH) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // close
- if (taosCloseFile(&pWriter->pWriteH) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t *); iBuf++) {
- tFree(pWriter->aBuf[iBuf]);
- }
- taosMemoryFree(pWriter);
-
- *ppWriter = NULL;
- return code;
-
-_err:
- tsdbError("vgId:%d, failed to close del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-int32_t tsdbWriteDelData(SDelFWriter *pWriter, SArray *aDelData, SDelIdx *pDelIdx) {
- int32_t code = 0;
- int64_t size;
- int64_t n;
-
- // prepare
- size = sizeof(uint32_t);
- for (int32_t iDelData = 0; iDelData < taosArrayGetSize(aDelData); iDelData++) {
- size += tPutDelData(NULL, taosArrayGet(aDelData, iDelData));
- }
- size += sizeof(TSCKSUM);
-
- // alloc
- code = tRealloc(&pWriter->aBuf[0], size);
- if (code) goto _err;
-
- // build
- n = 0;
- n += tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT);
- for (int32_t iDelData = 0; iDelData < taosArrayGetSize(aDelData); iDelData++) {
- n += tPutDelData(pWriter->aBuf[0] + n, taosArrayGet(aDelData, iDelData));
- }
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
-
- ASSERT(n + sizeof(TSCKSUM) == size);
-
- // write
- n = taosWriteFile(pWriter->pWriteH, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- ASSERT(n == size);
-
- // update
- pDelIdx->offset = pWriter->fDel.size;
- pDelIdx->size = size;
- pWriter->fDel.size += size;
-
- return code;
-
-_err:
- tsdbError("vgId:%d, failed to write del data since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SArray *aDelIdx) {
+// =============== PAGE-WISE FILE ===============
+static int32_t tsdbOpenFile(const char *path, int32_t szPage, int32_t flag, STsdbFD **ppFD) {
int32_t code = 0;
- int64_t size;
- int64_t n;
- SDelIdx *pDelIdx;
+ STsdbFD *pFD;
- // prepare
- size = sizeof(uint32_t);
- for (int32_t iDelIdx = 0; iDelIdx < taosArrayGetSize(aDelIdx); iDelIdx++) {
- size += tPutDelIdx(NULL, taosArrayGet(aDelIdx, iDelIdx));
- }
- size += sizeof(TSCKSUM);
+ *ppFD = NULL;
- // alloc
- code = tRealloc(&pWriter->aBuf[0], size);
- if (code) goto _err;
-
- // build
- n = 0;
- n += tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT);
- for (int32_t iDelIdx = 0; iDelIdx < taosArrayGetSize(aDelIdx); iDelIdx++) {
- n += tPutDelIdx(pWriter->aBuf[0] + n, taosArrayGet(aDelIdx, iDelIdx));
- }
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
-
- ASSERT(n + sizeof(TSCKSUM) == size);
-
- // write
- n = taosWriteFile(pWriter->pWriteH, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // update
- pWriter->fDel.offset = pWriter->fDel.size;
- pWriter->fDel.size += size;
-
- return code;
-
-_err:
- tsdbError("vgId:%d, write del idx failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter) {
- int32_t code = 0;
- char hdr[TSDB_FHDR_SIZE];
- int64_t size = TSDB_FHDR_SIZE;
- int64_t n;
-
- // build
- memset(hdr, 0, size);
- tPutDelFile(hdr, &pWriter->fDel);
- taosCalcChecksumAppend(0, hdr, size);
-
- // seek
- if (taosLSeekFile(pWriter->pWriteH, 0, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // write
- n = taosWriteFile(pWriter->pWriteH, hdr, size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d, update del file hdr failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-// SDelFReader ====================================================
-struct SDelFReader {
- STsdb *pTsdb;
- SDelFile fDel;
- TdFilePtr pReadH;
-
- uint8_t *aBuf[1];
-};
-
-int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb) {
- int32_t code = 0;
- char fname[TSDB_FILENAME_LEN];
- SDelFReader *pDelFReader;
- int64_t n;
-
- // alloc
- pDelFReader = (SDelFReader *)taosMemoryCalloc(1, sizeof(*pDelFReader));
- if (pDelFReader == NULL) {
+ pFD = (STsdbFD *)taosMemoryCalloc(1, sizeof(*pFD) + strlen(path) + 1);
+ if (pFD == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
+ goto _exit;
}
- // open impl
- pDelFReader->pTsdb = pTsdb;
- pDelFReader->fDel = *pFile;
-
- tsdbDelFileName(pTsdb, pFile, fname);
- pDelFReader->pReadH = taosOpenFile(fname, TD_FILE_READ);
- if (pDelFReader->pReadH == NULL) {
+ pFD->path = (char *)&pFD[1];
+ strcpy(pFD->path, path);
+ pFD->szPage = szPage;
+ pFD->flag = flag;
+ pFD->pFD = taosOpenFile(path, flag);
+ if (pFD->pFD == NULL) {
code = TAOS_SYSTEM_ERROR(errno);
- taosMemoryFree(pDelFReader);
- goto _err;
+ goto _exit;
}
+ pFD->szPage = szPage;
+ pFD->pgno = 0;
+ pFD->pBuf = taosMemoryCalloc(1, szPage);
+ if (pFD->pBuf == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ taosMemoryFree(pFD);
+ goto _exit;
+ }
+ if (taosStatFile(path, &pFD->szFile, NULL) < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _exit;
+ }
+ ASSERT(pFD->szFile % szPage == 0);
+ pFD->szFile = pFD->szFile / szPage;
+ *ppFD = pFD;
_exit:
- *ppReader = pDelFReader;
- return code;
-
-_err:
- tsdbError("vgId:%d, del file reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
- *ppReader = NULL;
return code;
}
-int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
- int32_t code = 0;
- SDelFReader *pReader = *ppReader;
+static void tsdbCloseFile(STsdbFD **ppFD) {
+ STsdbFD *pFD = *ppFD;
+ taosMemoryFree(pFD->pBuf);
+ taosCloseFile(&pFD->pFD);
+ taosMemoryFree(pFD);
+ *ppFD = NULL;
+}
- if (pReader) {
- if (taosCloseFile(&pReader->pReadH) < 0) {
+static int32_t tsdbWriteFilePage(STsdbFD *pFD) {
+ int32_t code = 0;
+
+ if (pFD->pgno > 0) {
+ int64_t n = taosLSeekFile(pFD->pFD, PAGE_OFFSET(pFD->pgno, pFD->szPage), SEEK_SET);
+ if (n < 0) {
code = TAOS_SYSTEM_ERROR(errno);
goto _exit;
}
- for (int32_t iBuf = 0; iBuf < sizeof(pReader->aBuf) / sizeof(uint8_t *); iBuf++) {
- tFree(pReader->aBuf[iBuf]);
+
+ taosCalcChecksumAppend(0, pFD->pBuf, pFD->szPage);
+
+ n = taosWriteFile(pFD->pFD, pFD->pBuf, pFD->szPage);
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _exit;
+ }
+
+ if (pFD->szFile < pFD->pgno) {
+ pFD->szFile = pFD->pgno;
}
- taosMemoryFree(pReader);
}
- *ppReader = NULL;
+ pFD->pgno = 0;
_exit:
return code;
}
-int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) {
+static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno) {
int32_t code = 0;
- int64_t offset = pDelIdx->offset;
- int64_t size = pDelIdx->size;
- int64_t n;
- taosArrayClear(aDelData);
+ ASSERT(pgno <= pFD->szFile);
// seek
- if (taosLSeekFile(pReader->pReadH, offset, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // alloc
- code = tRealloc(&pReader->aBuf[0], size);
- if (code) goto _err;
-
- // read
- n = taosReadFile(pReader->pReadH, pReader->aBuf[0], size);
+ int64_t offset = PAGE_OFFSET(pgno, pFD->szPage);
+ int64_t n = taosLSeekFile(pFD->pFD, offset, SEEK_SET);
if (n < 0) {
code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
+ goto _exit;
+ }
+
+ // read
+ n = taosReadFile(pFD->pFD, pFD->pBuf, pFD->szPage);
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _exit;
+ } else if (n < pFD->szPage) {
code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
+ goto _exit;
}
// check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
+ if (!taosCheckChecksumWhole(pFD->pBuf, pFD->szPage)) {
code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
+ goto _exit;
}
- // // decode
- n = 0;
+ pFD->pgno = pgno;
- uint32_t delimiter;
- n += tGetU32(pReader->aBuf[0] + n, &delimiter);
- while (n < size - sizeof(TSCKSUM)) {
- SDelData delData;
- n += tGetDelData(pReader->aBuf[0] + n, &delData);
-
- if (taosArrayPush(aDelData, &delData) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- }
-
- ASSERT(n == size - sizeof(TSCKSUM));
-
- return code;
-
-_err:
- tsdbError("vgId:%d, read del data failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
+_exit:
return code;
}
-int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx) {
+static int32_t tsdbWriteFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size) {
int32_t code = 0;
- int32_t n;
- int64_t offset = pReader->fDel.offset;
- int64_t size = pReader->fDel.size - offset;
+ int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
+ int64_t pgno = OFFSET_PGNO(fOffset, pFD->szPage);
+ int64_t bOffset = fOffset % pFD->szPage;
+ int64_t n = 0;
- taosArrayClear(aDelIdx);
+ do {
+ if (pFD->pgno != pgno) {
+ code = tsdbWriteFilePage(pFD);
+ if (code) goto _exit;
- // seek
- if (taosLSeekFile(pReader->pReadH, offset, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
+ if (pgno <= pFD->szFile) {
+ code = tsdbReadFilePage(pFD, pgno);
+ if (code) goto _exit;
+ } else {
+ pFD->pgno = pgno;
+ }
+ }
+
+ int64_t nWrite = TMIN(PAGE_CONTENT_SIZE(pFD->szPage) - bOffset, size - n);
+ memcpy(pFD->pBuf + bOffset, pBuf + n, nWrite);
+
+ pgno++;
+ bOffset = 0;
+ n += nWrite;
+ } while (n < size);
+
+_exit:
+ return code;
+}
+
+static int32_t tsdbReadFile(STsdbFD *pFD, int64_t offset, uint8_t *pBuf, int64_t size) {
+ int32_t code = 0;
+ int64_t n = 0;
+ int64_t fOffset = LOGIC_TO_FILE_OFFSET(offset, pFD->szPage);
+ int64_t pgno = OFFSET_PGNO(fOffset, pFD->szPage);
+ int32_t szPgCont = PAGE_CONTENT_SIZE(pFD->szPage);
+ int64_t bOffset = fOffset % pFD->szPage;
+
+ ASSERT(pgno && pgno <= pFD->szFile);
+ ASSERT(bOffset < szPgCont);
+
+ while (n < size) {
+ if (pFD->pgno != pgno) {
+ code = tsdbReadFilePage(pFD, pgno);
+ if (code) goto _exit;
+ }
+
+ int64_t nRead = TMIN(szPgCont - bOffset, size - n);
+ memcpy(pBuf + n, pFD->pBuf + bOffset, nRead);
+
+ n += nRead;
+ pgno++;
+ bOffset = 0;
}
+_exit:
+ return code;
+}
+
+static int32_t tsdbFsyncFile(STsdbFD *pFD) {
+ int32_t code = 0;
+
+ code = tsdbWriteFilePage(pFD);
+ if (code) goto _exit;
+
+ if (taosFsyncFile(pFD->pFD) < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _exit;
+ }
+
+_exit:
+ return code;
+}
+
+// SDataFWriter ====================================================
+int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet) {
+ int32_t code = 0;
+ int32_t flag;
+ int64_t n;
+ int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
+ SDataFWriter *pWriter = NULL;
+ char fname[TSDB_FILENAME_LEN];
+ char hdr[TSDB_FHDR_SIZE] = {0};
+
// alloc
- code = tRealloc(&pReader->aBuf[0], size);
+ pWriter = taosMemoryCalloc(1, sizeof(*pWriter));
+ if (pWriter == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ pWriter->pTsdb = pTsdb;
+ pWriter->wSet = (SDFileSet){.diskId = pSet->diskId,
+ .fid = pSet->fid,
+ .pHeadF = &pWriter->fHead,
+ .pDataF = &pWriter->fData,
+ .pSmaF = &pWriter->fSma,
+ .nSttF = pSet->nSttF};
+ pWriter->fHead = *pSet->pHeadF;
+ pWriter->fData = *pSet->pDataF;
+ pWriter->fSma = *pSet->pSmaF;
+ for (int8_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ pWriter->wSet.aSttF[iStt] = &pWriter->fStt[iStt];
+ pWriter->fStt[iStt] = *pSet->aSttF[iStt];
+ }
+
+ // head
+ flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
+ tsdbHeadFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fHead, fname);
+ code = tsdbOpenFile(fname, szPage, flag, &pWriter->pHeadFD);
if (code) goto _err;
- // read
- n = taosReadFile(pReader->pReadH, pReader->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
+ code = tsdbWriteFile(pWriter->pHeadFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+ pWriter->fHead.size += TSDB_FHDR_SIZE;
+
+ // data
+ if (pWriter->fData.size == 0) {
+ flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
+ } else {
+ flag = TD_FILE_READ | TD_FILE_WRITE;
+ }
+ tsdbDataFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fData, fname);
+ code = tsdbOpenFile(fname, szPage, flag, &pWriter->pDataFD);
+ if (code) goto _err;
+ if (pWriter->fData.size == 0) {
+ code = tsdbWriteFile(pWriter->pDataFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+ pWriter->fData.size += TSDB_FHDR_SIZE;
}
- // check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
+ // sma
+ if (pWriter->fSma.size == 0) {
+ flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
+ } else {
+ flag = TD_FILE_READ | TD_FILE_WRITE;
+ }
+ tsdbSmaFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fSma, fname);
+ code = tsdbOpenFile(fname, szPage, flag, &pWriter->pSmaFD);
+ if (code) goto _err;
+ if (pWriter->fSma.size == 0) {
+ code = tsdbWriteFile(pWriter->pSmaFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+
+ pWriter->fSma.size += TSDB_FHDR_SIZE;
}
- // decode
- n = 0;
- uint32_t delimiter;
- n += tGetU32(pReader->aBuf[0] + n, &delimiter);
- ASSERT(delimiter == TSDB_FILE_DLMT);
+ // stt
+ ASSERT(pWriter->fStt[pSet->nSttF - 1].size == 0);
+ flag = TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
+ tsdbSttFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fStt[pSet->nSttF - 1], fname);
+ code = tsdbOpenFile(fname, szPage, flag, &pWriter->pSttFD);
+ if (code) goto _err;
+ code = tsdbWriteFile(pWriter->pSttFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+ pWriter->fStt[pWriter->wSet.nSttF - 1].size += TSDB_FHDR_SIZE;
- while (n < size - sizeof(TSCKSUM)) {
- SDelIdx delIdx;
+ *ppWriter = pWriter;
+ return code;
- n += tGetDelIdx(pReader->aBuf[0] + n, &delIdx);
+_err:
+ tsdbError("vgId:%d, tsdb data file writer open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ *ppWriter = NULL;
+ return code;
+}
- if (taosArrayPush(aDelIdx, &delIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
+int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) {
+ int32_t code = 0;
+ STsdb *pTsdb = NULL;
+
+ if (*ppWriter == NULL) goto _exit;
+
+ pTsdb = (*ppWriter)->pTsdb;
+ if (sync) {
+ code = tsdbFsyncFile((*ppWriter)->pHeadFD);
+ if (code) goto _err;
+
+ code = tsdbFsyncFile((*ppWriter)->pDataFD);
+ if (code) goto _err;
+
+ code = tsdbFsyncFile((*ppWriter)->pSmaFD);
+ if (code) goto _err;
+
+ code = tsdbFsyncFile((*ppWriter)->pSttFD);
+ if (code) goto _err;
}
- ASSERT(n == size - sizeof(TSCKSUM));
+ tsdbCloseFile(&(*ppWriter)->pHeadFD);
+ tsdbCloseFile(&(*ppWriter)->pDataFD);
+ tsdbCloseFile(&(*ppWriter)->pSmaFD);
+ tsdbCloseFile(&(*ppWriter)->pSttFD);
+
+ for (int32_t iBuf = 0; iBuf < sizeof((*ppWriter)->aBuf) / sizeof(uint8_t *); iBuf++) {
+ tFree((*ppWriter)->aBuf[iBuf]);
+ }
+ taosMemoryFree(*ppWriter);
+_exit:
+ *ppWriter = NULL;
+ return code;
+
+_err:
+ tsdbError("vgId:%d, data file writer close failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) {
+ int32_t code = 0;
+ int64_t n;
+ char hdr[TSDB_FHDR_SIZE];
+
+ // head ==============
+ memset(hdr, 0, TSDB_FHDR_SIZE);
+ tPutHeadFile(hdr, &pWriter->fHead);
+ code = tsdbWriteFile(pWriter->pHeadFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+
+ // data ==============
+ memset(hdr, 0, TSDB_FHDR_SIZE);
+ tPutDataFile(hdr, &pWriter->fData);
+ code = tsdbWriteFile(pWriter->pDataFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+
+ // sma ==============
+ memset(hdr, 0, TSDB_FHDR_SIZE);
+ tPutSmaFile(hdr, &pWriter->fSma);
+ code = tsdbWriteFile(pWriter->pSmaFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
+
+ // stt ==============
+ memset(hdr, 0, TSDB_FHDR_SIZE);
+ tPutSttFile(hdr, &pWriter->fStt[pWriter->wSet.nSttF - 1]);
+ code = tsdbWriteFile(pWriter->pSttFD, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
return code;
_err:
- tsdbError("vgId:%d, read del idx failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, update DFileSet header failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx) {
+ int32_t code = 0;
+ SHeadFile *pHeadFile = &pWriter->fHead;
+ int64_t size;
+ int64_t n;
+
+ // check
+ if (taosArrayGetSize(aBlockIdx) == 0) {
+ pHeadFile->offset = pHeadFile->size;
+ goto _exit;
+ }
+
+ // prepare
+ size = 0;
+ for (int32_t iBlockIdx = 0; iBlockIdx < taosArrayGetSize(aBlockIdx); iBlockIdx++) {
+ size += tPutBlockIdx(NULL, taosArrayGet(aBlockIdx, iBlockIdx));
+ }
+
+ // alloc
+ code = tRealloc(&pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // build
+ n = 0;
+ for (int32_t iBlockIdx = 0; iBlockIdx < taosArrayGetSize(aBlockIdx); iBlockIdx++) {
+ n += tPutBlockIdx(pWriter->aBuf[0] + n, taosArrayGet(aBlockIdx, iBlockIdx));
+ }
+ ASSERT(n == size);
+
+ // write
+ code = tsdbWriteFile(pWriter->pHeadFD, pHeadFile->size, pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // update
+ pHeadFile->offset = pHeadFile->size;
+ pHeadFile->size += size;
+
+_exit:
+ // tsdbTrace("vgId:%d write block idx, offset:%" PRId64 " size:%" PRId64 " nBlockIdx:%d",
+ // TD_VID(pWriter->pTsdb->pVnode),
+ // pHeadFile->offset, size, taosArrayGetSize(aBlockIdx));
+ return code;
+
+_err:
+ tsdbError("vgId:%d, write block idx failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbWriteDataBlk(SDataFWriter *pWriter, SMapData *mDataBlk, SBlockIdx *pBlockIdx) {
+ int32_t code = 0;
+ SHeadFile *pHeadFile = &pWriter->fHead;
+ int64_t size;
+ int64_t n;
+
+ ASSERT(mDataBlk->nItem > 0);
+
+ // alloc
+ size = tPutMapData(NULL, mDataBlk);
+ code = tRealloc(&pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // build
+ n = tPutMapData(pWriter->aBuf[0], mDataBlk);
+
+ // write
+ code = tsdbWriteFile(pWriter->pHeadFD, pHeadFile->size, pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // update
+ pBlockIdx->offset = pHeadFile->size;
+ pBlockIdx->size = size;
+ pHeadFile->size += size;
+
+ tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%d suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
+ " size:%" PRId64 " nItem:%d",
+ TD_VID(pWriter->pTsdb->pVnode), pWriter->wSet.fid, pHeadFile->commitID, pBlockIdx->suid, pBlockIdx->uid,
+ pBlockIdx->offset, pBlockIdx->size, mDataBlk->nItem);
+ return code;
+
+_err:
+ tsdbError("vgId:%d, write block failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbWriteSttBlk(SDataFWriter *pWriter, SArray *aSttBlk) {
+ int32_t code = 0;
+ SSttFile *pSttFile = &pWriter->fStt[pWriter->wSet.nSttF - 1];
+ int64_t size;
+ int64_t n;
+
+ // check
+ if (taosArrayGetSize(aSttBlk) == 0) {
+ pSttFile->offset = pSttFile->size;
+ goto _exit;
+ }
+
+ // size
+ size = 0;
+ for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aSttBlk); iBlockL++) {
+ size += tPutSttBlk(NULL, taosArrayGet(aSttBlk, iBlockL));
+ }
+
+ // alloc
+ code = tRealloc(&pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // encode
+ n = 0;
+ for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aSttBlk); iBlockL++) {
+ n += tPutSttBlk(pWriter->aBuf[0] + n, taosArrayGet(aSttBlk, iBlockL));
+ }
+
+ // write
+ code = tsdbWriteFile(pWriter->pSttFD, pSttFile->size, pWriter->aBuf[0], size);
+ if (code) goto _err;
+
+ // update
+ pSttFile->offset = pSttFile->size;
+ pSttFile->size += size;
+
+_exit:
+ tsdbTrace("vgId:%d tsdb write stt block, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
+ pSttFile->offset, size);
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb write blockl failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbWriteBlockSma(SDataFWriter *pWriter, SBlockData *pBlockData, SSmaInfo *pSmaInfo) {
+ int32_t code = 0;
+
+ pSmaInfo->offset = 0;
+ pSmaInfo->size = 0;
+
+ // encode
+ for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
+ SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
+
+ if ((!pColData->smaOn) || IS_VAR_DATA_TYPE(pColData->type)) continue;
+
+ SColumnDataAgg sma;
+ tsdbCalcColDataSMA(pColData, &sma);
+
+ code = tRealloc(&pWriter->aBuf[0], pSmaInfo->size + tPutColumnDataAgg(NULL, &sma));
+ if (code) goto _err;
+ pSmaInfo->size += tPutColumnDataAgg(pWriter->aBuf[0] + pSmaInfo->size, &sma);
+ }
+
+ // write
+ if (pSmaInfo->size) {
+ code = tRealloc(&pWriter->aBuf[0], pSmaInfo->size);
+ if (code) goto _err;
+
+ code = tsdbWriteFile(pWriter->pSmaFD, pWriter->fSma.size, pWriter->aBuf[0], pSmaInfo->size);
+ if (code) goto _err;
+
+ pSmaInfo->offset = pWriter->fSma.size;
+ pWriter->fSma.size += pSmaInfo->size;
+ }
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb write block sma failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlockInfo *pBlkInfo, SSmaInfo *pSmaInfo,
+ int8_t cmprAlg, int8_t toLast) {
+ int32_t code = 0;
+
+ ASSERT(pBlockData->nRow > 0);
+
+ if (toLast) {
+ pBlkInfo->offset = pWriter->fStt[pWriter->wSet.nSttF - 1].size;
+ } else {
+ pBlkInfo->offset = pWriter->fData.size;
+ }
+ pBlkInfo->szBlock = 0;
+ pBlkInfo->szKey = 0;
+
+ int32_t aBufN[4] = {0};
+ code = tCmprBlockData(pBlockData, cmprAlg, NULL, NULL, pWriter->aBuf, aBufN);
+ if (code) goto _err;
+
+ // write =================
+ STsdbFD *pFD = toLast ? pWriter->pSttFD : pWriter->pDataFD;
+
+ pBlkInfo->szKey = aBufN[3] + aBufN[2];
+ pBlkInfo->szBlock = aBufN[0] + aBufN[1] + aBufN[2] + aBufN[3];
+
+ int64_t offset = pBlkInfo->offset;
+ code = tsdbWriteFile(pFD, offset, pWriter->aBuf[3], aBufN[3]);
+ if (code) goto _err;
+ offset += aBufN[3];
+
+ code = tsdbWriteFile(pFD, offset, pWriter->aBuf[2], aBufN[2]);
+ if (code) goto _err;
+ offset += aBufN[2];
+
+ if (aBufN[1]) {
+ code = tsdbWriteFile(pFD, offset, pWriter->aBuf[1], aBufN[1]);
+ if (code) goto _err;
+ offset += aBufN[1];
+ }
+
+ if (aBufN[0]) {
+ code = tsdbWriteFile(pFD, offset, pWriter->aBuf[0], aBufN[0]);
+ if (code) goto _err;
+ }
+
+ // update info
+ if (toLast) {
+ pWriter->fStt[pWriter->wSet.nSttF - 1].size += pBlkInfo->szBlock;
+ } else {
+ pWriter->fData.size += pBlkInfo->szBlock;
+ }
+
+ // ================= SMA ====================
+ if (pSmaInfo) {
+ code = tsdbWriteBlockSma(pWriter, pBlockData, pSmaInfo);
+ if (code) goto _err;
+ }
+
+_exit:
+ tsdbTrace("vgId:%d tsdb write block data, suid:%" PRId64 " uid:%" PRId64 " nRow:%d, offset:%" PRId64 " size:%d",
+ TD_VID(pWriter->pTsdb->pVnode), pBlockData->suid, pBlockData->uid, pBlockData->nRow, pBlkInfo->offset,
+ pBlkInfo->szBlock);
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb write block data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
+ int32_t code = 0;
+ int64_t n;
+ int64_t size;
+ TdFilePtr pOutFD = NULL;
+ TdFilePtr PInFD = NULL;
+ int32_t szPage = pTsdb->pVnode->config.szPage;
+ char fNameFrom[TSDB_FILENAME_LEN];
+ char fNameTo[TSDB_FILENAME_LEN];
+
+ // head
+ tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
+ tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
+ pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
+ if (pOutFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
+ if (PInFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->pHeadF->size, szPage));
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ taosCloseFile(&pOutFD);
+ taosCloseFile(&PInFD);
+
+ // data
+ tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
+ tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
+ pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
+ if (pOutFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
+ if (PInFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ n = taosFSendFile(pOutFD, PInFD, 0, LOGIC_TO_FILE_OFFSET(pSetFrom->pDataF->size, szPage));
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ taosCloseFile(&pOutFD);
+ taosCloseFile(&PInFD);
+
+ // sma
+ tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
+ tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
+ pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
+ if (pOutFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
+ if (PInFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->pSmaF->size, szPage));
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ taosCloseFile(&pOutFD);
+ taosCloseFile(&PInFD);
+
+ // stt
+ for (int8_t iStt = 0; iStt < pSetFrom->nSttF; iStt++) {
+ tsdbSttFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->aSttF[iStt], fNameFrom);
+ tsdbSttFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->aSttF[iStt], fNameTo);
+ pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
+ if (pOutFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
+ if (PInFD == NULL) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ n = taosFSendFile(pOutFD, PInFD, 0, tsdbLogicToFileSize(pSetFrom->aSttF[iStt]->size, szPage));
+ if (n < 0) {
+ code = TAOS_SYSTEM_ERROR(errno);
+ goto _err;
+ }
+ taosCloseFile(&pOutFD);
+ taosCloseFile(&PInFD);
+ }
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d, tsdb DFileSet copy failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
return code;
}
// SDataFReader ====================================================
-struct SDataFReader {
- STsdb *pTsdb;
- SDFileSet *pSet;
- TdFilePtr pHeadFD;
- TdFilePtr pDataFD;
- TdFilePtr pLastFD;
- TdFilePtr pSmaFD;
-
- uint8_t *aBuf[3];
-};
-
int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pSet) {
int32_t code = 0;
SDataFReader *pReader;
+ int32_t szPage = pTsdb->pVnode->config.tsdbPageSize;
char fname[TSDB_FILENAME_LEN];
// alloc
@@ -419,37 +726,26 @@ int32_t tsdbDataFReaderOpen(SDataFReader **ppReader, STsdb *pTsdb, SDFileSet *pS
pReader->pTsdb = pTsdb;
pReader->pSet = pSet;
- // open impl
// head
tsdbHeadFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pHeadF, fname);
- pReader->pHeadFD = taosOpenFile(fname, TD_FILE_READ);
- if (pReader->pHeadFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pHeadFD);
+ if (code) goto _err;
// data
tsdbDataFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pDataF, fname);
- pReader->pDataFD = taosOpenFile(fname, TD_FILE_READ);
- if (pReader->pDataFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // last
- tsdbLastFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pLastF, fname);
- pReader->pLastFD = taosOpenFile(fname, TD_FILE_READ);
- if (pReader->pLastFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pDataFD);
+ if (code) goto _err;
// sma
tsdbSmaFileName(pTsdb, pSet->diskId, pSet->fid, pSet->pSmaF, fname);
- pReader->pSmaFD = taosOpenFile(fname, TD_FILE_READ);
- if (pReader->pSmaFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
+ code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->pSmaFD);
+ if (code) goto _err;
+
+ // stt
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ tsdbSttFileName(pTsdb, pSet->diskId, pSet->fid, pSet->aSttF[iStt], fname);
+ code = tsdbOpenFile(fname, szPage, TD_FILE_READ, &pReader->aSttFD[iStt]);
+ if (code) goto _err;
}
*ppReader = pReader;
@@ -463,35 +759,28 @@ _err:
int32_t tsdbDataFReaderClose(SDataFReader **ppReader) {
int32_t code = 0;
- if (*ppReader == NULL) goto _exit;
+ if (*ppReader == NULL) return code;
- if (taosCloseFile(&(*ppReader)->pHeadFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ // head
+ tsdbCloseFile(&(*ppReader)->pHeadFD);
- if (taosCloseFile(&(*ppReader)->pDataFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ // data
+ tsdbCloseFile(&(*ppReader)->pDataFD);
- if (taosCloseFile(&(*ppReader)->pLastFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ // sma
+ tsdbCloseFile(&(*ppReader)->pSmaFD);
- if (taosCloseFile(&(*ppReader)->pSmaFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
+ // stt
+ for (int32_t iStt = 0; iStt < TSDB_MAX_STT_TRIGGER; iStt++) {
+ if ((*ppReader)->aSttFD[iStt]) {
+ tsdbCloseFile(&(*ppReader)->aSttFD[iStt]);
+ }
}
for (int32_t iBuf = 0; iBuf < sizeof((*ppReader)->aBuf) / sizeof(uint8_t *); iBuf++) {
tFree((*ppReader)->aBuf[iBuf]);
}
-
taosMemoryFree(*ppReader);
-
-_exit:
*ppReader = NULL;
return code;
@@ -501,49 +790,25 @@ _err:
}
int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
- int32_t code = 0;
- int64_t offset = pReader->pSet->pHeadF->offset;
- int64_t size = pReader->pSet->pHeadF->size - offset;
- int64_t n;
- uint32_t delimiter;
+ int32_t code = 0;
+ SHeadFile *pHeadFile = pReader->pSet->pHeadF;
+ int64_t offset = pHeadFile->offset;
+ int64_t size = pHeadFile->size - offset;
taosArrayClear(aBlockIdx);
- if (size == 0) {
- goto _exit;
- }
+ if (size == 0) return code;
// alloc
code = tRealloc(&pReader->aBuf[0], size);
if (code) goto _err;
- // seek
- if (taosLSeekFile(pReader->pHeadFD, offset, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
// read
- n = taosReadFile(pReader->pHeadFD, pReader->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
- // check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
+ code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size);
+ if (code) goto _err;
// decode
- n = 0;
- n = tGetU32(pReader->aBuf[0] + n, &delimiter);
- ASSERT(delimiter == TSDB_FILE_DLMT);
-
- while (n < size - sizeof(TSCKSUM)) {
+ int64_t n = 0;
+ while (n < size) {
SBlockIdx blockIdx;
n += tGetBlockIdx(pReader->aBuf[0] + n, &blockIdx);
@@ -552,10 +817,8 @@ int32_t tsdbReadBlockIdx(SDataFReader *pReader, SArray *aBlockIdx) {
goto _err;
}
}
+ ASSERT(n == size);
- ASSERT(n + sizeof(TSCKSUM) == size);
-
-_exit:
return code;
_err:
@@ -563,116 +826,63 @@ _err:
return code;
}
-int32_t tsdbReadBlockL(SDataFReader *pReader, SArray *aBlockL) {
- int32_t code = 0;
- int64_t offset = pReader->pSet->pLastF->offset;
- int64_t size = pReader->pSet->pLastF->size - offset;
- int64_t n;
- uint32_t delimiter;
+int32_t tsdbReadSttBlk(SDataFReader *pReader, int32_t iStt, SArray *aSttBlk) {
+ int32_t code = 0;
+ SSttFile *pSttFile = pReader->pSet->aSttF[iStt];
+ int64_t offset = pSttFile->offset;
+ int64_t size = pSttFile->size - offset;
- taosArrayClear(aBlockL);
- if (size == 0) {
- goto _exit;
- }
+ taosArrayClear(aSttBlk);
+ if (size == 0) return code;
// alloc
code = tRealloc(&pReader->aBuf[0], size);
if (code) goto _err;
- // seek
- if (taosLSeekFile(pReader->pLastFD, offset, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
// read
- n = taosReadFile(pReader->pLastFD, pReader->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
- // check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
+ code = tsdbReadFile(pReader->aSttFD[iStt], offset, pReader->aBuf[0], size);
+ if (code) goto _err;
// decode
- n = 0;
- n = tGetU32(pReader->aBuf[0] + n, &delimiter);
- ASSERT(delimiter == TSDB_FILE_DLMT);
+ int64_t n = 0;
+ while (n < size) {
+ SSttBlk sttBlk;
+ n += tGetSttBlk(pReader->aBuf[0] + n, &sttBlk);
- while (n < size - sizeof(TSCKSUM)) {
- SBlockL blockl;
- n += tGetBlockL(pReader->aBuf[0] + n, &blockl);
-
- if (taosArrayPush(aBlockL, &blockl) == NULL) {
+ if (taosArrayPush(aSttBlk, &sttBlk) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
}
+ ASSERT(n == size);
- ASSERT(n + sizeof(TSCKSUM) == size);
-
-_exit:
return code;
_err:
- tsdbError("vgId:%d read blockl failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d read stt blk failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
return code;
}
-int32_t tsdbReadBlock(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mBlock) {
+int32_t tsdbReadDataBlk(SDataFReader *pReader, SBlockIdx *pBlockIdx, SMapData *mDataBlk) {
int32_t code = 0;
int64_t offset = pBlockIdx->offset;
int64_t size = pBlockIdx->size;
- int64_t n;
- int64_t tn;
// alloc
code = tRealloc(&pReader->aBuf[0], size);
if (code) goto _err;
- // seek
- if (taosLSeekFile(pReader->pHeadFD, offset, SEEK_SET) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
// read
- n = taosReadFile(pReader->pHeadFD, pReader->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
- // check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
+ code = tsdbReadFile(pReader->pHeadFD, offset, pReader->aBuf[0], size);
+ if (code) goto _err;
// decode
- n = 0;
-
- uint32_t delimiter;
- n += tGetU32(pReader->aBuf[0] + n, &delimiter);
- ASSERT(delimiter == TSDB_FILE_DLMT);
-
- tn = tGetMapData(pReader->aBuf[0] + n, mBlock);
- if (tn < 0) {
+ int64_t n = tGetMapData(pReader->aBuf[0], mDataBlk);
+ if (n < 0) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
- n += tn;
- ASSERT(n + sizeof(TSCKSUM) == size);
+ ASSERT(n == size);
return code;
@@ -681,57 +891,34 @@ _err:
return code;
}
-int32_t tsdbReadBlockSma(SDataFReader *pReader, SBlock *pBlock, SArray *aColumnDataAgg) {
+int32_t tsdbReadBlockSma(SDataFReader *pReader, SDataBlk *pDataBlk, SArray *aColumnDataAgg) {
int32_t code = 0;
- SSmaInfo *pSmaInfo = &pBlock->smaInfo;
+ SSmaInfo *pSmaInfo = &pDataBlk->smaInfo;
ASSERT(pSmaInfo->size > 0);
taosArrayClear(aColumnDataAgg);
// alloc
- int32_t size = pSmaInfo->size + sizeof(TSCKSUM);
- code = tRealloc(&pReader->aBuf[0], size);
+ code = tRealloc(&pReader->aBuf[0], pSmaInfo->size);
if (code) goto _err;
- // seek
- int64_t n = taosLSeekFile(pReader->pSmaFD, pSmaInfo->offset, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < pSmaInfo->offset) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
// read
- n = taosReadFile(pReader->pSmaFD, pReader->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
-
- // check
- if (!taosCheckChecksumWhole(pReader->aBuf[0], size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _err;
- }
+ code = tsdbReadFile(pReader->pSmaFD, pSmaInfo->offset, pReader->aBuf[0], pSmaInfo->size);
+ if (code) goto _err;
// decode
- n = 0;
+ int32_t n = 0;
while (n < pSmaInfo->size) {
SColumnDataAgg sma;
-
n += tGetColumnDataAgg(pReader->aBuf[0] + n, &sma);
+
if (taosArrayPush(aColumnDataAgg, &sma) == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
}
-
+ ASSERT(n == pSmaInfo->size);
return code;
_err:
@@ -739,17 +926,20 @@ _err:
return code;
}
-static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo, int8_t fromLast,
- SBlockData *pBlockData) {
+static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo, SBlockData *pBlockData) {
int32_t code = 0;
tBlockDataClear(pBlockData);
- TdFilePtr pFD = fromLast ? pReader->pLastFD : pReader->pDataFD;
+ STsdbFD *pFD = pReader->pDataFD;
// uid + version + tskey
- code = tsdbReadAndCheck(pFD, pBlkInfo->offset, &pReader->aBuf[0], pBlkInfo->szKey, 1);
+ code = tRealloc(&pReader->aBuf[0], pBlkInfo->szKey);
if (code) goto _err;
+
+ code = tsdbReadFile(pFD, pBlkInfo->offset, pReader->aBuf[0], pBlkInfo->szKey);
+ if (code) goto _err;
+
SDiskDataHdr hdr;
uint8_t *p = pReader->aBuf[0] + tGetDiskDataHdr(pReader->aBuf[0], &hdr);
@@ -782,14 +972,18 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
if (code) goto _err;
p += hdr.szKey;
- ASSERT(p - pReader->aBuf[0] == pBlkInfo->szKey - sizeof(TSCKSUM));
+ ASSERT(p - pReader->aBuf[0] == pBlkInfo->szKey);
// read and decode columns
if (taosArrayGetSize(pBlockData->aIdx) == 0) goto _exit;
if (hdr.szBlkCol > 0) {
int64_t offset = pBlkInfo->offset + pBlkInfo->szKey;
- code = tsdbReadAndCheck(pFD, offset, &pReader->aBuf[0], hdr.szBlkCol + sizeof(TSCKSUM), 1);
+
+ code = tRealloc(&pReader->aBuf[0], hdr.szBlkCol);
+ if (code) goto _err;
+
+ code = tsdbReadFile(pFD, offset, pReader->aBuf[0], hdr.szBlkCol);
if (code) goto _err;
}
@@ -827,10 +1021,13 @@ static int32_t tsdbReadBlockDataImpl(SDataFReader *pReader, SBlockInfo *pBlkInfo
}
} else {
// decode from binary
- int64_t offset = pBlkInfo->offset + pBlkInfo->szKey + hdr.szBlkCol + sizeof(TSCKSUM) + pBlockCol->offset;
- int32_t size = pBlockCol->szBitmap + pBlockCol->szOffset + pBlockCol->szValue + sizeof(TSCKSUM);
+ int64_t offset = pBlkInfo->offset + pBlkInfo->szKey + hdr.szBlkCol + pBlockCol->offset;
+ int32_t size = pBlockCol->szBitmap + pBlockCol->szOffset + pBlockCol->szValue;
- code = tsdbReadAndCheck(pFD, offset, &pReader->aBuf[1], size, 0);
+ code = tRealloc(&pReader->aBuf[1], size);
+ if (code) goto _err;
+
+ code = tsdbReadFile(pFD, offset, pReader->aBuf[1], size);
if (code) goto _err;
code = tsdbDecmprColData(pReader->aBuf[1], pBlockCol, hdr.cmprAlg, hdr.nRow, pColData, &pReader->aBuf[2]);
@@ -847,13 +1044,36 @@ _err:
return code;
}
-int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBlockData) {
- int32_t code = 0;
+int32_t tsdbReadDataBlockEx(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) {
+ int32_t code = 0;
+ SBlockInfo *pBlockInfo = &pDataBlk->aSubBlock[0];
- code = tsdbReadBlockDataImpl(pReader, &pBlock->aSubBlock[0], 0, pBlockData);
+ // alloc
+ code = tRealloc(&pReader->aBuf[0], pBlockInfo->szBlock);
if (code) goto _err;
- if (pBlock->nSubBlock > 1) {
+ // read
+ code = tsdbReadFile(pReader->pDataFD, pBlockInfo->offset, pReader->aBuf[0], pBlockInfo->szBlock);
+ if (code) goto _err;
+
+ // decmpr
+ code = tDecmprBlockData(pReader->aBuf[0], pBlockInfo->szBlock, pBlockData, &pReader->aBuf[1]);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d tsdb read data block ex failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+
+int32_t tsdbReadDataBlock(SDataFReader *pReader, SDataBlk *pDataBlk, SBlockData *pBlockData) {
+ int32_t code = 0;
+
+ code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[0], pBlockData);
+ if (code) goto _err;
+
+ if (pDataBlk->nSubBlock > 1) {
SBlockData bData1;
SBlockData bData2;
@@ -867,8 +1087,8 @@ int32_t tsdbReadDataBlock(SDataFReader *pReader, SBlock *pBlock, SBlockData *pBl
tBlockDataInitEx(&bData1, pBlockData);
tBlockDataInitEx(&bData2, pBlockData);
- for (int32_t iSubBlock = 1; iSubBlock < pBlock->nSubBlock; iSubBlock++) {
- code = tsdbReadBlockDataImpl(pReader, &pBlock->aSubBlock[iSubBlock], 0, &bData1);
+ for (int32_t iSubBlock = 1; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) {
+ code = tsdbReadBlockDataImpl(pReader, &pDataBlk->aSubBlock[iSubBlock], &bData1);
if (code) {
tBlockDataDestroy(&bData1, 1);
tBlockDataDestroy(&bData2, 1);
@@ -901,325 +1121,103 @@ _err:
return code;
}
-int32_t tsdbReadLastBlock(SDataFReader *pReader, SBlockL *pBlockL, SBlockData *pBlockData) {
+int32_t tsdbReadSttBlock(SDataFReader *pReader, int32_t iStt, SSttBlk *pSttBlk, SBlockData *pBlockData) {
int32_t code = 0;
- code = tsdbReadBlockDataImpl(pReader, &pBlockL->bInfo, 1, pBlockData);
+ // alloc
+ code = tRealloc(&pReader->aBuf[0], pSttBlk->bInfo.szBlock);
+ if (code) goto _err;
+
+ // read
+ code = tsdbReadFile(pReader->aSttFD[iStt], pSttBlk->bInfo.offset, pReader->aBuf[0], pSttBlk->bInfo.szBlock);
+ if (code) goto _err;
+
+ // decmpr
+ code = tDecmprBlockData(pReader->aBuf[0], pSttBlk->bInfo.szBlock, pBlockData, &pReader->aBuf[1]);
if (code) goto _err;
return code;
_err:
- tsdbError("vgId:%d tsdb read last block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d tsdb read stt block failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
return code;
}
-// SDataFWriter ====================================================
-int32_t tsdbDataFWriterOpen(SDataFWriter **ppWriter, STsdb *pTsdb, SDFileSet *pSet) {
- int32_t code = 0;
- int32_t flag;
- int64_t n;
- SDataFWriter *pWriter = NULL;
- char fname[TSDB_FILENAME_LEN];
- char hdr[TSDB_FHDR_SIZE] = {0};
+// SDelFWriter ====================================================
+int32_t tsdbDelFWriterOpen(SDelFWriter **ppWriter, SDelFile *pFile, STsdb *pTsdb) {
+ int32_t code = 0;
+ char fname[TSDB_FILENAME_LEN];
+ uint8_t hdr[TSDB_FHDR_SIZE] = {0};
+ SDelFWriter *pDelFWriter;
+ int64_t n;
// alloc
- pWriter = taosMemoryCalloc(1, sizeof(*pWriter));
- if (pWriter == NULL) {
+ pDelFWriter = (SDelFWriter *)taosMemoryCalloc(1, sizeof(*pDelFWriter));
+ if (pDelFWriter == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
+ pDelFWriter->pTsdb = pTsdb;
+ pDelFWriter->fDel = *pFile;
+
+ tsdbDelFileName(pTsdb, pFile, fname);
+ code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ | TD_FILE_WRITE | TD_FILE_CREATE,
+ &pDelFWriter->pWriteH);
if (code) goto _err;
- pWriter->pTsdb = pTsdb;
- pWriter->wSet = (SDFileSet){.diskId = pSet->diskId,
- .fid = pSet->fid,
- .pHeadF = &pWriter->fHead,
- .pDataF = &pWriter->fData,
- .pLastF = &pWriter->fLast,
- .pSmaF = &pWriter->fSma};
- pWriter->fHead = *pSet->pHeadF;
- pWriter->fData = *pSet->pDataF;
- pWriter->fLast = *pSet->pLastF;
- pWriter->fSma = *pSet->pSmaF;
- // head
- flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
- tsdbHeadFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fHead, fname);
- pWriter->pHeadFD = taosOpenFile(fname, flag);
- if (pWriter->pHeadFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ // update header
+ code = tsdbWriteFile(pDelFWriter->pWriteH, 0, hdr, TSDB_FHDR_SIZE);
+ if (code) goto _err;
- n = taosWriteFile(pWriter->pHeadFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ pDelFWriter->fDel.size = TSDB_FHDR_SIZE;
+ pDelFWriter->fDel.offset = 0;
- ASSERT(n == TSDB_FHDR_SIZE);
-
- pWriter->fHead.size += TSDB_FHDR_SIZE;
-
- // data
- if (pWriter->fData.size == 0) {
- flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
- } else {
- flag = TD_FILE_WRITE;
- }
- tsdbDataFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fData, fname);
- pWriter->pDataFD = taosOpenFile(fname, flag);
- if (pWriter->pDataFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- if (pWriter->fData.size == 0) {
- n = taosWriteFile(pWriter->pDataFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- pWriter->fData.size += TSDB_FHDR_SIZE;
- } else {
- n = taosLSeekFile(pWriter->pDataFD, 0, SEEK_END);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- ASSERT(n == pWriter->fData.size);
- }
-
- // last
- if (pWriter->fLast.size == 0) {
- flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
- } else {
- flag = TD_FILE_WRITE;
- }
- tsdbLastFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fLast, fname);
- pWriter->pLastFD = taosOpenFile(fname, flag);
- if (pWriter->pLastFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- if (pWriter->fLast.size == 0) {
- n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- pWriter->fLast.size += TSDB_FHDR_SIZE;
- } else {
- n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_END);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- ASSERT(n == pWriter->fLast.size);
- }
-
- // sma
- if (pWriter->fSma.size == 0) {
- flag = TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC;
- } else {
- flag = TD_FILE_WRITE;
- }
- tsdbSmaFileName(pTsdb, pWriter->wSet.diskId, pWriter->wSet.fid, &pWriter->fSma, fname);
- pWriter->pSmaFD = taosOpenFile(fname, flag);
- if (pWriter->pSmaFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- if (pWriter->fSma.size == 0) {
- n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- pWriter->fSma.size += TSDB_FHDR_SIZE;
- } else {
- n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_END);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- ASSERT(n == pWriter->fSma.size);
- }
-
- *ppWriter = pWriter;
+ *ppWriter = pDelFWriter;
return code;
_err:
- tsdbError("vgId:%d, tsdb data file writer open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, failed to open del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
*ppWriter = NULL;
return code;
}
-int32_t tsdbDataFWriterClose(SDataFWriter **ppWriter, int8_t sync) {
- int32_t code = 0;
- STsdb *pTsdb = NULL;
+int32_t tsdbDelFWriterClose(SDelFWriter **ppWriter, int8_t sync) {
+ int32_t code = 0;
+ SDelFWriter *pWriter = *ppWriter;
+ STsdb *pTsdb = pWriter->pTsdb;
- if (*ppWriter == NULL) goto _exit;
-
- pTsdb = (*ppWriter)->pTsdb;
+ // sync
if (sync) {
- if (taosFsyncFile((*ppWriter)->pHeadFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- if (taosFsyncFile((*ppWriter)->pDataFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- if (taosFsyncFile((*ppWriter)->pLastFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- if (taosFsyncFile((*ppWriter)->pSmaFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ code = tsdbFsyncFile(pWriter->pWriteH);
+ if (code) goto _err;
}
- if (taosCloseFile(&(*ppWriter)->pHeadFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ // close
+ tsdbCloseFile(&pWriter->pWriteH);
- if (taosCloseFile(&(*ppWriter)->pDataFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
+ for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t *); iBuf++) {
+ tFree(pWriter->aBuf[iBuf]);
}
+ taosMemoryFree(pWriter);
- if (taosCloseFile(&(*ppWriter)->pLastFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- if (taosCloseFile(&(*ppWriter)->pSmaFD) < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- for (int32_t iBuf = 0; iBuf < sizeof((*ppWriter)->aBuf) / sizeof(uint8_t *); iBuf++) {
- tFree((*ppWriter)->aBuf[iBuf]);
- }
- taosMemoryFree(*ppWriter);
-_exit:
*ppWriter = NULL;
return code;
_err:
- tsdbError("vgId:%d, data file writer close failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, failed to close del file writer since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
return code;
}
-int32_t tsdbUpdateDFileSetHeader(SDataFWriter *pWriter) {
+int32_t tsdbWriteDelData(SDelFWriter *pWriter, SArray *aDelData, SDelIdx *pDelIdx) {
int32_t code = 0;
+ int64_t size;
int64_t n;
- char hdr[TSDB_FHDR_SIZE];
-
- // head ==============
- memset(hdr, 0, TSDB_FHDR_SIZE);
- tPutHeadFile(hdr, &pWriter->fHead);
- taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
-
- n = taosLSeekFile(pWriter->pHeadFD, 0, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosWriteFile(pWriter->pHeadFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // data ==============
- memset(hdr, 0, TSDB_FHDR_SIZE);
- tPutDataFile(hdr, &pWriter->fData);
- taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
-
- n = taosLSeekFile(pWriter->pDataFD, 0, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosWriteFile(pWriter->pDataFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // last ==============
- memset(hdr, 0, TSDB_FHDR_SIZE);
- tPutLastFile(hdr, &pWriter->fLast);
- taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
-
- n = taosLSeekFile(pWriter->pLastFD, 0, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosWriteFile(pWriter->pLastFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // sma ==============
- memset(hdr, 0, TSDB_FHDR_SIZE);
- tPutSmaFile(hdr, &pWriter->fSma);
- taosCalcChecksumAppend(0, hdr, TSDB_FHDR_SIZE);
-
- n = taosLSeekFile(pWriter->pSmaFD, 0, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosWriteFile(pWriter->pSmaFD, hdr, TSDB_FHDR_SIZE);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d, update DFileSet header failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx) {
- int32_t code = 0;
- SHeadFile *pHeadFile = &pWriter->fHead;
- int64_t size = 0;
- int64_t n;
-
- // check
- if (taosArrayGetSize(aBlockIdx) == 0) {
- pHeadFile->offset = pHeadFile->size;
- goto _exit;
- }
// prepare
- size = sizeof(uint32_t);
- for (int32_t iBlockIdx = 0; iBlockIdx < taosArrayGetSize(aBlockIdx); iBlockIdx++) {
- size += tPutBlockIdx(NULL, taosArrayGet(aBlockIdx, iBlockIdx));
+ size = 0;
+ for (int32_t iDelData = 0; iDelData < taosArrayGetSize(aDelData); iDelData++) {
+ size += tPutDelData(NULL, taosArrayGet(aDelData, iDelData));
}
- size += sizeof(TSCKSUM);
// alloc
code = tRealloc(&pWriter->aBuf[0], size);
@@ -1227,383 +1225,209 @@ int32_t tsdbWriteBlockIdx(SDataFWriter *pWriter, SArray *aBlockIdx) {
// build
n = 0;
- n = tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT);
- for (int32_t iBlockIdx = 0; iBlockIdx < taosArrayGetSize(aBlockIdx); iBlockIdx++) {
- n += tPutBlockIdx(pWriter->aBuf[0] + n, taosArrayGet(aBlockIdx, iBlockIdx));
+ for (int32_t iDelData = 0; iDelData < taosArrayGetSize(aDelData); iDelData++) {
+ n += tPutDelData(pWriter->aBuf[0] + n, taosArrayGet(aDelData, iDelData));
}
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
-
- ASSERT(n + sizeof(TSCKSUM) == size);
+ ASSERT(n == size);
// write
- n = taosWriteFile(pWriter->pHeadFD, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ code = tsdbWriteFile(pWriter->pWriteH, pWriter->fDel.size, pWriter->aBuf[0], size);
+ if (code) goto _err;
// update
- pHeadFile->offset = pHeadFile->size;
- pHeadFile->size += size;
+ pDelIdx->offset = pWriter->fDel.size;
+ pDelIdx->size = size;
+ pWriter->fDel.size += size;
-_exit:
- tsdbTrace("vgId:%d write block idx, offset:%" PRId64 " size:%" PRId64 " nBlockIdx:%d", TD_VID(pWriter->pTsdb->pVnode),
- pHeadFile->offset, size, taosArrayGetSize(aBlockIdx));
return code;
_err:
- tsdbError("vgId:%d, write block idx failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, failed to write del data since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
return code;
}
-int32_t tsdbWriteBlock(SDataFWriter *pWriter, SMapData *mBlock, SBlockIdx *pBlockIdx) {
- int32_t code = 0;
- SHeadFile *pHeadFile = &pWriter->fHead;
- int64_t size;
- int64_t n;
+int32_t tsdbWriteDelIdx(SDelFWriter *pWriter, SArray *aDelIdx) {
+ int32_t code = 0;
+ int64_t size;
+ int64_t n;
+ SDelIdx *pDelIdx;
- ASSERT(mBlock->nItem > 0);
+ // prepare
+ size = 0;
+ for (int32_t iDelIdx = 0; iDelIdx < taosArrayGetSize(aDelIdx); iDelIdx++) {
+ size += tPutDelIdx(NULL, taosArrayGet(aDelIdx, iDelIdx));
+ }
// alloc
- size = sizeof(uint32_t) + tPutMapData(NULL, mBlock) + sizeof(TSCKSUM);
code = tRealloc(&pWriter->aBuf[0], size);
if (code) goto _err;
// build
n = 0;
- n += tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT);
- n += tPutMapData(pWriter->aBuf[0] + n, mBlock);
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
-
- ASSERT(n + sizeof(TSCKSUM) == size);
+ for (int32_t iDelIdx = 0; iDelIdx < taosArrayGetSize(aDelIdx); iDelIdx++) {
+ n += tPutDelIdx(pWriter->aBuf[0] + n, taosArrayGet(aDelIdx, iDelIdx));
+ }
+ ASSERT(n == size);
// write
- n = taosWriteFile(pWriter->pHeadFD, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ code = tsdbWriteFile(pWriter->pWriteH, pWriter->fDel.size, pWriter->aBuf[0], size);
+ if (code) goto _err;
// update
- pBlockIdx->offset = pHeadFile->size;
- pBlockIdx->size = size;
- pHeadFile->size += size;
+ pWriter->fDel.offset = pWriter->fDel.size;
+ pWriter->fDel.size += size;
- tsdbTrace("vgId:%d, write block, file ID:%d commit ID:%d suid:%" PRId64 " uid:%" PRId64 " offset:%" PRId64
- " size:%" PRId64 " nItem:%d",
- TD_VID(pWriter->pTsdb->pVnode), pWriter->wSet.fid, pHeadFile->commitID, pBlockIdx->suid, pBlockIdx->uid,
- pBlockIdx->offset, pBlockIdx->size, mBlock->nItem);
return code;
_err:
- tsdbError("vgId:%d, write block failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, write del idx failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
return code;
}
-int32_t tsdbWriteBlockL(SDataFWriter *pWriter, SArray *aBlockL) {
- int32_t code = 0;
- SLastFile *pLastFile = &pWriter->fLast;
- int64_t size;
- int64_t n;
+int32_t tsdbUpdateDelFileHdr(SDelFWriter *pWriter) {
+ int32_t code = 0;
+ char hdr[TSDB_FHDR_SIZE] = {0};
+ int64_t size = TSDB_FHDR_SIZE;
+ int64_t n;
- // check
- if (taosArrayGetSize(aBlockL) == 0) {
- pLastFile->offset = pLastFile->size;
- goto _exit;
- }
+ // build
+ tPutDelFile(hdr, &pWriter->fDel);
- // size
- size = sizeof(uint32_t); // TSDB_FILE_DLMT
- for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aBlockL); iBlockL++) {
- size += tPutBlockL(NULL, taosArrayGet(aBlockL, iBlockL));
- }
- size += sizeof(TSCKSUM);
+ // write
+ code = tsdbWriteFile(pWriter->pWriteH, 0, hdr, size);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d, update del file hdr failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ return code;
+}
+// SDelFReader ====================================================
+struct SDelFReader {
+ STsdb *pTsdb;
+ SDelFile fDel;
+ STsdbFD *pReadH;
+ uint8_t *aBuf[1];
+};
+
+int32_t tsdbDelFReaderOpen(SDelFReader **ppReader, SDelFile *pFile, STsdb *pTsdb) {
+ int32_t code = 0;
+ char fname[TSDB_FILENAME_LEN];
+ SDelFReader *pDelFReader;
+ int64_t n;
// alloc
- code = tRealloc(&pWriter->aBuf[0], size);
+ pDelFReader = (SDelFReader *)taosMemoryCalloc(1, sizeof(*pDelFReader));
+ if (pDelFReader == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+
+ // open impl
+ pDelFReader->pTsdb = pTsdb;
+ pDelFReader->fDel = *pFile;
+
+ tsdbDelFileName(pTsdb, pFile, fname);
+ code = tsdbOpenFile(fname, pTsdb->pVnode->config.tsdbPageSize, TD_FILE_READ, &pDelFReader->pReadH);
if (code) goto _err;
- // encode
+ *ppReader = pDelFReader;
+ return code;
+
+_err:
+ tsdbError("vgId:%d, del file reader open failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ *ppReader = NULL;
+ return code;
+}
+
+int32_t tsdbDelFReaderClose(SDelFReader **ppReader) {
+ int32_t code = 0;
+ SDelFReader *pReader = *ppReader;
+
+ if (pReader) {
+ tsdbCloseFile(&pReader->pReadH);
+ for (int32_t iBuf = 0; iBuf < sizeof(pReader->aBuf) / sizeof(uint8_t *); iBuf++) {
+ tFree(pReader->aBuf[iBuf]);
+ }
+ taosMemoryFree(pReader);
+ }
+ *ppReader = NULL;
+
+_exit:
+ return code;
+}
+
+int32_t tsdbReadDelData(SDelFReader *pReader, SDelIdx *pDelIdx, SArray *aDelData) {
+ int32_t code = 0;
+ int64_t offset = pDelIdx->offset;
+ int64_t size = pDelIdx->size;
+ int64_t n;
+
+ taosArrayClear(aDelData);
+
+ // alloc
+ code = tRealloc(&pReader->aBuf[0], size);
+ if (code) goto _err;
+
+ // read
+ code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size);
+ if (code) goto _err;
+
+ // // decode
n = 0;
- n += tPutU32(pWriter->aBuf[0] + n, TSDB_FILE_DLMT);
- for (int32_t iBlockL = 0; iBlockL < taosArrayGetSize(aBlockL); iBlockL++) {
- n += tPutBlockL(pWriter->aBuf[0] + n, taosArrayGet(aBlockL, iBlockL));
- }
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
+ while (n < size) {
+ SDelData delData;
+ n += tGetDelData(pReader->aBuf[0] + n, &delData);
- ASSERT(n + sizeof(TSCKSUM) == size);
-
- // write
- n = taosWriteFile(pWriter->pLastFD, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- // update
- pLastFile->offset = pLastFile->size;
- pLastFile->size += size;
-
-_exit:
- tsdbTrace("vgId:%d tsdb write blockl, loffset:%" PRId64 " size:%" PRId64, TD_VID(pWriter->pTsdb->pVnode),
- pLastFile->offset, size);
- return code;
-
-_err:
- tsdbError("vgId:%d tsdb write blockl failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-static void tsdbUpdateBlockInfo(SBlockData *pBlockData, SBlock *pBlock) {
- for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
- TSDBKEY key = {.ts = pBlockData->aTSKEY[iRow], .version = pBlockData->aVersion[iRow]};
-
- if (iRow == 0) {
- if (tsdbKeyCmprFn(&pBlock->minKey, &key) > 0) {
- pBlock->minKey = key;
- }
- } else {
- if (pBlockData->aTSKEY[iRow] == pBlockData->aTSKEY[iRow - 1]) {
- pBlock->hasDup = 1;
- }
- }
-
- if (iRow == pBlockData->nRow - 1 && tsdbKeyCmprFn(&pBlock->maxKey, &key) < 0) {
- pBlock->maxKey = key;
- }
-
- pBlock->minVer = TMIN(pBlock->minVer, key.version);
- pBlock->maxVer = TMAX(pBlock->maxVer, key.version);
- }
- pBlock->nRow += pBlockData->nRow;
-}
-
-static int32_t tsdbWriteBlockSma(SDataFWriter *pWriter, SBlockData *pBlockData, SSmaInfo *pSmaInfo) {
- int32_t code = 0;
-
- pSmaInfo->offset = 0;
- pSmaInfo->size = 0;
-
- // encode
- for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
- SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
-
- if ((!pColData->smaOn) || IS_VAR_DATA_TYPE(pColData->type)) continue;
-
- SColumnDataAgg sma;
- tsdbCalcColDataSMA(pColData, &sma);
-
- code = tRealloc(&pWriter->aBuf[0], pSmaInfo->size + tPutColumnDataAgg(NULL, &sma));
- if (code) goto _err;
- pSmaInfo->size += tPutColumnDataAgg(pWriter->aBuf[0] + pSmaInfo->size, &sma);
- }
-
- // write
- if (pSmaInfo->size) {
- int32_t size = pSmaInfo->size + sizeof(TSCKSUM);
-
- code = tRealloc(&pWriter->aBuf[0], size);
- if (code) goto _err;
-
- taosCalcChecksumAppend(0, pWriter->aBuf[0], size);
-
- int64_t n = taosWriteFile(pWriter->pSmaFD, pWriter->aBuf[0], size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
+ if (taosArrayPush(aDelData, &delData) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
-
- pSmaInfo->offset = pWriter->fSma.size;
- pWriter->fSma.size += size;
}
+ ASSERT(n == size);
return code;
_err:
- tsdbError("vgId:%d tsdb write block sma failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, read del data failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
return code;
}
-int32_t tsdbWriteBlockData(SDataFWriter *pWriter, SBlockData *pBlockData, SBlockInfo *pBlkInfo, SSmaInfo *pSmaInfo,
- int8_t cmprAlg, int8_t toLast) {
+int32_t tsdbReadDelIdx(SDelFReader *pReader, SArray *aDelIdx) {
int32_t code = 0;
+ int32_t n;
+ int64_t offset = pReader->fDel.offset;
+ int64_t size = pReader->fDel.size - offset;
- ASSERT(pBlockData->nRow > 0);
+ taosArrayClear(aDelIdx);
- pBlkInfo->offset = toLast ? pWriter->fLast.size : pWriter->fData.size;
- pBlkInfo->szBlock = 0;
- pBlkInfo->szKey = 0;
-
- int32_t aBufN[4] = {0};
- code = tCmprBlockData(pBlockData, cmprAlg, NULL, NULL, pWriter->aBuf, aBufN);
+ // alloc
+ code = tRealloc(&pReader->aBuf[0], size);
if (code) goto _err;
- // write =================
- TdFilePtr pFD = toLast ? pWriter->pLastFD : pWriter->pDataFD;
+ // read
+ code = tsdbReadFile(pReader->pReadH, offset, pReader->aBuf[0], size);
+ if (code) goto _err;
- pBlkInfo->szKey = aBufN[3] + aBufN[2];
- pBlkInfo->szBlock = aBufN[0] + aBufN[1] + aBufN[2] + aBufN[3];
+ // decode
+ n = 0;
+ while (n < size) {
+ SDelIdx delIdx;
- int64_t n = taosWriteFile(pFD, pWriter->aBuf[3], aBufN[3]);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
+ n += tGetDelIdx(pReader->aBuf[0] + n, &delIdx);
- n = taosWriteFile(pFD, pWriter->aBuf[2], aBufN[2]);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- if (aBufN[1]) {
- n = taosWriteFile(pFD, pWriter->aBuf[1], aBufN[1]);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
+ if (taosArrayPush(aDelIdx, &delIdx) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
}
- if (aBufN[0]) {
- n = taosWriteFile(pFD, pWriter->aBuf[0], aBufN[0]);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- }
-
- // update info
- if (toLast) {
- pWriter->fLast.size += pBlkInfo->szBlock;
- } else {
- pWriter->fData.size += pBlkInfo->szBlock;
- }
-
- // ================= SMA ====================
- if (pSmaInfo) {
- code = tsdbWriteBlockSma(pWriter, pBlockData, pSmaInfo);
- if (code) goto _err;
- }
-
-_exit:
- tsdbTrace("vgId:%d tsdb write block data, suid:%" PRId64 " uid:%" PRId64 " nRow:%d, offset:%" PRId64 " size:%d",
- TD_VID(pWriter->pTsdb->pVnode), pBlockData->suid, pBlockData->uid, pBlockData->nRow, pBlkInfo->offset,
- pBlkInfo->szBlock);
- return code;
-
-_err:
- tsdbError("vgId:%d tsdb write block data failed since %s", TD_VID(pWriter->pTsdb->pVnode), tstrerror(code));
- return code;
-}
-
-int32_t tsdbDFileSetCopy(STsdb *pTsdb, SDFileSet *pSetFrom, SDFileSet *pSetTo) {
- int32_t code = 0;
- int64_t n;
- int64_t size;
- TdFilePtr pOutFD = NULL; // TODO
- TdFilePtr PInFD = NULL; // TODO
- char fNameFrom[TSDB_FILENAME_LEN];
- char fNameTo[TSDB_FILENAME_LEN];
-
- // head
- tsdbHeadFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pHeadF, fNameFrom);
- tsdbHeadFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pHeadF, fNameTo);
-
- pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
- if (pOutFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
- if (PInFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pHeadF->size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- taosCloseFile(&pOutFD);
- taosCloseFile(&PInFD);
-
- // data
- tsdbDataFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pDataF, fNameFrom);
- tsdbDataFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pDataF, fNameTo);
-
- pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
- if (pOutFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
- if (PInFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pDataF->size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- taosCloseFile(&pOutFD);
- taosCloseFile(&PInFD);
-
- // last
- tsdbLastFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pLastF, fNameFrom);
- tsdbLastFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pLastF, fNameTo);
-
- pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
- if (pOutFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
- if (PInFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pLastF->size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- taosCloseFile(&pOutFD);
- taosCloseFile(&PInFD);
-
- // sma
- tsdbSmaFileName(pTsdb, pSetFrom->diskId, pSetFrom->fid, pSetFrom->pSmaF, fNameFrom);
- tsdbSmaFileName(pTsdb, pSetTo->diskId, pSetTo->fid, pSetTo->pSmaF, fNameTo);
-
- pOutFD = taosOpenFile(fNameTo, TD_FILE_WRITE | TD_FILE_CREATE | TD_FILE_TRUNC);
- if (pOutFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- PInFD = taosOpenFile(fNameFrom, TD_FILE_READ);
- if (PInFD == NULL) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
-
- n = taosFSendFile(pOutFD, PInFD, 0, pSetFrom->pSmaF->size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _err;
- }
- taosCloseFile(&pOutFD);
- taosCloseFile(&PInFD);
+ ASSERT(n == size);
return code;
_err:
- tsdbError("vgId:%d, tsdb DFileSet copy failed since %s", TD_VID(pTsdb->pVnode), tstrerror(code));
+ tsdbError("vgId:%d, read del idx failed since %s", TD_VID(pReader->pTsdb->pVnode), tstrerror(code));
return code;
-}
+}
\ No newline at end of file
diff --git a/source/dnode/vnode/src/tsdb/tsdbRetention.c b/source/dnode/vnode/src/tsdb/tsdbRetention.c
index a30b9154ab..d99bf2aa5c 100644
--- a/source/dnode/vnode/src/tsdb/tsdbRetention.c
+++ b/source/dnode/vnode/src/tsdb/tsdbRetention.c
@@ -60,7 +60,7 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
if (expLevel < 0) {
taosMemoryFree(pSet->pHeadF);
taosMemoryFree(pSet->pDataF);
- taosMemoryFree(pSet->pLastF);
+ taosMemoryFree(pSet->aSttF[0]);
taosMemoryFree(pSet->pSmaF);
taosArrayRemove(fs.aDFileSet, iSet);
iSet--;
@@ -82,8 +82,6 @@ int32_t tsdbDoRetention(STsdb *pTsdb, int64_t now) {
code = tsdbFSUpsertFSet(&fs, &fSet);
if (code) goto _err;
}
-
- /* code */
}
// do change fs
diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
index ab2b2b617a..99e88a442c 100644
--- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
+++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c
@@ -16,6 +16,29 @@
#include "tsdb.h"
// STsdbSnapReader ========================================
+typedef enum { SNAP_DATA_FILE_ITER = 0, SNAP_STT_FILE_ITER } EFIterT;
+typedef struct {
+ SRBTreeNode n;
+ SRowInfo rInfo;
+ EFIterT type;
+ union {
+ struct {
+ SArray* aBlockIdx;
+ int32_t iBlockIdx;
+ SBlockIdx* pBlockIdx;
+ SMapData mBlock;
+ int32_t iBlock;
+ }; // .data file
+ struct {
+ int32_t iStt;
+ SArray* aSttBlk;
+ int32_t iSttBlk;
+ }; // .stt file
+ };
+ SBlockData bData;
+ int32_t iRow;
+} SFDataIter;
+
struct STsdbSnapReader {
STsdb* pTsdb;
int64_t sver;
@@ -26,146 +49,301 @@ struct STsdbSnapReader {
int8_t dataDone;
int32_t fid;
SDataFReader* pDataFReader;
- SArray* aBlockIdx; // SArray
- SArray* aBlockL; // SArray
- SBlockIdx* pBlockIdx;
- SBlockL* pBlockL;
-
- int32_t iBlockIdx;
- int32_t iBlockL;
- SMapData mBlock; // SMapData
- int32_t iBlock;
- SBlockData oBlockData;
- SBlockData nBlockData;
+ SFDataIter* pIter;
+ SRBTree rbt;
+ SFDataIter aFDataIter[TSDB_MAX_STT_TRIGGER + 1];
+ SBlockData bData;
+ SSkmInfo skmTable;
// for del file
int8_t delDone;
SDelFReader* pDelFReader;
SArray* aDelIdx; // SArray
int32_t iDelIdx;
SArray* aDelData; // SArray
+ uint8_t* aBuf[5];
};
+extern int32_t tRowInfoCmprFn(const void* p1, const void* p2);
+extern int32_t tsdbReadDataBlockEx(SDataFReader* pReader, SDataBlk* pDataBlk, SBlockData* pBlockData);
+extern int32_t tsdbUpdateTableSchema(SMeta* pMeta, int64_t suid, int64_t uid, SSkmInfo* pSkmInfo);
+
+static int32_t tsdbSnapReadOpenFile(STsdbSnapReader* pReader) {
+ int32_t code = 0;
+
+ SDFileSet dFileSet = {.fid = pReader->fid};
+ SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &dFileSet, tDFileSetCmprFn, TD_GT);
+ if (pSet == NULL) return code;
+
+ pReader->fid = pSet->fid;
+ code = tsdbDataFReaderOpen(&pReader->pDataFReader, pReader->pTsdb, pSet);
+ if (code) goto _err;
+
+ pReader->pIter = NULL;
+ tRBTreeCreate(&pReader->rbt, tRowInfoCmprFn);
+
+ // .data file
+ SFDataIter* pIter = &pReader->aFDataIter[0];
+ pIter->type = SNAP_DATA_FILE_ITER;
+
+ code = tsdbReadBlockIdx(pReader->pDataFReader, pIter->aBlockIdx);
+ if (code) goto _err;
+
+ for (pIter->iBlockIdx = 0; pIter->iBlockIdx < taosArrayGetSize(pIter->aBlockIdx); pIter->iBlockIdx++) {
+ pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx);
+
+ code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock);
+ if (code) goto _err;
+
+ for (pIter->iBlock = 0; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) {
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk);
+
+ if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue;
+
+ code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData);
+ if (code) goto _err;
+
+ ASSERT(pIter->pBlockIdx->suid == pIter->bData.suid);
+ ASSERT(pIter->pBlockIdx->uid == pIter->bData.uid);
+
+ for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
+ int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
+
+ if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
+ pIter->rInfo.suid = pIter->pBlockIdx->suid;
+ pIter->rInfo.uid = pIter->pBlockIdx->uid;
+ pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
+ goto _add_iter_and_break;
+ }
+ }
+ }
+
+ continue;
+
+ _add_iter_and_break:
+ tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter);
+ break;
+ }
+
+ // .stt file
+ pIter = &pReader->aFDataIter[1];
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ pIter->type = SNAP_STT_FILE_ITER;
+ pIter->iStt = iStt;
+
+ code = tsdbReadSttBlk(pReader->pDataFReader, iStt, pIter->aSttBlk);
+ if (code) goto _err;
+
+ for (pIter->iSttBlk = 0; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
+ SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
+
+ if (pSttBlk->minVer > pReader->ever) continue;
+ if (pSttBlk->maxVer < pReader->sver) continue;
+
+ code = tsdbReadSttBlock(pReader->pDataFReader, iStt, pSttBlk, &pIter->bData);
+ if (code) goto _err;
+
+ for (pIter->iRow = 0; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
+ int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
+
+ if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
+ pIter->rInfo.suid = pIter->bData.suid;
+ pIter->rInfo.uid = pIter->bData.uid;
+ pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
+ goto _add_iter;
+ }
+ }
+ }
+
+ continue;
+
+ _add_iter:
+ tRBTreePut(&pReader->rbt, (SRBTreeNode*)pIter);
+ pIter++;
+ }
+
+ tsdbInfo("vgId:%d, vnode snapshot tsdb open data file to read for %s, fid:%d", TD_VID(pReader->pTsdb->pVnode),
+ pReader->pTsdb->path, pReader->fid);
+ return code;
+
+_err:
+ tsdbError("vgId:%d vnode snapshot tsdb snap read open file failed since %s", TD_VID(pReader->pTsdb->pVnode),
+ tstrerror(code));
+ return code;
+}
+
+static SRowInfo* tsdbSnapGetRow(STsdbSnapReader* pReader) { return pReader->pIter ? &pReader->pIter->rInfo : NULL; }
+
+static int32_t tsdbSnapNextRow(STsdbSnapReader* pReader) {
+ int32_t code = 0;
+
+ if (pReader->pIter) {
+ SFDataIter* pIter = pReader->pIter;
+
+ while (true) {
+ _find_row:
+ for (pIter->iRow++; pIter->iRow < pIter->bData.nRow; pIter->iRow++) {
+ int64_t rowVer = pIter->bData.aVersion[pIter->iRow];
+
+ if (rowVer >= pReader->sver && rowVer <= pReader->ever) {
+ pIter->rInfo.uid = pIter->bData.uid ? pIter->bData.uid : pIter->bData.aUid[pIter->iRow];
+ pIter->rInfo.row = tsdbRowFromBlockData(&pIter->bData, pIter->iRow);
+ goto _out;
+ }
+ }
+
+ if (pIter->type == SNAP_DATA_FILE_ITER) {
+ while (true) {
+ for (pIter->iBlock++; pIter->iBlock < pIter->mBlock.nItem; pIter->iBlock++) {
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pIter->mBlock, pIter->iBlock, &dataBlk, tGetDataBlk);
+
+ if (dataBlk.minVer > pReader->ever || dataBlk.maxVer < pReader->sver) continue;
+
+ code = tsdbReadDataBlockEx(pReader->pDataFReader, &dataBlk, &pIter->bData);
+ if (code) goto _err;
+
+ pIter->iRow = -1;
+ goto _find_row;
+ }
+
+ pIter->iBlockIdx++;
+ if (pIter->iBlockIdx >= taosArrayGetSize(pIter->aBlockIdx)) break;
+
+ pIter->pBlockIdx = (SBlockIdx*)taosArrayGet(pIter->aBlockIdx, pIter->iBlockIdx);
+ code = tsdbReadDataBlk(pReader->pDataFReader, pIter->pBlockIdx, &pIter->mBlock);
+ if (code) goto _err;
+ pIter->iBlock = -1;
+ }
+
+ pReader->pIter = NULL;
+ } else if (pIter->type == SNAP_STT_FILE_ITER) {
+ for (pIter->iSttBlk++; pIter->iSttBlk < taosArrayGetSize(pIter->aSttBlk); pIter->iSttBlk++) {
+ SSttBlk* pSttBlk = (SSttBlk*)taosArrayGet(pIter->aSttBlk, pIter->iSttBlk);
+
+ if (pSttBlk->minVer > pReader->ever || pSttBlk->maxVer < pReader->sver) continue;
+
+ code = tsdbReadSttBlock(pReader->pDataFReader, pIter->iStt, pSttBlk, &pIter->bData);
+ if (code) goto _err;
+
+ pIter->iRow = -1;
+ goto _find_row;
+ }
+
+ pReader->pIter = NULL;
+ } else {
+ ASSERT(0);
+ }
+ }
+
+ _out:
+ pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt);
+ if (pReader->pIter && pIter) {
+ int32_t c = tRowInfoCmprFn(&pReader->pIter->rInfo, &pIter->rInfo);
+ if (c > 0) {
+ tRBTreePut(&pReader->rbt, (SRBTreeNode*)pReader->pIter);
+ pReader->pIter = NULL;
+ } else {
+ ASSERT(c);
+ }
+ }
+ }
+
+ if (pReader->pIter == NULL) {
+ pReader->pIter = (SFDataIter*)tRBTreeMin(&pReader->rbt);
+ if (pReader->pIter) {
+ tRBTreeDrop(&pReader->rbt, (SRBTreeNode*)pReader->pIter);
+ }
+ }
+
+ return code;
+
+_err:
+ return code;
+}
+
+static int32_t tsdbSnapCmprData(STsdbSnapReader* pReader, uint8_t** ppData) {
+ int32_t code = 0;
+
+ ASSERT(pReader->bData.nRow);
+
+ int32_t aBufN[5] = {0};
+ code = tCmprBlockData(&pReader->bData, TWO_STAGE_COMP, NULL, NULL, pReader->aBuf, aBufN);
+ if (code) goto _exit;
+
+ int32_t size = aBufN[0] + aBufN[1] + aBufN[2] + aBufN[3];
+ *ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + size);
+ if (*ppData == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+ SSnapDataHdr* pHdr = (SSnapDataHdr*)*ppData;
+ pHdr->type = SNAP_DATA_TSDB;
+ pHdr->size = size;
+
+ memcpy(pHdr->data, pReader->aBuf[3], aBufN[3]);
+ memcpy(pHdr->data + aBufN[3], pReader->aBuf[2], aBufN[2]);
+ if (aBufN[1]) {
+ memcpy(pHdr->data + aBufN[3] + aBufN[2], pReader->aBuf[1], aBufN[1]);
+ }
+ if (aBufN[0]) {
+ memcpy(pHdr->data + aBufN[3] + aBufN[2] + aBufN[1], pReader->aBuf[0], aBufN[0]);
+ }
+
+_exit:
+ return code;
+}
+
static int32_t tsdbSnapReadData(STsdbSnapReader* pReader, uint8_t** ppData) {
int32_t code = 0;
STsdb* pTsdb = pReader->pTsdb;
while (true) {
if (pReader->pDataFReader == NULL) {
- // next
- SDFileSet dFileSet = {.fid = pReader->fid};
- SDFileSet* pSet = taosArraySearch(pReader->fs.aDFileSet, &dFileSet, tDFileSetCmprFn, TD_GT);
- if (pSet == NULL) goto _exit;
- pReader->fid = pSet->fid;
-
- // load
- code = tsdbDataFReaderOpen(&pReader->pDataFReader, pTsdb, pSet);
+ code = tsdbSnapReadOpenFile(pReader);
if (code) goto _err;
-
- code = tsdbReadBlockIdx(pReader->pDataFReader, pReader->aBlockIdx);
- if (code) goto _err;
-
- code = tsdbReadBlockL(pReader->pDataFReader, pReader->aBlockL);
- if (code) goto _err;
-
- // init
- pReader->iBlockIdx = 0;
- if (pReader->iBlockIdx < taosArrayGetSize(pReader->aBlockIdx)) {
- pReader->pBlockIdx = (SBlockIdx*)taosArrayGet(pReader->aBlockIdx, pReader->iBlockIdx);
-
- code = tsdbReadBlock(pReader->pDataFReader, pReader->pBlockIdx, &pReader->mBlock);
- if (code) goto _err;
-
- pReader->iBlock = 0;
- } else {
- pReader->pBlockIdx = NULL;
- }
-
- pReader->iBlockL = 0;
- while (true) {
- if (pReader->iBlockL >= taosArrayGetSize(pReader->aBlockL)) {
- pReader->pBlockL = NULL;
- break;
- }
-
- pReader->pBlockL = (SBlockL*)taosArrayGet(pReader->aBlockL, pReader->iBlockL);
- if (pReader->pBlockL->minVer <= pReader->ever && pReader->pBlockL->maxVer >= pReader->sver) {
- // TODO
- break;
- }
-
- pReader->iBlockL++;
- }
-
- tsdbInfo("vgId:%d, vnode snapshot tsdb open data file to read for %s, fid:%d", TD_VID(pTsdb->pVnode), pTsdb->path,
- pReader->fid);
}
- while (true) {
- if (pReader->pBlockIdx && pReader->pBlockL) {
- TABLEID id = {.suid = pReader->pBlockL->suid, .uid = pReader->pBlockL->minUid};
+ if (pReader->pDataFReader == NULL) break;
- ASSERT(0);
+ SRowInfo* pRowInfo = tsdbSnapGetRow(pReader);
+ if (pRowInfo == NULL) {
+ tsdbDataFReaderClose(&pReader->pDataFReader);
+ continue;
+ }
- // if (tTABLEIDCmprFn(pReader->pBlockIdx, &minId) < 0) {
- // // TODO
- // } else if (tTABLEIDCmprFn(pReader->pBlockIdx, &maxId) < 0) {
- // // TODO
- // } else {
- // // TODO
- // }
- } else if (pReader->pBlockIdx) {
- while (pReader->iBlock < pReader->mBlock.nItem) {
- SBlock block;
- tMapDataGetItemByIdx(&pReader->mBlock, pReader->iBlock, &block, tGetBlock);
+ TABLEID id = {.suid = pRowInfo->suid, .uid = pRowInfo->uid};
+ SBlockData* pBlockData = &pReader->bData;
- if (block.minVer <= pReader->ever && block.maxVer >= pReader->sver) {
- // load data (todo)
- }
+ code = tsdbUpdateTableSchema(pTsdb->pVnode->pMeta, id.suid, id.uid, &pReader->skmTable);
+ if (code) goto _err;
- // next
- pReader->iBlock++;
- if (*ppData) break;
- }
+ code = tBlockDataInit(pBlockData, id.suid, id.uid, pReader->skmTable.pTSchema);
+ if (code) goto _err;
- if (pReader->iBlock >= pReader->mBlock.nItem) {
- pReader->iBlockIdx++;
- if (pReader->iBlockIdx < taosArrayGetSize(pReader->aBlockIdx)) {
- pReader->pBlockIdx = (SBlockIdx*)taosArrayGet(pReader->aBlockIdx, pReader->iBlockIdx);
+ while (pRowInfo->suid == id.suid && pRowInfo->uid == id.uid) {
+ code = tBlockDataAppendRow(pBlockData, &pRowInfo->row, NULL, pRowInfo->uid);
+ if (code) goto _err;
- code = tsdbReadBlock(pReader->pDataFReader, pReader->pBlockIdx, &pReader->mBlock);
- if (code) goto _err;
+ code = tsdbSnapNextRow(pReader);
+ if (code) goto _err;
- pReader->iBlock = 0;
- } else {
- pReader->pBlockIdx = NULL;
- }
- }
-
- if (*ppData) goto _exit;
- } else if (pReader->pBlockL) {
- while (pReader->pBlockL) {
- if (pReader->pBlockL->minVer <= pReader->ever && pReader->pBlockL->maxVer >= pReader->sver) {
- // load data (todo)
- }
-
- // next
- pReader->iBlockL++;
- if (pReader->iBlockL < taosArrayGetSize(pReader->aBlockL)) {
- pReader->pBlockL = (SBlockL*)taosArrayGetSize(pReader->aBlockL);
- } else {
- pReader->pBlockL = NULL;
- }
-
- if (*ppData) goto _exit;
- }
- } else {
+ pRowInfo = tsdbSnapGetRow(pReader);
+ if (pRowInfo == NULL) {
tsdbDataFReaderClose(&pReader->pDataFReader);
break;
}
+
+ if (pBlockData->nRow >= 4096) break;
}
+
+ code = tsdbSnapCmprData(pReader, ppData);
+ if (code) goto _err;
+
+ break;
}
-_exit:
return code;
_err:
@@ -216,7 +394,6 @@ static int32_t tsdbSnapReadDel(STsdbSnapReader* pReader, uint8_t** ppData) {
size += tPutDelData(NULL, pDelData);
}
}
-
if (size == 0) continue;
// org data
@@ -292,23 +469,33 @@ int32_t tsdbSnapReaderOpen(STsdb* pTsdb, int64_t sver, int64_t ever, int8_t type
goto _err;
}
+ // data
pReader->fid = INT32_MIN;
- pReader->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
- if (pReader->aBlockIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
+ for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) {
+ SFDataIter* pIter = &pReader->aFDataIter[iIter];
+
+ if (iIter == 0) {
+ pIter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
+ if (pIter->aBlockIdx == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ } else {
+ pIter->aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
+ if (pIter->aSttBlk == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ }
+
+ code = tBlockDataCreate(&pIter->bData);
+ if (code) goto _err;
}
- pReader->aBlockL = taosArrayInit(0, sizeof(SBlockL));
- if (pReader->aBlockL == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- pReader->mBlock = tMapDataInit();
- code = tBlockDataCreate(&pReader->oBlockData);
- if (code) goto _err;
- code = tBlockDataCreate(&pReader->nBlockData);
+
+ code = tBlockDataCreate(&pReader->bData);
if (code) goto _err;
+ // del
pReader->aDelIdx = taosArrayInit(0, sizeof(SDelIdx));
if (pReader->aDelIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -335,18 +522,26 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
int32_t code = 0;
STsdbSnapReader* pReader = *ppReader;
- if (pReader->pDataFReader) {
- tsdbDataFReaderClose(&pReader->pDataFReader);
- }
- taosArrayDestroy(pReader->aBlockL);
- taosArrayDestroy(pReader->aBlockIdx);
- tMapDataClear(&pReader->mBlock);
- tBlockDataDestroy(&pReader->oBlockData, 1);
- tBlockDataDestroy(&pReader->nBlockData, 1);
+ // data
+ if (pReader->pDataFReader) tsdbDataFReaderClose(&pReader->pDataFReader);
+ for (int32_t iIter = 0; iIter < sizeof(pReader->aFDataIter) / sizeof(pReader->aFDataIter[0]); iIter++) {
+ SFDataIter* pIter = &pReader->aFDataIter[iIter];
- if (pReader->pDelFReader) {
- tsdbDelFReaderClose(&pReader->pDelFReader);
+ if (iIter == 0) {
+ taosArrayDestroy(pIter->aBlockIdx);
+ tMapDataClear(&pIter->mBlock);
+ } else {
+ taosArrayDestroy(pIter->aSttBlk);
+ }
+
+ tBlockDataDestroy(&pIter->bData, 1);
}
+
+ tBlockDataDestroy(&pReader->bData, 1);
+ tTSchemaDestroy(pReader->skmTable.pTSchema);
+
+ // del
+ if (pReader->pDelFReader) tsdbDelFReaderClose(&pReader->pDelFReader);
taosArrayDestroy(pReader->aDelIdx);
taosArrayDestroy(pReader->aDelData);
@@ -354,6 +549,10 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
tsdbInfo("vgId:%d, vnode snapshot tsdb reader closed for %s", TD_VID(pReader->pTsdb->pVnode), pReader->pTsdb->path);
+ for (int32_t iBuf = 0; iBuf < sizeof(pReader->aBuf) / sizeof(pReader->aBuf[0]); iBuf++) {
+ tFree(pReader->aBuf[iBuf]);
+ }
+
taosMemoryFree(pReader);
*ppReader = NULL;
return code;
@@ -410,40 +609,37 @@ struct STsdbSnapWriter {
STsdbFS fs;
// config
- int32_t minutes;
- int8_t precision;
- int32_t minRow;
- int32_t maxRow;
- int8_t cmprAlg;
- int64_t commitID;
-
+ int32_t minutes;
+ int8_t precision;
+ int32_t minRow;
+ int32_t maxRow;
+ int8_t cmprAlg;
+ int64_t commitID;
uint8_t* aBuf[5];
+
// for data file
SBlockData bData;
-
- int32_t fid;
- SDataFReader* pDataFReader;
- SArray* aBlockIdx; // SArray
- int32_t iBlockIdx;
- SBlockIdx* pBlockIdx;
- SMapData mBlock; // SMapData
- int32_t iBlock;
- SBlockData* pBlockData;
- int32_t iRow;
- SBlockData bDataR;
- SArray* aBlockL; // SArray
- int32_t iBlockL;
- SBlockData lDataR;
-
- SDataFWriter* pDataFWriter;
- SBlockIdx* pBlockIdxW; // NULL when no committing table
- SBlock blockW;
- SBlockData bDataW;
- SBlockIdx blockIdxW;
-
- SMapData mBlockW; // SMapData
- SArray* aBlockIdxW; // SArray
- SArray* aBlockLW; // SArray
+ int32_t fid;
+ TABLEID id;
+ SSkmInfo skmTable;
+ struct {
+ SDataFReader* pReader;
+ SArray* aBlockIdx;
+ int32_t iBlockIdx;
+ SBlockIdx* pBlockIdx;
+ SMapData mDataBlk;
+ int32_t iDataBlk;
+ SBlockData bData;
+ int32_t iRow;
+ } dReader;
+ struct {
+ SDataFWriter* pWriter;
+ SArray* aBlockIdx;
+ SMapData mDataBlk;
+ SArray* aSttBlk;
+ SBlockData bData;
+ SBlockData sData;
+ } dWriter;
// for del file
SDelFReader* pDelFReader;
@@ -454,518 +650,447 @@ struct STsdbSnapWriter {
SArray* aDelIdxW;
};
+// SNAP_DATA_TSDB
+extern int32_t tsdbWriteDataBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SMapData* mDataBlk, int8_t cmprAlg);
+extern int32_t tsdbWriteSttBlock(SDataFWriter* pWriter, SBlockData* pBlockData, SArray* aSttBlk, int8_t cmprAlg);
+
+static int32_t tsdbSnapNextTableData(STsdbSnapWriter* pWriter) {
+ int32_t code = 0;
+
+ ASSERT(pWriter->dReader.iRow >= pWriter->dReader.bData.nRow);
+
+ if (pWriter->dReader.iBlockIdx < taosArrayGetSize(pWriter->dReader.aBlockIdx)) {
+ pWriter->dReader.pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->dReader.aBlockIdx, pWriter->dReader.iBlockIdx);
+
+ code = tsdbReadDataBlk(pWriter->dReader.pReader, pWriter->dReader.pBlockIdx, &pWriter->dReader.mDataBlk);
+ if (code) goto _exit;
+
+ pWriter->dReader.iBlockIdx++;
+ } else {
+ pWriter->dReader.pBlockIdx = NULL;
+ tMapDataReset(&pWriter->dReader.mDataBlk);
+ }
+ pWriter->dReader.iDataBlk = 0; // point to the next one
+ tBlockDataReset(&pWriter->dReader.bData);
+ pWriter->dReader.iRow = 0;
+
+_exit:
+ return code;
+}
+
+static int32_t tsdbSnapWriteCopyData(STsdbSnapWriter* pWriter, TABLEID* pId) {
+ int32_t code = 0;
+
+ while (true) {
+ if (pWriter->dReader.pBlockIdx == NULL) break;
+ if (tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, pId) >= 0) break;
+
+ SBlockIdx blkIdx = *pWriter->dReader.pBlockIdx;
+ code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dReader.mDataBlk, &blkIdx);
+ if (code) goto _exit;
+
+ if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blkIdx) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+ code = tsdbSnapNextTableData(pWriter);
+ if (code) goto _exit;
+ }
+
+_exit:
+ return code;
+}
+
+static int32_t tsdbSnapWriteTableDataStart(STsdbSnapWriter* pWriter, TABLEID* pId) {
+ int32_t code = 0;
+
+ code = tsdbSnapWriteCopyData(pWriter, pId);
+ if (code) goto _err;
+
+ pWriter->id.suid = pId->suid;
+ pWriter->id.uid = pId->uid;
+
+ code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pId->suid, pId->uid, &pWriter->skmTable);
+ if (code) goto _err;
+
+ tMapDataReset(&pWriter->dWriter.mDataBlk);
+ code = tBlockDataInit(&pWriter->dWriter.bData, pId->suid, pId->uid, pWriter->skmTable.pTSchema);
+ if (code) goto _err;
+
+ return code;
+
+_err:
+ tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ return code;
+}
+
static int32_t tsdbSnapWriteTableDataEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
- ASSERT(pWriter->pDataFWriter);
+ if (pWriter->id.suid == 0 && pWriter->id.uid == 0) return code;
- if (pWriter->pBlockIdxW == NULL) goto _exit;
+ int32_t c = 1;
+ if (pWriter->dReader.pBlockIdx) {
+ c = tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &pWriter->id);
+ ASSERT(c >= 0);
+ }
- // consume remain rows
- if (pWriter->pBlockData) {
- ASSERT(pWriter->iRow < pWriter->pBlockData->nRow);
- while (pWriter->iRow < pWriter->pBlockData->nRow) {
- code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow), NULL,
- 0); // todo
+ if (c == 0) {
+ SBlockData* pBData = &pWriter->dWriter.bData;
+
+ for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) {
+ TSDBROW row = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow);
+
+ code = tBlockDataAppendRow(pBData, &row, NULL, pWriter->id.uid);
if (code) goto _err;
- if (pWriter->bDataW.nRow >= pWriter->maxRow * 4 / 5) {
- // pWriter->blockW.last = 0;
- // code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
- // &pWriter->blockW, pWriter->cmprAlg);
+ if (pBData->nRow >= pWriter->maxRow) {
+ code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg);
if (code) goto _err;
-
- code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock);
- if (code) goto _err;
-
- tBlockReset(&pWriter->blockW);
- tBlockDataClear(&pWriter->bDataW);
- }
-
- pWriter->iRow++;
- }
- }
-
- // write remain data if has
- if (pWriter->bDataW.nRow > 0) {
- // pWriter->blockW.last = 0;
- if (pWriter->bDataW.nRow < pWriter->minRow) {
- if (pWriter->iBlock > pWriter->mBlock.nItem) {
- // pWriter->blockW.last = 1;
}
}
- // code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
- // &pWriter->blockW, pWriter->cmprAlg);
- // if (code) goto _err;
-
- code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock);
- if (code) goto _err;
- }
-
- while (true) {
- if (pWriter->iBlock >= pWriter->mBlock.nItem) break;
-
- SBlock block;
- tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetBlock);
-
- // if (block.last) {
- // code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
- // if (code) goto _err;
-
- // tBlockReset(&block);
- // block.last = 1;
- // code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pWriter->pBlockIdxW, &block,
- // pWriter->cmprAlg);
- // if (code) goto _err;
- // }
-
- code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock);
+ code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, pBData, &pWriter->dWriter.mDataBlk, pWriter->cmprAlg);
if (code) goto _err;
- pWriter->iBlock++;
- }
+ for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) {
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk);
- // SBlock
- // code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, NULL, pWriter->pBlockIdxW);
- // if (code) goto _err;
-
- // SBlockIdx
- if (taosArrayPush(pWriter->aBlockIdxW, pWriter->pBlockIdxW) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
-
-_exit:
- tsdbInfo("vgId:%d, tsdb snapshot write table data end for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb snapshot write table data end for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path, tstrerror(code));
- return code;
-}
-
-static int32_t tsdbSnapMoveWriteTableData(STsdbSnapWriter* pWriter, SBlockIdx* pBlockIdx) {
- int32_t code = 0;
-
- code = tsdbReadBlock(pWriter->pDataFReader, pBlockIdx, &pWriter->mBlock);
- if (code) goto _err;
-
- // SBlockData
- SBlock block;
- tMapDataReset(&pWriter->mBlockW);
- for (int32_t iBlock = 0; iBlock < pWriter->mBlock.nItem; iBlock++) {
- tMapDataGetItemByIdx(&pWriter->mBlock, iBlock, &block, tGetBlock);
-
- // if (block.last) {
- // code = tsdbReadBlockData(pWriter->pDataFReader, pBlockIdx, &block, &pWriter->bDataR, NULL, NULL);
- // if (code) goto _err;
-
- // tBlockReset(&block);
- // block.last = 1;
- // code =
- // tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataR, NULL, NULL, pBlockIdx, &block,
- // pWriter->cmprAlg);
- // if (code) goto _err;
- // }
-
- code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock);
- if (code) goto _err;
- }
-
- // SBlock
- SBlockIdx blockIdx = {.suid = pBlockIdx->suid, .uid = pBlockIdx->uid};
- code = tsdbWriteBlock(pWriter->pDataFWriter, &pWriter->mBlockW, &blockIdx);
- if (code) goto _err;
-
- // SBlockIdx
- if (taosArrayPush(pWriter->aBlockIdxW, &blockIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
-
-_exit:
- return code;
-
-_err:
- tsdbError("vgId:%d, tsdb snapshot move write table data for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path, tstrerror(code));
- return code;
-}
-
-static int32_t tsdbSnapWriteTableDataImpl(STsdbSnapWriter* pWriter) {
- int32_t code = 0;
- SBlockData* pBlockData = &pWriter->bData;
- int32_t iRow = 0;
- TSDBROW row;
- TSDBROW* pRow = &row;
-
- // // correct schema
- // code = tBlockDataCorrectSchema(&pWriter->bDataW, pBlockData);
- // if (code) goto _err;
-
- // loop to merge
- *pRow = tsdbRowFromBlockData(pBlockData, iRow);
- while (true) {
- if (pRow == NULL) break;
-
- if (pWriter->pBlockData) {
- ASSERT(pWriter->iRow < pWriter->pBlockData->nRow);
-
- int32_t c = tsdbRowCmprFn(pRow, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow));
-
- ASSERT(c);
-
- if (c < 0) {
- // code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
- // if (code) goto _err;
-
- iRow++;
- if (iRow < pWriter->pBlockData->nRow) {
- *pRow = tsdbRowFromBlockData(pBlockData, iRow);
- } else {
- pRow = NULL;
- }
- } else if (c > 0) {
- // code = tBlockDataAppendRow(&pWriter->bDataW, &tsdbRowFromBlockData(pWriter->pBlockData, pWriter->iRow),
- // NULL); if (code) goto _err;
-
- pWriter->iRow++;
- if (pWriter->iRow >= pWriter->pBlockData->nRow) {
- pWriter->pBlockData = NULL;
- }
- }
- } else {
- TSDBKEY key = TSDBROW_KEY(pRow);
-
- while (true) {
- if (pWriter->iBlock >= pWriter->mBlock.nItem) break;
-
- SBlock block;
- int32_t c;
-
- tMapDataGetItemByIdx(&pWriter->mBlock, pWriter->iBlock, &block, tGetBlock);
-
- // if (block.last) {
- // pWriter->pBlockData = &pWriter->bDataR;
-
- // code = tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL,
- // NULL); if (code) goto _err; pWriter->iRow = 0;
-
- // pWriter->iBlock++;
- // break;
- // }
-
- c = tsdbKeyCmprFn(&block.maxKey, &key);
-
- ASSERT(c);
-
- if (c < 0) {
- if (pWriter->bDataW.nRow) {
- // pWriter->blockW.last = 0;
- // code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
- // &pWriter->blockW, pWriter->cmprAlg);
- // if (code) goto _err;
-
- code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock);
- if (code) goto _err;
-
- tBlockReset(&pWriter->blockW);
- tBlockDataClear(&pWriter->bDataW);
- }
-
- code = tMapDataPutItem(&pWriter->mBlockW, &block, tPutBlock);
- if (code) goto _err;
-
- pWriter->iBlock++;
- } else {
- c = tsdbKeyCmprFn(&tBlockDataLastKey(pBlockData), &block.minKey);
-
- ASSERT(c);
-
- if (c > 0) {
- pWriter->pBlockData = &pWriter->bDataR;
- // code =
- // tsdbReadBlockData(pWriter->pDataFReader, pWriter->pBlockIdx, &block, pWriter->pBlockData, NULL,
- // NULL);
- // if (code) goto _err;
- pWriter->iRow = 0;
-
- pWriter->iBlock++;
- }
- break;
- }
- }
-
- if (pWriter->pBlockData) continue;
-
- // code = tBlockDataAppendRow(&pWriter->bDataW, pRow, NULL);
- // if (code) goto _err;
-
- iRow++;
- if (iRow < pBlockData->nRow) {
- *pRow = tsdbRowFromBlockData(pBlockData, iRow);
- } else {
- pRow = NULL;
- }
- }
-
- _check_write:
- if (pWriter->bDataW.nRow < pWriter->maxRow * 4 / 5) continue;
-
- _write_block:
- // code = tsdbWriteBlockData(pWriter->pDataFWriter, &pWriter->bDataW, NULL, NULL, pWriter->pBlockIdxW,
- // &pWriter->blockW, pWriter->cmprAlg);
- // if (code) goto _err;
-
- code = tMapDataPutItem(&pWriter->mBlockW, &pWriter->blockW, tPutBlock);
- if (code) goto _err;
-
- tBlockReset(&pWriter->blockW);
- tBlockDataClear(&pWriter->bDataW);
- }
-
- return code;
-
-_err:
- tsdbError("vgId:%d, vnode snapshot tsdb write table data impl for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path, tstrerror(code));
- return code;
-}
-
-static int32_t tsdbSnapWriteTableData(STsdbSnapWriter* pWriter, TABLEID id) {
- int32_t code = 0;
- SBlockData* pBlockData = &pWriter->bData;
- TSDBKEY keyFirst = tBlockDataFirstKey(pBlockData);
- TSDBKEY keyLast = tBlockDataLastKey(pBlockData);
-
- // end last table write if should
- if (pWriter->pBlockIdxW) {
- int32_t c = tTABLEIDCmprFn(pWriter->pBlockIdxW, &id);
- if (c < 0) {
- // end
- code = tsdbSnapWriteTableDataEnd(pWriter);
+ code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk);
if (code) goto _err;
+ }
- // reset
- pWriter->pBlockIdxW = NULL;
- } else if (c > 0) {
- ASSERT(0);
+ code = tsdbSnapNextTableData(pWriter);
+ if (code) goto _err;
+ }
+
+ if (pWriter->dWriter.mDataBlk.nItem) {
+ SBlockIdx blockIdx = {.suid = pWriter->id.suid, .uid = pWriter->id.uid};
+ code = tsdbWriteDataBlk(pWriter->dWriter.pWriter, &pWriter->dWriter.mDataBlk, &blockIdx);
+
+ if (taosArrayPush(pWriter->dWriter.aBlockIdx, &blockIdx) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
}
}
- // start new table data write if need
- if (pWriter->pBlockIdxW == NULL) {
- // write table data ahead
- while (true) {
- if (pWriter->iBlockIdx >= taosArrayGetSize(pWriter->aBlockIdx)) break;
+ pWriter->id.suid = 0;
+ pWriter->id.uid = 0;
- SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx);
- int32_t c = tTABLEIDCmprFn(pBlockIdx, &id);
-
- if (c >= 0) break;
-
- code = tsdbSnapMoveWriteTableData(pWriter, pBlockIdx);
- if (code) goto _err;
-
- pWriter->iBlockIdx++;
- }
-
- // reader
- pWriter->pBlockIdx = NULL;
- if (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) {
- ASSERT(pWriter->pDataFReader);
-
- SBlockIdx* pBlockIdx = (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx);
- int32_t c = tTABLEIDCmprFn(pBlockIdx, &id);
-
- ASSERT(c >= 0);
-
- if (c == 0) {
- pWriter->pBlockIdx = pBlockIdx;
- pWriter->iBlockIdx++;
- }
- }
-
- if (pWriter->pBlockIdx) {
- code = tsdbReadBlock(pWriter->pDataFReader, pWriter->pBlockIdx, &pWriter->mBlock);
- if (code) goto _err;
- } else {
- tMapDataReset(&pWriter->mBlock);
- }
- pWriter->iBlock = 0;
- pWriter->pBlockData = NULL;
- pWriter->iRow = 0;
-
- // writer
- pWriter->pBlockIdxW = &pWriter->blockIdxW;
- pWriter->pBlockIdxW->suid = id.suid;
- pWriter->pBlockIdxW->uid = id.uid;
-
- tBlockReset(&pWriter->blockW);
- tBlockDataReset(&pWriter->bDataW);
- tMapDataReset(&pWriter->mBlockW);
- }
-
- ASSERT(pWriter->pBlockIdxW && pWriter->pBlockIdxW->suid == id.suid && pWriter->pBlockIdxW->uid == id.uid);
- ASSERT(pWriter->pBlockIdx == NULL || (pWriter->pBlockIdx->suid == id.suid && pWriter->pBlockIdx->uid == id.uid));
-
- code = tsdbSnapWriteTableDataImpl(pWriter);
- if (code) goto _err;
-
-_exit:
- tsdbDebug("vgId:%d, vnode snapshot tsdb write data impl for %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path);
return code;
_err:
- tsdbError("vgId:%d, vnode snapshot tsdb write data impl for %s failed since %s", TD_VID(pWriter->pTsdb->pVnode),
- pWriter->pTsdb->path, tstrerror(code));
return code;
}
-static int32_t tsdbSnapWriteDataEnd(STsdbSnapWriter* pWriter) {
+static int32_t tsdbSnapWriteOpenFile(STsdbSnapWriter* pWriter, int32_t fid) {
int32_t code = 0;
STsdb* pTsdb = pWriter->pTsdb;
- if (pWriter->pDataFWriter == NULL) goto _exit;
+ ASSERT(pWriter->dWriter.pWriter == NULL);
+
+ pWriter->fid = fid;
+ pWriter->id = (TABLEID){0};
+ SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
+
+ // Reader
+ if (pSet) {
+ code = tsdbDataFReaderOpen(&pWriter->dReader.pReader, pWriter->pTsdb, pSet);
+ if (code) goto _err;
+
+ code = tsdbReadBlockIdx(pWriter->dReader.pReader, pWriter->dReader.aBlockIdx);
+ if (code) goto _err;
+ } else {
+ ASSERT(pWriter->dReader.pReader == NULL);
+ taosArrayClear(pWriter->dReader.aBlockIdx);
+ }
+ pWriter->dReader.iBlockIdx = 0; // point to the next one
+ code = tsdbSnapNextTableData(pWriter);
+ if (code) goto _err;
+
+ // Writer
+ SHeadFile fHead = {.commitID = pWriter->commitID};
+ SDataFile fData = {.commitID = pWriter->commitID};
+ SSmaFile fSma = {.commitID = pWriter->commitID};
+ SSttFile fStt = {.commitID = pWriter->commitID};
+ SDFileSet wSet = {.fid = pWriter->fid, .pHeadF = &fHead, .pDataF = &fData, .pSmaF = &fSma};
+ if (pSet) {
+ wSet.diskId = pSet->diskId;
+ fData = *pSet->pDataF;
+ fSma = *pSet->pSmaF;
+ for (int32_t iStt = 0; iStt < pSet->nSttF; iStt++) {
+ wSet.aSttF[iStt] = pSet->aSttF[iStt];
+ }
+ wSet.nSttF = pSet->nSttF + 1; // TODO: fix pSet->nSttF == pTsdb->maxFile
+ } else {
+ SDiskID did = {0};
+ tfsAllocDisk(pTsdb->pVnode->pTfs, 0, &did);
+ tfsMkdirRecurAt(pTsdb->pVnode->pTfs, pTsdb->path, did);
+ wSet.diskId = did;
+ wSet.nSttF = 1;
+ }
+ wSet.aSttF[wSet.nSttF - 1] = &fStt;
+
+ code = tsdbDataFWriterOpen(&pWriter->dWriter.pWriter, pWriter->pTsdb, &wSet);
+ if (code) goto _err;
+ taosArrayClear(pWriter->dWriter.aBlockIdx);
+ tMapDataReset(&pWriter->dWriter.mDataBlk);
+ taosArrayClear(pWriter->dWriter.aSttBlk);
+ tBlockDataReset(&pWriter->dWriter.bData);
+ tBlockDataReset(&pWriter->dWriter.sData);
+
+ return code;
+
+_err:
+ return code;
+}
+
+static int32_t tsdbSnapWriteCloseFile(STsdbSnapWriter* pWriter) {
+ int32_t code = 0;
+
+ ASSERT(pWriter->dWriter.pWriter);
- // finish current table
code = tsdbSnapWriteTableDataEnd(pWriter);
if (code) goto _err;
- // move remain table
- while (pWriter->iBlockIdx < taosArrayGetSize(pWriter->aBlockIdx)) {
- code = tsdbSnapMoveWriteTableData(pWriter, (SBlockIdx*)taosArrayGet(pWriter->aBlockIdx, pWriter->iBlockIdx));
- if (code) goto _err;
-
- pWriter->iBlockIdx++;
- }
-
- // write remain stuff
- if (taosArrayGetSize(pWriter->aBlockLW) > 0) {
- code = tsdbWriteBlockL(pWriter->pDataFWriter, pWriter->aBlockIdxW);
- if (code) goto _err;
- }
-
- if (taosArrayGetSize(pWriter->aBlockIdx) > 0) {
- code = tsdbWriteBlockIdx(pWriter->pDataFWriter, pWriter->aBlockIdxW);
- if (code) goto _err;
- }
-
- code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->pDataFWriter->wSet);
+ // copy remain table data
+ TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX};
+ code = tsdbSnapWriteCopyData(pWriter, &id);
if (code) goto _err;
- code = tsdbDataFWriterClose(&pWriter->pDataFWriter, 1);
+ code =
+ tsdbWriteSttBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.sData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
if (code) goto _err;
- if (pWriter->pDataFReader) {
- code = tsdbDataFReaderClose(&pWriter->pDataFReader);
+ // Indices
+ code = tsdbWriteBlockIdx(pWriter->dWriter.pWriter, pWriter->dWriter.aBlockIdx);
+ if (code) goto _err;
+
+ code = tsdbWriteSttBlk(pWriter->dWriter.pWriter, pWriter->dWriter.aSttBlk);
+ if (code) goto _err;
+
+ code = tsdbUpdateDFileSetHeader(pWriter->dWriter.pWriter);
+ if (code) goto _err;
+
+ code = tsdbFSUpsertFSet(&pWriter->fs, &pWriter->dWriter.pWriter->wSet);
+ if (code) goto _err;
+
+ code = tsdbDataFWriterClose(&pWriter->dWriter.pWriter, 1);
+ if (code) goto _err;
+
+ if (pWriter->dReader.pReader) {
+ code = tsdbDataFReaderClose(&pWriter->dReader.pReader);
if (code) goto _err;
}
_exit:
- tsdbInfo("vgId:%d, vnode snapshot tsdb writer data end for %s", TD_VID(pTsdb->pVnode), pTsdb->path);
return code;
_err:
- tsdbError("vgId:%d, vnode snapshot tsdb writer data end for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
- tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbSnapWriteToDataFile(STsdbSnapWriter* pWriter, int32_t iRow, int8_t* done) {
+ int32_t code = 0;
+
+ SBlockData* pBData = &pWriter->bData;
+ TABLEID id = {.suid = pBData->suid, .uid = pBData->uid ? pBData->uid : pBData->aUid[iRow]};
+ TSDBROW row = tsdbRowFromBlockData(pBData, iRow);
+ TSDBKEY key = TSDBROW_KEY(&row);
+
+ *done = 0;
+ while (pWriter->dReader.iRow < pWriter->dReader.bData.nRow ||
+ pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem) {
+ // Merge row by row
+ for (; pWriter->dReader.iRow < pWriter->dReader.bData.nRow; pWriter->dReader.iRow++) {
+ TSDBROW trow = tsdbRowFromBlockData(&pWriter->dReader.bData, pWriter->dReader.iRow);
+ TSDBKEY tKey = TSDBROW_KEY(&trow);
+
+ ASSERT(pWriter->dReader.bData.suid == id.suid && pWriter->dReader.bData.uid == id.uid);
+
+ int32_t c = tsdbKeyCmprFn(&key, &tKey);
+ if (c < 0) {
+ code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid);
+ if (code) goto _err;
+ } else if (c > 0) {
+ code = tBlockDataAppendRow(&pWriter->dWriter.bData, &trow, NULL, id.uid);
+ if (code) goto _err;
+ } else {
+ ASSERT(0);
+ }
+
+ if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) {
+ code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
+ pWriter->cmprAlg);
+ if (code) goto _err;
+ }
+
+ if (c < 0) {
+ *done = 1;
+ goto _exit;
+ }
+ }
+
+ // Merge row by block
+ SDataBlk tDataBlk = {.minKey = key, .maxKey = key};
+ for (; pWriter->dReader.iDataBlk < pWriter->dReader.mDataBlk.nItem; pWriter->dReader.iDataBlk++) {
+ SDataBlk dataBlk;
+ tMapDataGetItemByIdx(&pWriter->dReader.mDataBlk, pWriter->dReader.iDataBlk, &dataBlk, tGetDataBlk);
+
+ int32_t c = tDataBlkCmprFn(&dataBlk, &tDataBlk);
+ if (c < 0) {
+ code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
+ pWriter->cmprAlg);
+ if (code) goto _err;
+
+ code = tMapDataPutItem(&pWriter->dWriter.mDataBlk, &dataBlk, tPutDataBlk);
+ if (code) goto _err;
+ } else if (c > 0) {
+ code = tBlockDataAppendRow(&pWriter->dWriter.bData, &row, NULL, id.uid);
+ if (code) goto _err;
+
+ if (pWriter->dWriter.bData.nRow >= pWriter->maxRow) {
+ code = tsdbWriteDataBlock(pWriter->dWriter.pWriter, &pWriter->dWriter.bData, &pWriter->dWriter.mDataBlk,
+ pWriter->cmprAlg);
+ if (code) goto _err;
+ }
+
+ *done = 1;
+ goto _exit;
+ } else {
+ code = tsdbReadDataBlockEx(pWriter->dReader.pReader, &dataBlk, &pWriter->dReader.bData);
+ if (code) goto _err;
+ pWriter->dReader.iRow = 0;
+
+ pWriter->dReader.iDataBlk++;
+ break;
+ }
+ }
+ }
+
+_exit:
+ return code;
+
+_err:
+ tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
+ return code;
+}
+
+static int32_t tsdbSnapWriteToSttFile(STsdbSnapWriter* pWriter, int32_t iRow) {
+ int32_t code = 0;
+
+ TABLEID id = {.suid = pWriter->bData.suid,
+ .uid = pWriter->bData.uid ? pWriter->bData.uid : pWriter->bData.aUid[iRow]};
+ TSDBROW row = tsdbRowFromBlockData(&pWriter->bData, iRow);
+ SBlockData* pBData = &pWriter->dWriter.sData;
+
+ if (pBData->suid || pBData->uid) {
+ if (!TABLE_SAME_SCHEMA(pBData->suid, pBData->uid, id.suid, id.uid)) {
+ code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
+ if (code) goto _err;
+
+ pBData->suid = 0;
+ pBData->uid = 0;
+ }
+ }
+
+ if (pBData->suid == 0 && pBData->uid == 0) {
+ code = tsdbUpdateTableSchema(pWriter->pTsdb->pVnode->pMeta, pWriter->id.suid, pWriter->id.uid, &pWriter->skmTable);
+ if (code) goto _err;
+
+ code = tBlockDataInit(pBData, pWriter->id.suid, pWriter->id.suid ? 0 : pWriter->id.uid, pWriter->skmTable.pTSchema);
+ if (code) goto _err;
+ }
+
+ code = tBlockDataAppendRow(pBData, &row, NULL, id.uid);
+ if (code) goto _err;
+
+ if (pBData->nRow >= pWriter->maxRow) {
+ code = tsdbWriteSttBlock(pWriter->dWriter.pWriter, pBData, pWriter->dWriter.aSttBlk, pWriter->cmprAlg);
+ if (code) goto _err;
+ }
+
+_exit:
+ return code;
+
+_err:
+ return code;
+}
+
+static int32_t tsdbSnapWriteRowData(STsdbSnapWriter* pWriter, int32_t iRow) {
+ int32_t code = 0;
+
+ SBlockData* pBlockData = &pWriter->bData;
+ TABLEID id = {.suid = pBlockData->suid, .uid = pBlockData->uid ? pBlockData->uid : pBlockData->aUid[iRow]};
+
+ // End last table data write if need
+ if (tTABLEIDCmprFn(&pWriter->id, &id) != 0) {
+ code = tsdbSnapWriteTableDataEnd(pWriter);
+ if (code) goto _err;
+ }
+
+ // Start new table data write if need
+ if (pWriter->id.suid == 0 && pWriter->id.uid == 0) {
+ code = tsdbSnapWriteTableDataStart(pWriter, &id);
+ if (code) goto _err;
+ }
+
+ // Merge with .data file data
+ int8_t done = 0;
+ if (pWriter->dReader.pBlockIdx && tTABLEIDCmprFn(pWriter->dReader.pBlockIdx, &id) == 0) {
+ code = tsdbSnapWriteToDataFile(pWriter, iRow, &done);
+ if (code) goto _err;
+ }
+
+ // Append to the .stt data block (todo: check if need to set/reload sst block)
+ if (!done) {
+ code = tsdbSnapWriteToSttFile(pWriter, iRow);
+ if (code) goto _err;
+ }
+
+_exit:
+ return code;
+
+_err:
+ tsdbError("vgId:%d %s failed since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, tstrerror(code));
return code;
}
static int32_t tsdbSnapWriteData(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
- int32_t code = 0;
- STsdb* pTsdb = pWriter->pTsdb;
- SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
- TABLEID id = *(TABLEID*)(pData + sizeof(SSnapDataHdr));
- int64_t n;
-
- // decode
+ int32_t code = 0;
+ STsdb* pTsdb = pWriter->pTsdb;
SBlockData* pBlockData = &pWriter->bData;
- code = tDecmprBlockData(pData + sizeof(SSnapDataHdr) + sizeof(TABLEID), pHdr->size - sizeof(TABLEID), pBlockData,
- pWriter->aBuf);
+
+ // Decode data
+ SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
+ code = tDecmprBlockData(pHdr->data, pHdr->size, pBlockData, pWriter->aBuf);
if (code) goto _err;
- // open file
- TSDBKEY keyFirst = {.version = pBlockData->aVersion[0], .ts = pBlockData->aTSKEY[0]};
- TSDBKEY keyLast = {.version = pBlockData->aVersion[pBlockData->nRow - 1],
- .ts = pBlockData->aTSKEY[pBlockData->nRow - 1]};
+ ASSERT(pBlockData->nRow > 0);
- int32_t fid = tsdbKeyFid(keyFirst.ts, pWriter->minutes, pWriter->precision);
- ASSERT(fid == tsdbKeyFid(keyLast.ts, pWriter->minutes, pWriter->precision));
- if (pWriter->pDataFWriter == NULL || pWriter->fid != fid) {
- // end last file data write if need
- code = tsdbSnapWriteDataEnd(pWriter);
- if (code) goto _err;
+ // Loop to handle each row
+ for (int32_t iRow = 0; iRow < pBlockData->nRow; iRow++) {
+ TSKEY ts = pBlockData->aTSKEY[iRow];
+ int32_t fid = tsdbKeyFid(ts, pWriter->minutes, pWriter->precision);
- pWriter->fid = fid;
+ if (pWriter->dWriter.pWriter == NULL || pWriter->fid != fid) {
+ if (pWriter->dWriter.pWriter) {
+ ASSERT(fid > pWriter->fid);
- // read
- SDFileSet* pSet = taosArraySearch(pWriter->fs.aDFileSet, &(SDFileSet){.fid = fid}, tDFileSetCmprFn, TD_EQ);
- if (pSet) {
- code = tsdbDataFReaderOpen(&pWriter->pDataFReader, pTsdb, pSet);
+ code = tsdbSnapWriteCloseFile(pWriter);
+ if (code) goto _err;
+ }
+
+ code = tsdbSnapWriteOpenFile(pWriter, fid);
if (code) goto _err;
-
- code = tsdbReadBlockIdx(pWriter->pDataFReader, pWriter->aBlockIdx);
- if (code) goto _err;
-
- code = tsdbReadBlockL(pWriter->pDataFReader, pWriter->aBlockL);
- if (code) goto _err;
- } else {
- ASSERT(pWriter->pDataFReader == NULL);
- taosArrayClear(pWriter->aBlockIdx);
- taosArrayClear(pWriter->aBlockL);
- }
- pWriter->iBlockIdx = 0;
- pWriter->pBlockIdx = NULL;
- tMapDataReset(&pWriter->mBlock);
- pWriter->iBlock = 0;
- pWriter->pBlockData = NULL;
- pWriter->iRow = 0;
- pWriter->iBlockL = 0;
- tBlockDataReset(&pWriter->bDataR);
- tBlockDataReset(&pWriter->lDataR);
-
- // write
- SHeadFile fHead;
- SDataFile fData;
- SLastFile fLast;
- SSmaFile fSma;
- SDFileSet wSet = {.pHeadF = &fHead, .pDataF = &fData, .pLastF = &fLast, .pSmaF = &fSma};
-
- if (pSet) {
- wSet.diskId = pSet->diskId;
- wSet.fid = fid;
- fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0};
- fData = *pSet->pDataF;
- fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0};
- fSma = *pSet->pSmaF;
- } else {
- wSet.diskId = (SDiskID){.level = 0, .id = 0};
- wSet.fid = fid;
- fHead = (SHeadFile){.commitID = pWriter->commitID, .offset = 0, .size = 0};
- fData = (SDataFile){.commitID = pWriter->commitID, .size = 0};
- fLast = (SLastFile){.commitID = pWriter->commitID, .size = 0, .offset = 0};
- fSma = (SSmaFile){.commitID = pWriter->commitID, .size = 0};
}
- code = tsdbDataFWriterOpen(&pWriter->pDataFWriter, pTsdb, &wSet);
+ code = tsdbSnapWriteRowData(pWriter, iRow);
if (code) goto _err;
-
- taosArrayClear(pWriter->aBlockIdxW);
- taosArrayClear(pWriter->aBlockLW);
- tMapDataReset(&pWriter->mBlockW);
- pWriter->pBlockIdxW = NULL;
- tBlockDataReset(&pWriter->bDataW);
}
- code = tsdbSnapWriteTableData(pWriter, id);
- if (code) goto _err;
-
- tsdbInfo("vgId:%d, vnode snapshot tsdb write data for %s, fid:%d suid:%" PRId64 " uid:%" PRId64 " nRow:%d",
- TD_VID(pTsdb->pVnode), pTsdb->path, fid, id.suid, id.suid, pBlockData->nRow);
return code;
_err:
@@ -974,10 +1099,41 @@ _err:
return code;
}
+// SNAP_DATA_DEL
+static int32_t tsdbSnapMoveWriteDelData(STsdbSnapWriter* pWriter, TABLEID* pId) {
+ int32_t code = 0;
+
+ while (true) {
+ if (pWriter->iDelIdx >= taosArrayGetSize(pWriter->aDelIdxR)) break;
+
+ SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
+
+ if (tTABLEIDCmprFn(pDelIdx, pId) >= 0) break;
+
+ code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
+ if (code) goto _exit;
+
+ SDelIdx delIdx = *pDelIdx;
+ code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
+ if (code) goto _exit;
+
+ if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _exit;
+ }
+
+ pWriter->iDelIdx++;
+ }
+
+_exit:
+ return code;
+}
+
static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
int32_t code = 0;
STsdb* pTsdb = pWriter->pTsdb;
+ // Open del file if not opened yet
if (pWriter->pDelFWriter == NULL) {
SDelFile* pDelFile = pWriter->fs.pDelFile;
@@ -988,38 +1144,28 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
code = tsdbReadDelIdx(pWriter->pDelFReader, pWriter->aDelIdxR);
if (code) goto _err;
+ } else {
+ taosArrayClear(pWriter->aDelIdxR);
}
+ pWriter->iDelIdx = 0;
// writer
- SDelFile delFile = {.commitID = pWriter->commitID, .offset = 0, .size = 0};
+ SDelFile delFile = {.commitID = pWriter->commitID};
code = tsdbDelFWriterOpen(&pWriter->pDelFWriter, &delFile, pTsdb);
if (code) goto _err;
+ taosArrayClear(pWriter->aDelIdxW);
}
- // process the del data
- TABLEID id = *(TABLEID*)(pData + sizeof(SSnapDataHdr));
+ SSnapDataHdr* pHdr = (SSnapDataHdr*)pData;
+ TABLEID id = *(TABLEID*)pHdr->data;
- while (true) {
- if (pWriter->iDelIdx >= taosArrayGetSize(pWriter->aDelIdxR)) break;
- if (tTABLEIDCmprFn(taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx), &id) >= 0) break;
+ ASSERT(pHdr->size + sizeof(SSnapDataHdr) == nData);
- SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
-
- code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
- if (code) goto _err;
-
- SDelIdx delIdx = *pDelIdx;
- code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
- if (code) goto _err;
-
- if (taosArrayPush(pWriter->aDelIdxW, &delIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
-
- pWriter->iDelIdx++;
- }
+ // Move write data < id
+ code = tsdbSnapMoveWriteDelData(pWriter, &id);
+ if (code) goto _err;
+ // Merge incoming data with current
if (pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdxR) &&
tTABLEIDCmprFn(taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx), &id) == 0) {
SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
@@ -1053,7 +1199,6 @@ static int32_t tsdbSnapWriteDel(STsdbSnapWriter* pWriter, uint8_t* pData, uint32
goto _err;
}
-_exit:
return code;
_err:
@@ -1066,23 +1211,14 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
int32_t code = 0;
STsdb* pTsdb = pWriter->pTsdb;
- if (pWriter->pDelFWriter == NULL) goto _exit;
+ if (pWriter->pDelFWriter == NULL) return code;
- for (; pWriter->iDelIdx < taosArrayGetSize(pWriter->aDelIdxR); pWriter->iDelIdx++) {
- SDelIdx* pDelIdx = (SDelIdx*)taosArrayGet(pWriter->aDelIdxR, pWriter->iDelIdx);
+ TABLEID id = {.suid = INT64_MAX, .uid = INT64_MAX};
+ code = tsdbSnapMoveWriteDelData(pWriter, &id);
+ if (code) goto _err;
- code = tsdbReadDelData(pWriter->pDelFReader, pDelIdx, pWriter->aDelData);
- if (code) goto _err;
-
- SDelIdx delIdx = *pDelIdx;
- code = tsdbWriteDelData(pWriter->pDelFWriter, pWriter->aDelData, &delIdx);
- if (code) goto _err;
-
- if (taosArrayPush(pWriter->aDelIdxR, &delIdx) == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- }
+ code = tsdbWriteDelIdx(pWriter->pDelFWriter, pWriter->aDelIdxW);
+ if (code) goto _err;
code = tsdbUpdateDelFileHdr(pWriter->pDelFWriter);
if (code) goto _err;
@@ -1098,7 +1234,6 @@ static int32_t tsdbSnapWriteDelEnd(STsdbSnapWriter* pWriter) {
if (code) goto _err;
}
-_exit:
tsdbInfo("vgId:%d, vnode snapshot tsdb write del for %s end", TD_VID(pTsdb->pVnode), pTsdb->path);
return code;
@@ -1108,6 +1243,7 @@ _err:
return code;
}
+// APIs
int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWriter** ppWriter) {
int32_t code = 0;
STsdbSnapWriter* pWriter = NULL;
@@ -1133,39 +1269,38 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
pWriter->cmprAlg = pTsdb->pVnode->config.tsdbCfg.compression;
pWriter->commitID = pTsdb->pVnode->state.commitID;
- // for data file
+ // SNAP_DATA_TSDB
code = tBlockDataCreate(&pWriter->bData);
-
- if (code) goto _err;
- pWriter->aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
- if (pWriter->aBlockIdx == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- code = tBlockDataCreate(&pWriter->bDataR);
if (code) goto _err;
- pWriter->aBlockL = taosArrayInit(0, sizeof(SBlockL));
- if (pWriter->aBlockL == NULL) {
+ pWriter->fid = INT32_MIN;
+ pWriter->id = (TABLEID){0};
+ // Reader
+ pWriter->dReader.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
+ if (pWriter->dReader.aBlockIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
-
- pWriter->aBlockIdxW = taosArrayInit(0, sizeof(SBlockIdx));
- if (pWriter->aBlockIdxW == NULL) {
- code = TSDB_CODE_OUT_OF_MEMORY;
- goto _err;
- }
- code = tBlockDataCreate(&pWriter->bDataW);
+ code = tBlockDataCreate(&pWriter->dReader.bData);
if (code) goto _err;
- pWriter->aBlockLW = taosArrayInit(0, sizeof(SBlockL));
- if (pWriter->aBlockLW == NULL) {
+ // Writer
+ pWriter->dWriter.aBlockIdx = taosArrayInit(0, sizeof(SBlockIdx));
+ if (pWriter->dWriter.aBlockIdx == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _err;
}
+ pWriter->dWriter.aSttBlk = taosArrayInit(0, sizeof(SSttBlk));
+ if (pWriter->dWriter.aSttBlk == NULL) {
+ code = TSDB_CODE_OUT_OF_MEMORY;
+ goto _err;
+ }
+ code = tBlockDataCreate(&pWriter->dWriter.bData);
+ if (code) goto _err;
+ code = tBlockDataCreate(&pWriter->dWriter.sData);
+ if (code) goto _err;
- // for del file
+ // SNAP_DATA_DEL
pWriter->aDelIdxR = taosArrayInit(0, sizeof(SDelIdx));
if (pWriter->aDelIdxR == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
@@ -1186,6 +1321,7 @@ int32_t tsdbSnapWriterOpen(STsdb* pTsdb, int64_t sver, int64_t ever, STsdbSnapWr
tsdbInfo("vgId:%d, tsdb snapshot writer open for %s succeed", TD_VID(pTsdb->pVnode), pTsdb->path);
return code;
+
_err:
tsdbError("vgId:%d, tsdb snapshot writer open for %s failed since %s", TD_VID(pTsdb->pVnode), pTsdb->path,
tstrerror(code));
@@ -1196,14 +1332,17 @@ _err:
int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
int32_t code = 0;
STsdbSnapWriter* pWriter = *ppWriter;
+ STsdb* pTsdb = pWriter->pTsdb;
if (rollback) {
ASSERT(0);
// code = tsdbFSRollback(pWriter->pTsdb->pFS);
// if (code) goto _err;
} else {
- code = tsdbSnapWriteDataEnd(pWriter);
- if (code) goto _err;
+ if (pWriter->dWriter.pWriter) {
+ code = tsdbSnapWriteCloseFile(pWriter);
+ if (code) goto _err;
+ }
code = tsdbSnapWriteDelEnd(pWriter);
if (code) goto _err;
@@ -1211,14 +1350,44 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
code = tsdbFSCommit1(pWriter->pTsdb, &pWriter->fs);
if (code) goto _err;
+ // lock
+ taosThreadRwlockWrlock(&pTsdb->rwLock);
+
code = tsdbFSCommit2(pWriter->pTsdb, &pWriter->fs);
- if (code) goto _err;
+ if (code) {
+ taosThreadRwlockUnlock(&pTsdb->rwLock);
+ goto _err;
+ }
+
+ // unlock
+ taosThreadRwlockUnlock(&pTsdb->rwLock);
}
+ // SNAP_DATA_DEL
+ taosArrayDestroy(pWriter->aDelIdxW);
+ taosArrayDestroy(pWriter->aDelData);
+ taosArrayDestroy(pWriter->aDelIdxR);
+
+ // SNAP_DATA_TSDB
+
+ // Writer
+ tBlockDataDestroy(&pWriter->dWriter.sData, 1);
+ tBlockDataDestroy(&pWriter->dWriter.bData, 1);
+ taosArrayDestroy(pWriter->dWriter.aSttBlk);
+ tMapDataClear(&pWriter->dWriter.mDataBlk);
+ taosArrayDestroy(pWriter->dWriter.aBlockIdx);
+
+ // Reader
+ tBlockDataDestroy(&pWriter->dReader.bData, 1);
+ tMapDataClear(&pWriter->dReader.mDataBlk);
+ taosArrayDestroy(pWriter->dReader.aBlockIdx);
+
+ tBlockDataDestroy(&pWriter->bData, 1);
+ tTSchemaDestroy(pWriter->skmTable.pTSchema);
+
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
tFree(pWriter->aBuf[iBuf]);
}
-
tsdbInfo("vgId:%d, vnode snapshot tsdb writer close for %s", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
taosMemoryFree(pWriter);
*ppWriter = NULL;
@@ -1243,8 +1412,8 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
goto _exit;
} else {
- if (pWriter->pDataFWriter) {
- code = tsdbSnapWriteDataEnd(pWriter);
+ if (pWriter->dWriter.pWriter) {
+ code = tsdbSnapWriteCloseFile(pWriter);
if (code) goto _err;
}
}
@@ -1257,7 +1426,6 @@ int32_t tsdbSnapWrite(STsdbSnapWriter* pWriter, uint8_t* pData, uint32_t nData)
_exit:
tsdbDebug("vgId:%d, tsdb snapshot write for %s succeed", TD_VID(pWriter->pTsdb->pVnode), pWriter->pTsdb->path);
-
return code;
_err:
diff --git a/source/dnode/vnode/src/tsdb/tsdbUtil.c b/source/dnode/vnode/src/tsdb/tsdbUtil.c
index cfb04881e6..caeca45e01 100644
--- a/source/dnode/vnode/src/tsdb/tsdbUtil.c
+++ b/source/dnode/vnode/src/tsdb/tsdbUtil.c
@@ -51,6 +51,22 @@ _exit:
return code;
}
+int32_t tMapDataCopy(SMapData *pFrom, SMapData *pTo) {
+ int32_t code = 0;
+
+ pTo->nItem = pFrom->nItem;
+ pTo->nData = pFrom->nData;
+ code = tRealloc((uint8_t **)&pTo->aOffset, sizeof(int32_t) * pFrom->nItem);
+ if (code) goto _exit;
+ code = tRealloc(&pTo->pData, pFrom->nData);
+ if (code) goto _exit;
+ memcpy(pTo->aOffset, pFrom->aOffset, sizeof(int32_t) * pFrom->nItem);
+ memcpy(pTo->pData, pFrom->pData, pFrom->nData);
+
+_exit:
+ return code;
+}
+
int32_t tMapDataSearch(SMapData *pMapData, void *pSearchItem, int32_t (*tGetItemFn)(uint8_t *, void *),
int32_t (*tItemCmprFn)(const void *, const void *), void *pItem) {
int32_t code = 0;
@@ -198,7 +214,7 @@ int32_t tCmprBlockIdx(void const *lhs, void const *rhs) {
int32_t tCmprBlockL(void const *lhs, void const *rhs) {
SBlockIdx *lBlockIdx = (SBlockIdx *)lhs;
- SBlockL *rBlockL = (SBlockL *)rhs;
+ SSttBlk *rBlockL = (SSttBlk *)rhs;
if (lBlockIdx->suid < rBlockL->suid) {
return -1;
@@ -215,69 +231,69 @@ int32_t tCmprBlockL(void const *lhs, void const *rhs) {
return 0;
}
-// SBlock ======================================================
-void tBlockReset(SBlock *pBlock) {
- *pBlock = (SBlock){.minKey = TSDBKEY_MAX, .maxKey = TSDBKEY_MIN, .minVer = VERSION_MAX, .maxVer = VERSION_MIN};
+// SDataBlk ======================================================
+void tDataBlkReset(SDataBlk *pDataBlk) {
+ *pDataBlk = (SDataBlk){.minKey = TSDBKEY_MAX, .maxKey = TSDBKEY_MIN, .minVer = VERSION_MAX, .maxVer = VERSION_MIN};
}
-int32_t tPutBlock(uint8_t *p, void *ph) {
- int32_t n = 0;
- SBlock *pBlock = (SBlock *)ph;
+int32_t tPutDataBlk(uint8_t *p, void *ph) {
+ int32_t n = 0;
+ SDataBlk *pDataBlk = (SDataBlk *)ph;
- n += tPutI64v(p ? p + n : p, pBlock->minKey.version);
- n += tPutI64v(p ? p + n : p, pBlock->minKey.ts);
- n += tPutI64v(p ? p + n : p, pBlock->maxKey.version);
- n += tPutI64v(p ? p + n : p, pBlock->maxKey.ts);
- n += tPutI64v(p ? p + n : p, pBlock->minVer);
- n += tPutI64v(p ? p + n : p, pBlock->maxVer);
- n += tPutI32v(p ? p + n : p, pBlock->nRow);
- n += tPutI8(p ? p + n : p, pBlock->hasDup);
- n += tPutI8(p ? p + n : p, pBlock->nSubBlock);
- for (int8_t iSubBlock = 0; iSubBlock < pBlock->nSubBlock; iSubBlock++) {
- n += tPutI64v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].offset);
- n += tPutI32v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].szBlock);
- n += tPutI32v(p ? p + n : p, pBlock->aSubBlock[iSubBlock].szKey);
+ n += tPutI64v(p ? p + n : p, pDataBlk->minKey.version);
+ n += tPutI64v(p ? p + n : p, pDataBlk->minKey.ts);
+ n += tPutI64v(p ? p + n : p, pDataBlk->maxKey.version);
+ n += tPutI64v(p ? p + n : p, pDataBlk->maxKey.ts);
+ n += tPutI64v(p ? p + n : p, pDataBlk->minVer);
+ n += tPutI64v(p ? p + n : p, pDataBlk->maxVer);
+ n += tPutI32v(p ? p + n : p, pDataBlk->nRow);
+ n += tPutI8(p ? p + n : p, pDataBlk->hasDup);
+ n += tPutI8(p ? p + n : p, pDataBlk->nSubBlock);
+ for (int8_t iSubBlock = 0; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) {
+ n += tPutI64v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].offset);
+ n += tPutI32v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].szBlock);
+ n += tPutI32v(p ? p + n : p, pDataBlk->aSubBlock[iSubBlock].szKey);
}
- if (pBlock->nSubBlock == 1 && !pBlock->hasDup) {
- n += tPutI64v(p ? p + n : p, pBlock->smaInfo.offset);
- n += tPutI32v(p ? p + n : p, pBlock->smaInfo.size);
+ if (pDataBlk->nSubBlock == 1 && !pDataBlk->hasDup) {
+ n += tPutI64v(p ? p + n : p, pDataBlk->smaInfo.offset);
+ n += tPutI32v(p ? p + n : p, pDataBlk->smaInfo.size);
}
return n;
}
-int32_t tGetBlock(uint8_t *p, void *ph) {
- int32_t n = 0;
- SBlock *pBlock = (SBlock *)ph;
+int32_t tGetDataBlk(uint8_t *p, void *ph) {
+ int32_t n = 0;
+ SDataBlk *pDataBlk = (SDataBlk *)ph;
- n += tGetI64v(p + n, &pBlock->minKey.version);
- n += tGetI64v(p + n, &pBlock->minKey.ts);
- n += tGetI64v(p + n, &pBlock->maxKey.version);
- n += tGetI64v(p + n, &pBlock->maxKey.ts);
- n += tGetI64v(p + n, &pBlock->minVer);
- n += tGetI64v(p + n, &pBlock->maxVer);
- n += tGetI32v(p + n, &pBlock->nRow);
- n += tGetI8(p + n, &pBlock->hasDup);
- n += tGetI8(p + n, &pBlock->nSubBlock);
- for (int8_t iSubBlock = 0; iSubBlock < pBlock->nSubBlock; iSubBlock++) {
- n += tGetI64v(p + n, &pBlock->aSubBlock[iSubBlock].offset);
- n += tGetI32v(p + n, &pBlock->aSubBlock[iSubBlock].szBlock);
- n += tGetI32v(p + n, &pBlock->aSubBlock[iSubBlock].szKey);
+ n += tGetI64v(p + n, &pDataBlk->minKey.version);
+ n += tGetI64v(p + n, &pDataBlk->minKey.ts);
+ n += tGetI64v(p + n, &pDataBlk->maxKey.version);
+ n += tGetI64v(p + n, &pDataBlk->maxKey.ts);
+ n += tGetI64v(p + n, &pDataBlk->minVer);
+ n += tGetI64v(p + n, &pDataBlk->maxVer);
+ n += tGetI32v(p + n, &pDataBlk->nRow);
+ n += tGetI8(p + n, &pDataBlk->hasDup);
+ n += tGetI8(p + n, &pDataBlk->nSubBlock);
+ for (int8_t iSubBlock = 0; iSubBlock < pDataBlk->nSubBlock; iSubBlock++) {
+ n += tGetI64v(p + n, &pDataBlk->aSubBlock[iSubBlock].offset);
+ n += tGetI32v(p + n, &pDataBlk->aSubBlock[iSubBlock].szBlock);
+ n += tGetI32v(p + n, &pDataBlk->aSubBlock[iSubBlock].szKey);
}
- if (pBlock->nSubBlock == 1 && !pBlock->hasDup) {
- n += tGetI64v(p + n, &pBlock->smaInfo.offset);
- n += tGetI32v(p + n, &pBlock->smaInfo.size);
+ if (pDataBlk->nSubBlock == 1 && !pDataBlk->hasDup) {
+ n += tGetI64v(p + n, &pDataBlk->smaInfo.offset);
+ n += tGetI32v(p + n, &pDataBlk->smaInfo.size);
} else {
- pBlock->smaInfo.offset = 0;
- pBlock->smaInfo.size = 0;
+ pDataBlk->smaInfo.offset = 0;
+ pDataBlk->smaInfo.size = 0;
}
return n;
}
-int32_t tBlockCmprFn(const void *p1, const void *p2) {
- SBlock *pBlock1 = (SBlock *)p1;
- SBlock *pBlock2 = (SBlock *)p2;
+int32_t tDataBlkCmprFn(const void *p1, const void *p2) {
+ SDataBlk *pBlock1 = (SDataBlk *)p1;
+ SDataBlk *pBlock2 = (SDataBlk *)p2;
if (tsdbKeyCmprFn(&pBlock1->maxKey, &pBlock2->minKey) < 0) {
return -1;
@@ -288,48 +304,48 @@ int32_t tBlockCmprFn(const void *p1, const void *p2) {
return 0;
}
-bool tBlockHasSma(SBlock *pBlock) {
- if (pBlock->nSubBlock > 1) return false;
- if (pBlock->hasDup) return false;
+bool tDataBlkHasSma(SDataBlk *pDataBlk) {
+ if (pDataBlk->nSubBlock > 1) return false;
+ if (pDataBlk->hasDup) return false;
- return pBlock->smaInfo.size > 0;
+ return pDataBlk->smaInfo.size > 0;
}
-// SBlockL ======================================================
-int32_t tPutBlockL(uint8_t *p, void *ph) {
+// SSttBlk ======================================================
+int32_t tPutSttBlk(uint8_t *p, void *ph) {
int32_t n = 0;
- SBlockL *pBlockL = (SBlockL *)ph;
+ SSttBlk *pSttBlk = (SSttBlk *)ph;
- n += tPutI64(p ? p + n : p, pBlockL->suid);
- n += tPutI64(p ? p + n : p, pBlockL->minUid);
- n += tPutI64(p ? p + n : p, pBlockL->maxUid);
- n += tPutI64v(p ? p + n : p, pBlockL->minKey);
- n += tPutI64v(p ? p + n : p, pBlockL->maxKey);
- n += tPutI64v(p ? p + n : p, pBlockL->minVer);
- n += tPutI64v(p ? p + n : p, pBlockL->maxVer);
- n += tPutI32v(p ? p + n : p, pBlockL->nRow);
- n += tPutI64v(p ? p + n : p, pBlockL->bInfo.offset);
- n += tPutI32v(p ? p + n : p, pBlockL->bInfo.szBlock);
- n += tPutI32v(p ? p + n : p, pBlockL->bInfo.szKey);
+ n += tPutI64(p ? p + n : p, pSttBlk->suid);
+ n += tPutI64(p ? p + n : p, pSttBlk->minUid);
+ n += tPutI64(p ? p + n : p, pSttBlk->maxUid);
+ n += tPutI64v(p ? p + n : p, pSttBlk->minKey);
+ n += tPutI64v(p ? p + n : p, pSttBlk->maxKey);
+ n += tPutI64v(p ? p + n : p, pSttBlk->minVer);
+ n += tPutI64v(p ? p + n : p, pSttBlk->maxVer);
+ n += tPutI32v(p ? p + n : p, pSttBlk->nRow);
+ n += tPutI64v(p ? p + n : p, pSttBlk->bInfo.offset);
+ n += tPutI32v(p ? p + n : p, pSttBlk->bInfo.szBlock);
+ n += tPutI32v(p ? p + n : p, pSttBlk->bInfo.szKey);
return n;
}
-int32_t tGetBlockL(uint8_t *p, void *ph) {
+int32_t tGetSttBlk(uint8_t *p, void *ph) {
int32_t n = 0;
- SBlockL *pBlockL = (SBlockL *)ph;
+ SSttBlk *pSttBlk = (SSttBlk *)ph;
- n += tGetI64(p + n, &pBlockL->suid);
- n += tGetI64(p + n, &pBlockL->minUid);
- n += tGetI64(p + n, &pBlockL->maxUid);
- n += tGetI64v(p + n, &pBlockL->minKey);
- n += tGetI64v(p + n, &pBlockL->maxKey);
- n += tGetI64v(p + n, &pBlockL->minVer);
- n += tGetI64v(p + n, &pBlockL->maxVer);
- n += tGetI32v(p + n, &pBlockL->nRow);
- n += tGetI64v(p + n, &pBlockL->bInfo.offset);
- n += tGetI32v(p + n, &pBlockL->bInfo.szBlock);
- n += tGetI32v(p + n, &pBlockL->bInfo.szKey);
+ n += tGetI64(p + n, &pSttBlk->suid);
+ n += tGetI64(p + n, &pSttBlk->minUid);
+ n += tGetI64(p + n, &pSttBlk->maxUid);
+ n += tGetI64v(p + n, &pSttBlk->minKey);
+ n += tGetI64v(p + n, &pSttBlk->maxKey);
+ n += tGetI64v(p + n, &pSttBlk->minVer);
+ n += tGetI64v(p + n, &pSttBlk->maxVer);
+ n += tGetI32v(p + n, &pSttBlk->nRow);
+ n += tGetI64v(p + n, &pSttBlk->bInfo.offset);
+ n += tGetI32v(p + n, &pSttBlk->bInfo.szBlock);
+ n += tGetI32v(p + n, &pSttBlk->bInfo.szKey);
return n;
}
@@ -1532,7 +1548,7 @@ int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut,
if (code) goto _exit;
blockCol.offset = aBufN[0];
- aBufN[0] = aBufN[0] + blockCol.szBitmap + blockCol.szOffset + blockCol.szValue + sizeof(TSCKSUM);
+ aBufN[0] = aBufN[0] + blockCol.szBitmap + blockCol.szOffset + blockCol.szValue;
}
code = tRealloc(&aBuf[1], hdr.szBlkCol + tPutBlockCol(NULL, &blockCol));
@@ -1540,15 +1556,8 @@ int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut,
hdr.szBlkCol += tPutBlockCol(aBuf[1] + hdr.szBlkCol, &blockCol);
}
- aBufN[1] = 0;
- if (hdr.szBlkCol > 0) {
- aBufN[1] = hdr.szBlkCol + sizeof(TSCKSUM);
-
- code = tRealloc(&aBuf[1], aBufN[1]);
- if (code) goto _exit;
-
- taosCalcChecksumAppend(0, aBuf[1], aBufN[1]);
- }
+ // SBlockCol
+ aBufN[1] = hdr.szBlkCol;
// uid + version + tskey
aBufN[2] = 0;
@@ -1569,16 +1578,11 @@ int32_t tCmprBlockData(SBlockData *pBlockData, int8_t cmprAlg, uint8_t **ppOut,
if (code) goto _exit;
aBufN[2] += hdr.szKey;
- aBufN[2] += sizeof(TSCKSUM);
- code = tRealloc(&aBuf[2], aBufN[2]);
- if (code) goto _exit;
-
// hdr
aBufN[3] = tPutDiskDataHdr(NULL, &hdr);
code = tRealloc(&aBuf[3], aBufN[3]);
if (code) goto _exit;
tPutDiskDataHdr(aBuf[3], &hdr);
- taosCalcChecksumAppend(taosCalcChecksum(0, aBuf[3], aBufN[3]), aBuf[2], aBufN[2]);
// aggragate
if (ppOut) {
@@ -1603,17 +1607,13 @@ _exit:
int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uint8_t *aBuf[]) {
int32_t code = 0;
- tBlockDataClear(pBlockData);
+ tBlockDataReset(pBlockData);
int32_t n = 0;
SDiskDataHdr hdr = {0};
// SDiskDataHdr
n += tGetDiskDataHdr(pIn + n, &hdr);
- if (!taosCheckChecksumWhole(pIn, n + hdr.szUid + hdr.szVer + hdr.szKey + sizeof(TSCKSUM))) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _exit;
- }
ASSERT(hdr.delimiter == TSDB_FILE_DLMT);
pBlockData->suid = hdr.suid;
@@ -1641,7 +1641,7 @@ int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uin
code = tsdbDecmprData(pIn + n, hdr.szKey, TSDB_DATA_TYPE_TIMESTAMP, hdr.cmprAlg, (uint8_t **)&pBlockData->aTSKEY,
sizeof(TSKEY) * hdr.nRow, &aBuf[0]);
if (code) goto _exit;
- n = n + hdr.szKey + sizeof(TSCKSUM);
+ n += hdr.szKey;
// loop to decode each column data
if (hdr.szBlkCol == 0) goto _exit;
@@ -1663,8 +1663,8 @@ int32_t tDecmprBlockData(uint8_t *pIn, int32_t szIn, SBlockData *pBlockData, uin
if (code) goto _exit;
}
} else {
- code = tsdbDecmprColData(pIn + n + hdr.szBlkCol + sizeof(TSCKSUM) + blockCol.offset, &blockCol, hdr.cmprAlg,
- hdr.nRow, pColData, &aBuf[0]);
+ code = tsdbDecmprColData(pIn + n + hdr.szBlkCol + blockCol.offset, &blockCol, hdr.cmprAlg, hdr.nRow, pColData,
+ &aBuf[0]);
if (code) goto _exit;
}
}
@@ -2046,12 +2046,6 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
}
size += pBlockCol->szValue;
- // checksum
- size += sizeof(TSCKSUM);
- code = tRealloc(ppOut, nOut + size);
- if (code) goto _exit;
- taosCalcChecksumAppend(0, *ppOut + nOut, size);
-
_exit:
return code;
}
@@ -2060,12 +2054,6 @@ int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, in
uint8_t **ppBuf) {
int32_t code = 0;
- int32_t size = pBlockCol->szBitmap + pBlockCol->szOffset + pBlockCol->szValue + sizeof(TSCKSUM);
- if (!taosCheckChecksumWhole(pIn, size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _exit;
- }
-
ASSERT(pColData->cid == pBlockCol->cid);
ASSERT(pColData->type == pBlockCol->type);
pColData->smaOn = pBlockCol->smaOn;
@@ -2137,37 +2125,3 @@ int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, in
_exit:
return code;
}
-
-int32_t tsdbReadAndCheck(TdFilePtr pFD, int64_t offset, uint8_t **ppOut, int32_t size, int8_t toCheck) {
- int32_t code = 0;
-
- // alloc
- code = tRealloc(ppOut, size);
- if (code) goto _exit;
-
- // seek
- int64_t n = taosLSeekFile(pFD, offset, SEEK_SET);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _exit;
- }
-
- // read
- n = taosReadFile(pFD, *ppOut, size);
- if (n < 0) {
- code = TAOS_SYSTEM_ERROR(errno);
- goto _exit;
- } else if (n < size) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _exit;
- }
-
- // check
- if (toCheck && !taosCheckChecksumWhole(*ppOut, size)) {
- code = TSDB_CODE_FILE_CORRUPTED;
- goto _exit;
- }
-
-_exit:
- return code;
-}
diff --git a/source/dnode/vnode/src/tsdb/tsdbWrite.c b/source/dnode/vnode/src/tsdb/tsdbWrite.c
index 383652531e..0a9fbf92a4 100644
--- a/source/dnode/vnode/src/tsdb/tsdbWrite.c
+++ b/source/dnode/vnode/src/tsdb/tsdbWrite.c
@@ -39,7 +39,7 @@ int tsdbInsertData(STsdb *pTsdb, int64_t version, SSubmitReq *pMsg, SSubmitRsp *
SSubmitBlkRsp r = {0};
tGetSubmitMsgNext(&msgIter, &pBlock);
if (pBlock == NULL) break;
- if (tsdbInsertTableData(pTsdb, version, &msgIter, pBlock, &r) < 0) {
+ if ((terrno = tsdbInsertTableData(pTsdb, version, &msgIter, pBlock, &r)) < 0) {
return -1;
}
diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c
index 24dda29330..9ed72eeecd 100644
--- a/source/dnode/vnode/src/vnd/vnodeCfg.c
+++ b/source/dnode/vnode/src/vnd/vnodeCfg.c
@@ -13,6 +13,7 @@
* along with this program. If not, see .
*/
+#include "tutil.h"
#include "vnd.h"
const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
@@ -47,7 +48,9 @@ const SVnodeCfg vnodeCfgDefault = {.vgId = -1,
},
.hashBegin = 0,
.hashEnd = 0,
- .hashMethod = 0};
+ .hashMethod = 0,
+ .sttTrigger = TSDB_DEFAULT_STT_FILE,
+ .tsdbPageSize = TSDB_DEFAULT_PAGE_SIZE};
int vnodeCheckCfg(const SVnodeCfg *pCfg) {
// TODO
@@ -106,10 +109,12 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
if (tjsonAddIntegerToObject(pJson, "wal.retentionSize", pCfg->walCfg.retentionSize) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "wal.segSize", pCfg->walCfg.segSize) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "wal.level", pCfg->walCfg.level) < 0) return -1;
- if (tjsonAddIntegerToObject(pJson, "sstTrigger", pCfg->sstTrigger) < 0) return -1;
+ if (tjsonAddIntegerToObject(pJson, "sstTrigger", pCfg->sttTrigger) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "hashBegin", pCfg->hashBegin) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "hashEnd", pCfg->hashEnd) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "hashMethod", pCfg->hashMethod) < 0) return -1;
+ if (tjsonAddIntegerToObject(pJson, "hashPrefix", pCfg->hashPrefix) < 0) return -1;
+ if (tjsonAddIntegerToObject(pJson, "hashSuffix", pCfg->hashSuffix) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum) < 0) return -1;
if (tjsonAddIntegerToObject(pJson, "syncCfg.myIndex", pCfg->syncCfg.myIndex) < 0) return -1;
@@ -129,6 +134,9 @@ int vnodeEncodeConfig(const void *pObj, SJson *pJson) {
tjsonAddItemToArray(pNodeInfoArr, pNodeInfo);
}
+ // add tsdb page size config
+ if (tjsonAddIntegerToObject(pJson, "tsdbPageSize", pCfg->tsdbPageSize) < 0) return -1;
+
return 0;
}
@@ -206,7 +214,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if (code < 0) return -1;
tjsonGetNumberValue(pJson, "wal.level", pCfg->walCfg.level, code);
if (code < 0) return -1;
- tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sstTrigger, code);
+ tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code);
if (code < 0) return -1;
tjsonGetNumberValue(pJson, "hashBegin", pCfg->hashBegin, code);
if (code < 0) return -1;
@@ -214,6 +222,10 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if (code < 0) return -1;
tjsonGetNumberValue(pJson, "hashMethod", pCfg->hashMethod, code);
if (code < 0) return -1;
+ tjsonGetNumberValue(pJson, "hashPrefix", pCfg->hashPrefix, code);
+ if (code < 0) return -1;
+ tjsonGetNumberValue(pJson, "hashSuffix", pCfg->hashSuffix, code);
+ if (code < 0) return -1;
tjsonGetNumberValue(pJson, "syncCfg.replicaNum", pCfg->syncCfg.replicaNum, code);
if (code < 0) return -1;
@@ -242,6 +254,8 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetStringValue(pNodeInfo, "nodeFqdn", (pCfg->syncCfg.nodeInfo)[i].nodeFqdn);
}
+ tjsonGetNumberValue(pJson, "tsdbPageSize", pCfg->tsdbPageSize, code);
+
return 0;
}
@@ -250,7 +264,8 @@ int vnodeValidateTableHash(SVnode *pVnode, char *tableFName) {
switch (pVnode->config.hashMethod) {
default:
- hashValue = MurmurHash3_32(tableFName, strlen(tableFName));
+ hashValue = taosGetTbHashVal(tableFName, strlen(tableFName), pVnode->config.hashMethod, pVnode->config.hashPrefix,
+ pVnode->config.hashSuffix);
break;
}
diff --git a/source/dnode/vnode/src/vnd/vnodeOpen.c b/source/dnode/vnode/src/vnd/vnodeOpen.c
index a4fd984fb7..4ccfea4051 100644
--- a/source/dnode/vnode/src/vnd/vnodeOpen.c
+++ b/source/dnode/vnode/src/vnd/vnodeOpen.c
@@ -60,6 +60,8 @@ SVnode *vnodeOpen(const char *path, STfs *pTfs, SMsgCb msgCb) {
snprintf(dir, TSDB_FILENAME_LEN, "%s%s%s", tfsGetPrimaryPath(pTfs), TD_DIRSEP, path);
+ info.config = vnodeCfgDefault;
+
// load vnode info
ret = vnodeLoadInfo(dir, &info);
if (ret < 0) {
diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c
index 8d799e919d..8cfe1d8adf 100644
--- a/source/dnode/vnode/src/vnd/vnodeQuery.c
+++ b/source/dnode/vnode/src/vnd/vnodeQuery.c
@@ -368,6 +368,7 @@ _exit:
int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad) {
pLoad->vgId = TD_VID(pVnode);
pLoad->syncState = syncGetMyRole(pVnode->sync);
+ pLoad->cacheUsage = tsdbCacheGetUsage(pVnode);
pLoad->numOfTables = metaGetTbNum(pVnode->pMeta);
pLoad->numOfTimeSeries = metaGetTimeSeriesNum(pVnode->pMeta);
pLoad->totalStorage = (int64_t)3 * 1073741824;
@@ -424,8 +425,8 @@ int32_t vnodeGetCtbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
return TSDB_CODE_SUCCESS;
}
-int32_t vnodeGetStbIdList(SVnode* pVnode, int64_t suid, SArray* list) {
- SMStbCursor* pCur = metaOpenStbCursor(pVnode->pMeta, suid);
+int32_t vnodeGetStbIdList(SVnode *pVnode, int64_t suid, SArray *list) {
+ SMStbCursor *pCur = metaOpenStbCursor(pVnode->pMeta, suid);
if (!pCur) {
return TSDB_CODE_FAILED;
}
@@ -467,9 +468,13 @@ static int32_t vnodeGetStbColumnNum(SVnode *pVnode, tb_uid_t suid, int *num) {
STSchema *pTSchema = metaGetTbTSchema(pVnode->pMeta, suid, -1);
// metaGetTbTSchemaEx(pVnode->pMeta, suid, suid, -1, &pTSchema);
- *num = pTSchema->numOfCols;
+ if (pTSchema) {
+ *num = pTSchema->numOfCols;
- taosMemoryFree(pTSchema);
+ taosMemoryFree(pTSchema);
+ } else {
+ *num = 2;
+ }
return TSDB_CODE_SUCCESS;
}
diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c
index 5a81f91919..08c3a34699 100644
--- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c
+++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c
@@ -39,7 +39,7 @@ struct SVSnapReader {
SStreamStateReader *pStreamStateReader;
// rsma
int8_t rsmaDone;
- SRsmaSnapReader *pRsmaReader;
+ SRSmaSnapReader *pRsmaReader;
};
int32_t vnodeSnapReaderOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapReader **ppReader) {
@@ -241,7 +241,7 @@ struct SVSnapWriter {
SStreamTaskWriter *pStreamTaskWriter;
SStreamStateWriter *pStreamStateWriter;
// rsma
- SRsmaSnapWriter *pRsmaSnapWriter;
+ SRSmaSnapWriter *pRsmaSnapWriter;
};
int32_t vnodeSnapWriterOpen(SVnode *pVnode, int64_t sver, int64_t ever, SVSnapWriter **ppWriter) {
@@ -354,7 +354,8 @@ int32_t vnodeSnapWrite(SVSnapWriter *pWriter, uint8_t *pData, uint32_t nData) {
code = metaSnapWrite(pWriter->pMetaSnapWriter, pData, nData);
if (code) goto _err;
} break;
- case SNAP_DATA_TSDB: {
+ case SNAP_DATA_TSDB:
+ case SNAP_DATA_DEL: {
// tsdb
if (pWriter->pTsdbSnapWriter == NULL) {
code = tsdbSnapWriterOpen(pVnode->pTsdb, pWriter->sver, pWriter->ever, &pWriter->pTsdbSnapWriter);
diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c
index cd0c7ba1f3..51d83d8eed 100644
--- a/source/dnode/vnode/src/vnd/vnodeSvr.c
+++ b/source/dnode/vnode/src/vnd/vnodeSvr.c
@@ -371,7 +371,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
if (NULL == pMetaRsp) {
return;
}
-
+
strcpy(pMetaRsp->dbFName, pVnode->config.dbname);
pMetaRsp->dbId = pVnode->config.dbId;
pMetaRsp->vgId = TD_VID(pVnode);
@@ -527,14 +527,14 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
cRsp.code = TSDB_CODE_SUCCESS;
tdFetchTbUidList(pVnode->pSma, &pStore, pCreateReq->ctb.suid, pCreateReq->uid);
taosArrayPush(tbUids, &pCreateReq->uid);
- vnodeUpdateMetaRsp(pVnode, cRsp.pMeta);
+ vnodeUpdateMetaRsp(pVnode, cRsp.pMeta);
}
taosArrayPush(rsp.pArray, &cRsp);
}
tqUpdateTbUidList(pVnode->pTq, tbUids, true);
- if (tdUpdateTbUidList(pVnode->pSma, pStore) < 0) {
+ if (tdUpdateTbUidList(pVnode->pSma, pStore, true) < 0) {
goto _exit;
}
tdUidStoreFree(pStore);
@@ -692,6 +692,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
SEncoder encoder = {0};
int32_t ret;
SArray *tbUids = NULL;
+ STbUidStore *pStore = NULL;
pRsp->msgType = TDMT_VND_DROP_TABLE_RSP;
pRsp->pCont = NULL;
@@ -715,9 +716,10 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
SVDropTbReq *pDropTbReq = req.pReqs + iReq;
SVDropTbRsp dropTbRsp = {0};
+ tb_uid_t tbUid = 0;
/* code */
- ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids);
+ ret = metaDropTable(pVnode->pMeta, version, pDropTbReq, tbUids, &tbUid);
if (ret < 0) {
if (pDropTbReq->igNotExists && terrno == TSDB_CODE_VND_TABLE_NOT_EXIST) {
dropTbRsp.code = TSDB_CODE_SUCCESS;
@@ -726,15 +728,18 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t version, void *pReq
}
} else {
dropTbRsp.code = TSDB_CODE_SUCCESS;
+ if (tbUid > 0) tdFetchTbUidList(pVnode->pSma, &pStore, pDropTbReq->suid, tbUid);
}
taosArrayPush(rsp.pArray, &dropTbRsp);
}
tqUpdateTbUidList(pVnode->pTq, tbUids, false);
+ tdUpdateTbUidList(pVnode->pSma, pStore, false);
_exit:
taosArrayDestroy(tbUids);
+ tdUidStoreFree(pStore);
tDecoderClear(&decoder);
tEncodeSize(tEncodeSVDropTbBatchRsp, &rsp, pRsp->contLen, ret);
pRsp->pCont = rpcMallocCont(pRsp->contLen);
@@ -1107,6 +1112,7 @@ static int32_t vnodeProcessDeleteReq(SVnode *pVnode, int64_t version, void *pReq
tDecoderInit(pCoder, pReq, len);
tDecodeDeleteRes(pCoder, pRes);
+ ASSERT(taosArrayGetSize(pRes->uidList) == 0 || (pRes->skey != 0 && pRes->ekey != 0));
for (int32_t iUid = 0; iUid < taosArrayGetSize(pRes->uidList); iUid++) {
code = tsdbDeleteTableData(pVnode->pTsdb, version, pRes->suid, *(uint64_t *)taosArrayGet(pRes->uidList, iUid),
diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c
index bd3402dc39..d215242307 100644
--- a/source/libs/catalog/src/ctgDbg.c
+++ b/source/libs/catalog/src/ctgDbg.c
@@ -367,18 +367,22 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) {
int32_t stbNum = dbCache->stbCache ? taosHashGetSize(dbCache->stbCache) : 0;
int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION;
int32_t hashMethod = -1;
+ int16_t hashPrefix = 0;
+ int16_t hashSuffix = 0;
int32_t vgNum = 0;
if (dbCache->vgCache.vgInfo) {
vgVersion = dbCache->vgCache.vgInfo->vgVersion;
hashMethod = dbCache->vgCache.vgInfo->hashMethod;
+ hashPrefix = dbCache->vgCache.vgInfo->hashPrefix;
+ hashSuffix = dbCache->vgCache.vgInfo->hashSuffix;
if (dbCache->vgCache.vgInfo->vgHash) {
vgNum = taosHashGetSize(dbCache->vgCache.vgInfo->vgHash);
}
}
- ctgDebug("[%d] db [%.*s][0x%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d",
- i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, vgNum);
+ ctgDebug("[%d] db [%.*s][0x%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, prefix:%d, suffix:%d, vgNum:%d",
+ i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, hashPrefix, hashSuffix, vgNum);
pIter = taosHashIterate(dbHash, pIter);
}
diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c
index e28234ab76..296100ce6d 100644
--- a/source/libs/catalog/src/ctgUtil.c
+++ b/source/libs/catalog/src/ctgUtil.c
@@ -848,15 +848,11 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName
CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED);
}
- tableNameHashFp fp = NULL;
SVgroupInfo *vgInfo = NULL;
-
- CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp));
-
char tbFullName[TSDB_TABLE_FNAME_LEN];
tNameExtractFullName(pTableName, tbFullName);
- uint32_t hashValue = (*fp)(tbFullName, (uint32_t)strlen(tbFullName));
+ uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix);
void *pIter = taosHashIterate(dbInfo->vgHash, NULL);
while (pIter) {
@@ -919,11 +915,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR);
}
- tableNameHashFp fp = NULL;
SVgroupInfo *vgInfo = NULL;
-
- CTG_ERR_RET(ctgGetHashFunction(dbInfo->hashMethod, &fp));
-
int32_t tbNum = taosArrayGetSize(pNames);
if (1 == vgNum) {
@@ -975,7 +967,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo
tbNameLen = offset + strlen(pName->tname);
strcpy(tbFullName + offset, pName->tname);
- uint32_t hashValue = (*fp)(tbFullName, (uint32_t)tbNameLen);
+ uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix);
SVgroupInfo **p = taosArraySearch(pVgList, &hashValue, ctgHashValueComp, TD_EQ);
diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp
index 0be85333dc..c01c269e64 100644
--- a/source/libs/catalog/test/catalogTests.cpp
+++ b/source/libs/catalog/test/catalogTests.cpp
@@ -218,6 +218,8 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) {
ctgTestCurrentVgVersion = dbVgroup->vgVersion;
dbVgroup->hashMethod = 0;
+ dbVgroup->hashPrefix = 0;
+ dbVgroup->hashSuffix = 0;
dbVgroup->vgHash = taosHashInit(ctgTestVgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK);
vgNum = ctgTestGetVgNumFromVgVersion(dbVgroup->vgVersion);
diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h
index 9e7fcc2227..a26f1c74f8 100644
--- a/source/libs/executor/inc/executil.h
+++ b/source/libs/executor/inc/executil.h
@@ -87,9 +87,7 @@ struct SqlFunctionCtx;
size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput);
void initResultRowInfo(SResultRowInfo* pResultRowInfo);
-
-void initResultRow(SResultRow* pResultRow);
-void closeResultRow(SResultRow* pResultRow);
+void closeResultRow(SResultRow* pResultRow);
struct SResultRowEntryInfo* getResultEntryInfo(const SResultRow* pRow, int32_t index, const int32_t* offset);
@@ -128,6 +126,7 @@ SArray* extractPartitionColInfo(SNodeList* pNodeList);
SArray* extractColMatchInfo(SNodeList* pNodeList, SDataBlockDescNode* pOutputNodeList, int32_t* numOfOutputCols,
int32_t type);
+void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode);
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs);
SqlFunctionCtx* createSqlFunctionCtx(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowEntryInfoOffset);
diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h
index 3bed81f657..fc8f942015 100644
--- a/source/libs/executor/inc/executorimpl.h
+++ b/source/libs/executor/inc/executorimpl.h
@@ -38,11 +38,11 @@ extern "C" {
#include "tlockfree.h"
#include "tmsg.h"
#include "tpagedbuf.h"
-#include "tstreamUpdate.h"
#include "tstream.h"
+#include "tstreamUpdate.h"
-#include "vnode.h"
#include "executorInt.h"
+#include "vnode.h"
typedef int32_t (*__block_search_fn_t)(char* data, int32_t num, int64_t key, int32_t order);
@@ -139,23 +139,23 @@ enum {
};
typedef struct {
- //TODO remove prepareStatus
- STqOffsetVal prepareStatus; // for tmq
- STqOffsetVal lastStatus; // for tmq
- SMqMetaRsp metaRsp; // for tmq fetching meta
- int8_t returned;
- int64_t snapshotVer;
+ // TODO remove prepareStatus
+ STqOffsetVal prepareStatus; // for tmq
+ STqOffsetVal lastStatus; // for tmq
+ SMqMetaRsp metaRsp; // for tmq fetching meta
+ int8_t returned;
+ int64_t snapshotVer;
- SSchemaWrapper *schema;
- char tbName[TSDB_TABLE_NAME_LEN];
- SSDataBlock* pullOverBlk; // for streaming
- SWalFilterCond cond;
- int64_t lastScanUid;
- int8_t recoverStep;
+ SSchemaWrapper* schema;
+ char tbName[TSDB_TABLE_NAME_LEN];
+ SSDataBlock* pullOverBlk; // for streaming
+ SWalFilterCond cond;
+ int64_t lastScanUid;
+ int8_t recoverStep;
SQueryTableDataCond tableCond;
- int64_t recoverStartVer;
- int64_t recoverEndVer;
- SStreamState* pState;
+ int64_t recoverStartVer;
+ int64_t recoverEndVer;
+ SStreamState* pState;
} SStreamTaskInfo;
typedef struct {
@@ -167,29 +167,29 @@ typedef struct {
} SSchemaInfo;
typedef struct SExecTaskInfo {
- STaskIdInfo id;
- uint32_t status;
- STimeWindow window;
- STaskCostInfo cost;
- int64_t owner; // if it is in execution
- int32_t code;
+ STaskIdInfo id;
+ uint32_t status;
+ STimeWindow window;
+ STaskCostInfo cost;
+ int64_t owner; // if it is in execution
+ int32_t code;
- int64_t version; // used for stream to record wal version
- SStreamTaskInfo streamInfo;
- SSchemaInfo schemaInfo;
- STableListInfo tableqinfoList; // this is a table list
- const char* sql; // query sql string
- jmp_buf env; // jump to this position when error happens.
- EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
- SSubplan* pSubplan;
+ int64_t version; // used for stream to record wal version
+ SStreamTaskInfo streamInfo;
+ SSchemaInfo schemaInfo;
+ STableListInfo tableqinfoList; // this is a table list
+ const char* sql; // query sql string
+ jmp_buf env; // jump to this position when error happens.
+ EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
+ SSubplan* pSubplan;
struct SOperatorInfo* pRoot;
} SExecTaskInfo;
enum {
- OP_NOT_OPENED = 0x0,
- OP_OPENED = 0x1,
+ OP_NOT_OPENED = 0x0,
+ OP_OPENED = 0x1,
OP_RES_TO_RETURN = 0x5,
- OP_EXEC_DONE = 0x9,
+ OP_EXEC_DONE = 0x9,
};
typedef struct SOperatorFpSet {
@@ -228,7 +228,7 @@ typedef struct SOperatorInfo {
typedef enum {
EX_SOURCE_DATA_NOT_READY = 0x1,
- EX_SOURCE_DATA_READY = 0x2,
+ EX_SOURCE_DATA_READY = 0x2,
EX_SOURCE_DATA_EXHAUSTED = 0x3,
} EX_SOURCE_STATUS;
@@ -251,26 +251,26 @@ typedef struct SLoadRemoteDataInfo {
} SLoadRemoteDataInfo;
typedef struct SLimitInfo {
- SLimit limit;
- SLimit slimit;
- uint64_t currentGroupId;
- int64_t remainGroupOffset;
- int64_t numOfOutputGroups;
- int64_t remainOffset;
- int64_t numOfOutputRows;
+ SLimit limit;
+ SLimit slimit;
+ uint64_t currentGroupId;
+ int64_t remainGroupOffset;
+ int64_t numOfOutputGroups;
+ int64_t remainOffset;
+ int64_t numOfOutputRows;
} SLimitInfo;
typedef struct SExchangeInfo {
- SArray* pSources;
- SArray* pSourceDataInfo;
- tsem_t ready;
- void* pTransporter;
+ SArray* pSources;
+ SArray* pSourceDataInfo;
+ tsem_t ready;
+ void* pTransporter;
// SArray, result block list, used to keep the multi-block that
// passed by downstream operator
SArray* pResultBlockList;
- int32_t rspBlockIndex; // indicate the return block index in pResultBlockList
- SSDataBlock* pDummyBlock; // dummy block, not keep data
- bool seqLoadData; // sequential load data or not, false by default
+ int32_t rspBlockIndex; // indicate the return block index in pResultBlockList
+ SSDataBlock* pDummyBlock; // dummy block, not keep data
+ bool seqLoadData; // sequential load data or not, false by default
int32_t current;
SLoadRemoteDataInfo loadInfo;
uint64_t self;
@@ -278,22 +278,22 @@ typedef struct SExchangeInfo {
} SExchangeInfo;
typedef struct SColMatchInfo {
- int32_t srcSlotId; // source slot id
+ int32_t srcSlotId; // source slot id
int32_t colId;
int32_t targetSlotId;
- bool output; // todo remove this?
+ bool output; // todo remove this?
bool reserved;
- int32_t matchType; // determinate the source according to col id or slot id
+ int32_t matchType; // determinate the source according to col id or slot id
} SColMatchInfo;
typedef struct SScanInfo {
- int32_t numOfAsc;
- int32_t numOfDesc;
+ int32_t numOfAsc;
+ int32_t numOfDesc;
} SScanInfo;
typedef struct SSampleExecInfo {
- double sampleRatio; // data block sample ratio, 1 by default
- uint32_t seed; // random seed value
+ double sampleRatio; // data block sample ratio, 1 by default
+ uint32_t seed; // random seed value
} SSampleExecInfo;
enum {
@@ -305,39 +305,40 @@ typedef struct SAggSupporter {
SSHashObj* pResultRowHashTable; // quick locate the window object for each result
char* keyBuf; // window key buffer
SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
- int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
- int32_t currentPageId; // current write page id
+ int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
+ int32_t currentPageId; // current write page id
} SAggSupporter;
typedef struct {
- // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if current data block needs to be loaded.
- SInterval interval;
- SAggSupporter *pAggSup;
- SExprSupp *pExprSup; // expr supporter of aggregate operator
+ // if the upstream is an interval operator, the interval info is also kept here to get the time window to check if
+ // current data block needs to be loaded.
+ SInterval interval;
+ SAggSupporter* pAggSup;
+ SExprSupp* pExprSup; // expr supporter of aggregate operator
} SAggOptrPushDownInfo;
typedef struct STableScanInfo {
- STsdbReader* dataReader;
- SReadHandle readHandle;
+ STsdbReader* dataReader;
+ SReadHandle readHandle;
SFileBlockLoadRecorder readRecorder;
- SScanInfo scanInfo;
- int32_t scanTimes;
- SNode* pFilterNode; // filter info, which is push down by optimizer
+ SScanInfo scanInfo;
+ int32_t scanTimes;
+ SNode* pFilterNode; // filter info, which is push down by optimizer
- SSDataBlock* pResBlock;
- SArray* pColMatchInfo;
- SExprSupp pseudoSup;
- SQueryTableDataCond cond;
- int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
- int32_t dataBlockLoadFlag;
- SSampleExecInfo sample; // sample execution info
- int32_t currentGroupId;
- int32_t currentTable;
- int8_t scanMode;
- int8_t noTable;
+ SSDataBlock* pResBlock;
+ SArray* pColMatchInfo;
+ SExprSupp pseudoSup;
+ SQueryTableDataCond cond;
+ int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
+ int32_t dataBlockLoadFlag;
+ SSampleExecInfo sample; // sample execution info
+ int32_t currentGroupId;
+ int32_t currentTable;
+ int8_t scanMode;
+ int8_t noTable;
SAggOptrPushDownInfo pdInfo;
- int8_t assignBlockUid;
+ int8_t assignBlockUid;
} STableScanInfo;
typedef struct STableMergeScanInfo {
@@ -370,7 +371,7 @@ typedef struct STableMergeScanInfo {
SArray* pColMatchInfo;
int32_t numOfOutput;
- SExprSupp pseudoSup;
+ SExprSupp pseudoSup;
SQueryTableDataCond cond;
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
@@ -384,33 +385,33 @@ typedef struct STableMergeScanInfo {
} STableMergeScanInfo;
typedef struct STagScanInfo {
- SColumnInfo *pCols;
- SSDataBlock *pRes;
- SArray *pColMatchInfo;
- int32_t curPos;
- SReadHandle readHandle;
- STableListInfo *pTableList;
+ SColumnInfo* pCols;
+ SSDataBlock* pRes;
+ SArray* pColMatchInfo;
+ int32_t curPos;
+ SReadHandle readHandle;
+ STableListInfo* pTableList;
} STagScanInfo;
typedef struct SLastrowScanInfo {
- SSDataBlock *pRes;
- SReadHandle readHandle;
- void *pLastrowReader;
- SArray *pColMatchInfo;
- int32_t *pSlotIds;
- SExprSupp pseudoExprSup;
- int32_t retrieveType;
- int32_t currentGroupIndex;
- SSDataBlock *pBufferredRes;
- SArray *pUidList;
- int32_t indexOfBufferedRes;
+ SSDataBlock* pRes;
+ SReadHandle readHandle;
+ void* pLastrowReader;
+ SArray* pColMatchInfo;
+ int32_t* pSlotIds;
+ SExprSupp pseudoExprSup;
+ int32_t retrieveType;
+ int32_t currentGroupIndex;
+ SSDataBlock* pBufferredRes;
+ SArray* pUidList;
+ int32_t indexOfBufferedRes;
} SLastrowScanInfo;
typedef enum EStreamScanMode {
STREAM_SCAN_FROM_READERHANDLE = 1,
STREAM_SCAN_FROM_RES,
STREAM_SCAN_FROM_UPDATERES,
- STREAM_SCAN_FROM_DELETERES,
+ STREAM_SCAN_FROM_DELETE_DATA,
STREAM_SCAN_FROM_DATAREADER_RETRIEVE,
STREAM_SCAN_FROM_DATAREADER_RANGE,
} EStreamScanMode;
@@ -432,10 +433,10 @@ typedef struct SStreamAggSupporter {
SArray* pCurWins;
int32_t valueSize;
int32_t keySize;
- char* pKeyBuf; // window key buffer
- SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
- int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
- int32_t currentPageId; // buffer page that is active
+ char* pKeyBuf; // window key buffer
+ SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file
+ int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
+ int32_t currentPageId; // buffer page that is active
SSDataBlock* pScanBlock;
} SStreamAggSupporter;
@@ -447,22 +448,22 @@ typedef struct SWindowSupporter {
} SWindowSupporter;
typedef struct SPartitionBySupporter {
- SArray* pGroupCols; // group by columns, SArray
- SArray* pGroupColVals; // current group column values, SArray
- char* keyBuf; // group by keys for hash
- bool needCalc; // partition by column
+ SArray* pGroupCols; // group by columns, SArray
+ SArray* pGroupColVals; // current group column values, SArray
+ char* keyBuf; // group by keys for hash
+ bool needCalc; // partition by column
} SPartitionBySupporter;
typedef struct SPartitionDataInfo {
- uint64_t groupId;
- SArray* rowIds;
+ uint64_t groupId;
+ SArray* rowIds;
} SPartitionDataInfo;
typedef struct STimeWindowSupp {
- int8_t calTrigger;
- int64_t waterMark;
- TSKEY maxTs;
- SColumnInfoData timeWindowData; // query time window info for scalar function execution.
+ int8_t calTrigger;
+ int64_t waterMark;
+ TSKEY maxTs;
+ SColumnInfoData timeWindowData; // query time window info for scalar function execution.
} STimeWindowAggSupp;
typedef struct SStreamScanInfo {
@@ -487,22 +488,22 @@ typedef struct SStreamScanInfo {
uint64_t groupId;
SUpdateInfo* pUpdateInfo;
- EStreamScanMode scanMode;
- SOperatorInfo* pStreamScanOp;
- SOperatorInfo* pTableScanOp;
- SArray* childIds;
- SWindowSupporter windowSup;
- SPartitionBySupporter partitionSup;
- SExprSupp* pPartScalarSup;
- bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA.
- int32_t scanWinIndex; // for state operator
- int32_t pullDataResIndex;
- SSDataBlock* pPullDataRes; // pull data SSDataBlock
- SSDataBlock* pDeleteDataRes; // delete data SSDataBlock
- int32_t deleteDataIndex;
- STimeWindow updateWin;
- STimeWindowAggSupp twAggSup;
- SSDataBlock* pUpdateDataRes;
+ EStreamScanMode scanMode;
+ SOperatorInfo* pStreamScanOp;
+ SOperatorInfo* pTableScanOp;
+ SArray* childIds;
+ SWindowSupporter windowSup;
+ SPartitionBySupporter partitionSup;
+ SExprSupp* pPartScalarSup;
+ bool assignBlockUid; // assign block uid to groupId, temporarily used for generating rollup SMA.
+ int32_t scanWinIndex; // for state operator
+ int32_t pullDataResIndex;
+ SSDataBlock* pPullDataRes; // pull data SSDataBlock
+ SSDataBlock* pDeleteDataRes; // delete data SSDataBlock
+ int32_t deleteDataIndex;
+ STimeWindow updateWin;
+ STimeWindowAggSupp twAggSup;
+ SSDataBlock* pUpdateDataRes;
// status for tmq
SNodeList* pGroupTags;
SNode* pTagCond;
@@ -571,17 +572,17 @@ typedef struct SIntervalAggOperatorInfo {
EOPTR_EXEC_MODEL execModel; // operator execution model [batch model|stream model]
STimeWindowAggSupp twAggSup;
bool invertible;
- SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation.
+ SArray* pPrevValues; // SArray used to keep the previous not null value for interpolation.
bool ignoreExpiredData;
SArray* pRecycledPages;
- SArray* pDelWins; // SWinRes
+ SArray* pDelWins; // SWinRes
int32_t delIndex;
SSDataBlock* pDelRes;
SNode* pCondition;
} SIntervalAggOperatorInfo;
typedef struct SMergeAlignedIntervalAggOperatorInfo {
- SIntervalAggOperatorInfo *intervalAggOperatorInfo;
+ SIntervalAggOperatorInfo* intervalAggOperatorInfo;
bool hasGroupId;
uint64_t groupId; // current groupId
@@ -590,7 +591,7 @@ typedef struct SMergeAlignedIntervalAggOperatorInfo {
SNode* pCondition;
} SMergeAlignedIntervalAggOperatorInfo;
-typedef struct SStreamFinalIntervalOperatorInfo {
+typedef struct SStreamIntervalOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
SOptrBasicInfo binfo; // basic info
SAggSupporter aggSup; // aggregate supporter
@@ -598,57 +599,75 @@ typedef struct SStreamFinalIntervalOperatorInfo {
SGroupResInfo groupResInfo; // multiple results build supporter
SInterval interval; // interval info
int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator.
- int32_t order; // current SSDataBlock scan order
+ STimeWindowAggSupp twAggSup;
+ bool invertible;
+ bool ignoreExpiredData;
+ SArray* pRecycledPages;
+ SArray* pDelWins; // SWinRes
+ int32_t delIndex;
+ SSDataBlock* pDelRes;
+ bool isFinal;
+} SStreamIntervalOperatorInfo;
+
+typedef struct SStreamFinalIntervalOperatorInfo {
+ // SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
+ SOptrBasicInfo binfo; // basic info
+ SAggSupporter aggSup; // aggregate supporter
+ SExprSupp scalarSupp; // supporter for perform scalar function
+ SGroupResInfo groupResInfo; // multiple results build supporter
+ SInterval interval; // interval info
+ int32_t primaryTsIndex; // primary time stamp slot id from result of downstream operator.
+ int32_t order; // current SSDataBlock scan order
STimeWindowAggSupp twAggSup;
SArray* pChildren;
SSDataBlock* pUpdateRes;
bool returnUpdate;
- SPhysiNode* pPhyNode; // create new child
+ SPhysiNode* pPhyNode; // create new child
bool isFinal;
SHashObj* pPullDataMap;
- SArray* pPullWins; // SPullWindowInfo
+ SArray* pPullWins; // SPullWindowInfo
int32_t pullIndex;
SSDataBlock* pPullDataRes;
bool ignoreExpiredData;
SArray* pRecycledPages;
- SArray* pDelWins; // SWinRes
+ SArray* pDelWins; // SWinRes
int32_t delIndex;
SSDataBlock* pDelRes;
} SStreamFinalIntervalOperatorInfo;
typedef struct SAggOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
- STableQueryInfo *current;
- uint64_t groupId;
- SGroupResInfo groupResInfo;
- SExprSupp scalarExprSup;
- SNode *pCondition;
+ STableQueryInfo* current;
+ uint64_t groupId;
+ SGroupResInfo groupResInfo;
+ SExprSupp scalarExprSup;
+ SNode* pCondition;
} SAggOperatorInfo;
typedef struct SProjectOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
- SNode* pFilterNode; // filter info, which is push down by optimizer
- SArray* pPseudoColInfo;
- SLimitInfo limitInfo;
- bool mergeDataBlocks;
- SSDataBlock* pFinalRes;
- SNode* pCondition;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
+ SNode* pFilterNode; // filter info, which is push down by optimizer
+ SArray* pPseudoColInfo;
+ SLimitInfo limitInfo;
+ bool mergeDataBlocks;
+ SSDataBlock* pFinalRes;
+ SNode* pCondition;
} SProjectOperatorInfo;
typedef struct SIndefOperatorInfo {
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
- SArray* pPseudoColInfo;
- SExprSupp scalarSup;
- SNode* pCondition;
- uint64_t groupId;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
+ SArray* pPseudoColInfo;
+ SExprSupp scalarSup;
+ SNode* pCondition;
+ uint64_t groupId;
- SSDataBlock* pNextGroupRes;
+ SSDataBlock* pNextGroupRes;
} SIndefOperatorInfo;
typedef struct SFillOperatorInfo {
@@ -663,7 +682,7 @@ typedef struct SFillOperatorInfo {
SArray* pColMatchColInfo;
int32_t primaryTsCol;
int32_t primarySrcSlotId;
- uint64_t curGroupId; // current handled group id
+ uint64_t curGroupId; // current handled group id
SExprInfo* pExprInfo;
int32_t numOfExpr;
SExprInfo* pNotFillExprInfo;
@@ -672,23 +691,23 @@ typedef struct SFillOperatorInfo {
typedef struct SGroupbyOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
- SArray* pGroupCols; // group by columns, SArray
- SArray* pGroupColVals; // current group column values, SArray
- SNode* pCondition;
- bool isInit; // denote if current val is initialized or not
- char* keyBuf; // group by keys for hash
- int32_t groupKeyLen; // total group by column width
- SGroupResInfo groupResInfo;
- SExprSupp scalarSup;
+ SArray* pGroupCols; // group by columns, SArray
+ SArray* pGroupColVals; // current group column values, SArray
+ SNode* pCondition;
+ bool isInit; // denote if current val is initialized or not
+ char* keyBuf; // group by keys for hash
+ int32_t groupKeyLen; // total group by column width
+ SGroupResInfo groupResInfo;
+ SExprSupp scalarSup;
} SGroupbyOperatorInfo;
typedef struct SDataGroupInfo {
- uint64_t groupId;
- int64_t numOfRows;
- SArray* pPageList;
+ uint64_t groupId;
+ int64_t numOfRows;
+ SArray* pPageList;
} SDataGroupInfo;
// The sort in partition may be needed later.
@@ -700,12 +719,12 @@ typedef struct SPartitionOperatorInfo {
int32_t groupKeyLen; // total group by column width
SHashObj* pGroupSet; // quick locate the window object for each result
- SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file
- int32_t rowCapacity; // maximum number of rows for each buffer page
- int32_t* columnOffset; // start position for each column data
- SArray* sortedGroupArray; // SDataGroupInfo sorted by group id
- int32_t groupIndex; // group index
- int32_t pageIndex; // page index of current group
+ SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file
+ int32_t rowCapacity; // maximum number of rows for each buffer page
+ int32_t* columnOffset; // start position for each column data
+ SArray* sortedGroupArray; // SDataGroupInfo sorted by group id
+ int32_t groupIndex; // group index
+ int32_t pageIndex; // page index of current group
SExprSupp scalarSup;
} SPartitionOperatorInfo;
@@ -719,52 +738,52 @@ typedef struct SWindowRowsSup {
typedef struct SSessionAggOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
SGroupResInfo groupResInfo;
SWindowRowsSup winSup;
- bool reptScan; // next round scan
- int64_t gap; // session window gap
- int32_t tsSlotId; // primary timestamp slot id
+ bool reptScan; // next round scan
+ int64_t gap; // session window gap
+ int32_t tsSlotId; // primary timestamp slot id
STimeWindowAggSupp twAggSup;
- const SNode* pCondition;
+ const SNode* pCondition;
} SSessionAggOperatorInfo;
typedef struct SResultWindowInfo {
SResultRowPosition pos;
- STimeWindow win;
- uint64_t groupId;
- bool isOutput;
- bool isClosed;
+ STimeWindow win;
+ uint64_t groupId;
+ bool isOutput;
+ bool isClosed;
} SResultWindowInfo;
typedef struct SStateWindowInfo {
SResultWindowInfo winInfo;
- SStateKeys stateKey;
+ SStateKeys stateKey;
} SStateWindowInfo;
typedef struct SStreamSessionAggOperatorInfo {
- SOptrBasicInfo binfo;
- SStreamAggSupporter streamAggSup;
- SExprSupp scalarSupp; // supporter for perform scalar function
- SGroupResInfo groupResInfo;
- int64_t gap; // session window gap
- int32_t primaryTsIndex; // primary timestamp slot id
- int32_t endTsIndex; // window end timestamp slot id
- int32_t order; // current SSDataBlock scan order
- STimeWindowAggSupp twAggSup;
- SSDataBlock* pWinBlock; // window result
- SqlFunctionCtx* pDummyCtx; // for combine
- SSDataBlock* pDelRes; // delete result
- SSDataBlock* pUpdateRes; // update window
- bool returnUpdate;
- SHashObj* pStDeleted;
- void* pDelIterator;
- SArray* pChildren; // cache for children's result; final stream operator
- SPhysiNode* pPhyNode; // create new child
- bool isFinal;
- bool ignoreExpiredData;
+ SOptrBasicInfo binfo;
+ SStreamAggSupporter streamAggSup;
+ SExprSupp scalarSupp; // supporter for perform scalar function
+ SGroupResInfo groupResInfo;
+ int64_t gap; // session window gap
+ int32_t primaryTsIndex; // primary timestamp slot id
+ int32_t endTsIndex; // window end timestamp slot id
+ int32_t order; // current SSDataBlock scan order
+ STimeWindowAggSupp twAggSup;
+ SSDataBlock* pWinBlock; // window result
+ SqlFunctionCtx* pDummyCtx; // for combine
+ SSDataBlock* pDelRes; // delete result
+ SSDataBlock* pUpdateRes; // update window
+ bool returnUpdate;
+ SHashObj* pStDeleted;
+ void* pDelIterator;
+ SArray* pChildren; // cache for children's result; final stream operator
+ SPhysiNode* pPhyNode; // create new child
+ bool isFinal;
+ bool ignoreExpiredData;
} SStreamSessionAggOperatorInfo;
typedef struct SStreamPartitionOperatorInfo {
@@ -775,29 +794,30 @@ typedef struct SStreamPartitionOperatorInfo {
void* parIte;
SSDataBlock* pInputDataBlock;
int32_t tsColIndex;
+ SSDataBlock* pDelRes;
} SStreamPartitionOperatorInfo;
typedef struct STimeSliceOperatorInfo {
- SSDataBlock* pRes;
- STimeWindow win;
- SInterval interval;
- int64_t current;
- SArray* pPrevRow; // SArray
- SArray* pNextRow; // SArray
- SArray* pLinearInfo; // SArray
- bool fillLastPoint;
- bool isPrevRowSet;
- bool isNextRowSet;
- int32_t fillType; // fill type
- SColumn tsCol; // primary timestamp column
- SExprSupp scalarSup; // scalar calculation
- struct SFillColInfo* pFillColInfo; // fill column info
+ SSDataBlock* pRes;
+ STimeWindow win;
+ SInterval interval;
+ int64_t current;
+ SArray* pPrevRow; // SArray
+ SArray* pNextRow; // SArray
+ SArray* pLinearInfo; // SArray
+ bool fillLastPoint;
+ bool isPrevRowSet;
+ bool isNextRowSet;
+ int32_t fillType; // fill type
+ SColumn tsCol; // primary timestamp column
+ SExprSupp scalarSup; // scalar calculation
+ struct SFillColInfo* pFillColInfo; // fill column info
} STimeSliceOperatorInfo;
typedef struct SStateWindowOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
SGroupResInfo groupResInfo;
SWindowRowsSup winSup;
@@ -811,52 +831,52 @@ typedef struct SStateWindowOperatorInfo {
} SStateWindowOperatorInfo;
typedef struct SStreamStateAggOperatorInfo {
- SOptrBasicInfo binfo;
- SStreamAggSupporter streamAggSup;
- SExprSupp scalarSupp; // supporter for perform scalar function
- SGroupResInfo groupResInfo;
- int32_t primaryTsIndex; // primary timestamp slot id
- int32_t order; // current SSDataBlock scan order
- STimeWindowAggSupp twAggSup;
- SColumn stateCol;
- SqlFunctionCtx* pDummyCtx; // for combine
- SSDataBlock* pDelRes;
- SHashObj* pSeDeleted;
- void* pDelIterator;
- SArray* pChildren; // cache for children's result;
- bool ignoreExpiredData;
+ SOptrBasicInfo binfo;
+ SStreamAggSupporter streamAggSup;
+ SExprSupp scalarSupp; // supporter for perform scalar function
+ SGroupResInfo groupResInfo;
+ int32_t primaryTsIndex; // primary timestamp slot id
+ int32_t order; // current SSDataBlock scan order
+ STimeWindowAggSupp twAggSup;
+ SColumn stateCol;
+ SqlFunctionCtx* pDummyCtx; // for combine
+ SSDataBlock* pDelRes;
+ SHashObj* pSeDeleted;
+ void* pDelIterator;
+ SArray* pChildren; // cache for children's result;
+ bool ignoreExpiredData;
} SStreamStateAggOperatorInfo;
typedef struct SSortedMergeOperatorInfo {
// SOptrBasicInfo should be first, SAggSupporter should be second for stream encode
- SOptrBasicInfo binfo;
- SAggSupporter aggSup;
+ SOptrBasicInfo binfo;
+ SAggSupporter aggSup;
- SArray* pSortInfo;
- int32_t numOfSources;
- SSortHandle *pSortHandle;
- int32_t bufPageSize;
- uint32_t sortBufSize; // max buffer size for in-memory sort
- int32_t resultRowFactor;
- bool hasGroupVal;
- SDiskbasedBuf *pTupleStore; // keep the final results
- int32_t numOfResPerPage;
- char** groupVal;
- SArray *groupInfo;
+ SArray* pSortInfo;
+ int32_t numOfSources;
+ SSortHandle* pSortHandle;
+ int32_t bufPageSize;
+ uint32_t sortBufSize; // max buffer size for in-memory sort
+ int32_t resultRowFactor;
+ bool hasGroupVal;
+ SDiskbasedBuf* pTupleStore; // keep the final results
+ int32_t numOfResPerPage;
+ char** groupVal;
+ SArray* groupInfo;
} SSortedMergeOperatorInfo;
typedef struct SSortOperatorInfo {
SOptrBasicInfo binfo;
- uint32_t sortBufSize; // max buffer size for in-memory sort
- SArray* pSortInfo;
- SSortHandle* pSortHandle;
- SArray* pColMatchInfo; // for index map from table scan output
- int32_t bufPageSize;
+ uint32_t sortBufSize; // max buffer size for in-memory sort
+ SArray* pSortInfo;
+ SSortHandle* pSortHandle;
+ SArray* pColMatchInfo; // for index map from table scan output
+ int32_t bufPageSize;
- int64_t startTs; // sort start time
- uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
- SLimitInfo limitInfo;
- SNode* pCondition;
+ int64_t startTs; // sort start time
+ uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
+ SLimitInfo limitInfo;
+ SNode* pCondition;
} SSortOperatorInfo;
typedef struct STagFilterOperatorInfo {
@@ -864,18 +884,18 @@ typedef struct STagFilterOperatorInfo {
} STagFilterOperatorInfo;
typedef struct SJoinOperatorInfo {
- SSDataBlock *pRes;
- int32_t joinType;
- int32_t inputOrder;
+ SSDataBlock* pRes;
+ int32_t joinType;
+ int32_t inputOrder;
- SSDataBlock *pLeft;
- int32_t leftPos;
- SColumnInfo leftCol;
+ SSDataBlock* pLeft;
+ int32_t leftPos;
+ SColumnInfo leftCol;
- SSDataBlock *pRight;
- int32_t rightPos;
- SColumnInfo rightCol;
- SNode *pCondAfterMerge;
+ SSDataBlock* pRight;
+ int32_t rightPos;
+ SColumnInfo rightCol;
+ SNode* pCondAfterMerge;
} SJoinOperatorInfo;
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
@@ -884,8 +904,8 @@ typedef struct SJoinOperatorInfo {
void doDestroyExchangeOperatorInfo(void* param);
SOperatorFpSet createOperatorFpSet(__optr_open_fn_t openFn, __optr_fn_t nextFn, __optr_fn_t streamFn,
- __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
- __optr_decode_fn_t decode, __optr_explain_fn_t explain);
+ __optr_fn_t cleanup, __optr_close_fn_t closeFn, __optr_encode_fn_t encode,
+ __optr_decode_fn_t decode, __optr_explain_fn_t explain);
int32_t operatorDummyOpenFn(SOperatorInfo* pOperator);
void operatorDummyCloseFn(void* param, int32_t numOfCols);
@@ -896,24 +916,25 @@ void cleanupBasicInfo(SOptrBasicInfo* pInfo);
int32_t initExprSupp(SExprSupp* pSup, SExprInfo* pExprInfo, int32_t numOfExpr);
void cleanupExprSupp(SExprSupp* pSup);
void destroyExprInfo(SExprInfo* pExpr, int32_t numOfExprs);
-int32_t initAggInfo(SExprSupp *pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
+int32_t initAggInfo(SExprSupp* pSup, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, size_t keyBufSize,
const char* pkey);
-void initResultSizeInfo(SResultInfo * pResultInfo, int32_t numOfRows);
-void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo, SDiskbasedBuf* pBuf);
-int32_t handleLimitOffset(SOperatorInfo *pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf);
+void initResultSizeInfo(SResultInfo* pResultInfo, int32_t numOfRows);
+void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo,
+ SDiskbasedBuf* pBuf);
+int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf);
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo);
-void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, int32_t offset,
- int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput);
+void doApplyFunctions(SExecTaskInfo* taskInfo, SqlFunctionCtx* pCtx, SColumnInfoData* pTimeWindowData, int32_t offset,
+ int32_t forwardStep, int32_t numOfTotal, int32_t numOfOutput);
-int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, int32_t numOfOutput, SArray* pColList, char** pNextStart);
-void updateLoadRemoteInfo(SLoadRemoteDataInfo *pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
- SOperatorInfo* pOperator);
+int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart);
+void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t dataLen, int64_t startTs,
+ SOperatorInfo* pOperator);
STimeWindow getFirstQualifiedTimeWindow(int64_t ts, STimeWindow* pWindow, SInterval* pInterval, int32_t order);
-int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t *order, int32_t* scanFlag);
+int32_t getTableScanInfo(SOperatorInfo* pOperator, int32_t* order, int32_t* scanFlag);
int32_t getBufferPgSize(int32_t rowSize, uint32_t* defaultPgsz, uint32_t* defaultBufsz);
void doSetOperatorCompleted(SOperatorInfo* pOperator);
@@ -921,10 +942,10 @@ void doFilter(const SNode* pFilterNode, SSDataBlock* pBlock, const SArray* pC
int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int32_t numOfPseudoExpr,
SSDataBlock* pBlock, const char* idStr);
-void cleanupAggSup(SAggSupporter* pAggSup);
-void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
-void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
-void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId);
+void cleanupAggSup(SAggSupporter* pAggSup);
+void destroyBasicOperatorInfo(void* param, int32_t numOfOutput);
+void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
+void setTbNameColData(void* pMeta, const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId);
int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts);
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts);
@@ -933,29 +954,37 @@ SSDataBlock* loadNextDataBlock(void* param);
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
-SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo,
- char* pData, int16_t bytes, bool masterscan, uint64_t groupId,
- SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup);
+SResultRow* doSetResultOutBufByKey(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, char* pData,
+ int16_t bytes, bool masterscan, uint64_t groupId, SExecTaskInfo* pTaskInfo,
+ bool isIntervalQuery, SAggSupporter* pSup);
SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode* pExNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* pHandle,
+ SExecTaskInfo* pTaskInfo);
SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysiNode* pPhyNode,
STableListInfo* pTableListInfo, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode *pScanPhyNode, const char* pUser, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNode* pScanPhyNode,
+ const char* pUser, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
+SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
+ SSDataBlock* pResultBlock, SNode* pCondition, SExprInfo* pScalarExprInfo,
int32_t numOfScalarExpr, bool mergeResult, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode *pNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createIndefinitOutputOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode,
+ SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SProjectPhysiNode* pProjPhyNode,
+ SExecTaskInfo* pTaskInfo);
SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSortPhysiNode* pSortNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams, SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createMultiwayMergeOperatorInfo(SOperatorInfo** dowStreams, size_t numStreams,
+ SMergePhysiNode* pMergePhysiNode, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pTableScanNode, SReadHandle* readHandle,
+ SExecTaskInfo* pTaskInfo);
SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols,
SSDataBlock* pResBlock, SInterval* pInterval, int32_t primaryTsSlotId,
- STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, bool isStream);
+ STimeWindowAggSupp* pTwAggSupp, SIntervalPhysiNode* pPhyNode,
+ SExecTaskInfo* pTaskInfo, bool isStream);
SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMergeIntervalPhysiNode* pIntervalPhyNode,
SExecTaskInfo* pTaskInfo);
SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream, SMergeAlignedIntervalPhysiNode* pNode,
@@ -975,33 +1004,41 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWinodwPhysiNode* pStateNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo);
-
-SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo);
-
-SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream, SSortMergeJoinPhysiNode* pJoinNode,
+SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode,
+ SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWinodwPhysiNode* pStateNode,
+ SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode,
SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream,
- SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream,
- SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo, int32_t numOfChild);
+SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode,
+ SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createTimeSliceOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pNode, SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createMergeJoinOperatorInfo(SOperatorInfo** pDownstream, int32_t numOfDownstream,
+ SSortMergeJoinPhysiNode* pJoinNode, SExecTaskInfo* pTaskInfo);
+
+SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
+ SExecTaskInfo* pTaskInfo);
+SOperatorInfo* createStreamFinalSessionAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
+ SExecTaskInfo* pTaskInfo, int32_t numOfChild);
+SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream,
+ SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo);
+
+SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
+ SExecTaskInfo* pTaskInfo);
int32_t projectApplyFunctions(SExprInfo* pExpr, SSDataBlock* pResult, SSDataBlock* pSrcBlock, SqlFunctionCtx* pCtx,
- int32_t numOfOutput, SArray* pPseudoList);
+ int32_t numOfOutput, SArray* pPseudoList);
-void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order, int32_t scanFlag, bool createDummyCol);
+void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order,
+ int32_t scanFlag, bool createDummyCol);
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
int32_t checkForQueryBuf(size_t numOfTables);
-void setTaskKilled(SExecTaskInfo* pTaskInfo);
-void queryCostStatis(SExecTaskInfo* pTaskInfo);
+void setTaskKilled(SExecTaskInfo* pTaskInfo);
+void queryCostStatis(SExecTaskInfo* pTaskInfo);
void doDestroyTask(SExecTaskInfo* pTaskInfo);
int32_t getMaximumIdleDurationSec();
@@ -1013,7 +1050,7 @@ int32_t getMaximumIdleDurationSec();
* nOptrWithVal: *nOptrWithVal save the number of optr with value
* return: result code, 0 means success
*/
-int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t *length, int32_t *nOptrWithVal);
+int32_t encodeOperator(SOperatorInfo* ops, char** data, int32_t* length, int32_t* nOptrWithVal);
/*
* ops: root operator, created by caller
@@ -1026,7 +1063,7 @@ int32_t decodeOperator(SOperatorInfo* ops, const char* data, int32_t length);
void setTaskStatus(SExecTaskInfo* pTaskInfo, int8_t status);
int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SReadHandle* pHandle, uint64_t taskId,
char* sql, EOPTR_EXEC_MODEL model);
-int32_t createDataSinkParam(SDataSinkNode *pNode, void **pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
+int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList);
int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
@@ -1035,42 +1072,50 @@ int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* len
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
int32_t order);
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
- __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
+ __block_search_fn_t searchFn, STableQueryInfo* item, int32_t order);
int32_t binarySearchForKey(char* pValue, int num, TSKEY key, int order);
int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlFunctionCtx* pCtx, int32_t numOfOutput,
- int32_t size);
-SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize);
-SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs,
- TSKEY endTs, uint64_t groupId, int64_t gap, int32_t* pIndex);
-SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs,
- TSKEY endTs, uint64_t groupId, int64_t gap, int32_t* pIndex);
-bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap);
-bool functionNeedToExecute(SqlFunctionCtx* pCtx);
-bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
-bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup);
-bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup);
-void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp);
-void printDataBlock(SSDataBlock* pBlock, const char* flag);
+ int32_t size);
+SResultRow* getNewResultRow(SDiskbasedBuf* pResultBuf, int32_t* currentPageId, int32_t interBufSize);
+SResultWindowInfo* getSessionTimeWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId,
+ int64_t gap, int32_t* pIndex);
+SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId,
+ int64_t gap, int32_t* pIndex);
+bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap);
+bool functionNeedToExecute(SqlFunctionCtx* pCtx);
+bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup);
+bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup);
+bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup);
+void appendOneRow(SSDataBlock* pBlock, TSKEY* pStartTs, TSKEY* pEndTs, uint64_t* pUid, uint64_t* pGp);
+void printDataBlock(SSDataBlock* pBlock, const char* flag);
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId);
int32_t finalizeResultRowIntoResultDataBlock(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPosition,
- SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs, const int32_t* rowCellOffset,
- SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo);
+ SqlFunctionCtx* pCtx, SExprInfo* pExprInfo, int32_t numOfExprs,
+ const int32_t* rowCellOffset, SSDataBlock* pBlock,
+ SExecTaskInfo* pTaskInfo);
-int32_t createScanTableListInfo(SScanPhysiNode *pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
- STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond, const char* idstr);
+int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags, bool groupSort, SReadHandle* pHandle,
+ STableListInfo* pTableListInfo, SNode* pTagCond, SNode* pTagIndexCond,
+ const char* idstr);
SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode,
SExecTaskInfo* pTaskInfo);
-SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, STableListInfo *pTableListInfo,
+SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, STableListInfo* pTableListInfo,
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
-bool groupbyTbname(SNodeList* pGroupList);
+bool groupbyTbname(SNodeList* pGroupList);
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey);
-SSDataBlock* createSpecialDataBlock(EStreamType type);
-void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
+void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
+int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup,
+ SGroupResInfo* pGroupResInfo);
+int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
+ int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup,
+ SExecTaskInfo* pTaskInfo);
+int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult);
+int32_t saveOutput(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize);
#ifdef __cplusplus
}
diff --git a/source/libs/executor/src/dataDeleter.c b/source/libs/executor/src/dataDeleter.c
index 06b7c13fa2..40198615ea 100644
--- a/source/libs/executor/src/dataDeleter.c
+++ b/source/libs/executor/src/dataDeleter.c
@@ -168,7 +168,9 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
memcpy(&pDeleter->nextOutput, pBuf, sizeof(SDataDeleterBuf));
taosFreeQitem(pBuf);
- *pLen = ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->dataLen;
+
+ SDataCacheEntry* pEntry = (SDataCacheEntry*)pDeleter->nextOutput.pData;
+ *pLen = pEntry->dataLen;
*pQueryEnd = pDeleter->queryEnd;
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows);
}
diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c
index 20396046ba..1697ed63fb 100644
--- a/source/libs/executor/src/dataDispatcher.c
+++ b/source/libs/executor/src/dataDispatcher.c
@@ -93,6 +93,8 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn
pBuf->useSize = sizeof(SDataCacheEntry);
blockEncode(pInput->pData, pEntry->data, &pEntry->dataLen, numOfCols, pEntry->compressed);
+ ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data+8));
+ ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data+8+4));
pBuf->useSize += pEntry->dataLen;
@@ -170,7 +172,13 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
taosReadQitem(pDispatcher->pDataBlocks, (void**)&pBuf);
memcpy(&pDispatcher->nextOutput, pBuf, sizeof(SDataDispatchBuf));
taosFreeQitem(pBuf);
- *pLen = ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->dataLen;
+
+ SDataCacheEntry* pEntry = (SDataCacheEntry*)pDispatcher->nextOutput.pData;
+ *pLen = pEntry->dataLen;
+
+ ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data+8));
+ ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data+8+4));
+
*pQueryEnd = pDispatcher->queryEnd;
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->numOfRows);
}
@@ -191,6 +199,9 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
pOutput->numOfCols = pEntry->numOfCols;
pOutput->compressed = pEntry->compressed;
+ ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data+8));
+ ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data+8+4));
+
atomic_sub_fetch_64(&pDispatcher->cachedSize, pEntry->dataLen);
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c
index 3965b7e5b2..0c1728386b 100644
--- a/source/libs/executor/src/executil.c
+++ b/source/libs/executor/src/executil.c
@@ -475,7 +475,6 @@ static SColumnInfoData* getColInfoResult(void* metaHandle, uint64_t suid, SArray
if (code != TSDB_CODE_SUCCESS) {
terrno = code;
qError("failed to create result, reason:%s", tstrerror(code));
- terrno = code;
goto end;
}
@@ -1012,6 +1011,100 @@ static SColumn* createColumn(int32_t blockId, int32_t slotId, int32_t colId, SDa
return pCol;
}
+void createExprFromTargetNode(SExprInfo* pExp, STargetNode* pTargetNode) {
+ pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
+ pExp->pExpr->_function.num = 1;
+ pExp->pExpr->_function.functionId = -1;
+
+ int32_t type = nodeType(pTargetNode->pExpr);
+ // it is a project query, or group by column
+ if (type == QUERY_NODE_COLUMN) {
+ pExp->pExpr->nodeType = QUERY_NODE_COLUMN;
+ SColumnNode* pColNode = (SColumnNode*)pTargetNode->pExpr;
+
+ pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
+ pExp->base.numOfParams = 1;
+
+ SDataType* pType = &pColNode->node.resType;
+ pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
+ pType->precision, pColNode->colName);
+ pExp->base.pParam[0].pCol =
+ createColumn(pColNode->dataBlockId, pColNode->slotId, pColNode->colId, pType, pColNode->colType);
+ pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
+ } else if (type == QUERY_NODE_VALUE) {
+ pExp->pExpr->nodeType = QUERY_NODE_VALUE;
+ SValueNode* pValNode = (SValueNode*)pTargetNode->pExpr;
+
+ pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
+ pExp->base.numOfParams = 1;
+
+ SDataType* pType = &pValNode->node.resType;
+ pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
+ pType->precision, pValNode->node.aliasName);
+ pExp->base.pParam[0].type = FUNC_PARAM_TYPE_VALUE;
+ nodesValueNodeToVariant(pValNode, &pExp->base.pParam[0].param);
+ } else if (type == QUERY_NODE_FUNCTION) {
+ pExp->pExpr->nodeType = QUERY_NODE_FUNCTION;
+ SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr;
+
+ SDataType* pType = &pFuncNode->node.resType;
+ pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
+ pType->precision, pFuncNode->node.aliasName);
+
+ pExp->pExpr->_function.functionId = pFuncNode->funcId;
+ pExp->pExpr->_function.pFunctNode = pFuncNode;
+
+ strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName,
+ tListLen(pExp->pExpr->_function.functionName));
+#if 1
+ // todo refactor: add the parameter for tbname function
+ if (!pFuncNode->pParameterList && (strcmp(pExp->pExpr->_function.functionName, "tbname") == 0)) {
+ pFuncNode->pParameterList = nodesMakeList();
+ ASSERT(LIST_LENGTH(pFuncNode->pParameterList) == 0);
+ SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
+ if (NULL == res) { // todo handle error
+ } else {
+ res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
+ nodesListAppend(pFuncNode->pParameterList, (SNode*)res);
+ }
+ }
+#endif
+
+ int32_t numOfParam = LIST_LENGTH(pFuncNode->pParameterList);
+
+ pExp->base.pParam = taosMemoryCalloc(numOfParam, sizeof(SFunctParam));
+ pExp->base.numOfParams = numOfParam;
+
+ for (int32_t j = 0; j < numOfParam; ++j) {
+ SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j);
+ if (p1->type == QUERY_NODE_COLUMN) {
+ SColumnNode* pcn = (SColumnNode*)p1;
+
+ pExp->base.pParam[j].type = FUNC_PARAM_TYPE_COLUMN;
+ pExp->base.pParam[j].pCol =
+ createColumn(pcn->dataBlockId, pcn->slotId, pcn->colId, &pcn->node.resType, pcn->colType);
+ } else if (p1->type == QUERY_NODE_VALUE) {
+ SValueNode* pvn = (SValueNode*)p1;
+ pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE;
+ nodesValueNodeToVariant(pvn, &pExp->base.pParam[j].param);
+ }
+ }
+ } else if (type == QUERY_NODE_OPERATOR) {
+ pExp->pExpr->nodeType = QUERY_NODE_OPERATOR;
+ SOperatorNode* pNode = (SOperatorNode*)pTargetNode->pExpr;
+
+ pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
+ pExp->base.numOfParams = 1;
+
+ SDataType* pType = &pNode->node.resType;
+ pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
+ pType->precision, pNode->node.aliasName);
+ pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr;
+ } else {
+ ASSERT(0);
+ }
+}
+
SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* numOfExprs) {
int32_t numOfFuncs = LIST_LENGTH(pNodeList);
int32_t numOfGroupKeys = 0;
@@ -1035,98 +1128,7 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t*
}
SExprInfo* pExp = &pExprs[i];
-
- pExp->pExpr = taosMemoryCalloc(1, sizeof(tExprNode));
- pExp->pExpr->_function.num = 1;
- pExp->pExpr->_function.functionId = -1;
-
- int32_t type = nodeType(pTargetNode->pExpr);
- // it is a project query, or group by column
- if (type == QUERY_NODE_COLUMN) {
- pExp->pExpr->nodeType = QUERY_NODE_COLUMN;
- SColumnNode* pColNode = (SColumnNode*)pTargetNode->pExpr;
-
- pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
- pExp->base.numOfParams = 1;
-
- SDataType* pType = &pColNode->node.resType;
- pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
- pType->precision, pColNode->colName);
- pExp->base.pParam[0].pCol =
- createColumn(pColNode->dataBlockId, pColNode->slotId, pColNode->colId, pType, pColNode->colType);
- pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN;
- } else if (type == QUERY_NODE_VALUE) {
- pExp->pExpr->nodeType = QUERY_NODE_VALUE;
- SValueNode* pValNode = (SValueNode*)pTargetNode->pExpr;
-
- pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
- pExp->base.numOfParams = 1;
-
- SDataType* pType = &pValNode->node.resType;
- pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
- pType->precision, pValNode->node.aliasName);
- pExp->base.pParam[0].type = FUNC_PARAM_TYPE_VALUE;
- nodesValueNodeToVariant(pValNode, &pExp->base.pParam[0].param);
- } else if (type == QUERY_NODE_FUNCTION) {
- pExp->pExpr->nodeType = QUERY_NODE_FUNCTION;
- SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr;
-
- SDataType* pType = &pFuncNode->node.resType;
- pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
- pType->precision, pFuncNode->node.aliasName);
-
- pExp->pExpr->_function.functionId = pFuncNode->funcId;
- pExp->pExpr->_function.pFunctNode = pFuncNode;
-
- strncpy(pExp->pExpr->_function.functionName, pFuncNode->functionName,
- tListLen(pExp->pExpr->_function.functionName));
-#if 1
- // todo refactor: add the parameter for tbname function
- if (!pFuncNode->pParameterList && (strcmp(pExp->pExpr->_function.functionName, "tbname") == 0)) {
- pFuncNode->pParameterList = nodesMakeList();
- ASSERT(LIST_LENGTH(pFuncNode->pParameterList) == 0);
- SValueNode* res = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE);
- if (NULL == res) { // todo handle error
- } else {
- res->node.resType = (SDataType){.bytes = sizeof(int64_t), .type = TSDB_DATA_TYPE_BIGINT};
- nodesListAppend(pFuncNode->pParameterList, (SNode*)res);
- }
- }
-#endif
-
- int32_t numOfParam = LIST_LENGTH(pFuncNode->pParameterList);
-
- pExp->base.pParam = taosMemoryCalloc(numOfParam, sizeof(SFunctParam));
- pExp->base.numOfParams = numOfParam;
-
- for (int32_t j = 0; j < numOfParam; ++j) {
- SNode* p1 = nodesListGetNode(pFuncNode->pParameterList, j);
- if (p1->type == QUERY_NODE_COLUMN) {
- SColumnNode* pcn = (SColumnNode*)p1;
-
- pExp->base.pParam[j].type = FUNC_PARAM_TYPE_COLUMN;
- pExp->base.pParam[j].pCol =
- createColumn(pcn->dataBlockId, pcn->slotId, pcn->colId, &pcn->node.resType, pcn->colType);
- } else if (p1->type == QUERY_NODE_VALUE) {
- SValueNode* pvn = (SValueNode*)p1;
- pExp->base.pParam[j].type = FUNC_PARAM_TYPE_VALUE;
- nodesValueNodeToVariant(pvn, &pExp->base.pParam[j].param);
- }
- }
- } else if (type == QUERY_NODE_OPERATOR) {
- pExp->pExpr->nodeType = QUERY_NODE_OPERATOR;
- SOperatorNode* pNode = (SOperatorNode*)pTargetNode->pExpr;
-
- pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam));
- pExp->base.numOfParams = 1;
-
- SDataType* pType = &pNode->node.resType;
- pExp->base.resSchema = createResSchema(pType->type, pType->bytes, pTargetNode->slotId, pType->scale,
- pType->precision, pNode->node.aliasName);
- pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr;
- } else {
- ASSERT(0);
- }
+ createExprFromTargetNode(pExp, pTargetNode);
}
return pExprs;
diff --git a/source/libs/executor/src/executor.c b/source/libs/executor/src/executor.c
index 12118fad72..95415e1113 100644
--- a/source/libs/executor/src/executor.c
+++ b/source/libs/executor/src/executor.c
@@ -52,7 +52,11 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
// TODO: if a block was set but not consumed,
// prevent setting a different type of block
pInfo->validBlockIndex = 0;
- taosArrayClear(pInfo->pBlockLists);
+ if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
+ taosArrayClearP(pInfo->pBlockLists, taosMemoryFree);
+ } else {
+ taosArrayClear(pInfo->pBlockLists);
+ }
if (type == STREAM_INPUT__MERGED_SUBMIT) {
// ASSERT(numOfBlocks > 1);
@@ -93,6 +97,8 @@ static int32_t doSetStreamBlock(SOperatorInfo* pOperator, void* input, size_t nu
}
}
+static FORCE_INLINE void streamInputBlockDataDestory(void* pBlock) { blockDataDestroy((SSDataBlock*)pBlock); }
+
void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) {
SExecTaskInfo* pTaskInfo = (SExecTaskInfo*)tinfo;
if (!pTaskInfo || !pTaskInfo->pRoot || pTaskInfo->pRoot->numOfDownstream <= 0) {
@@ -103,11 +109,7 @@ void tdCleanupStreamInputDataBlock(qTaskInfo_t tinfo) {
if (pOptrInfo->operatorType == QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
SStreamScanInfo* pInfo = pOptrInfo->info;
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
- for (int32_t i = 0; i < taosArrayGetSize(pInfo->pBlockLists); ++i) {
- SSDataBlock* p = *(SSDataBlock**)taosArrayGet(pInfo->pBlockLists, i);
- taosArrayDestroy(p->pDataBlock);
- taosMemoryFreeClear(p);
- }
+ taosArrayClearP(pInfo->pBlockLists, streamInputBlockDataDestory);
} else {
ASSERT(0);
}
diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c
index 3cb4ea8702..815d6a71ef 100644
--- a/source/libs/executor/src/executorimpl.c
+++ b/source/libs/executor/src/executorimpl.c
@@ -1866,13 +1866,11 @@ void updateLoadRemoteInfo(SLoadRemoteDataInfo* pInfo, int32_t numOfRows, int32_t
pOperator->resultInfo.totalRows += numOfRows;
}
-int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, int32_t numOfOutput, SArray* pColList,
- char** pNextStart) {
+int32_t extractDataBlockFromFetchRsp(SSDataBlock* pRes, char* pData, SArray* pColList, char** pNextStart) {
if (pColList == NULL) { // data from other sources
blockDataCleanup(pRes);
*pNextStart = (char*)blockDecode(pRes, pData);
} else { // extract data according to pColList
- ASSERT(numOfOutput == taosArrayGetSize(pColList));
char* pStart = pData;
int32_t numOfCols = htonl(*(int32_t*)pStart);
@@ -1970,7 +1968,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
char* pStart = pRetrieveRsp->data;
while (index++ < pRetrieveRsp->numOfBlocks) {
SSDataBlock* pb = createOneDataBlock(pExchangeInfo->pDummyBlock, false);
- code = extractDataBlockFromFetchRsp(pb, pStart, pRetrieveRsp->numOfCols, NULL, &pStart);
+ code = extractDataBlockFromFetchRsp(pb, pStart, NULL, &pStart);
if (code != 0) {
taosMemoryFreeClear(pDataInfo->pRsp);
goto _error;
@@ -2095,7 +2093,7 @@ static int32_t seqLoadRemoteData(SOperatorInfo* pOperator) {
SRetrieveTableRsp* pRetrieveRsp = pDataInfo->pRsp;
char* pStart = pRetrieveRsp->data;
- int32_t code = extractDataBlockFromFetchRsp(NULL, pStart, pRetrieveRsp->numOfCols, NULL, &pStart);
+ int32_t code = extractDataBlockFromFetchRsp(NULL, pStart, NULL, &pStart);
if (pRsp->completed == 1) {
qDebug("%s fetch msg rsp from vgId:%d, taskId:0x%" PRIx64 " execId:%d numOfRows:%d, rowsOfSource:%" PRIu64
@@ -3441,6 +3439,44 @@ static int32_t initFillInfo(SFillOperatorInfo* pInfo, SExprInfo* pExpr, int32_t
}
}
+static bool isWstartColumnExist(SFillOperatorInfo* pInfo) {
+ if (pInfo->numOfNotFillExpr == 0) {
+ return false;
+ }
+ for (int32_t i = 0; i < pInfo->numOfNotFillExpr; ++i) {
+ SExprInfo* exprInfo = pInfo->pNotFillExprInfo + i;
+ if (exprInfo->pExpr->nodeType == QUERY_NODE_COLUMN &&
+ exprInfo->base.numOfParams == 1 &&
+ exprInfo->base.pParam[0].pCol->colType == COLUMN_TYPE_WINDOW_START) {
+ return true;
+ }
+ }
+ return false;
+}
+
+static int32_t createWStartTsAsNotFillExpr(SFillOperatorInfo* pInfo, SFillPhysiNode* pPhyFillNode) {
+ bool wstartExist = isWstartColumnExist(pInfo);
+ if (wstartExist == false) {
+ if (pPhyFillNode->pWStartTs->type != QUERY_NODE_TARGET) {
+ qError("pWStartTs of fill physical node is not a target node");
+ return TSDB_CODE_QRY_SYS_ERROR;
+ }
+
+ SExprInfo* notFillExprs = taosMemoryRealloc(pInfo->pNotFillExprInfo, (pInfo->numOfNotFillExpr + 1) * sizeof(SExprInfo));
+ if (notFillExprs == NULL) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+
+ createExprFromTargetNode(notFillExprs + pInfo->numOfNotFillExpr, (STargetNode*)pPhyFillNode->pWStartTs);
+
+ ++pInfo->numOfNotFillExpr;
+ pInfo->pNotFillExprInfo = notFillExprs;
+ return TSDB_CODE_SUCCESS;
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode* pPhyFillNode,
SExecTaskInfo* pTaskInfo) {
SFillOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SFillOperatorInfo));
@@ -3452,7 +3488,10 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
SSDataBlock* pResBlock = createResDataBlock(pPhyFillNode->node.pOutputDataBlockDesc);
SExprInfo* pExprInfo = createExprInfo(pPhyFillNode->pFillExprs, NULL, &pInfo->numOfExpr);
pInfo->pNotFillExprInfo = createExprInfo(pPhyFillNode->pNotFillExprs, NULL, &pInfo->numOfNotFillExpr);
-
+ int32_t code = createWStartTsAsNotFillExpr(pInfo, pPhyFillNode);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _error;
+ }
SInterval* pInterval =
QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == downstream->operatorType
? &((SMergeAlignedIntervalAggOperatorInfo*)downstream->info)->intervalAggOperatorInfo->interval
@@ -3473,7 +3512,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
SArray* pColMatchColInfo = extractColMatchInfo(pPhyFillNode->pFillExprs, pPhyFillNode->node.pOutputDataBlockDesc,
&numOfOutputCols, COL_MATCH_FROM_SLOT_ID);
- int32_t code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr,
+ code = initFillInfo(pInfo, pExprInfo, pInfo->numOfExpr, pInfo->pNotFillExprInfo, pInfo->numOfNotFillExpr,
(SNodeListNode*)pPhyFillNode->pValues, pPhyFillNode->timeRange, pResultInfo->capacity,
pTaskInfo->id.str, pInterval, type, order);
if (code != TSDB_CODE_SUCCESS) {
@@ -3915,7 +3954,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pOptr = createAggregateOperatorInfo(ops[0], pExprInfo, num, pResBlock, pAggNode->node.pConditions,
pScalarExprInfo, numOfScalarExpr, pAggNode->mergeDataBlock, pTaskInfo);
}
- } else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type || QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
+ } else if (QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL == type) {
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &num);
@@ -3940,6 +3979,8 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
pOptr = createIntervalOperatorInfo(ops[0], pExprInfo, num, pResBlock, &interval, tsSlotId, &as, pIntervalPhyNode,
pTaskInfo, isStream);
+ } else if (QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL == type) {
+ pOptr = createStreamIntervalOperatorInfo(ops[0], pPhyNode, pTaskInfo);
} else if (QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL == type) {
SMergeAlignedIntervalPhysiNode* pIntervalPhyNode = (SMergeAlignedIntervalPhysiNode*)pPhyNode;
pOptr = createMergeAlignedIntervalOperatorInfo(ops[0], pIntervalPhyNode, pTaskInfo);
@@ -4410,3 +4451,108 @@ int32_t initStreamAggSupporter(SStreamAggSupporter* pSup, const char* pKey, SqlF
return code;
}
+
+int32_t setOutputBuf(STimeWindow* win, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx,
+ int32_t numOfOutput, int32_t* rowEntryInfoOffset, SAggSupporter* pAggSup,
+ SExecTaskInfo* pTaskInfo) {
+ SWinKey key = {
+ .ts = win->skey,
+ .groupId = tableGroupId,
+ };
+ char* value = NULL;
+ int32_t size = pAggSup->resultRowSize;
+ if (streamStateAddIfNotExist(pTaskInfo->streamInfo.pState, &key, (void**)&value, &size) < 0) {
+ return TSDB_CODE_QRY_OUT_OF_MEMORY;
+ }
+ *pResult = (SResultRow*)value;
+ ASSERT(*pResult);
+ // set time window for current result
+ (*pResult)->win = (*win);
+ setResultRowInitCtx(*pResult, pCtx, numOfOutput, rowEntryInfoOffset);
+ return TSDB_CODE_SUCCESS;
+}
+
+int32_t releaseOutputBuf(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult) {
+ streamStateReleaseBuf(pTaskInfo->streamInfo.pState, pKey, pResult);
+ return TSDB_CODE_SUCCESS;
+}
+
+int32_t saveOutput(SExecTaskInfo* pTaskInfo, SWinKey* pKey, SResultRow* pResult, int32_t resSize) {
+ streamStatePut(pTaskInfo->streamInfo.pState, pKey, pResult, resSize);
+ return TSDB_CODE_SUCCESS;
+}
+
+int32_t buildDataBlockFromGroupRes(SExecTaskInfo* pTaskInfo, SSDataBlock* pBlock, SExprSupp* pSup,
+ SGroupResInfo* pGroupResInfo) {
+ SExprInfo* pExprInfo = pSup->pExprInfo;
+ int32_t numOfExprs = pSup->numOfExprs;
+ int32_t* rowEntryOffset = pSup->rowEntryInfoOffset;
+ SqlFunctionCtx* pCtx = pSup->pCtx;
+
+ int32_t numOfRows = getNumOfTotalRes(pGroupResInfo);
+
+ for (int32_t i = pGroupResInfo->index; i < numOfRows; i += 1) {
+ SResKeyPos* pPos = taosArrayGetP(pGroupResInfo->pRows, i);
+ int32_t size = 0;
+ void* pVal = NULL;
+ SWinKey key = {
+ .ts = *(TSKEY*)pPos->key,
+ .groupId = pPos->groupId,
+ };
+ int32_t code = streamStateGet(pTaskInfo->streamInfo.pState, &key, &pVal, &size);
+ ASSERT(code == 0);
+ SResultRow* pRow = (SResultRow*)pVal;
+ doUpdateNumOfRows(pCtx, pRow, numOfExprs, rowEntryOffset);
+ // no results, continue to check the next one
+ if (pRow->numOfRows == 0) {
+ pGroupResInfo->index += 1;
+ releaseOutputBuf(pTaskInfo, &key, pRow);
+ continue;
+ }
+
+ if (pBlock->info.groupId == 0) {
+ pBlock->info.groupId = pPos->groupId;
+ } else {
+ // current value belongs to different group, it can't be packed into one datablock
+ if (pBlock->info.groupId != pPos->groupId) {
+ releaseOutputBuf(pTaskInfo, &key, pRow);
+ break;
+ }
+ }
+
+ if (pBlock->info.rows + pRow->numOfRows > pBlock->info.capacity) {
+ ASSERT(pBlock->info.rows > 0);
+ releaseOutputBuf(pTaskInfo, &key, pRow);
+ break;
+ }
+
+ pGroupResInfo->index += 1;
+
+ for (int32_t j = 0; j < numOfExprs; ++j) {
+ int32_t slotId = pExprInfo[j].base.resSchema.slotId;
+
+ pCtx[j].resultInfo = getResultEntryInfo(pRow, j, rowEntryOffset);
+ if (pCtx[j].fpSet.finalize) {
+ int32_t code = pCtx[j].fpSet.finalize(&pCtx[j], pBlock);
+ if (TAOS_FAILED(code)) {
+ qError("%s build result data block error, code %s", GET_TASKID(pTaskInfo), tstrerror(code));
+ T_LONG_JMP(pTaskInfo->env, code);
+ }
+ } else if (strcmp(pCtx[j].pExpr->pExpr->_function.functionName, "_select_value") == 0) {
+ // do nothing, todo refactor
+ } else {
+ // expand the result into multiple rows. E.g., _wstart, top(k, 20)
+ // the _wstart needs to copy to 20 following rows, since the results of top-k expands to 20 different rows.
+ SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
+ char* in = GET_ROWCELL_INTERBUF(pCtx[j].resultInfo);
+ for (int32_t k = 0; k < pRow->numOfRows; ++k) {
+ colDataAppend(pColInfoData, pBlock->info.rows + k, in, pCtx[j].resultInfo->isNullRes);
+ }
+ }
+ }
+ releaseOutputBuf(pTaskInfo, &key, pRow);
+ pBlock->info.rows += pRow->numOfRows;
+ }
+ blockDataUpdateTsWindow(pBlock, 0);
+ return TSDB_CODE_SUCCESS;
+}
diff --git a/source/libs/executor/src/groupoperator.c b/source/libs/executor/src/groupoperator.c
index 599edb0722..5eb6557dbd 100644
--- a/source/libs/executor/src/groupoperator.c
+++ b/source/libs/executor/src/groupoperator.c
@@ -13,26 +13,26 @@
* along with this program. If not, see .
*/
-#include "os.h"
#include "function.h"
+#include "os.h"
#include "tname.h"
#include "tdatablock.h"
#include "tmsg.h"
+#include "executorInt.h"
#include "executorimpl.h"
#include "tcompare.h"
#include "thash.h"
#include "ttypes.h"
-#include "executorInt.h"
static void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInfo** pGroupInfo, int32_t len);
static int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity);
-static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
- uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup);
+static int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData,
+ int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup);
static void freeGroupKey(void* param) {
- SGroupKeys* pKey = (SGroupKeys*) param;
+ SGroupKeys* pKey = (SGroupKeys*)param;
taosMemoryFree(pKey->pData);
}
@@ -62,13 +62,13 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
int32_t numOfGroupCols = taosArrayGetSize(pGroupColList);
for (int32_t i = 0; i < numOfGroupCols; ++i) {
SColumn* pCol = taosArrayGet(pGroupColList, i);
- (*keyLen) += pCol->bytes; // actual data + null_flag
+ (*keyLen) += pCol->bytes; // actual data + null_flag
SGroupKeys key = {0};
- key.bytes = pCol->bytes;
- key.type = pCol->type;
+ key.bytes = pCol->bytes;
+ key.type = pCol->type;
key.isNull = false;
- key.pData = taosMemoryCalloc(1, pCol->bytes);
+ key.pData = taosMemoryCalloc(1, pCol->bytes);
if (key.pData == NULL) {
return TSDB_CODE_OUT_OF_MEMORY;
}
@@ -87,7 +87,8 @@ static int32_t initGroupOptrInfo(SArray** pGroupColVals, int32_t* keyLen, char**
return TSDB_CODE_SUCCESS;
}
-static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex, int32_t numOfGroupCols) {
+static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlock* pBlock, int32_t rowIndex,
+ int32_t numOfGroupCols) {
SColumnDataAgg* pColAgg = NULL;
for (int32_t i = 0; i < numOfGroupCols; ++i) {
SColumn* pCol = taosArrayGet(pGroupCols, i);
@@ -112,7 +113,7 @@ static bool groupKeyCompare(SArray* pGroupCols, SArray* pGroupColVals, SSDataBlo
if (pkey->type == TSDB_DATA_TYPE_JSON) {
int32_t dataLen = getJsonValueLen(val);
- if (memcmp(pkey->pData, val, dataLen) == 0){
+ if (memcmp(pkey->pData, val, dataLen) == 0) {
continue;
} else {
return false;
@@ -154,7 +155,7 @@ static void recordNewGroupKeys(SArray* pGroupCols, SArray* pGroupColVals, SSData
pkey->isNull = false;
char* val = colDataGetData(pColInfoData, rowIndex);
if (pkey->type == TSDB_DATA_TYPE_JSON) {
- if(tTagIsJson(val)){
+ if (tTagIsJson(val)) {
terrno = TSDB_CODE_QRY_JSON_IN_GROUP_ERROR;
return;
}
@@ -198,13 +199,13 @@ static int32_t buildGroupKeys(void* pKey, const SArray* pGroupColVals) {
}
}
- return (int32_t) (pStart - (char*)pKey);
+ return (int32_t)(pStart - (char*)pKey);
}
// assign the group keys or user input constant values if required
static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t totalRows, int32_t rowIndex) {
for (int32_t i = 0; i < numOfOutput; ++i) {
- if (pCtx[i].functionId == -1) { // select count(*),key from t group by key.
+ if (pCtx[i].functionId == -1) { // select count(*),key from t group by key.
SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pCtx[i]);
SColumnInfoData* pColInfoData = pCtx[i].input.pData[0];
@@ -221,7 +222,7 @@ static void doAssignGroupKeys(SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t
} else {
memcpy(dest, data, pColInfoData->info.bytes);
}
- } else { // it is a NULL value
+ } else { // it is a NULL value
pEntryInfo->isNullRes = 1;
}
@@ -275,7 +276,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
- int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len, pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
+ int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
+ len, pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
}
@@ -291,9 +293,8 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
if (num > 0) {
len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
- int32_t ret =
- setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf, len,
- pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
+ int32_t ret = setGroupResultOutputBuf(pOperator, &(pInfo->binfo), pOperator->exprSupp.numOfExprs, pInfo->keyBuf,
+ len, pBlock->info.groupId, pInfo->aggSup.pResultBuf, &pInfo->aggSup);
if (ret != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR);
}
@@ -308,7 +309,7 @@ static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) {
SGroupbyOperatorInfo* pInfo = pOperator->info;
SSDataBlock* pRes = pInfo->binfo.pRes;
- while(1) {
+ while (1) {
doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
doFilter(pInfo->pCondition, pRes, NULL);
@@ -323,7 +324,7 @@ static SSDataBlock* buildGroupResultDataBlock(SOperatorInfo* pOperator) {
}
pOperator->resultInfo.totalRows += pRes->info.rows;
- return (pRes->info.rows == 0)? NULL:pRes;
+ return (pRes->info.rows == 0) ? NULL : pRes;
}
static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
@@ -334,7 +335,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SGroupbyOperatorInfo* pInfo = pOperator->info;
- SSDataBlock* pRes = pInfo->binfo.pRes;
+ SSDataBlock* pRes = pInfo->binfo.pRes;
if (pOperator->status == OP_RES_TO_RETURN) {
return buildGroupResultDataBlock(pOperator);
@@ -343,7 +344,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
int32_t order = TSDB_ORDER_ASC;
int32_t scanFlag = MAIN_SCAN;
- int64_t st = taosGetTimestampUs();
+ int64_t st = taosGetTimestampUs();
SOperatorInfo* downstream = pOperator->pDownstream[0];
while (1) {
@@ -362,7 +363,8 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo* pOperator) {
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
if (pInfo->scalarSup.pExprInfo != NULL) {
- pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx, pInfo->scalarSup.numOfExprs, NULL);
+ pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx,
+ pInfo->scalarSup.numOfExprs, NULL);
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
}
@@ -403,8 +405,8 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
goto _error;
}
- pInfo->pGroupCols = pGroupColList;
- pInfo->pCondition = pCondition;
+ pInfo->pGroupCols = pGroupColList;
+ pInfo->pCondition = pCondition;
int32_t code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr);
if (code != TSDB_CODE_SUCCESS) {
@@ -425,14 +427,15 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
initBasicInfo(&pInfo->binfo, pResultBlock);
initResultRowInfo(&pInfo->binfo.resultRowInfo);
- pOperator->name = "GroupbyAggOperator";
- pOperator->blocking = true;
- pOperator->status = OP_NOT_OPENED;
+ pOperator->name = "GroupbyAggOperator";
+ pOperator->blocking = true;
+ pOperator->status = OP_NOT_OPENED;
// pOperator->operatorType = OP_Groupby;
- pOperator->info = pInfo;
- pOperator->pTaskInfo = pTaskInfo;
+ pOperator->info = pInfo;
+ pOperator->pTaskInfo = pTaskInfo;
- pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, NULL, destroyGroupOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
+ pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashGroupbyAggregate, NULL, NULL,
+ destroyGroupOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
code = appendDownstream(pOperator, &downstream, 1);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
@@ -440,7 +443,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
return pOperator;
- _error:
+_error:
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
destroyGroupOperatorInfo(pInfo);
taosMemoryFreeClear(pOperator);
@@ -448,7 +451,7 @@ SOperatorInfo* createGroupOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx
}
static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
-// SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+ // SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SPartitionOperatorInfo* pInfo = pOperator->info;
@@ -457,7 +460,7 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
int32_t len = buildGroupKeys(pInfo->keyBuf, pInfo->pGroupColVals);
SDataGroupInfo* pGroupInfo = NULL;
- void *pPage = getCurrentDataGroupInfo(pInfo, &pGroupInfo, len);
+ void* pPage = getCurrentDataGroupInfo(pInfo, &pGroupInfo, len);
pGroupInfo->numOfRows += 1;
@@ -467,32 +470,32 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
// number of rows
- int32_t* rows = (int32_t*) pPage;
+ int32_t* rows = (int32_t*)pPage;
size_t numOfCols = pOperator->exprSupp.numOfExprs;
- for(int32_t i = 0; i < numOfCols; ++i) {
+ for (int32_t i = 0; i < numOfCols; ++i) {
SExprInfo* pExpr = &pOperator->exprSupp.pExprInfo[i];
- int32_t slotId = pExpr->base.pParam[0].pCol->slotId;
+ int32_t slotId = pExpr->base.pParam[0].pCol->slotId;
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, slotId);
int32_t bytes = pColInfoData->info.bytes;
int32_t startOffset = pInfo->columnOffset[i];
- int32_t* columnLen = NULL;
+ int32_t* columnLen = NULL;
int32_t contentLen = 0;
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
int32_t* offset = (int32_t*)((char*)pPage + startOffset);
- columnLen = (int32_t*) ((char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity);
- char* data = (char*)((char*) columnLen + sizeof(int32_t));
+ columnLen = (int32_t*)((char*)pPage + startOffset + sizeof(int32_t) * pInfo->rowCapacity);
+ char* data = (char*)((char*)columnLen + sizeof(int32_t));
if (colDataIsNull_s(pColInfoData, j)) {
offset[(*rows)] = -1;
contentLen = 0;
- } else if(pColInfoData->info.type == TSDB_DATA_TYPE_JSON){
+ } else if (pColInfoData->info.type == TSDB_DATA_TYPE_JSON) {
offset[*rows] = (*columnLen);
- char* src = colDataGetData(pColInfoData, j);
+ char* src = colDataGetData(pColInfoData, j);
int32_t dataLen = getJsonValueLen(src);
memcpy(data + (*columnLen), src, dataLen);
@@ -511,8 +514,8 @@ static void doHashPartition(SOperatorInfo* pOperator, SSDataBlock* pBlock) {
}
} else {
char* bitmap = (char*)pPage + startOffset;
- columnLen = (int32_t*) ((char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity));
- char* data = (char*) columnLen + sizeof(int32_t);
+ columnLen = (int32_t*)((char*)pPage + startOffset + BitmapLen(pInfo->rowCapacity));
+ char* data = (char*)columnLen + sizeof(int32_t);
bool isNull = colDataIsNull_f(pColInfoData->nullbitmap, j);
if (isNull) {
@@ -539,7 +542,7 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
SDataGroupInfo* p = taosHashGet(pInfo->pGroupSet, pInfo->keyBuf, len);
void* pPage = NULL;
- if (p == NULL) { // it is a new group
+ if (p == NULL) { // it is a new group
SDataGroupInfo gi = {0};
gi.pPageList = taosArrayInit(100, sizeof(int32_t));
taosHashPut(pInfo->pGroupSet, pInfo->keyBuf, len, &gi, sizeof(SDataGroupInfo));
@@ -550,12 +553,12 @@ void* getCurrentDataGroupInfo(const SPartitionOperatorInfo* pInfo, SDataGroupInf
pPage = getNewBufPage(pInfo->pBuf, &pageId);
taosArrayPush(p->pPageList, &pageId);
- *(int32_t *) pPage = 0;
+ *(int32_t*)pPage = 0;
} else {
int32_t* curId = taosArrayGetLast(p->pPageList);
pPage = getBufPage(pInfo->pBuf, *curId);
- int32_t *rows = (int32_t*) pPage;
+ int32_t* rows = (int32_t*)pPage;
if (*rows >= pInfo->rowCapacity) {
// release buffer
releaseBufPage(pInfo->pBuf, pPage);
@@ -585,17 +588,18 @@ uint64_t calcGroupId(char* pData, int32_t len) {
}
int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
- size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
+ size_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
int32_t* offset = taosMemoryCalloc(numOfCols, sizeof(int32_t));
- offset[0] = sizeof(int32_t) + sizeof(uint64_t); // the number of rows in current page, ref to SSDataBlock paged serialization format
+ offset[0] = sizeof(int32_t) +
+ sizeof(uint64_t); // the number of rows in current page, ref to SSDataBlock paged serialization format
- for(int32_t i = 0; i < numOfCols - 1; ++i) {
+ for (int32_t i = 0; i < numOfCols - 1; ++i) {
SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i);
int32_t bytes = pColInfoData->info.bytes;
int32_t payloadLen = bytes * rowCapacity;
-
+
if (IS_VAR_DATA_TYPE(pColInfoData->info.type)) {
// offset segment + content length + payload
offset[i + 1] = rowCapacity * sizeof(int32_t) + sizeof(int32_t) + payloadLen + offset[i];
@@ -609,9 +613,9 @@ int32_t* setupColumnOffset(const SSDataBlock* pBlock, int32_t rowCapacity) {
}
static void clearPartitionOperator(SPartitionOperatorInfo* pInfo) {
- void *ite = NULL;
- while( (ite = taosHashIterate(pInfo->pGroupSet, ite)) != NULL ) {
- taosArrayDestroy( ((SDataGroupInfo *)ite)->pPageList);
+ void* ite = NULL;
+ while ((ite = taosHashIterate(pInfo->pGroupSet, ite)) != NULL) {
+ taosArrayDestroy(((SDataGroupInfo*)ite)->pPageList);
}
taosArrayClear(pInfo->sortedGroupArray);
clearDiskbasedBuf(pInfo->pBuf);
@@ -626,13 +630,14 @@ static int compareDataGroupInfo(const void* group1, const void* group2) {
return 0;
}
- return (pGroupInfo1->groupId < pGroupInfo2->groupId)? -1:1;
+ return (pGroupInfo1->groupId < pGroupInfo2->groupId) ? -1 : 1;
}
static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
SPartitionOperatorInfo* pInfo = pOperator->info;
- SDataGroupInfo* pGroupInfo = (pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL;
+ SDataGroupInfo* pGroupInfo =
+ (pInfo->groupIndex != -1) ? taosArrayGet(pInfo->sortedGroupArray, pInfo->groupIndex) : NULL;
if (pInfo->groupIndex == -1 || pInfo->pageIndex >= taosArrayGetSize(pGroupInfo->pPageList)) {
// try next group data
++pInfo->groupIndex;
@@ -647,7 +652,7 @@ static SSDataBlock* buildPartitionResult(SOperatorInfo* pOperator) {
}
int32_t* pageId = taosArrayGet(pGroupInfo->pPageList, pInfo->pageIndex);
- void* page = getBufPage(pInfo->pBuf, *pageId);
+ void* page = getBufPage(pInfo->pBuf, *pageId);
blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->rowCapacity);
blockDataFromBuf1(pInfo->binfo.pRes, page, pInfo->rowCapacity);
@@ -670,14 +675,14 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SPartitionOperatorInfo* pInfo = pOperator->info;
- SSDataBlock* pRes = pInfo->binfo.pRes;
+ SSDataBlock* pRes = pInfo->binfo.pRes;
if (pOperator->status == OP_RES_TO_RETURN) {
blockDataCleanup(pRes);
return buildPartitionResult(pOperator);
}
- int64_t st = taosGetTimestampUs();
+ int64_t st = taosGetTimestampUs();
SOperatorInfo* downstream = pOperator->pDownstream[0];
while (1) {
@@ -688,7 +693,8 @@ static SSDataBlock* hashPartition(SOperatorInfo* pOperator) {
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
if (pInfo->scalarSup.pExprInfo != NULL) {
- pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx, pInfo->scalarSup.numOfExprs, NULL);
+ pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx,
+ pInfo->scalarSup.numOfExprs, NULL);
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
T_LONG_JMP(pTaskInfo->env, pTaskInfo->code);
}
@@ -727,7 +733,7 @@ static void destroyPartitionOperatorInfo(void* param) {
cleanupBasicInfo(&pInfo->binfo);
taosArrayDestroy(pInfo->pGroupCols);
- for(int i = 0; i < taosArrayGetSize(pInfo->pGroupColVals); i++){
+ for (int i = 0; i < taosArrayGetSize(pInfo->pGroupColVals); i++) {
SGroupKeys key = *(SGroupKeys*)taosArrayGet(pInfo->pGroupColVals, i);
taosMemoryFree(key.pData);
}
@@ -743,24 +749,25 @@ static void destroyPartitionOperatorInfo(void* param) {
taosMemoryFreeClear(param);
}
-SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo) {
+SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartitionPhysiNode* pPartNode,
+ SExecTaskInfo* pTaskInfo) {
SPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SPartitionOperatorInfo));
- SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
+ SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) {
goto _error;
}
SSDataBlock* pResBlock = createResDataBlock(pPartNode->node.pOutputDataBlockDesc);
- int32_t numOfCols = 0;
+ int32_t numOfCols = 0;
SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols);
pInfo->pGroupCols = extractPartitionColInfo(pPartNode->pPartitionKeys);
if (pPartNode->pExprs != NULL) {
- int32_t num = 0;
+ int32_t num = 0;
SExprInfo* pExprInfo1 = createExprInfo(pPartNode->pExprs, NULL, &num);
- int32_t code = initExprSupp(&pInfo->scalarSup, pExprInfo1, num);
+ int32_t code = initExprSupp(&pInfo->scalarSup, pExprInfo1, num);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
@@ -772,7 +779,7 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
goto _error;
}
- uint32_t defaultPgsz = 0;
+ uint32_t defaultPgsz = 0;
uint32_t defaultBufsz = 0;
getBufferPgSize(pResBlock->info.rowSize, &defaultPgsz, &defaultBufsz);
@@ -794,15 +801,15 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
goto _error;
}
- pOperator->name = "PartitionOperator";
- pOperator->blocking = true;
- pOperator->status = OP_NOT_OPENED;
+ pOperator->name = "PartitionOperator";
+ pOperator->blocking = true;
+ pOperator->status = OP_NOT_OPENED;
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PARTITION;
- pInfo->binfo.pRes = pResBlock;
- pOperator->exprSupp.numOfExprs = numOfCols;
- pOperator->exprSupp.pExprInfo = pExprInfo;
- pOperator->info = pInfo;
- pOperator->pTaskInfo = pTaskInfo;
+ pInfo->binfo.pRes = pResBlock;
+ pOperator->exprSupp.numOfExprs = numOfCols;
+ pOperator->exprSupp.pExprInfo = pExprInfo;
+ pOperator->info = pInfo;
+ pOperator->pTaskInfo = pTaskInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, hashPartition, NULL, NULL, destroyPartitionOperatorInfo,
NULL, NULL, NULL);
@@ -810,16 +817,16 @@ SOperatorInfo* createPartitionOperatorInfo(SOperatorInfo* downstream, SPartition
code = appendDownstream(pOperator, &downstream, 1);
return pOperator;
- _error:
+_error:
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
taosMemoryFreeClear(pInfo);
taosMemoryFreeClear(pOperator);
return NULL;
}
-int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData, int16_t bytes,
- uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) {
- SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo, int32_t numOfCols, char* pData,
+ int16_t bytes, uint64_t groupId, SDiskbasedBuf* pBuf, SAggSupporter* pAggSup) {
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SResultRowInfo* pResultRowInfo = &binfo->resultRowInfo;
SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx;
@@ -833,37 +840,36 @@ int32_t setGroupResultOutputBuf(SOperatorInfo* pOperator, SOptrBasicInfo* binfo,
uint64_t calGroupIdByData(SPartitionBySupporter* pParSup, SExprSupp* pExprSup, SSDataBlock* pBlock, int32_t rowId) {
if (pExprSup->pExprInfo != NULL) {
- int32_t code = projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
+ int32_t code =
+ projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
if (code != TSDB_CODE_SUCCESS) {
qError("calaculate group id error, code:%d", code);
}
}
recordNewGroupKeys(pParSup->pGroupCols, pParSup->pGroupColVals, pBlock, rowId);
- int32_t len = buildGroupKeys(pParSup->keyBuf, pParSup->pGroupColVals);
+ int32_t len = buildGroupKeys(pParSup->keyBuf, pParSup->pGroupColVals);
uint64_t groupId = calcGroupId(pParSup->keyBuf, len);
return groupId;
}
-static bool hasRemainPartion(SStreamPartitionOperatorInfo* pInfo) {
- return pInfo->parIte != NULL;
-}
+static bool hasRemainPartion(SStreamPartitionOperatorInfo* pInfo) { return pInfo->parIte != NULL; }
static SSDataBlock* buildStreamPartitionResult(SOperatorInfo* pOperator) {
SStreamPartitionOperatorInfo* pInfo = pOperator->info;
- SSDataBlock* pDest = pInfo->binfo.pRes;
+ SSDataBlock* pDest = pInfo->binfo.pRes;
ASSERT(hasRemainPartion(pInfo));
SPartitionDataInfo* pParInfo = (SPartitionDataInfo*)pInfo->parIte;
blockDataCleanup(pDest);
- int32_t rows = taosArrayGetSize(pParInfo->rowIds);
+ int32_t rows = taosArrayGetSize(pParInfo->rowIds);
SSDataBlock* pSrc = pInfo->pInputDataBlock;
for (int32_t i = 0; i < rows; i++) {
int32_t rowIndex = *(int32_t*)taosArrayGet(pParInfo->rowIds, i);
for (int32_t j = 0; j < pOperator->exprSupp.numOfExprs; j++) {
- int32_t slotId = pOperator->exprSupp.pExprInfo[j].base.pParam[0].pCol->slotId;
+ int32_t slotId = pOperator->exprSupp.pExprInfo[j].base.pParam[0].pCol->slotId;
SColumnInfoData* pSrcCol = taosArrayGet(pSrc->pDataBlock, slotId);
SColumnInfoData* pDestCol = taosArrayGet(pDest->pDataBlock, j);
- bool isNull = colDataIsNull(pSrcCol, pSrc->info.rows, rowIndex, NULL);
- char* pSrcData = colDataGetData(pSrcCol, rowIndex);
+ bool isNull = colDataIsNull(pSrcCol, pSrc->info.rows, rowIndex, NULL);
+ char* pSrcData = colDataGetData(pSrcCol, rowIndex);
colDataAppend(pDestCol, pDest->info.rows, pSrcData, isNull);
}
pDest->info.rows++;
@@ -881,9 +887,9 @@ static void doStreamHashPartitionImpl(SStreamPartitionOperatorInfo* pInfo, SSDat
pInfo->pInputDataBlock = pBlock;
for (int32_t i = 0; i < pBlock->info.rows; ++i) {
recordNewGroupKeys(pInfo->partitionSup.pGroupCols, pInfo->partitionSup.pGroupColVals, pBlock, i);
- int32_t keyLen = buildGroupKeys(pInfo->partitionSup.keyBuf, pInfo->partitionSup.pGroupColVals);
- SPartitionDataInfo* pParData =
- (SPartitionDataInfo*) taosHashGet(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen);
+ int32_t keyLen = buildGroupKeys(pInfo->partitionSup.keyBuf, pInfo->partitionSup.pGroupColVals);
+ SPartitionDataInfo* pParData =
+ (SPartitionDataInfo*)taosHashGet(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen);
if (pParData) {
taosArrayPush(pParData->rowIds, &i);
} else {
@@ -891,8 +897,7 @@ static void doStreamHashPartitionImpl(SStreamPartitionOperatorInfo* pInfo, SSDat
newParData.groupId = calcGroupId(pInfo->partitionSup.keyBuf, keyLen);
newParData.rowIds = taosArrayInit(64, sizeof(int32_t));
taosArrayPush(newParData.rowIds, &i);
- taosHashPut(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen, &newParData,
- sizeof(SPartitionDataInfo));
+ taosHashPut(pInfo->pPartitions, pInfo->partitionSup.keyBuf, keyLen, &newParData, sizeof(SPartitionDataInfo));
}
}
}
@@ -902,13 +907,13 @@ static SSDataBlock* doStreamHashPartition(SOperatorInfo* pOperator) {
return NULL;
}
- SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SStreamPartitionOperatorInfo* pInfo = pOperator->info;
if (hasRemainPartion(pInfo)) {
return buildStreamPartitionResult(pOperator);
}
- int64_t st = taosGetTimestampUs();
+ int64_t st = taosGetTimestampUs();
SOperatorInfo* downstream = pOperator->pDownstream[0];
{
pInfo->pInputDataBlock = NULL;
@@ -924,14 +929,19 @@ static SSDataBlock* doStreamHashPartition(SOperatorInfo* pOperator) {
case STREAM_INVALID:
pInfo->binfo.pRes->info.type = pBlock->info.type;
break;
+ case STREAM_DELETE_DATA: {
+ copyDataBlock(pInfo->pDelRes, pBlock);
+ pInfo->pDelRes->info.type = STREAM_DELETE_RESULT;
+ return pInfo->pDelRes;
+ } break;
default:
return pBlock;
}
// there is an scalar expression that needs to be calculated right before apply the group aggregation.
if (pInfo->scalarSup.pExprInfo != NULL) {
- pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock,
- pInfo->scalarSup.pCtx, pInfo->scalarSup.numOfExprs, NULL);
+ pTaskInfo->code = projectApplyFunctions(pInfo->scalarSup.pExprInfo, pBlock, pBlock, pInfo->scalarSup.pCtx,
+ pInfo->scalarSup.numOfExprs, NULL);
if (pTaskInfo->code != TSDB_CODE_SUCCESS) {
longjmp(pTaskInfo->env, pTaskInfo->code);
}
@@ -940,7 +950,7 @@ static SSDataBlock* doStreamHashPartition(SOperatorInfo* pOperator) {
doStreamHashPartitionImpl(pInfo, pBlock);
}
pOperator->cost.openCost = (taosGetTimestampUs() - st) / 1000.0;
-
+
pInfo->parIte = taosHashIterate(pInfo->pPartitions, NULL);
return buildStreamPartitionResult(pOperator);
}
@@ -950,7 +960,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
cleanupBasicInfo(&pInfo->binfo);
taosArrayDestroy(pInfo->partitionSup.pGroupCols);
- for(int i = 0; i < taosArrayGetSize(pInfo->partitionSup.pGroupColVals); i++){
+ for (int i = 0; i < taosArrayGetSize(pInfo->partitionSup.pGroupColVals); i++) {
SGroupKeys key = *(SGroupKeys*)taosArrayGet(pInfo->partitionSup.pGroupColVals, i);
taosMemoryFree(key.pData);
}
@@ -958,6 +968,7 @@ static void destroyStreamPartitionOperatorInfo(void* param) {
taosMemoryFree(pInfo->partitionSup.keyBuf);
cleanupExprSupp(&pInfo->scalarSup);
+ blockDataDestroy(pInfo->pDelRes);
taosMemoryFreeClear(param);
}
@@ -970,7 +981,8 @@ void initParDownStream(SOperatorInfo* downstream, SPartitionBySupporter* pParSup
pScanInfo->pPartScalarSup = pExpr;
}
-SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStreamPartitionPhysiNode* pPartNode, SExecTaskInfo* pTaskInfo) {
+SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStreamPartitionPhysiNode* pPartNode,
+ SExecTaskInfo* pTaskInfo) {
SStreamPartitionOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamPartitionOperatorInfo));
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
if (pInfo == NULL || pOperator == NULL) {
@@ -980,7 +992,7 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
pInfo->partitionSup.pGroupCols = extractPartitionColInfo(pPartNode->pPartitionKeys);
if (pPartNode->pExprs != NULL) {
- int32_t num = 0;
+ int32_t num = 0;
SExprInfo* pCalExprInfo = createExprInfo(pPartNode->pExprs, NULL, &num);
code = initExprSupp(&pInfo->scalarSup, pCalExprInfo, num);
if (code != TSDB_CODE_SUCCESS) {
@@ -989,7 +1001,8 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
}
int32_t keyLen = 0;
- code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf, pInfo->partitionSup.pGroupCols);
+ code = initGroupOptrInfo(&pInfo->partitionSup.pGroupColVals, &keyLen, &pInfo->partitionSup.keyBuf,
+ pInfo->partitionSup.pGroupCols);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
}
@@ -1000,35 +1013,35 @@ SOperatorInfo* createStreamPartitionOperatorInfo(SOperatorInfo* downstream, SStr
goto _error;
}
blockDataEnsureCapacity(pResBlock, 4096);
- pInfo->binfo.pRes = pResBlock;
- pInfo->parIte = NULL;
- pInfo->pInputDataBlock = NULL;
+ pInfo->binfo.pRes = pResBlock;
+ pInfo->parIte = NULL;
+ pInfo->pInputDataBlock = NULL;
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
- pInfo->pPartitions = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
- pInfo->tsColIndex = 0;
+ pInfo->pPartitions = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
+ pInfo->tsColIndex = 0;
+ pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
- int32_t numOfCols = 0;
+ int32_t numOfCols = 0;
SExprInfo* pExprInfo = createExprInfo(pPartNode->pTargets, NULL, &numOfCols);
- pOperator->name = "StreamPartitionOperator";
- pOperator->blocking = false;
- pOperator->status = OP_NOT_OPENED;
+ pOperator->name = "StreamPartitionOperator";
+ pOperator->blocking = false;
+ pOperator->status = OP_NOT_OPENED;
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION;
- pOperator->exprSupp.numOfExprs = numOfCols;
- pOperator->exprSupp.pExprInfo = pExprInfo;
- pOperator->info = pInfo;
- pOperator->pTaskInfo = pTaskInfo;
- pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, NULL, destroyStreamPartitionOperatorInfo,
- NULL, NULL, NULL);
+ pOperator->exprSupp.numOfExprs = numOfCols;
+ pOperator->exprSupp.pExprInfo = pExprInfo;
+ pOperator->info = pInfo;
+ pOperator->pTaskInfo = pTaskInfo;
+ pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamHashPartition, NULL, NULL,
+ destroyStreamPartitionOperatorInfo, NULL, NULL, NULL);
initParDownStream(downstream, &pInfo->partitionSup, &pInfo->scalarSup);
code = appendDownstream(pOperator, &downstream, 1);
return pOperator;
- _error:
+_error:
pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY;
- taosMemoryFreeClear(pInfo);
+ destroyStreamPartitionOperatorInfo(pInfo);
taosMemoryFreeClear(pOperator);
return NULL;
}
-
diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c
index b740ec21d3..ad9cd1ffe7 100644
--- a/source/libs/executor/src/scanoperator.c
+++ b/source/libs/executor/src/scanoperator.c
@@ -695,6 +695,7 @@ static void destroyTableScanOperatorInfo(void* param) {
cleanupQueryTableDataCond(&pTableScanInfo->cond);
tsdbReaderClose(pTableScanInfo->dataReader);
+ pTableScanInfo->dataReader = NULL;
if (pTableScanInfo->pColMatchInfo != NULL) {
taosArrayDestroy(pTableScanInfo->pColMatchInfo);
@@ -955,9 +956,7 @@ void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) {
pTableScanInfo->currentGroupId = -1;
}
-static void freeArray(void* array) {
- taosArrayDestroy(array);
-}
+static void freeArray(void* array) { taosArrayDestroy(array); }
static void resetTableScanOperator(SOperatorInfo* pTableScanOp) {
STableScanInfo* pTableScanInfo = pTableScanOp->info;
@@ -971,15 +970,16 @@ static void resetTableScanOperator(SOperatorInfo* pTableScanOp) {
resetTableScanInfo(pTableScanOp->info, &win);
}
-static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbUid, TSKEY startTs, TSKEY endTs, int64_t maxVersion) {
+static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbUid, TSKEY startTs, TSKEY endTs,
+ int64_t maxVersion) {
SArray* gpTbls = pTableScanOp->pTaskInfo->tableqinfoList.pGroupList;
taosArrayClear(gpTbls);
STableKeyInfo tblInfo = {.uid = tbUid, .groupId = 0};
- SArray* tbls = taosArrayInit(1, sizeof(STableKeyInfo));
+ SArray* tbls = taosArrayInit(1, sizeof(STableKeyInfo));
taosArrayPush(tbls, &tblInfo);
taosArrayPush(gpTbls, &tbls);
- STimeWindow win = {.skey = startTs, .ekey = endTs};
+ STimeWindow win = {.skey = startTs, .ekey = endTs};
STableScanInfo* pTableScanInfo = pTableScanOp->info;
pTableScanInfo->cond.startVersion = -1;
pTableScanInfo->cond.endVersion = maxVersion;
@@ -1057,24 +1057,24 @@ static bool prepareRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pBlock, int32_
return true;
}
-static STimeWindow getSlidingWindow(TSKEY* tsCol, SInterval* pInterval, SDataBlockInfo* pDataBlockInfo,
- int32_t* pRowIndex, bool hasGroup) {
+static STimeWindow getSlidingWindow(TSKEY* startTsCol, TSKEY* endTsCol, SInterval* pInterval,
+ SDataBlockInfo* pDataBlockInfo, int32_t* pRowIndex, bool hasGroup) {
SResultRowInfo dumyInfo;
dumyInfo.cur.pageId = -1;
- STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC);
+ STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, startTsCol[*pRowIndex], pInterval, TSDB_ORDER_ASC);
STimeWindow endWin = win;
STimeWindow preWin = win;
while (1) {
if (hasGroup) {
(*pRowIndex) += 1;
} else {
- (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, tsCol, *pRowIndex, endWin.ekey,
- binarySearchForKey, NULL, TSDB_ORDER_ASC);
+ (*pRowIndex) += getNumOfRowsInTimeWindow(pDataBlockInfo, startTsCol, *pRowIndex, endWin.ekey, binarySearchForKey,
+ NULL, TSDB_ORDER_ASC);
}
do {
preWin = endWin;
getNextTimeWindow(pInterval, &endWin, TSDB_ORDER_ASC);
- } while (tsCol[(*pRowIndex) - 1] >= endWin.skey);
+ } while (endTsCol[(*pRowIndex) - 1] >= endWin.skey);
endWin = preWin;
if (win.ekey == endWin.ekey || (*pRowIndex) == pDataBlockInfo->rows) {
win.ekey = endWin.ekey;
@@ -1102,6 +1102,11 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32
return NULL;
}
+ doFilter(pInfo->pCondition, pResult, NULL);
+ if (pResult->info.rows == 0) {
+ continue;
+ }
+
if (pInfo->partitionSup.needCalc) {
SSDataBlock* tmpBlock = createOneDataBlock(pResult, true);
blockDataCleanup(pResult);
@@ -1110,8 +1115,8 @@ static SSDataBlock* doRangeScan(SStreamScanInfo* pInfo, SSDataBlock* pSDB, int32
for (int32_t j = 0; j < pInfo->pTableScanOp->exprSupp.numOfExprs; j++) {
SColumnInfoData* pSrcCol = taosArrayGet(tmpBlock->pDataBlock, j);
SColumnInfoData* pDestCol = taosArrayGet(pResult->pDataBlock, j);
- bool isNull = colDataIsNull(pSrcCol, tmpBlock->info.rows, i, NULL);
- char* pSrcData = colDataGetData(pSrcCol, i);
+ bool isNull = colDataIsNull(pSrcCol, tmpBlock->info.rows, i, NULL);
+ char* pSrcData = colDataGetData(pSrcCol, i);
colDataAppend(pDestCol, pResult->info.rows, pSrcData, isNull);
}
pResult->info.rows++;
@@ -1152,7 +1157,7 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
int32_t dummy = 0;
- int64_t version = pSrcBlock->info.version - 1;
+ int64_t version = pSrcBlock->info.version - 1;
for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], version);
// gap must be 0.
@@ -1188,28 +1193,31 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
return code;
}
- SColumnInfoData* pSrcTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
+ SColumnInfoData* pSrcStartTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
+ SColumnInfoData* pSrcEndTsCol = (SColumnInfoData*)taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
SColumnInfoData* pSrcUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
uint64_t* srcUidData = (uint64_t*)pSrcUidCol->pData;
SColumnInfoData* pSrcGpCol = taosArrayGet(pSrcBlock->pDataBlock, GROUPID_COLUMN_INDEX);
uint64_t* srcGp = (uint64_t*)pSrcGpCol->pData;
- ASSERT(pSrcTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
- TSKEY* tsCol = (TSKEY*)pSrcTsCol->pData;
+ ASSERT(pSrcStartTsCol->info.type == TSDB_DATA_TYPE_TIMESTAMP);
+ TSKEY* srcStartTsCol = (TSKEY*)pSrcStartTsCol->pData;
+ TSKEY* srcEndTsCol = (TSKEY*)pSrcEndTsCol->pData;
SColumnInfoData* pStartTsCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
SColumnInfoData* pEndTsCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
SColumnInfoData* pDeUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX);
SColumnInfoData* pGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
SColumnInfoData* pCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
SColumnInfoData* pCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
- int64_t version = pSrcBlock->info.version - 1;
+ int64_t version = pSrcBlock->info.version - 1;
for (int32_t i = 0; i < rows;) {
uint64_t srcUid = srcUidData[i];
- uint64_t groupId = getGroupIdByData(pInfo, srcUid, tsCol[i], version);
+ uint64_t groupId = getGroupIdByData(pInfo, srcUid, srcStartTsCol[i], version);
uint64_t srcGpId = srcGp[i];
- TSKEY calStartTs = tsCol[i];
+ TSKEY calStartTs = srcStartTsCol[i];
colDataAppend(pCalStartTsCol, pDestBlock->info.rows, (const char*)(&calStartTs), false);
- STimeWindow win = getSlidingWindow(tsCol, &pInfo->interval, &pSrcBlock->info, &i, pInfo->partitionSup.needCalc);
- TSKEY calEndTs = tsCol[i - 1];
+ STimeWindow win = getSlidingWindow(srcStartTsCol, srcEndTsCol, &pInfo->interval, &pSrcBlock->info, &i,
+ pInfo->partitionSup.needCalc);
+ TSKEY calEndTs = srcStartTsCol[i - 1];
colDataAppend(pCalEndTsCol, pDestBlock->info.rows, (const char*)(&calEndTs), false);
colDataAppend(pDeUidCol, pDestBlock->info.rows, (const char*)(&srcUid), false);
colDataAppend(pStartTsCol, pDestBlock->info.rows, (const char*)(&win.skey), false);
@@ -1229,11 +1237,49 @@ static int32_t generateIntervalScanRange(SStreamScanInfo* pInfo, SSDataBlock* pS
return TSDB_CODE_SUCCESS;
}
+static int32_t generateDeleteResultBlock(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
+ if (pSrcBlock->info.rows == 0) {
+ return TSDB_CODE_SUCCESS;
+ }
+ blockDataCleanup(pDestBlock);
+ int32_t code = blockDataEnsureCapacity(pDestBlock, pSrcBlock->info.rows);
+ if (code != TSDB_CODE_SUCCESS) {
+ return code;
+ }
+ ASSERT(taosArrayGetSize(pSrcBlock->pDataBlock) >= 3);
+ SColumnInfoData* pStartTsCol = taosArrayGet(pSrcBlock->pDataBlock, START_TS_COLUMN_INDEX);
+ TSKEY* startData = (TSKEY*)pStartTsCol->pData;
+ SColumnInfoData* pEndTsCol = taosArrayGet(pSrcBlock->pDataBlock, END_TS_COLUMN_INDEX);
+ TSKEY* endData = (TSKEY*)pEndTsCol->pData;
+ SColumnInfoData* pUidCol = taosArrayGet(pSrcBlock->pDataBlock, UID_COLUMN_INDEX);
+ uint64_t* uidCol = (uint64_t*)pUidCol->pData;
+
+ SColumnInfoData* pDestStartCol = taosArrayGet(pDestBlock->pDataBlock, START_TS_COLUMN_INDEX);
+ SColumnInfoData* pDestEndCol = taosArrayGet(pDestBlock->pDataBlock, END_TS_COLUMN_INDEX);
+ SColumnInfoData* pDestUidCol = taosArrayGet(pDestBlock->pDataBlock, UID_COLUMN_INDEX);
+ SColumnInfoData* pDestGpCol = taosArrayGet(pDestBlock->pDataBlock, GROUPID_COLUMN_INDEX);
+ SColumnInfoData* pDestCalStartTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_START_TS_COLUMN_INDEX);
+ SColumnInfoData* pDestCalEndTsCol = taosArrayGet(pDestBlock->pDataBlock, CALCULATE_END_TS_COLUMN_INDEX);
+ int32_t dummy = 0;
+ int64_t version = pSrcBlock->info.version - 1;
+ for (int32_t i = 0; i < pSrcBlock->info.rows; i++) {
+ uint64_t groupId = getGroupIdByData(pInfo, uidCol[i], startData[i], version);
+ colDataAppend(pDestStartCol, i, (const char*)(startData + i), false);
+ colDataAppend(pDestEndCol, i, (const char*)(endData + i), false);
+ colDataAppendNULL(pDestUidCol, i);
+ colDataAppend(pDestGpCol, i, (const char*)&groupId, false);
+ colDataAppendNULL(pDestCalStartTsCol, i);
+ colDataAppendNULL(pDestCalEndTsCol, i);
+ pDestBlock->info.rows++;
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
static int32_t generateScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSrcBlock, SSDataBlock* pDestBlock) {
int32_t code = TSDB_CODE_SUCCESS;
if (isIntervalWindow(pInfo)) {
code = generateIntervalScanRange(pInfo, pSrcBlock, pDestBlock);
- } else {
+ } else if (isSessionWindow(pInfo) || isStateWindow(pInfo)) {
code = generateSessionScanRange(pInfo, pSrcBlock, pDestBlock);
}
pDestBlock->info.type = STREAM_CLEAR;
@@ -1277,10 +1323,10 @@ static void checkUpdateData(SStreamScanInfo* pInfo, bool invertible, SSDataBlock
bool closedWin = isClosed && isSignleIntervalWindow(pInfo) &&
isDeletedWindow(&win, pBlock->info.groupId, pInfo->windowSup.pIntervalAggSup);
if ((update || closedWin) && out) {
- uint64_t gpId = closedWin&&pInfo->partitionSup.needCalc ?
- calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId) : 0;
- appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid,
- &gpId);
+ uint64_t gpId = closedWin && pInfo->partitionSup.needCalc
+ ? calGroupIdByData(&pInfo->partitionSup, pInfo->pPartScalarSup, pBlock, rowId)
+ : 0;
+ appendOneRow(pInfo->pUpdateDataRes, tsCol + rowId, tsCol + rowId, &pBlock->info.uid, &gpId);
}
}
if (out && pInfo->pUpdateDataRes->info.rows > 0) {
@@ -1510,13 +1556,23 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
updateInfoAddCloseWindowSBF(pInfo->pUpdateInfo);
} break;
case STREAM_DELETE_DATA: {
- pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
- pInfo->updateResIndex = 0;
- generateScanRange(pInfo, pBlock, pInfo->pUpdateRes);
- prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
- copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
- pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
- return pInfo->pDeleteDataRes;
+ printDataBlock(pBlock, "stream scan delete recv");
+ if (!isIntervalWindow(pInfo) && !isSessionWindow(pInfo) && !isStateWindow(pInfo)) {
+ generateDeleteResultBlock(pInfo, pBlock, pInfo->pDeleteDataRes);
+ pInfo->pDeleteDataRes->info.type = STREAM_DELETE_RESULT;
+ printDataBlock(pBlock, "stream scan delete result");
+ return pInfo->pDeleteDataRes;
+ } else {
+ pInfo->blockType = STREAM_INPUT__DATA_SUBMIT;
+ pInfo->updateResIndex = 0;
+ generateScanRange(pInfo, pBlock, pInfo->pUpdateRes);
+ prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
+ copyDataBlock(pInfo->pDeleteDataRes, pInfo->pUpdateRes);
+ pInfo->pDeleteDataRes->info.type = STREAM_DELETE_DATA;
+ pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
+ printDataBlock(pBlock, "stream scan delete data");
+ return pInfo->pDeleteDataRes;
+ }
} break;
default:
break;
@@ -1531,7 +1587,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
return pInfo->pRes;
} break;
- case STREAM_SCAN_FROM_DELETERES: {
+ case STREAM_SCAN_FROM_DELETE_DATA: {
generateScanRange(pInfo, pInfo->pUpdateDataRes, pInfo->pUpdateRes);
prepareRangeScan(pInfo, pInfo->pUpdateRes, &pInfo->updateResIndex);
pInfo->scanMode = STREAM_SCAN_FROM_DATAREADER_RANGE;
@@ -1645,7 +1701,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
pInfo->scanMode = STREAM_SCAN_FROM_RES;
return pInfo->pUpdateDataRes;
} else if (pInfo->pUpdateDataRes->info.type == STREAM_DELETE_DATA) {
- pInfo->scanMode = STREAM_SCAN_FROM_DELETERES;
+ pInfo->scanMode = STREAM_SCAN_FROM_DELETE_DATA;
}
}
}
@@ -1915,7 +1971,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
ASSERT(pHandle->tqReader);
pInfo->tqReader = pHandle->tqReader;
}
-
+
pInfo->pUpdateInfo = NULL;
pInfo->pTableScanOp = pTableScanOp;
pInfo->interval = pTSInfo->pdInfo.interval;
@@ -1947,8 +2003,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
pInfo->pUpdateRes = createSpecialDataBlock(STREAM_CLEAR);
pInfo->pCondition = pScanPhyNode->node.pConditions;
pInfo->scanMode = STREAM_SCAN_FROM_READERHANDLE;
- pInfo->windowSup =
- (SWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN};
+ pInfo->windowSup = (SWindowSupporter){.pStreamAggSup = NULL, .gap = -1, .parentType = QUERY_NODE_PHYSICAL_PLAN};
pInfo->groupId = 0;
pInfo->pPullDataRes = createSpecialDataBlock(STREAM_RETRIEVE);
pInfo->pStreamScanOp = pOperator;
@@ -2649,7 +2704,7 @@ static SSDataBlock* doSysTableScan(SOperatorInfo* pOperator) {
}
char* pStart = pRsp->data;
- extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pOperator->exprSupp.numOfExprs, pInfo->scanCols, &pStart);
+ extractDataBlockFromFetchRsp(pInfo->pRes, pRsp->data, pInfo->scanCols, &pStart);
updateLoadRemoteInfo(&pInfo->loadInfo, pRsp->numOfRows, pRsp->compLen, startTs, pOperator);
// todo log the filter info
diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c
index 26667cd64f..b3a85807ae 100644
--- a/source/libs/executor/src/timewindowoperator.c
+++ b/source/libs/executor/src/timewindowoperator.c
@@ -35,14 +35,15 @@ typedef struct SPullWindowInfo {
typedef struct SOpenWindowInfo {
SResultRowPosition pos;
- uint64_t groupId;
+ uint64_t groupId;
} SOpenWindowInfo;
static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator);
static int64_t* extractTsCol(SSDataBlock* pBlock, const SIntervalAggOperatorInfo* pInfo);
-static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult, uint64_t groupId);
+static SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SResultRow* pResult,
+ uint64_t groupId);
static void doCloseWindow(SResultRowInfo* pResultRowInfo, const SIntervalAggOperatorInfo* pInfo, SResultRow* pResult);
///*
@@ -601,15 +602,15 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info;
SExprSupp* pSup = &pOperatorInfo->exprSupp;
- int32_t startPos = 0;
- int32_t numOfOutput = pSup->numOfExprs;
+ int32_t startPos = 0;
+ int32_t numOfOutput = pSup->numOfExprs;
SResultRow* pResult = NULL;
while (1) {
- SListNode* pn = tdListGetHead(pResultRowInfo->openWindow);
- SOpenWindowInfo* pOpenWin = (SOpenWindowInfo *)pn->data;
- uint64_t groupId = pOpenWin->groupId;
+ SListNode* pn = tdListGetHead(pResultRowInfo->openWindow);
+ SOpenWindowInfo* pOpenWin = (SOpenWindowInfo*)pn->data;
+ uint64_t groupId = pOpenWin->groupId;
SResultRowPosition* p1 = &pOpenWin->pos;
if (p->pageId == p1->pageId && p->offset == p1->offset) {
break;
@@ -621,7 +622,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
if (pr->closed) {
ASSERT(isResultRowInterpolated(pr, RESULT_ROW_START_INTERP) &&
isResultRowInterpolated(pr, RESULT_ROW_END_INTERP));
- tdListPopHead(pResultRowInfo->openWindow);
+ SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow);
+ taosMemoryFree(pNode);
continue;
}
@@ -650,7 +652,8 @@ static void doInterpUnclosedTimeWindow(SOperatorInfo* pOperatorInfo, int32_t num
if (isResultRowInterpolated(pResult, RESULT_ROW_END_INTERP)) {
closeResultRow(pr);
- tdListPopHead(pResultRowInfo->openWindow);
+ SListNode* pNode = tdListPopHead(pResultRowInfo->openWindow);
+ taosMemoryFree(pNode);
} else { // the remains are can not be closed yet.
break;
}
@@ -936,7 +939,7 @@ bool isOverdue(TSKEY ts, STimeWindowAggSupp* pSup) {
bool isCloseWindow(STimeWindow* pWin, STimeWindowAggSupp* pSup) { return isOverdue(pWin->ekey, pSup); }
static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock,
- int32_t scanFlag, SHashObj* pUpdatedMap) {
+ int32_t scanFlag) {
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)pOperatorInfo->info;
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
@@ -952,21 +955,11 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
STimeWindow win =
getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->inputOrder);
- int32_t ret = TSDB_CODE_SUCCESS;
- if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
- inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
- ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
- numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
- if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
- T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
- }
-
- if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM && pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
- saveWinResultRow(pResult, tableGroupId, pUpdatedMap);
- setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur);
- }
+ int32_t ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
+ pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
+ if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
+ T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
}
-
TSKEY ekey = ascScan ? win.ekey : win.skey;
int32_t forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
@@ -988,12 +981,9 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
doWindowBorderInterpolation(pInfo, pBlock, pResult, &win, startPos, forwardRows, pSup);
}
- if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
- inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
- updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
- doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
- numOfOutput);
- }
+ updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
+ doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
+ numOfOutput);
doCloseWindow(pResultRowInfo, pInfo, pResult);
@@ -1004,13 +994,6 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
if (startPos < 0) {
break;
}
- if (pInfo->ignoreExpiredData && isCloseWindow(&nextWin, &pInfo->twAggSup)) {
- ekey = ascScan ? nextWin.ekey : nextWin.skey;
- forwardRows =
- getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
- continue;
- }
-
// null data, failed to allocate more memory buffer
int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
@@ -1018,17 +1001,12 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul
T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
}
- if (pInfo->execModel == OPTR_EXEC_MODEL_STREAM && pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
- saveWinResultRow(pResult, tableGroupId, pUpdatedMap);
- setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur);
- }
-
ekey = ascScan ? nextWin.ekey : nextWin.skey;
forwardRows =
getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, pInfo->inputOrder);
// window start(end) key interpolation
doWindowBorderInterpolation(pInfo, pBlock, pResult, &nextWin, startPos, forwardRows, pSup);
- //TODO: add to open window? how to close the open windows after input blocks exhausted?
+ // TODO: add to open window? how to close the open windows after input blocks exhausted?
#if 0
if ((ascScan && ekey <= pBlock->info.window.ekey) ||
(!ascScan && ekey >= pBlock->info.window.skey)) {
@@ -1062,13 +1040,13 @@ SResultRowPosition addToOpenWindowList(SResultRowInfo* pResultRowInfo, const SRe
openWin.pos.pageId = pResult->pageId;
openWin.pos.offset = pResult->offset;
openWin.groupId = groupId;
- SListNode* pn = tdListGetTail(pResultRowInfo->openWindow);
+ SListNode* pn = tdListGetTail(pResultRowInfo->openWindow);
if (pn == NULL) {
tdListAppend(pResultRowInfo->openWindow, &openWin);
return openWin.pos;
}
- SOpenWindowInfo * px = (SOpenWindowInfo *)pn->data;
+ SOpenWindowInfo* px = (SOpenWindowInfo*)pn->data;
if (px->pos.pageId != openWin.pos.pageId || px->pos.offset != openWin.pos.offset || px->groupId != openWin.groupId) {
tdListAppend(pResultRowInfo->openWindow, &openWin);
}
@@ -1127,7 +1105,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo* pOperator) {
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, scanFlag, true);
blockDataUpdateTsWindow(pBlock, pInfo->primaryTsIndex);
- hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag, NULL);
+ hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, scanFlag);
}
initGroupedResultInfo(&pInfo->groupResInfo, pInfo->aggSup.pResultRowHashTable, pInfo->resultTsOrder);
@@ -1424,23 +1402,29 @@ bool doDeleteIntervalWindow(SAggSupporter* pAggSup, TSKEY ts, uint64_t groupId)
return true;
}
-void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* pDelWins, SInterval* pInterval, SHashObj* pUpdatedMap) {
+void doDeleteSpecifyIntervalWindow(SAggSupporter* pAggSup, SSDataBlock* pBlock, SArray* pDelWins, SInterval* pInterval,
+ SHashObj* pUpdatedMap) {
SColumnInfoData* pStartCol = taosArrayGet(pBlock->pDataBlock, START_TS_COLUMN_INDEX);
TSKEY* tsStarts = (TSKEY*)pStartCol->pData;
+ SColumnInfoData* pEndCol = taosArrayGet(pBlock->pDataBlock, END_TS_COLUMN_INDEX);
+ TSKEY* tsEnds = (TSKEY*)pEndCol->pData;
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
uint64_t* groupIds = (uint64_t*)pGroupCol->pData;
for (int32_t i = 0; i < pBlock->info.rows; i++) {
SResultRowInfo dumyInfo;
dumyInfo.cur.pageId = -1;
STimeWindow win = getActiveTimeWindow(NULL, &dumyInfo, tsStarts[i], pInterval, TSDB_ORDER_ASC);
- doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]);
- SWinKey winRes = {.ts = win.skey, .groupId = groupIds[i]};
- if (pDelWins) {
- taosArrayPush(pDelWins, &winRes);
- }
- if (pUpdatedMap) {
- taosHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey));
- }
+ do {
+ doDeleteIntervalWindow(pAggSup, win.skey, groupIds[i]);
+ SWinKey winRes = {.ts = win.skey, .groupId = groupIds[i]};
+ if (pDelWins) {
+ taosArrayPush(pDelWins, &winRes);
+ }
+ if (pUpdatedMap) {
+ taosHashRemove(pUpdatedMap, &winRes, sizeof(SWinKey));
+ }
+ getNextTimeWindow(pInterval, pInterval->precision, TSDB_ORDER_ASC, &win);
+ } while (win.skey <= tsEnds[i]);
}
}
@@ -1469,7 +1453,6 @@ static void doClearWindows(SAggSupporter* pAggSup, SExprSupp* pSup1, SInterval*
}
static int32_t getAllIntervalWindow(SSHashObj* pHashMap, SHashObj* resWins) {
-
void* pIte = NULL;
size_t keyLen = 0;
int32_t iter = 0;
@@ -1578,141 +1561,6 @@ static void doBuildDeleteResult(SArray* pWins, int32_t* index, SSDataBlock* pBlo
}
}
-static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
- SIntervalAggOperatorInfo* pInfo = pOperator->info;
- SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
-
- pInfo->inputOrder = TSDB_ORDER_ASC;
- SExprSupp* pSup = &pOperator->exprSupp;
-
- if (pOperator->status == OP_EXEC_DONE) {
- return NULL;
- }
-
- if (pOperator->status == OP_RES_TO_RETURN) {
- doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
- if (pInfo->pDelRes->info.rows > 0) {
- printDataBlock(pInfo->pDelRes, "single interval");
- return pInfo->pDelRes;
- }
-
- doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
- if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) {
- pOperator->status = OP_EXEC_DONE;
- qDebug("===stream===single interval is done");
- freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
- }
- printDataBlock(pInfo->binfo.pRes, "single interval");
- return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
- }
-
- SOperatorInfo* downstream = pOperator->pDownstream[0];
-
- SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); // SResKeyPos
- _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
- SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
-
- SStreamState* pState = pTaskInfo->streamInfo.pState;
-
- while (1) {
- SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
- if (pBlock == NULL) {
- break;
- }
- // qInfo("===stream===%ld", pBlock->info.version);
- printDataBlock(pBlock, "single interval recv");
-
- if (pBlock->info.type == STREAM_CLEAR) {
- doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock,
- NULL);
- qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
- continue;
- }
- if (pBlock->info.type == STREAM_DELETE_DATA) {
- doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval, pUpdatedMap);
- continue;
- } else if (pBlock->info.type == STREAM_GET_ALL) {
- getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap);
- continue;
- }
-
- if (pBlock->info.type == STREAM_NORMAL && pBlock->info.version != 0) {
- // set input version
- pTaskInfo->version = pBlock->info.version;
- }
-
- if (pInfo->scalarSupp.pExprInfo != NULL) {
- SExprSupp* pExprSup = &pInfo->scalarSupp;
- projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
- }
-
- // The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
- // caller. Note that all the time window are not close till now.
- // the pDataBlock are always the same one, no need to call this again
- setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->inputOrder, MAIN_SCAN, true);
- if (pInfo->invertible) {
- setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type);
- }
-
- pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, pBlock->info.window.ekey);
- hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap);
- }
-
-#if 0
- if (pState) {
- printf(">>>>>>>> stream read backend\n");
- SWinKey key = {
- .ts = 1,
- .groupId = 2,
- };
- char* val = NULL;
- int32_t sz;
- if (streamStateGet(pState, &key, (void**)&val, &sz) < 0) {
- ASSERT(0);
- }
- printf("stream read %s %d\n", val, sz);
- streamFreeVal(val);
-
- SStreamStateCur* pCur = streamStateGetCur(pState, &key);
- ASSERT(pCur);
- while (streamStateCurNext(pState, pCur) == 0) {
- SWinKey key1;
- const void* val1;
- if (streamStateGetKVByCur(pCur, &key1, &val1, &sz) < 0) {
- break;
- }
- printf("stream iter key groupId:%d ts:%d, value %s %d\n", key1.groupId, key1.ts, val1, sz);
- }
- streamStateFreeCur(pCur);
- }
-#endif
-
- pOperator->status = OP_RES_TO_RETURN;
- closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdatedMap,
- pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
-
- void* pIte = NULL;
- while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) {
- taosArrayPush(pUpdated, pIte);
- }
- taosArraySort(pUpdated, resultrowComparAsc);
-
- finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset);
- initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
- blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
- removeDeleteResults(pUpdatedMap, pInfo->pDelWins);
- taosHashCleanup(pUpdatedMap);
- doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
- if (pInfo->pDelRes->info.rows > 0) {
- printDataBlock(pInfo->pDelRes, "single interval");
- return pInfo->pDelRes;
- }
-
- doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
- printDataBlock(pInfo->binfo.pRes, "single interval");
- return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
-}
-
static void destroyStateWindowOperatorInfo(void* param) {
SStateWindowOperatorInfo* pInfo = (SStateWindowOperatorInfo*)param;
cleanupBasicInfo(&pInfo->binfo);
@@ -1730,6 +1578,10 @@ void destroyIntervalOperatorInfo(void* param) {
SIntervalAggOperatorInfo* pInfo = (SIntervalAggOperatorInfo*)param;
cleanupBasicInfo(&pInfo->binfo);
cleanupAggSup(&pInfo->aggSup);
+ cleanupExprSupp(&pInfo->scalarSupp);
+
+ tdListFree(pInfo->binfo.resultRowInfo.openWindow);
+
pInfo->pRecycledPages = taosArrayDestroy(pInfo->pRecycledPages);
pInfo->pInterpCols = taosArrayDestroy(pInfo->pInterpCols);
taosArrayDestroyEx(pInfo->pPrevValues, freeItem);
@@ -1826,7 +1678,8 @@ static bool timeWindowinterpNeeded(SqlFunctionCtx* pCtx, int32_t numOfCols, SInt
return needed;
}
-void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup, SInterval* pInterval, int64_t waterMark) {
+void initIntervalDownStream(SOperatorInfo* downstream, uint16_t type, SAggSupporter* pSup, SInterval* pInterval,
+ int64_t waterMark) {
if (downstream->operatorType != QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN) {
initIntervalDownStream(downstream->pDownstream[0], type, pSup, pInterval, waterMark);
return;
@@ -1917,11 +1770,12 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo*
pOperator->status = OP_NOT_OPENED;
pOperator->info = pInfo;
- pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, doStreamIntervalAgg, NULL,
+ pOperator->fpSet = createOperatorFpSet(doOpenIntervalAgg, doBuildIntervalResult, NULL, NULL,
destroyIntervalOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
if (nodeType(pPhyNode) == QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL) {
- initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup, &pInfo->interval, pInfo->twAggSup.waterMark);
+ initIntervalDownStream(downstream, QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL, &pInfo->aggSup, &pInfo->interval,
+ pInfo->twAggSup.waterMark);
}
code = appendDownstream(pOperator, &downstream, 1);
@@ -2248,7 +2102,6 @@ static void genInterpolationResult(STimeSliceOperatorInfo* pSliceInfo, SExprSupp
if (hasInterp) {
pResBlock->info.rows += 1;
}
-
}
static int32_t initPrevRowsKeeper(STimeSliceOperatorInfo* pInfo, SSDataBlock* pBlock) {
@@ -2721,7 +2574,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
goto _error;
}
- int32_t num = 0;
+ int32_t num = 0;
SExprInfo* pExprInfo = createExprInfo(pStateNode->window.pFuncs, NULL, &num);
SSDataBlock* pResBlock = createResDataBlock(pStateNode->window.node.pOutputDataBlockDesc);
int32_t tsSlotId = ((SColumnNode*)pStateNode->window.pTspk)->slotId;
@@ -2748,7 +2601,9 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi
initBasicInfo(&pInfo->binfo, pResBlock);
initResultRowInfo(&pInfo->binfo.resultRowInfo);
- pInfo->twAggSup = (STimeWindowAggSupp){.waterMark = pStateNode->window.watermark, .calTrigger = pStateNode->window.triggerType};;
+ pInfo->twAggSup =
+ (STimeWindowAggSupp){.waterMark = pStateNode->window.watermark, .calTrigger = pStateNode->window.triggerType};
+ ;
initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
pInfo->tsSlotId = tsSlotId;
@@ -2857,8 +2712,8 @@ void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3
}
SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(&pDestCtx[k]);
- char* p = GET_ROWCELL_INTERBUF(pEntryInfo);
- SColumnInfoData idata = {0};
+ char* p = GET_ROWCELL_INTERBUF(pEntryInfo);
+ SColumnInfoData idata = {0};
idata.info.type = TSDB_DATA_TYPE_BIGINT;
idata.info.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes;
idata.pData = p;
@@ -2867,7 +2722,7 @@ void compactFunctions(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx, int3
SScalarParam tw = {.numOfRows = 5, .columnData = pTimeWindowData};
pDestCtx[k].sfp.process(&tw, 1, &out);
pEntryInfo->numOfRes = 1;
- }else if (functionNeedToExecute(&pDestCtx[k]) && pDestCtx[k].fpSet.combine != NULL) {
+ } else if (functionNeedToExecute(&pDestCtx[k]) && pDestCtx[k].fpSet.combine != NULL) {
int32_t code = pDestCtx[k].fpSet.combine(&pDestCtx[k], &pSourceCtx[k]);
if (code != TSDB_CODE_SUCCESS) {
qError("%s apply functions error, code: %s", GET_TASKID(pTaskInfo), tstrerror(code));
@@ -2893,7 +2748,8 @@ STimeWindow getFinalTimeWindow(int64_t ts, SInterval* pInterval) {
}
static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExprSupp* pSup, SArray* pWinArray,
- int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo, SHashObj* pUpdatedMap) {
+ int32_t groupId, int32_t numOfOutput, SExecTaskInfo* pTaskInfo,
+ SHashObj* pUpdatedMap) {
int32_t size = taosArrayGetSize(pWinArray);
if (!pInfo->pChildren) {
return;
@@ -2924,7 +2780,7 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &parentWin, true);
compactFunctions(pSup->pCtx, pChildSup->pCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData);
}
- if (num > 1 && pUpdatedMap) {
+ if (num > 0 && pUpdatedMap) {
saveWinResultRow(pCurResult, pWinRes->groupId, pUpdatedMap);
setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pInfo->binfo.resultRowInfo.cur);
}
@@ -2934,7 +2790,7 @@ static void rebuildIntervalWindow(SStreamFinalIntervalOperatorInfo* pInfo, SExpr
bool isDeletedWindow(STimeWindow* pWin, uint64_t groupId, SAggSupporter* pSup) {
SET_RES_WINDOW_KEY(pSup->keyBuf, &pWin->skey, sizeof(int64_t), groupId);
SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(pSup->pResultRowHashTable, pSup->keyBuf,
- GET_RES_WINDOW_KEY_LEN(sizeof(int64_t)));
+ GET_RES_WINDOW_KEY_LEN(sizeof(int64_t)));
return p1 == NULL;
}
@@ -2956,15 +2812,14 @@ void addPullWindow(SHashObj* pMap, SWinKey* pWinRes, int32_t size) {
static int32_t getChildIndex(SSDataBlock* pBlock) { return pBlock->info.childId; }
-static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId,
- SHashObj* pUpdatedMap) {
+static void doHashIntervalAgg(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId,
+ SHashObj* pUpdatedMap) {
SStreamFinalIntervalOperatorInfo* pInfo = (SStreamFinalIntervalOperatorInfo*)pOperatorInfo->info;
SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo);
SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
SExprSupp* pSup = &pOperatorInfo->exprSupp;
int32_t numOfOutput = pSup->numOfExprs;
int32_t step = 1;
- bool ascScan = true;
TSKEY* tsCols = NULL;
SResultRow* pResult = NULL;
int32_t forwardRows = 0;
@@ -2973,7 +2828,7 @@ static void doHashInterval(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBloc
SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
tsCols = (int64_t*)pColDataInfo->pData;
- int32_t startPos = ascScan ? 0 : (pSDataBlock->info.rows - 1);
+ int32_t startPos = 0;
TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols);
STimeWindow nextWin = {0};
if (IS_FINAL_OP(pInfo)) {
@@ -3059,7 +2914,7 @@ static void clearStreamIntervalOperator(SStreamFinalIntervalOperatorInfo* pInfo)
tSimpleHashClear(pInfo->aggSup.pResultRowHashTable);
clearDiskbasedBuf(pInfo->aggSup.pResultBuf);
initResultRowInfo(&pInfo->binfo.resultRowInfo);
- pInfo->aggSup.currentPageId = -1;
+ pInfo->aggSup.currentPageId = -1;
}
static void clearSpecialDataBlock(SSDataBlock* pBlock) {
@@ -3145,7 +3000,7 @@ void processPullOver(SSDataBlock* pBlock, SHashObj* pMap) {
static void addRetriveWindow(SArray* wins, SStreamFinalIntervalOperatorInfo* pInfo) {
int32_t size = taosArrayGetSize(wins);
for (int32_t i = 0; i < size; i++) {
- SWinKey* winKey = taosArrayGet(wins, i);
+ SWinKey* winKey = taosArrayGet(wins, i);
STimeWindow nextWin = getFinalTimeWindow(winKey->ts, &pInfo->interval);
if (isCloseWindow(&nextWin, &pInfo->twAggSup) && !pInfo->ignoreExpiredData) {
void* chIds = taosHashGet(pInfo->pPullDataMap, winKey, sizeof(SWinKey));
@@ -3161,6 +3016,12 @@ static void addRetriveWindow(SArray* wins, SStreamFinalIntervalOperatorInfo* pIn
}
}
+static void clearFunctionContext(SExprSupp* pSup) {
+ for (int32_t i = 0; i < pSup->numOfExprs; i++) {
+ pSup->pCtx[i].saveHandle.currentPage = -1;
+ }
+}
+
static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
SStreamFinalIntervalOperatorInfo* pInfo = pOperator->info;
@@ -3196,6 +3057,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
if (pInfo->binfo.pRes->info.rows == 0) {
pOperator->status = OP_EXEC_DONE;
if (!IS_FINAL_OP(pInfo)) {
+ clearFunctionContext(&pOperator->exprSupp);
// semi interval operator clear disk buffer
clearStreamIntervalOperator(pInfo);
qDebug("===stream===clear semi operator");
@@ -3274,8 +3136,8 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
SStreamFinalIntervalOperatorInfo* pChildInfo = pChildOp->info;
SExprSupp* pChildSup = &pChildOp->exprSupp;
doDeleteSpecifyIntervalWindow(&pChildInfo->aggSup, pBlock, NULL, &pChildInfo->interval, NULL);
- rebuildIntervalWindow(pInfo, pSup, delWins, pInfo->binfo.pRes->info.groupId,
- pOperator->exprSupp.numOfExprs, pOperator->pTaskInfo, pUpdatedMap);
+ rebuildIntervalWindow(pInfo, pSup, delWins, pInfo->binfo.pRes->info.groupId, pOperator->exprSupp.numOfExprs,
+ pOperator->pTaskInfo, pUpdatedMap);
addRetriveWindow(delWins, pInfo);
taosArrayAddAll(pInfo->pDelWins, delWins);
taosArrayDestroy(delWins);
@@ -3307,7 +3169,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
}
setInputDataBlock(pOperator, pSup->pCtx, pBlock, pInfo->order, MAIN_SCAN, true);
- doHashInterval(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
+ doHashIntervalAgg(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
if (IS_FINAL_OP(pInfo)) {
int32_t chIndex = getChildIndex(pBlock);
int32_t size = taosArrayGetSize(pInfo->pChildren);
@@ -3325,7 +3187,7 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, chIndex);
SStreamFinalIntervalOperatorInfo* pChInfo = pChildOp->info;
setInputDataBlock(pChildOp, pChildOp->exprSupp.pCtx, pBlock, pChInfo->order, MAIN_SCAN, true);
- doHashInterval(pChildOp, pBlock, pBlock->info.groupId, NULL);
+ doHashIntervalAgg(pChildOp, pBlock, pBlock->info.groupId, NULL);
}
}
@@ -3381,40 +3243,6 @@ static SSDataBlock* doStreamFinalIntervalAgg(SOperatorInfo* pOperator) {
return NULL;
}
-SSDataBlock* createSpecialDataBlock(EStreamType type) {
- SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
- pBlock->info.hasVarCol = false;
- pBlock->info.groupId = 0;
- pBlock->info.rows = 0;
- pBlock->info.type = type;
- pBlock->info.rowSize =
- sizeof(TSKEY) + sizeof(TSKEY) + sizeof(uint64_t) + sizeof(uint64_t) + sizeof(TSKEY) + sizeof(TSKEY);
- pBlock->info.watermark = INT64_MIN;
-
- pBlock->pDataBlock = taosArrayInit(6, sizeof(SColumnInfoData));
- SColumnInfoData infoData = {0};
- infoData.info.type = TSDB_DATA_TYPE_TIMESTAMP;
- infoData.info.bytes = sizeof(TSKEY);
- // window start ts
- taosArrayPush(pBlock->pDataBlock, &infoData);
- // window end ts
- taosArrayPush(pBlock->pDataBlock, &infoData);
-
- infoData.info.type = TSDB_DATA_TYPE_UBIGINT;
- infoData.info.bytes = sizeof(uint64_t);
- // uid
- taosArrayPush(pBlock->pDataBlock, &infoData);
- // group id
- taosArrayPush(pBlock->pDataBlock, &infoData);
-
- // calculate start ts
- taosArrayPush(pBlock->pDataBlock, &infoData);
- // calculate end ts
- taosArrayPush(pBlock->pDataBlock, &infoData);
-
- return pBlock;
-}
-
SOperatorInfo* createStreamFinalIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
SExecTaskInfo* pTaskInfo, int32_t numOfChild) {
SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode;
@@ -3709,7 +3537,8 @@ SOperatorInfo* createStreamSessionAggOperatorInfo(SOperatorInfo* downstream, SPh
createOperatorFpSet(operatorDummyOpenFn, doStreamSessionAgg, NULL, NULL, destroyStreamSessionAggOperatorInfo,
aggEncodeResultRow, aggDecodeResultRow, NULL);
if (downstream) {
- initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap, pInfo->twAggSup.waterMark, pOperator->operatorType, pInfo->primaryTsIndex);
+ initDownStream(downstream, &pInfo->streamAggSup, pInfo->gap, pInfo->twAggSup.waterMark, pOperator->operatorType,
+ pInfo->primaryTsIndex);
code = appendDownstream(pOperator, &downstream, 1);
}
return pOperator;
@@ -3740,12 +3569,14 @@ bool isInTimeWindow(STimeWindow* pWin, TSKEY ts, int64_t gap) {
bool isInWindow(SResultWindowInfo* pWinInfo, TSKEY ts, int64_t gap) { return isInTimeWindow(&pWinInfo->win, ts, gap); }
static SResultWindowInfo* insertNewSessionWindow(SArray* pWinInfos, TSKEY startTs, TSKEY endTs, int32_t index) {
- SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false};
+ SResultWindowInfo win = {
+ .pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false};
return taosArrayInsert(pWinInfos, index, &win);
}
static SResultWindowInfo* addNewSessionWindow(SArray* pWinInfos, TSKEY startTs, TSKEY endTs) {
- SResultWindowInfo win = {.pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false};
+ SResultWindowInfo win = {
+ .pos.offset = -1, .pos.pageId = -1, .win.skey = startTs, .win.ekey = endTs, .isOutput = false};
return taosArrayPush(pWinInfos, &win);
}
@@ -3764,7 +3595,8 @@ SArray* getWinInfos(SStreamAggSupporter* pAggSup, uint64_t groupId) {
// don't add new window
SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY startTs, TSKEY endTs, uint64_t groupId,
int64_t gap, int32_t* pIndex) {
- SArray* pWinInfos = getWinInfos(pAggSup, groupId);
+ STimeWindow searchWin = {.skey = startTs, .ekey = endTs};
+ SArray* pWinInfos = getWinInfos(pAggSup, groupId);
pAggSup->pCurWins = pWinInfos;
int32_t size = taosArrayGetSize(pWinInfos);
@@ -3776,7 +3608,7 @@ SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY start
SResultWindowInfo* pWin = NULL;
if (index >= 0) {
pWin = taosArrayGet(pWinInfos, index);
- if (isInWindow(pWin, startTs, gap)) {
+ if (isInWindow(pWin, startTs, gap) || isInTimeWindow(&searchWin, pWin->win.skey, gap)) {
*pIndex = index;
return pWin;
}
@@ -3784,7 +3616,7 @@ SResultWindowInfo* getCurSessionWindow(SStreamAggSupporter* pAggSup, TSKEY start
if (index + 1 < size) {
pWin = taosArrayGet(pWinInfos, index + 1);
- if (isInWindow(pWin, startTs, gap)) {
+ if (isInWindow(pWin, startTs, gap) || isInTimeWindow(&searchWin, pWin->win.skey, gap)) {
*pIndex = index + 1;
return pWin;
} else if (endTs != INT64_MIN && isInWindow(pWin, endTs, gap)) {
@@ -3962,7 +3794,7 @@ void compactTimeWindow(SStreamSessionAggOperatorInfo* pInfo, int32_t startIndex,
updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pCurWin->win, true);
compactFunctions(pSup->pCtx, pInfo->pDummyCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData);
taosHashRemove(pStUpdated, &pWinInfo->pos, sizeof(SResultRowPosition));
- if (pWinInfo->isOutput) {
+ if (pWinInfo->isOutput && pStDeleted) {
SWinKey res = {.ts = pWinInfo->win.skey, .groupId = groupId};
taosHashPut(pStDeleted, &res, sizeof(SWinKey), &res, sizeof(SWinKey));
pWinInfo->isOutput = false;
@@ -4055,19 +3887,24 @@ static void doDeleteTimeWindows(SStreamAggSupporter* pAggSup, SSDataBlock* pBloc
SColumnInfoData* pGroupCol = taosArrayGet(pBlock->pDataBlock, GROUPID_COLUMN_INDEX);
uint64_t* gpDatas = (uint64_t*)pGroupCol->pData;
for (int32_t i = 0; i < pBlock->info.rows; i++) {
- int32_t winIndex = 0;
- while (1) {
- SResultWindowInfo* pCurWin = getCurSessionWindow(pAggSup, startDatas[i], endDatas[i], gpDatas[i], gap, &winIndex);
- if (!pCurWin) {
- break;
- }
+ int32_t winIndex = 0;
+ SResultWindowInfo* pCurWin = getCurSessionWindow(pAggSup, startDatas[i], endDatas[i], gpDatas[i], gap, &winIndex);
+ if (!pCurWin) {
+ continue;
+ }
+
+ do {
SResultWindowInfo delWin = *pCurWin;
deleteWindow(pAggSup->pCurWins, winIndex, fp);
if (result) {
delWin.groupId = gpDatas[i];
taosArrayPush(result, &delWin);
}
- }
+ if (winIndex >= taosArrayGetSize(pAggSup->pCurWins)) {
+ break;
+ }
+ pCurWin = taosArrayGet(pAggSup->pCurWins, winIndex);
+ } while (pCurWin->win.skey <= endDatas[i]);
}
}
@@ -4147,26 +3984,17 @@ void doBuildDeleteDataBlock(SHashObj* pStDeleted, SSDataBlock* pBlock, void** It
}
}
-static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWinArray,
- int32_t numOfOutput, SOperatorInfo* pOperator, SHashObj* pStUpdated, bool needCreate) {
+static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWinArray, int32_t numOfOutput,
+ SOperatorInfo* pOperator, SHashObj* pStUpdated) {
SExprSupp* pSup = &pOperator->exprSupp;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
-
- int32_t size = taosArrayGetSize(pWinArray);
+ int32_t size = taosArrayGetSize(pWinArray);
ASSERT(pInfo->pChildren);
for (int32_t i = 0; i < size; i++) {
SResultWindowInfo* pParentWin = taosArrayGet(pWinArray, i);
- SResultRow* pCurResult = NULL;
uint64_t groupId = pParentWin->groupId;
- int32_t winIndex = 0;
- if (needCreate) {
- pParentWin = getSessionTimeWindow(&pInfo->streamAggSup, pParentWin->win.skey, pParentWin->win.ekey, groupId, 0, &winIndex);
- }
- setWindowOutputBuf(pParentWin, &pCurResult, pSup->pCtx, groupId, numOfOutput, pSup->rowEntryInfoOffset,
- &pInfo->streamAggSup, pTaskInfo);
- int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren);
- int32_t num = 0;
+ int32_t numOfChildren = taosArrayGetSize(pInfo->pChildren);
for (int32_t j = 0; j < numOfChildren; j++) {
SOperatorInfo* pChild = taosArrayGetP(pInfo->pChildren, j);
SStreamSessionAggOperatorInfo* pChInfo = pChild->info;
@@ -4179,31 +4007,36 @@ static void rebuildTimeWindow(SStreamSessionAggOperatorInfo* pInfo, SArray* pWin
for (int32_t k = index; k < chWinSize; k++) {
SResultWindowInfo* pChWin = taosArrayGet(pChWins, k);
if (pParentWin->win.skey <= pChWin->win.skey && pChWin->win.ekey <= pParentWin->win.ekey) {
+ int32_t winIndex = 0;
+ SResultWindowInfo* pNewParWin =
+ getSessionTimeWindow(&pInfo->streamAggSup, pChWin->win.skey, pChWin->win.ekey, groupId, 0, &winIndex);
+ SResultRow* pPareResult = NULL;
+ setWindowOutputBuf(pNewParWin, &pPareResult, pSup->pCtx, groupId, numOfOutput, pSup->rowEntryInfoOffset,
+ &pInfo->streamAggSup, pTaskInfo);
SResultRow* pChResult = NULL;
setWindowOutputBuf(pChWin, &pChResult, pChild->exprSupp.pCtx, groupId, numOfOutput,
pChild->exprSupp.rowEntryInfoOffset, &pChInfo->streamAggSup, pTaskInfo);
- updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pChWin->win, true);
+ updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pNewParWin->win, true);
compactFunctions(pSup->pCtx, pChild->exprSupp.pCtx, numOfOutput, pTaskInfo, &pInfo->twAggSup.timeWindowData);
+
+ int32_t winNum = getNumCompactWindow(pInfo->streamAggSup.pCurWins, winIndex, pInfo->gap);
+ if (winNum > 0) {
+ compactTimeWindow(pInfo, winIndex, winNum, groupId, numOfOutput, pStUpdated, NULL, pOperator);
+ }
+
SFilePage* bufPage = getBufPage(pChInfo->streamAggSup.pResultBuf, pChWin->pos.pageId);
releaseBufPage(pChInfo->streamAggSup.pResultBuf, bufPage);
- num++;
- continue;
+
+ bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pNewParWin->pos.pageId);
+ setBufPageDirty(bufPage, true);
+ releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage);
+ SWinKey value = {.ts = pNewParWin->win.skey, .groupId = groupId};
+ taosHashPut(pStUpdated, &pNewParWin->pos, sizeof(SResultRowPosition), &value, sizeof(SWinKey));
} else if (!pChWin->isClosed) {
break;
}
}
}
- if (num == 0 && needCreate) {
- deleteWindow(pInfo->streamAggSup.pCurWins, winIndex, NULL);
- }
- if (pStUpdated && num > 0) {
- SWinKey value = {.ts = pParentWin->win.skey, .groupId = groupId};
- taosHashPut(pStUpdated, &pParentWin->pos, sizeof(SResultRowPosition), &value, sizeof(SWinKey));
- }
- SFilePage* bufPage = getBufPage(pInfo->streamAggSup.pResultBuf, pParentWin->pos.pageId);
- ASSERT(size > 0);
- setBufPageDirty(bufPage, true);
- releaseBufPage(pInfo->streamAggSup.pResultBuf, bufPage);
}
}
@@ -4292,9 +4125,9 @@ static void removeSessionResults(SHashObj* pHashMap, SArray* pWins) {
}
int32_t compareWinKey(void* pKey, void* data, int32_t index) {
- SArray* res = (SArray*)data;
+ SArray* res = (SArray*)data;
SResKeyPos* pos = taosArrayGetP(res, index);
- SWinKey* pData = (SWinKey*)pKey;
+ SWinKey* pData = (SWinKey*)pKey;
if (pData->ts == *(int64_t*)pos->key) {
if (pData->groupId > pos->groupId) {
return 1;
@@ -4317,7 +4150,7 @@ static void removeSessionDeleteResults(SArray* update, SHashObj* pStDeleted) {
int32_t num = taosArrayGetSize(update);
for (int32_t i = 0; i < num; i++) {
SResKeyPos* pos = taosArrayGetP(update, i);
- SWinKey winKey = {.ts = *(int64_t*)pos->key, .groupId = pos->groupId};
+ SWinKey winKey = {.ts = *(int64_t*)pos->key, .groupId = pos->groupId};
taosHashRemove(pStDeleted, &winKey, sizeof(SWinKey));
}
}
@@ -4346,7 +4179,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
_hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
SHashObj* pStUpdated = taosHashInit(64, hashFn, true, HASH_NO_LOCK);
SOperatorInfo* downstream = pOperator->pDownstream[0];
- SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); // SResKeyPos
+ SArray* pUpdated = taosArrayInit(16, POINTER_BYTES); // SResKeyPos
while (1) {
SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
if (pBlock == NULL) {
@@ -4362,9 +4195,9 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
int32_t childIndex = getChildIndex(pBlock);
SOperatorInfo* pChildOp = taosArrayGetP(pInfo->pChildren, childIndex);
SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info;
- doClearSessionWindows(&pChildInfo->streamAggSup, &pChildOp->exprSupp, pBlock, START_TS_COLUMN_INDEX, pChildOp->exprSupp.numOfExprs,
- 0, NULL);
- rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, NULL, false);
+ doClearSessionWindows(&pChildInfo->streamAggSup, &pChildOp->exprSupp, pBlock, START_TS_COLUMN_INDEX,
+ pChildOp->exprSupp.numOfExprs, 0, NULL);
+ rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, pStUpdated);
}
taosArrayDestroy(pWins);
continue;
@@ -4378,7 +4211,7 @@ static SSDataBlock* doStreamSessionAgg(SOperatorInfo* pOperator) {
SStreamSessionAggOperatorInfo* pChildInfo = pChildOp->info;
// gap must be 0
doDeleteTimeWindows(&pChildInfo->streamAggSup, pBlock, 0, NULL, NULL);
- rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, pStUpdated, true);
+ rebuildTimeWindow(pInfo, pWins, pOperator->exprSupp.numOfExprs, pOperator, pStUpdated);
}
copyDeleteWindowInfo(pWins, pInfo->pStDeleted);
removeSessionResults(pStUpdated, pWins);
@@ -4464,7 +4297,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
if (pOperator->status == OP_EXEC_DONE) {
return NULL;
}
-
+
{
doBuildResultDatablock(pOperator, pBInfo, &pInfo->groupResInfo, pInfo->streamAggSup.pResultBuf);
if (pBInfo->pRes->info.rows > 0) {
@@ -4486,6 +4319,7 @@ static SSDataBlock* doStreamSessionSemiAgg(SOperatorInfo* pOperator) {
}
if (pOperator->status == OP_RES_TO_RETURN) {
+ clearFunctionContext(&pOperator->exprSupp);
// semi interval operator clear disk buffer
clearStreamSessionOperator(pInfo);
pOperator->status = OP_EXEC_DONE;
@@ -4856,8 +4690,7 @@ static void doStreamStateAggImpl(SOperatorInfo* pOperator, SSDataBlock* pSDataBl
i, &allEqual, pStDeleted);
if (!allEqual) {
uint64_t uid = 0;
- appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey,
- &uid, &groupId);
+ appendOneRow(pAggSup->pScanBlock, &pCurWin->winInfo.win.skey, &pCurWin->winInfo.win.ekey, &uid, &groupId);
taosHashRemove(pSeUpdated, &pCurWin->winInfo.pos, sizeof(SResultRowPosition));
deleteWindow(pAggSup->pCurWins, winIndex, destroyStateWinInfo);
continue;
@@ -4886,7 +4719,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
SExprSupp* pSup = &pOperator->exprSupp;
SStreamStateAggOperatorInfo* pInfo = pOperator->info;
SOptrBasicInfo* pBInfo = &pInfo->binfo;
- int64_t maxTs = INT64_MIN;
+ int64_t maxTs = INT64_MIN;
if (pOperator->status == OP_RES_TO_RETURN) {
doBuildDeleteDataBlock(pInfo->pSeDeleted, pInfo->pDelRes, &pInfo->pDelIterator);
if (pInfo->pDelRes->info.rows > 0) {
@@ -4915,7 +4748,7 @@ static SSDataBlock* doStreamStateAgg(SOperatorInfo* pOperator) {
if (pBlock->info.type == STREAM_CLEAR) {
doClearStateWindows(&pInfo->streamAggSup, pBlock, pSeUpdated, pInfo->pSeDeleted);
continue;
- } else if (pBlock->info.type == STREAM_DELETE_DATA) {
+ } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
SArray* pWins = taosArrayInit(16, sizeof(SResultWindowInfo));
doDeleteTimeWindows(&pInfo->streamAggSup, pBlock, 0, pWins, destroyStateWinInfo);
copyDeleteWindowInfo(pWins, pInfo->pSeDeleted);
@@ -5035,7 +4868,8 @@ SOperatorInfo* createStreamStateAggOperatorInfo(SOperatorInfo* downstream, SPhys
pOperator->info = pInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doStreamStateAgg, NULL, NULL,
destroyStreamStateOperatorInfo, aggEncodeResultRow, aggDecodeResultRow, NULL);
- initDownStream(downstream, &pInfo->streamAggSup, 0, pInfo->twAggSup.waterMark, pOperator->operatorType, pInfo->primaryTsIndex);
+ initDownStream(downstream, &pInfo->streamAggSup, 0, pInfo->twAggSup.waterMark, pOperator->operatorType,
+ pInfo->primaryTsIndex);
code = appendDownstream(pOperator, &downstream, 1);
if (code != TSDB_CODE_SUCCESS) {
goto _error;
@@ -5064,8 +4898,8 @@ static int32_t outputMergeAlignedIntervalResult(SOperatorInfo* pOperatorInfo, ui
SExprSupp* pSup = &pOperatorInfo->exprSupp;
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &wstartTs, TSDB_KEYSIZE, tableGroupId);
- SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf,
- GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
+ SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(
+ iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
ASSERT(p1 != NULL);
finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pSup->pCtx, pSup->pExprInfo, pSup->numOfExprs,
@@ -5274,11 +5108,11 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
SExprSupp* pSup = &pOperator->exprSupp;
miaInfo->pCondition = pNode->window.node.pConditions;
- miaInfo->curTs = INT64_MIN;
- iaInfo->win = pTaskInfo->window;
- iaInfo->inputOrder = TSDB_ORDER_ASC;
- iaInfo->interval = interval;
- iaInfo->execModel = pTaskInfo->execModel;
+ miaInfo->curTs = INT64_MIN;
+ iaInfo->win = pTaskInfo->window;
+ iaInfo->inputOrder = TSDB_ORDER_ASC;
+ iaInfo->interval = interval;
+ iaInfo->execModel = pTaskInfo->execModel;
iaInfo->primaryTsIndex = ((SColumnNode*)pNode->window.pTspk)->slotId;
iaInfo->binfo.mergeResultBlock = pNode->window.mergeDataBlock;
@@ -5301,12 +5135,12 @@ SOperatorInfo* createMergeAlignedIntervalOperatorInfo(SOperatorInfo* downstream,
initResultRowInfo(&iaInfo->binfo.resultRowInfo);
blockDataEnsureCapacity(iaInfo->binfo.pRes, pOperator->resultInfo.capacity);
- pOperator->name = "TimeMergeAlignedIntervalAggOperator";
+ pOperator->name = "TimeMergeAlignedIntervalAggOperator";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL;
- pOperator->blocking = false;
- pOperator->status = OP_NOT_OPENED;
- pOperator->pTaskInfo = pTaskInfo;
- pOperator->info = miaInfo;
+ pOperator->blocking = false;
+ pOperator->status = OP_NOT_OPENED;
+ pOperator->pTaskInfo = pTaskInfo;
+ pOperator->info = miaInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, mergeAlignedIntervalAgg, NULL, NULL,
destroyMergeAlignedIntervalOperatorInfo, NULL, NULL, NULL);
@@ -5359,8 +5193,8 @@ static int32_t finalizeWindowResult(SOperatorInfo* pOperatorInfo, uint64_t table
SExprSupp* pExprSup = &pOperatorInfo->exprSupp;
SET_RES_WINDOW_KEY(iaInfo->aggSup.keyBuf, &win->skey, TSDB_KEYSIZE, tableGroupId);
- SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf,
- GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
+ SResultRowPosition* p1 = (SResultRowPosition*)tSimpleHashGet(
+ iaInfo->aggSup.pResultRowHashTable, iaInfo->aggSup.keyBuf, GET_RES_WINDOW_KEY_LEN(TSDB_KEYSIZE));
ASSERT(p1 != NULL);
finalizeResultRowIntoResultDataBlock(iaInfo->aggSup.pResultBuf, p1, pExprSup->pCtx, pExprSup->pExprInfo,
pExprSup->numOfExprs, pExprSup->rowEntryInfoOffset, pResultBlock, pTaskInfo);
@@ -5585,10 +5419,10 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
pMergeIntervalInfo->groupIntervals = tdListNew(sizeof(SGroupTimeWindow));
SIntervalAggOperatorInfo* pIntervalInfo = &pMergeIntervalInfo->intervalAggOperatorInfo;
- pIntervalInfo->win = pTaskInfo->window;
+ pIntervalInfo->win = pTaskInfo->window;
pIntervalInfo->inputOrder = TSDB_ORDER_ASC;
- pIntervalInfo->interval = interval;
- pIntervalInfo->execModel = pTaskInfo->execModel;
+ pIntervalInfo->interval = interval;
+ pIntervalInfo->execModel = pTaskInfo->execModel;
pIntervalInfo->binfo.mergeResultBlock = pIntervalPhyNode->window.mergeDataBlock;
pIntervalInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
@@ -5605,7 +5439,6 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
initBasicInfo(&pIntervalInfo->binfo, pResBlock);
initExecTimeWindowInfo(&pIntervalInfo->twAggSup.timeWindowData, &pIntervalInfo->win);
-
pIntervalInfo->timeWindowInterpo = timeWindowinterpNeeded(pExprSupp->pCtx, num, pIntervalInfo);
if (pIntervalInfo->timeWindowInterpo) {
pIntervalInfo->binfo.resultRowInfo.openWindow = tdListNew(sizeof(SOpenWindowInfo));
@@ -5616,12 +5449,12 @@ SOperatorInfo* createMergeIntervalOperatorInfo(SOperatorInfo* downstream, SMerge
initResultRowInfo(&pIntervalInfo->binfo.resultRowInfo);
- pOperator->name = "TimeMergeIntervalAggOperator";
+ pOperator->name = "TimeMergeIntervalAggOperator";
pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_MERGE_INTERVAL;
- pOperator->blocking = false;
- pOperator->status = OP_NOT_OPENED;
- pOperator->pTaskInfo = pTaskInfo;
- pOperator->info = pMergeIntervalInfo;
+ pOperator->blocking = false;
+ pOperator->status = OP_NOT_OPENED;
+ pOperator->pTaskInfo = pTaskInfo;
+ pOperator->info = pMergeIntervalInfo;
pOperator->fpSet = createOperatorFpSet(operatorDummyOpenFn, doMergeIntervalAgg, NULL, NULL,
destroyMergeIntervalOperatorInfo, NULL, NULL, NULL);
@@ -5639,3 +5472,397 @@ _error:
pTaskInfo->code = code;
return NULL;
}
+
+static void doStreamIntervalAggImpl(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pBlock,
+ int32_t scanFlag, SHashObj* pUpdatedMap) {
+ SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info;
+
+ SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
+ SExprSupp* pSup = &pOperatorInfo->exprSupp;
+
+ int32_t startPos = 0;
+ int32_t numOfOutput = pSup->numOfExprs;
+ SColumnInfoData* pColDataInfo = taosArrayGet(pBlock->pDataBlock, pInfo->primaryTsIndex);
+ TSKEY* tsCols = (TSKEY*)pColDataInfo->pData;
+ uint64_t tableGroupId = pBlock->info.groupId;
+ bool ascScan = true;
+ TSKEY ts = getStartTsKey(&pBlock->info.window, tsCols);
+ SResultRow* pResult = NULL;
+
+ STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, TSDB_ORDER_ASC);
+ int32_t ret = TSDB_CODE_SUCCESS;
+ if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
+ inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
+ ret = setTimeWindowOutputBuf(pResultRowInfo, &win, (scanFlag == MAIN_SCAN), &pResult, tableGroupId, pSup->pCtx,
+ numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
+ if (ret != TSDB_CODE_SUCCESS || pResult == NULL) {
+ T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
+ }
+ if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
+ saveWinResultRow(pResult, tableGroupId, pUpdatedMap);
+ setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur);
+ }
+ }
+
+ TSKEY ekey = ascScan ? win.ekey : win.skey;
+ int32_t forwardRows =
+ getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
+ ASSERT(forwardRows > 0);
+
+ if ((!pInfo->ignoreExpiredData || !isCloseWindow(&win, &pInfo->twAggSup)) &&
+ inSlidingWindow(&pInfo->interval, &win, &pBlock->info)) {
+ updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &win, true);
+ doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
+ numOfOutput);
+ }
+
+ STimeWindow nextWin = win;
+ while (1) {
+ int32_t prevEndPos = forwardRows - 1 + startPos;
+ startPos = getNextQualifiedWindow(&pInfo->interval, &nextWin, &pBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC);
+ if (startPos < 0) {
+ break;
+ }
+ if (pInfo->ignoreExpiredData && isCloseWindow(&nextWin, &pInfo->twAggSup)) {
+ ekey = ascScan ? nextWin.ekey : nextWin.skey;
+ forwardRows =
+ getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
+ continue;
+ }
+
+ // null data, failed to allocate more memory buffer
+ int32_t code = setTimeWindowOutputBuf(pResultRowInfo, &nextWin, (scanFlag == MAIN_SCAN), &pResult, tableGroupId,
+ pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset, &pInfo->aggSup, pTaskInfo);
+ if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
+ T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
+ }
+
+ if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE) {
+ saveWinResultRow(pResult, tableGroupId, pUpdatedMap);
+ setResultBufPageDirty(pInfo->aggSup.pResultBuf, &pResultRowInfo->cur);
+ }
+
+ ekey = ascScan ? nextWin.ekey : nextWin.skey;
+ forwardRows =
+ getNumOfRowsInTimeWindow(&pBlock->info, tsCols, startPos, ekey, binarySearchForKey, NULL, TSDB_ORDER_ASC);
+ updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
+ doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows, pBlock->info.rows,
+ numOfOutput);
+ }
+}
+
+static void doStreamIntervalAggImpl2(SOperatorInfo* pOperatorInfo, SSDataBlock* pSDataBlock, uint64_t tableGroupId,
+ SHashObj* pUpdatedMap) {
+ SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)pOperatorInfo->info;
+
+ SResultRowInfo* pResultRowInfo = &(pInfo->binfo.resultRowInfo);
+ SExecTaskInfo* pTaskInfo = pOperatorInfo->pTaskInfo;
+ SExprSupp* pSup = &pOperatorInfo->exprSupp;
+ int32_t numOfOutput = pSup->numOfExprs;
+ int32_t step = 1;
+ TSKEY* tsCols = NULL;
+ SResultRow* pResult = NULL;
+ int32_t forwardRows = 0;
+ int32_t aa = 4;
+
+ ASSERT(pSDataBlock->pDataBlock != NULL);
+ SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, pInfo->primaryTsIndex);
+ tsCols = (int64_t*)pColDataInfo->pData;
+
+ int32_t startPos = 0;
+ TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols);
+ STimeWindow nextWin =
+ getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, TSDB_ORDER_ASC);
+ while (1) {
+ bool isClosed = isCloseWindow(&nextWin, &pInfo->twAggSup);
+ if ((pInfo->ignoreExpiredData && isClosed) || !inSlidingWindow(&pInfo->interval, &nextWin, &pSDataBlock->info)) {
+ startPos = getNexWindowPos(&pInfo->interval, &pSDataBlock->info, tsCols, startPos, nextWin.ekey, &nextWin);
+ if (startPos < 0) {
+ break;
+ }
+ continue;
+ }
+
+ int32_t code = setOutputBuf(&nextWin, &pResult, tableGroupId, pSup->pCtx, numOfOutput, pSup->rowEntryInfoOffset,
+ &pInfo->aggSup, pTaskInfo);
+ if (code != TSDB_CODE_SUCCESS || pResult == NULL) {
+ T_LONG_JMP(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY);
+ }
+
+ forwardRows = getNumOfRowsInTimeWindow(&pSDataBlock->info, tsCols, startPos, nextWin.ekey, binarySearchForKey, NULL,
+ TSDB_ORDER_ASC);
+ if (pInfo->twAggSup.calTrigger == STREAM_TRIGGER_AT_ONCE && pUpdatedMap) {
+ saveWinResultRow(pResult, tableGroupId, pUpdatedMap);
+ }
+ updateTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &nextWin, true);
+ doApplyFunctions(pTaskInfo, pSup->pCtx, &pInfo->twAggSup.timeWindowData, startPos, forwardRows,
+ pSDataBlock->info.rows, numOfOutput);
+ SWinKey key = {
+ .ts = nextWin.skey,
+ .groupId = tableGroupId,
+ };
+ saveOutput(pTaskInfo, &key, pResult, pInfo->aggSup.resultRowSize);
+ releaseOutputBuf(pTaskInfo, &key, pResult);
+ int32_t prevEndPos = (forwardRows - 1) * step + startPos;
+ ASSERT(pSDataBlock->info.window.skey > 0 && pSDataBlock->info.window.ekey > 0);
+ startPos =
+ getNextQualifiedWindow(&pInfo->interval, &nextWin, &pSDataBlock->info, tsCols, prevEndPos, TSDB_ORDER_ASC);
+ if (startPos < 0) {
+ break;
+ }
+ }
+}
+
+void doBuildResult(SOperatorInfo* pOperator, SSDataBlock* pBlock, SGroupResInfo* pGroupResInfo) {
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+ // set output datablock version
+ pBlock->info.version = pTaskInfo->version;
+
+ blockDataCleanup(pBlock);
+ if (!hasRemainResults(pGroupResInfo)) {
+ return;
+ }
+
+ // clear the existed group id
+ pBlock->info.groupId = 0;
+ buildDataBlockFromGroupRes(pTaskInfo, pBlock, &pOperator->exprSupp, pGroupResInfo);
+}
+
+static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
+ SStreamIntervalOperatorInfo* pInfo = pOperator->info;
+ SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
+ int64_t maxTs = INT64_MIN;
+ SExprSupp* pSup = &pOperator->exprSupp;
+
+ if (pOperator->status == OP_EXEC_DONE) {
+ return NULL;
+ }
+
+ if (pOperator->status == OP_RES_TO_RETURN) {
+ doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
+ if (pInfo->pDelRes->info.rows > 0) {
+ printDataBlock(pInfo->pDelRes, "single interval");
+ return pInfo->pDelRes;
+ }
+
+ doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
+ if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainResults(&pInfo->groupResInfo)) {
+ pOperator->status = OP_EXEC_DONE;
+ qDebug("===stream===single interval is done");
+ freeAllPages(pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
+ }
+ printDataBlock(pInfo->binfo.pRes, "single interval");
+ return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
+ }
+
+ SOperatorInfo* downstream = pOperator->pDownstream[0];
+
+ SArray* pUpdated = taosArrayInit(4, POINTER_BYTES); // SResKeyPos
+ _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY);
+ SHashObj* pUpdatedMap = taosHashInit(1024, hashFn, false, HASH_NO_LOCK);
+
+ SStreamState* pState = pTaskInfo->streamInfo.pState;
+
+ while (1) {
+ SSDataBlock* pBlock = downstream->fpSet.getNextFn(downstream);
+ if (pBlock == NULL) {
+ break;
+ }
+ printDataBlock(pBlock, "single interval recv");
+
+ if (pBlock->info.type == STREAM_CLEAR) {
+ doClearWindows(&pInfo->aggSup, &pOperator->exprSupp, &pInfo->interval, pOperator->exprSupp.numOfExprs, pBlock,
+ NULL);
+ qDebug("%s clear existed time window results for updates checked", GET_TASKID(pTaskInfo));
+ continue;
+ } else if (pBlock->info.type == STREAM_DELETE_DATA || pBlock->info.type == STREAM_DELETE_RESULT) {
+ doDeleteSpecifyIntervalWindow(&pInfo->aggSup, pBlock, pInfo->pDelWins, &pInfo->interval, pUpdatedMap);
+ continue;
+ } else if (pBlock->info.type == STREAM_GET_ALL) {
+ getAllIntervalWindow(pInfo->aggSup.pResultRowHashTable, pUpdatedMap);
+ continue;
+ }
+
+ if (pBlock->info.type == STREAM_NORMAL && pBlock->info.version != 0) {
+ // set input version
+ pTaskInfo->version = pBlock->info.version;
+ }
+
+ if (pInfo->scalarSupp.pExprInfo != NULL) {
+ SExprSupp* pExprSup = &pInfo->scalarSupp;
+ projectApplyFunctions(pExprSup->pExprInfo, pBlock, pBlock, pExprSup->pCtx, pExprSup->numOfExprs, NULL);
+ }
+
+ // The timewindow that overlaps the timestamps of the input pBlock need to be recalculated and return to the
+ // caller. Note that all the time window are not close till now.
+ // the pDataBlock are always the same one, no need to call this again
+ setInputDataBlock(pOperator, pSup->pCtx, pBlock, TSDB_ORDER_ASC, MAIN_SCAN, true);
+ if (pInfo->invertible) {
+ setInverFunction(pSup->pCtx, pOperator->exprSupp.numOfExprs, pBlock->info.type);
+ }
+
+ maxTs = TMAX(maxTs, pBlock->info.window.ekey);
+ doStreamIntervalAggImpl(pOperator, &pInfo->binfo.resultRowInfo, pBlock, MAIN_SCAN, pUpdatedMap);
+ // new disc buf
+ // doStreamIntervalAggImpl2(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
+ }
+ pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
+
+#if 0
+ if (pState) {
+ printf(">>>>>>>> stream read backend\n");
+ SWinKey key = {
+ .ts = 1,
+ .groupId = 2,
+ };
+ char* val = NULL;
+ int32_t sz;
+ if (streamStateGet(pState, &key, (void**)&val, &sz) < 0) {
+ ASSERT(0);
+ }
+ printf("stream read %s %d\n", val, sz);
+ streamFreeVal(val);
+
+ SStreamStateCur* pCur = streamStateGetCur(pState, &key);
+ ASSERT(pCur);
+ while (streamStateCurNext(pState, pCur) == 0) {
+ SWinKey key1;
+ const void* val1;
+ if (streamStateGetKVByCur(pCur, &key1, &val1, &sz) < 0) {
+ break;
+ }
+ printf("stream iter key groupId:%d ts:%d, value %s %d\n", key1.groupId, key1.ts, val1, sz);
+ }
+ streamStateFreeCur(pCur);
+ }
+#endif
+
+ pOperator->status = OP_RES_TO_RETURN;
+ closeIntervalWindow(pInfo->aggSup.pResultRowHashTable, &pInfo->twAggSup, &pInfo->interval, NULL, pUpdatedMap,
+ pInfo->pRecycledPages, pInfo->aggSup.pResultBuf);
+
+ void* pIte = NULL;
+ while ((pIte = taosHashIterate(pUpdatedMap, pIte)) != NULL) {
+ taosArrayPush(pUpdated, pIte);
+ }
+ taosArraySort(pUpdated, resultrowComparAsc);
+
+ // new disc buf
+ finalizeUpdatedResult(pOperator->exprSupp.numOfExprs, pInfo->aggSup.pResultBuf, pUpdated, pSup->rowEntryInfoOffset);
+ initMultiResInfoFromArrayList(&pInfo->groupResInfo, pUpdated);
+ blockDataEnsureCapacity(pInfo->binfo.pRes, pOperator->resultInfo.capacity);
+ removeDeleteResults(pUpdatedMap, pInfo->pDelWins);
+ taosHashCleanup(pUpdatedMap);
+ doBuildDeleteResult(pInfo->pDelWins, &pInfo->delIndex, pInfo->pDelRes);
+ if (pInfo->pDelRes->info.rows > 0) {
+ printDataBlock(pInfo->pDelRes, "single interval");
+ return pInfo->pDelRes;
+ }
+
+ doBuildResultDatablock(pOperator, &pInfo->binfo, &pInfo->groupResInfo, pInfo->aggSup.pResultBuf);
+ // new disc buf
+ // doBuildResult(pOperator, pInfo->binfo.pRes, &pInfo->groupResInfo);
+ printDataBlock(pInfo->binfo.pRes, "single interval");
+ return pInfo->binfo.pRes->info.rows == 0 ? NULL : pInfo->binfo.pRes;
+}
+
+void destroyStreamIntervalOperatorInfo(void* param) {
+ SStreamIntervalOperatorInfo* pInfo = (SStreamIntervalOperatorInfo*)param;
+ cleanupBasicInfo(&pInfo->binfo);
+ cleanupAggSup(&pInfo->aggSup);
+ pInfo->pRecycledPages = taosArrayDestroy(pInfo->pRecycledPages);
+
+ pInfo->pDelWins = taosArrayDestroy(pInfo->pDelWins);
+ pInfo->pDelRes = blockDataDestroy(pInfo->pDelRes);
+
+ cleanupGroupResInfo(&pInfo->groupResInfo);
+ colDataDestroy(&pInfo->twAggSup.timeWindowData);
+ taosMemoryFreeClear(param);
+}
+
+SOperatorInfo* createStreamIntervalOperatorInfo(SOperatorInfo* downstream, SPhysiNode* pPhyNode,
+ SExecTaskInfo* pTaskInfo) {
+ SStreamIntervalOperatorInfo* pInfo = taosMemoryCalloc(1, sizeof(SStreamIntervalOperatorInfo));
+ SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
+ if (pInfo == NULL || pOperator == NULL) {
+ goto _error;
+ }
+ SStreamIntervalPhysiNode* pIntervalPhyNode = (SStreamIntervalPhysiNode*)pPhyNode;
+
+ int32_t numOfCols = 0;
+ SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->window.pFuncs, NULL, &numOfCols);
+ ASSERT(numOfCols > 0);
+ SSDataBlock* pResBlock = createResDataBlock(pPhyNode->pOutputDataBlockDesc);
+ SInterval interval = {
+ .interval = pIntervalPhyNode->interval,
+ .sliding = pIntervalPhyNode->sliding,
+ .intervalUnit = pIntervalPhyNode->intervalUnit,
+ .slidingUnit = pIntervalPhyNode->slidingUnit,
+ .offset = pIntervalPhyNode->offset,
+ .precision = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->node.resType.precision,
+ };
+ STimeWindowAggSupp twAggSupp = {
+ .waterMark = pIntervalPhyNode->window.watermark,
+ .calTrigger = pIntervalPhyNode->window.triggerType,
+ .maxTs = INT64_MIN,
+ };
+ ASSERT(twAggSupp.calTrigger != STREAM_TRIGGER_MAX_DELAY);
+ pOperator->pTaskInfo = pTaskInfo;
+ pInfo->interval = interval;
+ pInfo->twAggSup = twAggSupp;
+ pInfo->ignoreExpiredData = pIntervalPhyNode->window.igExpired;
+ pInfo->isFinal = false;
+
+ if (pIntervalPhyNode->window.pExprs != NULL) {
+ int32_t numOfScalar = 0;
+ SExprInfo* pScalarExprInfo = createExprInfo(pIntervalPhyNode->window.pExprs, NULL, &numOfScalar);
+ int32_t code = initExprSupp(&pInfo->scalarSupp, pScalarExprInfo, numOfScalar);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _error;
+ }
+ }
+
+ pInfo->primaryTsIndex = ((SColumnNode*)pIntervalPhyNode->window.pTspk)->slotId;
+ initResultSizeInfo(&pOperator->resultInfo, 4096);
+ SExprSupp* pSup = &pOperator->exprSupp;
+ size_t keyBufSize = sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES;
+ int32_t code = initAggInfo(pSup, &pInfo->aggSup, pExprInfo, numOfCols, keyBufSize, pTaskInfo->id.str);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _error;
+ }
+
+ initBasicInfo(&pInfo->binfo, pResBlock);
+ initStreamFunciton(pSup->pCtx, pSup->numOfExprs);
+ initExecTimeWindowInfo(&pInfo->twAggSup.timeWindowData, &pTaskInfo->window);
+
+ pInfo->invertible = allInvertible(pSup->pCtx, numOfCols);
+ pInfo->invertible = false; // Todo(liuyao): Dependent TSDB API
+ pInfo->pRecycledPages = taosArrayInit(4, sizeof(int32_t));
+ pInfo->pDelWins = taosArrayInit(4, sizeof(SWinKey));
+ pInfo->delIndex = 0;
+ pInfo->pDelRes = createSpecialDataBlock(STREAM_DELETE_RESULT);
+ initResultRowInfo(&pInfo->binfo.resultRowInfo);
+
+ pOperator->name = "StreamIntervalOperator";
+ pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL;
+ pOperator->blocking = true;
+ pOperator->status = OP_NOT_OPENED;
+ pOperator->info = pInfo;
+ pOperator->fpSet =
+ createOperatorFpSet(operatorDummyOpenFn, doStreamIntervalAgg, NULL, NULL, destroyStreamIntervalOperatorInfo,
+ aggEncodeResultRow, aggDecodeResultRow, NULL);
+
+ initIntervalDownStream(downstream, pPhyNode->type, &pInfo->aggSup, &pInfo->interval, pInfo->twAggSup.waterMark);
+ code = appendDownstream(pOperator, &downstream, 1);
+ if (code != TSDB_CODE_SUCCESS) {
+ goto _error;
+ }
+
+ return pOperator;
+
+_error:
+ destroyStreamIntervalOperatorInfo(pInfo);
+ taosMemoryFreeClear(pOperator);
+ pTaskInfo->code = code;
+ return NULL;
+}
diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c
index 168cd21c44..63fc9d9e1c 100644
--- a/source/libs/executor/src/tsort.c
+++ b/source/libs/executor/src/tsort.c
@@ -227,9 +227,9 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int
continue;
}
- SPageInfo* pPgInfo = *(SPageInfo**)taosArrayGet(pSource->pageIdList, pSource->pageIndex);
+ int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex);
- void* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo));
+ void* pPage = getBufPage(pHandle->pBuf, *pPgId);
code = blockDataFromBuf(pSource->src.pBlock, pPage);
if (code != TSDB_CODE_SUCCESS) {
return code;
@@ -302,9 +302,9 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT
pSource->pageIndex = -1;
pSource->src.pBlock = blockDataDestroy(pSource->src.pBlock);
} else {
- SPageInfo* pPgInfo = *(SPageInfo**)taosArrayGet(pSource->pageIdList, pSource->pageIndex);
+ int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex);
- void* pPage = getBufPage(pHandle->pBuf, getPageId(pPgInfo));
+ void* pPage = getBufPage(pHandle->pBuf, *pPgId);
int32_t code = blockDataFromBuf(pSource->src.pBlock, pPage);
if (code != TSDB_CODE_SUCCESS) {
return code;
diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c
index 648ae5a538..5844784ea4 100644
--- a/source/libs/function/src/builtins.c
+++ b/source/libs/function/src/builtins.c
@@ -2175,6 +2175,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = {
.type = FUNCTION_TYPE_AVG_PARTIAL,
.classification = FUNC_MGT_AGG_FUNC,
.translateFunc = translateAvgPartial,
+ .dataRequiredFunc = statisDataRequired,
.getEnvFunc = getAvgFuncEnv,
.initFunc = avgFunctionSetup,
.processFunc = avgFunction,
diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c
index 7160541c13..0d7fd1a6da 100644
--- a/source/libs/function/src/builtinsimpl.c
+++ b/source/libs/function/src/builtinsimpl.c
@@ -76,11 +76,11 @@ typedef struct STopBotResItem {
} STopBotResItem;
typedef struct STopBotRes {
- int32_t maxSize;
- int16_t type;
+ int32_t maxSize;
+ int16_t type;
- STuplePos nullTuplePos;
- bool nullTupleSaved;
+ STuplePos nullTuplePos;
+ bool nullTupleSaved;
STopBotResItem* pItems;
} STopBotRes;
@@ -223,14 +223,14 @@ typedef struct SMavgInfo {
} SMavgInfo;
typedef struct SSampleInfo {
- int32_t samples;
- int32_t totalPoints;
- int32_t numSampled;
- uint8_t colType;
- int16_t colBytes;
+ int32_t samples;
+ int32_t totalPoints;
+ int32_t numSampled;
+ uint8_t colType;
+ int16_t colBytes;
- STuplePos nullTuplePos;
- bool nullTupleSaved;
+ STuplePos nullTuplePos;
+ bool nullTupleSaved;
char* data;
STuplePos* tuplePos;
@@ -1147,7 +1147,7 @@ bool getMinmaxFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) {
}
static STuplePos saveTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock);
-static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
+static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSDataBlock* pSrcBlock, STuplePos* pPos);
static const char* loadTupleData(SqlFunctionCtx* pCtx, const STuplePos* pPos);
static int32_t findRowIndex(int32_t start, int32_t num, SColumnInfoData* pCol, const char* tval) {
@@ -1357,8 +1357,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
numOfElems += 1;
}
- } else if (type == TSDB_DATA_TYPE_BIGINT ||
- type == TSDB_DATA_TYPE_TIMESTAMP) {
+ } else if (type == TSDB_DATA_TYPE_BIGINT || type == TSDB_DATA_TYPE_TIMESTAMP) {
int64_t* pData = (int64_t*)pCol->pData;
int64_t* val = (int64_t*)&pBuf->v;
@@ -1581,7 +1580,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) {
}
_min_max_over:
- if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved ) {
+ if (numOfElems == 0 && pCtx->subsidiaries.num > 0 && !pBuf->nullTupleSaved) {
pBuf->nullTuplePos = saveTupleData(pCtx, pInput->startRowIndex, pCtx->pSrcBlock);
pBuf->nullTupleSaved = true;
}
@@ -1601,7 +1600,8 @@ int32_t maxFunction(SqlFunctionCtx* pCtx) {
}
static void setNullSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t rowIndex);
-static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos, int32_t rowIndex);
+static void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuplePos* pTuplePos,
+ int32_t rowIndex);
int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock) {
SResultRowEntryInfo* pEntryInfo = GET_RES_INFO(pCtx);
@@ -1651,7 +1651,7 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
if (pCtx->saveHandle.pBuf != NULL) {
if (pTuplePos->pageId != -1) {
- int32_t numOfCols = pCtx->subsidiaries.num;
+ int32_t numOfCols = pCtx->subsidiaries.num;
const char* p = loadTupleData(pCtx, pTuplePos);
bool* nullList = (bool*)p;
@@ -1660,7 +1660,7 @@ void setSelectivityValue(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, const STuple
// todo set the offset value to optimize the performance.
for (int32_t j = 0; j < numOfCols; ++j) {
SqlFunctionCtx* pc = pCtx->subsidiaries.pCtx[j];
- int32_t dstSlotId = pc->pExpr->base.resSchema.slotId;
+ int32_t dstSlotId = pc->pExpr->base.resSchema.slotId;
SColumnInfoData* pDstCol = taosArrayGet(pBlock->pDataBlock, dstSlotId);
ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes);
@@ -1701,7 +1701,7 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
char* pData = colDataGetData(pSrcCol, rowIndex);
// append to dest col
- int32_t dstSlotId = pc->pExpr->base.resSchema.slotId;
+ int32_t dstSlotId = pc->pExpr->base.resSchema.slotId;
SColumnInfoData* pDstCol = taosArrayGet(pCtx->pDstBlock->pDataBlock, dstSlotId);
ASSERT(pc->pExpr->base.resSchema.bytes == pDstCol->info.bytes);
@@ -1712,7 +1712,6 @@ void appendSelectivityValue(SqlFunctionCtx* pCtx, int32_t rowIndex, int32_t pos)
colDataAppend(pDstCol, pos, pData, false);
}
}
-
}
void replaceTupleData(STuplePos* pDestPos, STuplePos* pSourcePos) {
@@ -2590,8 +2589,8 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo*
memcpy(pHisto, pInput->pHisto, sizeof(SHistogramInfo) + sizeof(SHistBin) * (MAX_HISTOGRAM_BIN + 1));
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
- qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
- pHisto->numOfEntries, pHisto);
+ qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, pHisto->numOfEntries,
+ pHisto);
} else {
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
qDebug("%s input histogram, elem:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
@@ -2601,8 +2600,8 @@ static void apercentileTransferInfo(SAPercentileInfo* pInput, SAPercentileInfo*
memcpy(pHisto, pRes, sizeof(SHistogramInfo) + sizeof(SHistBin) * MAX_HISTOGRAM_BIN);
pHisto->elems = (SHistBin*)((char*)pHisto + sizeof(SHistogramInfo));
- qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems,
- pHisto->numOfEntries, pHisto);
+ qDebug("%s merge histo, total:%" PRId64 ", entry:%d, %p", __FUNCTION__, pHisto->numOfElems, pHisto->numOfEntries,
+ pHisto);
tHistogramDestroy(&pRes);
}
}
@@ -2629,8 +2628,8 @@ int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx) {
}
if (pInfo->algo != APERCT_ALGO_TDIGEST) {
- qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems, pInfo->pHisto->numOfEntries,
- pInfo->pHisto);
+ qDebug("%s after merge, total:%d, numOfEntry:%d, %p", __FUNCTION__, pInfo->pHisto->numOfElems,
+ pInfo->pHisto->numOfEntries, pInfo->pHisto);
}
SET_VAL(pResInfo, 1, 1);
@@ -2709,7 +2708,7 @@ int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx)
}
EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow) {
- SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*) pRes;
+ SResultRowEntryInfo* pEntry = (SResultRowEntryInfo*)pRes;
// not initialized yet, data is required
if (pEntry == NULL) {
@@ -2752,7 +2751,8 @@ static FORCE_INLINE TSKEY getRowPTs(SColumnInfoData* pTsColInfo, int32_t rowInde
return *(TSKEY*)colDataGetData(pTsColInfo, rowIndex);
}
-static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx, SFirstLastRes* pInfo) {
+static void firstlastSaveTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SqlFunctionCtx* pCtx,
+ SFirstLastRes* pInfo) {
if (pCtx->subsidiaries.num <= 0) {
return;
}
@@ -2795,6 +2795,8 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
// All null data column, return directly.
if (pInput->colDataAggIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) {
ASSERT(pInputCol->hasNull == true);
+ // save selectivity value for column consisted of all null values
+ firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
return 0;
}
@@ -2871,7 +2873,10 @@ int32_t firstFunction(SqlFunctionCtx* pCtx) {
}
}
#endif
-
+ if (numOfElems == 0) {
+ // save selectivity value for column consisted of all null values
+ firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
+ }
SET_VAL(pResInfo, numOfElems, 1);
return TSDB_CODE_SUCCESS;
}
@@ -2892,6 +2897,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
// All null data column, return directly.
if (pInput->colDataAggIsSet && (pInput->pColumnDataAgg[0]->numOfNull == pInput->totalRows)) {
ASSERT(pInputCol->hasNull == true);
+ // save selectivity value for column consisted of all null values
+ firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
return 0;
}
@@ -2952,7 +2959,10 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) {
}
}
#endif
-
+ if (numOfElems == 0) {
+ // save selectivity value for column consisted of all null values
+ firstlastSaveTupleData(pCtx->pSrcBlock, pInput->startRowIndex, pCtx, pInfo);
+ }
SET_VAL(pResInfo, numOfElems, 1);
return TSDB_CODE_SUCCESS;
}
@@ -3176,7 +3186,7 @@ bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo) {
static void doSetPrevVal(SDiffInfo* pDiffInfo, int32_t type, const char* pv) {
switch (type) {
case TSDB_DATA_TYPE_BOOL:
- pDiffInfo->prev.i64 = *(bool*)pv? 1:0;
+ pDiffInfo->prev.i64 = *(bool*)pv ? 1 : 0;
break;
case TSDB_DATA_TYPE_TINYINT:
pDiffInfo->prev.i64 = *(int8_t*)pv;
@@ -3537,7 +3547,8 @@ void doAddIntoResult(SqlFunctionCtx* pCtx, void* pData, int32_t rowIndex, SSData
* |(n columns, one bit for each column)| src column #1| src column #2|
* +------------------------------------+--------------+--------------+
*/
-void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies, char* buf) {
+void* serializeTupleData(const SSDataBlock* pSrcBlock, int32_t rowIndex, SSubsidiaryResInfo* pSubsidiaryies,
+ char* buf) {
char* nullList = buf;
char* pStart = (char*)(nullList + sizeof(bool) * pSubsidiaryies->num);
@@ -3585,7 +3596,7 @@ static STuplePos doSaveTupleData(SSerializeDataHandle* pHandle, const void* pBuf
}
}
- p = (STuplePos) {.pageId = pHandle->currentPage, .offset = pPage->num};
+ p = (STuplePos){.pageId = pHandle->currentPage, .offset = pPage->num};
memcpy(pPage->data + pPage->num, pBuf, length);
pPage->num += length;
@@ -3621,7 +3632,6 @@ static int32_t doUpdateTupleData(SSerializeDataHandle* pHandle, const void* pBuf
setBufPageDirty(pPage, true);
releaseBufPage(pHandle->pBuf, pPage);
} else {
-
}
return TSDB_CODE_SUCCESS;
@@ -3636,7 +3646,7 @@ static int32_t updateTupleData(SqlFunctionCtx* pCtx, int32_t rowIndex, const SSD
static char* doLoadTupleData(SSerializeDataHandle* pHandle, const STuplePos* pPos) {
if (pHandle->pBuf != NULL) {
SFilePage* pPage = getBufPage(pHandle->pBuf, pPos->pageId);
- char* p = pPage->data + pPos->offset;
+ char* p = pPage->data + pPos->offset;
releaseBufPage(pHandle->pBuf, pPage);
return p;
} else {
@@ -3980,8 +3990,8 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
}
if (pCtx->end.key == INT64_MIN) {
- pInfo->min = (pInfo->min > ptsList[start + pInput->numOfRows - 1]) ?
- ptsList[start + pInput->numOfRows - 1] : pInfo->min;
+ pInfo->min =
+ (pInfo->min > ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->min;
} else {
pInfo->min = pCtx->end.key;
}
@@ -3993,8 +4003,8 @@ int32_t elapsedFunction(SqlFunctionCtx* pCtx) {
}
if (pCtx->end.key == INT64_MIN) {
- pInfo->max = (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ?
- ptsList[start + pInput->numOfRows - 1] : pInfo->max;
+ pInfo->max =
+ (pInfo->max < ptsList[start + pInput->numOfRows - 1]) ? ptsList[start + pInput->numOfRows - 1] : pInfo->max;
} else {
pInfo->max = pCtx->end.key + 1;
}
@@ -4701,7 +4711,7 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
colDataAppendNULL(pOutput, i);
// handle selectivity
if (pCtx->subsidiaries.num > 0) {
- appendSelectivityValue(pCtx, i, i);
+ appendSelectivityValue(pCtx, i, pCtx->offset + numOfElems - 1);
}
continue;
}
@@ -4714,11 +4724,11 @@ int32_t stateCountFunction(SqlFunctionCtx* pCtx) {
} else {
pInfo->count = 0;
}
- colDataAppend(pOutput, i, (char*)&output, false);
+ colDataAppend(pOutput, pCtx->offset + numOfElems - 1, (char*)&output, false);
// handle selectivity
if (pCtx->subsidiaries.num > 0) {
- appendSelectivityValue(pCtx, i, i);
+ appendSelectivityValue(pCtx, i, pCtx->offset + numOfElems - 1);
}
}
diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c
index 5de9c52cc1..3f472b53a0 100644
--- a/source/libs/function/src/tudf.c
+++ b/source/libs/function/src/tudf.c
@@ -1183,7 +1183,9 @@ void onUdfcPipeClose(uv_handle_t *handle) {
QUEUE_REMOVE(&task->procTaskQueue);
uv_sem_post(&task->taskSem);
}
- conn->session->udfUvPipe = NULL;
+ if (conn->session != NULL) {
+ conn->session->udfUvPipe = NULL;
+ }
taosMemoryFree(conn->readBuf.buf);
taosMemoryFree(conn);
taosMemoryFree((uv_pipe_t *) handle);
@@ -1803,6 +1805,7 @@ int32_t doTeardownUdf(UdfcFuncHandle handle) {
if (session->udfUvPipe == NULL) {
fnError("tear down udf. pipe to udfd does not exist. udf name: %s", session->udfName);
+ taosMemoryFree(session);
return TSDB_CODE_UDF_PIPE_NO_PIPE;
}
@@ -1821,7 +1824,11 @@ int32_t doTeardownUdf(UdfcFuncHandle handle) {
udfcRunUdfUvTask(task, UV_TASK_DISCONNECT);
fnInfo("tear down udf. udf name: %s, udf func handle: %p", session->udfName, handle);
-
+ //TODO: synchronization refactor between libuv event loop and request thread
+ if (session->udfUvPipe != NULL && session->udfUvPipe->data != NULL) {
+ SClientUvConn *conn = session->udfUvPipe->data;
+ conn->session = NULL;
+ }
taosMemoryFree(session);
taosMemoryFree(task);
diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c
index d9a6b80f3d..f507e1b3be 100644
--- a/source/libs/index/src/index.c
+++ b/source/libs/index/src/index.c
@@ -303,7 +303,7 @@ SIndexTerm* indexTermCreate(int64_t suid, SIndexOperOnColumn oper, uint8_t colTy
buf = strndup(INDEX_DATA_NULL_STR, (int32_t)strlen(INDEX_DATA_NULL_STR));
len = (int32_t)strlen(INDEX_DATA_NULL_STR);
} else {
- const char* emptyStr = " ";
+ static const char* emptyStr = " ";
buf = strndup(emptyStr, (int32_t)strlen(emptyStr));
len = (int32_t)strlen(emptyStr);
}
@@ -585,6 +585,12 @@ int idxFlushCacheToTFile(SIndex* sIdx, void* cache, bool quit) {
idxTRsltDestroy(tr);
int ret = idxGenTFile(sIdx, pCache, result);
+ if (ret != 0) {
+ indexError("failed to merge");
+ } else {
+ int64_t cost = taosGetTimestampUs() - st;
+ indexInfo("success to merge , time cost: %" PRId64 "ms", cost / 1000);
+ }
idxDestroyFinalRslt(result);
idxCacheDestroyImm(pCache);
@@ -595,12 +601,6 @@ int idxFlushCacheToTFile(SIndex* sIdx, void* cache, bool quit) {
tfileReaderUnRef(pReader);
idxCacheUnRef(pCache);
- int64_t cost = taosGetTimestampUs() - st;
- if (ret != 0) {
- indexError("failed to merge, time cost: %" PRId64 "ms", cost / 1000);
- } else {
- indexInfo("success to merge , time cost: %" PRId64 "ms", cost / 1000);
- }
atomic_store_32(&pCache->merging, 0);
if (quit) {
idxPost(sIdx);
diff --git a/source/libs/index/src/indexComm.c b/source/libs/index/src/indexComm.c
index 691eb6771c..ecf9136073 100644
--- a/source/libs/index/src/indexComm.c
+++ b/source/libs/index/src/indexComm.c
@@ -81,28 +81,28 @@ __compar_fn_t idxGetCompar(int8_t type) {
}
return getComparFunc(type, 0);
}
-static TExeCond tCompareLessThan(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareLessThan(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_LESS_THAN, a, b, type);
}
-static TExeCond tCompareLessEqual(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareLessEqual(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_LESS_EQUAL, a, b, type);
}
-static TExeCond tCompareGreaterThan(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareGreaterThan(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_GREATER_THAN, a, b, type);
}
-static TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareGreaterEqual(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_GREATER_EQUAL, a, b, type);
}
-static TExeCond tCompareContains(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareContains(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_TERM, a, b, type);
}
-static TExeCond tCompareEqual(void* a, void* b, int8_t type) {
+static FORCE_INLINE TExeCond tCompareEqual(void* a, void* b, int8_t type) {
__compar_fn_t func = idxGetCompar(type);
return tCompare(func, QUERY_TERM, a, b, type);
}
diff --git a/source/libs/index/src/indexFilter.c b/source/libs/index/src/indexFilter.c
index e7f221de3d..b65acc4672 100644
--- a/source/libs/index/src/indexFilter.c
+++ b/source/libs/index/src/indexFilter.c
@@ -88,7 +88,7 @@ typedef struct SIFCtx {
SIndexMetaArg arg;
} SIFCtx;
-static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
+static FORCE_INLINE int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
if (src == OP_TYPE_GREATER_THAN) {
*dst = QUERY_GREATER_THAN;
} else if (src == OP_TYPE_GREATER_EQUAL) {
@@ -110,10 +110,9 @@ static int32_t sifGetFuncFromSql(EOperatorType src, EIndexQueryType *dst) {
}
typedef int32_t (*sif_func_t)(SIFParam *left, SIFParam *rigth, SIFParam *output);
-
static sif_func_t sifNullFunc = NULL;
-static void sifFreeParam(SIFParam *param) {
+static FORCE_INLINE void sifFreeParam(SIFParam *param) {
if (param == NULL) return;
taosArrayDestroy(param->result);
@@ -123,7 +122,7 @@ static void sifFreeParam(SIFParam *param) {
param->pFilter = NULL;
}
-static int32_t sifGetOperParamNum(EOperatorType ty) {
+static FORCE_INLINE int32_t sifGetOperParamNum(EOperatorType ty) {
if (OP_TYPE_IS_NULL == ty || OP_TYPE_IS_NOT_NULL == ty || OP_TYPE_IS_TRUE == ty || OP_TYPE_IS_NOT_TRUE == ty ||
OP_TYPE_IS_FALSE == ty || OP_TYPE_IS_NOT_FALSE == ty || OP_TYPE_IS_UNKNOWN == ty ||
OP_TYPE_IS_NOT_UNKNOWN == ty || OP_TYPE_MINUS == ty) {
@@ -131,14 +130,14 @@ static int32_t sifGetOperParamNum(EOperatorType ty) {
}
return 2;
}
-static int32_t sifValidOp(EOperatorType ty) {
+static FORCE_INLINE int32_t sifValidOp(EOperatorType ty) {
if ((ty >= OP_TYPE_ADD && ty <= OP_TYPE_BIT_OR) || (ty == OP_TYPE_IN || ty == OP_TYPE_NOT_IN) ||
(ty == OP_TYPE_LIKE || ty == OP_TYPE_NOT_LIKE || ty == OP_TYPE_MATCH || ty == OP_TYPE_NMATCH)) {
return -1;
}
return 0;
}
-static int32_t sifValidColumn(SColumnNode *cn) {
+static FORCE_INLINE int32_t sifValidColumn(SColumnNode *cn) {
// add more check
if (cn == NULL) {
return TSDB_CODE_QRY_INVALID_INPUT;
@@ -149,7 +148,7 @@ static int32_t sifValidColumn(SColumnNode *cn) {
return TSDB_CODE_SUCCESS;
}
-static SIdxFltStatus sifMergeCond(ELogicConditionType type, SIdxFltStatus ls, SIdxFltStatus rs) {
+static FORCE_INLINE SIdxFltStatus sifMergeCond(ELogicConditionType type, SIdxFltStatus ls, SIdxFltStatus rs) {
// enh rule later
if (type == LOGIC_COND_TYPE_AND) {
if (ls == SFLT_NOT_INDEX || rs == SFLT_NOT_INDEX) {
@@ -167,7 +166,7 @@ static SIdxFltStatus sifMergeCond(ELogicConditionType type, SIdxFltStatus ls, SI
return SFLT_NOT_INDEX;
}
-static int32_t sifGetValueFromNode(SNode *node, char **value) {
+static FORCE_INLINE int32_t sifGetValueFromNode(SNode *node, char **value) {
// covert data From snode;
SValueNode *vn = (SValueNode *)node;
@@ -205,7 +204,7 @@ static int32_t sifGetValueFromNode(SNode *node, char **value) {
return TSDB_CODE_SUCCESS;
}
-static int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
+static FORCE_INLINE int32_t sifInitJsonParam(SNode *node, SIFParam *param, SIFCtx *ctx) {
SOperatorNode *nd = (SOperatorNode *)node;
assert(nodeType(node) == QUERY_NODE_OPERATOR);
SColumnNode *l = (SColumnNode *)nd->pLeft;
@@ -355,30 +354,30 @@ static int32_t sifExecFunction(SFunctionNode *node, SIFCtx *ctx, SIFParam *outpu
return TSDB_CODE_QRY_INVALID_INPUT;
}
-typedef int (*Filter)(void *a, void *b, int16_t dtype);
+typedef int (*FilterFunc)(void *a, void *b, int16_t dtype);
-int sifGreaterThan(void *a, void *b, int16_t dtype) {
+static FORCE_INLINE int sifGreaterThan(void *a, void *b, int16_t dtype) {
__compar_fn_t func = getComparFunc(dtype, 0);
return tDoCompare(func, QUERY_GREATER_THAN, a, b);
}
-int sifGreaterEqual(void *a, void *b, int16_t dtype) {
+static FORCE_INLINE int sifGreaterEqual(void *a, void *b, int16_t dtype) {
__compar_fn_t func = getComparFunc(dtype, 0);
return tDoCompare(func, QUERY_GREATER_EQUAL, a, b);
}
-int sifLessEqual(void *a, void *b, int16_t dtype) {
+static FORCE_INLINE int sifLessEqual(void *a, void *b, int16_t dtype) {
__compar_fn_t func = getComparFunc(dtype, 0);
return tDoCompare(func, QUERY_LESS_EQUAL, a, b);
}
-int sifLessThan(void *a, void *b, int16_t dtype) {
+static FORCE_INLINE int sifLessThan(void *a, void *b, int16_t dtype) {
__compar_fn_t func = getComparFunc(dtype, 0);
return (int)tDoCompare(func, QUERY_LESS_THAN, a, b);
}
-int sifEqual(void *a, void *b, int16_t dtype) {
+static FORCE_INLINE int sifEqual(void *a, void *b, int16_t dtype) {
__compar_fn_t func = getComparFunc(dtype, 0);
//__compar_fn_t func = idxGetCompar(dtype);
return (int)tDoCompare(func, QUERY_TERM, a, b);
}
-static Filter sifGetFilterFunc(EIndexQueryType type, bool *reverse) {
+static FORCE_INLINE FilterFunc sifGetFilterFunc(EIndexQueryType type, bool *reverse) {
if (type == QUERY_LESS_EQUAL || type == QUERY_LESS_THAN) {
*reverse = true;
} else {
@@ -470,8 +469,8 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
indexMultiTermQueryAdd(mtm, tm, qtype);
ret = indexJsonSearch(arg->ivtIdx, mtm, output->result);
} else {
- bool reverse;
- Filter filterFunc = sifGetFilterFunc(qtype, &reverse);
+ bool reverse;
+ FilterFunc filterFunc = sifGetFilterFunc(qtype, &reverse);
SMetaFltParam param = {.suid = arg->suid,
.cid = left->colId,
@@ -498,72 +497,72 @@ static int32_t sifDoIndex(SIFParam *left, SIFParam *right, int8_t operType, SIFP
return ret;
}
-static int32_t sifLessThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifLessThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_LOWER_THAN;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifLessEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifLessEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_LOWER_EQUAL;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifGreaterThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifGreaterThanFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_GREATER_THAN;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifGreaterEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifGreaterEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_GREATER_EQUAL;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_EQUAL;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifNotEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifNotEqualFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_NOT_EQUAL;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_IN;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifNotInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifNotInFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_NOT_IN;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_LIKE;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifNotLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifNotLikeFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_NOT_LIKE;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_MATCH;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifNotMatchFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_NMATCH;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifJsonContains(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifJsonContains(SIFParam *left, SIFParam *right, SIFParam *output) {
int id = OP_TYPE_JSON_CONTAINS;
return sifDoIndex(left, right, id, output);
}
-static int32_t sifJsonGetValue(SIFParam *left, SIFParam *rigth, SIFParam *output) {
+static FORCE_INLINE int32_t sifJsonGetValue(SIFParam *left, SIFParam *rigth, SIFParam *output) {
// return 0
return 0;
}
-static int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
+static FORCE_INLINE int32_t sifDefaultFunc(SIFParam *left, SIFParam *right, SIFParam *output) {
// add more except
return TSDB_CODE_QRY_INVALID_INPUT;
}
-static int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *status) {
+static FORCE_INLINE int32_t sifGetOperFn(int32_t funcId, sif_func_t *func, SIdxFltStatus *status) {
// impl later
*status = SFLT_ACCURATE_INDEX;
switch (funcId) {
diff --git a/source/libs/index/src/indexFst.c b/source/libs/index/src/indexFst.c
index 15152cef55..2aa8345e03 100644
--- a/source/libs/index/src/indexFst.c
+++ b/source/libs/index/src/indexFst.c
@@ -19,11 +19,12 @@
#include "tchecksum.h"
#include "tcoding.h"
-static void fstPackDeltaIn(IdxFstFile* wrt, CompiledAddr nodeAddr, CompiledAddr transAddr, uint8_t nBytes) {
+static FORCE_INLINE void fstPackDeltaIn(IdxFstFile* wrt, CompiledAddr nodeAddr, CompiledAddr transAddr,
+ uint8_t nBytes) {
CompiledAddr deltaAddr = (transAddr == EMPTY_ADDRESS) ? EMPTY_ADDRESS : nodeAddr - transAddr;
idxFilePackUintIn(wrt, deltaAddr, nBytes);
}
-static uint8_t fstPackDetla(IdxFstFile* wrt, CompiledAddr nodeAddr, CompiledAddr transAddr) {
+static FORCE_INLINE uint8_t fstPackDetla(IdxFstFile* wrt, CompiledAddr nodeAddr, CompiledAddr transAddr) {
uint8_t nBytes = packDeltaSize(nodeAddr, transAddr);
fstPackDeltaIn(wrt, nodeAddr, transAddr, nBytes);
return nBytes;
@@ -39,7 +40,7 @@ FstUnFinishedNodes* fstUnFinishedNodesCreate() {
fstUnFinishedNodesPushEmpty(nodes, false);
return nodes;
}
-static void unFinishedNodeDestroyElem(void* elem) {
+static void FORCE_INLINE unFinishedNodeDestroyElem(void* elem) {
FstBuilderNodeUnfinished* b = (FstBuilderNodeUnfinished*)elem;
fstBuilderNodeDestroy(b->node);
taosMemoryFree(b->last);
diff --git a/source/libs/index/src/indexFstFile.c b/source/libs/index/src/indexFstFile.c
index e6d1edfeda..2a33ddd477 100644
--- a/source/libs/index/src/indexFstFile.c
+++ b/source/libs/index/src/indexFstFile.c
@@ -30,14 +30,14 @@ typedef struct {
static void deleteDataBlockFromLRU(const void* key, size_t keyLen, void* value) { taosMemoryFree(value); }
-static void idxGenLRUKey(char* buf, const char* path, int32_t blockId) {
+static FORCE_INLINE void idxGenLRUKey(char* buf, const char* path, int32_t blockId) {
char* p = buf;
SERIALIZE_STR_VAR_TO_BUF(p, path, strlen(path));
SERIALIZE_VAR_TO_BUF(p, '_', char);
idxInt2str(blockId, p, 0);
return;
}
-static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
+static FORCE_INLINE int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
if (ctx->type == TFILE) {
int nwr = taosWriteFile(ctx->file.pFile, buf, len);
assert(nwr == len);
@@ -47,7 +47,7 @@ static int idxFileCtxDoWrite(IFileCtx* ctx, uint8_t* buf, int len) {
ctx->offset += len;
return len;
}
-static int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
+static FORCE_INLINE int idxFileCtxDoRead(IFileCtx* ctx, uint8_t* buf, int len) {
int nRead = 0;
if (ctx->type == TFILE) {
#ifdef USE_MMAP
@@ -111,7 +111,7 @@ static int idxFileCtxDoReadFrom(IFileCtx* ctx, uint8_t* buf, int len, int32_t of
} while (len > 0);
return total;
}
-static int idxFileCtxGetSize(IFileCtx* ctx) {
+static FORCE_INLINE int idxFileCtxGetSize(IFileCtx* ctx) {
if (ctx->type == TFILE) {
int64_t file_size = 0;
taosStatFile(ctx->file.buf, &file_size, NULL);
@@ -119,7 +119,7 @@ static int idxFileCtxGetSize(IFileCtx* ctx) {
}
return 0;
}
-static int idxFileCtxDoFlush(IFileCtx* ctx) {
+static FORCE_INLINE int idxFileCtxDoFlush(IFileCtx* ctx) {
if (ctx->type == TFILE) {
taosFsyncFile(ctx->file.pFile);
} else {
diff --git a/source/libs/index/src/indexFstRegister.c b/source/libs/index/src/indexFstRegister.c
index 34efee0d0d..e0abcadc78 100644
--- a/source/libs/index/src/indexFstRegister.c
+++ b/source/libs/index/src/indexFstRegister.c
@@ -16,7 +16,7 @@
#include "indexFstRegistry.h"
#include "os.h"
-uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) {
+static FORCE_INLINE uint64_t fstRegistryHash(FstRegistry* registry, FstBuilderNode* bNode) {
// TODO(yihaoDeng): refactor later
const uint64_t FNV_PRIME = 1099511628211;
uint64_t h = 14695981039346656037u;
diff --git a/source/libs/index/src/indexFstSparse.c b/source/libs/index/src/indexFstSparse.c
index ebc0cb3637..8746b04eab 100644
--- a/source/libs/index/src/indexFstSparse.c
+++ b/source/libs/index/src/indexFstSparse.c
@@ -15,7 +15,7 @@
#include "indexFstSparse.h"
-static void sparSetUtil(int32_t *buf, int32_t cap) {
+static FORCE_INLINE void sparSetInitBuf(int32_t *buf, int32_t cap) {
for (int32_t i = 0; i < cap; i++) {
buf[i] = -1;
}
@@ -28,8 +28,8 @@ FstSparseSet *sparSetCreate(int32_t sz) {
ss->dense = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
ss->sparse = (int32_t *)taosMemoryMalloc(sz * sizeof(int32_t));
- sparSetUtil(ss->dense, sz);
- sparSetUtil(ss->sparse, sz);
+ sparSetInitBuf(ss->dense, sz);
+ sparSetInitBuf(ss->sparse, sz);
ss->cap = sz;
@@ -90,7 +90,7 @@ void sparSetClear(FstSparseSet *ss) {
if (ss == NULL) {
return;
}
- sparSetUtil(ss->dense, ss->cap);
- sparSetUtil(ss->sparse, ss->cap);
+ sparSetInitBuf(ss->dense, ss->cap);
+ sparSetInitBuf(ss->sparse, ss->cap);
ss->size = 0;
}
diff --git a/source/libs/index/src/indexTfile.c b/source/libs/index/src/indexTfile.c
index 48a0c631cf..c3be0ea6f5 100644
--- a/source/libs/index/src/indexTfile.c
+++ b/source/libs/index/src/indexTfile.c
@@ -1034,7 +1034,8 @@ static void tfileGenFileName(char* filename, uint64_t suid, const char* col, int
sprintf(filename, "%" PRIu64 "-%s-%" PRId64 ".tindex", suid, col, version);
return;
}
-static void tfileGenFileFullName(char* fullname, const char* path, uint64_t suid, const char* col, int64_t version) {
+static void FORCE_INLINE tfileGenFileFullName(char* fullname, const char* path, uint64_t suid, const char* col,
+ int64_t version) {
char filename[128] = {0};
tfileGenFileName(filename, suid, col, version);
sprintf(fullname, "%s/%s", path, filename);
diff --git a/source/libs/index/src/indexUtil.c b/source/libs/index/src/indexUtil.c
index 3d083c1817..cdfb79016f 100644
--- a/source/libs/index/src/indexUtil.c
+++ b/source/libs/index/src/indexUtil.c
@@ -21,7 +21,7 @@ typedef struct MergeIndex {
int len;
} MergeIndex;
-static int iBinarySearch(SArray *arr, int s, int e, uint64_t k) {
+static FORCE_INLINE int iBinarySearch(SArray *arr, int s, int e, uint64_t k) {
uint64_t v;
int32_t m;
while (s <= e) {
diff --git a/source/libs/index/test/CMakeLists.txt b/source/libs/index/test/CMakeLists.txt
index b3eca28003..2bc7353aa5 100644
--- a/source/libs/index/test/CMakeLists.txt
+++ b/source/libs/index/test/CMakeLists.txt
@@ -80,6 +80,11 @@ IF(NOT TD_DARWIN)
"${TD_SOURCE_DIR}/include/libs/index"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
+ target_include_directories (idxJsonUT
+ PUBLIC
+ "${TD_SOURCE_DIR}/include/libs/index"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
+ )
target_link_libraries (idxTest
os
@@ -102,11 +107,7 @@ IF(NOT TD_DARWIN)
gtest_main
index
)
- target_include_directories (idxJsonUT
- PUBLIC
- "${TD_SOURCE_DIR}/include/libs/index"
- "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
- )
+
target_link_libraries (idxTest
os
util
diff --git a/source/libs/index/test/indexBench.cc b/source/libs/index/test/indexBench.cc
new file mode 100644
index 0000000000..b828be0ffe
--- /dev/null
+++ b/source/libs/index/test/indexBench.cc
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3 * or later ("AGPL"), as published by the Free
+ * Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#include
+#include
+#include
+#include
+#include
+#include "index.h"
+#include "indexCache.h"
+#include "indexFst.h"
+#include "indexFstUtil.h"
+#include "indexInt.h"
+#include "indexTfile.h"
+#include "indexUtil.h"
+#include "tskiplist.h"
+#include "tutil.h"
+using namespace std;
+
+static std::string logDir = TD_TMP_DIR_PATH "log";
+
+static void initLog() {
+ const char *defaultLogFileNamePrefix = "taoslog";
+ const int32_t maxLogFileNum = 10;
+
+ tsAsyncLog = 0;
+ idxDebugFlag = 143;
+ strcpy(tsLogDir, logDir.c_str());
+ taosRemoveDir(tsLogDir);
+ taosMkDir(tsLogDir);
+
+ if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
+ printf("failed to open log file in directory:%s\n", tsLogDir);
+ }
+}
+
+struct WriteBatch {
+ SIndexMultiTerm *terms;
+};
+class Idx {
+ public:
+ Idx(int _cacheSize = 1024 * 1024 * 4, const char *_path = "tindex") {
+ opts.cacheSize = _cacheSize;
+ path += TD_TMP_DIR_PATH;
+ path += _path;
+ }
+ int SetUp(bool remove) {
+ initLog();
+
+ if (remove) taosRemoveDir(path.c_str());
+
+ int ret = indexJsonOpen(&opts, path.c_str(), &index);
+ return ret;
+ }
+ int Write(WriteBatch *batch, uint64_t uid) {
+ // write batch
+ indexJsonPut(index, batch->terms, uid);
+ return 0;
+ }
+ int Read(const char *json, void *key, int64_t *id) {
+ // read batch
+ return 0;
+ }
+
+ void TearDown() { indexJsonClose(index); }
+
+ std::string path;
+
+ SIndexOpts opts;
+ SIndex *index;
+};
+
+SIndexTerm *indexTermCreateT(int64_t suid, SIndexOperOnColumn oper, uint8_t colType, const char *colName,
+ int32_t nColName, const char *colVal, int32_t nColVal) {
+ char buf[256] = {0};
+ int16_t sz = nColVal;
+ memcpy(buf, (uint16_t *)&sz, 2);
+ memcpy(buf + 2, colVal, nColVal);
+ if (colType == TSDB_DATA_TYPE_BINARY) {
+ return indexTermCreate(suid, oper, colType, colName, nColName, buf, sizeof(buf));
+ } else {
+ return indexTermCreate(suid, oper, colType, colName, nColName, colVal, nColVal);
+ }
+ return NULL;
+}
+int initWriteBatch(WriteBatch *wb, int batchSize) {
+ SIndexMultiTerm *terms = indexMultiTermCreate();
+
+ std::string colName;
+ std::string colVal;
+
+ for (int i = 0; i < 64; i++) {
+ colName += '0' + i;
+ colVal += '0' + i;
+ }
+
+ for (int i = 0; i < batchSize; i++) {
+ colVal[i % colVal.size()] = '0' + i % 128;
+ colName[i % colName.size()] = '0' + i % 128;
+ SIndexTerm *term = indexTermCreateT(0, ADD_VALUE, TSDB_DATA_TYPE_BINARY, colName.c_str(), colName.size(),
+ colVal.c_str(), colVal.size());
+ indexMultiTermAdd(terms, term);
+ }
+
+ wb->terms = terms;
+ return 0;
+}
+
+int BenchWrite(Idx *idx, int batchSize, int limit) {
+ for (int i = 0; i < limit; i += batchSize) {
+ WriteBatch wb;
+ idx->Write(&wb, i);
+ }
+ return 0;
+}
+
+int BenchRead(Idx *idx) { return 0; }
+
+int main() {
+ // Idx *idx = new Idx;
+ // if (idx->SetUp(true) != 0) {
+ // std::cout << "failed to setup index" << std::endl;
+ // return 0;
+ // } else {
+ // std::cout << "succ to setup index" << std::endl;
+ // }
+ // BenchWrite(idx, 100, 10000);
+ return 1;
+}
diff --git a/source/libs/index/test/indexTests.cc b/source/libs/index/test/indexTests.cc
index 5b76de2ef8..08bf84ff60 100644
--- a/source/libs/index/test/indexTests.cc
+++ b/source/libs/index/test/indexTests.cc
@@ -271,20 +271,20 @@ void validateFst() {
}
delete m;
}
+
static std::string logDir = TD_TMP_DIR_PATH "log";
+static void initLog() {
+ const char* defaultLogFileNamePrefix = "taoslog";
+ const int32_t maxLogFileNum = 10;
-static void initLog() {
- const char* defaultLogFileNamePrefix = "taoslog";
- const int32_t maxLogFileNum = 10;
+ tsAsyncLog = 0;
+ idxDebugFlag = 143;
+ strcpy(tsLogDir, logDir.c_str());
+ taosRemoveDir(tsLogDir);
+ taosMkDir(tsLogDir);
- tsAsyncLog = 0;
- idxDebugFlag = 143;
- strcpy(tsLogDir, logDir.c_str());
- taosRemoveDir(tsLogDir);
- taosMkDir(tsLogDir);
-
- if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
- printf("failed to open log file in directory:%s\n", tsLogDir);
+ if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) {
+ printf("failed to open log file in directory:%s\n", tsLogDir);
}
}
class IndexEnv : public ::testing::Test {
diff --git a/source/libs/monitor/src/monMsg.c b/source/libs/monitor/src/monMsg.c
index 8fa7e88605..bbee8b1166 100644
--- a/source/libs/monitor/src/monMsg.c
+++ b/source/libs/monitor/src/monMsg.c
@@ -510,6 +510,7 @@ int32_t tSerializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInfo)
SVnodeLoad *pLoad = taosArrayGet(pInfo->pVloads, i);
if (tEncodeI32(&encoder, pLoad->vgId) < 0) return -1;
if (tEncodeI32(&encoder, pLoad->syncState) < 0) return -1;
+ if (tEncodeI64(&encoder, pLoad->cacheUsage) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->numOfTables) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->numOfTimeSeries) < 0) return -1;
if (tEncodeI64(&encoder, pLoad->totalStorage) < 0) return -1;
@@ -544,6 +545,7 @@ int32_t tDeserializeSMonVloadInfo(void *buf, int32_t bufLen, SMonVloadInfo *pInf
SVnodeLoad load = {0};
if (tDecodeI32(&decoder, &load.vgId) < 0) return -1;
if (tDecodeI32(&decoder, &load.syncState) < 0) return -1;
+ if (tDecodeI64(&decoder, &load.cacheUsage) < 0) return -1;
if (tDecodeI64(&decoder, &load.numOfTables) < 0) return -1;
if (tDecodeI64(&decoder, &load.numOfTimeSeries) < 0) return -1;
if (tDecodeI64(&decoder, &load.totalStorage) < 0) return -1;
@@ -594,7 +596,6 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf
return 0;
}
-
int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) {
SEncoder encoder = {0};
tEncoderInit(&encoder, buf, bufLen);
@@ -639,5 +640,3 @@ int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo) {
tDecoderClear(&decoder);
return 0;
}
-
-
diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c
index 8976daadbd..a41462e3fd 100644
--- a/source/libs/nodes/src/nodesCodeFuncs.c
+++ b/source/libs/nodes/src/nodesCodeFuncs.c
@@ -362,18 +362,14 @@ static int32_t jsonToTableComInfo(const SJson* pJson, void* pObj) {
int32_t code;
tjsonGetNumberValue(pJson, jkTableComInfoNumOfTags, pNode->numOfTags, code);
- ;
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableComInfoPrecision, pNode->precision, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableComInfoNumOfColumns, pNode->numOfColumns, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableComInfoRowSize, pNode->rowSize, code);
- ;
}
return code;
@@ -406,14 +402,11 @@ static int32_t jsonToSchema(const SJson* pJson, void* pObj) {
int32_t code;
tjsonGetNumberValue(pJson, jkSchemaType, pNode->type, code);
- ;
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkSchemaColId, pNode->colId, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkSchemaBytes, pNode->bytes, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetStringValue(pJson, jkSchemaName, pNode->name);
@@ -466,26 +459,20 @@ static int32_t jsonToTableMeta(const SJson* pJson, void* pObj) {
int32_t code;
tjsonGetNumberValue(pJson, jkTableMetaVgId, pNode->vgId, code);
- ;
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableMetaTableType, pNode->tableType, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableMetaUid, pNode->uid, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableMetaSuid, pNode->suid, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableMetaSversion, pNode->sversion, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkTableMetaTversion, pNode->tversion, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonToObject(pJson, jkTableMetaComInfo, jsonToTableComInfo, &pNode->tableInfo);
@@ -926,7 +913,6 @@ static int32_t jsonToLogicFillNode(const SJson* pJson, void* pObj) {
int32_t code = jsonToLogicPlanNode(pJson, pObj);
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkFillLogicPlanMode, pNode->mode, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkFillLogicPlanWStartTs, &pNode->pWStartTs);
@@ -2815,7 +2801,6 @@ static int32_t jsonToColumnNode(const SJson* pJson, void* pObj) {
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkColumnColType, pNode->colType, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = tjsonGetStringValue(pJson, jkColumnDbName, pNode->dbName);
@@ -3118,7 +3103,6 @@ static int32_t jsonToOperatorNode(const SJson* pJson, void* pObj) {
int32_t code = jsonToExprNode(pJson, pObj);
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkOperatorType, pNode->opType, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkOperatorLeft, &pNode->pLeft);
@@ -3153,7 +3137,6 @@ static int32_t jsonToLogicConditionNode(const SJson* pJson, void* pObj) {
int32_t code = jsonToExprNode(pJson, pObj);
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkLogicCondType, pNode->condType, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeList(pJson, jkLogicCondParameters, &pNode->pParameterList);
@@ -3442,11 +3425,9 @@ static int32_t jsonToOrderByExprNode(const SJson* pJson, void* pObj) {
int32_t code = jsonToNodeObject(pJson, jkOrderByExprExpr, &pNode->pExpr);
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkOrderByExprOrder, pNode->order, code);
- ;
}
if (TSDB_CODE_SUCCESS == code) {
tjsonGetNumberValue(pJson, jkOrderByExprNullOrder, pNode->nullOrder, code);
- ;
}
return code;
@@ -3624,7 +3605,6 @@ static int32_t jsonToFillNode(const SJson* pJson, void* pObj) {
int32_t code;
tjsonGetNumberValue(pJson, jkFillMode, pNode->mode, code);
- ;
if (TSDB_CODE_SUCCESS == code) {
code = jsonToNodeObject(pJson, jkFillValues, &pNode->pValues);
}
diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c
new file mode 100644
index 0000000000..5fe31ed78e
--- /dev/null
+++ b/source/libs/nodes/src/nodesMsgFuncs.c
@@ -0,0 +1,3108 @@
+/*
+ * Copyright (c) 2019 TAOS Data, Inc.
+ *
+ * This program is free software: you can use, redistribute, and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3
+ * or later ("AGPL"), as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+#include "nodesUtil.h"
+#include "plannodes.h"
+#include "tdatablock.h"
+
+#define NODES_MSG_DEFAULT_LEN 1024
+
+#define tlvForEach(pDecoder, pTlv, code) \
+ while (TSDB_CODE_SUCCESS == code && TSDB_CODE_SUCCESS == (code = tlvGetNextTlv(pDecoder, &pTlv)) && NULL != pTlv)
+
+typedef struct STlv {
+ int16_t type;
+ int16_t len;
+ char value[0];
+} STlv;
+
+typedef struct STlvEncoder {
+ int32_t allocSize;
+ int32_t offset;
+ char* pBuf;
+ int32_t tlvCount;
+} STlvEncoder;
+
+typedef struct STlvDecoder {
+ int32_t bufSize;
+ int32_t offset;
+ const char* pBuf;
+} STlvDecoder;
+
+typedef int32_t (*FToMsg)(const void* pObj, STlvEncoder* pEncoder);
+typedef int32_t (*FToObject)(STlvDecoder* pDecoder, void* pObj);
+typedef void* (*FMakeObject)(int16_t type);
+typedef int32_t (*FSetObject)(STlv* pTlv, void* pObj);
+
+static int32_t nodeToMsg(const void* pObj, STlvEncoder* pEncoder);
+static int32_t nodeListToMsg(const void* pObj, STlvEncoder* pEncoder);
+static int32_t msgToNode(STlvDecoder* pDecoder, void** pObj);
+static int32_t msgToNodeFromTlv(STlv* pTlv, void** pObj);
+static int32_t msgToNodeList(STlvDecoder* pDecoder, void** pObj);
+static int32_t msgToNodeListFromTlv(STlv* pTlv, void** pObj);
+
+static int32_t initTlvEncoder(STlvEncoder* pEncoder) {
+ pEncoder->allocSize = NODES_MSG_DEFAULT_LEN;
+ pEncoder->offset = 0;
+ pEncoder->tlvCount = 0;
+ pEncoder->pBuf = taosMemoryMalloc(pEncoder->allocSize);
+ return NULL == pEncoder->pBuf ? TSDB_CODE_OUT_OF_MEMORY : TSDB_CODE_SUCCESS;
+}
+
+static void clearTlvEncoder(STlvEncoder* pEncoder) { taosMemoryFree(pEncoder->pBuf); }
+
+static void endTlvEncode(STlvEncoder* pEncoder, char** pMsg, int32_t* pLen) {
+ *pMsg = pEncoder->pBuf;
+ pEncoder->pBuf = NULL;
+ *pLen = pEncoder->offset;
+ // nodesWarn("encode tlv count = %d, tl size = %d", pEncoder->tlvCount, sizeof(STlv) * pEncoder->tlvCount);
+}
+
+static int32_t tlvEncodeImpl(STlvEncoder* pEncoder, int16_t type, const void* pValue, int16_t len) {
+ int32_t tlvLen = sizeof(STlv) + len;
+ if (pEncoder->offset + tlvLen > pEncoder->allocSize) {
+ void* pNewBuf = taosMemoryRealloc(pEncoder->pBuf, pEncoder->allocSize * 2);
+ if (NULL == pNewBuf) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ pEncoder->pBuf = pNewBuf;
+ pEncoder->allocSize = pEncoder->allocSize * 2;
+ }
+ STlv* pTlv = (STlv*)(pEncoder->pBuf + pEncoder->offset);
+ pTlv->type = type;
+ pTlv->len = len;
+ memcpy(pTlv->value, pValue, len);
+ pEncoder->offset += tlvLen;
+ ++(pEncoder->tlvCount);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t tlvEncodeI8(STlvEncoder* pEncoder, int16_t type, int8_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeI16(STlvEncoder* pEncoder, int16_t type, int16_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeI32(STlvEncoder* pEncoder, int16_t type, int32_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeI64(STlvEncoder* pEncoder, int16_t type, int64_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeU8(STlvEncoder* pEncoder, int16_t type, uint8_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeU16(STlvEncoder* pEncoder, int16_t type, uint16_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeU64(STlvEncoder* pEncoder, int16_t type, uint64_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeDouble(STlvEncoder* pEncoder, int16_t type, double value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeEnum(STlvEncoder* pEncoder, int16_t type, int32_t value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeBool(STlvEncoder* pEncoder, int16_t type, bool value) {
+ return tlvEncodeImpl(pEncoder, type, &value, sizeof(value));
+}
+
+static int32_t tlvEncodeCStr(STlvEncoder* pEncoder, int16_t type, const char* pValue) {
+ return tlvEncodeImpl(pEncoder, type, pValue, strlen(pValue));
+}
+
+static int32_t tlvEncodeBinary(STlvEncoder* pEncoder, int16_t type, const void* pValue, int32_t len) {
+ return tlvEncodeImpl(pEncoder, type, pValue, len);
+}
+
+static int32_t tlvEncodeObj(STlvEncoder* pEncoder, int16_t type, FToMsg func, const void* pObj) {
+ if (NULL == pObj) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ int32_t start = pEncoder->offset;
+ pEncoder->offset += sizeof(STlv);
+ int32_t code = func(pObj, pEncoder);
+ if (TSDB_CODE_SUCCESS == code) {
+ STlv* pTlv = (STlv*)(pEncoder->pBuf + start);
+ pTlv->type = type;
+ pTlv->len = pEncoder->offset - start - sizeof(STlv);
+ }
+ return code;
+}
+
+static int32_t tlvEncodeObjArray(STlvEncoder* pEncoder, int16_t type, FToMsg func, const void* pArray, int32_t itemSize,
+ int32_t num) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ if (num > 0) {
+ int32_t start = pEncoder->offset;
+ pEncoder->offset += sizeof(STlv);
+ for (size_t i = 0; TSDB_CODE_SUCCESS == code && i < num; ++i) {
+ code = tlvEncodeObj(pEncoder, 0, func, (const char*)pArray + i * itemSize);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ STlv* pTlv = (STlv*)(pEncoder->pBuf + start);
+ pTlv->type = type;
+ pTlv->len = pEncoder->offset - start - sizeof(STlv);
+ }
+ }
+ return code;
+}
+
+static int32_t tlvGetNextTlv(STlvDecoder* pDecoder, STlv** pTlv) {
+ if (pDecoder->offset == pDecoder->bufSize) {
+ *pTlv = NULL;
+ return TSDB_CODE_SUCCESS;
+ }
+
+ *pTlv = (STlv*)(pDecoder->pBuf + pDecoder->offset);
+ if ((*pTlv)->len + pDecoder->offset > pDecoder->bufSize) {
+ return TSDB_CODE_FAILED;
+ }
+ pDecoder->offset += sizeof(STlv) + (*pTlv)->len;
+ return TSDB_CODE_SUCCESS;
+}
+
+static bool tlvDecodeEnd(STlvDecoder* pDecoder) { return pDecoder->offset == pDecoder->bufSize; }
+
+static int32_t tlvDecodeImpl(STlv* pTlv, void* pValue, int16_t len) {
+ if (pTlv->len != len) {
+ return TSDB_CODE_FAILED;
+ }
+ memcpy(pValue, pTlv->value, len);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t tlvDecodeI8(STlv* pTlv, int8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeI16(STlv* pTlv, int16_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeI32(STlv* pTlv, int32_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeI64(STlv* pTlv, int64_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeU8(STlv* pTlv, uint8_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeU16(STlv* pTlv, uint16_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeU64(STlv* pTlv, uint64_t* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeDouble(STlv* pTlv, double* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeBool(STlv* pTlv, bool* pValue) { return tlvDecodeImpl(pTlv, pValue, sizeof(*pValue)); }
+
+static int32_t tlvDecodeEnum(STlv* pTlv, void* pValue, int16_t len) {
+ int32_t value = 0;
+ memcpy(&value, pTlv->value, pTlv->len);
+ switch (len) {
+ case 1:
+ *(int8_t*)pValue = value;
+ break;
+ case 2:
+ *(int16_t*)pValue = value;
+ break;
+ case 4:
+ *(int32_t*)pValue = value;
+ break;
+ default:
+ return TSDB_CODE_FAILED;
+ }
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t tlvDecodeCStr(STlv* pTlv, char* pValue) {
+ memcpy(pValue, pTlv->value, pTlv->len);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t tlvDecodeDynBinary(STlv* pTlv, void** pValue) {
+ *pValue = taosMemoryMalloc(pTlv->len);
+ if (NULL == *pValue) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ memcpy(*pValue, pTlv->value, pTlv->len);
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t tlvDecodeObjFromTlv(STlv* pTlv, FToObject func, void* pObj) {
+ STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
+ return func(&decoder, pObj);
+}
+
+static int32_t tlvDecodeObj(STlvDecoder* pDecoder, FToObject func, void* pObj) {
+ STlv* pTlv = NULL;
+ int32_t code = tlvGetNextTlv(pDecoder, &pTlv);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvDecodeObjFromTlv(pTlv, func, pObj);
+ }
+ return code;
+}
+
+static int32_t tlvDecodeObjArray(STlvDecoder* pDecoder, FToObject func, void* pArray, int32_t itemSize) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ int32_t i = 0;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) { code = tlvDecodeObjFromTlv(pTlv, func, (char*)pArray + itemSize * i++); }
+ return code;
+}
+
+static int32_t tlvDecodeObjArrayFromTlv(STlv* pTlv, FToObject func, void* pArray, int32_t itemSize) {
+ STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
+ return tlvDecodeObjArray(&decoder, func, pArray, itemSize);
+}
+
+static int32_t tlvDecodeDynObjFromTlv(STlv* pTlv, FMakeObject makeFunc, FToObject toFunc, void** pObj) {
+ *pObj = makeFunc(pTlv->type);
+ if (NULL == *pObj) {
+ return TSDB_CODE_OUT_OF_MEMORY;
+ }
+ return tlvDecodeObjFromTlv(pTlv, toFunc, *pObj);
+}
+
+static int32_t tlvDecodeDynObj(STlvDecoder* pDecoder, FMakeObject makeFunc, FToObject toFunc, void** pObj) {
+ STlv* pTlv = NULL;
+ int32_t code = tlvGetNextTlv(pDecoder, &pTlv);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvDecodeDynObjFromTlv(pTlv, makeFunc, toFunc, pObj);
+ }
+ return code;
+}
+
+enum { DATA_TYPE_CODE_TYPE = 1, DATA_TYPE_CODE_PRECISION, DATA_TYPE_CODE_SCALE, DATA_TYPE_CODE_BYTES };
+
+static int32_t dataTypeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SDataType* pNode = (const SDataType*)pObj;
+
+ int32_t code = tlvEncodeI8(pEncoder, DATA_TYPE_CODE_TYPE, pNode->type);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU8(pEncoder, DATA_TYPE_CODE_PRECISION, pNode->precision);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU8(pEncoder, DATA_TYPE_CODE_SCALE, pNode->scale);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, DATA_TYPE_CODE_BYTES, pNode->bytes);
+ }
+
+ return code;
+}
+
+static int32_t msgToDataType(STlvDecoder* pDecoder, void* pObj) {
+ SDataType* pNode = (SDataType*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case DATA_TYPE_CODE_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->type);
+ break;
+ case DATA_TYPE_CODE_PRECISION:
+ code = tlvDecodeU8(pTlv, &pNode->precision);
+ break;
+ case DATA_TYPE_CODE_SCALE:
+ code = tlvDecodeU8(pTlv, &pNode->scale);
+ break;
+ case DATA_TYPE_CODE_BYTES:
+ code = tlvDecodeI32(pTlv, &pNode->bytes);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { EXPR_CODE_RES_TYPE = 1 };
+
+static int32_t exprNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SExprNode* pNode = (const SExprNode*)pObj;
+ return tlvEncodeObj(pEncoder, EXPR_CODE_RES_TYPE, dataTypeToMsg, &pNode->resType);
+}
+
+static int32_t msgToExprNode(STlvDecoder* pDecoder, void* pObj) {
+ SExprNode* pNode = (SExprNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case EXPR_CODE_RES_TYPE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->resType);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ COLUMN_CODE_EXPR_BASE = 1,
+ COLUMN_CODE_TABLE_ID,
+ COLUMN_CODE_TABLE_TYPE,
+ COLUMN_CODE_COLUMN_ID,
+ COLUMN_CODE_COLUMN_TYPE,
+ COLUMN_CODE_DATABLOCK_ID,
+ COLUMN_CODE_SLOT_ID
+};
+
+static int32_t columnNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SColumnNode* pNode = (const SColumnNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, COLUMN_CODE_EXPR_BASE, exprNodeToMsg, pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, COLUMN_CODE_TABLE_ID, pNode->tableId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, COLUMN_CODE_TABLE_TYPE, pNode->tableType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI16(pEncoder, COLUMN_CODE_COLUMN_ID, pNode->colId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, COLUMN_CODE_COLUMN_TYPE, pNode->colType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI16(pEncoder, COLUMN_CODE_DATABLOCK_ID, pNode->dataBlockId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI16(pEncoder, COLUMN_CODE_SLOT_ID, pNode->slotId);
+ }
+
+ return code;
+}
+
+static int32_t msgToColumnNode(STlvDecoder* pDecoder, void* pObj) {
+ SColumnNode* pNode = (SColumnNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case COLUMN_CODE_EXPR_BASE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
+ break;
+ case COLUMN_CODE_TABLE_ID:
+ code = tlvDecodeU64(pTlv, &pNode->tableId);
+ break;
+ case COLUMN_CODE_TABLE_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->tableType);
+ break;
+ case COLUMN_CODE_COLUMN_ID:
+ code = tlvDecodeI16(pTlv, &pNode->colId);
+ break;
+ case COLUMN_CODE_COLUMN_TYPE:
+ code = tlvDecodeEnum(pTlv, &pNode->colType, sizeof(pNode->colType));
+ break;
+ case COLUMN_CODE_DATABLOCK_ID:
+ code = tlvDecodeI16(pTlv, &pNode->dataBlockId);
+ break;
+ case COLUMN_CODE_SLOT_ID:
+ code = tlvDecodeI16(pTlv, &pNode->slotId);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { VALUE_CODE_EXPR_BASE = 1, VALUE_CODE_IS_NULL, VALUE_CODE_DATUM };
+
+static int32_t datumToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SValueNode* pNode = (const SValueNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ switch (pNode->node.resType.type) {
+ case TSDB_DATA_TYPE_NULL:
+ break;
+ case TSDB_DATA_TYPE_BOOL:
+ code = tlvEncodeBool(pEncoder, VALUE_CODE_DATUM, pNode->datum.b);
+ break;
+ case TSDB_DATA_TYPE_TINYINT:
+ case TSDB_DATA_TYPE_SMALLINT:
+ case TSDB_DATA_TYPE_INT:
+ case TSDB_DATA_TYPE_BIGINT:
+ case TSDB_DATA_TYPE_TIMESTAMP:
+ code = tlvEncodeI64(pEncoder, VALUE_CODE_DATUM, pNode->datum.i);
+ break;
+ case TSDB_DATA_TYPE_UTINYINT:
+ case TSDB_DATA_TYPE_USMALLINT:
+ case TSDB_DATA_TYPE_UINT:
+ case TSDB_DATA_TYPE_UBIGINT:
+ code = tlvEncodeU64(pEncoder, VALUE_CODE_DATUM, pNode->datum.u);
+ break;
+ case TSDB_DATA_TYPE_FLOAT:
+ case TSDB_DATA_TYPE_DOUBLE:
+ code = tlvEncodeDouble(pEncoder, VALUE_CODE_DATUM, pNode->datum.d);
+ break;
+ case TSDB_DATA_TYPE_VARCHAR:
+ case TSDB_DATA_TYPE_VARBINARY:
+ case TSDB_DATA_TYPE_NCHAR:
+ code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, varDataTLen(pNode->datum.p));
+ break;
+ case TSDB_DATA_TYPE_JSON:
+ code = tlvEncodeBinary(pEncoder, VALUE_CODE_DATUM, pNode->datum.p, getJsonValueLen(pNode->datum.p));
+ break;
+ case TSDB_DATA_TYPE_DECIMAL:
+ case TSDB_DATA_TYPE_BLOB:
+ // todo
+ default:
+ break;
+ }
+
+ return code;
+}
+
+static int32_t valueNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SValueNode* pNode = (const SValueNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, VALUE_CODE_EXPR_BASE, exprNodeToMsg, pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, VALUE_CODE_IS_NULL, pNode->isNull);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = datumToMsg(pNode, pEncoder);
+ }
+
+ return code;
+}
+
+static int32_t msgToDatum(STlv* pTlv, void* pObj) {
+ SValueNode* pNode = (SValueNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ switch (pNode->node.resType.type) {
+ case TSDB_DATA_TYPE_NULL:
+ break;
+ case TSDB_DATA_TYPE_BOOL:
+ code = tlvDecodeBool(pTlv, &pNode->datum.b);
+ *(bool*)&pNode->typeData = pNode->datum.b;
+ break;
+ case TSDB_DATA_TYPE_TINYINT:
+ code = tlvDecodeI64(pTlv, &pNode->datum.i);
+ *(int8_t*)&pNode->typeData = pNode->datum.i;
+ break;
+ case TSDB_DATA_TYPE_SMALLINT:
+ code = tlvDecodeI64(pTlv, &pNode->datum.i);
+ *(int16_t*)&pNode->typeData = pNode->datum.i;
+ break;
+ case TSDB_DATA_TYPE_INT:
+ code = tlvDecodeI64(pTlv, &pNode->datum.i);
+ *(int32_t*)&pNode->typeData = pNode->datum.i;
+ break;
+ case TSDB_DATA_TYPE_BIGINT:
+ code = tlvDecodeI64(pTlv, &pNode->datum.i);
+ *(int64_t*)&pNode->typeData = pNode->datum.i;
+ break;
+ case TSDB_DATA_TYPE_TIMESTAMP:
+ code = tlvDecodeI64(pTlv, &pNode->datum.i);
+ *(int64_t*)&pNode->typeData = pNode->datum.i;
+ break;
+ case TSDB_DATA_TYPE_UTINYINT:
+ code = tlvDecodeU64(pTlv, &pNode->datum.u);
+ *(uint8_t*)&pNode->typeData = pNode->datum.u;
+ break;
+ case TSDB_DATA_TYPE_USMALLINT:
+ code = tlvDecodeU64(pTlv, &pNode->datum.u);
+ *(uint16_t*)&pNode->typeData = pNode->datum.u;
+ break;
+ case TSDB_DATA_TYPE_UINT:
+ code = tlvDecodeU64(pTlv, &pNode->datum.u);
+ *(uint32_t*)&pNode->typeData = pNode->datum.u;
+ break;
+ case TSDB_DATA_TYPE_UBIGINT:
+ code = tlvDecodeU64(pTlv, &pNode->datum.u);
+ *(uint64_t*)&pNode->typeData = pNode->datum.u;
+ break;
+ case TSDB_DATA_TYPE_FLOAT:
+ code = tlvDecodeDouble(pTlv, &pNode->datum.d);
+ *(float*)&pNode->typeData = pNode->datum.d;
+ break;
+ case TSDB_DATA_TYPE_DOUBLE:
+ code = tlvDecodeDouble(pTlv, &pNode->datum.d);
+ *(double*)&pNode->typeData = pNode->datum.d;
+ break;
+ case TSDB_DATA_TYPE_NCHAR:
+ case TSDB_DATA_TYPE_VARCHAR:
+ case TSDB_DATA_TYPE_VARBINARY:
+ code = tlvDecodeDynBinary(pTlv, (void**)&pNode->datum.p);
+ if (TSDB_CODE_SUCCESS == code) {
+ varDataSetLen(pNode->datum.p, pNode->node.resType.bytes - VARSTR_HEADER_SIZE);
+ }
+ break;
+ case TSDB_DATA_TYPE_JSON:
+ code = tlvDecodeDynBinary(pTlv, (void**)&pNode->datum.p);
+ break;
+ case TSDB_DATA_TYPE_DECIMAL:
+ case TSDB_DATA_TYPE_BLOB:
+ // todo
+ default:
+ break;
+ }
+
+ return code;
+}
+
+static int32_t msgToValueNode(STlvDecoder* pDecoder, void* pObj) {
+ SValueNode* pNode = (SValueNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case VALUE_CODE_EXPR_BASE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
+ break;
+ case VALUE_CODE_IS_NULL:
+ code = tlvDecodeBool(pTlv, &pNode->isNull);
+ break;
+ case VALUE_CODE_DATUM:
+ code = msgToDatum(pTlv, pNode);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { OPERATOR_CODE_EXPR_BASE = 1, OPERATOR_CODE_OP_TYPE, OPERATOR_CODE_LEFT, OPERATOR_CODE_RIGHT };
+
+static int32_t operatorNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SOperatorNode* pNode = (const SOperatorNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, OPERATOR_CODE_EXPR_BASE, exprNodeToMsg, pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, OPERATOR_CODE_OP_TYPE, pNode->opType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, OPERATOR_CODE_LEFT, nodeToMsg, pNode->pLeft);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, OPERATOR_CODE_RIGHT, nodeToMsg, pNode->pRight);
+ }
+
+ return code;
+}
+
+static int32_t msgToOperatorNode(STlvDecoder* pDecoder, void* pObj) {
+ SOperatorNode* pNode = (SOperatorNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case OPERATOR_CODE_EXPR_BASE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
+ break;
+ case OPERATOR_CODE_OP_TYPE:
+ code = tlvDecodeEnum(pTlv, &pNode->opType, sizeof(pNode->opType));
+ break;
+ case OPERATOR_CODE_LEFT:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pLeft);
+ break;
+ case OPERATOR_CODE_RIGHT:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pRight);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { LOGIC_COND_CODE_EXPR_BASE = 1, LOGIC_COND_CODE_COND_TYPE, LOGIC_COND_CODE_PARAMETERS };
+
+static int32_t logicConditionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SLogicConditionNode* pNode = (const SLogicConditionNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, LOGIC_COND_CODE_EXPR_BASE, exprNodeToMsg, pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, LOGIC_COND_CODE_COND_TYPE, pNode->condType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, LOGIC_COND_CODE_PARAMETERS, nodeListToMsg, pNode->pParameterList);
+ }
+
+ return code;
+}
+
+static int32_t msgToLogicConditionNode(STlvDecoder* pDecoder, void* pObj) {
+ SLogicConditionNode* pNode = (SLogicConditionNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case LOGIC_COND_CODE_EXPR_BASE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
+ break;
+ case LOGIC_COND_CODE_COND_TYPE:
+ code = tlvDecodeEnum(pTlv, &pNode->condType, sizeof(pNode->condType));
+ break;
+ case LOGIC_COND_CODE_PARAMETERS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pParameterList);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ FUNCTION_CODE_EXPR_BASE = 1,
+ FUNCTION_CODE_FUNCTION_ID,
+ FUNCTION_CODE_FUNCTION_TYPE,
+ FUNCTION_CODE_PARAMETERS,
+ FUNCTION_CODE_UDF_BUF_SIZE
+};
+
+static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SFunctionNode* pNode = (const SFunctionNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, FUNCTION_CODE_EXPR_BASE, exprNodeToMsg, pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, FUNCTION_CODE_FUNCTION_ID, pNode->funcId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, FUNCTION_CODE_FUNCTION_TYPE, pNode->funcType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, FUNCTION_CODE_PARAMETERS, nodeListToMsg, pNode->pParameterList);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, FUNCTION_CODE_UDF_BUF_SIZE, pNode->udfBufSize);
+ }
+
+ return code;
+}
+
+static int32_t msgToFunctionNode(STlvDecoder* pDecoder, void* pObj) {
+ SFunctionNode* pNode = (SFunctionNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case FUNCTION_CODE_EXPR_BASE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToExprNode, &pNode->node);
+ break;
+ case FUNCTION_CODE_FUNCTION_ID:
+ code = tlvDecodeI32(pTlv, &pNode->funcId);
+ break;
+ case FUNCTION_CODE_FUNCTION_TYPE:
+ code = tlvDecodeI32(pTlv, &pNode->funcType);
+ break;
+ case FUNCTION_CODE_PARAMETERS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pParameterList);
+ break;
+ case FUNCTION_CODE_UDF_BUF_SIZE:
+ code = tlvDecodeI32(pTlv, &pNode->udfBufSize);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { ORDER_BY_EXPR_CODE_EXPR = 1, ORDER_BY_EXPR_CODE_ORDER, ORDER_BY_EXPR_CODE_NULL_ORDER };
+
+static int32_t orderByExprNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SOrderByExprNode* pNode = (const SOrderByExprNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, ORDER_BY_EXPR_CODE_EXPR, nodeToMsg, pNode->pExpr);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, ORDER_BY_EXPR_CODE_ORDER, pNode->order);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, ORDER_BY_EXPR_CODE_NULL_ORDER, pNode->nullOrder);
+ }
+
+ return code;
+}
+
+static int32_t msgToOrderByExprNode(STlvDecoder* pDecoder, void* pObj) {
+ SOrderByExprNode* pNode = (SOrderByExprNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case ORDER_BY_EXPR_CODE_EXPR:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExpr);
+ break;
+ case ORDER_BY_EXPR_CODE_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->order, sizeof(pNode->order));
+ break;
+ case ORDER_BY_EXPR_CODE_NULL_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->nullOrder, sizeof(pNode->nullOrder));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { LIMIT_CODE_LIMIT = 1, LIMIT_CODE_OFFSET };
+
+static int32_t limitNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SLimitNode* pNode = (const SLimitNode*)pObj;
+
+ int32_t code = tlvEncodeI64(pEncoder, LIMIT_CODE_LIMIT, pNode->limit);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, LIMIT_CODE_OFFSET, pNode->offset);
+ }
+
+ return code;
+}
+
+static int32_t msgToLimitNode(STlvDecoder* pDecoder, void* pObj) {
+ SLimitNode* pNode = (SLimitNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case LIMIT_CODE_LIMIT:
+ code = tlvDecodeI64(pTlv, &pNode->limit);
+ break;
+ case LIMIT_CODE_OFFSET:
+ code = tlvDecodeI64(pTlv, &pNode->offset);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { NAME_CODE_TYPE = 1, NAME_CODE_ACCT_ID, NAME_CODE_DB_NAME, NAME_CODE_TABLE_NAME };
+
+static int32_t nameToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SName* pNode = (const SName*)pObj;
+
+ int32_t code = tlvEncodeU8(pEncoder, NAME_CODE_TYPE, pNode->type);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, NAME_CODE_ACCT_ID, pNode->acctId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, NAME_CODE_DB_NAME, pNode->dbname);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, NAME_CODE_TABLE_NAME, pNode->tname);
+ }
+
+ return code;
+}
+
+static int32_t msgToName(STlvDecoder* pDecoder, void* pObj) {
+ SName* pNode = (SName*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case NAME_CODE_TYPE:
+ code = tlvDecodeU8(pTlv, &pNode->type);
+ break;
+ case NAME_CODE_ACCT_ID:
+ code = tlvDecodeI32(pTlv, &pNode->acctId);
+ break;
+ case NAME_CODE_DB_NAME:
+ code = tlvDecodeCStr(pTlv, pNode->dbname);
+ break;
+ case NAME_CODE_TABLE_NAME:
+ code = tlvDecodeCStr(pTlv, pNode->tname);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { TIME_WINDOW_CODE_START_KEY = 1, TIME_WINDOW_CODE_END_KEY };
+
+static int32_t timeWindowToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const STimeWindow* pNode = (const STimeWindow*)pObj;
+
+ int32_t code = tlvEncodeI64(pEncoder, TIME_WINDOW_CODE_START_KEY, pNode->skey);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, TIME_WINDOW_CODE_END_KEY, pNode->ekey);
+ }
+
+ return code;
+}
+
+static int32_t msgToTimeWindow(STlvDecoder* pDecoder, void* pObj) {
+ STimeWindow* pNode = (STimeWindow*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case TIME_WINDOW_CODE_START_KEY:
+ code = tlvDecodeI64(pTlv, &pNode->skey);
+ break;
+ case TIME_WINDOW_CODE_END_KEY:
+ code = tlvDecodeI64(pTlv, &pNode->ekey);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { NODE_LIST_CODE_DATA_TYPE = 1, NODE_LIST_CODE_NODE_LIST };
+
+static int32_t nodeListNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SNodeListNode* pNode = (const SNodeListNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_DATA_TYPE, dataTypeToMsg, &pNode->dataType);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, NODE_LIST_CODE_NODE_LIST, nodeListToMsg, pNode->pNodeList);
+ }
+
+ return code;
+}
+
+static int32_t msgToNodeListNode(STlvDecoder* pDecoder, void* pObj) {
+ SNodeListNode* pNode = (SNodeListNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case NODE_LIST_CODE_DATA_TYPE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->dataType);
+ break;
+ case NODE_LIST_CODE_NODE_LIST:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNodeList);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { TARGET_CODE_DATA_BLOCK_ID = 1, TARGET_CODE_SLOT_ID, TARGET_CODE_EXPR };
+
+static int32_t targetNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const STargetNode* pNode = (const STargetNode*)pObj;
+
+ int32_t code = tlvEncodeI16(pEncoder, TARGET_CODE_DATA_BLOCK_ID, pNode->dataBlockId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI16(pEncoder, TARGET_CODE_SLOT_ID, pNode->slotId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, TARGET_CODE_EXPR, nodeToMsg, pNode->pExpr);
+ }
+
+ return code;
+}
+
+static int32_t msgToTargetNode(STlvDecoder* pDecoder, void* pObj) {
+ STargetNode* pNode = (STargetNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case TARGET_CODE_DATA_BLOCK_ID:
+ code = tlvDecodeI16(pTlv, &pNode->dataBlockId);
+ break;
+ case TARGET_CODE_SLOT_ID:
+ code = tlvDecodeI16(pTlv, &pNode->slotId);
+ break;
+ case TARGET_CODE_EXPR:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pExpr);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID = 1,
+ DATA_BLOCK_DESC_CODE_SLOTS,
+ DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE,
+ DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE,
+ DATA_BLOCK_DESC_CODE_PRECISION
+};
+
+static int32_t dataBlockDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SDataBlockDescNode* pNode = (const SDataBlockDescNode*)pObj;
+
+ int32_t code = tlvEncodeI16(pEncoder, DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID, pNode->dataBlockId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, DATA_BLOCK_DESC_CODE_SLOTS, nodeListToMsg, pNode->pSlots);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE, pNode->totalRowSize);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE, pNode->outputRowSize);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU8(pEncoder, DATA_BLOCK_DESC_CODE_PRECISION, pNode->precision);
+ }
+
+ return code;
+}
+
+static int32_t msgToDataBlockDescNode(STlvDecoder* pDecoder, void* pObj) {
+ SDataBlockDescNode* pNode = (SDataBlockDescNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case DATA_BLOCK_DESC_CODE_DATA_BLOCK_ID:
+ code = tlvDecodeI16(pTlv, &pNode->dataBlockId);
+ break;
+ case DATA_BLOCK_DESC_CODE_SLOTS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSlots);
+ break;
+ case DATA_BLOCK_DESC_CODE_TOTAL_ROW_SIZE:
+ code = tlvDecodeI32(pTlv, &pNode->totalRowSize);
+ break;
+ case DATA_BLOCK_DESC_CODE_OUTPUT_ROW_SIZE:
+ code = tlvDecodeI32(pTlv, &pNode->outputRowSize);
+ break;
+ case DATA_BLOCK_DESC_CODE_PRECISION:
+ code = tlvDecodeU8(pTlv, &pNode->precision);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ SLOT_DESC_CODE_SLOT_ID = 1,
+ SLOT_DESC_CODE_DATA_TYPE,
+ SLOT_DESC_CODE_RESERVE,
+ SLOT_DESC_CODE_OUTPUT,
+ SLOT_DESC_CODE_TAG
+};
+
+static int32_t slotDescNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSlotDescNode* pNode = (const SSlotDescNode*)pObj;
+
+ int32_t code = tlvEncodeI16(pEncoder, SLOT_DESC_CODE_SLOT_ID, pNode->slotId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SLOT_DESC_CODE_DATA_TYPE, dataTypeToMsg, &pNode->dataType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_RESERVE, pNode->reserve);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_OUTPUT, pNode->output);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, SLOT_DESC_CODE_TAG, pNode->tag);
+ }
+
+ return code;
+}
+
+static int32_t msgToSlotDescNode(STlvDecoder* pDecoder, void* pObj) {
+ SSlotDescNode* pNode = (SSlotDescNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case SLOT_DESC_CODE_SLOT_ID:
+ code = tlvDecodeI16(pTlv, &pNode->slotId);
+ break;
+ case SLOT_DESC_CODE_DATA_TYPE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToDataType, &pNode->dataType);
+ break;
+ case SLOT_DESC_CODE_RESERVE:
+ code = tlvDecodeBool(pTlv, &pNode->reserve);
+ break;
+ case SLOT_DESC_CODE_OUTPUT:
+ code = tlvDecodeBool(pTlv, &pNode->output);
+ break;
+ case SLOT_DESC_CODE_TAG:
+ code = tlvDecodeBool(pTlv, &pNode->tag);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_NODE_CODE_OUTPUT_DESC = 1,
+ PHY_NODE_CODE_CONDITIONS,
+ PHY_NODE_CODE_CHILDREN,
+ PHY_NODE_CODE_LIMIT,
+ PHY_NODE_CODE_SLIMIT
+};
+
+static int32_t physiNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SPhysiNode* pNode = (const SPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_OUTPUT_DESC, nodeToMsg, pNode->pOutputDataBlockDesc);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_CONDITIONS, nodeToMsg, pNode->pConditions);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_CHILDREN, nodeListToMsg, pNode->pChildren);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_LIMIT, nodeToMsg, pNode->pLimit);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_NODE_CODE_SLIMIT, nodeToMsg, pNode->pSlimit);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiNode(STlvDecoder* pDecoder, void* pObj) {
+ SPhysiNode* pNode = (SPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_NODE_CODE_OUTPUT_DESC:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pOutputDataBlockDesc);
+ break;
+ case PHY_NODE_CODE_CONDITIONS:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pConditions);
+ break;
+ case PHY_NODE_CODE_CHILDREN:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pChildren);
+ break;
+ case PHY_NODE_CODE_LIMIT:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pLimit);
+ break;
+ case PHY_NODE_CODE_SLIMIT:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pSlimit);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_SCAN_CODE_BASE_NODE = 1,
+ PHY_SCAN_CODE_SCAN_COLS,
+ PHY_SCAN_CODE_SCAN_PSEUDO_COLS,
+ PHY_SCAN_CODE_BASE_UID,
+ PHY_SCAN_CODE_BASE_SUID,
+ PHY_SCAN_CODE_BASE_TABLE_TYPE,
+ PHY_SCAN_CODE_BASE_TABLE_NAME
+};
+
+static int32_t physiScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SScanPhysiNode* pNode = (const SScanPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_SCAN_COLS, nodeListToMsg, pNode->pScanCols);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_SCAN_PSEUDO_COLS, nodeListToMsg, pNode->pScanPseudoCols);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, PHY_SCAN_CODE_BASE_UID, pNode->uid);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, PHY_SCAN_CODE_BASE_SUID, pNode->suid);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_SCAN_CODE_BASE_TABLE_TYPE, pNode->tableType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SCAN_CODE_BASE_TABLE_NAME, nameToMsg, &pNode->tableName);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiScanNode(STlvDecoder* pDecoder, void* pObj) {
+ SScanPhysiNode* pNode = (SScanPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_SCAN_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_SCAN_CODE_SCAN_COLS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pScanCols);
+ break;
+ case PHY_SCAN_CODE_SCAN_PSEUDO_COLS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pScanPseudoCols);
+ break;
+ case PHY_SCAN_CODE_BASE_UID:
+ code = tlvDecodeU64(pTlv, &pNode->uid);
+ break;
+ case PHY_SCAN_CODE_BASE_SUID:
+ code = tlvDecodeU64(pTlv, &pNode->suid);
+ break;
+ case PHY_SCAN_CODE_BASE_TABLE_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->tableType);
+ break;
+ case PHY_SCAN_CODE_BASE_TABLE_NAME:
+ code = tlvDecodeObjFromTlv(pTlv, msgToName, &pNode->tableName);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_LAST_ROW_SCAN_CODE_SCAN = 1, PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT };
+
+static int32_t physiLastRowScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SLastRowScanPhysiNode* pNode = (const SLastRowScanPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_LAST_ROW_SCAN_CODE_GROUP_SORT, pNode->groupSort);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiLastRowScanNode(STlvDecoder* pDecoder, void* pObj) {
+ SLastRowScanPhysiNode* pNode = (SLastRowScanPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_LAST_ROW_SCAN_CODE_SCAN:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
+ break;
+ case PHY_LAST_ROW_SCAN_CODE_GROUP_TAGS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags);
+ break;
+ case PHY_LAST_ROW_SCAN_CODE_GROUP_SORT:
+ code = tlvDecodeBool(pTlv, &pNode->groupSort);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_TABLE_SCAN_CODE_SCAN = 1,
+ PHY_TABLE_SCAN_CODE_SCAN_COUNT,
+ PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT,
+ PHY_TABLE_SCAN_CODE_SCAN_RANGE,
+ PHY_TABLE_SCAN_CODE_RATIO,
+ PHY_TABLE_SCAN_CODE_DATA_REQUIRED,
+ PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS,
+ PHY_TABLE_SCAN_CODE_GROUP_TAGS,
+ PHY_TABLE_SCAN_CODE_GROUP_SORT,
+ PHY_TABLE_SCAN_CODE_INTERVAL,
+ PHY_TABLE_SCAN_CODE_OFFSET,
+ PHY_TABLE_SCAN_CODE_SLIDING,
+ PHY_TABLE_SCAN_CODE_INTERVAL_UNIT,
+ PHY_TABLE_SCAN_CODE_SLIDING_UNIT,
+ PHY_TABLE_SCAN_CODE_TRIGGER_TYPE,
+ PHY_TABLE_SCAN_CODE_WATERMARK,
+ PHY_TABLE_SCAN_CODE_IG_EXPIRED,
+ PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID,
+};
+
+static int32_t physiTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const STableScanPhysiNode* pNode = (const STableScanPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU8(pEncoder, PHY_TABLE_SCAN_CODE_SCAN_COUNT, pNode->scanSeq[0]);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU8(pEncoder, PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT, pNode->scanSeq[1]);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_SCAN_RANGE, timeWindowToMsg, &pNode->scanRange);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeDouble(pEncoder, PHY_TABLE_SCAN_CODE_RATIO, pNode->ratio);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_TABLE_SCAN_CODE_DATA_REQUIRED, pNode->dataRequired);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS, nodeListToMsg, pNode->pDynamicScanFuncs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_TAGS, nodeListToMsg, pNode->pGroupTags);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_TABLE_SCAN_CODE_GROUP_SORT, pNode->groupSort);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_INTERVAL, pNode->interval);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_OFFSET, pNode->offset);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_SLIDING, pNode->sliding);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_INTERVAL_UNIT, pNode->intervalUnit);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_SLIDING_UNIT, pNode->slidingUnit);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_TRIGGER_TYPE, pNode->triggerType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_TABLE_SCAN_CODE_WATERMARK, pNode->watermark);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_TABLE_SCAN_CODE_IG_EXPIRED, pNode->igExpired);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID, pNode->assignBlockUid);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiTableScanNode(STlvDecoder* pDecoder, void* pObj) {
+ STableScanPhysiNode* pNode = (STableScanPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_TABLE_SCAN_CODE_SCAN:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
+ break;
+ case PHY_TABLE_SCAN_CODE_SCAN_COUNT:
+ code = tlvDecodeU8(pTlv, pNode->scanSeq);
+ break;
+ case PHY_TABLE_SCAN_CODE_REVERSE_SCAN_COUNT:
+ code = tlvDecodeU8(pTlv, pNode->scanSeq + 1);
+ break;
+ case PHY_TABLE_SCAN_CODE_SCAN_RANGE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->scanRange);
+ break;
+ case PHY_TABLE_SCAN_CODE_RATIO:
+ code = tlvDecodeDouble(pTlv, &pNode->ratio);
+ break;
+ case PHY_TABLE_SCAN_CODE_DATA_REQUIRED:
+ code = tlvDecodeI32(pTlv, &pNode->dataRequired);
+ break;
+ case PHY_TABLE_SCAN_CODE_DYN_SCAN_FUNCS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pDynamicScanFuncs);
+ break;
+ case PHY_TABLE_SCAN_CODE_GROUP_TAGS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupTags);
+ break;
+ case PHY_TABLE_SCAN_CODE_GROUP_SORT:
+ code = tlvDecodeBool(pTlv, &pNode->groupSort);
+ break;
+ case PHY_TABLE_SCAN_CODE_INTERVAL:
+ code = tlvDecodeI64(pTlv, &pNode->interval);
+ break;
+ case PHY_TABLE_SCAN_CODE_OFFSET:
+ code = tlvDecodeI64(pTlv, &pNode->offset);
+ break;
+ case PHY_TABLE_SCAN_CODE_SLIDING:
+ code = tlvDecodeI64(pTlv, &pNode->sliding);
+ break;
+ case PHY_TABLE_SCAN_CODE_INTERVAL_UNIT:
+ code = tlvDecodeI8(pTlv, &pNode->intervalUnit);
+ break;
+ case PHY_TABLE_SCAN_CODE_SLIDING_UNIT:
+ code = tlvDecodeI8(pTlv, &pNode->slidingUnit);
+ break;
+ case PHY_TABLE_SCAN_CODE_TRIGGER_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->triggerType);
+ break;
+ case PHY_TABLE_SCAN_CODE_WATERMARK:
+ code = tlvDecodeI64(pTlv, &pNode->watermark);
+ break;
+ case PHY_TABLE_SCAN_CODE_IG_EXPIRED:
+ code = tlvDecodeI8(pTlv, &pNode->igExpired);
+ break;
+ case PHY_TABLE_SCAN_CODE_ASSIGN_BLOCK_UID:
+ code = tlvDecodeBool(pTlv, &pNode->assignBlockUid);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { EP_CODE_FQDN = 1, EP_CODE_port };
+
+static int32_t epToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SEp* pNode = (const SEp*)pObj;
+
+ int32_t code = tlvEncodeCStr(pEncoder, EP_CODE_FQDN, pNode->fqdn);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU16(pEncoder, EP_CODE_port, pNode->port);
+ }
+
+ return code;
+}
+
+static int32_t msgToEp(STlvDecoder* pDecoder, void* pObj) {
+ SEp* pNode = (SEp*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case EP_CODE_FQDN:
+ code = tlvDecodeCStr(pTlv, pNode->fqdn);
+ break;
+ case EP_CODE_port:
+ code = tlvDecodeU16(pTlv, &pNode->port);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { EP_SET_CODE_IN_USE = 1, EP_SET_CODE_NUM_OF_EPS, EP_SET_CODE_EPS };
+
+static int32_t epSetToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SEpSet* pNode = (const SEpSet*)pObj;
+
+ int32_t code = tlvEncodeI8(pEncoder, EP_SET_CODE_IN_USE, pNode->inUse);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, EP_SET_CODE_NUM_OF_EPS, pNode->numOfEps);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObjArray(pEncoder, EP_SET_CODE_EPS, epToMsg, pNode->eps, sizeof(SEp), pNode->numOfEps);
+ }
+
+ return code;
+}
+
+static int32_t msgToEpSet(STlvDecoder* pDecoder, void* pObj) {
+ SEpSet* pNode = (SEpSet*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case EP_SET_CODE_IN_USE:
+ code = tlvDecodeI8(pTlv, &pNode->inUse);
+ break;
+ case EP_SET_CODE_NUM_OF_EPS:
+ code = tlvDecodeI8(pTlv, &pNode->numOfEps);
+ break;
+ case EP_SET_CODE_EPS:
+ code = tlvDecodeObjArrayFromTlv(pTlv, msgToEp, pNode->eps, sizeof(SEp));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_SYSTABLE_SCAN_CODE_SCAN = 1,
+ PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET,
+ PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE,
+ PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID,
+ PHY_SYSTABLE_SCAN_CODE_SYS_INFO
+};
+
+static int32_t physiSysTableScanNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSystemTableScanPhysiNode* pNode = (const SSystemTableScanPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_SYSTABLE_SCAN_CODE_SCAN, physiScanNodeToMsg, &pNode->scan);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET, epSetToMsg, &pNode->mgmtEpSet);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE, pNode->showRewrite);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID, pNode->accountId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_SYSTABLE_SCAN_CODE_SYS_INFO, pNode->sysInfo);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiSysTableScanNode(STlvDecoder* pDecoder, void* pObj) {
+ SSystemTableScanPhysiNode* pNode = (SSystemTableScanPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_SYSTABLE_SCAN_CODE_SCAN:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiScanNode, &pNode->scan);
+ break;
+ case PHY_SYSTABLE_SCAN_CODE_MGMT_EP_SET:
+ code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->mgmtEpSet);
+ break;
+ case PHY_SYSTABLE_SCAN_CODE_SHOW_REWRITE:
+ code = tlvDecodeBool(pTlv, &pNode->showRewrite);
+ break;
+ case PHY_SYSTABLE_SCAN_CODE_ACCOUNT_ID:
+ code = tlvDecodeI32(pTlv, &pNode->accountId);
+ break;
+ case PHY_SYSTABLE_SCAN_CODE_SYS_INFO:
+ code = tlvDecodeBool(pTlv, &pNode->sysInfo);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_PROJECT_CODE_BASE_NODE = 1,
+ PHY_PROJECT_CODE_PROJECTIONS,
+ PHY_PROJECT_CODE_MERGE_DATA_BLOCK,
+ PHY_PROJECT_CODE_IGNORE_GROUP_ID
+};
+
+static int32_t physiProjectNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SProjectPhysiNode* pNode = (const SProjectPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_PROJECT_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_PROJECT_CODE_PROJECTIONS, nodeListToMsg, pNode->pProjections);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_PROJECT_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_PROJECT_CODE_IGNORE_GROUP_ID, pNode->ignoreGroupId);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiProjectNode(STlvDecoder* pDecoder, void* pObj) {
+ SProjectPhysiNode* pNode = (SProjectPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_PROJECT_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_PROJECT_CODE_PROJECTIONS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pProjections);
+ break;
+ case PHY_PROJECT_CODE_MERGE_DATA_BLOCK:
+ code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
+ break;
+ case PHY_PROJECT_CODE_IGNORE_GROUP_ID:
+ code = tlvDecodeBool(pTlv, &pNode->ignoreGroupId);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_SORT_MERGE_JOIN_CODE_BASE_NODE = 1,
+ PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE,
+ PHY_SORT_MERGE_JOIN_CODE_MERGE_CONDITION,
+ PHY_SORT_MERGE_JOIN_CODE_ON_CONDITIONS,
+ PHY_SORT_MERGE_JOIN_CODE_TARGETS,
+ PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER
+};
+
+static int32_t physiJoinNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSortMergeJoinPhysiNode* pNode = (const SSortMergeJoinPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE, pNode->joinType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_MERGE_CONDITION, nodeToMsg, pNode->pMergeCondition);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_ON_CONDITIONS, nodeToMsg, pNode->pOnConditions);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_MERGE_JOIN_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER, pNode->inputTsOrder);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiJoinNode(STlvDecoder* pDecoder, void* pObj) {
+ SSortMergeJoinPhysiNode* pNode = (SSortMergeJoinPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_SORT_MERGE_JOIN_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_SORT_MERGE_JOIN_CODE_JOIN_TYPE:
+ code = tlvDecodeEnum(pTlv, &pNode->joinType, sizeof(pNode->joinType));
+ break;
+ case PHY_SORT_MERGE_JOIN_CODE_MERGE_CONDITION:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pMergeCondition);
+ break;
+ case PHY_SORT_MERGE_JOIN_CODE_ON_CONDITIONS:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pOnConditions);
+ break;
+ case PHY_SORT_MERGE_JOIN_CODE_TARGETS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
+ break;
+ case PHY_SORT_MERGE_JOIN_CODE_INPUT_TS_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->inputTsOrder, sizeof(pNode->inputTsOrder));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_AGG_CODE_BASE_NODE = 1,
+ PHY_AGG_CODE_EXPR,
+ PHY_AGG_CODE_GROUP_KEYS,
+ PHY_AGG_CODE_AGG_FUNCS,
+ PHY_AGG_CODE_MERGE_DATA_BLOCK
+};
+
+static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_EXPR, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_GROUP_KEYS, nodeListToMsg, pNode->pGroupKeys);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_AGG_CODE_AGG_FUNCS, nodeListToMsg, pNode->pAggFuncs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) {
+ SAggPhysiNode* pNode = (SAggPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_AGG_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_AGG_CODE_EXPR:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_AGG_CODE_GROUP_KEYS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pGroupKeys);
+ break;
+ case PHY_AGG_CODE_AGG_FUNCS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pAggFuncs);
+ break;
+ case PHY_AGG_CODE_MERGE_DATA_BLOCK:
+ code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_EXCHANGE_CODE_BASE_NODE = 1,
+ PHY_EXCHANGE_CODE_SRC_GROUP_ID,
+ PHY_EXCHANGE_CODE_SINGLE_CHANNEL,
+ PHY_EXCHANGE_CODE_SRC_ENDPOINTS
+};
+
+static int32_t physiExchangeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SExchangePhysiNode* pNode = (const SExchangePhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_EXCHANGE_CODE_SRC_GROUP_ID, pNode->srcGroupId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_EXCHANGE_CODE_SINGLE_CHANNEL, pNode->singleChannel);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_EXCHANGE_CODE_SRC_ENDPOINTS, nodeListToMsg, pNode->pSrcEndPoints);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiExchangeNode(STlvDecoder* pDecoder, void* pObj) {
+ SExchangePhysiNode* pNode = (SExchangePhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_EXCHANGE_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_EXCHANGE_CODE_SRC_GROUP_ID:
+ code = tlvDecodeI32(pTlv, &pNode->srcGroupId);
+ break;
+ case PHY_EXCHANGE_CODE_SINGLE_CHANNEL:
+ code = tlvDecodeBool(pTlv, &pNode->singleChannel);
+ break;
+ case PHY_EXCHANGE_CODE_SRC_ENDPOINTS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSrcEndPoints);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_MERGE_CODE_BASE_NODE = 1,
+ PHY_MERGE_CODE_MERGE_KEYS,
+ PHY_MERGE_CODE_TARGETS,
+ PHY_MERGE_CODE_NUM_OF_CHANNELS,
+ PHY_MERGE_CODE_SRC_GROUP_ID,
+ PHY_MERGE_CODE_GROUP_SORT
+};
+
+static int32_t physiMergeNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SMergePhysiNode* pNode = (const SMergePhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_MERGE_KEYS, nodeListToMsg, pNode->pMergeKeys);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_MERGE_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_MERGE_CODE_NUM_OF_CHANNELS, pNode->numOfChannels);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_MERGE_CODE_SRC_GROUP_ID, pNode->srcGroupId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_MERGE_CODE_GROUP_SORT, pNode->groupSort);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiMergeNode(STlvDecoder* pDecoder, void* pObj) {
+ SMergePhysiNode* pNode = (SMergePhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_MERGE_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_MERGE_CODE_MERGE_KEYS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pMergeKeys);
+ break;
+ case PHY_MERGE_CODE_TARGETS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
+ break;
+ case PHY_MERGE_CODE_NUM_OF_CHANNELS:
+ code = tlvDecodeI32(pTlv, &pNode->numOfChannels);
+ break;
+ case PHY_MERGE_CODE_SRC_GROUP_ID:
+ code = tlvDecodeI32(pTlv, &pNode->srcGroupId);
+ break;
+ case PHY_MERGE_CODE_GROUP_SORT:
+ code = tlvDecodeBool(pTlv, &pNode->groupSort);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_SORT_CODE_BASE_NODE = 1, PHY_SORT_CODE_EXPR, PHY_SORT_CODE_SORT_KEYS, PHY_SORT_CODE_TARGETS };
+
+static int32_t physiSortNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSortPhysiNode* pNode = (const SSortPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_EXPR, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_SORT_KEYS, nodeListToMsg, pNode->pSortKeys);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_SORT_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiSortNode(STlvDecoder* pDecoder, void* pObj) {
+ SSortPhysiNode* pNode = (SSortPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_SORT_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_SORT_CODE_EXPR:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_SORT_CODE_SORT_KEYS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSortKeys);
+ break;
+ case PHY_SORT_CODE_TARGETS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_WINDOW_CODE_BASE_NODE = 1,
+ PHY_WINDOW_CODE_EXPR,
+ PHY_WINDOW_CODE_FUNCS,
+ PHY_WINDOW_CODE_TS_PK,
+ PHY_WINDOW_CODE_TS_END,
+ PHY_WINDOW_CODE_TRIGGER_TYPE,
+ PHY_WINDOW_CODE_WATERMARK,
+ PHY_WINDOW_CODE_IG_EXPIRED,
+ PHY_WINDOW_CODE_INPUT_TS_ORDER,
+ PHY_WINDOW_CODE_OUTPUT_TS_ORDER,
+ PHY_WINDOW_CODE_MERGE_DATA_BLOCK
+};
+
+static int32_t physiWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SWinodwPhysiNode* pNode = (const SWinodwPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_EXPR, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_TS_PK, nodeToMsg, pNode->pTspk);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_WINDOW_CODE_TS_END, nodeToMsg, pNode->pTsEnd);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_TRIGGER_TYPE, pNode->triggerType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_WINDOW_CODE_WATERMARK, pNode->watermark);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_WINDOW_CODE_IG_EXPIRED, pNode->igExpired);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_WINDOW_CODE_INPUT_TS_ORDER, pNode->inputTsOrder);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_WINDOW_CODE_OUTPUT_TS_ORDER, pNode->outputTsOrder);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeBool(pEncoder, PHY_WINDOW_CODE_MERGE_DATA_BLOCK, pNode->mergeDataBlock);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiWindowNode(STlvDecoder* pDecoder, void* pObj) {
+ SWinodwPhysiNode* pNode = (SWinodwPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_WINDOW_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_WINDOW_CODE_EXPR:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_WINDOW_CODE_FUNCS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
+ break;
+ case PHY_WINDOW_CODE_TS_PK:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTspk);
+ break;
+ case PHY_WINDOW_CODE_TS_END:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTsEnd);
+ break;
+ case PHY_WINDOW_CODE_TRIGGER_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->triggerType);
+ break;
+ case PHY_WINDOW_CODE_WATERMARK:
+ code = tlvDecodeI64(pTlv, &pNode->watermark);
+ break;
+ case PHY_WINDOW_CODE_IG_EXPIRED:
+ code = tlvDecodeI8(pTlv, &pNode->igExpired);
+ break;
+ case PHY_WINDOW_CODE_INPUT_TS_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->inputTsOrder, sizeof(pNode->inputTsOrder));
+ break;
+ case PHY_WINDOW_CODE_OUTPUT_TS_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->outputTsOrder, sizeof(pNode->outputTsOrder));
+ break;
+ case PHY_WINDOW_CODE_MERGE_DATA_BLOCK:
+ code = tlvDecodeBool(pTlv, &pNode->mergeDataBlock);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_INTERVAL_CODE_WINDOW = 1,
+ PHY_INTERVAL_CODE_INTERVAL,
+ PHY_INTERVAL_CODE_OFFSET,
+ PHY_INTERVAL_CODE_SLIDING,
+ PHY_INTERVAL_CODE_INTERVAL_UNIT,
+ PHY_INTERVAL_CODE_SLIDING_UNIT
+};
+
+static int32_t physiIntervalNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SIntervalPhysiNode* pNode = (const SIntervalPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_INTERVAL_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_INTERVAL, pNode->interval);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_OFFSET, pNode->offset);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_INTERVAL_CODE_SLIDING, pNode->sliding);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_INTERVAL_CODE_INTERVAL_UNIT, pNode->intervalUnit);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_INTERVAL_CODE_SLIDING_UNIT, pNode->slidingUnit);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiIntervalNode(STlvDecoder* pDecoder, void* pObj) {
+ SIntervalPhysiNode* pNode = (SIntervalPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_INTERVAL_CODE_WINDOW:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
+ break;
+ case PHY_INTERVAL_CODE_INTERVAL:
+ code = tlvDecodeI64(pTlv, &pNode->interval);
+ break;
+ case PHY_INTERVAL_CODE_OFFSET:
+ code = tlvDecodeI64(pTlv, &pNode->offset);
+ break;
+ case PHY_INTERVAL_CODE_SLIDING:
+ code = tlvDecodeI64(pTlv, &pNode->sliding);
+ break;
+ case PHY_INTERVAL_CODE_INTERVAL_UNIT:
+ code = tlvDecodeI8(pTlv, &pNode->intervalUnit);
+ break;
+ case PHY_INTERVAL_CODE_SLIDING_UNIT:
+ code = tlvDecodeI8(pTlv, &pNode->slidingUnit);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_FILL_CODE_BASE_NODE = 1,
+ PHY_FILL_CODE_MODE,
+ PHY_FILL_CODE_FILL_EXPRS,
+ PHY_FILL_CODE_NOT_FILL_EXPRS,
+ PHY_FILL_CODE_WSTART,
+ PHY_FILL_CODE_VALUES,
+ PHY_FILL_CODE_TIME_RANGE,
+ PHY_FILL_CODE_INPUT_TS_ORDER
+};
+
+static int32_t physiFillNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SFillPhysiNode* pNode = (const SFillPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_FILL_CODE_MODE, pNode->mode);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_FILL_EXPRS, nodeListToMsg, pNode->pFillExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_NOT_FILL_EXPRS, nodeListToMsg, pNode->pNotFillExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_WSTART, nodeToMsg, pNode->pWStartTs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_VALUES, nodeToMsg, pNode->pValues);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_FILL_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_FILL_CODE_INPUT_TS_ORDER, pNode->inputTsOrder);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiFillNode(STlvDecoder* pDecoder, void* pObj) {
+ SFillPhysiNode* pNode = (SFillPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_FILL_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_FILL_CODE_MODE:
+ code = tlvDecodeEnum(pTlv, &pNode->mode, sizeof(pNode->mode));
+ break;
+ case PHY_FILL_CODE_FILL_EXPRS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFillExprs);
+ break;
+ case PHY_FILL_CODE_NOT_FILL_EXPRS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pNotFillExprs);
+ break;
+ case PHY_FILL_CODE_WSTART:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pWStartTs);
+ break;
+ case PHY_FILL_CODE_VALUES:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pValues);
+ break;
+ case PHY_FILL_CODE_TIME_RANGE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, (void**)&pNode->timeRange);
+ break;
+ case PHY_FILL_CODE_INPUT_TS_ORDER:
+ code = tlvDecodeEnum(pTlv, &pNode->inputTsOrder, sizeof(pNode->inputTsOrder));
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_SESSION_CODE_WINDOW = 1, PHY_SESSION_CODE_GAP };
+
+static int32_t physiSessionWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSessionWinodwPhysiNode* pNode = (const SSessionWinodwPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_SESSION_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_SESSION_CODE_GAP, pNode->gap);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiSessionWindowNode(STlvDecoder* pDecoder, void* pObj) {
+ SSessionWinodwPhysiNode* pNode = (SSessionWinodwPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_SESSION_CODE_WINDOW:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
+ break;
+ case PHY_SESSION_CODE_GAP:
+ code = tlvDecodeI64(pTlv, &pNode->gap);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_STATE_CODE_WINDOW = 1, PHY_STATE_CODE_KEY };
+
+static int32_t physiStateWindowNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SStateWinodwPhysiNode* pNode = (const SStateWinodwPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_STATE_CODE_WINDOW, physiWindowNodeToMsg, &pNode->window);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_STATE_CODE_KEY, nodeToMsg, pNode->pStateKey);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiStateWindowNode(STlvDecoder* pDecoder, void* pObj) {
+ SStateWinodwPhysiNode* pNode = (SStateWinodwPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_STATE_CODE_WINDOW:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiWindowNode, &pNode->window);
+ break;
+ case PHY_STATE_CODE_KEY:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStateKey);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_PARTITION_CODE_BASE_NODE = 1, PHY_PARTITION_CODE_EXPR, PHY_PARTITION_CODE_KEYS, PHY_PARTITION_CODE_TARGETS };
+
+static int32_t physiPartitionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SPartitionPhysiNode* pNode = (const SPartitionPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_EXPR, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_KEYS, nodeListToMsg, pNode->pPartitionKeys);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_PARTITION_CODE_TARGETS, nodeListToMsg, pNode->pTargets);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiPartitionNode(STlvDecoder* pDecoder, void* pObj) {
+ SPartitionPhysiNode* pNode = (SPartitionPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_PARTITION_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_PARTITION_CODE_EXPR:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_PARTITION_CODE_KEYS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pPartitionKeys);
+ break;
+ case PHY_PARTITION_CODE_TARGETS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pTargets);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE = 1, PHY_INDEF_ROWS_FUNC_CODE_EXPRS, PHY_INDEF_ROWS_FUNC_CODE_FUNCS };
+
+static int32_t physiIndefRowsFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SIndefRowsFuncPhysiNode* pNode = (const SIndefRowsFuncPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_EXPRS, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INDEF_ROWS_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiIndefRowsFuncNode(STlvDecoder* pDecoder, void* pObj) {
+ SIndefRowsFuncPhysiNode* pNode = (SIndefRowsFuncPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_INDEF_ROWS_FUNC_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_INDEF_ROWS_FUNC_CODE_EXPRS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_INDEF_ROWS_FUNC_CODE_FUNCS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_INERP_FUNC_CODE_BASE_NODE = 1,
+ PHY_INERP_FUNC_CODE_EXPR,
+ PHY_INERP_FUNC_CODE_FUNCS,
+ PHY_INERP_FUNC_CODE_TIME_RANGE,
+ PHY_INERP_FUNC_CODE_INTERVAL,
+ PHY_INERP_FUNC_CODE_INTERVAL_UNIT,
+ PHY_INERP_FUNC_CODE_FILL_MODE,
+ PHY_INERP_FUNC_CODE_FILL_VALUES,
+ PHY_INERP_FUNC_CODE_TIME_SERIES
+};
+
+static int32_t physiInterpFuncNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SInterpFuncPhysiNode* pNode = (const SInterpFuncPhysiNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_BASE_NODE, physiNodeToMsg, &pNode->node);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_EXPR, nodeListToMsg, pNode->pExprs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_FUNCS, nodeListToMsg, pNode->pFuncs);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_TIME_RANGE, timeWindowToMsg, &pNode->timeRange);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI64(pEncoder, PHY_INERP_FUNC_CODE_INTERVAL, pNode->interval);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_INERP_FUNC_CODE_INTERVAL_UNIT, pNode->intervalUnit);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, PHY_INERP_FUNC_CODE_FILL_MODE, pNode->fillMode);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_FILL_VALUES, nodeToMsg, pNode->pFillValues);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_INERP_FUNC_CODE_TIME_SERIES, nodeToMsg, pNode->pTimeSeries);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiInterpFuncNode(STlvDecoder* pDecoder, void* pObj) {
+ SInterpFuncPhysiNode* pNode = (SInterpFuncPhysiNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_INERP_FUNC_CODE_BASE_NODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysiNode, &pNode->node);
+ break;
+ case PHY_INERP_FUNC_CODE_EXPR:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pExprs);
+ break;
+ case PHY_INERP_FUNC_CODE_FUNCS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pFuncs);
+ break;
+ case PHY_INERP_FUNC_CODE_TIME_RANGE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->timeRange);
+ break;
+ case PHY_INERP_FUNC_CODE_INTERVAL:
+ code = tlvDecodeI64(pTlv, &pNode->interval);
+ break;
+ case PHY_INERP_FUNC_CODE_INTERVAL_UNIT:
+ code = tlvDecodeI8(pTlv, &pNode->intervalUnit);
+ break;
+ case PHY_INERP_FUNC_CODE_FILL_MODE:
+ code = tlvDecodeEnum(pTlv, &pNode->fillMode, sizeof(pNode->fillMode));
+ break;
+ case PHY_INERP_FUNC_CODE_FILL_VALUES:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pFillValues);
+ break;
+ case PHY_INERP_FUNC_CODE_TIME_SERIES:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTimeSeries);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_DATA_SINK_CODE_INPUT_DESC = 1 };
+
+static int32_t physicDataSinkNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SDataSinkNode* pNode = (const SDataSinkNode*)pObj;
+ return tlvEncodeObj(pEncoder, PHY_DATA_SINK_CODE_INPUT_DESC, nodeToMsg, pNode->pInputDataBlockDesc);
+}
+
+static int32_t msgToPhysicDataSinkNode(STlvDecoder* pDecoder, void* pObj) {
+ SDataSinkNode* pNode = (SDataSinkNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_DATA_SINK_CODE_INPUT_DESC:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pInputDataBlockDesc);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { PHY_DISPATCH_CODE_SINK = 1 };
+
+static int32_t physiDispatchNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SDataDispatcherNode* pNode = (const SDataDispatcherNode*)pObj;
+ return tlvEncodeObj(pEncoder, PHY_DISPATCH_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
+}
+
+static int32_t msgToPhysiDispatchNode(STlvDecoder* pDecoder, void* pObj) {
+ SDataDispatcherNode* pNode = (SDataDispatcherNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_DISPATCH_CODE_SINK:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_QUERY_INSERT_CODE_SINK = 1,
+ PHY_QUERY_INSERT_CODE_COLS,
+ PHY_QUERY_INSERT_CODE_TABLE_ID,
+ PHY_QUERY_INSERT_CODE_STABLE_ID,
+ PHY_QUERY_INSERT_CODE_TABLE_TYPE,
+ PHY_QUERY_INSERT_CODE_TABLE_NAME,
+ PHY_QUERY_INSERT_CODE_VG_ID,
+ PHY_QUERY_INSERT_CODE_EP_SET
+};
+
+static int32_t physiQueryInsertNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SQueryInserterNode* pNode = (const SQueryInserterNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_COLS, nodeListToMsg, pNode->pCols);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_ID, pNode->tableId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, PHY_QUERY_INSERT_CODE_STABLE_ID, pNode->stableId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_TYPE, pNode->tableType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, PHY_QUERY_INSERT_CODE_TABLE_NAME, pNode->tableName);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, PHY_QUERY_INSERT_CODE_VG_ID, pNode->vgId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_QUERY_INSERT_CODE_EP_SET, epSetToMsg, &pNode->epSet);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiQueryInsertNode(STlvDecoder* pDecoder, void* pObj) {
+ SQueryInserterNode* pNode = (SQueryInserterNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_QUERY_INSERT_CODE_SINK:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
+ break;
+ case PHY_QUERY_INSERT_CODE_COLS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pCols);
+ break;
+ case PHY_QUERY_INSERT_CODE_TABLE_ID:
+ code = tlvDecodeU64(pTlv, &pNode->tableId);
+ break;
+ case PHY_QUERY_INSERT_CODE_STABLE_ID:
+ code = tlvDecodeU64(pTlv, &pNode->stableId);
+ break;
+ case PHY_QUERY_INSERT_CODE_TABLE_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->tableType);
+ break;
+ case PHY_QUERY_INSERT_CODE_TABLE_NAME:
+ code = tlvDecodeCStr(pTlv, pNode->tableName);
+ break;
+ case PHY_QUERY_INSERT_CODE_VG_ID:
+ code = tlvDecodeI32(pTlv, &pNode->vgId);
+ break;
+ case PHY_QUERY_INSERT_CODE_EP_SET:
+ code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->epSet);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ PHY_DELETER_CODE_SINK = 1,
+ PHY_DELETER_CODE_TABLE_ID,
+ PHY_DELETER_CODE_TABLE_TYPE,
+ PHY_DELETER_CODE_TABLE_FNAME,
+ PHY_DELETER_CODE_TS_COL_NAME,
+ PHY_DELETER_CODE_DELETE_TIME_RANGE,
+ PHY_DELETER_CODE_AFFECTED_ROWS
+};
+
+static int32_t physiDeleteNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SDataDeleterNode* pNode = (const SDataDeleterNode*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_SINK, physicDataSinkNodeToMsg, &pNode->sink);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeU64(pEncoder, PHY_DELETER_CODE_TABLE_ID, pNode->tableId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI8(pEncoder, PHY_DELETER_CODE_TABLE_TYPE, pNode->tableType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, PHY_DELETER_CODE_TABLE_FNAME, pNode->tableFName);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, PHY_DELETER_CODE_TS_COL_NAME, pNode->tsColName);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_DELETE_TIME_RANGE, timeWindowToMsg, &pNode->deleteTimeRange);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_AFFECTED_ROWS, nodeToMsg, pNode->pAffectedRows);
+ }
+
+ return code;
+}
+
+static int32_t msgToPhysiDeleteNode(STlvDecoder* pDecoder, void* pObj) {
+ SDataDeleterNode* pNode = (SDataDeleterNode*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case PHY_DELETER_CODE_SINK:
+ code = tlvDecodeObjFromTlv(pTlv, msgToPhysicDataSinkNode, &pNode->sink);
+ break;
+ case PHY_DELETER_CODE_TABLE_ID:
+ code = tlvDecodeU64(pTlv, &pNode->tableId);
+ break;
+ case PHY_DELETER_CODE_TABLE_TYPE:
+ code = tlvDecodeI8(pTlv, &pNode->tableType);
+ break;
+ case PHY_DELETER_CODE_TABLE_FNAME:
+ code = tlvDecodeCStr(pTlv, pNode->tableFName);
+ break;
+ case PHY_DELETER_CODE_TS_COL_NAME:
+ code = tlvDecodeCStr(pTlv, pNode->tsColName);
+ break;
+ case PHY_DELETER_CODE_DELETE_TIME_RANGE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToTimeWindow, &pNode->deleteTimeRange);
+ break;
+ case PHY_DELETER_CODE_AFFECTED_ROWS:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pAffectedRows);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { SUBPLAN_ID_CODE_QUERY_ID = 1, SUBPLAN_ID_CODE_GROUP_ID, SUBPLAN_ID_CODE_SUBPLAN_ID };
+
+static int32_t subplanIdToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSubplanId* pNode = (const SSubplanId*)pObj;
+
+ int32_t code = tlvEncodeU64(pEncoder, SUBPLAN_ID_CODE_QUERY_ID, pNode->queryId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, SUBPLAN_ID_CODE_GROUP_ID, pNode->groupId);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, SUBPLAN_ID_CODE_SUBPLAN_ID, pNode->subplanId);
+ }
+
+ return code;
+}
+
+static int32_t msgToSubplanId(STlvDecoder* pDecoder, void* pObj) {
+ SSubplanId* pNode = (SSubplanId*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case SUBPLAN_ID_CODE_QUERY_ID:
+ code = tlvDecodeU64(pTlv, &pNode->queryId);
+ break;
+ case SUBPLAN_ID_CODE_GROUP_ID:
+ code = tlvDecodeI32(pTlv, &pNode->groupId);
+ break;
+ case SUBPLAN_ID_CODE_SUBPLAN_ID:
+ code = tlvDecodeI32(pTlv, &pNode->subplanId);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { QUERY_NODE_ADDR_CODE_NODE_ID = 1, QUERY_NODE_ADDR_CODE_EP_SET };
+
+static int32_t queryNodeAddrToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SQueryNodeAddr* pNode = (const SQueryNodeAddr*)pObj;
+
+ int32_t code = tlvEncodeI32(pEncoder, QUERY_NODE_ADDR_CODE_NODE_ID, pNode->nodeId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, QUERY_NODE_ADDR_CODE_EP_SET, epSetToMsg, &pNode->epSet);
+ }
+
+ return code;
+}
+
+static int32_t msgToQueryNodeAddr(STlvDecoder* pDecoder, void* pObj) {
+ SQueryNodeAddr* pNode = (SQueryNodeAddr*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case QUERY_NODE_ADDR_CODE_NODE_ID:
+ code = tlvDecodeI32(pTlv, &pNode->nodeId);
+ break;
+ case QUERY_NODE_ADDR_CODE_EP_SET:
+ code = tlvDecodeObjFromTlv(pTlv, msgToEpSet, &pNode->epSet);
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum {
+ SUBPLAN_CODE_SUBPLAN_ID = 1,
+ SUBPLAN_CODE_SUBPLAN_TYPE,
+ SUBPLAN_CODE_MSG_TYPE,
+ SUBPLAN_CODE_LEVEL,
+ SUBPLAN_CODE_DBFNAME,
+ SUBPLAN_CODE_USER,
+ SUBPLAN_CODE_EXECNODE,
+ SUBPLAN_CODE_ROOT_NODE,
+ SUBPLAN_CODE_DATA_SINK,
+ SUBPLAN_CODE_TAG_COND,
+ SUBPLAN_CODE_TAG_INDEX_COND
+};
+
+static int32_t subplanToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SSubplan* pNode = (const SSubplan*)pObj;
+
+ int32_t code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_SUBPLAN_ID, subplanIdToMsg, &pNode->id);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeEnum(pEncoder, SUBPLAN_CODE_SUBPLAN_TYPE, pNode->subplanType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, SUBPLAN_CODE_MSG_TYPE, pNode->msgType);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, SUBPLAN_CODE_LEVEL, pNode->level);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, SUBPLAN_CODE_DBFNAME, pNode->dbFName);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeCStr(pEncoder, SUBPLAN_CODE_USER, pNode->user);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_EXECNODE, queryNodeAddrToMsg, &pNode->execNode);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_ROOT_NODE, nodeToMsg, pNode->pNode);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_DATA_SINK, nodeToMsg, pNode->pDataSink);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_TAG_COND, nodeToMsg, pNode->pTagCond);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, SUBPLAN_CODE_TAG_INDEX_COND, nodeToMsg, pNode->pTagIndexCond);
+ }
+
+ return code;
+}
+
+static int32_t msgToSubplan(STlvDecoder* pDecoder, void* pObj) {
+ SSubplan* pNode = (SSubplan*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case SUBPLAN_CODE_SUBPLAN_ID:
+ code = tlvDecodeObjFromTlv(pTlv, msgToSubplanId, &pNode->id);
+ break;
+ case SUBPLAN_CODE_SUBPLAN_TYPE:
+ code = tlvDecodeEnum(pTlv, &pNode->subplanType, sizeof(pNode->subplanType));
+ break;
+ case SUBPLAN_CODE_MSG_TYPE:
+ code = tlvDecodeI32(pTlv, &pNode->msgType);
+ break;
+ case SUBPLAN_CODE_LEVEL:
+ code = tlvDecodeI32(pTlv, &pNode->level);
+ break;
+ case SUBPLAN_CODE_DBFNAME:
+ code = tlvDecodeCStr(pTlv, pNode->dbFName);
+ break;
+ case SUBPLAN_CODE_USER:
+ code = tlvDecodeCStr(pTlv, pNode->user);
+ break;
+ case SUBPLAN_CODE_EXECNODE:
+ code = tlvDecodeObjFromTlv(pTlv, msgToQueryNodeAddr, &pNode->execNode);
+ break;
+ case SUBPLAN_CODE_ROOT_NODE:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pNode);
+ break;
+ case SUBPLAN_CODE_DATA_SINK:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pDataSink);
+ break;
+ case SUBPLAN_CODE_TAG_COND:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTagCond);
+ break;
+ case SUBPLAN_CODE_TAG_INDEX_COND:
+ code = msgToNodeFromTlv(pTlv, (void**)&pNode->pTagIndexCond);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+enum { QUERY_PLAN_CODE_QUERY_ID = 1, QUERY_PLAN_CODE_NUM_OF_SUBPLANS, QUERY_PLAN_CODE_SUBPLANS };
+
+static int32_t queryPlanToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SQueryPlan* pNode = (const SQueryPlan*)pObj;
+
+ int32_t code = tlvEncodeU64(pEncoder, QUERY_PLAN_CODE_QUERY_ID, pNode->queryId);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeI32(pEncoder, QUERY_PLAN_CODE_NUM_OF_SUBPLANS, pNode->numOfSubplans);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = tlvEncodeObj(pEncoder, QUERY_PLAN_CODE_SUBPLANS, nodeListToMsg, pNode->pSubplans);
+ }
+
+ return code;
+}
+
+static int32_t msgToQueryPlan(STlvDecoder* pDecoder, void* pObj) {
+ SQueryPlan* pNode = (SQueryPlan*)pObj;
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ STlv* pTlv = NULL;
+ tlvForEach(pDecoder, pTlv, code) {
+ switch (pTlv->type) {
+ case QUERY_PLAN_CODE_QUERY_ID:
+ code = tlvDecodeU64(pTlv, &pNode->queryId);
+ break;
+ case QUERY_PLAN_CODE_NUM_OF_SUBPLANS:
+ code = tlvDecodeI32(pTlv, &pNode->numOfSubplans);
+ break;
+ case QUERY_PLAN_CODE_SUBPLANS:
+ code = msgToNodeListFromTlv(pTlv, (void**)&pNode->pSubplans);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return code;
+}
+
+static int32_t specificNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ switch (nodeType(pObj)) {
+ case QUERY_NODE_COLUMN:
+ code = columnNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_VALUE:
+ code = valueNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_OPERATOR:
+ code = operatorNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_LOGIC_CONDITION:
+ code = logicConditionNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_FUNCTION:
+ code = functionNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_ORDER_BY_EXPR:
+ code = orderByExprNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_LIMIT:
+ code = limitNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_NODE_LIST:
+ code = nodeListNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_TARGET:
+ code = targetNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_DATABLOCK_DESC:
+ code = dataBlockDescNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_SLOT_DESC:
+ code = slotDescNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_LEFT_VALUE:
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
+ code = physiScanNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
+ code = physiLastRowScanNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
+ code = physiTableScanNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
+ code = physiSysTableScanNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
+ code = physiProjectNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
+ code = physiJoinNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG:
+ code = physiAggNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
+ code = physiExchangeNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE:
+ code = physiMergeNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_SORT:
+ case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT:
+ code = physiSortNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
+ code = physiIntervalNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_FILL:
+ code = physiFillNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
+ code = physiSessionWindowNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE:
+ code = physiStateWindowNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION:
+ code = physiPartitionNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC:
+ code = physiIndefRowsFuncNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
+ code = physiInterpFuncNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ code = physiDispatchNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
+ code = physiQueryInsertNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_DELETE:
+ code = physiDeleteNodeToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_SUBPLAN:
+ code = subplanToMsg(pObj, pEncoder);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN:
+ code = queryPlanToMsg(pObj, pEncoder);
+ break;
+ default:
+ nodesWarn("specificNodeToMsg unknown node = %s", nodesNodeName(nodeType(pObj)));
+ break;
+ }
+ if (TSDB_CODE_SUCCESS != code) {
+ nodesError("specificNodeToMsg error node = %s", nodesNodeName(nodeType(pObj)));
+ }
+ return code;
+}
+
+static int32_t msgToSpecificNode(STlvDecoder* pDecoder, void* pObj) {
+ int32_t code = TSDB_CODE_SUCCESS;
+ switch (nodeType(pObj)) {
+ case QUERY_NODE_COLUMN:
+ code = msgToColumnNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_VALUE:
+ code = msgToValueNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_OPERATOR:
+ code = msgToOperatorNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_LOGIC_CONDITION:
+ code = msgToLogicConditionNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_FUNCTION:
+ code = msgToFunctionNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_ORDER_BY_EXPR:
+ code = msgToOrderByExprNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_LIMIT:
+ code = msgToLimitNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_NODE_LIST:
+ code = msgToNodeListNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_TARGET:
+ code = msgToTargetNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_DATABLOCK_DESC:
+ code = msgToDataBlockDescNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_SLOT_DESC:
+ code = msgToSlotDescNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_LEFT_VALUE:
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN:
+ code = msgToPhysiScanNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN:
+ code = msgToPhysiLastRowScanNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN:
+ code = msgToPhysiTableScanNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:
+ code = msgToPhysiSysTableScanNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_PROJECT:
+ code = msgToPhysiProjectNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN:
+ code = msgToPhysiJoinNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_HASH_AGG:
+ code = msgToPhysiAggNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:
+ code = msgToPhysiExchangeNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE:
+ code = msgToPhysiMergeNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_SORT:
+ case QUERY_NODE_PHYSICAL_PLAN_GROUP_SORT:
+ code = msgToPhysiSortNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_HASH_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_ALIGNED_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_INTERVAL:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_INTERVAL:
+ code = msgToPhysiIntervalNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_FILL:
+ code = msgToPhysiFillNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_SEMI_SESSION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_FINAL_SESSION:
+ code = msgToPhysiSessionWindowNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_MERGE_STATE:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_STATE:
+ code = msgToPhysiStateWindowNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_PARTITION:
+ case QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION:
+ code = msgToPhysiPartitionNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_INDEF_ROWS_FUNC:
+ code = msgToPhysiIndefRowsFuncNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_INTERP_FUNC:
+ code = msgToPhysiInterpFuncNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_DISPATCH:
+ code = msgToPhysiDispatchNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_QUERY_INSERT:
+ code = msgToPhysiQueryInsertNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN_DELETE:
+ code = msgToPhysiDeleteNode(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_SUBPLAN:
+ code = msgToSubplan(pDecoder, pObj);
+ break;
+ case QUERY_NODE_PHYSICAL_PLAN:
+ code = msgToQueryPlan(pDecoder, pObj);
+ break;
+ default:
+ nodesWarn("msgToSpecificNode unknown node = %s", nodesNodeName(nodeType(pObj)));
+ break;
+ }
+ if (TSDB_CODE_SUCCESS != code) {
+ nodesError("msgToSpecificNode error node = %s", nodesNodeName(nodeType(pObj)));
+ }
+ return code;
+}
+
+static int32_t nodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ return tlvEncodeObj(pEncoder, nodeType(pObj), specificNodeToMsg, pObj);
+}
+
+static int32_t msgToNode(STlvDecoder* pDecoder, void** pObj) {
+ return tlvDecodeDynObj(pDecoder, (FMakeObject)nodesMakeNode, msgToSpecificNode, pObj);
+}
+
+static int32_t msgToNodeFromTlv(STlv* pTlv, void** pObj) {
+ STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
+ return msgToNode(&decoder, pObj);
+}
+
+static int32_t nodeListToMsg(const void* pObj, STlvEncoder* pEncoder) {
+ const SNodeList* pList = (const SNodeList*)pObj;
+
+ SNode* pNode = NULL;
+ FOREACH(pNode, pList) {
+ int32_t code = nodeToMsg(pNode, pEncoder);
+ if (TSDB_CODE_SUCCESS != code) {
+ return code;
+ }
+ }
+
+ return TSDB_CODE_SUCCESS;
+}
+
+static int32_t msgToNodeList(STlvDecoder* pDecoder, void** pObj) {
+ SNodeList* pList = nodesMakeList();
+
+ int32_t code = TSDB_CODE_SUCCESS;
+ while (TSDB_CODE_SUCCESS == code && !tlvDecodeEnd(pDecoder)) {
+ SNode* pNode = NULL;
+ code = msgToNode(pDecoder, (void**)&pNode);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = nodesListAppend(pList, pNode);
+ }
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ *pObj = pList;
+ } else {
+ nodesDestroyList(pList);
+ }
+ return code;
+}
+
+static int32_t msgToNodeListFromTlv(STlv* pTlv, void** pObj) {
+ STlvDecoder decoder = {.bufSize = pTlv->len, .offset = 0, .pBuf = pTlv->value};
+ return msgToNodeList(&decoder, pObj);
+}
+
+int32_t nodesNodeToMsg(const SNode* pNode, char** pMsg, int32_t* pLen) {
+ if (NULL == pNode || NULL == pMsg || NULL == pLen) {
+ terrno = TSDB_CODE_FAILED;
+ return TSDB_CODE_FAILED;
+ }
+
+ STlvEncoder encoder;
+ int32_t code = initTlvEncoder(&encoder);
+ if (TSDB_CODE_SUCCESS == code) {
+ code = nodeToMsg(pNode, &encoder);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ endTlvEncode(&encoder, pMsg, pLen);
+ }
+ clearTlvEncoder(&encoder);
+
+ terrno = code;
+ return code;
+}
+
+int32_t nodesMsgToNode(const char* pMsg, int32_t len, SNode** pNode) {
+ if (NULL == pMsg || NULL == pNode) {
+ return TSDB_CODE_SUCCESS;
+ }
+
+ STlvDecoder decoder = {.bufSize = len, .offset = 0, .pBuf = pMsg};
+ int32_t code = msgToNode(&decoder, (void**)pNode);
+ if (TSDB_CODE_SUCCESS != code) {
+ nodesDestroyNode(*pNode);
+ *pNode = NULL;
+ }
+
+ terrno = code;
+ return code;
+}
diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h
index eab2d40164..0507fe0c66 100644
--- a/source/libs/parser/inc/parAst.h
+++ b/source/libs/parser/inc/parAst.h
@@ -60,7 +60,9 @@ typedef enum EDatabaseOptionType {
DB_OPTION_WAL_RETENTION_SIZE,
DB_OPTION_WAL_ROLL_PERIOD,
DB_OPTION_WAL_SEGMENT_SIZE,
- DB_OPTION_SST_TRIGGER
+ DB_OPTION_SST_TRIGGER,
+ DB_OPTION_TABLE_PREFIX,
+ DB_OPTION_TABLE_SUFFIX
} EDatabaseOptionType;
typedef enum ETableOptionType {
diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y
index cfa3379e28..fdd0ec548b 100644
--- a/source/libs/parser/inc/sql.y
+++ b/source/libs/parser/inc/sql.y
@@ -208,6 +208,8 @@ db_options(A) ::= db_options(B) WAL_RETENTION_SIZE NK_MINUS(D) NK_INTEGER(C).
db_options(A) ::= db_options(B) WAL_ROLL_PERIOD NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_ROLL_PERIOD, &C); }
db_options(A) ::= db_options(B) WAL_SEGMENT_SIZE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_WAL_SEGMENT_SIZE, &C); }
db_options(A) ::= db_options(B) SST_TRIGGER NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SST_TRIGGER, &C); }
+db_options(A) ::= db_options(B) TABLE_PREFIX NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_PREFIX, &C); }
+db_options(A) ::= db_options(B) TABLE_SUFFIX NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_TABLE_SUFFIX, &C); }
alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); }
alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); }
diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c
index 92c6058f07..901abf17ee 100644
--- a/source/libs/parser/src/parAstCreater.c
+++ b/source/libs/parser/src/parAstCreater.c
@@ -836,6 +836,8 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) {
updateWalOptionsDefault(pOptions);
pOptions->walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE;
pOptions->sstTrigger = TSDB_DEFAULT_SST_TRIGGER;
+ pOptions->tablePrefix = TSDB_DEFAULT_HASH_PREFIX;
+ pOptions->tableSuffix = TSDB_DEFAULT_HASH_SUFFIX;
return (SNode*)pOptions;
}
@@ -868,6 +870,8 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) {
pOptions->walRollPeriod = -1;
pOptions->walSegmentSize = -1;
pOptions->sstTrigger = -1;
+ pOptions->tablePrefix = -1;
+ pOptions->tableSuffix = -1;
return (SNode*)pOptions;
}
@@ -954,6 +958,12 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti
case DB_OPTION_SST_TRIGGER:
pDbOptions->sstTrigger = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
break;
+ case DB_OPTION_TABLE_PREFIX:
+ pDbOptions->tablePrefix = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
+ break;
+ case DB_OPTION_TABLE_SUFFIX:
+ pDbOptions->tableSuffix = taosStr2Int32(((SToken*)pVal)->z, NULL, 10);
+ break;
default:
break;
}
diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c
index 750263215a..e0f54530dd 100644
--- a/source/libs/parser/src/parTokenizer.c
+++ b/source/libs/parser/src/parTokenizer.c
@@ -200,6 +200,8 @@ static SKeyword keywordTable[] = {
{"SYSINFO", TK_SYSINFO},
{"TABLE", TK_TABLE},
{"TABLES", TK_TABLES},
+ {"TABLE_PREFIX", TK_TABLE_PREFIX},
+ {"TABLE_SUFFIX", TK_TABLE_SUFFIX},
{"TAG", TK_TAG},
{"TAGS", TK_TAGS},
{"TBNAME", TK_TBNAME},
diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c
index c3db67668a..91787f5a72 100644
--- a/source/libs/parser/src/parTranslater.c
+++ b/source/libs/parser/src/parTranslater.c
@@ -3483,6 +3483,8 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS
pReq->walRollPeriod = pStmt->pOptions->walRollPeriod;
pReq->walSegmentSize = pStmt->pOptions->walSegmentSize;
pReq->sstTrigger = pStmt->pOptions->sstTrigger;
+ pReq->hashPrefix = pStmt->pOptions->tablePrefix;
+ pReq->hashSuffix = pStmt->pOptions->tableSuffix;
pReq->ignoreExist = pStmt->ignoreExists;
return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq);
}
@@ -3768,7 +3770,13 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName
checkDbRangeOption(pCxt, "walSegmentSize", pOptions->walSegmentSize, TSDB_DB_MIN_WAL_SEGMENT_SIZE, INT32_MAX);
}
if (TSDB_CODE_SUCCESS == code) {
- code = checkDbRangeOption(pCxt, "sstTrigger", pOptions->sstTrigger, TSDB_MIN_SST_TRIGGER, TSDB_MAX_SST_TRIGGER);
+ code = checkDbRangeOption(pCxt, "sstTrigger", pOptions->sstTrigger, TSDB_MIN_STT_TRIGGER, TSDB_MAX_STT_TRIGGER);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = checkDbRangeOption(pCxt, "tablePrefix", pOptions->tablePrefix, TSDB_MIN_HASH_PREFIX, TSDB_MAX_HASH_PREFIX);
+ }
+ if (TSDB_CODE_SUCCESS == code) {
+ code = checkDbRangeOption(pCxt, "tableSuffix", pOptions->tableSuffix, TSDB_MIN_HASH_SUFFIX, TSDB_MAX_HASH_SUFFIX);
}
if (TSDB_CODE_SUCCESS == code) {
code = checkOptionsDependency(pCxt, pDbName, pOptions);
@@ -5856,7 +5864,7 @@ static int32_t rewriteShowVnodes(STranslateContext* pCxt, SQuery* pQuery) {
if (NULL != pShow->pDnodeId) {
code = createOperatorNode(OP_TYPE_EQUAL, "dnode_id", pShow->pDnodeId, &pStmt->pWhere);
} else {
- code = createOperatorNode(OP_TYPE_EQUAL, "dnode_endpoint", pShow->pDnodeEndpoint, &pStmt->pWhere);
+ code = createOperatorNode(OP_TYPE_EQUAL, "dnode_ep", pShow->pDnodeEndpoint, &pStmt->pWhere);
}
}
if (TSDB_CODE_SUCCESS == code) {
@@ -6596,7 +6604,17 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS
pReq->colId = pSchema->colId;
SDataType targetDt = schemaToDataType(pTableMeta->tableInfo.precision, pSchema);
- if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) {
+
+ if (QUERY_NODE_VALUE != pStmt->pVal->node.type) {
+ SValueNode* pVal = NULL;
+ pCxt->errCode = createTagValFromExpr(pCxt, targetDt, (SNode*)pStmt->pVal, &pVal);
+ if (pCxt->errCode) {
+ return pCxt->errCode;
+ }
+
+ nodesDestroyNode((SNode*)pStmt->pVal);
+ pStmt->pVal = pVal;
+ } else if (DEAL_RES_ERROR == translateValueImpl(pCxt, pStmt->pVal, targetDt, true)) {
return pCxt->errCode;
}
diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c
index d54261f0cb..0442d262f1 100644
--- a/source/libs/parser/src/sql.c
+++ b/source/libs/parser/src/sql.c
@@ -104,26 +104,26 @@
#endif
/************* Begin control #defines *****************************************/
#define YYCODETYPE unsigned short int
-#define YYNOCODE 427
+#define YYNOCODE 429
#define YYACTIONTYPE unsigned short int
#define ParseTOKENTYPE SToken
typedef union {
int yyinit;
ParseTOKENTYPE yy0;
- SAlterOption yy95;
- EOperatorType yy198;
- EOrder yy204;
- int8_t yy215;
- ENullOrder yy277;
- bool yy313;
- int64_t yy473;
- SNodeList* yy544;
- SToken yy617;
- EJoinType yy708;
- SDataType yy784;
- EFillMode yy816;
- SNode* yy840;
- int32_t yy844;
+ int32_t yy46;
+ SNode* yy80;
+ int64_t yy129;
+ SDataType yy136;
+ EOperatorType yy194;
+ SToken yy239;
+ SAlterOption yy299;
+ EOrder yy422;
+ EFillMode yy426;
+ int8_t yy509;
+ SNodeList* yy574;
+ EJoinType yy750;
+ ENullOrder yy763;
+ bool yy845;
} YYMINORTYPE;
#ifndef YYSTACKDEPTH
#define YYSTACKDEPTH 100
@@ -139,17 +139,17 @@ typedef union {
#define ParseCTX_FETCH
#define ParseCTX_STORE
#define YYFALLBACK 1
-#define YYNSTATE 672
-#define YYNRULE 493
-#define YYNTOKEN 306
-#define YY_MAX_SHIFT 671
-#define YY_MIN_SHIFTREDUCE 979
-#define YY_MAX_SHIFTREDUCE 1471
-#define YY_ERROR_ACTION 1472
-#define YY_ACCEPT_ACTION 1473
-#define YY_NO_ACTION 1474
-#define YY_MIN_REDUCE 1475
-#define YY_MAX_REDUCE 1967
+#define YYNSTATE 674
+#define YYNRULE 495
+#define YYNTOKEN 308
+#define YY_MAX_SHIFT 673
+#define YY_MIN_SHIFTREDUCE 983
+#define YY_MAX_SHIFTREDUCE 1477
+#define YY_ERROR_ACTION 1478
+#define YY_ACCEPT_ACTION 1479
+#define YY_NO_ACTION 1480
+#define YY_MIN_REDUCE 1481
+#define YY_MAX_REDUCE 1975
/************* End control #defines *******************************************/
#define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0])))
@@ -216,692 +216,680 @@ typedef union {
** yy_default[] Default action for each state.
**
*********** Begin parsing tables **********************************************/
-#define YY_ACTTAB_COUNT (2522)
+#define YY_ACTTAB_COUNT (2464)
static const YYACTIONTYPE yy_action[] = {
- /* 0 */ 517, 1801, 436, 530, 437, 1510, 379, 326, 1720, 64,
- /* 10 */ 1717, 553, 39, 37, 117, 1606, 444, 553, 437, 1510,
- /* 20 */ 340, 474, 1272, 1475, 40, 38, 36, 35, 34, 1819,
- /* 30 */ 530, 1617, 530, 1348, 1029, 1270, 1028, 582, 553, 127,
- /* 40 */ 556, 55, 1771, 169, 581, 127, 1945, 116, 115, 114,
- /* 50 */ 113, 112, 111, 110, 109, 108, 1343, 558, 1617, 164,
- /* 60 */ 1617, 14, 327, 1942, 1030, 558, 127, 1833, 1278, 1537,
- /* 70 */ 146, 94, 1802, 584, 1804, 1805, 580, 125, 575, 1619,
- /* 80 */ 148, 1879, 1487, 125, 1498, 306, 1875, 1298, 1012, 1281,
- /* 90 */ 1, 555, 160, 1887, 1888, 63, 1892, 1945, 250, 1887,
- /* 100 */ 552, 1669, 551, 345, 125, 1945, 1662, 1664, 328, 150,
- /* 110 */ 166, 1595, 668, 1576, 1942, 453, 1819, 1667, 166, 161,
- /* 120 */ 1887, 1888, 1942, 1892, 546, 1771, 1350, 1351, 1016, 1017,
- /* 130 */ 30, 260, 645, 644, 643, 642, 350, 1476, 641, 640,
- /* 140 */ 128, 635, 634, 633, 632, 631, 630, 629, 139, 625,
- /* 150 */ 624, 623, 349, 348, 620, 619, 618, 628, 107, 1589,
- /* 160 */ 545, 106, 105, 104, 103, 102, 101, 100, 99, 98,
- /* 170 */ 556, 453, 1273, 1894, 1271, 1127, 606, 605, 604, 1131,
- /* 180 */ 603, 1133, 1134, 602, 1136, 599, 542, 1142, 596, 1144,
- /* 190 */ 1145, 593, 590, 1169, 1170, 1276, 1277, 1891, 1325, 1326,
- /* 200 */ 1328, 1329, 1330, 1331, 1332, 1333, 577, 573, 1341, 1342,
- /* 210 */ 1344, 1345, 1346, 1347, 1349, 1352, 39, 37, 1411, 1945,
- /* 220 */ 1789, 302, 158, 1295, 340, 1801, 1272, 222, 1284, 167,
- /* 230 */ 415, 1785, 1944, 427, 167, 1656, 1942, 1348, 107, 1270,
- /* 240 */ 43, 106, 105, 104, 103, 102, 101, 100, 99, 98,
- /* 250 */ 400, 556, 428, 1819, 402, 1781, 1787, 329, 74, 1297,
- /* 260 */ 1343, 582, 1298, 548, 543, 14, 1771, 575, 581, 33,
- /* 270 */ 32, 122, 1278, 40, 38, 36, 35, 34, 33, 32,
- /* 280 */ 1612, 217, 40, 38, 36, 35, 34, 1252, 1253, 1297,
- /* 290 */ 1945, 1833, 393, 91, 2, 95, 1802, 584, 1804, 1805,
- /* 300 */ 580, 63, 575, 165, 389, 1879, 124, 1942, 547, 331,
- /* 310 */ 1875, 1958, 1663, 1664, 1609, 63, 668, 78, 33, 32,
- /* 320 */ 1913, 42, 40, 38, 36, 35, 34, 441, 1432, 63,
- /* 330 */ 1350, 1351, 426, 1295, 63, 421, 420, 419, 418, 417,
- /* 340 */ 414, 413, 412, 411, 410, 406, 405, 404, 403, 397,
- /* 350 */ 396, 395, 394, 22, 391, 390, 314, 483, 482, 33,
- /* 360 */ 32, 1442, 61, 40, 38, 36, 35, 34, 1029, 530,
- /* 370 */ 1028, 539, 1430, 1431, 1433, 1434, 1273, 1710, 1271, 26,
- /* 380 */ 117, 1296, 378, 472, 377, 33, 32, 479, 172, 40,
- /* 390 */ 38, 36, 35, 34, 223, 224, 553, 1617, 1030, 1276,
- /* 400 */ 1277, 173, 1325, 1326, 1328, 1329, 1330, 1331, 1332, 1333,
- /* 410 */ 577, 573, 1341, 1342, 1344, 1345, 1346, 1347, 1349, 1352,
- /* 420 */ 39, 37, 1801, 491, 127, 1468, 615, 609, 340, 1593,
- /* 430 */ 1272, 36, 35, 34, 71, 1894, 435, 70, 501, 439,
- /* 440 */ 167, 1348, 1422, 1270, 1801, 137, 136, 612, 611, 610,
- /* 450 */ 1819, 422, 209, 305, 167, 1415, 520, 49, 582, 1890,
- /* 460 */ 167, 1297, 125, 1771, 1343, 581, 494, 1669, 167, 14,
- /* 470 */ 488, 500, 1819, 167, 344, 208, 1278, 162, 1887, 1888,
- /* 480 */ 582, 1892, 1473, 1667, 498, 1771, 496, 581, 1833, 617,
- /* 490 */ 1789, 1758, 96, 1802, 584, 1804, 1805, 580, 2, 575,
- /* 500 */ 558, 1785, 1879, 617, 177, 176, 1878, 1875, 58, 1089,
- /* 510 */ 1833, 57, 1467, 374, 94, 1802, 584, 1804, 1805, 580,
- /* 520 */ 668, 575, 343, 1602, 1879, 1781, 1787, 335, 306, 1875,
- /* 530 */ 146, 1497, 376, 372, 1350, 1351, 385, 575, 362, 1619,
- /* 540 */ 1945, 355, 1091, 1278, 33, 32, 1945, 74, 40, 38,
- /* 550 */ 36, 35, 34, 164, 28, 443, 1358, 1942, 439, 1943,
- /* 560 */ 33, 32, 1297, 1942, 40, 38, 36, 35, 34, 1613,
- /* 570 */ 33, 32, 1771, 303, 40, 38, 36, 35, 34, 1299,
- /* 580 */ 1273, 1945, 1271, 33, 32, 11, 10, 40, 38, 36,
- /* 590 */ 35, 34, 317, 627, 164, 1496, 167, 307, 1942, 516,
- /* 600 */ 1495, 562, 210, 1276, 1277, 560, 1325, 1326, 1328, 1329,
- /* 610 */ 1330, 1331, 1332, 1333, 577, 573, 1341, 1342, 1344, 1345,
- /* 620 */ 1346, 1347, 1349, 1352, 39, 37, 1801, 1310, 1604, 346,
- /* 630 */ 1272, 353, 340, 1372, 1272, 1370, 1771, 146, 1710, 1945,
- /* 640 */ 1327, 1771, 1801, 1270, 1594, 1348, 1619, 1270, 318, 175,
- /* 650 */ 316, 315, 164, 476, 1819, 255, 1942, 478, 1669, 76,
- /* 660 */ 305, 530, 582, 520, 639, 637, 1310, 1771, 1343, 581,
- /* 670 */ 1819, 1945, 383, 84, 1668, 1384, 1278, 1592, 557, 477,
- /* 680 */ 1278, 517, 1494, 1771, 164, 581, 1016, 1017, 1942, 1617,
- /* 690 */ 1371, 1718, 1833, 1600, 1610, 27, 96, 1802, 584, 1804,
- /* 700 */ 1805, 580, 8, 575, 1493, 1377, 1879, 1540, 1833, 1492,
- /* 710 */ 569, 1875, 95, 1802, 584, 1804, 1805, 580, 252, 575,
- /* 720 */ 668, 145, 1879, 1771, 668, 1300, 331, 1875, 159, 33,
- /* 730 */ 32, 7, 1491, 40, 38, 36, 35, 34, 1350, 1351,
- /* 740 */ 163, 1327, 146, 1408, 1490, 1771, 615, 1716, 1905, 300,
- /* 750 */ 1771, 1620, 29, 338, 1365, 1366, 1367, 1368, 1369, 1373,
- /* 760 */ 1374, 1375, 1376, 530, 1489, 137, 136, 612, 611, 610,
- /* 770 */ 1297, 486, 485, 1771, 384, 1715, 1669, 300, 123, 615,
- /* 780 */ 1273, 509, 1271, 312, 1273, 1771, 1271, 90, 481, 484,
- /* 790 */ 1486, 1617, 1667, 1485, 480, 1899, 1404, 87, 137, 136,
- /* 800 */ 612, 611, 610, 1276, 1277, 1771, 563, 1276, 1277, 1484,
- /* 810 */ 1325, 1326, 1328, 1329, 1330, 1331, 1332, 1333, 577, 573,
- /* 820 */ 1341, 1342, 1344, 1345, 1346, 1347, 1349, 1352, 39, 37,
- /* 830 */ 1353, 1771, 1483, 213, 1771, 1894, 340, 530, 1272, 1801,
- /* 840 */ 565, 167, 1608, 530, 1945, 486, 485, 352, 392, 1348,
- /* 850 */ 1771, 1270, 123, 1785, 407, 1790, 1482, 165, 530, 1889,
- /* 860 */ 1801, 1942, 481, 484, 232, 1617, 1785, 1819, 480, 408,
- /* 870 */ 530, 1617, 1343, 1771, 1481, 557, 1480, 1781, 1787, 1488,
- /* 880 */ 1771, 451, 581, 1577, 1278, 540, 1617, 1945, 1819, 575,
- /* 890 */ 1781, 1787, 613, 44, 4, 1660, 579, 1771, 1617, 1479,
- /* 900 */ 164, 1771, 575, 581, 1942, 1833, 9, 1478, 576, 95,
- /* 910 */ 1802, 584, 1804, 1805, 580, 1771, 575, 1771, 614, 1879,
- /* 920 */ 1404, 1660, 471, 331, 1875, 159, 1833, 1801, 668, 478,
- /* 930 */ 293, 1802, 584, 1804, 1805, 580, 578, 575, 572, 1851,
- /* 940 */ 1771, 272, 1350, 1351, 1647, 1906, 244, 135, 1771, 1327,
- /* 950 */ 530, 477, 33, 32, 386, 1819, 40, 38, 36, 35,
- /* 960 */ 34, 452, 201, 582, 608, 199, 530, 387, 1771, 1407,
- /* 970 */ 581, 203, 1820, 205, 202, 530, 204, 1614, 1617, 207,
- /* 980 */ 351, 530, 206, 53, 513, 530, 503, 571, 1273, 1280,
- /* 990 */ 1271, 1511, 510, 1833, 1617, 54, 514, 289, 1802, 584,
- /* 1000 */ 1804, 1805, 580, 1617, 575, 307, 11, 10, 1801, 1617,
- /* 1010 */ 502, 1276, 1277, 1617, 1325, 1326, 1328, 1329, 1330, 1331,
- /* 1020 */ 1332, 1333, 577, 573, 1341, 1342, 1344, 1345, 1346, 1347,
- /* 1030 */ 1349, 1352, 39, 37, 1801, 549, 1819, 530, 1527, 1522,
- /* 1040 */ 340, 1516, 1272, 1370, 582, 530, 1520, 566, 227, 1771,
- /* 1050 */ 1945, 581, 1792, 1348, 216, 1270, 526, 1657, 530, 1056,
- /* 1060 */ 487, 489, 1819, 164, 1909, 1617, 554, 1942, 492, 528,
- /* 1070 */ 582, 1470, 1471, 1617, 1833, 1771, 1343, 581, 149, 1802,
- /* 1080 */ 584, 1804, 1805, 580, 530, 575, 1617, 41, 1278, 663,
- /* 1090 */ 77, 249, 1057, 221, 131, 529, 1794, 134, 1371, 254,
- /* 1100 */ 1833, 257, 530, 671, 95, 1802, 584, 1804, 1805, 580,
- /* 1110 */ 9, 575, 1617, 261, 1879, 259, 530, 267, 331, 1875,
- /* 1120 */ 1958, 1362, 559, 1959, 135, 3, 51, 347, 1283, 1936,
- /* 1130 */ 1617, 156, 668, 621, 236, 1223, 661, 657, 653, 649,
- /* 1140 */ 265, 225, 523, 5, 1617, 229, 1350, 1351, 51, 41,
- /* 1150 */ 41, 588, 134, 135, 119, 1075, 134, 356, 622, 313,
- /* 1160 */ 29, 338, 1365, 1366, 1367, 1368, 1369, 1373, 1374, 1375,
- /* 1170 */ 1376, 361, 1120, 92, 1429, 268, 230, 1239, 174, 388,
- /* 1180 */ 1073, 1295, 239, 409, 1712, 416, 423, 424, 425, 429,
- /* 1190 */ 431, 433, 1273, 1301, 1271, 434, 1378, 1334, 271, 1148,
- /* 1200 */ 1152, 1159, 1157, 442, 138, 1303, 445, 183, 446, 527,
- /* 1210 */ 185, 1801, 1302, 447, 1304, 1276, 1277, 188, 1325, 1326,
- /* 1220 */ 1328, 1329, 1330, 1331, 1332, 1333, 577, 573, 1341, 1342,
- /* 1230 */ 1344, 1345, 1346, 1347, 1349, 1352, 39, 37, 190, 1819,
- /* 1240 */ 450, 448, 219, 72, 340, 73, 1272, 582, 454, 194,
- /* 1250 */ 473, 475, 1771, 1607, 581, 198, 1603, 1348, 200, 1270,
- /* 1260 */ 1246, 304, 212, 118, 140, 1751, 141, 1605, 269, 504,
- /* 1270 */ 1601, 142, 143, 505, 211, 508, 214, 1833, 511, 515,
- /* 1280 */ 1343, 96, 1802, 584, 1804, 1805, 580, 218, 575, 323,
- /* 1290 */ 518, 1879, 1278, 538, 524, 81, 1876, 132, 1750, 147,
- /* 1300 */ 525, 1722, 521, 133, 278, 337, 336, 270, 325, 83,
- /* 1310 */ 1618, 1300, 541, 534, 2, 1286, 1910, 1920, 276, 60,
- /* 1320 */ 234, 536, 59, 537, 1919, 330, 1348, 238, 1279, 544,
- /* 1330 */ 6, 550, 532, 535, 1901, 1299, 668, 533, 180, 432,
- /* 1340 */ 430, 1801, 248, 1404, 126, 567, 564, 153, 48, 1343,
- /* 1350 */ 1350, 1351, 85, 332, 243, 1895, 586, 245, 246, 1661,
- /* 1360 */ 273, 1278, 1590, 664, 247, 665, 264, 667, 52, 1819,
- /* 1370 */ 277, 63, 1860, 253, 324, 299, 286, 582, 275, 296,
- /* 1380 */ 1941, 1765, 1771, 295, 581, 1764, 65, 561, 1763, 1762,
- /* 1390 */ 1961, 568, 256, 66, 1759, 358, 1273, 258, 1271, 359,
- /* 1400 */ 1264, 1265, 170, 363, 1757, 570, 365, 1833, 366, 93,
- /* 1410 */ 367, 294, 1802, 584, 1804, 1805, 580, 1756, 575, 1276,
- /* 1420 */ 1277, 1801, 1325, 1326, 1328, 1329, 1330, 1331, 1332, 1333,
- /* 1430 */ 577, 573, 1341, 1342, 1344, 1345, 1346, 1347, 1349, 1352,
- /* 1440 */ 369, 1755, 1801, 371, 1754, 68, 67, 382, 373, 1819,
- /* 1450 */ 171, 1753, 1242, 375, 531, 1241, 1733, 582, 380, 381,
- /* 1460 */ 1731, 1730, 1771, 1732, 581, 1287, 301, 1282, 1211, 370,
- /* 1470 */ 1819, 368, 364, 360, 357, 354, 129, 1702, 582, 1705,
- /* 1480 */ 1704, 1703, 1701, 1771, 1700, 581, 69, 1833, 1290, 1292,
- /* 1490 */ 1699, 294, 1802, 584, 1804, 1805, 580, 1698, 575, 1697,
- /* 1500 */ 573, 1341, 1342, 1344, 1345, 1346, 1347, 1696, 1833, 1695,
- /* 1510 */ 167, 1694, 95, 1802, 584, 1804, 1805, 580, 399, 575,
- /* 1520 */ 398, 401, 1879, 1693, 1692, 1801, 331, 1875, 1958, 1691,
- /* 1530 */ 1690, 1689, 1688, 1687, 1686, 1685, 1684, 1898, 1683, 1682,
- /* 1540 */ 1681, 1801, 1680, 130, 1679, 1678, 1677, 1676, 1675, 1674,
- /* 1550 */ 1213, 1673, 1672, 1819, 1671, 1670, 1542, 1541, 178, 179,
- /* 1560 */ 1539, 582, 1507, 181, 120, 157, 1771, 1019, 581, 1819,
- /* 1570 */ 1506, 1746, 1018, 438, 1740, 1729, 189, 582, 1049, 1538,
- /* 1580 */ 121, 558, 1771, 440, 581, 1728, 1714, 1596, 1536, 1534,
- /* 1590 */ 182, 1833, 1532, 1530, 455, 285, 1802, 584, 1804, 1805,
- /* 1600 */ 580, 459, 575, 187, 457, 1519, 461, 1833, 456, 1801,
- /* 1610 */ 460, 149, 1802, 584, 1804, 1805, 580, 463, 575, 464,
- /* 1620 */ 465, 1945, 469, 468, 1518, 1801, 467, 1503, 1598, 1163,
- /* 1630 */ 1162, 1597, 1088, 1087, 166, 1082, 1084, 1819, 1942, 636,
- /* 1640 */ 1528, 1083, 50, 638, 319, 582, 1523, 320, 490, 1521,
- /* 1650 */ 1771, 321, 581, 1819, 493, 1502, 1960, 1501, 495, 1500,
- /* 1660 */ 1745, 579, 97, 499, 56, 558, 1771, 497, 581, 1248,
- /* 1670 */ 197, 1739, 506, 144, 507, 1833, 215, 1727, 1725, 285,
- /* 1680 */ 1802, 584, 1804, 1805, 580, 1726, 575, 1801, 1256, 1721,
- /* 1690 */ 519, 1833, 1724, 1723, 15, 293, 1802, 584, 1804, 1805,
- /* 1700 */ 580, 220, 575, 1713, 1852, 1945, 1801, 226, 79, 80,
- /* 1710 */ 82, 87, 231, 242, 1792, 1819, 41, 47, 164, 16,
- /* 1720 */ 339, 1444, 1942, 582, 235, 23, 522, 322, 1771, 233,
- /* 1730 */ 581, 45, 251, 237, 1819, 228, 1426, 151, 512, 341,
- /* 1740 */ 241, 240, 582, 1428, 24, 25, 86, 1771, 1456, 581,
- /* 1750 */ 17, 46, 1421, 1833, 1401, 1400, 1791, 294, 1802, 584,
- /* 1760 */ 1804, 1805, 580, 154, 575, 18, 1461, 1801, 196, 1455,
- /* 1770 */ 1450, 333, 1833, 1460, 1459, 334, 294, 1802, 584, 1804,
- /* 1780 */ 1805, 580, 152, 575, 553, 1801, 1288, 470, 466, 462,
- /* 1790 */ 458, 195, 10, 19, 1836, 1819, 574, 1363, 1338, 155,
- /* 1800 */ 1336, 31, 12, 582, 168, 1335, 20, 1318, 1771, 583,
- /* 1810 */ 581, 21, 127, 1819, 1149, 587, 585, 13, 342, 589,
- /* 1820 */ 592, 582, 1146, 591, 75, 1126, 1771, 193, 581, 594,
- /* 1830 */ 597, 595, 558, 1833, 1143, 1801, 1137, 279, 1802, 584,
- /* 1840 */ 1804, 1805, 580, 1135, 575, 598, 600, 601, 607, 1158,
- /* 1850 */ 125, 1833, 88, 89, 1154, 280, 1802, 584, 1804, 1805,
- /* 1860 */ 580, 1141, 575, 1819, 62, 250, 1887, 552, 1140, 551,
- /* 1870 */ 1139, 582, 1945, 1138, 262, 1047, 1771, 616, 581, 1079,
- /* 1880 */ 1078, 1077, 1076, 1074, 1072, 164, 1071, 1801, 1070, 1942,
- /* 1890 */ 192, 186, 1095, 191, 626, 1068, 1067, 449, 263, 1066,
- /* 1900 */ 1065, 1833, 1064, 1063, 1062, 281, 1802, 584, 1804, 1805,
- /* 1910 */ 580, 1092, 575, 184, 1090, 1819, 1059, 1058, 1055, 1054,
- /* 1920 */ 1053, 1052, 1535, 582, 646, 647, 648, 1533, 1771, 650,
- /* 1930 */ 581, 1531, 651, 1529, 652, 1801, 654, 655, 656, 658,
- /* 1940 */ 659, 660, 1517, 662, 1009, 1499, 266, 1801, 1274, 666,
- /* 1950 */ 670, 274, 1474, 1833, 1474, 669, 1474, 288, 1802, 584,
- /* 1960 */ 1804, 1805, 580, 1819, 575, 1474, 1474, 1474, 1474, 1474,
- /* 1970 */ 1474, 582, 1474, 1474, 1474, 1819, 1771, 1474, 581, 1474,
- /* 1980 */ 1474, 1474, 1474, 582, 1474, 1474, 1474, 1474, 1771, 1474,
- /* 1990 */ 581, 1474, 1474, 1474, 1474, 1474, 1474, 1801, 1474, 1474,
- /* 2000 */ 1474, 1833, 1474, 1474, 1474, 290, 1802, 584, 1804, 1805,
- /* 2010 */ 580, 1474, 575, 1833, 1801, 1474, 1474, 282, 1802, 584,
- /* 2020 */ 1804, 1805, 580, 1474, 575, 1819, 1474, 1474, 1474, 1474,
- /* 2030 */ 1474, 1474, 1474, 582, 1474, 1474, 1474, 1474, 1771, 1474,
- /* 2040 */ 581, 1474, 1819, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2050 */ 582, 1474, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474,
- /* 2060 */ 1474, 1474, 1474, 1833, 1474, 1474, 1474, 291, 1802, 584,
- /* 2070 */ 1804, 1805, 580, 1474, 575, 1474, 1474, 1801, 1474, 1474,
- /* 2080 */ 1833, 1474, 1474, 1474, 283, 1802, 584, 1804, 1805, 580,
- /* 2090 */ 1474, 575, 1474, 1801, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2100 */ 1474, 1474, 1474, 1474, 1474, 1819, 1474, 1474, 1474, 1474,
- /* 2110 */ 1474, 1474, 1474, 582, 1474, 1474, 1474, 1474, 1771, 1474,
- /* 2120 */ 581, 1819, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 582,
- /* 2130 */ 1474, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474, 1474,
- /* 2140 */ 1474, 1474, 1474, 1833, 1474, 1801, 1474, 292, 1802, 584,
- /* 2150 */ 1804, 1805, 580, 1474, 575, 1474, 1474, 1474, 1474, 1833,
- /* 2160 */ 1474, 1801, 1474, 284, 1802, 584, 1804, 1805, 580, 1474,
- /* 2170 */ 575, 1474, 1474, 1819, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2180 */ 1474, 582, 1474, 1474, 1474, 1474, 1771, 1474, 581, 1819,
- /* 2190 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 582, 1474, 1474,
- /* 2200 */ 1474, 1801, 1771, 1474, 581, 1474, 1474, 1474, 1474, 1474,
- /* 2210 */ 1474, 1833, 1474, 1474, 1474, 297, 1802, 584, 1804, 1805,
- /* 2220 */ 580, 1474, 575, 1801, 1474, 1474, 1474, 1833, 1474, 1819,
- /* 2230 */ 1474, 298, 1802, 584, 1804, 1805, 580, 582, 575, 1474,
- /* 2240 */ 1474, 1474, 1771, 1474, 581, 1474, 1474, 1474, 1474, 1474,
- /* 2250 */ 1474, 1819, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 582,
- /* 2260 */ 1474, 1474, 1474, 1801, 1771, 1474, 581, 1833, 1474, 1474,
- /* 2270 */ 1474, 1813, 1802, 584, 1804, 1805, 580, 1474, 575, 1474,
- /* 2280 */ 1474, 1801, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1833,
- /* 2290 */ 1474, 1819, 1474, 1812, 1802, 584, 1804, 1805, 580, 582,
- /* 2300 */ 575, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474, 1819,
- /* 2310 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 582, 1474, 1474,
- /* 2320 */ 1474, 1474, 1771, 1474, 581, 1474, 1474, 1474, 1474, 1833,
- /* 2330 */ 1474, 1801, 1474, 1811, 1802, 584, 1804, 1805, 580, 1474,
- /* 2340 */ 575, 1474, 1474, 1801, 1474, 1474, 1474, 1833, 1474, 1474,
- /* 2350 */ 1474, 310, 1802, 584, 1804, 1805, 580, 1474, 575, 1819,
- /* 2360 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 582, 1474, 1474,
- /* 2370 */ 1474, 1819, 1771, 1474, 581, 1474, 1474, 1474, 1474, 582,
- /* 2380 */ 1474, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474, 1474,
- /* 2390 */ 1474, 1474, 1474, 1474, 1801, 1474, 1474, 1833, 1474, 1474,
- /* 2400 */ 1474, 309, 1802, 584, 1804, 1805, 580, 1474, 575, 1833,
- /* 2410 */ 1474, 1474, 1474, 311, 1802, 584, 1804, 1805, 580, 1474,
- /* 2420 */ 575, 1474, 1819, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2430 */ 582, 1474, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474,
- /* 2440 */ 1474, 1474, 1474, 1474, 1801, 1474, 1474, 1474, 1474, 1474,
- /* 2450 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2460 */ 1833, 1474, 1474, 1474, 308, 1802, 584, 1804, 1805, 580,
- /* 2470 */ 1474, 575, 1819, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2480 */ 582, 1474, 1474, 1474, 1474, 1771, 1474, 581, 1474, 1474,
- /* 2490 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2500 */ 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474, 1474,
- /* 2510 */ 1833, 1474, 1474, 1474, 287, 1802, 584, 1804, 1805, 580,
- /* 2520 */ 1474, 575,
+ /* 0 */ 436, 379, 437, 1516, 1809, 91, 516, 444, 1616, 437,
+ /* 10 */ 1516, 1614, 39, 37, 553, 64, 30, 260, 124, 1793,
+ /* 20 */ 340, 1953, 1278, 33, 32, 1016, 1617, 40, 38, 36,
+ /* 30 */ 35, 34, 1827, 1354, 1952, 1276, 385, 148, 1950, 1493,
+ /* 40 */ 582, 1953, 127, 1789, 1795, 1779, 1953, 581, 40, 38,
+ /* 50 */ 36, 35, 34, 556, 164, 575, 1349, 517, 1950, 164,
+ /* 60 */ 558, 14, 558, 1950, 326, 1020, 1021, 1725, 1284, 1543,
+ /* 70 */ 1841, 1304, 74, 303, 94, 1810, 584, 1812, 1813, 580,
+ /* 80 */ 125, 575, 1504, 173, 1887, 122, 217, 345, 306, 1883,
+ /* 90 */ 1670, 1672, 1, 556, 1620, 250, 1895, 552, 63, 551,
+ /* 100 */ 1953, 107, 1953, 63, 106, 105, 104, 103, 102, 101,
+ /* 110 */ 100, 99, 98, 166, 670, 166, 453, 1950, 71, 1950,
+ /* 120 */ 1421, 70, 63, 1779, 78, 42, 1303, 1303, 1356, 1357,
+ /* 130 */ 11, 10, 647, 646, 645, 644, 350, 1503, 643, 642,
+ /* 140 */ 128, 637, 636, 635, 634, 633, 632, 631, 139, 627,
+ /* 150 */ 626, 625, 349, 348, 622, 621, 620, 619, 618, 530,
+ /* 160 */ 500, 33, 32, 196, 1481, 40, 38, 36, 35, 34,
+ /* 170 */ 55, 223, 224, 498, 1279, 496, 1277, 152, 1779, 1175,
+ /* 180 */ 1176, 1474, 470, 466, 462, 458, 195, 1625, 116, 115,
+ /* 190 */ 114, 113, 112, 111, 110, 109, 108, 1282, 1283, 63,
+ /* 200 */ 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, 577, 573,
+ /* 210 */ 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358, 39, 37,
+ /* 220 */ 1417, 75, 1390, 302, 193, 1301, 340, 84, 1278, 1809,
+ /* 230 */ 305, 167, 415, 520, 1953, 427, 353, 167, 530, 1354,
+ /* 240 */ 542, 1276, 167, 1677, 1798, 553, 1448, 165, 1618, 169,
+ /* 250 */ 328, 1950, 400, 1677, 428, 1793, 402, 1827, 1953, 1675,
+ /* 260 */ 344, 167, 1349, 1304, 167, 582, 1625, 14, 1473, 1675,
+ /* 270 */ 1779, 1951, 581, 127, 1284, 1950, 1953, 33, 32, 1789,
+ /* 280 */ 1795, 40, 38, 36, 35, 34, 1797, 192, 186, 164,
+ /* 290 */ 191, 575, 49, 1950, 449, 1841, 393, 1793, 2, 95,
+ /* 300 */ 1810, 584, 1812, 1813, 580, 1303, 575, 1333, 389, 1887,
+ /* 310 */ 184, 125, 22, 331, 1883, 1966, 556, 548, 543, 158,
+ /* 320 */ 670, 1789, 1795, 329, 1921, 555, 160, 1895, 1896, 1724,
+ /* 330 */ 1900, 300, 1664, 575, 1356, 1357, 426, 1479, 167, 421,
+ /* 340 */ 420, 419, 418, 417, 414, 413, 412, 411, 410, 406,
+ /* 350 */ 405, 404, 403, 397, 396, 395, 394, 1522, 391, 390,
+ /* 360 */ 314, 1902, 1133, 606, 605, 604, 1137, 603, 1139, 1140,
+ /* 370 */ 602, 1142, 599, 530, 1148, 596, 1150, 1151, 593, 590,
+ /* 380 */ 1279, 327, 1277, 317, 383, 1899, 33, 32, 43, 146,
+ /* 390 */ 40, 38, 36, 35, 34, 150, 355, 547, 1627, 1584,
+ /* 400 */ 1033, 1625, 1032, 1282, 1283, 665, 1331, 1332, 1334, 1335,
+ /* 410 */ 1336, 1337, 1338, 1339, 577, 573, 1347, 1348, 1350, 1351,
+ /* 420 */ 1352, 1353, 1355, 1358, 39, 37, 1809, 491, 1671, 1672,
+ /* 430 */ 1034, 167, 340, 1723, 1278, 300, 1953, 1302, 36, 35,
+ /* 440 */ 34, 318, 501, 316, 315, 1354, 476, 1276, 1677, 164,
+ /* 450 */ 478, 1305, 222, 1950, 1827, 312, 209, 1602, 486, 485,
+ /* 460 */ 1364, 1603, 582, 617, 1675, 123, 1303, 1779, 1349, 581,
+ /* 470 */ 494, 1428, 477, 14, 488, 481, 484, 26, 343, 208,
+ /* 480 */ 1284, 480, 558, 33, 32, 346, 146, 40, 38, 36,
+ /* 490 */ 35, 34, 1841, 146, 7, 1627, 94, 1810, 584, 1812,
+ /* 500 */ 1813, 580, 1627, 575, 2, 609, 1887, 1378, 553, 530,
+ /* 510 */ 306, 1883, 1258, 1259, 58, 435, 1953, 57, 439, 1502,
+ /* 520 */ 117, 453, 1953, 147, 1827, 63, 670, 474, 278, 165,
+ /* 530 */ 1809, 1501, 546, 1950, 374, 164, 127, 1625, 28, 1950,
+ /* 540 */ 1356, 1357, 276, 60, 33, 32, 59, 1284, 40, 38,
+ /* 550 */ 36, 35, 34, 376, 372, 337, 336, 1500, 1827, 530,
+ /* 560 */ 1779, 615, 180, 432, 430, 1292, 582, 1728, 545, 27,
+ /* 570 */ 117, 1779, 1779, 581, 125, 517, 1354, 479, 1285, 1383,
+ /* 580 */ 137, 136, 612, 611, 610, 1726, 1279, 1625, 1277, 161,
+ /* 590 */ 1895, 1896, 252, 1900, 629, 1499, 1841, 63, 1779, 1349,
+ /* 600 */ 149, 1810, 584, 1812, 1813, 580, 378, 575, 377, 1282,
+ /* 610 */ 1283, 1284, 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339,
+ /* 620 */ 577, 573, 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358,
+ /* 630 */ 39, 37, 1902, 1278, 1498, 93, 1779, 1497, 340, 630,
+ /* 640 */ 1278, 1597, 441, 1601, 559, 1967, 1276, 1333, 1301, 1610,
+ /* 650 */ 1033, 1354, 1032, 1276, 33, 32, 1898, 570, 40, 38,
+ /* 660 */ 36, 35, 34, 1546, 167, 472, 443, 352, 1612, 439,
+ /* 670 */ 1496, 68, 67, 382, 1349, 1779, 171, 1608, 1779, 1284,
+ /* 680 */ 1034, 210, 1495, 33, 32, 1410, 1284, 40, 38, 36,
+ /* 690 */ 35, 34, 301, 530, 1809, 370, 74, 368, 364, 360,
+ /* 700 */ 357, 354, 1492, 617, 384, 1020, 1021, 1953, 33, 32,
+ /* 710 */ 8, 1779, 40, 38, 36, 35, 34, 1293, 1621, 1288,
+ /* 720 */ 164, 1625, 1827, 1779, 1950, 670, 213, 486, 485, 1491,
+ /* 730 */ 557, 1490, 670, 502, 123, 1779, 167, 581, 76, 305,
+ /* 740 */ 1296, 1298, 520, 1779, 481, 484, 1356, 1357, 1489, 1095,
+ /* 750 */ 480, 1902, 573, 1347, 1348, 1350, 1351, 1352, 1353, 1438,
+ /* 760 */ 1841, 307, 1907, 1410, 95, 1810, 584, 1812, 1813, 580,
+ /* 770 */ 1779, 575, 1779, 1953, 1887, 1897, 615, 1718, 331, 1883,
+ /* 780 */ 159, 1414, 1097, 483, 482, 1279, 164, 1277, 172, 1779,
+ /* 790 */ 1950, 478, 1279, 1316, 1277, 137, 136, 612, 611, 610,
+ /* 800 */ 1914, 1376, 539, 1436, 1437, 1439, 1440, 145, 1282, 1283,
+ /* 810 */ 1488, 1809, 1487, 477, 1486, 1282, 1283, 1306, 1331, 1332,
+ /* 820 */ 1334, 1335, 1336, 1337, 1338, 1339, 577, 573, 1347, 1348,
+ /* 830 */ 1350, 1351, 1352, 1353, 1355, 1358, 39, 37, 1359, 1827,
+ /* 840 */ 1482, 146, 422, 509, 340, 1060, 1278, 582, 1485, 167,
+ /* 850 */ 1628, 1779, 1779, 1779, 581, 1779, 1377, 1354, 1484, 1276,
+ /* 860 */ 1677, 107, 1718, 61, 106, 105, 104, 103, 102, 101,
+ /* 870 */ 100, 99, 98, 175, 641, 639, 1676, 1841, 1061, 1303,
+ /* 880 */ 1349, 96, 1810, 584, 1812, 1813, 580, 613, 575, 1779,
+ /* 890 */ 1668, 1887, 1284, 44, 4, 1886, 1883, 177, 176, 1779,
+ /* 900 */ 614, 33, 32, 1668, 1797, 40, 38, 36, 35, 34,
+ /* 910 */ 272, 135, 576, 1655, 1809, 1793, 9, 1766, 29, 338,
+ /* 920 */ 1371, 1372, 1373, 1374, 1375, 1379, 1380, 1381, 1382, 33,
+ /* 930 */ 32, 1809, 530, 40, 38, 36, 35, 34, 670, 1789,
+ /* 940 */ 1795, 335, 1827, 392, 562, 530, 608, 324, 1533, 386,
+ /* 950 */ 582, 575, 1356, 1357, 307, 1779, 407, 581, 232, 1827,
+ /* 960 */ 1625, 54, 387, 201, 362, 203, 199, 582, 202, 1494,
+ /* 970 */ 487, 530, 1779, 1625, 581, 53, 513, 11, 10, 530,
+ /* 980 */ 1841, 216, 408, 565, 294, 1810, 584, 1812, 1813, 580,
+ /* 990 */ 451, 575, 553, 205, 1376, 1528, 204, 1841, 1279, 1625,
+ /* 1000 */ 1277, 96, 1810, 584, 1812, 1813, 580, 1625, 575, 1413,
+ /* 1010 */ 207, 1887, 41, 206, 1316, 569, 1883, 489, 255, 77,
+ /* 1020 */ 127, 1282, 1283, 1526, 1331, 1332, 1334, 1335, 1336, 1337,
+ /* 1030 */ 1338, 1339, 577, 573, 1347, 1348, 1350, 1351, 1352, 1353,
+ /* 1040 */ 1355, 1358, 39, 37, 530, 492, 221, 1585, 530, 1377,
+ /* 1050 */ 340, 131, 1278, 134, 673, 452, 530, 1287, 125, 1622,
+ /* 1060 */ 1333, 471, 1229, 1354, 1809, 1276, 1286, 503, 267, 1476,
+ /* 1070 */ 1477, 540, 1625, 162, 1895, 1896, 1625, 1900, 571, 1800,
+ /* 1080 */ 623, 135, 156, 51, 1625, 90, 1349, 663, 659, 655,
+ /* 1090 */ 651, 265, 1827, 1600, 244, 87, 225, 531, 1284, 530,
+ /* 1100 */ 582, 523, 1079, 229, 1809, 1779, 236, 581, 560, 1828,
+ /* 1110 */ 510, 29, 338, 1371, 1372, 1373, 1374, 1375, 1379, 1380,
+ /* 1120 */ 1381, 1382, 9, 41, 624, 1802, 92, 1625, 351, 230,
+ /* 1130 */ 1841, 1126, 1827, 1435, 294, 1810, 584, 1812, 1813, 580,
+ /* 1140 */ 557, 575, 1665, 51, 670, 1779, 1077, 581, 1517, 41,
+ /* 1150 */ 588, 563, 530, 1917, 530, 530, 239, 530, 1356, 1357,
+ /* 1160 */ 554, 134, 527, 514, 249, 227, 526, 254, 528, 257,
+ /* 1170 */ 1841, 135, 259, 271, 95, 1810, 584, 1812, 1813, 580,
+ /* 1180 */ 1625, 575, 1625, 1625, 1887, 1625, 3, 5, 331, 1883,
+ /* 1190 */ 159, 356, 566, 1384, 361, 219, 313, 615, 1290, 1340,
+ /* 1200 */ 1154, 530, 163, 119, 1279, 134, 1277, 1289, 1245, 174,
+ /* 1210 */ 1913, 1158, 529, 1252, 1368, 212, 137, 136, 612, 611,
+ /* 1220 */ 610, 1165, 268, 388, 1301, 409, 1720, 1282, 1283, 1625,
+ /* 1230 */ 1331, 1332, 1334, 1335, 1336, 1337, 1338, 1339, 577, 573,
+ /* 1240 */ 1347, 1348, 1350, 1351, 1352, 1353, 1355, 1358, 39, 37,
+ /* 1250 */ 1809, 530, 530, 1163, 416, 138, 340, 424, 1278, 423,
+ /* 1260 */ 425, 429, 261, 347, 431, 433, 1307, 1309, 434, 1354,
+ /* 1270 */ 442, 1276, 445, 183, 446, 185, 1308, 447, 1827, 1625,
+ /* 1280 */ 1625, 1310, 188, 448, 450, 190, 582, 72, 73, 454,
+ /* 1290 */ 194, 1779, 1349, 581, 473, 475, 118, 1615, 304, 198,
+ /* 1300 */ 1611, 1759, 200, 269, 1284, 140, 504, 141, 211, 505,
+ /* 1310 */ 1809, 1613, 1609, 142, 143, 214, 1841, 511, 218, 515,
+ /* 1320 */ 95, 1810, 584, 1812, 1813, 580, 553, 575, 2, 538,
+ /* 1330 */ 1887, 524, 508, 81, 331, 1883, 1966, 323, 1827, 83,
+ /* 1340 */ 518, 132, 1758, 1730, 521, 1944, 582, 1306, 133, 525,
+ /* 1350 */ 670, 1779, 1626, 581, 127, 270, 325, 1928, 534, 541,
+ /* 1360 */ 1918, 536, 6, 234, 1356, 1357, 537, 330, 544, 1909,
+ /* 1370 */ 550, 535, 533, 238, 558, 532, 1841, 1305, 1410, 126,
+ /* 1380 */ 95, 1810, 584, 1812, 1813, 580, 567, 575, 564, 48,
+ /* 1390 */ 1887, 332, 125, 246, 331, 1883, 1966, 1927, 243, 248,
+ /* 1400 */ 1903, 85, 586, 1669, 1598, 1906, 247, 250, 1895, 552,
+ /* 1410 */ 1279, 551, 1277, 1868, 1953, 153, 273, 264, 666, 667,
+ /* 1420 */ 52, 669, 299, 286, 275, 245, 1809, 164, 296, 1773,
+ /* 1430 */ 277, 1950, 295, 1282, 1283, 65, 1331, 1332, 1334, 1335,
+ /* 1440 */ 1336, 1337, 1338, 1339, 577, 573, 1347, 1348, 1350, 1351,
+ /* 1450 */ 1352, 1353, 1355, 1358, 1827, 1969, 1772, 1949, 1771, 253,
+ /* 1460 */ 1770, 256, 582, 66, 561, 568, 258, 1779, 1767, 581,
+ /* 1470 */ 359, 358, 1270, 1271, 170, 363, 1765, 365, 366, 367,
+ /* 1480 */ 1764, 369, 558, 1763, 371, 1762, 373, 1809, 1761, 375,
+ /* 1490 */ 1248, 1741, 1841, 1247, 1740, 380, 285, 1810, 584, 1812,
+ /* 1500 */ 1813, 580, 381, 575, 1739, 1738, 1713, 1217, 1712, 1711,
+ /* 1510 */ 1710, 129, 1709, 1708, 69, 1827, 1707, 1706, 1705, 1704,
+ /* 1520 */ 1703, 398, 1953, 582, 399, 1702, 401, 1701, 1779, 1700,
+ /* 1530 */ 581, 1699, 1698, 1697, 1696, 166, 1695, 1694, 1693, 1950,
+ /* 1540 */ 1692, 1691, 1690, 558, 1809, 1689, 1688, 1687, 1686, 130,
+ /* 1550 */ 1685, 1684, 1683, 1841, 178, 1547, 179, 285, 1810, 584,
+ /* 1560 */ 1812, 1813, 580, 1682, 575, 1219, 1681, 1680, 1679, 1678,
+ /* 1570 */ 1809, 1548, 1827, 1545, 1513, 1023, 438, 181, 120, 1022,
+ /* 1580 */ 579, 1512, 1754, 1953, 1748, 1779, 1737, 581, 189, 1736,
+ /* 1590 */ 1722, 1604, 157, 1544, 1542, 121, 164, 182, 1827, 440,
+ /* 1600 */ 1950, 187, 1540, 1538, 1536, 455, 582, 456, 1525, 1524,
+ /* 1610 */ 1841, 1779, 459, 581, 293, 1810, 584, 1812, 1813, 580,
+ /* 1620 */ 578, 575, 572, 1859, 457, 460, 1053, 461, 1809, 1509,
+ /* 1630 */ 463, 465, 467, 1606, 464, 469, 1841, 1168, 1605, 97,
+ /* 1640 */ 96, 1810, 584, 1812, 1813, 580, 1809, 575, 468, 1169,
+ /* 1650 */ 1887, 1094, 1093, 638, 640, 1884, 1827, 1090, 197, 50,
+ /* 1660 */ 1089, 1088, 1534, 319, 582, 1529, 320, 490, 1527, 1779,
+ /* 1670 */ 321, 581, 493, 1508, 1827, 1507, 1506, 495, 497, 499,
+ /* 1680 */ 1753, 1254, 582, 56, 1747, 506, 215, 1779, 144, 581,
+ /* 1690 */ 1735, 1733, 1734, 1732, 1841, 1731, 1809, 15, 289, 1810,
+ /* 1700 */ 584, 1812, 1813, 580, 1262, 575, 220, 519, 1729, 1721,
+ /* 1710 */ 80, 45, 1841, 226, 87, 41, 149, 1810, 584, 1812,
+ /* 1720 */ 1813, 580, 1809, 575, 1827, 231, 79, 82, 23, 47,
+ /* 1730 */ 16, 241, 579, 507, 17, 522, 549, 1779, 512, 581,
+ /* 1740 */ 322, 1462, 1450, 233, 242, 235, 1809, 1432, 237, 1800,
+ /* 1750 */ 1827, 1434, 151, 240, 25, 339, 228, 1427, 582, 24,
+ /* 1760 */ 251, 1968, 1841, 1779, 46, 581, 293, 1810, 584, 1812,
+ /* 1770 */ 1813, 580, 1799, 575, 1827, 1860, 1407, 86, 154, 341,
+ /* 1780 */ 1406, 18, 582, 1461, 333, 1466, 1465, 1779, 1841, 581,
+ /* 1790 */ 1467, 334, 294, 1810, 584, 1812, 1813, 580, 1456, 575,
+ /* 1800 */ 10, 1294, 19, 1369, 1809, 1844, 155, 168, 1344, 574,
+ /* 1810 */ 1324, 1342, 1841, 1341, 31, 13, 294, 1810, 584, 1812,
+ /* 1820 */ 1813, 580, 12, 575, 1155, 20, 583, 21, 585, 587,
+ /* 1830 */ 342, 589, 1827, 1152, 591, 592, 594, 1149, 595, 597,
+ /* 1840 */ 582, 600, 1132, 1147, 598, 1779, 1143, 581, 1141, 601,
+ /* 1850 */ 1146, 1164, 1145, 1144, 88, 1809, 89, 62, 607, 1160,
+ /* 1860 */ 262, 1085, 1051, 616, 1084, 1809, 1083, 1082, 1081, 1080,
+ /* 1870 */ 1841, 1078, 628, 1076, 279, 1810, 584, 1812, 1813, 580,
+ /* 1880 */ 1075, 575, 1074, 1827, 1072, 263, 1101, 1071, 1070, 1069,
+ /* 1890 */ 1068, 582, 1067, 1827, 1066, 1098, 1779, 1096, 581, 1063,
+ /* 1900 */ 1062, 582, 1059, 1057, 1058, 1056, 1779, 1541, 581, 648,
+ /* 1910 */ 649, 650, 1539, 652, 654, 1537, 658, 656, 1809, 1535,
+ /* 1920 */ 653, 1841, 660, 657, 662, 280, 1810, 584, 1812, 1813,
+ /* 1930 */ 580, 1841, 575, 661, 1809, 281, 1810, 584, 1812, 1813,
+ /* 1940 */ 580, 1523, 575, 664, 1013, 1505, 1827, 266, 668, 1480,
+ /* 1950 */ 1280, 274, 671, 672, 582, 1480, 1480, 1480, 1809, 1779,
+ /* 1960 */ 1480, 581, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 1970 */ 582, 1480, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480,
+ /* 1980 */ 1480, 1480, 1480, 1480, 1841, 1480, 1827, 1480, 288, 1810,
+ /* 1990 */ 584, 1812, 1813, 580, 582, 575, 1480, 1480, 1480, 1779,
+ /* 2000 */ 1841, 581, 1480, 1480, 290, 1810, 584, 1812, 1813, 580,
+ /* 2010 */ 1809, 575, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2020 */ 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480, 282, 1810,
+ /* 2030 */ 584, 1812, 1813, 580, 1809, 575, 1480, 1480, 1827, 1480,
+ /* 2040 */ 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480,
+ /* 2050 */ 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480, 1809, 1480,
+ /* 2060 */ 1480, 1480, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2070 */ 582, 1480, 1480, 1480, 1809, 1779, 1841, 581, 1480, 1480,
+ /* 2080 */ 291, 1810, 584, 1812, 1813, 580, 1827, 575, 1480, 1480,
+ /* 2090 */ 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480, 1480, 1779,
+ /* 2100 */ 1841, 581, 1827, 1480, 283, 1810, 584, 1812, 1813, 580,
+ /* 2110 */ 582, 575, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480,
+ /* 2120 */ 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480, 292, 1810,
+ /* 2130 */ 584, 1812, 1813, 580, 1480, 575, 1480, 1480, 1480, 1480,
+ /* 2140 */ 1841, 1480, 1480, 1480, 284, 1810, 584, 1812, 1813, 580,
+ /* 2150 */ 1480, 575, 1809, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2160 */ 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2170 */ 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2180 */ 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480,
+ /* 2190 */ 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480,
+ /* 2200 */ 1480, 1480, 1480, 1809, 1480, 1480, 1480, 1480, 1480, 1480,
+ /* 2210 */ 1480, 1480, 1480, 1809, 1480, 1480, 1480, 1480, 1841, 1480,
+ /* 2220 */ 1480, 1480, 297, 1810, 584, 1812, 1813, 580, 1480, 575,
+ /* 2230 */ 1480, 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582,
+ /* 2240 */ 1480, 1827, 1480, 1480, 1779, 1480, 581, 1480, 1480, 582,
+ /* 2250 */ 1480, 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480,
+ /* 2260 */ 1480, 1480, 1480, 1480, 1480, 1480, 1809, 1480, 1480, 1841,
+ /* 2270 */ 1480, 1480, 1480, 298, 1810, 584, 1812, 1813, 580, 1841,
+ /* 2280 */ 575, 1480, 1809, 1821, 1810, 584, 1812, 1813, 580, 1480,
+ /* 2290 */ 575, 1480, 1480, 1480, 1827, 1480, 1480, 1480, 1480, 1480,
+ /* 2300 */ 1480, 1480, 582, 1480, 1480, 1480, 1809, 1779, 1480, 581,
+ /* 2310 */ 1827, 1480, 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480,
+ /* 2320 */ 1480, 1480, 1809, 1779, 1480, 581, 1480, 1480, 1480, 1480,
+ /* 2330 */ 1480, 1480, 1841, 1480, 1827, 1480, 1820, 1810, 584, 1812,
+ /* 2340 */ 1813, 580, 582, 575, 1480, 1480, 1809, 1779, 1841, 581,
+ /* 2350 */ 1827, 1480, 1819, 1810, 584, 1812, 1813, 580, 582, 575,
+ /* 2360 */ 1480, 1480, 1480, 1779, 1480, 581, 1480, 1480, 1480, 1480,
+ /* 2370 */ 1809, 1480, 1841, 1480, 1827, 1480, 310, 1810, 584, 1812,
+ /* 2380 */ 1813, 580, 582, 575, 1480, 1480, 1809, 1779, 1841, 581,
+ /* 2390 */ 1480, 1480, 309, 1810, 584, 1812, 1813, 580, 1827, 575,
+ /* 2400 */ 1480, 1480, 1480, 1480, 1480, 1480, 582, 1480, 1480, 1480,
+ /* 2410 */ 1480, 1779, 1841, 581, 1827, 1480, 311, 1810, 584, 1812,
+ /* 2420 */ 1813, 580, 582, 575, 1480, 1480, 1480, 1779, 1480, 581,
+ /* 2430 */ 1480, 1480, 1480, 1480, 1480, 1480, 1841, 1480, 1480, 1480,
+ /* 2440 */ 308, 1810, 584, 1812, 1813, 580, 1480, 575, 1480, 1480,
+ /* 2450 */ 1480, 1480, 1841, 1480, 1480, 1480, 287, 1810, 584, 1812,
+ /* 2460 */ 1813, 580, 1480, 575,
};
static const YYCODETYPE yy_lookahead[] = {
- /* 0 */ 352, 309, 313, 317, 315, 316, 365, 359, 0, 4,
- /* 10 */ 362, 317, 12, 13, 328, 338, 313, 317, 315, 316,
- /* 20 */ 20, 335, 22, 0, 12, 13, 14, 15, 16, 337,
- /* 30 */ 317, 345, 317, 33, 20, 35, 22, 345, 317, 345,
- /* 40 */ 20, 328, 350, 328, 352, 345, 405, 24, 25, 26,
- /* 50 */ 27, 28, 29, 30, 31, 32, 56, 365, 345, 418,
- /* 60 */ 345, 61, 329, 422, 50, 365, 345, 375, 68, 0,
- /* 70 */ 337, 379, 380, 381, 382, 383, 384, 383, 386, 346,
- /* 80 */ 308, 389, 310, 383, 309, 393, 394, 20, 4, 35,
- /* 90 */ 90, 397, 398, 399, 400, 90, 402, 405, 398, 399,
- /* 100 */ 400, 337, 402, 348, 383, 405, 351, 352, 344, 322,
- /* 110 */ 418, 0, 112, 326, 422, 60, 337, 353, 418, 398,
- /* 120 */ 399, 400, 422, 402, 345, 350, 126, 127, 44, 45,
- /* 130 */ 390, 391, 63, 64, 65, 66, 67, 0, 69, 70,
+ /* 0 */ 315, 367, 317, 318, 311, 321, 367, 315, 341, 317,
+ /* 10 */ 318, 340, 12, 13, 319, 4, 392, 393, 334, 352,
+ /* 20 */ 20, 407, 22, 8, 9, 4, 342, 12, 13, 14,
+ /* 30 */ 15, 16, 339, 33, 420, 35, 319, 310, 424, 312,
+ /* 40 */ 347, 407, 347, 376, 377, 352, 407, 354, 12, 13,
+ /* 50 */ 14, 15, 16, 20, 420, 388, 56, 354, 424, 420,
+ /* 60 */ 367, 61, 367, 424, 361, 44, 45, 364, 68, 0,
+ /* 70 */ 377, 20, 323, 356, 381, 382, 383, 384, 385, 386,
+ /* 80 */ 385, 388, 311, 56, 391, 336, 56, 350, 395, 396,
+ /* 90 */ 353, 354, 92, 20, 345, 400, 401, 402, 92, 404,
+ /* 100 */ 407, 21, 407, 92, 24, 25, 26, 27, 28, 29,
+ /* 110 */ 30, 31, 32, 420, 114, 420, 60, 424, 91, 424,
+ /* 120 */ 14, 94, 92, 352, 94, 92, 20, 20, 128, 129,
+ /* 130 */ 1, 2, 63, 64, 65, 66, 67, 311, 69, 70,
/* 140 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
- /* 150 */ 81, 82, 83, 84, 85, 86, 87, 325, 21, 327,
- /* 160 */ 381, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- /* 170 */ 20, 60, 172, 377, 174, 103, 104, 105, 106, 107,
- /* 180 */ 108, 109, 110, 111, 112, 113, 157, 115, 116, 117,
- /* 190 */ 118, 119, 120, 126, 127, 195, 196, 401, 198, 199,
+ /* 150 */ 81, 82, 83, 84, 85, 86, 87, 88, 89, 319,
+ /* 160 */ 21, 8, 9, 33, 0, 12, 13, 14, 15, 16,
+ /* 170 */ 330, 123, 124, 34, 174, 36, 176, 47, 352, 128,
+ /* 180 */ 129, 166, 52, 53, 54, 55, 56, 347, 24, 25,
+ /* 190 */ 26, 27, 28, 29, 30, 31, 32, 197, 198, 92,
/* 200 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- /* 210 */ 210, 211, 212, 213, 214, 215, 12, 13, 14, 405,
- /* 220 */ 339, 18, 336, 20, 20, 309, 22, 121, 174, 229,
- /* 230 */ 27, 350, 418, 30, 229, 349, 422, 33, 21, 35,
- /* 240 */ 90, 24, 25, 26, 27, 28, 29, 30, 31, 32,
- /* 250 */ 47, 20, 49, 337, 51, 374, 375, 376, 321, 20,
- /* 260 */ 56, 345, 20, 234, 235, 61, 350, 386, 352, 8,
- /* 270 */ 9, 334, 68, 12, 13, 14, 15, 16, 8, 9,
- /* 280 */ 343, 56, 12, 13, 14, 15, 16, 181, 182, 20,
- /* 290 */ 405, 375, 89, 319, 90, 379, 380, 381, 382, 383,
- /* 300 */ 384, 90, 386, 418, 101, 389, 332, 422, 20, 393,
- /* 310 */ 394, 395, 351, 352, 340, 90, 112, 92, 8, 9,
- /* 320 */ 404, 90, 12, 13, 14, 15, 16, 14, 195, 90,
- /* 330 */ 126, 127, 129, 20, 90, 132, 133, 134, 135, 136,
- /* 340 */ 137, 138, 139, 140, 141, 142, 143, 144, 145, 146,
- /* 350 */ 147, 148, 149, 43, 151, 152, 153, 323, 324, 8,
- /* 360 */ 9, 91, 3, 12, 13, 14, 15, 16, 20, 317,
- /* 370 */ 22, 238, 239, 240, 241, 242, 172, 345, 174, 2,
- /* 380 */ 328, 20, 171, 35, 173, 8, 9, 335, 356, 12,
- /* 390 */ 13, 14, 15, 16, 121, 122, 317, 345, 50, 195,
- /* 400 */ 196, 56, 198, 199, 200, 201, 202, 203, 204, 205,
- /* 410 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
- /* 420 */ 12, 13, 309, 4, 345, 164, 102, 101, 20, 0,
- /* 430 */ 22, 14, 15, 16, 89, 377, 314, 92, 19, 317,
- /* 440 */ 229, 33, 91, 35, 309, 121, 122, 123, 124, 125,
- /* 450 */ 337, 77, 33, 180, 229, 14, 183, 90, 345, 401,
- /* 460 */ 229, 20, 383, 350, 56, 352, 47, 337, 229, 61,
- /* 470 */ 51, 21, 337, 229, 344, 56, 68, 398, 399, 400,
- /* 480 */ 345, 402, 306, 353, 34, 350, 36, 352, 375, 60,
- /* 490 */ 339, 0, 379, 380, 381, 382, 383, 384, 90, 386,
- /* 500 */ 365, 350, 389, 60, 130, 131, 393, 394, 89, 35,
- /* 510 */ 375, 92, 251, 167, 379, 380, 381, 382, 383, 384,
- /* 520 */ 112, 386, 329, 338, 389, 374, 375, 376, 393, 394,
- /* 530 */ 337, 309, 186, 187, 126, 127, 317, 386, 47, 346,
- /* 540 */ 405, 365, 68, 68, 8, 9, 405, 321, 12, 13,
- /* 550 */ 14, 15, 16, 418, 2, 314, 14, 422, 317, 418,
- /* 560 */ 8, 9, 20, 422, 12, 13, 14, 15, 16, 343,
- /* 570 */ 8, 9, 350, 354, 12, 13, 14, 15, 16, 20,
- /* 580 */ 172, 405, 174, 8, 9, 1, 2, 12, 13, 14,
- /* 590 */ 15, 16, 37, 68, 418, 309, 229, 61, 422, 365,
- /* 600 */ 309, 43, 122, 195, 196, 246, 198, 199, 200, 201,
- /* 610 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
- /* 620 */ 212, 213, 214, 215, 12, 13, 309, 91, 338, 329,
- /* 630 */ 22, 365, 20, 154, 22, 99, 350, 337, 345, 405,
- /* 640 */ 199, 350, 309, 35, 0, 33, 346, 35, 93, 356,
- /* 650 */ 95, 96, 418, 98, 337, 425, 422, 102, 337, 179,
- /* 660 */ 180, 317, 345, 183, 323, 324, 91, 350, 56, 352,
- /* 670 */ 337, 405, 328, 319, 353, 91, 68, 0, 345, 124,
- /* 680 */ 68, 352, 309, 350, 418, 352, 44, 45, 422, 345,
- /* 690 */ 154, 362, 375, 338, 340, 216, 379, 380, 381, 382,
- /* 700 */ 383, 384, 90, 386, 309, 226, 389, 0, 375, 309,
- /* 710 */ 393, 394, 379, 380, 381, 382, 383, 384, 159, 386,
- /* 720 */ 112, 159, 389, 350, 112, 20, 393, 394, 395, 8,
- /* 730 */ 9, 39, 309, 12, 13, 14, 15, 16, 126, 127,
- /* 740 */ 407, 199, 337, 4, 309, 350, 102, 361, 415, 363,
- /* 750 */ 350, 346, 216, 217, 218, 219, 220, 221, 222, 223,
- /* 760 */ 224, 225, 226, 317, 309, 121, 122, 123, 124, 125,
- /* 770 */ 20, 64, 65, 350, 328, 361, 337, 363, 71, 102,
- /* 780 */ 172, 369, 174, 344, 172, 350, 174, 90, 81, 82,
- /* 790 */ 309, 345, 353, 309, 87, 227, 228, 100, 121, 122,
- /* 800 */ 123, 124, 125, 195, 196, 350, 248, 195, 196, 309,
- /* 810 */ 198, 199, 200, 201, 202, 203, 204, 205, 206, 207,
- /* 820 */ 208, 209, 210, 211, 212, 213, 214, 215, 12, 13,
- /* 830 */ 14, 350, 309, 338, 350, 377, 20, 317, 22, 309,
- /* 840 */ 43, 229, 339, 317, 405, 64, 65, 365, 328, 33,
- /* 850 */ 350, 35, 71, 350, 328, 339, 309, 418, 317, 401,
- /* 860 */ 309, 422, 81, 82, 159, 345, 350, 337, 87, 328,
- /* 870 */ 317, 345, 56, 350, 309, 345, 309, 374, 375, 310,
- /* 880 */ 350, 328, 352, 326, 68, 416, 345, 405, 337, 386,
- /* 890 */ 374, 375, 347, 42, 43, 350, 345, 350, 345, 309,
- /* 900 */ 418, 350, 386, 352, 422, 375, 90, 309, 338, 379,
- /* 910 */ 380, 381, 382, 383, 384, 350, 386, 350, 347, 389,
- /* 920 */ 228, 350, 318, 393, 394, 395, 375, 309, 112, 102,
- /* 930 */ 379, 380, 381, 382, 383, 384, 385, 386, 387, 388,
- /* 940 */ 350, 330, 126, 127, 333, 415, 412, 43, 350, 199,
- /* 950 */ 317, 124, 8, 9, 22, 337, 12, 13, 14, 15,
- /* 960 */ 16, 328, 94, 345, 338, 97, 317, 35, 350, 230,
- /* 970 */ 352, 94, 337, 94, 97, 317, 97, 328, 345, 94,
- /* 980 */ 318, 317, 97, 159, 160, 317, 328, 61, 172, 35,
- /* 990 */ 174, 316, 328, 375, 345, 91, 328, 379, 380, 381,
- /* 1000 */ 382, 383, 384, 345, 386, 61, 1, 2, 309, 345,
- /* 1010 */ 365, 195, 196, 345, 198, 199, 200, 201, 202, 203,
- /* 1020 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
- /* 1030 */ 214, 215, 12, 13, 309, 417, 337, 317, 0, 0,
- /* 1040 */ 20, 0, 22, 99, 345, 317, 0, 250, 328, 350,
- /* 1050 */ 405, 352, 46, 33, 56, 35, 328, 349, 317, 35,
- /* 1060 */ 22, 22, 337, 418, 378, 345, 403, 422, 22, 328,
- /* 1070 */ 345, 126, 127, 345, 375, 350, 56, 352, 379, 380,
- /* 1080 */ 381, 382, 383, 384, 317, 386, 345, 43, 68, 48,
- /* 1090 */ 92, 396, 68, 43, 43, 328, 90, 43, 154, 419,
- /* 1100 */ 375, 419, 317, 19, 379, 380, 381, 382, 383, 384,
- /* 1110 */ 90, 386, 345, 328, 389, 419, 317, 33, 393, 394,
- /* 1120 */ 395, 195, 423, 424, 43, 406, 43, 328, 174, 404,
- /* 1130 */ 345, 47, 112, 13, 43, 91, 52, 53, 54, 55,
- /* 1140 */ 56, 91, 91, 231, 345, 91, 126, 127, 43, 43,
- /* 1150 */ 43, 43, 43, 43, 43, 35, 43, 373, 13, 372,
- /* 1160 */ 216, 217, 218, 219, 220, 221, 222, 223, 224, 225,
- /* 1170 */ 226, 47, 91, 89, 91, 367, 92, 170, 42, 357,
- /* 1180 */ 35, 20, 91, 317, 317, 357, 355, 154, 355, 317,
- /* 1190 */ 317, 317, 172, 20, 174, 311, 91, 91, 91, 91,
- /* 1200 */ 91, 91, 91, 311, 91, 20, 371, 321, 352, 125,
- /* 1210 */ 321, 309, 20, 364, 20, 195, 196, 321, 198, 199,
- /* 1220 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
- /* 1230 */ 210, 211, 212, 213, 214, 215, 12, 13, 321, 337,
- /* 1240 */ 364, 366, 158, 321, 20, 321, 22, 345, 317, 321,
- /* 1250 */ 311, 337, 350, 337, 352, 337, 337, 33, 337, 35,
- /* 1260 */ 176, 311, 178, 317, 337, 350, 337, 337, 371, 177,
- /* 1270 */ 337, 337, 337, 370, 319, 352, 319, 375, 317, 317,
- /* 1280 */ 56, 379, 380, 381, 382, 383, 384, 319, 386, 364,
- /* 1290 */ 350, 389, 68, 236, 156, 319, 394, 360, 350, 18,
- /* 1300 */ 358, 350, 350, 360, 23, 12, 13, 333, 350, 319,
- /* 1310 */ 345, 20, 237, 350, 90, 22, 378, 411, 37, 38,
- /* 1320 */ 360, 350, 41, 350, 411, 350, 33, 360, 35, 350,
- /* 1330 */ 243, 163, 232, 245, 414, 20, 112, 244, 57, 58,
- /* 1340 */ 59, 309, 373, 228, 345, 249, 247, 411, 90, 56,
- /* 1350 */ 126, 127, 90, 252, 413, 377, 341, 410, 409, 350,
- /* 1360 */ 317, 68, 327, 36, 408, 312, 319, 311, 368, 337,
- /* 1370 */ 307, 90, 392, 420, 342, 363, 331, 345, 320, 331,
- /* 1380 */ 421, 0, 350, 331, 352, 0, 179, 421, 0, 0,
- /* 1390 */ 426, 421, 420, 42, 0, 35, 172, 420, 174, 189,
- /* 1400 */ 35, 35, 35, 189, 0, 112, 35, 375, 35, 128,
- /* 1410 */ 189, 379, 380, 381, 382, 383, 384, 0, 386, 195,
- /* 1420 */ 196, 309, 198, 199, 200, 201, 202, 203, 204, 205,
- /* 1430 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
- /* 1440 */ 189, 0, 309, 35, 0, 164, 165, 166, 22, 337,
- /* 1450 */ 169, 0, 174, 35, 342, 172, 0, 345, 168, 167,
- /* 1460 */ 0, 0, 350, 0, 352, 172, 185, 174, 46, 188,
- /* 1470 */ 337, 190, 191, 192, 193, 194, 42, 0, 345, 0,
- /* 1480 */ 0, 0, 0, 350, 0, 352, 150, 375, 195, 196,
- /* 1490 */ 0, 379, 380, 381, 382, 383, 384, 0, 386, 0,
- /* 1500 */ 207, 208, 209, 210, 211, 212, 213, 0, 375, 0,
- /* 1510 */ 229, 0, 379, 380, 381, 382, 383, 384, 35, 386,
- /* 1520 */ 145, 145, 389, 0, 0, 309, 393, 394, 395, 0,
- /* 1530 */ 0, 0, 0, 0, 0, 0, 0, 404, 0, 0,
- /* 1540 */ 0, 309, 0, 42, 0, 0, 0, 0, 0, 0,
- /* 1550 */ 22, 0, 0, 337, 0, 0, 0, 0, 56, 56,
- /* 1560 */ 0, 345, 0, 42, 39, 43, 350, 14, 352, 337,
- /* 1570 */ 0, 0, 14, 46, 0, 0, 163, 345, 62, 0,
- /* 1580 */ 39, 365, 350, 46, 352, 0, 0, 0, 0, 0,
- /* 1590 */ 40, 375, 0, 0, 35, 379, 380, 381, 382, 383,
- /* 1600 */ 384, 35, 386, 39, 39, 0, 39, 375, 47, 309,
- /* 1610 */ 47, 379, 380, 381, 382, 383, 384, 35, 386, 47,
- /* 1620 */ 39, 405, 39, 47, 0, 309, 35, 0, 0, 35,
- /* 1630 */ 22, 0, 35, 35, 418, 22, 35, 337, 422, 43,
- /* 1640 */ 0, 35, 99, 43, 22, 345, 0, 22, 49, 0,
- /* 1650 */ 350, 22, 352, 337, 35, 0, 424, 0, 35, 0,
- /* 1660 */ 0, 345, 20, 22, 159, 365, 350, 35, 352, 35,
- /* 1670 */ 97, 0, 22, 175, 159, 375, 156, 0, 0, 379,
- /* 1680 */ 380, 381, 382, 383, 384, 0, 386, 309, 35, 0,
- /* 1690 */ 184, 375, 0, 0, 90, 379, 380, 381, 382, 383,
- /* 1700 */ 384, 91, 386, 0, 388, 405, 309, 90, 90, 39,
- /* 1710 */ 90, 100, 46, 46, 46, 337, 43, 43, 418, 233,
- /* 1720 */ 342, 91, 422, 345, 91, 90, 157, 159, 350, 90,
- /* 1730 */ 352, 227, 46, 90, 337, 155, 91, 90, 161, 342,
- /* 1740 */ 43, 90, 345, 91, 90, 43, 90, 350, 35, 352,
- /* 1750 */ 233, 43, 91, 375, 91, 91, 46, 379, 380, 381,
- /* 1760 */ 382, 383, 384, 46, 386, 43, 91, 309, 33, 35,
- /* 1770 */ 91, 35, 375, 35, 35, 35, 379, 380, 381, 382,
- /* 1780 */ 383, 384, 47, 386, 317, 309, 22, 52, 53, 54,
- /* 1790 */ 55, 56, 2, 43, 90, 337, 90, 195, 91, 46,
- /* 1800 */ 91, 90, 90, 345, 46, 91, 90, 22, 350, 197,
- /* 1810 */ 352, 90, 345, 337, 91, 35, 101, 233, 35, 90,
- /* 1820 */ 90, 345, 91, 35, 89, 22, 350, 92, 352, 35,
- /* 1830 */ 35, 90, 365, 375, 91, 309, 91, 379, 380, 381,
- /* 1840 */ 382, 383, 384, 91, 386, 90, 35, 90, 102, 35,
- /* 1850 */ 383, 375, 90, 90, 22, 379, 380, 381, 382, 383,
- /* 1860 */ 384, 114, 386, 337, 90, 398, 399, 400, 114, 402,
- /* 1870 */ 114, 345, 405, 114, 43, 62, 350, 61, 352, 35,
- /* 1880 */ 35, 35, 35, 35, 35, 418, 35, 309, 35, 422,
- /* 1890 */ 155, 156, 68, 158, 88, 35, 35, 162, 43, 22,
- /* 1900 */ 35, 375, 22, 35, 35, 379, 380, 381, 382, 383,
- /* 1910 */ 384, 68, 386, 178, 35, 337, 35, 35, 35, 35,
- /* 1920 */ 22, 35, 0, 345, 35, 47, 39, 0, 350, 35,
- /* 1930 */ 352, 0, 47, 0, 39, 309, 35, 47, 39, 35,
- /* 1940 */ 47, 39, 0, 35, 35, 0, 22, 309, 22, 21,
- /* 1950 */ 20, 22, 427, 375, 427, 21, 427, 379, 380, 381,
- /* 1960 */ 382, 383, 384, 337, 386, 427, 427, 427, 427, 427,
- /* 1970 */ 427, 345, 427, 427, 427, 337, 350, 427, 352, 427,
- /* 1980 */ 427, 427, 427, 345, 427, 427, 427, 427, 350, 427,
- /* 1990 */ 352, 427, 427, 427, 427, 427, 427, 309, 427, 427,
- /* 2000 */ 427, 375, 427, 427, 427, 379, 380, 381, 382, 383,
- /* 2010 */ 384, 427, 386, 375, 309, 427, 427, 379, 380, 381,
- /* 2020 */ 382, 383, 384, 427, 386, 337, 427, 427, 427, 427,
- /* 2030 */ 427, 427, 427, 345, 427, 427, 427, 427, 350, 427,
- /* 2040 */ 352, 427, 337, 427, 427, 427, 427, 427, 427, 427,
- /* 2050 */ 345, 427, 427, 427, 427, 350, 427, 352, 427, 427,
- /* 2060 */ 427, 427, 427, 375, 427, 427, 427, 379, 380, 381,
- /* 2070 */ 382, 383, 384, 427, 386, 427, 427, 309, 427, 427,
- /* 2080 */ 375, 427, 427, 427, 379, 380, 381, 382, 383, 384,
- /* 2090 */ 427, 386, 427, 309, 427, 427, 427, 427, 427, 427,
- /* 2100 */ 427, 427, 427, 427, 427, 337, 427, 427, 427, 427,
- /* 2110 */ 427, 427, 427, 345, 427, 427, 427, 427, 350, 427,
- /* 2120 */ 352, 337, 427, 427, 427, 427, 427, 427, 427, 345,
- /* 2130 */ 427, 427, 427, 427, 350, 427, 352, 427, 427, 427,
- /* 2140 */ 427, 427, 427, 375, 427, 309, 427, 379, 380, 381,
- /* 2150 */ 382, 383, 384, 427, 386, 427, 427, 427, 427, 375,
- /* 2160 */ 427, 309, 427, 379, 380, 381, 382, 383, 384, 427,
- /* 2170 */ 386, 427, 427, 337, 427, 427, 427, 427, 427, 427,
- /* 2180 */ 427, 345, 427, 427, 427, 427, 350, 427, 352, 337,
- /* 2190 */ 427, 427, 427, 427, 427, 427, 427, 345, 427, 427,
- /* 2200 */ 427, 309, 350, 427, 352, 427, 427, 427, 427, 427,
- /* 2210 */ 427, 375, 427, 427, 427, 379, 380, 381, 382, 383,
- /* 2220 */ 384, 427, 386, 309, 427, 427, 427, 375, 427, 337,
- /* 2230 */ 427, 379, 380, 381, 382, 383, 384, 345, 386, 427,
- /* 2240 */ 427, 427, 350, 427, 352, 427, 427, 427, 427, 427,
- /* 2250 */ 427, 337, 427, 427, 427, 427, 427, 427, 427, 345,
- /* 2260 */ 427, 427, 427, 309, 350, 427, 352, 375, 427, 427,
- /* 2270 */ 427, 379, 380, 381, 382, 383, 384, 427, 386, 427,
- /* 2280 */ 427, 309, 427, 427, 427, 427, 427, 427, 427, 375,
- /* 2290 */ 427, 337, 427, 379, 380, 381, 382, 383, 384, 345,
- /* 2300 */ 386, 427, 427, 427, 350, 427, 352, 427, 427, 337,
- /* 2310 */ 427, 427, 427, 427, 427, 427, 427, 345, 427, 427,
- /* 2320 */ 427, 427, 350, 427, 352, 427, 427, 427, 427, 375,
- /* 2330 */ 427, 309, 427, 379, 380, 381, 382, 383, 384, 427,
- /* 2340 */ 386, 427, 427, 309, 427, 427, 427, 375, 427, 427,
- /* 2350 */ 427, 379, 380, 381, 382, 383, 384, 427, 386, 337,
- /* 2360 */ 427, 427, 427, 427, 427, 427, 427, 345, 427, 427,
- /* 2370 */ 427, 337, 350, 427, 352, 427, 427, 427, 427, 345,
- /* 2380 */ 427, 427, 427, 427, 350, 427, 352, 427, 427, 427,
- /* 2390 */ 427, 427, 427, 427, 309, 427, 427, 375, 427, 427,
- /* 2400 */ 427, 379, 380, 381, 382, 383, 384, 427, 386, 375,
- /* 2410 */ 427, 427, 427, 379, 380, 381, 382, 383, 384, 427,
- /* 2420 */ 386, 427, 337, 427, 427, 427, 427, 427, 427, 427,
- /* 2430 */ 345, 427, 427, 427, 427, 350, 427, 352, 427, 427,
- /* 2440 */ 427, 427, 427, 427, 309, 427, 427, 427, 427, 427,
- /* 2450 */ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- /* 2460 */ 375, 427, 427, 427, 379, 380, 381, 382, 383, 384,
- /* 2470 */ 427, 386, 337, 427, 427, 427, 427, 427, 427, 427,
- /* 2480 */ 345, 427, 427, 427, 427, 350, 427, 352, 427, 427,
- /* 2490 */ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- /* 2500 */ 427, 427, 427, 427, 427, 427, 427, 427, 427, 427,
- /* 2510 */ 375, 427, 427, 427, 379, 380, 381, 382, 383, 384,
- /* 2520 */ 427, 386,
+ /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 12, 13,
+ /* 220 */ 14, 91, 93, 18, 94, 20, 20, 321, 22, 311,
+ /* 230 */ 182, 231, 27, 185, 407, 30, 367, 231, 319, 33,
+ /* 240 */ 159, 35, 231, 339, 341, 319, 93, 420, 342, 330,
+ /* 250 */ 346, 424, 47, 339, 49, 352, 51, 339, 407, 355,
+ /* 260 */ 346, 231, 56, 20, 231, 347, 347, 61, 253, 355,
+ /* 270 */ 352, 420, 354, 347, 68, 424, 407, 8, 9, 376,
+ /* 280 */ 377, 12, 13, 14, 15, 16, 341, 157, 158, 420,
+ /* 290 */ 160, 388, 92, 424, 164, 377, 91, 352, 92, 381,
+ /* 300 */ 382, 383, 384, 385, 386, 20, 388, 201, 103, 391,
+ /* 310 */ 180, 385, 43, 395, 396, 397, 20, 236, 237, 338,
+ /* 320 */ 114, 376, 377, 378, 406, 399, 400, 401, 402, 363,
+ /* 330 */ 404, 365, 351, 388, 128, 129, 131, 308, 231, 134,
+ /* 340 */ 135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
+ /* 350 */ 145, 146, 147, 148, 149, 150, 151, 0, 153, 154,
+ /* 360 */ 155, 379, 105, 106, 107, 108, 109, 110, 111, 112,
+ /* 370 */ 113, 114, 115, 319, 117, 118, 119, 120, 121, 122,
+ /* 380 */ 174, 331, 176, 37, 330, 403, 8, 9, 92, 339,
+ /* 390 */ 12, 13, 14, 15, 16, 324, 367, 20, 348, 328,
+ /* 400 */ 20, 347, 22, 197, 198, 48, 200, 201, 202, 203,
+ /* 410 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+ /* 420 */ 214, 215, 216, 217, 12, 13, 311, 4, 353, 354,
+ /* 430 */ 50, 231, 20, 363, 22, 365, 407, 20, 14, 15,
+ /* 440 */ 16, 95, 19, 97, 98, 33, 100, 35, 339, 420,
+ /* 450 */ 104, 20, 123, 424, 339, 346, 33, 0, 64, 65,
+ /* 460 */ 14, 0, 347, 60, 355, 71, 20, 352, 56, 354,
+ /* 470 */ 47, 93, 126, 61, 51, 81, 82, 2, 331, 56,
+ /* 480 */ 68, 87, 367, 8, 9, 331, 339, 12, 13, 14,
+ /* 490 */ 15, 16, 377, 339, 39, 348, 381, 382, 383, 384,
+ /* 500 */ 385, 386, 348, 388, 92, 103, 391, 156, 319, 319,
+ /* 510 */ 395, 396, 183, 184, 91, 316, 407, 94, 319, 311,
+ /* 520 */ 330, 60, 407, 18, 339, 92, 114, 337, 23, 420,
+ /* 530 */ 311, 311, 347, 424, 169, 420, 347, 347, 2, 424,
+ /* 540 */ 128, 129, 37, 38, 8, 9, 41, 68, 12, 13,
+ /* 550 */ 14, 15, 16, 188, 189, 12, 13, 311, 339, 319,
+ /* 560 */ 352, 104, 57, 58, 59, 22, 347, 0, 383, 218,
+ /* 570 */ 330, 352, 352, 354, 385, 354, 33, 337, 35, 228,
+ /* 580 */ 123, 124, 125, 126, 127, 364, 174, 347, 176, 400,
+ /* 590 */ 401, 402, 161, 404, 68, 311, 377, 92, 352, 56,
+ /* 600 */ 381, 382, 383, 384, 385, 386, 173, 388, 175, 197,
+ /* 610 */ 198, 68, 200, 201, 202, 203, 204, 205, 206, 207,
+ /* 620 */ 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
+ /* 630 */ 12, 13, 379, 22, 311, 130, 352, 311, 20, 327,
+ /* 640 */ 22, 329, 14, 0, 425, 426, 35, 201, 20, 340,
+ /* 650 */ 20, 33, 22, 35, 8, 9, 403, 114, 12, 13,
+ /* 660 */ 14, 15, 16, 0, 231, 35, 316, 367, 340, 319,
+ /* 670 */ 311, 166, 167, 168, 56, 352, 171, 340, 352, 68,
+ /* 680 */ 50, 124, 311, 8, 9, 230, 68, 12, 13, 14,
+ /* 690 */ 15, 16, 187, 319, 311, 190, 323, 192, 193, 194,
+ /* 700 */ 195, 196, 311, 60, 330, 44, 45, 407, 8, 9,
+ /* 710 */ 92, 352, 12, 13, 14, 15, 16, 174, 345, 176,
+ /* 720 */ 420, 347, 339, 352, 424, 114, 340, 64, 65, 311,
+ /* 730 */ 347, 311, 114, 367, 71, 352, 231, 354, 181, 182,
+ /* 740 */ 197, 198, 185, 352, 81, 82, 128, 129, 311, 35,
+ /* 750 */ 87, 379, 209, 210, 211, 212, 213, 214, 215, 197,
+ /* 760 */ 377, 61, 229, 230, 381, 382, 383, 384, 385, 386,
+ /* 770 */ 352, 388, 352, 407, 391, 403, 104, 347, 395, 396,
+ /* 780 */ 397, 4, 68, 325, 326, 174, 420, 176, 358, 352,
+ /* 790 */ 424, 104, 174, 93, 176, 123, 124, 125, 126, 127,
+ /* 800 */ 417, 101, 240, 241, 242, 243, 244, 161, 197, 198,
+ /* 810 */ 311, 311, 311, 126, 311, 197, 198, 20, 200, 201,
+ /* 820 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211,
+ /* 830 */ 212, 213, 214, 215, 216, 217, 12, 13, 14, 339,
+ /* 840 */ 0, 339, 77, 371, 20, 35, 22, 347, 311, 231,
+ /* 850 */ 348, 352, 352, 352, 354, 352, 156, 33, 311, 35,
+ /* 860 */ 339, 21, 347, 3, 24, 25, 26, 27, 28, 29,
+ /* 870 */ 30, 31, 32, 358, 325, 326, 355, 377, 68, 20,
+ /* 880 */ 56, 381, 382, 383, 384, 385, 386, 349, 388, 352,
+ /* 890 */ 352, 391, 68, 42, 43, 395, 396, 132, 133, 352,
+ /* 900 */ 349, 8, 9, 352, 341, 12, 13, 14, 15, 16,
+ /* 910 */ 332, 43, 340, 335, 311, 352, 92, 0, 218, 219,
+ /* 920 */ 220, 221, 222, 223, 224, 225, 226, 227, 228, 8,
+ /* 930 */ 9, 311, 319, 12, 13, 14, 15, 16, 114, 376,
+ /* 940 */ 377, 378, 339, 330, 43, 319, 340, 344, 0, 22,
+ /* 950 */ 347, 388, 128, 129, 61, 352, 330, 354, 161, 339,
+ /* 960 */ 347, 93, 35, 96, 47, 96, 99, 347, 99, 312,
+ /* 970 */ 22, 319, 352, 347, 354, 161, 162, 1, 2, 319,
+ /* 980 */ 377, 56, 330, 43, 381, 382, 383, 384, 385, 386,
+ /* 990 */ 330, 388, 319, 96, 101, 0, 99, 377, 174, 347,
+ /* 1000 */ 176, 381, 382, 383, 384, 385, 386, 347, 388, 232,
+ /* 1010 */ 96, 391, 43, 99, 93, 395, 396, 22, 427, 94,
+ /* 1020 */ 347, 197, 198, 0, 200, 201, 202, 203, 204, 205,
+ /* 1030 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215,
+ /* 1040 */ 216, 217, 12, 13, 319, 22, 43, 328, 319, 156,
+ /* 1050 */ 20, 43, 22, 43, 19, 330, 319, 35, 385, 330,
+ /* 1060 */ 201, 320, 93, 33, 311, 35, 35, 330, 33, 128,
+ /* 1070 */ 129, 418, 347, 400, 401, 402, 347, 404, 61, 46,
+ /* 1080 */ 13, 43, 47, 43, 347, 92, 56, 52, 53, 54,
+ /* 1090 */ 55, 56, 339, 0, 414, 102, 93, 344, 68, 319,
+ /* 1100 */ 347, 93, 35, 93, 311, 352, 43, 354, 248, 339,
+ /* 1110 */ 330, 218, 219, 220, 221, 222, 223, 224, 225, 226,
+ /* 1120 */ 227, 228, 92, 43, 13, 92, 91, 347, 320, 94,
+ /* 1130 */ 377, 93, 339, 93, 381, 382, 383, 384, 385, 386,
+ /* 1140 */ 347, 388, 351, 43, 114, 352, 35, 354, 318, 43,
+ /* 1150 */ 43, 250, 319, 380, 319, 319, 93, 319, 128, 129,
+ /* 1160 */ 405, 43, 127, 330, 398, 330, 330, 421, 330, 421,
+ /* 1170 */ 377, 43, 421, 93, 381, 382, 383, 384, 385, 386,
+ /* 1180 */ 347, 388, 347, 347, 391, 347, 408, 233, 395, 396,
+ /* 1190 */ 397, 375, 252, 93, 47, 160, 374, 104, 176, 93,
+ /* 1200 */ 93, 319, 409, 43, 174, 43, 176, 176, 172, 42,
+ /* 1210 */ 417, 93, 330, 178, 197, 180, 123, 124, 125, 126,
+ /* 1220 */ 127, 93, 369, 359, 20, 319, 319, 197, 198, 347,
+ /* 1230 */ 200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
+ /* 1240 */ 210, 211, 212, 213, 214, 215, 216, 217, 12, 13,
+ /* 1250 */ 311, 319, 319, 93, 359, 93, 20, 156, 22, 357,
+ /* 1260 */ 357, 319, 330, 330, 319, 319, 20, 20, 313, 33,
+ /* 1270 */ 313, 35, 373, 323, 354, 323, 20, 366, 339, 347,
+ /* 1280 */ 347, 20, 323, 368, 366, 323, 347, 323, 323, 319,
+ /* 1290 */ 323, 352, 56, 354, 313, 339, 319, 339, 313, 339,
+ /* 1300 */ 339, 352, 339, 373, 68, 339, 179, 339, 321, 372,
+ /* 1310 */ 311, 339, 339, 339, 339, 321, 377, 319, 321, 319,
+ /* 1320 */ 381, 382, 383, 384, 385, 386, 319, 388, 92, 238,
+ /* 1330 */ 391, 158, 354, 321, 395, 396, 397, 366, 339, 321,
+ /* 1340 */ 352, 362, 352, 352, 352, 406, 347, 20, 362, 360,
+ /* 1350 */ 114, 352, 347, 354, 347, 335, 352, 413, 352, 239,
+ /* 1360 */ 380, 352, 245, 362, 128, 129, 352, 352, 352, 416,
+ /* 1370 */ 165, 247, 246, 362, 367, 234, 377, 20, 230, 347,
+ /* 1380 */ 381, 382, 383, 384, 385, 386, 251, 388, 249, 92,
+ /* 1390 */ 391, 254, 385, 411, 395, 396, 397, 413, 415, 375,
+ /* 1400 */ 379, 92, 343, 352, 329, 406, 410, 400, 401, 402,
+ /* 1410 */ 174, 404, 176, 394, 407, 413, 319, 321, 36, 314,
+ /* 1420 */ 370, 313, 365, 333, 322, 412, 311, 420, 333, 0,
+ /* 1430 */ 309, 424, 333, 197, 198, 181, 200, 201, 202, 203,
+ /* 1440 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213,
+ /* 1450 */ 214, 215, 216, 217, 339, 428, 0, 423, 0, 422,
+ /* 1460 */ 0, 422, 347, 42, 423, 423, 422, 352, 0, 354,
+ /* 1470 */ 191, 35, 35, 35, 35, 191, 0, 35, 35, 191,
+ /* 1480 */ 0, 191, 367, 0, 35, 0, 22, 311, 0, 35,
+ /* 1490 */ 176, 0, 377, 174, 0, 170, 381, 382, 383, 384,
+ /* 1500 */ 385, 386, 169, 388, 0, 0, 0, 46, 0, 0,
+ /* 1510 */ 0, 42, 0, 0, 152, 339, 0, 0, 0, 0,
+ /* 1520 */ 0, 147, 407, 347, 35, 0, 147, 0, 352, 0,
+ /* 1530 */ 354, 0, 0, 0, 0, 420, 0, 0, 0, 424,
+ /* 1540 */ 0, 0, 0, 367, 311, 0, 0, 0, 0, 42,
+ /* 1550 */ 0, 0, 0, 377, 56, 0, 56, 381, 382, 383,
+ /* 1560 */ 384, 385, 386, 0, 388, 22, 0, 0, 0, 0,
+ /* 1570 */ 311, 0, 339, 0, 0, 14, 46, 42, 39, 14,
+ /* 1580 */ 347, 0, 0, 407, 0, 352, 0, 354, 165, 0,
+ /* 1590 */ 0, 0, 43, 0, 0, 39, 420, 40, 339, 46,
+ /* 1600 */ 424, 39, 0, 0, 0, 35, 347, 47, 0, 0,
+ /* 1610 */ 377, 352, 35, 354, 381, 382, 383, 384, 385, 386,
+ /* 1620 */ 387, 388, 389, 390, 39, 47, 62, 39, 311, 0,
+ /* 1630 */ 35, 39, 35, 0, 47, 39, 377, 22, 0, 20,
+ /* 1640 */ 381, 382, 383, 384, 385, 386, 311, 388, 47, 35,
+ /* 1650 */ 391, 35, 35, 43, 43, 396, 339, 35, 99, 101,
+ /* 1660 */ 35, 22, 0, 22, 347, 0, 22, 49, 0, 352,
+ /* 1670 */ 22, 354, 35, 0, 339, 0, 0, 35, 35, 22,
+ /* 1680 */ 0, 35, 347, 161, 0, 22, 158, 352, 177, 354,
+ /* 1690 */ 0, 0, 0, 0, 377, 0, 311, 92, 381, 382,
+ /* 1700 */ 383, 384, 385, 386, 35, 388, 93, 186, 0, 0,
+ /* 1710 */ 39, 229, 377, 92, 102, 43, 381, 382, 383, 384,
+ /* 1720 */ 385, 386, 311, 388, 339, 46, 92, 92, 92, 43,
+ /* 1730 */ 235, 43, 347, 161, 235, 159, 419, 352, 163, 354,
+ /* 1740 */ 161, 35, 93, 92, 46, 93, 311, 93, 92, 46,
+ /* 1750 */ 339, 93, 92, 92, 43, 344, 157, 93, 347, 92,
+ /* 1760 */ 46, 426, 377, 352, 43, 354, 381, 382, 383, 384,
+ /* 1770 */ 385, 386, 46, 388, 339, 390, 93, 92, 46, 344,
+ /* 1780 */ 93, 43, 347, 35, 35, 35, 35, 352, 377, 354,
+ /* 1790 */ 93, 35, 381, 382, 383, 384, 385, 386, 93, 388,
+ /* 1800 */ 2, 22, 43, 197, 311, 92, 46, 46, 93, 92,
+ /* 1810 */ 22, 93, 377, 93, 92, 235, 381, 382, 383, 384,
+ /* 1820 */ 385, 386, 92, 388, 93, 92, 199, 92, 103, 35,
+ /* 1830 */ 35, 92, 339, 93, 35, 92, 35, 93, 92, 35,
+ /* 1840 */ 347, 35, 22, 116, 92, 352, 93, 354, 93, 92,
+ /* 1850 */ 116, 35, 116, 116, 92, 311, 92, 92, 104, 22,
+ /* 1860 */ 43, 35, 62, 61, 35, 311, 35, 35, 35, 35,
+ /* 1870 */ 377, 35, 90, 35, 381, 382, 383, 384, 385, 386,
+ /* 1880 */ 35, 388, 35, 339, 35, 43, 68, 35, 22, 35,
+ /* 1890 */ 22, 347, 35, 339, 35, 68, 352, 35, 354, 35,
+ /* 1900 */ 35, 347, 35, 22, 35, 35, 352, 0, 354, 35,
+ /* 1910 */ 47, 39, 0, 35, 39, 0, 39, 35, 311, 0,
+ /* 1920 */ 47, 377, 35, 47, 39, 381, 382, 383, 384, 385,
+ /* 1930 */ 386, 377, 388, 47, 311, 381, 382, 383, 384, 385,
+ /* 1940 */ 386, 0, 388, 35, 35, 0, 339, 22, 21, 429,
+ /* 1950 */ 22, 22, 21, 20, 347, 429, 429, 429, 311, 352,
+ /* 1960 */ 429, 354, 339, 429, 429, 429, 429, 429, 429, 429,
+ /* 1970 */ 347, 429, 429, 429, 429, 352, 429, 354, 429, 429,
+ /* 1980 */ 429, 429, 429, 429, 377, 429, 339, 429, 381, 382,
+ /* 1990 */ 383, 384, 385, 386, 347, 388, 429, 429, 429, 352,
+ /* 2000 */ 377, 354, 429, 429, 381, 382, 383, 384, 385, 386,
+ /* 2010 */ 311, 388, 429, 429, 429, 429, 429, 429, 429, 429,
+ /* 2020 */ 429, 429, 429, 429, 377, 429, 429, 429, 381, 382,
+ /* 2030 */ 383, 384, 385, 386, 311, 388, 429, 429, 339, 429,
+ /* 2040 */ 429, 429, 429, 429, 429, 429, 347, 429, 429, 429,
+ /* 2050 */ 429, 352, 429, 354, 429, 429, 429, 429, 311, 429,
+ /* 2060 */ 429, 429, 339, 429, 429, 429, 429, 429, 429, 429,
+ /* 2070 */ 347, 429, 429, 429, 311, 352, 377, 354, 429, 429,
+ /* 2080 */ 381, 382, 383, 384, 385, 386, 339, 388, 429, 429,
+ /* 2090 */ 429, 429, 429, 429, 347, 429, 429, 429, 429, 352,
+ /* 2100 */ 377, 354, 339, 429, 381, 382, 383, 384, 385, 386,
+ /* 2110 */ 347, 388, 429, 429, 429, 352, 429, 354, 429, 429,
+ /* 2120 */ 429, 429, 429, 429, 377, 429, 429, 429, 381, 382,
+ /* 2130 */ 383, 384, 385, 386, 429, 388, 429, 429, 429, 429,
+ /* 2140 */ 377, 429, 429, 429, 381, 382, 383, 384, 385, 386,
+ /* 2150 */ 429, 388, 311, 429, 429, 429, 429, 429, 429, 429,
+ /* 2160 */ 429, 429, 429, 429, 429, 429, 429, 429, 429, 429,
+ /* 2170 */ 429, 429, 429, 429, 429, 429, 429, 429, 429, 429,
+ /* 2180 */ 339, 429, 429, 429, 429, 429, 429, 429, 347, 429,
+ /* 2190 */ 429, 429, 429, 352, 429, 354, 429, 429, 429, 429,
+ /* 2200 */ 429, 429, 429, 311, 429, 429, 429, 429, 429, 429,
+ /* 2210 */ 429, 429, 429, 311, 429, 429, 429, 429, 377, 429,
+ /* 2220 */ 429, 429, 381, 382, 383, 384, 385, 386, 429, 388,
+ /* 2230 */ 429, 339, 429, 429, 429, 429, 429, 429, 429, 347,
+ /* 2240 */ 429, 339, 429, 429, 352, 429, 354, 429, 429, 347,
+ /* 2250 */ 429, 429, 429, 429, 352, 429, 354, 429, 429, 429,
+ /* 2260 */ 429, 429, 429, 429, 429, 429, 311, 429, 429, 377,
+ /* 2270 */ 429, 429, 429, 381, 382, 383, 384, 385, 386, 377,
+ /* 2280 */ 388, 429, 311, 381, 382, 383, 384, 385, 386, 429,
+ /* 2290 */ 388, 429, 429, 429, 339, 429, 429, 429, 429, 429,
+ /* 2300 */ 429, 429, 347, 429, 429, 429, 311, 352, 429, 354,
+ /* 2310 */ 339, 429, 429, 429, 429, 429, 429, 429, 347, 429,
+ /* 2320 */ 429, 429, 311, 352, 429, 354, 429, 429, 429, 429,
+ /* 2330 */ 429, 429, 377, 429, 339, 429, 381, 382, 383, 384,
+ /* 2340 */ 385, 386, 347, 388, 429, 429, 311, 352, 377, 354,
+ /* 2350 */ 339, 429, 381, 382, 383, 384, 385, 386, 347, 388,
+ /* 2360 */ 429, 429, 429, 352, 429, 354, 429, 429, 429, 429,
+ /* 2370 */ 311, 429, 377, 429, 339, 429, 381, 382, 383, 384,
+ /* 2380 */ 385, 386, 347, 388, 429, 429, 311, 352, 377, 354,
+ /* 2390 */ 429, 429, 381, 382, 383, 384, 385, 386, 339, 388,
+ /* 2400 */ 429, 429, 429, 429, 429, 429, 347, 429, 429, 429,
+ /* 2410 */ 429, 352, 377, 354, 339, 429, 381, 382, 383, 384,
+ /* 2420 */ 385, 386, 347, 388, 429, 429, 429, 352, 429, 354,
+ /* 2430 */ 429, 429, 429, 429, 429, 429, 377, 429, 429, 429,
+ /* 2440 */ 381, 382, 383, 384, 385, 386, 429, 388, 429, 429,
+ /* 2450 */ 429, 429, 377, 429, 429, 429, 381, 382, 383, 384,
+ /* 2460 */ 385, 386, 429, 388,
};
-#define YY_SHIFT_COUNT (671)
+#define YY_SHIFT_COUNT (673)
#define YY_SHIFT_MIN (0)
#define YY_SHIFT_MAX (1945)
static const unsigned short int yy_shift_ofst[] = {
- /* 0 */ 1281, 0, 0, 204, 204, 408, 408, 408, 612, 612,
- /* 10 */ 408, 408, 816, 1020, 1224, 1020, 1020, 1020, 1020, 1020,
- /* 20 */ 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020,
- /* 30 */ 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020, 1020,
- /* 40 */ 1020, 1020, 231, 231, 150, 150, 150, 1293, 1293, 239,
- /* 50 */ 1293, 1293, 211, 225, 244, 367, 244, 20, 20, 84,
- /* 60 */ 84, 5, 67, 244, 244, 20, 20, 20, 20, 20,
- /* 70 */ 20, 20, 20, 20, 20, 55, 20, 20, 20, 242,
- /* 80 */ 20, 20, 269, 20, 20, 269, 288, 20, 269, 269,
- /* 90 */ 269, 20, 443, 203, 536, 944, 944, 217, 608, 608,
- /* 100 */ 608, 608, 608, 608, 608, 608, 608, 608, 608, 608,
- /* 110 */ 608, 608, 608, 608, 608, 608, 608, 555, 781, 67,
- /* 120 */ 313, 313, 111, 474, 429, 559, 559, 559, 474, 361,
- /* 130 */ 361, 242, 8, 8, 269, 269, 475, 475, 326, 525,
- /* 140 */ 72, 72, 72, 72, 72, 72, 72, 1084, 137, 261,
- /* 150 */ 707, 133, 348, 29, 441, 542, 14, 642, 827, 705,
- /* 160 */ 568, 692, 568, 851, 359, 359, 359, 739, 750, 912,
- /* 170 */ 1124, 1007, 1136, 1161, 1161, 1136, 1033, 1033, 1161, 1161,
- /* 180 */ 1161, 1173, 1173, 1185, 55, 242, 55, 1192, 1194, 55,
- /* 190 */ 1192, 55, 55, 55, 1161, 55, 1173, 269, 269, 269,
- /* 200 */ 269, 269, 269, 269, 269, 269, 269, 269, 1161, 1173,
- /* 210 */ 475, 1185, 443, 1092, 242, 443, 1161, 1161, 1192, 443,
- /* 220 */ 1057, 475, 475, 475, 475, 1057, 475, 1138, 443, 326,
- /* 230 */ 443, 361, 1291, 475, 1075, 1057, 475, 475, 1075, 1057,
- /* 240 */ 475, 475, 269, 1087, 1168, 1075, 1088, 1093, 1100, 912,
- /* 250 */ 1115, 361, 1315, 1096, 1099, 1101, 1096, 1099, 1096, 1099,
- /* 260 */ 1258, 1262, 475, 525, 1161, 443, 1327, 1173, 2522, 2522,
- /* 270 */ 2522, 2522, 2522, 2522, 2522, 69, 1735, 23, 419, 270,
- /* 280 */ 310, 351, 377, 552, 562, 575, 644, 721, 721, 721,
- /* 290 */ 721, 721, 721, 721, 721, 677, 324, 12, 12, 480,
- /* 300 */ 273, 346, 345, 374, 450, 106, 584, 479, 417, 417,
- /* 310 */ 417, 417, 904, 491, 932, 868, 877, 879, 885, 1038,
- /* 320 */ 1039, 1046, 998, 824, 1044, 1050, 1051, 1054, 1081, 1083,
- /* 330 */ 1091, 1005, 945, 558, 797, 1105, 54, 954, 926, 1106,
- /* 340 */ 1006, 1107, 1108, 1109, 1110, 1111, 1113, 697, 1120, 1145,
- /* 350 */ 1024, 1041, 1381, 1385, 1207, 1388, 1389, 1351, 1394, 1360,
- /* 360 */ 1210, 1365, 1366, 1367, 1214, 1404, 1371, 1373, 1221, 1417,
- /* 370 */ 1251, 1441, 1408, 1444, 1426, 1451, 1418, 1278, 1283, 1456,
- /* 380 */ 1463, 1290, 1292, 1460, 1461, 1422, 1479, 1480, 1481, 1434,
- /* 390 */ 1477, 1482, 1484, 1336, 1490, 1497, 1499, 1507, 1509, 1375,
- /* 400 */ 1483, 1511, 1376, 1523, 1524, 1529, 1530, 1531, 1532, 1533,
- /* 410 */ 1534, 1535, 1536, 1538, 1539, 1540, 1542, 1501, 1544, 1545,
- /* 420 */ 1546, 1547, 1548, 1549, 1528, 1551, 1552, 1554, 1555, 1556,
- /* 430 */ 1502, 1557, 1503, 1560, 1562, 1521, 1525, 1522, 1553, 1527,
- /* 440 */ 1558, 1537, 1570, 1550, 1541, 1571, 1574, 1575, 1564, 1413,
- /* 450 */ 1585, 1586, 1587, 1516, 1579, 1588, 1559, 1561, 1565, 1589,
- /* 460 */ 1566, 1563, 1567, 1592, 1582, 1572, 1581, 1593, 1591, 1576,
- /* 470 */ 1583, 1605, 1624, 1627, 1628, 1543, 1573, 1594, 1608, 1631,
- /* 480 */ 1597, 1598, 1596, 1600, 1601, 1606, 1613, 1640, 1622, 1646,
- /* 490 */ 1625, 1599, 1649, 1629, 1619, 1655, 1623, 1657, 1632, 1659,
- /* 500 */ 1641, 1642, 1660, 1505, 1634, 1671, 1498, 1650, 1515, 1520,
- /* 510 */ 1677, 1678, 1568, 1577, 1685, 1692, 1693, 1604, 1610, 1653,
- /* 520 */ 1506, 1689, 1617, 1569, 1618, 1703, 1670, 1580, 1620, 1611,
- /* 530 */ 1666, 1673, 1486, 1635, 1630, 1639, 1633, 1645, 1643, 1674,
- /* 540 */ 1652, 1647, 1651, 1654, 1661, 1697, 1667, 1668, 1656, 1702,
- /* 550 */ 1517, 1663, 1664, 1686, 1504, 1708, 1710, 1717, 1675, 1722,
- /* 560 */ 1584, 1679, 1713, 1734, 1736, 1738, 1739, 1740, 1679, 1790,
- /* 570 */ 1764, 1602, 1750, 1704, 1707, 1706, 1709, 1711, 1714, 1753,
- /* 580 */ 1712, 1716, 1758, 1785, 1612, 1721, 1715, 1723, 1780, 1783,
- /* 590 */ 1729, 1731, 1788, 1730, 1743, 1794, 1741, 1745, 1795, 1755,
- /* 600 */ 1752, 1811, 1757, 1747, 1754, 1756, 1759, 1803, 1746, 1762,
- /* 610 */ 1763, 1814, 1774, 1831, 1831, 1832, 1813, 1816, 1844, 1845,
- /* 620 */ 1846, 1847, 1848, 1849, 1851, 1853, 1824, 1806, 1855, 1860,
- /* 630 */ 1861, 1877, 1865, 1880, 1868, 1869, 1843, 1596, 1879, 1600,
- /* 640 */ 1881, 1882, 1883, 1884, 1898, 1886, 1922, 1889, 1878, 1887,
- /* 650 */ 1927, 1894, 1885, 1895, 1931, 1901, 1890, 1899, 1933, 1904,
- /* 660 */ 1893, 1902, 1942, 1908, 1909, 1945, 1924, 1928, 1926, 1929,
- /* 670 */ 1934, 1930,
+ /* 0 */ 505, 0, 0, 206, 206, 412, 412, 412, 618, 618,
+ /* 10 */ 412, 412, 824, 1030, 1236, 1030, 1030, 1030, 1030, 1030,
+ /* 20 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 30 */ 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030, 1030,
+ /* 40 */ 1030, 1030, 33, 33, 296, 296, 296, 543, 543, 107,
+ /* 50 */ 543, 543, 433, 30, 6, 200, 6, 73, 73, 21,
+ /* 60 */ 21, 11, 51, 6, 6, 73, 73, 73, 73, 73,
+ /* 70 */ 73, 73, 73, 73, 73, 56, 73, 73, 73, 243,
+ /* 80 */ 73, 73, 285, 73, 73, 285, 377, 73, 285, 285,
+ /* 90 */ 285, 73, 403, 205, 700, 893, 893, 80, 611, 611,
+ /* 100 */ 611, 611, 611, 611, 611, 611, 611, 611, 611, 611,
+ /* 110 */ 611, 611, 611, 611, 611, 611, 611, 346, 394, 51,
+ /* 120 */ 628, 628, 461, 714, 643, 431, 431, 431, 714, 417,
+ /* 130 */ 417, 243, 567, 567, 285, 285, 479, 479, 402, 526,
+ /* 140 */ 257, 257, 257, 257, 257, 257, 257, 1035, 840, 15,
+ /* 150 */ 663, 562, 630, 81, 106, 446, 380, 661, 687, 797,
+ /* 160 */ 533, 455, 533, 851, 860, 860, 860, 777, 859, 954,
+ /* 170 */ 1147, 1036, 1167, 1204, 1204, 1167, 1101, 1101, 1204, 1204,
+ /* 180 */ 1204, 1246, 1246, 1247, 56, 243, 56, 1256, 1261, 56,
+ /* 190 */ 1256, 56, 56, 56, 1204, 56, 1246, 285, 285, 285,
+ /* 200 */ 285, 285, 285, 285, 285, 285, 285, 285, 1204, 1246,
+ /* 210 */ 479, 1247, 403, 1127, 243, 403, 1204, 1204, 1256, 403,
+ /* 220 */ 1091, 479, 479, 479, 479, 1091, 479, 1173, 403, 402,
+ /* 230 */ 403, 417, 1327, 479, 1120, 1091, 479, 479, 1120, 1091,
+ /* 240 */ 479, 479, 285, 1117, 1205, 1120, 1124, 1126, 1141, 954,
+ /* 250 */ 1148, 417, 1357, 1135, 1139, 1137, 1135, 1139, 1135, 1139,
+ /* 260 */ 1297, 1309, 479, 526, 1204, 403, 1382, 1246, 2464, 2464,
+ /* 270 */ 2464, 2464, 2464, 2464, 2464, 69, 130, 164, 423, 153,
+ /* 280 */ 269, 378, 475, 536, 646, 921, 457, 675, 675, 675,
+ /* 290 */ 675, 675, 675, 675, 675, 1093, 672, 36, 36, 557,
+ /* 300 */ 48, 365, 27, 765, 139, 329, 129, 351, 424, 424,
+ /* 310 */ 424, 424, 868, 917, 927, 867, 869, 897, 914, 948,
+ /* 320 */ 995, 1023, 925, 814, 969, 1003, 1008, 1010, 1038, 1040,
+ /* 330 */ 1063, 976, 941, 901, 940, 1100, 1022, 1031, 1017, 1106,
+ /* 340 */ 1033, 1080, 1107, 1118, 1128, 1160, 1162, 993, 1067, 1111,
+ /* 350 */ 810, 357, 1429, 1456, 1254, 1458, 1460, 1421, 1468, 1436,
+ /* 360 */ 1279, 1437, 1438, 1439, 1284, 1476, 1442, 1443, 1288, 1480,
+ /* 370 */ 1290, 1483, 1449, 1485, 1464, 1488, 1454, 1314, 1319, 1491,
+ /* 380 */ 1494, 1325, 1333, 1504, 1505, 1461, 1506, 1508, 1509, 1469,
+ /* 390 */ 1510, 1512, 1513, 1362, 1516, 1517, 1518, 1519, 1520, 1374,
+ /* 400 */ 1489, 1525, 1379, 1527, 1529, 1531, 1532, 1533, 1534, 1536,
+ /* 410 */ 1537, 1538, 1540, 1541, 1542, 1545, 1546, 1507, 1547, 1548,
+ /* 420 */ 1550, 1551, 1552, 1563, 1543, 1566, 1567, 1568, 1569, 1571,
+ /* 430 */ 1498, 1555, 1500, 1573, 1574, 1535, 1539, 1549, 1561, 1530,
+ /* 440 */ 1565, 1553, 1581, 1557, 1556, 1582, 1584, 1586, 1562, 1423,
+ /* 450 */ 1589, 1590, 1591, 1564, 1593, 1594, 1570, 1560, 1585, 1602,
+ /* 460 */ 1577, 1578, 1588, 1603, 1595, 1587, 1592, 1604, 1597, 1601,
+ /* 470 */ 1596, 1608, 1609, 1629, 1633, 1558, 1559, 1614, 1615, 1638,
+ /* 480 */ 1616, 1617, 1610, 1611, 1622, 1625, 1639, 1662, 1641, 1665,
+ /* 490 */ 1644, 1618, 1668, 1648, 1637, 1673, 1642, 1675, 1643, 1676,
+ /* 500 */ 1657, 1619, 1680, 1522, 1646, 1684, 1511, 1663, 1572, 1528,
+ /* 510 */ 1690, 1691, 1579, 1575, 1692, 1693, 1695, 1605, 1613, 1669,
+ /* 520 */ 1521, 1708, 1621, 1576, 1634, 1709, 1671, 1599, 1635, 1612,
+ /* 530 */ 1679, 1672, 1495, 1636, 1649, 1651, 1652, 1654, 1656, 1686,
+ /* 540 */ 1658, 1660, 1661, 1667, 1664, 1688, 1698, 1703, 1685, 1711,
+ /* 550 */ 1499, 1683, 1687, 1714, 1482, 1721, 1726, 1732, 1697, 1738,
+ /* 560 */ 1580, 1705, 1706, 1748, 1749, 1750, 1751, 1756, 1705, 1798,
+ /* 570 */ 1779, 1606, 1759, 1713, 1715, 1717, 1718, 1722, 1720, 1760,
+ /* 580 */ 1730, 1733, 1761, 1788, 1627, 1735, 1725, 1731, 1794, 1795,
+ /* 590 */ 1739, 1740, 1799, 1743, 1744, 1801, 1746, 1753, 1804, 1752,
+ /* 600 */ 1755, 1806, 1757, 1727, 1734, 1736, 1737, 1820, 1754, 1762,
+ /* 610 */ 1764, 1816, 1765, 1817, 1817, 1837, 1800, 1802, 1826, 1829,
+ /* 620 */ 1831, 1832, 1833, 1834, 1836, 1838, 1845, 1847, 1818, 1782,
+ /* 630 */ 1842, 1849, 1852, 1866, 1854, 1868, 1857, 1859, 1827, 1610,
+ /* 640 */ 1862, 1611, 1864, 1865, 1867, 1869, 1881, 1870, 1907, 1874,
+ /* 650 */ 1863, 1872, 1912, 1878, 1873, 1875, 1915, 1882, 1876, 1877,
+ /* 660 */ 1919, 1887, 1886, 1885, 1941, 1908, 1909, 1945, 1925, 1927,
+ /* 670 */ 1928, 1929, 1931, 1933,
};
#define YY_REDUCE_COUNT (274)
-#define YY_REDUCE_MIN (-359)
-#define YY_REDUCE_MAX (2135)
+#define YY_REDUCE_MIN (-386)
+#define YY_REDUCE_MAX (2075)
static const short yy_reduce_ofst[] = {
- /* 0 */ 176, -308, 135, 333, 530, -84, 725, 1133, 1216, 1300,
- /* 10 */ 113, 317, 551, 699, 902, 1032, 1112, 618, 1232, 1316,
- /* 20 */ 1378, 1397, 1458, 1476, 1526, 1578, 1626, 1638, 1688, 1705,
- /* 30 */ 1768, 1784, 1836, 1852, 1892, 1914, 1954, 1972, 2022, 2034,
- /* 40 */ 2085, 2135, -300, 1467, -306, -279, 79, -119, 151, 439,
- /* 50 */ 503, 516, -359, 234, 266, 482, 645, -314, 52, -311,
- /* 60 */ -297, -186, -245, -115, 141, -287, -285, 344, 446, 520,
- /* 70 */ 526, 541, 553, 633, 649, -63, 658, 664, 668, -352,
- /* 80 */ 720, 728, -267, 741, 767, -236, -221, 785, 193, 130,
- /* 90 */ 300, 799, -26, 219, -260, -260, -260, -228, -225, 222,
- /* 100 */ 286, 291, 373, 395, 400, 423, 435, 455, 481, 484,
- /* 110 */ 500, 523, 547, 565, 567, 590, 598, -114, -213, -39,
- /* 120 */ 122, 241, 226, 34, 354, -204, 58, 458, 341, 32,
- /* 130 */ 293, 329, 386, 414, 405, 321, 545, 571, 611, -168,
- /* 140 */ -323, 185, 290, 355, 495, 570, 626, 412, 569, 230,
- /* 150 */ 557, 469, 604, 534, 635, 635, 662, 675, 708, 686,
- /* 160 */ 663, 663, 663, 695, 680, 682, 696, 719, 635, 784,
- /* 170 */ 787, 808, 822, 866, 867, 828, 831, 833, 872, 873,
- /* 180 */ 874, 884, 892, 835, 886, 856, 889, 849, 875, 896,
- /* 190 */ 876, 917, 922, 924, 931, 928, 939, 914, 916, 918,
- /* 200 */ 919, 921, 927, 929, 930, 933, 934, 935, 946, 950,
- /* 210 */ 915, 897, 955, 903, 923, 957, 961, 962, 925, 968,
- /* 220 */ 937, 940, 948, 951, 952, 943, 958, 942, 976, 974,
- /* 230 */ 990, 965, 938, 963, 906, 960, 971, 973, 913, 967,
- /* 240 */ 975, 979, 635, 920, 941, 936, 947, 949, 956, 969,
- /* 250 */ 663, 999, 978, 959, 953, 964, 966, 972, 970, 977,
- /* 260 */ 980, 1015, 1009, 1035, 1043, 1047, 1053, 1056, 1000, 1012,
- /* 270 */ 1045, 1048, 1052, 1058, 1063,
+ /* 0 */ 29, -307, 115, 793, 383, -82, 939, 999, 1115, 1176,
+ /* 10 */ 500, 620, 1233, 219, 1259, 603, 753, 1317, 1335, 1385,
+ /* 20 */ 1411, 1435, 1493, 1544, 1554, 1607, 1623, 1647, 1699, 1723,
+ /* 30 */ 1747, 1763, 1841, 1892, 1902, 1955, 1971, 1995, 2011, 2035,
+ /* 40 */ 2059, 2075, -305, 1007, -74, 189, 673, -55, 563, 109,
+ /* 50 */ -333, -97, -366, -361, -131, 300, 366, 190, 240, -315,
+ /* 60 */ -308, -386, -263, -173, -149, -160, -81, 54, 374, 613,
+ /* 70 */ 626, 652, 660, 725, 729, -251, 737, 780, 833, -297,
+ /* 80 */ 835, 836, 50, 838, 882, -96, 185, 932, 147, -86,
+ /* 90 */ 154, 933, -316, -283, -376, -376, -376, -273, -229, -174,
+ /* 100 */ 208, 220, 246, 284, 323, 326, 359, 371, 391, 418,
+ /* 110 */ 420, 437, 499, 501, 503, 537, 547, -19, 71, 75,
+ /* 120 */ 199, 350, 373, 458, -94, -18, 253, 372, 549, 430,
+ /* 130 */ 515, 221, -34, 70, 502, 521, 538, 551, 578, 312,
+ /* 140 */ -329, 309, 328, 337, 386, 572, 606, 472, 657, 591,
+ /* 150 */ 719, 653, 741, 680, 770, 770, 808, 830, 791, 773,
+ /* 160 */ 755, 755, 755, 766, 746, 748, 751, 778, 770, 816,
+ /* 170 */ 822, 853, 864, 906, 907, 895, 902, 903, 942, 945,
+ /* 180 */ 946, 955, 957, 899, 950, 920, 952, 911, 915, 959,
+ /* 190 */ 918, 962, 964, 965, 970, 967, 981, 956, 958, 960,
+ /* 200 */ 961, 963, 966, 968, 972, 973, 974, 975, 977, 985,
+ /* 210 */ 949, 930, 987, 937, 978, 994, 998, 1000, 971, 997,
+ /* 220 */ 979, 988, 990, 991, 992, 986, 1004, 989, 1012, 1020,
+ /* 230 */ 1018, 1005, 980, 1006, 944, 1001, 1009, 1014, 984, 1011,
+ /* 240 */ 1015, 1016, 770, 953, 983, 1002, 1013, 982, 996, 1024,
+ /* 250 */ 755, 1032, 1021, 1034, 1037, 1027, 1041, 1039, 1042, 1044,
+ /* 260 */ 1019, 1059, 1051, 1075, 1097, 1096, 1105, 1108, 1050, 1057,
+ /* 270 */ 1090, 1095, 1099, 1102, 1121,
};
static const YYACTIONTYPE yy_default[] = {
- /* 0 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 10 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 20 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 30 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 40 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 50 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 60 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 70 */ 1472, 1472, 1472, 1472, 1472, 1546, 1472, 1472, 1472, 1472,
- /* 80 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 90 */ 1472, 1472, 1544, 1706, 1472, 1881, 1472, 1472, 1472, 1472,
- /* 100 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 110 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 120 */ 1472, 1472, 1546, 1472, 1544, 1893, 1893, 1893, 1472, 1472,
- /* 130 */ 1472, 1472, 1747, 1747, 1472, 1472, 1472, 1472, 1646, 1472,
- /* 140 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1741, 1472, 1962,
- /* 150 */ 1472, 1472, 1472, 1916, 1472, 1472, 1472, 1472, 1599, 1908,
- /* 160 */ 1885, 1899, 1886, 1883, 1947, 1947, 1947, 1902, 1472, 1912,
- /* 170 */ 1472, 1734, 1711, 1472, 1472, 1711, 1708, 1708, 1472, 1472,
- /* 180 */ 1472, 1472, 1472, 1472, 1546, 1472, 1546, 1472, 1472, 1546,
- /* 190 */ 1472, 1546, 1546, 1546, 1472, 1546, 1472, 1472, 1472, 1472,
- /* 200 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 210 */ 1472, 1472, 1544, 1743, 1472, 1544, 1472, 1472, 1472, 1544,
- /* 220 */ 1921, 1472, 1472, 1472, 1472, 1921, 1472, 1472, 1544, 1472,
- /* 230 */ 1544, 1472, 1472, 1472, 1923, 1921, 1472, 1472, 1923, 1921,
- /* 240 */ 1472, 1472, 1472, 1935, 1931, 1923, 1939, 1937, 1914, 1912,
- /* 250 */ 1899, 1472, 1472, 1953, 1949, 1965, 1953, 1949, 1953, 1949,
- /* 260 */ 1472, 1615, 1472, 1472, 1472, 1544, 1504, 1472, 1736, 1747,
- /* 270 */ 1649, 1649, 1649, 1547, 1477, 1472, 1472, 1472, 1472, 1472,
- /* 280 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1818, 1934, 1933,
- /* 290 */ 1857, 1856, 1855, 1853, 1817, 1472, 1611, 1816, 1815, 1472,
- /* 300 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1809, 1810,
- /* 310 */ 1808, 1807, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 320 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 330 */ 1472, 1882, 1472, 1950, 1954, 1472, 1472, 1472, 1472, 1472,
- /* 340 */ 1793, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 350 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 360 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 370 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 380 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 390 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 400 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 410 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 420 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 430 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1509, 1472, 1472,
- /* 440 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 450 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 460 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 470 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 480 */ 1472, 1472, 1582, 1581, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 490 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 500 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 510 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 520 */ 1472, 1751, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 530 */ 1472, 1915, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 540 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1793, 1472, 1932,
- /* 550 */ 1472, 1892, 1888, 1472, 1472, 1884, 1792, 1472, 1472, 1948,
- /* 560 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1877,
- /* 570 */ 1472, 1472, 1850, 1835, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 580 */ 1472, 1472, 1472, 1472, 1803, 1472, 1472, 1472, 1472, 1472,
- /* 590 */ 1643, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 600 */ 1472, 1472, 1472, 1628, 1626, 1625, 1624, 1472, 1621, 1472,
- /* 610 */ 1472, 1472, 1472, 1652, 1651, 1472, 1472, 1472, 1472, 1472,
- /* 620 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1565, 1472,
- /* 630 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1557, 1472, 1556,
- /* 640 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 650 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 660 */ 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472, 1472,
- /* 670 */ 1472, 1472,
+ /* 0 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 10 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 20 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 30 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 40 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 50 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 60 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 70 */ 1478, 1478, 1478, 1478, 1478, 1552, 1478, 1478, 1478, 1478,
+ /* 80 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 90 */ 1478, 1478, 1550, 1714, 1478, 1889, 1478, 1478, 1478, 1478,
+ /* 100 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 110 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 120 */ 1478, 1478, 1552, 1478, 1550, 1901, 1901, 1901, 1478, 1478,
+ /* 130 */ 1478, 1478, 1755, 1755, 1478, 1478, 1478, 1478, 1654, 1478,
+ /* 140 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1749, 1478, 1970,
+ /* 150 */ 1478, 1478, 1478, 1924, 1478, 1478, 1478, 1478, 1607, 1916,
+ /* 160 */ 1893, 1907, 1894, 1891, 1955, 1955, 1955, 1910, 1478, 1920,
+ /* 170 */ 1478, 1742, 1719, 1478, 1478, 1719, 1716, 1716, 1478, 1478,
+ /* 180 */ 1478, 1478, 1478, 1478, 1552, 1478, 1552, 1478, 1478, 1552,
+ /* 190 */ 1478, 1552, 1552, 1552, 1478, 1552, 1478, 1478, 1478, 1478,
+ /* 200 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 210 */ 1478, 1478, 1550, 1751, 1478, 1550, 1478, 1478, 1478, 1550,
+ /* 220 */ 1929, 1478, 1478, 1478, 1478, 1929, 1478, 1478, 1550, 1478,
+ /* 230 */ 1550, 1478, 1478, 1478, 1931, 1929, 1478, 1478, 1931, 1929,
+ /* 240 */ 1478, 1478, 1478, 1943, 1939, 1931, 1947, 1945, 1922, 1920,
+ /* 250 */ 1907, 1478, 1478, 1961, 1957, 1973, 1961, 1957, 1961, 1957,
+ /* 260 */ 1478, 1623, 1478, 1478, 1478, 1550, 1510, 1478, 1744, 1755,
+ /* 270 */ 1657, 1657, 1657, 1553, 1483, 1478, 1478, 1478, 1478, 1478,
+ /* 280 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1826, 1942, 1941,
+ /* 290 */ 1865, 1864, 1863, 1861, 1825, 1478, 1619, 1824, 1823, 1478,
+ /* 300 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1817, 1818,
+ /* 310 */ 1816, 1815, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 320 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 330 */ 1478, 1890, 1478, 1958, 1962, 1478, 1478, 1478, 1478, 1478,
+ /* 340 */ 1801, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 350 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 360 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 370 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 380 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 390 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 400 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 410 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 420 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 430 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1515, 1478, 1478,
+ /* 440 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 450 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 460 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 470 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 480 */ 1478, 1478, 1590, 1589, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 490 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 500 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 510 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 520 */ 1478, 1759, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 530 */ 1478, 1923, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 540 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1801, 1478, 1940,
+ /* 550 */ 1478, 1900, 1896, 1478, 1478, 1892, 1800, 1478, 1478, 1956,
+ /* 560 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1885,
+ /* 570 */ 1478, 1478, 1858, 1843, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 580 */ 1478, 1478, 1478, 1478, 1811, 1478, 1478, 1478, 1478, 1478,
+ /* 590 */ 1651, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 600 */ 1478, 1478, 1478, 1636, 1634, 1633, 1632, 1478, 1629, 1478,
+ /* 610 */ 1478, 1478, 1478, 1660, 1659, 1478, 1478, 1478, 1478, 1478,
+ /* 620 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 630 */ 1571, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1563,
+ /* 640 */ 1478, 1562, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 650 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 660 */ 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478, 1478,
+ /* 670 */ 1478, 1478, 1478, 1478,
};
/********** End of lemon-generated parsing tables *****************************/
@@ -1009,6 +997,8 @@ static const YYCODETYPE yyFallback[] = {
0, /* WAL_ROLL_PERIOD => nothing */
0, /* WAL_SEGMENT_SIZE => nothing */
0, /* SST_TRIGGER => nothing */
+ 0, /* TABLE_PREFIX => nothing */
+ 0, /* TABLE_SUFFIX => nothing */
0, /* NK_COLON => nothing */
0, /* TABLE => nothing */
0, /* NK_LP => nothing */
@@ -1175,58 +1165,58 @@ static const YYCODETYPE yyFallback[] = {
0, /* ASC => nothing */
0, /* NULLS => nothing */
0, /* ABORT => nothing */
- 253, /* AFTER => ABORT */
- 253, /* ATTACH => ABORT */
- 253, /* BEFORE => ABORT */
- 253, /* BEGIN => ABORT */
- 253, /* BITAND => ABORT */
- 253, /* BITNOT => ABORT */
- 253, /* BITOR => ABORT */
- 253, /* BLOCKS => ABORT */
- 253, /* CHANGE => ABORT */
- 253, /* COMMA => ABORT */
- 253, /* COMPACT => ABORT */
- 253, /* CONCAT => ABORT */
- 253, /* CONFLICT => ABORT */
- 253, /* COPY => ABORT */
- 253, /* DEFERRED => ABORT */
- 253, /* DELIMITERS => ABORT */
- 253, /* DETACH => ABORT */
- 253, /* DIVIDE => ABORT */
- 253, /* DOT => ABORT */
- 253, /* EACH => ABORT */
- 253, /* END => ABORT */
- 253, /* FAIL => ABORT */
- 253, /* FILE => ABORT */
- 253, /* FOR => ABORT */
- 253, /* GLOB => ABORT */
- 253, /* ID => ABORT */
- 253, /* IMMEDIATE => ABORT */
- 253, /* IMPORT => ABORT */
- 253, /* INITIALLY => ABORT */
- 253, /* INSTEAD => ABORT */
- 253, /* ISNULL => ABORT */
- 253, /* KEY => ABORT */
- 253, /* NK_BITNOT => ABORT */
- 253, /* NK_SEMI => ABORT */
- 253, /* NOTNULL => ABORT */
- 253, /* OF => ABORT */
- 253, /* PLUS => ABORT */
- 253, /* PRIVILEGE => ABORT */
- 253, /* RAISE => ABORT */
- 253, /* REPLACE => ABORT */
- 253, /* RESTRICT => ABORT */
- 253, /* ROW => ABORT */
- 253, /* SEMI => ABORT */
- 253, /* STAR => ABORT */
- 253, /* STATEMENT => ABORT */
- 253, /* STRING => ABORT */
- 253, /* TIMES => ABORT */
- 253, /* UPDATE => ABORT */
- 253, /* VALUES => ABORT */
- 253, /* VARIABLE => ABORT */
- 253, /* VIEW => ABORT */
- 253, /* WAL => ABORT */
+ 255, /* AFTER => ABORT */
+ 255, /* ATTACH => ABORT */
+ 255, /* BEFORE => ABORT */
+ 255, /* BEGIN => ABORT */
+ 255, /* BITAND => ABORT */
+ 255, /* BITNOT => ABORT */
+ 255, /* BITOR => ABORT */
+ 255, /* BLOCKS => ABORT */
+ 255, /* CHANGE => ABORT */
+ 255, /* COMMA => ABORT */
+ 255, /* COMPACT => ABORT */
+ 255, /* CONCAT => ABORT */
+ 255, /* CONFLICT => ABORT */
+ 255, /* COPY => ABORT */
+ 255, /* DEFERRED => ABORT */
+ 255, /* DELIMITERS => ABORT */
+ 255, /* DETACH => ABORT */
+ 255, /* DIVIDE => ABORT */
+ 255, /* DOT => ABORT */
+ 255, /* EACH => ABORT */
+ 255, /* END => ABORT */
+ 255, /* FAIL => ABORT */
+ 255, /* FILE => ABORT */
+ 255, /* FOR => ABORT */
+ 255, /* GLOB => ABORT */
+ 255, /* ID => ABORT */
+ 255, /* IMMEDIATE => ABORT */
+ 255, /* IMPORT => ABORT */
+ 255, /* INITIALLY => ABORT */
+ 255, /* INSTEAD => ABORT */
+ 255, /* ISNULL => ABORT */
+ 255, /* KEY => ABORT */
+ 255, /* NK_BITNOT => ABORT */
+ 255, /* NK_SEMI => ABORT */
+ 255, /* NOTNULL => ABORT */
+ 255, /* OF => ABORT */
+ 255, /* PLUS => ABORT */
+ 255, /* PRIVILEGE => ABORT */
+ 255, /* RAISE => ABORT */
+ 255, /* REPLACE => ABORT */
+ 255, /* RESTRICT => ABORT */
+ 255, /* ROW => ABORT */
+ 255, /* SEMI => ABORT */
+ 255, /* STAR => ABORT */
+ 255, /* STATEMENT => ABORT */
+ 255, /* STRING => ABORT */
+ 255, /* TIMES => ABORT */
+ 255, /* UPDATE => ABORT */
+ 255, /* VALUES => ABORT */
+ 255, /* VARIABLE => ABORT */
+ 255, /* VIEW => ABORT */
+ 255, /* WAL => ABORT */
};
#endif /* YYFALLBACK */
@@ -1402,345 +1392,347 @@ static const char *const yyTokenName[] = {
/* 85 */ "WAL_ROLL_PERIOD",
/* 86 */ "WAL_SEGMENT_SIZE",
/* 87 */ "SST_TRIGGER",
- /* 88 */ "NK_COLON",
- /* 89 */ "TABLE",
- /* 90 */ "NK_LP",
- /* 91 */ "NK_RP",
- /* 92 */ "STABLE",
- /* 93 */ "ADD",
- /* 94 */ "COLUMN",
- /* 95 */ "MODIFY",
- /* 96 */ "RENAME",
- /* 97 */ "TAG",
- /* 98 */ "SET",
- /* 99 */ "NK_EQ",
- /* 100 */ "USING",
- /* 101 */ "TAGS",
- /* 102 */ "COMMENT",
- /* 103 */ "BOOL",
- /* 104 */ "TINYINT",
- /* 105 */ "SMALLINT",
- /* 106 */ "INT",
- /* 107 */ "INTEGER",
- /* 108 */ "BIGINT",
- /* 109 */ "FLOAT",
- /* 110 */ "DOUBLE",
- /* 111 */ "BINARY",
- /* 112 */ "TIMESTAMP",
- /* 113 */ "NCHAR",
- /* 114 */ "UNSIGNED",
- /* 115 */ "JSON",
- /* 116 */ "VARCHAR",
- /* 117 */ "MEDIUMBLOB",
- /* 118 */ "BLOB",
- /* 119 */ "VARBINARY",
- /* 120 */ "DECIMAL",
- /* 121 */ "MAX_DELAY",
- /* 122 */ "WATERMARK",
- /* 123 */ "ROLLUP",
- /* 124 */ "TTL",
- /* 125 */ "SMA",
- /* 126 */ "FIRST",
- /* 127 */ "LAST",
- /* 128 */ "SHOW",
- /* 129 */ "DATABASES",
- /* 130 */ "TABLES",
- /* 131 */ "STABLES",
- /* 132 */ "MNODES",
- /* 133 */ "MODULES",
- /* 134 */ "QNODES",
- /* 135 */ "FUNCTIONS",
- /* 136 */ "INDEXES",
- /* 137 */ "ACCOUNTS",
- /* 138 */ "APPS",
- /* 139 */ "CONNECTIONS",
- /* 140 */ "LICENCES",
- /* 141 */ "GRANTS",
- /* 142 */ "QUERIES",
- /* 143 */ "SCORES",
- /* 144 */ "TOPICS",
- /* 145 */ "VARIABLES",
- /* 146 */ "BNODES",
- /* 147 */ "SNODES",
- /* 148 */ "CLUSTER",
- /* 149 */ "TRANSACTIONS",
- /* 150 */ "DISTRIBUTED",
- /* 151 */ "CONSUMERS",
- /* 152 */ "SUBSCRIPTIONS",
- /* 153 */ "VNODES",
- /* 154 */ "LIKE",
- /* 155 */ "INDEX",
- /* 156 */ "FUNCTION",
- /* 157 */ "INTERVAL",
- /* 158 */ "TOPIC",
- /* 159 */ "AS",
- /* 160 */ "WITH",
- /* 161 */ "META",
- /* 162 */ "CONSUMER",
- /* 163 */ "GROUP",
- /* 164 */ "DESC",
- /* 165 */ "DESCRIBE",
- /* 166 */ "RESET",
- /* 167 */ "QUERY",
- /* 168 */ "CACHE",
- /* 169 */ "EXPLAIN",
- /* 170 */ "ANALYZE",
- /* 171 */ "VERBOSE",
- /* 172 */ "NK_BOOL",
- /* 173 */ "RATIO",
- /* 174 */ "NK_FLOAT",
- /* 175 */ "OUTPUTTYPE",
- /* 176 */ "AGGREGATE",
- /* 177 */ "BUFSIZE",
- /* 178 */ "STREAM",
- /* 179 */ "INTO",
- /* 180 */ "TRIGGER",
- /* 181 */ "AT_ONCE",
- /* 182 */ "WINDOW_CLOSE",
- /* 183 */ "IGNORE",
- /* 184 */ "EXPIRED",
- /* 185 */ "KILL",
- /* 186 */ "CONNECTION",
- /* 187 */ "TRANSACTION",
- /* 188 */ "BALANCE",
- /* 189 */ "VGROUP",
- /* 190 */ "MERGE",
- /* 191 */ "REDISTRIBUTE",
- /* 192 */ "SPLIT",
- /* 193 */ "DELETE",
- /* 194 */ "INSERT",
- /* 195 */ "NULL",
- /* 196 */ "NK_QUESTION",
- /* 197 */ "NK_ARROW",
- /* 198 */ "ROWTS",
- /* 199 */ "TBNAME",
- /* 200 */ "QSTART",
- /* 201 */ "QEND",
- /* 202 */ "QDURATION",
- /* 203 */ "WSTART",
- /* 204 */ "WEND",
- /* 205 */ "WDURATION",
- /* 206 */ "CAST",
- /* 207 */ "NOW",
- /* 208 */ "TODAY",
- /* 209 */ "TIMEZONE",
- /* 210 */ "CLIENT_VERSION",
- /* 211 */ "SERVER_VERSION",
- /* 212 */ "SERVER_STATUS",
- /* 213 */ "CURRENT_USER",
- /* 214 */ "COUNT",
- /* 215 */ "LAST_ROW",
- /* 216 */ "BETWEEN",
- /* 217 */ "IS",
- /* 218 */ "NK_LT",
- /* 219 */ "NK_GT",
- /* 220 */ "NK_LE",
- /* 221 */ "NK_GE",
- /* 222 */ "NK_NE",
- /* 223 */ "MATCH",
- /* 224 */ "NMATCH",
- /* 225 */ "CONTAINS",
- /* 226 */ "IN",
- /* 227 */ "JOIN",
- /* 228 */ "INNER",
- /* 229 */ "SELECT",
- /* 230 */ "DISTINCT",
- /* 231 */ "WHERE",
- /* 232 */ "PARTITION",
- /* 233 */ "BY",
- /* 234 */ "SESSION",
- /* 235 */ "STATE_WINDOW",
- /* 236 */ "SLIDING",
- /* 237 */ "FILL",
- /* 238 */ "VALUE",
- /* 239 */ "NONE",
- /* 240 */ "PREV",
- /* 241 */ "LINEAR",
- /* 242 */ "NEXT",
- /* 243 */ "HAVING",
- /* 244 */ "RANGE",
- /* 245 */ "EVERY",
- /* 246 */ "ORDER",
- /* 247 */ "SLIMIT",
- /* 248 */ "SOFFSET",
- /* 249 */ "LIMIT",
- /* 250 */ "OFFSET",
- /* 251 */ "ASC",
- /* 252 */ "NULLS",
- /* 253 */ "ABORT",
- /* 254 */ "AFTER",
- /* 255 */ "ATTACH",
- /* 256 */ "BEFORE",
- /* 257 */ "BEGIN",
- /* 258 */ "BITAND",
- /* 259 */ "BITNOT",
- /* 260 */ "BITOR",
- /* 261 */ "BLOCKS",
- /* 262 */ "CHANGE",
- /* 263 */ "COMMA",
- /* 264 */ "COMPACT",
- /* 265 */ "CONCAT",
- /* 266 */ "CONFLICT",
- /* 267 */ "COPY",
- /* 268 */ "DEFERRED",
- /* 269 */ "DELIMITERS",
- /* 270 */ "DETACH",
- /* 271 */ "DIVIDE",
- /* 272 */ "DOT",
- /* 273 */ "EACH",
- /* 274 */ "END",
- /* 275 */ "FAIL",
- /* 276 */ "FILE",
- /* 277 */ "FOR",
- /* 278 */ "GLOB",
- /* 279 */ "ID",
- /* 280 */ "IMMEDIATE",
- /* 281 */ "IMPORT",
- /* 282 */ "INITIALLY",
- /* 283 */ "INSTEAD",
- /* 284 */ "ISNULL",
- /* 285 */ "KEY",
- /* 286 */ "NK_BITNOT",
- /* 287 */ "NK_SEMI",
- /* 288 */ "NOTNULL",
- /* 289 */ "OF",
- /* 290 */ "PLUS",
- /* 291 */ "PRIVILEGE",
- /* 292 */ "RAISE",
- /* 293 */ "REPLACE",
- /* 294 */ "RESTRICT",
- /* 295 */ "ROW",
- /* 296 */ "SEMI",
- /* 297 */ "STAR",
- /* 298 */ "STATEMENT",
- /* 299 */ "STRING",
- /* 300 */ "TIMES",
- /* 301 */ "UPDATE",
- /* 302 */ "VALUES",
- /* 303 */ "VARIABLE",
- /* 304 */ "VIEW",
- /* 305 */ "WAL",
- /* 306 */ "cmd",
- /* 307 */ "account_options",
- /* 308 */ "alter_account_options",
- /* 309 */ "literal",
- /* 310 */ "alter_account_option",
- /* 311 */ "user_name",
- /* 312 */ "sysinfo_opt",
- /* 313 */ "privileges",
- /* 314 */ "priv_level",
- /* 315 */ "priv_type_list",
- /* 316 */ "priv_type",
- /* 317 */ "db_name",
- /* 318 */ "dnode_endpoint",
- /* 319 */ "not_exists_opt",
- /* 320 */ "db_options",
- /* 321 */ "exists_opt",
- /* 322 */ "alter_db_options",
- /* 323 */ "integer_list",
- /* 324 */ "variable_list",
- /* 325 */ "retention_list",
- /* 326 */ "alter_db_option",
- /* 327 */ "retention",
- /* 328 */ "full_table_name",
- /* 329 */ "column_def_list",
- /* 330 */ "tags_def_opt",
- /* 331 */ "table_options",
- /* 332 */ "multi_create_clause",
- /* 333 */ "tags_def",
- /* 334 */ "multi_drop_clause",
- /* 335 */ "alter_table_clause",
- /* 336 */ "alter_table_options",
- /* 337 */ "column_name",
- /* 338 */ "type_name",
- /* 339 */ "signed_literal",
- /* 340 */ "create_subtable_clause",
- /* 341 */ "specific_cols_opt",
- /* 342 */ "expression_list",
- /* 343 */ "drop_table_clause",
- /* 344 */ "col_name_list",
- /* 345 */ "table_name",
- /* 346 */ "column_def",
- /* 347 */ "duration_list",
- /* 348 */ "rollup_func_list",
- /* 349 */ "alter_table_option",
- /* 350 */ "duration_literal",
- /* 351 */ "rollup_func_name",
- /* 352 */ "function_name",
- /* 353 */ "col_name",
- /* 354 */ "db_name_cond_opt",
- /* 355 */ "like_pattern_opt",
- /* 356 */ "table_name_cond",
- /* 357 */ "from_db_opt",
- /* 358 */ "index_options",
- /* 359 */ "func_list",
- /* 360 */ "sliding_opt",
- /* 361 */ "sma_stream_opt",
- /* 362 */ "func",
- /* 363 */ "stream_options",
- /* 364 */ "topic_name",
- /* 365 */ "query_expression",
- /* 366 */ "cgroup_name",
- /* 367 */ "analyze_opt",
- /* 368 */ "explain_options",
- /* 369 */ "agg_func_opt",
- /* 370 */ "bufsize_opt",
- /* 371 */ "stream_name",
- /* 372 */ "dnode_list",
- /* 373 */ "where_clause_opt",
- /* 374 */ "signed",
- /* 375 */ "literal_func",
- /* 376 */ "literal_list",
- /* 377 */ "table_alias",
- /* 378 */ "column_alias",
- /* 379 */ "expression",
- /* 380 */ "pseudo_column",
- /* 381 */ "column_reference",
- /* 382 */ "function_expression",
- /* 383 */ "subquery",
- /* 384 */ "star_func",
- /* 385 */ "star_func_para_list",
- /* 386 */ "noarg_func",
- /* 387 */ "other_para_list",
- /* 388 */ "star_func_para",
- /* 389 */ "predicate",
- /* 390 */ "compare_op",
- /* 391 */ "in_op",
- /* 392 */ "in_predicate_value",
- /* 393 */ "boolean_value_expression",
- /* 394 */ "boolean_primary",
- /* 395 */ "common_expression",
- /* 396 */ "from_clause_opt",
- /* 397 */ "table_reference_list",
- /* 398 */ "table_reference",
- /* 399 */ "table_primary",
- /* 400 */ "joined_table",
- /* 401 */ "alias_opt",
- /* 402 */ "parenthesized_joined_table",
- /* 403 */ "join_type",
- /* 404 */ "search_condition",
- /* 405 */ "query_specification",
- /* 406 */ "set_quantifier_opt",
- /* 407 */ "select_list",
- /* 408 */ "partition_by_clause_opt",
- /* 409 */ "range_opt",
- /* 410 */ "every_opt",
- /* 411 */ "fill_opt",
- /* 412 */ "twindow_clause_opt",
- /* 413 */ "group_by_clause_opt",
- /* 414 */ "having_clause_opt",
- /* 415 */ "select_item",
- /* 416 */ "fill_mode",
- /* 417 */ "group_by_list",
- /* 418 */ "query_expression_body",
- /* 419 */ "order_by_clause_opt",
- /* 420 */ "slimit_clause_opt",
- /* 421 */ "limit_clause_opt",
- /* 422 */ "query_primary",
- /* 423 */ "sort_specification_list",
- /* 424 */ "sort_specification",
- /* 425 */ "ordering_specification_opt",
- /* 426 */ "null_ordering_opt",
+ /* 88 */ "TABLE_PREFIX",
+ /* 89 */ "TABLE_SUFFIX",
+ /* 90 */ "NK_COLON",
+ /* 91 */ "TABLE",
+ /* 92 */ "NK_LP",
+ /* 93 */ "NK_RP",
+ /* 94 */ "STABLE",
+ /* 95 */ "ADD",
+ /* 96 */ "COLUMN",
+ /* 97 */ "MODIFY",
+ /* 98 */ "RENAME",
+ /* 99 */ "TAG",
+ /* 100 */ "SET",
+ /* 101 */ "NK_EQ",
+ /* 102 */ "USING",
+ /* 103 */ "TAGS",
+ /* 104 */ "COMMENT",
+ /* 105 */ "BOOL",
+ /* 106 */ "TINYINT",
+ /* 107 */ "SMALLINT",
+ /* 108 */ "INT",
+ /* 109 */ "INTEGER",
+ /* 110 */ "BIGINT",
+ /* 111 */ "FLOAT",
+ /* 112 */ "DOUBLE",
+ /* 113 */ "BINARY",
+ /* 114 */ "TIMESTAMP",
+ /* 115 */ "NCHAR",
+ /* 116 */ "UNSIGNED",
+ /* 117 */ "JSON",
+ /* 118 */ "VARCHAR",
+ /* 119 */ "MEDIUMBLOB",
+ /* 120 */ "BLOB",
+ /* 121 */ "VARBINARY",
+ /* 122 */ "DECIMAL",
+ /* 123 */ "MAX_DELAY",
+ /* 124 */ "WATERMARK",
+ /* 125 */ "ROLLUP",
+ /* 126 */ "TTL",
+ /* 127 */ "SMA",
+ /* 128 */ "FIRST",
+ /* 129 */ "LAST",
+ /* 130 */ "SHOW",
+ /* 131 */ "DATABASES",
+ /* 132 */ "TABLES",
+ /* 133 */ "STABLES",
+ /* 134 */ "MNODES",
+ /* 135 */ "MODULES",
+ /* 136 */ "QNODES",
+ /* 137 */ "FUNCTIONS",
+ /* 138 */ "INDEXES",
+ /* 139 */ "ACCOUNTS",
+ /* 140 */ "APPS",
+ /* 141 */ "CONNECTIONS",
+ /* 142 */ "LICENCES",
+ /* 143 */ "GRANTS",
+ /* 144 */ "QUERIES",
+ /* 145 */ "SCORES",
+ /* 146 */ "TOPICS",
+ /* 147 */ "VARIABLES",
+ /* 148 */ "BNODES",
+ /* 149 */ "SNODES",
+ /* 150 */ "CLUSTER",
+ /* 151 */ "TRANSACTIONS",
+ /* 152 */ "DISTRIBUTED",
+ /* 153 */ "CONSUMERS",
+ /* 154 */ "SUBSCRIPTIONS",
+ /* 155 */ "VNODES",
+ /* 156 */ "LIKE",
+ /* 157 */ "INDEX",
+ /* 158 */ "FUNCTION",
+ /* 159 */ "INTERVAL",
+ /* 160 */ "TOPIC",
+ /* 161 */ "AS",
+ /* 162 */ "WITH",
+ /* 163 */ "META",
+ /* 164 */ "CONSUMER",
+ /* 165 */ "GROUP",
+ /* 166 */ "DESC",
+ /* 167 */ "DESCRIBE",
+ /* 168 */ "RESET",
+ /* 169 */ "QUERY",
+ /* 170 */ "CACHE",
+ /* 171 */ "EXPLAIN",
+ /* 172 */ "ANALYZE",
+ /* 173 */ "VERBOSE",
+ /* 174 */ "NK_BOOL",
+ /* 175 */ "RATIO",
+ /* 176 */ "NK_FLOAT",
+ /* 177 */ "OUTPUTTYPE",
+ /* 178 */ "AGGREGATE",
+ /* 179 */ "BUFSIZE",
+ /* 180 */ "STREAM",
+ /* 181 */ "INTO",
+ /* 182 */ "TRIGGER",
+ /* 183 */ "AT_ONCE",
+ /* 184 */ "WINDOW_CLOSE",
+ /* 185 */ "IGNORE",
+ /* 186 */ "EXPIRED",
+ /* 187 */ "KILL",
+ /* 188 */ "CONNECTION",
+ /* 189 */ "TRANSACTION",
+ /* 190 */ "BALANCE",
+ /* 191 */ "VGROUP",
+ /* 192 */ "MERGE",
+ /* 193 */ "REDISTRIBUTE",
+ /* 194 */ "SPLIT",
+ /* 195 */ "DELETE",
+ /* 196 */ "INSERT",
+ /* 197 */ "NULL",
+ /* 198 */ "NK_QUESTION",
+ /* 199 */ "NK_ARROW",
+ /* 200 */ "ROWTS",
+ /* 201 */ "TBNAME",
+ /* 202 */ "QSTART",
+ /* 203 */ "QEND",
+ /* 204 */ "QDURATION",
+ /* 205 */ "WSTART",
+ /* 206 */ "WEND",
+ /* 207 */ "WDURATION",
+ /* 208 */ "CAST",
+ /* 209 */ "NOW",
+ /* 210 */ "TODAY",
+ /* 211 */ "TIMEZONE",
+ /* 212 */ "CLIENT_VERSION",
+ /* 213 */ "SERVER_VERSION",
+ /* 214 */ "SERVER_STATUS",
+ /* 215 */ "CURRENT_USER",
+ /* 216 */ "COUNT",
+ /* 217 */ "LAST_ROW",
+ /* 218 */ "BETWEEN",
+ /* 219 */ "IS",
+ /* 220 */ "NK_LT",
+ /* 221 */ "NK_GT",
+ /* 222 */ "NK_LE",
+ /* 223 */ "NK_GE",
+ /* 224 */ "NK_NE",
+ /* 225 */ "MATCH",
+ /* 226 */ "NMATCH",
+ /* 227 */ "CONTAINS",
+ /* 228 */ "IN",
+ /* 229 */ "JOIN",
+ /* 230 */ "INNER",
+ /* 231 */ "SELECT",
+ /* 232 */ "DISTINCT",
+ /* 233 */ "WHERE",
+ /* 234 */ "PARTITION",
+ /* 235 */ "BY",
+ /* 236 */ "SESSION",
+ /* 237 */ "STATE_WINDOW",
+ /* 238 */ "SLIDING",
+ /* 239 */ "FILL",
+ /* 240 */ "VALUE",
+ /* 241 */ "NONE",
+ /* 242 */ "PREV",
+ /* 243 */ "LINEAR",
+ /* 244 */ "NEXT",
+ /* 245 */ "HAVING",
+ /* 246 */ "RANGE",
+ /* 247 */ "EVERY",
+ /* 248 */ "ORDER",
+ /* 249 */ "SLIMIT",
+ /* 250 */ "SOFFSET",
+ /* 251 */ "LIMIT",
+ /* 252 */ "OFFSET",
+ /* 253 */ "ASC",
+ /* 254 */ "NULLS",
+ /* 255 */ "ABORT",
+ /* 256 */ "AFTER",
+ /* 257 */ "ATTACH",
+ /* 258 */ "BEFORE",
+ /* 259 */ "BEGIN",
+ /* 260 */ "BITAND",
+ /* 261 */ "BITNOT",
+ /* 262 */ "BITOR",
+ /* 263 */ "BLOCKS",
+ /* 264 */ "CHANGE",
+ /* 265 */ "COMMA",
+ /* 266 */ "COMPACT",
+ /* 267 */ "CONCAT",
+ /* 268 */ "CONFLICT",
+ /* 269 */ "COPY",
+ /* 270 */ "DEFERRED",
+ /* 271 */ "DELIMITERS",
+ /* 272 */ "DETACH",
+ /* 273 */ "DIVIDE",
+ /* 274 */ "DOT",
+ /* 275 */ "EACH",
+ /* 276 */ "END",
+ /* 277 */ "FAIL",
+ /* 278 */ "FILE",
+ /* 279 */ "FOR",
+ /* 280 */ "GLOB",
+ /* 281 */ "ID",
+ /* 282 */ "IMMEDIATE",
+ /* 283 */ "IMPORT",
+ /* 284 */ "INITIALLY",
+ /* 285 */ "INSTEAD",
+ /* 286 */ "ISNULL",
+ /* 287 */ "KEY",
+ /* 288 */ "NK_BITNOT",
+ /* 289 */ "NK_SEMI",
+ /* 290 */ "NOTNULL",
+ /* 291 */ "OF",
+ /* 292 */ "PLUS",
+ /* 293 */ "PRIVILEGE",
+ /* 294 */ "RAISE",
+ /* 295 */ "REPLACE",
+ /* 296 */ "RESTRICT",
+ /* 297 */ "ROW",
+ /* 298 */ "SEMI",
+ /* 299 */ "STAR",
+ /* 300 */ "STATEMENT",
+ /* 301 */ "STRING",
+ /* 302 */ "TIMES",
+ /* 303 */ "UPDATE",
+ /* 304 */ "VALUES",
+ /* 305 */ "VARIABLE",
+ /* 306 */ "VIEW",
+ /* 307 */ "WAL",
+ /* 308 */ "cmd",
+ /* 309 */ "account_options",
+ /* 310 */ "alter_account_options",
+ /* 311 */ "literal",
+ /* 312 */ "alter_account_option",
+ /* 313 */ "user_name",
+ /* 314 */ "sysinfo_opt",
+ /* 315 */ "privileges",
+ /* 316 */ "priv_level",
+ /* 317 */ "priv_type_list",
+ /* 318 */ "priv_type",
+ /* 319 */ "db_name",
+ /* 320 */ "dnode_endpoint",
+ /* 321 */ "not_exists_opt",
+ /* 322 */ "db_options",
+ /* 323 */ "exists_opt",
+ /* 324 */ "alter_db_options",
+ /* 325 */ "integer_list",
+ /* 326 */ "variable_list",
+ /* 327 */ "retention_list",
+ /* 328 */ "alter_db_option",
+ /* 329 */ "retention",
+ /* 330 */ "full_table_name",
+ /* 331 */ "column_def_list",
+ /* 332 */ "tags_def_opt",
+ /* 333 */ "table_options",
+ /* 334 */ "multi_create_clause",
+ /* 335 */ "tags_def",
+ /* 336 */ "multi_drop_clause",
+ /* 337 */ "alter_table_clause",
+ /* 338 */ "alter_table_options",
+ /* 339 */ "column_name",
+ /* 340 */ "type_name",
+ /* 341 */ "signed_literal",
+ /* 342 */ "create_subtable_clause",
+ /* 343 */ "specific_cols_opt",
+ /* 344 */ "expression_list",
+ /* 345 */ "drop_table_clause",
+ /* 346 */ "col_name_list",
+ /* 347 */ "table_name",
+ /* 348 */ "column_def",
+ /* 349 */ "duration_list",
+ /* 350 */ "rollup_func_list",
+ /* 351 */ "alter_table_option",
+ /* 352 */ "duration_literal",
+ /* 353 */ "rollup_func_name",
+ /* 354 */ "function_name",
+ /* 355 */ "col_name",
+ /* 356 */ "db_name_cond_opt",
+ /* 357 */ "like_pattern_opt",
+ /* 358 */ "table_name_cond",
+ /* 359 */ "from_db_opt",
+ /* 360 */ "index_options",
+ /* 361 */ "func_list",
+ /* 362 */ "sliding_opt",
+ /* 363 */ "sma_stream_opt",
+ /* 364 */ "func",
+ /* 365 */ "stream_options",
+ /* 366 */ "topic_name",
+ /* 367 */ "query_expression",
+ /* 368 */ "cgroup_name",
+ /* 369 */ "analyze_opt",
+ /* 370 */ "explain_options",
+ /* 371 */ "agg_func_opt",
+ /* 372 */ "bufsize_opt",
+ /* 373 */ "stream_name",
+ /* 374 */ "dnode_list",
+ /* 375 */ "where_clause_opt",
+ /* 376 */ "signed",
+ /* 377 */ "literal_func",
+ /* 378 */ "literal_list",
+ /* 379 */ "table_alias",
+ /* 380 */ "column_alias",
+ /* 381 */ "expression",
+ /* 382 */ "pseudo_column",
+ /* 383 */ "column_reference",
+ /* 384 */ "function_expression",
+ /* 385 */ "subquery",
+ /* 386 */ "star_func",
+ /* 387 */ "star_func_para_list",
+ /* 388 */ "noarg_func",
+ /* 389 */ "other_para_list",
+ /* 390 */ "star_func_para",
+ /* 391 */ "predicate",
+ /* 392 */ "compare_op",
+ /* 393 */ "in_op",
+ /* 394 */ "in_predicate_value",
+ /* 395 */ "boolean_value_expression",
+ /* 396 */ "boolean_primary",
+ /* 397 */ "common_expression",
+ /* 398 */ "from_clause_opt",
+ /* 399 */ "table_reference_list",
+ /* 400 */ "table_reference",
+ /* 401 */ "table_primary",
+ /* 402 */ "joined_table",
+ /* 403 */ "alias_opt",
+ /* 404 */ "parenthesized_joined_table",
+ /* 405 */ "join_type",
+ /* 406 */ "search_condition",
+ /* 407 */ "query_specification",
+ /* 408 */ "set_quantifier_opt",
+ /* 409 */ "select_list",
+ /* 410 */ "partition_by_clause_opt",
+ /* 411 */ "range_opt",
+ /* 412 */ "every_opt",
+ /* 413 */ "fill_opt",
+ /* 414 */ "twindow_clause_opt",
+ /* 415 */ "group_by_clause_opt",
+ /* 416 */ "having_clause_opt",
+ /* 417 */ "select_item",
+ /* 418 */ "fill_mode",
+ /* 419 */ "group_by_list",
+ /* 420 */ "query_expression_body",
+ /* 421 */ "order_by_clause_opt",
+ /* 422 */ "slimit_clause_opt",
+ /* 423 */ "limit_clause_opt",
+ /* 424 */ "query_primary",
+ /* 425 */ "sort_specification_list",
+ /* 426 */ "sort_specification",
+ /* 427 */ "ordering_specification_opt",
+ /* 428 */ "null_ordering_opt",
};
#endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */
@@ -1849,398 +1841,400 @@ static const char *const yyRuleName[] = {
/* 98 */ "db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER",
/* 99 */ "db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER",
/* 100 */ "db_options ::= db_options SST_TRIGGER NK_INTEGER",
- /* 101 */ "alter_db_options ::= alter_db_option",
- /* 102 */ "alter_db_options ::= alter_db_options alter_db_option",
- /* 103 */ "alter_db_option ::= CACHEMODEL NK_STRING",
- /* 104 */ "alter_db_option ::= CACHESIZE NK_INTEGER",
- /* 105 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER",
- /* 106 */ "alter_db_option ::= KEEP integer_list",
- /* 107 */ "alter_db_option ::= KEEP variable_list",
- /* 108 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER",
- /* 109 */ "alter_db_option ::= SST_TRIGGER NK_INTEGER",
- /* 110 */ "integer_list ::= NK_INTEGER",
- /* 111 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER",
- /* 112 */ "variable_list ::= NK_VARIABLE",
- /* 113 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE",
- /* 114 */ "retention_list ::= retention",
- /* 115 */ "retention_list ::= retention_list NK_COMMA retention",
- /* 116 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE",
- /* 117 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options",
- /* 118 */ "cmd ::= CREATE TABLE multi_create_clause",
- /* 119 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options",
- /* 120 */ "cmd ::= DROP TABLE multi_drop_clause",
- /* 121 */ "cmd ::= DROP STABLE exists_opt full_table_name",
- /* 122 */ "cmd ::= ALTER TABLE alter_table_clause",
- /* 123 */ "cmd ::= ALTER STABLE alter_table_clause",
- /* 124 */ "alter_table_clause ::= full_table_name alter_table_options",
- /* 125 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name",
- /* 126 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name",
- /* 127 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name",
- /* 128 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name",
- /* 129 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name",
- /* 130 */ "alter_table_clause ::= full_table_name DROP TAG column_name",
- /* 131 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name",
- /* 132 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name",
- /* 133 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal",
- /* 134 */ "multi_create_clause ::= create_subtable_clause",
- /* 135 */ "multi_create_clause ::= multi_create_clause create_subtable_clause",
- /* 136 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options",
- /* 137 */ "multi_drop_clause ::= drop_table_clause",
- /* 138 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause",
- /* 139 */ "drop_table_clause ::= exists_opt full_table_name",
- /* 140 */ "specific_cols_opt ::=",
- /* 141 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP",
- /* 142 */ "full_table_name ::= table_name",
- /* 143 */ "full_table_name ::= db_name NK_DOT table_name",
- /* 144 */ "column_def_list ::= column_def",
- /* 145 */ "column_def_list ::= column_def_list NK_COMMA column_def",
- /* 146 */ "column_def ::= column_name type_name",
- /* 147 */ "column_def ::= column_name type_name COMMENT NK_STRING",
- /* 148 */ "type_name ::= BOOL",
- /* 149 */ "type_name ::= TINYINT",
- /* 150 */ "type_name ::= SMALLINT",
- /* 151 */ "type_name ::= INT",
- /* 152 */ "type_name ::= INTEGER",
- /* 153 */ "type_name ::= BIGINT",
- /* 154 */ "type_name ::= FLOAT",
- /* 155 */ "type_name ::= DOUBLE",
- /* 156 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP",
- /* 157 */ "type_name ::= TIMESTAMP",
- /* 158 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP",
- /* 159 */ "type_name ::= TINYINT UNSIGNED",
- /* 160 */ "type_name ::= SMALLINT UNSIGNED",
- /* 161 */ "type_name ::= INT UNSIGNED",
- /* 162 */ "type_name ::= BIGINT UNSIGNED",
- /* 163 */ "type_name ::= JSON",
- /* 164 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP",
- /* 165 */ "type_name ::= MEDIUMBLOB",
- /* 166 */ "type_name ::= BLOB",
- /* 167 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP",
- /* 168 */ "type_name ::= DECIMAL",
- /* 169 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP",
- /* 170 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP",
- /* 171 */ "tags_def_opt ::=",
- /* 172 */ "tags_def_opt ::= tags_def",
- /* 173 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP",
- /* 174 */ "table_options ::=",
- /* 175 */ "table_options ::= table_options COMMENT NK_STRING",
- /* 176 */ "table_options ::= table_options MAX_DELAY duration_list",
- /* 177 */ "table_options ::= table_options WATERMARK duration_list",
- /* 178 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP",
- /* 179 */ "table_options ::= table_options TTL NK_INTEGER",
- /* 180 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP",
- /* 181 */ "alter_table_options ::= alter_table_option",
- /* 182 */ "alter_table_options ::= alter_table_options alter_table_option",
- /* 183 */ "alter_table_option ::= COMMENT NK_STRING",
- /* 184 */ "alter_table_option ::= TTL NK_INTEGER",
- /* 185 */ "duration_list ::= duration_literal",
- /* 186 */ "duration_list ::= duration_list NK_COMMA duration_literal",
- /* 187 */ "rollup_func_list ::= rollup_func_name",
- /* 188 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name",
- /* 189 */ "rollup_func_name ::= function_name",
- /* 190 */ "rollup_func_name ::= FIRST",
- /* 191 */ "rollup_func_name ::= LAST",
- /* 192 */ "col_name_list ::= col_name",
- /* 193 */ "col_name_list ::= col_name_list NK_COMMA col_name",
- /* 194 */ "col_name ::= column_name",
- /* 195 */ "cmd ::= SHOW DNODES",
- /* 196 */ "cmd ::= SHOW USERS",
- /* 197 */ "cmd ::= SHOW DATABASES",
- /* 198 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt",
- /* 199 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt",
- /* 200 */ "cmd ::= SHOW db_name_cond_opt VGROUPS",
- /* 201 */ "cmd ::= SHOW MNODES",
- /* 202 */ "cmd ::= SHOW MODULES",
- /* 203 */ "cmd ::= SHOW QNODES",
- /* 204 */ "cmd ::= SHOW FUNCTIONS",
- /* 205 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt",
- /* 206 */ "cmd ::= SHOW STREAMS",
- /* 207 */ "cmd ::= SHOW ACCOUNTS",
- /* 208 */ "cmd ::= SHOW APPS",
- /* 209 */ "cmd ::= SHOW CONNECTIONS",
- /* 210 */ "cmd ::= SHOW LICENCES",
- /* 211 */ "cmd ::= SHOW GRANTS",
- /* 212 */ "cmd ::= SHOW CREATE DATABASE db_name",
- /* 213 */ "cmd ::= SHOW CREATE TABLE full_table_name",
- /* 214 */ "cmd ::= SHOW CREATE STABLE full_table_name",
- /* 215 */ "cmd ::= SHOW QUERIES",
- /* 216 */ "cmd ::= SHOW SCORES",
- /* 217 */ "cmd ::= SHOW TOPICS",
- /* 218 */ "cmd ::= SHOW VARIABLES",
- /* 219 */ "cmd ::= SHOW LOCAL VARIABLES",
- /* 220 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES",
- /* 221 */ "cmd ::= SHOW BNODES",
- /* 222 */ "cmd ::= SHOW SNODES",
- /* 223 */ "cmd ::= SHOW CLUSTER",
- /* 224 */ "cmd ::= SHOW TRANSACTIONS",
- /* 225 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name",
- /* 226 */ "cmd ::= SHOW CONSUMERS",
- /* 227 */ "cmd ::= SHOW SUBSCRIPTIONS",
- /* 228 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt",
- /* 229 */ "cmd ::= SHOW VNODES NK_INTEGER",
- /* 230 */ "cmd ::= SHOW VNODES NK_STRING",
- /* 231 */ "db_name_cond_opt ::=",
- /* 232 */ "db_name_cond_opt ::= db_name NK_DOT",
- /* 233 */ "like_pattern_opt ::=",
- /* 234 */ "like_pattern_opt ::= LIKE NK_STRING",
- /* 235 */ "table_name_cond ::= table_name",
- /* 236 */ "from_db_opt ::=",
- /* 237 */ "from_db_opt ::= FROM db_name",
- /* 238 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options",
- /* 239 */ "cmd ::= DROP INDEX exists_opt full_table_name",
- /* 240 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt",
- /* 241 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt",
- /* 242 */ "func_list ::= func",
- /* 243 */ "func_list ::= func_list NK_COMMA func",
- /* 244 */ "func ::= function_name NK_LP expression_list NK_RP",
- /* 245 */ "sma_stream_opt ::=",
- /* 246 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal",
- /* 247 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal",
- /* 248 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression",
- /* 249 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name",
- /* 250 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name",
- /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name",
- /* 252 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name",
- /* 253 */ "cmd ::= DROP TOPIC exists_opt topic_name",
- /* 254 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name",
- /* 255 */ "cmd ::= DESC full_table_name",
- /* 256 */ "cmd ::= DESCRIBE full_table_name",
- /* 257 */ "cmd ::= RESET QUERY CACHE",
- /* 258 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression",
- /* 259 */ "analyze_opt ::=",
- /* 260 */ "analyze_opt ::= ANALYZE",
- /* 261 */ "explain_options ::=",
- /* 262 */ "explain_options ::= explain_options VERBOSE NK_BOOL",
- /* 263 */ "explain_options ::= explain_options RATIO NK_FLOAT",
- /* 264 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt",
- /* 265 */ "cmd ::= DROP FUNCTION exists_opt function_name",
- /* 266 */ "agg_func_opt ::=",
- /* 267 */ "agg_func_opt ::= AGGREGATE",
- /* 268 */ "bufsize_opt ::=",
- /* 269 */ "bufsize_opt ::= BUFSIZE NK_INTEGER",
- /* 270 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression",
- /* 271 */ "cmd ::= DROP STREAM exists_opt stream_name",
- /* 272 */ "stream_options ::=",
- /* 273 */ "stream_options ::= stream_options TRIGGER AT_ONCE",
- /* 274 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE",
- /* 275 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal",
- /* 276 */ "stream_options ::= stream_options WATERMARK duration_literal",
- /* 277 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER",
- /* 278 */ "cmd ::= KILL CONNECTION NK_INTEGER",
- /* 279 */ "cmd ::= KILL QUERY NK_STRING",
- /* 280 */ "cmd ::= KILL TRANSACTION NK_INTEGER",
- /* 281 */ "cmd ::= BALANCE VGROUP",
- /* 282 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER",
- /* 283 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list",
- /* 284 */ "cmd ::= SPLIT VGROUP NK_INTEGER",
- /* 285 */ "dnode_list ::= DNODE NK_INTEGER",
- /* 286 */ "dnode_list ::= dnode_list DNODE NK_INTEGER",
- /* 287 */ "cmd ::= DELETE FROM full_table_name where_clause_opt",
- /* 288 */ "cmd ::= query_expression",
- /* 289 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression",
- /* 290 */ "cmd ::= INSERT INTO full_table_name query_expression",
- /* 291 */ "literal ::= NK_INTEGER",
- /* 292 */ "literal ::= NK_FLOAT",
- /* 293 */ "literal ::= NK_STRING",
- /* 294 */ "literal ::= NK_BOOL",
- /* 295 */ "literal ::= TIMESTAMP NK_STRING",
- /* 296 */ "literal ::= duration_literal",
- /* 297 */ "literal ::= NULL",
- /* 298 */ "literal ::= NK_QUESTION",
- /* 299 */ "duration_literal ::= NK_VARIABLE",
- /* 300 */ "signed ::= NK_INTEGER",
- /* 301 */ "signed ::= NK_PLUS NK_INTEGER",
- /* 302 */ "signed ::= NK_MINUS NK_INTEGER",
- /* 303 */ "signed ::= NK_FLOAT",
- /* 304 */ "signed ::= NK_PLUS NK_FLOAT",
- /* 305 */ "signed ::= NK_MINUS NK_FLOAT",
- /* 306 */ "signed_literal ::= signed",
- /* 307 */ "signed_literal ::= NK_STRING",
- /* 308 */ "signed_literal ::= NK_BOOL",
- /* 309 */ "signed_literal ::= TIMESTAMP NK_STRING",
- /* 310 */ "signed_literal ::= duration_literal",
- /* 311 */ "signed_literal ::= NULL",
- /* 312 */ "signed_literal ::= literal_func",
- /* 313 */ "signed_literal ::= NK_QUESTION",
- /* 314 */ "literal_list ::= signed_literal",
- /* 315 */ "literal_list ::= literal_list NK_COMMA signed_literal",
- /* 316 */ "db_name ::= NK_ID",
- /* 317 */ "table_name ::= NK_ID",
- /* 318 */ "column_name ::= NK_ID",
- /* 319 */ "function_name ::= NK_ID",
- /* 320 */ "table_alias ::= NK_ID",
- /* 321 */ "column_alias ::= NK_ID",
- /* 322 */ "user_name ::= NK_ID",
- /* 323 */ "topic_name ::= NK_ID",
- /* 324 */ "stream_name ::= NK_ID",
- /* 325 */ "cgroup_name ::= NK_ID",
- /* 326 */ "expression ::= literal",
- /* 327 */ "expression ::= pseudo_column",
- /* 328 */ "expression ::= column_reference",
- /* 329 */ "expression ::= function_expression",
- /* 330 */ "expression ::= subquery",
- /* 331 */ "expression ::= NK_LP expression NK_RP",
- /* 332 */ "expression ::= NK_PLUS expression",
- /* 333 */ "expression ::= NK_MINUS expression",
- /* 334 */ "expression ::= expression NK_PLUS expression",
- /* 335 */ "expression ::= expression NK_MINUS expression",
- /* 336 */ "expression ::= expression NK_STAR expression",
- /* 337 */ "expression ::= expression NK_SLASH expression",
- /* 338 */ "expression ::= expression NK_REM expression",
- /* 339 */ "expression ::= column_reference NK_ARROW NK_STRING",
- /* 340 */ "expression ::= expression NK_BITAND expression",
- /* 341 */ "expression ::= expression NK_BITOR expression",
- /* 342 */ "expression_list ::= expression",
- /* 343 */ "expression_list ::= expression_list NK_COMMA expression",
- /* 344 */ "column_reference ::= column_name",
- /* 345 */ "column_reference ::= table_name NK_DOT column_name",
- /* 346 */ "pseudo_column ::= ROWTS",
- /* 347 */ "pseudo_column ::= TBNAME",
- /* 348 */ "pseudo_column ::= table_name NK_DOT TBNAME",
- /* 349 */ "pseudo_column ::= QSTART",
- /* 350 */ "pseudo_column ::= QEND",
- /* 351 */ "pseudo_column ::= QDURATION",
- /* 352 */ "pseudo_column ::= WSTART",
- /* 353 */ "pseudo_column ::= WEND",
- /* 354 */ "pseudo_column ::= WDURATION",
- /* 355 */ "function_expression ::= function_name NK_LP expression_list NK_RP",
- /* 356 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP",
- /* 357 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP",
- /* 358 */ "function_expression ::= literal_func",
- /* 359 */ "literal_func ::= noarg_func NK_LP NK_RP",
- /* 360 */ "literal_func ::= NOW",
- /* 361 */ "noarg_func ::= NOW",
- /* 362 */ "noarg_func ::= TODAY",
- /* 363 */ "noarg_func ::= TIMEZONE",
- /* 364 */ "noarg_func ::= DATABASE",
- /* 365 */ "noarg_func ::= CLIENT_VERSION",
- /* 366 */ "noarg_func ::= SERVER_VERSION",
- /* 367 */ "noarg_func ::= SERVER_STATUS",
- /* 368 */ "noarg_func ::= CURRENT_USER",
- /* 369 */ "noarg_func ::= USER",
- /* 370 */ "star_func ::= COUNT",
- /* 371 */ "star_func ::= FIRST",
- /* 372 */ "star_func ::= LAST",
- /* 373 */ "star_func ::= LAST_ROW",
- /* 374 */ "star_func_para_list ::= NK_STAR",
- /* 375 */ "star_func_para_list ::= other_para_list",
- /* 376 */ "other_para_list ::= star_func_para",
- /* 377 */ "other_para_list ::= other_para_list NK_COMMA star_func_para",
- /* 378 */ "star_func_para ::= expression",
- /* 379 */ "star_func_para ::= table_name NK_DOT NK_STAR",
- /* 380 */ "predicate ::= expression compare_op expression",
- /* 381 */ "predicate ::= expression BETWEEN expression AND expression",
- /* 382 */ "predicate ::= expression NOT BETWEEN expression AND expression",
- /* 383 */ "predicate ::= expression IS NULL",
- /* 384 */ "predicate ::= expression IS NOT NULL",
- /* 385 */ "predicate ::= expression in_op in_predicate_value",
- /* 386 */ "compare_op ::= NK_LT",
- /* 387 */ "compare_op ::= NK_GT",
- /* 388 */ "compare_op ::= NK_LE",
- /* 389 */ "compare_op ::= NK_GE",
- /* 390 */ "compare_op ::= NK_NE",
- /* 391 */ "compare_op ::= NK_EQ",
- /* 392 */ "compare_op ::= LIKE",
- /* 393 */ "compare_op ::= NOT LIKE",
- /* 394 */ "compare_op ::= MATCH",
- /* 395 */ "compare_op ::= NMATCH",
- /* 396 */ "compare_op ::= CONTAINS",
- /* 397 */ "in_op ::= IN",
- /* 398 */ "in_op ::= NOT IN",
- /* 399 */ "in_predicate_value ::= NK_LP literal_list NK_RP",
- /* 400 */ "boolean_value_expression ::= boolean_primary",
- /* 401 */ "boolean_value_expression ::= NOT boolean_primary",
- /* 402 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
- /* 403 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
- /* 404 */ "boolean_primary ::= predicate",
- /* 405 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
- /* 406 */ "common_expression ::= expression",
- /* 407 */ "common_expression ::= boolean_value_expression",
- /* 408 */ "from_clause_opt ::=",
- /* 409 */ "from_clause_opt ::= FROM table_reference_list",
- /* 410 */ "table_reference_list ::= table_reference",
- /* 411 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
- /* 412 */ "table_reference ::= table_primary",
- /* 413 */ "table_reference ::= joined_table",
- /* 414 */ "table_primary ::= table_name alias_opt",
- /* 415 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
- /* 416 */ "table_primary ::= subquery alias_opt",
- /* 417 */ "table_primary ::= parenthesized_joined_table",
- /* 418 */ "alias_opt ::=",
- /* 419 */ "alias_opt ::= table_alias",
- /* 420 */ "alias_opt ::= AS table_alias",
- /* 421 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
- /* 422 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
- /* 423 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
- /* 424 */ "join_type ::=",
- /* 425 */ "join_type ::= INNER",
- /* 426 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
- /* 427 */ "set_quantifier_opt ::=",
- /* 428 */ "set_quantifier_opt ::= DISTINCT",
- /* 429 */ "set_quantifier_opt ::= ALL",
- /* 430 */ "select_list ::= select_item",
- /* 431 */ "select_list ::= select_list NK_COMMA select_item",
- /* 432 */ "select_item ::= NK_STAR",
- /* 433 */ "select_item ::= common_expression",
- /* 434 */ "select_item ::= common_expression column_alias",
- /* 435 */ "select_item ::= common_expression AS column_alias",
- /* 436 */ "select_item ::= table_name NK_DOT NK_STAR",
- /* 437 */ "where_clause_opt ::=",
- /* 438 */ "where_clause_opt ::= WHERE search_condition",
- /* 439 */ "partition_by_clause_opt ::=",
- /* 440 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
- /* 441 */ "twindow_clause_opt ::=",
- /* 442 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP",
- /* 443 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP",
- /* 444 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
- /* 445 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
- /* 446 */ "sliding_opt ::=",
- /* 447 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
- /* 448 */ "fill_opt ::=",
- /* 449 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
- /* 450 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
- /* 451 */ "fill_mode ::= NONE",
- /* 452 */ "fill_mode ::= PREV",
- /* 453 */ "fill_mode ::= NULL",
- /* 454 */ "fill_mode ::= LINEAR",
- /* 455 */ "fill_mode ::= NEXT",
- /* 456 */ "group_by_clause_opt ::=",
- /* 457 */ "group_by_clause_opt ::= GROUP BY group_by_list",
- /* 458 */ "group_by_list ::= expression",
- /* 459 */ "group_by_list ::= group_by_list NK_COMMA expression",
- /* 460 */ "having_clause_opt ::=",
- /* 461 */ "having_clause_opt ::= HAVING search_condition",
- /* 462 */ "range_opt ::=",
- /* 463 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP",
- /* 464 */ "every_opt ::=",
- /* 465 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP",
- /* 466 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
- /* 467 */ "query_expression_body ::= query_primary",
- /* 468 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
- /* 469 */ "query_expression_body ::= query_expression_body UNION query_expression_body",
- /* 470 */ "query_primary ::= query_specification",
- /* 471 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP",
- /* 472 */ "order_by_clause_opt ::=",
- /* 473 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
- /* 474 */ "slimit_clause_opt ::=",
- /* 475 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
- /* 476 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
- /* 477 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 478 */ "limit_clause_opt ::=",
- /* 479 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
- /* 480 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
- /* 481 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
- /* 482 */ "subquery ::= NK_LP query_expression NK_RP",
- /* 483 */ "search_condition ::= common_expression",
- /* 484 */ "sort_specification_list ::= sort_specification",
- /* 485 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
- /* 486 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt",
- /* 487 */ "ordering_specification_opt ::=",
- /* 488 */ "ordering_specification_opt ::= ASC",
- /* 489 */ "ordering_specification_opt ::= DESC",
- /* 490 */ "null_ordering_opt ::=",
- /* 491 */ "null_ordering_opt ::= NULLS FIRST",
- /* 492 */ "null_ordering_opt ::= NULLS LAST",
+ /* 101 */ "db_options ::= db_options TABLE_PREFIX NK_INTEGER",
+ /* 102 */ "db_options ::= db_options TABLE_SUFFIX NK_INTEGER",
+ /* 103 */ "alter_db_options ::= alter_db_option",
+ /* 104 */ "alter_db_options ::= alter_db_options alter_db_option",
+ /* 105 */ "alter_db_option ::= CACHEMODEL NK_STRING",
+ /* 106 */ "alter_db_option ::= CACHESIZE NK_INTEGER",
+ /* 107 */ "alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER",
+ /* 108 */ "alter_db_option ::= KEEP integer_list",
+ /* 109 */ "alter_db_option ::= KEEP variable_list",
+ /* 110 */ "alter_db_option ::= WAL_LEVEL NK_INTEGER",
+ /* 111 */ "alter_db_option ::= SST_TRIGGER NK_INTEGER",
+ /* 112 */ "integer_list ::= NK_INTEGER",
+ /* 113 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER",
+ /* 114 */ "variable_list ::= NK_VARIABLE",
+ /* 115 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE",
+ /* 116 */ "retention_list ::= retention",
+ /* 117 */ "retention_list ::= retention_list NK_COMMA retention",
+ /* 118 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE",
+ /* 119 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options",
+ /* 120 */ "cmd ::= CREATE TABLE multi_create_clause",
+ /* 121 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options",
+ /* 122 */ "cmd ::= DROP TABLE multi_drop_clause",
+ /* 123 */ "cmd ::= DROP STABLE exists_opt full_table_name",
+ /* 124 */ "cmd ::= ALTER TABLE alter_table_clause",
+ /* 125 */ "cmd ::= ALTER STABLE alter_table_clause",
+ /* 126 */ "alter_table_clause ::= full_table_name alter_table_options",
+ /* 127 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name",
+ /* 128 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name",
+ /* 129 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name",
+ /* 130 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name",
+ /* 131 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name",
+ /* 132 */ "alter_table_clause ::= full_table_name DROP TAG column_name",
+ /* 133 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name",
+ /* 134 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name",
+ /* 135 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal",
+ /* 136 */ "multi_create_clause ::= create_subtable_clause",
+ /* 137 */ "multi_create_clause ::= multi_create_clause create_subtable_clause",
+ /* 138 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options",
+ /* 139 */ "multi_drop_clause ::= drop_table_clause",
+ /* 140 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause",
+ /* 141 */ "drop_table_clause ::= exists_opt full_table_name",
+ /* 142 */ "specific_cols_opt ::=",
+ /* 143 */ "specific_cols_opt ::= NK_LP col_name_list NK_RP",
+ /* 144 */ "full_table_name ::= table_name",
+ /* 145 */ "full_table_name ::= db_name NK_DOT table_name",
+ /* 146 */ "column_def_list ::= column_def",
+ /* 147 */ "column_def_list ::= column_def_list NK_COMMA column_def",
+ /* 148 */ "column_def ::= column_name type_name",
+ /* 149 */ "column_def ::= column_name type_name COMMENT NK_STRING",
+ /* 150 */ "type_name ::= BOOL",
+ /* 151 */ "type_name ::= TINYINT",
+ /* 152 */ "type_name ::= SMALLINT",
+ /* 153 */ "type_name ::= INT",
+ /* 154 */ "type_name ::= INTEGER",
+ /* 155 */ "type_name ::= BIGINT",
+ /* 156 */ "type_name ::= FLOAT",
+ /* 157 */ "type_name ::= DOUBLE",
+ /* 158 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP",
+ /* 159 */ "type_name ::= TIMESTAMP",
+ /* 160 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP",
+ /* 161 */ "type_name ::= TINYINT UNSIGNED",
+ /* 162 */ "type_name ::= SMALLINT UNSIGNED",
+ /* 163 */ "type_name ::= INT UNSIGNED",
+ /* 164 */ "type_name ::= BIGINT UNSIGNED",
+ /* 165 */ "type_name ::= JSON",
+ /* 166 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP",
+ /* 167 */ "type_name ::= MEDIUMBLOB",
+ /* 168 */ "type_name ::= BLOB",
+ /* 169 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP",
+ /* 170 */ "type_name ::= DECIMAL",
+ /* 171 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP",
+ /* 172 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP",
+ /* 173 */ "tags_def_opt ::=",
+ /* 174 */ "tags_def_opt ::= tags_def",
+ /* 175 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP",
+ /* 176 */ "table_options ::=",
+ /* 177 */ "table_options ::= table_options COMMENT NK_STRING",
+ /* 178 */ "table_options ::= table_options MAX_DELAY duration_list",
+ /* 179 */ "table_options ::= table_options WATERMARK duration_list",
+ /* 180 */ "table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP",
+ /* 181 */ "table_options ::= table_options TTL NK_INTEGER",
+ /* 182 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP",
+ /* 183 */ "alter_table_options ::= alter_table_option",
+ /* 184 */ "alter_table_options ::= alter_table_options alter_table_option",
+ /* 185 */ "alter_table_option ::= COMMENT NK_STRING",
+ /* 186 */ "alter_table_option ::= TTL NK_INTEGER",
+ /* 187 */ "duration_list ::= duration_literal",
+ /* 188 */ "duration_list ::= duration_list NK_COMMA duration_literal",
+ /* 189 */ "rollup_func_list ::= rollup_func_name",
+ /* 190 */ "rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name",
+ /* 191 */ "rollup_func_name ::= function_name",
+ /* 192 */ "rollup_func_name ::= FIRST",
+ /* 193 */ "rollup_func_name ::= LAST",
+ /* 194 */ "col_name_list ::= col_name",
+ /* 195 */ "col_name_list ::= col_name_list NK_COMMA col_name",
+ /* 196 */ "col_name ::= column_name",
+ /* 197 */ "cmd ::= SHOW DNODES",
+ /* 198 */ "cmd ::= SHOW USERS",
+ /* 199 */ "cmd ::= SHOW DATABASES",
+ /* 200 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt",
+ /* 201 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt",
+ /* 202 */ "cmd ::= SHOW db_name_cond_opt VGROUPS",
+ /* 203 */ "cmd ::= SHOW MNODES",
+ /* 204 */ "cmd ::= SHOW MODULES",
+ /* 205 */ "cmd ::= SHOW QNODES",
+ /* 206 */ "cmd ::= SHOW FUNCTIONS",
+ /* 207 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt",
+ /* 208 */ "cmd ::= SHOW STREAMS",
+ /* 209 */ "cmd ::= SHOW ACCOUNTS",
+ /* 210 */ "cmd ::= SHOW APPS",
+ /* 211 */ "cmd ::= SHOW CONNECTIONS",
+ /* 212 */ "cmd ::= SHOW LICENCES",
+ /* 213 */ "cmd ::= SHOW GRANTS",
+ /* 214 */ "cmd ::= SHOW CREATE DATABASE db_name",
+ /* 215 */ "cmd ::= SHOW CREATE TABLE full_table_name",
+ /* 216 */ "cmd ::= SHOW CREATE STABLE full_table_name",
+ /* 217 */ "cmd ::= SHOW QUERIES",
+ /* 218 */ "cmd ::= SHOW SCORES",
+ /* 219 */ "cmd ::= SHOW TOPICS",
+ /* 220 */ "cmd ::= SHOW VARIABLES",
+ /* 221 */ "cmd ::= SHOW LOCAL VARIABLES",
+ /* 222 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES",
+ /* 223 */ "cmd ::= SHOW BNODES",
+ /* 224 */ "cmd ::= SHOW SNODES",
+ /* 225 */ "cmd ::= SHOW CLUSTER",
+ /* 226 */ "cmd ::= SHOW TRANSACTIONS",
+ /* 227 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name",
+ /* 228 */ "cmd ::= SHOW CONSUMERS",
+ /* 229 */ "cmd ::= SHOW SUBSCRIPTIONS",
+ /* 230 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt",
+ /* 231 */ "cmd ::= SHOW VNODES NK_INTEGER",
+ /* 232 */ "cmd ::= SHOW VNODES NK_STRING",
+ /* 233 */ "db_name_cond_opt ::=",
+ /* 234 */ "db_name_cond_opt ::= db_name NK_DOT",
+ /* 235 */ "like_pattern_opt ::=",
+ /* 236 */ "like_pattern_opt ::= LIKE NK_STRING",
+ /* 237 */ "table_name_cond ::= table_name",
+ /* 238 */ "from_db_opt ::=",
+ /* 239 */ "from_db_opt ::= FROM db_name",
+ /* 240 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options",
+ /* 241 */ "cmd ::= DROP INDEX exists_opt full_table_name",
+ /* 242 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt",
+ /* 243 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt",
+ /* 244 */ "func_list ::= func",
+ /* 245 */ "func_list ::= func_list NK_COMMA func",
+ /* 246 */ "func ::= function_name NK_LP expression_list NK_RP",
+ /* 247 */ "sma_stream_opt ::=",
+ /* 248 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal",
+ /* 249 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal",
+ /* 250 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression",
+ /* 251 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name",
+ /* 252 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name",
+ /* 253 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name",
+ /* 254 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name",
+ /* 255 */ "cmd ::= DROP TOPIC exists_opt topic_name",
+ /* 256 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name",
+ /* 257 */ "cmd ::= DESC full_table_name",
+ /* 258 */ "cmd ::= DESCRIBE full_table_name",
+ /* 259 */ "cmd ::= RESET QUERY CACHE",
+ /* 260 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression",
+ /* 261 */ "analyze_opt ::=",
+ /* 262 */ "analyze_opt ::= ANALYZE",
+ /* 263 */ "explain_options ::=",
+ /* 264 */ "explain_options ::= explain_options VERBOSE NK_BOOL",
+ /* 265 */ "explain_options ::= explain_options RATIO NK_FLOAT",
+ /* 266 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt",
+ /* 267 */ "cmd ::= DROP FUNCTION exists_opt function_name",
+ /* 268 */ "agg_func_opt ::=",
+ /* 269 */ "agg_func_opt ::= AGGREGATE",
+ /* 270 */ "bufsize_opt ::=",
+ /* 271 */ "bufsize_opt ::= BUFSIZE NK_INTEGER",
+ /* 272 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression",
+ /* 273 */ "cmd ::= DROP STREAM exists_opt stream_name",
+ /* 274 */ "stream_options ::=",
+ /* 275 */ "stream_options ::= stream_options TRIGGER AT_ONCE",
+ /* 276 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE",
+ /* 277 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal",
+ /* 278 */ "stream_options ::= stream_options WATERMARK duration_literal",
+ /* 279 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER",
+ /* 280 */ "cmd ::= KILL CONNECTION NK_INTEGER",
+ /* 281 */ "cmd ::= KILL QUERY NK_STRING",
+ /* 282 */ "cmd ::= KILL TRANSACTION NK_INTEGER",
+ /* 283 */ "cmd ::= BALANCE VGROUP",
+ /* 284 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER",
+ /* 285 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list",
+ /* 286 */ "cmd ::= SPLIT VGROUP NK_INTEGER",
+ /* 287 */ "dnode_list ::= DNODE NK_INTEGER",
+ /* 288 */ "dnode_list ::= dnode_list DNODE NK_INTEGER",
+ /* 289 */ "cmd ::= DELETE FROM full_table_name where_clause_opt",
+ /* 290 */ "cmd ::= query_expression",
+ /* 291 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression",
+ /* 292 */ "cmd ::= INSERT INTO full_table_name query_expression",
+ /* 293 */ "literal ::= NK_INTEGER",
+ /* 294 */ "literal ::= NK_FLOAT",
+ /* 295 */ "literal ::= NK_STRING",
+ /* 296 */ "literal ::= NK_BOOL",
+ /* 297 */ "literal ::= TIMESTAMP NK_STRING",
+ /* 298 */ "literal ::= duration_literal",
+ /* 299 */ "literal ::= NULL",
+ /* 300 */ "literal ::= NK_QUESTION",
+ /* 301 */ "duration_literal ::= NK_VARIABLE",
+ /* 302 */ "signed ::= NK_INTEGER",
+ /* 303 */ "signed ::= NK_PLUS NK_INTEGER",
+ /* 304 */ "signed ::= NK_MINUS NK_INTEGER",
+ /* 305 */ "signed ::= NK_FLOAT",
+ /* 306 */ "signed ::= NK_PLUS NK_FLOAT",
+ /* 307 */ "signed ::= NK_MINUS NK_FLOAT",
+ /* 308 */ "signed_literal ::= signed",
+ /* 309 */ "signed_literal ::= NK_STRING",
+ /* 310 */ "signed_literal ::= NK_BOOL",
+ /* 311 */ "signed_literal ::= TIMESTAMP NK_STRING",
+ /* 312 */ "signed_literal ::= duration_literal",
+ /* 313 */ "signed_literal ::= NULL",
+ /* 314 */ "signed_literal ::= literal_func",
+ /* 315 */ "signed_literal ::= NK_QUESTION",
+ /* 316 */ "literal_list ::= signed_literal",
+ /* 317 */ "literal_list ::= literal_list NK_COMMA signed_literal",
+ /* 318 */ "db_name ::= NK_ID",
+ /* 319 */ "table_name ::= NK_ID",
+ /* 320 */ "column_name ::= NK_ID",
+ /* 321 */ "function_name ::= NK_ID",
+ /* 322 */ "table_alias ::= NK_ID",
+ /* 323 */ "column_alias ::= NK_ID",
+ /* 324 */ "user_name ::= NK_ID",
+ /* 325 */ "topic_name ::= NK_ID",
+ /* 326 */ "stream_name ::= NK_ID",
+ /* 327 */ "cgroup_name ::= NK_ID",
+ /* 328 */ "expression ::= literal",
+ /* 329 */ "expression ::= pseudo_column",
+ /* 330 */ "expression ::= column_reference",
+ /* 331 */ "expression ::= function_expression",
+ /* 332 */ "expression ::= subquery",
+ /* 333 */ "expression ::= NK_LP expression NK_RP",
+ /* 334 */ "expression ::= NK_PLUS expression",
+ /* 335 */ "expression ::= NK_MINUS expression",
+ /* 336 */ "expression ::= expression NK_PLUS expression",
+ /* 337 */ "expression ::= expression NK_MINUS expression",
+ /* 338 */ "expression ::= expression NK_STAR expression",
+ /* 339 */ "expression ::= expression NK_SLASH expression",
+ /* 340 */ "expression ::= expression NK_REM expression",
+ /* 341 */ "expression ::= column_reference NK_ARROW NK_STRING",
+ /* 342 */ "expression ::= expression NK_BITAND expression",
+ /* 343 */ "expression ::= expression NK_BITOR expression",
+ /* 344 */ "expression_list ::= expression",
+ /* 345 */ "expression_list ::= expression_list NK_COMMA expression",
+ /* 346 */ "column_reference ::= column_name",
+ /* 347 */ "column_reference ::= table_name NK_DOT column_name",
+ /* 348 */ "pseudo_column ::= ROWTS",
+ /* 349 */ "pseudo_column ::= TBNAME",
+ /* 350 */ "pseudo_column ::= table_name NK_DOT TBNAME",
+ /* 351 */ "pseudo_column ::= QSTART",
+ /* 352 */ "pseudo_column ::= QEND",
+ /* 353 */ "pseudo_column ::= QDURATION",
+ /* 354 */ "pseudo_column ::= WSTART",
+ /* 355 */ "pseudo_column ::= WEND",
+ /* 356 */ "pseudo_column ::= WDURATION",
+ /* 357 */ "function_expression ::= function_name NK_LP expression_list NK_RP",
+ /* 358 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP",
+ /* 359 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP",
+ /* 360 */ "function_expression ::= literal_func",
+ /* 361 */ "literal_func ::= noarg_func NK_LP NK_RP",
+ /* 362 */ "literal_func ::= NOW",
+ /* 363 */ "noarg_func ::= NOW",
+ /* 364 */ "noarg_func ::= TODAY",
+ /* 365 */ "noarg_func ::= TIMEZONE",
+ /* 366 */ "noarg_func ::= DATABASE",
+ /* 367 */ "noarg_func ::= CLIENT_VERSION",
+ /* 368 */ "noarg_func ::= SERVER_VERSION",
+ /* 369 */ "noarg_func ::= SERVER_STATUS",
+ /* 370 */ "noarg_func ::= CURRENT_USER",
+ /* 371 */ "noarg_func ::= USER",
+ /* 372 */ "star_func ::= COUNT",
+ /* 373 */ "star_func ::= FIRST",
+ /* 374 */ "star_func ::= LAST",
+ /* 375 */ "star_func ::= LAST_ROW",
+ /* 376 */ "star_func_para_list ::= NK_STAR",
+ /* 377 */ "star_func_para_list ::= other_para_list",
+ /* 378 */ "other_para_list ::= star_func_para",
+ /* 379 */ "other_para_list ::= other_para_list NK_COMMA star_func_para",
+ /* 380 */ "star_func_para ::= expression",
+ /* 381 */ "star_func_para ::= table_name NK_DOT NK_STAR",
+ /* 382 */ "predicate ::= expression compare_op expression",
+ /* 383 */ "predicate ::= expression BETWEEN expression AND expression",
+ /* 384 */ "predicate ::= expression NOT BETWEEN expression AND expression",
+ /* 385 */ "predicate ::= expression IS NULL",
+ /* 386 */ "predicate ::= expression IS NOT NULL",
+ /* 387 */ "predicate ::= expression in_op in_predicate_value",
+ /* 388 */ "compare_op ::= NK_LT",
+ /* 389 */ "compare_op ::= NK_GT",
+ /* 390 */ "compare_op ::= NK_LE",
+ /* 391 */ "compare_op ::= NK_GE",
+ /* 392 */ "compare_op ::= NK_NE",
+ /* 393 */ "compare_op ::= NK_EQ",
+ /* 394 */ "compare_op ::= LIKE",
+ /* 395 */ "compare_op ::= NOT LIKE",
+ /* 396 */ "compare_op ::= MATCH",
+ /* 397 */ "compare_op ::= NMATCH",
+ /* 398 */ "compare_op ::= CONTAINS",
+ /* 399 */ "in_op ::= IN",
+ /* 400 */ "in_op ::= NOT IN",
+ /* 401 */ "in_predicate_value ::= NK_LP literal_list NK_RP",
+ /* 402 */ "boolean_value_expression ::= boolean_primary",
+ /* 403 */ "boolean_value_expression ::= NOT boolean_primary",
+ /* 404 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression",
+ /* 405 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression",
+ /* 406 */ "boolean_primary ::= predicate",
+ /* 407 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP",
+ /* 408 */ "common_expression ::= expression",
+ /* 409 */ "common_expression ::= boolean_value_expression",
+ /* 410 */ "from_clause_opt ::=",
+ /* 411 */ "from_clause_opt ::= FROM table_reference_list",
+ /* 412 */ "table_reference_list ::= table_reference",
+ /* 413 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference",
+ /* 414 */ "table_reference ::= table_primary",
+ /* 415 */ "table_reference ::= joined_table",
+ /* 416 */ "table_primary ::= table_name alias_opt",
+ /* 417 */ "table_primary ::= db_name NK_DOT table_name alias_opt",
+ /* 418 */ "table_primary ::= subquery alias_opt",
+ /* 419 */ "table_primary ::= parenthesized_joined_table",
+ /* 420 */ "alias_opt ::=",
+ /* 421 */ "alias_opt ::= table_alias",
+ /* 422 */ "alias_opt ::= AS table_alias",
+ /* 423 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP",
+ /* 424 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP",
+ /* 425 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition",
+ /* 426 */ "join_type ::=",
+ /* 427 */ "join_type ::= INNER",
+ /* 428 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt",
+ /* 429 */ "set_quantifier_opt ::=",
+ /* 430 */ "set_quantifier_opt ::= DISTINCT",
+ /* 431 */ "set_quantifier_opt ::= ALL",
+ /* 432 */ "select_list ::= select_item",
+ /* 433 */ "select_list ::= select_list NK_COMMA select_item",
+ /* 434 */ "select_item ::= NK_STAR",
+ /* 435 */ "select_item ::= common_expression",
+ /* 436 */ "select_item ::= common_expression column_alias",
+ /* 437 */ "select_item ::= common_expression AS column_alias",
+ /* 438 */ "select_item ::= table_name NK_DOT NK_STAR",
+ /* 439 */ "where_clause_opt ::=",
+ /* 440 */ "where_clause_opt ::= WHERE search_condition",
+ /* 441 */ "partition_by_clause_opt ::=",
+ /* 442 */ "partition_by_clause_opt ::= PARTITION BY expression_list",
+ /* 443 */ "twindow_clause_opt ::=",
+ /* 444 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP",
+ /* 445 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP",
+ /* 446 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt",
+ /* 447 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt",
+ /* 448 */ "sliding_opt ::=",
+ /* 449 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP",
+ /* 450 */ "fill_opt ::=",
+ /* 451 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP",
+ /* 452 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP",
+ /* 453 */ "fill_mode ::= NONE",
+ /* 454 */ "fill_mode ::= PREV",
+ /* 455 */ "fill_mode ::= NULL",
+ /* 456 */ "fill_mode ::= LINEAR",
+ /* 457 */ "fill_mode ::= NEXT",
+ /* 458 */ "group_by_clause_opt ::=",
+ /* 459 */ "group_by_clause_opt ::= GROUP BY group_by_list",
+ /* 460 */ "group_by_list ::= expression",
+ /* 461 */ "group_by_list ::= group_by_list NK_COMMA expression",
+ /* 462 */ "having_clause_opt ::=",
+ /* 463 */ "having_clause_opt ::= HAVING search_condition",
+ /* 464 */ "range_opt ::=",
+ /* 465 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP",
+ /* 466 */ "every_opt ::=",
+ /* 467 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP",
+ /* 468 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt",
+ /* 469 */ "query_expression_body ::= query_primary",
+ /* 470 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body",
+ /* 471 */ "query_expression_body ::= query_expression_body UNION query_expression_body",
+ /* 472 */ "query_primary ::= query_specification",
+ /* 473 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP",
+ /* 474 */ "order_by_clause_opt ::=",
+ /* 475 */ "order_by_clause_opt ::= ORDER BY sort_specification_list",
+ /* 476 */ "slimit_clause_opt ::=",
+ /* 477 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER",
+ /* 478 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER",
+ /* 479 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 480 */ "limit_clause_opt ::=",
+ /* 481 */ "limit_clause_opt ::= LIMIT NK_INTEGER",
+ /* 482 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER",
+ /* 483 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER",
+ /* 484 */ "subquery ::= NK_LP query_expression NK_RP",
+ /* 485 */ "search_condition ::= common_expression",
+ /* 486 */ "sort_specification_list ::= sort_specification",
+ /* 487 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification",
+ /* 488 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt",
+ /* 489 */ "ordering_specification_opt ::=",
+ /* 490 */ "ordering_specification_opt ::= ASC",
+ /* 491 */ "ordering_specification_opt ::= DESC",
+ /* 492 */ "null_ordering_opt ::=",
+ /* 493 */ "null_ordering_opt ::= NULLS FIRST",
+ /* 494 */ "null_ordering_opt ::= NULLS LAST",
};
#endif /* NDEBUG */
@@ -2367,179 +2361,179 @@ static void yy_destructor(
*/
/********* Begin destructor definitions ***************************************/
/* Default NON-TERMINAL Destructor */
- case 306: /* cmd */
- case 309: /* literal */
- case 320: /* db_options */
- case 322: /* alter_db_options */
- case 327: /* retention */
- case 328: /* full_table_name */
- case 331: /* table_options */
- case 335: /* alter_table_clause */
- case 336: /* alter_table_options */
- case 339: /* signed_literal */
- case 340: /* create_subtable_clause */
- case 343: /* drop_table_clause */
- case 346: /* column_def */
- case 350: /* duration_literal */
- case 351: /* rollup_func_name */
- case 353: /* col_name */
- case 354: /* db_name_cond_opt */
- case 355: /* like_pattern_opt */
- case 356: /* table_name_cond */
- case 357: /* from_db_opt */
- case 358: /* index_options */
- case 360: /* sliding_opt */
- case 361: /* sma_stream_opt */
- case 362: /* func */
- case 363: /* stream_options */
- case 365: /* query_expression */
- case 368: /* explain_options */
- case 373: /* where_clause_opt */
- case 374: /* signed */
- case 375: /* literal_func */
- case 379: /* expression */
- case 380: /* pseudo_column */
- case 381: /* column_reference */
- case 382: /* function_expression */
- case 383: /* subquery */
- case 388: /* star_func_para */
- case 389: /* predicate */
- case 392: /* in_predicate_value */
- case 393: /* boolean_value_expression */
- case 394: /* boolean_primary */
- case 395: /* common_expression */
- case 396: /* from_clause_opt */
- case 397: /* table_reference_list */
- case 398: /* table_reference */
- case 399: /* table_primary */
- case 400: /* joined_table */
- case 402: /* parenthesized_joined_table */
- case 404: /* search_condition */
- case 405: /* query_specification */
- case 409: /* range_opt */
- case 410: /* every_opt */
- case 411: /* fill_opt */
- case 412: /* twindow_clause_opt */
- case 414: /* having_clause_opt */
- case 415: /* select_item */
- case 418: /* query_expression_body */
- case 420: /* slimit_clause_opt */
- case 421: /* limit_clause_opt */
- case 422: /* query_primary */
- case 424: /* sort_specification */
+ case 308: /* cmd */
+ case 311: /* literal */
+ case 322: /* db_options */
+ case 324: /* alter_db_options */
+ case 329: /* retention */
+ case 330: /* full_table_name */
+ case 333: /* table_options */
+ case 337: /* alter_table_clause */
+ case 338: /* alter_table_options */
+ case 341: /* signed_literal */
+ case 342: /* create_subtable_clause */
+ case 345: /* drop_table_clause */
+ case 348: /* column_def */
+ case 352: /* duration_literal */
+ case 353: /* rollup_func_name */
+ case 355: /* col_name */
+ case 356: /* db_name_cond_opt */
+ case 357: /* like_pattern_opt */
+ case 358: /* table_name_cond */
+ case 359: /* from_db_opt */
+ case 360: /* index_options */
+ case 362: /* sliding_opt */
+ case 363: /* sma_stream_opt */
+ case 364: /* func */
+ case 365: /* stream_options */
+ case 367: /* query_expression */
+ case 370: /* explain_options */
+ case 375: /* where_clause_opt */
+ case 376: /* signed */
+ case 377: /* literal_func */
+ case 381: /* expression */
+ case 382: /* pseudo_column */
+ case 383: /* column_reference */
+ case 384: /* function_expression */
+ case 385: /* subquery */
+ case 390: /* star_func_para */
+ case 391: /* predicate */
+ case 394: /* in_predicate_value */
+ case 395: /* boolean_value_expression */
+ case 396: /* boolean_primary */
+ case 397: /* common_expression */
+ case 398: /* from_clause_opt */
+ case 399: /* table_reference_list */
+ case 400: /* table_reference */
+ case 401: /* table_primary */
+ case 402: /* joined_table */
+ case 404: /* parenthesized_joined_table */
+ case 406: /* search_condition */
+ case 407: /* query_specification */
+ case 411: /* range_opt */
+ case 412: /* every_opt */
+ case 413: /* fill_opt */
+ case 414: /* twindow_clause_opt */
+ case 416: /* having_clause_opt */
+ case 417: /* select_item */
+ case 420: /* query_expression_body */
+ case 422: /* slimit_clause_opt */
+ case 423: /* limit_clause_opt */
+ case 424: /* query_primary */
+ case 426: /* sort_specification */
{
- nodesDestroyNode((yypminor->yy840));
+ nodesDestroyNode((yypminor->yy80));
}
break;
- case 307: /* account_options */
- case 308: /* alter_account_options */
- case 310: /* alter_account_option */
- case 370: /* bufsize_opt */
+ case 309: /* account_options */
+ case 310: /* alter_account_options */
+ case 312: /* alter_account_option */
+ case 372: /* bufsize_opt */
{
}
break;
- case 311: /* user_name */
- case 314: /* priv_level */
- case 317: /* db_name */
- case 318: /* dnode_endpoint */
- case 337: /* column_name */
- case 345: /* table_name */
- case 352: /* function_name */
- case 364: /* topic_name */
- case 366: /* cgroup_name */
- case 371: /* stream_name */
- case 377: /* table_alias */
- case 378: /* column_alias */
- case 384: /* star_func */
- case 386: /* noarg_func */
- case 401: /* alias_opt */
+ case 313: /* user_name */
+ case 316: /* priv_level */
+ case 319: /* db_name */
+ case 320: /* dnode_endpoint */
+ case 339: /* column_name */
+ case 347: /* table_name */
+ case 354: /* function_name */
+ case 366: /* topic_name */
+ case 368: /* cgroup_name */
+ case 373: /* stream_name */
+ case 379: /* table_alias */
+ case 380: /* column_alias */
+ case 386: /* star_func */
+ case 388: /* noarg_func */
+ case 403: /* alias_opt */
{
}
break;
- case 312: /* sysinfo_opt */
+ case 314: /* sysinfo_opt */
{
}
break;
- case 313: /* privileges */
- case 315: /* priv_type_list */
- case 316: /* priv_type */
+ case 315: /* privileges */
+ case 317: /* priv_type_list */
+ case 318: /* priv_type */
{
}
break;
- case 319: /* not_exists_opt */
- case 321: /* exists_opt */
- case 367: /* analyze_opt */
- case 369: /* agg_func_opt */
- case 406: /* set_quantifier_opt */
+ case 321: /* not_exists_opt */
+ case 323: /* exists_opt */
+ case 369: /* analyze_opt */
+ case 371: /* agg_func_opt */
+ case 408: /* set_quantifier_opt */
{
}
break;
- case 323: /* integer_list */
- case 324: /* variable_list */
- case 325: /* retention_list */
- case 329: /* column_def_list */
- case 330: /* tags_def_opt */
- case 332: /* multi_create_clause */
- case 333: /* tags_def */
- case 334: /* multi_drop_clause */
- case 341: /* specific_cols_opt */
- case 342: /* expression_list */
- case 344: /* col_name_list */
- case 347: /* duration_list */
- case 348: /* rollup_func_list */
- case 359: /* func_list */
- case 372: /* dnode_list */
- case 376: /* literal_list */
- case 385: /* star_func_para_list */
- case 387: /* other_para_list */
- case 407: /* select_list */
- case 408: /* partition_by_clause_opt */
- case 413: /* group_by_clause_opt */
- case 417: /* group_by_list */
- case 419: /* order_by_clause_opt */
- case 423: /* sort_specification_list */
+ case 325: /* integer_list */
+ case 326: /* variable_list */
+ case 327: /* retention_list */
+ case 331: /* column_def_list */
+ case 332: /* tags_def_opt */
+ case 334: /* multi_create_clause */
+ case 335: /* tags_def */
+ case 336: /* multi_drop_clause */
+ case 343: /* specific_cols_opt */
+ case 344: /* expression_list */
+ case 346: /* col_name_list */
+ case 349: /* duration_list */
+ case 350: /* rollup_func_list */
+ case 361: /* func_list */
+ case 374: /* dnode_list */
+ case 378: /* literal_list */
+ case 387: /* star_func_para_list */
+ case 389: /* other_para_list */
+ case 409: /* select_list */
+ case 410: /* partition_by_clause_opt */
+ case 415: /* group_by_clause_opt */
+ case 419: /* group_by_list */
+ case 421: /* order_by_clause_opt */
+ case 425: /* sort_specification_list */
{
- nodesDestroyList((yypminor->yy544));
+ nodesDestroyList((yypminor->yy574));
}
break;
- case 326: /* alter_db_option */
- case 349: /* alter_table_option */
+ case 328: /* alter_db_option */
+ case 351: /* alter_table_option */
{
}
break;
- case 338: /* type_name */
+ case 340: /* type_name */
{
}
break;
- case 390: /* compare_op */
- case 391: /* in_op */
+ case 392: /* compare_op */
+ case 393: /* in_op */
{
}
break;
- case 403: /* join_type */
+ case 405: /* join_type */
{
}
break;
- case 416: /* fill_mode */
+ case 418: /* fill_mode */
{
}
break;
- case 425: /* ordering_specification_opt */
+ case 427: /* ordering_specification_opt */
{
}
break;
- case 426: /* null_ordering_opt */
+ case 428: /* null_ordering_opt */
{
}
@@ -2838,499 +2832,501 @@ static const struct {
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
} yyRuleInfo[] = {
- { 306, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
- { 306, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
- { 307, 0 }, /* (2) account_options ::= */
- { 307, -3 }, /* (3) account_options ::= account_options PPS literal */
- { 307, -3 }, /* (4) account_options ::= account_options TSERIES literal */
- { 307, -3 }, /* (5) account_options ::= account_options STORAGE literal */
- { 307, -3 }, /* (6) account_options ::= account_options STREAMS literal */
- { 307, -3 }, /* (7) account_options ::= account_options QTIME literal */
- { 307, -3 }, /* (8) account_options ::= account_options DBS literal */
- { 307, -3 }, /* (9) account_options ::= account_options USERS literal */
- { 307, -3 }, /* (10) account_options ::= account_options CONNS literal */
- { 307, -3 }, /* (11) account_options ::= account_options STATE literal */
- { 308, -1 }, /* (12) alter_account_options ::= alter_account_option */
- { 308, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */
- { 310, -2 }, /* (14) alter_account_option ::= PASS literal */
- { 310, -2 }, /* (15) alter_account_option ::= PPS literal */
- { 310, -2 }, /* (16) alter_account_option ::= TSERIES literal */
- { 310, -2 }, /* (17) alter_account_option ::= STORAGE literal */
- { 310, -2 }, /* (18) alter_account_option ::= STREAMS literal */
- { 310, -2 }, /* (19) alter_account_option ::= QTIME literal */
- { 310, -2 }, /* (20) alter_account_option ::= DBS literal */
- { 310, -2 }, /* (21) alter_account_option ::= USERS literal */
- { 310, -2 }, /* (22) alter_account_option ::= CONNS literal */
- { 310, -2 }, /* (23) alter_account_option ::= STATE literal */
- { 306, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
- { 306, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
- { 306, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
- { 306, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
- { 306, -3 }, /* (28) cmd ::= DROP USER user_name */
- { 312, 0 }, /* (29) sysinfo_opt ::= */
- { 312, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */
- { 306, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */
- { 306, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */
- { 313, -1 }, /* (33) privileges ::= ALL */
- { 313, -1 }, /* (34) privileges ::= priv_type_list */
- { 315, -1 }, /* (35) priv_type_list ::= priv_type */
- { 315, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */
- { 316, -1 }, /* (37) priv_type ::= READ */
- { 316, -1 }, /* (38) priv_type ::= WRITE */
- { 314, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */
- { 314, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */
- { 306, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */
- { 306, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
- { 306, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */
- { 306, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */
- { 306, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
- { 306, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
- { 306, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */
- { 306, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
- { 318, -1 }, /* (49) dnode_endpoint ::= NK_STRING */
- { 318, -1 }, /* (50) dnode_endpoint ::= NK_ID */
- { 318, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */
- { 306, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */
- { 306, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
- { 306, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
- { 306, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
- { 306, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */
- { 306, -2 }, /* (64) cmd ::= USE db_name */
- { 306, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */
- { 306, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */
- { 306, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */
- { 319, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */
- { 319, 0 }, /* (69) not_exists_opt ::= */
- { 321, -2 }, /* (70) exists_opt ::= IF EXISTS */
- { 321, 0 }, /* (71) exists_opt ::= */
- { 320, 0 }, /* (72) db_options ::= */
- { 320, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */
- { 320, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */
- { 320, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */
- { 320, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */
- { 320, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */
- { 320, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */
- { 320, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */
- { 320, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */
- { 320, -3 }, /* (81) db_options ::= db_options KEEP integer_list */
- { 320, -3 }, /* (82) db_options ::= db_options KEEP variable_list */
- { 320, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */
- { 320, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */
- { 320, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */
- { 320, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */
- { 320, -3 }, /* (87) db_options ::= db_options STRICT NK_STRING */
- { 320, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */
- { 320, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
- { 320, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */
- { 320, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */
- { 320, -3 }, /* (92) db_options ::= db_options WAL_LEVEL NK_INTEGER */
- { 320, -3 }, /* (93) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
- { 320, -3 }, /* (94) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
- { 320, -4 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
- { 320, -3 }, /* (96) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
- { 320, -4 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
- { 320, -3 }, /* (98) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
- { 320, -3 }, /* (99) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
- { 320, -3 }, /* (100) db_options ::= db_options SST_TRIGGER NK_INTEGER */
- { 322, -1 }, /* (101) alter_db_options ::= alter_db_option */
- { 322, -2 }, /* (102) alter_db_options ::= alter_db_options alter_db_option */
- { 326, -2 }, /* (103) alter_db_option ::= CACHEMODEL NK_STRING */
- { 326, -2 }, /* (104) alter_db_option ::= CACHESIZE NK_INTEGER */
- { 326, -2 }, /* (105) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
- { 326, -2 }, /* (106) alter_db_option ::= KEEP integer_list */
- { 326, -2 }, /* (107) alter_db_option ::= KEEP variable_list */
- { 326, -2 }, /* (108) alter_db_option ::= WAL_LEVEL NK_INTEGER */
- { 326, -2 }, /* (109) alter_db_option ::= SST_TRIGGER NK_INTEGER */
- { 323, -1 }, /* (110) integer_list ::= NK_INTEGER */
- { 323, -3 }, /* (111) integer_list ::= integer_list NK_COMMA NK_INTEGER */
- { 324, -1 }, /* (112) variable_list ::= NK_VARIABLE */
- { 324, -3 }, /* (113) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
- { 325, -1 }, /* (114) retention_list ::= retention */
- { 325, -3 }, /* (115) retention_list ::= retention_list NK_COMMA retention */
- { 327, -3 }, /* (116) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
- { 306, -9 }, /* (117) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
- { 306, -3 }, /* (118) cmd ::= CREATE TABLE multi_create_clause */
- { 306, -9 }, /* (119) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
- { 306, -3 }, /* (120) cmd ::= DROP TABLE multi_drop_clause */
- { 306, -4 }, /* (121) cmd ::= DROP STABLE exists_opt full_table_name */
- { 306, -3 }, /* (122) cmd ::= ALTER TABLE alter_table_clause */
- { 306, -3 }, /* (123) cmd ::= ALTER STABLE alter_table_clause */
- { 335, -2 }, /* (124) alter_table_clause ::= full_table_name alter_table_options */
- { 335, -5 }, /* (125) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
- { 335, -4 }, /* (126) alter_table_clause ::= full_table_name DROP COLUMN column_name */
- { 335, -5 }, /* (127) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
- { 335, -5 }, /* (128) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
- { 335, -5 }, /* (129) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
- { 335, -4 }, /* (130) alter_table_clause ::= full_table_name DROP TAG column_name */
- { 335, -5 }, /* (131) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
- { 335, -5 }, /* (132) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
- { 335, -6 }, /* (133) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
- { 332, -1 }, /* (134) multi_create_clause ::= create_subtable_clause */
- { 332, -2 }, /* (135) multi_create_clause ::= multi_create_clause create_subtable_clause */
- { 340, -10 }, /* (136) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */
- { 334, -1 }, /* (137) multi_drop_clause ::= drop_table_clause */
- { 334, -2 }, /* (138) multi_drop_clause ::= multi_drop_clause drop_table_clause */
- { 343, -2 }, /* (139) drop_table_clause ::= exists_opt full_table_name */
- { 341, 0 }, /* (140) specific_cols_opt ::= */
- { 341, -3 }, /* (141) specific_cols_opt ::= NK_LP col_name_list NK_RP */
- { 328, -1 }, /* (142) full_table_name ::= table_name */
- { 328, -3 }, /* (143) full_table_name ::= db_name NK_DOT table_name */
- { 329, -1 }, /* (144) column_def_list ::= column_def */
- { 329, -3 }, /* (145) column_def_list ::= column_def_list NK_COMMA column_def */
- { 346, -2 }, /* (146) column_def ::= column_name type_name */
- { 346, -4 }, /* (147) column_def ::= column_name type_name COMMENT NK_STRING */
- { 338, -1 }, /* (148) type_name ::= BOOL */
- { 338, -1 }, /* (149) type_name ::= TINYINT */
- { 338, -1 }, /* (150) type_name ::= SMALLINT */
- { 338, -1 }, /* (151) type_name ::= INT */
- { 338, -1 }, /* (152) type_name ::= INTEGER */
- { 338, -1 }, /* (153) type_name ::= BIGINT */
- { 338, -1 }, /* (154) type_name ::= FLOAT */
- { 338, -1 }, /* (155) type_name ::= DOUBLE */
- { 338, -4 }, /* (156) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
- { 338, -1 }, /* (157) type_name ::= TIMESTAMP */
- { 338, -4 }, /* (158) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
- { 338, -2 }, /* (159) type_name ::= TINYINT UNSIGNED */
- { 338, -2 }, /* (160) type_name ::= SMALLINT UNSIGNED */
- { 338, -2 }, /* (161) type_name ::= INT UNSIGNED */
- { 338, -2 }, /* (162) type_name ::= BIGINT UNSIGNED */
- { 338, -1 }, /* (163) type_name ::= JSON */
- { 338, -4 }, /* (164) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
- { 338, -1 }, /* (165) type_name ::= MEDIUMBLOB */
- { 338, -1 }, /* (166) type_name ::= BLOB */
- { 338, -4 }, /* (167) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
- { 338, -1 }, /* (168) type_name ::= DECIMAL */
- { 338, -4 }, /* (169) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
- { 338, -6 }, /* (170) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
- { 330, 0 }, /* (171) tags_def_opt ::= */
- { 330, -1 }, /* (172) tags_def_opt ::= tags_def */
- { 333, -4 }, /* (173) tags_def ::= TAGS NK_LP column_def_list NK_RP */
- { 331, 0 }, /* (174) table_options ::= */
- { 331, -3 }, /* (175) table_options ::= table_options COMMENT NK_STRING */
- { 331, -3 }, /* (176) table_options ::= table_options MAX_DELAY duration_list */
- { 331, -3 }, /* (177) table_options ::= table_options WATERMARK duration_list */
- { 331, -5 }, /* (178) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
- { 331, -3 }, /* (179) table_options ::= table_options TTL NK_INTEGER */
- { 331, -5 }, /* (180) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
- { 336, -1 }, /* (181) alter_table_options ::= alter_table_option */
- { 336, -2 }, /* (182) alter_table_options ::= alter_table_options alter_table_option */
- { 349, -2 }, /* (183) alter_table_option ::= COMMENT NK_STRING */
- { 349, -2 }, /* (184) alter_table_option ::= TTL NK_INTEGER */
- { 347, -1 }, /* (185) duration_list ::= duration_literal */
- { 347, -3 }, /* (186) duration_list ::= duration_list NK_COMMA duration_literal */
- { 348, -1 }, /* (187) rollup_func_list ::= rollup_func_name */
- { 348, -3 }, /* (188) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */
- { 351, -1 }, /* (189) rollup_func_name ::= function_name */
- { 351, -1 }, /* (190) rollup_func_name ::= FIRST */
- { 351, -1 }, /* (191) rollup_func_name ::= LAST */
- { 344, -1 }, /* (192) col_name_list ::= col_name */
- { 344, -3 }, /* (193) col_name_list ::= col_name_list NK_COMMA col_name */
- { 353, -1 }, /* (194) col_name ::= column_name */
- { 306, -2 }, /* (195) cmd ::= SHOW DNODES */
- { 306, -2 }, /* (196) cmd ::= SHOW USERS */
- { 306, -2 }, /* (197) cmd ::= SHOW DATABASES */
- { 306, -4 }, /* (198) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
- { 306, -4 }, /* (199) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
- { 306, -3 }, /* (200) cmd ::= SHOW db_name_cond_opt VGROUPS */
- { 306, -2 }, /* (201) cmd ::= SHOW MNODES */
- { 306, -2 }, /* (202) cmd ::= SHOW MODULES */
- { 306, -2 }, /* (203) cmd ::= SHOW QNODES */
- { 306, -2 }, /* (204) cmd ::= SHOW FUNCTIONS */
- { 306, -5 }, /* (205) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
- { 306, -2 }, /* (206) cmd ::= SHOW STREAMS */
- { 306, -2 }, /* (207) cmd ::= SHOW ACCOUNTS */
- { 306, -2 }, /* (208) cmd ::= SHOW APPS */
- { 306, -2 }, /* (209) cmd ::= SHOW CONNECTIONS */
- { 306, -2 }, /* (210) cmd ::= SHOW LICENCES */
- { 306, -2 }, /* (211) cmd ::= SHOW GRANTS */
- { 306, -4 }, /* (212) cmd ::= SHOW CREATE DATABASE db_name */
- { 306, -4 }, /* (213) cmd ::= SHOW CREATE TABLE full_table_name */
- { 306, -4 }, /* (214) cmd ::= SHOW CREATE STABLE full_table_name */
- { 306, -2 }, /* (215) cmd ::= SHOW QUERIES */
- { 306, -2 }, /* (216) cmd ::= SHOW SCORES */
- { 306, -2 }, /* (217) cmd ::= SHOW TOPICS */
- { 306, -2 }, /* (218) cmd ::= SHOW VARIABLES */
- { 306, -3 }, /* (219) cmd ::= SHOW LOCAL VARIABLES */
- { 306, -4 }, /* (220) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */
- { 306, -2 }, /* (221) cmd ::= SHOW BNODES */
- { 306, -2 }, /* (222) cmd ::= SHOW SNODES */
- { 306, -2 }, /* (223) cmd ::= SHOW CLUSTER */
- { 306, -2 }, /* (224) cmd ::= SHOW TRANSACTIONS */
- { 306, -4 }, /* (225) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
- { 306, -2 }, /* (226) cmd ::= SHOW CONSUMERS */
- { 306, -2 }, /* (227) cmd ::= SHOW SUBSCRIPTIONS */
- { 306, -5 }, /* (228) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
- { 306, -3 }, /* (229) cmd ::= SHOW VNODES NK_INTEGER */
- { 306, -3 }, /* (230) cmd ::= SHOW VNODES NK_STRING */
- { 354, 0 }, /* (231) db_name_cond_opt ::= */
- { 354, -2 }, /* (232) db_name_cond_opt ::= db_name NK_DOT */
- { 355, 0 }, /* (233) like_pattern_opt ::= */
- { 355, -2 }, /* (234) like_pattern_opt ::= LIKE NK_STRING */
- { 356, -1 }, /* (235) table_name_cond ::= table_name */
- { 357, 0 }, /* (236) from_db_opt ::= */
- { 357, -2 }, /* (237) from_db_opt ::= FROM db_name */
- { 306, -8 }, /* (238) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */
- { 306, -4 }, /* (239) cmd ::= DROP INDEX exists_opt full_table_name */
- { 358, -10 }, /* (240) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
- { 358, -12 }, /* (241) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */
- { 359, -1 }, /* (242) func_list ::= func */
- { 359, -3 }, /* (243) func_list ::= func_list NK_COMMA func */
- { 362, -4 }, /* (244) func ::= function_name NK_LP expression_list NK_RP */
- { 361, 0 }, /* (245) sma_stream_opt ::= */
- { 361, -3 }, /* (246) sma_stream_opt ::= stream_options WATERMARK duration_literal */
- { 361, -3 }, /* (247) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */
- { 306, -6 }, /* (248) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
- { 306, -7 }, /* (249) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
- { 306, -9 }, /* (250) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
- { 306, -7 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
- { 306, -9 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
- { 306, -4 }, /* (253) cmd ::= DROP TOPIC exists_opt topic_name */
- { 306, -7 }, /* (254) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
- { 306, -2 }, /* (255) cmd ::= DESC full_table_name */
- { 306, -2 }, /* (256) cmd ::= DESCRIBE full_table_name */
- { 306, -3 }, /* (257) cmd ::= RESET QUERY CACHE */
- { 306, -4 }, /* (258) cmd ::= EXPLAIN analyze_opt explain_options query_expression */
- { 367, 0 }, /* (259) analyze_opt ::= */
- { 367, -1 }, /* (260) analyze_opt ::= ANALYZE */
- { 368, 0 }, /* (261) explain_options ::= */
- { 368, -3 }, /* (262) explain_options ::= explain_options VERBOSE NK_BOOL */
- { 368, -3 }, /* (263) explain_options ::= explain_options RATIO NK_FLOAT */
- { 306, -10 }, /* (264) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
- { 306, -4 }, /* (265) cmd ::= DROP FUNCTION exists_opt function_name */
- { 369, 0 }, /* (266) agg_func_opt ::= */
- { 369, -1 }, /* (267) agg_func_opt ::= AGGREGATE */
- { 370, 0 }, /* (268) bufsize_opt ::= */
- { 370, -2 }, /* (269) bufsize_opt ::= BUFSIZE NK_INTEGER */
- { 306, -9 }, /* (270) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */
- { 306, -4 }, /* (271) cmd ::= DROP STREAM exists_opt stream_name */
- { 363, 0 }, /* (272) stream_options ::= */
- { 363, -3 }, /* (273) stream_options ::= stream_options TRIGGER AT_ONCE */
- { 363, -3 }, /* (274) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
- { 363, -4 }, /* (275) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
- { 363, -3 }, /* (276) stream_options ::= stream_options WATERMARK duration_literal */
- { 363, -4 }, /* (277) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
- { 306, -3 }, /* (278) cmd ::= KILL CONNECTION NK_INTEGER */
- { 306, -3 }, /* (279) cmd ::= KILL QUERY NK_STRING */
- { 306, -3 }, /* (280) cmd ::= KILL TRANSACTION NK_INTEGER */
- { 306, -2 }, /* (281) cmd ::= BALANCE VGROUP */
- { 306, -4 }, /* (282) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
- { 306, -4 }, /* (283) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
- { 306, -3 }, /* (284) cmd ::= SPLIT VGROUP NK_INTEGER */
- { 372, -2 }, /* (285) dnode_list ::= DNODE NK_INTEGER */
- { 372, -3 }, /* (286) dnode_list ::= dnode_list DNODE NK_INTEGER */
- { 306, -4 }, /* (287) cmd ::= DELETE FROM full_table_name where_clause_opt */
- { 306, -1 }, /* (288) cmd ::= query_expression */
- { 306, -7 }, /* (289) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */
- { 306, -4 }, /* (290) cmd ::= INSERT INTO full_table_name query_expression */
- { 309, -1 }, /* (291) literal ::= NK_INTEGER */
- { 309, -1 }, /* (292) literal ::= NK_FLOAT */
- { 309, -1 }, /* (293) literal ::= NK_STRING */
- { 309, -1 }, /* (294) literal ::= NK_BOOL */
- { 309, -2 }, /* (295) literal ::= TIMESTAMP NK_STRING */
- { 309, -1 }, /* (296) literal ::= duration_literal */
- { 309, -1 }, /* (297) literal ::= NULL */
- { 309, -1 }, /* (298) literal ::= NK_QUESTION */
- { 350, -1 }, /* (299) duration_literal ::= NK_VARIABLE */
- { 374, -1 }, /* (300) signed ::= NK_INTEGER */
- { 374, -2 }, /* (301) signed ::= NK_PLUS NK_INTEGER */
- { 374, -2 }, /* (302) signed ::= NK_MINUS NK_INTEGER */
- { 374, -1 }, /* (303) signed ::= NK_FLOAT */
- { 374, -2 }, /* (304) signed ::= NK_PLUS NK_FLOAT */
- { 374, -2 }, /* (305) signed ::= NK_MINUS NK_FLOAT */
- { 339, -1 }, /* (306) signed_literal ::= signed */
- { 339, -1 }, /* (307) signed_literal ::= NK_STRING */
- { 339, -1 }, /* (308) signed_literal ::= NK_BOOL */
- { 339, -2 }, /* (309) signed_literal ::= TIMESTAMP NK_STRING */
- { 339, -1 }, /* (310) signed_literal ::= duration_literal */
- { 339, -1 }, /* (311) signed_literal ::= NULL */
- { 339, -1 }, /* (312) signed_literal ::= literal_func */
- { 339, -1 }, /* (313) signed_literal ::= NK_QUESTION */
- { 376, -1 }, /* (314) literal_list ::= signed_literal */
- { 376, -3 }, /* (315) literal_list ::= literal_list NK_COMMA signed_literal */
- { 317, -1 }, /* (316) db_name ::= NK_ID */
- { 345, -1 }, /* (317) table_name ::= NK_ID */
- { 337, -1 }, /* (318) column_name ::= NK_ID */
- { 352, -1 }, /* (319) function_name ::= NK_ID */
- { 377, -1 }, /* (320) table_alias ::= NK_ID */
- { 378, -1 }, /* (321) column_alias ::= NK_ID */
- { 311, -1 }, /* (322) user_name ::= NK_ID */
- { 364, -1 }, /* (323) topic_name ::= NK_ID */
- { 371, -1 }, /* (324) stream_name ::= NK_ID */
- { 366, -1 }, /* (325) cgroup_name ::= NK_ID */
- { 379, -1 }, /* (326) expression ::= literal */
- { 379, -1 }, /* (327) expression ::= pseudo_column */
- { 379, -1 }, /* (328) expression ::= column_reference */
- { 379, -1 }, /* (329) expression ::= function_expression */
- { 379, -1 }, /* (330) expression ::= subquery */
- { 379, -3 }, /* (331) expression ::= NK_LP expression NK_RP */
- { 379, -2 }, /* (332) expression ::= NK_PLUS expression */
- { 379, -2 }, /* (333) expression ::= NK_MINUS expression */
- { 379, -3 }, /* (334) expression ::= expression NK_PLUS expression */
- { 379, -3 }, /* (335) expression ::= expression NK_MINUS expression */
- { 379, -3 }, /* (336) expression ::= expression NK_STAR expression */
- { 379, -3 }, /* (337) expression ::= expression NK_SLASH expression */
- { 379, -3 }, /* (338) expression ::= expression NK_REM expression */
- { 379, -3 }, /* (339) expression ::= column_reference NK_ARROW NK_STRING */
- { 379, -3 }, /* (340) expression ::= expression NK_BITAND expression */
- { 379, -3 }, /* (341) expression ::= expression NK_BITOR expression */
- { 342, -1 }, /* (342) expression_list ::= expression */
- { 342, -3 }, /* (343) expression_list ::= expression_list NK_COMMA expression */
- { 381, -1 }, /* (344) column_reference ::= column_name */
- { 381, -3 }, /* (345) column_reference ::= table_name NK_DOT column_name */
- { 380, -1 }, /* (346) pseudo_column ::= ROWTS */
- { 380, -1 }, /* (347) pseudo_column ::= TBNAME */
- { 380, -3 }, /* (348) pseudo_column ::= table_name NK_DOT TBNAME */
- { 380, -1 }, /* (349) pseudo_column ::= QSTART */
- { 380, -1 }, /* (350) pseudo_column ::= QEND */
- { 380, -1 }, /* (351) pseudo_column ::= QDURATION */
- { 380, -1 }, /* (352) pseudo_column ::= WSTART */
- { 380, -1 }, /* (353) pseudo_column ::= WEND */
- { 380, -1 }, /* (354) pseudo_column ::= WDURATION */
- { 382, -4 }, /* (355) function_expression ::= function_name NK_LP expression_list NK_RP */
- { 382, -4 }, /* (356) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
- { 382, -6 }, /* (357) function_expression ::= CAST NK_LP expression AS type_name NK_RP */
- { 382, -1 }, /* (358) function_expression ::= literal_func */
- { 375, -3 }, /* (359) literal_func ::= noarg_func NK_LP NK_RP */
- { 375, -1 }, /* (360) literal_func ::= NOW */
- { 386, -1 }, /* (361) noarg_func ::= NOW */
- { 386, -1 }, /* (362) noarg_func ::= TODAY */
- { 386, -1 }, /* (363) noarg_func ::= TIMEZONE */
- { 386, -1 }, /* (364) noarg_func ::= DATABASE */
- { 386, -1 }, /* (365) noarg_func ::= CLIENT_VERSION */
- { 386, -1 }, /* (366) noarg_func ::= SERVER_VERSION */
- { 386, -1 }, /* (367) noarg_func ::= SERVER_STATUS */
- { 386, -1 }, /* (368) noarg_func ::= CURRENT_USER */
- { 386, -1 }, /* (369) noarg_func ::= USER */
- { 384, -1 }, /* (370) star_func ::= COUNT */
- { 384, -1 }, /* (371) star_func ::= FIRST */
- { 384, -1 }, /* (372) star_func ::= LAST */
- { 384, -1 }, /* (373) star_func ::= LAST_ROW */
- { 385, -1 }, /* (374) star_func_para_list ::= NK_STAR */
- { 385, -1 }, /* (375) star_func_para_list ::= other_para_list */
- { 387, -1 }, /* (376) other_para_list ::= star_func_para */
- { 387, -3 }, /* (377) other_para_list ::= other_para_list NK_COMMA star_func_para */
- { 388, -1 }, /* (378) star_func_para ::= expression */
- { 388, -3 }, /* (379) star_func_para ::= table_name NK_DOT NK_STAR */
- { 389, -3 }, /* (380) predicate ::= expression compare_op expression */
- { 389, -5 }, /* (381) predicate ::= expression BETWEEN expression AND expression */
- { 389, -6 }, /* (382) predicate ::= expression NOT BETWEEN expression AND expression */
- { 389, -3 }, /* (383) predicate ::= expression IS NULL */
- { 389, -4 }, /* (384) predicate ::= expression IS NOT NULL */
- { 389, -3 }, /* (385) predicate ::= expression in_op in_predicate_value */
- { 390, -1 }, /* (386) compare_op ::= NK_LT */
- { 390, -1 }, /* (387) compare_op ::= NK_GT */
- { 390, -1 }, /* (388) compare_op ::= NK_LE */
- { 390, -1 }, /* (389) compare_op ::= NK_GE */
- { 390, -1 }, /* (390) compare_op ::= NK_NE */
- { 390, -1 }, /* (391) compare_op ::= NK_EQ */
- { 390, -1 }, /* (392) compare_op ::= LIKE */
- { 390, -2 }, /* (393) compare_op ::= NOT LIKE */
- { 390, -1 }, /* (394) compare_op ::= MATCH */
- { 390, -1 }, /* (395) compare_op ::= NMATCH */
- { 390, -1 }, /* (396) compare_op ::= CONTAINS */
- { 391, -1 }, /* (397) in_op ::= IN */
- { 391, -2 }, /* (398) in_op ::= NOT IN */
- { 392, -3 }, /* (399) in_predicate_value ::= NK_LP literal_list NK_RP */
- { 393, -1 }, /* (400) boolean_value_expression ::= boolean_primary */
- { 393, -2 }, /* (401) boolean_value_expression ::= NOT boolean_primary */
- { 393, -3 }, /* (402) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
- { 393, -3 }, /* (403) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
- { 394, -1 }, /* (404) boolean_primary ::= predicate */
- { 394, -3 }, /* (405) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
- { 395, -1 }, /* (406) common_expression ::= expression */
- { 395, -1 }, /* (407) common_expression ::= boolean_value_expression */
- { 396, 0 }, /* (408) from_clause_opt ::= */
- { 396, -2 }, /* (409) from_clause_opt ::= FROM table_reference_list */
- { 397, -1 }, /* (410) table_reference_list ::= table_reference */
- { 397, -3 }, /* (411) table_reference_list ::= table_reference_list NK_COMMA table_reference */
- { 398, -1 }, /* (412) table_reference ::= table_primary */
- { 398, -1 }, /* (413) table_reference ::= joined_table */
- { 399, -2 }, /* (414) table_primary ::= table_name alias_opt */
- { 399, -4 }, /* (415) table_primary ::= db_name NK_DOT table_name alias_opt */
- { 399, -2 }, /* (416) table_primary ::= subquery alias_opt */
- { 399, -1 }, /* (417) table_primary ::= parenthesized_joined_table */
- { 401, 0 }, /* (418) alias_opt ::= */
- { 401, -1 }, /* (419) alias_opt ::= table_alias */
- { 401, -2 }, /* (420) alias_opt ::= AS table_alias */
- { 402, -3 }, /* (421) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- { 402, -3 }, /* (422) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
- { 400, -6 }, /* (423) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
- { 403, 0 }, /* (424) join_type ::= */
- { 403, -1 }, /* (425) join_type ::= INNER */
- { 405, -12 }, /* (426) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
- { 406, 0 }, /* (427) set_quantifier_opt ::= */
- { 406, -1 }, /* (428) set_quantifier_opt ::= DISTINCT */
- { 406, -1 }, /* (429) set_quantifier_opt ::= ALL */
- { 407, -1 }, /* (430) select_list ::= select_item */
- { 407, -3 }, /* (431) select_list ::= select_list NK_COMMA select_item */
- { 415, -1 }, /* (432) select_item ::= NK_STAR */
- { 415, -1 }, /* (433) select_item ::= common_expression */
- { 415, -2 }, /* (434) select_item ::= common_expression column_alias */
- { 415, -3 }, /* (435) select_item ::= common_expression AS column_alias */
- { 415, -3 }, /* (436) select_item ::= table_name NK_DOT NK_STAR */
- { 373, 0 }, /* (437) where_clause_opt ::= */
- { 373, -2 }, /* (438) where_clause_opt ::= WHERE search_condition */
- { 408, 0 }, /* (439) partition_by_clause_opt ::= */
- { 408, -3 }, /* (440) partition_by_clause_opt ::= PARTITION BY expression_list */
- { 412, 0 }, /* (441) twindow_clause_opt ::= */
- { 412, -6 }, /* (442) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
- { 412, -4 }, /* (443) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
- { 412, -6 }, /* (444) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
- { 412, -8 }, /* (445) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
- { 360, 0 }, /* (446) sliding_opt ::= */
- { 360, -4 }, /* (447) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
- { 411, 0 }, /* (448) fill_opt ::= */
- { 411, -4 }, /* (449) fill_opt ::= FILL NK_LP fill_mode NK_RP */
- { 411, -6 }, /* (450) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
- { 416, -1 }, /* (451) fill_mode ::= NONE */
- { 416, -1 }, /* (452) fill_mode ::= PREV */
- { 416, -1 }, /* (453) fill_mode ::= NULL */
- { 416, -1 }, /* (454) fill_mode ::= LINEAR */
- { 416, -1 }, /* (455) fill_mode ::= NEXT */
- { 413, 0 }, /* (456) group_by_clause_opt ::= */
- { 413, -3 }, /* (457) group_by_clause_opt ::= GROUP BY group_by_list */
- { 417, -1 }, /* (458) group_by_list ::= expression */
- { 417, -3 }, /* (459) group_by_list ::= group_by_list NK_COMMA expression */
- { 414, 0 }, /* (460) having_clause_opt ::= */
- { 414, -2 }, /* (461) having_clause_opt ::= HAVING search_condition */
- { 409, 0 }, /* (462) range_opt ::= */
- { 409, -6 }, /* (463) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */
- { 410, 0 }, /* (464) every_opt ::= */
- { 410, -4 }, /* (465) every_opt ::= EVERY NK_LP duration_literal NK_RP */
- { 365, -4 }, /* (466) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
- { 418, -1 }, /* (467) query_expression_body ::= query_primary */
- { 418, -4 }, /* (468) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
- { 418, -3 }, /* (469) query_expression_body ::= query_expression_body UNION query_expression_body */
- { 422, -1 }, /* (470) query_primary ::= query_specification */
- { 422, -6 }, /* (471) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */
- { 419, 0 }, /* (472) order_by_clause_opt ::= */
- { 419, -3 }, /* (473) order_by_clause_opt ::= ORDER BY sort_specification_list */
- { 420, 0 }, /* (474) slimit_clause_opt ::= */
- { 420, -2 }, /* (475) slimit_clause_opt ::= SLIMIT NK_INTEGER */
- { 420, -4 }, /* (476) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- { 420, -4 }, /* (477) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 421, 0 }, /* (478) limit_clause_opt ::= */
- { 421, -2 }, /* (479) limit_clause_opt ::= LIMIT NK_INTEGER */
- { 421, -4 }, /* (480) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
- { 421, -4 }, /* (481) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- { 383, -3 }, /* (482) subquery ::= NK_LP query_expression NK_RP */
- { 404, -1 }, /* (483) search_condition ::= common_expression */
- { 423, -1 }, /* (484) sort_specification_list ::= sort_specification */
- { 423, -3 }, /* (485) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
- { 424, -3 }, /* (486) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
- { 425, 0 }, /* (487) ordering_specification_opt ::= */
- { 425, -1 }, /* (488) ordering_specification_opt ::= ASC */
- { 425, -1 }, /* (489) ordering_specification_opt ::= DESC */
- { 426, 0 }, /* (490) null_ordering_opt ::= */
- { 426, -2 }, /* (491) null_ordering_opt ::= NULLS FIRST */
- { 426, -2 }, /* (492) null_ordering_opt ::= NULLS LAST */
+ { 308, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
+ { 308, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
+ { 309, 0 }, /* (2) account_options ::= */
+ { 309, -3 }, /* (3) account_options ::= account_options PPS literal */
+ { 309, -3 }, /* (4) account_options ::= account_options TSERIES literal */
+ { 309, -3 }, /* (5) account_options ::= account_options STORAGE literal */
+ { 309, -3 }, /* (6) account_options ::= account_options STREAMS literal */
+ { 309, -3 }, /* (7) account_options ::= account_options QTIME literal */
+ { 309, -3 }, /* (8) account_options ::= account_options DBS literal */
+ { 309, -3 }, /* (9) account_options ::= account_options USERS literal */
+ { 309, -3 }, /* (10) account_options ::= account_options CONNS literal */
+ { 309, -3 }, /* (11) account_options ::= account_options STATE literal */
+ { 310, -1 }, /* (12) alter_account_options ::= alter_account_option */
+ { 310, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */
+ { 312, -2 }, /* (14) alter_account_option ::= PASS literal */
+ { 312, -2 }, /* (15) alter_account_option ::= PPS literal */
+ { 312, -2 }, /* (16) alter_account_option ::= TSERIES literal */
+ { 312, -2 }, /* (17) alter_account_option ::= STORAGE literal */
+ { 312, -2 }, /* (18) alter_account_option ::= STREAMS literal */
+ { 312, -2 }, /* (19) alter_account_option ::= QTIME literal */
+ { 312, -2 }, /* (20) alter_account_option ::= DBS literal */
+ { 312, -2 }, /* (21) alter_account_option ::= USERS literal */
+ { 312, -2 }, /* (22) alter_account_option ::= CONNS literal */
+ { 312, -2 }, /* (23) alter_account_option ::= STATE literal */
+ { 308, -6 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
+ { 308, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */
+ { 308, -5 }, /* (26) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
+ { 308, -5 }, /* (27) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
+ { 308, -3 }, /* (28) cmd ::= DROP USER user_name */
+ { 314, 0 }, /* (29) sysinfo_opt ::= */
+ { 314, -2 }, /* (30) sysinfo_opt ::= SYSINFO NK_INTEGER */
+ { 308, -6 }, /* (31) cmd ::= GRANT privileges ON priv_level TO user_name */
+ { 308, -6 }, /* (32) cmd ::= REVOKE privileges ON priv_level FROM user_name */
+ { 315, -1 }, /* (33) privileges ::= ALL */
+ { 315, -1 }, /* (34) privileges ::= priv_type_list */
+ { 317, -1 }, /* (35) priv_type_list ::= priv_type */
+ { 317, -3 }, /* (36) priv_type_list ::= priv_type_list NK_COMMA priv_type */
+ { 318, -1 }, /* (37) priv_type ::= READ */
+ { 318, -1 }, /* (38) priv_type ::= WRITE */
+ { 316, -3 }, /* (39) priv_level ::= NK_STAR NK_DOT NK_STAR */
+ { 316, -3 }, /* (40) priv_level ::= db_name NK_DOT NK_STAR */
+ { 308, -3 }, /* (41) cmd ::= CREATE DNODE dnode_endpoint */
+ { 308, -5 }, /* (42) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
+ { 308, -3 }, /* (43) cmd ::= DROP DNODE NK_INTEGER */
+ { 308, -3 }, /* (44) cmd ::= DROP DNODE dnode_endpoint */
+ { 308, -4 }, /* (45) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
+ { 308, -5 }, /* (46) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */
+ { 308, -4 }, /* (47) cmd ::= ALTER ALL DNODES NK_STRING */
+ { 308, -5 }, /* (48) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */
+ { 320, -1 }, /* (49) dnode_endpoint ::= NK_STRING */
+ { 320, -1 }, /* (50) dnode_endpoint ::= NK_ID */
+ { 320, -1 }, /* (51) dnode_endpoint ::= NK_IPTOKEN */
+ { 308, -3 }, /* (52) cmd ::= ALTER LOCAL NK_STRING */
+ { 308, -4 }, /* (53) cmd ::= ALTER LOCAL NK_STRING NK_STRING */
+ { 308, -5 }, /* (54) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (55) cmd ::= DROP QNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (56) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (57) cmd ::= DROP BNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (58) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (59) cmd ::= DROP SNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (60) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (61) cmd ::= DROP MNODE ON DNODE NK_INTEGER */
+ { 308, -5 }, /* (62) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
+ { 308, -4 }, /* (63) cmd ::= DROP DATABASE exists_opt db_name */
+ { 308, -2 }, /* (64) cmd ::= USE db_name */
+ { 308, -4 }, /* (65) cmd ::= ALTER DATABASE db_name alter_db_options */
+ { 308, -3 }, /* (66) cmd ::= FLUSH DATABASE db_name */
+ { 308, -3 }, /* (67) cmd ::= TRIM DATABASE db_name */
+ { 321, -3 }, /* (68) not_exists_opt ::= IF NOT EXISTS */
+ { 321, 0 }, /* (69) not_exists_opt ::= */
+ { 323, -2 }, /* (70) exists_opt ::= IF EXISTS */
+ { 323, 0 }, /* (71) exists_opt ::= */
+ { 322, 0 }, /* (72) db_options ::= */
+ { 322, -3 }, /* (73) db_options ::= db_options BUFFER NK_INTEGER */
+ { 322, -3 }, /* (74) db_options ::= db_options CACHEMODEL NK_STRING */
+ { 322, -3 }, /* (75) db_options ::= db_options CACHESIZE NK_INTEGER */
+ { 322, -3 }, /* (76) db_options ::= db_options COMP NK_INTEGER */
+ { 322, -3 }, /* (77) db_options ::= db_options DURATION NK_INTEGER */
+ { 322, -3 }, /* (78) db_options ::= db_options DURATION NK_VARIABLE */
+ { 322, -3 }, /* (79) db_options ::= db_options MAXROWS NK_INTEGER */
+ { 322, -3 }, /* (80) db_options ::= db_options MINROWS NK_INTEGER */
+ { 322, -3 }, /* (81) db_options ::= db_options KEEP integer_list */
+ { 322, -3 }, /* (82) db_options ::= db_options KEEP variable_list */
+ { 322, -3 }, /* (83) db_options ::= db_options PAGES NK_INTEGER */
+ { 322, -3 }, /* (84) db_options ::= db_options PAGESIZE NK_INTEGER */
+ { 322, -3 }, /* (85) db_options ::= db_options PRECISION NK_STRING */
+ { 322, -3 }, /* (86) db_options ::= db_options REPLICA NK_INTEGER */
+ { 322, -3 }, /* (87) db_options ::= db_options STRICT NK_STRING */
+ { 322, -3 }, /* (88) db_options ::= db_options VGROUPS NK_INTEGER */
+ { 322, -3 }, /* (89) db_options ::= db_options SINGLE_STABLE NK_INTEGER */
+ { 322, -3 }, /* (90) db_options ::= db_options RETENTIONS retention_list */
+ { 322, -3 }, /* (91) db_options ::= db_options SCHEMALESS NK_INTEGER */
+ { 322, -3 }, /* (92) db_options ::= db_options WAL_LEVEL NK_INTEGER */
+ { 322, -3 }, /* (93) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
+ { 322, -3 }, /* (94) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
+ { 322, -4 }, /* (95) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
+ { 322, -3 }, /* (96) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
+ { 322, -4 }, /* (97) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
+ { 322, -3 }, /* (98) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
+ { 322, -3 }, /* (99) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
+ { 322, -3 }, /* (100) db_options ::= db_options SST_TRIGGER NK_INTEGER */
+ { 322, -3 }, /* (101) db_options ::= db_options TABLE_PREFIX NK_INTEGER */
+ { 322, -3 }, /* (102) db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
+ { 324, -1 }, /* (103) alter_db_options ::= alter_db_option */
+ { 324, -2 }, /* (104) alter_db_options ::= alter_db_options alter_db_option */
+ { 328, -2 }, /* (105) alter_db_option ::= CACHEMODEL NK_STRING */
+ { 328, -2 }, /* (106) alter_db_option ::= CACHESIZE NK_INTEGER */
+ { 328, -2 }, /* (107) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
+ { 328, -2 }, /* (108) alter_db_option ::= KEEP integer_list */
+ { 328, -2 }, /* (109) alter_db_option ::= KEEP variable_list */
+ { 328, -2 }, /* (110) alter_db_option ::= WAL_LEVEL NK_INTEGER */
+ { 328, -2 }, /* (111) alter_db_option ::= SST_TRIGGER NK_INTEGER */
+ { 325, -1 }, /* (112) integer_list ::= NK_INTEGER */
+ { 325, -3 }, /* (113) integer_list ::= integer_list NK_COMMA NK_INTEGER */
+ { 326, -1 }, /* (114) variable_list ::= NK_VARIABLE */
+ { 326, -3 }, /* (115) variable_list ::= variable_list NK_COMMA NK_VARIABLE */
+ { 327, -1 }, /* (116) retention_list ::= retention */
+ { 327, -3 }, /* (117) retention_list ::= retention_list NK_COMMA retention */
+ { 329, -3 }, /* (118) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
+ { 308, -9 }, /* (119) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
+ { 308, -3 }, /* (120) cmd ::= CREATE TABLE multi_create_clause */
+ { 308, -9 }, /* (121) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */
+ { 308, -3 }, /* (122) cmd ::= DROP TABLE multi_drop_clause */
+ { 308, -4 }, /* (123) cmd ::= DROP STABLE exists_opt full_table_name */
+ { 308, -3 }, /* (124) cmd ::= ALTER TABLE alter_table_clause */
+ { 308, -3 }, /* (125) cmd ::= ALTER STABLE alter_table_clause */
+ { 337, -2 }, /* (126) alter_table_clause ::= full_table_name alter_table_options */
+ { 337, -5 }, /* (127) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
+ { 337, -4 }, /* (128) alter_table_clause ::= full_table_name DROP COLUMN column_name */
+ { 337, -5 }, /* (129) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
+ { 337, -5 }, /* (130) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
+ { 337, -5 }, /* (131) alter_table_clause ::= full_table_name ADD TAG column_name type_name */
+ { 337, -4 }, /* (132) alter_table_clause ::= full_table_name DROP TAG column_name */
+ { 337, -5 }, /* (133) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
+ { 337, -5 }, /* (134) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
+ { 337, -6 }, /* (135) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
+ { 334, -1 }, /* (136) multi_create_clause ::= create_subtable_clause */
+ { 334, -2 }, /* (137) multi_create_clause ::= multi_create_clause create_subtable_clause */
+ { 342, -10 }, /* (138) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */
+ { 336, -1 }, /* (139) multi_drop_clause ::= drop_table_clause */
+ { 336, -2 }, /* (140) multi_drop_clause ::= multi_drop_clause drop_table_clause */
+ { 345, -2 }, /* (141) drop_table_clause ::= exists_opt full_table_name */
+ { 343, 0 }, /* (142) specific_cols_opt ::= */
+ { 343, -3 }, /* (143) specific_cols_opt ::= NK_LP col_name_list NK_RP */
+ { 330, -1 }, /* (144) full_table_name ::= table_name */
+ { 330, -3 }, /* (145) full_table_name ::= db_name NK_DOT table_name */
+ { 331, -1 }, /* (146) column_def_list ::= column_def */
+ { 331, -3 }, /* (147) column_def_list ::= column_def_list NK_COMMA column_def */
+ { 348, -2 }, /* (148) column_def ::= column_name type_name */
+ { 348, -4 }, /* (149) column_def ::= column_name type_name COMMENT NK_STRING */
+ { 340, -1 }, /* (150) type_name ::= BOOL */
+ { 340, -1 }, /* (151) type_name ::= TINYINT */
+ { 340, -1 }, /* (152) type_name ::= SMALLINT */
+ { 340, -1 }, /* (153) type_name ::= INT */
+ { 340, -1 }, /* (154) type_name ::= INTEGER */
+ { 340, -1 }, /* (155) type_name ::= BIGINT */
+ { 340, -1 }, /* (156) type_name ::= FLOAT */
+ { 340, -1 }, /* (157) type_name ::= DOUBLE */
+ { 340, -4 }, /* (158) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+ { 340, -1 }, /* (159) type_name ::= TIMESTAMP */
+ { 340, -4 }, /* (160) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+ { 340, -2 }, /* (161) type_name ::= TINYINT UNSIGNED */
+ { 340, -2 }, /* (162) type_name ::= SMALLINT UNSIGNED */
+ { 340, -2 }, /* (163) type_name ::= INT UNSIGNED */
+ { 340, -2 }, /* (164) type_name ::= BIGINT UNSIGNED */
+ { 340, -1 }, /* (165) type_name ::= JSON */
+ { 340, -4 }, /* (166) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+ { 340, -1 }, /* (167) type_name ::= MEDIUMBLOB */
+ { 340, -1 }, /* (168) type_name ::= BLOB */
+ { 340, -4 }, /* (169) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+ { 340, -1 }, /* (170) type_name ::= DECIMAL */
+ { 340, -4 }, /* (171) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+ { 340, -6 }, /* (172) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+ { 332, 0 }, /* (173) tags_def_opt ::= */
+ { 332, -1 }, /* (174) tags_def_opt ::= tags_def */
+ { 335, -4 }, /* (175) tags_def ::= TAGS NK_LP column_def_list NK_RP */
+ { 333, 0 }, /* (176) table_options ::= */
+ { 333, -3 }, /* (177) table_options ::= table_options COMMENT NK_STRING */
+ { 333, -3 }, /* (178) table_options ::= table_options MAX_DELAY duration_list */
+ { 333, -3 }, /* (179) table_options ::= table_options WATERMARK duration_list */
+ { 333, -5 }, /* (180) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
+ { 333, -3 }, /* (181) table_options ::= table_options TTL NK_INTEGER */
+ { 333, -5 }, /* (182) table_options ::= table_options SMA NK_LP col_name_list NK_RP */
+ { 338, -1 }, /* (183) alter_table_options ::= alter_table_option */
+ { 338, -2 }, /* (184) alter_table_options ::= alter_table_options alter_table_option */
+ { 351, -2 }, /* (185) alter_table_option ::= COMMENT NK_STRING */
+ { 351, -2 }, /* (186) alter_table_option ::= TTL NK_INTEGER */
+ { 349, -1 }, /* (187) duration_list ::= duration_literal */
+ { 349, -3 }, /* (188) duration_list ::= duration_list NK_COMMA duration_literal */
+ { 350, -1 }, /* (189) rollup_func_list ::= rollup_func_name */
+ { 350, -3 }, /* (190) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */
+ { 353, -1 }, /* (191) rollup_func_name ::= function_name */
+ { 353, -1 }, /* (192) rollup_func_name ::= FIRST */
+ { 353, -1 }, /* (193) rollup_func_name ::= LAST */
+ { 346, -1 }, /* (194) col_name_list ::= col_name */
+ { 346, -3 }, /* (195) col_name_list ::= col_name_list NK_COMMA col_name */
+ { 355, -1 }, /* (196) col_name ::= column_name */
+ { 308, -2 }, /* (197) cmd ::= SHOW DNODES */
+ { 308, -2 }, /* (198) cmd ::= SHOW USERS */
+ { 308, -2 }, /* (199) cmd ::= SHOW DATABASES */
+ { 308, -4 }, /* (200) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
+ { 308, -4 }, /* (201) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
+ { 308, -3 }, /* (202) cmd ::= SHOW db_name_cond_opt VGROUPS */
+ { 308, -2 }, /* (203) cmd ::= SHOW MNODES */
+ { 308, -2 }, /* (204) cmd ::= SHOW MODULES */
+ { 308, -2 }, /* (205) cmd ::= SHOW QNODES */
+ { 308, -2 }, /* (206) cmd ::= SHOW FUNCTIONS */
+ { 308, -5 }, /* (207) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
+ { 308, -2 }, /* (208) cmd ::= SHOW STREAMS */
+ { 308, -2 }, /* (209) cmd ::= SHOW ACCOUNTS */
+ { 308, -2 }, /* (210) cmd ::= SHOW APPS */
+ { 308, -2 }, /* (211) cmd ::= SHOW CONNECTIONS */
+ { 308, -2 }, /* (212) cmd ::= SHOW LICENCES */
+ { 308, -2 }, /* (213) cmd ::= SHOW GRANTS */
+ { 308, -4 }, /* (214) cmd ::= SHOW CREATE DATABASE db_name */
+ { 308, -4 }, /* (215) cmd ::= SHOW CREATE TABLE full_table_name */
+ { 308, -4 }, /* (216) cmd ::= SHOW CREATE STABLE full_table_name */
+ { 308, -2 }, /* (217) cmd ::= SHOW QUERIES */
+ { 308, -2 }, /* (218) cmd ::= SHOW SCORES */
+ { 308, -2 }, /* (219) cmd ::= SHOW TOPICS */
+ { 308, -2 }, /* (220) cmd ::= SHOW VARIABLES */
+ { 308, -3 }, /* (221) cmd ::= SHOW LOCAL VARIABLES */
+ { 308, -4 }, /* (222) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */
+ { 308, -2 }, /* (223) cmd ::= SHOW BNODES */
+ { 308, -2 }, /* (224) cmd ::= SHOW SNODES */
+ { 308, -2 }, /* (225) cmd ::= SHOW CLUSTER */
+ { 308, -2 }, /* (226) cmd ::= SHOW TRANSACTIONS */
+ { 308, -4 }, /* (227) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
+ { 308, -2 }, /* (228) cmd ::= SHOW CONSUMERS */
+ { 308, -2 }, /* (229) cmd ::= SHOW SUBSCRIPTIONS */
+ { 308, -5 }, /* (230) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
+ { 308, -3 }, /* (231) cmd ::= SHOW VNODES NK_INTEGER */
+ { 308, -3 }, /* (232) cmd ::= SHOW VNODES NK_STRING */
+ { 356, 0 }, /* (233) db_name_cond_opt ::= */
+ { 356, -2 }, /* (234) db_name_cond_opt ::= db_name NK_DOT */
+ { 357, 0 }, /* (235) like_pattern_opt ::= */
+ { 357, -2 }, /* (236) like_pattern_opt ::= LIKE NK_STRING */
+ { 358, -1 }, /* (237) table_name_cond ::= table_name */
+ { 359, 0 }, /* (238) from_db_opt ::= */
+ { 359, -2 }, /* (239) from_db_opt ::= FROM db_name */
+ { 308, -8 }, /* (240) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */
+ { 308, -4 }, /* (241) cmd ::= DROP INDEX exists_opt full_table_name */
+ { 360, -10 }, /* (242) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
+ { 360, -12 }, /* (243) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */
+ { 361, -1 }, /* (244) func_list ::= func */
+ { 361, -3 }, /* (245) func_list ::= func_list NK_COMMA func */
+ { 364, -4 }, /* (246) func ::= function_name NK_LP expression_list NK_RP */
+ { 363, 0 }, /* (247) sma_stream_opt ::= */
+ { 363, -3 }, /* (248) sma_stream_opt ::= stream_options WATERMARK duration_literal */
+ { 363, -3 }, /* (249) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */
+ { 308, -6 }, /* (250) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
+ { 308, -7 }, /* (251) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
+ { 308, -9 }, /* (252) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
+ { 308, -7 }, /* (253) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
+ { 308, -9 }, /* (254) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
+ { 308, -4 }, /* (255) cmd ::= DROP TOPIC exists_opt topic_name */
+ { 308, -7 }, /* (256) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
+ { 308, -2 }, /* (257) cmd ::= DESC full_table_name */
+ { 308, -2 }, /* (258) cmd ::= DESCRIBE full_table_name */
+ { 308, -3 }, /* (259) cmd ::= RESET QUERY CACHE */
+ { 308, -4 }, /* (260) cmd ::= EXPLAIN analyze_opt explain_options query_expression */
+ { 369, 0 }, /* (261) analyze_opt ::= */
+ { 369, -1 }, /* (262) analyze_opt ::= ANALYZE */
+ { 370, 0 }, /* (263) explain_options ::= */
+ { 370, -3 }, /* (264) explain_options ::= explain_options VERBOSE NK_BOOL */
+ { 370, -3 }, /* (265) explain_options ::= explain_options RATIO NK_FLOAT */
+ { 308, -10 }, /* (266) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
+ { 308, -4 }, /* (267) cmd ::= DROP FUNCTION exists_opt function_name */
+ { 371, 0 }, /* (268) agg_func_opt ::= */
+ { 371, -1 }, /* (269) agg_func_opt ::= AGGREGATE */
+ { 372, 0 }, /* (270) bufsize_opt ::= */
+ { 372, -2 }, /* (271) bufsize_opt ::= BUFSIZE NK_INTEGER */
+ { 308, -9 }, /* (272) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */
+ { 308, -4 }, /* (273) cmd ::= DROP STREAM exists_opt stream_name */
+ { 365, 0 }, /* (274) stream_options ::= */
+ { 365, -3 }, /* (275) stream_options ::= stream_options TRIGGER AT_ONCE */
+ { 365, -3 }, /* (276) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
+ { 365, -4 }, /* (277) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
+ { 365, -3 }, /* (278) stream_options ::= stream_options WATERMARK duration_literal */
+ { 365, -4 }, /* (279) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
+ { 308, -3 }, /* (280) cmd ::= KILL CONNECTION NK_INTEGER */
+ { 308, -3 }, /* (281) cmd ::= KILL QUERY NK_STRING */
+ { 308, -3 }, /* (282) cmd ::= KILL TRANSACTION NK_INTEGER */
+ { 308, -2 }, /* (283) cmd ::= BALANCE VGROUP */
+ { 308, -4 }, /* (284) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
+ { 308, -4 }, /* (285) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
+ { 308, -3 }, /* (286) cmd ::= SPLIT VGROUP NK_INTEGER */
+ { 374, -2 }, /* (287) dnode_list ::= DNODE NK_INTEGER */
+ { 374, -3 }, /* (288) dnode_list ::= dnode_list DNODE NK_INTEGER */
+ { 308, -4 }, /* (289) cmd ::= DELETE FROM full_table_name where_clause_opt */
+ { 308, -1 }, /* (290) cmd ::= query_expression */
+ { 308, -7 }, /* (291) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */
+ { 308, -4 }, /* (292) cmd ::= INSERT INTO full_table_name query_expression */
+ { 311, -1 }, /* (293) literal ::= NK_INTEGER */
+ { 311, -1 }, /* (294) literal ::= NK_FLOAT */
+ { 311, -1 }, /* (295) literal ::= NK_STRING */
+ { 311, -1 }, /* (296) literal ::= NK_BOOL */
+ { 311, -2 }, /* (297) literal ::= TIMESTAMP NK_STRING */
+ { 311, -1 }, /* (298) literal ::= duration_literal */
+ { 311, -1 }, /* (299) literal ::= NULL */
+ { 311, -1 }, /* (300) literal ::= NK_QUESTION */
+ { 352, -1 }, /* (301) duration_literal ::= NK_VARIABLE */
+ { 376, -1 }, /* (302) signed ::= NK_INTEGER */
+ { 376, -2 }, /* (303) signed ::= NK_PLUS NK_INTEGER */
+ { 376, -2 }, /* (304) signed ::= NK_MINUS NK_INTEGER */
+ { 376, -1 }, /* (305) signed ::= NK_FLOAT */
+ { 376, -2 }, /* (306) signed ::= NK_PLUS NK_FLOAT */
+ { 376, -2 }, /* (307) signed ::= NK_MINUS NK_FLOAT */
+ { 341, -1 }, /* (308) signed_literal ::= signed */
+ { 341, -1 }, /* (309) signed_literal ::= NK_STRING */
+ { 341, -1 }, /* (310) signed_literal ::= NK_BOOL */
+ { 341, -2 }, /* (311) signed_literal ::= TIMESTAMP NK_STRING */
+ { 341, -1 }, /* (312) signed_literal ::= duration_literal */
+ { 341, -1 }, /* (313) signed_literal ::= NULL */
+ { 341, -1 }, /* (314) signed_literal ::= literal_func */
+ { 341, -1 }, /* (315) signed_literal ::= NK_QUESTION */
+ { 378, -1 }, /* (316) literal_list ::= signed_literal */
+ { 378, -3 }, /* (317) literal_list ::= literal_list NK_COMMA signed_literal */
+ { 319, -1 }, /* (318) db_name ::= NK_ID */
+ { 347, -1 }, /* (319) table_name ::= NK_ID */
+ { 339, -1 }, /* (320) column_name ::= NK_ID */
+ { 354, -1 }, /* (321) function_name ::= NK_ID */
+ { 379, -1 }, /* (322) table_alias ::= NK_ID */
+ { 380, -1 }, /* (323) column_alias ::= NK_ID */
+ { 313, -1 }, /* (324) user_name ::= NK_ID */
+ { 366, -1 }, /* (325) topic_name ::= NK_ID */
+ { 373, -1 }, /* (326) stream_name ::= NK_ID */
+ { 368, -1 }, /* (327) cgroup_name ::= NK_ID */
+ { 381, -1 }, /* (328) expression ::= literal */
+ { 381, -1 }, /* (329) expression ::= pseudo_column */
+ { 381, -1 }, /* (330) expression ::= column_reference */
+ { 381, -1 }, /* (331) expression ::= function_expression */
+ { 381, -1 }, /* (332) expression ::= subquery */
+ { 381, -3 }, /* (333) expression ::= NK_LP expression NK_RP */
+ { 381, -2 }, /* (334) expression ::= NK_PLUS expression */
+ { 381, -2 }, /* (335) expression ::= NK_MINUS expression */
+ { 381, -3 }, /* (336) expression ::= expression NK_PLUS expression */
+ { 381, -3 }, /* (337) expression ::= expression NK_MINUS expression */
+ { 381, -3 }, /* (338) expression ::= expression NK_STAR expression */
+ { 381, -3 }, /* (339) expression ::= expression NK_SLASH expression */
+ { 381, -3 }, /* (340) expression ::= expression NK_REM expression */
+ { 381, -3 }, /* (341) expression ::= column_reference NK_ARROW NK_STRING */
+ { 381, -3 }, /* (342) expression ::= expression NK_BITAND expression */
+ { 381, -3 }, /* (343) expression ::= expression NK_BITOR expression */
+ { 344, -1 }, /* (344) expression_list ::= expression */
+ { 344, -3 }, /* (345) expression_list ::= expression_list NK_COMMA expression */
+ { 383, -1 }, /* (346) column_reference ::= column_name */
+ { 383, -3 }, /* (347) column_reference ::= table_name NK_DOT column_name */
+ { 382, -1 }, /* (348) pseudo_column ::= ROWTS */
+ { 382, -1 }, /* (349) pseudo_column ::= TBNAME */
+ { 382, -3 }, /* (350) pseudo_column ::= table_name NK_DOT TBNAME */
+ { 382, -1 }, /* (351) pseudo_column ::= QSTART */
+ { 382, -1 }, /* (352) pseudo_column ::= QEND */
+ { 382, -1 }, /* (353) pseudo_column ::= QDURATION */
+ { 382, -1 }, /* (354) pseudo_column ::= WSTART */
+ { 382, -1 }, /* (355) pseudo_column ::= WEND */
+ { 382, -1 }, /* (356) pseudo_column ::= WDURATION */
+ { 384, -4 }, /* (357) function_expression ::= function_name NK_LP expression_list NK_RP */
+ { 384, -4 }, /* (358) function_expression ::= star_func NK_LP star_func_para_list NK_RP */
+ { 384, -6 }, /* (359) function_expression ::= CAST NK_LP expression AS type_name NK_RP */
+ { 384, -1 }, /* (360) function_expression ::= literal_func */
+ { 377, -3 }, /* (361) literal_func ::= noarg_func NK_LP NK_RP */
+ { 377, -1 }, /* (362) literal_func ::= NOW */
+ { 388, -1 }, /* (363) noarg_func ::= NOW */
+ { 388, -1 }, /* (364) noarg_func ::= TODAY */
+ { 388, -1 }, /* (365) noarg_func ::= TIMEZONE */
+ { 388, -1 }, /* (366) noarg_func ::= DATABASE */
+ { 388, -1 }, /* (367) noarg_func ::= CLIENT_VERSION */
+ { 388, -1 }, /* (368) noarg_func ::= SERVER_VERSION */
+ { 388, -1 }, /* (369) noarg_func ::= SERVER_STATUS */
+ { 388, -1 }, /* (370) noarg_func ::= CURRENT_USER */
+ { 388, -1 }, /* (371) noarg_func ::= USER */
+ { 386, -1 }, /* (372) star_func ::= COUNT */
+ { 386, -1 }, /* (373) star_func ::= FIRST */
+ { 386, -1 }, /* (374) star_func ::= LAST */
+ { 386, -1 }, /* (375) star_func ::= LAST_ROW */
+ { 387, -1 }, /* (376) star_func_para_list ::= NK_STAR */
+ { 387, -1 }, /* (377) star_func_para_list ::= other_para_list */
+ { 389, -1 }, /* (378) other_para_list ::= star_func_para */
+ { 389, -3 }, /* (379) other_para_list ::= other_para_list NK_COMMA star_func_para */
+ { 390, -1 }, /* (380) star_func_para ::= expression */
+ { 390, -3 }, /* (381) star_func_para ::= table_name NK_DOT NK_STAR */
+ { 391, -3 }, /* (382) predicate ::= expression compare_op expression */
+ { 391, -5 }, /* (383) predicate ::= expression BETWEEN expression AND expression */
+ { 391, -6 }, /* (384) predicate ::= expression NOT BETWEEN expression AND expression */
+ { 391, -3 }, /* (385) predicate ::= expression IS NULL */
+ { 391, -4 }, /* (386) predicate ::= expression IS NOT NULL */
+ { 391, -3 }, /* (387) predicate ::= expression in_op in_predicate_value */
+ { 392, -1 }, /* (388) compare_op ::= NK_LT */
+ { 392, -1 }, /* (389) compare_op ::= NK_GT */
+ { 392, -1 }, /* (390) compare_op ::= NK_LE */
+ { 392, -1 }, /* (391) compare_op ::= NK_GE */
+ { 392, -1 }, /* (392) compare_op ::= NK_NE */
+ { 392, -1 }, /* (393) compare_op ::= NK_EQ */
+ { 392, -1 }, /* (394) compare_op ::= LIKE */
+ { 392, -2 }, /* (395) compare_op ::= NOT LIKE */
+ { 392, -1 }, /* (396) compare_op ::= MATCH */
+ { 392, -1 }, /* (397) compare_op ::= NMATCH */
+ { 392, -1 }, /* (398) compare_op ::= CONTAINS */
+ { 393, -1 }, /* (399) in_op ::= IN */
+ { 393, -2 }, /* (400) in_op ::= NOT IN */
+ { 394, -3 }, /* (401) in_predicate_value ::= NK_LP literal_list NK_RP */
+ { 395, -1 }, /* (402) boolean_value_expression ::= boolean_primary */
+ { 395, -2 }, /* (403) boolean_value_expression ::= NOT boolean_primary */
+ { 395, -3 }, /* (404) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ { 395, -3 }, /* (405) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ { 396, -1 }, /* (406) boolean_primary ::= predicate */
+ { 396, -3 }, /* (407) boolean_primary ::= NK_LP boolean_value_expression NK_RP */
+ { 397, -1 }, /* (408) common_expression ::= expression */
+ { 397, -1 }, /* (409) common_expression ::= boolean_value_expression */
+ { 398, 0 }, /* (410) from_clause_opt ::= */
+ { 398, -2 }, /* (411) from_clause_opt ::= FROM table_reference_list */
+ { 399, -1 }, /* (412) table_reference_list ::= table_reference */
+ { 399, -3 }, /* (413) table_reference_list ::= table_reference_list NK_COMMA table_reference */
+ { 400, -1 }, /* (414) table_reference ::= table_primary */
+ { 400, -1 }, /* (415) table_reference ::= joined_table */
+ { 401, -2 }, /* (416) table_primary ::= table_name alias_opt */
+ { 401, -4 }, /* (417) table_primary ::= db_name NK_DOT table_name alias_opt */
+ { 401, -2 }, /* (418) table_primary ::= subquery alias_opt */
+ { 401, -1 }, /* (419) table_primary ::= parenthesized_joined_table */
+ { 403, 0 }, /* (420) alias_opt ::= */
+ { 403, -1 }, /* (421) alias_opt ::= table_alias */
+ { 403, -2 }, /* (422) alias_opt ::= AS table_alias */
+ { 404, -3 }, /* (423) parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ { 404, -3 }, /* (424) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */
+ { 402, -6 }, /* (425) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+ { 405, 0 }, /* (426) join_type ::= */
+ { 405, -1 }, /* (427) join_type ::= INNER */
+ { 407, -12 }, /* (428) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ { 408, 0 }, /* (429) set_quantifier_opt ::= */
+ { 408, -1 }, /* (430) set_quantifier_opt ::= DISTINCT */
+ { 408, -1 }, /* (431) set_quantifier_opt ::= ALL */
+ { 409, -1 }, /* (432) select_list ::= select_item */
+ { 409, -3 }, /* (433) select_list ::= select_list NK_COMMA select_item */
+ { 417, -1 }, /* (434) select_item ::= NK_STAR */
+ { 417, -1 }, /* (435) select_item ::= common_expression */
+ { 417, -2 }, /* (436) select_item ::= common_expression column_alias */
+ { 417, -3 }, /* (437) select_item ::= common_expression AS column_alias */
+ { 417, -3 }, /* (438) select_item ::= table_name NK_DOT NK_STAR */
+ { 375, 0 }, /* (439) where_clause_opt ::= */
+ { 375, -2 }, /* (440) where_clause_opt ::= WHERE search_condition */
+ { 410, 0 }, /* (441) partition_by_clause_opt ::= */
+ { 410, -3 }, /* (442) partition_by_clause_opt ::= PARTITION BY expression_list */
+ { 414, 0 }, /* (443) twindow_clause_opt ::= */
+ { 414, -6 }, /* (444) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
+ { 414, -4 }, /* (445) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
+ { 414, -6 }, /* (446) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+ { 414, -8 }, /* (447) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+ { 362, 0 }, /* (448) sliding_opt ::= */
+ { 362, -4 }, /* (449) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
+ { 413, 0 }, /* (450) fill_opt ::= */
+ { 413, -4 }, /* (451) fill_opt ::= FILL NK_LP fill_mode NK_RP */
+ { 413, -6 }, /* (452) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+ { 418, -1 }, /* (453) fill_mode ::= NONE */
+ { 418, -1 }, /* (454) fill_mode ::= PREV */
+ { 418, -1 }, /* (455) fill_mode ::= NULL */
+ { 418, -1 }, /* (456) fill_mode ::= LINEAR */
+ { 418, -1 }, /* (457) fill_mode ::= NEXT */
+ { 415, 0 }, /* (458) group_by_clause_opt ::= */
+ { 415, -3 }, /* (459) group_by_clause_opt ::= GROUP BY group_by_list */
+ { 419, -1 }, /* (460) group_by_list ::= expression */
+ { 419, -3 }, /* (461) group_by_list ::= group_by_list NK_COMMA expression */
+ { 416, 0 }, /* (462) having_clause_opt ::= */
+ { 416, -2 }, /* (463) having_clause_opt ::= HAVING search_condition */
+ { 411, 0 }, /* (464) range_opt ::= */
+ { 411, -6 }, /* (465) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */
+ { 412, 0 }, /* (466) every_opt ::= */
+ { 412, -4 }, /* (467) every_opt ::= EVERY NK_LP duration_literal NK_RP */
+ { 367, -4 }, /* (468) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ { 420, -1 }, /* (469) query_expression_body ::= query_primary */
+ { 420, -4 }, /* (470) query_expression_body ::= query_expression_body UNION ALL query_expression_body */
+ { 420, -3 }, /* (471) query_expression_body ::= query_expression_body UNION query_expression_body */
+ { 424, -1 }, /* (472) query_primary ::= query_specification */
+ { 424, -6 }, /* (473) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */
+ { 421, 0 }, /* (474) order_by_clause_opt ::= */
+ { 421, -3 }, /* (475) order_by_clause_opt ::= ORDER BY sort_specification_list */
+ { 422, 0 }, /* (476) slimit_clause_opt ::= */
+ { 422, -2 }, /* (477) slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ { 422, -4 }, /* (478) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ { 422, -4 }, /* (479) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 423, 0 }, /* (480) limit_clause_opt ::= */
+ { 423, -2 }, /* (481) limit_clause_opt ::= LIMIT NK_INTEGER */
+ { 423, -4 }, /* (482) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */
+ { 423, -4 }, /* (483) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ { 385, -3 }, /* (484) subquery ::= NK_LP query_expression NK_RP */
+ { 406, -1 }, /* (485) search_condition ::= common_expression */
+ { 425, -1 }, /* (486) sort_specification_list ::= sort_specification */
+ { 425, -3 }, /* (487) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */
+ { 426, -3 }, /* (488) sort_specification ::= expression ordering_specification_opt null_ordering_opt */
+ { 427, 0 }, /* (489) ordering_specification_opt ::= */
+ { 427, -1 }, /* (490) ordering_specification_opt ::= ASC */
+ { 427, -1 }, /* (491) ordering_specification_opt ::= DESC */
+ { 428, 0 }, /* (492) null_ordering_opt ::= */
+ { 428, -2 }, /* (493) null_ordering_opt ::= NULLS FIRST */
+ { 428, -2 }, /* (494) null_ordering_opt ::= NULLS LAST */
};
static void yy_accept(yyParser*); /* Forward Declaration */
@@ -3419,11 +3415,11 @@ static YYACTIONTYPE yy_reduce(
YYMINORTYPE yylhsminor;
case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
- yy_destructor(yypParser,307,&yymsp[0].minor);
+ yy_destructor(yypParser,309,&yymsp[0].minor);
break;
case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
- yy_destructor(yypParser,308,&yymsp[0].minor);
+ yy_destructor(yypParser,310,&yymsp[0].minor);
break;
case 2: /* account_options ::= */
{ }
@@ -3437,20 +3433,20 @@ static YYACTIONTYPE yy_reduce(
case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9);
case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10);
case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11);
-{ yy_destructor(yypParser,307,&yymsp[-2].minor);
+{ yy_destructor(yypParser,309,&yymsp[-2].minor);
{ }
- yy_destructor(yypParser,309,&yymsp[0].minor);
+ yy_destructor(yypParser,311,&yymsp[0].minor);
}
break;
case 12: /* alter_account_options ::= alter_account_option */
-{ yy_destructor(yypParser,310,&yymsp[0].minor);
+{ yy_destructor(yypParser,312,&yymsp[0].minor);
{ }
}
break;
case 13: /* alter_account_options ::= alter_account_options alter_account_option */
-{ yy_destructor(yypParser,308,&yymsp[-1].minor);
+{ yy_destructor(yypParser,310,&yymsp[-1].minor);
{ }
- yy_destructor(yypParser,310,&yymsp[0].minor);
+ yy_destructor(yypParser,312,&yymsp[0].minor);
}
break;
case 14: /* alter_account_option ::= PASS literal */
@@ -3464,72 +3460,72 @@ static YYACTIONTYPE yy_reduce(
case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22);
case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23);
{ }
- yy_destructor(yypParser,309,&yymsp[0].minor);
+ yy_destructor(yypParser,311,&yymsp[0].minor);
break;
case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt */
-{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy617, &yymsp[-1].minor.yy0, yymsp[0].minor.yy215); }
+{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-3].minor.yy239, &yymsp[-1].minor.yy0, yymsp[0].minor.yy509); }
break;
case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy617, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); }
break;
case 26: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy617, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); }
break;
case 27: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */
-{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy617, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy239, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); }
break;
case 28: /* cmd ::= DROP USER user_name */
-{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy239); }
break;
case 29: /* sysinfo_opt ::= */
-{ yymsp[1].minor.yy215 = 1; }
+{ yymsp[1].minor.yy509 = 1; }
break;
case 30: /* sysinfo_opt ::= SYSINFO NK_INTEGER */
-{ yymsp[-1].minor.yy215 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); }
+{ yymsp[-1].minor.yy509 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); }
break;
case 31: /* cmd ::= GRANT privileges ON priv_level TO user_name */
-{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy473, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); }
break;
case 32: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */
-{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy473, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy129, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); }
break;
case 33: /* privileges ::= ALL */
-{ yymsp[0].minor.yy473 = PRIVILEGE_TYPE_ALL; }
+{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_ALL; }
break;
case 34: /* privileges ::= priv_type_list */
case 35: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==35);
-{ yylhsminor.yy473 = yymsp[0].minor.yy473; }
- yymsp[0].minor.yy473 = yylhsminor.yy473;
+{ yylhsminor.yy129 = yymsp[0].minor.yy129; }
+ yymsp[0].minor.yy129 = yylhsminor.yy129;
break;
case 36: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */
-{ yylhsminor.yy473 = yymsp[-2].minor.yy473 | yymsp[0].minor.yy473; }
- yymsp[-2].minor.yy473 = yylhsminor.yy473;
+{ yylhsminor.yy129 = yymsp[-2].minor.yy129 | yymsp[0].minor.yy129; }
+ yymsp[-2].minor.yy129 = yylhsminor.yy129;
break;
case 37: /* priv_type ::= READ */
-{ yymsp[0].minor.yy473 = PRIVILEGE_TYPE_READ; }
+{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_READ; }
break;
case 38: /* priv_type ::= WRITE */
-{ yymsp[0].minor.yy473 = PRIVILEGE_TYPE_WRITE; }
+{ yymsp[0].minor.yy129 = PRIVILEGE_TYPE_WRITE; }
break;
case 39: /* priv_level ::= NK_STAR NK_DOT NK_STAR */
-{ yylhsminor.yy617 = yymsp[-2].minor.yy0; }
- yymsp[-2].minor.yy617 = yylhsminor.yy617;
+{ yylhsminor.yy239 = yymsp[-2].minor.yy0; }
+ yymsp[-2].minor.yy239 = yylhsminor.yy239;
break;
case 40: /* priv_level ::= db_name NK_DOT NK_STAR */
-{ yylhsminor.yy617 = yymsp[-2].minor.yy617; }
- yymsp[-2].minor.yy617 = yylhsminor.yy617;
+{ yylhsminor.yy239 = yymsp[-2].minor.yy239; }
+ yymsp[-2].minor.yy239 = yylhsminor.yy239;
break;
case 41: /* cmd ::= CREATE DNODE dnode_endpoint */
-{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy617, NULL); }
+{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy239, NULL); }
break;
case 42: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */
-{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy0); }
+{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0); }
break;
case 43: /* cmd ::= DROP DNODE NK_INTEGER */
{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); }
break;
case 44: /* cmd ::= DROP DNODE dnode_endpoint */
-{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy239); }
break;
case 45: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */
{ pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); }
@@ -3546,31 +3542,31 @@ static YYACTIONTYPE yy_reduce(
case 49: /* dnode_endpoint ::= NK_STRING */
case 50: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==50);
case 51: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==51);
- case 316: /* db_name ::= NK_ID */ yytestcase(yyruleno==316);
- case 317: /* table_name ::= NK_ID */ yytestcase(yyruleno==317);
- case 318: /* column_name ::= NK_ID */ yytestcase(yyruleno==318);
- case 319: /* function_name ::= NK_ID */ yytestcase(yyruleno==319);
- case 320: /* table_alias ::= NK_ID */ yytestcase(yyruleno==320);
- case 321: /* column_alias ::= NK_ID */ yytestcase(yyruleno==321);
- case 322: /* user_name ::= NK_ID */ yytestcase(yyruleno==322);
- case 323: /* topic_name ::= NK_ID */ yytestcase(yyruleno==323);
- case 324: /* stream_name ::= NK_ID */ yytestcase(yyruleno==324);
- case 325: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==325);
- case 361: /* noarg_func ::= NOW */ yytestcase(yyruleno==361);
- case 362: /* noarg_func ::= TODAY */ yytestcase(yyruleno==362);
- case 363: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==363);
- case 364: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==364);
- case 365: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==365);
- case 366: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==366);
- case 367: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==367);
- case 368: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==368);
- case 369: /* noarg_func ::= USER */ yytestcase(yyruleno==369);
- case 370: /* star_func ::= COUNT */ yytestcase(yyruleno==370);
- case 371: /* star_func ::= FIRST */ yytestcase(yyruleno==371);
- case 372: /* star_func ::= LAST */ yytestcase(yyruleno==372);
- case 373: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==373);
-{ yylhsminor.yy617 = yymsp[0].minor.yy0; }
- yymsp[0].minor.yy617 = yylhsminor.yy617;
+ case 318: /* db_name ::= NK_ID */ yytestcase(yyruleno==318);
+ case 319: /* table_name ::= NK_ID */ yytestcase(yyruleno==319);
+ case 320: /* column_name ::= NK_ID */ yytestcase(yyruleno==320);
+ case 321: /* function_name ::= NK_ID */ yytestcase(yyruleno==321);
+ case 322: /* table_alias ::= NK_ID */ yytestcase(yyruleno==322);
+ case 323: /* column_alias ::= NK_ID */ yytestcase(yyruleno==323);
+ case 324: /* user_name ::= NK_ID */ yytestcase(yyruleno==324);
+ case 325: /* topic_name ::= NK_ID */ yytestcase(yyruleno==325);
+ case 326: /* stream_name ::= NK_ID */ yytestcase(yyruleno==326);
+ case 327: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==327);
+ case 363: /* noarg_func ::= NOW */ yytestcase(yyruleno==363);
+ case 364: /* noarg_func ::= TODAY */ yytestcase(yyruleno==364);
+ case 365: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==365);
+ case 366: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==366);
+ case 367: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==367);
+ case 368: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==368);
+ case 369: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==369);
+ case 370: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==370);
+ case 371: /* noarg_func ::= USER */ yytestcase(yyruleno==371);
+ case 372: /* star_func ::= COUNT */ yytestcase(yyruleno==372);
+ case 373: /* star_func ::= FIRST */ yytestcase(yyruleno==373);
+ case 374: /* star_func ::= LAST */ yytestcase(yyruleno==374);
+ case 375: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==375);
+{ yylhsminor.yy239 = yymsp[0].minor.yy0; }
+ yymsp[0].minor.yy239 = yylhsminor.yy239;
break;
case 52: /* cmd ::= ALTER LOCAL NK_STRING */
{ pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); }
@@ -3603,1274 +3599,1282 @@ static YYACTIONTYPE yy_reduce(
{ pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); }
break;
case 62: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */
-{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy313, &yymsp[-1].minor.yy617, yymsp[0].minor.yy840); }
+{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy845, &yymsp[-1].minor.yy239, yymsp[0].minor.yy80); }
break;
case 63: /* cmd ::= DROP DATABASE exists_opt db_name */
-{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy313, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); }
break;
case 64: /* cmd ::= USE db_name */
-{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy239); }
break;
case 65: /* cmd ::= ALTER DATABASE db_name alter_db_options */
-{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy617, yymsp[0].minor.yy840); }
+{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy239, yymsp[0].minor.yy80); }
break;
case 66: /* cmd ::= FLUSH DATABASE db_name */
-{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy239); }
break;
case 67: /* cmd ::= TRIM DATABASE db_name */
-{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy617); }
+{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[0].minor.yy239); }
break;
case 68: /* not_exists_opt ::= IF NOT EXISTS */
-{ yymsp[-2].minor.yy313 = true; }
+{ yymsp[-2].minor.yy845 = true; }
break;
case 69: /* not_exists_opt ::= */
case 71: /* exists_opt ::= */ yytestcase(yyruleno==71);
- case 259: /* analyze_opt ::= */ yytestcase(yyruleno==259);
- case 266: /* agg_func_opt ::= */ yytestcase(yyruleno==266);
- case 427: /* set_quantifier_opt ::= */ yytestcase(yyruleno==427);
-{ yymsp[1].minor.yy313 = false; }
+ case 261: /* analyze_opt ::= */ yytestcase(yyruleno==261);
+ case 268: /* agg_func_opt ::= */ yytestcase(yyruleno==268);
+ case 429: /* set_quantifier_opt ::= */ yytestcase(yyruleno==429);
+{ yymsp[1].minor.yy845 = false; }
break;
case 70: /* exists_opt ::= IF EXISTS */
-{ yymsp[-1].minor.yy313 = true; }
+{ yymsp[-1].minor.yy845 = true; }
break;
case 72: /* db_options ::= */
-{ yymsp[1].minor.yy840 = createDefaultDatabaseOptions(pCxt); }
+{ yymsp[1].minor.yy80 = createDefaultDatabaseOptions(pCxt); }
break;
case 73: /* db_options ::= db_options BUFFER NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 74: /* db_options ::= db_options CACHEMODEL NK_STRING */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 75: /* db_options ::= db_options CACHESIZE NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 76: /* db_options ::= db_options COMP NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_COMP, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 77: /* db_options ::= db_options DURATION NK_INTEGER */
case 78: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==78);
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_DAYS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 79: /* db_options ::= db_options MAXROWS NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 80: /* db_options ::= db_options MINROWS NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 81: /* db_options ::= db_options KEEP integer_list */
case 82: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==82);
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_KEEP, yymsp[0].minor.yy544); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_KEEP, yymsp[0].minor.yy574); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 83: /* db_options ::= db_options PAGES NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_PAGES, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGES, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 84: /* db_options ::= db_options PAGESIZE NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 85: /* db_options ::= db_options PRECISION NK_STRING */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 86: /* db_options ::= db_options REPLICA NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 87: /* db_options ::= db_options STRICT NK_STRING */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_STRICT, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_STRICT, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 88: /* db_options ::= db_options VGROUPS NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 89: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 90: /* db_options ::= db_options RETENTIONS retention_list */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_RETENTIONS, yymsp[0].minor.yy544); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_RETENTIONS, yymsp[0].minor.yy574); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 91: /* db_options ::= db_options SCHEMALESS NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 92: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 93: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 94: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 95: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-3].minor.yy840, DB_OPTION_WAL_RETENTION_PERIOD, &t);
+ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_PERIOD, &t);
}
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
case 96: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 97: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-3].minor.yy840, DB_OPTION_WAL_RETENTION_SIZE, &t);
+ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-3].minor.yy80, DB_OPTION_WAL_RETENTION_SIZE, &t);
}
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
case 98: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 99: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
case 100: /* db_options ::= db_options SST_TRIGGER NK_INTEGER */
-{ yylhsminor.yy840 = setDatabaseOption(pCxt, yymsp[-2].minor.yy840, DB_OPTION_SST_TRIGGER, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
- break;
- case 101: /* alter_db_options ::= alter_db_option */
-{ yylhsminor.yy840 = createAlterDatabaseOptions(pCxt); yylhsminor.yy840 = setAlterDatabaseOption(pCxt, yylhsminor.yy840, &yymsp[0].minor.yy95); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
- break;
- case 102: /* alter_db_options ::= alter_db_options alter_db_option */
-{ yylhsminor.yy840 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy840, &yymsp[0].minor.yy95); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
- break;
- case 103: /* alter_db_option ::= CACHEMODEL NK_STRING */
-{ yymsp[-1].minor.yy95.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
- break;
- case 104: /* alter_db_option ::= CACHESIZE NK_INTEGER */
-{ yymsp[-1].minor.yy95.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
- break;
- case 105: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
-{ yymsp[-1].minor.yy95.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
- break;
- case 106: /* alter_db_option ::= KEEP integer_list */
- case 107: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==107);
-{ yymsp[-1].minor.yy95.type = DB_OPTION_KEEP; yymsp[-1].minor.yy95.pList = yymsp[0].minor.yy544; }
- break;
- case 108: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */
-{ yymsp[-1].minor.yy95.type = DB_OPTION_WAL; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
- break;
- case 109: /* alter_db_option ::= SST_TRIGGER NK_INTEGER */
-{ yymsp[-1].minor.yy95.type = DB_OPTION_SST_TRIGGER; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
- break;
- case 110: /* integer_list ::= NK_INTEGER */
-{ yylhsminor.yy544 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
- break;
- case 111: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */
- case 286: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==286);
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-2].minor.yy544, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy544 = yylhsminor.yy544;
- break;
- case 112: /* variable_list ::= NK_VARIABLE */
-{ yylhsminor.yy544 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
- break;
- case 113: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-2].minor.yy544, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy544 = yylhsminor.yy544;
- break;
- case 114: /* retention_list ::= retention */
- case 134: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==134);
- case 137: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==137);
- case 144: /* column_def_list ::= column_def */ yytestcase(yyruleno==144);
- case 187: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==187);
- case 192: /* col_name_list ::= col_name */ yytestcase(yyruleno==192);
- case 242: /* func_list ::= func */ yytestcase(yyruleno==242);
- case 314: /* literal_list ::= signed_literal */ yytestcase(yyruleno==314);
- case 376: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==376);
- case 430: /* select_list ::= select_item */ yytestcase(yyruleno==430);
- case 484: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==484);
-{ yylhsminor.yy544 = createNodeList(pCxt, yymsp[0].minor.yy840); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
- break;
- case 115: /* retention_list ::= retention_list NK_COMMA retention */
- case 145: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==145);
- case 188: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==188);
- case 193: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==193);
- case 243: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==243);
- case 315: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==315);
- case 377: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==377);
- case 431: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==431);
- case 485: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==485);
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-2].minor.yy544, yymsp[0].minor.yy840); }
- yymsp[-2].minor.yy544 = yylhsminor.yy544;
- break;
- case 116: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
-{ yylhsminor.yy840 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
- break;
- case 117: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
- case 119: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==119);
-{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy313, yymsp[-5].minor.yy840, yymsp[-3].minor.yy544, yymsp[-1].minor.yy544, yymsp[0].minor.yy840); }
- break;
- case 118: /* cmd ::= CREATE TABLE multi_create_clause */
-{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy544); }
- break;
- case 120: /* cmd ::= DROP TABLE multi_drop_clause */
-{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy544); }
- break;
- case 121: /* cmd ::= DROP STABLE exists_opt full_table_name */
-{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy313, yymsp[0].minor.yy840); }
- break;
- case 122: /* cmd ::= ALTER TABLE alter_table_clause */
- case 288: /* cmd ::= query_expression */ yytestcase(yyruleno==288);
-{ pCxt->pRootNode = yymsp[0].minor.yy840; }
- break;
- case 123: /* cmd ::= ALTER STABLE alter_table_clause */
-{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy840); }
- break;
- case 124: /* alter_table_clause ::= full_table_name alter_table_options */
-{ yylhsminor.yy840 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
- break;
- case 125: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
-{ yylhsminor.yy840 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy617, yymsp[0].minor.yy784); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
- break;
- case 126: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */
-{ yylhsminor.yy840 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy840, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy617); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
- break;
- case 127: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
-{ yylhsminor.yy840 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy617, yymsp[0].minor.yy784); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_SST_TRIGGER, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 101: /* db_options ::= db_options TABLE_PREFIX NK_INTEGER */
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_PREFIX, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 102: /* db_options ::= db_options TABLE_SUFFIX NK_INTEGER */
+{ yylhsminor.yy80 = setDatabaseOption(pCxt, yymsp[-2].minor.yy80, DB_OPTION_TABLE_SUFFIX, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 103: /* alter_db_options ::= alter_db_option */
+{ yylhsminor.yy80 = createAlterDatabaseOptions(pCxt); yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yylhsminor.yy80, &yymsp[0].minor.yy299); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 104: /* alter_db_options ::= alter_db_options alter_db_option */
+{ yylhsminor.yy80 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy80, &yymsp[0].minor.yy299); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 105: /* alter_db_option ::= CACHEMODEL NK_STRING */
+{ yymsp[-1].minor.yy299.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
+ break;
+ case 106: /* alter_db_option ::= CACHESIZE NK_INTEGER */
+{ yymsp[-1].minor.yy299.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
+ break;
+ case 107: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */
+{ yymsp[-1].minor.yy299.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
+ break;
+ case 108: /* alter_db_option ::= KEEP integer_list */
+ case 109: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==109);
+{ yymsp[-1].minor.yy299.type = DB_OPTION_KEEP; yymsp[-1].minor.yy299.pList = yymsp[0].minor.yy574; }
+ break;
+ case 110: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */
+{ yymsp[-1].minor.yy299.type = DB_OPTION_WAL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
+ break;
+ case 111: /* alter_db_option ::= SST_TRIGGER NK_INTEGER */
+{ yymsp[-1].minor.yy299.type = DB_OPTION_SST_TRIGGER; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
+ break;
+ case 112: /* integer_list ::= NK_INTEGER */
+{ yylhsminor.yy574 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 113: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */
+ case 288: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==288);
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 114: /* variable_list ::= NK_VARIABLE */
+{ yylhsminor.yy574 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 115: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 116: /* retention_list ::= retention */
+ case 136: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==136);
+ case 139: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==139);
+ case 146: /* column_def_list ::= column_def */ yytestcase(yyruleno==146);
+ case 189: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==189);
+ case 194: /* col_name_list ::= col_name */ yytestcase(yyruleno==194);
+ case 244: /* func_list ::= func */ yytestcase(yyruleno==244);
+ case 316: /* literal_list ::= signed_literal */ yytestcase(yyruleno==316);
+ case 378: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==378);
+ case 432: /* select_list ::= select_item */ yytestcase(yyruleno==432);
+ case 486: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==486);
+{ yylhsminor.yy574 = createNodeList(pCxt, yymsp[0].minor.yy80); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 117: /* retention_list ::= retention_list NK_COMMA retention */
+ case 147: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==147);
+ case 190: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==190);
+ case 195: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==195);
+ case 245: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==245);
+ case 317: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==317);
+ case 379: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==379);
+ case 433: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==433);
+ case 487: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==487);
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); }
+ yymsp[-2].minor.yy574 = yylhsminor.yy574;
+ break;
+ case 118: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */
+{ yylhsminor.yy80 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 119: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */
+ case 121: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==121);
+{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy845, yymsp[-5].minor.yy80, yymsp[-3].minor.yy574, yymsp[-1].minor.yy574, yymsp[0].minor.yy80); }
+ break;
+ case 120: /* cmd ::= CREATE TABLE multi_create_clause */
+{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy574); }
+ break;
+ case 122: /* cmd ::= DROP TABLE multi_drop_clause */
+{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy574); }
+ break;
+ case 123: /* cmd ::= DROP STABLE exists_opt full_table_name */
+{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); }
+ break;
+ case 124: /* cmd ::= ALTER TABLE alter_table_clause */
+ case 290: /* cmd ::= query_expression */ yytestcase(yyruleno==290);
+{ pCxt->pRootNode = yymsp[0].minor.yy80; }
+ break;
+ case 125: /* cmd ::= ALTER STABLE alter_table_clause */
+{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy80); }
+ break;
+ case 126: /* alter_table_clause ::= full_table_name alter_table_options */
+{ yylhsminor.yy80 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 127: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */
+{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 128: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */
+{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy239); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 129: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */
+{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 128: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
-{ yylhsminor.yy840 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy617, &yymsp[0].minor.yy617); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ case 130: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */
+{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 129: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */
-{ yylhsminor.yy840 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy617, yymsp[0].minor.yy784); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
- break;
- case 130: /* alter_table_clause ::= full_table_name DROP TAG column_name */
-{ yylhsminor.yy840 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy840, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy617); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 131: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */
+{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
+ break;
+ case 132: /* alter_table_clause ::= full_table_name DROP TAG column_name */
+{ yylhsminor.yy80 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy80, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy239); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 131: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
-{ yylhsminor.yy840 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy617, yymsp[0].minor.yy784); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ case 133: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */
+{ yylhsminor.yy80 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 132: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
-{ yylhsminor.yy840 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy840, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy617, &yymsp[0].minor.yy617); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ case 134: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */
+{ yylhsminor.yy80 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy80, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 133: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
-{ yylhsminor.yy840 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy840, &yymsp[-2].minor.yy617, yymsp[0].minor.yy840); }
- yymsp[-5].minor.yy840 = yylhsminor.yy840;
+ case 135: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */
+{ yylhsminor.yy80 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy80, &yymsp[-2].minor.yy239, yymsp[0].minor.yy80); }
+ yymsp[-5].minor.yy80 = yylhsminor.yy80;
break;
- case 135: /* multi_create_clause ::= multi_create_clause create_subtable_clause */
- case 138: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==138);
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-1].minor.yy544, yymsp[0].minor.yy840); }
- yymsp[-1].minor.yy544 = yylhsminor.yy544;
+ case 137: /* multi_create_clause ::= multi_create_clause create_subtable_clause */
+ case 140: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==140);
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-1].minor.yy574, yymsp[0].minor.yy80); }
+ yymsp[-1].minor.yy574 = yylhsminor.yy574;
break;
- case 136: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */
-{ yylhsminor.yy840 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy313, yymsp[-8].minor.yy840, yymsp[-6].minor.yy840, yymsp[-5].minor.yy544, yymsp[-2].minor.yy544, yymsp[0].minor.yy840); }
- yymsp[-9].minor.yy840 = yylhsminor.yy840;
+ case 138: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP expression_list NK_RP table_options */
+{ yylhsminor.yy80 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy845, yymsp[-8].minor.yy80, yymsp[-6].minor.yy80, yymsp[-5].minor.yy574, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); }
+ yymsp[-9].minor.yy80 = yylhsminor.yy80;
break;
- case 139: /* drop_table_clause ::= exists_opt full_table_name */
-{ yylhsminor.yy840 = createDropTableClause(pCxt, yymsp[-1].minor.yy313, yymsp[0].minor.yy840); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 141: /* drop_table_clause ::= exists_opt full_table_name */
+{ yylhsminor.yy80 = createDropTableClause(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 140: /* specific_cols_opt ::= */
- case 171: /* tags_def_opt ::= */ yytestcase(yyruleno==171);
- case 439: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==439);
- case 456: /* group_by_clause_opt ::= */ yytestcase(yyruleno==456);
- case 472: /* order_by_clause_opt ::= */ yytestcase(yyruleno==472);
-{ yymsp[1].minor.yy544 = NULL; }
+ case 142: /* specific_cols_opt ::= */
+ case 173: /* tags_def_opt ::= */ yytestcase(yyruleno==173);
+ case 441: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==441);
+ case 458: /* group_by_clause_opt ::= */ yytestcase(yyruleno==458);
+ case 474: /* order_by_clause_opt ::= */ yytestcase(yyruleno==474);
+{ yymsp[1].minor.yy574 = NULL; }
break;
- case 141: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */
-{ yymsp[-2].minor.yy544 = yymsp[-1].minor.yy544; }
+ case 143: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */
+{ yymsp[-2].minor.yy574 = yymsp[-1].minor.yy574; }
break;
- case 142: /* full_table_name ::= table_name */
-{ yylhsminor.yy840 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy617, NULL); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 144: /* full_table_name ::= table_name */
+{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy239, NULL); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 143: /* full_table_name ::= db_name NK_DOT table_name */
-{ yylhsminor.yy840 = createRealTableNode(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617, NULL); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 145: /* full_table_name ::= db_name NK_DOT table_name */
+{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239, NULL); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 146: /* column_def ::= column_name type_name */
-{ yylhsminor.yy840 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy617, yymsp[0].minor.yy784, NULL); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 148: /* column_def ::= column_name type_name */
+{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy239, yymsp[0].minor.yy136, NULL); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 147: /* column_def ::= column_name type_name COMMENT NK_STRING */
-{ yylhsminor.yy840 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy617, yymsp[-2].minor.yy784, &yymsp[0].minor.yy0); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 149: /* column_def ::= column_name type_name COMMENT NK_STRING */
+{ yylhsminor.yy80 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-2].minor.yy136, &yymsp[0].minor.yy0); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 148: /* type_name ::= BOOL */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_BOOL); }
+ case 150: /* type_name ::= BOOL */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BOOL); }
break;
- case 149: /* type_name ::= TINYINT */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_TINYINT); }
+ case 151: /* type_name ::= TINYINT */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_TINYINT); }
break;
- case 150: /* type_name ::= SMALLINT */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_SMALLINT); }
+ case 152: /* type_name ::= SMALLINT */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_SMALLINT); }
break;
- case 151: /* type_name ::= INT */
- case 152: /* type_name ::= INTEGER */ yytestcase(yyruleno==152);
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_INT); }
+ case 153: /* type_name ::= INT */
+ case 154: /* type_name ::= INTEGER */ yytestcase(yyruleno==154);
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_INT); }
break;
- case 153: /* type_name ::= BIGINT */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_BIGINT); }
+ case 155: /* type_name ::= BIGINT */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BIGINT); }
break;
- case 154: /* type_name ::= FLOAT */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_FLOAT); }
+ case 156: /* type_name ::= FLOAT */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_FLOAT); }
break;
- case 155: /* type_name ::= DOUBLE */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_DOUBLE); }
+ case 157: /* type_name ::= DOUBLE */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_DOUBLE); }
break;
- case 156: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy784 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); }
+ case 158: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); }
break;
- case 157: /* type_name ::= TIMESTAMP */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
+ case 159: /* type_name ::= TIMESTAMP */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); }
break;
- case 158: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy784 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); }
+ case 160: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); }
break;
- case 159: /* type_name ::= TINYINT UNSIGNED */
-{ yymsp[-1].minor.yy784 = createDataType(TSDB_DATA_TYPE_UTINYINT); }
+ case 161: /* type_name ::= TINYINT UNSIGNED */
+{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UTINYINT); }
break;
- case 160: /* type_name ::= SMALLINT UNSIGNED */
-{ yymsp[-1].minor.yy784 = createDataType(TSDB_DATA_TYPE_USMALLINT); }
+ case 162: /* type_name ::= SMALLINT UNSIGNED */
+{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_USMALLINT); }
break;
- case 161: /* type_name ::= INT UNSIGNED */
-{ yymsp[-1].minor.yy784 = createDataType(TSDB_DATA_TYPE_UINT); }
+ case 163: /* type_name ::= INT UNSIGNED */
+{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UINT); }
break;
- case 162: /* type_name ::= BIGINT UNSIGNED */
-{ yymsp[-1].minor.yy784 = createDataType(TSDB_DATA_TYPE_UBIGINT); }
+ case 164: /* type_name ::= BIGINT UNSIGNED */
+{ yymsp[-1].minor.yy136 = createDataType(TSDB_DATA_TYPE_UBIGINT); }
break;
- case 163: /* type_name ::= JSON */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_JSON); }
+ case 165: /* type_name ::= JSON */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_JSON); }
break;
- case 164: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy784 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); }
+ case 166: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); }
break;
- case 165: /* type_name ::= MEDIUMBLOB */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
+ case 167: /* type_name ::= MEDIUMBLOB */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); }
break;
- case 166: /* type_name ::= BLOB */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_BLOB); }
+ case 168: /* type_name ::= BLOB */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_BLOB); }
break;
- case 167: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy784 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); }
+ case 169: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy136 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); }
break;
- case 168: /* type_name ::= DECIMAL */
-{ yymsp[0].minor.yy784 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 170: /* type_name ::= DECIMAL */
+{ yymsp[0].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 169: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
-{ yymsp[-3].minor.yy784 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 171: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */
+{ yymsp[-3].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 170: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
-{ yymsp[-5].minor.yy784 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
+ case 172: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */
+{ yymsp[-5].minor.yy136 = createDataType(TSDB_DATA_TYPE_DECIMAL); }
break;
- case 172: /* tags_def_opt ::= tags_def */
- case 375: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==375);
-{ yylhsminor.yy544 = yymsp[0].minor.yy544; }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
+ case 174: /* tags_def_opt ::= tags_def */
+ case 377: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==377);
+{ yylhsminor.yy574 = yymsp[0].minor.yy574; }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
break;
- case 173: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */
-{ yymsp[-3].minor.yy544 = yymsp[-1].minor.yy544; }
+ case 175: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */
+{ yymsp[-3].minor.yy574 = yymsp[-1].minor.yy574; }
break;
- case 174: /* table_options ::= */
-{ yymsp[1].minor.yy840 = createDefaultTableOptions(pCxt); }
+ case 176: /* table_options ::= */
+{ yymsp[1].minor.yy80 = createDefaultTableOptions(pCxt); }
break;
- case 175: /* table_options ::= table_options COMMENT NK_STRING */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-2].minor.yy840, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 177: /* table_options ::= table_options COMMENT NK_STRING */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 176: /* table_options ::= table_options MAX_DELAY duration_list */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-2].minor.yy840, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy544); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 178: /* table_options ::= table_options MAX_DELAY duration_list */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy574); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 177: /* table_options ::= table_options WATERMARK duration_list */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-2].minor.yy840, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy544); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 179: /* table_options ::= table_options WATERMARK duration_list */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy574); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 178: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-4].minor.yy840, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy544); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ case 180: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy574); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 179: /* table_options ::= table_options TTL NK_INTEGER */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-2].minor.yy840, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 181: /* table_options ::= table_options TTL NK_INTEGER */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-2].minor.yy80, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 180: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-4].minor.yy840, TABLE_OPTION_SMA, yymsp[-1].minor.yy544); }
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ case 182: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-4].minor.yy80, TABLE_OPTION_SMA, yymsp[-1].minor.yy574); }
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 181: /* alter_table_options ::= alter_table_option */
-{ yylhsminor.yy840 = createAlterTableOptions(pCxt); yylhsminor.yy840 = setTableOption(pCxt, yylhsminor.yy840, yymsp[0].minor.yy95.type, &yymsp[0].minor.yy95.val); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 183: /* alter_table_options ::= alter_table_option */
+{ yylhsminor.yy80 = createAlterTableOptions(pCxt); yylhsminor.yy80 = setTableOption(pCxt, yylhsminor.yy80, yymsp[0].minor.yy299.type, &yymsp[0].minor.yy299.val); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 182: /* alter_table_options ::= alter_table_options alter_table_option */
-{ yylhsminor.yy840 = setTableOption(pCxt, yymsp[-1].minor.yy840, yymsp[0].minor.yy95.type, &yymsp[0].minor.yy95.val); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 184: /* alter_table_options ::= alter_table_options alter_table_option */
+{ yylhsminor.yy80 = setTableOption(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy299.type, &yymsp[0].minor.yy299.val); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 183: /* alter_table_option ::= COMMENT NK_STRING */
-{ yymsp[-1].minor.yy95.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
+ case 185: /* alter_table_option ::= COMMENT NK_STRING */
+{ yymsp[-1].minor.yy299.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
break;
- case 184: /* alter_table_option ::= TTL NK_INTEGER */
-{ yymsp[-1].minor.yy95.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy95.val = yymsp[0].minor.yy0; }
+ case 186: /* alter_table_option ::= TTL NK_INTEGER */
+{ yymsp[-1].minor.yy299.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy299.val = yymsp[0].minor.yy0; }
break;
- case 185: /* duration_list ::= duration_literal */
- case 342: /* expression_list ::= expression */ yytestcase(yyruleno==342);
-{ yylhsminor.yy544 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy840)); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
+ case 187: /* duration_list ::= duration_literal */
+ case 344: /* expression_list ::= expression */ yytestcase(yyruleno==344);
+{ yylhsminor.yy574 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
break;
- case 186: /* duration_list ::= duration_list NK_COMMA duration_literal */
- case 343: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==343);
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-2].minor.yy544, releaseRawExprNode(pCxt, yymsp[0].minor.yy840)); }
- yymsp[-2].minor.yy544 = yylhsminor.yy544;
+ case 188: /* duration_list ::= duration_list NK_COMMA duration_literal */
+ case 345: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==345);
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, releaseRawExprNode(pCxt, yymsp[0].minor.yy80)); }
+ yymsp[-2].minor.yy574 = yylhsminor.yy574;
break;
- case 189: /* rollup_func_name ::= function_name */
-{ yylhsminor.yy840 = createFunctionNode(pCxt, &yymsp[0].minor.yy617, NULL); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 191: /* rollup_func_name ::= function_name */
+{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy239, NULL); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 190: /* rollup_func_name ::= FIRST */
- case 191: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==191);
-{ yylhsminor.yy840 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 192: /* rollup_func_name ::= FIRST */
+ case 193: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==193);
+{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 194: /* col_name ::= column_name */
-{ yylhsminor.yy840 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy617); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 196: /* col_name ::= column_name */
+{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy239); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 195: /* cmd ::= SHOW DNODES */
+ case 197: /* cmd ::= SHOW DNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); }
break;
- case 196: /* cmd ::= SHOW USERS */
+ case 198: /* cmd ::= SHOW USERS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); }
break;
- case 197: /* cmd ::= SHOW DATABASES */
+ case 199: /* cmd ::= SHOW DATABASES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); }
break;
- case 198: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy840, yymsp[0].minor.yy840, OP_TYPE_LIKE); }
+ case 200: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); }
break;
- case 199: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy840, yymsp[0].minor.yy840, OP_TYPE_LIKE); }
+ case 201: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, OP_TYPE_LIKE); }
break;
- case 200: /* cmd ::= SHOW db_name_cond_opt VGROUPS */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy840, NULL, OP_TYPE_LIKE); }
+ case 202: /* cmd ::= SHOW db_name_cond_opt VGROUPS */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy80, NULL, OP_TYPE_LIKE); }
break;
- case 201: /* cmd ::= SHOW MNODES */
+ case 203: /* cmd ::= SHOW MNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); }
break;
- case 202: /* cmd ::= SHOW MODULES */
+ case 204: /* cmd ::= SHOW MODULES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); }
break;
- case 203: /* cmd ::= SHOW QNODES */
+ case 205: /* cmd ::= SHOW QNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); }
break;
- case 204: /* cmd ::= SHOW FUNCTIONS */
+ case 206: /* cmd ::= SHOW FUNCTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); }
break;
- case 205: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy840, yymsp[-1].minor.yy840, OP_TYPE_EQUAL); }
+ case 207: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); }
break;
- case 206: /* cmd ::= SHOW STREAMS */
+ case 208: /* cmd ::= SHOW STREAMS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); }
break;
- case 207: /* cmd ::= SHOW ACCOUNTS */
+ case 209: /* cmd ::= SHOW ACCOUNTS */
{ pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); }
break;
- case 208: /* cmd ::= SHOW APPS */
+ case 210: /* cmd ::= SHOW APPS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); }
break;
- case 209: /* cmd ::= SHOW CONNECTIONS */
+ case 211: /* cmd ::= SHOW CONNECTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); }
break;
- case 210: /* cmd ::= SHOW LICENCES */
- case 211: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==211);
+ case 212: /* cmd ::= SHOW LICENCES */
+ case 213: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==213);
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); }
break;
- case 212: /* cmd ::= SHOW CREATE DATABASE db_name */
-{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy617); }
+ case 214: /* cmd ::= SHOW CREATE DATABASE db_name */
+{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy239); }
break;
- case 213: /* cmd ::= SHOW CREATE TABLE full_table_name */
-{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy840); }
+ case 215: /* cmd ::= SHOW CREATE TABLE full_table_name */
+{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy80); }
break;
- case 214: /* cmd ::= SHOW CREATE STABLE full_table_name */
-{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy840); }
+ case 216: /* cmd ::= SHOW CREATE STABLE full_table_name */
+{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy80); }
break;
- case 215: /* cmd ::= SHOW QUERIES */
+ case 217: /* cmd ::= SHOW QUERIES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); }
break;
- case 216: /* cmd ::= SHOW SCORES */
+ case 218: /* cmd ::= SHOW SCORES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); }
break;
- case 217: /* cmd ::= SHOW TOPICS */
+ case 219: /* cmd ::= SHOW TOPICS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); }
break;
- case 218: /* cmd ::= SHOW VARIABLES */
+ case 220: /* cmd ::= SHOW VARIABLES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); }
break;
- case 219: /* cmd ::= SHOW LOCAL VARIABLES */
+ case 221: /* cmd ::= SHOW LOCAL VARIABLES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); }
break;
- case 220: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */
+ case 222: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */
{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); }
break;
- case 221: /* cmd ::= SHOW BNODES */
+ case 223: /* cmd ::= SHOW BNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); }
break;
- case 222: /* cmd ::= SHOW SNODES */
+ case 224: /* cmd ::= SHOW SNODES */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); }
break;
- case 223: /* cmd ::= SHOW CLUSTER */
+ case 225: /* cmd ::= SHOW CLUSTER */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); }
break;
- case 224: /* cmd ::= SHOW TRANSACTIONS */
+ case 226: /* cmd ::= SHOW TRANSACTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); }
break;
- case 225: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
-{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy840); }
+ case 227: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */
+{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy80); }
break;
- case 226: /* cmd ::= SHOW CONSUMERS */
+ case 228: /* cmd ::= SHOW CONSUMERS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); }
break;
- case 227: /* cmd ::= SHOW SUBSCRIPTIONS */
+ case 229: /* cmd ::= SHOW SUBSCRIPTIONS */
{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); }
break;
- case 228: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
-{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy840, yymsp[-1].minor.yy840, OP_TYPE_EQUAL); }
+ case 230: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */
+{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy80, yymsp[-1].minor.yy80, OP_TYPE_EQUAL); }
break;
- case 229: /* cmd ::= SHOW VNODES NK_INTEGER */
+ case 231: /* cmd ::= SHOW VNODES NK_INTEGER */
{ pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); }
break;
- case 230: /* cmd ::= SHOW VNODES NK_STRING */
+ case 232: /* cmd ::= SHOW VNODES NK_STRING */
{ pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); }
break;
- case 231: /* db_name_cond_opt ::= */
- case 236: /* from_db_opt ::= */ yytestcase(yyruleno==236);
-{ yymsp[1].minor.yy840 = createDefaultDatabaseCondValue(pCxt); }
+ case 233: /* db_name_cond_opt ::= */
+ case 238: /* from_db_opt ::= */ yytestcase(yyruleno==238);
+{ yymsp[1].minor.yy80 = createDefaultDatabaseCondValue(pCxt); }
break;
- case 232: /* db_name_cond_opt ::= db_name NK_DOT */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy617); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 234: /* db_name_cond_opt ::= db_name NK_DOT */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy239); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 233: /* like_pattern_opt ::= */
- case 408: /* from_clause_opt ::= */ yytestcase(yyruleno==408);
- case 437: /* where_clause_opt ::= */ yytestcase(yyruleno==437);
- case 441: /* twindow_clause_opt ::= */ yytestcase(yyruleno==441);
- case 446: /* sliding_opt ::= */ yytestcase(yyruleno==446);
- case 448: /* fill_opt ::= */ yytestcase(yyruleno==448);
- case 460: /* having_clause_opt ::= */ yytestcase(yyruleno==460);
- case 462: /* range_opt ::= */ yytestcase(yyruleno==462);
- case 464: /* every_opt ::= */ yytestcase(yyruleno==464);
- case 474: /* slimit_clause_opt ::= */ yytestcase(yyruleno==474);
- case 478: /* limit_clause_opt ::= */ yytestcase(yyruleno==478);
-{ yymsp[1].minor.yy840 = NULL; }
+ case 235: /* like_pattern_opt ::= */
+ case 410: /* from_clause_opt ::= */ yytestcase(yyruleno==410);
+ case 439: /* where_clause_opt ::= */ yytestcase(yyruleno==439);
+ case 443: /* twindow_clause_opt ::= */ yytestcase(yyruleno==443);
+ case 448: /* sliding_opt ::= */ yytestcase(yyruleno==448);
+ case 450: /* fill_opt ::= */ yytestcase(yyruleno==450);
+ case 462: /* having_clause_opt ::= */ yytestcase(yyruleno==462);
+ case 464: /* range_opt ::= */ yytestcase(yyruleno==464);
+ case 466: /* every_opt ::= */ yytestcase(yyruleno==466);
+ case 476: /* slimit_clause_opt ::= */ yytestcase(yyruleno==476);
+ case 480: /* limit_clause_opt ::= */ yytestcase(yyruleno==480);
+{ yymsp[1].minor.yy80 = NULL; }
break;
- case 234: /* like_pattern_opt ::= LIKE NK_STRING */
-{ yymsp[-1].minor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
+ case 236: /* like_pattern_opt ::= LIKE NK_STRING */
+{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
break;
- case 235: /* table_name_cond ::= table_name */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy617); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 237: /* table_name_cond ::= table_name */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy239); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 237: /* from_db_opt ::= FROM db_name */
-{ yymsp[-1].minor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy617); }
+ case 239: /* from_db_opt ::= FROM db_name */
+{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy239); }
break;
- case 238: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */
-{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy313, yymsp[-3].minor.yy840, yymsp[-1].minor.yy840, NULL, yymsp[0].minor.yy840); }
+ case 240: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */
+{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy845, yymsp[-3].minor.yy80, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); }
break;
- case 239: /* cmd ::= DROP INDEX exists_opt full_table_name */
-{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy313, yymsp[0].minor.yy840); }
+ case 241: /* cmd ::= DROP INDEX exists_opt full_table_name */
+{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy845, yymsp[0].minor.yy80); }
break;
- case 240: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
-{ yymsp[-9].minor.yy840 = createIndexOption(pCxt, yymsp[-7].minor.yy544, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), NULL, yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 242: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */
+{ yymsp[-9].minor.yy80 = createIndexOption(pCxt, yymsp[-7].minor.yy574, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 241: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */
-{ yymsp[-11].minor.yy840 = createIndexOption(pCxt, yymsp[-9].minor.yy544, releaseRawExprNode(pCxt, yymsp[-5].minor.yy840), releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 243: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */
+{ yymsp[-11].minor.yy80 = createIndexOption(pCxt, yymsp[-9].minor.yy574, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 244: /* func ::= function_name NK_LP expression_list NK_RP */
-{ yylhsminor.yy840 = createFunctionNode(pCxt, &yymsp[-3].minor.yy617, yymsp[-1].minor.yy544); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 246: /* func ::= function_name NK_LP expression_list NK_RP */
+{ yylhsminor.yy80 = createFunctionNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-1].minor.yy574); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 245: /* sma_stream_opt ::= */
- case 272: /* stream_options ::= */ yytestcase(yyruleno==272);
-{ yymsp[1].minor.yy840 = createStreamOptions(pCxt); }
+ case 247: /* sma_stream_opt ::= */
+ case 274: /* stream_options ::= */ yytestcase(yyruleno==274);
+{ yymsp[1].minor.yy80 = createStreamOptions(pCxt); }
break;
- case 246: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */
- case 276: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==276);
-{ ((SStreamOptions*)yymsp[-2].minor.yy840)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy840); yylhsminor.yy840 = yymsp[-2].minor.yy840; }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 248: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */
+ case 278: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==278);
+{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 247: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */
-{ ((SStreamOptions*)yymsp[-2].minor.yy840)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy840); yylhsminor.yy840 = yymsp[-2].minor.yy840; }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 249: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */
+{ ((SStreamOptions*)yymsp[-2].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-2].minor.yy80; }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 248: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
-{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy313, &yymsp[-2].minor.yy617, yymsp[0].minor.yy840); }
+ case 250: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */
+{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy239, yymsp[0].minor.yy80); }
break;
- case 249: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy313, &yymsp[-3].minor.yy617, &yymsp[0].minor.yy617, false); }
+ case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy239, &yymsp[0].minor.yy239, false); }
break;
- case 250: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy313, &yymsp[-5].minor.yy617, &yymsp[0].minor.yy617, true); }
+ case 252: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, &yymsp[0].minor.yy239, true); }
break;
- case 251: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy313, &yymsp[-3].minor.yy617, yymsp[0].minor.yy840, false); }
+ case 253: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy845, &yymsp[-3].minor.yy239, yymsp[0].minor.yy80, false); }
break;
- case 252: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
-{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy313, &yymsp[-5].minor.yy617, yymsp[0].minor.yy840, true); }
+ case 254: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */
+{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, yymsp[0].minor.yy80, true); }
break;
- case 253: /* cmd ::= DROP TOPIC exists_opt topic_name */
-{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy313, &yymsp[0].minor.yy617); }
+ case 255: /* cmd ::= DROP TOPIC exists_opt topic_name */
+{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); }
break;
- case 254: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
-{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy313, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617); }
+ case 256: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */
+{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy845, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239); }
break;
- case 255: /* cmd ::= DESC full_table_name */
- case 256: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==256);
-{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy840); }
+ case 257: /* cmd ::= DESC full_table_name */
+ case 258: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==258);
+{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy80); }
break;
- case 257: /* cmd ::= RESET QUERY CACHE */
+ case 259: /* cmd ::= RESET QUERY CACHE */
{ pCxt->pRootNode = createResetQueryCacheStmt(pCxt); }
break;
- case 258: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */
-{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy313, yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 260: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */
+{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy845, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 260: /* analyze_opt ::= ANALYZE */
- case 267: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==267);
- case 428: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==428);
-{ yymsp[0].minor.yy313 = true; }
+ case 262: /* analyze_opt ::= ANALYZE */
+ case 269: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==269);
+ case 430: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==430);
+{ yymsp[0].minor.yy845 = true; }
break;
- case 261: /* explain_options ::= */
-{ yymsp[1].minor.yy840 = createDefaultExplainOptions(pCxt); }
+ case 263: /* explain_options ::= */
+{ yymsp[1].minor.yy80 = createDefaultExplainOptions(pCxt); }
break;
- case 262: /* explain_options ::= explain_options VERBOSE NK_BOOL */
-{ yylhsminor.yy840 = setExplainVerbose(pCxt, yymsp[-2].minor.yy840, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 264: /* explain_options ::= explain_options VERBOSE NK_BOOL */
+{ yylhsminor.yy80 = setExplainVerbose(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 263: /* explain_options ::= explain_options RATIO NK_FLOAT */
-{ yylhsminor.yy840 = setExplainRatio(pCxt, yymsp[-2].minor.yy840, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 265: /* explain_options ::= explain_options RATIO NK_FLOAT */
+{ yylhsminor.yy80 = setExplainRatio(pCxt, yymsp[-2].minor.yy80, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 264: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
-{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy313, yymsp[-8].minor.yy313, &yymsp[-5].minor.yy617, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy784, yymsp[0].minor.yy844); }
+ case 266: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */
+{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-6].minor.yy845, yymsp[-8].minor.yy845, &yymsp[-5].minor.yy239, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy136, yymsp[0].minor.yy46); }
break;
- case 265: /* cmd ::= DROP FUNCTION exists_opt function_name */
-{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy313, &yymsp[0].minor.yy617); }
+ case 267: /* cmd ::= DROP FUNCTION exists_opt function_name */
+{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); }
break;
- case 268: /* bufsize_opt ::= */
-{ yymsp[1].minor.yy844 = 0; }
+ case 270: /* bufsize_opt ::= */
+{ yymsp[1].minor.yy46 = 0; }
break;
- case 269: /* bufsize_opt ::= BUFSIZE NK_INTEGER */
-{ yymsp[-1].minor.yy844 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); }
+ case 271: /* bufsize_opt ::= BUFSIZE NK_INTEGER */
+{ yymsp[-1].minor.yy46 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); }
break;
- case 270: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */
-{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy313, &yymsp[-5].minor.yy617, yymsp[-2].minor.yy840, yymsp[-4].minor.yy840, yymsp[0].minor.yy840); }
+ case 272: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name AS query_expression */
+{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-6].minor.yy845, &yymsp[-5].minor.yy239, yymsp[-2].minor.yy80, yymsp[-4].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 271: /* cmd ::= DROP STREAM exists_opt stream_name */
-{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy313, &yymsp[0].minor.yy617); }
+ case 273: /* cmd ::= DROP STREAM exists_opt stream_name */
+{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy845, &yymsp[0].minor.yy239); }
break;
- case 273: /* stream_options ::= stream_options TRIGGER AT_ONCE */
-{ ((SStreamOptions*)yymsp[-2].minor.yy840)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy840 = yymsp[-2].minor.yy840; }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 275: /* stream_options ::= stream_options TRIGGER AT_ONCE */
+{ ((SStreamOptions*)yymsp[-2].minor.yy80)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy80 = yymsp[-2].minor.yy80; }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 274: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
-{ ((SStreamOptions*)yymsp[-2].minor.yy840)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy840 = yymsp[-2].minor.yy840; }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 276: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */
+{ ((SStreamOptions*)yymsp[-2].minor.yy80)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy80 = yymsp[-2].minor.yy80; }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 275: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
-{ ((SStreamOptions*)yymsp[-3].minor.yy840)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy840)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy840); yylhsminor.yy840 = yymsp[-3].minor.yy840; }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 277: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */
+{ ((SStreamOptions*)yymsp[-3].minor.yy80)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy80)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); yylhsminor.yy80 = yymsp[-3].minor.yy80; }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 277: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
-{ ((SStreamOptions*)yymsp[-3].minor.yy840)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy840 = yymsp[-3].minor.yy840; }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 279: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */
+{ ((SStreamOptions*)yymsp[-3].minor.yy80)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy80 = yymsp[-3].minor.yy80; }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 278: /* cmd ::= KILL CONNECTION NK_INTEGER */
+ case 280: /* cmd ::= KILL CONNECTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); }
break;
- case 279: /* cmd ::= KILL QUERY NK_STRING */
+ case 281: /* cmd ::= KILL QUERY NK_STRING */
{ pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); }
break;
- case 280: /* cmd ::= KILL TRANSACTION NK_INTEGER */
+ case 282: /* cmd ::= KILL TRANSACTION NK_INTEGER */
{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); }
break;
- case 281: /* cmd ::= BALANCE VGROUP */
+ case 283: /* cmd ::= BALANCE VGROUP */
{ pCxt->pRootNode = createBalanceVgroupStmt(pCxt); }
break;
- case 282: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
+ case 284: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */
{ pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); }
break;
- case 283: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
-{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy544); }
+ case 285: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */
+{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy574); }
break;
- case 284: /* cmd ::= SPLIT VGROUP NK_INTEGER */
+ case 286: /* cmd ::= SPLIT VGROUP NK_INTEGER */
{ pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); }
break;
- case 285: /* dnode_list ::= DNODE NK_INTEGER */
-{ yymsp[-1].minor.yy544 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
+ case 287: /* dnode_list ::= DNODE NK_INTEGER */
+{ yymsp[-1].minor.yy574 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); }
break;
- case 287: /* cmd ::= DELETE FROM full_table_name where_clause_opt */
-{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 289: /* cmd ::= DELETE FROM full_table_name where_clause_opt */
+{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 289: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */
-{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy840, yymsp[-2].minor.yy544, yymsp[0].minor.yy840); }
+ case 291: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_expression */
+{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy80, yymsp[-2].minor.yy574, yymsp[0].minor.yy80); }
break;
- case 290: /* cmd ::= INSERT INTO full_table_name query_expression */
-{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy840, NULL, yymsp[0].minor.yy840); }
+ case 292: /* cmd ::= INSERT INTO full_table_name query_expression */
+{ pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy80, NULL, yymsp[0].minor.yy80); }
break;
- case 291: /* literal ::= NK_INTEGER */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 293: /* literal ::= NK_INTEGER */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 292: /* literal ::= NK_FLOAT */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 294: /* literal ::= NK_FLOAT */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 293: /* literal ::= NK_STRING */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 295: /* literal ::= NK_STRING */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 294: /* literal ::= NK_BOOL */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 296: /* literal ::= NK_BOOL */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 295: /* literal ::= TIMESTAMP NK_STRING */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 297: /* literal ::= TIMESTAMP NK_STRING */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 296: /* literal ::= duration_literal */
- case 306: /* signed_literal ::= signed */ yytestcase(yyruleno==306);
- case 326: /* expression ::= literal */ yytestcase(yyruleno==326);
- case 327: /* expression ::= pseudo_column */ yytestcase(yyruleno==327);
- case 328: /* expression ::= column_reference */ yytestcase(yyruleno==328);
- case 329: /* expression ::= function_expression */ yytestcase(yyruleno==329);
- case 330: /* expression ::= subquery */ yytestcase(yyruleno==330);
- case 358: /* function_expression ::= literal_func */ yytestcase(yyruleno==358);
- case 400: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==400);
- case 404: /* boolean_primary ::= predicate */ yytestcase(yyruleno==404);
- case 406: /* common_expression ::= expression */ yytestcase(yyruleno==406);
- case 407: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==407);
- case 410: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==410);
- case 412: /* table_reference ::= table_primary */ yytestcase(yyruleno==412);
- case 413: /* table_reference ::= joined_table */ yytestcase(yyruleno==413);
- case 417: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==417);
- case 467: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==467);
- case 470: /* query_primary ::= query_specification */ yytestcase(yyruleno==470);
-{ yylhsminor.yy840 = yymsp[0].minor.yy840; }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 298: /* literal ::= duration_literal */
+ case 308: /* signed_literal ::= signed */ yytestcase(yyruleno==308);
+ case 328: /* expression ::= literal */ yytestcase(yyruleno==328);
+ case 329: /* expression ::= pseudo_column */ yytestcase(yyruleno==329);
+ case 330: /* expression ::= column_reference */ yytestcase(yyruleno==330);
+ case 331: /* expression ::= function_expression */ yytestcase(yyruleno==331);
+ case 332: /* expression ::= subquery */ yytestcase(yyruleno==332);
+ case 360: /* function_expression ::= literal_func */ yytestcase(yyruleno==360);
+ case 402: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==402);
+ case 406: /* boolean_primary ::= predicate */ yytestcase(yyruleno==406);
+ case 408: /* common_expression ::= expression */ yytestcase(yyruleno==408);
+ case 409: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==409);
+ case 412: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==412);
+ case 414: /* table_reference ::= table_primary */ yytestcase(yyruleno==414);
+ case 415: /* table_reference ::= joined_table */ yytestcase(yyruleno==415);
+ case 419: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==419);
+ case 469: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==469);
+ case 472: /* query_primary ::= query_specification */ yytestcase(yyruleno==472);
+{ yylhsminor.yy80 = yymsp[0].minor.yy80; }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 297: /* literal ::= NULL */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 299: /* literal ::= NULL */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 298: /* literal ::= NK_QUESTION */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 300: /* literal ::= NK_QUESTION */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 299: /* duration_literal ::= NK_VARIABLE */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 301: /* duration_literal ::= NK_VARIABLE */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 300: /* signed ::= NK_INTEGER */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 302: /* signed ::= NK_INTEGER */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 301: /* signed ::= NK_PLUS NK_INTEGER */
-{ yymsp[-1].minor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
+ case 303: /* signed ::= NK_PLUS NK_INTEGER */
+{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); }
break;
- case 302: /* signed ::= NK_MINUS NK_INTEGER */
+ case 304: /* signed ::= NK_MINUS NK_INTEGER */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t);
+ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t);
}
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 303: /* signed ::= NK_FLOAT */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 305: /* signed ::= NK_FLOAT */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 304: /* signed ::= NK_PLUS NK_FLOAT */
-{ yymsp[-1].minor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
+ case 306: /* signed ::= NK_PLUS NK_FLOAT */
+{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); }
break;
- case 305: /* signed ::= NK_MINUS NK_FLOAT */
+ case 307: /* signed ::= NK_MINUS NK_FLOAT */
{
SToken t = yymsp[-1].minor.yy0;
t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z;
- yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t);
+ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t);
}
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 307: /* signed_literal ::= NK_STRING */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 309: /* signed_literal ::= NK_STRING */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 308: /* signed_literal ::= NK_BOOL */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 310: /* signed_literal ::= NK_BOOL */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 309: /* signed_literal ::= TIMESTAMP NK_STRING */
-{ yymsp[-1].minor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
+ case 311: /* signed_literal ::= TIMESTAMP NK_STRING */
+{ yymsp[-1].minor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); }
break;
- case 310: /* signed_literal ::= duration_literal */
- case 312: /* signed_literal ::= literal_func */ yytestcase(yyruleno==312);
- case 378: /* star_func_para ::= expression */ yytestcase(yyruleno==378);
- case 433: /* select_item ::= common_expression */ yytestcase(yyruleno==433);
- case 483: /* search_condition ::= common_expression */ yytestcase(yyruleno==483);
-{ yylhsminor.yy840 = releaseRawExprNode(pCxt, yymsp[0].minor.yy840); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 312: /* signed_literal ::= duration_literal */
+ case 314: /* signed_literal ::= literal_func */ yytestcase(yyruleno==314);
+ case 380: /* star_func_para ::= expression */ yytestcase(yyruleno==380);
+ case 435: /* select_item ::= common_expression */ yytestcase(yyruleno==435);
+ case 485: /* search_condition ::= common_expression */ yytestcase(yyruleno==485);
+{ yylhsminor.yy80 = releaseRawExprNode(pCxt, yymsp[0].minor.yy80); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 311: /* signed_literal ::= NULL */
-{ yylhsminor.yy840 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 313: /* signed_literal ::= NULL */
+{ yylhsminor.yy80 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 313: /* signed_literal ::= NK_QUESTION */
-{ yylhsminor.yy840 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 315: /* signed_literal ::= NK_QUESTION */
+{ yylhsminor.yy80 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 331: /* expression ::= NK_LP expression NK_RP */
- case 405: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==405);
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy840)); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 333: /* expression ::= NK_LP expression NK_RP */
+ case 407: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==407);
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 332: /* expression ::= NK_PLUS expression */
+ case 334: /* expression ::= NK_PLUS expression */
{
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy840));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy80));
}
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 333: /* expression ::= NK_MINUS expression */
+ case 335: /* expression ::= NK_MINUS expression */
{
- SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy840), NULL));
+ SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL));
}
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 334: /* expression ::= expression NK_PLUS expression */
+ case 336: /* expression ::= expression NK_PLUS expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 335: /* expression ::= expression NK_MINUS expression */
+ case 337: /* expression ::= expression NK_MINUS expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 336: /* expression ::= expression NK_STAR expression */
+ case 338: /* expression ::= expression NK_STAR expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 337: /* expression ::= expression NK_SLASH expression */
+ case 339: /* expression ::= expression NK_SLASH expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 338: /* expression ::= expression NK_REM expression */
+ case 340: /* expression ::= expression NK_REM expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 339: /* expression ::= column_reference NK_ARROW NK_STRING */
+ case 341: /* expression ::= column_reference NK_ARROW NK_STRING */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 340: /* expression ::= expression NK_BITAND expression */
+ case 342: /* expression ::= expression NK_BITAND expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 341: /* expression ::= expression NK_BITOR expression */
+ case 343: /* expression ::= expression NK_BITOR expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 344: /* column_reference ::= column_name */
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy617, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy617)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 346: /* column_reference ::= column_name */
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy239, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy239)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 345: /* column_reference ::= table_name NK_DOT column_name */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617, createColumnNode(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy617)); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 347: /* column_reference ::= table_name NK_DOT column_name */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239, createColumnNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy239)); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 346: /* pseudo_column ::= ROWTS */
- case 347: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==347);
- case 349: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==349);
- case 350: /* pseudo_column ::= QEND */ yytestcase(yyruleno==350);
- case 351: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==351);
- case 352: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==352);
- case 353: /* pseudo_column ::= WEND */ yytestcase(yyruleno==353);
- case 354: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==354);
- case 360: /* literal_func ::= NOW */ yytestcase(yyruleno==360);
-{ yylhsminor.yy840 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 348: /* pseudo_column ::= ROWTS */
+ case 349: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==349);
+ case 351: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==351);
+ case 352: /* pseudo_column ::= QEND */ yytestcase(yyruleno==352);
+ case 353: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==353);
+ case 354: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==354);
+ case 355: /* pseudo_column ::= WEND */ yytestcase(yyruleno==355);
+ case 356: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==356);
+ case 362: /* literal_func ::= NOW */ yytestcase(yyruleno==362);
+{ yylhsminor.yy80 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 348: /* pseudo_column ::= table_name NK_DOT TBNAME */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy617)))); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 350: /* pseudo_column ::= table_name NK_DOT TBNAME */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy239)))); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 355: /* function_expression ::= function_name NK_LP expression_list NK_RP */
- case 356: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==356);
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy617, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy617, yymsp[-1].minor.yy544)); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 357: /* function_expression ::= function_name NK_LP expression_list NK_RP */
+ case 358: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==358);
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy239, yymsp[-1].minor.yy574)); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 357: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), yymsp[-1].minor.yy784)); }
- yymsp[-5].minor.yy840 = yylhsminor.yy840;
+ case 359: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy136)); }
+ yymsp[-5].minor.yy80 = yylhsminor.yy80;
break;
- case 359: /* literal_func ::= noarg_func NK_LP NK_RP */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy617, NULL)); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 361: /* literal_func ::= noarg_func NK_LP NK_RP */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy239, NULL)); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 374: /* star_func_para_list ::= NK_STAR */
-{ yylhsminor.yy544 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
+ case 376: /* star_func_para_list ::= NK_STAR */
+{ yylhsminor.yy574 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
break;
- case 379: /* star_func_para ::= table_name NK_DOT NK_STAR */
- case 436: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==436);
-{ yylhsminor.yy840 = createColumnNode(pCxt, &yymsp[-2].minor.yy617, &yymsp[0].minor.yy0); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 381: /* star_func_para ::= table_name NK_DOT NK_STAR */
+ case 438: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==438);
+{ yylhsminor.yy80 = createColumnNode(pCxt, &yymsp[-2].minor.yy239, &yymsp[0].minor.yy0); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 380: /* predicate ::= expression compare_op expression */
- case 385: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==385);
+ case 382: /* predicate ::= expression compare_op expression */
+ case 387: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==387);
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy198, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy194, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 381: /* predicate ::= expression BETWEEN expression AND expression */
+ case 383: /* predicate ::= expression BETWEEN expression AND expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy840), releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-4].minor.yy840 = yylhsminor.yy840;
+ yymsp[-4].minor.yy80 = yylhsminor.yy80;
break;
- case 382: /* predicate ::= expression NOT BETWEEN expression AND expression */
+ case 384: /* predicate ::= expression NOT BETWEEN expression AND expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy840), releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-5].minor.yy840 = yylhsminor.yy840;
+ yymsp[-5].minor.yy80 = yylhsminor.yy80;
break;
- case 383: /* predicate ::= expression IS NULL */
+ case 385: /* predicate ::= expression IS NULL */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), NULL));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 384: /* predicate ::= expression IS NOT NULL */
+ case 386: /* predicate ::= expression IS NOT NULL */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), NULL));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL));
}
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 386: /* compare_op ::= NK_LT */
-{ yymsp[0].minor.yy198 = OP_TYPE_LOWER_THAN; }
+ case 388: /* compare_op ::= NK_LT */
+{ yymsp[0].minor.yy194 = OP_TYPE_LOWER_THAN; }
break;
- case 387: /* compare_op ::= NK_GT */
-{ yymsp[0].minor.yy198 = OP_TYPE_GREATER_THAN; }
+ case 389: /* compare_op ::= NK_GT */
+{ yymsp[0].minor.yy194 = OP_TYPE_GREATER_THAN; }
break;
- case 388: /* compare_op ::= NK_LE */
-{ yymsp[0].minor.yy198 = OP_TYPE_LOWER_EQUAL; }
+ case 390: /* compare_op ::= NK_LE */
+{ yymsp[0].minor.yy194 = OP_TYPE_LOWER_EQUAL; }
break;
- case 389: /* compare_op ::= NK_GE */
-{ yymsp[0].minor.yy198 = OP_TYPE_GREATER_EQUAL; }
+ case 391: /* compare_op ::= NK_GE */
+{ yymsp[0].minor.yy194 = OP_TYPE_GREATER_EQUAL; }
break;
- case 390: /* compare_op ::= NK_NE */
-{ yymsp[0].minor.yy198 = OP_TYPE_NOT_EQUAL; }
+ case 392: /* compare_op ::= NK_NE */
+{ yymsp[0].minor.yy194 = OP_TYPE_NOT_EQUAL; }
break;
- case 391: /* compare_op ::= NK_EQ */
-{ yymsp[0].minor.yy198 = OP_TYPE_EQUAL; }
+ case 393: /* compare_op ::= NK_EQ */
+{ yymsp[0].minor.yy194 = OP_TYPE_EQUAL; }
break;
- case 392: /* compare_op ::= LIKE */
-{ yymsp[0].minor.yy198 = OP_TYPE_LIKE; }
+ case 394: /* compare_op ::= LIKE */
+{ yymsp[0].minor.yy194 = OP_TYPE_LIKE; }
break;
- case 393: /* compare_op ::= NOT LIKE */
-{ yymsp[-1].minor.yy198 = OP_TYPE_NOT_LIKE; }
+ case 395: /* compare_op ::= NOT LIKE */
+{ yymsp[-1].minor.yy194 = OP_TYPE_NOT_LIKE; }
break;
- case 394: /* compare_op ::= MATCH */
-{ yymsp[0].minor.yy198 = OP_TYPE_MATCH; }
+ case 396: /* compare_op ::= MATCH */
+{ yymsp[0].minor.yy194 = OP_TYPE_MATCH; }
break;
- case 395: /* compare_op ::= NMATCH */
-{ yymsp[0].minor.yy198 = OP_TYPE_NMATCH; }
+ case 397: /* compare_op ::= NMATCH */
+{ yymsp[0].minor.yy194 = OP_TYPE_NMATCH; }
break;
- case 396: /* compare_op ::= CONTAINS */
-{ yymsp[0].minor.yy198 = OP_TYPE_JSON_CONTAINS; }
+ case 398: /* compare_op ::= CONTAINS */
+{ yymsp[0].minor.yy194 = OP_TYPE_JSON_CONTAINS; }
break;
- case 397: /* in_op ::= IN */
-{ yymsp[0].minor.yy198 = OP_TYPE_IN; }
+ case 399: /* in_op ::= IN */
+{ yymsp[0].minor.yy194 = OP_TYPE_IN; }
break;
- case 398: /* in_op ::= NOT IN */
-{ yymsp[-1].minor.yy198 = OP_TYPE_NOT_IN; }
+ case 400: /* in_op ::= NOT IN */
+{ yymsp[-1].minor.yy194 = OP_TYPE_NOT_IN; }
break;
- case 399: /* in_predicate_value ::= NK_LP literal_list NK_RP */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy544)); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 401: /* in_predicate_value ::= NK_LP literal_list NK_RP */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy574)); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 401: /* boolean_value_expression ::= NOT boolean_primary */
+ case 403: /* boolean_value_expression ::= NOT boolean_primary */
{
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy840), NULL));
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy80), NULL));
}
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 402: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
+ case 404: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 403: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
+ case 405: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */
{
- SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy840);
- SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy840);
- yylhsminor.yy840 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), releaseRawExprNode(pCxt, yymsp[0].minor.yy840)));
+ SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy80);
+ SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy80);
+ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), releaseRawExprNode(pCxt, yymsp[0].minor.yy80)));
}
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 409: /* from_clause_opt ::= FROM table_reference_list */
- case 438: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==438);
- case 461: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==461);
-{ yymsp[-1].minor.yy840 = yymsp[0].minor.yy840; }
+ case 411: /* from_clause_opt ::= FROM table_reference_list */
+ case 440: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==440);
+ case 463: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==463);
+{ yymsp[-1].minor.yy80 = yymsp[0].minor.yy80; }
break;
- case 411: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
-{ yylhsminor.yy840 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy840, yymsp[0].minor.yy840, NULL); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 413: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */
+{ yylhsminor.yy80 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy80, yymsp[0].minor.yy80, NULL); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 414: /* table_primary ::= table_name alias_opt */
-{ yylhsminor.yy840 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy617, &yymsp[0].minor.yy617); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 416: /* table_primary ::= table_name alias_opt */
+{ yylhsminor.yy80 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 415: /* table_primary ::= db_name NK_DOT table_name alias_opt */
-{ yylhsminor.yy840 = createRealTableNode(pCxt, &yymsp[-3].minor.yy617, &yymsp[-1].minor.yy617, &yymsp[0].minor.yy617); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 417: /* table_primary ::= db_name NK_DOT table_name alias_opt */
+{ yylhsminor.yy80 = createRealTableNode(pCxt, &yymsp[-3].minor.yy239, &yymsp[-1].minor.yy239, &yymsp[0].minor.yy239); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 416: /* table_primary ::= subquery alias_opt */
-{ yylhsminor.yy840 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy840), &yymsp[0].minor.yy617); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 418: /* table_primary ::= subquery alias_opt */
+{ yylhsminor.yy80 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy239); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 418: /* alias_opt ::= */
-{ yymsp[1].minor.yy617 = nil_token; }
+ case 420: /* alias_opt ::= */
+{ yymsp[1].minor.yy239 = nil_token; }
break;
- case 419: /* alias_opt ::= table_alias */
-{ yylhsminor.yy617 = yymsp[0].minor.yy617; }
- yymsp[0].minor.yy617 = yylhsminor.yy617;
+ case 421: /* alias_opt ::= table_alias */
+{ yylhsminor.yy239 = yymsp[0].minor.yy239; }
+ yymsp[0].minor.yy239 = yylhsminor.yy239;
break;
- case 420: /* alias_opt ::= AS table_alias */
-{ yymsp[-1].minor.yy617 = yymsp[0].minor.yy617; }
+ case 422: /* alias_opt ::= AS table_alias */
+{ yymsp[-1].minor.yy239 = yymsp[0].minor.yy239; }
break;
- case 421: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
- case 422: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==422);
-{ yymsp[-2].minor.yy840 = yymsp[-1].minor.yy840; }
+ case 423: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */
+ case 424: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==424);
+{ yymsp[-2].minor.yy80 = yymsp[-1].minor.yy80; }
break;
- case 423: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
-{ yylhsminor.yy840 = createJoinTableNode(pCxt, yymsp[-4].minor.yy708, yymsp[-5].minor.yy840, yymsp[-2].minor.yy840, yymsp[0].minor.yy840); }
- yymsp[-5].minor.yy840 = yylhsminor.yy840;
+ case 425: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */
+{ yylhsminor.yy80 = createJoinTableNode(pCxt, yymsp[-4].minor.yy750, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); }
+ yymsp[-5].minor.yy80 = yylhsminor.yy80;
break;
- case 424: /* join_type ::= */
-{ yymsp[1].minor.yy708 = JOIN_TYPE_INNER; }
+ case 426: /* join_type ::= */
+{ yymsp[1].minor.yy750 = JOIN_TYPE_INNER; }
break;
- case 425: /* join_type ::= INNER */
-{ yymsp[0].minor.yy708 = JOIN_TYPE_INNER; }
+ case 427: /* join_type ::= INNER */
+{ yymsp[0].minor.yy750 = JOIN_TYPE_INNER; }
break;
- case 426: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
+ case 428: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */
{
- yymsp[-11].minor.yy840 = createSelectStmt(pCxt, yymsp[-10].minor.yy313, yymsp[-9].minor.yy544, yymsp[-8].minor.yy840);
- yymsp[-11].minor.yy840 = addWhereClause(pCxt, yymsp[-11].minor.yy840, yymsp[-7].minor.yy840);
- yymsp[-11].minor.yy840 = addPartitionByClause(pCxt, yymsp[-11].minor.yy840, yymsp[-6].minor.yy544);
- yymsp[-11].minor.yy840 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy840, yymsp[-2].minor.yy840);
- yymsp[-11].minor.yy840 = addGroupByClause(pCxt, yymsp[-11].minor.yy840, yymsp[-1].minor.yy544);
- yymsp[-11].minor.yy840 = addHavingClause(pCxt, yymsp[-11].minor.yy840, yymsp[0].minor.yy840);
- yymsp[-11].minor.yy840 = addRangeClause(pCxt, yymsp[-11].minor.yy840, yymsp[-5].minor.yy840);
- yymsp[-11].minor.yy840 = addEveryClause(pCxt, yymsp[-11].minor.yy840, yymsp[-4].minor.yy840);
- yymsp[-11].minor.yy840 = addFillClause(pCxt, yymsp[-11].minor.yy840, yymsp[-3].minor.yy840);
+ yymsp[-11].minor.yy80 = createSelectStmt(pCxt, yymsp[-10].minor.yy845, yymsp[-9].minor.yy574, yymsp[-8].minor.yy80);
+ yymsp[-11].minor.yy80 = addWhereClause(pCxt, yymsp[-11].minor.yy80, yymsp[-7].minor.yy80);
+ yymsp[-11].minor.yy80 = addPartitionByClause(pCxt, yymsp[-11].minor.yy80, yymsp[-6].minor.yy574);
+ yymsp[-11].minor.yy80 = addWindowClauseClause(pCxt, yymsp[-11].minor.yy80, yymsp[-2].minor.yy80);
+ yymsp[-11].minor.yy80 = addGroupByClause(pCxt, yymsp[-11].minor.yy80, yymsp[-1].minor.yy574);
+ yymsp[-11].minor.yy80 = addHavingClause(pCxt, yymsp[-11].minor.yy80, yymsp[0].minor.yy80);
+ yymsp[-11].minor.yy80 = addRangeClause(pCxt, yymsp[-11].minor.yy80, yymsp[-5].minor.yy80);
+ yymsp[-11].minor.yy80 = addEveryClause(pCxt, yymsp[-11].minor.yy80, yymsp[-4].minor.yy80);
+ yymsp[-11].minor.yy80 = addFillClause(pCxt, yymsp[-11].minor.yy80, yymsp[-3].minor.yy80);
}
break;
- case 429: /* set_quantifier_opt ::= ALL */
-{ yymsp[0].minor.yy313 = false; }
+ case 431: /* set_quantifier_opt ::= ALL */
+{ yymsp[0].minor.yy845 = false; }
break;
- case 432: /* select_item ::= NK_STAR */
-{ yylhsminor.yy840 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); }
- yymsp[0].minor.yy840 = yylhsminor.yy840;
+ case 434: /* select_item ::= NK_STAR */
+{ yylhsminor.yy80 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); }
+ yymsp[0].minor.yy80 = yylhsminor.yy80;
break;
- case 434: /* select_item ::= common_expression column_alias */
-{ yylhsminor.yy840 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy840), &yymsp[0].minor.yy617); }
- yymsp[-1].minor.yy840 = yylhsminor.yy840;
+ case 436: /* select_item ::= common_expression column_alias */
+{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80), &yymsp[0].minor.yy239); }
+ yymsp[-1].minor.yy80 = yylhsminor.yy80;
break;
- case 435: /* select_item ::= common_expression AS column_alias */
-{ yylhsminor.yy840 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), &yymsp[0].minor.yy617); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 437: /* select_item ::= common_expression AS column_alias */
+{ yylhsminor.yy80 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), &yymsp[0].minor.yy239); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 440: /* partition_by_clause_opt ::= PARTITION BY expression_list */
- case 457: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==457);
- case 473: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==473);
-{ yymsp[-2].minor.yy544 = yymsp[0].minor.yy544; }
+ case 442: /* partition_by_clause_opt ::= PARTITION BY expression_list */
+ case 459: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==459);
+ case 475: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==475);
+{ yymsp[-2].minor.yy574 = yymsp[0].minor.yy574; }
break;
- case 442: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
-{ yymsp[-5].minor.yy840 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), releaseRawExprNode(pCxt, yymsp[-1].minor.yy840)); }
+ case 444: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */
+{ yymsp[-5].minor.yy80 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); }
break;
- case 443: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
-{ yymsp[-3].minor.yy840 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy840)); }
+ case 445: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */
+{ yymsp[-3].minor.yy80 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); }
break;
- case 444: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
-{ yymsp[-5].minor.yy840 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), NULL, yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 446: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */
+{ yymsp[-5].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), NULL, yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 445: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
-{ yymsp[-7].minor.yy840 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy840), releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), yymsp[-1].minor.yy840, yymsp[0].minor.yy840); }
+ case 447: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */
+{ yymsp[-7].minor.yy80 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy80), releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), yymsp[-1].minor.yy80, yymsp[0].minor.yy80); }
break;
- case 447: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
- case 465: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==465);
-{ yymsp[-3].minor.yy840 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy840); }
+ case 449: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */
+ case 467: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==467);
+{ yymsp[-3].minor.yy80 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy80); }
break;
- case 449: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
-{ yymsp[-3].minor.yy840 = createFillNode(pCxt, yymsp[-1].minor.yy816, NULL); }
+ case 451: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */
+{ yymsp[-3].minor.yy80 = createFillNode(pCxt, yymsp[-1].minor.yy426, NULL); }
break;
- case 450: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
-{ yymsp[-5].minor.yy840 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy544)); }
+ case 452: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */
+{ yymsp[-5].minor.yy80 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy574)); }
break;
- case 451: /* fill_mode ::= NONE */
-{ yymsp[0].minor.yy816 = FILL_MODE_NONE; }
+ case 453: /* fill_mode ::= NONE */
+{ yymsp[0].minor.yy426 = FILL_MODE_NONE; }
break;
- case 452: /* fill_mode ::= PREV */
-{ yymsp[0].minor.yy816 = FILL_MODE_PREV; }
+ case 454: /* fill_mode ::= PREV */
+{ yymsp[0].minor.yy426 = FILL_MODE_PREV; }
break;
- case 453: /* fill_mode ::= NULL */
-{ yymsp[0].minor.yy816 = FILL_MODE_NULL; }
+ case 455: /* fill_mode ::= NULL */
+{ yymsp[0].minor.yy426 = FILL_MODE_NULL; }
break;
- case 454: /* fill_mode ::= LINEAR */
-{ yymsp[0].minor.yy816 = FILL_MODE_LINEAR; }
+ case 456: /* fill_mode ::= LINEAR */
+{ yymsp[0].minor.yy426 = FILL_MODE_LINEAR; }
break;
- case 455: /* fill_mode ::= NEXT */
-{ yymsp[0].minor.yy816 = FILL_MODE_NEXT; }
+ case 457: /* fill_mode ::= NEXT */
+{ yymsp[0].minor.yy426 = FILL_MODE_NEXT; }
break;
- case 458: /* group_by_list ::= expression */
-{ yylhsminor.yy544 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy840))); }
- yymsp[0].minor.yy544 = yylhsminor.yy544;
+ case 460: /* group_by_list ::= expression */
+{ yylhsminor.yy574 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); }
+ yymsp[0].minor.yy574 = yylhsminor.yy574;
break;
- case 459: /* group_by_list ::= group_by_list NK_COMMA expression */
-{ yylhsminor.yy544 = addNodeToList(pCxt, yymsp[-2].minor.yy544, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy840))); }
- yymsp[-2].minor.yy544 = yylhsminor.yy544;
+ case 461: /* group_by_list ::= group_by_list NK_COMMA expression */
+{ yylhsminor.yy574 = addNodeToList(pCxt, yymsp[-2].minor.yy574, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy80))); }
+ yymsp[-2].minor.yy574 = yylhsminor.yy574;
break;
- case 463: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */
-{ yymsp[-5].minor.yy840 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy840), releaseRawExprNode(pCxt, yymsp[-1].minor.yy840)); }
+ case 465: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */
+{ yymsp[-5].minor.yy80 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy80), releaseRawExprNode(pCxt, yymsp[-1].minor.yy80)); }
break;
- case 466: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
+ case 468: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */
{
- yylhsminor.yy840 = addOrderByClause(pCxt, yymsp[-3].minor.yy840, yymsp[-2].minor.yy544);
- yylhsminor.yy840 = addSlimitClause(pCxt, yylhsminor.yy840, yymsp[-1].minor.yy840);
- yylhsminor.yy840 = addLimitClause(pCxt, yylhsminor.yy840, yymsp[0].minor.yy840);
+ yylhsminor.yy80 = addOrderByClause(pCxt, yymsp[-3].minor.yy80, yymsp[-2].minor.yy574);
+ yylhsminor.yy80 = addSlimitClause(pCxt, yylhsminor.yy80, yymsp[-1].minor.yy80);
+ yylhsminor.yy80 = addLimitClause(pCxt, yylhsminor.yy80, yymsp[0].minor.yy80);
}
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 468: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
-{ yylhsminor.yy840 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy840, yymsp[0].minor.yy840); }
- yymsp[-3].minor.yy840 = yylhsminor.yy840;
+ case 470: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */
+{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy80, yymsp[0].minor.yy80); }
+ yymsp[-3].minor.yy80 = yylhsminor.yy80;
break;
- case 469: /* query_expression_body ::= query_expression_body UNION query_expression_body */
-{ yylhsminor.yy840 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy840, yymsp[0].minor.yy840); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 471: /* query_expression_body ::= query_expression_body UNION query_expression_body */
+{ yylhsminor.yy80 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy80, yymsp[0].minor.yy80); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 471: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */
+ case 473: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */
{
- yymsp[-5].minor.yy840 = addOrderByClause(pCxt, yymsp[-4].minor.yy840, yymsp[-3].minor.yy544);
- yymsp[-5].minor.yy840 = addSlimitClause(pCxt, yymsp[-5].minor.yy840, yymsp[-2].minor.yy840);
- yymsp[-5].minor.yy840 = addLimitClause(pCxt, yymsp[-5].minor.yy840, yymsp[-1].minor.yy840);
+ yymsp[-5].minor.yy80 = addOrderByClause(pCxt, yymsp[-4].minor.yy80, yymsp[-3].minor.yy574);
+ yymsp[-5].minor.yy80 = addSlimitClause(pCxt, yymsp[-5].minor.yy80, yymsp[-2].minor.yy80);
+ yymsp[-5].minor.yy80 = addLimitClause(pCxt, yymsp[-5].minor.yy80, yymsp[-1].minor.yy80);
}
break;
- case 475: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
- case 479: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==479);
-{ yymsp[-1].minor.yy840 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
+ case 477: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */
+ case 481: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==481);
+{ yymsp[-1].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); }
break;
- case 476: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
- case 480: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==480);
-{ yymsp[-3].minor.yy840 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
+ case 478: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */
+ case 482: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==482);
+{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); }
break;
- case 477: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
- case 481: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==481);
-{ yymsp[-3].minor.yy840 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
+ case 479: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */
+ case 483: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==483);
+{ yymsp[-3].minor.yy80 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); }
break;
- case 482: /* subquery ::= NK_LP query_expression NK_RP */
-{ yylhsminor.yy840 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy840); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 484: /* subquery ::= NK_LP query_expression NK_RP */
+{ yylhsminor.yy80 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy80); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 486: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
-{ yylhsminor.yy840 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy840), yymsp[-1].minor.yy204, yymsp[0].minor.yy277); }
- yymsp[-2].minor.yy840 = yylhsminor.yy840;
+ case 488: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */
+{ yylhsminor.yy80 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy80), yymsp[-1].minor.yy422, yymsp[0].minor.yy763); }
+ yymsp[-2].minor.yy80 = yylhsminor.yy80;
break;
- case 487: /* ordering_specification_opt ::= */
-{ yymsp[1].minor.yy204 = ORDER_ASC; }
+ case 489: /* ordering_specification_opt ::= */
+{ yymsp[1].minor.yy422 = ORDER_ASC; }
break;
- case 488: /* ordering_specification_opt ::= ASC */
-{ yymsp[0].minor.yy204 = ORDER_ASC; }
+ case 490: /* ordering_specification_opt ::= ASC */
+{ yymsp[0].minor.yy422 = ORDER_ASC; }
break;
- case 489: /* ordering_specification_opt ::= DESC */
-{ yymsp[0].minor.yy204 = ORDER_DESC; }
+ case 491: /* ordering_specification_opt ::= DESC */
+{ yymsp[0].minor.yy422 = ORDER_DESC; }
break;
- case 490: /* null_ordering_opt ::= */
-{ yymsp[1].minor.yy277 = NULL_ORDER_DEFAULT; }
+ case 492: /* null_ordering_opt ::= */
+{ yymsp[1].minor.yy763 = NULL_ORDER_DEFAULT; }
break;
- case 491: /* null_ordering_opt ::= NULLS FIRST */
-{ yymsp[-1].minor.yy277 = NULL_ORDER_FIRST; }
+ case 493: /* null_ordering_opt ::= NULLS FIRST */
+{ yymsp[-1].minor.yy763 = NULL_ORDER_FIRST; }
break;
- case 492: /* null_ordering_opt ::= NULLS LAST */
-{ yymsp[-1].minor.yy277 = NULL_ORDER_LAST; }
+ case 494: /* null_ordering_opt ::= NULLS LAST */
+{ yymsp[-1].minor.yy763 = NULL_ORDER_LAST; }
break;
default:
break;
diff --git a/source/libs/parser/test/mockCatalog.cpp b/source/libs/parser/test/mockCatalog.cpp
index f84305193b..7725674200 100644
--- a/source/libs/parser/test/mockCatalog.cpp
+++ b/source/libs/parser/test/mockCatalog.cpp
@@ -83,7 +83,7 @@ void generateInformationSchema(MockCatalogService* mcs) {
.done();
mcs->createTableBuilder(TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_VNODES, TSDB_SYSTEM_TABLE, 2)
.addColumn("dnode_id", TSDB_DATA_TYPE_INT)
- .addColumn("dnode_endpoint", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN)
+ .addColumn("dnode_ep", TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN)
.done();
}
diff --git a/source/libs/parser/test/parAlterToBalanceTest.cpp b/source/libs/parser/test/parAlterToBalanceTest.cpp
index 8eb64719b2..871f28b9db 100644
--- a/source/libs/parser/test/parAlterToBalanceTest.cpp
+++ b/source/libs/parser/test/parAlterToBalanceTest.cpp
@@ -88,7 +88,7 @@ TEST_F(ParserInitialATest, alterDnode) {
* | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica
* | STRICT {'off' | 'on'} -- todo: default 'off'
* | WAL_LEVEL int_value -- enum 1, 2, default 1
- * | SST_TRIGGER int_value -- rang [1, 128], default 8
+ * | SST_TRIGGER int_value -- rang [1, 16], default 8
* }
*/
TEST_F(ParserInitialATest, alterDatabase) {
@@ -161,8 +161,8 @@ TEST_F(ParserInitialATest, alterDatabase) {
setAlterDbFsync(200);
setAlterDbWal(1);
setAlterDbCacheModel(TSDB_CACHE_MODEL_LAST_ROW);
- setAlterDbSstTrigger(20);
- run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 WAL_LEVEL 1 SST_TRIGGER 20");
+ setAlterDbSstTrigger(16);
+ run("ALTER DATABASE test CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 WAL_LEVEL 1 SST_TRIGGER 16");
clearAlterDbReq();
initAlterDb("test");
@@ -237,7 +237,7 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
run("ALTER DATABASE test WAL_LEVEL 0", TSDB_CODE_PAR_INVALID_DB_OPTION);
run("ALTER DATABASE test WAL_LEVEL 3", TSDB_CODE_PAR_INVALID_DB_OPTION);
run("ALTER DATABASE test SST_TRIGGER 0", TSDB_CODE_PAR_INVALID_DB_OPTION);
- run("ALTER DATABASE test SST_TRIGGER 129", TSDB_CODE_PAR_INVALID_DB_OPTION);
+ run("ALTER DATABASE test SST_TRIGGER 17", TSDB_CODE_PAR_INVALID_DB_OPTION);
// Regardless of the specific sentence
run("ALTER DATABASE db WAL_LEVEL 0 # td-14436", TSDB_CODE_PAR_SYNTAX_ERROR, PARSER_STAGE_PARSE);
}
diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp
index d68adde86d..28bcae53ef 100644
--- a/source/libs/parser/test/parInitialCTest.cpp
+++ b/source/libs/parser/test/parInitialCTest.cpp
@@ -116,6 +116,8 @@ TEST_F(ParserInitialCTest, createDatabase) {
expect.walRollPeriod = TSDB_REP_DEF_DB_WAL_ROLL_PERIOD;
expect.walSegmentSize = TSDB_DEFAULT_DB_WAL_SEGMENT_SIZE;
expect.sstTrigger = TSDB_DEFAULT_SST_TRIGGER;
+ expect.hashPrefix = TSDB_DEFAULT_HASH_PREFIX;
+ expect.hashSuffix = TSDB_DEFAULT_HASH_SUFFIX;
};
auto setDbBufferFunc = [&](int32_t buffer) { expect.buffer = buffer; };
@@ -157,6 +159,8 @@ TEST_F(ParserInitialCTest, createDatabase) {
auto setDbWalRollPeriod = [&](int32_t walRollPeriod) { expect.walRollPeriod = walRollPeriod; };
auto setDbWalSegmentSize = [&](int32_t walSegmentSize) { expect.walSegmentSize = walSegmentSize; };
auto setDbSstTrigger = [&](int32_t sstTrigger) { expect.sstTrigger = sstTrigger; };
+ auto setDbHashPrefix = [&](int32_t hashPrefix) { expect.hashPrefix = hashPrefix; };
+ auto setDbHashSuffix = [&](int32_t hashSuffix) { expect.hashSuffix = hashSuffix; };
setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) {
ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DATABASE_STMT);
@@ -188,6 +192,8 @@ TEST_F(ParserInitialCTest, createDatabase) {
ASSERT_EQ(req.walRollPeriod, expect.walRollPeriod);
ASSERT_EQ(req.walSegmentSize, expect.walSegmentSize);
ASSERT_EQ(req.sstTrigger, expect.sstTrigger);
+ ASSERT_EQ(req.hashPrefix, expect.hashPrefix);
+ ASSERT_EQ(req.hashSuffix, expect.hashSuffix);
ASSERT_EQ(req.ignoreExist, expect.ignoreExist);
ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions);
if (expect.numOfRetensions > 0) {
@@ -236,6 +242,8 @@ TEST_F(ParserInitialCTest, createDatabase) {
setDbWalRollPeriod(10);
setDbWalSegmentSize(20);
setDbSstTrigger(16);
+ setDbHashPrefix(3);
+ setDbHashSuffix(4);
run("CREATE DATABASE IF NOT EXISTS wxy_db "
"BUFFER 64 "
"CACHEMODEL 'last_value' "
@@ -260,7 +268,9 @@ TEST_F(ParserInitialCTest, createDatabase) {
"WAL_RETENTION_SIZE -1 "
"WAL_ROLL_PERIOD 10 "
"WAL_SEGMENT_SIZE 20 "
- "SST_TRIGGER 16");
+ "SST_TRIGGER 16 "
+ "TABLE_PREFIX 3"
+ "TABLE_SUFFIX 4");
clearCreateDbReq();
setCreateDbReqFunc("wxy_db", 1);
diff --git a/source/libs/planner/test/planTestUtil.cpp b/source/libs/planner/test/planTestUtil.cpp
index 96f7d29230..b280b32a94 100644
--- a/source/libs/planner/test/planTestUtil.cpp
+++ b/source/libs/planner/test/planTestUtil.cpp
@@ -19,6 +19,7 @@
#include
#include
+#include
#include "cmdnodes.h"
#include "mockCatalogService.h"
@@ -251,6 +252,7 @@ class PlannerTestBaseImpl {
string splitLogicPlan_;
string scaledLogicPlan_;
string physiPlan_;
+ string physiPlanMsg_;
vector physiSubplans_;
};
@@ -274,6 +276,7 @@ class PlannerTestBaseImpl {
res_.splitLogicPlan_.clear();
res_.scaledLogicPlan_.clear();
res_.physiPlan_.clear();
+ res_.physiPlanMsg_.clear();
res_.physiSubplans_.clear();
}
@@ -408,6 +411,8 @@ class PlannerTestBaseImpl {
SNode* pSubplan;
FOREACH(pSubplan, ((SNodeListNode*)pNode)->pNodeList) { res_.physiSubplans_.push_back(toString(pSubplan)); }
}
+ res_.physiPlanMsg_ = toMsg((SNode*)(*pPlan));
+ cout << "json len: " << res_.physiPlan_.length() << ", msg len: " << res_.physiPlanMsg_.length() << endl;
}
void setPlanContext(SQuery* pQuery, SPlanContext* pCxt) {
@@ -446,12 +451,45 @@ class PlannerTestBaseImpl {
string toString(const SNode* pRoot) {
char* pStr = NULL;
int32_t len = 0;
+
+ auto start = chrono::steady_clock::now();
DO_WITH_THROW(nodesNodeToString, pRoot, false, &pStr, &len)
+ if (QUERY_NODE_PHYSICAL_PLAN == nodeType(pRoot)) {
+ cout << "nodesNodeToString: "
+ << chrono::duration_cast(chrono::steady_clock::now() - start).count() << "us" << endl;
+ }
+
string str(pStr);
taosMemoryFreeClear(pStr);
return str;
}
+ string toMsg(const SNode* pRoot) {
+ char* pStr = NULL;
+ int32_t len = 0;
+
+ auto start = chrono::steady_clock::now();
+ DO_WITH_THROW(nodesNodeToMsg, pRoot, &pStr, &len)
+ cout << "nodesNodeToMsg: "
+ << chrono::duration_cast(chrono::steady_clock::now() - start).count() << "us" << endl;
+
+ SNode* pNode = NULL;
+ char* pNewStr = NULL;
+ int32_t newlen = 0;
+ DO_WITH_THROW(nodesMsgToNode, pStr, len, &pNode)
+ DO_WITH_THROW(nodesNodeToMsg, pNode, &pNewStr, &newlen)
+ if (newlen != len || 0 != memcmp(pStr, pNewStr, len)) {
+ cout << "nodesNodeToMsg error!!!!!!!!!!!!!! len = " << len << ", newlen = " << newlen << endl;
+ DO_WITH_THROW(nodesNodeToString, pNode, false, &pNewStr, &newlen)
+ cout << "nodesNodeToString " << pNewStr << endl;
+ }
+ taosMemoryFreeClear(pNewStr);
+
+ string str(pStr, len);
+ taosMemoryFreeClear(pStr);
+ return str;
+ }
+
caseEnv caseEnv_;
stmtEnv stmtEnv_;
stmtRes res_;
diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c
index e2d3ac1583..e54937114c 100644
--- a/source/libs/qcom/src/querymsg.c
+++ b/source/libs/qcom/src/querymsg.c
@@ -38,6 +38,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) {
pOut->dbVgroup->vgVersion = usedbRsp->vgVersion;
pOut->dbVgroup->hashMethod = usedbRsp->hashMethod;
+ pOut->dbVgroup->hashPrefix = usedbRsp->hashPrefix;
+ pOut->dbVgroup->hashSuffix = usedbRsp->hashSuffix;
qDebug("Got %d vgroup for db %s", usedbRsp->vgNum, usedbRsp->db);
diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c
index 9cab39c301..c5f161b66a 100644
--- a/source/libs/scheduler/src/schTask.c
+++ b/source/libs/scheduler/src/schTask.c
@@ -52,7 +52,7 @@ void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel) {
int32_t nodeNum = taosArrayGetSize(pJob->nodeList);
pTask->maxRetryTimes = TMAX(nodeNum, SCH_DEFAULT_MAX_RETRY_NUM);
}
-
+
pTask->maxExecTimes = pTask->maxRetryTimes * (pLevel->level + 1);
}
@@ -139,13 +139,15 @@ int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int3
}
if ((execId != pTask->execId) || pTask->waitRetry) { // ignore it
- SCH_TASK_DLOG("handle not updated since execId %d is already not current execId %d, waitRetry %d", execId, pTask->execId, pTask->waitRetry);
+ SCH_TASK_DLOG("handle not updated since execId %d is already not current execId %d, waitRetry %d", execId,
+ pTask->execId, pTask->waitRetry);
return TSDB_CODE_SUCCESS;
}
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId));
if (NULL == nodeInfo) { // ignore it
- SCH_TASK_DLOG("handle not updated since execId %d already not exist, current execId %d, waitRetry %d", execId, pTask->execId, pTask->waitRetry);
+ SCH_TASK_DLOG("handle not updated since execId %d already not exist, current execId %d, waitRetry %d", execId,
+ pTask->execId, pTask->waitRetry);
return TSDB_CODE_SUCCESS;
}
@@ -314,7 +316,7 @@ int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask) {
if (!schMgmt.cfg.enableReSchedule) {
return TSDB_CODE_SUCCESS;
}
-
+
if (SCH_IS_DATA_BIND_TASK(pTask)) {
return TSDB_CODE_SUCCESS;
}
@@ -341,7 +343,8 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
}
if (((pTask->execId + 1) >= pTask->maxExecTimes) || ((pTask->retryTimes + 1) > pTask->maxRetryTimes)) {
- SCH_TASK_DLOG("task no more retry since reach max times %d:%d, execId %d", pTask->maxRetryTimes, pTask->maxExecTimes, pTask->execId);
+ SCH_TASK_DLOG("task no more retry since reach max times %d:%d, execId %d", pTask->maxRetryTimes,
+ pTask->maxExecTimes, pTask->execId);
schHandleJobFailure(pJob, rspCode);
return TSDB_CODE_SUCCESS;
}
@@ -548,7 +551,8 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
if ((pTask->retryTimes + 1) > pTask->maxRetryTimes) {
*needRetry = false;
- SCH_TASK_DLOG("task no more retry since reach max retry times, retryTimes:%d/%d", pTask->retryTimes, pTask->maxRetryTimes);
+ SCH_TASK_DLOG("task no more retry since reach max retry times, retryTimes:%d/%d", pTask->retryTimes,
+ pTask->maxRetryTimes);
return TSDB_CODE_SUCCESS;
}
@@ -564,25 +568,25 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
return TSDB_CODE_SUCCESS;
}
-/*
- if (SCH_IS_DATA_BIND_TASK(pTask)) {
- if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
- *needRetry = false;
- SCH_TASK_DLOG("task no more retry since all ep tried, execId:%d, epNum:%d", pTask->execId,
- SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
- return TSDB_CODE_SUCCESS;
- }
- } else {
- int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
+ /*
+ if (SCH_IS_DATA_BIND_TASK(pTask)) {
+ if ((pTask->execId + 1) >= SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode)) {
+ *needRetry = false;
+ SCH_TASK_DLOG("task no more retry since all ep tried, execId:%d, epNum:%d", pTask->execId,
+ SCH_TASK_NUM_OF_EPS(&pTask->plan->execNode));
+ return TSDB_CODE_SUCCESS;
+ }
+ } else {
+ int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
- if ((pTask->candidateIdx + 1) >= candidateNum && (TSDB_CODE_SCH_TIMEOUT_ERROR != errCode)) {
- *needRetry = false;
- SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d",
- pTask->candidateIdx, candidateNum);
- return TSDB_CODE_SUCCESS;
+ if ((pTask->candidateIdx + 1) >= candidateNum && (TSDB_CODE_SCH_TIMEOUT_ERROR != errCode)) {
+ *needRetry = false;
+ SCH_TASK_DLOG("task no more retry since all candiates tried, candidateIdx:%d, candidateNum:%d",
+ pTask->candidateIdx, candidateNum);
+ return TSDB_CODE_SUCCESS;
+ }
}
- }
-*/
+ */
*needRetry = true;
SCH_TASK_DLOG("task need the %dth retry, errCode:%x - %s", pTask->execId + 1, errCode, tstrerror(errCode));
@@ -630,8 +634,9 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) {
SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY);
}
- SCH_TASK_TLOG("set %dth candidate addr, id %d, inUse:%d/%d, fqdn:%s, port:%d", i, naddr->nodeId, naddr->epSet.inUse, naddr->epSet.numOfEps,
- SCH_GET_CUR_EP(naddr)->fqdn, SCH_GET_CUR_EP(naddr)->port);
+ SCH_TASK_TLOG("set %dth candidate addr, id %d, inUse:%d/%d, fqdn:%s, port:%d", i, naddr->nodeId,
+ naddr->epSet.inUse, naddr->epSet.numOfEps, SCH_GET_CUR_EP(naddr)->fqdn,
+ SCH_GET_CUR_EP(naddr)->port);
++addNum;
}
@@ -711,10 +716,10 @@ int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
if (candidateNum <= 1) {
goto _return;
}
-
+
switch (schMgmt.cfg.schPolicy) {
case SCH_LOAD_SEQ:
- case SCH_ALL:
+ case SCH_ALL:
default:
if (++pTask->candidateIdx >= candidateNum) {
pTask->candidateIdx = 0;
@@ -732,7 +737,7 @@ int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
_return:
SCH_TASK_DLOG("switch task candiateIdx to %d/%d", pTask->candidateIdx, candidateNum);
-
+
return TSDB_CODE_SUCCESS;
}
@@ -759,7 +764,7 @@ void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask) {
return;
}
- int32_t i = 0;
+ int32_t i = 0;
SSchNodeInfo *nodeInfo = taosHashIterate(pTask->execNodes, NULL);
while (nodeInfo) {
if (nodeInfo->handle) {
@@ -821,16 +826,16 @@ int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList) {
int32_t schLaunchTaskImpl(void *param) {
SSchTaskCtx *pCtx = (SSchTaskCtx *)param;
- SSchJob *pJob = schAcquireJob(pCtx->jobRid);
+ SSchJob *pJob = schAcquireJob(pCtx->jobRid);
if (NULL == pJob) {
- taosMemoryFree(param);
qDebug("job refId 0x%" PRIx64 " already not exist", pCtx->jobRid);
+ taosMemoryFree(param);
SCH_RET(TSDB_CODE_SCH_JOB_IS_DROPPING);
}
-
+
SSchTask *pTask = pCtx->pTask;
- int8_t status = 0;
- int32_t code = 0;
+ int8_t status = 0;
+ int32_t code = 0;
atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1);
pTask->execId++;
@@ -891,13 +896,12 @@ _return:
SCH_RET(code);
}
-int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
-
+int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
SSchTaskCtx *param = taosMemoryCalloc(1, sizeof(SSchTaskCtx));
if (NULL == param) {
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
}
-
+
param->jobRid = pJob->refId;
param->pTask = pTask;
@@ -906,7 +910,7 @@ int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
} else {
SCH_ERR_RET(schLaunchTaskImpl(param));
}
-
+
return TSDB_CODE_SUCCESS;
}
diff --git a/source/libs/stream/src/streamDispatch.c b/source/libs/stream/src/streamDispatch.c
index 9d4010f60e..a2a45938e4 100644
--- a/source/libs/stream/src/streamDispatch.c
+++ b/source/libs/stream/src/streamDispatch.c
@@ -243,6 +243,36 @@ FAIL:
return 0;
}
+int32_t streamSearchAndAddBlock(SStreamTask* pTask, SStreamDispatchReq* pReqs, SSDataBlock* pDataBlock, int32_t vgSz,
+ int64_t groupId) {
+ char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, groupId);
+ SArray* vgInfo = pTask->shuffleDispatcher.dbInfo.pVgroupInfos;
+
+ // TODO: get hash function by hashMethod
+ uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));
+ taosMemoryFree(ctbName);
+ bool found = false;
+ // TODO: optimize search
+ int32_t j;
+ for (j = 0; j < vgSz; j++) {
+ SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
+ ASSERT(pVgInfo->vgId > 0);
+ if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) {
+ if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
+ return -1;
+ }
+ if (pReqs[j].blockNum == 0) {
+ atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1);
+ }
+ pReqs[j].blockNum++;
+ found = true;
+ break;
+ }
+ }
+ ASSERT(found);
+ return 0;
+}
+
int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pData) {
int32_t code = -1;
int32_t blockNum = taosArrayGetSize(pData->blocks);
@@ -317,20 +347,10 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
for (int32_t i = 0; i < blockNum; i++) {
SSDataBlock* pDataBlock = taosArrayGet(pData->blocks, i);
- char* ctbName = buildCtbNameByGroupId(pTask->shuffleDispatcher.stbFullName, pDataBlock->info.groupId);
- // TODO: get hash function by hashMethod
- uint32_t hashValue = MurmurHash3_32(ctbName, strlen(ctbName));
-
- taosMemoryFree(ctbName);
-
- bool found = false;
- // TODO: optimize search
- int32_t j;
- for (j = 0; j < vgSz; j++) {
- SVgroupInfo* pVgInfo = taosArrayGet(vgInfo, j);
- ASSERT(pVgInfo->vgId > 0);
- if (hashValue >= pVgInfo->hashBegin && hashValue <= pVgInfo->hashEnd) {
+ // TODO: do not use broadcast
+ if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
+ for (int32_t j = 0; j < vgSz; j++) {
if (streamAddBlockToDispatchMsg(pDataBlock, &pReqs[j]) < 0) {
goto FAIL_SHUFFLE_DISPATCH;
}
@@ -338,11 +358,13 @@ int32_t streamDispatchAllBlocks(SStreamTask* pTask, const SStreamDataBlock* pDat
atomic_add_fetch_32(&pTask->shuffleDispatcher.waitingRspCnt, 1);
}
pReqs[j].blockNum++;
- found = true;
- break;
}
+ continue;
+ }
+
+ if (streamSearchAndAddBlock(pTask, pReqs, pDataBlock, vgSz, pDataBlock->info.groupId) < 0) {
+ goto FAIL_SHUFFLE_DISPATCH;
}
- ASSERT(found);
}
for (int32_t i = 0; i < vgSz; i++) {
diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c
index dfd6f012cc..5efdbb4679 100644
--- a/source/libs/stream/src/streamState.c
+++ b/source/libs/stream/src/streamState.c
@@ -112,6 +112,29 @@ int32_t streamStateDel(SStreamState* pState, const SWinKey* key) {
return tdbTbDelete(pState->pStateDb, key, sizeof(SWinKey), &pState->txn);
}
+int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen) {
+ // todo refactor
+ int32_t size = *pVLen;
+ if (streamStateGet(pState, key, pVal, pVLen) == 0) {
+ return 0;
+ }
+ void* tmp = taosMemoryCalloc(1, size);
+ if (streamStatePut(pState, key, &tmp, size) == 0) {
+ taosMemoryFree(tmp);
+ int32_t code = streamStateGet(pState, key, pVal, pVLen);
+ ASSERT(code == 0);
+ return code;
+ }
+ taosMemoryFree(tmp);
+ return -1;
+}
+
+int32_t streamStateReleaseBuf(SStreamState* pState, const SWinKey* key, void* pVal) {
+ // todo refactor
+ streamFreeVal(pVal);
+ return 0;
+}
+
SStreamStateCur* streamStateGetCur(SStreamState* pState, const SWinKey* key) {
SStreamStateCur* pCur = taosMemoryCalloc(1, sizeof(SStreamStateCur));
if (pCur == NULL) return NULL;
diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c
index 51098374b0..6f29b54f80 100644
--- a/source/libs/sync/src/syncMain.c
+++ b/source/libs/sync/src/syncMain.c
@@ -2766,8 +2766,6 @@ const char* syncStr(ESyncState state) {
}
int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* pEntry) {
- SyncLeaderTransfer* pSyncLeaderTransfer = syncLeaderTransferFromRpcMsg2(pRpcMsg);
-
if (ths->state != TAOS_SYNC_STATE_FOLLOWER) {
syncNodeEventLog(ths, "I am not follower, can not do leader transfer");
return 0;
@@ -2799,6 +2797,8 @@ int32_t syncDoLeaderTransfer(SSyncNode* ths, SRpcMsg* pRpcMsg, SSyncRaftEntry* p
}
*/
+ SyncLeaderTransfer* pSyncLeaderTransfer = syncLeaderTransferFromRpcMsg2(pRpcMsg);
+
do {
char logBuf[128];
snprintf(logBuf, sizeof(logBuf), "do leader transfer, index:%ld", pEntry->index);
diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c
index b42aba560f..faebe5bbec 100644
--- a/source/libs/sync/src/syncMessage.c
+++ b/source/libs/sync/src/syncMessage.c
@@ -1992,6 +1992,313 @@ void syncAppendEntriesReplyLog2(char* s, const SyncAppendEntriesReply* pMsg) {
}
}
+// ---- message process SyncHeartbeat----
+SyncHeartbeat* syncHeartbeatBuild(int32_t vgId) {
+ uint32_t bytes = sizeof(SyncHeartbeat);
+ SyncHeartbeat* pMsg = taosMemoryMalloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->vgId = vgId;
+ pMsg->msgType = TDMT_SYNC_HEARTBEAT;
+ return pMsg;
+}
+
+void syncHeartbeatDestroy(SyncHeartbeat* pMsg) {
+ if (pMsg != NULL) {
+ taosMemoryFree(pMsg);
+ }
+}
+
+void syncHeartbeatSerialize(const SyncHeartbeat* pMsg, char* buf, uint32_t bufLen) {
+ ASSERT(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncHeartbeatDeserialize(const char* buf, uint32_t len, SyncHeartbeat* pMsg) {
+ memcpy(pMsg, buf, len);
+ ASSERT(len == pMsg->bytes);
+}
+
+char* syncHeartbeatSerialize2(const SyncHeartbeat* pMsg, uint32_t* len) {
+ char* buf = taosMemoryMalloc(pMsg->bytes);
+ ASSERT(buf != NULL);
+ syncHeartbeatSerialize(pMsg, buf, pMsg->bytes);
+ if (len != NULL) {
+ *len = pMsg->bytes;
+ }
+ return buf;
+}
+
+SyncHeartbeat* syncHeartbeatDeserialize2(const char* buf, uint32_t len) {
+ uint32_t bytes = *((uint32_t*)buf);
+ SyncHeartbeat* pMsg = taosMemoryMalloc(bytes);
+ ASSERT(pMsg != NULL);
+ syncHeartbeatDeserialize(buf, len, pMsg);
+ ASSERT(len == pMsg->bytes);
+ return pMsg;
+}
+
+void syncHeartbeat2RpcMsg(const SyncHeartbeat* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncHeartbeatSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncHeartbeatFromRpcMsg(const SRpcMsg* pRpcMsg, SyncHeartbeat* pMsg) {
+ syncHeartbeatDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+SyncHeartbeat* syncHeartbeatFromRpcMsg2(const SRpcMsg* pRpcMsg) {
+ SyncHeartbeat* pMsg = syncHeartbeatDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
+ ASSERT(pMsg != NULL);
+ return pMsg;
+}
+
+cJSON* syncHeartbeat2Json(const SyncHeartbeat* pMsg) {
+ char u64buf[128] = {0};
+ cJSON* pRoot = cJSON_CreateObject();
+
+ if (pMsg != NULL) {
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128] = {0};
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128] = {0};
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
+ cJSON_AddStringToObject(pRoot, "term", u64buf);
+
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm);
+ cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
+
+ snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->commitIndex);
+ cJSON_AddStringToObject(pRoot, "commitIndex", u64buf);
+ }
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncHeartbeat", pRoot);
+ return pJson;
+}
+
+char* syncHeartbeat2Str(const SyncHeartbeat* pMsg) {
+ cJSON* pJson = syncHeartbeat2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ cJSON_Delete(pJson);
+ return serialized;
+}
+
+void syncHeartbeatPrint(const SyncHeartbeat* pMsg) {
+ char* serialized = syncHeartbeat2Str(pMsg);
+ printf("syncHeartbeatPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ fflush(NULL);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatPrint2(char* s, const SyncHeartbeat* pMsg) {
+ char* serialized = syncHeartbeat2Str(pMsg);
+ printf("syncHeartbeatPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ fflush(NULL);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatLog(const SyncHeartbeat* pMsg) {
+ char* serialized = syncHeartbeat2Str(pMsg);
+ sTrace("syncHeartbeatLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatLog2(char* s, const SyncHeartbeat* pMsg) {
+ if (gRaftDetailLog) {
+ char* serialized = syncHeartbeat2Str(pMsg);
+ sTrace("syncHeartbeatLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ taosMemoryFree(serialized);
+ }
+}
+
+// ---- message process SyncHeartbeatReply----
+SyncHeartbeatReply* syncHeartbeatReplyBuild(int32_t vgId) {
+ uint32_t bytes = sizeof(SyncHeartbeatReply);
+ SyncHeartbeatReply* pMsg = taosMemoryMalloc(bytes);
+ memset(pMsg, 0, bytes);
+ pMsg->bytes = bytes;
+ pMsg->vgId = vgId;
+ pMsg->msgType = TDMT_SYNC_HEARTBEAT_REPLY;
+ return pMsg;
+}
+
+void syncHeartbeatReplyDestroy(SyncHeartbeatReply* pMsg) {
+ if (pMsg != NULL) {
+ taosMemoryFree(pMsg);
+ }
+}
+
+void syncHeartbeatReplySerialize(const SyncHeartbeatReply* pMsg, char* buf, uint32_t bufLen) {
+ ASSERT(pMsg->bytes <= bufLen);
+ memcpy(buf, pMsg, pMsg->bytes);
+}
+
+void syncHeartbeatReplyDeserialize(const char* buf, uint32_t len, SyncHeartbeatReply* pMsg) {
+ memcpy(pMsg, buf, len);
+ ASSERT(len == pMsg->bytes);
+}
+
+char* syncHeartbeatReplySerialize2(const SyncHeartbeatReply* pMsg, uint32_t* len) {
+ char* buf = taosMemoryMalloc(pMsg->bytes);
+ ASSERT(buf != NULL);
+ syncHeartbeatReplySerialize(pMsg, buf, pMsg->bytes);
+ if (len != NULL) {
+ *len = pMsg->bytes;
+ }
+ return buf;
+}
+
+SyncHeartbeatReply* syncHeartbeatReplyDeserialize2(const char* buf, uint32_t len) {
+ uint32_t bytes = *((uint32_t*)buf);
+ SyncHeartbeatReply* pMsg = taosMemoryMalloc(bytes);
+ ASSERT(pMsg != NULL);
+ syncHeartbeatReplyDeserialize(buf, len, pMsg);
+ ASSERT(len == pMsg->bytes);
+ return pMsg;
+}
+
+void syncHeartbeatReply2RpcMsg(const SyncHeartbeatReply* pMsg, SRpcMsg* pRpcMsg) {
+ memset(pRpcMsg, 0, sizeof(*pRpcMsg));
+ pRpcMsg->msgType = pMsg->msgType;
+ pRpcMsg->contLen = pMsg->bytes;
+ pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
+ syncHeartbeatReplySerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
+}
+
+void syncHeartbeatReplyFromRpcMsg(const SRpcMsg* pRpcMsg, SyncHeartbeatReply* pMsg) {
+ syncHeartbeatReplyDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
+}
+
+SyncHeartbeatReply* syncHeartbeatReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) {
+ SyncHeartbeatReply* pMsg = syncHeartbeatReplyDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
+ ASSERT(pMsg != NULL);
+ return pMsg;
+}
+
+cJSON* syncHeartbeatReply2Json(const SyncHeartbeatReply* pMsg) {
+ char u64buf[128] = {0};
+ cJSON* pRoot = cJSON_CreateObject();
+
+ if (pMsg != NULL) {
+ cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
+ cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId);
+ cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
+
+ cJSON* pSrcId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr);
+ cJSON_AddStringToObject(pSrcId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->srcId.addr;
+ cJSON* pTmp = pSrcId;
+ char host[128] = {0};
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
+ cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
+
+ cJSON* pDestId = cJSON_CreateObject();
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr);
+ cJSON_AddStringToObject(pDestId, "addr", u64buf);
+ {
+ uint64_t u64 = pMsg->destId.addr;
+ cJSON* pTmp = pDestId;
+ char host[128] = {0};
+ uint16_t port;
+ syncUtilU642Addr(u64, host, sizeof(host), &port);
+ cJSON_AddStringToObject(pTmp, "addr_host", host);
+ cJSON_AddNumberToObject(pTmp, "addr_port", port);
+ }
+ cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
+ cJSON_AddItemToObject(pRoot, "destId", pDestId);
+
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->privateTerm);
+ cJSON_AddStringToObject(pRoot, "privateTerm", u64buf);
+
+ snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->term);
+ cJSON_AddStringToObject(pRoot, "term", u64buf);
+
+ cJSON_AddStringToObject(pRoot, "matchIndex", u64buf);
+ snprintf(u64buf, sizeof(u64buf), "%" PRId64, pMsg->startTime);
+ cJSON_AddStringToObject(pRoot, "startTime", u64buf);
+ }
+
+ cJSON* pJson = cJSON_CreateObject();
+ cJSON_AddItemToObject(pJson, "SyncHeartbeatReply", pRoot);
+ return pJson;
+}
+
+char* syncHeartbeatReply2Str(const SyncHeartbeatReply* pMsg) {
+ cJSON* pJson = syncHeartbeatReply2Json(pMsg);
+ char* serialized = cJSON_Print(pJson);
+ cJSON_Delete(pJson);
+ return serialized;
+}
+
+void syncHeartbeatReplyPrint(const SyncHeartbeatReply* pMsg) {
+ char* serialized = syncHeartbeatReply2Str(pMsg);
+ printf("syncHeartbeatReplyPrint | len:%" PRIu64 " | %s \n", strlen(serialized), serialized);
+ fflush(NULL);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatReplyPrint2(char* s, const SyncHeartbeatReply* pMsg) {
+ char* serialized = syncHeartbeatReply2Str(pMsg);
+ printf("syncHeartbeatReplyPrint2 | len:%" PRIu64 " | %s | %s \n", strlen(serialized), s, serialized);
+ fflush(NULL);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatReplyLog(const SyncHeartbeatReply* pMsg) {
+ char* serialized = syncHeartbeatReply2Str(pMsg);
+ sTrace("syncHeartbeatReplyLog | len:%" PRIu64 " | %s", strlen(serialized), serialized);
+ taosMemoryFree(serialized);
+}
+
+void syncHeartbeatReplyLog2(char* s, const SyncHeartbeatReply* pMsg) {
+ if (gRaftDetailLog) {
+ char* serialized = syncHeartbeatReply2Str(pMsg);
+ sTrace("syncHeartbeatReplyLog2 | len:%" PRIu64 " | %s | %s", strlen(serialized), s, serialized);
+ taosMemoryFree(serialized);
+ }
+}
+
// ---- message process SyncApplyMsg----
SyncApplyMsg* syncApplyMsgBuild(uint32_t dataLen) {
uint32_t bytes = sizeof(SyncApplyMsg) + dataLen;
diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt
index 72845d0c1d..b9cc7a391d 100644
--- a/source/libs/sync/test/CMakeLists.txt
+++ b/source/libs/sync/test/CMakeLists.txt
@@ -57,6 +57,8 @@ add_executable(syncLeaderTransferTest "")
add_executable(syncReconfigFinishTest "")
add_executable(syncRestoreFromSnapshot "")
add_executable(syncRaftCfgIndexTest "")
+add_executable(syncHeartbeatTest "")
+add_executable(syncHeartbeatReplyTest "")
target_sources(syncTest
@@ -295,6 +297,14 @@ target_sources(syncRaftCfgIndexTest
PRIVATE
"syncRaftCfgIndexTest.cpp"
)
+target_sources(syncHeartbeatTest
+ PRIVATE
+ "syncHeartbeatTest.cpp"
+)
+target_sources(syncHeartbeatReplyTest
+ PRIVATE
+ "syncHeartbeatReplyTest.cpp"
+)
target_include_directories(syncTest
@@ -592,6 +602,16 @@ target_include_directories(syncRaftCfgIndexTest
"${TD_SOURCE_DIR}/include/libs/sync"
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
)
+target_include_directories(syncHeartbeatTest
+ PUBLIC
+ "${TD_SOURCE_DIR}/include/libs/sync"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
+)
+target_include_directories(syncHeartbeatReplyTest
+ PUBLIC
+ "${TD_SOURCE_DIR}/include/libs/sync"
+ "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
+)
target_link_libraries(syncTest
@@ -830,6 +850,14 @@ target_link_libraries(syncRaftCfgIndexTest
sync
gtest_main
)
+target_link_libraries(syncHeartbeatTest
+ sync
+ gtest_main
+)
+target_link_libraries(syncHeartbeatReplyTest
+ sync
+ gtest_main
+)
enable_testing()
diff --git a/source/libs/sync/test/syncHeartbeatReplyTest.cpp b/source/libs/sync/test/syncHeartbeatReplyTest.cpp
new file mode 100644
index 0000000000..0ccd7b70bb
--- /dev/null
+++ b/source/libs/sync/test/syncHeartbeatReplyTest.cpp
@@ -0,0 +1,105 @@
+#include
+#include
+#include "syncIO.h"
+#include "syncInt.h"
+#include "syncMessage.h"
+#include "syncUtil.h"
+
+void logTest() {
+ sTrace("--- sync log test: trace");
+ sDebug("--- sync log test: debug");
+ sInfo("--- sync log test: info");
+ sWarn("--- sync log test: warn");
+ sError("--- sync log test: error");
+ sFatal("--- sync log test: fatal");
+}
+
+SyncHeartbeatReply *createMsg() {
+ SyncHeartbeatReply *pMsg = syncHeartbeatReplyBuild(1000);
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
+ pMsg->destId.vgId = 100;
+
+ pMsg->term = 33;
+ pMsg->privateTerm = 44;
+ pMsg->startTime = taosGetTimestampMs();
+ return pMsg;
+}
+
+void test1() {
+ SyncHeartbeatReply *pMsg = createMsg();
+ syncHeartbeatReplyLog2((char *)"test1:", pMsg);
+ syncHeartbeatReplyDestroy(pMsg);
+}
+
+void test2() {
+ SyncHeartbeatReply *pMsg = createMsg();
+ uint32_t len = pMsg->bytes;
+ char * serialized = (char *)taosMemoryMalloc(len);
+ syncHeartbeatReplySerialize(pMsg, serialized, len);
+ SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyBuild(1000);
+ syncHeartbeatReplyDeserialize(serialized, len, pMsg2);
+ syncHeartbeatReplyLog2((char *)"test2: syncHeartbeatReplySerialize -> syncHeartbeatReplyDeserialize ",
+ pMsg2);
+
+ taosMemoryFree(serialized);
+ syncHeartbeatReplyDestroy(pMsg);
+ syncHeartbeatReplyDestroy(pMsg2);
+}
+
+void test3() {
+ SyncHeartbeatReply *pMsg = createMsg();
+ uint32_t len;
+ char * serialized = syncHeartbeatReplySerialize2(pMsg, &len);
+ SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyDeserialize2(serialized, len);
+ syncHeartbeatReplyLog2((char *)"test3: syncHeartbeatReplySerialize3 -> syncHeartbeatReplyDeserialize2 ",
+ pMsg2);
+
+ taosMemoryFree(serialized);
+ syncHeartbeatReplyDestroy(pMsg);
+ syncHeartbeatReplyDestroy(pMsg2);
+}
+
+void test4() {
+ SyncHeartbeatReply *pMsg = createMsg();
+ SRpcMsg rpcMsg;
+ syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg);
+ SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyBuild(1000);
+ syncHeartbeatReplyFromRpcMsg(&rpcMsg, pMsg2);
+ syncHeartbeatReplyLog2((char *)"test4: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg ",
+ pMsg2);
+
+ rpcFreeCont(rpcMsg.pCont);
+ syncHeartbeatReplyDestroy(pMsg);
+ syncHeartbeatReplyDestroy(pMsg2);
+}
+
+void test5() {
+ SyncHeartbeatReply *pMsg = createMsg();
+ SRpcMsg rpcMsg;
+ syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg);
+ SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyFromRpcMsg2(&rpcMsg);
+ syncHeartbeatReplyLog2((char *)"test5: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg2 ",
+ pMsg2);
+
+ rpcFreeCont(rpcMsg.pCont);
+ syncHeartbeatReplyDestroy(pMsg);
+ syncHeartbeatReplyDestroy(pMsg2);
+}
+
+int main() {
+ gRaftDetailLog = true;
+
+ tsAsyncLog = 0;
+ sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
+ logTest();
+
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+
+ return 0;
+}
diff --git a/source/libs/sync/test/syncHeartbeatTest.cpp b/source/libs/sync/test/syncHeartbeatTest.cpp
new file mode 100644
index 0000000000..d910c828f1
--- /dev/null
+++ b/source/libs/sync/test/syncHeartbeatTest.cpp
@@ -0,0 +1,99 @@
+#include
+#include
+#include "syncIO.h"
+#include "syncInt.h"
+#include "syncMessage.h"
+#include "syncUtil.h"
+
+void logTest() {
+ sTrace("--- sync log test: trace");
+ sDebug("--- sync log test: debug");
+ sInfo("--- sync log test: info");
+ sWarn("--- sync log test: warn");
+ sError("--- sync log test: error");
+ sFatal("--- sync log test: fatal");
+}
+
+SyncHeartbeat *createMsg() {
+ SyncHeartbeat *pMsg = syncHeartbeatBuild(789);
+ pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
+ pMsg->srcId.vgId = 100;
+ pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
+ pMsg->destId.vgId = 100;
+ pMsg->term = 8;
+ pMsg->commitIndex = 33;
+ pMsg->privateTerm = 44;
+ return pMsg;
+}
+
+void test1() {
+ SyncHeartbeat *pMsg = createMsg();
+ syncHeartbeatLog2((char *)"test1:", pMsg);
+ syncHeartbeatDestroy(pMsg);
+}
+
+void test2() {
+ SyncHeartbeat *pMsg = createMsg();
+ uint32_t len = pMsg->bytes;
+ char * serialized = (char *)taosMemoryMalloc(len);
+ syncHeartbeatSerialize(pMsg, serialized, len);
+ SyncHeartbeat *pMsg2 = syncHeartbeatBuild(789);
+ syncHeartbeatDeserialize(serialized, len, pMsg2);
+ syncHeartbeatLog2((char *)"test2: syncHeartbeatSerialize -> syncHeartbeatDeserialize ", pMsg2);
+
+ taosMemoryFree(serialized);
+ syncHeartbeatDestroy(pMsg);
+ syncHeartbeatDestroy(pMsg2);
+}
+
+void test3() {
+ SyncHeartbeat *pMsg = createMsg();
+ uint32_t len;
+ char * serialized = syncHeartbeatSerialize2(pMsg, &len);
+ SyncHeartbeat *pMsg2 = syncHeartbeatDeserialize2(serialized, len);
+ syncHeartbeatLog2((char *)"test3: syncHeartbeatSerialize2 -> syncHeartbeatDeserialize2 ", pMsg2);
+
+ taosMemoryFree(serialized);
+ syncHeartbeatDestroy(pMsg);
+ syncHeartbeatDestroy(pMsg2);
+}
+
+void test4() {
+ SyncHeartbeat *pMsg = createMsg();
+ SRpcMsg rpcMsg;
+ syncHeartbeat2RpcMsg(pMsg, &rpcMsg);
+ SyncHeartbeat *pMsg2 = (SyncHeartbeat *)taosMemoryMalloc(rpcMsg.contLen);
+ syncHeartbeatFromRpcMsg(&rpcMsg, pMsg2);
+ syncHeartbeatLog2((char *)"test4: syncHeartbeat2RpcMsg -> syncHeartbeatFromRpcMsg ", pMsg2);
+
+ rpcFreeCont(rpcMsg.pCont);
+ syncHeartbeatDestroy(pMsg);
+ syncHeartbeatDestroy(pMsg2);
+}
+
+void test5() {
+ SyncHeartbeat *pMsg = createMsg();
+ SRpcMsg rpcMsg;
+ syncHeartbeat2RpcMsg(pMsg, &rpcMsg);
+ SyncHeartbeat *pMsg2 =syncHeartbeatFromRpcMsg2(&rpcMsg);
+ syncHeartbeatLog2((char *)"test5: syncHeartbeat2RpcMsg -> syncHeartbeatFromRpcMsg2 ", pMsg2);
+
+ rpcFreeCont(rpcMsg.pCont);
+ syncHeartbeatDestroy(pMsg);
+ syncHeartbeatDestroy(pMsg2);
+}
+
+int main() {
+ tsAsyncLog = 0;
+ sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
+ gRaftDetailLog = true;
+ logTest();
+
+ test1();
+ test2();
+ test3();
+ test4();
+ test5();
+
+ return 0;
+}
diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c
index f90c392788..bec07b935e 100644
--- a/source/libs/tdb/src/db/tdbPager.c
+++ b/source/libs/tdb/src/db/tdbPager.c
@@ -502,7 +502,7 @@ static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage) {
i64 offset;
int ret;
- offset = pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1);
+ offset = (i64)pPage->pageSize * (TDB_PAGE_PGNO(pPage) - 1);
if (tdbOsLSeek(pPager->fd, offset, SEEK_SET) < 0) {
ASSERT(0);
return -1;
diff --git a/source/libs/transport/src/thttp.c b/source/libs/transport/src/thttp.c
index 275e7b42cc..1559c85e23 100644
--- a/source/libs/transport/src/thttp.c
+++ b/source/libs/transport/src/thttp.c
@@ -126,22 +126,22 @@ _OVER:
return code;
}
-static void destroyHttpClient(SHttpClient* cli) {
+static FORCE_INLINE void destroyHttpClient(SHttpClient* cli) {
taosMemoryFree(cli->wbuf);
taosMemoryFree(cli->rbuf);
taosMemoryFree(cli->addr);
taosMemoryFree(cli);
}
-static void clientCloseCb(uv_handle_t* handle) {
+static FORCE_INLINE void clientCloseCb(uv_handle_t* handle) {
SHttpClient* cli = handle->data;
destroyHttpClient(cli);
}
-static void clientAllocBuffCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
+static FORCE_INLINE void clientAllocBuffCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) {
SHttpClient* cli = handle->data;
buf->base = cli->rbuf;
buf->len = HTTP_RECV_BUF_SIZE;
}
-static void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
+static FORCE_INLINE void clientRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) {
SHttpClient* cli = handle->data;
if (nread < 0) {
uError("http-report recv error:%s", uv_err_name(nread));
@@ -173,7 +173,7 @@ static void clientConnCb(uv_connect_t* req, int32_t status) {
uv_write(&cli->req, (uv_stream_t*)&cli->tcp, cli->wbuf, 2, clientSentCb);
}
-static int32_t taosBuildDstAddr(const char* server, uint16_t port, struct sockaddr_in* dest) {
+static FORCE_INLINE int32_t taosBuildDstAddr(const char* server, uint16_t port, struct sockaddr_in* dest) {
uint32_t ip = taosGetIpv4FromFqdn(server);
if (ip == 0xffffffff) {
terrno = TAOS_SYSTEM_ERROR(errno);
diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c
index 4b5441f738..4a0008b5ff 100644
--- a/source/libs/transport/src/transCli.c
+++ b/source/libs/transport/src/transCli.c
@@ -69,11 +69,9 @@ typedef struct SCliThrd {
SAsyncPool* asyncPool;
uv_prepare_t* prepare;
void* pool; // conn pool
-
+ // timer handles
SArray* timerList;
-
// msg queue
-
queue msg;
TdThreadMutex msgMtx;
SDelayQueue* delayQueue;
@@ -108,7 +106,7 @@ static void cliReadTimeoutCb(uv_timer_t* handle);
// register timer in each thread to clear expire conn
// static void cliTimeoutCb(uv_timer_t* handle);
// alloc buffer for recv
-static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
+static FORCE_INLINE void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf);
// callback after recv nbytes from socket
static void cliRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf);
// callback after send data to socket
@@ -132,10 +130,10 @@ static void cliSend(SCliConn* pConn);
static void cliDestroyConnMsgs(SCliConn* conn, bool destroy);
// cli util func
-static bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx);
-static void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr);
+static FORCE_INLINE bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx);
+static FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr);
-static int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* resp);
+static FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* resp);
// process data read from server, add decompress etc later
static void cliHandleResp(SCliConn* conn);
@@ -150,13 +148,11 @@ static void cliHandleUpdate(SCliMsg* pMsg, SCliThrd* pThrd);
static void (*cliAsyncHandle[])(SCliMsg* pMsg, SCliThrd* pThrd) = {cliHandleReq, cliHandleQuit, cliHandleRelease, NULL,
cliHandleUpdate};
-static void cliSendQuit(SCliThrd* thrd);
-static void destroyUserdata(STransMsg* userdata);
+static FORCE_INLINE void destroyUserdata(STransMsg* userdata);
+static FORCE_INLINE void destroyCmsg(void* cmsg);
+static FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst);
+static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx);
-static int cliRBChoseIdx(STrans* pTransInst);
-
-static void destroyCmsg(void* cmsg);
-static void transDestroyConnCtx(STransConnCtx* ctx);
// thread obj
static SCliThrd* createThrdObj();
static void destroyThrdObj(SCliThrd* pThrd);
@@ -166,7 +162,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg);
static void cliReleaseUnfinishedMsg(SCliConn* conn) {
for (int i = 0; i < transQueueSize(&conn->cliMsgs); i++) {
SCliMsg* msg = transQueueGet(&conn->cliMsgs, i);
- if (msg != NULL && msg->ctx != NULL) {
+ if (msg != NULL && msg->ctx != NULL && msg->ctx->ahandle != (void*)0x9527) {
if (conn->ctx.freeFunc != NULL && msg->ctx->ahandle != NULL) {
conn->ctx.freeFunc(msg->ctx->ahandle);
}
@@ -200,22 +196,22 @@ static void cliReleaseUnfinishedMsg(SCliConn* conn) {
#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL)
#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrd*)(conn)->hostThrd)->pTransInst))->label)
-#define CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle) \
- do { \
- int i = 0, sz = transQueueSize(&conn->cliMsgs); \
- for (; i < sz; i++) { \
- pMsg = transQueueGet(&conn->cliMsgs, i); \
- if (pMsg != NULL && pMsg->ctx != NULL && (uint64_t)pMsg->ctx->ahandle == ahandle) { \
- break; \
- } \
- } \
- if (i == sz) { \
- pMsg = NULL; \
- tDebug("msg not found, %" PRIu64 "", ahandle); \
- } else { \
- pMsg = transQueueRm(&conn->cliMsgs, i); \
- tDebug("msg found, %" PRIu64 "", ahandle); \
- } \
+#define CONN_GET_MSGCTX_BY_AHANDLE(conn, ahandle) \
+ do { \
+ int i = 0, sz = transQueueSize(&conn->cliMsgs); \
+ for (; i < sz; i++) { \
+ pMsg = transQueueGet(&conn->cliMsgs, i); \
+ if (pMsg->ctx != NULL && (uint64_t)pMsg->ctx->ahandle == ahandle) { \
+ break; \
+ } \
+ } \
+ if (i == sz) { \
+ pMsg = NULL; \
+ tDebug("msg not found, %" PRIu64 "", ahandle); \
+ } else { \
+ pMsg = transQueueRm(&conn->cliMsgs, i); \
+ tDebug("msg found, %" PRIu64 "", ahandle); \
+ } \
} while (0)
#define CONN_GET_NEXT_SENDMSG(conn) \
do { \
@@ -293,7 +289,12 @@ bool cliMaySendCachedMsg(SCliConn* conn) {
if (!transQueueEmpty(&conn->cliMsgs)) {
SCliMsg* pCliMsg = NULL;
CONN_GET_NEXT_SENDMSG(conn);
- cliSend(conn);
+ if (pCliMsg == NULL)
+ return false;
+ else {
+ cliSend(conn);
+ return true;
+ }
}
return false;
_RETURN:
@@ -380,8 +381,10 @@ void cliHandleResp(SCliConn* conn) {
return;
}
- if (cliAppCb(conn, &transMsg, pMsg) != 0) {
- return;
+ if (pMsg == NULL || (pMsg && pMsg->type != Release)) {
+ if (cliAppCb(conn, &transMsg, pMsg) != 0) {
+ return;
+ }
}
destroyCmsg(pMsg);
@@ -429,17 +432,20 @@ void cliHandleExceptImpl(SCliConn* pConn, int32_t code) {
transMsg.info.ahandle);
}
} else {
- transMsg.info.ahandle = pCtx ? pCtx->ahandle : NULL;
+ transMsg.info.ahandle = (pMsg->type != Release && pCtx) ? pCtx->ahandle : NULL;
}
if (pCtx == NULL || pCtx->pSem == NULL) {
if (transMsg.info.ahandle == NULL) {
+ if (REQUEST_NO_RESP(&pMsg->msg) || pMsg->type == Release) destroyCmsg(pMsg);
once = true;
continue;
}
}
- if (cliAppCb(pConn, &transMsg, pMsg) != 0) {
- return;
+ if (pMsg == NULL || (pMsg && pMsg->type != Release)) {
+ if (cliAppCb(pConn, &transMsg, pMsg) != 0) {
+ return;
+ }
}
destroyCmsg(pMsg);
tTrace("%s conn %p start to destroy, ref:%d", CONN_GET_INST_LABEL(pConn), pConn, T_REF_VAL_GET(pConn));
@@ -705,6 +711,9 @@ static bool cliHandleNoResp(SCliConn* conn) {
if (cliMaySendCachedMsg(conn) == false) {
SCliThrd* thrd = conn->hostThrd;
addConnToPool(thrd->pool, conn);
+ res = false;
+ } else {
+ res = true;
}
}
}
@@ -782,7 +791,13 @@ void cliSend(SCliConn* pConn) {
uv_buf_t wb = uv_buf_init((char*)pHead, msgLen);
uv_write_t* req = transReqQueuePush(&pConn->wreqQueue);
- uv_write(req, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb);
+
+ int status = uv_write(req, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb);
+ if (status != 0) {
+ tGError("%s conn %p failed to sent msg:%s, errmsg:%s", CONN_GET_INST_LABEL(pConn), pConn, TMSG_INFO(pMsg->msgType),
+ uv_err_name(status));
+ cliHandleExcept(pConn);
+ }
return;
_RETURN:
return;
@@ -885,26 +900,23 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrd* pThrd, bool* ignore) {
}
return conn;
}
-void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) {
+FORCE_INLINE void cliMayCvtFqdnToIp(SEpSet* pEpSet, SCvtAddr* pCvtAddr) {
if (pCvtAddr->cvt == false) {
return;
}
- for (int i = 0; i < pEpSet->numOfEps && pEpSet->numOfEps == 1; i++) {
- if (strncmp(pEpSet->eps[i].fqdn, pCvtAddr->fqdn, TSDB_FQDN_LEN) == 0) {
- memset(pEpSet->eps[i].fqdn, 0, TSDB_FQDN_LEN);
- memcpy(pEpSet->eps[i].fqdn, pCvtAddr->ip, TSDB_FQDN_LEN);
- }
+ if (pEpSet->numOfEps == 1 && strncmp(pEpSet->eps[0].fqdn, pCvtAddr->fqdn, TSDB_FQDN_LEN) == 0) {
+ memset(pEpSet->eps[0].fqdn, 0, TSDB_FQDN_LEN);
+ memcpy(pEpSet->eps[0].fqdn, pCvtAddr->ip, TSDB_FQDN_LEN);
}
}
-bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) {
+FORCE_INLINE bool cliIsEpsetUpdated(int32_t code, STransConnCtx* pCtx) {
if (code != 0) return false;
if (pCtx->retryCnt == 0) return false;
if (transEpSetIsEqual(&pCtx->epSet, &pCtx->origEpSet)) return false;
return true;
}
-
-int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
+FORCE_INLINE int32_t cliBuildExceptResp(SCliMsg* pMsg, STransMsg* pResp) {
if (pMsg == NULL) return -1;
memset(pResp, 0, sizeof(STransMsg));
@@ -934,7 +946,9 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
// persist conn already release by server
STransMsg resp;
cliBuildExceptResp(pMsg, &resp);
- pTransInst->cfp(pTransInst->parent, &resp, NULL);
+ if (pMsg->type != Release) {
+ pTransInst->cfp(pTransInst->parent, &resp, NULL);
+ }
destroyCmsg(pMsg);
return;
}
@@ -980,6 +994,8 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrd* pThrd) {
return;
}
}
+ STraceId* trace = &pMsg->msg.info.traceId;
+ tGTrace("%s conn %p ready", pTransInst->label, conn);
}
static void cliAsyncCb(uv_async_t* handle) {
SAsyncItem* item = handle->data;
@@ -1128,14 +1144,15 @@ void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads,
return cli;
}
-static void destroyUserdata(STransMsg* userdata) {
+static FORCE_INLINE void destroyUserdata(STransMsg* userdata) {
if (userdata->pCont == NULL) {
return;
}
transFreeMsg(userdata->pCont);
userdata->pCont = NULL;
}
-static void destroyCmsg(void* arg) {
+
+static FORCE_INLINE void destroyCmsg(void* arg) {
SCliMsg* pMsg = arg;
if (pMsg == NULL) {
return;
@@ -1201,7 +1218,7 @@ static void destroyThrdObj(SCliThrd* pThrd) {
taosMemoryFree(pThrd);
}
-static void transDestroyConnCtx(STransConnCtx* ctx) {
+static FORCE_INLINE void transDestroyConnCtx(STransConnCtx* ctx) {
//
taosMemoryFree(ctx);
}
@@ -1220,7 +1237,7 @@ void cliWalkCb(uv_handle_t* handle, void* arg) {
}
}
-int cliRBChoseIdx(STrans* pTransInst) {
+FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst) {
int8_t index = pTransInst->index;
if (pTransInst->numOfThreads == 0) {
return -1;
@@ -1230,7 +1247,7 @@ int cliRBChoseIdx(STrans* pTransInst) {
}
return index % pTransInst->numOfThreads;
}
-static void doDelayTask(void* param) {
+static FORCE_INLINE void doDelayTask(void* param) {
STaskArg* arg = param;
SCliMsg* pMsg = arg->param1;
SCliThrd* pThrd = arg->param2;
@@ -1264,13 +1281,13 @@ static void cliSchedMsgToNextNode(SCliMsg* pMsg, SCliThrd* pThrd) {
transDQSched(pThrd->delayQueue, doDelayTask, arg, TRANS_RETRY_INTERVAL);
}
-void cliCompareAndSwap(int8_t* val, int8_t exp, int8_t newVal) {
+FORCE_INLINE void cliCompareAndSwap(int8_t* val, int8_t exp, int8_t newVal) {
if (*val != exp) {
*val = newVal;
}
}
-bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
+FORCE_INLINE bool cliTryExtractEpSet(STransMsg* pResp, SEpSet* dst) {
if ((pResp == NULL || pResp->info.hasEpSet == 0)) {
return false;
}
@@ -1300,7 +1317,7 @@ int cliAppCb(SCliConn* pConn, STransMsg* pResp, SCliMsg* pMsg) {
STrans* pTransInst = pThrd->pTransInst;
if (pMsg == NULL || pMsg->ctx == NULL) {
- tTrace("%s conn %p handle resp", pTransInst->label, pConn);
+ tDebug("%s conn %p handle resp", pTransInst->label, pConn);
pTransInst->cfp(pTransInst->parent, pResp, NULL);
return 0;
}
@@ -1402,53 +1419,57 @@ void transUnrefCliHandle(void* handle) {
cliDestroyConn((SCliConn*)handle, true);
}
}
-SCliThrd* transGetWorkThrdFromHandle(int64_t handle, bool* validHandle) {
+static FORCE_INLINE SCliThrd* transGetWorkThrdFromHandle(STrans* trans, int64_t handle) {
SCliThrd* pThrd = NULL;
SExHandle* exh = transAcquireExHandle(transGetRefMgt(), handle);
if (exh == NULL) {
return NULL;
}
- *validHandle = true;
+ if (exh->pThrd == NULL && trans != NULL) {
+ int idx = cliRBChoseIdx(trans);
+ if (idx < 0) return NULL;
+ exh->pThrd = ((SCliObj*)trans->tcphandle)->pThreadObj[idx];
+ }
+
pThrd = exh->pThrd;
transReleaseExHandle(transGetRefMgt(), handle);
return pThrd;
}
-SCliThrd* transGetWorkThrd(STrans* trans, int64_t handle, bool* validHandle) {
+SCliThrd* transGetWorkThrd(STrans* trans, int64_t handle) {
if (handle == 0) {
int idx = cliRBChoseIdx(trans);
if (idx < 0) return NULL;
return ((SCliObj*)trans->tcphandle)->pThreadObj[idx];
}
- SCliThrd* pThrd = transGetWorkThrdFromHandle(handle, validHandle);
- if (*validHandle == true && pThrd == NULL) {
- int idx = cliRBChoseIdx(trans);
- if (idx < 0) return NULL;
- pThrd = ((SCliObj*)trans->tcphandle)->pThreadObj[idx];
- }
+ SCliThrd* pThrd = transGetWorkThrdFromHandle(trans, handle);
return pThrd;
}
int transReleaseCliHandle(void* handle) {
int idx = -1;
bool valid = false;
- SCliThrd* pThrd = transGetWorkThrdFromHandle((int64_t)handle, &valid);
+ SCliThrd* pThrd = transGetWorkThrdFromHandle(NULL, (int64_t)handle);
if (pThrd == NULL) {
return -1;
}
- STransMsg tmsg = {.info.handle = handle};
+ STransMsg tmsg = {.info.handle = handle, .info.ahandle = (void*)0x9527};
TRACE_SET_MSGID(&tmsg.info.traceId, tGenIdPI64());
+ STransConnCtx* pCtx = taosMemoryCalloc(1, sizeof(STransConnCtx));
+ pCtx->ahandle = tmsg.info.ahandle;
+
SCliMsg* cmsg = taosMemoryCalloc(1, sizeof(SCliMsg));
cmsg->msg = tmsg;
cmsg->type = Release;
+ cmsg->ctx = pCtx;
STraceId* trace = &tmsg.info.traceId;
tGDebug("send release request at thread:%08" PRId64 "", pThrd->pid);
if (0 != transAsyncSend(pThrd->asyncPool, &cmsg->q)) {
- taosMemoryFree(cmsg);
+ destroyCmsg(cmsg);
return -1;
}
return 0;
@@ -1461,9 +1482,8 @@ int transSendRequest(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STran
return -1;
}
- bool valid = false;
- SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle, &valid);
- if (pThrd == NULL && valid == false) {
+ SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
+ if (pThrd == NULL) {
transFreeMsg(pReq->pCont);
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
return TSDB_CODE_RPC_BROKEN_LINK;
@@ -1506,9 +1526,8 @@ int transSendRecv(void* shandle, const SEpSet* pEpSet, STransMsg* pReq, STransMs
return -1;
}
- bool valid = false;
- SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle, &valid);
- if (pThrd == NULL && valid == false) {
+ SCliThrd* pThrd = transGetWorkThrd(pTransInst, (int64_t)pReq->info.handle);
+ if (pThrd == NULL) {
transFreeMsg(pReq->pCont);
transReleaseExHandle(transGetInstMgt(), (int64_t)shandle);
return TSDB_CODE_RPC_BROKEN_LINK;
@@ -1592,6 +1611,7 @@ int64_t transAllocHandle() {
SExHandle* exh = taosMemoryCalloc(1, sizeof(SExHandle));
exh->refId = transAddExHandle(transGetRefMgt(), exh);
tDebug("pre alloc refId %" PRId64 "", exh->refId);
+
return exh->refId;
}
#endif
diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c
index a4d679b281..5f3171ee0e 100644
--- a/source/libs/transport/src/transComm.c
+++ b/source/libs/transport/src/transComm.c
@@ -287,10 +287,10 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) {
STransCtxVal* sVal = (STransCtxVal*)iter;
key = taosHashGetKey(sVal, &klen);
- STransCtxVal* dVal = taosHashGet(dst->args, key, klen);
- if (dVal) {
- dst->freeFunc(dVal->val);
- }
+ // STransCtxVal* dVal = taosHashGet(dst->args, key, klen);
+ // if (dVal) {
+ // dst->freeFunc(dVal->val);
+ // }
taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal));
iter = taosHashIterate(src->args, iter);
}
@@ -424,7 +424,7 @@ void transQueueDestroy(STransQueue* queue) {
taosArrayDestroy(queue->q);
}
-static int32_t timeCompare(const HeapNode* a, const HeapNode* b) {
+static FORCE_INLINE int32_t timeCompare(const HeapNode* a, const HeapNode* b) {
SDelayTask* arg1 = container_of(a, SDelayTask, node);
SDelayTask* arg2 = container_of(b, SDelayTask, node);
if (arg1->execTime > arg2->execTime) {
diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c
index 7007079f87..d3277d1cc1 100644
--- a/source/libs/transport/src/transSvr.c
+++ b/source/libs/transport/src/transSvr.c
@@ -125,17 +125,17 @@ static void uvWorkAfterTask(uv_work_t* req, int status);
static void uvWalkCb(uv_handle_t* handle, void* arg);
static void uvFreeCb(uv_handle_t* handle);
-static void uvStartSendRespImpl(SSvrMsg* smsg);
+static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg);
+
static void uvPrepareSendData(SSvrMsg* msg, uv_buf_t* wb);
static void uvStartSendResp(SSvrMsg* msg);
static void uvNotifyLinkBrokenToApp(SSvrConn* conn);
-static void destroySmsg(SSvrMsg* smsg);
-// check whether already read complete packet
-static SSvrConn* createConn(void* hThrd);
-static void destroyConn(SSvrConn* conn, bool clear /*clear handle or not*/);
-static void destroyConnRegArg(SSvrConn* conn);
+static FORCE_INLINE void destroySmsg(SSvrMsg* smsg);
+static FORCE_INLINE SSvrConn* createConn(void* hThrd);
+static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear /*clear handle or not*/);
+static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn);
static int reallocConnRef(SSvrConn* conn);
@@ -413,7 +413,7 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) {
wb->len = len;
}
-static void uvStartSendRespImpl(SSvrMsg* smsg) {
+static FORCE_INLINE void uvStartSendRespImpl(SSvrMsg* smsg) {
SSvrConn* pConn = smsg->pConn;
if (pConn->broken) {
return;
@@ -447,7 +447,7 @@ static void uvStartSendResp(SSvrMsg* smsg) {
return;
}
-static void destroySmsg(SSvrMsg* smsg) {
+static FORCE_INLINE void destroySmsg(SSvrMsg* smsg) {
if (smsg == NULL) {
return;
}
@@ -812,7 +812,7 @@ void* transWorkerThread(void* arg) {
return NULL;
}
-static SSvrConn* createConn(void* hThrd) {
+static FORCE_INLINE SSvrConn* createConn(void* hThrd) {
SWorkThrd* pThrd = hThrd;
SSvrConn* pConn = (SSvrConn*)taosMemoryCalloc(1, sizeof(SSvrConn));
@@ -842,7 +842,7 @@ static SSvrConn* createConn(void* hThrd) {
return pConn;
}
-static void destroyConn(SSvrConn* conn, bool clear) {
+static FORCE_INLINE void destroyConn(SSvrConn* conn, bool clear) {
if (conn == NULL) {
return;
}
@@ -854,7 +854,7 @@ static void destroyConn(SSvrConn* conn, bool clear) {
}
}
}
-static void destroyConnRegArg(SSvrConn* conn) {
+static FORCE_INLINE void destroyConnRegArg(SSvrConn* conn) {
if (conn->regArg.init == 1) {
transFreeMsg(conn->regArg.msg.pCont);
conn->regArg.init = 0;
@@ -907,7 +907,7 @@ static void uvDestroyConn(uv_handle_t* handle) {
}
static void uvPipeListenCb(uv_stream_t* handle, int status) {
if (status != 0) {
- tError("server failed to init pipe");
+ tError("server failed to init pipe, errmsg: %s", uv_err_name(status));
return;
}
@@ -945,7 +945,10 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
uv_loop_init(srv->loop);
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
- assert(ret == 0);
+ if (ret != 0) {
+ tError("failed to init pipe, errmsg: %s", uv_err_name(ret));
+ goto End;
+ }
#ifdef WINDOWS
char pipeName[64];
@@ -956,10 +959,16 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
taosGetSelfPthreadId());
#endif
ret = uv_pipe_bind(&srv->pipeListen, pipeName);
- assert(ret == 0);
+ if (ret != 0) {
+ tError("failed to bind pipe, errmsg: %s", uv_err_name(ret));
+ goto End;
+ }
ret = uv_listen((uv_stream_t*)&srv->pipeListen, SOMAXCONN, uvPipeListenCb);
- assert(ret == 0);
+ if (ret != 0) {
+ tError("failed to listen pipe, errmsg: %s", uv_err_name(ret));
+ goto End;
+ }
for (int i = 0; i < srv->numOfThreads; i++) {
SWorkThrd* thrd = (SWorkThrd*)taosMemoryCalloc(1, sizeof(SWorkThrd));
@@ -1082,12 +1091,12 @@ void transCloseServer(void* arg) {
if (srv->inited) {
uv_async_send(srv->pAcceptAsync);
taosThreadJoin(srv->thread, NULL);
- }
- SRV_RELEASE_UV(srv->loop);
+ SRV_RELEASE_UV(srv->loop);
- for (int i = 0; i < srv->numOfThreads; i++) {
- sendQuitToWorkThrd(srv->pThreadObj[i]);
- destroyWorkThrd(srv->pThreadObj[i]);
+ for (int i = 0; i < srv->numOfThreads; i++) {
+ sendQuitToWorkThrd(srv->pThreadObj[i]);
+ destroyWorkThrd(srv->pThreadObj[i]);
+ }
}
taosMemoryFree(srv->pThreadObj);
diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c
index 9db7d6c455..5c437e6f7a 100644
--- a/source/libs/wal/src/walRead.c
+++ b/source/libs/wal/src/walRead.c
@@ -168,6 +168,9 @@ static int32_t walReadChangeFile(SWalReader *pReader, int64_t fileFirstVer) {
}
pReader->pIdxFile = pIdxFile;
+
+ pReader->curFileFirstVer = fileFirstVer;
+
return 0;
}
@@ -372,7 +375,7 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver, SWalCkHead *pHead) {
int32_t walSkipFetchBody(SWalReader *pRead, const SWalCkHead *pHead) {
int64_t code;
-// ASSERT(pRead->curVersion == pHead->head.version);
+ // ASSERT(pRead->curVersion == pHead->head.version);
code = taosLSeekFile(pRead->pLogFile, pHead->head.bodyLen, SEEK_CUR);
if (code < 0) {
@@ -415,7 +418,8 @@ int32_t walFetchBody(SWalReader *pRead, SWalCkHead **ppHead) {
}
if (walValidBodyCksum(*ppHead) != 0) {
- wError("vgId:%d, wal fetch body error, index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId, ver);
+ wError("vgId:%d, wal fetch body error, index:%" PRId64 ", since body checksum not passed", pRead->pWal->cfg.vgId,
+ ver);
pRead->curInvalid = 1;
terrno = TSDB_CODE_WAL_FILE_CORRUPTED;
return -1;
diff --git a/source/util/src/terror.c b/source/util/src/terror.c
index 3117152af6..044cdc86b4 100644
--- a/source/util/src/terror.c
+++ b/source/util/src/terror.c
@@ -618,6 +618,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_REMOVE_EXISTS, "Rsma remove exists"
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_FETCH_MSG_MSSED_UP, "Rsma fetch msg is messed up")
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_EMPTY_INFO, "Rsma info is empty")
TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_SCHEMA, "Rsma invalid schema")
+TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_REGEX_MATCH, "Rsma regex match")
//index
TAOS_DEFINE_ERROR(TSDB_CODE_INDEX_REBUILDING, "Index is rebuilding")
diff --git a/source/util/src/trbtree.c b/source/util/src/trbtree.c
index 0970485dad..65f1bac60a 100644
--- a/source/util/src/trbtree.c
+++ b/source/util/src/trbtree.c
@@ -13,179 +13,297 @@
* along with this program. If not, see .
*/
-#include "os.h"
+#include "trbtree.h"
-typedef int32_t (*tRBTreeCmprFn)(void *, void *);
-
-typedef struct SRBTree SRBTree;
-typedef struct SRBTreeNode SRBTreeNode;
-typedef struct SRBTreeIter SRBTreeIter;
-
-struct SRBTreeNode {
- enum { RED, BLACK } color;
- SRBTreeNode *parent;
- SRBTreeNode *left;
- SRBTreeNode *right;
- uint8_t payload[];
-};
-
-struct SRBTree {
- tRBTreeCmprFn cmprFn;
- SRBTreeNode *root;
-};
-
-struct SRBTreeIter {
- SRBTree *pTree;
-};
-
-#define RBTREE_NODE_COLOR(N) ((N) ? (N)->color : BLACK)
-
-// APIs ================================================
-static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *pNode) {
- SRBTreeNode *right = pNode->right;
-
- pNode->right = right->left;
- if (pNode->right) {
- pNode->right->parent = pNode;
+static void tRBTreeRotateLeft(SRBTree *pTree, SRBTreeNode *x) {
+ SRBTreeNode *y = x->right;
+ x->right = y->left;
+ if (y->left != pTree->NIL) {
+ y->left->parent = x;
}
-
- right->parent = pNode->parent;
- if (pNode->parent == NULL) {
- pTree->root = right;
- } else if (pNode == pNode->parent->left) {
- pNode->parent->left = right;
+ y->parent = x->parent;
+ if (x->parent == pTree->NIL) {
+ pTree->root = y;
+ } else if (x == x->parent->left) {
+ x->parent->left = y;
} else {
- pNode->parent->right = right;
+ x->parent->right = y;
}
-
- right->left = pNode;
- pNode->parent = right;
+ y->left = x;
+ x->parent = y;
}
-static void tRBTreeRotateRight(SRBTree *pTree, SRBTreeNode *pNode) {
- SRBTreeNode *left = pNode->left;
-
- pNode->left = left->right;
- if (pNode->left) {
- pNode->left->parent = pNode;
+static void tRBTreeRotateRight(SRBTree *pTree, SRBTreeNode *x) {
+ SRBTreeNode *y = x->left;
+ x->left = y->right;
+ if (y->right != pTree->NIL) {
+ y->right->parent = x;
}
-
- left->parent = pNode->parent;
- if (pNode->parent == NULL) {
- pTree->root = left;
- } else if (pNode == pNode->parent->left) {
- pNode->parent->left = left;
+ y->parent = x->parent;
+ if (x->parent == pTree->NIL) {
+ pTree->root = y;
+ } else if (x == x->parent->right) {
+ x->parent->right = y;
} else {
- pNode->parent->right = left;
+ x->parent->left = y;
}
-
- left->right = pNode;
- pNode->parent = left;
+ y->right = x;
+ x->parent = y;
}
-#define tRBTreeCreate(compare) \
- (SRBTree) { .cmprFn = (compare), .root = NULL }
+static void tRBTreePutFix(SRBTree *pTree, SRBTreeNode *z) {
+ while (z->parent->color == RED) {
+ if (z->parent == z->parent->parent->left) { // z.parent is the left child
-SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *pNew) {
- pNew->left = NULL;
- pNew->right = NULL;
- pNew->color = RED;
+ SRBTreeNode *y = z->parent->parent->right; // uncle of z
- // insert
- if (pTree->root == NULL) {
- pNew->parent = NULL;
- pTree->root = pNew;
- } else {
- SRBTreeNode *pNode = pTree->root;
- while (true) {
- ASSERT(pNode);
-
- int32_t c = pTree->cmprFn(pNew->payload, pNode->payload);
- if (c < 0) {
- if (pNode->left) {
- pNode = pNode->left;
- } else {
- pNew->parent = pNode;
- pNode->left = pNew;
- break;
- }
- } else if (c > 0) {
- if (pNode->right) {
- pNode = pNode->right;
- } else {
- pNew->parent = pNode;
- pNode->right = pNew;
- break;
+ if (y->color == RED) { // case 1
+ z->parent->color = BLACK;
+ y->color = BLACK;
+ z->parent->parent->color = RED;
+ z = z->parent->parent;
+ } else { // case2 or case3
+ if (z == z->parent->right) { // case2
+ z = z->parent; // marked z.parent as new z
+ tRBTreeRotateLeft(pTree, z);
}
+ // case3
+ z->parent->color = BLACK; // made parent black
+ z->parent->parent->color = RED; // made parent red
+ tRBTreeRotateRight(pTree, z->parent->parent);
+ }
+ } else { // z.parent is the right child
+ SRBTreeNode *y = z->parent->parent->left; // uncle of z
+
+ if (y->color == RED) {
+ z->parent->color = BLACK;
+ y->color = BLACK;
+ z->parent->parent->color = RED;
+ z = z->parent->parent;
} else {
- return NULL;
+ if (z == z->parent->left) {
+ z = z->parent; // marked z.parent as new z
+ tRBTreeRotateRight(pTree, z);
+ }
+ z->parent->color = BLACK; // made parent black
+ z->parent->parent->color = RED; // made parent red
+ tRBTreeRotateLeft(pTree, z->parent->parent);
}
}
}
+ pTree->root->color = BLACK;
+}
+
+static void tRBTreeTransplant(SRBTree *pTree, SRBTreeNode *u, SRBTreeNode *v) {
+ if (u->parent == pTree->NIL)
+ pTree->root = v;
+ else if (u == u->parent->left)
+ u->parent->left = v;
+ else
+ u->parent->right = v;
+ v->parent = u->parent;
+}
+
+static void tRBTreeDropFix(SRBTree *pTree, SRBTreeNode *x) {
+ while (x != pTree->root && x->color == BLACK) {
+ if (x == x->parent->left) {
+ SRBTreeNode *w = x->parent->right;
+ if (w->color == RED) {
+ w->color = BLACK;
+ x->parent->color = RED;
+ tRBTreeRotateLeft(pTree, x->parent);
+ w = x->parent->right;
+ }
+ if (w->left->color == BLACK && w->right->color == BLACK) {
+ w->color = RED;
+ x = x->parent;
+ } else {
+ if (w->right->color == BLACK) {
+ w->left->color = BLACK;
+ w->color = RED;
+ tRBTreeRotateRight(pTree, w);
+ w = x->parent->right;
+ }
+ w->color = x->parent->color;
+ x->parent->color = BLACK;
+ w->right->color = BLACK;
+ tRBTreeRotateLeft(pTree, x->parent);
+ x = pTree->root;
+ }
+ } else {
+ SRBTreeNode *w = x->parent->left;
+ if (w->color == RED) {
+ w->color = BLACK;
+ x->parent->color = RED;
+ tRBTreeRotateRight(pTree, x->parent);
+ w = x->parent->left;
+ }
+ if (w->right->color == BLACK && w->left->color == BLACK) {
+ w->color = RED;
+ x = x->parent;
+ } else {
+ if (w->left->color == BLACK) {
+ w->right->color = BLACK;
+ w->color = RED;
+ tRBTreeRotateLeft(pTree, w);
+ w = x->parent->left;
+ }
+ w->color = x->parent->color;
+ x->parent->color = BLACK;
+ w->left->color = BLACK;
+ tRBTreeRotateRight(pTree, x->parent);
+ x = pTree->root;
+ }
+ }
+ }
+ x->color = BLACK;
+}
+
+static SRBTreeNode *tRBTreeSuccessor(SRBTree *pTree, SRBTreeNode *pNode) {
+ if (pNode->right != pTree->NIL) {
+ pNode = pNode->right;
+ while (pNode->left != pTree->NIL) {
+ pNode = pNode->left;
+ }
+ } else {
+ while (true) {
+ if (pNode->parent == pTree->NIL || pNode == pNode->parent->left) {
+ pNode = pNode->parent;
+ break;
+ } else {
+ pNode = pNode->parent;
+ }
+ }
+ }
+
+ return pNode;
+}
+
+static SRBTreeNode *tRBTreePredecessor(SRBTree *pTree, SRBTreeNode *pNode) {
+ if (pNode->left != pTree->NIL) {
+ pNode = pNode->left;
+ while (pNode->right != pTree->NIL) {
+ pNode = pNode->right;
+ }
+ } else {
+ while (true) {
+ if (pNode->parent == pTree->NIL || pNode == pNode->parent->right) {
+ pNode = pNode->parent;
+ break;
+ } else {
+ pNode = pNode->parent;
+ }
+ }
+ }
+
+ return pNode;
+}
+
+void tRBTreeCreate(SRBTree *pTree, tRBTreeCmprFn cmprFn) {
+ pTree->cmprFn = cmprFn;
+ pTree->n = 0;
+ pTree->NIL = &pTree->NILNODE;
+ pTree->NIL->color = BLACK;
+ pTree->NIL->parent = NULL;
+ pTree->NIL->left = NULL;
+ pTree->NIL->right = NULL;
+ pTree->root = pTree->NIL;
+ pTree->min = pTree->NIL;
+ pTree->max = pTree->NIL;
+}
+
+SRBTreeNode *tRBTreePut(SRBTree *pTree, SRBTreeNode *z) {
+ SRBTreeNode *y = pTree->NIL; // variable for the parent of the added node
+ SRBTreeNode *temp = pTree->root;
+
+ while (temp != pTree->NIL) {
+ y = temp;
+
+ int32_t c = pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(temp));
+ if (c < 0) {
+ temp = temp->left;
+ } else if (c > 0) {
+ temp = temp->right;
+ } else {
+ return NULL;
+ }
+ }
+ z->parent = y;
+
+ if (y == pTree->NIL) {
+ pTree->root = z;
+ } else if (pTree->cmprFn(RBTREE_NODE_PAYLOAD(z), RBTREE_NODE_PAYLOAD(y)) < 0) {
+ y->left = z;
+ } else {
+ y->right = z;
+ }
+
+ z->color = RED;
+ z->left = pTree->NIL;
+ z->right = pTree->NIL;
+
+ tRBTreePutFix(pTree, z);
+
+ // update min/max node
+ if (pTree->min == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->min), RBTREE_NODE_PAYLOAD(z)) > 0) {
+ pTree->min = z;
+ }
+ if (pTree->max == pTree->NIL || pTree->cmprFn(RBTREE_NODE_PAYLOAD(pTree->max), RBTREE_NODE_PAYLOAD(z)) < 0) {
+ pTree->max = z;
+ }
+ pTree->n++;
+ return z;
+}
+
+void tRBTreeDrop(SRBTree *pTree, SRBTreeNode *z) {
+ SRBTreeNode *y = z;
+ SRBTreeNode *x;
+ ECOLOR y_orignal_color = y->color;
+
+ // update min/max node
+ if (pTree->min == z) {
+ pTree->min = tRBTreeSuccessor(pTree, pTree->min);
+ }
+ if (pTree->max == z) {
+ pTree->max = tRBTreePredecessor(pTree, pTree->max);
+ }
+
+ // drop impl
+ if (z->left == pTree->NIL) {
+ x = z->right;
+ tRBTreeTransplant(pTree, z, z->right);
+ } else if (z->right == pTree->NIL) {
+ x = z->left;
+ tRBTreeTransplant(pTree, z, z->left);
+ } else {
+ y = tRBTreeSuccessor(pTree, z);
+ y_orignal_color = y->color;
+ x = y->right;
+ if (y->parent == z) {
+ x->parent = z;
+ } else {
+ tRBTreeTransplant(pTree, y, y->right);
+ y->right = z->right;
+ y->right->parent = y;
+ }
+ tRBTreeTransplant(pTree, z, y);
+ y->left = z->left;
+ y->left->parent = y;
+ y->color = z->color;
+ }
// fix
- SRBTreeNode *pNode = pNew;
- while (pNode->parent && pNode->parent->color == RED) {
- SRBTreeNode *p = pNode->parent;
- SRBTreeNode *g = p->parent;
-
- if (p == g->left) {
- SRBTreeNode *u = g->right;
-
- if (RBTREE_NODE_COLOR(u) == RED) {
- p->color = BLACK;
- u->color = BLACK;
- g->color = RED;
- pNode = g;
- } else {
- if (pNode == p->right) {
- pNode = p;
- tRBTreeRotateLeft(pTree, pNode);
- }
- pNode->parent->color = BLACK;
- pNode->parent->parent->color = RED;
- tRBTreeRotateRight(pTree, pNode->parent->parent);
- }
- } else {
- SRBTreeNode *u = g->left;
-
- if (RBTREE_NODE_COLOR(u) == RED) {
- p->color = BLACK;
- u->color = BLACK;
- g->color = RED;
- } else {
- if (pNode == p->left) {
- pNode = p;
- tRBTreeRotateRight(pTree, pNode);
- }
- pNode->parent->color = BLACK;
- pNode->parent->parent->color = RED;
- tRBTreeRotateLeft(pTree, pNode->parent->parent);
- }
- }
+ if (y_orignal_color == BLACK) {
+ tRBTreeDropFix(pTree, x);
}
-
- pTree->root->color = BLACK;
- return pNew;
+ pTree->n--;
}
-SRBTreeNode *tRBTreeDrop(SRBTree *pTree, void *pKey) {
- SRBTreeNode *pNode = pTree->root;
-
- while (pNode) {
- int32_t c = pTree->cmprFn(pKey, pNode->payload);
-
- if (c < 0) {
- pNode = pNode->left;
- } else if (c > 0) {
- pNode = pNode->right;
- } else {
- break;
- }
- }
+SRBTreeNode *tRBTreeDropByKey(SRBTree *pTree, void *pKey) {
+ SRBTreeNode *pNode = tRBTreeGet(pTree, pKey);
if (pNode) {
- // TODO
+ tRBTreeDrop(pTree, pNode);
}
return pNode;
@@ -194,8 +312,8 @@ SRBTreeNode *tRBTreeDrop(SRBTree *pTree, void *pKey) {
SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey) {
SRBTreeNode *pNode = pTree->root;
- while (pNode) {
- int32_t c = pTree->cmprFn(pKey, pNode->payload);
+ while (pNode != pTree->NIL) {
+ int32_t c = pTree->cmprFn(pKey, RBTREE_NODE_PAYLOAD(pNode));
if (c < 0) {
pNode = pNode->left;
@@ -206,5 +324,23 @@ SRBTreeNode *tRBTreeGet(SRBTree *pTree, void *pKey) {
}
}
- return pNode;
+ return (pNode == pTree->NIL) ? NULL : pNode;
}
+
+// SRBTreeIter ================================================
+SRBTreeNode *tRBTreeIterNext(SRBTreeIter *pIter) {
+ SRBTreeNode *pNode = pIter->pNode;
+
+ if (pIter->pNode != pIter->pTree->NIL) {
+ if (pIter->asc) {
+ // ascend
+ pIter->pNode = tRBTreeSuccessor(pIter->pTree, pIter->pNode);
+ } else {
+ // descend
+ pIter->pNode = tRBTreePredecessor(pIter->pTree, pIter->pNode);
+ }
+ }
+
+_exit:
+ return (pNode == pIter->pTree->NIL) ? NULL : pNode;
+}
\ No newline at end of file
diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c
index 9101aec949..7460ccbc82 100644
--- a/source/util/src/tuuid.c
+++ b/source/util/src/tuuid.c
@@ -51,11 +51,11 @@ int64_t tGenIdPI64(void) {
int64_t id;
while (true) {
- int64_t ts = taosGetTimestampMs();
+ int64_t ts = taosGetTimestampMs() >> 8;
uint64_t pid = taosGetPId();
int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1);
- id = ((tUUIDHashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF);
+ id = ((tUUIDHashId & 0x07FF) << 52) | ((pid & 0x0F) << 48) | ((ts & 0x3FFFFFF) << 20) | (val & 0xFFFFF);
if (id) {
break;
}
diff --git a/source/util/test/CMakeLists.txt b/source/util/test/CMakeLists.txt
index d2a503e661..6e42ef7e75 100644
--- a/source/util/test/CMakeLists.txt
+++ b/source/util/test/CMakeLists.txt
@@ -75,4 +75,12 @@ target_link_libraries(taosbsearchTest os util gtest_main)
add_test(
NAME taosbsearchTest
COMMAND taosbsearchTest
+)
+
+# trbtreeTest
+add_executable(rbtreeTest "trbtreeTest.cpp")
+target_link_libraries(rbtreeTest os util gtest_main)
+add_test(
+ NAME rbtreeTest
+ COMMAND rbtreeTest
)
\ No newline at end of file
diff --git a/source/util/test/pageBufferTest.cpp b/source/util/test/pageBufferTest.cpp
index 1a057c5875..534c177587 100644
--- a/source/util/test/pageBufferTest.cpp
+++ b/source/util/test/pageBufferTest.cpp
@@ -23,9 +23,9 @@ void simpleTest() {
ASSERT_EQ(getTotalBufSize(pBuf), 1024);
- SIDList list = getDataBufPagesIdList(pBuf, groupId);
+ SIDList list = getDataBufPagesIdList(pBuf);
ASSERT_EQ(taosArrayGetSize(list), 1);
- ASSERT_EQ(getNumOfBufGroupId(pBuf), 1);
+ //ASSERT_EQ(getNumOfBufGroupId(pBuf), 1);
releaseBufPage(pBuf, pBufPage);
@@ -98,7 +98,7 @@ void writeDownTest() {
SFilePage* pBufPagex = static_cast(getBufPage(pBuf, writePageId));
ASSERT_EQ(*(int32_t*)pBufPagex->data, nx);
- SArray* pa = getDataBufPagesIdList(pBuf, groupId);
+ SArray* pa = getDataBufPagesIdList(pBuf);
ASSERT_EQ(taosArrayGetSize(pa), 5);
destroyDiskbasedBuf(pBuf);
@@ -152,7 +152,7 @@ void recyclePageTest() {
SFilePage* pBufPagex1 = static_cast(getBufPage(pBuf, 1));
- SArray* pa = getDataBufPagesIdList(pBuf, groupId);
+ SArray* pa = getDataBufPagesIdList(pBuf);
ASSERT_EQ(taosArrayGetSize(pa), 6);
destroyDiskbasedBuf(pBuf);
diff --git a/source/util/test/trbtreeTest.cpp b/source/util/test/trbtreeTest.cpp
new file mode 100644
index 0000000000..cabf315df0
--- /dev/null
+++ b/source/util/test/trbtreeTest.cpp
@@ -0,0 +1,40 @@
+#include
+
+#include
+#include
+
+#include "trbtree.h"
+
+static int32_t tCmprInteger(const void *p1, const void *p2) {
+ if (*(int *)p1 < *(int *)p2) {
+ return -1;
+ } else if (*(int *)p1 > *(int *)p2) {
+ return 1;
+ }
+ return 0;
+}
+
+TEST(trbtreeTest, rbtree_test1) {
+#if 0
+ SRBTree rt;
+ tRBTreeCreate(&rt, tCmprInteger);
+ int a[] = {1, 3, 4, 2, 7, 5, 8};
+
+ for (int i = 0; i < sizeof(a) / sizeof(a[0]); i++) {
+ SRBTreeNode *pNode = (SRBTreeNode *)taosMemoryMalloc(sizeof(*pNode) + sizeof(int));
+ *(int *)pNode->payload = a[i];
+
+ tRBTreePut(&rt, pNode);
+ }
+
+ SRBTreeIter rti = tRBTreeIterCreate(&rt, 1);
+ SRBTreeNode *pNode = tRBTreeIterNext(&rti);
+ int la = 0;
+ while (pNode) {
+ GTEST_ASSERT_GT(*(int *)pNode->payload, la);
+ la = *(int *)pNode->payload;
+ // printf("%d\n", la);
+ pNode = tRBTreeIterNext(&rti);
+ }
+#endif
+}
\ No newline at end of file
diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt
index 46bae734ea..161c878440 100644
--- a/tests/script/jenkins/basic.txt
+++ b/tests/script/jenkins/basic.txt
@@ -221,6 +221,7 @@
./test.sh -f tsim/table/describe.sim
./test.sh -f tsim/table/double.sim
./test.sh -f tsim/table/float.sim
+./test.sh -f tsim/table/hash.sim
./test.sh -f tsim/table/int.sim
./test.sh -f tsim/table/limit.sim
./test.sh -f tsim/table/smallint.sim
@@ -248,6 +249,12 @@
./test.sh -f tsim/stream/windowClose.sim
./test.sh -f tsim/stream/ignoreExpiredData.sim
./test.sh -f tsim/stream/sliding.sim
+#./test.sh -f tsim/stream/partitionbyColumnInterval.sim
+#./test.sh -f tsim/stream/partitionbyColumnSession.sim
+#./test.sh -f tsim/stream/partitionbyColumnState.sim
+#./test.sh -f tsim/stream/deleteInterval.sim
+#./test.sh -f tsim/stream/deleteSession.sim
+#./test.sh -f tsim/stream/deleteState.sim
# ---- transaction ----
./test.sh -f tsim/trans/lossdata1.sim
diff --git a/tests/script/sh/abs_max.c b/tests/script/sh/abs_max.c
deleted file mode 100644
index d623adacf9..0000000000
--- a/tests/script/sh/abs_max.c
+++ /dev/null
@@ -1,88 +0,0 @@
-#include
-#include
-#include
-
-typedef struct SUdfInit{
- int maybe_null; /* 1 if function can return NULL */
- int decimals; /* for real functions */
- long long length; /* For string functions */
- char *ptr; /* free pointer for function data */
- int const_item; /* 0 if result is independent of arguments */
-} SUdfInit;
-
-
-#define TSDB_DATA_INT_NULL 0x80000000LL
-#define TSDB_DATA_BIGINT_NULL 0x8000000000000000LL
-
-void abs_max(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput,
- int* numOfOutput, short otype, short obytes, SUdfInit* buf) {
- int i;
- int r = 0;
- printf("abs_max input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf);
- if (itype == 5) {
- r=*(long *)dataOutput;
- *numOfOutput=0;
-
- for(i=0;i r) {
- r = v;
- }
- }
-
- *(long *)dataOutput=r;
-
- printf("abs_max out, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
- }
-}
-
-
-
-void abs_max_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) {
- int i;
- int r = 0;
- printf("abs_max_finalize dataoutput:%p:%d, numOfOutput:%d, buf:%p\n", dataOutput, *dataOutput, *numOfOutput, buf);
- *numOfOutput=1;
- printf("abs_max finalize, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
-}
-
-void abs_max_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) {
- int r = 0;
-
- if (numOfRows > 0) {
- r = *((long *)data);
- }
- printf("abs_max_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf);
- for (int i = 1; i < numOfRows; ++i) {
- printf("abs_max_merge %d - %ld\n", i, *((long *)data + i));
- if (*((long*)data + i) > r) {
- r= *((long*)data + i);
- }
- }
-
- *(long*)dataOutput=r;
- if (numOfRows > 0) {
- *numOfOutput=1;
- } else {
- *numOfOutput=0;
- }
-
- printf("abs_max_merge, dataoutput:%ld, numOfOutput:%d\n", *(long *)dataOutput, *numOfOutput);
-}
-
-
-int abs_max_init(SUdfInit* buf) {
- printf("abs_max init\n");
- return 0;
-}
-
-
-void abs_max_destroy(SUdfInit* buf) {
- printf("abs_max destroy\n");
-}
-
diff --git a/tests/script/sh/add_one.c b/tests/script/sh/add_one.c
deleted file mode 100644
index e12cf8f26f..0000000000
--- a/tests/script/sh/add_one.c
+++ /dev/null
@@ -1,33 +0,0 @@
-#include
-#include
-#include
-
-typedef struct SUdfInit{
- int maybe_null; /* 1 if function can return NULL */
- int decimals; /* for real functions */
- long long length; /* For string functions */
- char *ptr; /* free pointer for function data */
- int const_item; /* 0 if result is independent of arguments */
-} SUdfInit;
-
-void add_one(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBUf, char* tsOutput,
- int* numOfOutput, short otype, short obytes, SUdfInit* buf) {
- int i;
- int r = 0;
- printf("add_one input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf);
- if (itype == 4) {
- for(i=0;i
-#include
-#include
-
-typedef struct SUdfInit{
- int maybe_null; /* 1 if function can return NULL */
- int decimals; /* for real functions */
- long long length; /* For string functions */
- char *ptr; /* free pointer for function data */
- int const_item; /* 0 if result is independent of arguments */
-} SUdfInit;
-
-typedef struct SDemo{
- double sum;
- int num;
- short otype;
-}SDemo;
-
-#define FLOAT_NULL 0x7FF00000 // it is an NAN
-#define DOUBLE_NULL 0x7FFFFF0000000000LL // it is an NAN
-
-
-void demo(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput,
- int* numOfOutput, short otype, short obytes, SUdfInit* buf) {
- int i;
- double r = 0;
- SDemo *p = (SDemo *)interBuf;
- SDemo *q = (SDemo *)dataOutput;
- printf("demo input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, interBUf:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, interBuf, tsOutput, numOfOutput, buf);
-
- for(i=0;isum += r*r;
- }
-
- p->otype = otype;
- p->num += numOfRows;
-
- q->sum = p->sum;
- q->num = p->num;
- q->otype = p->otype;
-
- *numOfOutput=1;
-
- printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput);
-}
-
-
-void demo_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) {
- int i;
- SDemo *p = (SDemo *)data;
- SDemo res = {0};
- printf("demo_merge input data:%p, rows:%d, dataoutput:%p, numOfOutput:%p, buf:%p\n", data, numOfRows, dataOutput, numOfOutput, buf);
-
- for(i=0;isum * p->sum;
- res.num += p->num;
- p++;
- }
-
- p->sum = res.sum;
- p->num = res.num;
-
- *numOfOutput=1;
-
- printf("demo out, sum:%f, num:%d, numOfOutput:%d\n", p->sum, p->num, *numOfOutput);
-}
-
-
-
-void demo_finalize(char* dataOutput, char* interBuf, int* numOfOutput, SUdfInit* buf) {
- SDemo *p = (SDemo *)interBuf;
- printf("demo_finalize interbuf:%p, numOfOutput:%p, buf:%p, sum:%f, num:%d\n", interBuf, numOfOutput, buf, p->sum, p->num);
- if (p->otype == 6) {
- if (p->num != 30000) {
- *(unsigned int *)dataOutput = FLOAT_NULL;
- } else {
- *(float *)dataOutput = (float)(p->sum / p->num);
- }
- printf("finalize values:%f\n", *(float *)dataOutput);
- } else if (p->otype == 7) {
- if (p->num != 30000) {
- *(unsigned long long *)dataOutput = DOUBLE_NULL;
- } else {
- *(double *)dataOutput = (double)(p->sum / p->num);
- }
- printf("finalize values:%f\n", *(double *)dataOutput);
- }
-
- *numOfOutput=1;
-
- printf("demo finalize, numOfOutput:%d\n", *numOfOutput);
-}
-
-
-int demo_init(SUdfInit* buf) {
- printf("demo init\n");
- return 0;
-}
-
-
-void demo_destroy(SUdfInit* buf) {
- printf("demo destroy\n");
-}
-
diff --git a/tests/script/sh/demo.lua b/tests/script/sh/demo.lua
deleted file mode 100644
index c5e5582fc3..0000000000
--- a/tests/script/sh/demo.lua
+++ /dev/null
@@ -1,43 +0,0 @@
-funcName = "test"
-
-global = {}
-
-function test_init()
- return global
-end
-
-function test_add(rows, ans, key)
- t = {}
- t["sum"] = 0.0
- t["num"] = 0
- for i=1, #rows do
- t["sum"] = t["sum"] + rows[i] * rows[i]
- end
- t["num"] = #rows
-
-
- if (ans[key] ~= nil)
- then
- ans[key]["sum"] = ans[key]["sum"] + t["sum"]
- ans[key]["num"] = ans[key]["num"] + t["num"]
- else
- ans[key] = t
- end
-
- return ans;
-end
-
-function test_finalize(ans, key)
- local ret = 0.0
-
- if (ans[key] ~= nil and ans[key]["num"] == 30000)
- then
- ret = ans[key]["sum"]/ans[key]["num"]
- ans[key]["sum"] = 0.0
- ans[key]["num"] = 0
- else
- ret = inf
- end
-
- return ret, ans
-end
diff --git a/tests/script/sh/sum_double.c b/tests/script/sh/sum_double.c
deleted file mode 100644
index d6eea5d291..0000000000
--- a/tests/script/sh/sum_double.c
+++ /dev/null
@@ -1,84 +0,0 @@
-#include
-#include
-#include
-
-typedef struct SUdfInit{
- int maybe_null; /* 1 if function can return NULL */
- int decimals; /* for real functions */
- long long length; /* For string functions */
- char *ptr; /* free pointer for function data */
- int const_item; /* 0 if result is independent of arguments */
-} SUdfInit;
-
-#define TSDB_DATA_INT_NULL 0x80000000LL
-
-
-void sum_double(char* data, short itype, short ibytes, int numOfRows, long long* ts, char* dataOutput, char* interBuf, char* tsOutput,
- int* numOfOutput, short otype, short obytes, SUdfInit* buf) {
- int i;
- int r = 0;
- printf("sum_double input data:%p, type:%d, rows:%d, ts:%p,%lld, dataoutput:%p, tsOutput:%p, numOfOutput:%p, buf:%p\n", data, itype, numOfRows, ts, *ts, dataOutput, tsOutput, numOfOutput, buf);
- if (itype == 4) {
- r=*(int *)dataOutput;
- *numOfOutput=0;
-
- for(i=0;iptr)=*(int*)dataOutput*2;
- *(int*)dataOutput=*(int*)(buf->ptr);
- printf("sum_double finalize, dataoutput:%d, numOfOutput:%d\n", *(int *)dataOutput, *numOfOutput);
-}
-
-void sum_double_merge(char* data, int32_t numOfRows, char* dataOutput, int32_t* numOfOutput, SUdfInit* buf) {
- int r = 0;
- int sum = 0;
-
- printf("sum_double_merge numOfRows:%d, dataoutput:%p, buf:%p\n", numOfRows, dataOutput, buf);
- for (int i = 0; i < numOfRows; ++i) {
- printf("sum_double_merge %d - %d\n", i, *((int*)data + i));
- sum +=*((int*)data + i);
- }
-
- *(int*)dataOutput+=sum;
- if (numOfRows > 0) {
- *numOfOutput=1;
- } else {
- *numOfOutput=0;
- }
-
- printf("sum_double_merge, dataoutput:%d, numOfOutput:%d\n", *(int *)dataOutput, *numOfOutput);
-}
-
-
-int sum_double_init(SUdfInit* buf) {
- buf->maybe_null=1;
- buf->ptr = taosMemoryMalloc(sizeof(int));
- printf("sum_double init\n");
- return 0;
-}
-
-
-void sum_double_destroy(SUdfInit* buf) {
- taosMemoryFree(buf->ptr);
- printf("sum_double destroy\n");
-}
-
diff --git a/tests/script/tsim/column/table.sim b/tests/script/tsim/column/table.sim
index 4f1d32c373..03c4799681 100644
--- a/tests/script/tsim/column/table.sim
+++ b/tests/script/tsim/column/table.sim
@@ -159,6 +159,7 @@ if $data01 != 10 then
return -1
endi
if $data02 != 4.500000000 then
+ print expect 4.500000000, actual: $data02
return -1
endi
if $data03 != 4.500000000 then
diff --git a/tests/script/tsim/db/basic1.sim b/tests/script/tsim/db/basic1.sim
index 3f6bf05398..5d7d0bd9e9 100644
--- a/tests/script/tsim/db/basic1.sim
+++ b/tests/script/tsim/db/basic1.sim
@@ -133,10 +133,10 @@ if $data(4)[5] != localhost:7100 then
return -1
endi
-#sql show vnodes 'localhost:7100'
-#if $rows != 9 then
-# return -1
-#endi
+sql show vnodes 'localhost:7100'
+if $rows != 9 then
+ return -1
+endi
print =============== drop database
sql drop database d2
diff --git a/tests/script/tsim/parser/commit.sim b/tests/script/tsim/parser/commit.sim
index ae19a4803b..a9bf8b26eb 100644
--- a/tests/script/tsim/parser/commit.sim
+++ b/tests/script/tsim/parser/commit.sim
@@ -97,6 +97,7 @@ while $loop <= $loops
endw
sql select count(*) from $stb
if $data00 != $totalNum then
+ print expect $totalNum , actual: $data00
return -1
endi
$loop = $loop + 1
diff --git a/tests/script/tsim/parser/slimit_alter_tags.sim b/tests/script/tsim/parser/slimit_alter_tags.sim
index 3827b14b45..b5afbfa56e 100644
--- a/tests/script/tsim/parser/slimit_alter_tags.sim
+++ b/tests/script/tsim/parser/slimit_alter_tags.sim
@@ -128,6 +128,7 @@ if $rows != 5 then
return -1
endi
if $data00 != $rowNum then
+ print expect $rowNum , actual: $data00
return -1
endi
if $data10 != $rowNum then
diff --git a/tests/script/tsim/stream/basic1.sim b/tests/script/tsim/stream/basic1.sim
index d9777d5133..8942f7f702 100644
--- a/tests/script/tsim/stream/basic1.sim
+++ b/tests/script/tsim/stream/basic1.sim
@@ -5,7 +5,7 @@ sleep 50
sql connect
print =============== create database
-sql create database test vgroups 1
+sql create database test vgroups 1;
sql select * from information_schema.ins_databases
if $rows != 3 then
return -1
@@ -13,7 +13,7 @@ endi
print $data00 $data01 $data02
-sql use test
+sql use test;
sql create table t1(ts timestamp, a int, b int , c int, d double);
@@ -588,4 +588,38 @@ if $data00 != 5 then
goto loop3
endi
+#max,min selectivity
+sql create database test3 vgroups 1;
+sql use test3;
+sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
+sql create table ts1 using st tags(1,1,1);
+sql create stream stream_t3 trigger at_once into streamtST3 as select ts, min(a) c6, a, b, c, ta, tb, tc from ts1 interval(10s) ;
+
+sql insert into ts1 values(1648791211000,1,2,3);
+sleep 50
+sql insert into ts1 values(1648791222001,2,2,3);
+sleep 50
+
+$loop_count = 0
+loop3:
+sql select * from streamtST3;
+
+sleep 300
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+# row 0
+if $data02 != 1 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+# row 1
+if $data12 != 2 then
+ print =====data12=$data12
+ goto loop3
+endi
+
system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/stream/deleteInterval.sim b/tests/script/tsim/stream/deleteInterval.sim
new file mode 100644
index 0000000000..dfd0ddc9d3
--- /dev/null
+++ b/tests/script/tsim/stream/deleteInterval.sim
@@ -0,0 +1,419 @@
+$loop_all = 0
+looptest:
+
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sleep 200
+sql connect
+
+sql drop stream if exists streams0;
+sql drop stream if exists streams1;
+sql drop stream if exists streams2;
+sql drop stream if exists streams3;
+sql drop stream if exists streams4;
+sql drop database if exists test;
+sql create database test vgroups 1;
+sql use test;
+sql create table t1(ts timestamp, a int, b int , c int, d double);
+sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from t1 interval(10s);
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+sleep 200
+sql delete from t1 where ts = 1648791213000;
+
+$loop_count = 0
+
+loop0:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 0 then
+ print =====rows=$rows
+ goto loop0
+endi
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+
+$loop_count = 0
+
+loop1:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop1
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213001,2,2,2,2.0);
+sql insert into t1 values(1648791213002,3,3,3,3.0);
+sql insert into t1 values(1648791213003,4,4,4,4.0);
+
+sleep 200
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791213002;
+
+$loop_count = 0
+
+loop3:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+sql insert into t1 values(1648791223000,1,2,3,1.0);
+sql insert into t1 values(1648791223001,1,2,3,1.0);
+sql insert into t1 values(1648791223002,3,2,3,1.0);
+sql insert into t1 values(1648791223003,3,2,3,1.0);
+
+$loop_count = 0
+
+loop4:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop4
+endi
+
+sleep 200
+
+sql delete from t1 where ts >= 1648791223000 and ts <= 1648791223003;
+
+$loop_count = 0
+
+loop5:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop5
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop5
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213005,2,2,2,2.0);
+sql insert into t1 values(1648791213006,3,3,3,3.0);
+sql insert into t1 values(1648791213007,4,4,4,4.0);
+
+sql insert into t1 values(1648791223000,1,1,1,1.0);
+sql insert into t1 values(1648791223001,2,2,2,2.0);
+sql insert into t1 values(1648791223002,3,3,3,3.0);
+sql insert into t1 values(1648791223003,4,4,4,4.0);
+
+sql insert into t1 values(1648791233000,1,1,1,1.0);
+sql insert into t1 values(1648791233001,2,2,2,2.0);
+sql insert into t1 values(1648791233008,3,3,3,3.0);
+sql insert into t1 values(1648791233009,4,4,4,4.0);
+
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791233005;
+
+$loop_count = 0
+
+loop6:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop6
+endi
+
+if $data02 != 1 then
+ print =====data02=$data02
+ goto loop6
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop6
+endi
+
+if $data12 != 4 then
+ print =====data12=$data12
+ goto loop6
+endi
+
+sql drop stream if exists streams2;
+sql drop database if exists test2;
+sql create database test2 vgroups 4;
+sql use test2;
+sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+sql create stream streams2 trigger at_once into test.streamt2 as select _wstart c1, count(*) c2, max(a) c3 from st interval(10s);
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL);
+
+$loop_count = 0
+
+loop7:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop7
+endi
+
+sleep 200
+
+sql delete from t1 where ts = 1648791213000;
+
+$loop_count = 0
+
+loop8:
+sleep 200
+
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop8
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop8
+endi
+
+sql insert into t1 values(1648791223000,1,2,3,1.0);
+sql insert into t1 values(1648791223001,1,2,3,1.0);
+sql insert into t1 values(1648791223002,3,2,3,1.0);
+sql insert into t1 values(1648791223003,3,2,3,1.0);
+sql insert into t2 values(1648791223000,1,2,3,1.0);
+sql insert into t2 values(1648791223001,1,2,3,1.0);
+sql insert into t2 values(1648791223002,3,2,3,1.0);
+sql insert into t2 values(1648791223003,3,2,3,1.0);
+
+sleep 200
+
+sql delete from t2 where ts >= 1648791223000 and ts <= 1648791223001;
+
+$loop_count = 0
+
+loop11:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop11
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop11
+endi
+
+if $data11 != 6 then
+ print =====data11=$data11
+ goto loop11
+endi
+
+if $data12 != 3 then
+ print =====data12=$data12
+ goto loop11
+endi
+
+sleep 200
+
+sql delete from st where ts >= 1648791223000 and ts <= 1648791223003;
+
+$loop_count = 0
+
+loop12:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop12
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop12
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop12
+endi
+
+sql insert into t1 values(1648791213004,3,2,3,1.0);
+sql insert into t1 values(1648791213005,3,2,3,1.0);
+sql insert into t1 values(1648791213006,3,2,3,1.0);
+sql insert into t1 values(1648791223004,1,2,3,1.0);
+sql insert into t2 values(1648791213004,3,2,3,1.0);
+sql insert into t2 values(1648791213005,3,2,3,1.0);
+sql insert into t2 values(1648791213006,3,2,3,1.0);
+sql insert into t2 values(1648791223004,1,2,3,1.0);
+
+sleep 200
+
+sql delete from t2 where ts >= 1648791213004 and ts <= 1648791213006;
+
+$loop_count = 0
+
+loop13:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop13
+endi
+
+if $data01 != 4 then
+ print =====data01=$data01
+ goto loop13
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop13
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop13
+endi
+
+if $data12 != 1 then
+ print =====data12=$data12
+ goto loop13
+endi
+
+sql insert into t1 values(1648791223005,1,2,3,1.0);
+sql insert into t1 values(1648791223006,1,2,3,1.0);
+sql insert into t2 values(1648791223005,1,2,3,1.0);
+sql insert into t2 values(1648791223006,1,2,3,1.0);
+
+sql insert into t1 values(1648791233005,4,2,3,1.0);
+sql insert into t1 values(1648791233006,2,2,3,1.0);
+sql insert into t2 values(1648791233005,5,2,3,1.0);
+sql insert into t2 values(1648791233006,3,2,3,1.0);
+
+sleep 200
+
+sql delete from st where ts >= 1648791213001 and ts <= 1648791233005;
+
+$loop_count = 0
+
+loop14:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop14
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop14
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop14
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop14
+endi
+
+if $data12 != 3 then
+ print =====data12=$data12
+ goto loop14
+endi
+
+$loop_all = $loop_all + 1
+print ============loop_all=$loop_all
+
+system sh/stop_dnodes.sh
+
+#goto looptest
\ No newline at end of file
diff --git a/tests/script/tsim/stream/deleteSession.sim b/tests/script/tsim/stream/deleteSession.sim
new file mode 100644
index 0000000000..541609633b
--- /dev/null
+++ b/tests/script/tsim/stream/deleteSession.sim
@@ -0,0 +1,532 @@
+$loop_all = 0
+looptest:
+
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sleep 200
+sql connect
+
+sql drop stream if exists streams0;
+sql drop stream if exists streams1;
+sql drop stream if exists streams2;
+sql drop stream if exists streams3;
+sql drop stream if exists streams4;
+sql drop database if exists test;
+sql create database test vgroups 1;
+sql use test;
+sql create table t1(ts timestamp, a int, b int , c int, d double);
+sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(a) c3 from t1 session(ts, 5s);
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+sleep 200
+sql delete from t1 where ts = 1648791213000;
+
+$loop_count = 0
+
+loop0:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 0 then
+ print =====rows=$rows
+ goto loop0
+endi
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+
+$loop_count = 0
+
+loop1:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop1
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213001,2,2,2,2.0);
+sql insert into t1 values(1648791213002,3,3,3,3.0);
+sql insert into t1 values(1648791213003,4,4,4,4.0);
+
+sleep 200
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791213002;
+
+$loop_count = 0
+
+loop3:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+sql insert into t1 values(1648791223000,1,2,3,1.0);
+sql insert into t1 values(1648791223001,1,2,3,1.0);
+sql insert into t1 values(1648791223002,3,2,3,1.0);
+sql insert into t1 values(1648791223003,3,2,3,1.0);
+
+$loop_count = 0
+
+loop4:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop4
+endi
+
+sleep 200
+
+sql delete from t1 where ts >= 1648791223000 and ts <= 1648791223003;
+
+$loop_count = 0
+
+loop5:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop5
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop5
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213005,2,2,2,2.0);
+sql insert into t1 values(1648791213006,3,3,3,3.0);
+sql insert into t1 values(1648791213007,4,4,4,4.0);
+
+sql insert into t1 values(1648791223000,1,1,1,1.0);
+sql insert into t1 values(1648791223001,2,2,2,2.0);
+sql insert into t1 values(1648791223002,3,3,3,3.0);
+sql insert into t1 values(1648791223003,4,4,4,4.0);
+
+sql insert into t1 values(1648791233000,1,1,1,1.0);
+sql insert into t1 values(1648791233001,2,2,2,2.0);
+sql insert into t1 values(1648791233008,3,3,3,3.0);
+sql insert into t1 values(1648791233009,4,4,4,4.0);
+
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791233005;
+
+$loop_count = 0
+
+loop6:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop6
+endi
+
+if $data02 != 1 then
+ print =====data02=$data02
+ goto loop6
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop6
+endi
+
+if $data12 != 4 then
+ print =====data12=$data12
+ goto loop6
+endi
+
+sql drop stream if exists streams2;
+sql drop database if exists test2;
+sql create database test2 vgroups 4;
+sql use test2;
+sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+sql create stream streams2 trigger at_once into test.streamt2 as select _wstart c1, count(*) c2, max(a) c3 from st session(ts,5s);
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL);
+
+$loop_count = 0
+
+loop7:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop7
+endi
+
+sleep 200
+
+sql delete from t1 where ts = 1648791213000;
+
+$loop_count = 0
+
+loop8:
+sleep 200
+
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop8
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop8
+endi
+
+sql insert into t1 values(1648791223000,1,2,3,1.0);
+sql insert into t1 values(1648791223001,1,2,3,1.0);
+sql insert into t1 values(1648791223002,3,2,3,1.0);
+sql insert into t1 values(1648791223003,3,2,3,1.0);
+sql insert into t2 values(1648791223000,1,2,3,1.0);
+sql insert into t2 values(1648791223001,1,2,3,1.0);
+sql insert into t2 values(1648791223002,3,2,3,1.0);
+sql insert into t2 values(1648791223003,3,2,3,1.0);
+
+sleep 200
+
+sql delete from t2 where ts >= 1648791223000 and ts <= 1648791223001;
+
+$loop_count = 0
+
+loop11:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop11
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop11
+endi
+
+if $data11 != 6 then
+ print =====data11=$data11
+ goto loop11
+endi
+
+if $data12 != 3 then
+ print =====data12=$data12
+ goto loop11
+endi
+
+sleep 200
+
+sql delete from st where ts >= 1648791223000 and ts <= 1648791223003;
+
+$loop_count = 0
+
+loop12:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 1 then
+ print =====rows=$rows
+ goto loop12
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop12
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop12
+endi
+
+sql insert into t1 values(1648791213004,3,2,3,1.0);
+sql insert into t1 values(1648791213005,3,2,3,1.0);
+sql insert into t1 values(1648791213006,3,2,3,1.0);
+sql insert into t1 values(1648791223004,1,2,3,1.0);
+sql insert into t2 values(1648791213004,3,2,3,1.0);
+sql insert into t2 values(1648791213005,3,2,3,1.0);
+sql insert into t2 values(1648791213006,3,2,3,1.0);
+sql insert into t2 values(1648791223004,1,2,3,1.0);
+
+sleep 200
+
+sql delete from t2 where ts >= 1648791213004 and ts <= 1648791213006;
+
+$loop_count = 0
+
+loop13:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop13
+endi
+
+if $data01 != 4 then
+ print =====data01=$data01
+ goto loop13
+endi
+
+if $data02 != 3 then
+ print =====data02=$data02
+ goto loop13
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop13
+endi
+
+if $data12 != 1 then
+ print =====data12=$data12
+ goto loop13
+endi
+
+sql insert into t1 values(1648791223005,1,2,3,1.0);
+sql insert into t1 values(1648791223006,1,2,3,1.0);
+sql insert into t2 values(1648791223005,1,2,3,1.0);
+sql insert into t2 values(1648791223006,1,2,3,1.0);
+
+sql insert into t1 values(1648791233005,4,2,3,1.0);
+sql insert into t1 values(1648791233006,2,2,3,1.0);
+sql insert into t2 values(1648791233005,5,2,3,1.0);
+sql insert into t2 values(1648791233006,3,2,3,1.0);
+
+sleep 200
+
+sql delete from st where ts >= 1648791213001 and ts <= 1648791233005;
+
+$loop_count = 0
+
+loop14:
+sleep 200
+sql select * from test.streamt2 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop14
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop14
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop14
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop14
+endi
+
+if $data12 != 3 then
+ print =====data12=$data12
+ goto loop14
+endi
+
+sql drop stream if exists streams1;
+sql drop stream if exists streams2;
+sql drop stream if exists streams3;
+sql drop database if exists test3;
+sql drop database if exists test;
+sql create database test3 vgroups 4;
+sql create database test vgroups 1;
+sql use test3;
+sql create stable st(ts timestamp, a int, b int, c int, d double) tags(ta int,tb int,tc int);
+sql create table t1 using st tags(1,1,1);
+sql create table t2 using st tags(2,2,2);
+sql create stream streams3 trigger at_once into test.streamt3 as select _wstart c1, count(*) c2, max(a) c3 from st session(ts,5s);
+
+sql insert into t1 values(1648791210000,1,1,1,NULL);
+sql insert into t1 values(1648791210001,2,2,2,NULL);
+sql insert into t2 values(1648791213001,3,3,3,NULL);
+sql insert into t2 values(1648791213003,4,4,4,NULL);
+sql insert into t1 values(1648791216000,5,5,5,NULL);
+sql insert into t1 values(1648791216002,6,6,6,NULL);
+sql insert into t1 values(1648791216004,7,7,7,NULL);
+sql insert into t2 values(1648791218001,8,8,8,NULL);
+sql insert into t2 values(1648791218003,9,9,9,NULL);
+sql insert into t1 values(1648791222000,10,10,10,NULL);
+sql insert into t1 values(1648791222003,11,11,11,NULL);
+sql insert into t1 values(1648791222005,12,12,12,NULL);
+
+sql insert into t1 values(1648791232005,13,13,13,NULL);
+sql insert into t2 values(1648791242005,14,14,14,NULL);
+
+$loop_count = 0
+
+loop19:
+sleep 200
+sql select * from test.streamt3 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 3 then
+ print =====rows=$rows
+ goto loop19
+endi
+
+sql delete from t2 where ts >= 1648791213001 and ts <= 1648791218003;
+
+$loop_count = 0
+
+loop20:
+sleep 200
+sql select * from test.streamt3 order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 5 then
+ print =====rows=$rows
+ goto loop20
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop20
+endi
+
+if $data02 != 2 then
+ print =====data02=$data02
+ goto loop20
+endi
+
+if $data11 != 3 then
+ print =====data11=$data11
+ goto loop20
+endi
+
+if $data12 != 7 then
+ print =====data12=$data12
+ goto loop20
+endi
+
+if $data21 != 3 then
+ print =====data21=$data21
+ goto loop20
+endi
+
+if $data22 != 12 then
+ print =====data22=$data22
+ goto loop20
+endi
+
+if $data31 != 1 then
+ print =====data31=$data31
+ goto loop20
+endi
+
+if $data32 != 13 then
+ print =====data32=$data32
+ goto loop20
+endi
+
+if $data41 != 1 then
+ print =====data41=$data41
+ goto loop20
+endi
+
+if $data42 != 14 then
+ print =====data42=$data42
+ goto loop20
+endi
+
+$loop_all = $loop_all + 1
+print ============loop_all=$loop_all
+
+system sh/stop_dnodes.sh
+
+#goto looptest
\ No newline at end of file
diff --git a/tests/script/tsim/stream/deleteState.sim b/tests/script/tsim/stream/deleteState.sim
new file mode 100644
index 0000000000..ecd9f55340
--- /dev/null
+++ b/tests/script/tsim/stream/deleteState.sim
@@ -0,0 +1,198 @@
+$loop_all = 0
+looptest:
+
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sleep 200
+sql connect
+
+sql drop stream if exists streams0;
+sql drop stream if exists streams1;
+sql drop stream if exists streams2;
+sql drop stream if exists streams3;
+sql drop stream if exists streams4;
+sql drop database if exists test;
+sql create database test vgroups 1;
+sql use test;
+sql create table t1(ts timestamp, a int, b int , c int, d double);
+sql create stream streams0 trigger at_once into streamt as select _wstart c1, count(*) c2, max(b) c3 from t1 state_window(a);
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+sleep 200
+sql delete from t1 where ts = 1648791213000;
+
+$loop_count = 0
+
+loop0:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 0 then
+ print =====rows=$rows
+ goto loop0
+endi
+
+sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
+
+$loop_count = 0
+
+loop1:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop1
+endi
+
+if $data02 != NULL then
+ print =====data02=$data02
+ goto loop1
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213001,1,2,2,2.0);
+sql insert into t1 values(1648791213002,1,3,3,3.0);
+sql insert into t1 values(1648791213003,1,4,4,4.0);
+
+sleep 200
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791213002;
+
+$loop_count = 0
+
+loop3:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop3
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+sql insert into t1 values(1648791223000,2,2,3,1.0);
+sql insert into t1 values(1648791223001,2,2,3,1.0);
+sql insert into t1 values(1648791223002,2,2,3,1.0);
+sql insert into t1 values(1648791223003,2,2,3,1.0);
+
+$loop_count = 0
+
+loop4:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop4
+endi
+
+sleep 200
+
+sql delete from t1 where ts >= 1648791223000 and ts <= 1648791223003;
+
+$loop_count = 0
+
+loop5:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $data01 != 2 then
+ print =====data01=$data01
+ goto loop5
+endi
+
+if $data02 != 4 then
+ print =====data02=$data02
+ goto loop5
+endi
+
+sql insert into t1 values(1648791213000,1,1,1,1.0);
+sql insert into t1 values(1648791213005,1,2,2,2.0);
+sql insert into t1 values(1648791213006,1,3,3,3.0);
+sql insert into t1 values(1648791213007,1,4,4,4.0);
+
+sql insert into t1 values(1648791223000,2,1,1,1.0);
+sql insert into t1 values(1648791223001,2,2,2,2.0);
+sql insert into t1 values(1648791223002,2,3,3,3.0);
+sql insert into t1 values(1648791223003,2,4,4,4.0);
+
+sql insert into t1 values(1648791233000,3,1,1,1.0);
+sql insert into t1 values(1648791233001,3,2,2,2.0);
+sql insert into t1 values(1648791233008,3,3,3,3.0);
+sql insert into t1 values(1648791233009,3,4,4,4.0);
+
+sql delete from t1 where ts >= 1648791213001 and ts <= 1648791233005;
+
+$loop_count = 0
+
+loop6:
+sleep 200
+sql select * from streamt order by c1, c2, c3;
+
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+if $rows != 2 then
+ print =====rows=$rows
+ goto loop6
+endi
+
+if $data01 != 1 then
+ print =====data01=$data01
+ goto loop6
+endi
+
+if $data02 != 1 then
+ print =====data02=$data02
+ goto loop6
+endi
+
+if $data11 != 2 then
+ print =====data11=$data11
+ goto loop6
+endi
+
+if $data12 != 4 then
+ print =====data12=$data12
+ goto loop6
+endi
+
+
+$loop_all = $loop_all + 1
+print ============loop_all=$loop_all
+
+system sh/stop_dnodes.sh
+
+#goto looptest
\ No newline at end of file
diff --git a/tests/script/tsim/stream/distributeInterval0.sim b/tests/script/tsim/stream/distributeInterval0.sim
index b6b427343e..9b2e940556 100644
--- a/tests/script/tsim/stream/distributeInterval0.sim
+++ b/tests/script/tsim/stream/distributeInterval0.sim
@@ -198,7 +198,7 @@ endi
sql select _wstart, count(*) c1, count(d) c2 , sum(a) c3 , max(b) c4, min(c) c5, avg(d) from st interval(10s);
-sql create database test1 vgroups 1;
+sql create database test1 vgroups 4;
sql use test1;
sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
sql create table ts1 using st tags(1,1,1);
@@ -232,4 +232,43 @@ if $data11 != 2 then
goto loop2
endi
+#max,min selectivity
+sql create database test3 vgroups 4;
+sql use test3;
+sql create stable st(ts timestamp, a int, b int , c int) tags(ta int,tb int,tc int);
+sql create table ts1 using st tags(1,1,1);
+sql create table ts2 using st tags(2,2,2);
+sql create stream stream_t3 trigger at_once into streamtST3 as select ts, min(a) c6, a, b, c, ta, tb, tc from st interval(10s) ;
+
+sql insert into ts1 values(1648791211000,1,2,3);
+sleep 50
+sql insert into ts1 values(1648791222001,2,2,3);
+sleep 50
+sql insert into ts2 values(1648791211000,1,2,3);
+sleep 50
+sql insert into ts2 values(1648791222001,2,2,3);
+sleep 50
+
+$loop_count = 0
+loop3:
+sql select * from streamtST3;
+
+sleep 300
+$loop_count = $loop_count + 1
+if $loop_count == 10 then
+ return -1
+endi
+
+# row 0
+if $data02 != 1 then
+ print =====data02=$data02
+ goto loop3
+endi
+
+# row 1
+if $data12 != 2 then
+ print =====data12=$data12
+ goto loop3
+endi
+
system sh/stop_dnodes.sh
diff --git a/tests/script/tsim/stream/partitionbyColumn0.sim b/tests/script/tsim/stream/partitionbyColumnInterval.sim
similarity index 98%
rename from tests/script/tsim/stream/partitionbyColumn0.sim
rename to tests/script/tsim/stream/partitionbyColumnInterval.sim
index d91d4b7bf0..24fdb9c994 100644
--- a/tests/script/tsim/stream/partitionbyColumn0.sim
+++ b/tests/script/tsim/stream/partitionbyColumnInterval.sim
@@ -24,7 +24,7 @@ sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
$loop_count = 0
loop0:
-sleep 100
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -48,7 +48,7 @@ sql insert into t1 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop1:
-sleep 100
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -71,7 +71,7 @@ sql insert into t1 values(1648791213000,2,2,3,1.0);
$loop_count = 0
loop2:
-sleep 100
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -97,7 +97,7 @@ sql insert into t1 values(1648791213002,1,2,3,1.0);
$loop_count = 0
loop3:
-sleep 100
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -134,7 +134,7 @@ sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (16
$loop_count = 0
loop4:
-sleep 100
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -208,7 +208,7 @@ sql insert into t1 values(1648791213001,1,2,3,2.0);
$loop_count = 0
loop5:
-sleep 100
+sleep 50
sql select * from streamt1 order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -229,7 +229,7 @@ sql insert into t1 values(1648791213001,1,1,6,2.0) (1648791223002,1,1,7,2.0);
$loop_count = 0
loop6:
-sleep 100
+sleep 50
sql select * from streamt1 order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
@@ -294,7 +294,7 @@ sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL);
$loop_count = 0
loop7:
-sleep 100
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -318,7 +318,7 @@ sql insert into t2 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop8:
-sleep 100
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -342,7 +342,7 @@ sql insert into t2 values(1648791213000,2,2,3,1.0);
$loop_count = 0
loop9:
-sleep 100
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -372,7 +372,7 @@ sql insert into t2 values(1648791213002,1,2,3,1.0);
$loop_count = 0
loop10:
-sleep 100
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -414,7 +414,7 @@ sql insert into t2 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (16
$loop_count = 0
loop11:
-sleep 100
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -492,7 +492,7 @@ sql insert into t4 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop13:
-sleep 100
+sleep 50
sql select * from test.streamt4 order by c1, c2, c3;
$loop_count = $loop_count + 1
@@ -534,7 +534,7 @@ sql insert into t1 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop14:
-sleep 100
+sleep 50
sql select * from test.streamt4 order by c1, c2, c3;
$loop_count = $loop_count + 1
diff --git a/tests/script/tsim/stream/partitionbyColumn1.sim b/tests/script/tsim/stream/partitionbyColumnSession.sim
similarity index 93%
rename from tests/script/tsim/stream/partitionbyColumn1.sim
rename to tests/script/tsim/stream/partitionbyColumnSession.sim
index 7f5c53ebe3..1742d52cf0 100644
--- a/tests/script/tsim/stream/partitionbyColumn1.sim
+++ b/tests/script/tsim/stream/partitionbyColumnSession.sim
@@ -24,11 +24,11 @@ sql insert into t1 values(1648791213000,NULL,NULL,NULL,NULL);
$loop_count = 0
loop0:
-sleep 300
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -45,12 +45,14 @@ endi
sql insert into t1 values(1648791213000,1,2,3,1.0);
+$loop_count = 0
+
loop1:
-sleep 300
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -66,12 +68,14 @@ endi
sql insert into t1 values(1648791213000,2,2,3,1.0);
+$loop_count = 0
+
loop2:
-sleep 300
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -90,12 +94,14 @@ sql insert into t1 values(1648791213001,2,2,3,1.0);
sql insert into t1 values(1648791213002,2,2,3,1.0);
sql insert into t1 values(1648791213002,1,2,3,1.0);
+$loop_count = 0
+
loop3:
-sleep 300
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -125,12 +131,14 @@ sql insert into t1 values(1648791223002,3,2,3,1.0);
sql insert into t1 values(1648791223003,3,2,3,1.0);
sql insert into t1 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0);
+$loop_count = 0
+
loop4:
-sleep 300
+sleep 50
sql select * from streamt order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -199,11 +207,11 @@ sql insert into t1 values(1648791213001,1,2,3,2.0);
$loop_count = 0
loop5:
-sleep 300
+sleep 50
sql select * from streamt1 order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -217,12 +225,14 @@ sql insert into t1 values(1648791223001,1,2,5,2.0);
sql insert into t1 values(1648791223002,1,2,5,2.0);
sql insert into t1 values(1648791213001,1,1,6,2.0) (1648791223002,1,1,7,2.0);
+$loop_count = 0
+
loop6:
-sleep 300
+sleep 50
sql select * from streamt1 order by c1, c4, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -282,11 +292,11 @@ sql insert into t2 values(1648791213000,NULL,NULL,NULL,NULL);
$loop_count = 0
loop7:
-sleep 300
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -303,12 +313,14 @@ endi
sql insert into t1 values(1648791213000,1,2,3,1.0);
sql insert into t2 values(1648791213000,1,2,3,1.0);
+$loop_count = 0
+
loop8:
-sleep 300
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -324,12 +336,15 @@ endi
sql insert into t1 values(1648791213000,2,2,3,1.0);
sql insert into t2 values(1648791213000,2,2,3,1.0);
+
+$loop_count = 0
+
loop9:
-sleep 300
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -352,12 +367,14 @@ sql insert into t2 values(1648791213001,2,2,3,1.0);
sql insert into t2 values(1648791213002,2,2,3,1.0);
sql insert into t2 values(1648791213002,1,2,3,1.0);
+$loop_count = 0
+
loop10:
-sleep 300
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -373,7 +390,7 @@ endi
if $data11 != 2 thenloop4
print =====data11=$data11
- goto loop3
+ goto loop10
endi
if $data12 != 1 then
@@ -392,12 +409,14 @@ sql insert into t2 values(1648791223002,3,2,3,1.0);
sql insert into t2 values(1648791223003,3,2,3,1.0);
sql insert into t2 values(1648791213001,1,2,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0);
+$loop_count = 0
+
loop11:
-sleep 300
+sleep 50
sql select * from test.streamt2 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
@@ -470,17 +489,17 @@ sql insert into t4 values(1648791213000,1,2,3,1.0);
$loop_count = 0
loop13:
-sleep 300
+sleep 50
sql select * from test.streamt4 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
if $rows != 2 then
print =====rows=$rows
- goto loop14
+ goto loop13
endi
if $data01 != 1 then
@@ -495,12 +514,12 @@ endi
if $data11 != 3 then
print =====data11=$data11
- goto loop11
+ goto loop13
endi
if $data12 != 2 then
print =====data12=$data12
- goto loop11
+ goto loop13
endi
sql insert into t4 values(1648791213000,2,2,3,1.0);
@@ -509,12 +528,14 @@ sql insert into t1 values(1648791233000,2,2,3,1.0);
sql insert into t1 values(1648791213000,1,2,3,1.0);
+$loop_count = 0
+
loop14:
-sleep 300
+sleep 50
sql select * from test.streamt4 order by c1, c2, c3;
$loop_count = $loop_count + 1
-if $loop_count == 10 then
+if $loop_count == 20 then
return -1
endi
diff --git a/tests/script/tsim/stream/partitionbyColumn2.sim b/tests/script/tsim/stream/partitionbyColumnState.sim
similarity index 98%
rename from tests/script/tsim/stream/partitionbyColumn2.sim
rename to tests/script/tsim/stream/partitionbyColumnState.sim
index 3d9acbcac5..75d01b17ec 100644
--- a/tests/script/tsim/stream/partitionbyColumn2.sim
+++ b/tests/script/tsim/stream/partitionbyColumnState.sim
@@ -40,6 +40,8 @@ endi
sql insert into t1 values(1648791213000,1,1,3,1.0);
+$loop_count = 0
+
loop1:
sleep 300
sql select * from streamt order by c1, c4, c2, c3;
@@ -61,6 +63,8 @@ endi
sql insert into t1 values(1648791213000,2,1,3,1.0);
+$loop_count = 0
+
loop2:
sleep 300
sql select * from streamt order by c1, c4, c2, c3;
@@ -85,6 +89,8 @@ sql insert into t1 values(1648791213001,2,1,3,1.0);
sql insert into t1 values(1648791213002,2,1,3,1.0);
sql insert into t1 values(1648791213002,1,1,3,1.0);
+$loop_count = 0
+
loop3:
sleep 300
sql select * from streamt order by c1, c4, c2, c3;
@@ -120,6 +126,8 @@ sql insert into t1 values(1648791223002,3,2,3,1.0);
sql insert into t1 values(1648791223003,3,2,3,1.0);
sql insert into t1 values(1648791213001,1,1,3,1.0) (1648791223001,2,2,3,1.0) (1648791223003,1,2,3,1.0);
+$loop_count = 0
+
loop4:
sleep 300
sql select * from streamt order by c1, c4, c2, c3;
@@ -212,6 +220,8 @@ sql insert into t1 values(1648791223001,1,2,2,5);
sql insert into t1 values(1648791223002,1,2,2,6);
sql insert into t1 values(1648791213001,1,1,1,7) (1648791223002,1,1,2,8);
+$loop_count = 0
+
loop6:
sleep 300
sql select * from streamt1 order by c1, c4, c2, c3;
diff --git a/tests/script/tsim/table/hash.sim b/tests/script/tsim/table/hash.sim
new file mode 100644
index 0000000000..664f867137
--- /dev/null
+++ b/tests/script/tsim/table/hash.sim
@@ -0,0 +1,84 @@
+system sh/stop_dnodes.sh
+system sh/deploy.sh -n dnode1 -i 1
+system sh/exec.sh -n dnode1 -s start
+sql connect
+
+#=========== prepare
+#sql create database d1 vgroups 2
+sql create database d1 vgroups 2 table_prefix 3 table_suffix 2
+sql select * from information_schema.ins_databases
+print $data(d1)[27] $data(d1)[28]
+if $data(d1)[27] != 3 then
+ return -1
+endi
+if $data(d1)[28] != 2 then
+ return -1
+endi
+
+sql use d1;
+sql create table st (ts timestamp, i int) tags (j int);
+sql create table st_ct_1 using st tags(3) st_ct_2 using st tags(4) st_ct_3 using st tags(5) st_ct_4 using st tags(6) st_ct_5 using st tags(7)
+sql insert into st_ct_1 values(now+1s, 1)
+sql insert into st_ct_1 values(now+2s, 2)
+sql insert into st_ct_1 values(now+3s, 3)
+sql insert into st_ct_2 values(now+1s, 1)
+sql insert into st_ct_2 values(now+2s, 2)
+sql insert into st_ct_2 values(now+3s, 3)
+sql insert into st_ct_3 values(now+1s, 1)
+sql insert into st_ct_3 values(now+2s, 2)
+sql insert into st_ct_3 values(now+3s, 2)
+sql insert into st_ct_4 values(now+1s, 1)
+sql insert into st_ct_4 values(now+2s, 2)
+sql insert into st_ct_4 values(now+3s, 2)
+sql insert into st_ct_5 values(now+1s, 1)
+sql insert into st_ct_5 values(now+2s, 2)
+sql insert into st_ct_5 values(now+3s, 2)
+
+# check query
+sql select * from st
+if $rows != 15 then
+ return -1
+endi
+
+# check table vgroup
+sql select * from information_schema.ins_tables where db_name = 'd1'
+if $data(st_ct_1)[6] != 2 then
+ return -1
+endi
+if $data(st_ct_2)[6] != 2 then
+ return -1
+endi
+if $data(st_ct_3)[6] != 2 then
+ return -1
+endi
+if $data(st_ct_4)[6] != 2 then
+ return -1
+endi
+if $data(st_ct_5)[6] != 2 then
+ return -1
+endi
+
+# check invalid table name
+sql create table c1 using st tags(3)
+sql create table c12 using st tags(3)
+sql create table c123 using st tags(3)
+sql create table c1234 using st tags(3)
+sql create table c12345 using st tags(3)
+sql select * from information_schema.ins_tables where db_name = 'd1'
+if $data(c1)[6] != 2 then
+ return -1
+endi
+if $data(c12)[6] != 3 then
+ return -1
+endi
+if $data(c123)[6] != 2 then
+ return -1
+endi
+if $data(c1234)[6] != 3 then
+ return -1
+endi
+if $data(c12345)[6] != 3 then
+ return -1
+endi
+
+system sh/exec.sh -n dnode1 -s stop -x SIGINT
diff --git a/tests/script/tsim/valgrind/checkError6.sim b/tests/script/tsim/valgrind/checkError6.sim
index d85a1bebc8..11a387ed4d 100644
--- a/tests/script/tsim/valgrind/checkError6.sim
+++ b/tests/script/tsim/valgrind/checkError6.sim
@@ -158,6 +158,8 @@ print =============== restart
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start -v
+sleep 1000
+
sql select avg(tbcol) as c from stb
sql select avg(tbcol) as c from stb where ts <= 1601481840000
sql select avg(tbcol) as c from stb where tgcol < 5 and ts <= 1601481840000
diff --git a/tests/system-test/fulltest.sh b/tests/system-test/fulltest.sh
index 4305ceff56..8987ba3bbd 100755
--- a/tests/system-test/fulltest.sh
+++ b/tests/system-test/fulltest.sh
@@ -156,8 +156,8 @@ python3 ./test.py -f 2-query/sin.py
python3 ./test.py -f 2-query/sin.py -R
python3 ./test.py -f 2-query/smaTest.py
python3 ./test.py -f 2-query/smaTest.py -R
-python3 ./test.py -f 2-query/sml.py
-python3 ./test.py -f 2-query/sml.py -R
+#python3 ./test.py -f 2-query/sml.py
+#python3 ./test.py -f 2-query/sml.py -R
python3 ./test.py -f 2-query/spread.py
python3 ./test.py -f 2-query/spread.py -R
python3 ./test.py -f 2-query/sqrt.py
@@ -333,7 +333,7 @@ python3 ./test.py -f 7-tmq/stbTagFilter-1ctb.py
python3 ./test.py -f 7-tmq/dataFromTsdbNWal.py
python3 ./test.py -f 7-tmq/dataFromTsdbNWal-multiCtb.py
python3 ./test.py -f 7-tmq/tmq_taosx.py
-# python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
+python3 ./test.py -f 7-tmq/stbTagFilter-multiCtb.py
#------------querPolicy 2-----------
@@ -512,6 +512,6 @@ python3 ./test.py -f 2-query/count_partition.py -Q 3
python3 ./test.py -f 2-query/max_partition.py -Q 3
python3 ./test.py -f 2-query/last_row.py -Q 3
python3 ./test.py -f 2-query/tsbsQuery.py -Q 3
-python3 ./test.py -f 2-query/sml.py -Q 3
+#python3 ./test.py -f 2-query/sml.py -Q 3
python3 ./test.py -f 2-query/interp.py -Q 3
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100644
index 0000000000..59cbbb3147
--- /dev/null
+++ b/utils/CMakeLists.txt
@@ -0,0 +1,4 @@
+#ADD_SUBDIRECTORY(examples/c)
+ADD_SUBDIRECTORY(tsim)
+ADD_SUBDIRECTORY(test/c)
+#ADD_SUBDIRECTORY(comparisonTest/tdengine)
diff --git a/tests/test/c/CMakeLists.txt b/utils/test/c/CMakeLists.txt
similarity index 97%
rename from tests/test/c/CMakeLists.txt
rename to utils/test/c/CMakeLists.txt
index 31331b5265..839c65b633 100644
--- a/tests/test/c/CMakeLists.txt
+++ b/utils/test/c/CMakeLists.txt
@@ -1,4 +1,5 @@
add_executable(tmq_demo tmqDemo.c)
+add_dependencies(tmq_demo taos)
add_executable(tmq_sim tmqSim.c)
add_executable(create_table createTable.c)
add_executable(tmq_taosx_ci tmq_taosx_ci.c)
diff --git a/tests/test/c/createTable.c b/utils/test/c/createTable.c
similarity index 100%
rename from tests/test/c/createTable.c
rename to utils/test/c/createTable.c
diff --git a/tests/test/c/sdbDump.c b/utils/test/c/sdbDump.c
similarity index 100%
rename from tests/test/c/sdbDump.c
rename to utils/test/c/sdbDump.c
diff --git a/tests/test/c/sml_test.c b/utils/test/c/sml_test.c
similarity index 99%
rename from tests/test/c/sml_test.c
rename to utils/test/c/sml_test.c
index 1fd1def263..ca3d464da7 100644
--- a/tests/test/c/sml_test.c
+++ b/utils/test/c/sml_test.c
@@ -92,7 +92,7 @@ int smlProcess_telnet_Test() {
int smlProcess_json1_Test() {
TAOS *taos = taos_connect("localhost", "root", "taosdata", NULL, 0);
- TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db schemaless 1");
+ TAOS_RES *pRes = taos_query(taos, "create database if not exists sml_db");
taos_free_result(pRes);
pRes = taos_query(taos, "use sml_db");
@@ -112,7 +112,7 @@ int smlProcess_json1_Test() {
" },"
" {"
" \"metric\": \"sys.cpu.nice\","
- " \"timestamp\": 1346846400,"
+ " \"timestamp\": 1662344042,"
" \"value\": 9,"
" \"tags\": {"
" \"host\": \"web02\","
@@ -141,7 +141,7 @@ int smlProcess_json2_Test() {
"{"
" \"metric\": \"meter_current0\","
" \"timestamp\": {"
- " \"value\" : 1346846400,"
+ " \"value\" : 1662344042,"
" \"type\" : \"s\""
" },"
" \"value\": {"
@@ -181,7 +181,7 @@ int smlProcess_json3_Test() {
"{"
" \"metric\": \"meter_current1\","
" \"timestamp\": {"
- " \"value\" : 1346846400,"
+ " \"value\" : 1662344042,"
" \"type\" : \"s\""
" },"
" \"value\": {"
@@ -249,7 +249,7 @@ int smlProcess_json4_Test() {
"{"
" \"metric\": \"meter_current2\","
" \"timestamp\": {"
- " \"value\" : 1346846500000,"
+ " \"value\" : 1662344042000,"
" \"type\" : \"ms\""
" },"
" \"value\": \"ni\","
diff --git a/tests/test/c/tmqDemo.c b/utils/test/c/tmqDemo.c
similarity index 100%
rename from tests/test/c/tmqDemo.c
rename to utils/test/c/tmqDemo.c
diff --git a/tests/test/c/tmqSim.c b/utils/test/c/tmqSim.c
similarity index 100%
rename from tests/test/c/tmqSim.c
rename to utils/test/c/tmqSim.c
diff --git a/tests/test/c/tmq_taosx_ci.c b/utils/test/c/tmq_taosx_ci.c
similarity index 100%
rename from tests/test/c/tmq_taosx_ci.c
rename to utils/test/c/tmq_taosx_ci.c
diff --git a/tests/tsim/CMakeLists.txt b/utils/tsim/CMakeLists.txt
similarity index 100%
rename from tests/tsim/CMakeLists.txt
rename to utils/tsim/CMakeLists.txt
diff --git a/tests/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h
similarity index 100%
rename from tests/tsim/inc/simInt.h
rename to utils/tsim/inc/simInt.h
diff --git a/tests/tsim/inc/simParse.h b/utils/tsim/inc/simParse.h
similarity index 100%
rename from tests/tsim/inc/simParse.h
rename to utils/tsim/inc/simParse.h
diff --git a/tests/tsim/src/simExe.c b/utils/tsim/src/simExe.c
similarity index 100%
rename from tests/tsim/src/simExe.c
rename to utils/tsim/src/simExe.c
diff --git a/tests/tsim/src/simMain.c b/utils/tsim/src/simMain.c
similarity index 100%
rename from tests/tsim/src/simMain.c
rename to utils/tsim/src/simMain.c
diff --git a/tests/tsim/src/simParse.c b/utils/tsim/src/simParse.c
similarity index 100%
rename from tests/tsim/src/simParse.c
rename to utils/tsim/src/simParse.c
diff --git a/tests/tsim/src/simSystem.c b/utils/tsim/src/simSystem.c
similarity index 100%
rename from tests/tsim/src/simSystem.c
rename to utils/tsim/src/simSystem.c