diff --git a/README-CN.md b/README-CN.md index 627b35698c21cf234b011c17c85c7faee53671b3..437d671bb97a1009f5d48d2423a3d17f75bf1494 100644 --- a/README-CN.md +++ b/README-CN.md @@ -107,7 +107,7 @@ sudo yum config-manager --set-enabled Powertools ### macOS ``` -sudo brew install argp-standalone pkgconfig +brew install argp-standalone pkgconfig ``` ### 设置 golang 开发环境 @@ -276,7 +276,7 @@ sudo make install 安装成功后,可以在应用程序中双击 TDengine 图标启动服务,或者在终端中启动 TDengine 服务: ```bash -launchctl start taosd +launchctl start com.tdengine.taosd ``` 用户可以使用 TDengine CLI 来连接 TDengine 服务,在终端中,输入: diff --git a/README.md b/README.md index 00d36efb5a630a44eeeaa9b3b47df5c649a0a305..8d2567a816f9048cd689afa06426e9c88979a354 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ sudo yum config-manager --set-enabled powertools ### macOS ``` -sudo brew install argp-standalone pkgconfig +brew install argp-standalone pkgconfig ``` ### Setup golang environment @@ -280,7 +280,7 @@ Installing from source code will also configure service management for TDengine. To start the service after installation, double-click the /applications/TDengine to start the program, or in a terminal, use: ```bash -launchctl start taosd +launchctl start com.tdengine.taosd ``` Then users can use the TDengine CLI to connect the TDengine server. In a terminal, use: diff --git a/cmake/cmake.platform b/cmake/cmake.platform index e4d440d76edbfcf0d1d6f932cfa598fe0a0f43d2..3e239d2e0c9f1fb53a4c156cab52801f6206df75 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -45,10 +45,19 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") - IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") - MESSAGE("Current system arch is 64") + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") + MESSAGE("Current system arch is arm64") SET(TD_DARWIN_64 TRUE) + SET(TD_DARWIN_ARM64 TRUE) ADD_DEFINITIONS("-D_TD_DARWIN_64") + ADD_DEFINITIONS("-D_TD_DARWIN_ARM64") + ENDIF () + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") + MESSAGE("Current system arch is x86_64") + SET(TD_DARWIN_64 TRUE) + SET(TD_DARWIN_X64 TRUE) + ADD_DEFINITIONS("-D_TD_DARWIN_64") + ADD_DEFINITIONS("-D_TD_DARWIN_X64") ENDIF () ADD_DEFINITIONS("-DHAVE_UNISTD_H") diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index a1a6cd4519294fa99a5bee41ae21aad4c1731373..969724cc8d0ebd68f3a3cbdf5716bdcb4efb5ff9 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -270,7 +270,7 @@ if(${JEMALLOC_ENABLED}) PREFIX "jemalloc" SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/jemalloc BUILD_IN_SOURCE 1 - CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls + CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${CMAKE_BINARY_DIR}/build/ --disable-initial-exec-tls --with-malloc-conf='background_thread:true,metadata_thp:auto' BUILD_COMMAND ${MAKE} ) INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/build/include) diff --git a/docs/en/05-get-started/03-package.md b/docs/en/05-get-started/03-package.md index f734e354fb16c8ca7342f04fc46f869009bbd8c8..7800fb1c88a59c28945a196e1e5dac95427bf1f6 100644 --- a/docs/en/05-get-started/03-package.md +++ b/docs/en/05-get-started/03-package.md @@ -189,13 +189,13 @@ After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengin -After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start taosd` to start TDengine Server. +After the installation is complete, double-click the /applications/TDengine to start the program, or run `launchctl start com.tdengine.taosd` to start TDengine Server. The following `launchctl` commands can help you manage TDengine service: -- Start TDengine Server: `launchctl start taosd` +- Start TDengine Server: `launchctl start com.tdengine.taosd` -- Stop TDengine Server: `launchctl stop taosd` +- Stop TDengine Server: `launchctl stop com.tdengine.taosd` - Check TDengine Server status: `launchctl list | grep taosd` diff --git a/docs/en/07-develop/01-connect/index.md b/docs/en/07-develop/01-connect/index.md index 61eb8f04eb3fb8cea5096b321105fa9e88722bda..5ccddb06b024ea22dfbc2bd0ddf896b544a7cd8d 100644 --- a/docs/en/07-develop/01-connect/index.md +++ b/docs/en/07-develop/01-connect/index.md @@ -68,7 +68,7 @@ After the above installation and configuration are done and making sure TDengine - + If `maven` is used to manage the projects, what needs to be done is only adding below dependency in `pom.xml`. ```xml @@ -138,19 +138,19 @@ Node.js connector provides different ways of establishing connections by providi 1. Install Node.js Native Connector - ``` - npm install @tdengine/client - ``` +``` +npm install @tdengine/client +``` :::note It's recommend to use Node whose version is between `node-v12.8.0` and `node-v13.0.0`. -::: - +::: + 2. Install Node.js REST Connector - ``` - npm install @tdengine/rest - ``` +``` +npm install @tdengine/rest +``` diff --git a/docs/en/07-develop/02-model/index.mdx b/docs/en/07-develop/02-model/index.mdx index 3c16ed2df15940f3f59232a37b6f559010305a96..19a239805f1492eae0c463f5a942378b83ecf6b8 100644 --- a/docs/en/07-develop/02-model/index.mdx +++ b/docs/en/07-develop/02-model/index.mdx @@ -2,12 +2,10 @@ title: Data Model --- -The data model employed by TDengine is similar to that of a relational database. You have to create databases and tables. You must design the data model based on your own business and application requirements. You should design the [STable](/concept/#super-table-stable) (an abbreviation for super table) schema to fit your data. This chapter will explain the big picture without getting into syntactical details. +The data model employed by TDengine is similar to that of a relational database. You have to create databases and tables. You must design the data model based on your own business and application requirements. You should design the [STable](/concept/#super-table-stable) (an abbreviation for super table) schema to fit your data. This chapter will explain the big picture without getting into syntactical details. Note: before you read this chapter, please make sure you have already read through [Key Concepts](/concept/), since TDengine introduces new concepts like "one table for one [data collection point](/concept/#data-collection-point)" and "[super table](/concept/#super-table-stable)". - - ## Create Database The characteristics of time-series data from different data collection points may be different. Characteristics include collection frequency, retention policy and others which determine how you create and configure the database. For e.g. days to keep, number of replicas, data block size, whether data updates are allowed and other configurable parameters would be determined by the characteristics of your data and your business requirements. For TDengine to operate with the best performance, we strongly recommend that you create and configure different databases for data with different characteristics. This allows you, for example, to set up different storage and retention policies. When creating a database, there are a lot of parameters that can be configured such as, the days to keep data, the number of replicas, the size of the cache, time precision, the minimum and maximum number of rows in each data block, whether compression is enabled, the time range of the data in single data file and so on. An example is shown as follows: @@ -17,10 +15,11 @@ CREATE DATABASE power KEEP 365 DURATION 10 BUFFER 16 WAL_LEVEL 1; ``` In the above SQL statement: + - a database named "power" is created - the data in it is retained for 365 days, which means that data older than 365 days will be deleted automatically - a new data file will be created every 10 days -- the size of the write cache pool on each vnode is 16 MB +- the size of the write cache pool on each VNode is 16 MB - the number of vgroups is 100 - WAL is enabled but fsync is disabled For more details please refer to [Database](/taos-sql/database). diff --git a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx index c91dbba5d2786f8a5a78ed77c105e3661ae8641f..6f933d52ac0b70bf4700525d31e0e46bad470193 100644 --- a/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx +++ b/docs/en/07-develop/03-insert-data/02-influxdb-line.mdx @@ -24,7 +24,7 @@ measurement,tag_set field_set timestamp - `measurement` will be used as the name of the STable Enter a comma (,) between `measurement` and `tag_set`. - `tag_set` will be used as tags, with format like `=,=` Enter a space between `tag_set` and `field_set`. - `field_set`will be used as data columns, with format like `=,=` Enter a space between `field_set` and `timestamp`. -- `timestamp` is the primary key timestamp corresponding to this row of data +- `timestamp` is the primary key timestamp corresponding to this row of data For example: @@ -34,12 +34,12 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 :::note -- All the data in `tag_set` will be converted to nchar type automatically . +- All the data in `tag_set` will be converted to NCHAR type automatically . - Each data in `field_set` must be self-descriptive for its data type. For example 1.2f32 means a value 1.2 of float type. Without the "f" type suffix, it will be treated as type double. - Multiple kinds of precision can be used for the `timestamp` field. Time precision can be from nanosecond (ns) to hour (h). - You can configure smlChildTableName in taos.cfg to specify table names, for example, `smlChildTableName=tname`. You can insert `st,tname=cpul,t1=4 c1=3 1626006833639000000` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. - It is assumed that the order of field_set in a supertable is consistent, meaning that the first record contains all fields and subsequent records store fields in the same order. If the order is not consistent, set smlDataFormat in taos.cfg to false. Otherwise, data will be written out of order and a database error will occur.(smlDataFormat in taos.cfg default to false after version of 3.0.1.3) -::: + ::: For more details please refer to [InfluxDB Line Protocol](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) and [TDengine Schemaless](/reference/schemaless/#Schemaless-Line-Protocol) @@ -67,5 +67,9 @@ For more details please refer to [InfluxDB Line Protocol](https://docs.influxdat ## Query Examples -If you want query the data of `location=California.LosAngeles,groupid=2`,here is the query sql: -select * from `meters.voltage` where location="California.LosAngeles" and groupid=2 + +If you want query the data of `location=California.LosAngeles,groupid=2`,here is the query SQL: + +```sql +SELECT * FROM meters WHERE location = "California.LosAngeles" AND groupid = 2; +``` diff --git a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx index a71efde7353bdba6fad14b159b44d7a36d008bdd..10482df6b21674ec45e1f3e5e0517475618f94b6 100644 --- a/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/en/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -24,15 +24,16 @@ A single line of text is used in OpenTSDB line protocol to represent one row of - `metric` will be used as the STable name. - `timestamp` is the timestamp of current row of data. The time precision will be determined automatically based on the length of the timestamp. Second and millisecond time precision are supported. - `value` is a metric which must be a numeric value, The corresponding column name is "value". -- The last part is the tag set separated by spaces, all tags will be converted to nchar type automatically. +- The last part is the tag set separated by spaces, all tags will be converted to NCHAR type automatically. For example: ```txt meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3 ``` -- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify chile table names, for example, `smlChildTableName=tname`. You can insert `meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. -Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_telnet/put.html) for more details. + +- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify child table names, for example, `smlChildTableName=tname`. You can insert `meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. + Please refer to [OpenTSDB Telnet API](http://opentsdb.net/docs/build/html/api_telnet/put.html) for more details. ## Examples @@ -79,6 +80,11 @@ taos> select tbname, * from `meters.current`; t_7e7b26dd860280242c6492a16... | 2022-03-28 09:56:51.250 | 12.600000000 | 2 | California.SanFrancisco | Query OK, 4 row(s) in set (0.005399s) ``` + ## Query Examples -If you want query the data of `location=California.LosAngeles groupid=3`,here is the query sql: -select * from `meters.voltage` where location="California.LosAngeles" and groupid=3 + +If you want query the data of `location=California.LosAngeles groupid=3`,here is the query SQL: + +```sql +SELECT * FROM `meters.current` WHERE location = "California.LosAngeles" AND groupid = 3; +``` diff --git a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx index c0a287e331a8fff32fc975decf1f7e56083406fa..be8f521cf2e7d2ed1364dedc7b523e65af287f4f 100644 --- a/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/en/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -46,10 +46,10 @@ Please refer to [OpenTSDB HTTP API](http://opentsdb.net/docs/build/html/api_http :::note -- In JSON protocol, strings will be converted to nchar type and numeric values will be converted to double type. +- In JSON protocol, strings will be converted to NCHAR type and numeric values will be converted to double type. - Only data in array format is accepted and so an array must be used even if there is only one row. -- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify chile table names, for example, `smlChildTableName=tname`. You can insert `"tags": { "host": "web02","dc": "lga","tname":"cpu1"}` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. -::: +- The defult child table name is generated by rules.You can configure smlChildTableName in taos.cfg to specify child table names, for example, `smlChildTableName=tname`. You can insert `"tags": { "host": "web02","dc": "lga","tname":"cpu1"}` and the cpu1 table will be automatically created. Note that if multiple rows have the same tname but different tag_set values, the tag_set of the first row is used to create the table and the others are ignored. + ::: ## Examples @@ -94,6 +94,11 @@ taos> select * from `meters.current`; 2022-03-28 09:56:51.250 | 12.600000000 | 2.000000000 | California.SanFrancisco | Query OK, 2 row(s) in set (0.004076s) ``` + ## Query Examples -If you want query the data of "tags": {"location": "California.LosAngeles", "groupid": 1},here is the query sql: -select * from `meters.voltage` where location="California.LosAngeles" and groupid=1 + +If you want query the data of "tags": {"location": "California.LosAngeles", "groupid": 1},here is the query SQL: + +```sql +SELECT * FROM `meters.current` WHERE location = "California.LosAngeles" AND groupid = 3; +``` diff --git a/docs/en/07-develop/03-insert-data/05-high-volume.md b/docs/en/07-develop/03-insert-data/05-high-volume.md index 9ea0c884473e670d0624cb3be737830f46bedc38..272a13881372b58a9a66c0d452cda54f9ee8c78c 100644 --- a/docs/en/07-develop/03-insert-data/05-high-volume.md +++ b/docs/en/07-develop/03-insert-data/05-high-volume.md @@ -16,16 +16,16 @@ To achieve high performance writing, there are a few aspects to consider. In the From the perspective of application program, you need to consider: -1. The data size of each single write, also known as batch size. Generally speaking, higher batch size generates better writing performance. However, once the batch size is over a specific value, you will not get any additional benefit anymore. When using SQL to write into TDengine, it's better to put as much as possible data in single SQL. The maximum SQL length supported by TDengine is 1,048,576 bytes, i.e. 1 MB. +1. The data size of each single write, also known as batch size. Generally speaking, higher batch size generates better writing performance. However, once the batch size is over a specific value, you will not get any additional benefit anymore. When using SQL to write into TDengine, it's better to put as much as possible data in single SQL. The maximum SQL length supported by TDengine is 1,048,576 bytes, i.e. 1 MB. 2. The number of concurrent connections. Normally more connections can get better result. However, once the number of connections exceeds the processing ability of the server side, the performance may downgrade. 3. The distribution of data to be written across tables or sub-tables. Writing to single table in one batch is more efficient than writing to multiple tables in one batch. 4. Data Writing Protocol. - - Prameter binding mode is more efficient than SQL because it doesn't have the cost of parsing SQL. - - Writing to known existing tables is more efficient than wirting to uncertain tables in automatic creating mode because the later needs to check whether the table exists or not before actually writing data into it - - Writing in SQL is more efficient than writing in schemaless mode because schemaless writing creats table automatically and may alter table schema + - Parameter binding mode is more efficient than SQL because it doesn't have the cost of parsing SQL. + - Writing to known existing tables is more efficient than writing to uncertain tables in automatic creating mode because the later needs to check whether the table exists or not before actually writing data into it. + - Writing in SQL is more efficient than writing in schemaless mode because schemaless writing creates table automatically and may alter table schema. Application programs need to take care of the above factors and try to take advantage of them. The application progam should write to single table in each write batch. The batch size needs to be tuned to a proper value on a specific system. The number of concurrent connections needs to be tuned to a proper value too to achieve the best writing throughput. @@ -37,7 +37,7 @@ Application programs need to read data from data source then write into TDengine 2. The speed of data generation from single data source is much higher than the speed of single writing thread. The purpose of message queue in this case is to provide buffer so that data is not lost and multiple writing threads can get data from the buffer. 3. The data for single table are from multiple data source. In this case the purpose of message queues is to combine the data for single table together to improve the write efficiency. -If the data source is Kafka, then the appication program is a consumer of Kafka, you can benefit from some kafka features to achieve high performance writing: +If the data source is Kafka, then the application program is a consumer of Kafka, you can benefit from some kafka features to achieve high performance writing: 1. Put the data for a table in single partition of single topic so that it's easier to put the data for each table together and write in batch 2. Subscribe multiple topics to accumulate data together. @@ -56,7 +56,7 @@ This section will introduce the sample programs to demonstrate how to write into ### Scenario -Below are the scenario for the sample programs of high performance wrting. +Below are the scenario for the sample programs of high performance writing. - Application program reads data from data source, the sample program simulates a data source by generating data - The speed of single writing thread is much slower than the speed of generating data, so the program starts multiple writing threads while each thread establish a connection to TDengine and each thread has a message queue of fixed size. @@ -80,7 +80,7 @@ The sample programs assume the source data is for all the different sub tables i | ---------------- | ----------------------------------------------------------------------------------------------------- | | FastWriteExample | Main Program | | ReadTask | Read data from simulated data source and put into a queue according to the hash value of table name | -| WriteTask | Read data from Queue, compose a wirte batch and write into TDengine | +| WriteTask | Read data from Queue, compose a write batch and write into TDengine | | MockDataSource | Generate data for some sub tables of super table meters | | SQLWriter | WriteTask uses this class to compose SQL, create table automatically, check SQL length and write data | | StmtWriter | Write in Parameter binding mode (Not finished yet) | @@ -95,16 +95,16 @@ The main Program is responsible for: 1. Create message queues 2. Start writing threads 3. Start reading threads -4. Otuput writing speed every 10 seconds +4. Output writing speed every 10 seconds The main program provides 4 parameters for tuning: 1. The number of reading threads, default value is 1 -2. The number of writing threads, default alue is 2 +2. The number of writing threads, default value is 2 3. The total number of tables in the generated data, default value is 1000. These tables are distributed evenly across all writing threads. If the number of tables is very big, it will cost much time to firstly create these tables. 4. The batch size of single write, default value is 3,000 -The capacity of message queue also impacts performance and can be tuned by modifying program. Normally it's always better to have a larger message queue. A larger message queue means lower possibility of being blocked when enqueueing and higher throughput. But a larger message queue consumes more memory space. The default value used in the sample programs is already big enoug. +The capacity of message queue also impacts performance and can be tuned by modifying program. Normally it's always better to have a larger message queue. A larger message queue means lower possibility of being blocked when enqueueing and higher throughput. But a larger message queue consumes more memory space. The default value used in the sample programs is already big enough. ```java {{#include docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java}} @@ -179,7 +179,7 @@ TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata" **Launch in IDE** -1. Clone TDengine repolitory +1. Clone TDengine repository ``` git clone git@github.com:taosdata/TDengine.git --depth 1 ``` @@ -282,7 +282,7 @@ Sample programs in Python uses multi-process and cross-process message queues. | run_read_task Function | Read data and distribute to message queues | | MockDataSource Class | Simulate data source, return next 1,000 rows of each table | | run_write_task Function | Read as much as possible data from message queue and write in batch | -| SQLWriter Class | Write in SQL and create table utomatically | +| SQLWriter Class | Write in SQL and create table automatically | | StmtWriter Class | Write in parameter binding mode (not finished yet) |
@@ -292,7 +292,7 @@ Sample programs in Python uses multi-process and cross-process message queues. 1. Monitoring process, initializes database and calculating writing speed 2. Reading process (n), reads data from data source -3. Writing process (m), wirtes data into TDengine +3. Writing process (m), writes data into TDengine `main` function provides 5 parameters: @@ -311,7 +311,7 @@ Sample programs in Python uses multi-process and cross-process message queues.
run_monitor_process -Monitoring process initilizes database and monitoring writing speed. +Monitoring process initializes database and monitoring writing speed. ```python {{#include docs/examples/python/fast_write_example.py:monitor}} @@ -356,7 +356,7 @@ Writing process tries to read as much as possible data from message queue and wr
-SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug. This class also checks the SQL length, and passes the maximum SQL length by parameter maxSQLLength according to actual TDengine limit. +SQLWriter class encapsulates the logic of composing SQL and writing data. Please be noted that the tables have not been created before writing, but are created automatically when catching the exception of table doesn't exist. For other exceptions caught, the SQL which caused the exception are logged for you to debug. This class also checks the SQL length, and passes the maximum SQL length by parameter maxSQLLength according to actual TDengine limit. SQLWriter @@ -372,7 +372,7 @@ SQLWriter class encapsulates the logic of composing SQL and writing data. Please Launch Sample Program in Python -1. Prerequisities +1. Prerequisites - TDengine client driver has been installed - Python3 has been installed, the the version >= 3.8 diff --git a/docs/en/07-develop/index.md b/docs/en/07-develop/index.md index 1ef5e23f72f707f7a9decce6ea0bfed8fd642c0c..34649d32a2f758fda2bd79afbbd8f3427b714353 100644 --- a/docs/en/07-develop/index.md +++ b/docs/en/07-develop/index.md @@ -3,6 +3,7 @@ title: Developer Guide --- Before creating an application to process time-series data with TDengine, consider the following: + 1. Choose the method to connect to TDengine. TDengine offers a REST API that can be used with any programming language. It also has connectors for a variety of languages. 2. Design the data model based on your own use cases. Consider the main [concepts](/concept/) of TDengine, including "one table per data collection point" and the supertable. Learn about static labels, collected metrics, and subtables. Depending on the characteristics of your data and your requirements, you decide to create one or more databases and design a supertable schema that fit your data. 3. Decide how you will insert data. TDengine supports writing using standard SQL, but also supports schemaless writing, so that data can be written directly without creating tables manually. diff --git a/docs/en/14-reference/12-config/index.md b/docs/en/14-reference/12-config/index.md index d91675a0ab7209bdae9b4aa5a80e984c7605f2f9..8053c4d25d527adf3e2c22fd107c7c28114e2eb6 100644 --- a/docs/en/14-reference/12-config/index.md +++ b/docs/en/14-reference/12-config/index.md @@ -675,7 +675,7 @@ To prevent system resource from being exhausted by multiple concurrent streams, | Meaning | Whether to generate core file when server crashes | | Value Range | 0: false, 1: true | | Default Value | 1 | -| Note | The core file is generated under root directory `systemctl/launchctl start taosd` is used to start, or under the working directory if `taosd` is started directly on Linux/macOS Shell. | +| Note | The core file is generated under root directory `systemctl start taosd`/`launchctl start com.tdengine.taosd` is used to start, or under the working directory if `taosd` is started directly on Linux/macOS Shell. | ### udf diff --git a/docs/en/21-tdinternal/01-arch.md b/docs/en/21-tdinternal/01-arch.md index 2f876adffc2543bb9f117e5812ccc5241d7a6d99..a938084eb1ee76e85c076b13335e0ce813bf7a7c 100644 --- a/docs/en/21-tdinternal/01-arch.md +++ b/docs/en/21-tdinternal/01-arch.md @@ -5,7 +5,7 @@ title: Architecture ## Cluster and Primary Logic Unit -The design of TDengine is based on the assumption that any hardware or software system is not 100% reliable and that no single node can provide sufficient computing and storage resources to process massive data. Therefore, since day one, TDengine has been designed as a natively distributed system, with high-reliability architecture. Hardware failure or software failure of a single, or even multiple servers will not affect the availability and reliability of the system. At the same time, through node virtualization and automatic load-balancing technology, TDengine can make the most efficient use of computing and storage resources in heterogeneous clusters to reduce hardware resource needs, significantly. +The design of TDengine is based on the assumption that any hardware or software system is not 100% reliable and that no single node can provide sufficient computing and storage resources to process massive data. Therefore, since day one, TDengine has been designed as a natively distributed system, with high-reliability architecture, and can be scaled out easily. Hardware failure or software failure of a single, or even multiple servers will not affect the availability and reliability of the system. At the same time, through node virtualization and automatic load-balancing technology, TDengine can make the most efficient use of computing and storage resources in heterogeneous clusters to reduce hardware resource needs significantly. ### Primary Logic Unit @@ -15,44 +15,50 @@ Logical structure diagram of TDengine's distributed architecture is as follows:
Figure 1: TDengine architecture diagram
-A complete TDengine system runs on one or more physical nodes. Logically, it includes data node (dnode), TDengine client driver (TAOSC) and application (app). There are one or more data nodes in the system, which form a cluster. The application interacts with the TDengine cluster through TAOSC's API. The following is a brief introduction to each logical unit. +A complete TDengine system runs on one or more physical nodes. Logically, a complete system includes data node (dnode), TDengine client driver (TAOSC) and application (app). There are one or more data nodes in the system, which form a cluster. The application interacts with the TDengine cluster through TDengine client driver (TAOSC). The following is a brief introduction to each logical unit. **Physical node (pnode)**: A pnode is a computer that runs independently and has its own computing, storage and network capabilities. It can be a physical machine, virtual machine, or Docker container installed with OS. The physical node is identified by its configured FQDN (Fully Qualified Domain Name). TDengine relies entirely on FQDN for network communication. If you don't know about FQDN, please check [wikipedia](https://en.wikipedia.org/wiki/Fully_qualified_domain_name). -**Data node (dnode):** A dnode is a running instance of the TDengine server-side execution code taosd on a physical node (pnode). A working system must have at least one data node. A dnode contains zero to multiple logical virtual nodes (VNODE) and zero or at most one logical management node (mnode). The unique identification of a dnode in the system is determined by the instance's End Point (EP). EP is a combination of FQDN (Fully Qualified Domain Name) of the physical node where the dnode is located and the network port number (Port) configured by the system. By configuring different ports, a physical node (a physical machine, virtual machine or container) can run multiple instances or have multiple data nodes. +**Data node (dnode):** A dnode is a running instance of the TDengine server `taosd` on a physical node (pnode). A working system must have at least one data node. A dnode contains zero to multiple virtual nodes (VNODE) and zero or at most one management node (mnode). The unique identification of a dnode in the system is determined by the instance's End Point (EP). EP is a combination of FQDN (Fully Qualified Domain Name) of the physical node where the dnode is located and the network port number (Port) configured by the system. By configuring different ports, a physical node (a physical machine, virtual machine or container) can run multiple instances or have multiple data nodes. -**Virtual node (vnode)**: To better support data sharding, load balancing and prevent data from overheating or skewing, data nodes are virtualized into multiple virtual nodes (vnode, V2, V3, V4, etc. in the figure). Each vnode is a relatively independent work unit, which is the basic unit of time-series data storage and has independent running threads, memory space and persistent storage path. A vnode contains a certain number of tables (data collection points). When a new table is created, the system checks whether a new vnode needs to be created. The number of vnodes that can be created on a data node depends on the capacity of the hardware of the physical node where the data node is located. A vnode belongs to only one DB, but a DB can have multiple vnodes. In addition to the stored time-series data, a vnode also stores the schema and tag values of the included tables. A virtual node is uniquely identified in the system by the EP of the data node and the VGroup ID to which it belongs and is created and managed by the management node. +**Virtual node (vnode)**: To better support data sharding, load balancing and prevent data from overheating or skewing, data nodes are virtualized into multiple virtual nodes (vnode, V2, V3, V4, etc. in the figure). Each vnode is a relatively independent work unit, which is the basic unit of time-series data storage and has independent running threads, memory space and persistent storage path. A vnode contains a certain number of tables (data collection points). When a database is created, some vnodes are created for the database. The number of vnodes that can be created on a specific dnode depends on the available system resources. Each vnode must belong to a single DB, while each DB can have multiple vnodes. Each vnodes stores time series data plus the schema, tags of the tables hosted by it. A vnode is identified by the EP of the dnode it belongs to and the unique ID of the vgruop it belongs to. Vgroups are created and managed by mnode. -**Management node (mnode)**: A virtual logical unit responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes (M in the figure). At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 3) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). The leader/follower mechanism is adopted for the mnode group and the data synchronization is carried out in a strongly consistent way. Any data update operation can only be executed on the leader. The creation of mnode cluster is completed automatically by the system without manual intervention. There is at most one mnode on each dnode, which is uniquely identified by the EP of the data node to which it belongs. Each dnode automatically obtains the EP of the dnode where all mnodes in the whole cluster are located, through internal messaging interaction. +**Management node (mnode)**: A virtual logical unit (M in the figure) responsible for monitoring and maintaining the running status of all data nodes and load balancing among nodes. At the same time, the management node is also responsible for the storage and management of metadata (including users, databases, tables, static tags, etc.), so it is also called Meta Node. Multiple (up to 3) mnodes can be configured in a TDengine cluster, and they are automatically constructed into a virtual management node group (M0, M1, M2 in the figure). mnode adopts RAFT protocol to guarantee high data availability and high data reliability. Any data operation can only be performed through the Leader in the RAFT group. The first mnode in the mnode RAFT group is created automatically when the first dnode of the cluster is deployed. Other two follower mnodes need to be created through SQL command in TDengine CLI. There can be at most one mnode in a single dnode, and the mnode is identified by the EP of the dnode where it's located. Each dnode can communicate with each other to automatically get the EP of all mnodes. -**Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed in a leader/follower mechanism. Write operations can only be performed on the leader vnode, and then replicated to follower vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `“replica”` when creating a DB, and the default is 1. Using the multi-replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node groups are created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID. If two virtual nodes have the same vnode group ID, it means that they belong to the same group and the data is backed up to each other. The number of virtual nodes in a virtual node group can be dynamically changed, allowing only one, that is, no data replication. VGroup ID is never changed. Even if a virtual node group is deleted, its ID will not be reused. +**Computation node (qnode)**: A virtual logical unit (Q in the figure) responsible for executing query and computing tasks including the `show` commands based on system built-in tables. There can be multiple qnodes configured in a TDengine cluster to share the query and computing tasks. A qnode is not coupled with a specific database, that means each qnode can execute the query tasks for multiple databases in parallel. There can be at most one qnode in a single dnode, and the qnode is identified by the EP of the dnode. TDengine client driver can get the list of qnodes through the communication with mnode. If there is no qnode available in the system, query and computing tasks are executed by vnodes. When a query task is executed, according to the execution plan, one or more qnodes may be scheduled by the scheduler to execute the task. qnode can get data from vnode, and send the execution result to other qnodes for further processing. With introducing qnodes, TDengine achieves the separation between storage and computing. -**TAOSC**: TAOSC is the driver provided by TDengine to applications. It is responsible for dealing with the interaction between application and cluster, and provides the native interface for the C/C++ language. It is also embedded in the JDBC, C #, Python, Go, Node.js language connection libraries. Applications interact with the whole cluster through TAOSC instead of directly connecting to data nodes in the cluster. This module is responsible for obtaining and caching metadata; forwarding requests for insertion, query, etc. to the correct data node; when returning the results to the application, TAOSC also needs to be responsible for the final level of aggregation, sorting, filtering and other operations. For JDBC, C/C++/C#/Python/Go/Node.js interfaces, this module runs on the physical node where the application is located. At the same time, in order to support the fully distributed RESTful interface, TAOSC has a running instance on each dnode of TDengine cluster. +**Stream Processing node (snode)**: A virtual logical unit (S in the figure) responsible for stream processing tasks is introduced in TDengine. There can be multiple snodes configured in a TDengine cluster to share the burden of stream processing tasks. snode is not coupled with a specific stream, that means a single snode can execute the tasks of multiple streams. There can be at most one snode in a single dnode, it's identified by the EP of the dnode. mnode schedules available snodes to perform the stream processing tasks. If there is no snode available in the system, stream processing tasks are executed in vnodes. + +**Virtual node group (VGroup)**: Vnodes on different data nodes can form a virtual node group to ensure the high availability of the system. The virtual node group is managed using RAFT protocol. Write operations can only be performed on the leader vnode, and then replicated to follower vnodes, thus ensuring that one single replica of data is copied on multiple physical nodes. The number of virtual nodes in a vgroup equals the number of data replicas. If the number of replicas of a DB is N, the system must have at least N data nodes. The number of replicas can be specified by the parameter `replica` when creating a DB, and the default is 1. Using the multiple replication feature of TDengine, the same high data reliability can be achieved without the need for expensive storage devices such as disk arrays. Virtual node groups are created and managed by the management node, and the management node assigns a system unique ID, aka VGroup ID, to each vgroup. Virtual nodes with the same vnode group ID belong to the same vgroup. If `replica` is set to 1, it means no data replication. The number of replication for a database can be dynamically changed to 3 for high data reliability. Even if a virtual node group is deleted, its ID will not be reused. + +**TDengine client driver**: TAOSC is the abbreviation for TDengine client driver provided by TDengine to applications. It is responsible for dealing with the interaction between applications and the cluster, and provides the native interface for the C/C++ language. It is also embedded in the JDBC, C #, Python, Go, Node.js language connection libraries. Applications interact with the whole cluster through TDengine client driver instead of directly connecting to data nodes in the cluster. This module is responsible for obtaining and caching metadata; forwarding requests for insertion, query, etc, to the correct data node; when returning the results to the application, TAOSC also needs to be responsible for the final aggregation, sorting, filtering and other operations. For JDBC, C/C++/C#/Python/Go/Node.js interfaces, this module runs on the physical node where the application is located. Another critical component in TDengine product, named `taosAdapter` which provides fully distributed RESTful interface, also invokes TDengine client driver to communicate with TDengine cluster. ### Node Communication -**Communication mode**: The communication among each data node of TDengine system, and among the client driver and each data node is carried out through TCP/UDP. Considering an IoT scenario, the data writing packets are generally not large, so TDengine uses UDP in addition to TCP for transmission, because UDP is more efficient and is not limited by the number of connections. TDengine implements its own timeout, retransmission, confirmation and other mechanisms to ensure reliable transmission of UDP. For packets with a data volume of less than 15K, UDP is adopted for transmission, and TCP is automatically adopted for transmission of packets with a data volume of more than 15K or query operations. At the same time, TDengine will automatically compress/decompress the data, digitally sign/authenticate the data according to the configuration and data packet. For data replication among data nodes, only TCP is used for data transportation. +**Communication mode**: The communication among data nodes of TDengine system, and among the client driver and each data node is carried out through TCP. TDengine automatically compress/decompress data and sign/authorize according to configuration and data packets. + +**FQDN configuration:** A data node may have one or more FQDNs, which can be specified with the parameter `fqdn` in the system configuration file `taos.cfg`. If it is not specified, TDengine will automatically use the hostname of the computer as its FQDN. IP address also can be used to configure `fqdn` but it's not a recommended way because IP address may vary. Once the IP address is changed, the whole TDengine cluster will not work. The end point of a data node is composed of FQDN and prot number. It is necessary to ensure the DNS service is running or hosts files on nodes are configured properly to make sure FQDN works. -**FQDN configuration:** A data node has one or more FQDNs, which can be specified in the system configuration file taos.cfg with the parameter “fqdn”. If it is not specified, the system will automatically use the hostname of the computer as its FQDN. If the node is not configured with FQDN, you can directly set the configuration parameter “fqdn” of the node to its IP address. However, IP is not recommended because IP address may be changed, and once it changes, the cluster will not work properly. The EP (End Point) of a data node consists of FQDN + Port. With FQDN, it is necessary to ensure the DNS service is running, or hosts files on nodes are configured properly. +**Port configuration**: The port of a data node is configured with parameter `serverPort` in `taosc.cfg`. -**Port configuration**: The external port of a data node is determined by the system configuration parameter “serverPort” in TDengine, and the port for internal communication of cluster is serverPort+5. The data replication operation among data nodes in the cluster also occupies a TCP port, which is serverPort+10. In order to support multithreading and efficient processing of UDP data, each internal and external UDP connection needs to occupy 5 consecutive ports. Therefore, the total port range of a data node will be serverPort to serverPort + 10, for a total of 11 TCP/UDP ports. To run the system, make sure that the firewall keeps these ports open. Each data node can be configured with a different serverPort. +**Cluster external connection**: TDengine cluster can accommodate a single, multiple or even thousands of data nodes. The application only needs to initiate a connection to any data node in the cluster. The network parameter required for connection is the End Point (FQDN plus configured port number) of a data node. When starting TDengine CLI `taos`, the FQDN of the data node can be specified through the option `-h`, and the configured port number can be specified through `-p`. If the port is not configured, the configuration parameter `serverPort` of TDengine will be used. -**Cluster external connection**: TDengine cluster can accommodate a single, multiple or even thousands of data nodes. The application only needs to initiate a connection to any data node in the cluster. The network parameter required for connection is the End Point (FQDN plus configured port number) of a data node. When starting the application taos through CLI, the FQDN of the data node can be specified through the option `-h`, and the configured port number can be specified through `-p`. If the port is not configured, the system configuration parameter “serverPort” of TDengine will be adopted. +**Inter-cluster communication**: Data nodes connect with each other through TCP. When a data node starts, it will obtain the EP of the dnode where the mnode is located, and then establish a connection with the mnode to exchange information. There are three steps to obtain EP information of the mnode: -**Inter-cluster communication**: Data nodes connect with each other through TCP/UDP. When a data node starts, it will obtain the EP information of the dnode where the mnode is located, and then establish a connection with the mnode in the system to exchange information. There are three steps to obtain EP information of the mnode: +1. Check whether `dnode.json` file exists, if it does not exist or cannot be opened normally, skip to the second step; +2. Check the system configuration file `taos.cfg` to obtain node configuration parameters `firstEp` and `secondEp` (the nodes specified by these two parameters can be a normal node without mnode, in this case the node will try to redirect to the mnode node when connected). If these two configuration parameters do not exist or do not exist in taos.cfg or are invalid, skip to the third step; +3. Set your own EP as a mnode EP and run it independently. -1. Check whether the mnodeEpList file exists, if it does not exist or cannot be opened normally to obtain EP information of the mnode, skip to the second step; -2. Check the system configuration file taos.cfg to obtain node configuration parameters “firstEp” and “secondEp” (the node specified by these two parameters can be a normal node without mnode, in this case, the node will try to redirect to the mnode node when connected). If these two configuration parameters do not exist or do not exist in taos.cfg, or are invalid, skip to the third step; -3. Set your own EP as a mnode EP and run it independently. After obtaining the mnode EP list, the data node initiates the connection. It will successfully join the working cluster after connection. If not successful, it will try the next item in the mnode EP list. If all attempts are made, but the connection still fails, sleep for a few seconds before trying again. +After obtaining the mnode EP list, the data node initiates the connection. It will successfully join the working cluster after connection is established successfully. If not successful, it will try the next item in the mnode EP list. If all attempts failed, the dnode will sleep for a few seconds and try again. -**The choice of MNODE**: TDengine logically has a management node, but there is no separate execution code. The server-side only has one set of execution code, taosd. So which data node will be the management node? This is determined automatically by the system without any manual intervention. The principle is as follows: when a data node starts, it will check its End Point and compare it with the obtained mnode EP List. If its EP exists in it, the data node shall start the mnode module and become a mnode. If your own EP is not in the mnode EP List, the mnode module will not start. During the system operation, due to load balancing, downtime and other reasons, mnode may migrate to the new dnode, totally transparently and without manual intervention. The modification of configuration parameters is the decision made by mnode itself according to resources usage. +**Create MNODE**: The management node (mnode) in TDengine is a logical node without specific process. In other words, mnode also runs in a dnode, which is a real process on operating system. So which data node will be the management node? This is determined automatically by the system without any manual intervention. The principle is as follows: when the first dnode in the cluster starts, it becomes mnode automatically, and the other mnodes need to be created using SQL in TDengine CLI. -**Add new data nodes:** After the system has a data node, it has become a working system. There are two steps to add a new node into the cluster. +**Add new data nodes:** After the first data node starts successfully, the system can begin to work. There are two steps to add a new data node into the cluster. -- Step1: Connect to the existing working data node using TDengine CLI, and then add the End Point of the new data node with the command "create dnode" -- Step 2: In the system configuration parameter file taos.cfg of the new data node, set the “firstEp” and “secondEp” parameters to the EP of any two data nodes in the existing cluster. Please refer to the user tutorial for detailed steps. In this way, the cluster will be established step by step. +- Step : Connect to the existing working data node using TDengine CLI, and then add the End Point of the new data node with the command "create dnode" +- Step 2: In the system configuration parameter file `taos.cfg` of the new data node, set the `firstEp` and `secondEp` parameters to the EP of any two data nodes in the existing cluster. If there is only one existing data node in the system, skip parameter `secondEp`. Please refer to the user tutorial for detailed steps. In this way, the cluster will be established step by step. -**Redirection**: Regardless of dnode or TAOSC, the connection to the mnode is initiated first. The mnode is automatically created and maintained by the system, so the user does not know which dnode is running the mnode. TDengine only requires a connection to any working dnode in the system. Because any running dnode maintains the currently running mnode EP List, when receiving a connecting request from the newly started dnode or TAOSC, if it’s not an mnode itself, it will reply to the mnode with the EP List. After receiving this list, TAOSC or the newly started dnode will try to establish the connection again. When the mnode EP List changes, each data node quickly obtains the latest list and notifies TAOSC through messaging interaction among nodes. +**Redirection**: Regardless of dnode or TAOSC, the connection to the mnode is initiated first. The mnode is automatically created and maintained by the system, so the user does not know which dnode is running the mnode. TDengine only requires a connection to any working dnode in the system. Because any running dnode maintains the currently running mnode EP List, when receiving a connecting request from the newly started dnode or TAOSC, if it’s not an mnode itself, it will reply to the connection initiator with the mnode EP List. After receiving this list, TAOSC or the newly started dnode will try to establish the connection again with mnode. When the mnode EP List changes, each data node quickly obtains the latest list and notifies TAOSC through messaging interaction among nodes. ### A Typical Data Writing Process @@ -62,18 +68,20 @@ To explain the relationship between vnode, mnode, TAOSC and application and thei
Figure 2: Typical process of TDengine
-1. Application initiates a request to insert data through JDBC, ODBC, or other APIs. -2. TAOSC checks the cache to see if meta data exists for the table. If it does, it goes straight to Step 4. If not, TAOSC sends a get meta-data request to mnode. -3. Mnode returns the meta-data of the table to TAOSC. Meta-data contains the schema of the table, and also the vgroup information to which the table belongs (the vnode ID and the End Point of the dnode where the table belongs. If the number of replicas is N, there will be N groups of End Points). If TAOSC does not receive a response from the mnode for a long time, and there are multiple mnodes, TAOSC will send a request to the next mnode. -4. TAOSC initiates an insert request to leader vnode. -5. After vnode inserts the data, it gives a reply to TAOSC, indicating that the insertion is successful. If TAOSC doesn't get a response from vnode for a long time, TAOSC will treat this node as offline. In this case, if there are multiple replicas of the inserted database, TAOSC will issue an insert request to the next vnode in vgroup. -6. TAOSC notifies APP that writing is successful. +1. Application initiates a request to insert data through JDBC, or other APIs. +2. TAOSC checks the cache to see if the vgroups-info for the database being requested to insert data exists. If the vgroups-info exists, it goes straight to Step 4. Otherwise, TAOSC sends a get meta-data request to mnode. +3. Mnode returns the vgroups-info of the database to TAOSC. The vgroups-info contains the distribution of the vgroups of the database, and also the vgroup information to which the table belongs (the vnode ID and the End Point of the dnode where the table belongs. If the number of replicas is N, there will be N groups of End Points). If TAOSC does not receive a response from the mnode for a long time, and there are multiple mnodes, TAOSC will send a request to the next mnode. +4. TAOSC checks to see whether the metadata for the table to be inserted is in cache. If yes, skip to step 6; otherwise taosc sends a request to corresponding to get the metadata for the table. +5. vnode returns the metadata for the table to TAOSC, the metadata includes the table's schema. +6. TAOSC initiates an insert request to leader vnode of the table. +7. After vnode inserts the data, it gives a reply to TAOSC, indicating that the insertion is successful. If TAOSC doesn't get a response from vnode for a long time, TAOSC will treat this node as offline. In this case, if there are multiple replicas of the inserted database, TAOSC will issue an insert request to the next vnode in vgroup. +8. TAOSC notifies APP that writing is successful. -For Step 2 and 3, when TAOSC starts, it does not know the End Point of mnode, so it will directly initiate a request to the configured serving End Point of the cluster. If the dnode that receives the request does not have a mnode configured, it will reply with the mnode EP list, so that TAOSC will re-issue a request to obtain meta-data to the EP of another mnode. +For Step 2, when TAOSC starts, it does not know the End Point of mnode, so it will directly initiate a request to the configured serving End Point of the cluster. If the dnode that receives the request does not have a mnode configured, it will reply with the mnode EP list, so that TAOSC will re-issue a request to the EP of another mnode to obtain meta-data . -For Step 4 and 5, without caching, TAOSC can't recognize the leader in the virtual node group, so assumes that the first vnode is the leader and sends a request to it. If this vnode is not the leader, it will reply to the actual leader as a new target to which TAOSC shall send a request. Once a response of successful insertion is obtained, TAOSC will cache the information of leader node. +For Step 4 and 6, without caching, TAOSC can't recognize the leader in the virtual node group, so assumes that the first vnode is the leader and sends a request to it. If this vnode is not the leader, it will reply to TAOSC with the actual leader, then TAOC will send a request to the true leader. Once a response of successful insertion is obtained, TAOSC will cache the information of leader node for further use. -The above describes the process of inserting data. The processes of querying and computing are the same. TAOSC encapsulates and hides all these complicated processes, and it is transparent to applications. +The above flow describes the process of inserting data. The process of querying and computing are similar. TAOSC encapsulates and hides all these complicated processes so that it is transparent to applications. Through TAOSC caching mechanism, mnode needs to be accessed only when a table is accessed for the first time, so mnode will not become a system bottleneck. However, because schema and vgroup may change (such as load balancing), TAOSC will interact with mnode regularly to automatically update the cache. @@ -81,15 +89,15 @@ Through TAOSC caching mechanism, mnode needs to be accessed only when a table is ### Storage Model -The data stored by TDengine includes collected time-series data, metadata related to database and tables, tag data, etc. All of the data is specifically divided into three parts: +The data stored by TDengine includes collected time-series data, metadata and tag data related to database and tablesetc. All of the data is specifically divided into three parts: -- Time-series data: stored in vnode and composed of data, head and last files. The amount of data is large and query amount depends on the application scenario. Out-of-order writing is allowed, but delete operation is not supported for the time being, and update operation is only allowed when database “update” parameter is set to 1. By adopting the model with **one table for each data collection point**, the data of a given time period is continuously stored, and the writing against one single table is a simple appending operation. Multiple records can be read at one time, thus ensuring the best performance for both insert and query operations of a single data collection point. -- Tag data: meta files stored in vnode. Four standard operations of create, read, update and delete are supported. The amount of data is not large. If there are N tables, there are N records, so all can be stored in memory. To make tag filtering efficient, TDengine supports multi-core and multi-threaded concurrent queries. As long as the computing resources are sufficient, even with millions of tables, the tag filtering results will return in milliseconds. -- Metadata: stored in mnode and includes system node, user, DB, table schema and other information. Four standard operations of create, delete, update and read are supported. The amount of this data is not large and can be stored in memory. Moreover, the number of queries is not large because of client cache. Even though TDengine uses centralized storage management, because of the architecture, there is no performance bottleneck. +- Time-series data: stored in vnode and composed of data, head and last files. Normally the amount of time series data is very huge and query amount depends on the application scenario. Out-of-order writing is allowed. By adopting the model with **one table for each data collection point**, the data of a given time period is continuously stored, and the writing against one single table is a simple appending operation. Multiple records can be read at one time, thus ensuring the best performance for both insert and query operations of a single data collection point. +- Table Metadata: table meta data includes tags and table schema and is stored in meta file in each vnode. CRUD can be operated on table metadata. There is a specific record for each table, so the amount of table meta data depends on the number of tables. Table meta data is stored in LRU model and supports index for tag data. TDengine can support multiple queries in parallel. As long as the memory resource is enough, meta data is all stored in memory for quick access. The filtering on tens of millions of tags can be finished in a few milliseconds. Even though when the memory resource is not sufficient, TDengine can still perform high speed query on tens of millions of tables. +- Database Metadata: stored in mnode and includes system node, user, DB, table schema and other information. Four standard operations of create, delete, update and read are supported. The amount of this data is not large and can be stored in memory. Moreover, the number of queries is not large because of client cache. Even though TDengine uses centralized storage management, because of the architecture, there is no performance bottleneck. Compared with the typical NoSQL storage model, TDengine stores tag data and time-series data completely separately. This has two major advantages: -- Reduces the redundancy of tag data storage significantly. General NoSQL database or time-series database adopts K-V (key-value) storage, in which the key includes a timestamp, a device ID and various tags. Each record carries these duplicated tags, so storage space is wasted. Moreover, if the application needs to add, modify or delete tags on historical data, it has to traverse the data and rewrite them again, which is an extremely expensive operation. +- Reduces the redundancy of tag data storage significantly. General NoSQL database or time-series database adopts K-V (key-value) storage, in which the key includes a timestamp, a device ID and various tags. Each record carries these duplicated tags, so much storage space is wasted. Moreover, if the application needs to add, modify or delete tags on historical data, it has to traverse the data and rewrite them again, which is an extremely expensive operation. - Aggregate data efficiently between multiple tables: when aggregating data between multiple tables, it first finds the tables which satisfy the filtering conditions, and then finds the corresponding data blocks of these tables. This greatly reduces the data sets to be scanned which in turn improves the aggregation efficiency. Moreover, tag data is managed and maintained in a full-memory structure, and tag data queries in tens of millions can return in milliseconds. ### Data Sharding @@ -106,36 +114,26 @@ The meta data of each table (including schema, tags, etc.) is also stored in vno ### Data Partitioning -In addition to vnode sharding, TDengine partitions the time-series data by time range. Each data file contains only one time range of time-series data, and the length of the time range is determined by the database configuration parameter `“days”`. This method of partitioning by time range is also convenient to efficiently implement data retention policies. As long as the data file exceeds the specified number of days (system configuration parameter `“keep”`), it will be automatically deleted. Moreover, different time ranges can be stored in different paths and storage media, so as to facilitate tiered-storage. Cold/hot data can be stored in different storage media to significantly reduce storage costs. +In addition to vnode sharding, TDengine partitions the time-series data by time range. Each data file contains only one time range of time-series data, and the length of the time range is determined by the database configuration parameter `duration`. This method of partitioning by time range is also convenient to efficiently implement data retention policies. As long as the data file exceeds the specified number of days (system configuration parameter `keep`), it will be automatically deleted. Moreover, different time ranges can be stored in different paths and storage media, so as to facilitate tiered-storage. Cold/hot data can be stored in different storage media to significantly reduce storage costs. In general, **TDengine splits big data by vnode and time range in two dimensions** to manage the data efficiently with horizontal scalability. -### Load Balancing - -Each dnode regularly reports its status (including hard disk space, memory size, CPU, network, number of virtual nodes, etc.) to the mnode (virtual management node) so that the mnode knows the status of the entire cluster. Based on the overall status, when the mnode finds a dnode is overloaded, it will migrate one or more vnodes to other dnodes. During the process, TDengine services keep running and the data insertion, query and computing operations are not affected. - -If the mnode has not received the dnode status for a period of time, the dnode will be treated as offline. If the dnode stays offline beyond the time configured by parameter `“offlineThreshold”`, the dnode will be forcibly removed from the cluster by mnode. If the number of replicas of vnodes on this dnode is greater than one, the system will automatically create new replicas on other dnodes to ensure the replica number. If there are other mnodes on this dnode and the number of mnodes replicas is greater than one, the system will automatically create new mnodes on other dnodes to ensure the replica number. - -When new data nodes are added to the cluster, with new computing and storage resources, the system will automatically start the load balancing process. - -The load balancing process does not require any manual intervention, and it is transparent to the application. **Note: load balancing is controlled by parameter “balance”, which determines to turn on/off automatic load balancing.** - ## Data Writing and Replication Process -If a database has N replicas, a virtual node group has N virtual nodes. But only one is the Leader and all others are slaves. When the application writes a new record to system, only the Leader vnode can accept the writing request. If a follower vnode receives a writing request, the system will notifies TAOSC to redirect. +TDengine utilizes RAFT protocol to replicate data. If a database has N replicas, a virtual node group has N virtual nodes, N can be either 1 or 3. In each vnode group, only one is the Leader and all others are followers. When the application writes a new record to system, only the Leader vnode can accept the writing request. If a follower vnode receives a writing request, the system will notify TAOSC to redirect the request to the leader. ### Leader vnode Writing Process Leader Vnode uses a writing process as follows: -![TDengine Database Leader Writing Process](write_master.webp) +![TDengine Database Leader Writing Process](write_leader.webp)
Figure 3: TDengine Leader writing process
1. Leader vnode receives the application data insertion request, verifies, and moves to next step; -2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; -3. If there are multiple replicas, vnode will forward data packet to follower vnodes in the same virtual node group, and the forwarded packet has a version number with data; -4. Write into memory and add the record to “skip list”; +2. Leader vnode will write the original request packet into database log file WAL. If the database configuration parameter `“wal_level”` is set to 1, vnode doesn't invoked fsync. If `wal_level` is set to 2, fsync is invoked according to another database parameter `wal_fsync_period`. +3. If there are multiple replicas, the leader vnode will forward data packet to follower vnodes in the same virtual node group, and the forwarded packet has a version number with data; +4. Leader vnode Writes the data into memory and add the record to “skip list”; 5. Leader vnode returns a confirmation message to the application, indicating a successful write. 6. If any of Step 2, 3 or 4 fails, the error will directly return to the application. @@ -143,74 +141,53 @@ Leader Vnode uses a writing process as follows: For a follower vnode, the write process as follows: -![TDengine Database Follower Writing Process](write_slave.webp) +![TDengine Database Follower Writing Process](write_follower.webp)
Figure 4: TDengine Follower Writing Process
1. Follower vnode receives a data insertion request forwarded by Leader vnode; -2. If the system configuration parameter `“walLevel”` is greater than 0, vnode will write the original request packet into database log file WAL. If walLevel is set to 2 and fsync is set to 0, TDengine will make WAL data written immediately to ensure that even system goes down, all data can be recovered from database log file; +2. The behavior regarding `wal_level` and `wal_fsync_period` in a follower vnode is same as the leader vnode. 3. Write into memory and add the record to “skip list”. -Compared with Leader vnode, follower vnode has no forwarding or reply confirmation step, means two steps less. But writing into memory and WAL is exactly the same. - -### Remote Disaster Recovery and IDC (Internet Data Center) Migration - -As discussed above, TDengine writes using Leader and Follower processes. TDengine adopts asynchronous replication for data synchronization. This method can greatly improve write performance, with no obvious impact from network delay. By configuring IDC and rack number for each physical node, it can be ensured that for a virtual node group, virtual nodes are composed of physical nodes from different IDC and different racks, thus implementing remote disaster recovery without other tools. - -On the other hand, TDengine supports dynamic modification of the replica number. Once the number of replicas increases, the newly added virtual nodes will immediately enter the data synchronization process. After synchronization is complete, added virtual nodes can provide services. In the synchronization process, leader and other synchronized virtual nodes keep serving. With this feature, TDengine can provide IDC migration without service interruption. It is only necessary to add new physical nodes to the existing IDC cluster, and then remove old physical nodes after the data synchronization is completed. - -However, the asynchronous replication has a very low probability scenario where data may be lost. The specific scenario is as follows: - -1. Leader vnode has finished its 5-step operations, confirmed the success of writing to APP, and then goes down; -2. Follower vnode receives the write request, then processing fails before writing to the log in Step 2; -3. Follower vnode will become the new leader, thus losing one record. - -In theory, for asynchronous replication, there is no guarantee to prevent data loss. However, this is an extremely low probability scenario as described above. - -Note: Remote disaster recovery and no-downtime IDC migration are only supported by Enterprise Edition. **Hint: This function is not available yet** +Compared with Leader vnode, follower vnode has no forwarding or reply confirmation step. But writing into memory and WAL is exactly the same. ### Leader/follower Selection -Vnode maintains a version number. When memory data is persisted, the version number will also be persisted. For each data update operation, whether it is time-series data or metadata, this version number will be increased by one. - -When a vnode starts, the roles (leader, follower) are uncertain, and the data is in an unsynchronized state. It’s necessary to establish TCP connections with other nodes in the virtual node group and exchange status, including version and its own roles. Through the exchange, the system implements a leader-selection process. The rules are as follows: +Vnode maintains a version number. When memory data is persisted, the version number is also persisted. For each data update operation, whether it is time-series data or metadata, this version number will be increased by one. -1. If there’s only one replica, it’s always leader -2. When all replicas are online, the one with latest version is leader -3. Over half of online nodes are virtual nodes, and some virtual node is follower, it will automatically become leader -4. For 2 and 3, if multiple virtual nodes meet the requirement, the first vnode in virtual node group list will be selected as leader. +When a vnode starts, its role (leader, follower) is uncertain, and the data is in an unsynchronized state. It’s necessary to establish TCP connections with other vnodes in the virtual node group and exchange status, including version and its own role. Through the exchange, the system implements a leader-selection process according to standard RAFT protocol. ### Synchronous Replication -For scenarios with strong data consistency requirements, asynchronous data replication is not applicable, because there is a small probability of data loss. So, TDengine provides a synchronous replication mechanism for users. When creating a database, in addition to specifying the number of replicas, user also needs to specify a new parameter “quorum”. If quorum is greater than one, it means that every time the Leader forwards a message to the replica, it needs to wait for “quorum-1” reply confirms before informing the application that data has been successfully written in follower. If “quorum-1” reply confirms are not received within a certain period of time, the leader vnode will return an error to the application. +For scenarios with strong data consistency requirements, asynchronous data replication is not enough, because there is a small probability of data loss. So, TDengine provides a synchronous replication mechanism for users to choose. When creating a database, in addition to specifying the number of replicas by parameter `replica`, user also needs to specify a new parameter `strict`. If `strict` is set to 1, it means the leader vnode can return success to the client only after over half of the followers vnodes have confirmed the data has been replicated to them. If any follower vnode is offline and the leader vnode can't get confirmation from over half of follower vnodes, the leader vnode will return failure to the client. -With synchronous replication, performance of system will decrease and latency will increase. Because metadata needs strong consistency, the default for data synchronization between mnodes is synchronous replication. +With synchronous replication, the system performance will decrease and latency will increase. Because metadata needs strong consistency, the default policy for data replication between mnodes is synchronous mode. ## Caching and Persistence ### Caching -TDengine adopts a time-driven cache management strategy (First-In-First-Out, FIFO), also known as a Write-driven Cache Management Mechanism. This strategy is different from the read-driven data caching mode (Least-Recent-Used, LRU), which directly puts the most recently written data in the system buffer. When the buffer reaches a threshold, the earliest data are written to disk in batches. Generally speaking, for the use of IoT data, users are most concerned about the most recently generated data, that is, the current status. TDengine takes full advantage of this feature to put the most recently arrived (current state) data in the buffer. +TDengine adopts a time-driven cache management strategy (First-In-First-Out, FIFO), also known as a Write-driven Cache Management Mechanism. This strategy is different from the read-driven data caching mode (Least-Recent-Used, LRU), it directly puts the most recently written data in the system buffer. When the buffer reaches a threshold, the earliest data are written to disk in batches. Generally speaking, for the use of IoT data, users are most concerned about the most recently generated data, that is, the current status. TDengine takes full advantage of this feature to put the most recently arrived (current state) data in the buffer. -TDengine provides millisecond-level data collecting capability to users through query functions. Putting the recently arrived data directly in the buffer can respond to users' analysis query for the latest piece or batch of data more quickly, and provide faster database query response capability as a whole. In this sense, **TDengine can be used as a data cache by setting appropriate configuration parameters without deploying Redis or other additional cache systems**. This can effectively simplify the system architecture and reduce operational costs. It should be noted that after TDengine is restarted, the buffer of the system will be emptied, the previously cached data will be written to disk in batches, and the previously cached data will not be reloaded into the buffer. In this sense, TDengine's cache differs from proprietary key-value cache systems. +TDengine provides millisecond-level data collecting capability to users through query functions. Putting the recently arrived data directly in the buffer can respond to users' analysis query for the latest piece or batch of data more quickly, and provide faster database query response capability as a whole. In this sense, **TDengine can be used as a data cache by setting appropriate configuration parameters without deploying Redis or other additional cache systems**. This can significantly simplify the system architecture and reduce operational costs. It should be noted that after TDengine is restarted, the buffer of the system will be emptied, the previously cached data will be written to disk in batches, and the previously cached data will not be reloaded into the buffer. In this sense, TDengine's cache differs from proprietary key-value cache systems. -Each vnode has its own independent memory, and it is composed of multiple memory blocks of fixed size, and different vnodes are completely isolated. When writing data, similar to the writing of logs, data is sequentially added to memory, but each vnode maintains its own skip list for quick search. When more than one third of the memory block are used, the disk writing operation will start, and the subsequent writing operation is carried out in a new memory block. By this design, one third of the memory blocks in a vnode keep the latest data, so as to achieve the purpose of caching and quick search. The number of memory blocks of a vnode is determined by the configuration parameter “blocks”, and the size of memory blocks is determined by the configuration parameter “cache”. +Each vnode has its own independent memory composed of multiple memory blocks of fixed size, and the memory of different vnodes are completely isolated. When writing data, similar to the writing of logs, data is sequentially added to memory, but each vnode maintains its own skip list for quick search. When more than one third of the memory block are used, the data will be persisted to disk storage, and the subsequent writing operation will be carried out in a new memory block. By this design, one third of the memory blocks in a vnode keeps the latest data, so as to achieve the purpose of caching and quick search. The number of memory blocks of a vnode is determined by the configuration parameter `buffer`. ### Persistent Storage -TDengine uses a data-driven method to write the data from buffer into hard disk for persistent storage. When the cached data in vnode reaches a certain volume, TDengine will pull up the disk-writing thread to write the cached data into persistent storage so that subsequent data writing is not blocked. TDengine will open a new database log file when the data is written, and delete the old database log file after successfull persistence, to avoid unlimited log growth. +TDengine uses a data-driven method to write the data from buffer into hard disk for persistent storage. When the cached data in vnode reaches a certain amount, TDengine will pull up the disk-writing thread to write the cached data into persistent storage so that subsequent data writing is not blocked. TDengine will open a new database log file when the data is written, and delete the old database log file after successful persistence, to avoid unlimited log growth. -To make full use of the characteristics of time-series data, TDengine splits the data stored in persistent storage by a vnode into multiple files, each file only saves data for a fixed number of days, which is determined by the system configuration parameter `“days”`. Thus for given start and end dates of a query, you can locate the data files to open immediately without any index. This greatly speeds up read operations. +To make full use of the characteristics of time-series data, TDengine splits the data stored in persistent storage by a vnode into multiple files, each file only saves data for a fixed number of days, which is determined by the system configuration parameter `duration`. Thus for given start and end dates of a query, you can locate the data files to open immediately without any index. This greatly speeds up read operations. -For time-series data, there is generally a retention policy, which is determined by the system configuration parameter `“keep”`. Data files exceeding this set number of days will be automatically deleted by the system to free up storage space. +For time-series data, there is generally a retention policy, which is determined by the system configuration parameter `keep`. Data files exceeding this set number of days will be automatically deleted by the system to free up storage space. -Given “days” and “keep” parameters, the total number of data files in a vnode is: keep/days. The total number of data files should not be too large or too small. 10 to 100 is appropriate. Based on this principle, reasonable days can be set. In the current version, parameter “keep” can be modified, but parameter “days” cannot be modified once it is set. +Given `duration` and `keep` parameters, the total number of data files in a vnode is: round up of (keep/duration+1). The total number of data files should not be too large or too small. 10 to 100 is appropriate. Based on this principle, reasonable `duration` can be set. In the current version, parameter `keep` can be modified, but parameter `duration` cannot be modified once it is set. -In each data file, the data of a table is stored in blocks. A table can have one or more data file blocks. In a file block, data is stored in columns, occupying a continuous storage space, thus greatly improving the reading speed. The size of file block is determined by the system parameter `“maxRows”` (the maximum number of records per block), and the default value is 4096. This value should not be too large or too small. If it is too large, data location for queries will take a longer tim. If it is too small, the index of data block is too large, and the compression efficiency will be low with slower reading speed. +In each data file, the data of a table is stored in blocks. A table can have one or more data file blocks. In a file block, data is stored in columns, occupying a continuous storage space, thus greatly improving the reading speed. The size of file block is determined by the system parameter `maxRows` (the maximum number of records per block), and the default value is 4096. This value should not be too large or too small. If it is too large, data location for queries will take a longer time. If it is too small, the index of data block is too large, and the compression efficiency will be low with slower reading speed. -Each data file (with a .data postfix) has a corresponding index file (with a .head postfix). The index file has summary information of a data block for each table, recording the offset of each data block in the data file, start and end time of data and other information which allows the system to locate the data to be found very quickly. Each data file also has a corresponding last file (with a .last postfix), which is designed to prevent data block fragmentation when written in disk. If the number of written records from a table does not reach the system configuration parameter `“minRows”` (minimum number of records per block), it will be stored in the last file first. At the next write operation to the disk, the newly written records will be merged with the records in last file and then written into data file. +Each data file (with a .data postfix) has a corresponding index file (with a .head postfix). The index file has summary information of a data block for each table, recording the offset of each data block in the data file, start and end time of data and other information which allows the system to locate the data to be found very quickly. Each data file also has a corresponding last file (with a .last postfix), which is designed to prevent data block fragmentation when written in disk. If the number of written records from a table does not reach the system configuration parameter `minRows` (minimum number of records per block), it will be stored in the last file first. At the next write operation to the disk, the newly written records will be merged with the records in last file and then written into data file. -When data is written to disk, the system decideswhether to compress the data based on the system configuration parameter `“comp”`. TDengine provides three compression options: no compression, one-stage compression and two-stage compression, corresponding to comp values of 0, 1 and 2 respectively. One-stage compression is carried out according to the type of data. Compression algorithms include delta-delta coding, simple 8B method, zig-zag coding, LZ4 and other algorithms. Two-stage compression is based on one-stage compression and compressed by general compression algorithm, which has higher compression ratio. +When data is written to disk, the system decides whether to compress the data based on the database configuration parameter `comp`. TDengine provides three compression options: no compression, one-stage compression and two-stage compression, corresponding to comp values of 0, 1 and 2 respectively. One-stage compression is carried out according to the type of data. Compression algorithms include delta-delta coding, simple 8B method, zig-zag coding, LZ4 and other algorithms. Two-stage compression is based on one-stage compression and compressed by general compression algorithm, which has higher compression ratio. ### Tiered Storage @@ -241,19 +218,20 @@ Note: Tiered Storage is only supported in Enterprise Edition ## Data Query -TDengine provides a variety of query processing functions for tables and STables. In addition to common aggregation queries, TDengine also provides window queries and statistical aggregation functions for time-series data. Query processing in TDengine needs the collaboration of client, vnode and mnode. +TDengine provides a variety of query processing functions for tables and STables. In addition to common aggregation queries, TDengine also provides window queries and statistical aggregation functions for time-series data. Query processing in TDengine needs the collaboration of client, vnode, qnode and mnode. A complex aggregate query on a super table may need multiple vnodes and multiple qnodes to share the query and computing tasks. -### Single Table Query +### Query Process -The parsing and verification of SQL statements are completed on the client side. SQL statements are parsed and generate an Abstract Syntax Tree (AST), which is then checksummed. Then metadata information (table metadata) for the table specified is requested in the query from management node (mnode). - -According to the End Point information in metadata information, the query request is serialized and sent to the data node (dnode) where the table is located. After receiving the query, the dnode identifies the virtual node (vnode) pointed to and forwards the message to the query execution queue of the vnode. The query execution thread of vnode establishes the basic query execution environment, immediately returns the query request and starts executing the query at the same time. - -When client obtains query result, the worker thread in query execution queue of dnode will wait for the execution of vnode execution thread to complete before returning the query result to the requesting client. +1. TDEngine client driver `taosc` parses the SQL statement and generates an abstract syntax tree (AST), then check and verify the AST according to metadata. During this stage, the metadata management module in `taosc` (Catalog) requests the metadata of the involved database and table from mnode and vnode. +2. After the verification passes, `taosc` generates distributed query plan and optimizes the plan. +3. `taosc` schedules the tasks according to configured query policy, a query sub-task may be scheduled to a vnode or qnode according to data relative and system load. Please be noted that both vnode and qnode are logic execution unit, the physical execution node is dnode (data node). +4. When a dnode receives a query request, it identifies which vnode or qnode this query request is targeted, and forwards the request to the query execution queue of the identified vnode or qnode. +5. The query execution thread of the vnode or qnode establishes fundamental query execution context, and executes the query, and notifies the client once obtaining a part of result data. +6. TDengine client driver `taosc` will initiates next level query tasks or obtain the result simply. ### Aggregation by Time Axis, Downsampling, Interpolation -Time-series data is different from ordinary data in that each record has a timestamp. So aggregating data by timestamps on the time axis is an important and distinct feature of time-series databases which is different from that of common databases. It is similar to the window query of stream computing engines. +Time-series data is different from ordinary data in that each record has a timestamp. So aggregating data by timestamps on the time axis is an important and distinct feature of time-series databases compared with common databases. It is similar to the window query of stream computing engines. The keyword `interval` is introduced into TDengine to split fixed length time windows on the time axis. The data is aggregated based on time windows, and the data within time window ranges is aggregated as needed. For example: @@ -269,24 +247,32 @@ In application scenarios where query results need to be obtained continuously, i select count(*) from d1001 interval(1h) fill(prev); ``` -For the data collected by device D1001, the number of records per hour is counted. If there is no data in a certain hour, statistical data of the previous hour is returned. TDengine provides forward interpolation (prev), linear interpolation (linear), NULL value populating (NULL), and specific value populating (value). +In case that the query result needs to be obtained continuously, if there is data loss in a given time range, the resulting data for the time range may be lost too. TDengine provides interpolation for the aggregation result by time window, using `fill` keyword. For example: + +```sql +SELECT COUNT(*) FROM d1001 WHERE ts >= '2017-7-14 00:00:00' AND ts < '2017-7-14 23:59:59' INTERVAL(1h) FILL(PREV); +``` + +For the data collected by device D1001, the number of records per hour is counted. If there is no data in a certain hour, statistical data of the previous hour is returned. TDengine provides forward interpolation (prev), linear interpolation (linear), NULL value filling (NULL), and specific value filling (value). ### Multi-table Aggregation Query -TDengine creates a separate table for each data collection point, but in practical applications, it is often necessary to aggregate data from different data collection points. In order to perform aggregation operations efficiently, TDengine introduces the concept of STable (super table). STable is used to represent a specific type of data collection point. It is a table set containing multiple tables. The schema of each table in the set is the same, but each table has its own static tag. There can be multiple tags which can be added, deleted and modified at any time. Applications can aggregate or statistically operate on all or a subset of tables under a STABLE by specifying tag filters. This greatly simplifies the development of applications. The process is shown in the following figure: +TDengine creates a separate table for each data collection point, but in practical applications, it is often necessary to aggregate data from different data collection points. In order to perform aggregation operations efficiently, TDengine introduces the concept of STable (super table). STable is used to represent a specific type of data collection points. It is a table set containing multiple tables. The schema of each table in the set is the same, but each table has its own static tags. There can be multiple tags which can be added, deleted and modified at any time. Applications can aggregate or statistically operate on all or a subset of tables under a STable by specifying tag filters. This greatly simplifies the development of applications. The process for aggregation across multiple tables is shown in the following figure: ![TDengine Database Diagram of multi-table aggregation query](multi_tables.webp)
Figure 5: Diagram of multi-table aggregation query
-1. Application sends a query condition to system; -2. TAOSC sends the STable name to Meta Node(management node); -3. Management node sends the vnode list owned by the STable back to TAOSC; -4. TAOSC sends the computing request together with tag filters to multiple data nodes corresponding to these vnodes; -5. Each vnode first finds the set of tables within its own node that meet the tag filters from memory, then scans the stored time-series data, completes corresponding aggregation calculations, and returns result to TAOSC; -6. TAOSC finally aggregates the results returned by multiple data nodes and send them back to application. +1. Client requests the metadata for the database and tables from mnode +2. mnode returns the requested metadata +3. Client sends query requests to every vnode of the STable +4. Each vnode performs query locally, and returns the query response to client +5. Client sends query request to aggregation node, i.e. qnode +6. qnode requests the query result data from the vnodes involved +7. Each vnode returns its local query result data +8. qnode aggregates the result and returns the final result to the client -Since TDengine stores tag data and time-series data separately in vnode, by filtering tag data in memory, the set of tables that need to participate in aggregation operation is first found, which reduces the volume of data to be scanned and improves aggregation speed. At the same time, because the data is distributed in multiple vnodes/dnodes, the aggregation operation is carried out concurrently in multiple vnodes, which further improves the aggregation speed. Aggregation functions for ordinary tables and most operations are applicable to STables. The syntax is exactly the same. Please see TDengine SQL for details. +Since TDengine stores tag data and time-series data separately in vnode, filtering tag data in memory and finding the set of tables that need to participate in aggregation operation can reduce the volume of data to be scanned and improves aggregation speed. At the same time, because the data is distributed in multiple vnodes/dnodes, the aggregation operation is carried out concurrently in multiple vnodes, which further improves the aggregation speed. Aggregation functions and most operations for ordinary tables are applicable to STables. The syntax is exactly the same. Please see TDengine SQL for details. ### Precomputation diff --git a/docs/en/21-tdinternal/message.webp b/docs/en/21-tdinternal/message.webp index a2a42abff3d6e932b41a3abe9feae4a5cc13c9e5..4a5f5f86f38abfe134cef2801b7dca24c55b6657 100644 Binary files a/docs/en/21-tdinternal/message.webp and b/docs/en/21-tdinternal/message.webp differ diff --git a/docs/en/21-tdinternal/multi_tables.webp b/docs/en/21-tdinternal/multi_tables.webp index 8f649e34a3a62d1b11b4403b2e743ff6b5e47be2..481020a5f718e2ad3f1265b2785ddff8ad9ee292 100644 Binary files a/docs/en/21-tdinternal/multi_tables.webp and b/docs/en/21-tdinternal/multi_tables.webp differ diff --git a/docs/en/21-tdinternal/structure.webp b/docs/en/21-tdinternal/structure.webp index b77a42c074b15302b5c3ab889fb550a46dd549b3..ee7a799975b3d2a71f27c236743ddd6bd0be7f69 100644 Binary files a/docs/en/21-tdinternal/structure.webp and b/docs/en/21-tdinternal/structure.webp differ diff --git a/docs/en/21-tdinternal/write_follower.webp b/docs/en/21-tdinternal/write_follower.webp new file mode 100644 index 0000000000000000000000000000000000000000..1ca537cd60506a7e7ef0f9442bdcd9d8035fae4d Binary files /dev/null and b/docs/en/21-tdinternal/write_follower.webp differ diff --git a/docs/en/21-tdinternal/write_leader.webp b/docs/en/21-tdinternal/write_leader.webp new file mode 100644 index 0000000000000000000000000000000000000000..1771961b97766aaa43bc47f1311c441c94511477 Binary files /dev/null and b/docs/en/21-tdinternal/write_leader.webp differ diff --git a/docs/en/21-tdinternal/write_master.webp b/docs/en/21-tdinternal/write_master.webp deleted file mode 100644 index 9624036ed3d46ed60924ead9ce5c61acee0f4652..0000000000000000000000000000000000000000 Binary files a/docs/en/21-tdinternal/write_master.webp and /dev/null differ diff --git a/docs/en/21-tdinternal/write_slave.webp b/docs/en/21-tdinternal/write_slave.webp deleted file mode 100644 index 7c45dec11b00e6a738de458f9e1bedacfad75a96..0000000000000000000000000000000000000000 Binary files a/docs/en/21-tdinternal/write_slave.webp and /dev/null differ diff --git a/docs/zh/05-get-started/03-package.md b/docs/zh/05-get-started/03-package.md index 50ee721386a591bbafece210cd963e50eef3ea7e..167a68d3c84a7da25f8ae0bfa9592fbd933299e0 100644 --- a/docs/zh/05-get-started/03-package.md +++ b/docs/zh/05-get-started/03-package.md @@ -188,13 +188,13 @@ Active: inactive (dead) -安装后,在应用程序目录下,双击 TDengine 图标来启动程序,也可以运行 `launchctl start taosd` 来启动 TDengine 服务进程。 +安装后,在应用程序目录下,双击 TDengine 图标来启动程序,也可以运行 `launchctl start com.tdengine.taosd` 来启动 TDengine 服务进程。 如下 `launchctl` 命令可以帮助你管理 TDengine 服务: -- 启动服务进程:`launchctl start taosd` +- 启动服务进程:`launchctl start com.tdengine.taosd` -- 停止服务进程:`launchctl stop taosd` +- 停止服务进程:`launchctl stop com.tdengine.taosd` - 查看服务状态:`launchctl list | grep taosd` diff --git a/docs/zh/07-develop/01-connect/index.md b/docs/zh/07-develop/01-connect/index.md index 075d99cfee78b01b66ebc527892e90b9291dd422..d3ffe7eba216de0ef3e4790f555ed8499f0ba64c 100644 --- a/docs/zh/07-develop/01-connect/index.md +++ b/docs/zh/07-develop/01-connect/index.md @@ -32,7 +32,7 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速 关键不同点在于: -1. 使用 REST 连接,用户无需安装客户端驱动程序 taosc,具有跨平台易用的优势,但性能要下降 30%左右。 +1. 使用 REST 连接,用户无需安装客户端驱动程序 taosc,具有跨平台易用的优势,但性能要下降 30% 左右。 2. 使用原生连接可以体验 TDengine 的全部功能,如[参数绑定接口](../../connector/cpp/#参数绑定-api)、[订阅](../../connector/cpp/#订阅和消费-api)等等。 ## 安装客户端驱动 taosc @@ -67,8 +67,8 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速 - -如果使用 maven 管理项目,只需在 pom.xml 中加入以下依赖。 + +如果使用 Maven 管理项目,只需在 pom.xml 中加入以下依赖。 ```xml @@ -107,7 +107,7 @@ require github.com/taosdata/driver-go/v3 latest ``` :::note -driver-go 使用 cgo 封装了 taosc 的 API。cgo 需要使用 gcc 编译 C 的源码。因此需要确保你的系统上有 gcc。 +driver-go 使用 cgo 封装了 taosc 的 API。cgo 需要使用 GCC 编译 C 的源码。因此需要确保你的系统上有 GCC。 ::: @@ -137,19 +137,19 @@ Node.js 连接器通过不同的包提供不同的连接方式。 1. 安装 Node.js 原生连接器 - ``` - npm install @tdengine/client - ``` +``` +npm install @tdengine/client +``` :::note 推荐 Node 版本大于等于 `node-v12.8.0` 小于 `node-v13.0.0` -::: - +::: + 2. 安装 Node.js REST 连接器 - ``` - npm install @tdengine/rest - ``` +``` +npm install @tdengine/rest +``` diff --git a/docs/zh/07-develop/02-model/index.mdx b/docs/zh/07-develop/02-model/index.mdx index d66059c2cda2a0e4629b16ca44cee036dc67546f..ca2afdf66412044aa1c5180448a5420c598fa107 100644 --- a/docs/zh/07-develop/02-model/index.mdx +++ b/docs/zh/07-develop/02-model/index.mdx @@ -10,13 +10,13 @@ TDengine 采用类关系型数据模型,需要建库、建表。因此对于 ## 创建库 -不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能最大效率的工作,TDengine 建议将不同数据特征的表创建在不同的库里,因为每个库可以配置不同的存储策略。创建一个库时,除 SQL 标准的选项外,还可以指定保留时长、副本数、缓存大小、时间精度、文件块里最大最小记录条数、是否压缩、一个数据文件覆盖的天数等多种参数。比如: +不同类型的数据采集点往往具有不同的数据特征,包括数据采集频率的高低,数据保留时间的长短,副本的数目,数据块的大小,是否允许更新数据等等。为了在各种场景下 TDengine 都能以最大效率工作,TDengine 建议将不同数据特征的表创建在不同的库里,因为每个库可以配置不同的存储策略。创建一个库时,除 SQL 标准的选项外,还可以指定保留时长、副本数、缓存大小、时间精度、文件块里最大最小记录条数、是否压缩、一个数据文件覆盖的天数等多种参数。比如: ```sql CREATE DATABASE power KEEP 365 DURATION 10 BUFFER 16 WAL_LEVEL 1; ``` -上述语句将创建一个名为 power 的库,这个库的数据将保留 365 天(超过 365 天将被自动删除),每 10 天一个数据文件,每个 VNODE 的写入内存池的大小为 16 MB,对该数据库入会写 WAL 但不执行 FSYNC。详细的语法及参数请见 [数据库管理](/taos-sql/database) 章节。 +上述语句将创建一个名为 power 的库,这个库的数据将保留 365 天(超过 365 天将被自动删除),每 10 天一个数据文件,每个 VNode 的写入内存池的大小为 16 MB,对该数据库入会写 WAL 但不执行 FSYNC。详细的语法及参数请见 [数据库管理](/taos-sql/database) 章节。 创建库之后,需要使用 SQL 命令 `USE` 将当前库切换过来,例如: @@ -35,39 +35,39 @@ USE power; ## 创建超级表 -一个物联网系统,往往存在多种类型的设备,比如对于电网,存在智能电表、变压器、母线、开关等等。为便于多表之间的聚合,使用 TDengine, 需要对每个类型的数据采集点创建一个超级表。以[表 1](/tdinternal/arch#model_table1) 中的智能电表为例,可以使用如下的 SQL 命令创建超级表: +一个物联网系统,往往存在多种类型的设备,比如对于电网,存在智能电表、变压器、母线、开关等等。为便于多表之间的聚合,使用 TDengine, 需要对每个类型的数据采集点创建一个超级表。以 [表 1](/concept) 中的智能电表为例,可以使用如下的 SQL 命令创建超级表: ```sql CREATE STABLE meters (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int); ``` -与创建普通表一样,创建超级表时,需要提供表名(示例中为 meters),表结构 Schema,即数据列的定义。第一列必须为时间戳(示例中为 ts),其他列为采集的物理量(示例中为 current, voltage, phase),数据类型可以为整型、浮点型、字符串等。除此之外,还需要提供标签的 schema (示例中为 location, groupId),标签的数据类型可以为整型、浮点型、字符串等。采集点的静态属性往往可以作为标签,比如采集点的地理位置、设备型号、设备组 ID、管理员 ID 等等。标签的 schema 可以事后增加、删除、修改。具体定义以及细节请见 [TDengine SQL 的超级表管理](/taos-sql/stable) 章节。 +与创建普通表一样,创建超级表时,需要提供表名(示例中为 meters),表结构 Schema,即数据列的定义。第一列必须为时间戳(示例中为 ts),其他列为采集的物理量(示例中为 current, voltage, phase),数据类型可以为整型、浮点型、字符串等。除此之外,还需要提供标签的 Schema (示例中为 location, groupId),标签的数据类型可以为整型、浮点型、字符串等。采集点的静态属性往往可以作为标签,比如采集点的地理位置、设备型号、设备组 ID、管理员 ID 等等。标签的 Schema 可以事后增加、删除、修改。具体定义以及细节请见 [TDengine SQL 的超级表管理](/taos-sql/stable) 章节。 每一种类型的数据采集点需要建立一个超级表,因此一个物联网系统,往往会有多个超级表。对于电网,我们就需要对智能电表、变压器、母线、开关等都建立一个超级表。在物联网中,一个设备就可能有多个数据采集点(比如一台风力发电的风机,有的采集点采集电流、电压等电参数,有的采集点采集温度、湿度、风向等环境参数),这个时候,对这一类型的设备,需要建立多张超级表。 -一张超级表最多容许 4096 列,如果一个采集点采集的物理量个数超过 4096,需要建多张超级表来处理。一个系统可以有多个 DB,一个 DB 里可以有一到多个超级表。 +一张超级表最多容许 4096 列,如果一个采集点采集的物理量个数超过 4096,需要建多张超级表来处理。一个系统可以有多个 Database,一个 Database 里可以有一到多个超级表。 ## 创建表 -TDengine 对每个数据采集点需要独立建表。与标准的关系型数据库一样,一张表有表名,Schema,但除此之外,还可以带有一到多个标签。创建时,需要使用超级表做模板,同时指定标签的具体值。以[表 1](/tdinternal/arch#model_table1)中的智能电表为例,可以使用如下的 SQL 命令建表: +TDengine 对每个数据采集点需要独立建表。与标准的关系型数据库一样,一张表有表名,Schema,但除此之外,还可以带有一到多个标签。创建时,需要使用超级表做模板,同时指定标签的具体值。以 [表 1](/concept) 中的智能电表为例,可以使用如下的 SQL 命令建表: ```sql CREATE TABLE d1001 USING meters TAGS ("California.SanFrancisco", 2); ``` -其中 d1001 是表名,meters 是超级表的表名,后面紧跟标签 Location 的具体标签值 "California.SanFrancisco",标签 groupId 的具体标签值 2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 [TDengine SQL 的表管理](/taos-sql/table) 章节。 +其中 d1001 是表名,meters 是超级表的表名,后面紧跟标签 Location 的具体标签值为 "California.SanFrancisco",标签 groupId 的具体标签值为 2。虽然在创建表时,需要指定标签值,但可以事后修改。详细细则请见 [TDengine SQL 的表管理](/taos-sql/table) 章节。 -TDengine 建议将数据采集点的全局唯一 ID 作为表名(比如设备序列号)。但对于有的场景,并没有唯一的 ID,可以将多个 ID 组合成一个唯一的 ID。不建议将具有唯一性的 ID 作为标签值。 +TDengine 建议将数据采集点的全局唯一 ID 作为表名(比如设备序列号)。但对于有的场景,并没有唯一的 ID,可以将多个 ID 组合成一个唯一的 ID。不建议将具有唯一性的 ID 作为标签值。 ### 自动建表 在某些特殊场景中,用户在写数据时并不确定某个数据采集点的表是否存在,此时可在写入数据时使用自动建表语法来创建不存在的表,若该表已存在则不会建立新表且后面的 USING 语句被忽略。比如: ```sql -INSERT INTO d1001 USING meters TAGS ("California.SanFrancisco", 2) VALUES (now, 10.2, 219, 0.32); +INSERT INTO d1001 USING meters TAGS ("California.SanFrancisco", 2) VALUES (NOW, 10.2, 219, 0.32); ``` -上述 SQL 语句将记录`(now, 10.2, 219, 0.32)`插入表 d1001。如果表 d1001 还未创建,则使用超级表 meters 做模板自动创建,同时打上标签值 `"California.SanFrancisco", 2`。 +上述 SQL 语句将记录`(NOW, 10.2, 219, 0.32)`插入表 d1001。如果表 d1001 还未创建,则使用超级表 meters 做模板自动创建,同时打上标签值 `"California.SanFrancisco", 2`。 关于自动建表的详细语法请参见 [插入记录时自动建表](/taos-sql/insert#插入记录时自动建表) 章节。 diff --git a/docs/zh/07-develop/03-insert-data/01-sql-writing.mdx b/docs/zh/07-develop/03-insert-data/01-sql-writing.mdx index 8818eaae3dc1806a00e73d9846fbd1dfe15e0c8a..47024171562bb7dc2d4e2063bc2fb0d44faad45b 100644 --- a/docs/zh/07-develop/03-insert-data/01-sql-writing.mdx +++ b/docs/zh/07-develop/03-insert-data/01-sql-writing.mdx @@ -53,15 +53,15 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, :::info -- 要提高写入效率,需要批量写入。一般来说一批写入的记录条数越多,插入效率就越高。但一条记录不能超过 48K,一条 SQL 语句总长度不能超过 1M 。 -- TDengine 支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开多个同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程频繁切换,会带来额外开销,合适的线程数量与服务端的处理能力,服务端的具体配置,数据库的参数,数据定义的 Schema,写入数据的 Batch Size 等很多因素相关。一般来说,服务端和客户端处理能力越强,所能支持的并发写入的线程可以越多;数据库配置时的 vgroups 越多(但仍然要在服务端的处理能力以内)则所能支持的并发写入越多;数据定义的 Schema 越简单,所能支持的并发写入越多。 +- 要提高写入效率,需要批量写入。一般来说一批写入的记录条数越多,插入效率就越高。但一条记录不能超过 48KB,一条 SQL 语句总长度不能超过 1MB。 +- TDengine 支持多线程同时写入,要进一步提高写入速度,一个客户端需要打开多个同时写。但线程数达到一定数量后,无法再提高,甚至还会下降,因为线程频繁切换,会带来额外开销,合适的线程数量与服务端的处理能力,服务端的具体配置,数据库的参数,数据定义的 Schema,写入数据的 Batch Size 等很多因素相关。一般来说,服务端和客户端处理能力越强,所能支持的并发写入的线程可以越多;数据库配置时的 vgroups 参数值越多(但仍然要在服务端的处理能力以内)则所能支持的并发写入越多;数据定义的 Schema 越简单,所能支持的并发写入越多。 ::: :::warning - 对同一张表,如果新插入记录的时间戳已经存在,则指定了新值的列会用新值覆盖旧值,而没有指定新值的列则不受影响。 -- 写入的数据的时间戳必须大于当前时间减去配置参数 keep 的时间。如果 keep 配置为 3650 天,那么无法写入比 3650 天还早的数据。写入数据的时间戳也不能大于当前时间加配置参数 duration。如果 duration 为 2,那么无法写入比当前时间还晚 2 天的数据。 +- 写入的数据的时间戳必须大于当前时间减去数据库配置参数 KEEP 的时间。如果 KEEP 配置为 3650 天,那么无法写入比 3650 天还早的数据。写入数据的时间戳也不能大于当前时间加配置参数 DURATION。如果 DURATION 为 2,那么无法写入比当前时间还晚 2 天的数据。 ::: @@ -99,7 +99,7 @@ INSERT INTO d1001 VALUES (1538548685000, 10.3, 219, 0.31) (1538548695000, 12.6, :::note 1. 无论 RESTful 方式建立连接还是本地驱动方式建立连接,以上示例代码都能正常工作。 -2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `use db` 语句来切换数据库, 所以在上面示例中使用了`dbName.tbName`指定表名。 +2. 唯一需要注意的是:由于 RESTful 接口无状态, 不能使用 `USE db;` 语句来切换数据库, 所以在上面示例中使用了`dbName.tbName`指定表名。 ::: diff --git a/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx b/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx index 95155c31442a59e3fa0eb2a28dec96c2abff9cf7..19ccf49906237f606d128ef568bcf8cf3ee23775 100644 --- a/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx +++ b/docs/zh/07-develop/03-insert-data/02-influxdb-line.mdx @@ -34,13 +34,13 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 :::note -- tag_set 中的所有的数据自动转化为 nchar 数据类型; -- field_set 中的每个数据项都需要对自身的数据类型进行描述, 比如 1.2f32 代表 float 类型的数值 1.2, 如果不带类型后缀会被当作 double 处理; +- tag_set 中的所有的数据自动转化为 NCHAR 数据类型; +- field_set 中的每个数据项都需要对自身的数据类型进行描述, 比如 1.2f32 代表 FLOAT 类型的数值 1.2, 如果不带类型后缀会被当作 DOUBLE 处理; - timestamp 支持多种时间精度。写入数据的时候需要用参数指定时间精度,支持从小时到纳秒的 6 种时间精度。 -- 为了提高写入的效率,默认假设同一个超级表中 field_set 的顺序是一样的(第一条数据包含所有的 field,后面的数据按照这个顺序),如果顺序不一样,需要配置参数 smlDataFormat 为 false,否则,数据写入按照相同顺序写入,库中数据会异常。(3.0.1.3之后的版本 smlDataFormat 默认为 false) [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) -- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 -举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。[TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) -::: +- 为了提高写入的效率,默认假设同一个超级表中 field_set 的顺序是一样的(第一条数据包含所有的 field,后面的数据按照这个顺序),如果顺序不一样,需要配置参数 smlDataFormat 为 false,否则,数据写入按照相同顺序写入,库中数据会异常。(3.0.1.3 之后的版本 smlDataFormat 默认为 false) [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) +- 默认生产的子表名是根据规则生成的唯一 ID 值。为了让用户可以指定生成的表名,可以通过在 taos.cfg 里配置 smlChildTableName 参数来指定。 + 举例如下:配置 smlChildTableName=tname 插入数据为 st,tname=cpu1,t1=4 c1=3 1626006833639000000 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。[TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) + ::: 要了解更多可参考:[InfluxDB Line 协议官方文档](https://docs.influxdata.com/influxdb/v2.0/reference/syntax/line-protocol/) 和 [TDengine 无模式写入参考指南](/reference/schemaless/#无模式写入行协议) @@ -67,10 +67,12 @@ meters,location=California.LosAngeles,groupid=2 current=13.4,voltage=223,phase=0 -## SQL查询示例 -- meters 是插入数据的超级表名 -- 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles,groupid=2` 可以通过如下sql: +## SQL 查询示例 -``` cmd -select * from meters where location="California.LosAngeles" and groupid=2 +`meters` 是插入数据的超级表名。 + +可以通过超级表的 TAG 来过滤数据,比如查询 `location=California.LosAngeles,groupid=2` 可以通过如下 SQL: + +```sql +SELECT * FROM meters WHERE location = "California.LosAngeles" AND groupid = 2; ``` diff --git a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx index b008953c0b65149e9a852bbf2caef1c0ed63cca6..25be8a0aa4486121642f73e0117db4de5f33877e 100644 --- a/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx +++ b/docs/zh/07-develop/03-insert-data/03-opentsdb-telnet.mdx @@ -21,10 +21,10 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB =[ =] ``` -- metric 将作为超级表名。 -- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度 -- value 度量值,必须为一个数值。对应的列名是 “_value”。 -- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 nchar 数据类型; +- metric 将作为超级表名; +- timestamp 本行数据对应的时间戳。根据时间戳的长度自动识别时间精度。支持秒和毫秒两种时间精度; +- value 度量值,必须为一个数值。对应的列名是 “\_value”; +- 最后一部分是标签集, 用空格分隔不同标签, 所有标签自动转化为 NCHAR 数据类型。 例如: @@ -32,9 +32,9 @@ OpenTSDB 行协议同样采用一行字符串来表示一行数据。OpenTSDB meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3 ``` -- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 -举例如下:配置 smlChildTableName=tname 插入数据为 meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 -参考[OpenTSDB Telnet API 文档](http://opentsdb.net/docs/build/html/api_telnet/put.html)。 +- 默认生产的子表名是根据规则生成的唯一 ID 值。为了让用户可以指定生成的表名,可以通过在 taos.cfg 里配置 smlChildTableName 参数来指定。 + 举例如下:配置 smlChildTableName=tname 插入数据为 meters.current 1648432611250 11.3 tname=cpu1 location=California.LosAngeles groupid=3 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 + 参考 [OpenTSDB Telnet API 文档](http://opentsdb.net/docs/build/html/api_telnet/put.html)。 ## 示例代码 @@ -62,17 +62,17 @@ meters.current 1648432611250 11.3 location=California.LosAngeles groupid=3 以上示例代码会自动创建 2 个超级表, 每个超级表有 4 条数据。 ```cmd -taos> use test; +taos> USE test; Database changed. -taos> show stables; +taos> SHOW STABLES; name | ================================= meters.current | meters.voltage | Query OK, 2 row(s) in set (0.002544s) -taos> select tbname, * from `meters.current`; +taos> SELECT TBNAME, * FROM `meters.current`; tbname | _ts | _value | groupid | location | ================================================================================================================================== t_0e7bcfa21a02331c06764f275... | 2022-03-28 09:56:51.249 | 10.800000000 | 3 | California.LosAngeles | @@ -82,9 +82,12 @@ taos> select tbname, * from `meters.current`; Query OK, 4 row(s) in set (0.005399s) ``` -## SQL查询示例 -- `meters.current` 是插入数据的超级表名 -- 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles groupid=3` 可以通过如下sql: -``` cmd -select * from `meters.current` where location="California.LosAngeles" and groupid=3 +## SQL 查询示例 + +`meters.current` 是插入数据的超级表名。 + +可以通过超级表的 TAG 来过滤数据,比如查询 `location=California.LosAngeles groupid=3` 可以通过如下 SQL: + +```sql +SELECT * FROM `meters.current` WHERE location = "California.LosAngeles" AND groupid = 3; ``` diff --git a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx index 1795d8edde7d13fad2b30bfd693df5785cb95675..57b00ab310cd10012e800ff12685a7be9f76bb69 100644 --- a/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx +++ b/docs/zh/07-develop/03-insert-data/04-opentsdb-json.mdx @@ -46,11 +46,11 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 :::note -- 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 nchar 类型, 字符串将将转为 nchar 类型, 数值将同样转换为 double 类型。 +- 对于 JSON 格式协议,TDengine 并不会自动把所有标签转成 NCHAR 类型, 字符串将将转为 NCHAR 类型, 数值将同样转换为 DOUBLE 类型。 - TDengine 只接收 JSON **数组格式**的字符串,即使一行数据也需要转换成数组形式。 -- 默认生产的子表名是根据规则生成的唯一ID值。为了让用户可以指定生成的表名,可以通过在taos.cfg里配置 smlChildTableName 参数来指定。 -举例如下:配置 smlChildTableName=tname 插入数据为 "tags": { "host": "web02","dc": "lga","tname":"cpu1"} 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 -::: +- 默认生产的子表名是根据规则生成的唯一 ID 值。为了让用户可以指定生成的表名,可以通过在 taos.cfg 里配置 smlChildTableName 参数来指定。 + 举例如下:配置 smlChildTableName=tname 插入数据为 `"tags": { "host": "web02","dc": "lga","tname":"cpu1"}` 则创建的表名为 cpu1,注意如果多行数据 tname 相同,但是后面的 tag_set 不同,则使用第一行自动建表时指定的 tag_set,其他的行会忽略)。 + ::: ## 示例代码 @@ -78,17 +78,17 @@ OpenTSDB JSON 格式协议采用一个 JSON 字符串表示一行或多行数据 以上示例代码会自动创建 2 个超级表, 每个超级表有 2 条数据。 ```cmd -taos> use test; +taos> USE test; Database changed. -taos> show stables; +taos> SHOW STABLES; name | ================================= meters.current | meters.voltage | Query OK, 2 row(s) in set (0.001954s) -taos> select * from `meters.current`; +taos> SELECT * FROM `meters.current`; _ts | _value | groupid | location | =================================================================================================================== 2022-03-28 09:56:51.249 | 10.300000000 | 2.000000000 | California.SanFrancisco | @@ -96,9 +96,12 @@ taos> select * from `meters.current`; Query OK, 2 row(s) in set (0.004076s) ``` -## SQL查询示例 -- `meters.voltage` 是插入数据的超级表名 -- 可以通过超级表的tag来过滤数据,比如查询 `location=California.LosAngeles groupid=1` 可以通过如下sql: -``` cmd -select * from `meters.voltage` where location="California.LosAngeles" and groupid=1 +## SQL 查询示例 + +`meters.voltage` 是插入数据的超级表名。 + +可以通过超级表的 TAG 来过滤数据,比如查询 `location=California.LosAngeles groupid=1` 可以通过如下 SQL: + +```sql +SELECT * FROM `meters.current` WHERE location = "California.LosAngeles" AND groupid = 3; ``` diff --git a/docs/zh/07-develop/03-insert-data/05-high-volume.md b/docs/zh/07-develop/03-insert-data/05-high-volume.md index d7581467ae0315442d89de395d35bbd677f75d3a..0a3a7a3919f744e7617c5162065daa213751d157 100644 --- a/docs/zh/07-develop/03-insert-data/05-high-volume.md +++ b/docs/zh/07-develop/03-insert-data/05-high-volume.md @@ -11,11 +11,11 @@ import TabItem from "@theme/TabItem"; 从客户端程序的角度来说,高效写入数据要考虑以下几个因素: -1. 单次写入的数据量。一般来讲,每批次写入的数据量越大越高效(但超过一定阈值其优势会消失)。使用 SQL 写入 TDengine 时,尽量在一条 SQL 中拼接更多数据。目前,TDengine 支持的一条 SQL 的最大长度为 1,048,576(1M)个字符。 -2. 并发连接数。一般来讲,同时写入数据的并发连接数越多写入越高效(但超过一定阈值反而会下降,取决于服务端处理能力)。 -3. 数据在不同表(或子表)之间的分布,即要写入数据的相邻性。一般来说,每批次只向同一张表(或子表)写入数据比向多张表(或子表)写入数据要更高效; +1. 单次写入的数据量。一般来讲,每批次写入的数据量越大越高效(但超过一定阈值其优势会消失)。使用 SQL 写入 TDengine 时,尽量在一条 SQL 中拼接更多数据。目前,TDengine 支持的一条 SQL 的最大长度为 1,048,576(1MB)个字符 +2. 并发连接数。一般来讲,同时写入数据的并发连接数越多写入越高效(但超过一定阈值反而会下降,取决于服务端处理能力) +3. 数据在不同表(或子表)之间的分布,即要写入数据的相邻性。一般来说,每批次只向同一张表(或子表)写入数据比向多张表(或子表)写入数据要更高效 4. 写入方式。一般来讲: - - 参数绑定写入比 SQL 写入更高效。因参数绑定方式避免了 SQL 解析。(但增加了 C 接口的调用次数,对于连接器也有性能损耗)。 + - 参数绑定写入比 SQL 写入更高效。因参数绑定方式避免了 SQL 解析。(但增加了 C 接口的调用次数,对于连接器也有性能损耗) - SQL 写入不自动建表比自动建表更高效。因自动建表要频繁检查表是否存在 - SQL 写入比无模式写入更高效。因无模式写入会自动建表且支持动态更改表结构 @@ -34,7 +34,7 @@ import TabItem from "@theme/TabItem"; 1. 将同一张表的数据写到同一个 Topic 的同一个 Partition,增加数据的相邻性 2. 通过订阅多个 Topic 实现数据汇聚 3. 通过增加 Consumer 线程数增加写入的并发度 -4. 通过增加每次 fetch 的最大数据量来增加单次写入的最大数据量 +4. 通过增加每次 Fetch 的最大数据量来增加单次写入的最大数据量 ### 服务器配置的角度 {#setting-view} @@ -59,7 +59,7 @@ import TabItem from "@theme/TabItem"; 这一部分是针对以上场景的示例代码。对于其它场景高效写入原理相同,不过代码需要适当修改。 -本示例代码假设源数据属于同一张超级表(meters)的不同子表。程序在开始写入数据之前已经在 test 库创建了这个超级表。对于子表,将根据收到的数据,由应用程序自动创建。如果实际场景是多个超级表,只需修改写任务自动建表的代码。 +本示例代码假设源数据属于同一张超级表(meters)的不同子表。程序在开始写入数据之前已经在 test 库创建了这个超级表。对于子表,将根据收到的数据,由应用程序自动创建。如果实际场景是多个超级表,只需修改写任务自动建表的代码。 @@ -69,14 +69,13 @@ import TabItem from "@theme/TabItem"; | 类名 | 功能说明 | | ---------------- | --------------------------------------------------------------------------- | | FastWriteExample | 主程序 | -| ReadTask | 从模拟源中读取数据,将表名经过 hash 后得到 Queue 的 index,写入对应的 Queue | +| ReadTask | 从模拟源中读取数据,将表名经过 Hash 后得到 Queue 的 Index,写入对应的 Queue | | WriteTask | 从 Queue 中获取数据,组成一个 Batch,写入 TDengine | | MockDataSource | 模拟生成一定数量 meters 子表的数据 | | SQLWriter | WriteTask 依赖这个类完成 SQL 拼接、自动建表、 SQL 写入、SQL 长度检查 | | StmtWriter | 实现参数绑定方式批量写入(暂未完成) | | DataBaseMonitor | 统计写入速度,并每隔 10 秒把当前写入速度打印到控制台 | - 以下是各类的完整代码和更详细的功能说明。
@@ -92,10 +91,10 @@ import TabItem from "@theme/TabItem"; 1. 读线程个数。默认为 1。 2. 写线程个数。默认为 3。 -3. 模拟生成的总表数。默认为 1000。将会平分给各个读线程。如果总表数较大,建表需要花费较长,开始统计的写入速度可能较慢。 -4. 每批最多写入记录数量。默认为 3000。 +3. 模拟生成的总表数。默认为 1,000。将会平分给各个读线程。如果总表数较大,建表需要花费较长,开始统计的写入速度可能较慢。 +4. 每批最多写入记录数量。默认为 3,000。 -队列容量(taskQueueCapacity)也是与性能有关的参数,可通过修改程序调节。一般来讲,队列容量越大,入队被阻塞的概率越小,队列的吞吐量越大,但是内存占用也会越大。 示例程序默认值已经设置地足够大。 +队列容量(taskQueueCapacity)也是与性能有关的参数,可通过修改程序调节。一般来讲,队列容量越大,入队被阻塞的概率越小,队列的吞吐量越大,但是内存占用也会越大。示例程序默认值已经设置地足够大。 ```java {{#include docs/examples/java/src/main/java/com/taos/example/highvolume/FastWriteExample.java}} @@ -208,14 +207,14 @@ TDENGINE_JDBC_URL="jdbc:TAOS://localhost:6030?user=root&password=taosdata" 以上使用的是本地部署 TDengine Server 时默认的 JDBC URL。你需要根据自己的实际情况更改。 -5. 用 java 命令启动示例程序,命令模板: +5. 用 Java 命令启动示例程序,命令模板: ``` java -classpath lib/*:javaexample-1.0.jar com.taos.example.highvolume.FastWriteExample ``` 6. 结束测试程序。测试程序不会自动结束,在获取到当前配置下稳定的写入速度后,按 CTRL + C 结束程序。 - 下面是一次实际运行的日志输出,机器配置 16核 + 64G + 固态硬盘。 + 下面是一次实际运行的日志输出,机器配置 16 核 + 64G + 固态硬盘。 ``` root@vm85$ java -classpath lib/*:javaexample-1.0.jar com.taos.example.highvolume.FastWriteExample 2 12 @@ -271,12 +270,11 @@ Python 示例程序中采用了多进程的架构,并使用了跨进程的消 | main 函数 | 程序入口, 创建各个子进程和消息队列 | | run_monitor_process 函数 | 创建数据库,超级表,统计写入速度并定时打印到控制台 | | run_read_task 函数 | 读进程主要逻辑,负责从其它数据系统读数据,并分发数据到为之分配的队列 | -| MockDataSource 类 | 模拟数据源, 实现迭代器接口,每次批量返回每张表的接下来 1000 条数据 | +| MockDataSource 类 | 模拟数据源, 实现迭代器接口,每次批量返回每张表的接下来 1,000 条数据 | | run_write_task 函数 | 写进程主要逻辑。每次从队列中取出尽量多的数据,并批量写入 | -| SQLWriter类 | SQL 写入和自动建表 | +| SQLWriter 类 | SQL 写入和自动建表 | | StmtWriter 类 | 实现参数绑定方式批量写入(暂未完成) | -
main 函数 @@ -290,9 +288,9 @@ main 函数可以接收 5 个启动参数,依次是: 1. 读任务(进程)数, 默认为 1 2. 写任务(进程)数, 默认为 1 -3. 模拟生成的总表数,默认为 1000 -4. 队列大小(单位字节),默认为 1000000 -5. 每批最多写入记录数量, 默认为 3000 +3. 模拟生成的总表数,默认为 1,000 +4. 队列大小(单位字节),默认为 1,000,000 +5. 每批最多写入记录数量, 默认为 3,000 ```python {{#include docs/examples/python/fast_write_example.py:main}} @@ -348,7 +346,7 @@ main 函数可以接收 5 个启动参数,依次是:
-SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提前创建,而是在发生表不存在错误的时候,再以超级表为模板批量建表,然后重新执行 INSERT 语句。对于其它错误会记录当时执行的 SQL, 以便排查错误和故障恢复。这个类也对 SQL 是否超过最大长度限制做了检查,根据 TDengine 3.0 的限制由输入参数 maxSQLLength 传入了支持的最大 SQL 长度,即 1048576 。 +SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提前创建,而是在发生表不存在错误的时候,再以超级表为模板批量建表,然后重新执行 INSERT 语句。对于其它错误会记录当时执行的 SQL, 以便排查错误和故障恢复。这个类也对 SQL 是否超过最大长度限制做了检查,根据 TDengine 3.0 的限制由输入参数 maxSQLLength 传入了支持的最大 SQL 长度,即 1,048,576 。 SQLWriter @@ -384,7 +382,7 @@ SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提 python3 fast_write_example.py ``` - 下面是一次实际运行的输出, 机器配置 16核 + 64G + 固态硬盘。 + 下面是一次实际运行的输出, 机器配置 16 核 + 64G + 固态硬盘。 ``` root@vm85$ python3 fast_write_example.py 8 8 @@ -432,5 +430,3 @@ SQLWriter 类封装了拼 SQL 和写数据的逻辑。所有的表都没有提 - - diff --git a/docs/zh/07-develop/index.md b/docs/zh/07-develop/index.md index efaffaea71ce68ee0a8ddbf5634c4150adc94bfb..a3d1410ab6cd0f2d37d1f481df03ba4a1181c16c 100644 --- a/docs/zh/07-develop/index.md +++ b/docs/zh/07-develop/index.md @@ -4,19 +4,20 @@ sidebar_label: 开发指南 description: 让开发者能够快速上手的指南 --- -开发一个应用,如果你准备采用TDengine作为时序数据处理的工具,那么有如下几个事情要做: -1. 确定应用到TDengine的链接方式。无论你使用何种编程语言,你总可以使用REST接口, 但也可以使用每种编程语言独有的连接器方便的进行链接。 +开发一个应用,如果你准备采用 TDengine 作为时序数据处理的工具,那么有如下几个事情要做: + +1. 确定应用到 TDengine 的连接方式。无论你使用何种编程语言,你总是可以使用 REST 接口, 但也可以使用每种编程语言独有的连接器进行方便的连接。 2. 根据自己的应用场景,确定数据模型。根据数据特征,决定建立一个还是多个库;分清静态标签、采集量,建立正确的超级表,建立子表。 -3. 决定插入数据的方式。TDengine支持使用标准的SQL写入,但同时也支持schemaless模式写入,这样不用手工建表,可以将数据直接写入。 -4. 根据业务要求,看需要撰写哪些SQL查询语句。 +3. 决定插入数据的方式。TDengine 支持使用标准的 SQL 写入,但同时也支持 Schemaless 模式写入,这样不用手工建表,可以将数据直接写入。 +4. 根据业务要求,看需要撰写哪些 SQL 查询语句。 5. 如果你要基于时序数据做轻量级的实时统计分析,包括各种监测看板,那么建议你采用 TDengine 3.0 的流式计算功能,而不用额外部署 Spark, Flink 等复杂的流式计算系统。 -6. 如果你的应用有模块需要消费插入的数据,希望有新的数据插入时,就能获取通知,那么建议你采用TDengine提供的数据订阅功能,而无需专门部署Kafka或其他消息队列软件。 -7. 在很多场景下(如车辆管理),应用需要获取每个数据采集点的最新状态,那么建议你采用TDengine的cache功能,而不用单独部署Redis等缓存软件。 -8. 如果你发现TDengine的函数无法满足你的要求,那么你可以使用用户自定义函数来解决问题。 +6. 如果你的应用有模块需要消费插入的数据,希望有新的数据插入时,就能获取通知,那么建议你采用 TDengine 提供的数据订阅功能,而无需专门部署 Kafka 或其他消息队列软件。 +7. 在很多场景下(如车辆管理),应用需要获取每个数据采集点的最新状态,那么建议你采用 TDengine 的 Cache 功能,而不用单独部署 Redis 等缓存软件。 +8. 如果你发现 TDengine 的函数无法满足你的要求,那么你可以使用用户自定义函数(UDF)来解决问题。 -本部分内容就是按照上述的顺序组织的。为便于理解,TDengine为每个功能为每个支持的编程语言都提供了示例代码。如果你希望深入了解SQL的使用,需要查看[SQL手册](/taos-sql/)。如果想更深入地了解各连接器的使用,请阅读[连接器参考指南](../connector/)。如果还希望想将TDengine与第三方系统集成起来,比如Grafana, 请参考[第三方工具](../third-party/)。 +本部分内容就是按照上述顺序组织的。为便于理解,TDengine 为每个功能和每个支持的编程语言都提供了示例代码。如果你希望深入了解 SQL 的使用,需要查看[SQL 手册](/taos-sql/)。如果想更深入地了解各连接器的使用,请阅读[连接器参考指南](../connector/)。如果还希望想将 TDengine 与第三方系统集成起来,比如 Grafana, 请参考[第三方工具](../third-party/)。 -如果在开发过程中遇到任何问题,请点击每个页面下方的["反馈问题"](https://github.com/taosdata/TDengine/issues/new/choose), 在GitHub上直接递交issue。 +如果在开发过程中遇到任何问题,请点击每个页面下方的["反馈问题"](https://github.com/taosdata/TDengine/issues/new/choose), 在 GitHub 上直接递交 Issue。 ```mdx-code-block import DocCardList from '@theme/DocCardList'; diff --git a/docs/zh/21-tdinternal/01-arch.md b/docs/zh/21-tdinternal/01-arch.md index b128b9d438371f22763b0ccea605e19d2dc9aa7b..782e4bcdd8bd3451ce2558567ed5faf2002327ce 100644 --- a/docs/zh/21-tdinternal/01-arch.md +++ b/docs/zh/21-tdinternal/01-arch.md @@ -137,7 +137,7 @@ Leader Vnode 遵循下面的写入流程:
图 3 TDengine Leader 写入流程
1. leader vnode 收到应用的数据插入请求,验证 OK,进入下一步; -2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; +2. vnode 将该请求的原始数据包写入数据库日志文件 WAL。如果 `wal_level` 设置为 2,而且 `wal_fsync_period` 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失; 3. 如果有多个副本,vnode 将把数据包转发给同一虚拟节点组内的 follower vnodes,该转发包带有数据的版本号(version); 4. 写入内存,并将记录加入到 skip list。但如果未达成一致,会触发回滚操作; 5. leader vnode 返回确认信息给应用,表示写入成功; @@ -152,7 +152,7 @@ Leader Vnode 遵循下面的写入流程:
图 4 TDengine Follower 写入流程
1. follower vnode 收到 leader vnode 转发了的数据插入请求。 -2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 walLevel 设置为 2,而且 fsync 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 +2. vnode 将把该请求的原始数据包写入数据库日志文件 WAL。如果 `wal_level` 设置为 2,而且 `wal_fsync_period` 设置为 0,TDengine 还将 WAL 数据立即落盘,以保证即使宕机,也能从数据库日志文件中恢复数据,避免数据的丢失。 3. 写入内存,更新内存中的 skip list。 与 leader vnode 相比,follower vnode 不存在转发环节,也不存在回复确认环节,少了两步。但写内存与 WAL 是完全一样的。 @@ -165,7 +165,7 @@ Vnode 会保持一个数据版本号(version),对内存数据进行持久 ### 同步复制 -对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 replica 之外,用户还需要指定新的参数 strict。如果 strict 等于 1,它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内,得不到半数以上副本的确认,leader vnode 将返回错误给应用。 +对于数据一致性要求更高的场景,异步数据复制提供的最终一致性无法满足要求。因此 TDengine 提供同步复制的机制供用户选择。在创建数据库时,除指定副本数 `replica` 之外,用户还需要指定新的参数 `strict`。如果 `strict` 等于 1,它表示每次 leader 转发给副本时,需要等待半数以上副本达成一致后,才能通知应用,数据在 follower 已经写入成功。如果在一定的时间内,得不到半数以上副本的确认,leader vnode 将返回错误给应用。 采用同步复制,系统的性能会有所下降,而且 latency 会增加。因为元数据要强一致,mnode 之间的数据同步缺省就是采用的同步复制。 @@ -183,11 +183,11 @@ TDengine 通过查询函数向用户提供毫秒级的数据获取能力。直 TDengine 采用数据驱动的方式让缓存中的数据写入硬盘进行持久化存储。当 vnode 中缓存的数据达到一定规模时,为了不阻塞后续数据的写入,TDengine 也会拉起落盘线程将缓存的数据写入持久化存储。TDengine 在数据落盘时会打开新的数据库日志文件,在落盘成功后则会删除老的数据库日志文件,避免日志文件无限制地增长。 -为充分利用时序数据特点,TDengine 将一个 vnode 保存在持久化存储的数据切分成多个文件,每个文件只保存固定天数的数据,这个天数由系统配置参数 days 决定。切分成多个文件后,给定查询的起止日期,无需任何索引,就可以立即定位需要打开哪些数据文件,大大加快读取速度。 +为充分利用时序数据特点,TDengine 将一个 vnode 保存在持久化存储的数据切分成多个文件,每个文件只保存固定天数的数据,这个天数由系统配置参数 `duration` 决定。切分成多个文件后,给定查询的起止日期,无需任何索引,就可以立即定位需要打开哪些数据文件,大大加快读取速度。 -对于采集的数据,一般有保留时长,这个时长由系统配置参数 keep 决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。 +对于采集的数据,一般有保留时长,这个时长由系统配置参数 `keep` 决定。超过这个设置天数的数据文件,将被系统自动删除,释放存储空间。 -给定 days 与 keep 两个参数,一个典型工作状态的 vnode 中总的数据文件数为:向上取整 `(keep/days)+1` 个。总的数据文件个数不宜过大,也不宜过小。10 到 100 以内合适。基于这个原则,可以设置合理的 days。目前的版本,参数 keep 可以修改,但对于参数 days,一旦设置后,不可修改。 +给定 `duration` 与 `keep` 两个参数,一个典型工作状态的 vnode 中总的数据文件数为:向上取整 `(keep/duration)+1` 个。总的数据文件个数不宜过大,也不宜过小。10 到 100 以内合适。基于这个原则,可以设置合理的 `duration`。目前的版本,参数 `keep` 可以修改,但对于参数 `duration`,一旦设置后,不可修改。 在每个数据文件里,一张表的数据是一块一块存储的。一张表可以有一到多个数据文件块。在一个文件块里,数据是列式存储的,占用的是一片连续的存储空间,这样大大提高读取速度。文件块的大小由系统参数 maxRows (每块最大记录条数)决定,缺省值为 4096。这个值不宜过大,也不宜过小。过大,定位具体时间段的数据的搜索时间会变长,影响读取速度;过小,数据块的索引太大,压缩效率偏低,也影响读取速度。 diff --git a/include/common/systable.h b/include/common/systable.h index 882c54de952dc044ed30aa6a1aed66145c0db804..102465c8c2006d9026a22c67909008b03a7db3ac 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -47,14 +47,14 @@ extern "C" { #define TSDB_INS_TABLE_TOPICS "ins_topics" #define TSDB_INS_TABLE_STREAMS "ins_streams" -#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" -#define TSDB_PERFS_TABLE_SMAS "perf_smas" -#define TSDB_PERFS_TABLE_CONNECTIONS "perf_connections" -#define TSDB_PERFS_TABLE_QUERIES "perf_queries" -#define TSDB_PERFS_TABLE_CONSUMERS "perf_consumers" -#define TSDB_PERFS_TABLE_OFFSETS "perf_offsets" -#define TSDB_PERFS_TABLE_TRANS "perf_trans" -#define TSDB_PERFS_TABLE_APPS "perf_apps" +#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" +#define TSDB_PERFS_TABLE_SMAS "perf_smas" +#define TSDB_PERFS_TABLE_CONNECTIONS "perf_connections" +#define TSDB_PERFS_TABLE_QUERIES "perf_queries" +#define TSDB_PERFS_TABLE_CONSUMERS "perf_consumers" +#define TSDB_PERFS_TABLE_OFFSETS "perf_offsets" +#define TSDB_PERFS_TABLE_TRANS "perf_trans" +#define TSDB_PERFS_TABLE_APPS "perf_apps" typedef struct SSysDbTableSchema { const char* name; diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 350cd785d96c838345366453fae5ba935d6dd9eb..0e22985059907956c207d7c40103480d0913e65e 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -140,7 +140,7 @@ extern int32_t tsTtlPushInterval; extern int32_t tsGrantHBInterval; extern int32_t tsUptimeInterval; -#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) +//#define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize) int32_t taosCreateLog(const char *logname, int32_t logFileNum, const char *cfgDir, const char **envCmd, const char *envFile, char *apolloUrl, SArray *pArgs, bool tsc); diff --git a/include/common/tgrant.h b/include/common/tgrant.h index 97fb773044b0508774883aac0a09e6278a172d70..8a47b850c446d16378a80dd6c4eadf89aac21325 100644 --- a/include/common/tgrant.h +++ b/include/common/tgrant.h @@ -47,22 +47,23 @@ typedef enum { int32_t grantCheck(EGrantType grant); #ifndef GRANTS_CFG -#define GRANTS_SCHEMA static const SSysDbTableSchema grantsSchema[] = { \ - {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ - {.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ -} +#define GRANTS_SCHEMA \ + static const SSysDbTableSchema grantsSchema[] = { \ + {.name = "version", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "expire_time", .bytes = 19 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "expired", .bytes = 5 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "storage", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "timeseries", .bytes = 21 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "databases", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "users", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "accounts", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "dnodes", .bytes = 10 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "connections", .bytes = 11 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "streams", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "cpu_cores", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "speed", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + {.name = "querytime", .bytes = 9 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR}, \ + } #define GRANT_CFG_ADD #define GRANT_CFG_SET #define GRANT_CFG_GET diff --git a/include/common/tmsgtype.h b/include/common/tmsgtype.h index ebbf99b942199d2a1b247e8159eb2364b39e9830..035a2350a3a149a43dffc07433a4c4e6ca099231 100644 --- a/include/common/tmsgtype.h +++ b/include/common/tmsgtype.h @@ -20,6 +20,8 @@ extern "C" { #endif +// clang-format off + // sql type #ifdef TSDB_SQL_C @@ -103,8 +105,10 @@ enum { TSDB_DEFINE_SQL_TYPE( TSDB_SQL_MAX, "max" ) }; +// clang-format on + #ifdef __cplusplus } #endif -#endif /*_TD_COMMON_SQLMSGTYPE_H_*/ +#endif /*_TD_COMMON_SQLMSGTYPE_H_*/ diff --git a/include/common/tname.h b/include/common/tname.h index 89c7764404a1c8730109080a80d826af08dfa3b9..8c594a2b5ebbb8b9d71f54d01ac0d867ddb5c133 100644 --- a/include/common/tname.h +++ b/include/common/tname.h @@ -49,7 +49,7 @@ bool tNameIsValid(const SName* name); const char* tNameGetTableName(const SName* name); -int32_t tNameGetDbName(const SName* name, char* dst); +int32_t tNameGetDbName(const SName* name, char* dst); const char* tNameGetDbNameP(const SName* name); int32_t tNameGetFullDbName(const SName* name, char* dst); diff --git a/include/common/trow.h b/include/common/trow.h index 6cc93551448e26aafe1d5e78db881a36e40c7219..3680a82594c2fb679ae0b1d9afbb294f247b82d0 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -285,11 +285,11 @@ static FORCE_INLINE void tdSRowInit(SRowBuilder *pBuilder, int16_t sver) { pBuilder->rowType = TD_ROW_TP; // default STpRow pBuilder->sver = sver; } -int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen); -int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen); -int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen, - int32_t allNullLen, int32_t boundNullLen); -int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf); +int32_t tdSRowSetInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen); +int32_t tdSRowSetTpInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t flen); +int32_t tdSRowSetExtendedInfo(SRowBuilder *pBuilder, int32_t nCols, int32_t nBoundCols, int32_t flen, + int32_t allNullLen, int32_t boundNullLen); +int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf); static FORCE_INLINE void tdSRowEnd(SRowBuilder *pBuilder) { STSRow *pRow = (STSRow *)pBuilder->pBuf; if (pBuilder->hasNull || pBuilder->hasNone) { diff --git a/include/common/ttime.h b/include/common/ttime.h index 8f4f4f15d8752db38a2d411ac6e391be40dbb191..eaf44c2771e2ba4512db63bed2f398a2e613bc34 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -59,11 +59,11 @@ static FORCE_INLINE int64_t taosGetTimestamp(int32_t precision) { * precision == TSDB_TIME_PRECISION_NANO, it returns timestamp in nanosecond. */ static FORCE_INLINE int64_t taosGetTimestampToday(int32_t precision) { - int64_t factor = (precision == TSDB_TIME_PRECISION_MILLI) ? 1000 - : (precision == TSDB_TIME_PRECISION_MICRO) ? 1000000 - : 1000000000; - time_t t = taosTime(NULL); - struct tm tm; + int64_t factor = (precision == TSDB_TIME_PRECISION_MILLI) ? 1000 + : (precision == TSDB_TIME_PRECISION_MICRO) ? 1000000 + : 1000000000; + time_t t = taosTime(NULL); + struct tm tm; taosLocalTime(&t, &tm); tm.tm_hour = 0; tm.tm_min = 0; diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index d061da7aafc8de15ac0763d3fa62c167c2dd6fc3..18da3276633a30c3d9a6060e376c05cb50eaf293 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -152,166 +152,166 @@ #define TK_TABLES 134 #define TK_STABLES 135 #define TK_MNODES 136 -#define TK_MODULES 137 -#define TK_QNODES 138 -#define TK_FUNCTIONS 139 -#define TK_INDEXES 140 -#define TK_ACCOUNTS 141 -#define TK_APPS 142 -#define TK_CONNECTIONS 143 -#define TK_LICENCES 144 -#define TK_GRANTS 145 -#define TK_QUERIES 146 -#define TK_SCORES 147 -#define TK_TOPICS 148 -#define TK_VARIABLES 149 -#define TK_BNODES 150 -#define TK_SNODES 151 -#define TK_CLUSTER 152 -#define TK_TRANSACTIONS 153 -#define TK_DISTRIBUTED 154 -#define TK_CONSUMERS 155 -#define TK_SUBSCRIPTIONS 156 -#define TK_VNODES 157 -#define TK_LIKE 158 -#define TK_INDEX 159 -#define TK_FUNCTION 160 -#define TK_INTERVAL 161 -#define TK_TOPIC 162 -#define TK_AS 163 -#define TK_WITH 164 -#define TK_META 165 -#define TK_CONSUMER 166 -#define TK_GROUP 167 -#define TK_DESC 168 -#define TK_DESCRIBE 169 -#define TK_RESET 170 -#define TK_QUERY 171 -#define TK_CACHE 172 -#define TK_EXPLAIN 173 -#define TK_ANALYZE 174 -#define TK_VERBOSE 175 -#define TK_NK_BOOL 176 -#define TK_RATIO 177 -#define TK_NK_FLOAT 178 -#define TK_OUTPUTTYPE 179 -#define TK_AGGREGATE 180 -#define TK_BUFSIZE 181 -#define TK_STREAM 182 -#define TK_INTO 183 -#define TK_TRIGGER 184 -#define TK_AT_ONCE 185 -#define TK_WINDOW_CLOSE 186 -#define TK_IGNORE 187 -#define TK_EXPIRED 188 -#define TK_SUBTABLE 189 -#define TK_KILL 190 -#define TK_CONNECTION 191 -#define TK_TRANSACTION 192 -#define TK_BALANCE 193 -#define TK_VGROUP 194 -#define TK_MERGE 195 -#define TK_REDISTRIBUTE 196 -#define TK_SPLIT 197 -#define TK_DELETE 198 -#define TK_INSERT 199 -#define TK_NULL 200 -#define TK_NK_QUESTION 201 -#define TK_NK_ARROW 202 -#define TK_ROWTS 203 -#define TK_TBNAME 204 -#define TK_QSTART 205 -#define TK_QEND 206 -#define TK_QDURATION 207 -#define TK_WSTART 208 -#define TK_WEND 209 -#define TK_WDURATION 210 -#define TK_IROWTS 211 -#define TK_QTAGS 212 -#define TK_CAST 213 -#define TK_NOW 214 -#define TK_TODAY 215 -#define TK_TIMEZONE 216 -#define TK_CLIENT_VERSION 217 -#define TK_SERVER_VERSION 218 -#define TK_SERVER_STATUS 219 -#define TK_CURRENT_USER 220 -#define TK_COUNT 221 -#define TK_LAST_ROW 222 -#define TK_CASE 223 -#define TK_END 224 -#define TK_WHEN 225 -#define TK_THEN 226 -#define TK_ELSE 227 -#define TK_BETWEEN 228 -#define TK_IS 229 -#define TK_NK_LT 230 -#define TK_NK_GT 231 -#define TK_NK_LE 232 -#define TK_NK_GE 233 -#define TK_NK_NE 234 -#define TK_MATCH 235 -#define TK_NMATCH 236 -#define TK_CONTAINS 237 -#define TK_IN 238 -#define TK_JOIN 239 -#define TK_INNER 240 -#define TK_SELECT 241 -#define TK_DISTINCT 242 -#define TK_WHERE 243 -#define TK_PARTITION 244 -#define TK_BY 245 -#define TK_SESSION 246 -#define TK_STATE_WINDOW 247 -#define TK_SLIDING 248 -#define TK_FILL 249 -#define TK_VALUE 250 -#define TK_NONE 251 -#define TK_PREV 252 -#define TK_LINEAR 253 -#define TK_NEXT 254 -#define TK_HAVING 255 -#define TK_RANGE 256 -#define TK_EVERY 257 -#define TK_ORDER 258 -#define TK_SLIMIT 259 -#define TK_SOFFSET 260 -#define TK_LIMIT 261 -#define TK_OFFSET 262 -#define TK_ASC 263 -#define TK_NULLS 264 -#define TK_ABORT 265 -#define TK_AFTER 266 -#define TK_ATTACH 267 -#define TK_BEFORE 268 -#define TK_BEGIN 269 -#define TK_BITAND 270 -#define TK_BITNOT 271 -#define TK_BITOR 272 -#define TK_BLOCKS 273 -#define TK_CHANGE 274 -#define TK_COMMA 275 -#define TK_COMPACT 276 -#define TK_CONCAT 277 -#define TK_CONFLICT 278 -#define TK_COPY 279 -#define TK_DEFERRED 280 -#define TK_DELIMITERS 281 -#define TK_DETACH 282 -#define TK_DIVIDE 283 -#define TK_DOT 284 -#define TK_EACH 285 -#define TK_FAIL 286 -#define TK_FILE 287 -#define TK_FOR 288 -#define TK_GLOB 289 -#define TK_ID 290 -#define TK_IMMEDIATE 291 -#define TK_IMPORT 292 -#define TK_INITIALLY 293 -#define TK_INSTEAD 294 -#define TK_ISNULL 295 -#define TK_KEY 296 +#define TK_QNODES 137 +#define TK_FUNCTIONS 138 +#define TK_INDEXES 139 +#define TK_ACCOUNTS 140 +#define TK_APPS 141 +#define TK_CONNECTIONS 142 +#define TK_LICENCES 143 +#define TK_GRANTS 144 +#define TK_QUERIES 145 +#define TK_SCORES 146 +#define TK_TOPICS 147 +#define TK_VARIABLES 148 +#define TK_BNODES 149 +#define TK_SNODES 150 +#define TK_CLUSTER 151 +#define TK_TRANSACTIONS 152 +#define TK_DISTRIBUTED 153 +#define TK_CONSUMERS 154 +#define TK_SUBSCRIPTIONS 155 +#define TK_VNODES 156 +#define TK_LIKE 157 +#define TK_INDEX 158 +#define TK_FUNCTION 159 +#define TK_INTERVAL 160 +#define TK_TOPIC 161 +#define TK_AS 162 +#define TK_WITH 163 +#define TK_META 164 +#define TK_CONSUMER 165 +#define TK_GROUP 166 +#define TK_DESC 167 +#define TK_DESCRIBE 168 +#define TK_RESET 169 +#define TK_QUERY 170 +#define TK_CACHE 171 +#define TK_EXPLAIN 172 +#define TK_ANALYZE 173 +#define TK_VERBOSE 174 +#define TK_NK_BOOL 175 +#define TK_RATIO 176 +#define TK_NK_FLOAT 177 +#define TK_OUTPUTTYPE 178 +#define TK_AGGREGATE 179 +#define TK_BUFSIZE 180 +#define TK_STREAM 181 +#define TK_INTO 182 +#define TK_TRIGGER 183 +#define TK_AT_ONCE 184 +#define TK_WINDOW_CLOSE 185 +#define TK_IGNORE 186 +#define TK_EXPIRED 187 +#define TK_SUBTABLE 188 +#define TK_KILL 189 +#define TK_CONNECTION 190 +#define TK_TRANSACTION 191 +#define TK_BALANCE 192 +#define TK_VGROUP 193 +#define TK_MERGE 194 +#define TK_REDISTRIBUTE 195 +#define TK_SPLIT 196 +#define TK_DELETE 197 +#define TK_INSERT 198 +#define TK_NULL 199 +#define TK_NK_QUESTION 200 +#define TK_NK_ARROW 201 +#define TK_ROWTS 202 +#define TK_TBNAME 203 +#define TK_QSTART 204 +#define TK_QEND 205 +#define TK_QDURATION 206 +#define TK_WSTART 207 +#define TK_WEND 208 +#define TK_WDURATION 209 +#define TK_IROWTS 210 +#define TK_QTAGS 211 +#define TK_CAST 212 +#define TK_NOW 213 +#define TK_TODAY 214 +#define TK_TIMEZONE 215 +#define TK_CLIENT_VERSION 216 +#define TK_SERVER_VERSION 217 +#define TK_SERVER_STATUS 218 +#define TK_CURRENT_USER 219 +#define TK_COUNT 220 +#define TK_LAST_ROW 221 +#define TK_CASE 222 +#define TK_END 223 +#define TK_WHEN 224 +#define TK_THEN 225 +#define TK_ELSE 226 +#define TK_BETWEEN 227 +#define TK_IS 228 +#define TK_NK_LT 229 +#define TK_NK_GT 230 +#define TK_NK_LE 231 +#define TK_NK_GE 232 +#define TK_NK_NE 233 +#define TK_MATCH 234 +#define TK_NMATCH 235 +#define TK_CONTAINS 236 +#define TK_IN 237 +#define TK_JOIN 238 +#define TK_INNER 239 +#define TK_SELECT 240 +#define TK_DISTINCT 241 +#define TK_WHERE 242 +#define TK_PARTITION 243 +#define TK_BY 244 +#define TK_SESSION 245 +#define TK_STATE_WINDOW 246 +#define TK_SLIDING 247 +#define TK_FILL 248 +#define TK_VALUE 249 +#define TK_NONE 250 +#define TK_PREV 251 +#define TK_LINEAR 252 +#define TK_NEXT 253 +#define TK_HAVING 254 +#define TK_RANGE 255 +#define TK_EVERY 256 +#define TK_ORDER 257 +#define TK_SLIMIT 258 +#define TK_SOFFSET 259 +#define TK_LIMIT 260 +#define TK_OFFSET 261 +#define TK_ASC 262 +#define TK_NULLS 263 +#define TK_ABORT 264 +#define TK_AFTER 265 +#define TK_ATTACH 266 +#define TK_BEFORE 267 +#define TK_BEGIN 268 +#define TK_BITAND 269 +#define TK_BITNOT 270 +#define TK_BITOR 271 +#define TK_BLOCKS 272 +#define TK_CHANGE 273 +#define TK_COMMA 274 +#define TK_COMPACT 275 +#define TK_CONCAT 276 +#define TK_CONFLICT 277 +#define TK_COPY 278 +#define TK_DEFERRED 279 +#define TK_DELIMITERS 280 +#define TK_DETACH 281 +#define TK_DIVIDE 282 +#define TK_DOT 283 +#define TK_EACH 284 +#define TK_FAIL 285 +#define TK_FILE 286 +#define TK_FOR 287 +#define TK_GLOB 288 +#define TK_ID 289 +#define TK_IMMEDIATE 290 +#define TK_IMPORT 291 +#define TK_INITIALLY 292 +#define TK_INSTEAD 293 +#define TK_ISNULL 294 +#define TK_KEY 295 +#define TK_MODULES 296 #define TK_NK_BITNOT 297 #define TK_NK_SEMI 298 #define TK_NOTNULL 299 diff --git a/include/common/ttszip.h b/include/common/ttszip.h index e9f430232054a4a13c8aec7eada9b452d4873ca8..8eb99bd45e6fe041fc12cb83a32604a5af14a1e6 100644 --- a/include/common/ttszip.h +++ b/include/common/ttszip.h @@ -144,4 +144,4 @@ bool tsBufIsValidElem(STSElem* pElem); } #endif -#endif /*_TD_COMMON_TTSZIP_H_*/ +#endif /*_TD_COMMON_TTSZIP_H_*/ diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index c3caac00ad62a030babfad2843e7e3eb47884dc3..d66c8c5949f99c39851f34e530bcba8600592072 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -115,7 +115,7 @@ typedef struct SSTableVersion { uint64_t dbId; uint64_t suid; int16_t sversion; - int16_t tversion; + int16_t tversion; int32_t smaVer; } SSTableVersion; @@ -182,7 +182,8 @@ int32_t catalogRemoveStbMeta(SCatalog* pCtg, const char* dbFName, uint64_t dbId, * @param pTableMeta(output, table meta data, NEED to free it by calller) * @return error code */ -int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta); +int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta); /** * Get a super table's meta data. @@ -193,9 +194,10 @@ int32_t catalogGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const S * @param pTableMeta(output, table meta data, NEED to free it by calller) * @return error code */ -int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta); +int32_t catalogGetSTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta); -int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp *rspMsg); +int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg); int32_t catalogUpdateTableMeta(SCatalog* pCatalog, STableMetaRsp* rspMsg); @@ -232,7 +234,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, con * @param isSTable (input, is super table or not, 1:supposed to be stable, 0: supposed not to be stable, -1:not sure) * @return error code */ -int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable); +int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta, int32_t isSTable); /** * Get a table's actual vgroup, for stable it's all possible vgroup list. @@ -243,7 +246,8 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, * @param pVgroupList (output, vgroup info list, element is SVgroupInfo, NEED to simply free the array by caller) * @return error code */ -int32_t catalogGetTableDistVgInfo(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, SArray** pVgroupList); +int32_t catalogGetTableDistVgInfo(SCatalog* pCatalog, SRequestConnInfo* pConn, const SName* pTableName, + SArray** pVgroupList); /** * Get a table's vgroup from its name's hash value. @@ -267,13 +271,14 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, SRequestConnInfo* pConn, c */ int32_t catalogGetAllMeta(SCatalog* pCatalog, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp); -int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId); +int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, + void* param, int64_t* jobId); int32_t catalogGetQnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray* pQnodeList); int32_t catalogGetDnodeList(SCatalog* pCatalog, SRequestConnInfo* pConn, SArray** pDnodeList); -int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion **stables, uint32_t *num); +int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableVersion** stables, uint32_t* num); int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbVgVersion** dbs, uint32_t* num); @@ -285,19 +290,20 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char* int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes); -int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg); +int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg); -int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp); +int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp* pRsp); int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo); -int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass); +int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, + bool* pass); int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth); -int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet *epSet); +int32_t catalogUpdateVgEpSet(SCatalog* pCtg, const char* dbFName, int32_t vgId, SEpSet* epSet); -int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion); +int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo* pConn, char** pVersion); int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate); diff --git a/include/libs/executor/dataSinkMgt.h b/include/libs/executor/dataSinkMgt.h index 71105d88eb52cb7da920ebb967a892f59cde3894..816a53ad9626a8a49da940c62cd231aa6aa90da3 100644 --- a/include/libs/executor/dataSinkMgt.h +++ b/include/libs/executor/dataSinkMgt.h @@ -20,10 +20,10 @@ extern "C" { #endif -#include "os.h" -#include "thash.h" #include "executor.h" +#include "os.h" #include "plannodes.h" +#include "thash.h" #define DS_BUF_LOW 1 #define DS_BUF_FULL 2 @@ -56,11 +56,11 @@ typedef struct SDataSinkStat { } SDataSinkStat; typedef struct SDataSinkMgtCfg { - uint32_t maxDataBlockNum; // todo: this should be numOfRows? + uint32_t maxDataBlockNum; // todo: this should be numOfRows? uint32_t maxDataBlockNumPerQuery; } SDataSinkMgtCfg; -int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg); +int32_t dsDataSinkMgtInit(SDataSinkMgtCfg* cfg); typedef struct SInputData { const struct SSDataBlock* pData; @@ -79,14 +79,14 @@ typedef struct SOutputData { } SOutputData; /** - * Create a subplan's datasinker handle for all later operations. + * Create a subplan's datasinker handle for all later operations. * @param pDataSink * @param pHandle output * @return error code */ int32_t dsCreateDataSinker(const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam); -int32_t dsDataSinkGetCacheSize(SDataSinkStat *pStat); +int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat); /** * Put the result set returned by the executor into datasinker. @@ -114,7 +114,7 @@ void dsGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd); */ int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput); -int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t *pSize); +int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t* pSize); /** * After dsGetStatus returns DS_NEED_SCHEDULE, the caller need to put this into the work queue. diff --git a/include/libs/function/function.h b/include/libs/function/function.h index 1796956f96ea6f2e8b42eaf637bf371167f1fa2c..72248336f713386807b3b62360226dd485bb519d 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -176,9 +176,9 @@ struct SScalarParam { SColumnInfoData *columnData; SHashObj *pHashFilter; int32_t hashValueType; - void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value + void *param; // other parameter, such as meta handle from vnode, to extract table name/tag value int32_t numOfRows; - int32_t numOfQualified; // number of qualified elements in the final results + int32_t numOfQualified; // number of qualified elements in the final results }; void cleanupResultRowEntry(struct SResultRowEntryInfo *pCell); diff --git a/include/libs/function/taosudf.h b/include/libs/function/taosudf.h index 2b2063e3f61e575cd59de099feee3b83ad87ff9c..3fe3bb7d3b805f285e79a48eca45f5fd4855dacf 100644 --- a/include/libs/function/taosudf.h +++ b/include/libs/function/taosudf.h @@ -1,23 +1,23 @@ /* -* 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 . -*/ + * 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 TDENGINE_TAOSUDF_H #define TDENGINE_TAOSUDF_H -#include #include +#include #include #include @@ -52,16 +52,15 @@ typedef struct SUdfColumnData { } fixLenCol; struct { - int32_t varOffsetsLen; - int32_t *varOffsets; - int32_t payloadLen; - char *payload; - int32_t payloadAllocLen; + int32_t varOffsetsLen; + int32_t *varOffsets; + int32_t payloadLen; + char *payload; + int32_t payloadAllocLen; } varLenCol; }; } SUdfColumnData; - typedef struct SUdfColumn { SUdfColumnMeta colMeta; bool hasNull; @@ -69,15 +68,15 @@ typedef struct SUdfColumn { } SUdfColumn; typedef struct SUdfDataBlock { - int32_t numOfRows; - int32_t numOfCols; + int32_t numOfRows; + int32_t numOfCols; SUdfColumn **udfCols; } SUdfDataBlock; typedef struct SUdfInterBuf { int32_t bufLen; - char* buf; - int8_t numOfResult; //zero or one + char *buf; + int8_t numOfResult; // zero or one } SUdfInterBuf; typedef void *UdfcFuncHandle; @@ -86,28 +85,29 @@ typedef int32_t (*TUdfInitFunc)(); typedef int32_t (*TUdfDestroyFunc)(); #define UDF_MEMORY_EXP_GROWTH 1.5 -#define NBIT (3u) -#define BitPos(_n) ((_n) & ((1 << NBIT) - 1)) -#define BMCharPos(bm_, r_) ((bm_)[(r_) >> NBIT]) -#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) +#define NBIT (3u) +#define BitPos(_n) ((_n) & ((1 << NBIT) - 1)) +#define BMCharPos(bm_, r_) ((bm_)[(r_) >> NBIT]) +#define BitmapLen(_n) (((_n) + ((1 << NBIT) - 1)) >> NBIT) #define udfColDataIsNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] == -1) -#define udfColDataIsNull_f(pColumn, row) ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) +#define udfColDataIsNull_f(pColumn, row) \ + ((BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) & (1u << (7u - BitPos(row)))) == (1u << (7u - BitPos(row)))) #define udfColDataSetNull_f(pColumn, row) \ do { \ BMCharPos(pColumn->colData.fixLenCol.nullBitmap, row) |= (1u << (7u - BitPos(row))); \ } while (0) -#define udfColDataSetNotNull_f(pColumn, r_) \ - do { \ - BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ +#define udfColDataSetNotNull_f(pColumn, r_) \ + do { \ + BMCharPos(pColumn->colData.fixLenCol.nullBitmap, r_) &= ~(1u << (7u - BitPos(r_))); \ } while (0) -#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) +#define udfColDataSetNull_var(pColumn, row) ((pColumn->colData.varLenCol.varOffsets)[row] = -1) typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 -#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) -#define varDataLen(v) ((VarDataLenT *)(v))[0] -#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) +#define VARSTR_HEADER_SIZE sizeof(VarDataLenT) +#define varDataLen(v) ((VarDataLenT *)(v))[0] +#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE) #define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v)) #define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v)) #define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE)) @@ -116,8 +116,7 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 32767 (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON)) #define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_NCHAR)) - -static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t row) { +static FORCE_INLINE char *udfColDataGetData(const SUdfColumn *pColumn, int32_t row) { if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { return pColumn->colData.varLenCol.payload + pColumn->colData.varLenCol.varOffsets[row]; } else { @@ -125,13 +124,13 @@ static FORCE_INLINE char* udfColDataGetData(const SUdfColumn* pColumn, int32_t r } } -static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row) { +static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn *pColumn, int32_t row) { if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { if (pColumn->colMeta.type == TSDB_DATA_TYPE_JSON) { if (udfColDataIsNull_var(pColumn, row)) { return true; } - char* data = udfColDataGetData(pColumn, row); + char *data = udfColDataGetData(pColumn, row); return (*data == TSDB_DATA_TYPE_NULL); } else { return udfColDataIsNull_var(pColumn, row); @@ -141,29 +140,29 @@ static FORCE_INLINE bool udfColDataIsNull(const SUdfColumn* pColumn, int32_t row } } -static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t newCapacity) { +static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t newCapacity) { SUdfColumnMeta *meta = &pColumn->colMeta; SUdfColumnData *data = &pColumn->colData; - if (newCapacity== 0 || newCapacity <= data->rowsAlloc) { + if (newCapacity == 0 || newCapacity <= data->rowsAlloc) { return TSDB_CODE_SUCCESS; } - int allocCapacity = (data->rowsAlloc< 8) ? 8 : data->rowsAlloc; + int allocCapacity = (data->rowsAlloc < 8) ? 8 : data->rowsAlloc; while (allocCapacity < newCapacity) { allocCapacity *= UDF_MEMORY_EXP_GROWTH; } if (IS_VAR_DATA_TYPE(meta->type)) { - char* tmp = (char*)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); + char *tmp = (char *)realloc(data->varLenCol.varOffsets, sizeof(int32_t) * allocCapacity); if (tmp == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } - data->varLenCol.varOffsets = (int32_t*)tmp; + data->varLenCol.varOffsets = (int32_t *)tmp; data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity; // for payload, add data in udfColDataAppend } else { - char* tmp = (char*)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); + char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity)); if (tmp == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -173,13 +172,13 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t ne return TSDB_CODE_SUCCESS; } - tmp = (char*)realloc(data->fixLenCol.data, allocCapacity* meta->bytes); + tmp = (char *)realloc(data->fixLenCol.data, allocCapacity * meta->bytes); if (tmp == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } data->fixLenCol.data = tmp; - data->fixLenCol.dataLen = allocCapacity* meta->bytes; + data->fixLenCol.dataLen = allocCapacity * meta->bytes; } data->rowsAlloc = allocCapacity; @@ -187,8 +186,8 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn* pColumn, int32_t ne return TSDB_CODE_SUCCESS; } -static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { - udfColEnsureCapacity(pColumn, row+1); +static FORCE_INLINE void udfColDataSetNull(SUdfColumn *pColumn, int32_t row) { + udfColEnsureCapacity(pColumn, row + 1); if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) { udfColDataSetNull_var(pColumn, row); } else { @@ -197,10 +196,10 @@ static FORCE_INLINE void udfColDataSetNull(SUdfColumn* pColumn, int32_t row) { pColumn->hasNull = true; } -static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentRow, const char* pData, bool isNull) { +static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentRow, const char *pData, bool isNull) { SUdfColumnMeta *meta = &pColumn->colMeta; SUdfColumnData *data = &pColumn->colData; - udfColEnsureCapacity(pColumn, currentRow+1); + udfColEnsureCapacity(pColumn, currentRow + 1); bool isVarCol = IS_VAR_DATA_TYPE(meta->type); if (isNull) { udfColDataSetNull(pColumn, currentRow); @@ -233,7 +232,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentR newSize = newSize * UDF_MEMORY_EXP_GROWTH; } - char *buf = (char*)realloc(data->varLenCol.payload, newSize); + char *buf = (char *)realloc(data->varLenCol.payload, newSize); if (buf == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -249,11 +248,11 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn* pColumn, uint32_t currentR data->varLenCol.payloadLen += dataLen; } } - data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow+1) : data->numOfRows; + data->numOfRows = (currentRow + 1 > data->numOfRows) ? (currentRow + 1) : data->numOfRows; return 0; } -typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock* block, SUdfColumn *resultCol); +typedef int32_t (*TUdfScalarProcFunc)(SUdfDataBlock *block, SUdfColumn *resultCol); typedef int32_t (*TUdfAggStartFunc)(SUdfInterBuf *buf); typedef int32_t (*TUdfAggProcessFunc)(SUdfDataBlock *block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf); diff --git a/include/libs/function/tudf.h b/include/libs/function/tudf.h index b4c05fea87448bab3e7872ebdbb0a9de20b1c289..31cc53bb9f01a062db95fcdcc8b7704c23e12660 100644 --- a/include/libs/function/tudf.h +++ b/include/libs/function/tudf.h @@ -24,12 +24,12 @@ #define alloc alloc #include -#include #include -#include "tmsg.h" -#include "tcommon.h" +#include #include "function.h" +#include "tcommon.h" #include "tdatablock.h" +#include "tmsg.h" #ifdef __cplusplus extern "C" { @@ -43,8 +43,7 @@ extern "C" { #endif #define UDF_DNODE_ID_ENV_NAME "DNODE_ID" - -//low level APIs +// low level APIs /** * setup udf * @param udf, in @@ -62,7 +61,8 @@ int32_t doCallUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInter int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData); // input: interbuf1, interbuf2 // output: resultBuf -int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf); +int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, + SUdfInterBuf *resultBuf); // input: block // output: resultData int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output); @@ -75,11 +75,11 @@ int32_t doTeardownUdf(UdfcFuncHandle handle); void freeUdfInterBuf(SUdfInterBuf *buf); -//high level APIs -bool udfAggGetEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); +// high level APIs +bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv); +bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo); int32_t udfAggProcess(struct SqlFunctionCtx *pCtx); -int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); +int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock); int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output); diff --git a/include/libs/monitor/monitor.h b/include/libs/monitor/monitor.h index 41d80c1a83a1b01eae5bae71e150b33569706556..30254d61a9fd0b53509b89eab01d63422f5f835e 100644 --- a/include/libs/monitor/monitor.h +++ b/include/libs/monitor/monitor.h @@ -227,7 +227,6 @@ int32_t tDeserializeSMonMloadInfo(void *buf, int32_t bufLen, SMonMloadInfo *pInf int32_t tSerializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo); int32_t tDeserializeSQnodeLoad(void *buf, int32_t bufLen, SQnodeLoad *pInfo); - typedef struct { const char *server; uint16_t port; diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 25ff18a8fc1a5b6f35e82c2323ed6a4023285d76..c57e9718b26d428f986f48f6945c687a0286acac 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -99,6 +99,7 @@ typedef struct SScanLogicNode { int8_t cacheLastMode; bool hasNormalCols; // neither tag column nor primary key tag column bool sortPrimaryKey; + bool igLastNull; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -115,6 +116,7 @@ typedef struct SAggLogicNode { SNodeList* pGroupKeys; SNodeList* pAggFuncs; bool hasLastRow; + bool hasLast; bool hasTimeLineFunc; bool onlyHasKeepOrderFunc; } SAggLogicNode; @@ -317,6 +319,7 @@ typedef struct SLastRowScanPhysiNode { SScanPhysiNode scan; SNodeList* pGroupTags; bool groupSort; + bool ignoreNull; } SLastRowScanPhysiNode; typedef struct SSystemTableScanPhysiNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index e1acf0dd6ac74954c3be320e9792b7a78206a4bf..8d85c139df03853c3fa70b6d860f6821b364fe1f 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -291,6 +291,7 @@ typedef struct SSelectStmt { bool hasTailFunc; bool hasInterpFunc; bool hasLastRowFunc; + bool hasLastFunc; bool hasTimeLineFunc; bool hasUdaf; bool hasStateKey; diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index e9f3864f6738bc7714db49d8f2373900fe10bfb6..777fe1c4dfecd7b14c9f4395f519782a8c45762c 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -61,7 +61,6 @@ typedef struct STableComInfo { int32_t rowSize; // row size of the schema } STableComInfo; - typedef struct SIndexMeta { #if defined(WINDOWS) || defined(_TD_DARWIN_64) size_t avoidCompilationErrors; @@ -70,11 +69,11 @@ typedef struct SIndexMeta { } SIndexMeta; typedef struct SExecResult { - int32_t code; - uint64_t numOfRows; - uint64_t numOfBytes; - int32_t msgType; - void* res; + int32_t code; + uint64_t numOfRows; + uint64_t numOfBytes; + int32_t msgType; + void* res; } SExecResult; typedef struct STbVerInfo { @@ -166,7 +165,7 @@ typedef struct SRequestConnInfo { SEpSet mgmtEps; } SRequestConnInfo; -typedef void (*__freeFunc)(void *param); +typedef void (*__freeFunc)(void* param); typedef struct SMsgSendInfo { __async_send_cb_fn_t fp; // async callback function @@ -218,7 +217,7 @@ void initQueryModuleMsgHandle(); const SSchema* tGetTbnameColumnSchema(); bool tIsValidSchema(struct SSchema* pSchema, int32_t numOfCols, int32_t numOfTags); -int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta); +int32_t queryCreateCTableMetaFromMsg(STableMetaRsp* msg, SCTableMeta* pMeta); int32_t queryCreateTableMetaFromMsg(STableMetaRsp* msg, bool isSuperTable, STableMeta** pMeta); char* jobTaskStatusStr(int32_t status); @@ -231,7 +230,7 @@ int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst); int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst); extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen, - void* (*mallocFp)(int32_t)); + void* (*mallocFp)(int64_t)); extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t msgSize); #define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE @@ -250,64 +249,66 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define NEED_CLIENT_HANDLE_ERROR(_code) \ (NEED_CLIENT_RM_TBLMETA_ERROR(_code) || NEED_CLIENT_REFRESH_VG_ERROR(_code) || \ NEED_CLIENT_REFRESH_TBLMETA_ERROR(_code)) -#define NEED_REDIRECT_ERROR(_code) \ - ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ - (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || (_code) == TSDB_CODE_SYN_NOT_LEADER || \ +#define NEED_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL || \ + (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || (_code) == TSDB_CODE_SYN_NOT_LEADER || \ (_code) == TSDB_CODE_APP_NOT_READY || (_code) == TSDB_CODE_RPC_BROKEN_LINK) - + #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ (_type) == TDMT_MND_DROP_STB) -#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ - ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \ +#define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ + ((_code) == TSDB_CODE_RPC_REDIRECT || (_code) == TSDB_CODE_NODE_NOT_DEPLOYED || \ (_code) == TSDB_CODE_SYN_NOT_LEADER || (_code) == TSDB_CODE_APP_NOT_READY) #define REQUEST_TOTAL_EXEC_TIMES 2 -#define IS_SYS_DBNAME(_dbname) (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) +#define IS_SYS_DBNAME(_dbname) \ + (((*(_dbname) == 'i') && (0 == strcmp(_dbname, TSDB_INFORMATION_SCHEMA_DB))) || \ + ((*(_dbname) == 'p') && (0 == strcmp(_dbname, TSDB_PERFORMANCE_SCHEMA_DB)))) -#define qFatal(...) \ - do { \ - if (qDebugFlag & DEBUG_FATAL) { \ +#define qFatal(...) \ + do { \ + if (qDebugFlag & DEBUG_FATAL) { \ taosPrintLog("QRY FATAL ", DEBUG_FATAL, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qError(...) \ - do { \ - if (qDebugFlag & DEBUG_ERROR) { \ +#define qError(...) \ + do { \ + if (qDebugFlag & DEBUG_ERROR) { \ taosPrintLog("QRY ERROR ", DEBUG_ERROR, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qWarn(...) \ - do { \ - if (qDebugFlag & DEBUG_WARN) { \ +#define qWarn(...) \ + do { \ + if (qDebugFlag & DEBUG_WARN) { \ taosPrintLog("QRY WARN ", DEBUG_WARN, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qInfo(...) \ - do { \ - if (qDebugFlag & DEBUG_INFO) { \ +#define qInfo(...) \ + do { \ + if (qDebugFlag & DEBUG_INFO) { \ taosPrintLog("QRY ", DEBUG_INFO, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qDebug(...) \ - do { \ - if (qDebugFlag & DEBUG_DEBUG) { \ +#define qDebug(...) \ + do { \ + if (qDebugFlag & DEBUG_DEBUG) { \ taosPrintLog("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qTrace(...) \ - do { \ - if (qDebugFlag & DEBUG_TRACE) { \ +#define qTrace(...) \ + do { \ + if (qDebugFlag & DEBUG_TRACE) { \ taosPrintLog("QRY ", DEBUG_TRACE, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) -#define qDebugL(...) \ - do { \ - if (qDebugFlag & DEBUG_DEBUG) { \ +#define qDebugL(...) \ + do { \ + if (qDebugFlag & DEBUG_DEBUG) { \ taosPrintLongString("QRY ", DEBUG_DEBUG, qDebugFlag, __VA_ARGS__); \ - } \ + } \ } while (0) #define QRY_ERR_RET(c) \ diff --git a/include/libs/qworker/qworker.h b/include/libs/qworker/qworker.h index 99f51892284bb4eb9884b763bef051771d39e1b7..7a1e9bb2721c214dcf0ff961ca62dc0953d54882 100644 --- a/include/libs/qworker/qworker.h +++ b/include/libs/qworker/qworker.h @@ -72,7 +72,6 @@ typedef struct SQWMsg { SRpcHandleInfo connInfo; } SQWMsg; - int32_t qWorkerInit(int8_t nodeType, int32_t nodeId, void **qWorkerMgmt, const SMsgCb *pMsgCb); int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg); @@ -95,13 +94,15 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_ int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SDeleteRes *pRes); -void qWorkerDestroy(void **qWorkerMgmt); +void qWorkerDestroy(void **qWorkerMgmt); int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pStat); -int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, SQWMsg *qwMsg, SArray *explainRes); +int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, + SQWMsg *qwMsg, SArray *explainRes); -int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, void** pRsp, SArray* explainRes); +int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, + void **pRsp, SArray *explainRes); #ifdef __cplusplus } diff --git a/include/libs/scalar/filter.h b/include/libs/scalar/filter.h index e02b4a617253c7ade77a922568b478eaf62e0d9a..f20ba287de0ac2ec429ad44107418c8bfe58e0d7 100644 --- a/include/libs/scalar/filter.h +++ b/include/libs/scalar/filter.h @@ -31,9 +31,9 @@ enum { FLT_OPTION_NEED_UNIQE = 4, }; -#define FILTER_RESULT_ALL_QUALIFIED 0x1 -#define FILTER_RESULT_NONE_QUALIFIED 0x2 -#define FILTER_RESULT_PARTIAL_QUALIFIED 0x3 +#define FILTER_RESULT_ALL_QUALIFIED 0x1 +#define FILTER_RESULT_NONE_QUALIFIED 0x2 +#define FILTER_RESULT_PARTIAL_QUALIFIED 0x3 typedef struct SFilterColumnParam { int32_t numOfCols; @@ -41,7 +41,8 @@ typedef struct SFilterColumnParam { } SFilterColumnParam; extern int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pinfo, uint32_t options); -extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* pFilterResStatus); +extern bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis, + int16_t numOfCols, int32_t *pFilterResStatus); extern int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param); extern int32_t filterSetDataFromColId(SFilterInfo *info, void *param); extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict); diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index 6322c6a1e969371c20efbb0e2f4b96800242ecee..ef8e80b57fbc7fdb6255bcd38b88652e20cc5a9d 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -43,7 +43,7 @@ int32_t scalarGetOperatorParamNum(EOperatorType type); int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type); int32_t vectorGetConvertType(int32_t type1, int32_t type2); -int32_t vectorConvertImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow); +int32_t vectorConvertSingleColImpl(const SScalarParam *pIn, SScalarParam *pOut, int32_t *overflow, int32_t startIndex, int32_t numOfRows); /* Math functions */ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 077c23c1b580bb693e0ec581920b9ebea46de751..958d63349d8681cd294bf335fd024c2c15a74441 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -26,18 +26,18 @@ extern "C" { extern tsem_t schdRspSem; typedef struct SQueryProfileSummary { - int64_t startTs; // Object created and added into the message queue - int64_t endTs; // the timestamp when the task is completed - int64_t cputime; // total cpu cost, not execute elapsed time + int64_t startTs; // Object created and added into the message queue + int64_t endTs; // the timestamp when the task is completed + int64_t cputime; // total cpu cost, not execute elapsed time - int64_t loadRemoteDataDuration; // remote io time - int64_t loadNativeDataDuration; // native disk io time + int64_t loadRemoteDataDuration; // remote io time + int64_t loadNativeDataDuration; // native disk io time - uint64_t loadNativeData; // blocks + SMA + header files - uint64_t loadRemoteData; // remote data acquired by exchange operator. + uint64_t loadNativeData; // blocks + SMA + header files + uint64_t loadRemoteData; // remote data acquired by exchange operator. - uint64_t waitDuration; // the time to waiting to be scheduled in queue does matter, so we need to record it - int64_t addQTs; // the time to be added into the message queue, used to calculate the waiting duration in queue. + uint64_t waitDuration; // the time to waiting to be scheduled in queue does matter, so we need to record it + int64_t addQTs; // the time to be added into the message queue, used to calculate the waiting duration in queue. uint64_t totalRows; uint64_t loadRows; @@ -45,16 +45,16 @@ typedef struct SQueryProfileSummary { uint32_t loadBlocks; uint32_t loadBlockAgg; uint32_t skipBlocks; - uint64_t resultSize; // generated result size in Kb. + uint64_t resultSize; // generated result size in Kb. } SQueryProfileSummary; typedef struct STaskInfo { SQueryNodeAddr addr; - SSubQueryMsg *msg; + SSubQueryMsg* msg; } STaskInfo; typedef struct SSchdFetchParam { - void **pData; + void** pData; int32_t* code; } SSchdFetchParam; @@ -63,35 +63,34 @@ typedef void (*schedulerFetchFp)(void* pResult, void* param, int32_t code); typedef bool (*schedulerChkKillFp)(void* param); typedef struct SSchedulerReq { - bool syncReq; - bool localReq; - SRequestConnInfo *pConn; - SArray *pNodeList; - SQueryPlan *pDag; - int64_t allocatorRefId; - const char *sql; - int64_t startTs; - schedulerExecFp execFp; - schedulerFetchFp fetchFp; - void* cbParam; - schedulerChkKillFp chkKillFp; - void* chkKillParam; - SExecResult* pExecRes; - void** pFetchRes; + bool syncReq; + bool localReq; + SRequestConnInfo* pConn; + SArray* pNodeList; + SQueryPlan* pDag; + int64_t allocatorRefId; + const char* sql; + int64_t startTs; + schedulerExecFp execFp; + schedulerFetchFp fetchFp; + void* cbParam; + schedulerChkKillFp chkKillFp; + void* chkKillParam; + SExecResult* pExecRes; + void** pFetchRes; } SSchedulerReq; - int32_t schedulerInit(void); -int32_t schedulerExecJob(SSchedulerReq *pReq, int64_t *pJob); +int32_t schedulerExecJob(SSchedulerReq* pReq, int64_t* pJob); -int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq *pReq); +int32_t schedulerFetchRows(int64_t jobId, SSchedulerReq* pReq); void schedulerFetchRowsA(int64_t job, schedulerFetchFp fp, void* param); -int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); +int32_t schedulerGetTasksStatus(int64_t job, SArray* pSub); -void schedulerStopQueryHb(void *pTrans); +void schedulerStopQueryHb(void* pTrans); int32_t schedulerUpdatePolicy(int32_t policy); int32_t schedulerEnableReSchedule(bool enableResche); @@ -101,7 +100,7 @@ int32_t schedulerEnableReSchedule(bool enableResche); * @param pJob * @return */ -//int32_t scheduleCancelJob(void *pJob); +// int32_t scheduleCancelJob(void *pJob); /** * Free the query job diff --git a/include/libs/stream/streamState.h b/include/libs/stream/streamState.h index c2b3a7977c850d07feeed5af9fe71f7006fdc893..9445a0baa5302a7529e8d2d75ca89db6b96d6374 100644 --- a/include/libs/stream/streamState.h +++ b/include/libs/stream/streamState.h @@ -36,7 +36,7 @@ typedef struct { int32_t number; } SStreamState; -SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath); +SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages); void streamStateClose(SStreamState* pState); int32_t streamStateBegin(SStreamState* pState); int32_t streamStateCommit(SStreamState* pState); diff --git a/include/libs/sync/sync.h b/include/libs/sync/sync.h index 58c9b308901f6e9ed1bc8e871dd25997efe2fd15..411a63a37966fc7104b86202fe97f22c78c92ad1 100644 --- a/include/libs/sync/sync.h +++ b/include/libs/sync/sync.h @@ -132,7 +132,7 @@ typedef struct SSyncFSM { void (*FpRollBackCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpRestoreFinishCb)(struct SSyncFSM* pFsm); - void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta); + void (*FpReConfigCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta); void (*FpLeaderTransferCb)(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SFsmCbMeta cbMeta); void (*FpBecomeLeaderCb)(struct SSyncFSM* pFsm); diff --git a/include/libs/tfs/tfs.h b/include/libs/tfs/tfs.h index 6f71fd4cd02a241b9d4a43efbfd92bc99b3c91a8..3af75e0eaf443e7887dacd6a3056be4241ec5c9b 100644 --- a/include/libs/tfs/tfs.h +++ b/include/libs/tfs/tfs.h @@ -16,15 +16,15 @@ #ifndef _TD_TFS_H_ #define _TD_TFS_H_ -#include "tdef.h" #include "monitor.h" +#include "tdef.h" #ifdef __cplusplus extern "C" { #endif /* ------------------------ TYPES EXPOSED ------------------------ */ -typedef struct STfs STfs; +typedef struct STfs STfs; typedef struct STfsDir STfsDir; typedef struct { diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 655c903c0b74262ef9331a196ac7f589207282cd..53edcd4fee9bb9af6ab0d44235159b90990cf5c1 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -82,6 +82,9 @@ typedef struct SRpcInit { int8_t connType; // TAOS_CONN_UDP, TAOS_CONN_TCPC, TAOS_CONN_TCPS int32_t idleTime; // milliseconds, 0 means idle timer is disabled + int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size + int8_t encryption; // encrypt or not + // the following is for client app ecurity only char *user; // user name @@ -115,15 +118,14 @@ typedef struct { } SRpcCtx; int32_t rpcInit(); +void rpcCleanup(); -void rpcCleanup(); void *rpcOpen(const SRpcInit *pRpc); - void rpcClose(void *); void rpcCloseImpl(void *); -void *rpcMallocCont(int32_t contLen); +void *rpcMallocCont(int64_t contLen); void rpcFreeCont(void *pCont); -void *rpcReallocCont(void *ptr, int32_t contLen); +void *rpcReallocCont(void *ptr, int64_t contLen); // Because taosd supports multi-process mode // These functions should not be used on the server side diff --git a/include/os/os.h b/include/os/os.h index d646ffe4fdc4a3118c0594b406031a6287256c54..28a3ebee81228380c35f5d400235641ae6df2b6f 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -26,33 +26,33 @@ extern "C" { #include #if !defined(WINDOWS) -#include #include +#include #include +#include #include -#include -#include -#include -#include #include +#include +#include +#include #include +#include #include #include -#include -#include -#include +#include #include +#include #if defined(DARWIN) #else -#include #include +#include #endif #else #ifndef __func__ -#define __func__ __FUNCTION__ +#define __func__ __FUNCTION__ #endif #include #include @@ -82,11 +82,13 @@ extern "C" { #include #include -#include "taoserror.h" +#include "osThread.h" + #include "osAtomic.h" #include "osDef.h" #include "osDir.h" #include "osEndian.h" +#include "osEnv.h" #include "osFile.h" #include "osLocale.h" #include "osLz4.h" @@ -94,10 +96,9 @@ extern "C" { #include "osMemory.h" #include "osProc.h" #include "osRand.h" -#include "osThread.h" #include "osSemaphore.h" -#include "osSignal.h" #include "osShm.h" +#include "osSignal.h" #include "osSleep.h" #include "osSocket.h" #include "osString.h" @@ -106,7 +107,7 @@ extern "C" { #include "osTime.h" #include "osTimer.h" #include "osTimezone.h" -#include "osEnv.h" +#include "taoserror.h" #ifdef __cplusplus } diff --git a/include/os/osDef.h b/include/os/osDef.h index be8689398dacc44a262de53c597f8ec103b49923..297d19e21a4383e2fcc6c4f1ecf3dc86cb30f570 100644 --- a/include/os/osDef.h +++ b/include/os/osDef.h @@ -21,105 +21,104 @@ extern "C" { #endif #if defined(_TD_DARWIN_64) - // specific +// specific #ifndef __COMPAR_FN_T #define __COMPAR_FN_T - typedef int(*__compar_fn_t)(const void *, const void *); +typedef int (*__compar_fn_t)(const void *, const void *); #endif - // for send function in tsocket.c - #if defined(MSG_NOSIGNAL) - #undef MSG_NOSIGNAL - #endif +// for send function in tsocket.c +#if defined(MSG_NOSIGNAL) +#undef MSG_NOSIGNAL +#endif - #define MSG_NOSIGNAL 0 +#define MSG_NOSIGNAL 0 - #define SO_NO_CHECK 0x1234 - #define SOL_TCP 0x1234 - #define TCP_KEEPIDLE 0x1234 +#define SO_NO_CHECK 0x1234 +#define SOL_TCP 0x1234 +#define TCP_KEEPIDLE 0x1234 - #ifndef PTHREAD_MUTEX_RECURSIVE_NP - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE - #endif +#ifndef PTHREAD_MUTEX_RECURSIVE_NP +#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE +#endif #endif #if defined(_ALPINE) #ifndef __COMPAR_FN_T #define __COMPAR_FN_T - typedef int(*__compar_fn_t)(const void *, const void *); +typedef int (*__compar_fn_t)(const void *, const void *); +#endif +void error(int, int, const char *); +#ifndef PTHREAD_MUTEX_RECURSIVE_NP +#define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE #endif - void error (int, int, const char *); - #ifndef PTHREAD_MUTEX_RECURSIVE_NP - #define PTHREAD_MUTEX_RECURSIVE_NP PTHREAD_MUTEX_RECURSIVE - #endif #endif - #if defined(WINDOWS) - char *stpcpy (char *dest, const char *src); - char *stpncpy (char *dest, const char *src, int n); +char *stpcpy(char *dest, const char *src); +char *stpncpy(char *dest, const char *src, int n); - // specific +// specific #ifndef __COMPAR_FN_T #define __COMPAR_FN_T - typedef int (*__compar_fn_t)(const void *, const void *); -#endif - #define ssize_t int - #define _SSIZE_T_ - #define bzero(ptr, size) memset((ptr), 0, (size)) - #define strcasecmp _stricmp - #define strncasecmp _strnicmp - #define wcsncasecmp _wcsnicmp - #define strtok_r strtok_s - // #define snprintf _snprintf - #define in_addr_t unsigned long +typedef int (*__compar_fn_t)(const void *, const void *); +#endif +#define ssize_t int +#define _SSIZE_T_ +#define bzero(ptr, size) memset((ptr), 0, (size)) +#define strcasecmp _stricmp +#define strncasecmp _strnicmp +#define wcsncasecmp _wcsnicmp +#define strtok_r strtok_s +// #define snprintf _snprintf +#define in_addr_t unsigned long // #define socklen_t int - char * strsep(char **stringp, const char *delim); - char * getpass(const char *prefix); - char * strndup(const char *s, int n); - - // for send function in tsocket.c - #define MSG_NOSIGNAL 0 - #define SO_NO_CHECK 0x1234 - #define SOL_TCP 0x1234 - - #define SHUT_RDWR SD_BOTH - #define SHUT_RD SD_RECEIVE - #define SHUT_WR SD_SEND - - #define LOCK_EX 1 - #define LOCK_NB 2 - #define LOCK_UN 3 - - #ifndef PATH_MAX - #define PATH_MAX 256 - #endif - - typedef struct { - int we_wordc; - char *we_wordv[1]; - int we_offs; - char wordPos[1025]; - } wordexp_t; - int wordexp(char *words, wordexp_t *pwordexp, int flags); - void wordfree(wordexp_t *pwordexp); - - #define openlog(a, b, c) - #define closelog() - #define LOG_ERR 0 - #define LOG_INFO 1 - void syslog(int unused, const char *format, ...); -#endif // WINDOWS - +char *strsep(char **stringp, const char *delim); +char *getpass(const char *prefix); +char *strndup(const char *s, int n); + +// for send function in tsocket.c +#define MSG_NOSIGNAL 0 +#define SO_NO_CHECK 0x1234 +#define SOL_TCP 0x1234 + +#define SHUT_RDWR SD_BOTH +#define SHUT_RD SD_RECEIVE +#define SHUT_WR SD_SEND + +#define LOCK_EX 1 +#define LOCK_NB 2 +#define LOCK_UN 3 + +#ifndef PATH_MAX +#define PATH_MAX 256 +#endif + +typedef struct { + int we_wordc; + char *we_wordv[1]; + int we_offs; + char wordPos[1025]; +} wordexp_t; +int wordexp(char *words, wordexp_t *pwordexp, int flags); +void wordfree(wordexp_t *pwordexp); + +#define openlog(a, b, c) +#define closelog() +#define LOG_ERR 0 +#define LOG_INFO 1 +void syslog(int unused, const char *format, ...); +#endif // WINDOWS + #ifndef WINDOWS - #ifndef O_BINARY - #define O_BINARY 0 - #endif +#ifndef O_BINARY +#define O_BINARY 0 +#endif #endif -#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) -#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2)) +#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b))) +#define POINTER_DISTANCE(p1, p2) ((char *)(p1) - (char *)(p2)) #ifndef NDEBUG #define ASSERT(x) assert(x) @@ -141,7 +140,7 @@ extern "C" { #if defined(__GNUC__) #define UNUSED_PARAM(x) _UNUSED##x __attribute__((unused)) -#define UNUSED_FUNC __attribute__((unused)) +#define UNUSED_FUNC __attribute__((unused)) #else #define UNUSED_PARAM(x) x #define UNUSED_FUNC @@ -169,16 +168,22 @@ extern "C" { } \ } while (0) -#define DEFAULT_DOUBLE_COMP(x, y) \ - do { \ - if (isnan(x) && isnan(y)) { return 0; } \ - if (isnan(x)) { return -1; } \ - if (isnan(y)) { return 1; } \ - if ((x) == (y)) { \ - return 0; \ - } else { \ - return (x) < (y) ? -1 : 1; \ - } \ +#define DEFAULT_DOUBLE_COMP(x, y) \ + do { \ + if (isnan(x) && isnan(y)) { \ + return 0; \ + } \ + if (isnan(x)) { \ + return -1; \ + } \ + if (isnan(y)) { \ + return 1; \ + } \ + if ((x) == (y)) { \ + return 0; \ + } else { \ + return (x) < (y) ? -1 : 1; \ + } \ } while (0) #define DEFAULT_FLOAT_COMP(x, y) DEFAULT_DOUBLE_COMP(x, y) @@ -190,43 +195,49 @@ extern "C" { #undef threadlocal #ifdef _ISOC11_SOURCE - #define threadlocal _Thread_local +#define threadlocal _Thread_local #elif defined(__APPLE__) - #define threadlocal __thread +#define threadlocal __thread #elif defined(__GNUC__) && !defined(threadlocal) - #define threadlocal __thread +#define threadlocal __thread #else - #define threadlocal __declspec( thread ) +#define threadlocal __declspec(thread) #endif #ifdef WINDOWS - #define PRIzu "ld" +#define PRIzu "ld" #else - #define PRIzu "zu" +#define PRIzu "zu" #endif #if !defined(WINDOWS) - #if defined(_TD_DARWIN_64) - // MacOS - #if !defined(_GNU_SOURCE) - #define setThreadName(name) do { pthread_setname_np((name)); } while (0) - #else - // pthread_setname_np not defined - #define setThreadName(name) - #endif - #else - // Linux, length of name must <= 16 (the last '\0' included) - #define setThreadName(name) do { prctl(PR_SET_NAME, (name)); } while (0) - #endif +#if defined(_TD_DARWIN_64) +// MacOS +#if !defined(_GNU_SOURCE) +#define setThreadName(name) \ + do { \ + pthread_setname_np((name)); \ + } while (0) +#else +// pthread_setname_np not defined +#define setThreadName(name) +#endif +#else +// Linux, length of name must <= 16 (the last '\0' included) +#define setThreadName(name) \ + do { \ + prctl(PR_SET_NAME, (name)); \ + } while (0) +#endif #else - // Windows - #define setThreadName(name) +// Windows +#define setThreadName(name) #endif #if defined(_WIN32) -#define TD_DIRSEP "\\" +#define TD_DIRSEP "\\" #else -#define TD_DIRSEP "/" +#define TD_DIRSEP "/" #endif #define TD_LOCALE_LEN 64 diff --git a/include/os/osDir.h b/include/os/osDir.h index 2bdc99d2687d23a826e3430ed2c69e96e5619d24..40012f8141d9be3ad4b1d669327e019516448df4 100644 --- a/include/os/osDir.h +++ b/include/os/osDir.h @@ -19,12 +19,12 @@ // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define opendir OPENDIR_FUNC_TAOS_FORBID - #define readdir READDIR_FUNC_TAOS_FORBID - #define closedir CLOSEDIR_FUNC_TAOS_FORBID - #define dirname DIRNAME_FUNC_TAOS_FORBID - #undef basename - #define basename BASENAME_FUNC_TAOS_FORBID +#define opendir OPENDIR_FUNC_TAOS_FORBID +#define readdir READDIR_FUNC_TAOS_FORBID +#define closedir CLOSEDIR_FUNC_TAOS_FORBID +#define dirname DIRNAME_FUNC_TAOS_FORBID +#undef basename +#define basename BASENAME_FUNC_TAOS_FORBID #endif #ifdef __cplusplus @@ -32,26 +32,25 @@ extern "C" { #endif #ifdef WINDOWS -#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\" -#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\" +#define TD_TMP_DIR_PATH "C:\\Windows\\Temp\\" +#define TD_CFG_DIR_PATH "C:\\TDengine\\cfg\\" #define TD_DATA_DIR_PATH "C:\\TDengine\\data\\" -#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" +#define TD_LOG_DIR_PATH "C:\\TDengine\\log\\" #elif defined(_TD_DARWIN_64) -#define TD_TMP_DIR_PATH "/tmp/taosd/" -#define TD_CFG_DIR_PATH "/etc/taos/" +#define TD_TMP_DIR_PATH "/tmp/taosd/" +#define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" -#define TD_LOG_DIR_PATH "/var/log/taos/" +#define TD_LOG_DIR_PATH "/var/log/taos/" #else -#define TD_TMP_DIR_PATH "/tmp/" -#define TD_CFG_DIR_PATH "/etc/taos/" +#define TD_TMP_DIR_PATH "/tmp/" +#define TD_CFG_DIR_PATH "/etc/taos/" #define TD_DATA_DIR_PATH "/var/lib/taos/" -#define TD_LOG_DIR_PATH "/var/log/taos/" +#define TD_LOG_DIR_PATH "/var/log/taos/" #endif -typedef struct TdDir *TdDirPtr; +typedef struct TdDir *TdDirPtr; typedef struct TdDirEntry *TdDirEntryPtr; - void taosRemoveDir(const char *dirname); bool taosDirExist(const char *dirname); int32_t taosMkDir(const char *dirname); @@ -61,13 +60,13 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays); int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen); int32_t taosRealPath(char *dirname, char *realPath, int32_t maxlen); bool taosIsDir(const char *dirname); -char* taosDirName(char *dirname); -char* taosDirEntryBaseName(char *dirname); +char *taosDirName(char *dirname); +char *taosDirEntryBaseName(char *dirname); TdDirPtr taosOpenDir(const char *dirname); TdDirEntryPtr taosReadDir(TdDirPtr pDir); bool taosDirEntryIsDir(TdDirEntryPtr pDirEntry); -char* taosGetDirEntryName(TdDirEntryPtr pDirEntry); +char *taosGetDirEntryName(TdDirEntryPtr pDirEntry); int32_t taosCloseDir(TdDirPtr *ppDir); #ifdef __cplusplus diff --git a/include/os/osEndian.h b/include/os/osEndian.h index 1f52ece535139da70c3563bb1cb13acd16c6346d..8292b284d8b108f44676fb52869ec65928c7faf8 100644 --- a/include/os/osEndian.h +++ b/include/os/osEndian.h @@ -24,7 +24,7 @@ typedef enum { TD_LITTLE_ENDIAN = 0, TD_BIG_ENDIAN } td_endian_t; static const int32_t endian_test_var = 1; #define IS_LITTLE_ENDIAN() (*(uint8_t *)(&endian_test_var) != 0) -#define TD_RT_ENDIAN() (IS_LITTLE_ENDIAN() ? TD_LITTLE_ENDIAN : TD_BIG_ENDIAN) +#define TD_RT_ENDIAN() (IS_LITTLE_ENDIAN() ? TD_LITTLE_ENDIAN : TD_BIG_ENDIAN) #ifdef __cplusplus } diff --git a/include/os/osEnv.h b/include/os/osEnv.h index 798bfc197ef13bf95b3246fedbb27dafd881c2dd..293d9d17f85b9fe890570ec7045a5b4c59b7adc5 100644 --- a/include/os/osEnv.h +++ b/include/os/osEnv.h @@ -17,6 +17,7 @@ #define _TD_OS_ENV_H_ #include "osSysinfo.h" +#include "osTimezone.h" #ifdef __cplusplus extern "C" { @@ -34,7 +35,7 @@ extern int64_t tsOpenMax; extern int64_t tsStreamMax; extern float tsNumOfCores; extern int64_t tsTotalMemoryKB; -extern char* tsProcPath; +extern char *tsProcPath; extern char configDir[]; extern char tsDataDir[]; diff --git a/include/os/osEok.h b/include/os/osEok.h index 3ca476f840c1fc35bc796ecb4de67f6e0a156ca9..eed75abc6ae8e5cd101fd98bb1914d5500cace02 100644 --- a/include/os/osEok.h +++ b/include/os/osEok.h @@ -24,58 +24,54 @@ extern "C" { #ifdef __APPLE__ -enum EPOLL_EVENTS - { - EPOLLIN = 0x001, +enum EPOLL_EVENTS { + EPOLLIN = 0x001, #define EPOLLIN EPOLLIN - EPOLLPRI = 0x002, + EPOLLPRI = 0x002, #define EPOLLPRI EPOLLPRI - EPOLLOUT = 0x004, + EPOLLOUT = 0x004, #define EPOLLOUT EPOLLOUT - EPOLLRDNORM = 0x040, + EPOLLRDNORM = 0x040, #define EPOLLRDNORM EPOLLRDNORM - EPOLLRDBAND = 0x080, + EPOLLRDBAND = 0x080, #define EPOLLRDBAND EPOLLRDBAND - EPOLLWRNORM = 0x100, + EPOLLWRNORM = 0x100, #define EPOLLWRNORM EPOLLWRNORM - EPOLLWRBAND = 0x200, + EPOLLWRBAND = 0x200, #define EPOLLWRBAND EPOLLWRBAND - EPOLLMSG = 0x400, + EPOLLMSG = 0x400, #define EPOLLMSG EPOLLMSG - EPOLLERR = 0x008, + EPOLLERR = 0x008, #define EPOLLERR EPOLLERR - EPOLLHUP = 0x010, + EPOLLHUP = 0x010, #define EPOLLHUP EPOLLHUP - EPOLLRDHUP = 0x2000, + EPOLLRDHUP = 0x2000, #define EPOLLRDHUP EPOLLRDHUP - EPOLLEXCLUSIVE = 1u << 28, + EPOLLEXCLUSIVE = 1u << 28, #define EPOLLEXCLUSIVE EPOLLEXCLUSIVE - EPOLLWAKEUP = 1u << 29, + EPOLLWAKEUP = 1u << 29, #define EPOLLWAKEUP EPOLLWAKEUP - EPOLLONESHOT = 1u << 30, + EPOLLONESHOT = 1u << 30, #define EPOLLONESHOT EPOLLONESHOT - EPOLLET = 1u << 31 + EPOLLET = 1u << 31 #define EPOLLET EPOLLET - }; +}; /* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ #define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ #define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ #define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ - -typedef union epoll_data -{ - void *ptr; - int fd; +typedef union epoll_data { + void *ptr; + int fd; uint32_t u32; uint64_t u64; } epoll_data_t; -struct epoll_event -{ - uint32_t events; /* Epoll events */ - epoll_data_t data; /* User data variable */ +struct epoll_event { + uint32_t events; /* Epoll events */ + epoll_data_t data; /* User data variable */ }; int epoll_create(int size); @@ -83,11 +79,10 @@ int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); int epoll_close(int epfd); -#endif // __APPLE__ +#endif // __APPLE__ #ifdef __cplusplus } #endif -#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ - +#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ diff --git a/include/os/osLocale.h b/include/os/osLocale.h index 74922cc0b9fcfe3312458583a4c38f23391d1305..19627f1c7346de2a494118b0e49c32353a474ff7 100644 --- a/include/os/osLocale.h +++ b/include/os/osLocale.h @@ -25,7 +25,7 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define setlocale SETLOCALE_FUNC_TAOS_FORBID +#define setlocale SETLOCALE_FUNC_TAOS_FORBID #endif char *taosCharsetReplace(char *charsetstr); diff --git a/include/os/osLz4.h b/include/os/osLz4.h index 5bb33242d45dd7918c7ef2a1a53b59076e9ce4c0..39ff7c339049f76c0a3c8eae3dedc7b6aea44484 100644 --- a/include/os/osLz4.h +++ b/include/os/osLz4.h @@ -21,25 +21,25 @@ extern "C" { #endif #ifdef WINDOWS - int32_t BUILDIN_CLZL(uint64_t val); - int32_t BUILDIN_CLZ(uint32_t val); - int32_t BUILDIN_CTZL(uint64_t val); - int32_t BUILDIN_CTZ(uint32_t val); -#elif defined (_TD_LINUX_32) - #define BUILDIN_CLZL(val) __builtin_clzll(val) - #define BUILDIN_CTZL(val) __builtin_ctzll(val) - #define BUILDIN_CLZ(val) __builtin_clz(val) - #define BUILDIN_CTZ(val) __builtin_ctz(val) -#elif defined (_TD_ARM_32) - #define BUILDIN_CLZL(val) __builtin_clzll(val) - #define BUILDIN_CTZL(val) __builtin_ctzll(val) - #define BUILDIN_CLZ(val) __builtin_clz(val) - #define BUILDIN_CTZ(val) __builtin_ctz(val) +int32_t BUILDIN_CLZL(uint64_t val); +int32_t BUILDIN_CLZ(uint32_t val); +int32_t BUILDIN_CTZL(uint64_t val); +int32_t BUILDIN_CTZ(uint32_t val); +#elif defined(_TD_LINUX_32) +#define BUILDIN_CLZL(val) __builtin_clzll(val) +#define BUILDIN_CTZL(val) __builtin_ctzll(val) +#define BUILDIN_CLZ(val) __builtin_clz(val) +#define BUILDIN_CTZ(val) __builtin_ctz(val) +#elif defined(_TD_ARM_32) +#define BUILDIN_CLZL(val) __builtin_clzll(val) +#define BUILDIN_CTZL(val) __builtin_ctzll(val) +#define BUILDIN_CLZ(val) __builtin_clz(val) +#define BUILDIN_CTZ(val) __builtin_ctz(val) #else - #define BUILDIN_CLZL(val) __builtin_clzl(val) - #define BUILDIN_CTZL(val) __builtin_ctzl(val) - #define BUILDIN_CLZ(val) __builtin_clz(val) - #define BUILDIN_CTZ(val) __builtin_ctz(val) +#define BUILDIN_CLZL(val) __builtin_clzl(val) +#define BUILDIN_CTZL(val) __builtin_ctzl(val) +#define BUILDIN_CLZ(val) __builtin_clz(val) +#define BUILDIN_CTZ(val) __builtin_ctz(val) #endif #ifdef __cplusplus diff --git a/include/os/osMath.h b/include/os/osMath.h index 74973d9bb22168ba99b6eb48dd9f98976c77c17c..ec17073e9b5c6ad3897c86e8c7777288f8b85a4c 100644 --- a/include/os/osMath.h +++ b/include/os/osMath.h @@ -23,40 +23,40 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following sectio #ifndef ALLOW_FORBID_FUNC -#define qsort QSORT_FUNC_TAOS_FORBID +#define qsort QSORT_FUNC_TAOS_FORBID #endif #define TPOW2(x) ((x) * (x)) -#define TABS(x) ((x) > 0 ? (x) : -(x)) +#define TABS(x) ((x) > 0 ? (x) : -(x)) -#define TSWAP(a, b) \ - do { \ - char *__tmp = alloca(sizeof(a)); \ - memcpy(__tmp, &(a), sizeof(a)); \ - memcpy(&(a), &(b), sizeof(a)); \ - memcpy(&(b), __tmp, sizeof(a)); \ +#define TSWAP(a, b) \ + do { \ + char *__tmp = alloca(sizeof(a)); \ + memcpy(__tmp, &(a), sizeof(a)); \ + memcpy(&(a), &(b), sizeof(a)); \ + memcpy(&(b), __tmp, sizeof(a)); \ } while (0) #ifdef WINDOWS - #define TMAX(a, b) (((a) > (b)) ? (a) : (b)) - #define TMIN(a, b) (((a) < (b)) ? (a) : (b)) - #define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)),(aa) = TMIN((aa), (cc))) +#define TMAX(a, b) (((a) > (b)) ? (a) : (b)) +#define TMIN(a, b) (((a) < (b)) ? (a) : (b)) +#define TRANGE(aa, bb, cc) ((aa) = TMAX((aa), (bb)), (aa) = TMIN((aa), (cc))) #else - #define TMAX(a, b) \ - ({ \ - __typeof(a) __a = (a); \ - __typeof(b) __b = (b); \ - (__a > __b) ? __a : __b; \ - }) +#define TMAX(a, b) \ + ({ \ + __typeof(a) __a = (a); \ + __typeof(b) __b = (b); \ + (__a > __b) ? __a : __b; \ + }) -#define TMIN(a, b) \ - ({ \ - __typeof(a) __a = (a); \ - __typeof(b) __b = (b); \ - (__a < __b) ? __a : __b; \ +#define TMIN(a, b) \ + ({ \ + __typeof(a) __a = (a); \ + __typeof(b) __b = (b); \ + (__a < __b) ? __a : __b; \ }) #define TRANGE(a, b, c) \ @@ -71,7 +71,7 @@ extern "C" { typedef int32_t (*__compar_fn_t)(const void *, const void *); #endif -void taosSort(void* arr, int64_t sz, int64_t width, __compar_fn_t compar); +void taosSort(void *arr, int64_t sz, int64_t width, __compar_fn_t compar); #ifdef __cplusplus } diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 88dfe02074fa3d8940c71b5aa4354ab2871d070d..7ec8366ee4cb584dc41aa0ce94d5c54f6405964e 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -23,19 +23,19 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following sectio #ifndef ALLOW_FORBID_FUNC - #define malloc MALLOC_FUNC_TAOS_FORBID - #define calloc CALLOC_FUNC_TAOS_FORBID - #define realloc REALLOC_FUNC_TAOS_FORBID - #define free FREE_FUNC_TAOS_FORBID +#define malloc MALLOC_FUNC_TAOS_FORBID +#define calloc CALLOC_FUNC_TAOS_FORBID +#define realloc REALLOC_FUNC_TAOS_FORBID +#define free FREE_FUNC_TAOS_FORBID #endif -void *taosMemoryMalloc(int32_t size); -void *taosMemoryCalloc(int32_t num, int32_t size); -void *taosMemoryRealloc(void *ptr, int32_t size); -void *taosMemoryStrDup(const char *ptr); -void taosMemoryFree(void *ptr); -int32_t taosMemorySize(void *ptr); -void taosPrintBackTrace(); +void *taosMemoryMalloc(int64_t size); +void *taosMemoryCalloc(int64_t num, int64_t size); +void *taosMemoryRealloc(void *ptr, int64_t size); +void *taosMemoryStrDup(const char *ptr); +void taosMemoryFree(void *ptr); +int64_t taosMemorySize(void *ptr); +void taosPrintBackTrace(); #define taosMemoryFreeClear(ptr) \ do { \ diff --git a/include/os/osRand.h b/include/os/osRand.h index bce2c08a2ec16468b9c8a8ae7a4764e8838fb492..27d07e8c6ffe64fe940f592553a20bbe6972ec31 100644 --- a/include/os/osRand.h +++ b/include/os/osRand.h @@ -23,14 +23,14 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define rand RAND_FUNC_TAOS_FORBID - #define srand SRAND_FUNC_TAOS_FORBID - #define rand_r RANDR_FUNC_TAOS_FORBID +#define rand RAND_FUNC_TAOS_FORBID +#define srand SRAND_FUNC_TAOS_FORBID +#define rand_r RANDR_FUNC_TAOS_FORBID #endif -void taosSeedRand(uint32_t seed); +void taosSeedRand(uint32_t seed); uint32_t taosRand(void); -uint32_t taosRandR(uint32_t *pSeed); +uint32_t taosRandR(uint32_t* pSeed); void taosRandStr(char* str, int32_t size); uint32_t taosSafeRand(void); diff --git a/include/os/osShm.h b/include/os/osShm.h index 61ffc0f6cc983229e5d35385909905b7af036731..87efb1ab16e8978294b2a286d8c1093d406c82a8 100644 --- a/include/os/osShm.h +++ b/include/os/osShm.h @@ -23,10 +23,10 @@ extern "C" { typedef struct { int32_t id; int32_t size; - void* ptr; + void *ptr; } SShm; -int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize) ; +int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize); void taosDropShm(SShm *pShm); int32_t taosAttachShm(SShm *pShm); diff --git a/include/os/osSignal.h b/include/os/osSignal.h index 12f4f2ed0fb9ea2511a876772dd27f8f5b5a3379..3917c6cefc77e27be18c4a7150f9072af0eec2f1 100644 --- a/include/os/osSignal.h +++ b/include/os/osSignal.h @@ -21,27 +21,27 @@ extern "C" { #endif #ifndef SIGALRM - #define SIGALRM 1234 +#define SIGALRM 1234 #endif #ifndef SIGHUP - #define SIGHUP 1230 +#define SIGHUP 1230 #endif #ifndef SIGCHLD - #define SIGCHLD 1234 +#define SIGCHLD 1234 #endif #ifndef SIGUSR1 - #define SIGUSR1 1234 +#define SIGUSR1 1234 #endif #ifndef SIGUSR2 - #define SIGUSR2 1234 +#define SIGUSR2 1234 #endif #ifndef SIGBREAK - #define SIGBREAK 1234 +#define SIGBREAK 1234 #endif #ifdef WINDOWS @@ -59,4 +59,4 @@ void taosKillChildOnParentStopped(); } #endif -#endif /*_TD_OS_SIGNAL_H_*/ +#endif /*_TD_OS_SIGNAL_H_*/ diff --git a/include/os/osSleep.h b/include/os/osSleep.h index 1d0ccf32bd272ab60c42efae47bf8eba2050fa4f..95babb38de3557044fe6f3dc0523d486cdfebcf4 100644 --- a/include/os/osSleep.h +++ b/include/os/osSleep.h @@ -23,10 +23,10 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define Sleep SLEEP_FUNC_TAOS_FORBID - #define sleep SLEEP_FUNC_TAOS_FORBID - #define usleep USLEEP_FUNC_TAOS_FORBID - #define nanosleep NANOSLEEP_FUNC_TAOS_FORBID +#define Sleep SLEEP_FUNC_TAOS_FORBID +#define sleep SLEEP_FUNC_TAOS_FORBID +#define usleep USLEEP_FUNC_TAOS_FORBID +#define nanosleep NANOSLEEP_FUNC_TAOS_FORBID #endif void taosSsleep(int32_t s); diff --git a/include/os/osSocket.h b/include/os/osSocket.h index c6729da76af0e59cb3ccda024709b86fe034b039..2c7c579401c54fb74428dc90f972f817a010778c 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -75,7 +75,7 @@ extern "C" { typedef int socklen_t; #define TAOS_EPOLL_WAIT_TIME 100 typedef SOCKET eventfd_t; -#define eventfd(a, b) -1 +#define eventfd(a, b) -1 #ifndef EPOLLWAKEUP #define EPOLLWAKEUP (1u << 29) #endif @@ -119,8 +119,8 @@ typedef int32_t SocketFd; typedef SocketFd EpollFd; typedef struct TdSocketServer *TdSocketServerPtr; -typedef struct TdSocket * TdSocketPtr; -typedef struct TdEpoll * TdEpollPtr; +typedef struct TdSocket *TdSocketPtr; +typedef struct TdEpoll *TdEpollPtr; int32_t taosSendto(TdSocketPtr pSocket, void *msg, int len, unsigned int flags, const struct sockaddr *to, int tolen); int32_t taosWriteSocket(TdSocketPtr pSocket, void *msg, int len); diff --git a/include/os/osString.h b/include/os/osString.h index 8c1885efdfd72c3bdbd7e588e834901c78c41d1f..4c3fbe46c3870d98ae8b22f4dcf9a6edcb9ab4f7 100644 --- a/include/os/osString.h +++ b/include/os/osString.h @@ -26,37 +26,37 @@ typedef int32_t TdUcs4; // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID - #define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID - #define iconv ICONV_FUNC_TAOS_FORBID - #define wcwidth WCWIDTH_FUNC_TAOS_FORBID - #define wcswidth WCSWIDTH_FUNC_TAOS_FORBID - #define mbtowc MBTOWC_FUNC_TAOS_FORBID - #define mbstowcs MBSTOWCS_FUNC_TAOS_FORBID - #define wctomb WCTOMB_FUNC_TAOS_FORBID - #define wcstombs WCSTOMBS_FUNC_TAOS_FORBID - #define wcsncpy WCSNCPY_FUNC_TAOS_FORBID - #define wchar_t WCHAR_T_TYPE_TAOS_FORBID - #define strcasestr STR_CASE_STR_FORBID - #define strtoll STR_TO_LL_FUNC_TAOS_FORBID - #define strtoull STR_TO_ULL_FUNC_TAOS_FORBID - #define strtol STR_TO_L_FUNC_TAOS_FORBID - #define strtoul STR_TO_UL_FUNC_TAOS_FORBID - #define strtod STR_TO_LD_FUNC_TAOS_FORBID - #define strtold STR_TO_D_FUNC_TAOS_FORBID - #define strtof STR_TO_F_FUNC_TAOS_FORBID +#define iconv_open ICONV_OPEN_FUNC_TAOS_FORBID +#define iconv_close ICONV_CLOSE_FUNC_TAOS_FORBID +#define iconv ICONV_FUNC_TAOS_FORBID +#define wcwidth WCWIDTH_FUNC_TAOS_FORBID +#define wcswidth WCSWIDTH_FUNC_TAOS_FORBID +#define mbtowc MBTOWC_FUNC_TAOS_FORBID +#define mbstowcs MBSTOWCS_FUNC_TAOS_FORBID +#define wctomb WCTOMB_FUNC_TAOS_FORBID +#define wcstombs WCSTOMBS_FUNC_TAOS_FORBID +#define wcsncpy WCSNCPY_FUNC_TAOS_FORBID +#define wchar_t WCHAR_T_TYPE_TAOS_FORBID +#define strcasestr STR_CASE_STR_FORBID +#define strtoll STR_TO_LL_FUNC_TAOS_FORBID +#define strtoull STR_TO_ULL_FUNC_TAOS_FORBID +#define strtol STR_TO_L_FUNC_TAOS_FORBID +#define strtoul STR_TO_UL_FUNC_TAOS_FORBID +#define strtod STR_TO_LD_FUNC_TAOS_FORBID +#define strtold STR_TO_D_FUNC_TAOS_FORBID +#define strtof STR_TO_F_FUNC_TAOS_FORBID #endif #ifdef WINDOWS - #define tstrdup(str) _strdup(str) +#define tstrdup(str) _strdup(str) #else - #define tstrdup(str) strdup(str) +#define tstrdup(str) strdup(str) #endif -#define tstrncpy(dst, src, size) \ - do { \ - strncpy((dst), (src), (size)); \ - (dst)[(size)-1] = 0; \ +#define tstrncpy(dst, src, size) \ + do { \ + strncpy((dst), (src), (size)); \ + (dst)[(size)-1] = 0; \ } while (0) int32_t taosUcs4len(TdUcs4 *ucs4); @@ -67,7 +67,7 @@ void taosConvDestroy(); int32_t taosUcs4ToMbs(TdUcs4 *ucs4, int32_t ucs4_max_len, char *mbs); bool taosMbsToUcs4(const char *mbs, size_t mbs_len, TdUcs4 *ucs4, int32_t ucs4_max_len, int32_t *len); int32_t tasoUcs4Compare(TdUcs4 *f1_ucs4, TdUcs4 *f2_ucs4, int32_t bytes); -TdUcs4* tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4); +TdUcs4 *tasoUcs4Copy(TdUcs4 *target_ucs4, TdUcs4 *source_ucs4, int32_t len_ucs4); bool taosValidateEncodec(const char *encodec); int32_t taosHexEncode(const unsigned char *src, char *dst, int32_t len); int32_t taosHexDecode(const char *src, char *dst, int32_t len); @@ -80,16 +80,16 @@ int32_t taosWcharToMb(char *pStr, TdWchar wchar); char *taosStrCaseStr(const char *str, const char *pattern); -int64_t taosStr2Int64(const char *str, char** pEnd, int32_t radix); -uint64_t taosStr2UInt64(const char *str, char** pEnd, int32_t radix); -int32_t taosStr2Int32(const char *str, char** pEnd, int32_t radix); -uint32_t taosStr2UInt32(const char *str, char** pEnd, int32_t radix); -int16_t taosStr2Int16(const char *str, char** pEnd, int32_t radix); -uint16_t taosStr2UInt16(const char *str, char** pEnd, int32_t radix); -int8_t taosStr2Int8(const char *str, char** pEnd, int32_t radix); -uint8_t taosStr2UInt8(const char *str, char** pEnd, int32_t radix); -double taosStr2Double(const char *str, char** pEnd); -float taosStr2Float(const char *str, char** pEnd); +int64_t taosStr2Int64(const char *str, char **pEnd, int32_t radix); +uint64_t taosStr2UInt64(const char *str, char **pEnd, int32_t radix); +int32_t taosStr2Int32(const char *str, char **pEnd, int32_t radix); +uint32_t taosStr2UInt32(const char *str, char **pEnd, int32_t radix); +int16_t taosStr2Int16(const char *str, char **pEnd, int32_t radix); +uint16_t taosStr2UInt16(const char *str, char **pEnd, int32_t radix); +int8_t taosStr2Int8(const char *str, char **pEnd, int32_t radix); +uint8_t taosStr2UInt8(const char *str, char **pEnd, int32_t radix); +double taosStr2Double(const char *str, char **pEnd); +float taosStr2Float(const char *str, char **pEnd); #ifdef __cplusplus } diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index 6eed31b5e9a6de475c06734970490e93c9cdda62..47cdb02a6fb66be825484249434f2fa0c7a1a38e 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -54,10 +54,10 @@ void taosSetCoreDump(bool enable); #if !defined(LINUX) -#define _UTSNAME_LENGTH 65 +#define _UTSNAME_LENGTH 65 #define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH -#endif // WINDOWS +#endif // WINDOWS typedef struct { char sysname[_UTSNAME_MACHINE_LENGTH]; @@ -68,7 +68,7 @@ typedef struct { } SysNameInfo; SysNameInfo taosGetSysNameInfo(); -bool taosCheckCurrentInDll(); +bool taosCheckCurrentInDll(); #ifdef __cplusplus } diff --git a/include/os/osSystem.h b/include/os/osSystem.h index c5b8fc7be764c99a2194e3deaf179c80abd93744..eca984c41a3a0502ba726dfbac228dcc82076298 100644 --- a/include/os/osSystem.h +++ b/include/os/osSystem.h @@ -23,16 +23,16 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define popen POPEN_FUNC_TAOS_FORBID - #define pclose PCLOSE_FUNC_TAOS_FORBID - #define tcsetattr TCSETATTR_FUNC_TAOS_FORBID - #define tcgetattr TCGETATTR_FUNC_TAOS_FORBID +#define popen POPEN_FUNC_TAOS_FORBID +#define pclose PCLOSE_FUNC_TAOS_FORBID +#define tcsetattr TCSETATTR_FUNC_TAOS_FORBID +#define tcgetattr TCGETATTR_FUNC_TAOS_FORBID #endif -typedef struct TdCmd *TdCmdPtr; +typedef struct TdCmd* TdCmdPtr; TdCmdPtr taosOpenCmd(const char* cmd); -int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf); +int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf); int64_t taosGetLineCmd(TdCmdPtr pCmd, char** __restrict ptrBuf); int32_t taosEOFCmd(TdCmdPtr pCmd); int64_t taosCloseCmd(TdCmdPtr* ppCmd); diff --git a/include/os/osThread.h b/include/os/osThread.h index b1ea8277f0b405be876d51b123e1103d1676d6c2..916d463733373c2512ab77a7e6931cede98966af 100644 --- a/include/os/osThread.h +++ b/include/os/osThread.h @@ -29,21 +29,20 @@ typedef pthread_mutex_t pthread_spinlock_t; #endif #endif -typedef pthread_t TdThread; -typedef pthread_spinlock_t TdThreadSpinlock; -typedef pthread_mutex_t TdThreadMutex; -typedef pthread_mutexattr_t TdThreadMutexAttr; -typedef pthread_rwlock_t TdThreadRwlock; -typedef pthread_attr_t TdThreadAttr; -typedef pthread_once_t TdThreadOnce; +typedef pthread_t TdThread; +typedef pthread_spinlock_t TdThreadSpinlock; +typedef pthread_mutex_t TdThreadMutex; +typedef pthread_mutexattr_t TdThreadMutexAttr; +typedef pthread_rwlock_t TdThreadRwlock; +typedef pthread_attr_t TdThreadAttr; +typedef pthread_once_t TdThreadOnce; typedef pthread_rwlockattr_t TdThreadRwlockAttr; -typedef pthread_cond_t TdThreadCond; -typedef pthread_condattr_t TdThreadCondAttr; -typedef pthread_key_t TdThreadKey; +typedef pthread_cond_t TdThreadCond; +typedef pthread_condattr_t TdThreadCondAttr; +typedef pthread_key_t TdThreadKey; #define taosThreadCleanupPush pthread_cleanup_push -#define taosThreadCleanupPop pthread_cleanup_pop - +#define taosThreadCleanupPop pthread_cleanup_pop #ifdef WINDOWS #define TD_PTHREAD_MUTEX_INITIALIZER (TdThreadMutex)(-1) @@ -54,181 +53,181 @@ typedef pthread_key_t TdThreadKey; // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define pthread_t PTHREAD_T_TYPE_TAOS_FORBID - #define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID - #define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID - #define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID - #define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID - #define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID - #define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID - #define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID - #define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID - #define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID - #define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID - #define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID - #define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID - #define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID - #define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID - #define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID - #define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID - #define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID - #define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID - #define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID - #define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID - #define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID - #define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID - #define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID - #define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID - #define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID - #define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID - #define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID - #define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID - #define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID - #define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID - #define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID - #define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID - #define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID - #define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID - #define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID - #define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID - #define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID - #define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID - #define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID - #define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID - #define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID - #define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID - #define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID - #define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID - #define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID - #define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID - #define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID - #define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID - #define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID - #define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID - #define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID - #define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID - #define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID - #define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID - #define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID - #define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID - #define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID - #define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID - #define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID - #define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID - #define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID - #define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID - #define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID - #define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID - #define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID - #define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID - #define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID - #define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID - #define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID - #define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID - #define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID - #define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID - #define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID - #define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID - #define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID - #define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID - #define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID - #define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID - #define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID - #define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID - #define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID - #define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID - #define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID - #define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID - #define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID - #define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID - #define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID - #define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID - #define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID - #define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID - #define sigwait SIGWAIT_FUNC_TAOS_FORBID +#define pthread_t PTHREAD_T_TYPE_TAOS_FORBID +#define pthread_spinlock_t PTHREAD_SPINLOCK_T_TYPE_TAOS_FORBID +#define pthread_mutex_t PTHREAD_MUTEX_T_TYPE_TAOS_FORBID +#define pthread_mutexattr_t PTHREAD_MUTEXATTR_T_TYPE_TAOS_FORBID +#define pthread_rwlock_t PTHREAD_RWLOCK_T_TYPE_TAOS_FORBID +#define pthread_attr_t PTHREAD_ATTR_T_TYPE_TAOS_FORBID +#define pthread_once_t PTHREAD_ONCE_T_TYPE_TAOS_FORBID +#define pthread_rwlockattr_t PTHREAD_RWLOCKATTR_T_TYPE_TAOS_FORBID +#define pthread_cond_t PTHREAD_COND_T_TYPE_TAOS_FORBID +#define pthread_condattr_t PTHREAD_CONDATTR_T_TYPE_TAOS_FORBID +#define pthread_key_t PTHREAD_KEY_T_TYPE_TAOS_FORBID +#define pthread_barrier_t PTHREAD_BARRIER_T_TYPE_TAOS_FORBID +#define pthread_barrierattr_t PTHREAD_BARRIERATTR_T_TYPE_TAOS_FORBID +#define pthread_create PTHREAD_CREATE_FUNC_TAOS_FORBID +#define pthread_attr_destroy PTHREAD_ATTR_DESTROY_FUNC_TAOS_FORBID +#define pthread_attr_getdetachstate PTHREAD_ATTR_GETDETACHSTATE_FUNC_TAOS_FORBID +#define pthread_attr_getinheritsched PTHREAD_ATTR_GETINHERITSCHED_FUNC_TAOS_FORBID +#define pthread_attr_getschedparam PTHREAD_ATTR_GETSCHEDPARAM_FUNC_TAOS_FORBID +#define pthread_attr_getschedpolicy PTHREAD_ATTR_GETSCHEDPOLICY_FUNC_TAOS_FORBID +#define pthread_attr_getscope PTHREAD_ATTR_GETSCOPE_FUNC_TAOS_FORBID +#define pthread_attr_getstacksize PTHREAD_ATTR_GETSTACKSIZE_FUNC_TAOS_FORBID +#define pthread_attr_init PTHREAD_ATTR_INIT_FUNC_TAOS_FORBID +#define pthread_attr_setdetachstate PTHREAD_ATTR_SETDETACHSTATE_FUNC_TAOS_FORBID +#define pthread_attr_setinheritsched PTHREAD_ATTR_SETINHERITSCHED_FUNC_TAOS_FORBID +#define pthread_attr_setschedparam PTHREAD_ATTR_SETSCHEDPARAM_FUNC_TAOS_FORBID +#define pthread_attr_setschedpolicy PTHREAD_ATTR_SETSCHEDPOLICY_FUNC_TAOS_FORBID +#define pthread_attr_setscope PTHREAD_ATTR_SETSCOPE_FUNC_TAOS_FORBID +#define pthread_attr_setstacksize PTHREAD_ATTR_SETSTACKSIZE_FUNC_TAOS_FORBID +#define pthread_barrier_destroy PTHREAD_BARRIER_DESTROY_FUNC_TAOS_FORBID +#define pthread_barrier_init PTHREAD_BARRIER_INIT_FUNC_TAOS_FORBID +#define pthread_barrier_wait PTHREAD_BARRIER_WAIT_FUNC_TAOS_FORBID +#define pthread_barrierattr_destroy PTHREAD_BARRIERATTR_DESTROY_FUNC_TAOS_FORBID +#define pthread_barrierattr_getpshared PTHREAD_BARRIERATTR_GETPSHARED_FUNC_TAOS_FORBID +#define pthread_barrierattr_init PTHREAD_BARRIERATTR_INIT_FUNC_TAOS_FORBID +#define pthread_barrierattr_setpshared PTHREAD_BARRIERATTR_SETPSHARED_FUNC_TAOS_FORBID +#define pthread_cancel PTHREAD_CANCEL_FUNC_TAOS_FORBID +#define pthread_cond_destroy PTHREAD_COND_DESTROY_FUNC_TAOS_FORBID +#define pthread_cond_init PTHREAD_COND_INIT_FUNC_TAOS_FORBID +#define pthread_cond_signal PTHREAD_COND_SIGNAL_FUNC_TAOS_FORBID +#define pthread_cond_broadcast PTHREAD_COND_BROADCAST_FUNC_TAOS_FORBID +#define pthread_cond_wait PTHREAD_COND_WAIT_FUNC_TAOS_FORBID +#define pthread_cond_timedwait PTHREAD_COND_TIMEDWAIT_FUNC_TAOS_FORBID +#define pthread_condattr_destroy PTHREAD_CONDATTR_DESTROY_FUNC_TAOS_FORBID +#define pthread_condattr_getpshared PTHREAD_CONDATTR_GETPSHARED_FUNC_TAOS_FORBID +#define pthread_condattr_init PTHREAD_CONDATTR_INIT_FUNC_TAOS_FORBID +#define pthread_condattr_setpshared PTHREAD_CONDATTR_SETPSHARED_FUNC_TAOS_FORBID +#define pthread_detach PTHREAD_DETACH_FUNC_TAOS_FORBID +#define pthread_equal PTHREAD_EQUAL_FUNC_TAOS_FORBID +#define pthread_exit PTHREAD_EXIT_FUNC_TAOS_FORBID +#define pthread_getschedparam PTHREAD_GETSCHEDPARAM_FUNC_TAOS_FORBID +#define pthread_getspecific PTHREAD_GETSPECIFIC_FUNC_TAOS_FORBID +#define pthread_join PTHREAD_JOIN_FUNC_TAOS_FORBID +#define pthread_key_create PTHREAD_KEY_CREATE_FUNC_TAOS_FORBID +#define pthread_key_delete PTHREAD_KEY_DELETE_FUNC_TAOS_FORBID +#define pthread_kill PTHREAD_KILL_FUNC_TAOS_FORBID +#define pthread_mutex_consistent PTHREAD_MUTEX_CONSISTENT_FUNC_TAOS_FORBID +#define pthread_mutex_destroy PTHREAD_MUTEX_DESTROY_FUNC_TAOS_FORBID +#define pthread_mutex_init PTHREAD_MUTEX_INIT_FUNC_TAOS_FORBID +#define pthread_mutex_lock PTHREAD_MUTEX_LOCK_FUNC_TAOS_FORBID +#define pthread_mutex_timedlock PTHREAD_MUTEX_TIMEDLOCK_FUNC_TAOS_FORBID +#define pthread_mutex_trylock PTHREAD_MUTEX_TRYLOCK_FUNC_TAOS_FORBID +#define pthread_mutex_unlock PTHREAD_MUTEX_UNLOCK_FUNC_TAOS_FORBID +#define pthread_mutexattr_destroy PTHREAD_MUTEXATTR_DESTROY_FUNC_TAOS_FORBID +#define pthread_mutexattr_getpshared PTHREAD_MUTEXATTR_GETPSHARED_FUNC_TAOS_FORBID +#define pthread_mutexattr_getrobust PTHREAD_MUTEXATTR_GETROBUST_FUNC_TAOS_FORBID +#define pthread_mutexattr_gettype PTHREAD_MUTEXATTR_GETTYPE_FUNC_TAOS_FORBID +#define pthread_mutexattr_init PTHREAD_MUTEXATTR_INIT_FUNC_TAOS_FORBID +#define pthread_mutexattr_setpshared PTHREAD_MUTEXATTR_SETPSHARED_FUNC_TAOS_FORBID +#define pthread_mutexattr_setrobust PTHREAD_MUTEXATTR_SETROBUST_FUNC_TAOS_FORBID +#define pthread_mutexattr_settype PTHREAD_MUTEXATTR_SETTYPE_FUNC_TAOS_FORBID +#define pthread_once PTHREAD_ONCE_FUNC_TAOS_FORBID +#define pthread_rwlock_destroy PTHREAD_RWLOCK_DESTROY_FUNC_TAOS_FORBID +#define pthread_rwlock_init PTHREAD_RWLOCK_INIT_FUNC_TAOS_FORBID +#define pthread_rwlock_rdlock PTHREAD_RWLOCK_RDLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_timedrdlock PTHREAD_RWLOCK_TIMEDRDLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_timedwrlock PTHREAD_RWLOCK_TIMEDWRLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_tryrdlock PTHREAD_RWLOCK_TRYRDLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_trywrlock PTHREAD_RWLOCK_TRYWRLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_unlock PTHREAD_RWLOCK_UNLOCK_FUNC_TAOS_FORBID +#define pthread_rwlock_wrlock PTHREAD_RWLOCK_WRLOCK_FUNC_TAOS_FORBID +#define pthread_rwlockattr_destroy PTHREAD_RWLOCKATTR_DESTROY_FUNC_TAOS_FORBID +#define pthread_rwlockattr_getpshared PTHREAD_RWLOCKATTR_GETPSHARED_FUNC_TAOS_FORBID +#define pthread_rwlockattr_init PTHREAD_RWLOCKATTR_INIT_FUNC_TAOS_FORBID +#define pthread_rwlockattr_setpshared PTHREAD_RWLOCKATTR_SETPSHARED_FUNC_TAOS_FORBID +#define pthread_self PTHREAD_SELF_FUNC_TAOS_FORBID +#define pthread_setcancelstate PTHREAD_SETCANCELSTATE_FUNC_TAOS_FORBID +#define pthread_setcanceltype PTHREAD_SETCANCELTYPE_FUNC_TAOS_FORBID +#define pthread_setschedparam PTHREAD_SETSCHEDPARAM_FUNC_TAOS_FORBID +#define pthread_setspecific PTHREAD_SETSPECIFIC_FUNC_TAOS_FORBID +#define pthread_spin_destroy PTHREAD_SPIN_DESTROY_FUNC_TAOS_FORBID +#define pthread_spin_init PTHREAD_SPIN_INIT_FUNC_TAOS_FORBID +#define pthread_spin_lock PTHREAD_SPIN_LOCK_FUNC_TAOS_FORBID +#define pthread_spin_trylock PTHREAD_SPIN_TRYLOCK_FUNC_TAOS_FORBID +#define pthread_spin_unlock PTHREAD_SPIN_UNLOCK_FUNC_TAOS_FORBID +#define pthread_testcancel PTHREAD_TESTCANCEL_FUNC_TAOS_FORBID +#define pthread_sigmask PTHREAD_SIGMASK_FUNC_TAOS_FORBID +#define sigwait SIGWAIT_FUNC_TAOS_FORBID #endif -int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg); -int32_t taosThreadAttrDestroy(TdThreadAttr * attr); -int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate); -int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched); -int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param); -int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy); -int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope); -int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize); -int32_t taosThreadAttrInit(TdThreadAttr * attr); -int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate); -int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched); -int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param); -int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy); -int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope); -int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize); +int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg); +int32_t taosThreadAttrDestroy(TdThreadAttr *attr); +int32_t taosThreadAttrGetDetachState(const TdThreadAttr *attr, int32_t *detachstate); +int32_t taosThreadAttrGetInheritSched(const TdThreadAttr *attr, int32_t *inheritsched); +int32_t taosThreadAttrGetSchedParam(const TdThreadAttr *attr, struct sched_param *param); +int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr *attr, int32_t *policy); +int32_t taosThreadAttrGetScope(const TdThreadAttr *attr, int32_t *contentionscope); +int32_t taosThreadAttrGetStackSize(const TdThreadAttr *attr, size_t *stacksize); +int32_t taosThreadAttrInit(TdThreadAttr *attr); +int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachstate); +int32_t taosThreadAttrSetInheritSched(TdThreadAttr *attr, int32_t inheritsched); +int32_t taosThreadAttrSetSchedParam(TdThreadAttr *attr, const struct sched_param *param); +int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr *attr, int32_t policy); +int32_t taosThreadAttrSetScope(TdThreadAttr *attr, int32_t contentionscope); +int32_t taosThreadAttrSetStackSize(TdThreadAttr *attr, size_t stacksize); int32_t taosThreadCancel(TdThread thread); -int32_t taosThreadCondDestroy(TdThreadCond * cond); -int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr); -int32_t taosThreadCondSignal(TdThreadCond * cond); -int32_t taosThreadCondBroadcast(TdThreadCond * cond); -int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex); -int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime); -int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr); -int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared); -int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr); -int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared); +int32_t taosThreadCondDestroy(TdThreadCond *cond); +int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr); +int32_t taosThreadCondSignal(TdThreadCond *cond); +int32_t taosThreadCondBroadcast(TdThreadCond *cond); +int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex); +int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime); +int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr); +int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared); +int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr); +int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared); int32_t taosThreadDetach(TdThread thread); int32_t taosThreadEqual(TdThread t1, TdThread t2); -void taosThreadExit(void *valuePtr); +void taosThreadExit(void *valuePtr); int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param); -void *taosThreadGetSpecific(TdThreadKey key); +void *taosThreadGetSpecific(TdThreadKey key); int32_t taosThreadJoin(TdThread thread, void **valuePtr); -int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *)); +int32_t taosThreadKeyCreate(TdThreadKey *key, void (*destructor)(void *)); int32_t taosThreadKeyDelete(TdThreadKey key); int32_t taosThreadKill(TdThread thread, int32_t sig); // int32_t taosThreadMutexConsistent(TdThreadMutex* mutex); -int32_t taosThreadMutexDestroy(TdThreadMutex * mutex); -int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr); -int32_t taosThreadMutexLock(TdThreadMutex * mutex); +int32_t taosThreadMutexDestroy(TdThreadMutex *mutex); +int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr); +int32_t taosThreadMutexLock(TdThreadMutex *mutex); // int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime); -int32_t taosThreadMutexTryLock(TdThreadMutex * mutex); -int32_t taosThreadMutexUnlock(TdThreadMutex * mutex); -int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr); -int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared); +int32_t taosThreadMutexTryLock(TdThreadMutex *mutex); +int32_t taosThreadMutexUnlock(TdThreadMutex *mutex); +int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr); +int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared); // int32_t taosThreadMutexAttrGetRobust(const TdThreadMutexAttr * attr, int32_t * robust); -int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind); -int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr); -int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared); +int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr *attr, int32_t *kind); +int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr); +int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared); // int32_t taosThreadMutexAttrSetRobust(TdThreadMutexAttr * attr, int32_t robust); -int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind); -int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)); -int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock); -int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr); -int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock); +int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr *attr, int32_t kind); +int32_t taosThreadOnce(TdThreadOnce *onceControl, void (*initRoutine)(void)); +int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock); +int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr); +int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock); // int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime); // int32_t taosThreadRwlockTimedWrlock(TdThreadRwlock * rwlock, const struct timespec *abstime); -int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock); -int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock); -int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock); -int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock); -int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr); -int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared); -int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr); -int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared); +int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock); +int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock); +int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock); +int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock); +int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr); +int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared); +int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr); +int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared); TdThread taosThreadSelf(void); -int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate); -int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype); -int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param); -int32_t taosThreadSetSpecific(TdThreadKey key, const void *value); -int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock); -int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared); -int32_t taosThreadSpinLock(TdThreadSpinlock * lock); -int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock); -int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock); -void taosThreadTestCancel(void); -void taosThreadClear(TdThread *thread); +int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate); +int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype); +int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param); +int32_t taosThreadSetSpecific(TdThreadKey key, const void *value); +int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock); +int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared); +int32_t taosThreadSpinLock(TdThreadSpinlock *lock); +int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock); +int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock); +void taosThreadTestCancel(void); +void taosThreadClear(TdThread *thread); #ifdef __cplusplus } diff --git a/include/os/osTimer.h b/include/os/osTimer.h index 5fece432177e9a2f9923fb2507bdf339188eb1b0..9af50e999a19a3582e78f143e536e5e642d8096d 100644 --- a/include/os/osTimer.h +++ b/include/os/osTimer.h @@ -23,22 +23,22 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define timer_create TIMER_CREATE_FUNC_TAOS_FORBID - #define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID - #define timer_delete TIMER_DELETE_FUNC_TAOS_FORBID - #define timeSetEvent TIMESETEVENT_SETTIME_FUNC_TAOS_FORBID - #define timeKillEvent TIMEKILLEVENT_SETTIME_FUNC_TAOS_FORBID +#define timer_create TIMER_CREATE_FUNC_TAOS_FORBID +#define timer_settime TIMER_SETTIME_FUNC_TAOS_FORBID +#define timer_delete TIMER_DELETE_FUNC_TAOS_FORBID +#define timeSetEvent TIMESETEVENT_SETTIME_FUNC_TAOS_FORBID +#define timeKillEvent TIMEKILLEVENT_SETTIME_FUNC_TAOS_FORBID #endif #define MSECONDS_PER_TICK 5 -int32_t taosInitTimer(void (*callback)(int32_t), int32_t ms); -void taosUninitTimer(); -int64_t taosGetMonotonicMs(); +int32_t taosInitTimer(void (*callback)(int32_t), int32_t ms); +void taosUninitTimer(); +int64_t taosGetMonotonicMs(); const char *taosMonotonicInit(); #ifdef __cplusplus } #endif -#endif /*_TD_OS_TIMER_H_*/ +#endif /*_TD_OS_TIMER_H_*/ diff --git a/include/os/osTimezone.h b/include/os/osTimezone.h index 3676c4b634df89ec712bd07e2fc3b1b743fd4ab1..ce573d320b9028a04e51a071550675d518333c7b 100644 --- a/include/os/osTimezone.h +++ b/include/os/osTimezone.h @@ -23,36 +23,35 @@ extern "C" { // If the error is in a third-party library, place this header file under the third-party library header file. // When you want to use this feature, you should find or add the same function in the following section. #ifndef ALLOW_FORBID_FUNC - #define tzset TZSET_FUNC_TAOS_FORBID +#define tzset TZSET_FUNC_TAOS_FORBID #endif -enum TdTimezone -{ - TdWestZone12=-12, - TdWestZone11, - TdWestZone10, - TdWestZone9, - TdWestZone8, - TdWestZone7, - TdWestZone6, - TdWestZone5, - TdWestZone4, - TdWestZone3, - TdWestZone2, - TdWestZone1, - TdZeroZone, - TdEastZone1, - TdEastZone2, - TdEastZone3, - TdEastZone4, - TdEastZone5, - TdEastZone6, - TdEastZone7, - TdEastZone8, - TdEastZone9, - TdEastZone10, - TdEastZone11, - TdEastZone12 +enum TdTimezone { + TdWestZone12 = -12, + TdWestZone11, + TdWestZone10, + TdWestZone9, + TdWestZone8, + TdWestZone7, + TdWestZone6, + TdWestZone5, + TdWestZone4, + TdWestZone3, + TdWestZone2, + TdWestZone1, + TdZeroZone, + TdEastZone1, + TdEastZone2, + TdEastZone3, + TdEastZone4, + TdEastZone5, + TdEastZone6, + TdEastZone7, + TdEastZone8, + TdEastZone9, + TdEastZone10, + TdEastZone11, + TdEastZone12 }; void taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index add8f33cc24a3fcb973df596e20222b1512dbace..6bc0e0e7dd509075834b5fb650b28206f5c502f9 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -566,6 +566,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_NOT_UNIQUE_TABLE_ALIAS TAOS_DEF_ERROR_CODE(0, 0x2663) #define TSDB_CODE_PAR_NOT_SUPPORT_JOIN TAOS_DEF_ERROR_CODE(0, 0x2664) #define TSDB_CODE_PAR_INVALID_TAGS_PC TAOS_DEF_ERROR_CODE(0, 0x2665) +#define TSDB_CODE_PAR_INVALID_TIMELINE_QUERY TAOS_DEF_ERROR_CODE(0, 0x2666) #define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF) //planner diff --git a/include/util/tbloomfilter.h b/include/util/tbloomfilter.h index c9ca905f8244205f40ae932b9574435808b3bb96..16f7ff7958bc0ba22741ba170982f0f9477f2065 100644 --- a/include/util/tbloomfilter.h +++ b/include/util/tbloomfilter.h @@ -25,26 +25,25 @@ extern "C" { #endif typedef struct SBloomFilter { - uint32_t hashFunctions; - uint64_t expectedEntries; - uint64_t numUnits; - uint64_t numBits; - uint64_t size; + uint32_t hashFunctions; + uint64_t expectedEntries; + uint64_t numUnits; + uint64_t numBits; + uint64_t size; _hash_fn_t hashFn1; _hash_fn_t hashFn2; - void *buffer; - double errorRate; + void *buffer; + double errorRate; } SBloomFilter; SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate); -int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len); -int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, - uint32_t len); -void tBloomFilterDestroy(SBloomFilter *pBF); -void tBloomFilterDump(const SBloomFilter *pBF); -bool tBloomFilterIsFull(const SBloomFilter *pBF); -int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder* pEncoder); -SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder); +int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len); +int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len); +void tBloomFilterDestroy(SBloomFilter *pBF); +void tBloomFilterDump(const SBloomFilter *pBF); +bool tBloomFilterIsFull(const SBloomFilter *pBF); +int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder *pEncoder); +SBloomFilter *tBloomFilterDecode(SDecoder *pDecoder); #ifdef __cplusplus } diff --git a/include/util/tconfig.h b/include/util/tconfig.h index 102656da2bdb17b4c347b3a8e9bbcf85e0e030ca..ca3c5eb0ebd35867464c5c02851a9761e111d250 100644 --- a/include/util/tconfig.h +++ b/include/util/tconfig.h @@ -105,11 +105,11 @@ int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal); const char *cfgStypeStr(ECfgSrcType type); const char *cfgDtypeStr(ECfgDataType type); -void cfgDumpItemValue(SConfigItem *pItem, char* buf, int32_t bufSize, int32_t* pLen); +void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen); void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump); -int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl); +int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl); #ifdef __cplusplus } diff --git a/include/util/tcrc32c.h b/include/util/tcrc32c.h index 0246e09c31140aa2fe943de868b8056f320be883..4fe4f1465f8acc14bdec30364cbe6cf768e679cd 100644 --- a/include/util/tcrc32c.h +++ b/include/util/tcrc32c.h @@ -1,22 +1,22 @@ /* - Copyright (c) 2013 - 2014, 2016 Mark Adler, Robert Vazan, Max Vysokikh + Copyright (c) 2013 - 2014, 2016 Mark Adler, Robert Vazan, Max Vysokikh - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - */ + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ #ifndef _TD_UTIL_CRC32_H_ #define _TD_UTIL_CRC32_H_ @@ -41,4 +41,4 @@ void taosResolveCRC(); } #endif -#endif /*_TD_UTIL_CRC32_H_*/ +#endif /*_TD_UTIL_CRC32_H_*/ diff --git a/include/util/tdigest.h b/include/util/tdigest.h index f9b615318f5c33f0cf386653367ddfe36ae759f8..836af92e78e766206b3982ea5be8c197764c21e2 100644 --- a/include/util/tdigest.h +++ b/include/util/tdigest.h @@ -22,50 +22,53 @@ #ifndef TDIGEST_H #define TDIGEST_H +#include "os.h" + #ifndef M_PI -#define M_PI 3.14159265358979323846264338327950288 /* pi */ +#define M_PI 3.14159265358979323846264338327950288 /* pi */ #endif #define DOUBLE_MAX 1.79e+308 -#define ADDITION_CENTROID_NUM 2 -#define COMPRESSION 300 +#define ADDITION_CENTROID_NUM 2 +#define COMPRESSION 300 #define GET_CENTROID(compression) (ceil(compression * M_PI / 2) + 1 + ADDITION_CENTROID_NUM) #define GET_THRESHOLD(compression) (7.5 + 0.37 * compression - 2e-4 * pow(compression, 2)) -#define TDIGEST_SIZE(compression) (sizeof(TDigest) + sizeof(SCentroid)*GET_CENTROID(compression) + sizeof(SPt)*GET_THRESHOLD(compression)) +#define TDIGEST_SIZE(compression) \ + (sizeof(TDigest) + sizeof(SCentroid) * GET_CENTROID(compression) + sizeof(SPt) * GET_THRESHOLD(compression)) typedef struct SCentroid { - double mean; - int64_t weight; -}SCentroid; + double mean; + int64_t weight; +} SCentroid; typedef struct SPt { - double value; - int64_t weight; -}SPt; + double value; + int64_t weight; +} SPt; typedef struct TDigest { - double compression; - int32_t threshold; - int64_t size; + double compression; + int32_t threshold; + int64_t size; - int64_t total_weight; - double min; - double max; + int64_t total_weight; + double min; + double max; - int32_t num_buffered_pts; - SPt *buffered_pts; + int32_t num_buffered_pts; + SPt *buffered_pts; - int32_t num_centroids; - SCentroid *centroids; -}TDigest; + int32_t num_centroids; + SCentroid *centroids; +} TDigest; -TDigest *tdigestNewFrom(void* pBuf, int32_t compression); -void tdigestAdd(TDigest *t, double x, int64_t w); -void tdigestMerge(TDigest *t1, TDigest *t2); -double tdigestQuantile(TDigest *t, double q); -void tdigestCompress(TDigest *t); -void tdigestFreeFrom(TDigest *t); -void tdigestAutoFill(TDigest* t, int32_t compression); +TDigest *tdigestNewFrom(void *pBuf, int32_t compression); +void tdigestAdd(TDigest *t, double x, int64_t w); +void tdigestMerge(TDigest *t1, TDigest *t2); +double tdigestQuantile(TDigest *t, double q); +void tdigestCompress(TDigest *t); +void tdigestFreeFrom(TDigest *t); +void tdigestAutoFill(TDigest *t, int32_t compression); #endif /* TDIGEST_H */ diff --git a/include/util/thash.h b/include/util/thash.h index f4d09eb0906b04bfd40d97c39ec66feb3b1967a1..2be5f4a047162c4095821a2d650e576ca2581c58 100644 --- a/include/util/thash.h +++ b/include/util/thash.h @@ -29,7 +29,7 @@ typedef void (*_hash_before_fn_t)(void *); typedef void (*_hash_free_fn_t)(void *); #define HASH_KEY_ALREADY_EXISTS (-2) -#define HASH_NODE_EXIST(code) (code == HASH_KEY_ALREADY_EXISTS) +#define HASH_NODE_EXIST(code) (code == HASH_KEY_ALREADY_EXISTS) /** * murmur hash algorithm @@ -50,7 +50,7 @@ uint64_t MurmurHash3_64(const char *key, uint32_t len); uint32_t taosIntHash_32(const char *key, uint32_t len); uint32_t taosIntHash_64(const char *key, uint32_t len); -_hash_fn_t taosGetDefaultHashFunction(int32_t type); +_hash_fn_t taosGetDefaultHashFunction(int32_t type); _equal_fn_t taosGetDefaultEqualFunction(int32_t type); typedef enum SHashLockTypeE { @@ -59,7 +59,7 @@ typedef enum SHashLockTypeE { } SHashLockTypeE; typedef struct SHashNode SHashNode; -typedef struct SHashObj SHashObj; +typedef struct SHashObj SHashObj; /** * init the hash table @@ -118,7 +118,7 @@ int32_t taosHashGetDup(SHashObj *pHashObj, const void *key, size_t keyLen, void * @param size * @return */ -int32_t taosHashGetDup_m(SHashObj* pHashObj, const void* key, size_t keyLen, void** destBuf, int32_t* size); +int32_t taosHashGetDup_m(SHashObj *pHashObj, const void *key, size_t keyLen, void **destBuf, int32_t *size); /** * remove item with the specified key @@ -169,13 +169,13 @@ void *taosHashIterate(SHashObj *pHashObj, void *p); */ void taosHashCancelIterate(SHashObj *pHashObj, void *p); - /** - * Get the corresponding key information for a given data in hash table - * @param data - * @param keyLen - * @return - */ -void *taosHashGetKey(void *data, size_t* keyLen); +/** + * Get the corresponding key information for a given data in hash table + * @param data + * @param keyLen + * @return + */ +void *taosHashGetKey(void *data, size_t *keyLen); /** * return the payload data with the specified key(reference number added) diff --git a/include/util/tidpool.h b/include/util/tidpool.h index c97f4c5f388ee48f3f86f50b82665f6479c5bb9b..c47a08dad8b248bab545ece218cd64ba3553c3e5 100644 --- a/include/util/tidpool.h +++ b/include/util/tidpool.h @@ -23,10 +23,10 @@ extern "C" { #endif typedef struct { - int32_t maxId; - int32_t numOfFree; - int32_t freeSlot; - bool *freeList; + int32_t maxId; + int32_t numOfFree; + int32_t freeSlot; + bool *freeList; TdThreadMutex mutex; } id_pool_t; diff --git a/include/util/tlrucache.h b/include/util/tlrucache.h index 5aee50c42abe3bf41972231df07e8cabe67a178e..19009342484bce74c5173e7bf61ab52d6ddae767 100644 --- a/include/util/tlrucache.h +++ b/include/util/tlrucache.h @@ -28,37 +28,34 @@ typedef void (*_taos_lru_deleter_t)(const void *key, size_t keyLen, void *value) typedef struct LRUHandle LRUHandle; -typedef enum { - TAOS_LRU_PRIORITY_HIGH, - TAOS_LRU_PRIORITY_LOW -} LRUPriority; - +typedef enum { TAOS_LRU_PRIORITY_HIGH, TAOS_LRU_PRIORITY_LOW } LRUPriority; + typedef enum { TAOS_LRU_STATUS_OK, TAOS_LRU_STATUS_FAIL, TAOS_LRU_STATUS_INCOMPLETE, TAOS_LRU_STATUS_OK_OVERWRITTEN } LRUStatus; - -SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoolRatio); -void taosLRUCacheCleanup(SLRUCache *cache); -LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, - _taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority); -LRUHandle *taosLRUCacheLookup(SLRUCache * cache, const void *key, size_t keyLen); -void taosLRUCacheErase(SLRUCache * cache, const void *key, size_t keyLen); +SLRUCache *taosLRUCacheInit(size_t capacity, int numShardBits, double highPriPoolRatio); +void taosLRUCacheCleanup(SLRUCache *cache); + +LRUStatus taosLRUCacheInsert(SLRUCache *cache, const void *key, size_t keyLen, void *value, size_t charge, + _taos_lru_deleter_t deleter, LRUHandle **handle, LRUPriority priority); +LRUHandle *taosLRUCacheLookup(SLRUCache *cache, const void *key, size_t keyLen); +void taosLRUCacheErase(SLRUCache *cache, const void *key, size_t keyLen); void taosLRUCacheEraseUnrefEntries(SLRUCache *cache); bool taosLRUCacheRef(SLRUCache *cache, LRUHandle *handle); bool taosLRUCacheRelease(SLRUCache *cache, LRUHandle *handle, bool eraseIfLastRef); -void* taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle); +void *taosLRUCacheValue(SLRUCache *cache, LRUHandle *handle); size_t taosLRUCacheGetUsage(SLRUCache *cache); size_t taosLRUCacheGetPinnedUsage(SLRUCache *cache); -void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity); +void taosLRUCacheSetCapacity(SLRUCache *cache, size_t capacity); size_t taosLRUCacheGetCapacity(SLRUCache *cache); void taosLRUCacheSetStrictCapacity(SLRUCache *cache, bool strict); diff --git a/include/util/tpagedbuf.h b/include/util/tpagedbuf.h index 9ab89273e6895c2ea322fa116c06332a431028bc..5f81ccfcfd08cb1cfbd6ff84ea83b4430da45dad 100644 --- a/include/util/tpagedbuf.h +++ b/include/util/tpagedbuf.h @@ -53,7 +53,8 @@ typedef struct SDiskbasedBufStatis { * @param handle * @return */ -int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id, const char* dir); +int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMemBufSize, const char* id, + const char* dir); /** * @@ -158,7 +159,7 @@ void setBufPageCompressOnDisk(SDiskbasedBuf* pBuf, bool comp); * @param pBuf * @param pageId */ -void dBufSetBufPageRecycled(SDiskbasedBuf *pBuf, void* pPage); +void dBufSetBufPageRecycled(SDiskbasedBuf* pBuf, void* pPage); /** * Print the statistics when closing this buffer diff --git a/include/util/tscalablebf.h b/include/util/tscalablebf.h index 1386f840a84006db687ff47bb324e623be887731..9977c1436d00d2e6c71417b5e963d4fc09046767 100644 --- a/include/util/tscalablebf.h +++ b/include/util/tscalablebf.h @@ -23,18 +23,17 @@ extern "C" { #endif typedef struct SScalableBf { - SArray *bfArray; // array of bloom filters + SArray *bfArray; // array of bloom filters uint32_t growth; uint64_t numBits; } SScalableBf; SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate); -int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len); -int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, - uint32_t len); -void tScalableBfDestroy(SScalableBf *pSBf); -int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder); -SScalableBf* tScalableBfDecode(SDecoder* pDecoder); +int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len); +int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len); +void tScalableBfDestroy(SScalableBf *pSBf); +int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder *pEncoder); +SScalableBf *tScalableBfDecode(SDecoder *pDecoder); #ifdef __cplusplus } diff --git a/include/util/tthread.h b/include/util/tthread.h index 7afed98839dfc8a09ce46191f62216b418a671f1..26818e5c1f485ef4932974030566b5341fc71532 100644 --- a/include/util/tthread.h +++ b/include/util/tthread.h @@ -23,10 +23,10 @@ extern "C" { #endif TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param); -bool taosDestroyThread(TdThread* pthread); -bool taosThreadRunning(TdThread* pthread); +bool taosDestroyThread(TdThread* pthread); +bool taosThreadRunning(TdThread* pthread); -typedef void *(*ThreadFp)(void *param); +typedef void* (*ThreadFp)(void* param); #ifdef __cplusplus } diff --git a/include/util/tutil.h b/include/util/tutil.h index c22495b75fdb0fe0a035d7f30809c3a9152d0798..2a3f0dcb020666fc3b80b8d4f3d304dc13c8544c 100644 --- a/include/util/tutil.h +++ b/include/util/tutil.h @@ -19,8 +19,8 @@ #include "os.h" #include "tcrc32c.h" #include "tdef.h" -#include "tmd5.h" #include "thash.h" +#include "tmd5.h" #ifdef __cplusplus extern "C" { @@ -71,7 +71,7 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar } static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen, int32_t method, int32_t prefix, - int32_t suffix) { + int32_t suffix) { if (prefix == 0 && suffix == 0) { return MurmurHash3_32(tbname, tblen); } else { diff --git a/packaging/release.sh b/packaging/release.sh index 9ebbc50a84ffb762a2440b840fce8064bb4b7f2b..ce424918926dc7b9f62d70fe8da03d9688f33189 100755 --- a/packaging/release.sh +++ b/packaging/release.sh @@ -260,7 +260,7 @@ if [ "$osType" != "Darwin" ]; then if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/tools/taos-tools/packaging/deb ]; then cd ${top_dir}/tools/taos-tools/packaging/deb - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}') + taos_tools_ver=$(git tag |grep -v taos | sort | tail -1) [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" ${csudo}./make-taos-tools-deb.sh ${top_dir} \ @@ -285,7 +285,7 @@ if [ "$osType" != "Darwin" ]; then if [[ "$pagMode" == "full" ]]; then if [ -d ${top_dir}/tools/taos-tools/packaging/rpm ]; then cd ${top_dir}/tools/taos-tools/packaging/rpm - taos_tools_ver=$(git describe --tags | sed -e 's/ver-//g' | awk -F '-' '{print $1}' | sed -e 's/-/_/g') + taos_tools_ver=$(git tag |grep -v taos | sort | tail -1) [ -z "$taos_tools_ver" ] && taos_tools_ver="0.1.0" ${csudo}./make-taos-tools-rpm.sh ${top_dir} \ diff --git a/packaging/tools/TDengine b/packaging/tools/TDengine index 3025a5639f3dda2c9b06ef5ffaf0a7f0995c2532..c0b80564c49c5dde631bc96f68e4d37fc1f12b33 100755 --- a/packaging/tools/TDengine +++ b/packaging/tools/TDengine @@ -17,12 +17,12 @@ EOF taosd_status=`Launchctl list | grep taosd | head -n 1 | awk '{print $1}'` if [ "$taosd_status"x = "-"x ]; then - launchctl start taosd + launchctl start com.tdengine.taosd showAlertMessage "Taosd is running!" "TDengine" "ok" "note" else choose_result=`showAlertMessage "Taosd is running!\nDo you want to close it?" "TDengine" "yes,cancel" "stop"` if [ "$choose_result"x = "button returned:yes"x ]; then - launchctl stop taosd + launchctl stop com.tdengine.taosd fi fi diff --git a/packaging/tools/TDengine.pkgproj b/packaging/tools/TDengine.pkgproj new file mode 100644 index 0000000000000000000000000000000000000000..7aaac627352e60385af5fd6e4fd2b2694952a580 --- /dev/null +++ b/packaging/tools/TDengine.pkgproj @@ -0,0 +1,882 @@ + + + + + PACKAGES + + + MUST-CLOSE-APPLICATION-ITEMS + + MUST-CLOSE-APPLICATIONS + + PACKAGE_FILES + + DEFAULT_INSTALL_LOCATION + / + HIERARCHY + + CHILDREN + + + CHILDREN + + GID + 80 + PATH + Applications + PATH_TYPE + 0 + PERMISSIONS + 509 + TYPE + 1 + UID + 0 + + + CHILDREN + + + CHILDREN + + GID + 80 + PATH + Application Support + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Automator + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Documentation + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Extensions + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Filesystems + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Frameworks + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Input Methods + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Internet Plug-Ins + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Keyboard Layouts + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + LaunchAgents + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + LaunchDaemons + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + PreferencePanes + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Preferences + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 80 + PATH + Printers + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + PrivilegedHelperTools + PATH_TYPE + 0 + PERMISSIONS + 1005 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + QuickLook + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + QuickTime + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Screen Savers + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Scripts + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Services + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + GID + 0 + PATH + Widgets + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + GID + 0 + PATH + Library + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + CHILDREN + + + CHILDREN + + GID + 0 + PATH + Shared + PATH_TYPE + 0 + PERMISSIONS + 1023 + TYPE + 1 + UID + 0 + + + GID + 80 + PATH + Users + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + + GID + 0 + PATH + / + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 1 + UID + 0 + + PAYLOAD_TYPE + 0 + PRESERVE_EXTENDED_ATTRIBUTES + + SHOW_INVISIBLE + + SPLIT_FORKS + + TREAT_MISSING_FILES_AS_WARNING + + VERSION + 5 + + PACKAGE_SCRIPTS + + POSTINSTALL_PATH + + PATH + /opt/taos/TDengine/packaging/tools/post.sh + PATH_TYPE + 0 + + PREINSTALL_PATH + + PATH_TYPE + 0 + + RESOURCES + + + CHILDREN + + GID + 0 + PATH + /opt/tdengine + PATH_TYPE + 0 + PERMISSIONS + 493 + TYPE + 3 + UID + 0 + + + + PACKAGE_SETTINGS + + AUTHENTICATION + 1 + CONCLUSION_ACTION + 0 + FOLLOW_SYMBOLIC_LINKS + + IDENTIFIER + com.taosdata.pkg.pkgtaos + LOCATION + 0 + NAME + TDengine + OVERWRITE_PERMISSIONS + + PAYLOAD_SIZE + -1 + REFERENCE_PATH + + RELOCATABLE + + USE_HFS+_COMPRESSION + + VERSION + 3.0.1.4 + + TYPE + 0 + UUID + 48F6B249-AF56-46E3-B75A-AEED5858A764 + + + PROJECT + + PROJECT_COMMENTS + + NOTES + + + + PROJECT_PRESENTATION + + BACKGROUND + + APPAREANCES + + DARK_AQUA + + LIGHT_AQUA + + + SHARED_SETTINGS_FOR_ALL_APPAREANCES + + + INSTALLATION TYPE + + HIERARCHIES + + INSTALLER + + LIST + + + CHILDREN + + DESCRIPTION + + OPTIONS + + HIDDEN + + STATE + 1 + + PACKAGE_UUID + 48F6B249-AF56-46E3-B75A-AEED5858A764 + TITLE + + TYPE + 0 + UUID + 7ED88D2C-D55C-46FF-99CB-73313ACAD73D + + + REMOVED + + + + MODE + 0 + + INSTALLATION_STEPS + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewIntroductionController + INSTALLER_PLUGIN + Introduction + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewReadMeController + INSTALLER_PLUGIN + ReadMe + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewLicenseController + INSTALLER_PLUGIN + License + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewDestinationSelectController + INSTALLER_PLUGIN + TargetSelect + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewInstallationTypeController + INSTALLER_PLUGIN + PackageSelection + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewInstallationController + INSTALLER_PLUGIN + Install + LIST_TITLE_KEY + InstallerSectionTitle + + + ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS + ICPresentationViewSummaryController + INSTALLER_PLUGIN + Summary + LIST_TITLE_KEY + InstallerSectionTitle + + + INTRODUCTION + + LOCALIZATIONS + + + LANGUAGE + English + VALUE + + PATH + /opt/taos/TDengine/packaging/tools/mac_before_install.txt + PATH_TYPE + 0 + + + + + LICENSE + + LOCALIZATIONS + + MODE + 0 + + README + + LOCALIZATIONS + + + SUMMARY + + LOCALIZATIONS + + + TITLE + + LOCALIZATIONS + + + LANGUAGE + English + VALUE + TDengine + + + + + PROJECT_REQUIREMENTS + + LIST + + RESOURCES + + ROOT_VOLUME_ONLY + + + PROJECT_SETTINGS + + BUILD_FORMAT + 0 + BUILD_PATH + + PATH + /opt/taos/TDengine/release + PATH_TYPE + 0 + + EXCLUDED_FILES + + + PATTERNS_ARRAY + + + REGULAR_EXPRESSION + + STRING + .DS_Store + TYPE + 0 + + + PROTECTED + + PROXY_NAME + Remove .DS_Store files + PROXY_TOOLTIP + Remove ".DS_Store" files created by the Finder. + STATE + + + + PATTERNS_ARRAY + + + REGULAR_EXPRESSION + + STRING + .pbdevelopment + TYPE + 0 + + + PROTECTED + + PROXY_NAME + Remove .pbdevelopment files + PROXY_TOOLTIP + Remove ".pbdevelopment" files created by ProjectBuilder or Xcode. + STATE + + + + PATTERNS_ARRAY + + + REGULAR_EXPRESSION + + STRING + CVS + TYPE + 1 + + + REGULAR_EXPRESSION + + STRING + .cvsignore + TYPE + 0 + + + REGULAR_EXPRESSION + + STRING + .cvspass + TYPE + 0 + + + REGULAR_EXPRESSION + + STRING + .svn + TYPE + 1 + + + REGULAR_EXPRESSION + + STRING + .git + TYPE + 1 + + + REGULAR_EXPRESSION + + STRING + .gitignore + TYPE + 0 + + + PROTECTED + + PROXY_NAME + Remove SCM metadata + PROXY_TOOLTIP + Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems. + STATE + + + + PATTERNS_ARRAY + + + REGULAR_EXPRESSION + + STRING + classes.nib + TYPE + 0 + + + REGULAR_EXPRESSION + + STRING + designable.db + TYPE + 0 + + + REGULAR_EXPRESSION + + STRING + info.nib + TYPE + 0 + + + PROTECTED + + PROXY_NAME + Optimize nib files + PROXY_TOOLTIP + Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles. + STATE + + + + PATTERNS_ARRAY + + + REGULAR_EXPRESSION + + STRING + Resources Disabled + TYPE + 1 + + + PROTECTED + + PROXY_NAME + Remove Resources Disabled folders + PROXY_TOOLTIP + Remove "Resources Disabled" folders. + STATE + + + + SEPARATOR + + + + NAME + TDengine-client-3.0.1.4-macOS-arm64 + PAYLOAD_ONLY + + TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING + + + + TYPE + 0 + VERSION + 2 + + diff --git a/packaging/tools/com.taosdata.taosd.plist b/packaging/tools/com.taosdata.taosd.plist index ca9b8c5ef1a103afc125417f99b60ccf4b51f610..0bf3135ac30239fefe081d1b45928540ecbebdbf 100644 --- a/packaging/tools/com.taosdata.taosd.plist +++ b/packaging/tools/com.taosdata.taosd.plist @@ -3,7 +3,7 @@ Label - taosd + com.tdengine.taosd ProgramArguments /usr/local/bin/taosd diff --git a/packaging/tools/mac_before_install.txt b/packaging/tools/mac_before_install.txt index f70ea7161f4df28594639f8f2a1f0a335b8ad03f..b33cd478b8982a5c6c8263ea3d2ea6d607f3f706 100644 --- a/packaging/tools/mac_before_install.txt +++ b/packaging/tools/mac_before_install.txt @@ -1,5 +1,5 @@ TDengine is a high-efficient, scalable, high-available distributed time-series database, which makes a lot of optimizations on inserting and querying data, which is far more efficient than normal regular databases. So TDengine can meet the high requirements of IOT and other areas on storing and querying a large amount of data. To configure TDengine : edit /etc/taos/taos.cfg -To start service : launchctl start taosd +To start service : launchctl start com.tdengine.taosd To access TDengine : use taos in shell \ No newline at end of file diff --git a/packaging/tools/make_install.sh b/packaging/tools/make_install.sh index b8796ddf09b2f0d899aad793ebe757b649ad9814..b56a5a203d7e42827512c8930345e45022a719b1 100755 --- a/packaging/tools/make_install.sh +++ b/packaging/tools/make_install.sh @@ -615,7 +615,7 @@ function update_TDengine() { if [ "$osType" != "Darwin" ]; then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" else - echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}" + echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}" fi [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" @@ -666,7 +666,7 @@ function install_TDengine() { if [ "$osType" != "Darwin" ]; then echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}" else - echo -e "${GREEN_DARK}To start service ${NC}: launchctl start ${serverName}${NC}" + echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}" fi [ -f ${installDir}/bin/taosadapter ] && \ echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}" diff --git a/packaging/tools/post.sh b/packaging/tools/post.sh index 29d4ac017ca9d8813e1f7c69f4f5e6056602b16c..b729513b97206673c2ed6d2d9be20a28b5b8e258 100755 --- a/packaging/tools/post.sh +++ b/packaging/tools/post.sh @@ -18,6 +18,7 @@ if [ "$osType" != "Darwin" ]; then script_dir=$(dirname $(readlink -f "$0")) verNumber="" lib_file_ext="so" + lib_file_ext_1="so.1" bin_link_dir="/usr/bin" lib_link_dir="/usr/lib" @@ -29,6 +30,7 @@ else script_dir=${source_dir}/packaging/tools verNumber=`ls tdengine/driver | grep -E "libtaos\.[0-9]\.[0-9]" | sed "s/libtaos.//g" | sed "s/.dylib//g" | head -n 1` lib_file_ext="dylib" + lib_file_ext_1="1.dylib" bin_link_dir="/usr/local/bin" lib_link_dir="/usr/local/lib" @@ -134,14 +136,14 @@ function install_lib() { [ -f ${lib_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.${lib_file_ext} || : [ -f ${lib64_link_dir}/libtaosws.${lib_file_ext} ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.${lib_file_ext} || : - ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.so.1 - ${csudo}ln -s ${lib_link_dir}/libtaos.so.1 ${lib_link_dir}/libtaos.so + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib_link_dir}/libtaos.${lib_file_ext_1} + ${csudo}ln -s ${lib_link_dir}/libtaos.${lib_file_ext_1} ${lib_link_dir}/libtaos.${lib_file_ext} [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib_link_dir}/libtaosws.${lib_file_ext} ||: - if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.so ]]; then - ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.so.1 || : - ${csudo}ln -s ${lib64_link_dir}/libtaos.so.1 ${lib64_link_dir}/libtaos.so || : + if [[ -d ${lib64_link_dir} && ! -e ${lib64_link_dir}/libtaos.${lib_file_ext} ]]; then + ${csudo}ln -s ${lib_dir}/libtaos.* ${lib64_link_dir}/libtaos.${lib_file_ext_1} || : + ${csudo}ln -s ${lib64_link_dir}/libtaos.${lib_file_ext_1} ${lib64_link_dir}/libtaos.${lib_file_ext} || : [ -f ${lib_dir}/libtaosws.${lib_file_ext} ] && ${csudo}ln -sf ${lib_dir}/libtaosws.${lib_file_ext} ${lib64_link_dir}/libtaosws.${lib_file_ext} || : fi diff --git a/packaging/tools/remove.sh b/packaging/tools/remove.sh index 6172fc9bc8bcce6a311b82cff52b797c3731b296..bace0bc869e599aaf376356094b85e8f5e0d4556 100755 --- a/packaging/tools/remove.sh +++ b/packaging/tools/remove.sh @@ -117,7 +117,7 @@ function clean_local_bin() { function clean_lib() { # Remove link ${csudo}rm -f ${lib_link_dir}/libtaos.* || : - [ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || : + [ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || : ${csudo}rm -f ${lib64_link_dir}/libtaos.* || : [ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || : diff --git a/source/client/CMakeLists.txt b/source/client/CMakeLists.txt index e8e3c878496c58631131922cc6de47491d548f06..0c445c7fbfa01b6432259bd20e7e481966aee7a7 100644 --- a/source/client/CMakeLists.txt +++ b/source/client/CMakeLists.txt @@ -19,6 +19,13 @@ target_link_libraries( PRIVATE os util common transport nodes parser command planner catalog scheduler function qcom ) +if(TD_DARWIN_ARM64) + target_link_libraries( + taos + PRIVATE "-arch x86_64" + ) +endif() + if(TD_WINDOWS) INCLUDE_DIRECTORIES(jni/windows) INCLUDE_DIRECTORIES(jni/windows/win32) diff --git a/source/client/inc/clientLog.h b/source/client/inc/clientLog.h index ec0a41a68f9515bc7ea2c54e96b0235c0a9683eb..541717c7eb4bf9719e49ce0482b0df95625199c6 100644 --- a/source/client/inc/clientLog.h +++ b/source/client/inc/clientLog.h @@ -22,6 +22,7 @@ extern "C" { #include "tlog.h" +// clang-format off #define tscFatal(...) do { if (cDebugFlag & DEBUG_FATAL) { taosPrintLog("TSC FATAL ", DEBUG_FATAL, cDebugFlag, __VA_ARGS__); }} while(0) #define tscError(...) do { if (cDebugFlag & DEBUG_ERROR) { taosPrintLog("TSC ERROR ", DEBUG_ERROR, cDebugFlag, __VA_ARGS__); }} while(0) #define tscWarn(...) do { if (cDebugFlag & DEBUG_WARN) { taosPrintLog("TSC WARN ", DEBUG_WARN, cDebugFlag, __VA_ARGS__); }} while(0) @@ -30,6 +31,7 @@ extern "C" { #define tscTrace(...) do { if (cDebugFlag & DEBUG_TRACE) { taosPrintLog("TSC ", DEBUG_TRACE, cDebugFlag, __VA_ARGS__); }} while(0) #define tscDebugL(...) do { if (cDebugFlag & DEBUG_DEBUG) { taosPrintLongString("TSC ", DEBUG_DEBUG, cDebugFlag, __VA_ARGS__); }} while(0) #define tscPerf(...) do { taosPrintLog("TSC ", 0, cDebugFlag, __VA_ARGS__); } while(0) +// clang-format on #ifdef __cplusplus } diff --git a/source/client/inc/clientStmt.h b/source/client/inc/clientStmt.h index a7adaef96613cbaa52a212528b36eaa5a1ea0cb7..2261a6becb30c01e5d8edb096169721d84a4a88c 100644 --- a/source/client/inc/clientStmt.h +++ b/source/client/inc/clientStmt.h @@ -42,37 +42,37 @@ typedef enum { } STMT_STATUS; typedef struct SStmtTableCache { - STableDataBlocks* pDataBlock; - void* boundTags; + STableDataBlocks *pDataBlock; + void *boundTags; } SStmtTableCache; typedef struct SStmtQueryResInfo { - TAOS_FIELD* fields; - TAOS_FIELD* userFields; - uint32_t numOfCols; - int32_t precision; + TAOS_FIELD *fields; + TAOS_FIELD *userFields; + uint32_t numOfCols; + int32_t precision; } SStmtQueryResInfo; typedef struct SStmtBindInfo { - bool needParse; - bool inExecCache; - uint64_t tbUid; - uint64_t tbSuid; - int32_t sBindRowNum; - int32_t sBindLastIdx; - int8_t tbType; - bool tagsCached; - void* boundTags; - char tbName[TSDB_TABLE_FNAME_LEN]; - char tbFName[TSDB_TABLE_FNAME_LEN]; - char stbFName[TSDB_TABLE_FNAME_LEN]; - SName sname; + bool needParse; + bool inExecCache; + uint64_t tbUid; + uint64_t tbSuid; + int32_t sBindRowNum; + int32_t sBindLastIdx; + int8_t tbType; + bool tagsCached; + void *boundTags; + char tbName[TSDB_TABLE_FNAME_LEN]; + char tbFName[TSDB_TABLE_FNAME_LEN]; + char stbFName[TSDB_TABLE_FNAME_LEN]; + SName sname; } SStmtBindInfo; typedef struct SStmtExecInfo { int32_t affectedRows; - SRequestObj* pRequest; - SHashObj* pBlockHash; + SRequestObj *pRequest; + SHashObj *pBlockHash; bool autoCreateTbl; } SStmtExecInfo; @@ -80,20 +80,20 @@ typedef struct SStmtSQLInfo { STMT_TYPE type; STMT_STATUS status; uint64_t runTimes; - SHashObj* pTableCache; //SHash - SQuery* pQuery; - char* sqlStr; + SHashObj *pTableCache; // SHash + SQuery *pQuery; + char *sqlStr; int32_t sqlLen; - SArray* nodeList; + SArray *nodeList; SStmtQueryResInfo queryRes; bool autoCreateTbl; - SHashObj* pVgHash; + SHashObj *pVgHash; } SStmtSQLInfo; typedef struct STscStmt { - STscObj* taos; - SCatalog* pCatalog; - int32_t affectedRows; + STscObj *taos; + SCatalog *pCatalog; + int32_t affectedRows; SStmtSQLInfo sql; SStmtExecInfo exec; @@ -103,28 +103,48 @@ typedef struct STscStmt { #define STMT_STATUS_NE(S) (pStmt->sql.status != STMT_##S) #define STMT_STATUS_EQ(S) (pStmt->sql.status == STMT_##S) -#define STMT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define STMT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define STMT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) - -TAOS_STMT *stmtInit(STscObj* taos); -int stmtClose(TAOS_STMT *stmt); -int stmtExec(TAOS_STMT *stmt); +#define STMT_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define STMT_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define STMT_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ + } while (0) + +TAOS_STMT *stmtInit(STscObj *taos); +int stmtClose(TAOS_STMT *stmt); +int stmtExec(TAOS_STMT *stmt); const char *stmtErrstr(TAOS_STMT *stmt); -int stmtAffectedRows(TAOS_STMT *stmt); -int stmtAffectedRowsOnce(TAOS_STMT *stmt); -int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); -int stmtSetTbName(TAOS_STMT *stmt, const char *tbName); -int stmtSetTbTags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags); -int stmtGetTagFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields); -int stmtGetColFields(TAOS_STMT* stmt, int* nums, TAOS_FIELD_E** fields); -int stmtIsInsert(TAOS_STMT *stmt, int *insert); -int stmtGetParamNum(TAOS_STMT *stmt, int *nums); -int stmtGetParam(TAOS_STMT *stmt, int idx, int *type, int *bytes); -int stmtAddBatch(TAOS_STMT *stmt); -TAOS_RES *stmtUseResult(TAOS_STMT *stmt); -int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx); - +int stmtAffectedRows(TAOS_STMT *stmt); +int stmtAffectedRowsOnce(TAOS_STMT *stmt); +int stmtPrepare(TAOS_STMT *stmt, const char *sql, unsigned long length); +int stmtSetTbName(TAOS_STMT *stmt, const char *tbName); +int stmtSetTbTags(TAOS_STMT *stmt, TAOS_MULTI_BIND *tags); +int stmtGetTagFields(TAOS_STMT *stmt, int *nums, TAOS_FIELD_E **fields); +int stmtGetColFields(TAOS_STMT *stmt, int *nums, TAOS_FIELD_E **fields); +int stmtIsInsert(TAOS_STMT *stmt, int *insert); +int stmtGetParamNum(TAOS_STMT *stmt, int *nums); +int stmtGetParam(TAOS_STMT *stmt, int idx, int *type, int *bytes); +int stmtAddBatch(TAOS_STMT *stmt); +TAOS_RES *stmtUseResult(TAOS_STMT *stmt); +int stmtBindBatch(TAOS_STMT *stmt, TAOS_MULTI_BIND *bind, int32_t colIdx); #ifdef __cplusplus } diff --git a/source/client/src/clientEnv.c b/source/client/src/clientEnv.c index 5792f498efddfdf43a7bab3ce3d47aebaa512a36..fc489f08af05b02937bfb9f3a4f11b127fd62e47 100644 --- a/source/client/src/clientEnv.c +++ b/source/client/src/clientEnv.c @@ -71,7 +71,8 @@ static void deregisterRequest(SRequestObj *pRequest) { int32_t num = atomic_sub_fetch_32(&pTscObj->numOfReqs, 1); int64_t duration = taosGetTimestampUs() - pRequest->metric.start; - tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 " elapsed:%.2f ms, " + tscDebug("0x%" PRIx64 " free Request from connObj: 0x%" PRIx64 ", reqId:0x%" PRIx64 + " elapsed:%.2f ms, " "current:%d, app current:%d", pRequest->self, pTscObj->id, pRequest->requestId, duration / 1000.0, num, currentInst); @@ -84,7 +85,7 @@ static void deregisterRequest(SRequestObj *pRequest) { atomic_add_fetch_64((int64_t *)&pActivity->insertElapsedTime, duration); } else if (QUERY_NODE_SELECT_STMT == pRequest->stmtType) { tscPerf("select duration %" PRId64 "us: syntax:%" PRId64 "us, ctg:%" PRId64 "us, semantic:%" PRId64 - "us, planner:%" PRId64 "us, exec:%" PRId64 "us, reqId:0x%"PRIx64, + "us, planner:%" PRId64 "us, exec:%" PRId64 "us, reqId:0x%" PRIx64, duration, pRequest->metric.syntaxEnd - pRequest->metric.syntaxStart, pRequest->metric.ctgEnd - pRequest->metric.ctgStart, pRequest->metric.semanticEnd - pRequest->metric.ctgEnd, pRequest->metric.planEnd - pRequest->metric.semanticEnd, @@ -144,6 +145,7 @@ void *openTransporter(const char *user, const char *auth, int32_t numOfThread) { rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.user = (char *)user; rpcInit.idleTime = tsShellActivityTimer * 1000; + rpcInit.compressSize = tsCompressMsgSize; void *pDnodeConn = rpcOpen(&rpcInit); if (pDnodeConn == NULL) { tscError("failed to init connection to server"); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 58bfcc8a09cb5189ad619ab3e7e03efafbd3a13c..7b437e47699ca623da62ceb496ab2a7337df7412 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1991,6 +1991,7 @@ TSDB_SERVER_STATUS taos_check_server_status(const char* fqdn, int port, char* de rpcInit.sessions = 16; rpcInit.connType = TAOS_CONN_CLIENT; rpcInit.idleTime = tsShellActivityTimer * 1000; + rpcInit.compressSize = tsCompressMsgSize; rpcInit.user = "_dnd"; clientRpc = rpcOpen(&rpcInit); diff --git a/source/client/src/clientSml.c b/source/client/src/clientSml.c index c5633e73d0521c9304f1f23c778506cd9a0ad005..24da5f7b7005fad2e2be60f5391d541abe915887 100644 --- a/source/client/src/clientSml.c +++ b/source/client/src/clientSml.c @@ -2477,11 +2477,12 @@ static void smlInsertCallback(void *param, void *res, int32_t code) { } else { pParam->request->body.resInfo.numOfRows += info->affectedRows; } + // unlock + taosThreadSpinUnlock(&pParam->lock); + if (pParam->cnt == pParam->total) { tsem_post(&pParam->sem); } - taosThreadSpinUnlock(&pParam->lock); - // unlock uDebug("SML:0x%" PRIx64 " insert finished, code: %d, rows: %d, total: %d", info->id, code, rows, info->affectedRows); info->cost.endTime = taosGetTimestampUs(); info->cost.code = code; diff --git a/source/client/src/clientStmt.c b/source/client/src/clientStmt.c index fa21f82d190569e1c6eb3b2642aeb7b63d4b66f9..7a800bd3349308d87ef4897e034b23330dabce0e 100644 --- a/source/client/src/clientStmt.c +++ b/source/client/src/clientStmt.c @@ -7,8 +7,8 @@ static int32_t stmtCreateRequest(STscStmt* pStmt) { int32_t code = 0; - - if (pStmt->exec.pRequest == NULL) { + + if (pStmt->exec.pRequest == NULL) { code = buildRequest(pStmt->taos->id, pStmt->sql.sqlStr, pStmt->sql.sqlLen, NULL, false, &pStmt->exec.pRequest); if (TSDB_CODE_SUCCESS == code) { pStmt->exec.pRequest->syncQuery = true; @@ -232,7 +232,7 @@ int32_t stmtParseSql(STscStmt* pStmt) { }; STMT_ERR_RET(stmtCreateRequest(pStmt)); - + STMT_ERR_RET(parseSql(pStmt->exec.pRequest, false, &pStmt->sql.pQuery, &stmtCb)); pStmt->bInfo.needParse = false; @@ -402,7 +402,7 @@ int32_t stmtGetFromCache(STscStmt* pStmt) { STMT_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - tscDebug("reuse stmt block for tb %s in sqlBlock, suid:0x%" PRIx64 , pStmt->bInfo.tbFName, pStmt->bInfo.tbSuid); + tscDebug("reuse stmt block for tb %s in sqlBlock, suid:0x%" PRIx64, pStmt->bInfo.tbFName, pStmt->bInfo.tbSuid); return TSDB_CODE_SUCCESS; } @@ -600,8 +600,9 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) { } tscDebug("start to bind stmt tag values"); - STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName, pStmt->bInfo.sname.tname, - tags, pStmt->exec.pRequest->msgBuf, pStmt->exec.pRequest->msgBufLen)); + STMT_ERR_RET(qBindStmtTagsValue(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.tbSuid, pStmt->bInfo.stbFName, + pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf, + pStmt->exec.pRequest->msgBufLen)); return TSDB_CODE_SUCCESS; } diff --git a/source/client/src/clientTmqConnector.c b/source/client/src/clientTmqConnector.c index 26bf55055f76eeade6a192e759560f21c0c2253d..6edf76124e5940b9120d9e8ccdd4c1c4ec537fcb 100644 --- a/source/client/src/clientTmqConnector.c +++ b/source/client/src/clientTmqConnector.c @@ -212,7 +212,8 @@ JNIEXPORT void JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqCommitAsync(JN tmq_commit_async(tmq, res, commit_cb, consumer); } -JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp(JNIEnv *env, jobject jobj, jlong jtmq) { +JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp(JNIEnv *env, jobject jobj, + jlong jtmq) { tmq_t *tmq = (tmq_t *)jtmq; if (tmq == NULL) { jniError("jobj:%p, tmq is closed", jobj); @@ -223,7 +224,7 @@ JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqUnsubscribeImp } JNIEXPORT jint JNICALL Java_com_taosdata_jdbc_tmq_TMQConnector_tmqConsumerCloseImp(JNIEnv *env, jobject jobj, - jlong jtmq) { + jlong jtmq) { tmq_t *tmq = (tmq_t *)jtmq; if (tmq == NULL) { jniDebug("jobj:%p, tmq is closed", jobj); diff --git a/source/client/test/clientTests.cpp b/source/client/test/clientTests.cpp index 4ea5443678d8b927f8df831874f32b20655cb7d0..e69174476a8631d5a1935764a03bf1645dd1102b 100644 --- a/source/client/test/clientTests.cpp +++ b/source/client/test/clientTests.cpp @@ -13,12 +13,12 @@ * along with this program. If not, see . */ -#include #include +#include +#include "clientInt.h" #include "taoserror.h" #include "tglobal.h" #include "thash.h" -#include "clientInt.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wwrite-strings" @@ -26,8 +26,8 @@ #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wsign-compare" -#include "taos.h" #include "executor.h" +#include "taos.h" namespace { void showDB(TAOS* pConn) { @@ -50,11 +50,11 @@ void printResult(TAOS_RES* pRes) { int32_t numOfFields = taos_num_fields(pRes); int32_t n = 0; - char str[512] = {0}; + char str[512] = {0}; while ((pRow = taos_fetch_row(pRes)) != NULL) { int32_t* length = taos_fetch_lengths(pRes); - for(int32_t i = 0; i < numOfFields; ++i) { - printf("(%d):%d " , i, length[i]); + for (int32_t i = 0; i < numOfFields; ++i) { + printf("(%d):%d ", i, length[i]); } printf("\n"); @@ -123,16 +123,16 @@ void createNewTable(TAOS* pConn, int32_t index) { } taos_free_result(pRes); - for(int32_t i = 0; i < 3280; i += 20) { + for (int32_t i = 0; i < 3280; i += 20) { char sql[1024] = {0}; sprintf(sql, "insert into tu%d values(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)" - "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)", index, - i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, i + 7, - i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, i + 14, - i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19); + "(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)(now+%da, %d)", + index, i, i, i + 1, i + 1, i + 2, i + 2, i + 3, i + 3, i + 4, i + 4, i + 5, i + 5, i + 6, i + 6, i + 7, + i + 7, i + 8, i + 8, i + 9, i + 9, i + 10, i + 10, i + 11, i + 11, i + 12, i + 12, i + 13, i + 13, i + 14, + i + 14, i + 15, i + 15, i + 16, i + 16, i + 17, i + 17, i + 18, i + 18, i + 19, i + 19); TAOS_RES* p = taos_query(pConn, sql); if (taos_errno(p) != 0) { printf("failed to insert data, reason:%s\n", taos_errstr(p)); @@ -150,7 +150,7 @@ int main(int argc, char** argv) { TEST(testCase, driverInit_Test) { // taosInitGlobalCfg(); -// taos_init(); + // taos_init(); } TEST(testCase, connect_Test) { @@ -670,11 +670,11 @@ TEST(testCase, projection_query_tables) { TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0); ASSERT_NE(pConn, nullptr); -// TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); -// if (taos_errno(pRes) != 0) { -// printf("error in create db, reason:%s\n", taos_errstr(pRes)); -// } -// taos_free_result(pRes); + // TAOS_RES* pRes = taos_query(pConn, "create database if not exists abc1 vgroups 1"); + // if (taos_errno(pRes) != 0) { + // printf("error in create db, reason:%s\n", taos_errstr(pRes)); + // } + // taos_free_result(pRes); TAOS_RES* pRes = taos_query(pConn, "use abc1"); taos_free_result(pRes); @@ -697,27 +697,27 @@ TEST(testCase, projection_query_tables) { } taos_free_result(pRes); - for(int32_t i = 0; i < 2; ++i) { + for (int32_t i = 0; i < 2; ++i) { printf("create table :%d\n", i); createNewTable(pConn, i); } -// -// pRes = taos_query(pConn, "select * from tu"); -// if (taos_errno(pRes) != 0) { -// printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); -// taos_free_result(pRes); -// ASSERT_TRUE(false); -// } -// -// TAOS_ROW pRow = NULL; -// TAOS_FIELD* pFields = taos_fetch_fields(pRes); -// int32_t numOfFields = taos_num_fields(pRes); -// -// char str[512] = {0}; -// while ((pRow = taos_fetch_row(pRes)) != NULL) { -// int32_t code = taos_print_row(str, pRow, pFields, numOfFields); -// printf("%s\n", str); -// } + // + // pRes = taos_query(pConn, "select * from tu"); + // if (taos_errno(pRes) != 0) { + // printf("failed to select from table, reason:%s\n", taos_errstr(pRes)); + // taos_free_result(pRes); + // ASSERT_TRUE(false); + // } + // + // TAOS_ROW pRow = NULL; + // TAOS_FIELD* pFields = taos_fetch_fields(pRes); + // int32_t numOfFields = taos_num_fields(pRes); + // + // char str[512] = {0}; + // while ((pRow = taos_fetch_row(pRes)) != NULL) { + // int32_t code = taos_print_row(str, pRow, pFields, numOfFields); + // printf("%s\n", str); + // } taos_free_result(pRes); taos_close(pConn); @@ -860,5 +860,4 @@ TEST(testCase, update_test) { #endif - #pragma GCC diagnostic pop diff --git a/source/client/test/smlTest.cpp b/source/client/test/smlTest.cpp index b62238ccf26c991a516313270889a05a5b87d6ee..ab4442eca7abda74f851aedf2926cdb3f64ec7a7 100644 --- a/source/client/test/smlTest.cpp +++ b/source/client/test/smlTest.cpp @@ -42,9 +42,9 @@ TEST(testCase, smlParseInfluxString_Test) { // case 1 char *tmp = "\\,st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ,32,c=3"; - char *sql = (char*)taosMemoryCalloc(256, 1); + char *sql = (char *)taosMemoryCalloc(256, 1); memcpy(sql, tmp, strlen(tmp) + 1); - int ret = smlParseInfluxString(sql, &elements, &msgBuf); + int ret = smlParseInfluxString(sql, &elements, &msgBuf); ASSERT_EQ(ret, 0); ASSERT_EQ(elements.measure, sql); ASSERT_EQ(elements.measureLen, strlen(",st")); @@ -136,83 +136,81 @@ TEST(testCase, smlParseInfluxString_Test) { } TEST(testCase, smlParseCols_Error_Test) { - const char *data[] = { - "c=\"89sd", // binary, nchar - "c=j\"89sd\"", - "c=\"89sd\"k", - "c=u", // bool - "c=truet", - "c=f64", // double - "c=8f64f", - "c=8ef64", - "c=f32", // float - "c=8f32f", - "c=8wef32", - "c=-3.402823466e+39f32", - "c=", // double - "c=8f", - "c=8we", - "c=i8", // tiny int - "c=-8i8f", - "c=8wei8", - "c=-999i8", - "c=u8", // u tiny int - "c=8fu8", - "c=8weu8", - "c=999u8", - "c=-8u8", - "c=i16", // small int - "c=8fi16u", - "c=8wei16", - "c=-67787i16", - "c=u16", // u small int - "c=8u16f", - "c=8weu16", - "c=-9u16", - "c=67787u16", - "c=i32", // int - "c=8i32f", - "c=8wei32", - "c=2147483649i32", - "c=u32", // u int - "c=8u32f", - "c=8weu32", - "c=-4u32", - "c=42949672958u32", - "c=i64", // big int - "c=8i64i", - "c=8wei64", - "c=-9223372036854775809i64", - "c=i", // big int - "c=8fi", - "c=8wei", - "c=9223372036854775808i", - "c=u64", // u big int - "c=8u64f", - "c=8weu64", - "c=-3.402823466e+39u64", - "c=-339u64", - "c=18446744073709551616u64", - "c=1,c=2", - "c=1=2" - }; + const char *data[] = {"c=\"89sd", // binary, nchar + "c=j\"89sd\"", + "c=\"89sd\"k", + "c=u", // bool + "c=truet", + "c=f64", // double + "c=8f64f", + "c=8ef64", + "c=f32", // float + "c=8f32f", + "c=8wef32", + "c=-3.402823466e+39f32", + "c=", // double + "c=8f", + "c=8we", + "c=i8", // tiny int + "c=-8i8f", + "c=8wei8", + "c=-999i8", + "c=u8", // u tiny int + "c=8fu8", + "c=8weu8", + "c=999u8", + "c=-8u8", + "c=i16", // small int + "c=8fi16u", + "c=8wei16", + "c=-67787i16", + "c=u16", // u small int + "c=8u16f", + "c=8weu16", + "c=-9u16", + "c=67787u16", + "c=i32", // int + "c=8i32f", + "c=8wei32", + "c=2147483649i32", + "c=u32", // u int + "c=8u32f", + "c=8weu32", + "c=-4u32", + "c=42949672958u32", + "c=i64", // big int + "c=8i64i", + "c=8wei64", + "c=-9223372036854775809i64", + "c=i", // big int + "c=8fi", + "c=8wei", + "c=9223372036854775808i", + "c=u64", // u big int + "c=8u64f", + "c=8weu64", + "c=-3.402823466e+39u64", + "c=-339u64", + "c=18446744073709551616u64", + "c=1,c=2", + "c=1=2"}; SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - for(int i = 0; i < sizeof(data)/sizeof(data[0]); i++){ + for (int i = 0; i < sizeof(data) / sizeof(data[0]); i++) { char msg[256] = {0}; SSmlMsgBuf msgBuf; msgBuf.buf = msg; msgBuf.len = 256; int32_t len = strlen(data[i]); - char *sql = (char*)taosMemoryCalloc(256, 1); + char *sql = (char *)taosMemoryCalloc(256, 1); memcpy(sql, data[i], len + 1); SArray *cols = taosArrayInit(8, POINTER_BYTES); int32_t ret = smlParseCols(sql, len, cols, NULL, false, dumplicateKey, &msgBuf); - printf("i:%d\n",i); + printf("i:%d\n", i); ASSERT_NE(ret, TSDB_CODE_SUCCESS); taosHashClear(dumplicateKey); taosMemoryFree(sql); - for(int j = 0; j < taosArrayGetSize(cols); j++){ + for (int j = 0; j < taosArrayGetSize(cols); j++) { void *kv = taosArrayGetP(cols, j); taosMemoryFree(kv); } @@ -232,7 +230,10 @@ TEST(testCase, smlParseCols_tag_Test) { SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); const char *data = - "cbin=\"passit helloc\",cnch=L\"iisdfsf\",cbool=false,cf64=4.31f64,cf64_=8.32,cf32=8.23f32,ci8=-34i8,cu8=89u8,ci16=233i16,cu16=898u16,ci32=98289i32,cu32=12323u32,ci64=-89238i64,ci=989i,cu64=8989323u64,cbooltrue=true,cboolt=t,cboolf=f,cnch_=l\"iuwq\""; + "cbin=\"passit " + "helloc\",cnch=L\"iisdfsf\",cbool=false,cf64=4.31f64,cf64_=8.32,cf32=8.23f32,ci8=-34i8,cu8=89u8,ci16=233i16,cu16=" + "898u16,ci32=98289i32,cu32=12323u32,ci64=-89238i64,ci=989i,cu64=8989323u64,cbooltrue=true,cboolt=t,cboolf=f,cnch_" + "=l\"iuwq\""; int32_t len = strlen(data); int32_t ret = smlParseCols(data, len, cols, NULL, true, dumplicateKey, &msgBuf); ASSERT_EQ(ret, TSDB_CODE_SUCCESS); @@ -255,7 +256,7 @@ TEST(testCase, smlParseCols_tag_Test) { ASSERT_EQ(kv->length, 7); ASSERT_EQ(strncasecmp(kv->value, "4.31f64", 7), 0); - for(int i = 0; i < size; i++){ + for (int i = 0; i < size; i++) { void *tmp = taosArrayGetP(cols, i); taosMemoryFree(tmp); } @@ -286,9 +287,13 @@ TEST(testCase, smlParseCols_Test) { SHashObj *dumplicateKey = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - const char *data = "cb\\=in=\"pass\\,it hello,c=2\",cnch=L\"ii\\=sdfsf\",cbool=false,cf64=4.31f64,cf64_=8.32,cf32=8.23f32,ci8=-34i8,cu8=89u8,ci16=233i16,cu16=898u16,ci32=98289i32,cu32=12323u32,ci64=-89238i64,ci=989i,cu64=8989323u64,cbooltrue=true,cboolt=t,cboolf=f,cnch_=l\"iuwq\""; + const char *data = + "cb\\=in=\"pass\\,it " + "hello,c=2\",cnch=L\"ii\\=sdfsf\",cbool=false,cf64=4.31f64,cf64_=8.32,cf32=8.23f32,ci8=-34i8,cu8=89u8,ci16=" + "233i16,cu16=898u16,ci32=98289i32,cu32=12323u32,ci64=-89238i64,ci=989i,cu64=8989323u64,cbooltrue=true,cboolt=t," + "cboolf=f,cnch_=l\"iuwq\""; int32_t len = strlen(data); - char *sql = (char*)taosMemoryCalloc(1024, 1); + char *sql = (char *)taosMemoryCalloc(1024, 1); memcpy(sql, data, len + 1); int32_t ret = smlParseCols(sql, len, cols, NULL, false, dumplicateKey, &msgBuf); ASSERT_EQ(ret, TSDB_CODE_SUCCESS); @@ -328,7 +333,7 @@ TEST(testCase, smlParseCols_Test) { ASSERT_EQ(kv->keyLen, 4); ASSERT_EQ(kv->type, TSDB_DATA_TYPE_DOUBLE); ASSERT_EQ(kv->length, 8); - //ASSERT_EQ(kv->d, 4.31); + // ASSERT_EQ(kv->d, 4.31); printf("4.31 = kv->d:%f\n", kv->d); taosMemoryFree(kv); @@ -338,7 +343,7 @@ TEST(testCase, smlParseCols_Test) { ASSERT_EQ(kv->keyLen, 5); ASSERT_EQ(kv->type, TSDB_DATA_TYPE_DOUBLE); ASSERT_EQ(kv->length, 8); - //ASSERT_EQ(kv->f, 8.32); + // ASSERT_EQ(kv->f, 8.32); printf("8.32 = kv->d:%f\n", kv->d); taosMemoryFree(kv); @@ -348,7 +353,7 @@ TEST(testCase, smlParseCols_Test) { ASSERT_EQ(kv->keyLen, 4); ASSERT_EQ(kv->type, TSDB_DATA_TYPE_FLOAT); ASSERT_EQ(kv->length, 4); - //ASSERT_EQ(kv->f, 8.23); + // ASSERT_EQ(kv->f, 8.23); printf("8.23 = kv->f:%f\n", kv->f); taosMemoryFree(kv); @@ -406,7 +411,6 @@ TEST(testCase, smlParseCols_Test) { ASSERT_EQ(kv->u, 12323); taosMemoryFree(kv); - // bigint kv = (SSmlKv *)taosArrayGetP(cols, 12); ASSERT_EQ(strncasecmp(kv->key, "ci64", 4), 0); @@ -443,7 +447,6 @@ TEST(testCase, smlParseCols_Test) { ASSERT_EQ(kv->i, true); taosMemoryFree(kv); - // bool kv = (SSmlKv *)taosArrayGetP(cols, 16); ASSERT_EQ(strncasecmp(kv->key, "cboolt", 6), 0); @@ -500,15 +503,15 @@ TEST(testCase, smlGetTimestampLen_Test) { } TEST(testCase, smlParseNumber_Test) { - SSmlKv kv = {0}; - char buf[64] = {0}; + SSmlKv kv = {0}; + char buf[64] = {0}; SSmlMsgBuf msg = {0}; msg.buf = buf; msg.len = 64; kv.value = "3.2e-900"; kv.length = 8; bool res = smlParseNumber(&kv, &msg); - printf("res:%d,v:%f, %f\n", res,kv.d, HUGE_VAL); + printf("res:%d,v:%f, %f\n", res, kv.d, HUGE_VAL); } TEST(testCase, smlParseTelnetLine_error_Test) { @@ -538,8 +541,8 @@ TEST(testCase, smlParseTelnetLine_error_Test) { "sys.procs.running 1479496100 42 host=web01=er", "sys.procs.running 1479496100 42 host= web01", }; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - int ret = smlParseTelnetLine(info, (void*)sql[i]); + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { + int ret = smlParseTelnetLine(info, (void *)sql[i]); ASSERT_NE(ret, 0); } @@ -550,16 +553,16 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) { SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_TELNET_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); ASSERT_NE(info, nullptr); - const char *sql[] = { - "sys.procs.running 1479496104000 42 host=web01", - "sys.procs.running 1479496104000 42u8 host=web01", - "appywjnuct 1626006833641 True id=\"appywjnuct_40601_49808_1\" t0=t t1=127i8 id=\"appywjnuct_40601_49808_2\" t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 t5=11.12345f32 t6=22.123456789f64 t7=\"binaryTagValue\" t8=L\"ncharTagValue\"" - }; + const char *sql[] = {"sys.procs.running 1479496104000 42 host=web01", + "sys.procs.running 1479496104000 42u8 host=web01", + "appywjnuct 1626006833641 True id=\"appywjnuct_40601_49808_1\" t0=t t1=127i8 " + "id=\"appywjnuct_40601_49808_2\" t2=32767i16 t3=2147483647i32 t4=9223372036854775807i64 " + "t5=11.12345f32 t6=22.123456789f64 t7=\"binaryTagValue\" t8=L\"ncharTagValue\""}; int ret = TSDB_CODE_SUCCESS; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - ret = smlParseTelnetLine(info, (void*)sql[i]); - if(ret != TSDB_CODE_SUCCESS) break; + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { + ret = smlParseTelnetLine(info, (void *)sql[i]); + if (ret != TSDB_CODE_SUCCESS) break; } ASSERT_NE(ret, 0); smlDestroyInfo(info); @@ -613,8 +616,8 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) { }; int ret = TSDB_CODE_SUCCESS; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - ret = smlParseTelnetLine(info, (void*)sql[i]); + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { + ret = smlParseTelnetLine(info, (void *)sql[i]); ASSERT_NE(ret, 0); } @@ -622,7 +625,6 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) { } TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { - SSmlHandle *info = smlBuildSmlInfo(NULL, NULL, TSDB_SML_JSON_PROTOCOL, TSDB_SML_TIMESTAMP_NANO_SECONDS); ASSERT_NE(info, nullptr); @@ -650,9 +652,9 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) { }; int ret = TSDB_CODE_SUCCESS; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - ret = smlParseTelnetLine(info, (void*)sql[i]); - if(ret != TSDB_CODE_SUCCESS) break; + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { + ret = smlParseTelnetLine(info, (void *)sql[i]); + if (ret != TSDB_CODE_SUCCESS) break; } ASSERT_NE(ret, 0); smlDestroyInfo(info); @@ -685,9 +687,9 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) { "]", }; int ret = TSDB_CODE_SUCCESS; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ - ret = smlParseTelnetLine(info, (void*)sql[i]); - if(ret != TSDB_CODE_SUCCESS) break; + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { + ret = smlParseTelnetLine(info, (void *)sql[i]); + if (ret != TSDB_CODE_SUCCESS) break; } ASSERT_NE(ret, 0); smlDestroyInfo(info); @@ -698,45 +700,310 @@ TEST(testCase, sml_col_4096_Test) { ASSERT_NE(info, nullptr); const char *sql[] = { - "spgwgvldxv,id=spgwgvldxv_1,t0=f c0=t,c1=t,c2=t,c3=t,c4=t,c5=t,c6=t,c7=t,c8=t,c9=t,c10=t,c11=t,c12=t,c13=t,c14=t,c15=t,c16=t,c17=t,c18=t,c19=t,c20=t,c21=t,c22=t,c23=t,c24=t,c25=t,c26=t,c27=t,c28=t,c29=t,c30=t,c31=t,c32=t,c33=t,c34=t,c35=t,c36=t,c37=t,c38=t,c39=t,c40=t,c41=t,c42=t,c43=t,c44=t,c45=t,c46=t,c47=t,c48=t,c49=t,c50=t,c51=t,c52=t,c53=t,c54=t,c55=t,c56=t,c57=t,c58=t,c59=t,c60=t,c61=t,c62=t,c63=t,c64=t,c65=t,c66=t,c67=t,c68=t,c69=t,c70=t,c71=t,c72=t,c73=t,c74=t,c75=t,c76=t,c77=t,c78=t,c79=t,c80=t,c81=t,c82=t,c83=t,c84=t,c85=t,c86=t,c87=t,c88=t,c89=t,c90=t,c91=t,c92=t,c93=t,c94=t,c95=t,c96=t,c97=t,c98=t,c99=t,c100=t," - "c101=t,c102=t,c103=t,c104=t,c105=t,c106=t,c107=t,c108=t,c109=t,c110=t,c111=t,c112=t,c113=t,c114=t,c115=t,c116=t,c117=t,c118=t,c119=t,c120=t,c121=t,c122=t,c123=t,c124=t,c125=t,c126=t,c127=t,c128=t,c129=t,c130=t,c131=t,c132=t,c133=t,c134=t,c135=t,c136=t,c137=t,c138=t,c139=t,c140=t,c141=t,c142=t,c143=t,c144=t,c145=t,c146=t,c147=t,c148=t,c149=t,c150=t,c151=t,c152=t,c153=t,c154=t,c155=t,c156=t,c157=t,c158=t,c159=t,c160=t,c161=t,c162=t,c163=t,c164=t,c165=t,c166=t,c167=t,c168=t,c169=t,c170=t,c171=t,c172=t,c173=t,c174=t,c175=t,c176=t,c177=t,c178=t,c179=t,c180=t,c181=t,c182=t,c183=t,c184=t,c185=t,c186=t,c187=t,c188=t,c189=t," - "c190=t,c191=t,c192=t,c193=t,c194=t,c195=t,c196=t,c197=t,c198=t,c199=t,c200=t,c201=t,c202=t,c203=t,c204=t,c205=t,c206=t,c207=t,c208=t,c209=t,c210=t,c211=t,c212=t,c213=t,c214=t,c215=t,c216=t,c217=t,c218=t,c219=t,c220=t,c221=t,c222=t,c223=t,c224=t,c225=t,c226=t,c227=t,c228=t,c229=t,c230=t,c231=t,c232=t,c233=t,c234=t,c235=t,c236=t,c237=t,c238=t,c239=t,c240=t,c241=t,c242=t,c243=t,c244=t,c245=t,c246=t,c247=t,c248=t,c249=t,c250=t,c251=t,c252=t,c253=t,c254=t,c255=t,c256=t,c257=t,c258=t,c259=t,c260=t,c261=t,c262=t,c263=t,c264=t,c265=t,c266=t,c267=t,c268=t,c269=t,c270=t,c271=t,c272=t,c273=t,c274=t,c275=t,c276=t,c277=t,c278=t," - "c279=t,c280=t,c281=t,c282=t,c283=t,c284=t,c285=t,c286=t,c287=t,c288=t,c289=t,c290=t,c291=t,c292=t,c293=t,c294=t,c295=t,c296=t,c297=t,c298=t,c299=t,c300=t,c301=t,c302=t,c303=t,c304=t,c305=t,c306=t,c307=t,c308=t,c309=t,c310=t,c311=t,c312=t,c313=t,c314=t,c315=t,c316=t,c317=t,c318=t,c319=t,c320=t,c321=t,c322=t,c323=t,c324=t,c325=t,c326=t,c327=t,c328=t,c329=t,c330=t,c331=t,c332=t,c333=t,c334=t,c335=t,c336=t,c337=t,c338=t,c339=t,c340=t,c341=t,c342=t,c343=t,c344=t,c345=t,c346=t,c347=t,c348=t,c349=t,c350=t,c351=t,c352=t,c353=t,c354=t,c355=t,c356=t,c357=t,c358=t,c359=t,c360=t,c361=t,c362=t,c363=t,c364=t,c365=t,c366=t,c367=t,c368=t,c369=t,c370=t,c371=t,c372=t,c373=t,c374=t,c375=t,c376=t,c377=t,c378=t,c379=t,c380=t,c381=t,c382=t,c383=t,c384=t,c385=t,c386=t,c387=t,c388=t,c389=t,c390=t,c391=t,c392=t,c393=t,c394=t,c395=t,c396=t,c397=t,c398=t,c399=t,c400=t,c401=t,c402=t,c403=t,c404=t,c405=t,c406=t,c407=t,c408=t,c409=t,c410=t,c411=t,c412=t,c413=t,c414=t,c415=t,c416=t,c417=t,c418=t,c419=t,c420=t,c421=t,c422=t,c423=t,c424=t,c425=t,c426=t,c427=t,c428=t,c429=t,c430=t,c431=t,c432=t,c433=t,c434=t,c435=t,c436=t,c437=t,c438=t,c439=t,c440=t,c441=t,c442=t,c443=t,c444=t,c445=t,c446=t," - "c447=t,c448=t,c449=t,c450=t,c451=t,c452=t,c453=t,c454=t,c455=t,c456=t,c457=t,c458=t,c459=t,c460=t,c461=t,c462=t,c463=t,c464=t,c465=t,c466=t,c467=t,c468=t,c469=t,c470=t,c471=t,c472=t,c473=t,c474=t,c475=t,c476=t,c477=t,c478=t,c479=t,c480=t,c481=t,c482=t,c483=t,c484=t,c485=t,c486=t,c487=t,c488=t,c489=t,c490=t,c491=t,c492=t,c493=t,c494=t,c495=t,c496=t,c497=t,c498=t,c499=t,c500=t,c501=t,c502=t,c503=t,c504=t,c505=t,c506=t,c507=t,c508=t,c509=t,c510=t,c511=t,c512=t,c513=t,c514=t,c515=t,c516=t,c517=t,c518=t,c519=t,c520=t,c521=t,c522=t,c523=t,c524=t,c525=t,c526=t,c527=t,c528=t,c529=t,c530=t,c531=t,c532=t,c533=t,c534=t,c535=t,c536=t,c537=t,c538=t,c539=t,c540=t,c541=t,c542=t,c543=t,c544=t,c545=t,c546=t,c547=t,c548=t,c549=t,c550=t,c551=t,c552=t,c553=t,c554=t,c555=t,c556=t,c557=t,c558=t,c559=t,c560=t,c561=t,c562=t,c563=t,c564=t,c565=t,c566=t,c567=t,c568=t,c569=t,c570=t,c571=t,c572=t,c573=t,c574=t,c575=t,c576=t,c577=t,c578=t,c579=t,c580=t,c581=t,c582=t,c583=t,c584=t,c585=t,c586=t,c587=t,c588=t,c589=t,c590=t,c591=t,c592=t,c593=t,c594=t,c595=t,c596=t,c597=t,c598=t,c599=t,c600=t,c601=t,c602=t,c603=t,c604=t,c605=t,c606=t,c607=t,c608=t,c609=t,c610=t,c611=t,c612=t,c613=t,c614=t," - "c615=t,c616=t,c617=t,c618=t,c619=t,c620=t,c621=t,c622=t,c623=t,c624=t,c625=t,c626=t,c627=t,c628=t,c629=t,c630=t,c631=t,c632=t,c633=t,c634=t,c635=t,c636=t,c637=t,c638=t,c639=t,c640=t,c641=t,c642=t,c643=t,c644=t,c645=t,c646=t,c647=t,c648=t,c649=t,c650=t,c651=t,c652=t,c653=t,c654=t,c655=t,c656=t,c657=t,c658=t,c659=t,c660=t,c661=t,c662=t,c663=t,c664=t,c665=t,c666=t,c667=t,c668=t,c669=t,c670=t,c671=t,c672=t,c673=t,c674=t,c675=t,c676=t,c677=t,c678=t,c679=t,c680=t,c681=t,c682=t,c683=t,c684=t,c685=t,c686=t,c687=t,c688=t,c689=t,c690=t,c691=t,c692=t,c693=t,c694=t,c695=t,c696=t,c697=t,c698=t,c699=t,c700=t,c701=t,c702=t,c703=t,c704=t,c705=t,c706=t,c707=t,c708=t,c709=t,c710=t,c711=t,c712=t,c713=t,c714=t,c715=t,c716=t,c717=t,c718=t,c719=t,c720=t,c721=t,c722=t,c723=t,c724=t,c725=t,c726=t,c727=t,c728=t,c729=t,c730=t,c731=t,c732=t,c733=t,c734=t,c735=t,c736=t,c737=t,c738=t,c739=t,c740=t,c741=t,c742=t,c743=t,c744=t,c745=t,c746=t,c747=t,c748=t,c749=t,c750=t,c751=t,c752=t,c753=t,c754=t,c755=t,c756=t,c757=t,c758=t,c759=t,c760=t,c761=t,c762=t,c763=t,c764=t,c765=t,c766=t,c767=t,c768=t,c769=t,c770=t,c771=t,c772=t,c773=t,c774=t,c775=t,c776=t,c777=t,c778=t,c779=t,c780=t,c781=t,c782=t," - "c783=t,c784=t,c785=t,c786=t,c787=t,c788=t,c789=t,c790=t,c791=t,c792=t,c793=t,c794=t,c795=t,c796=t,c797=t,c798=t,c799=t,c800=t,c801=t,c802=t,c803=t,c804=t,c805=t,c806=t,c807=t,c808=t,c809=t,c810=t,c811=t,c812=t,c813=t," - "c814=t,c815=t,c816=t,c817=t,c818=t,c819=t,c820=t,c821=t,c822=t,c823=t,c824=t,c825=t,c826=t,c827=t,c828=t,c829=t,c830=t,c831=t,c832=t,c833=t,c834=t,c835=t,c836=t,c837=t,c838=t,c839=t,c840=t,c841=t,c842=t,c843=t,c844=t,c845=t,c846=t,c847=t,c848=t,c849=t,c850=t,c851=t,c852=t,c853=t,c854=t,c855=t,c856=t,c857=t,c858=t,c859=t,c860=t,c861=t,c862=t," - "c863=t,c864=t,c865=t,c866=t,c867=t,c868=t,c869=t,c870=t,c871=t,c872=t,c873=t,c874=t,c875=t,c876=t,c877=t,c878=t,c879=t,c880=t,c881=t,c882=t,c883=t,c884=t,c885=t,c886=t,c887=t,c888=t,c889=t,c890=t,c891=t,c892=t,c893=t,c894=t,c895=t,c896=t,c897=t,c898=t,c899=t,c900=t,c901=t,c902=t,c903=t,c904=t,c905=t,c906=t,c907=t,c908=t,c909=t,c910=t,c911=t,c912=t,c913=t,c914=t,c915=t,c916=t,c917=t,c918=t,c919=t,c920=t,c921=t,c922=t,c923=t,c924=t,c925=t,c926=t,c927=t,c928=t,c929=t,c930=t,c931=t,c932=t,c933=t,c934=t,c935=t,c936=t,c937=t,c938=t,c939=t,c940=t,c941=t,c942=t,c943=t,c944=t,c945=t,c946=t,c947=t,c948=t,c949=t,c950=t,c951=t,c952=t,c953=t,c954=t,c955=t,c956=t,c957=t,c958=t,c959=t,c960=t,c961=t,c962=t,c963=t,c964=t,c965=t,c966=t,c967=t,c968=t,c969=t,c970=t,c971=t,c972=t,c973=t,c974=t,c975=t,c976=t,c977=t,c978=t,c979=t,c980=t,c981=t,c982=t,c983=t,c984=t,c985=t,c986=t,c987=t,c988=t,c989=t,c990=t,c991=t,c992=t,c993=t,c994=t,c995=t,c996=t,c997=t,c998=t,c999=t,c1000=t,c1001=t,c1002=t,c1003=t,c1004=t,c1005=t,c1006=t,c1007=t,c1008=t,c1009=t,c1010=t,c1011=t,c1012=t,c1013=t,c1014=t,c1015=t,c1016=t,c1017=t,c1018=t,c1019=t,c1020=t,c1021=t,c1022=t,c1023=t,c1024=t,c1025=t,c1026=t," - "c1027=t,c1028=t,c1029=t,c1030=t,c1031=t,c1032=t,c1033=t,c1034=t,c1035=t,c1036=t,c1037=t,c1038=t,c1039=t,c1040=t,c1041=t,c1042=t,c1043=t,c1044=t,c1045=t,c1046=t,c1047=t,c1048=t,c1049=t,c1050=t,c1051=t,c1052=t,c1053=t,c1054=t,c1055=t,c1056=t,c1057=t,c1058=t,c1059=t,c1060=t,c1061=t,c1062=t,c1063=t,c1064=t,c1065=t,c1066=t,c1067=t,c1068=t,c1069=t,c1070=t,c1071=t,c1072=t,c1073=t,c1074=t,c1075=t,c1076=t,c1077=t,c1078=t,c1079=t,c1080=t,c1081=t,c1082=t,c1083=t,c1084=t,c1085=t,c1086=t,c1087=t,c1088=t,c1089=t,c1090=t,c1091=t,c1092=t,c1093=t,c1094=t,c1095=t,c1096=t,c1097=t,c1098=t,c1099=t,c1100=t,c1101=t,c1102=t,c1103=t,c1104=t,c1105=t,c1106=t,c1107=t,c1108=t,c1109=t,c1110=t,c1111=t,c1112=t,c1113=t,c1114=t,c1115=t,c1116=t,c1117=t,c1118=t,c1119=t,c1120=t,c1121=t,c1122=t,c1123=t,c1124=t,c1125=t,c1126=t,c1127=t,c1128=t,c1129=t,c1130=t,c1131=t,c1132=t,c1133=t,c1134=t,c1135=t,c1136=t,c1137=t,c1138=t,c1139=t,c1140=t,c1141=t,c1142=t,c1143=t,c1144=t,c1145=t,c1146=t,c1147=t,c1148=t,c1149=t,c1150=t,c1151=t,c1152=t,c1153=t,c1154=t,c1155=t,c1156=t,c1157=t,c1158=t,c1159=t,c1160=t,c1161=t,c1162=t,c1163=t,c1164=t,c1165=t,c1166=t,c1167=t,c1168=t,c1169=t,c1170=t,c1171=t,c1172=t,c1173=t," - "c1174=t,c1175=t,c1176=t,c1177=t,c1178=t,c1179=t,c1180=t,c1181=t,c1182=t,c1183=t,c1184=t,c1185=t,c1186=t,c1187=t,c1188=t,c1189=t,c1190=t,c1191=t,c1192=t,c1193=t,c1194=t,c1195=t,c1196=t,c1197=t,c1198=t,c1199=t,c1200=t,c1201=t,c1202=t,c1203=t,c1204=t,c1205=t,c1206=t,c1207=t,c1208=t,c1209=t,c1210=t,c1211=t,c1212=t,c1213=t,c1214=t,c1215=t,c1216=t,c1217=t,c1218=t,c1219=t,c1220=t,c1221=t,c1222=t,c1223=t,c1224=t,c1225=t,c1226=t,c1227=t,c1228=t,c1229=t,c1230=t,c1231=t,c1232=t,c1233=t,c1234=t,c1235=t,c1236=t,c1237=t,c1238=t,c1239=t,c1240=t,c1241=t,c1242=t,c1243=t,c1244=t,c1245=t,c1246=t,c1247=t,c1248=t,c1249=t,c1250=t,c1251=t,c1252=t,c1253=t,c1254=t,c1255=t,c1256=t,c1257=t,c1258=t,c1259=t,c1260=t,c1261=t,c1262=t,c1263=t,c1264=t,c1265=t,c1266=t,c1267=t,c1268=t,c1269=t,c1270=t,c1271=t,c1272=t,c1273=t,c1274=t,c1275=t,c1276=t,c1277=t,c1278=t,c1279=t,c1280=t,c1281=t,c1282=t,c1283=t,c1284=t,c1285=t,c1286=t,c1287=t,c1288=t,c1289=t,c1290=t,c1291=t,c1292=t,c1293=t,c1294=t,c1295=t,c1296=t,c1297=t,c1298=t,c1299=t,c1300=t,c1301=t,c1302=t,c1303=t,c1304=t,c1305=t,c1306=t,c1307=t,c1308=t,c1309=t,c1310=t,c1311=t,c1312=t,c1313=t,c1314=t,c1315=t,c1316=t,c1317=t,c1318=t,c1319=t,c1320=t," - "c1321=t,c1322=t,c1323=t,c1324=t,c1325=t,c1326=t,c1327=t,c1328=t,c1329=t,c1330=t,c1331=t,c1332=t,c1333=t,c1334=t,c1335=t,c1336=t,c1337=t,c1338=t,c1339=t,c1340=t,c1341=t,c1342=t,c1343=t,c1344=t,c1345=t,c1346=t,c1347=t," - "c1348=t,c1349=t,c1350=t,c1351=t,c1352=t,c1353=t,c1354=t,c1355=t,c1356=t,c1357=t,c1358=t,c1359=t,c1360=t,c1361=t,c1362=t,c1363=t,c1364=t,c1365=t,c1366=t,c1367=t,c1368=t,c1369=t,c1370=t,c1371=t,c1372=t,c1373=t,c1374=t,c1375=t,c1376=t,c1377=t,c1378=t,c1379=t,c1380=t,c1381=t,c1382=t,c1383=t,c1384=t,c1385=t,c1386=t,c1387=t,c1388=t,c1389=t,c1390=t,c1391=t,c1392=t,c1393=t,c1394=t,c1395=t,c1396=t,c1397=t,c1398=t,c1399=t,c1400=t,c1401=t,c1402=t,c1403=t,c1404=t,c1405=t,c1406=t,c1407=t,c1408=t,c1409=t,c1410=t,c1411=t,c1412=t,c1413=t,c1414=t,c1415=t,c1416=t,c1417=t,c1418=t,c1419=t,c1420=t,c1421=t,c1422=t,c1423=t,c1424=t,c1425=t,c1426=t,c1427=t,c1428=t,c1429=t,c1430=t,c1431=t,c1432=t,c1433=t,c1434=t,c1435=t,c1436=t,c1437=t,c1438=t,c1439=t,c1440=t,c1441=t,c1442=t,c1443=t,c1444=t,c1445=t,c1446=t,c1447=t,c1448=t,c1449=t,c1450=t,c1451=t,c1452=t,c1453=t,c1454=t,c1455=t,c1456=t,c1457=t,c1458=t,c1459=t,c1460=t,c1461=t,c1462=t,c1463=t,c1464=t,c1465=t,c1466=t,c1467=t,c1468=t,c1469=t,c1470=t,c1471=t,c1472=t,c1473=t,c1474=t,c1475=t,c1476=t,c1477=t,c1478=t,c1479=t,c1480=t,c1481=t,c1482=t,c1483=t,c1484=t,c1485=t,c1486=t,c1487=t,c1488=t,c1489=t,c1490=t,c1491=t,c1492=t,c1493=t,c1494=t," - "c1495=t,c1496=t,c1497=t,c1498=t,c1499=t,c1500=t,c1501=t,c1502=t,c1503=t,c1504=t,c1505=t,c1506=t,c1507=t,c1508=t,c1509=t,c1510=t,c1511=t,c1512=t,c1513=t,c1514=t,c1515=t,c1516=t,c1517=t,c1518=t,c1519=t,c1520=t,c1521=t,c1522=t,c1523=t,c1524=t,c1525=t,c1526=t,c1527=t,c1528=t,c1529=t,c1530=t,c1531=t,c1532=t,c1533=t,c1534=t,c1535=t,c1536=t,c1537=t,c1538=t,c1539=t,c1540=t,c1541=t,c1542=t,c1543=t,c1544=t,c1545=t,c1546=t,c1547=t,c1548=t,c1549=t,c1550=t,c1551=t,c1552=t,c1553=t,c1554=t,c1555=t,c1556=t,c1557=t,c1558=t,c1559=t,c1560=t,c1561=t,c1562=t,c1563=t,c1564=t,c1565=t,c1566=t,c1567=t,c1568=t,c1569=t,c1570=t,c1571=t,c1572=t,c1573=t,c1574=t,c1575=t,c1576=t,c1577=t,c1578=t,c1579=t,c1580=t,c1581=t,c1582=t,c1583=t,c1584=t,c1585=t,c1586=t,c1587=t,c1588=t,c1589=t,c1590=t,c1591=t,c1592=t,c1593=t,c1594=t,c1595=t,c1596=t,c1597=t,c1598=t,c1599=t,c1600=t,c1601=t,c1602=t,c1603=t,c1604=t,c1605=t,c1606=t,c1607=t,c1608=t,c1609=t,c1610=t,c1611=t,c1612=t,c1613=t,c1614=t,c1615=t,c1616=t,c1617=t,c1618=t,c1619=t,c1620=t,c1621=t,c1622=t,c1623=t,c1624=t,c1625=t,c1626=t,c1627=t,c1628=t,c1629=t,c1630=t,c1631=t,c1632=t,c1633=t,c1634=t,c1635=t,c1636=t,c1637=t,c1638=t,c1639=t,c1640=t,c1641=t," - "c1642=t,c1643=t,c1644=t,c1645=t,c1646=t,c1647=t,c1648=t,c1649=t,c1650=t,c1651=t,c1652=t,c1653=t,c1654=t,c1655=t,c1656=t,c1657=t,c1658=t,c1659=t,c1660=t,c1661=t,c1662=t,c1663=t,c1664=t,c1665=t,c1666=t,c1667=t,c1668=t,c1669=t,c1670=t,c1671=t,c1672=t,c1673=t,c1674=t,c1675=t,c1676=t,c1677=t,c1678=t,c1679=t,c1680=t,c1681=t,c1682=t,c1683=t,c1684=t,c1685=t,c1686=t,c1687=t,c1688=t,c1689=t,c1690=t,c1691=t,c1692=t,c1693=t,c1694=t,c1695=t,c1696=t,c1697=t,c1698=t,c1699=t,c1700=t,c1701=t,c1702=t,c1703=t,c1704=t,c1705=t,c1706=t,c1707=t,c1708=t,c1709=t,c1710=t,c1711=t,c1712=t,c1713=t,c1714=t,c1715=t,c1716=t,c1717=t,c1718=t,c1719=t,c1720=t,c1721=t,c1722=t,c1723=t,c1724=t,c1725=t,c1726=t,c1727=t,c1728=t,c1729=t,c1730=t,c1731=t,c1732=t,c1733=t,c1734=t,c1735=t,c1736=t,c1737=t,c1738=t,c1739=t,c1740=t,c1741=t,c1742=t,c1743=t,c1744=t,c1745=t,c1746=t,c1747=t,c1748=t,c1749=t,c1750=t,c1751=t,c1752=t,c1753=t,c1754=t,c1755=t,c1756=t,c1757=t,c1758=t,c1759=t,c1760=t,c1761=t,c1762=t,c1763=t,c1764=t,c1765=t,c1766=t,c1767=t,c1768=t,c1769=t,c1770=t,c1771=t,c1772=t,c1773=t,c1774=t,c1775=t,c1776=t,c1777=t,c1778=t,c1779=t,c1780=t,c1781=t,c1782=t,c1783=t,c1784=t,c1785=t,c1786=t,c1787=t,c1788=t," - "c1789=t,c1790=t,c1791=t,c1792=t,c1793=t,c1794=t,c1795=t,c1796=t,c1797=t,c1798=t,c1799=t,c1800=t,c1801=t,c1802=t,c1803=t,c1804=t,c1805=t,c1806=t,c1807=t,c1808=t,c1809=t,c1810=t,c1811=t,c1812=t,c1813=t,c1814=t,c1815=t," - "c1816=t,c1817=t,c1818=t,c1819=t,c1820=t,c1821=t,c1822=t,c1823=t,c1824=t,c1825=t,c1826=t,c1827=t,c1828=t,c1829=t,c1830=t,c1831=t,c1832=t,c1833=t,c1834=t,c1835=t,c1836=t,c1837=t,c1838=t,c1839=t,c1840=t,c1841=t,c1842=t,c1843=t,c1844=t,c1845=t,c1846=t,c1847=t,c1848=t,c1849=t,c1850=t,c1851=t,c1852=t,c1853=t,c1854=t,c1855=t,c1856=t,c1857=t,c1858=t,c1859=t,c1860=t,c1861=t,c1862=t,c1863=t,c1864=t,c1865=t,c1866=t,c1867=t,c1868=t,c1869=t,c1870=t,c1871=t,c1872=t,c1873=t,c1874=t,c1875=t,c1876=t,c1877=t,c1878=t,c1879=t,c1880=t,c1881=t,c1882=t,c1883=t,c1884=t,c1885=t,c1886=t,c1887=t,c1888=t,c1889=t,c1890=t,c1891=t,c1892=t,c1893=t,c1894=t,c1895=t,c1896=t,c1897=t,c1898=t,c1899=t,c1900=t,c1901=t,c1902=t,c1903=t,c1904=t,c1905=t,c1906=t,c1907=t,c1908=t,c1909=t,c1910=t,c1911=t,c1912=t,c1913=t,c1914=t,c1915=t,c1916=t,c1917=t,c1918=t,c1919=t,c1920=t,c1921=t,c1922=t,c1923=t,c1924=t,c1925=t,c1926=t,c1927=t,c1928=t,c1929=t,c1930=t,c1931=t,c1932=t,c1933=t,c1934=t,c1935=t,c1936=t,c1937=t,c1938=t,c1939=t,c1940=t,c1941=t,c1942=t,c1943=t,c1944=t,c1945=t,c1946=t,c1947=t,c1948=t,c1949=t,c1950=t,c1951=t,c1952=t,c1953=t,c1954=t,c1955=t,c1956=t,c1957=t,c1958=t,c1959=t,c1960=t,c1961=t,c1962=t," - "c1963=t,c1964=t,c1965=t,c1966=t,c1967=t,c1968=t,c1969=t,c1970=t,c1971=t,c1972=t,c1973=t,c1974=t,c1975=t,c1976=t,c1977=t,c1978=t,c1979=t,c1980=t,c1981=t,c1982=t,c1983=t,c1984=t,c1985=t,c1986=t,c1987=t,c1988=t,c1989=t,c1990=t,c1991=t,c1992=t,c1993=t,c1994=t,c1995=t,c1996=t,c1997=t,c1998=t,c1999=t,c2000=t,c2001=t,c2002=t,c2003=t,c2004=t,c2005=t,c2006=t,c2007=t,c2008=t,c2009=t,c2010=t,c2011=t,c2012=t,c2013=t,c2014=t,c2015=t,c2016=t,c2017=t,c2018=t,c2019=t,c2020=t,c2021=t,c2022=t,c2023=t,c2024=t,c2025=t,c2026=t,c2027=t,c2028=t,c2029=t,c2030=t,c2031=t,c2032=t,c2033=t,c2034=t,c2035=t,c2036=t,c2037=t,c2038=t,c2039=t,c2040=t,c2041=t,c2042=t,c2043=t,c2044=t,c2045=t,c2046=t,c2047=t,c2048=t,c2049=t,c2050=t,c2051=t,c2052=t,c2053=t,c2054=t,c2055=t,c2056=t,c2057=t,c2058=t,c2059=t,c2060=t,c2061=t,c2062=t,c2063=t,c2064=t,c2065=t,c2066=t,c2067=t,c2068=t,c2069=t,c2070=t,c2071=t,c2072=t,c2073=t,c2074=t,c2075=t,c2076=t,c2077=t,c2078=t,c2079=t,c2080=t,c2081=t,c2082=t,c2083=t,c2084=t,c2085=t,c2086=t,c2087=t,c2088=t,c2089=t,c2090=t,c2091=t,c2092=t,c2093=t,c2094=t,c2095=t,c2096=t,c2097=t,c2098=t,c2099=t,c2100=t,c2101=t,c2102=t,c2103=t,c2104=t,c2105=t,c2106=t,c2107=t,c2108=t,c2109=t," - "c2110=t,c2111=t,c2112=t,c2113=t,c2114=t,c2115=t,c2116=t,c2117=t,c2118=t,c2119=t,c2120=t,c2121=t,c2122=t,c2123=t,c2124=t,c2125=t,c2126=t,c2127=t,c2128=t,c2129=t,c2130=t,c2131=t,c2132=t,c2133=t,c2134=t,c2135=t,c2136=t,c2137=t,c2138=t,c2139=t,c2140=t,c2141=t,c2142=t,c2143=t,c2144=t,c2145=t,c2146=t,c2147=t,c2148=t,c2149=t,c2150=t,c2151=t,c2152=t,c2153=t,c2154=t,c2155=t,c2156=t,c2157=t,c2158=t,c2159=t,c2160=t,c2161=t,c2162=t,c2163=t,c2164=t,c2165=t,c2166=t,c2167=t,c2168=t,c2169=t,c2170=t,c2171=t,c2172=t,c2173=t,c2174=t,c2175=t,c2176=t,c2177=t,c2178=t,c2179=t,c2180=t,c2181=t,c2182=t,c2183=t,c2184=t,c2185=t,c2186=t,c2187=t,c2188=t,c2189=t,c2190=t,c2191=t,c2192=t,c2193=t,c2194=t,c2195=t,c2196=t,c2197=t,c2198=t,c2199=t,c2200=t,c2201=t,c2202=t,c2203=t,c2204=t,c2205=t,c2206=t,c2207=t,c2208=t,c2209=t,c2210=t,c2211=t,c2212=t,c2213=t,c2214=t,c2215=t,c2216=t,c2217=t,c2218=t,c2219=t,c2220=t,c2221=t,c2222=t,c2223=t,c2224=t,c2225=t,c2226=t,c2227=t,c2228=t,c2229=t,c2230=t,c2231=t,c2232=t,c2233=t,c2234=t,c2235=t,c2236=t,c2237=t,c2238=t,c2239=t,c2240=t,c2241=t,c2242=t,c2243=t,c2244=t,c2245=t,c2246=t,c2247=t,c2248=t,c2249=t,c2250=t,c2251=t,c2252=t,c2253=t,c2254=t,c2255=t,c2256=t," - "c2257=t,c2258=t,c2259=t,c2260=t,c2261=t,c2262=t,c2263=t,c2264=t,c2265=t,c2266=t,c2267=t,c2268=t,c2269=t,c2270=t,c2271=t,c2272=t,c2273=t,c2274=t,c2275=t,c2276=t,c2277=t,c2278=t,c2279=t,c2280=t,c2281=t,c2282=t,c2283=t," - "c2284=t,c2285=t,c2286=t,c2287=t,c2288=t,c2289=t,c2290=t,c2291=t,c2292=t,c2293=t,c2294=t,c2295=t,c2296=t,c2297=t,c2298=t,c2299=t,c2300=t,c2301=t,c2302=t,c2303=t,c2304=t,c2305=t,c2306=t,c2307=t,c2308=t,c2309=t,c2310=t,c2311=t,c2312=t,c2313=t,c2314=t,c2315=t,c2316=t,c2317=t,c2318=t,c2319=t,c2320=t,c2321=t,c2322=t,c2323=t,c2324=t,c2325=t,c2326=t,c2327=t,c2328=t,c2329=t,c2330=t,c2331=t,c2332=t,c2333=t,c2334=t,c2335=t,c2336=t,c2337=t,c2338=t,c2339=t,c2340=t,c2341=t,c2342=t,c2343=t,c2344=t,c2345=t,c2346=t,c2347=t,c2348=t,c2349=t,c2350=t,c2351=t,c2352=t,c2353=t,c2354=t,c2355=t,c2356=t,c2357=t,c2358=t,c2359=t,c2360=t,c2361=t,c2362=t,c2363=t,c2364=t,c2365=t,c2366=t,c2367=t,c2368=t,c2369=t,c2370=t,c2371=t,c2372=t,c2373=t,c2374=t,c2375=t,c2376=t,c2377=t,c2378=t,c2379=t,c2380=t,c2381=t,c2382=t,c2383=t,c2384=t,c2385=t,c2386=t,c2387=t,c2388=t,c2389=t,c2390=t,c2391=t,c2392=t,c2393=t,c2394=t,c2395=t,c2396=t,c2397=t,c2398=t,c2399=t,c2400=t,c2401=t,c2402=t,c2403=t,c2404=t,c2405=t,c2406=t,c2407=t,c2408=t,c2409=t,c2410=t,c2411=t,c2412=t,c2413=t,c2414=t,c2415=t,c2416=t,c2417=t,c2418=t,c2419=t,c2420=t,c2421=t,c2422=t,c2423=t,c2424=t,c2425=t,c2426=t,c2427=t,c2428=t,c2429=t,c2430=t," - "c2431=t,c2432=t,c2433=t,c2434=t,c2435=t,c2436=t,c2437=t,c2438=t,c2439=t,c2440=t,c2441=t,c2442=t,c2443=t,c2444=t,c2445=t,c2446=t,c2447=t,c2448=t,c2449=t,c2450=t,c2451=t,c2452=t,c2453=t,c2454=t,c2455=t,c2456=t,c2457=t,c2458=t,c2459=t,c2460=t,c2461=t,c2462=t,c2463=t,c2464=t,c2465=t,c2466=t,c2467=t,c2468=t,c2469=t,c2470=t,c2471=t,c2472=t,c2473=t,c2474=t,c2475=t,c2476=t,c2477=t,c2478=t,c2479=t,c2480=t,c2481=t,c2482=t,c2483=t,c2484=t,c2485=t,c2486=t,c2487=t,c2488=t,c2489=t,c2490=t,c2491=t,c2492=t,c2493=t,c2494=t,c2495=t,c2496=t,c2497=t,c2498=t,c2499=t,c2500=t,c2501=t,c2502=t,c2503=t,c2504=t,c2505=t,c2506=t,c2507=t,c2508=t,c2509=t,c2510=t,c2511=t,c2512=t,c2513=t,c2514=t,c2515=t,c2516=t,c2517=t,c2518=t,c2519=t,c2520=t,c2521=t,c2522=t,c2523=t,c2524=t,c2525=t,c2526=t,c2527=t,c2528=t,c2529=t,c2530=t,c2531=t,c2532=t,c2533=t,c2534=t,c2535=t,c2536=t,c2537=t,c2538=t,c2539=t,c2540=t,c2541=t,c2542=t,c2543=t,c2544=t,c2545=t,c2546=t,c2547=t,c2548=t,c2549=t,c2550=t,c2551=t,c2552=t,c2553=t,c2554=t,c2555=t,c2556=t,c2557=t,c2558=t,c2559=t,c2560=t,c2561=t,c2562=t,c2563=t,c2564=t,c2565=t,c2566=t,c2567=t,c2568=t,c2569=t,c2570=t,c2571=t,c2572=t,c2573=t,c2574=t,c2575=t,c2576=t,c2577=t," - "c2578=t,c2579=t,c2580=t,c2581=t,c2582=t,c2583=t,c2584=t,c2585=t,c2586=t,c2587=t,c2588=t,c2589=t,c2590=t,c2591=t,c2592=t,c2593=t,c2594=t,c2595=t,c2596=t,c2597=t,c2598=t,c2599=t,c2600=t,c2601=t,c2602=t,c2603=t,c2604=t,c2605=t,c2606=t,c2607=t,c2608=t,c2609=t,c2610=t,c2611=t,c2612=t,c2613=t,c2614=t,c2615=t,c2616=t,c2617=t,c2618=t,c2619=t,c2620=t,c2621=t,c2622=t,c2623=t,c2624=t,c2625=t,c2626=t,c2627=t,c2628=t,c2629=t,c2630=t,c2631=t,c2632=t,c2633=t,c2634=t,c2635=t,c2636=t,c2637=t,c2638=t,c2639=t,c2640=t,c2641=t,c2642=t,c2643=t,c2644=t,c2645=t,c2646=t,c2647=t,c2648=t,c2649=t,c2650=t,c2651=t,c2652=t,c2653=t,c2654=t,c2655=t,c2656=t,c2657=t,c2658=t,c2659=t,c2660=t,c2661=t,c2662=t,c2663=t,c2664=t,c2665=t,c2666=t,c2667=t,c2668=t,c2669=t,c2670=t,c2671=t,c2672=t,c2673=t,c2674=t,c2675=t,c2676=t,c2677=t,c2678=t,c2679=t,c2680=t,c2681=t,c2682=t,c2683=t,c2684=t,c2685=t,c2686=t,c2687=t,c2688=t,c2689=t,c2690=t,c2691=t,c2692=t,c2693=t,c2694=t,c2695=t,c2696=t,c2697=t,c2698=t,c2699=t,c2700=t,c2701=t,c2702=t,c2703=t,c2704=t,c2705=t,c2706=t,c2707=t,c2708=t,c2709=t,c2710=t,c2711=t,c2712=t,c2713=t,c2714=t,c2715=t,c2716=t,c2717=t,c2718=t,c2719=t,c2720=t,c2721=t,c2722=t,c2723=t,c2724=t," - "c2725=t,c2726=t,c2727=t,c2728=t,c2729=t,c2730=t,c2731=t,c2732=t,c2733=t,c2734=t,c2735=t,c2736=t,c2737=t,c2738=t,c2739=t,c2740=t,c2741=t,c2742=t,c2743=t,c2744=t,c2745=t,c2746=t,c2747=t,c2748=t,c2749=t,c2750=t,c2751=t,c2752=t,c2753=t,c2754=t,c2755=t,c2756=t,c2757=t,c2758=t,c2759=t,c2760=t,c2761=t,c2762=t,c2763=t,c2764=t,c2765=t,c2766=t,c2767=t,c2768=t,c2769=t,c2770=t,c2771=t,c2772=t,c2773=t,c2774=t,c2775=t,c2776=t,c2777=t,c2778=t,c2779=t,c2780=t,c2781=t,c2782=t,c2783=t,c2784=t,c2785=t,c2786=t,c2787=t,c2788=t,c2789=t,c2790=t,c2791=t,c2792=t,c2793=t,c2794=t,c2795=t,c2796=t,c2797=t,c2798=t,c2799=t,c2800=t,c2801=t,c2802=t,c2803=t,c2804=t,c2805=t,c2806=t,c2807=t,c2808=t,c2809=t,c2810=t,c2811=t,c2812=t,c2813=t,c2814=t,c2815=t,c2816=t,c2817=t,c2818=t,c2819=t,c2820=t,c2821=t,c2822=t,c2823=t,c2824=t,c2825=t,c2826=t,c2827=t,c2828=t,c2829=t,c2830=t,c2831=t,c2832=t,c2833=t,c2834=t,c2835=t,c2836=t,c2837=t,c2838=t,c2839=t,c2840=t,c2841=t,c2842=t,c2843=t,c2844=t,c2845=t,c2846=t,c2847=t,c2848=t,c2849=t,c2850=t,c2851=t,c2852=t,c2853=t,c2854=t,c2855=t,c2856=t,c2857=t,c2858=t,c2859=t,c2860=t,c2861=t,c2862=t,c2863=t,c2864=t,c2865=t,c2866=t,c2867=t,c2868=t,c2869=t,c2870=t,c2871=t," - "c2872=t,c2873=t,c2874=t,c2875=t,c2876=t,c2877=t,c2878=t,c2879=t,c2880=t,c2881=t,c2882=t,c2883=t,c2884=t,c2885=t,c2886=t,c2887=t,c2888=t,c2889=t,c2890=t,c2891=t,c2892=t,c2893=t,c2894=t,c2895=t,c2896=t,c2897=t,c2898=t,c2899=t,c2900=t,c2901=t,c2902=t,c2903=t,c2904=t,c2905=t,c2906=t,c2907=t,c2908=t,c2909=t,c2910=t,c2911=t,c2912=t,c2913=t,c2914=t,c2915=t,c2916=t,c2917=t,c2918=t,c2919=t,c2920=t,c2921=t,c2922=t,c2923=t,c2924=t,c2925=t,c2926=t,c2927=t,c2928=t,c2929=t,c2930=t,c2931=t,c2932=t,c2933=t,c2934=t,c2935=t,c2936=t,c2937=t,c2938=t,c2939=t,c2940=t,c2941=t,c2942=t,c2943=t,c2944=t,c2945=t,c2946=t,c2947=t,c2948=t,c2949=t,c2950=t,c2951=t,c2952=t,c2953=t,c2954=t,c2955=t,c2956=t,c2957=t,c2958=t,c2959=t,c2960=t,c2961=t,c2962=t,c2963=t,c2964=t,c2965=t,c2966=t,c2967=t,c2968=t,c2969=t,c2970=t,c2971=t,c2972=t,c2973=t,c2974=t,c2975=t,c2976=t,c2977=t,c2978=t,c2979=t,c2980=t,c2981=t,c2982=t,c2983=t,c2984=t,c2985=t,c2986=t,c2987=t,c2988=t,c2989=t,c2990=t,c2991=t,c2992=t,c2993=t,c2994=t,c2995=t,c2996=t,c2997=t,c2998=t,c2999=t,c3000=t,c3001=t,c3002=t,c3003=t,c3004=t,c3005=t,c3006=t,c3007=t,c3008=t,c3009=t,c3010=t,c3011=t,c3012=t,c3013=t,c3014=t,c3015=t,c3016=t,c3017=t,c3018=t," - "c3019=t,c3020=t,c3021=t,c3022=t,c3023=t,c3024=t,c3025=t,c3026=t,c3027=t,c3028=t,c3029=t,c3030=t,c3031=t,c3032=t,c3033=t,c3034=t,c3035=t,c3036=t,c3037=t,c3038=t,c3039=t,c3040=t,c3041=t,c3042=t,c3043=t,c3044=t,c3045=t,c3046=t,c3047=t,c3048=t,c3049=t,c3050=t,c3051=t,c3052=t,c3053=t,c3054=t,c3055=t,c3056=t,c3057=t,c3058=t,c3059=t,c3060=t,c3061=t,c3062=t,c3063=t,c3064=t,c3065=t,c3066=t,c3067=t,c3068=t,c3069=t,c3070=t,c3071=t,c3072=t,c3073=t,c3074=t,c3075=t,c3076=t,c3077=t,c3078=t,c3079=t,c3080=t,c3081=t,c3082=t,c3083=t,c3084=t,c3085=t,c3086=t,c3087=t,c3088=t,c3089=t,c3090=t,c3091=t,c3092=t,c3093=t,c3094=t,c3095=t,c3096=t,c3097=t,c3098=t,c3099=t,c3100=t,c3101=t,c3102=t,c3103=t,c3104=t,c3105=t,c3106=t,c3107=t,c3108=t,c3109=t,c3110=t,c3111=t,c3112=t,c3113=t,c3114=t,c3115=t,c3116=t,c3117=t,c3118=t,c3119=t,c3120=t,c3121=t,c3122=t,c3123=t,c3124=t,c3125=t,c3126=t,c3127=t,c3128=t,c3129=t,c3130=t,c3131=t,c3132=t,c3133=t,c3134=t,c3135=t,c3136=t,c3137=t,c3138=t,c3139=t,c3140=t,c3141=t,c3142=t,c3143=t,c3144=t,c3145=t,c3146=t,c3147=t,c3148=t,c3149=t,c3150=t,c3151=t,c3152=t,c3153=t,c3154=t,c3155=t,c3156=t,c3157=t,c3158=t,c3159=t,c3160=t,c3161=t,c3162=t,c3163=t,c3164=t,c3165=t," - "c3166=t,c3167=t,c3168=t,c3169=t,c3170=t,c3171=t,c3172=t,c3173=t,c3174=t,c3175=t,c3176=t,c3177=t,c3178=t,c3179=t,c3180=t,c3181=t,c3182=t,c3183=t,c3184=t,c3185=t,c3186=t,c3187=t,c3188=t,c3189=t,c3190=t,c3191=t,c3192=t,c3193=t,c3194=t,c3195=t,c3196=t,c3197=t,c3198=t,c3199=t,c3200=t,c3201=t,c3202=t,c3203=t,c3204=t,c3205=t,c3206=t,c3207=t,c3208=t,c3209=t,c3210=t,c3211=t,c3212=t,c3213=t,c3214=t,c3215=t,c3216=t,c3217=t,c3218=t,c3219=t,c3220=t,c3221=t,c3222=t,c3223=t,c3224=t,c3225=t,c3226=t,c3227=t,c3228=t,c3229=t,c3230=t,c3231=t,c3232=t,c3233=t,c3234=t,c3235=t,c3236=t,c3237=t,c3238=t,c3239=t,c3240=t,c3241=t,c3242=t,c3243=t,c3244=t,c3245=t,c3246=t,c3247=t,c3248=t,c3249=t,c3250=t,c3251=t,c3252=t,c3253=t,c3254=t,c3255=t,c3256=t,c3257=t,c3258=t,c3259=t,c3260=t,c3261=t,c3262=t,c3263=t,c3264=t,c3265=t,c3266=t,c3267=t,c3268=t,c3269=t,c3270=t,c3271=t,c3272=t,c3273=t,c3274=t,c3275=t,c3276=t,c3277=t,c3278=t,c3279=t,c3280=t,c3281=t,c3282=t,c3283=t,c3284=t,c3285=t,c3286=t,c3287=t,c3288=t,c3289=t,c3290=t,c3291=t,c3292=t,c3293=t,c3294=t,c3295=t,c3296=t,c3297=t,c3298=t,c3299=t,c3300=t,c3301=t,c3302=t,c3303=t,c3304=t,c3305=t,c3306=t,c3307=t,c3308=t,c3309=t,c3310=t,c3311=t,c3312=t," - "c3313=t,c3314=t,c3315=t,c3316=t,c3317=t,c3318=t,c3319=t,c3320=t,c3321=t,c3322=t,c3323=t,c3324=t,c3325=t,c3326=t,c3327=t,c3328=t,c3329=t,c3330=t,c3331=t,c3332=t,c3333=t,c3334=t,c3335=t,c3336=t,c3337=t,c3338=t,c3339=t,c3340=t,c3341=t,c3342=t,c3343=t,c3344=t,c3345=t,c3346=t,c3347=t,c3348=t,c3349=t,c3350=t,c3351=t,c3352=t,c3353=t,c3354=t,c3355=t,c3356=t,c3357=t,c3358=t,c3359=t,c3360=t,c3361=t,c3362=t,c3363=t,c3364=t,c3365=t,c3366=t,c3367=t,c3368=t,c3369=t,c3370=t,c3371=t,c3372=t,c3373=t,c3374=t,c3375=t,c3376=t,c3377=t,c3378=t,c3379=t,c3380=t,c3381=t,c3382=t,c3383=t,c3384=t,c3385=t,c3386=t,c3387=t,c3388=t,c3389=t,c3390=t,c3391=t,c3392=t,c3393=t,c3394=t,c3395=t,c3396=t,c3397=t,c3398=t,c3399=t,c3400=t,c3401=t,c3402=t,c3403=t,c3404=t,c3405=t,c3406=t,c3407=t,c3408=t,c3409=t,c3410=t,c3411=t,c3412=t,c3413=t,c3414=t,c3415=t,c3416=t,c3417=t,c3418=t,c3419=t,c3420=t,c3421=t,c3422=t,c3423=t,c3424=t,c3425=t,c3426=t,c3427=t,c3428=t,c3429=t,c3430=t,c3431=t,c3432=t,c3433=t,c3434=t,c3435=t,c3436=t,c3437=t,c3438=t,c3439=t,c3440=t,c3441=t,c3442=t,c3443=t,c3444=t,c3445=t,c3446=t,c3447=t,c3448=t,c3449=t,c3450=t,c3451=t,c3452=t,c3453=t,c3454=t,c3455=t,c3456=t,c3457=t,c3458=t,c3459=t," - "c3460=t,c3461=t,c3462=t,c3463=t,c3464=t,c3465=t,c3466=t,c3467=t,c3468=t,c3469=t,c3470=t,c3471=t,c3472=t,c3473=t,c3474=t,c3475=t,c3476=t,c3477=t,c3478=t,c3479=t,c3480=t,c3481=t,c3482=t,c3483=t,c3484=t,c3485=t,c3486=t,c3487=t,c3488=t,c3489=t,c3490=t,c3491=t,c3492=t,c3493=t,c3494=t,c3495=t,c3496=t,c3497=t,c3498=t,c3499=t,c3500=t,c3501=t,c3502=t,c3503=t,c3504=t,c3505=t,c3506=t,c3507=t,c3508=t,c3509=t,c3510=t,c3511=t,c3512=t,c3513=t," - "c3514=t,c3515=t,c3516=t,c3517=t,c3518=t,c3519=t,c3520=t,c3521=t,c3522=t,c3523=t,c3524=t,c3525=t,c3526=t,c3527=t,c3528=t,c3529=t,c3530=t,c3531=t,c3532=t,c3533=t,c3534=t,c3535=t,c3536=t,c3537=t,c3538=t,c3539=t,c3540=t,c3541=t,c3542=t,c3543=t,c3544=t,c3545=t,c3546=t,c3547=t,c3548=t,c3549=t,c3550=t,c3551=t,c3552=t,c3553=t,c3554=t,c3555=t,c3556=t,c3557=t,c3558=t,c3559=t,c3560=t,c3561=t,c3562=t,c3563=t,c3564=t,c3565=t,c3566=t,c3567=t,c3568=t,c3569=t,c3570=t,c3571=t,c3572=t,c3573=t,c3574=t,c3575=t,c3576=t,c3577=t,c3578=t,c3579=t,c3580=t,c3581=t,c3582=t,c3583=t,c3584=t,c3585=t,c3586=t,c3587=t,c3588=t,c3589=t,c3590=t,c3591=t,c3592=t,c3593=t,c3594=t,c3595=t,c3596=t,c3597=t,c3598=t,c3599=t,c3600=t,c3601=t,c3602=t,c3603=t,c3604=t,c3605=t,c3606=t,c3607=t,c3608=t,c3609=t,c3610=t,c3611=t,c3612=t,c3613=t,c3614=t,c3615=t,c3616=t,c3617=t,c3618=t,c3619=t,c3620=t,c3621=t,c3622=t,c3623=t,c3624=t,c3625=t,c3626=t,c3627=t,c3628=t,c3629=t,c3630=t,c3631=t,c3632=t,c3633=t,c3634=t,c3635=t,c3636=t,c3637=t,c3638=t,c3639=t,c3640=t,c3641=t,c3642=t,c3643=t,c3644=t,c3645=t,c3646=t,c3647=t,c3648=t,c3649=t,c3650=t,c3651=t,c3652=t,c3653=t,c3654=t,c3655=t,c3656=t,c3657=t,c3658=t,c3659=t,c3660=t," - "c3661=t,c3662=t,c3663=t,c3664=t,c3665=t,c3666=t,c3667=t,c3668=t,c3669=t,c3670=t,c3671=t,c3672=t,c3673=t,c3674=t,c3675=t,c3676=t,c3677=t,c3678=t,c3679=t,c3680=t,c3681=t,c3682=t,c3683=t,c3684=t,c3685=t,c3686=t,c3687=t,c3688=t,c3689=t,c3690=t,c3691=t,c3692=t,c3693=t,c3694=t,c3695=t,c3696=t,c3697=t,c3698=t,c3699=t,c3700=t,c3701=t,c3702=t,c3703=t,c3704=t,c3705=t,c3706=t,c3707=t,c3708=t,c3709=t,c3710=t,c3711=t,c3712=t,c3713=t,c3714=t,c3715=t,c3716=t,c3717=t,c3718=t,c3719=t,c3720=t,c3721=t,c3722=t,c3723=t,c3724=t,c3725=t,c3726=t,c3727=t,c3728=t,c3729=t,c3730=t,c3731=t,c3732=t,c3733=t,c3734=t,c3735=t,c3736=t,c3737=t,c3738=t,c3739=t,c3740=t,c3741=t,c3742=t,c3743=t,c3744=t,c3745=t,c3746=t,c3747=t,c3748=t,c3749=t,c3750=t,c3751=t,c3752=t,c3753=t,c3754=t,c3755=t,c3756=t,c3757=t,c3758=t,c3759=t,c3760=t,c3761=t,c3762=t,c3763=t,c3764=t,c3765=t,c3766=t,c3767=t,c3768=t,c3769=t,c3770=t,c3771=t,c3772=t,c3773=t,c3774=t,c3775=t,c3776=t,c3777=t,c3778=t,c3779=t,c3780=t,c3781=t,c3782=t,c3783=t,c3784=t,c3785=t,c3786=t,c3787=t,c3788=t,c3789=t,c3790=t,c3791=t,c3792=t,c3793=t,c3794=t,c3795=t,c3796=t,c3797=t,c3798=t,c3799=t,c3800=t,c3801=t,c3802=t,c3803=t,c3804=t,c3805=t,c3806=t,c3807=t," - "c3808=t,c3809=t,c3810=t,c3811=t,c3812=t,c3813=t,c3814=t,c3815=t,c3816=t,c3817=t,c3818=t,c3819=t,c3820=t,c3821=t,c3822=t,c3823=t,c3824=t,c3825=t,c3826=t,c3827=t,c3828=t,c3829=t,c3830=t,c3831=t,c3832=t,c3833=t,c3834=t,c3835=t,c3836=t,c3837=t,c3838=t,c3839=t,c3840=t,c3841=t,c3842=t,c3843=t,c3844=t,c3845=t,c3846=t,c3847=t,c3848=t,c3849=t,c3850=t,c3851=t,c3852=t,c3853=t,c3854=t,c3855=t,c3856=t,c3857=t,c3858=t,c3859=t,c3860=t,c3861=t,c3862=t,c3863=t,c3864=t,c3865=t,c3866=t,c3867=t,c3868=t,c3869=t,c3870=t,c3871=t,c3872=t,c3873=t,c3874=t,c3875=t,c3876=t,c3877=t,c3878=t,c3879=t,c3880=t,c3881=t,c3882=t,c3883=t,c3884=t,c3885=t,c3886=t,c3887=t,c3888=t,c3889=t,c3890=t,c3891=t,c3892=t,c3893=t,c3894=t,c3895=t,c3896=t,c3897=t,c3898=t,c3899=t,c3900=t,c3901=t,c3902=t,c3903=t,c3904=t,c3905=t,c3906=t,c3907=t,c3908=t,c3909=t,c3910=t,c3911=t,c3912=t,c3913=t,c3914=t,c3915=t,c3916=t,c3917=t,c3918=t,c3919=t,c3920=t,c3921=t,c3922=t,c3923=t,c3924=t,c3925=t,c3926=t,c3927=t,c3928=t,c3929=t,c3930=t,c3931=t,c3932=t,c3933=t,c3934=t,c3935=t,c3936=t,c3937=t,c3938=t,c3939=t,c3940=t,c3941=t,c3942=t,c3943=t,c3944=t,c3945=t,c3946=t,c3947=t,c3948=t,c3949=t,c3950=t,c3951=t,c3952=t,c3953=t,c3954=t," - "c3955=t,c3956=t,c3957=t,c3958=t,c3959=t,c3960=t,c3961=t,c3962=t,c3963=t,c3964=t,c3965=t,c3966=t,c3967=t,c3968=t,c3969=t,c3970=t,c3971=t,c3972=t,c3973=t,c3974=t,c3975=t,c3976=t,c3977=t,c3978=t,c3979=t,c3980=t,c3981=t,c3982=t,c3983=t,c3984=t,c3985=t,c3986=t,c3987=t,c3988=t,c3989=t,c3990=t,c3991=t,c3992=t,c3993=t,c3994=t,c3995=t,c3996=t,c3997=t,c3998=t,c3999=t,c4000=t,c4001=t,c4002=t,c4003=t,c4004=t,c4005=t,c4006=t,c4007=t,c4008=t,c4009=t,c4010=t,c4011=t,c4012=t,c4013=t,c4014=t,c4015=t,c4016=t,c4017=t,c4018=t,c4019=t,c4020=t,c4021=t,c4022=t,c4023=t,c4024=t,c4025=t,c4026=t,c4027=t,c4028=t,c4029=t,c4030=t,c4031=t,c4032=t,c4033=t,c4034=t,c4035=t,c4036=t,c4037=t,c4038=t,c4039=t,c4040=t,c4041=t,c4042=t,c4043=t,c4044=t,c4045=t,c4046=t,c4047=t,c4048=t,c4049=t,c4050=t,c4051=t,c4052=t,c4053=t,c4054=t,c4055=t,c4056=t,c4057=t,c4058=t,c4059=t,c4060=t,c4061=t,c4062=t,c4063=t,c4064=t,c4065=t,c4066=t,c4067=t,c4068=t,c4069=t,c4070=t,c4071=t,c4072=t,c4073=t,c4074=t,c4075=t,c4076=t,c4077=t,c4078=t,c4079=t,c4080=t,c4081=t,c4082=t,c4083=t,c4084=t,c4085=t,c4086=t,c4087=t,c4088=t,c4089=t,c4090=t,c4091=t,c4092=t,c4093=t 1626006833640000000" - }; + "spgwgvldxv,id=spgwgvldxv_1,t0=f " + "c0=t,c1=t,c2=t,c3=t,c4=t,c5=t,c6=t,c7=t,c8=t,c9=t,c10=t,c11=t,c12=t,c13=t,c14=t,c15=t,c16=t,c17=t,c18=t,c19=t," + "c20=t,c21=t,c22=t,c23=t,c24=t,c25=t,c26=t,c27=t,c28=t,c29=t,c30=t,c31=t,c32=t,c33=t,c34=t,c35=t,c36=t,c37=t,c38=" + "t,c39=t,c40=t,c41=t,c42=t,c43=t,c44=t,c45=t,c46=t,c47=t,c48=t,c49=t,c50=t,c51=t,c52=t,c53=t,c54=t,c55=t,c56=t," + "c57=t,c58=t,c59=t,c60=t,c61=t,c62=t,c63=t,c64=t,c65=t,c66=t,c67=t,c68=t,c69=t,c70=t,c71=t,c72=t,c73=t,c74=t,c75=" + "t,c76=t,c77=t,c78=t,c79=t,c80=t,c81=t,c82=t,c83=t,c84=t,c85=t,c86=t,c87=t,c88=t,c89=t,c90=t,c91=t,c92=t,c93=t," + "c94=t,c95=t,c96=t,c97=t,c98=t,c99=t,c100=t," + "c101=t,c102=t,c103=t,c104=t,c105=t,c106=t,c107=t,c108=t,c109=t,c110=t,c111=t,c112=t,c113=t,c114=t,c115=t,c116=t," + "c117=t,c118=t,c119=t,c120=t,c121=t,c122=t,c123=t,c124=t,c125=t,c126=t,c127=t,c128=t,c129=t,c130=t,c131=t,c132=t," + "c133=t,c134=t,c135=t,c136=t,c137=t,c138=t,c139=t,c140=t,c141=t,c142=t,c143=t,c144=t,c145=t,c146=t,c147=t,c148=t," + "c149=t,c150=t,c151=t,c152=t,c153=t,c154=t,c155=t,c156=t,c157=t,c158=t,c159=t,c160=t,c161=t,c162=t,c163=t,c164=t," + "c165=t,c166=t,c167=t,c168=t,c169=t,c170=t,c171=t,c172=t,c173=t,c174=t,c175=t,c176=t,c177=t,c178=t,c179=t,c180=t," + "c181=t,c182=t,c183=t,c184=t,c185=t,c186=t,c187=t,c188=t,c189=t," + "c190=t,c191=t,c192=t,c193=t,c194=t,c195=t,c196=t,c197=t,c198=t,c199=t,c200=t,c201=t,c202=t,c203=t,c204=t,c205=t," + "c206=t,c207=t,c208=t,c209=t,c210=t,c211=t,c212=t,c213=t,c214=t,c215=t,c216=t,c217=t,c218=t,c219=t,c220=t,c221=t," + "c222=t,c223=t,c224=t,c225=t,c226=t,c227=t,c228=t,c229=t,c230=t,c231=t,c232=t,c233=t,c234=t,c235=t,c236=t,c237=t," + "c238=t,c239=t,c240=t,c241=t,c242=t,c243=t,c244=t,c245=t,c246=t,c247=t,c248=t,c249=t,c250=t,c251=t,c252=t,c253=t," + "c254=t,c255=t,c256=t,c257=t,c258=t,c259=t,c260=t,c261=t,c262=t,c263=t,c264=t,c265=t,c266=t,c267=t,c268=t,c269=t," + "c270=t,c271=t,c272=t,c273=t,c274=t,c275=t,c276=t,c277=t,c278=t," + "c279=t,c280=t,c281=t,c282=t,c283=t,c284=t,c285=t,c286=t,c287=t,c288=t,c289=t,c290=t,c291=t,c292=t,c293=t,c294=t," + "c295=t,c296=t,c297=t,c298=t,c299=t,c300=t,c301=t,c302=t,c303=t,c304=t,c305=t,c306=t,c307=t,c308=t,c309=t,c310=t," + "c311=t,c312=t,c313=t,c314=t,c315=t,c316=t,c317=t,c318=t,c319=t,c320=t,c321=t,c322=t,c323=t,c324=t,c325=t,c326=t," + "c327=t,c328=t,c329=t,c330=t,c331=t,c332=t,c333=t,c334=t,c335=t,c336=t,c337=t,c338=t,c339=t,c340=t,c341=t,c342=t," + "c343=t,c344=t,c345=t,c346=t,c347=t,c348=t,c349=t,c350=t,c351=t,c352=t,c353=t,c354=t,c355=t,c356=t,c357=t,c358=t," + "c359=t,c360=t,c361=t,c362=t,c363=t,c364=t,c365=t,c366=t,c367=t,c368=t,c369=t,c370=t,c371=t,c372=t,c373=t,c374=t," + "c375=t,c376=t,c377=t,c378=t,c379=t,c380=t,c381=t,c382=t,c383=t,c384=t,c385=t,c386=t,c387=t,c388=t,c389=t,c390=t," + "c391=t,c392=t,c393=t,c394=t,c395=t,c396=t,c397=t,c398=t,c399=t,c400=t,c401=t,c402=t,c403=t,c404=t,c405=t,c406=t," + "c407=t,c408=t,c409=t,c410=t,c411=t,c412=t,c413=t,c414=t,c415=t,c416=t,c417=t,c418=t,c419=t,c420=t,c421=t,c422=t," + "c423=t,c424=t,c425=t,c426=t,c427=t,c428=t,c429=t,c430=t,c431=t,c432=t,c433=t,c434=t,c435=t,c436=t,c437=t,c438=t," + "c439=t,c440=t,c441=t,c442=t,c443=t,c444=t,c445=t,c446=t," + "c447=t,c448=t,c449=t,c450=t,c451=t,c452=t,c453=t,c454=t,c455=t,c456=t,c457=t,c458=t,c459=t,c460=t,c461=t,c462=t," + "c463=t,c464=t,c465=t,c466=t,c467=t,c468=t,c469=t,c470=t,c471=t,c472=t,c473=t,c474=t,c475=t,c476=t,c477=t,c478=t," + "c479=t,c480=t,c481=t,c482=t,c483=t,c484=t,c485=t,c486=t,c487=t,c488=t,c489=t,c490=t,c491=t,c492=t,c493=t,c494=t," + "c495=t,c496=t,c497=t,c498=t,c499=t,c500=t,c501=t,c502=t,c503=t,c504=t,c505=t,c506=t,c507=t,c508=t,c509=t,c510=t," + "c511=t,c512=t,c513=t,c514=t,c515=t,c516=t,c517=t,c518=t,c519=t,c520=t,c521=t,c522=t,c523=t,c524=t,c525=t,c526=t," + "c527=t,c528=t,c529=t,c530=t,c531=t,c532=t,c533=t,c534=t,c535=t,c536=t,c537=t,c538=t,c539=t,c540=t,c541=t,c542=t," + "c543=t,c544=t,c545=t,c546=t,c547=t,c548=t,c549=t,c550=t,c551=t,c552=t,c553=t,c554=t,c555=t,c556=t,c557=t,c558=t," + "c559=t,c560=t,c561=t,c562=t,c563=t,c564=t,c565=t,c566=t,c567=t,c568=t,c569=t,c570=t,c571=t,c572=t,c573=t,c574=t," + "c575=t,c576=t,c577=t,c578=t,c579=t,c580=t,c581=t,c582=t,c583=t,c584=t,c585=t,c586=t,c587=t,c588=t,c589=t,c590=t," + "c591=t,c592=t,c593=t,c594=t,c595=t,c596=t,c597=t,c598=t,c599=t,c600=t,c601=t,c602=t,c603=t,c604=t,c605=t,c606=t," + "c607=t,c608=t,c609=t,c610=t,c611=t,c612=t,c613=t,c614=t," + "c615=t,c616=t,c617=t,c618=t,c619=t,c620=t,c621=t,c622=t,c623=t,c624=t,c625=t,c626=t,c627=t,c628=t,c629=t,c630=t," + "c631=t,c632=t,c633=t,c634=t,c635=t,c636=t,c637=t,c638=t,c639=t,c640=t,c641=t,c642=t,c643=t,c644=t,c645=t,c646=t," + "c647=t,c648=t,c649=t,c650=t,c651=t,c652=t,c653=t,c654=t,c655=t,c656=t,c657=t,c658=t,c659=t,c660=t,c661=t,c662=t," + "c663=t,c664=t,c665=t,c666=t,c667=t,c668=t,c669=t,c670=t,c671=t,c672=t,c673=t,c674=t,c675=t,c676=t,c677=t,c678=t," + "c679=t,c680=t,c681=t,c682=t,c683=t,c684=t,c685=t,c686=t,c687=t,c688=t,c689=t,c690=t,c691=t,c692=t,c693=t,c694=t," + "c695=t,c696=t,c697=t,c698=t,c699=t,c700=t,c701=t,c702=t,c703=t,c704=t,c705=t,c706=t,c707=t,c708=t,c709=t,c710=t," + "c711=t,c712=t,c713=t,c714=t,c715=t,c716=t,c717=t,c718=t,c719=t,c720=t,c721=t,c722=t,c723=t,c724=t,c725=t,c726=t," + "c727=t,c728=t,c729=t,c730=t,c731=t,c732=t,c733=t,c734=t,c735=t,c736=t,c737=t,c738=t,c739=t,c740=t,c741=t,c742=t," + "c743=t,c744=t,c745=t,c746=t,c747=t,c748=t,c749=t,c750=t,c751=t,c752=t,c753=t,c754=t,c755=t,c756=t,c757=t,c758=t," + "c759=t,c760=t,c761=t,c762=t,c763=t,c764=t,c765=t,c766=t,c767=t,c768=t,c769=t,c770=t,c771=t,c772=t,c773=t,c774=t," + "c775=t,c776=t,c777=t,c778=t,c779=t,c780=t,c781=t,c782=t," + "c783=t,c784=t,c785=t,c786=t,c787=t,c788=t,c789=t,c790=t,c791=t,c792=t,c793=t,c794=t,c795=t,c796=t,c797=t,c798=t," + "c799=t,c800=t,c801=t,c802=t,c803=t,c804=t,c805=t,c806=t,c807=t,c808=t,c809=t,c810=t,c811=t,c812=t,c813=t," + "c814=t,c815=t,c816=t,c817=t,c818=t,c819=t,c820=t,c821=t,c822=t,c823=t,c824=t,c825=t,c826=t,c827=t,c828=t,c829=t," + "c830=t,c831=t,c832=t,c833=t,c834=t,c835=t,c836=t,c837=t,c838=t,c839=t,c840=t,c841=t,c842=t,c843=t,c844=t,c845=t," + "c846=t,c847=t,c848=t,c849=t,c850=t,c851=t,c852=t,c853=t,c854=t,c855=t,c856=t,c857=t,c858=t,c859=t,c860=t,c861=t," + "c862=t," + "c863=t,c864=t,c865=t,c866=t,c867=t,c868=t,c869=t,c870=t,c871=t,c872=t,c873=t,c874=t,c875=t,c876=t,c877=t,c878=t," + "c879=t,c880=t,c881=t,c882=t,c883=t,c884=t,c885=t,c886=t,c887=t,c888=t,c889=t,c890=t,c891=t,c892=t,c893=t,c894=t," + "c895=t,c896=t,c897=t,c898=t,c899=t,c900=t,c901=t,c902=t,c903=t,c904=t,c905=t,c906=t,c907=t,c908=t,c909=t,c910=t," + "c911=t,c912=t,c913=t,c914=t,c915=t,c916=t,c917=t,c918=t,c919=t,c920=t,c921=t,c922=t,c923=t,c924=t,c925=t,c926=t," + "c927=t,c928=t,c929=t,c930=t,c931=t,c932=t,c933=t,c934=t,c935=t,c936=t,c937=t,c938=t,c939=t,c940=t,c941=t,c942=t," + "c943=t,c944=t,c945=t,c946=t,c947=t,c948=t,c949=t,c950=t,c951=t,c952=t,c953=t,c954=t,c955=t,c956=t,c957=t,c958=t," + "c959=t,c960=t,c961=t,c962=t,c963=t,c964=t,c965=t,c966=t,c967=t,c968=t,c969=t,c970=t,c971=t,c972=t,c973=t,c974=t," + "c975=t,c976=t,c977=t,c978=t,c979=t,c980=t,c981=t,c982=t,c983=t,c984=t,c985=t,c986=t,c987=t,c988=t,c989=t,c990=t," + "c991=t,c992=t,c993=t,c994=t,c995=t,c996=t,c997=t,c998=t,c999=t,c1000=t,c1001=t,c1002=t,c1003=t,c1004=t,c1005=t," + "c1006=t,c1007=t,c1008=t,c1009=t,c1010=t,c1011=t,c1012=t,c1013=t,c1014=t,c1015=t,c1016=t,c1017=t,c1018=t,c1019=t," + "c1020=t,c1021=t,c1022=t,c1023=t,c1024=t,c1025=t,c1026=t," + "c1027=t,c1028=t,c1029=t,c1030=t,c1031=t,c1032=t,c1033=t,c1034=t,c1035=t,c1036=t,c1037=t,c1038=t,c1039=t,c1040=t," + "c1041=t,c1042=t,c1043=t,c1044=t,c1045=t,c1046=t,c1047=t,c1048=t,c1049=t,c1050=t,c1051=t,c1052=t,c1053=t,c1054=t," + "c1055=t,c1056=t,c1057=t,c1058=t,c1059=t,c1060=t,c1061=t,c1062=t,c1063=t,c1064=t,c1065=t,c1066=t,c1067=t,c1068=t," + "c1069=t,c1070=t,c1071=t,c1072=t,c1073=t,c1074=t,c1075=t,c1076=t,c1077=t,c1078=t,c1079=t,c1080=t,c1081=t,c1082=t," + "c1083=t,c1084=t,c1085=t,c1086=t,c1087=t,c1088=t,c1089=t,c1090=t,c1091=t,c1092=t,c1093=t,c1094=t,c1095=t,c1096=t," + "c1097=t,c1098=t,c1099=t,c1100=t,c1101=t,c1102=t,c1103=t,c1104=t,c1105=t,c1106=t,c1107=t,c1108=t,c1109=t,c1110=t," + "c1111=t,c1112=t,c1113=t,c1114=t,c1115=t,c1116=t,c1117=t,c1118=t,c1119=t,c1120=t,c1121=t,c1122=t,c1123=t,c1124=t," + "c1125=t,c1126=t,c1127=t,c1128=t,c1129=t,c1130=t,c1131=t,c1132=t,c1133=t,c1134=t,c1135=t,c1136=t,c1137=t,c1138=t," + "c1139=t,c1140=t,c1141=t,c1142=t,c1143=t,c1144=t,c1145=t,c1146=t,c1147=t,c1148=t,c1149=t,c1150=t,c1151=t,c1152=t," + "c1153=t,c1154=t,c1155=t,c1156=t,c1157=t,c1158=t,c1159=t,c1160=t,c1161=t,c1162=t,c1163=t,c1164=t,c1165=t,c1166=t," + "c1167=t,c1168=t,c1169=t,c1170=t,c1171=t,c1172=t,c1173=t," + "c1174=t,c1175=t,c1176=t,c1177=t,c1178=t,c1179=t,c1180=t,c1181=t,c1182=t,c1183=t,c1184=t,c1185=t,c1186=t,c1187=t," + "c1188=t,c1189=t,c1190=t,c1191=t,c1192=t,c1193=t,c1194=t,c1195=t,c1196=t,c1197=t,c1198=t,c1199=t,c1200=t,c1201=t," + "c1202=t,c1203=t,c1204=t,c1205=t,c1206=t,c1207=t,c1208=t,c1209=t,c1210=t,c1211=t,c1212=t,c1213=t,c1214=t,c1215=t," + "c1216=t,c1217=t,c1218=t,c1219=t,c1220=t,c1221=t,c1222=t,c1223=t,c1224=t,c1225=t,c1226=t,c1227=t,c1228=t,c1229=t," + "c1230=t,c1231=t,c1232=t,c1233=t,c1234=t,c1235=t,c1236=t,c1237=t,c1238=t,c1239=t,c1240=t,c1241=t,c1242=t,c1243=t," + "c1244=t,c1245=t,c1246=t,c1247=t,c1248=t,c1249=t,c1250=t,c1251=t,c1252=t,c1253=t,c1254=t,c1255=t,c1256=t,c1257=t," + "c1258=t,c1259=t,c1260=t,c1261=t,c1262=t,c1263=t,c1264=t,c1265=t,c1266=t,c1267=t,c1268=t,c1269=t,c1270=t,c1271=t," + "c1272=t,c1273=t,c1274=t,c1275=t,c1276=t,c1277=t,c1278=t,c1279=t,c1280=t,c1281=t,c1282=t,c1283=t,c1284=t,c1285=t," + "c1286=t,c1287=t,c1288=t,c1289=t,c1290=t,c1291=t,c1292=t,c1293=t,c1294=t,c1295=t,c1296=t,c1297=t,c1298=t,c1299=t," + "c1300=t,c1301=t,c1302=t,c1303=t,c1304=t,c1305=t,c1306=t,c1307=t,c1308=t,c1309=t,c1310=t,c1311=t,c1312=t,c1313=t," + "c1314=t,c1315=t,c1316=t,c1317=t,c1318=t,c1319=t,c1320=t," + "c1321=t,c1322=t,c1323=t,c1324=t,c1325=t,c1326=t,c1327=t,c1328=t,c1329=t,c1330=t,c1331=t,c1332=t,c1333=t,c1334=t," + "c1335=t,c1336=t,c1337=t,c1338=t,c1339=t,c1340=t,c1341=t,c1342=t,c1343=t,c1344=t,c1345=t,c1346=t,c1347=t," + "c1348=t,c1349=t,c1350=t,c1351=t,c1352=t,c1353=t,c1354=t,c1355=t,c1356=t,c1357=t,c1358=t,c1359=t,c1360=t,c1361=t," + "c1362=t,c1363=t,c1364=t,c1365=t,c1366=t,c1367=t,c1368=t,c1369=t,c1370=t,c1371=t,c1372=t,c1373=t,c1374=t,c1375=t," + "c1376=t,c1377=t,c1378=t,c1379=t,c1380=t,c1381=t,c1382=t,c1383=t,c1384=t,c1385=t,c1386=t,c1387=t,c1388=t,c1389=t," + "c1390=t,c1391=t,c1392=t,c1393=t,c1394=t,c1395=t,c1396=t,c1397=t,c1398=t,c1399=t,c1400=t,c1401=t,c1402=t,c1403=t," + "c1404=t,c1405=t,c1406=t,c1407=t,c1408=t,c1409=t,c1410=t,c1411=t,c1412=t,c1413=t,c1414=t,c1415=t,c1416=t,c1417=t," + "c1418=t,c1419=t,c1420=t,c1421=t,c1422=t,c1423=t,c1424=t,c1425=t,c1426=t,c1427=t,c1428=t,c1429=t,c1430=t,c1431=t," + "c1432=t,c1433=t,c1434=t,c1435=t,c1436=t,c1437=t,c1438=t,c1439=t,c1440=t,c1441=t,c1442=t,c1443=t,c1444=t,c1445=t," + "c1446=t,c1447=t,c1448=t,c1449=t,c1450=t,c1451=t,c1452=t,c1453=t,c1454=t,c1455=t,c1456=t,c1457=t,c1458=t,c1459=t," + "c1460=t,c1461=t,c1462=t,c1463=t,c1464=t,c1465=t,c1466=t,c1467=t,c1468=t,c1469=t,c1470=t,c1471=t,c1472=t,c1473=t," + "c1474=t,c1475=t,c1476=t,c1477=t,c1478=t,c1479=t,c1480=t,c1481=t,c1482=t,c1483=t,c1484=t,c1485=t,c1486=t,c1487=t," + "c1488=t,c1489=t,c1490=t,c1491=t,c1492=t,c1493=t,c1494=t," + "c1495=t,c1496=t,c1497=t,c1498=t,c1499=t,c1500=t,c1501=t,c1502=t,c1503=t,c1504=t,c1505=t,c1506=t,c1507=t,c1508=t," + "c1509=t,c1510=t,c1511=t,c1512=t,c1513=t,c1514=t,c1515=t,c1516=t,c1517=t,c1518=t,c1519=t,c1520=t,c1521=t,c1522=t," + "c1523=t,c1524=t,c1525=t,c1526=t,c1527=t,c1528=t,c1529=t,c1530=t,c1531=t,c1532=t,c1533=t,c1534=t,c1535=t,c1536=t," + "c1537=t,c1538=t,c1539=t,c1540=t,c1541=t,c1542=t,c1543=t,c1544=t,c1545=t,c1546=t,c1547=t,c1548=t,c1549=t,c1550=t," + "c1551=t,c1552=t,c1553=t,c1554=t,c1555=t,c1556=t,c1557=t,c1558=t,c1559=t,c1560=t,c1561=t,c1562=t,c1563=t,c1564=t," + "c1565=t,c1566=t,c1567=t,c1568=t,c1569=t,c1570=t,c1571=t,c1572=t,c1573=t,c1574=t,c1575=t,c1576=t,c1577=t,c1578=t," + "c1579=t,c1580=t,c1581=t,c1582=t,c1583=t,c1584=t,c1585=t,c1586=t,c1587=t,c1588=t,c1589=t,c1590=t,c1591=t,c1592=t," + "c1593=t,c1594=t,c1595=t,c1596=t,c1597=t,c1598=t,c1599=t,c1600=t,c1601=t,c1602=t,c1603=t,c1604=t,c1605=t,c1606=t," + "c1607=t,c1608=t,c1609=t,c1610=t,c1611=t,c1612=t,c1613=t,c1614=t,c1615=t,c1616=t,c1617=t,c1618=t,c1619=t,c1620=t," + "c1621=t,c1622=t,c1623=t,c1624=t,c1625=t,c1626=t,c1627=t,c1628=t,c1629=t,c1630=t,c1631=t,c1632=t,c1633=t,c1634=t," + "c1635=t,c1636=t,c1637=t,c1638=t,c1639=t,c1640=t,c1641=t," + "c1642=t,c1643=t,c1644=t,c1645=t,c1646=t,c1647=t,c1648=t,c1649=t,c1650=t,c1651=t,c1652=t,c1653=t,c1654=t,c1655=t," + "c1656=t,c1657=t,c1658=t,c1659=t,c1660=t,c1661=t,c1662=t,c1663=t,c1664=t,c1665=t,c1666=t,c1667=t,c1668=t,c1669=t," + "c1670=t,c1671=t,c1672=t,c1673=t,c1674=t,c1675=t,c1676=t,c1677=t,c1678=t,c1679=t,c1680=t,c1681=t,c1682=t,c1683=t," + "c1684=t,c1685=t,c1686=t,c1687=t,c1688=t,c1689=t,c1690=t,c1691=t,c1692=t,c1693=t,c1694=t,c1695=t,c1696=t,c1697=t," + "c1698=t,c1699=t,c1700=t,c1701=t,c1702=t,c1703=t,c1704=t,c1705=t,c1706=t,c1707=t,c1708=t,c1709=t,c1710=t,c1711=t," + "c1712=t,c1713=t,c1714=t,c1715=t,c1716=t,c1717=t,c1718=t,c1719=t,c1720=t,c1721=t,c1722=t,c1723=t,c1724=t,c1725=t," + "c1726=t,c1727=t,c1728=t,c1729=t,c1730=t,c1731=t,c1732=t,c1733=t,c1734=t,c1735=t,c1736=t,c1737=t,c1738=t,c1739=t," + "c1740=t,c1741=t,c1742=t,c1743=t,c1744=t,c1745=t,c1746=t,c1747=t,c1748=t,c1749=t,c1750=t,c1751=t,c1752=t,c1753=t," + "c1754=t,c1755=t,c1756=t,c1757=t,c1758=t,c1759=t,c1760=t,c1761=t,c1762=t,c1763=t,c1764=t,c1765=t,c1766=t,c1767=t," + "c1768=t,c1769=t,c1770=t,c1771=t,c1772=t,c1773=t,c1774=t,c1775=t,c1776=t,c1777=t,c1778=t,c1779=t,c1780=t,c1781=t," + "c1782=t,c1783=t,c1784=t,c1785=t,c1786=t,c1787=t,c1788=t," + "c1789=t,c1790=t,c1791=t,c1792=t,c1793=t,c1794=t,c1795=t,c1796=t,c1797=t,c1798=t,c1799=t,c1800=t,c1801=t,c1802=t," + "c1803=t,c1804=t,c1805=t,c1806=t,c1807=t,c1808=t,c1809=t,c1810=t,c1811=t,c1812=t,c1813=t,c1814=t,c1815=t," + "c1816=t,c1817=t,c1818=t,c1819=t,c1820=t,c1821=t,c1822=t,c1823=t,c1824=t,c1825=t,c1826=t,c1827=t,c1828=t,c1829=t," + "c1830=t,c1831=t,c1832=t,c1833=t,c1834=t,c1835=t,c1836=t,c1837=t,c1838=t,c1839=t,c1840=t,c1841=t,c1842=t,c1843=t," + "c1844=t,c1845=t,c1846=t,c1847=t,c1848=t,c1849=t,c1850=t,c1851=t,c1852=t,c1853=t,c1854=t,c1855=t,c1856=t,c1857=t," + "c1858=t,c1859=t,c1860=t,c1861=t,c1862=t,c1863=t,c1864=t,c1865=t,c1866=t,c1867=t,c1868=t,c1869=t,c1870=t,c1871=t," + "c1872=t,c1873=t,c1874=t,c1875=t,c1876=t,c1877=t,c1878=t,c1879=t,c1880=t,c1881=t,c1882=t,c1883=t,c1884=t,c1885=t," + "c1886=t,c1887=t,c1888=t,c1889=t,c1890=t,c1891=t,c1892=t,c1893=t,c1894=t,c1895=t,c1896=t,c1897=t,c1898=t,c1899=t," + "c1900=t,c1901=t,c1902=t,c1903=t,c1904=t,c1905=t,c1906=t,c1907=t,c1908=t,c1909=t,c1910=t,c1911=t,c1912=t,c1913=t," + "c1914=t,c1915=t,c1916=t,c1917=t,c1918=t,c1919=t,c1920=t,c1921=t,c1922=t,c1923=t,c1924=t,c1925=t,c1926=t,c1927=t," + "c1928=t,c1929=t,c1930=t,c1931=t,c1932=t,c1933=t,c1934=t,c1935=t,c1936=t,c1937=t,c1938=t,c1939=t,c1940=t,c1941=t," + "c1942=t,c1943=t,c1944=t,c1945=t,c1946=t,c1947=t,c1948=t,c1949=t,c1950=t,c1951=t,c1952=t,c1953=t,c1954=t,c1955=t," + "c1956=t,c1957=t,c1958=t,c1959=t,c1960=t,c1961=t,c1962=t," + "c1963=t,c1964=t,c1965=t,c1966=t,c1967=t,c1968=t,c1969=t,c1970=t,c1971=t,c1972=t,c1973=t,c1974=t,c1975=t,c1976=t," + "c1977=t,c1978=t,c1979=t,c1980=t,c1981=t,c1982=t,c1983=t,c1984=t,c1985=t,c1986=t,c1987=t,c1988=t,c1989=t,c1990=t," + "c1991=t,c1992=t,c1993=t,c1994=t,c1995=t,c1996=t,c1997=t,c1998=t,c1999=t,c2000=t,c2001=t,c2002=t,c2003=t,c2004=t," + "c2005=t,c2006=t,c2007=t,c2008=t,c2009=t,c2010=t,c2011=t,c2012=t,c2013=t,c2014=t,c2015=t,c2016=t,c2017=t,c2018=t," + "c2019=t,c2020=t,c2021=t,c2022=t,c2023=t,c2024=t,c2025=t,c2026=t,c2027=t,c2028=t,c2029=t,c2030=t,c2031=t,c2032=t," + "c2033=t,c2034=t,c2035=t,c2036=t,c2037=t,c2038=t,c2039=t,c2040=t,c2041=t,c2042=t,c2043=t,c2044=t,c2045=t,c2046=t," + "c2047=t,c2048=t,c2049=t,c2050=t,c2051=t,c2052=t,c2053=t,c2054=t,c2055=t,c2056=t,c2057=t,c2058=t,c2059=t,c2060=t," + "c2061=t,c2062=t,c2063=t,c2064=t,c2065=t,c2066=t,c2067=t,c2068=t,c2069=t,c2070=t,c2071=t,c2072=t,c2073=t,c2074=t," + "c2075=t,c2076=t,c2077=t,c2078=t,c2079=t,c2080=t,c2081=t,c2082=t,c2083=t,c2084=t,c2085=t,c2086=t,c2087=t,c2088=t," + "c2089=t,c2090=t,c2091=t,c2092=t,c2093=t,c2094=t,c2095=t,c2096=t,c2097=t,c2098=t,c2099=t,c2100=t,c2101=t,c2102=t," + "c2103=t,c2104=t,c2105=t,c2106=t,c2107=t,c2108=t,c2109=t," + "c2110=t,c2111=t,c2112=t,c2113=t,c2114=t,c2115=t,c2116=t,c2117=t,c2118=t,c2119=t,c2120=t,c2121=t,c2122=t,c2123=t," + "c2124=t,c2125=t,c2126=t,c2127=t,c2128=t,c2129=t,c2130=t,c2131=t,c2132=t,c2133=t,c2134=t,c2135=t,c2136=t,c2137=t," + "c2138=t,c2139=t,c2140=t,c2141=t,c2142=t,c2143=t,c2144=t,c2145=t,c2146=t,c2147=t,c2148=t,c2149=t,c2150=t,c2151=t," + "c2152=t,c2153=t,c2154=t,c2155=t,c2156=t,c2157=t,c2158=t,c2159=t,c2160=t,c2161=t,c2162=t,c2163=t,c2164=t,c2165=t," + "c2166=t,c2167=t,c2168=t,c2169=t,c2170=t,c2171=t,c2172=t,c2173=t,c2174=t,c2175=t,c2176=t,c2177=t,c2178=t,c2179=t," + "c2180=t,c2181=t,c2182=t,c2183=t,c2184=t,c2185=t,c2186=t,c2187=t,c2188=t,c2189=t,c2190=t,c2191=t,c2192=t,c2193=t," + "c2194=t,c2195=t,c2196=t,c2197=t,c2198=t,c2199=t,c2200=t,c2201=t,c2202=t,c2203=t,c2204=t,c2205=t,c2206=t,c2207=t," + "c2208=t,c2209=t,c2210=t,c2211=t,c2212=t,c2213=t,c2214=t,c2215=t,c2216=t,c2217=t,c2218=t,c2219=t,c2220=t,c2221=t," + "c2222=t,c2223=t,c2224=t,c2225=t,c2226=t,c2227=t,c2228=t,c2229=t,c2230=t,c2231=t,c2232=t,c2233=t,c2234=t,c2235=t," + "c2236=t,c2237=t,c2238=t,c2239=t,c2240=t,c2241=t,c2242=t,c2243=t,c2244=t,c2245=t,c2246=t,c2247=t,c2248=t,c2249=t," + "c2250=t,c2251=t,c2252=t,c2253=t,c2254=t,c2255=t,c2256=t," + "c2257=t,c2258=t,c2259=t,c2260=t,c2261=t,c2262=t,c2263=t,c2264=t,c2265=t,c2266=t,c2267=t,c2268=t,c2269=t,c2270=t," + "c2271=t,c2272=t,c2273=t,c2274=t,c2275=t,c2276=t,c2277=t,c2278=t,c2279=t,c2280=t,c2281=t,c2282=t,c2283=t," + "c2284=t,c2285=t,c2286=t,c2287=t,c2288=t,c2289=t,c2290=t,c2291=t,c2292=t,c2293=t,c2294=t,c2295=t,c2296=t,c2297=t," + "c2298=t,c2299=t,c2300=t,c2301=t,c2302=t,c2303=t,c2304=t,c2305=t,c2306=t,c2307=t,c2308=t,c2309=t,c2310=t,c2311=t," + "c2312=t,c2313=t,c2314=t,c2315=t,c2316=t,c2317=t,c2318=t,c2319=t,c2320=t,c2321=t,c2322=t,c2323=t,c2324=t,c2325=t," + "c2326=t,c2327=t,c2328=t,c2329=t,c2330=t,c2331=t,c2332=t,c2333=t,c2334=t,c2335=t,c2336=t,c2337=t,c2338=t,c2339=t," + "c2340=t,c2341=t,c2342=t,c2343=t,c2344=t,c2345=t,c2346=t,c2347=t,c2348=t,c2349=t,c2350=t,c2351=t,c2352=t,c2353=t," + "c2354=t,c2355=t,c2356=t,c2357=t,c2358=t,c2359=t,c2360=t,c2361=t,c2362=t,c2363=t,c2364=t,c2365=t,c2366=t,c2367=t," + "c2368=t,c2369=t,c2370=t,c2371=t,c2372=t,c2373=t,c2374=t,c2375=t,c2376=t,c2377=t,c2378=t,c2379=t,c2380=t,c2381=t," + "c2382=t,c2383=t,c2384=t,c2385=t,c2386=t,c2387=t,c2388=t,c2389=t,c2390=t,c2391=t,c2392=t,c2393=t,c2394=t,c2395=t," + "c2396=t,c2397=t,c2398=t,c2399=t,c2400=t,c2401=t,c2402=t,c2403=t,c2404=t,c2405=t,c2406=t,c2407=t,c2408=t,c2409=t," + "c2410=t,c2411=t,c2412=t,c2413=t,c2414=t,c2415=t,c2416=t,c2417=t,c2418=t,c2419=t,c2420=t,c2421=t,c2422=t,c2423=t," + "c2424=t,c2425=t,c2426=t,c2427=t,c2428=t,c2429=t,c2430=t," + "c2431=t,c2432=t,c2433=t,c2434=t,c2435=t,c2436=t,c2437=t,c2438=t,c2439=t,c2440=t,c2441=t,c2442=t,c2443=t,c2444=t," + "c2445=t,c2446=t,c2447=t,c2448=t,c2449=t,c2450=t,c2451=t,c2452=t,c2453=t,c2454=t,c2455=t,c2456=t,c2457=t,c2458=t," + "c2459=t,c2460=t,c2461=t,c2462=t,c2463=t,c2464=t,c2465=t,c2466=t,c2467=t,c2468=t,c2469=t,c2470=t,c2471=t,c2472=t," + "c2473=t,c2474=t,c2475=t,c2476=t,c2477=t,c2478=t,c2479=t,c2480=t,c2481=t,c2482=t,c2483=t,c2484=t,c2485=t,c2486=t," + "c2487=t,c2488=t,c2489=t,c2490=t,c2491=t,c2492=t,c2493=t,c2494=t,c2495=t,c2496=t,c2497=t,c2498=t,c2499=t,c2500=t," + "c2501=t,c2502=t,c2503=t,c2504=t,c2505=t,c2506=t,c2507=t,c2508=t,c2509=t,c2510=t,c2511=t,c2512=t,c2513=t,c2514=t," + "c2515=t,c2516=t,c2517=t,c2518=t,c2519=t,c2520=t,c2521=t,c2522=t,c2523=t,c2524=t,c2525=t,c2526=t,c2527=t,c2528=t," + "c2529=t,c2530=t,c2531=t,c2532=t,c2533=t,c2534=t,c2535=t,c2536=t,c2537=t,c2538=t,c2539=t,c2540=t,c2541=t,c2542=t," + "c2543=t,c2544=t,c2545=t,c2546=t,c2547=t,c2548=t,c2549=t,c2550=t,c2551=t,c2552=t,c2553=t,c2554=t,c2555=t,c2556=t," + "c2557=t,c2558=t,c2559=t,c2560=t,c2561=t,c2562=t,c2563=t,c2564=t,c2565=t,c2566=t,c2567=t,c2568=t,c2569=t,c2570=t," + "c2571=t,c2572=t,c2573=t,c2574=t,c2575=t,c2576=t,c2577=t," + "c2578=t,c2579=t,c2580=t,c2581=t,c2582=t,c2583=t,c2584=t,c2585=t,c2586=t,c2587=t,c2588=t,c2589=t,c2590=t,c2591=t," + "c2592=t,c2593=t,c2594=t,c2595=t,c2596=t,c2597=t,c2598=t,c2599=t,c2600=t,c2601=t,c2602=t,c2603=t,c2604=t,c2605=t," + "c2606=t,c2607=t,c2608=t,c2609=t,c2610=t,c2611=t,c2612=t,c2613=t,c2614=t,c2615=t,c2616=t,c2617=t,c2618=t,c2619=t," + "c2620=t,c2621=t,c2622=t,c2623=t,c2624=t,c2625=t,c2626=t,c2627=t,c2628=t,c2629=t,c2630=t,c2631=t,c2632=t,c2633=t," + "c2634=t,c2635=t,c2636=t,c2637=t,c2638=t,c2639=t,c2640=t,c2641=t,c2642=t,c2643=t,c2644=t,c2645=t,c2646=t,c2647=t," + "c2648=t,c2649=t,c2650=t,c2651=t,c2652=t,c2653=t,c2654=t,c2655=t,c2656=t,c2657=t,c2658=t,c2659=t,c2660=t,c2661=t," + "c2662=t,c2663=t,c2664=t,c2665=t,c2666=t,c2667=t,c2668=t,c2669=t,c2670=t,c2671=t,c2672=t,c2673=t,c2674=t,c2675=t," + "c2676=t,c2677=t,c2678=t,c2679=t,c2680=t,c2681=t,c2682=t,c2683=t,c2684=t,c2685=t,c2686=t,c2687=t,c2688=t,c2689=t," + "c2690=t,c2691=t,c2692=t,c2693=t,c2694=t,c2695=t,c2696=t,c2697=t,c2698=t,c2699=t,c2700=t,c2701=t,c2702=t,c2703=t," + "c2704=t,c2705=t,c2706=t,c2707=t,c2708=t,c2709=t,c2710=t,c2711=t,c2712=t,c2713=t,c2714=t,c2715=t,c2716=t,c2717=t," + "c2718=t,c2719=t,c2720=t,c2721=t,c2722=t,c2723=t,c2724=t," + "c2725=t,c2726=t,c2727=t,c2728=t,c2729=t,c2730=t,c2731=t,c2732=t,c2733=t,c2734=t,c2735=t,c2736=t,c2737=t,c2738=t," + "c2739=t,c2740=t,c2741=t,c2742=t,c2743=t,c2744=t,c2745=t,c2746=t,c2747=t,c2748=t,c2749=t,c2750=t,c2751=t,c2752=t," + "c2753=t,c2754=t,c2755=t,c2756=t,c2757=t,c2758=t,c2759=t,c2760=t,c2761=t,c2762=t,c2763=t,c2764=t,c2765=t,c2766=t," + "c2767=t,c2768=t,c2769=t,c2770=t,c2771=t,c2772=t,c2773=t,c2774=t,c2775=t,c2776=t,c2777=t,c2778=t,c2779=t,c2780=t," + "c2781=t,c2782=t,c2783=t,c2784=t,c2785=t,c2786=t,c2787=t,c2788=t,c2789=t,c2790=t,c2791=t,c2792=t,c2793=t,c2794=t," + "c2795=t,c2796=t,c2797=t,c2798=t,c2799=t,c2800=t,c2801=t,c2802=t,c2803=t,c2804=t,c2805=t,c2806=t,c2807=t,c2808=t," + "c2809=t,c2810=t,c2811=t,c2812=t,c2813=t,c2814=t,c2815=t,c2816=t,c2817=t,c2818=t,c2819=t,c2820=t,c2821=t,c2822=t," + "c2823=t,c2824=t,c2825=t,c2826=t,c2827=t,c2828=t,c2829=t,c2830=t,c2831=t,c2832=t,c2833=t,c2834=t,c2835=t,c2836=t," + "c2837=t,c2838=t,c2839=t,c2840=t,c2841=t,c2842=t,c2843=t,c2844=t,c2845=t,c2846=t,c2847=t,c2848=t,c2849=t,c2850=t," + "c2851=t,c2852=t,c2853=t,c2854=t,c2855=t,c2856=t,c2857=t,c2858=t,c2859=t,c2860=t,c2861=t,c2862=t,c2863=t,c2864=t," + "c2865=t,c2866=t,c2867=t,c2868=t,c2869=t,c2870=t,c2871=t," + "c2872=t,c2873=t,c2874=t,c2875=t,c2876=t,c2877=t,c2878=t,c2879=t,c2880=t,c2881=t,c2882=t,c2883=t,c2884=t,c2885=t," + "c2886=t,c2887=t,c2888=t,c2889=t,c2890=t,c2891=t,c2892=t,c2893=t,c2894=t,c2895=t,c2896=t,c2897=t,c2898=t,c2899=t," + "c2900=t,c2901=t,c2902=t,c2903=t,c2904=t,c2905=t,c2906=t,c2907=t,c2908=t,c2909=t,c2910=t,c2911=t,c2912=t,c2913=t," + "c2914=t,c2915=t,c2916=t,c2917=t,c2918=t,c2919=t,c2920=t,c2921=t,c2922=t,c2923=t,c2924=t,c2925=t,c2926=t,c2927=t," + "c2928=t,c2929=t,c2930=t,c2931=t,c2932=t,c2933=t,c2934=t,c2935=t,c2936=t,c2937=t,c2938=t,c2939=t,c2940=t,c2941=t," + "c2942=t,c2943=t,c2944=t,c2945=t,c2946=t,c2947=t,c2948=t,c2949=t,c2950=t,c2951=t,c2952=t,c2953=t,c2954=t,c2955=t," + "c2956=t,c2957=t,c2958=t,c2959=t,c2960=t,c2961=t,c2962=t,c2963=t,c2964=t,c2965=t,c2966=t,c2967=t,c2968=t,c2969=t," + "c2970=t,c2971=t,c2972=t,c2973=t,c2974=t,c2975=t,c2976=t,c2977=t,c2978=t,c2979=t,c2980=t,c2981=t,c2982=t,c2983=t," + "c2984=t,c2985=t,c2986=t,c2987=t,c2988=t,c2989=t,c2990=t,c2991=t,c2992=t,c2993=t,c2994=t,c2995=t,c2996=t,c2997=t," + "c2998=t,c2999=t,c3000=t,c3001=t,c3002=t,c3003=t,c3004=t,c3005=t,c3006=t,c3007=t,c3008=t,c3009=t,c3010=t,c3011=t," + "c3012=t,c3013=t,c3014=t,c3015=t,c3016=t,c3017=t,c3018=t," + "c3019=t,c3020=t,c3021=t,c3022=t,c3023=t,c3024=t,c3025=t,c3026=t,c3027=t,c3028=t,c3029=t,c3030=t,c3031=t,c3032=t," + "c3033=t,c3034=t,c3035=t,c3036=t,c3037=t,c3038=t,c3039=t,c3040=t,c3041=t,c3042=t,c3043=t,c3044=t,c3045=t,c3046=t," + "c3047=t,c3048=t,c3049=t,c3050=t,c3051=t,c3052=t,c3053=t,c3054=t,c3055=t,c3056=t,c3057=t,c3058=t,c3059=t,c3060=t," + "c3061=t,c3062=t,c3063=t,c3064=t,c3065=t,c3066=t,c3067=t,c3068=t,c3069=t,c3070=t,c3071=t,c3072=t,c3073=t,c3074=t," + "c3075=t,c3076=t,c3077=t,c3078=t,c3079=t,c3080=t,c3081=t,c3082=t,c3083=t,c3084=t,c3085=t,c3086=t,c3087=t,c3088=t," + "c3089=t,c3090=t,c3091=t,c3092=t,c3093=t,c3094=t,c3095=t,c3096=t,c3097=t,c3098=t,c3099=t,c3100=t,c3101=t,c3102=t," + "c3103=t,c3104=t,c3105=t,c3106=t,c3107=t,c3108=t,c3109=t,c3110=t,c3111=t,c3112=t,c3113=t,c3114=t,c3115=t,c3116=t," + "c3117=t,c3118=t,c3119=t,c3120=t,c3121=t,c3122=t,c3123=t,c3124=t,c3125=t,c3126=t,c3127=t,c3128=t,c3129=t,c3130=t," + "c3131=t,c3132=t,c3133=t,c3134=t,c3135=t,c3136=t,c3137=t,c3138=t,c3139=t,c3140=t,c3141=t,c3142=t,c3143=t,c3144=t," + "c3145=t,c3146=t,c3147=t,c3148=t,c3149=t,c3150=t,c3151=t,c3152=t,c3153=t,c3154=t,c3155=t,c3156=t,c3157=t,c3158=t," + "c3159=t,c3160=t,c3161=t,c3162=t,c3163=t,c3164=t,c3165=t," + "c3166=t,c3167=t,c3168=t,c3169=t,c3170=t,c3171=t,c3172=t,c3173=t,c3174=t,c3175=t,c3176=t,c3177=t,c3178=t,c3179=t," + "c3180=t,c3181=t,c3182=t,c3183=t,c3184=t,c3185=t,c3186=t,c3187=t,c3188=t,c3189=t,c3190=t,c3191=t,c3192=t,c3193=t," + "c3194=t,c3195=t,c3196=t,c3197=t,c3198=t,c3199=t,c3200=t,c3201=t,c3202=t,c3203=t,c3204=t,c3205=t,c3206=t,c3207=t," + "c3208=t,c3209=t,c3210=t,c3211=t,c3212=t,c3213=t,c3214=t,c3215=t,c3216=t,c3217=t,c3218=t,c3219=t,c3220=t,c3221=t," + "c3222=t,c3223=t,c3224=t,c3225=t,c3226=t,c3227=t,c3228=t,c3229=t,c3230=t,c3231=t,c3232=t,c3233=t,c3234=t,c3235=t," + "c3236=t,c3237=t,c3238=t,c3239=t,c3240=t,c3241=t,c3242=t,c3243=t,c3244=t,c3245=t,c3246=t,c3247=t,c3248=t,c3249=t," + "c3250=t,c3251=t,c3252=t,c3253=t,c3254=t,c3255=t,c3256=t,c3257=t,c3258=t,c3259=t,c3260=t,c3261=t,c3262=t,c3263=t," + "c3264=t,c3265=t,c3266=t,c3267=t,c3268=t,c3269=t,c3270=t,c3271=t,c3272=t,c3273=t,c3274=t,c3275=t,c3276=t,c3277=t," + "c3278=t,c3279=t,c3280=t,c3281=t,c3282=t,c3283=t,c3284=t,c3285=t,c3286=t,c3287=t,c3288=t,c3289=t,c3290=t,c3291=t," + "c3292=t,c3293=t,c3294=t,c3295=t,c3296=t,c3297=t,c3298=t,c3299=t,c3300=t,c3301=t,c3302=t,c3303=t,c3304=t,c3305=t," + "c3306=t,c3307=t,c3308=t,c3309=t,c3310=t,c3311=t,c3312=t," + "c3313=t,c3314=t,c3315=t,c3316=t,c3317=t,c3318=t,c3319=t,c3320=t,c3321=t,c3322=t,c3323=t,c3324=t,c3325=t,c3326=t," + "c3327=t,c3328=t,c3329=t,c3330=t,c3331=t,c3332=t,c3333=t,c3334=t,c3335=t,c3336=t,c3337=t,c3338=t,c3339=t,c3340=t," + "c3341=t,c3342=t,c3343=t,c3344=t,c3345=t,c3346=t,c3347=t,c3348=t,c3349=t,c3350=t,c3351=t,c3352=t,c3353=t,c3354=t," + "c3355=t,c3356=t,c3357=t,c3358=t,c3359=t,c3360=t,c3361=t,c3362=t,c3363=t,c3364=t,c3365=t,c3366=t,c3367=t,c3368=t," + "c3369=t,c3370=t,c3371=t,c3372=t,c3373=t,c3374=t,c3375=t,c3376=t,c3377=t,c3378=t,c3379=t,c3380=t,c3381=t,c3382=t," + "c3383=t,c3384=t,c3385=t,c3386=t,c3387=t,c3388=t,c3389=t,c3390=t,c3391=t,c3392=t,c3393=t,c3394=t,c3395=t,c3396=t," + "c3397=t,c3398=t,c3399=t,c3400=t,c3401=t,c3402=t,c3403=t,c3404=t,c3405=t,c3406=t,c3407=t,c3408=t,c3409=t,c3410=t," + "c3411=t,c3412=t,c3413=t,c3414=t,c3415=t,c3416=t,c3417=t,c3418=t,c3419=t,c3420=t,c3421=t,c3422=t,c3423=t,c3424=t," + "c3425=t,c3426=t,c3427=t,c3428=t,c3429=t,c3430=t,c3431=t,c3432=t,c3433=t,c3434=t,c3435=t,c3436=t,c3437=t,c3438=t," + "c3439=t,c3440=t,c3441=t,c3442=t,c3443=t,c3444=t,c3445=t,c3446=t,c3447=t,c3448=t,c3449=t,c3450=t,c3451=t,c3452=t," + "c3453=t,c3454=t,c3455=t,c3456=t,c3457=t,c3458=t,c3459=t," + "c3460=t,c3461=t,c3462=t,c3463=t,c3464=t,c3465=t,c3466=t,c3467=t,c3468=t,c3469=t,c3470=t,c3471=t,c3472=t,c3473=t," + "c3474=t,c3475=t,c3476=t,c3477=t,c3478=t,c3479=t,c3480=t,c3481=t,c3482=t,c3483=t,c3484=t,c3485=t,c3486=t,c3487=t," + "c3488=t,c3489=t,c3490=t,c3491=t,c3492=t,c3493=t,c3494=t,c3495=t,c3496=t,c3497=t,c3498=t,c3499=t,c3500=t,c3501=t," + "c3502=t,c3503=t,c3504=t,c3505=t,c3506=t,c3507=t,c3508=t,c3509=t,c3510=t,c3511=t,c3512=t,c3513=t," + "c3514=t,c3515=t,c3516=t,c3517=t,c3518=t,c3519=t,c3520=t,c3521=t,c3522=t,c3523=t,c3524=t,c3525=t,c3526=t,c3527=t," + "c3528=t,c3529=t,c3530=t,c3531=t,c3532=t,c3533=t,c3534=t,c3535=t,c3536=t,c3537=t,c3538=t,c3539=t,c3540=t,c3541=t," + "c3542=t,c3543=t,c3544=t,c3545=t,c3546=t,c3547=t,c3548=t,c3549=t,c3550=t,c3551=t,c3552=t,c3553=t,c3554=t,c3555=t," + "c3556=t,c3557=t,c3558=t,c3559=t,c3560=t,c3561=t,c3562=t,c3563=t,c3564=t,c3565=t,c3566=t,c3567=t,c3568=t,c3569=t," + "c3570=t,c3571=t,c3572=t,c3573=t,c3574=t,c3575=t,c3576=t,c3577=t,c3578=t,c3579=t,c3580=t,c3581=t,c3582=t,c3583=t," + "c3584=t,c3585=t,c3586=t,c3587=t,c3588=t,c3589=t,c3590=t,c3591=t,c3592=t,c3593=t,c3594=t,c3595=t,c3596=t,c3597=t," + "c3598=t,c3599=t,c3600=t,c3601=t,c3602=t,c3603=t,c3604=t,c3605=t,c3606=t,c3607=t,c3608=t,c3609=t,c3610=t,c3611=t," + "c3612=t,c3613=t,c3614=t,c3615=t,c3616=t,c3617=t,c3618=t,c3619=t,c3620=t,c3621=t,c3622=t,c3623=t,c3624=t,c3625=t," + "c3626=t,c3627=t,c3628=t,c3629=t,c3630=t,c3631=t,c3632=t,c3633=t,c3634=t,c3635=t,c3636=t,c3637=t,c3638=t,c3639=t," + "c3640=t,c3641=t,c3642=t,c3643=t,c3644=t,c3645=t,c3646=t,c3647=t,c3648=t,c3649=t,c3650=t,c3651=t,c3652=t,c3653=t," + "c3654=t,c3655=t,c3656=t,c3657=t,c3658=t,c3659=t,c3660=t," + "c3661=t,c3662=t,c3663=t,c3664=t,c3665=t,c3666=t,c3667=t,c3668=t,c3669=t,c3670=t,c3671=t,c3672=t,c3673=t,c3674=t," + "c3675=t,c3676=t,c3677=t,c3678=t,c3679=t,c3680=t,c3681=t,c3682=t,c3683=t,c3684=t,c3685=t,c3686=t,c3687=t,c3688=t," + "c3689=t,c3690=t,c3691=t,c3692=t,c3693=t,c3694=t,c3695=t,c3696=t,c3697=t,c3698=t,c3699=t,c3700=t,c3701=t,c3702=t," + "c3703=t,c3704=t,c3705=t,c3706=t,c3707=t,c3708=t,c3709=t,c3710=t,c3711=t,c3712=t,c3713=t,c3714=t,c3715=t,c3716=t," + "c3717=t,c3718=t,c3719=t,c3720=t,c3721=t,c3722=t,c3723=t,c3724=t,c3725=t,c3726=t,c3727=t,c3728=t,c3729=t,c3730=t," + "c3731=t,c3732=t,c3733=t,c3734=t,c3735=t,c3736=t,c3737=t,c3738=t,c3739=t,c3740=t,c3741=t,c3742=t,c3743=t,c3744=t," + "c3745=t,c3746=t,c3747=t,c3748=t,c3749=t,c3750=t,c3751=t,c3752=t,c3753=t,c3754=t,c3755=t,c3756=t,c3757=t,c3758=t," + "c3759=t,c3760=t,c3761=t,c3762=t,c3763=t,c3764=t,c3765=t,c3766=t,c3767=t,c3768=t,c3769=t,c3770=t,c3771=t,c3772=t," + "c3773=t,c3774=t,c3775=t,c3776=t,c3777=t,c3778=t,c3779=t,c3780=t,c3781=t,c3782=t,c3783=t,c3784=t,c3785=t,c3786=t," + "c3787=t,c3788=t,c3789=t,c3790=t,c3791=t,c3792=t,c3793=t,c3794=t,c3795=t,c3796=t,c3797=t,c3798=t,c3799=t,c3800=t," + "c3801=t,c3802=t,c3803=t,c3804=t,c3805=t,c3806=t,c3807=t," + "c3808=t,c3809=t,c3810=t,c3811=t,c3812=t,c3813=t,c3814=t,c3815=t,c3816=t,c3817=t,c3818=t,c3819=t,c3820=t,c3821=t," + "c3822=t,c3823=t,c3824=t,c3825=t,c3826=t,c3827=t,c3828=t,c3829=t,c3830=t,c3831=t,c3832=t,c3833=t,c3834=t,c3835=t," + "c3836=t,c3837=t,c3838=t,c3839=t,c3840=t,c3841=t,c3842=t,c3843=t,c3844=t,c3845=t,c3846=t,c3847=t,c3848=t,c3849=t," + "c3850=t,c3851=t,c3852=t,c3853=t,c3854=t,c3855=t,c3856=t,c3857=t,c3858=t,c3859=t,c3860=t,c3861=t,c3862=t,c3863=t," + "c3864=t,c3865=t,c3866=t,c3867=t,c3868=t,c3869=t,c3870=t,c3871=t,c3872=t,c3873=t,c3874=t,c3875=t,c3876=t,c3877=t," + "c3878=t,c3879=t,c3880=t,c3881=t,c3882=t,c3883=t,c3884=t,c3885=t,c3886=t,c3887=t,c3888=t,c3889=t,c3890=t,c3891=t," + "c3892=t,c3893=t,c3894=t,c3895=t,c3896=t,c3897=t,c3898=t,c3899=t,c3900=t,c3901=t,c3902=t,c3903=t,c3904=t,c3905=t," + "c3906=t,c3907=t,c3908=t,c3909=t,c3910=t,c3911=t,c3912=t,c3913=t,c3914=t,c3915=t,c3916=t,c3917=t,c3918=t,c3919=t," + "c3920=t,c3921=t,c3922=t,c3923=t,c3924=t,c3925=t,c3926=t,c3927=t,c3928=t,c3929=t,c3930=t,c3931=t,c3932=t,c3933=t," + "c3934=t,c3935=t,c3936=t,c3937=t,c3938=t,c3939=t,c3940=t,c3941=t,c3942=t,c3943=t,c3944=t,c3945=t,c3946=t,c3947=t," + "c3948=t,c3949=t,c3950=t,c3951=t,c3952=t,c3953=t,c3954=t," + "c3955=t,c3956=t,c3957=t,c3958=t,c3959=t,c3960=t,c3961=t,c3962=t,c3963=t,c3964=t,c3965=t,c3966=t,c3967=t,c3968=t," + "c3969=t,c3970=t,c3971=t,c3972=t,c3973=t,c3974=t,c3975=t,c3976=t,c3977=t,c3978=t,c3979=t,c3980=t,c3981=t,c3982=t," + "c3983=t,c3984=t,c3985=t,c3986=t,c3987=t,c3988=t,c3989=t,c3990=t,c3991=t,c3992=t,c3993=t,c3994=t,c3995=t,c3996=t," + "c3997=t,c3998=t,c3999=t,c4000=t,c4001=t,c4002=t,c4003=t,c4004=t,c4005=t,c4006=t,c4007=t,c4008=t,c4009=t,c4010=t," + "c4011=t,c4012=t,c4013=t,c4014=t,c4015=t,c4016=t,c4017=t,c4018=t,c4019=t,c4020=t,c4021=t,c4022=t,c4023=t,c4024=t," + "c4025=t,c4026=t,c4027=t,c4028=t,c4029=t,c4030=t,c4031=t,c4032=t,c4033=t,c4034=t,c4035=t,c4036=t,c4037=t,c4038=t," + "c4039=t,c4040=t,c4041=t,c4042=t,c4043=t,c4044=t,c4045=t,c4046=t,c4047=t,c4048=t,c4049=t,c4050=t,c4051=t,c4052=t," + "c4053=t,c4054=t,c4055=t,c4056=t,c4057=t,c4058=t,c4059=t,c4060=t,c4061=t,c4062=t,c4063=t,c4064=t,c4065=t,c4066=t," + "c4067=t,c4068=t,c4069=t,c4070=t,c4071=t,c4072=t,c4073=t,c4074=t,c4075=t,c4076=t,c4077=t,c4078=t,c4079=t,c4080=t," + "c4081=t,c4082=t,c4083=t,c4084=t,c4085=t,c4086=t,c4087=t,c4088=t,c4089=t,c4090=t,c4091=t,c4092=t,c4093=t " + "1626006833640000000"}; int ret = TSDB_CODE_SUCCESS; - for(int i = 0; i < sizeof(sql)/sizeof(sql[0]); i++){ + for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) { ret = smlParseInfluxLine(info, sql[i]); - if(ret != TSDB_CODE_SUCCESS) break; + if (ret != TSDB_CODE_SUCCESS) break; } ASSERT_NE(ret, 0); smlDestroyInfo(info); diff --git a/source/common/src/tmisce.c b/source/common/src/tmisce.c index 2290c5d45f38d1daeb27f9988c842ca775b35b9f..f1713cfd98c87d7c20f2d3de0c8e41c6a8709245 100644 --- a/source/common/src/tmisce.c +++ b/source/common/src/tmisce.c @@ -61,17 +61,15 @@ bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2) { void updateEpSet_s(SCorEpSet* pEpSet, SEpSet* pNewEpSet) { taosCorBeginWrite(&pEpSet->version); - pEpSet->epSet = *pNewEpSet; + pEpSet->epSet = *pNewEpSet; taosCorEndWrite(&pEpSet->version); } SEpSet getEpSet_s(SCorEpSet* pEpSet) { SEpSet ep = {0}; taosCorBeginRead(&pEpSet->version); - ep = pEpSet->epSet; + ep = pEpSet->epSet; taosCorEndRead(&pEpSet->version); return ep; } - - diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 77b45b6df1bb861375986e946b0e24680c11cfdc..d9d4fb274ef63a9a53c07650066f27d8f43792fc 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -67,11 +67,11 @@ static int64_t user_mktime64(const uint32_t year0, const uint32_t mon0, const ui // ==== mktime() kernel code =================// static int64_t m_deltaUtc = 0; void deltaToUtcInitOnce() { - struct tm tm = {0}; + struct tm tm = {0}; - (void)taosStrpTime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm); - m_deltaUtc = (int64_t)taosMktime(&tm); - // printf("====delta:%lld\n\n", seconds); + (void)taosStrpTime("1970-01-01 00:00:00", (const char*)("%Y-%m-%d %H:%M:%S"), &tm); + m_deltaUtc = (int64_t)taosMktime(&tm); + // printf("====delta:%lld\n\n", seconds); } static int64_t parseFraction(char* str, char** end, int32_t timePrec); @@ -81,8 +81,8 @@ static int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* utime, int static char* forwardToTimeStringEnd(char* str); static bool checkTzPresent(const char* str, int32_t len); -static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) = {parseLocaltime, - parseLocaltimeDst}; +static int32_t (*parseLocaltimeFp[])(char* timestr, int32_t len, int64_t* utime, int32_t timePrec, char delim) = { + parseLocaltime, parseLocaltimeDst}; int32_t taosParseTime(const char* timestr, int64_t* utime, int32_t len, int32_t timePrec, int8_t day_light) { /* parse datatime string in with tz */ @@ -324,7 +324,7 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) { int32_t leapYearMonthDay = 29; int32_t year = pTm->tm_year + 1900; - bool isLeapYear = ((year % 100) == 0)? ((year % 400) == 0):((year % 4) == 0); + bool isLeapYear = ((year % 100) == 0) ? ((year % 400) == 0) : ((year % 4) == 0); if (isLeapYear && (pTm->tm_mon == 1)) { if (pTm->tm_mday > leapYearMonthDay) { @@ -336,14 +336,14 @@ static FORCE_INLINE bool validateTm(struct tm* pTm) { } } - return true; + return true; } int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePrec, char delim) { *time = 0; struct tm tm = {0}; - char *str; + char* str; if (delim == 'T') { str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm); } else if (delim == 0) { @@ -353,7 +353,7 @@ int32_t parseLocaltime(char* timestr, int32_t len, int64_t* time, int32_t timePr } if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { - //if parse failed, try "%Y-%m-%d" format + // if parse failed, try "%Y-%m-%d" format str = taosStrpTime(timestr, "%Y-%m-%d", &tm); if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; @@ -390,7 +390,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim struct tm tm = {0}; tm.tm_isdst = -1; - char *str; + char* str; if (delim == 'T') { str = taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm); } else if (delim == 0) { @@ -400,7 +400,7 @@ int32_t parseLocaltimeDst(char* timestr, int32_t len, int64_t* time, int32_t tim } if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { - //if parse failed, try "%Y-%m-%d" format + // if parse failed, try "%Y-%m-%d" format str = taosStrpTime(timestr, "%Y-%m-%d", &tm); if (str == NULL || (((str - timestr) < len) && (*str != '.')) || !validateTm(&tm)) { return -1; @@ -438,14 +438,12 @@ char getPrecisionUnit(int32_t precision) { } int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { - assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || - fromPrecision == TSDB_TIME_PRECISION_MICRO || + assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_NANO); - assert(toPrecision == TSDB_TIME_PRECISION_MILLI || - toPrecision == TSDB_TIME_PRECISION_MICRO || + assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO || toPrecision == TSDB_TIME_PRECISION_NANO); double tempResult = (double)time; - switch(fromPrecision) { + switch (fromPrecision) { case TSDB_TIME_PRECISION_MILLI: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: @@ -459,7 +457,7 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec time *= 1000000; goto end_; } - } // end from milli + } // end from milli case TSDB_TIME_PRECISION_MICRO: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: @@ -471,7 +469,7 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec time *= 1000; goto end_; } - } //end from micro + } // end from micro case TSDB_TIME_PRECISION_NANO: { switch (toPrecision) { case TSDB_TIME_PRECISION_MILLI: @@ -481,20 +479,21 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec case TSDB_TIME_PRECISION_NANO: return time; } - } //end from nano + } // end from nano default: { assert(0); return time; // only to pass windows compilation } - } //end switch fromPrecision + } // end switch fromPrecision end_: if (tempResult >= (double)INT64_MAX) return INT64_MAX; if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL return time; } -// !!!!notice:there are precision problems, double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064 -//int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { +// !!!!notice:there are precision problems, double lose precison if time is too large, for example: +// 1626006833631000000*1.0 = double = 1626006833631000064 +// int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { // assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || // fromPrecision == TSDB_TIME_PRECISION_NANO); // assert(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO || @@ -503,53 +502,53 @@ end_: // ((double)time * factors[fromPrecision][toPrecision]); //} - -// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = 1626006833631000064 +// !!!!notice: double lose precison if time is too large, for example: 1626006833631000000*1.0 = double = +// 1626006833631000064 int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) { assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_NANO); int64_t factors[3] = {NANOSECOND_PER_MSEC, NANOSECOND_PER_USEC, 1}; - double tmp = time; + double tmp = time; switch (toUnit) { - case 's':{ - tmp /= (NANOSECOND_PER_SEC/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_SEC/factors[fromPrecision]); + case 's': { + tmp /= (NANOSECOND_PER_SEC / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_SEC / factors[fromPrecision]); break; } case 'm': - tmp /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_MINUTE/factors[fromPrecision]); + tmp /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_MINUTE / factors[fromPrecision]); break; case 'h': - tmp /= (NANOSECOND_PER_HOUR/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_HOUR/factors[fromPrecision]); + tmp /= (NANOSECOND_PER_HOUR / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_HOUR / factors[fromPrecision]); break; case 'd': - tmp /= (NANOSECOND_PER_DAY/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_DAY/factors[fromPrecision]); + tmp /= (NANOSECOND_PER_DAY / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_DAY / factors[fromPrecision]); break; case 'w': - tmp /= (NANOSECOND_PER_WEEK/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_WEEK/factors[fromPrecision]); + tmp /= (NANOSECOND_PER_WEEK / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_WEEK / factors[fromPrecision]); break; case 'a': - tmp /= (NANOSECOND_PER_MSEC/factors[fromPrecision]); // the result of division is an integer - time /= (NANOSECOND_PER_MSEC/factors[fromPrecision]); + tmp /= (NANOSECOND_PER_MSEC / factors[fromPrecision]); // the result of division is an integer + time /= (NANOSECOND_PER_MSEC / factors[fromPrecision]); break; case 'u': // the result of (NANOSECOND_PER_USEC/(double)factors[fromPrecision]) maybe a double switch (fromPrecision) { - case TSDB_TIME_PRECISION_MILLI:{ + case TSDB_TIME_PRECISION_MILLI: { tmp *= 1000; time *= 1000; break; } - case TSDB_TIME_PRECISION_MICRO:{ + case TSDB_TIME_PRECISION_MICRO: { tmp /= 1; time /= 1; break; } - case TSDB_TIME_PRECISION_NANO:{ + case TSDB_TIME_PRECISION_NANO: { tmp /= 1000; time /= 1000; break; @@ -569,11 +568,11 @@ int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char return time; } -int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, int64_t *timeVal) { +int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal) { int32_t charLen = varDataLen(inputData); - char *newColData; + char* newColData; if (type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_VARBINARY) { - newColData = taosMemoryCalloc(1, charLen + 1); + newColData = taosMemoryCalloc(1, charLen + 1); memcpy(newColData, varDataVal(inputData), charLen); int32_t ret = taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, tsDaylight); if (ret != TSDB_CODE_SUCCESS) { @@ -582,9 +581,9 @@ int32_t convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec } taosMemoryFree(newColData); } else if (type == TSDB_DATA_TYPE_NCHAR) { - newColData = taosMemoryCalloc(1, charLen + TSDB_NCHAR_SIZE); - int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inputData), charLen, newColData); - if (len < 0){ + newColData = taosMemoryCalloc(1, charLen + TSDB_NCHAR_SIZE); + int len = taosUcs4ToMbs((TdUcs4*)varDataVal(inputData), charLen, newColData); + if (len < 0) { taosMemoryFree(newColData); return TSDB_CODE_FAILED; } @@ -877,8 +876,8 @@ const char* fmtts(int64_t ts) { } void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) { - char ts[40] = {0}; - struct tm ptm; + char ts[40] = {0}; + struct tm ptm; int32_t fractionLen; char* format = NULL; diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index 3dd865e91ff55851b5ed8353aa111e5b3ec08d74..aeb9292b417978c708ddaabae50e371834cbd600 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -209,7 +209,8 @@ static STSGroupBlockInfoEx* addOneGroupInfo(STSBuf* pTSBuf, int32_t id) { uint32_t newSize = (uint32_t)(pTSBuf->numOfAlloc * 1.5); assert((int32_t)newSize > pTSBuf->numOfAlloc); - STSGroupBlockInfoEx* tmp = (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); + STSGroupBlockInfoEx* tmp = + (STSGroupBlockInfoEx*)taosMemoryRealloc(pTSBuf->pData, sizeof(STSGroupBlockInfoEx) * newSize); if (tmp == NULL) { return NULL; } diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index 6406ae560f3619ca5b7019e309430e40246d4d54..acc3fc56581420a1a2d253dd1db40fc760a2c7c9 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -15,9 +15,10 @@ #define _DEFAULT_SOURCE #include "dmMgmt.h" -#include "tconfig.h" #include "mnode.h" +#include "tconfig.h" +// clang-format off #define DM_APOLLO_URL "The apollo string to use when configuring the server, such as: -a 'jsonFile:./tests/cfg.json', cfg.json text can be '{\"fqdn\":\"td1\"}'." #define DM_CFG_DIR "Configuration directory." #define DM_DMP_CFG "Dump configuration." @@ -28,9 +29,10 @@ #define DM_MACHINE_CODE "Get machine code." #define DM_VERSION "Print program version." #define DM_EMAIL "" +// clang-format on static struct { #ifdef WINDOWS - bool winServiceMode; + bool winServiceMode; #endif bool dumpConfig; bool dumpSdb; @@ -101,10 +103,10 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) { global.dumpConfig = true; } else if (strcmp(argv[i], "-V") == 0) { global.printVersion = true; - #ifdef WINDOWS +#ifdef WINDOWS } else if (strcmp(argv[i], "--win_service") == 0) { global.winServiceMode = true; - #endif +#endif } else if (strcmp(argv[i], "-e") == 0) { global.envCmd[cmdEnvIndex] = argv[++i]; cmdEnvIndex++; @@ -183,7 +185,7 @@ int main(int argc, char const *argv[]) { } #ifdef WINDOWS - int mainWindows(int argc,char** argv); + int mainWindows(int argc, char **argv); if (global.winServiceMode) { stratWindowsService(mainWindows); } else { @@ -191,7 +193,7 @@ int main(int argc, char const *argv[]) { } return 0; } -int mainWindows(int argc,char** argv) { +int mainWindows(int argc, char **argv) { #endif if (global.generateGrant) { @@ -224,7 +226,7 @@ int mainWindows(int argc,char** argv) { taosCleanupArgs(); return -1; } - + taosConvInit(); if (global.dumpConfig) { diff --git a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c index 9d9217267ab0cfcf42d822ff3e22a94c1e3bd916..e7ccce1c8b7ce1fd72f7a703b3757cef64833648 100644 --- a/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c +++ b/source/dnode/mgmt/mgmt_dnode/src/dmWorker.c @@ -101,7 +101,7 @@ void dmStopMonitorThread(SDnodeMgmt *pMgmt) { static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) { SDnodeMgmt *pMgmt = pInfo->ahandle; int32_t code = -1; - STraceId * trace = &pMsg->info.traceId; + STraceId *trace = &pMsg->info.traceId; dGTrace("msg:%p, will be processed in dnode queue, type:%s", pMsg, TMSG_INFO(pMsg->msgType)); switch (pMsg->msgType) { diff --git a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h index acc101386bd112862ea243bea89c2e3e0c867fbc..56bf56f25e85a57140566bb20b9b252dae5b521a 100644 --- a/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h +++ b/source/dnode/mgmt/mgmt_qnode/inc/qmInt.h @@ -51,7 +51,7 @@ int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg); -int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg); +int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c index 14cb1bd533416c96ef16b39c2fbb53a15883bcbf..6382152cd1a1877e35d943fb09e817af94c02ab0 100644 --- a/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c +++ b/source/dnode/mgmt/mgmt_qnode/src/qmHandle.c @@ -21,7 +21,6 @@ void qmGetMonitorInfo(SQnodeMgmt *pMgmt, SMonQmInfo *qmInfo) { qndGetLoad(pMgmt->pQnode, &qload); qload.dnodeId = pMgmt->pData->dnodeId; - } void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) { diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index d8456ad6264c5c784be91afdcd8c58b832a99ee8..0e53b7ca80fad5db6fedec880e495965b90e25a6 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -224,18 +224,17 @@ int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return -1; } - dInfo( - "vgId:%d, start to create vnode, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64 - " cacheLast:%d cacheLastSize:%d sstTrigger:%d tsdbPageSize:%d %d dbname:%s dbId:%" PRId64 - "days:%d keep0:%d keep1:%d keep2:%d tsma:%d precision:%d compression:%d minRows:%d maxRows:%d, wal " - "fsync:%d level:%d retentionPeriod:%d retentionSize:%d rollPeriod:%d segSize:%d, hash method:%d begin:%u end:%u " - "prefix:%d surfix:%d replica:%d selfIndex:%d strict:%d", - req.vgId, req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024, - req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize, req.tsdbPageSize * 1024, req.db, req.dbUid, - req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2, req.isTsma, req.precision, req.compression, - req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize, - req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, req.hashSuffix, - req.replica, req.selfIndex, req.strict); + dInfo("vgId:%d, start to create vnode, page:%d pageSize:%d buffer:%d szPage:%d szBuf:%" PRIu64 + ", cacheLast:%d cacheLastSize:%d sstTrigger:%d tsdbPageSize:%d %d dbname:%s dbId:%" PRId64 + ", days:%d keep0:%d keep1:%d keep2:%d tsma:%d precision:%d compression:%d minRows:%d maxRows:%d" + ", wal fsync:%d level:%d retentionPeriod:%d retentionSize:%" PRId64 " rollPeriod:%d segSize:%" PRId64 + ", hash method:%d begin:%u end:%u prefix:%d surfix:%d replica:%d selfIndex:%d strict:%d", + req.vgId, req.pages, req.pageSize, req.buffer, req.pageSize * 1024, (uint64_t)req.buffer * 1024 * 1024, + req.cacheLast, req.cacheLastSize, req.sstTrigger, req.tsdbPageSize, req.tsdbPageSize * 1024, req.db, req.dbUid, + req.daysPerFile, req.daysToKeep0, req.daysToKeep1, req.daysToKeep2, req.isTsma, req.precision, req.compression, + req.minRows, req.maxRows, req.walFsyncPeriod, req.walLevel, req.walRetentionPeriod, req.walRetentionSize, + req.walRollPeriod, req.walSegmentSize, req.hashMethod, req.hashBegin, req.hashEnd, req.hashPrefix, + req.hashSuffix, req.replica, req.selfIndex, req.strict); for (int32_t i = 0; i < req.replica; ++i) { dInfo("vgId:%d, replica:%d fqdn:%s port:%u", req.vgId, req.replicas[i].id, req.replicas[i].fqdn, req.replicas[i].port); diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index 81da38076d058095720c162eae295fbda4a56c5d..d07ec7abb03501f1fe627f66dce36228df014fad 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -52,17 +52,23 @@ static int32_t dmInitMonitor() { static bool dmCheckDiskSpace() { osUpdate(); if (!osDataSpaceAvailable()) { - dError("free disk size: %f GB, too little, require %f GB at least at least , quit", (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0); + dError("free disk size: %f GB, too little, require %f GB at least at least , quit", + (double)tsDataSpace.size.avail / 1024.0 / 1024.0 / 1024.0, + (double)tsDataSpace.reserved / 1024.0 / 1024.0 / 1024.0); terrno = TSDB_CODE_NO_AVAIL_DISK; return false; } if (!osLogSpaceAvailable()) { - dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0); + dError("free disk size: %f GB, too little, require %f GB at least at least, quit", + (double)tsLogSpace.size.avail / 1024.0 / 1024.0 / 1024.0, + (double)tsLogSpace.reserved / 1024.0 / 1024.0 / 1024.0); terrno = TSDB_CODE_NO_AVAIL_DISK; return false; } if (!osTempSpaceAvailable()) { - dError("free disk size: %f GB, too little, require %f GB at least at least, quit", (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0); + dError("free disk size: %f GB, too little, require %f GB at least at least, quit", + (double)tsTempSpace.size.avail / 1024.0 / 1024.0 / 1024.0, + (double)tsTempSpace.reserved / 1024.0 / 1024.0 / 1024.0); terrno = TSDB_CODE_NO_AVAIL_DISK; return false; } @@ -73,7 +79,8 @@ static bool dmCheckDataDirVersion() { char checkDataDirJsonFileName[PATH_MAX]; snprintf(checkDataDirJsonFileName, PATH_MAX, "%s/dnode/dnodeCfg.json", tsDataDir); if (taosCheckExistFile(checkDataDirJsonFileName)) { - dError("The default data directory %s contains old data of tdengine 2.x, please clear it before running!", tsDataDir); + dError("The default data directory %s contains old data of tdengine 2.x, please clear it before running!", + tsDataDir); return false; } return true; diff --git a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c index 50d6aca53e56093db5201e7eabee6df17bdd3e36..1c71fe5e1f00535b5938f2416cffc5cbca1a12b8 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmMonitor.c +++ b/source/dnode/mgmt/node_mgmt/src/dmMonitor.c @@ -183,4 +183,3 @@ void dmGetQnodeLoads(SQnodeLoad *pInfo) { dmReleaseWrapper(pWrapper); } } - diff --git a/source/dnode/mgmt/node_mgmt/src/dmProc.c b/source/dnode/mgmt/node_mgmt/src/dmProc.c index ce03d767fee6528afba1de8a9d46aadc04a9bd34..dc07455e6bd5abd99e890348232a8fb33491c1b1 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmProc.c +++ b/source/dnode/mgmt/node_mgmt/src/dmProc.c @@ -91,8 +91,8 @@ static SProcQueue *dmInitProcQueue(SProc *proc, char *ptr, int32_t size) { static void dmCleanupProcQueue(SProcQueue *queue) {} static inline int32_t dmPushToProcQueue(SProc *proc, SProcQueue *queue, SRpcMsg *pMsg, EProcFuncType ftype) { - const void * pHead = pMsg; - const void * pBody = pMsg->pCont; + const void *pHead = pMsg; + const void *pBody = pMsg->pCont; const int16_t rawHeadLen = sizeof(SRpcMsg); const int32_t rawBodyLen = pMsg->contLen; const int16_t headLen = CEIL8(rawHeadLen); @@ -261,7 +261,7 @@ int32_t dmInitProc(struct SMgmtWrapper *pWrapper) { proc->wrapper = pWrapper; proc->name = pWrapper->name; - SShm * shm = &proc->shm; + SShm *shm = &proc->shm; int32_t cstart = 0; int32_t csize = CEIL8(shm->size / 2); int32_t pstart = csize; @@ -285,13 +285,13 @@ int32_t dmInitProc(struct SMgmtWrapper *pWrapper) { } static void *dmConsumChildQueue(void *param) { - SProc * proc = param; + SProc *proc = param; SMgmtWrapper *pWrapper = proc->wrapper; - SProcQueue * queue = proc->cqueue; + SProcQueue *queue = proc->cqueue; int32_t numOfMsgs = 0; int32_t code = 0; EProcFuncType ftype = DND_FUNC_REQ; - SRpcMsg * pMsg = NULL; + SRpcMsg *pMsg = NULL; dDebug("node:%s, start to consume from cqueue", proc->name); do { @@ -328,13 +328,13 @@ static void *dmConsumChildQueue(void *param) { } static void *dmConsumParentQueue(void *param) { - SProc * proc = param; + SProc *proc = param; SMgmtWrapper *pWrapper = proc->wrapper; - SProcQueue * queue = proc->pqueue; + SProcQueue *queue = proc->pqueue; int32_t numOfMsgs = 0; int32_t code = 0; EProcFuncType ftype = DND_FUNC_REQ; - SRpcMsg * pMsg = NULL; + SRpcMsg *pMsg = NULL; dDebug("node:%s, start to consume from pqueue", proc->name); do { diff --git a/source/dnode/mgmt/node_mgmt/src/dmTransport.c b/source/dnode/mgmt/node_mgmt/src/dmTransport.c index e83f1f7cabf67702e32da0a03becfe70296445d9..542baaec091b5d9bf8ce04a10ee4edc8463fc203 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmTransport.c +++ b/source/dnode/mgmt/node_mgmt/src/dmTransport.c @@ -277,6 +277,7 @@ int32_t dmInitClient(SDnode *pDnode) { rpcInit.idleTime = tsShellActivityTimer * 1000; rpcInit.parent = pDnode; rpcInit.rfp = rpcRfp; + rpcInit.compressSize = tsCompressMsgSize; pTrans->clientRpc = rpcOpen(&rpcInit); if (pTrans->clientRpc == NULL) { diff --git a/source/dnode/mgmt/node_util/inc/dmUtil.h b/source/dnode/mgmt/node_util/inc/dmUtil.h index 01958aa05355e489371679c56f74d73bf2f2db0b..f599de384cdc36f04873b0d34d40b18168b136da 100644 --- a/source/dnode/mgmt/node_util/inc/dmUtil.h +++ b/source/dnode/mgmt/node_util/inc/dmUtil.h @@ -44,7 +44,6 @@ extern "C" { #endif - // clang-format off #define dFatal(...) { if (dDebugFlag & DEBUG_FATAL) { taosPrintLog("DND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} diff --git a/source/dnode/mgmt/test/bnode/dbnode.cpp b/source/dnode/mgmt/test/bnode/dbnode.cpp index c2a9873e5b0e4b2ddca8007e76d10e4e69fa3567..24d8c594ce54a9e5c7d92575edcee9cd88d5bfef 100644 --- a/source/dnode/mgmt/test/bnode/dbnode.cpp +++ b/source/dnode/mgmt/test/bnode/dbnode.cpp @@ -17,7 +17,7 @@ class DndTestBnode : public ::testing::Test { test.Init(TD_TMP_DIR_PATH "dbnodeTest", 9112); taosMsleep(1100); } - static void TearDownTestSuite() { test.Cleanup(); } + static void TearDownTestSuite() { test.Cleanup(); } static Testbase test; public: diff --git a/source/dnode/mgmt/test/sut/inc/sut.h b/source/dnode/mgmt/test/sut/inc/sut.h index 268f779fcf81900d990b4327efbdc9be1f482442..90d7a2505239361f8530abd3ae97be85783c363e 100644 --- a/source/dnode/mgmt/test/sut/inc/sut.h +++ b/source/dnode/mgmt/test/sut/inc/sut.h @@ -47,7 +47,7 @@ class Testbase { int32_t connId; public: - int32_t SendShowReq(int8_t showType, const char *tb, const char* db); + int32_t SendShowReq(int8_t showType, const char* tb, const char* db); int32_t GetShowRows(); #if 0 diff --git a/source/dnode/mgmt/test/sut/src/sut.cpp b/source/dnode/mgmt/test/sut/src/sut.cpp index 572c57284a9516a8f469f4de1b79d92946a63314..699203e8c1daf52727959c794dd22e1f9a031c9c 100644 --- a/source/dnode/mgmt/test/sut/src/sut.cpp +++ b/source/dnode/mgmt/test/sut/src/sut.cpp @@ -30,14 +30,14 @@ void Testbase::InitLog(const char* path) { tsdbDebugFlag = 0; tsLogEmbedded = 1; tsAsyncLog = 0; - + taosRemoveDir(path); taosMkDir(path); tstrncpy(tsLogDir, path, PATH_MAX); taosGetSystemInfo(); tsRpcQueueMemoryAllowed = tsTotalMemoryKB * 0.1; -if (taosInitLog("taosdlog", 1) != 0) { + if (taosInitLog("taosdlog", 1) != 0) { printf("failed to init log file\n"); } } diff --git a/source/dnode/mnode/impl/inc/mndGrant.h b/source/dnode/mnode/impl/inc/mndGrant.h index 9c8e853a21ab1a118a97b3574259c4eabbea230f..88f118cb8febcf6d69a1f0cacfd3f88e81969408 100644 --- a/source/dnode/mnode/impl/inc/mndGrant.h +++ b/source/dnode/mnode/impl/inc/mndGrant.h @@ -22,12 +22,12 @@ #include "mndInt.h" -int32_t mndInitGrant(SMnode *pMnode); -void mndCleanupGrant(); -void grantParseParameter(); -void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value); -void grantAdd(EGrantType grant, uint64_t value); -void grantRestore(EGrantType grant, uint64_t value); + int32_t mndInitGrant(SMnode * pMnode); + void mndCleanupGrant(); + void grantParseParameter(); + void grantReset(SMnode * pMnode, EGrantType grant, uint64_t value); + void grantAdd(EGrantType grant, uint64_t value); + void grantRestore(EGrantType grant, uint64_t value); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndInt.h b/source/dnode/mnode/impl/inc/mndInt.h index 505a1384efdd7296751c6d29700b0888aa04543e..71315a39fd6c75d7b09e7371a9e0af30577a54d8 100644 --- a/source/dnode/mnode/impl/inc/mndInt.h +++ b/source/dnode/mnode/impl/inc/mndInt.h @@ -51,8 +51,8 @@ extern "C" { // clang-format on #define SYSTABLE_SCH_TABLE_NAME_LEN ((TSDB_TABLE_NAME_LEN - 1) + VARSTR_HEADER_SIZE) -#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) -#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_DB_NAME_LEN ((TSDB_DB_NAME_LEN - 1) + VARSTR_HEADER_SIZE) +#define SYSTABLE_SCH_COL_NAME_LEN ((TSDB_COL_NAME_LEN - 1) + VARSTR_HEADER_SIZE) typedef int32_t (*MndMsgFp)(SRpcMsg *pMsg); typedef int32_t (*MndInitFp)(SMnode *pMnode); diff --git a/source/dnode/mnode/impl/inc/mndPerfSchema.h b/source/dnode/mnode/impl/inc/mndPerfSchema.h index 87b4626e83fb400e45083ea5d3380dee0f543c75..3d9f3e4d7f507997a815222acd756ee45875bb01 100644 --- a/source/dnode/mnode/impl/inc/mndPerfSchema.h +++ b/source/dnode/mnode/impl/inc/mndPerfSchema.h @@ -25,7 +25,7 @@ extern "C" { int32_t mndBuildPerfsTableSchema(SMnode *pMnode, const char *dbFName, const char *tbName, STableMetaRsp *pRsp); int32_t mndBuildPerfsTableCfg(SMnode *pMnode, const char *dbFName, const char *tbName, STableCfgRsp *pRsp); int32_t mndInitPerfs(SMnode *pMnode); -void mndCleanupPerfs(SMnode *pMnode); +void mndCleanupPerfs(SMnode *pMnode); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndQuery.h b/source/dnode/mnode/impl/inc/mndQuery.h index 7fab80de77dc06f37c7b36403efc7b4efb6306ec..4b359c0a1408dc84688992cd5fd107dafe646087 100644 --- a/source/dnode/mnode/impl/inc/mndQuery.h +++ b/source/dnode/mnode/impl/inc/mndQuery.h @@ -22,9 +22,8 @@ extern "C" { #endif -int32_t mndInitQuery(SMnode *pMnode); -void mndCleanupQuery(SMnode *pMnode); - +int32_t mndInitQuery(SMnode *pMnode); +void mndCleanupQuery(SMnode *pMnode); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/inc/mndStb.h b/source/dnode/mnode/impl/inc/mndStb.h index ba9acdbd8fb7bc7762e26f6580f7eecee49a961c..6a4031692301cfe835a2e6426eb51ca874d642ee 100644 --- a/source/dnode/mnode/impl/inc/mndStb.h +++ b/source/dnode/mnode/impl/inc/mndStb.h @@ -35,7 +35,7 @@ SDbObj *mndAcquireDbByStb(SMnode *pMnode, const char *stbName); int32_t mndBuildStbFromReq(SMnode *pMnode, SStbObj *pDst, SMCreateStbReq *pCreate, SDbObj *pDb); int32_t mndAddStbToTrans(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb); void mndFreeStb(SStbObj *pStb); -int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char* dbFName, char* stbFName, void **pCont, int32_t *pLen); +int32_t mndBuildSMCreateStbRsp(SMnode *pMnode, char *dbFName, char *stbFName, void **pCont, int32_t *pLen); void mndExtractDbNameFromStbFullName(const char *stbFullName, char *dst); void mndExtractTbNameFromStbFullName(const char *stbFullName, char *dst, int32_t dstSize); diff --git a/source/dnode/mnode/impl/src/mndBnode.c b/source/dnode/mnode/impl/src/mndBnode.c index 9cae83152a7ceba87d13d09ee10befb82c59d9fd..06209d89c75f5ab5da28ae490c042414a8d2fa32 100644 --- a/source/dnode/mnode/impl/src/mndBnode.c +++ b/source/dnode/mnode/impl/src/mndBnode.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndBnode.h" -#include "mndPrivilege.h" #include "mndDnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 7ffa3cef9992d998f36f34392c0f45d1fdc9d955..46aaa7ffe16c9d684229480ac88a29e0469987b3 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -116,11 +116,13 @@ static int32_t mndProcessConsumerLostMsg(SRpcMsg *pMsg) { if (mndSetConsumerCommitLogs(pMnode, pTrans, pConsumerNew) != 0) goto FAIL; if (mndTransPrepare(pMnode, pTrans) != 0) goto FAIL; - mndTransDrop(pTrans); tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); + mndTransDrop(pTrans); return 0; FAIL: tDeleteSMqConsumerObj(pConsumerNew); + taosMemoryFree(pConsumerNew); mndTransDrop(pTrans); return -1; } diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index 31d7571363d56c32af36ab9523a6c39cf40dcc45..9ade39e8e7c3302389e8f4b339baaad6071ae5b3 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -440,7 +440,7 @@ static int32_t mndProcessStatusReq(SRpcMsg *pReq) { statusReq.memAvail, statusReq.memTotal, statusReq.numOfCores); } else { mInfo("dnode:%d, send dnode epset, online:%d dnodeVer:%" PRId64 ":%" PRId64 " reboot:%d", pDnode->id, online, - statusReq.dnodeVer, dnodeVer, reboot); + statusReq.dnodeVer, dnodeVer, reboot); } pDnode->rebootTime = statusReq.rebootTime; diff --git a/source/dnode/mnode/impl/src/mndDump.c b/source/dnode/mnode/impl/src/mndDump.c index 881ebbbf9de161018a3d0965bd61f2ab92666094..c1c7581a7e2c1d64cbcc2409da86a1b07de90db5 100644 --- a/source/dnode/mnode/impl/src/mndDump.c +++ b/source/dnode/mnode/impl/src/mndDump.c @@ -102,21 +102,21 @@ void dumpDb(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "compression", i642str(pObj->cfg.compression)); tjsonAddStringToObject(item, "replications", i642str(pObj->cfg.replications)); tjsonAddStringToObject(item, "strict", i642str(pObj->cfg.strict)); - tjsonAddStringToObject(item, "cacheLast",i642str( pObj->cfg.cacheLast)); + tjsonAddStringToObject(item, "cacheLast", i642str(pObj->cfg.cacheLast)); tjsonAddStringToObject(item, "hashMethod", i642str(pObj->cfg.hashMethod)); tjsonAddStringToObject(item, "hashPrefix", i642str(pObj->cfg.hashPrefix)); tjsonAddStringToObject(item, "hashSuffix", i642str(pObj->cfg.hashSuffix)); tjsonAddStringToObject(item, "sstTrigger", i642str(pObj->cfg.sstTrigger)); - tjsonAddStringToObject(item, "tsdbPageSize",i642str( pObj->cfg.tsdbPageSize)); + tjsonAddStringToObject(item, "tsdbPageSize", i642str(pObj->cfg.tsdbPageSize)); tjsonAddStringToObject(item, "schemaless", i642str(pObj->cfg.schemaless)); - tjsonAddStringToObject(item, "walLevel",i642str( pObj->cfg.walLevel)); + tjsonAddStringToObject(item, "walLevel", i642str(pObj->cfg.walLevel)); tjsonAddStringToObject(item, "walFsyncPeriod", i642str(pObj->cfg.walFsyncPeriod)); tjsonAddStringToObject(item, "walRetentionPeriod", i642str(pObj->cfg.walRetentionPeriod)); - tjsonAddStringToObject(item, "walRetentionSize",i642str( pObj->cfg.walRetentionSize)); + tjsonAddStringToObject(item, "walRetentionSize", i642str(pObj->cfg.walRetentionSize)); tjsonAddStringToObject(item, "walRollPeriod", i642str(pObj->cfg.walRollPeriod)); tjsonAddStringToObject(item, "walSegmentSize", i642str(pObj->cfg.walSegmentSize)); - tjsonAddStringToObject(item, "numOfRetensions",i642str( pObj->cfg.numOfRetensions)); + tjsonAddStringToObject(item, "numOfRetensions", i642str(pObj->cfg.numOfRetensions)); for (int32_t i = 0; i < pObj->cfg.numOfRetensions; ++i) { SJson *rentensions = tjsonAddArrayToObject(item, "rentensions"); SJson *rentension = tjsonCreateObject(); @@ -126,7 +126,7 @@ void dumpDb(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "freq", i642str(pRetension->freq)); tjsonAddStringToObject(item, "freqUnit", i642str(pRetension->freqUnit)); tjsonAddStringToObject(item, "keep", i642str(pRetension->keep)); - tjsonAddStringToObject(item, "keepUnit",i642str( pRetension->keepUnit)); + tjsonAddStringToObject(item, "keepUnit", i642str(pRetension->keepUnit)); } sdbRelease(pSdb, pObj); @@ -150,21 +150,21 @@ void dumpStb(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); - tjsonAddStringToObject(item, "tagVer",i642str( pObj->tagVer)); + tjsonAddStringToObject(item, "tagVer", i642str(pObj->tagVer)); tjsonAddStringToObject(item, "colVer", i642str(pObj->colVer)); tjsonAddStringToObject(item, "smaVer", i642str(pObj->smaVer)); tjsonAddStringToObject(item, "nextColId", i642str(pObj->nextColId)); tjsonAddStringToObject(item, "watermark1", i642str(pObj->watermark[0])); tjsonAddStringToObject(item, "watermark2", i642str(pObj->watermark[1])); - tjsonAddStringToObject(item, "maxdelay0",i642str( pObj->maxdelay[0])); - tjsonAddStringToObject(item, "maxdelay1",i642str( pObj->maxdelay[1])); - tjsonAddStringToObject(item, "ttl",i642str( pObj->ttl)); - tjsonAddStringToObject(item, "numOfFuncs",i642str( pObj->numOfFuncs)); + tjsonAddStringToObject(item, "maxdelay0", i642str(pObj->maxdelay[0])); + tjsonAddStringToObject(item, "maxdelay1", i642str(pObj->maxdelay[1])); + tjsonAddStringToObject(item, "ttl", i642str(pObj->ttl)); + tjsonAddStringToObject(item, "numOfFuncs", i642str(pObj->numOfFuncs)); tjsonAddStringToObject(item, "commentLen", i642str(pObj->commentLen)); tjsonAddStringToObject(item, "ast1Len", i642str(pObj->ast1Len)); - tjsonAddStringToObject(item, "ast2Len",i642str( pObj->ast2Len)); + tjsonAddStringToObject(item, "ast2Len", i642str(pObj->ast2Len)); - tjsonAddStringToObject(item, "numOfColumns",i642str( pObj->numOfColumns)); + tjsonAddStringToObject(item, "numOfColumns", i642str(pObj->numOfColumns)); SJson *columns = tjsonAddArrayToObject(item, "columns"); for (int32_t i = 0; i < pObj->numOfColumns; ++i) { SJson *column = tjsonCreateObject(); @@ -188,7 +188,7 @@ void dumpStb(SSdb *pSdb, SJson *json) { SSchema *pTag = &pObj->pTags[i]; tjsonAddStringToObject(tag, "type", i642str(pTag->type)); tjsonAddStringToObject(tag, "typestr", tDataTypes[pTag->type].name); - tjsonAddStringToObject(tag, "flags",i642str( pTag->flags)); + tjsonAddStringToObject(tag, "flags", i642str(pTag->flags)); tjsonAddStringToObject(tag, "colId", i642str(pTag->colId)); tjsonAddStringToObject(tag, "bytes", i642str(pTag->bytes)); tjsonAddStringToObject(tag, "name", pTag->name); @@ -219,16 +219,16 @@ void dumpSma(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "dstTbUid", i642str(pObj->dstTbUid)); tjsonAddStringToObject(item, "intervalUnit", i642str(pObj->intervalUnit)); - tjsonAddStringToObject(item, "slidingUnit",i642str( pObj->slidingUnit)); + tjsonAddStringToObject(item, "slidingUnit", i642str(pObj->slidingUnit)); tjsonAddStringToObject(item, "timezone", i642str(pObj->timezone)); - tjsonAddStringToObject(item, "dstVgId",i642str( pObj->dstVgId)); + tjsonAddStringToObject(item, "dstVgId", i642str(pObj->dstVgId)); tjsonAddStringToObject(item, "interval", i642str(pObj->interval)); tjsonAddStringToObject(item, "offset", i642str(pObj->offset)); tjsonAddStringToObject(item, "sliding", i642str(pObj->sliding)); - tjsonAddStringToObject(item, "exprLen",i642str( pObj->exprLen)); + tjsonAddStringToObject(item, "exprLen", i642str(pObj->exprLen)); tjsonAddStringToObject(item, "tagsFilterLen", i642str(pObj->tagsFilterLen)); - tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); - tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); + tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen)); + tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen)); sdbRelease(pSdb, pObj); } } @@ -247,13 +247,13 @@ void dumpVgroup(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "vgId", i642str(pObj->vgId)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "version",i642str(pObj->version)); + tjsonAddStringToObject(item, "version", i642str(pObj->version)); tjsonAddStringToObject(item, "hashBegin", i642str(pObj->hashBegin)); tjsonAddStringToObject(item, "hashEnd", i642str(pObj->hashEnd)); tjsonAddStringToObject(item, "db", mndGetDbStr(pObj->dbName)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); tjsonAddStringToObject(item, "isTsma", i642str(pObj->isTsma)); - tjsonAddStringToObject(item, "replica",i642str( pObj->replica)); + tjsonAddStringToObject(item, "replica", i642str(pObj->replica)); for (int32_t i = 0; i < pObj->replica; ++i) { SJson *replicas = tjsonAddArrayToObject(item, "replicas"); SJson *replica = tjsonCreateObject(); @@ -281,13 +281,13 @@ void dumpTopic(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); tjsonAddStringToObject(item, "dbUid", i642str(pObj->dbUid)); - tjsonAddStringToObject(item, "version",i642str( pObj->version)); - tjsonAddStringToObject(item, "subType",i642str( pObj->subType)); + tjsonAddStringToObject(item, "version", i642str(pObj->version)); + tjsonAddStringToObject(item, "subType", i642str(pObj->subType)); tjsonAddStringToObject(item, "withMeta", i642str(pObj->withMeta)); tjsonAddStringToObject(item, "stbUid", i642str(pObj->stbUid)); tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen)); - tjsonAddStringToObject(item, "astLen",i642str( pObj->astLen)); - tjsonAddStringToObject(item, "sqlLen",i642str( pObj->sqlLen)); + tjsonAddStringToObject(item, "astLen", i642str(pObj->astLen)); + tjsonAddStringToObject(item, "sqlLen", i642str(pObj->sqlLen)); tjsonAddStringToObject(item, "ntbUid", i642str(pObj->ntbUid)); tjsonAddStringToObject(item, "ctbStbUid", i642str(pObj->ctbStbUid)); sdbRelease(pSdb, pObj); @@ -365,9 +365,9 @@ void dumpStream(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "totalLevel", i642str(pObj->totalLevel)); tjsonAddStringToObject(item, "smaId", i642str(pObj->smaId)); tjsonAddStringToObject(item, "uid", i642str(pObj->uid)); - tjsonAddStringToObject(item, "status",i642str( pObj->status)); - tjsonAddStringToObject(item, "igExpired",i642str( pObj->igExpired)); - tjsonAddStringToObject(item, "trigger",i642str( pObj->trigger)); + tjsonAddStringToObject(item, "status", i642str(pObj->status)); + tjsonAddStringToObject(item, "igExpired", i642str(pObj->igExpired)); + tjsonAddStringToObject(item, "trigger", i642str(pObj->trigger)); tjsonAddStringToObject(item, "triggerParam", i642str(pObj->triggerParam)); tjsonAddStringToObject(item, "watermark", i642str(pObj->watermark)); tjsonAddStringToObject(item, "sourceDbUid", i642str(pObj->sourceDbUid)); @@ -419,9 +419,9 @@ void dumpUser(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "acct", pObj->acct); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "superUser",i642str( pObj->superUser)); + tjsonAddStringToObject(item, "superUser", i642str(pObj->superUser)); tjsonAddStringToObject(item, "authVersion", i642str(pObj->authVersion)); - tjsonAddStringToObject(item, "numOfReadDbs",i642str( taosHashGetSize(pObj->readDbs))); + tjsonAddStringToObject(item, "numOfReadDbs", i642str(taosHashGetSize(pObj->readDbs))); tjsonAddStringToObject(item, "numOfWriteDbs", i642str(taosHashGetSize(pObj->writeDbs))); sdbRelease(pSdb, pObj); } @@ -438,10 +438,10 @@ void dumpDnode(SSdb *pSdb, SJson *json) { SJson *item = tjsonCreateObject(); tjsonAddItemToArray(items, item); - tjsonAddStringToObject(item, "id",i642str( pObj->id)); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); - tjsonAddStringToObject(item, "port",i642str( pObj->port)); + tjsonAddStringToObject(item, "port", i642str(pObj->port)); tjsonAddStringToObject(item, "fqdn", pObj->fqdn); sdbRelease(pSdb, pObj); } @@ -462,7 +462,7 @@ void dumpSnode(SSdb *pSdb, SJson *json) { SJson *item = tjsonCreateObject(); tjsonAddItemToArray(items, item); - tjsonAddStringToObject(item, "id",i642str( pObj->id)); + tjsonAddStringToObject(item, "id", i642str(pObj->id)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "updateTime", i642str(pObj->updateTime)); sdbRelease(pSdb, pObj); @@ -538,15 +538,15 @@ void dumpTrans(SSdb *pSdb, SJson *json) { tjsonAddStringToObject(item, "id", i642str(pObj->id)); tjsonAddStringToObject(item, "stage", i642str(pObj->stage)); tjsonAddStringToObject(item, "policy", i642str(pObj->policy)); - tjsonAddStringToObject(item, "conflict",i642str( pObj->conflict)); + tjsonAddStringToObject(item, "conflict", i642str(pObj->conflict)); tjsonAddStringToObject(item, "exec", i642str(pObj->exec)); tjsonAddStringToObject(item, "oper", i642str(pObj->oper)); tjsonAddStringToObject(item, "createdTime", i642str(pObj->createdTime)); tjsonAddStringToObject(item, "dbname", pObj->dbname); tjsonAddStringToObject(item, "stbname", pObj->stbname); tjsonAddStringToObject(item, "opername", pObj->opername); - tjsonAddStringToObject(item, "commitLogNum",i642str( taosArrayGetSize(pObj->commitActions))); - tjsonAddStringToObject(item, "redoActionNum",i642str(taosArrayGetSize(pObj->redoActions))); + tjsonAddStringToObject(item, "commitLogNum", i642str(taosArrayGetSize(pObj->commitActions))); + tjsonAddStringToObject(item, "redoActionNum", i642str(taosArrayGetSize(pObj->redoActions))); tjsonAddStringToObject(item, "undoActionNum", i642str(taosArrayGetSize(pObj->undoActions))); sdbRelease(pSdb, pObj); } diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 09eef7b4d63ce81aedf946d64de28519b843d3a8..d0440359ffa849678b4f2f124059d11ec3214809 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndMnode.h" -#include "mndPrivilege.h" #include "mndDnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndSync.h" #include "mndTrans.h" diff --git a/source/dnode/mnode/impl/src/mndPerfSchema.c b/source/dnode/mnode/impl/src/mndPerfSchema.c index cb636dc037af5ac13d8a517c29ceeaf9b65eef5a..e874c1a53e6d5e0aaffe4891fb25dca3b6a11d07 100644 --- a/source/dnode/mnode/impl/src/mndPerfSchema.c +++ b/source/dnode/mnode/impl/src/mndPerfSchema.c @@ -45,8 +45,8 @@ int32_t mndPerfsInitMeta(SHashObj *hash) { meta.sversion = 1; meta.tversion = 1; - size_t size = 0; - const SSysTableMeta* pSysDbTableMeta = NULL; + size_t size = 0; + const SSysTableMeta *pSysDbTableMeta = NULL; getPerfDbMeta(&pSysDbTableMeta, &size); for (int32_t i = 0; i < size; ++i) { @@ -150,4 +150,3 @@ void mndCleanupPerfs(SMnode *pMnode) { taosHashCleanup(pMnode->perfsMeta); pMnode->perfsMeta = NULL; } - diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index cbd398e36181517b19dc5c682badb80a2814f09a..d48a446e20ecb979acf559dc88710a719869b310 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndQnode.h" -#include "mndPrivilege.h" #include "mndDnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" diff --git a/source/dnode/mnode/impl/src/mndQuery.c b/source/dnode/mnode/impl/src/mndQuery.c index 0e897de4e7bd64cdaffcd0c0f6da339ab8db4851..f185cdeaec5305d638d95443cd5d773e01de7d81 100644 --- a/source/dnode/mnode/impl/src/mndQuery.c +++ b/source/dnode/mnode/impl/src/mndQuery.c @@ -64,36 +64,36 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) { } int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) { - int32_t code = 0; - int32_t offset = 0; - int32_t rspSize = 0; - SBatchReq *batchReq = (SBatchReq*)pMsg->pCont; - int32_t msgNum = ntohl(batchReq->msgNum); + int32_t code = 0; + int32_t offset = 0; + int32_t rspSize = 0; + SBatchReq *batchReq = (SBatchReq *)pMsg->pCont; + int32_t msgNum = ntohl(batchReq->msgNum); offset += sizeof(SBatchReq); SBatchMsg req = {0}; SBatchRsp rsp = {0}; - SRpcMsg reqMsg = *pMsg; - SRpcMsg rspMsg = {0}; - void* pRsp = NULL; - SMnode *pMnode = pMsg->info.node; + SRpcMsg reqMsg = *pMsg; + SRpcMsg rspMsg = {0}; + void *pRsp = NULL; + SMnode *pMnode = pMsg->info.node; - SArray* batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp)); + SArray *batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp)); if (NULL == batchRsp) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - + for (int32_t i = 0; i < msgNum; ++i) { - req.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgIdx); - req.msgType = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgType); - req.msgLen = ntohl(*(int32_t*)((char*)pMsg->pCont + offset)); + req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset)); offset += sizeof(req.msgLen); - req.msg = (char*)pMsg->pCont + offset; + req.msg = (char *)pMsg->pCont + offset; offset += req.msgLen; reqMsg.msgType = req.msgType; @@ -118,7 +118,7 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) { rsp.reqType = reqMsg.msgType; rsp.msgLen = reqMsg.info.rspLen; rsp.msg = reqMsg.info.rsp; - + taosArrayPush(batchRsp, &rsp); rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES; @@ -126,27 +126,27 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) { rspSize += sizeof(int32_t); offset = 0; - + pRsp = rpcMallocCont(rspSize); if (pRsp == NULL) { code = TSDB_CODE_OUT_OF_MEMORY; goto _exit; } - *(int32_t*)((char*)pRsp + offset) = htonl(msgNum); + *(int32_t *)((char *)pRsp + offset) = htonl(msgNum); offset += sizeof(msgNum); for (int32_t i = 0; i < msgNum; ++i) { SBatchRsp *p = taosArrayGet(batchRsp, i); - - *(int32_t*)((char*)pRsp + offset) = htonl(p->reqType); + + *(int32_t *)((char *)pRsp + offset) = htonl(p->reqType); offset += sizeof(p->reqType); - *(int32_t*)((char*)pRsp + offset) = htonl(p->msgIdx); + *(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx); offset += sizeof(p->msgIdx); - *(int32_t*)((char*)pRsp + offset) = htonl(p->msgLen); + *(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen); offset += sizeof(p->msgLen); - *(int32_t*)((char*)pRsp + offset) = htonl(p->rspCode); + *(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode); offset += sizeof(p->rspCode); - memcpy((char*)pRsp + offset, p->msg, p->msgLen); + memcpy((char *)pRsp + offset, p->msg, p->msgLen); offset += p->msgLen; rpcFreeCont(p->msg); diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 90d05e8f211d98a2b66d0c98a76a01492a3f3749..da548cd3ebfee591132ed1235d4b158c3ea54565 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -604,7 +604,7 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; mInfo("sma:%s, uid:%" PRIi64 " create on stb:%" PRIi64 ", dstSuid:%" PRIi64 " dstTb:%s dstVg:%d", pCreate->name, - smaObj.uid, smaObj.stbUid, smaObj.dstTbUid, smaObj.dstTbName, smaObj.dstVgId); + smaObj.uid, smaObj.stbUid, smaObj.dstTbUid, smaObj.dstTbName, smaObj.dstVgId); code = 0; diff --git a/source/dnode/mnode/impl/src/mndSnode.c b/source/dnode/mnode/impl/src/mndSnode.c index 691270997064f0648fad3c268beac0f34921980c..916e8d0c449334f3a4b436b7187c4bf2b965a842 100644 --- a/source/dnode/mnode/impl/src/mndSnode.c +++ b/source/dnode/mnode/impl/src/mndSnode.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "mndSnode.h" -#include "mndPrivilege.h" #include "mndDnode.h" +#include "mndPrivilege.h" #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 8cd8431c348232cdf99ccaef3b6c18889e455605..10cfb0a6602622373954b46c8771f48f65bcb2b4 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1162,7 +1162,7 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, if (pIter == NULL) break; mInfo("topic:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, subType:%d sql:%s", - pTopic->name, stbFullName, suid, colId, pTopic->subType, pTopic->sql); + pTopic->name, stbFullName, suid, colId, pTopic->subType, pTopic->sql); if (pTopic->subType != TOPIC_SUB_TYPE__COLUMN) { sdbRelease(pSdb, pTopic); continue; @@ -1179,8 +1179,8 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName, SNode *pNode = NULL; FOREACH(pNode, pNodeList) { SColumnNode *pCol = (SColumnNode *)pNode; - mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, - pCol->tableId, pTopic->ctbStbUid); + mInfo("topic:%s, check colId:%d tableId:%" PRId64 " ctbStbUid:%" PRId64, pTopic->name, pCol->colId, pCol->tableId, + pTopic->ctbStbUid); if (pCol->tableId != suid && pTopic->ctbStbUid != suid) { mInfo("topic:%s, check colId:%d passed", pTopic->name, pCol->colId); @@ -1256,8 +1256,8 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName, pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); if (pIter == NULL) break; - mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, - stbFullName, suid, colId, pSma->sql); + mInfo("tsma:%s, check tag and column modifiable, stb:%s suid:%" PRId64 " colId:%d, sql:%s", pSma->name, stbFullName, + suid, colId, pSma->sql); SNode *pAst = NULL; if (nodesStringToNode(pSma->ast, &pAst) != 0) { diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index aabde3fed2de9d509ef396ccd865b86727ae8a51..0e4dd9fc3c51d121e54be959129cf1e98a508181 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -51,9 +51,9 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM int32_t transId = sdbGetIdFromRaw(pMnode->pSdb, pRaw); pMgmt->errCode = cbMeta.code; mInfo("trans:%d, is proposed, saved:%d code:0x%x, apply index:%" PRId64 " term:%" PRIu64 " config:%" PRId64 - " role:%s raw:%p", - transId, pMgmt->transId, cbMeta.code, cbMeta.index, cbMeta.term, cbMeta.lastConfigIndex, syncStr(cbMeta.state), - pRaw); + " role:%s raw:%p", + transId, pMgmt->transId, cbMeta.code, cbMeta.index, cbMeta.term, cbMeta.lastConfigIndex, syncStr(cbMeta.state), + pRaw); if (pMgmt->errCode == 0) { sdbWriteWithoutFree(pMnode->pSdb, pRaw); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index ae259b95be220a3c1cb0d3c2178b92e322d65ace..90ac69423c5f496bebc156b290264e990cacd615 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -154,6 +154,8 @@ TOPIC_ENCODE_OVER: SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_OUT_OF_MEMORY; + + void *buf = NULL; int8_t sver = 0; if (sdbGetRawSoftVer(pRaw, &sver) != 0) goto TOPIC_DECODE_OVER; @@ -215,17 +217,15 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &len, TOPIC_DECODE_OVER); if (len) { - void *buf = taosMemoryMalloc(len); + buf = taosMemoryMalloc(len); if (buf == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto TOPIC_DECODE_OVER; } SDB_GET_BINARY(pRaw, dataPos, buf, len, TOPIC_DECODE_OVER); if (taosDecodeSSchemaWrapper(buf, &pTopic->schema) == NULL) { - taosMemoryFree(buf); goto TOPIC_DECODE_OVER; } - taosMemoryFree(buf); } else { pTopic->schema.nCols = 0; pTopic->schema.version = 0; @@ -251,6 +251,7 @@ SSdbRow *mndTopicActionDecode(SSdbRaw *pRaw) { terrno = TSDB_CODE_SUCCESS; TOPIC_DECODE_OVER: + taosMemoryFreeClear(buf); if (terrno != TSDB_CODE_SUCCESS) { mError("topic:%s, failed to decode from raw:%p since %s", pTopic->name, pRaw, terrstr()); taosMemoryFreeClear(pRow); diff --git a/source/dnode/mnode/impl/src/mndVgroup.c b/source/dnode/mnode/impl/src/mndVgroup.c index 8e91ec90f537cd069f87474e29695eaa37ce30c0..4ab80b0a40e73584696d6678f2b6eeefdc261f15 100644 --- a/source/dnode/mnode/impl/src/mndVgroup.c +++ b/source/dnode/mnode/impl/src/mndVgroup.c @@ -1555,8 +1555,8 @@ static int32_t mndCheckDnodeMemory(SMnode *pMnode, SDbObj *pOldDb, SDbObj *pNewD terrno = TSDB_CODE_MND_NO_ENOUGH_MEM_IN_DNODE; return -1; } else if (inVgroup) { - mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName, - pNewVgroup->vgId, pDnode->id, pDnode->memAvail, pDnode->memUsed); + mInfo("db:%s, vgId:%d, memory in dnode:%d, avail:%" PRId64 " used:%" PRId64, pNewVgroup->dbName, pNewVgroup->vgId, + pDnode->id, pDnode->memAvail, pDnode->memUsed); } else { } } diff --git a/source/dnode/mnode/impl/test/func/func.cpp b/source/dnode/mnode/impl/test/func/func.cpp index 53029f5963377a9b20bc0c7c96b399f96bd4a363..64bca96702056a74d54f8ea02306d4be1924d09f 100644 --- a/source/dnode/mnode/impl/test/func/func.cpp +++ b/source/dnode/mnode/impl/test/func/func.cpp @@ -29,7 +29,7 @@ class MndTestFunc : public ::testing::Test { Testbase MndTestFunc::test; -void MndTestFunc::SetCode(SCreateFuncReq *pReq, const char *pCode, int32_t size) { +void MndTestFunc::SetCode(SCreateFuncReq* pReq, const char* pCode, int32_t size) { pReq->pCode = (char*)taosMemoryMalloc(size); memcpy(pReq->pCode, pCode, size); pReq->codeLen = size; @@ -41,9 +41,7 @@ void MndTestFunc::SetComment(SCreateFuncReq* pReq, const char* pComment) { strcpy(pReq->pComment, pComment); } -void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) { - pReq->bufSize = size; -} +void MndTestFunc::SetBufSize(SCreateFuncReq* pReq, int32_t size) { pReq->bufSize = size; } TEST_F(MndTestFunc, 01_Show_Func) { test.SendShowReq(TSDB_MGMT_TABLE_FUNC, "ins_functions", ""); @@ -505,9 +503,8 @@ TEST_F(MndTestFunc, 05_Actual_code) { EXPECT_EQ(pFuncInfo->signature, 5); EXPECT_STREQ("comment1", pFuncInfo->pComment); for (int32_t i = 0; i < 300; ++i) { - EXPECT_EQ(pFuncInfo->pCode[i], (i) % 20); + EXPECT_EQ(pFuncInfo->pCode[i], (i) % 20); } tFreeSRetrieveFuncRsp(&retrieveRsp); } - } \ No newline at end of file diff --git a/source/dnode/mnode/impl/test/stb/stb.cpp b/source/dnode/mnode/impl/test/stb/stb.cpp index 64982951c9c0b405bc3ad9ef06c2094e02f9f42e..dd03917fc29c6b4d4d84cf1a2d0b2d8c0971b1f4 100644 --- a/source/dnode/mnode/impl/test/stb/stb.cpp +++ b/source/dnode/mnode/impl/test/stb/stb.cpp @@ -32,7 +32,8 @@ class MndTestStb : public ::testing::Test { void* BuildAlterStbUpdateTagBytesReq(const char* stbname, const char* tagname, int32_t bytes, int32_t* pContLen); void* BuildAlterStbAddColumnReq(const char* stbname, const char* colname, int32_t* pContLen); void* BuildAlterStbDropColumnReq(const char* stbname, const char* colname, int32_t* pContLen); - void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen, int32_t verInBlock); + void* BuildAlterStbUpdateColumnBytesReq(const char* stbname, const char* colname, int32_t bytes, int32_t* pContLen, + int32_t verInBlock); }; Testbase MndTestStb::test; diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index 3df0fcee172611d2dbd4af1b37dfc858b6967360..18dbea150b2fd38ef84d067cb73546baa95438cc 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -306,8 +306,8 @@ static int32_t sdbReadFileImp(SSdb *pSdb) { pSdb->commitTerm = pSdb->applyTerm; pSdb->commitConfig = pSdb->applyConfig; memcpy(pSdb->tableVer, tableVer, sizeof(tableVer)); - mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, - pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig); + mInfo("read sdb file:%s success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64, file, pSdb->commitIndex, + pSdb->commitTerm, pSdb->commitConfig); _OVER: taosCloseFile(&pFile); @@ -340,9 +340,9 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { snprintf(curfile, sizeof(curfile), "%s%ssdb.data", pSdb->currDir, TD_DIRSEP); mInfo("start to write sdb file, apply index:%" PRId64 " term:%" PRId64 " config:%" PRId64 ", commit index:%" PRId64 - " term:%" PRId64 " config:%" PRId64 ", file:%s", - pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, - curfile); + " term:%" PRId64 " config:%" PRId64 ", file:%s", + pSdb->applyIndex, pSdb->applyTerm, pSdb->applyConfig, pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, + curfile); TdFilePtr pFile = taosOpenFile(tmpfile, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_TRUNC); if (pFile == NULL) { @@ -438,7 +438,7 @@ static int32_t sdbWriteFileImp(SSdb *pSdb) { pSdb->commitTerm = pSdb->applyTerm; pSdb->commitConfig = pSdb->applyConfig; mInfo("write sdb file success, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s", - pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, curfile); + pSdb->commitIndex, pSdb->commitTerm, pSdb->commitConfig, curfile); } terrno = code; @@ -556,9 +556,8 @@ int32_t sdbStartRead(SSdb *pSdb, SSdbIter **ppIter, int64_t *index, int64_t *ter if (term != NULL) *term = commitTerm; if (config != NULL) *config = commitConfig; - mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 - " file:%s", - pIter, commitIndex, commitTerm, commitConfig, pIter->name); + mInfo("sdbiter:%p, is created to read snapshot, commit index:%" PRId64 " term:%" PRId64 " config:%" PRId64 " file:%s", + pIter, commitIndex, commitTerm, commitConfig, pIter->name); return 0; } diff --git a/source/dnode/qnode/inc/qndInt.h b/source/dnode/qnode/inc/qndInt.h index c18a43c4fb20df1b939ee0d9f0ef8813abba58c6..e8ccb75040cbc54ab080e7887a877ce9ff67006b 100644 --- a/source/dnode/qnode/inc/qndInt.h +++ b/source/dnode/qnode/inc/qndInt.h @@ -20,8 +20,8 @@ #include "tlog.h" #include "tmsg.h" -#include "trpc.h" #include "tmsgcb.h" +#include "trpc.h" #include "qnode.h" diff --git a/source/dnode/qnode/src/qnode.c b/source/dnode/qnode/src/qnode.c index efdc8b46934f9677868312c9310cffe989e73ab1..be5ea67b48b1fa436a99f1415ef6c2b9ebe73b38 100644 --- a/source/dnode/qnode/src/qnode.c +++ b/source/dnode/qnode/src/qnode.c @@ -14,10 +14,10 @@ */ #include "executor.h" +#include "libs/function/function.h" #include "qndInt.h" #include "query.h" #include "qworker.h" -#include "libs/function/function.h" SQnode *qndOpen(const SQnodeOpt *pOption) { SQnode *pQnode = taosMemoryCalloc(1, sizeof(SQnode)); @@ -40,8 +40,8 @@ void qndClose(SQnode *pQnode) { taosMemoryFree(pQnode); } -int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { - SReadHandle handle = {.pMsgCb = &pQnode->msgCb}; +int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { + SReadHandle handle = {.pMsgCb = &pQnode->msgCb}; SQWorkerStat stat = {0}; int32_t code = qWorkerGetStat(&handle, pQnode->pQuery, &stat); @@ -60,11 +60,11 @@ int32_t qndGetLoad(SQnode *pQnode, SQnodeLoad *pLoad) { pLoad->numOfProcessedDrop = stat.dropProcessed; pLoad->numOfProcessedHb = stat.hbProcessed; pLoad->numOfProcessedDelete = stat.deleteProcessed; - - return 0; + + return 0; } -int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg * pMsg) { +int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg) { if (TDMT_SCH_QUERY != pMsg->msgType && TDMT_SCH_MERGE_QUERY != pMsg->msgType) { return 0; } diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index d006f12a3f393b7ed562de56a9b14072fa81f260..54d5d9eec25e0a6fa8c6a80961c9a1ea6b5ee4e1 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -95,6 +95,7 @@ typedef struct SMetaEntry SMetaEntry; #define META_READER_NOLOCK 0x1 void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags); +void metaReaderReleaseLock(SMetaReader *pReader); void metaReaderClear(SMetaReader *pReader); int32_t metaGetTableEntryByUid(SMetaReader *pReader, tb_uid_t uid); int metaGetTableEntryByName(SMetaReader *pReader, const char *name); diff --git a/source/dnode/vnode/src/meta/metaEntry.c b/source/dnode/vnode/src/meta/metaEntry.c index 23d7665ba3685d95253a0b844298a2c105ba25c4..b7bdadec03a184a8debc7c2f9a0366fa1ec80734 100644 --- a/source/dnode/vnode/src/meta/metaEntry.c +++ b/source/dnode/vnode/src/meta/metaEntry.c @@ -34,7 +34,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) { if (tEncodeI64(pCoder, pME->ctbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ctbEntry.ttlDays) < 0) return -1; if (tEncodeI32v(pCoder, pME->ctbEntry.commentLen) < 0) return -1; - if (pME->ctbEntry.commentLen > 0){ + if (pME->ctbEntry.commentLen > 0) { if (tEncodeCStr(pCoder, pME->ctbEntry.comment) < 0) return -1; } if (tEncodeI64(pCoder, pME->ctbEntry.suid) < 0) return -1; @@ -43,7 +43,7 @@ int metaEncodeEntry(SEncoder *pCoder, const SMetaEntry *pME) { if (tEncodeI64(pCoder, pME->ntbEntry.ctime) < 0) return -1; if (tEncodeI32(pCoder, pME->ntbEntry.ttlDays) < 0) return -1; if (tEncodeI32v(pCoder, pME->ntbEntry.commentLen) < 0) return -1; - if (pME->ntbEntry.commentLen > 0){ + if (pME->ntbEntry.commentLen > 0) { if (tEncodeCStr(pCoder, pME->ntbEntry.comment) < 0) return -1; } if (tEncodeI32v(pCoder, pME->ntbEntry.ncid) < 0) return -1; @@ -77,9 +77,8 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (tDecodeI64(pCoder, &pME->ctbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ctbEntry.ttlDays) < 0) return -1; if (tDecodeI32v(pCoder, &pME->ctbEntry.commentLen) < 0) return -1; - if (pME->ctbEntry.commentLen > 0){ - if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) - return -1; + if (pME->ctbEntry.commentLen > 0) { + if (tDecodeCStr(pCoder, &pME->ctbEntry.comment) < 0) return -1; } if (tDecodeI64(pCoder, &pME->ctbEntry.suid) < 0) return -1; if (tDecodeTag(pCoder, (STag **)&pME->ctbEntry.pTags) < 0) return -1; // (TODO) @@ -87,7 +86,7 @@ int metaDecodeEntry(SDecoder *pCoder, SMetaEntry *pME) { if (tDecodeI64(pCoder, &pME->ntbEntry.ctime) < 0) return -1; if (tDecodeI32(pCoder, &pME->ntbEntry.ttlDays) < 0) return -1; if (tDecodeI32v(pCoder, &pME->ntbEntry.commentLen) < 0) return -1; - if (pME->ntbEntry.commentLen > 0){ + if (pME->ntbEntry.commentLen > 0) { if (tDecodeCStr(pCoder, &pME->ntbEntry.comment) < 0) return -1; } if (tDecodeI32v(pCoder, &pME->ntbEntry.ncid) < 0) return -1; diff --git a/source/dnode/vnode/src/meta/metaQuery.c b/source/dnode/vnode/src/meta/metaQuery.c index b4fc2c010b251d4a239179749f2c87cffe4ae635..84ce087e555a195fe8ab924f9357626939fe335f 100644 --- a/source/dnode/vnode/src/meta/metaQuery.c +++ b/source/dnode/vnode/src/meta/metaQuery.c @@ -24,6 +24,13 @@ void metaReaderInit(SMetaReader *pReader, SMeta *pMeta, int32_t flags) { } } +void metaReaderReleaseLock(SMetaReader *pReader) { + if (pReader->pMeta && !(pReader->flags & META_READER_NOLOCK)) { + metaULock(pReader->pMeta); + pReader->flags |= META_READER_NOLOCK; + } +} + void metaReaderClear(SMetaReader *pReader) { if (pReader->pMeta && !(pReader->flags & META_READER_NOLOCK)) { metaULock(pReader->pMeta); diff --git a/source/dnode/vnode/src/sma/smaFS.c b/source/dnode/vnode/src/sma/smaFS.c index 55378751eb729b046346d5d5aba3e37cc8c7ad4b..8db36be741f3187834d4b2f2eca4fa302ca524fe 100644 --- a/source/dnode/vnode/src/sma/smaFS.c +++ b/source/dnode/vnode/src/sma/smaFS.c @@ -33,7 +33,7 @@ int32_t tdRSmaFSOpen(SSma *pSma, int64_t version) { SSmaEnv *pEnv = SMA_RSMA_ENV(pSma); SRSmaStat *pStat = NULL; SArray *output = NULL; - + terrno = TSDB_CODE_SUCCESS; if (!pEnv) { diff --git a/source/dnode/vnode/src/sma/smaOpen.c b/source/dnode/vnode/src/sma/smaOpen.c index d9ffda279f16501ac8f39fde7fe14728640db676..ef0d51f0eb7382350da103129df2566f4bc18d15 100644 --- a/source/dnode/vnode/src/sma/smaOpen.c +++ b/source/dnode/vnode/src/sma/smaOpen.c @@ -73,7 +73,7 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p } ASSERT(level >= TSDB_RETENTION_L1 && level <= TSDB_RETENTION_L2); - + freqDuration = convertTimeFromPrecisionToUnit((r + level)->freq, precision, TIME_UNIT_MINUTE); keepDuration = convertTimeFromPrecisionToUnit((r + level)->keep, precision, TIME_UNIT_MINUTE); @@ -92,7 +92,8 @@ static int32_t smaEvalDays(SVnode *pVnode, SRetention *r, int8_t level, int8_t p days = freqDuration; } end: - smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, duration); + smaInfo("vgId:%d, evaluated duration for level %" PRIi8 " is %d, raw val:%d", TD_VID(pVnode), level + 1, days, + duration); return days; } diff --git a/source/dnode/vnode/src/sma/smaRollup.c b/source/dnode/vnode/src/sma/smaRollup.c index 155086a5a8fd771447d465d5a1685b280823924a..722a3f479e47c5e19fa3419fc244accea5282df6 100644 --- a/source/dnode/vnode/src/sma/smaRollup.c +++ b/source/dnode/vnode/src/sma/smaRollup.c @@ -321,7 +321,7 @@ static int32_t tdSetRSmaInfoItemParams(SSma *pSma, SRSmaParam *param, SRSmaStat } taosMemoryFree(s); } - pStreamState = streamStateOpen(taskInfDir, NULL, true); + pStreamState = streamStateOpen(taskInfDir, NULL, true, -1, -1); if (!pStreamState) { terrno = TSDB_CODE_RSMA_STREAM_STATE_OPEN; return TSDB_CODE_FAILED; diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 83cb3955e3c15b6b83ff8f52a5f458a52ffc0faf..59a9f326427a64904bda2c5d86b6619587be2b47 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -890,7 +890,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) { // expand executor if (pTask->taskLevel == TASK_LEVEL__SOURCE) { - pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false); + pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1); if (pTask->pState == NULL) { return -1; } @@ -904,7 +904,7 @@ int32_t tqExpandTask(STQ* pTq, SStreamTask* pTask) { pTask->exec.executor = qCreateStreamExecTaskInfo(pTask->exec.qmsg, &handle); ASSERT(pTask->exec.executor); } else if (pTask->taskLevel == TASK_LEVEL__AGG) { - pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false); + pTask->pState = streamStateOpen(pTq->pStreamMeta->path, pTask, false, -1, -1); if (pTask->pState == NULL) { return -1; } diff --git a/source/dnode/vnode/src/tq/tqMeta.c b/source/dnode/vnode/src/tq/tqMeta.c index 1c5eee73785841eb23debb0909ebd8fd1b12ac2e..8e4bc34e0cf016878595117e65539ced34440c37 100644 --- a/source/dnode/vnode/src/tq/tqMeta.c +++ b/source/dnode/vnode/src/tq/tqMeta.c @@ -177,6 +177,7 @@ int32_t tqMetaRestoreCheckInfo(STQ* pTq) { tDecoderClear(&decoder); if (taosHashPut(pTq->pCheckInfo, info.topic, strlen(info.topic), &info, sizeof(STqCheckInfo)) < 0) { terrno = TSDB_CODE_OUT_OF_MEMORY; + tdbFree(pKey); tdbTbcClose(pCur); return -1; } @@ -328,4 +329,3 @@ int32_t tqMetaRestoreHandle(STQ* pTq) { tdbTbcClose(pCur); return 0; } - diff --git a/source/dnode/vnode/src/tsdb/tsdbCache.c b/source/dnode/vnode/src/tsdb/tsdbCache.c index ac6be9af2d85fa15387d8fd8b1c760055fe061c0..50c7a7cc53751eee9b1e73d5d4c4472134547c82 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCache.c +++ b/source/dnode/vnode/src/tsdb/tsdbCache.c @@ -429,7 +429,8 @@ typedef struct { SDataFReader *pDataFReader; TSDBROW row; - SMergeTree mergeTree; + SMergeTree mergeTree; + SMergeTree *pMergeTree; } SFSLastNextRowIter; static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { @@ -444,11 +445,14 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { case SFSLASTNEXTROW_FILESET: { SDFileSet *pFileSet = NULL; _next_fileset: + if (state->pMergeTree != NULL) { + tMergeTreeClose(state->pMergeTree); + state->pMergeTree = NULL; + } + if (--state->iFileSet >= 0) { pFileSet = (SDFileSet *)taosArrayGet(state->aDFileSet, state->iFileSet); } else { - tMergeTreeClose(&state->mergeTree); - *ppRow = NULL; return code; } @@ -460,10 +464,10 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { tMergeTreeOpen(&state->mergeTree, 1, state->pDataFReader, state->suid, state->uid, &(STimeWindow){.skey = TSKEY_MIN, .ekey = TSKEY_MAX}, &(SVersionRange){.minVer = 0, .maxVer = UINT64_MAX}, pLoadInfo, true, NULL); + state->pMergeTree = &state->mergeTree; bool hasVal = tMergeTreeNext(&state->mergeTree); if (!hasVal) { state->state = SFSLASTNEXTROW_FILESET; - tMergeTreeClose(&state->mergeTree); goto _next_fileset; } state->state = SFSLASTNEXTROW_BLOCKROW; @@ -475,6 +479,7 @@ static int32_t getNextRowFromFSLast(void *iter, TSDBROW **ppRow) { if (!hasVal) { state->state = SFSLASTNEXTROW_FILESET; } + return code; default: ASSERT(0); @@ -486,6 +491,11 @@ _err: tsdbDataFReaderClose(&state->pDataFReader); state->pDataFReader = NULL; } + if (state->pMergeTree != NULL) { + tMergeTreeClose(state->pMergeTree); + state->pMergeTree = NULL; + } + *ppRow = NULL; return code; @@ -504,6 +514,11 @@ int32_t clearNextRowFromFSLast(void *iter) { state->pDataFReader = NULL; } + if (state->pMergeTree != NULL) { + tMergeTreeClose(state->pMergeTree); + state->pMergeTree = NULL; + } + return code; } diff --git a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c index 4a6f6777875a7c7a5e855f2a57db38383d3d0d15..0b7d1cbaf4b0d21799e1e6bea56168facda996ac 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMergeTree.c +++ b/source/dnode/vnode/src/tsdb/tsdbMergeTree.c @@ -17,28 +17,28 @@ // 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; + 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(STSchema* pSchema, int16_t* colList, int32_t numOfCols) { - SSttBlockLoadInfo* pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo)); +SSttBlockLoadInfo *tCreateLastBlockLoadInfo(STSchema *pSchema, int16_t *colList, int32_t numOfCols) { + SSttBlockLoadInfo *pLoadInfo = taosMemoryCalloc(TSDB_DEFAULT_STT_FILE, sizeof(SSttBlockLoadInfo)); if (pLoadInfo == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; + terrno = TSDB_CODE_OUT_OF_MEMORY; return NULL; } - for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { + 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; @@ -62,8 +62,8 @@ SSttBlockLoadInfo* tCreateLastBlockLoadInfo(STSchema* pSchema, int16_t* colList, return pLoadInfo; } -void resetLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) { - for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { +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; @@ -75,15 +75,15 @@ void resetLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) { } } -void getLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo, int64_t* blocks, double* el) { - for(int32_t i = 0; i < TSDB_DEFAULT_STT_FILE; ++i) { +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) { +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; @@ -98,15 +98,25 @@ void* destroyLastBlockLoadInfo(SSttBlockLoadInfo* pLoadInfo) { return NULL; } -static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { +static SBlockData *loadLastBlock(SLDataIter *pIter, const char *idStr) { int32_t code = 0; - SSttBlockLoadInfo* pInfo = pIter->pBlockLoadInfo; - if (pInfo->blockIndex[0] == pIter->iSttBlk) { + SSttBlockLoadInfo *pInfo = pIter->pBlockLoadInfo; + if (pInfo->blockIndex[0] == pIter->iSttBlk) { + if (pInfo->currentLoadBlockIndex != 0) { + tsdbDebug("current load index is set to 0, block index:%d, file index:%d, due to uid:%" PRIu64 ", load data, %s", + pIter->iSttBlk, pIter->iStt, pIter->uid, idStr); + pInfo->currentLoadBlockIndex = 0; + } return &pInfo->blockData[0]; } if (pInfo->blockIndex[1] == pIter->iSttBlk) { + if (pInfo->currentLoadBlockIndex != 1) { + tsdbDebug("current load index is set to 1, block index:%d, file index:%d, due to uid:%" PRIu64 ", load data, %s", + pIter->iSttBlk, pIter->iStt, pIter->uid, idStr); + pInfo->currentLoadBlockIndex = 1; + } return &pInfo->blockData[1]; } @@ -114,7 +124,7 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { if (pIter->pSttBlk != NULL) { // current block not loaded yet int64_t st = taosGetTimestampUs(); - SBlockData* pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; + SBlockData *pBlock = &pInfo->blockData[pInfo->currentLoadBlockIndex]; TABLEID id = {0}; if (pIter->pSttBlk->suid != 0) { @@ -126,22 +136,27 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { tBlockDataInit(pBlock, &id, pInfo->pSchema, pInfo->colIds, pInfo->numOfCols); code = tsdbReadSttBlock(pIter->pReader, pIter->iStt, pIter->pSttBlk, pBlock); - double el = (taosGetTimestampUs() - st)/ 1000.0; + 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); + tsdbDebug("read last block, total load:%d, trigger by uid:%" PRIu64 + ", last file index:%d, last block index:%d, entry:%d, %p, elapsed time:%.2f ms, %s", + pInfo->loadBlocks, pIter->uid, pIter->iStt, pIter->iSttBlk, pInfo->currentLoadBlockIndex, pBlock, el, + idStr); if (code != TSDB_CODE_SUCCESS) { goto _exit; } pInfo->blockIndex[pInfo->currentLoadBlockIndex] = pIter->iSttBlk; + tsdbDebug("last block index list:%d, %d, %s", pInfo->blockIndex[0], pInfo->blockIndex[1], idStr); + pIter->iRow = (pIter->backward) ? pInfo->blockData[pInfo->currentLoadBlockIndex].nRow : -1; } return &pInfo->blockData[pInfo->currentLoadBlockIndex]; - _exit: +_exit: if (code != TSDB_CODE_SUCCESS) { terrno = code; } @@ -150,16 +165,17 @@ static SBlockData* loadLastBlock(SLDataIter *pIter, const char* idStr) { } // 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) { +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; + 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) { +static int32_t binarySearchForStartBlock(SSttBlk *pBlockList, int32_t num, uint64_t uid, int32_t backward) { int32_t midPos = -1; if (num <= 0) { return -1; @@ -195,16 +211,17 @@ static int32_t binarySearchForStartBlock(SSttBlk*pBlockList, int32_t num, uint64 } } -static FORCE_INLINE int32_t findEarliestRow(int32_t index, uint64_t uid, const uint64_t* uidList, int32_t num, int32_t 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; + 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) { +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; @@ -236,8 +253,8 @@ static int32_t binarySearchForStartRowIndex(uint64_t* uidList, int32_t num, uint } 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, - const char* idStr) { + uint64_t uid, STimeWindow *pTimeWindow, SVersionRange *pRange, SSttBlockLoadInfo *pBlockLoadInfo, + const char *idStr) { int32_t code = 0; *pIter = taosMemoryCalloc(1, sizeof(SLDataIter)); if (*pIter == NULL) { @@ -277,7 +294,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t } else if (pStart->suid != suid) { // no qualified stt block existed (*pIter)->iSttBlk = -1; - double el = (taosGetTimestampUs() - st)/1000.0; + double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr); return code; } @@ -302,7 +319,7 @@ int32_t tLDataIterOpen(struct SLDataIter **pIter, SDataFReader *pReader, int32_t } } - double el = (taosGetTimestampUs() - st)/1000.0; + double el = (taosGetTimestampUs() - st) / 1000.0; tsdbDebug("load the last file info completed, elapsed time:%.2fms, %s", el, idStr); } @@ -319,12 +336,12 @@ _exit: return code; } -void tLDataIterClose(SLDataIter *pIter) { - taosMemoryFree(pIter); -} +void tLDataIterClose(SLDataIter *pIter) { taosMemoryFree(pIter); } -void tLDataIterNextBlock(SLDataIter *pIter) { +void tLDataIterNextBlock(SLDataIter *pIter, const char *idStr) { int32_t step = pIter->backward ? -1 : 1; + int32_t oldIndex = pIter->iSttBlk; + pIter->iSttBlk += step; int32_t index = -1; @@ -371,20 +388,25 @@ void tLDataIterNextBlock(SLDataIter *pIter) { if (index != -1) { pIter->iSttBlk = index; pIter->pSttBlk = (SSttBlk *)taosArrayGet(pIter->pBlockLoadInfo->aSttBlk, pIter->iSttBlk); + tsdbDebug("try next last file block:%d from %d, trigger by uid:%" PRIu64 ", file index:%d, %s", pIter->iSttBlk, + oldIndex, pIter->uid, pIter->iStt, idStr); + } else { + tsdbDebug("no more last block qualified, uid:%" PRIu64 ", file index::%d, %s", pIter->uid, oldIndex, idStr); } } -static void findNextValidRow(SLDataIter *pIter, const char* idStr) { +static void findNextValidRow(SLDataIter *pIter, const char *idStr) { int32_t step = pIter->backward ? -1 : 1; - bool hasVal = false; - int32_t i = pIter->iRow; + 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 == 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; @@ -394,15 +416,11 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) { 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) { + if (pBlockData->aUid[i] > pIter->uid) { break; } } else { - /*if (pBlockData->aUid[i] > pIter->uid) { - continue; - } else */if (pBlockData->aUid[i] < pIter->uid) { + if (pBlockData->aUid[i] < pIter->uid) { break; } } @@ -440,7 +458,7 @@ static void findNextValidRow(SLDataIter *pIter, const char* idStr) { pIter->iRow = (hasVal) ? i : -1; } -bool tLDataIterNextRow(SLDataIter *pIter, const char* idStr) { +bool tLDataIterNextRow(SLDataIter *pIter, const char *idStr) { int32_t code = 0; int32_t step = pIter->backward ? -1 : 1; @@ -449,7 +467,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char* idStr) { return false; } - int32_t iBlockL = pIter->iSttBlk; + int32_t iBlockL = pIter->iSttBlk; SBlockData *pBlockData = loadLastBlock(pIter, idStr); pIter->iRow += step; @@ -457,7 +475,7 @@ bool tLDataIterNextRow(SLDataIter *pIter, const char* idStr) { findNextValidRow(pIter, idStr); if (pIter->iRow >= pBlockData->nRow || pIter->iRow < 0) { - tLDataIterNextBlock(pIter); + tLDataIterNextBlock(pIter, idStr); if (pIter->pSttBlk == NULL) { // no more data goto _exit; } @@ -527,8 +545,9 @@ int32_t tMergeTreeOpen(SMergeTree *pMTree, int8_t backward, SDataFReader *pFRead pMTree->destroyLoadInfo = destroyLoadInfo; 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, &pMTree->pLoadInfo[i], pMTree->idStr); + struct SLDataIter *pIter = NULL; + code = tLDataIterOpen(&pIter, pFReader, i, pMTree->backward, suid, uid, pTimeWindow, pVerRange, + &pMTree->pLoadInfo[i], pMTree->idStr); if (code != TSDB_CODE_SUCCESS) { goto _end; } diff --git a/source/dnode/vnode/src/tsdb/tsdbRead.c b/source/dnode/vnode/src/tsdb/tsdbRead.c index 1ed050f64f72ced65cd3c39883886f962dabd177..a7850f31141b64682a33e9e2e3d07ac0efb022b3 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead.c @@ -1645,6 +1645,7 @@ static int32_t doMergeFileBlockAndLastBlock(SLastBlockReader* pLastBlockReader, STSRow* pTSRow = NULL; SRowMerger merge = {0}; TSDBROW fRow = tMergeTreeGetRow(&pLastBlockReader->mergeTree); + tsdbTrace("fRow ptr:%p, %d, uid:%" PRIu64 ", %s", fRow.pBlockData, fRow.iRow, pLastBlockReader->uid, pReader->idStr); // only last block exists if ((!mergeBlockData) || (tsLastBlock != pBlockData->aTSKEY[pDumpInfo->rowIndex])) { diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index 2b61bc6f33f8aedb2ede0506083399dcb0f344e7..e18379fe8aa331a71ffc3378707170bb93da629c 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -74,7 +74,7 @@ int vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) { schemaTag = mer1.me.stbEntry.schemaTag; metaRsp.suid = mer1.me.uid; } else if (mer1.me.type == TSDB_CHILD_TABLE) { - metaReaderInit(&mer2, pVnode->pMeta, 0); + metaReaderInit(&mer2, pVnode->pMeta, META_READER_NOLOCK); if (metaGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit; strcpy(metaRsp.stbName, mer2.me.name); diff --git a/source/dnode/vnode/src/vnd/vnodeSync.c b/source/dnode/vnode/src/vnd/vnodeSync.c index 353c3874c00173ad1628cdf28747e08382cc8152..ab7fb001f017e2f6917d1407aa102fbb86434b02 100644 --- a/source/dnode/vnode/src/vnd/vnodeSync.c +++ b/source/dnode/vnode/src/vnd/vnodeSync.c @@ -799,4 +799,3 @@ bool vnodeIsLeader(SVnode *pVnode) { return true; } - diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 33623f1bdd206a2bf3871650c591efbbd96cd3c4..0278a11f809fbdd8b6eeb1712c8eb220fea72990 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -20,8 +20,8 @@ #include #include -#include #include +#include #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wwrite-strings" @@ -424,7 +424,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { TSDB_DATA_TYPE_DOUBLE, TSDB_DATA_TYPE_VARCHAR, TSDB_DATA_TYPE_NCHAR}; // last 2 columns for group by tags // int32_t tSmaTypeArray[tSmaNumOfCols] = {TSDB_DATA_TYPE_TIMESTAMP, TSDB_DATA_TYPE_BOOL}; - const char *tSmaGroupbyTags[tSmaGroupSize * tSmaNumOfTags] = {"BeiJing", "HaiDian", "BeiJing", "ChaoYang", + const char *tSmaGroupbyTags[tSmaGroupSize * tSmaNumOfTags] = {"BeiJing", "HaiDian", "BeiJing", "ChaoYang", "ShangHai", "PuDong", "ShangHai", "MinHang"}; TSKEY tSmaSKeyMs = (int64_t)1648535332 * 1000; int64_t tSmaIntervalMs = tSma.interval * 60 * 1000; @@ -441,7 +441,6 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pDataBlock->pDataBlock = taosArrayInit(tSmaNumOfCols, sizeof(SColumnInfoData *)); EXPECT_NE(pDataBlock->pDataBlock, nullptr); for (int32_t c = 0; c < tSmaNumOfCols; ++c) { - SColumnInfoData *pColInfoData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData)); EXPECT_NE(pColInfoData, nullptr); diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 9b62581051daac9c232409c0cb30d379e3a4d596..fe71987103aedbee555b67e99c95a7fb6fb2fb0e 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -21,18 +21,18 @@ extern "C" { #endif #include "catalog.h" -#include "tcommon.h" #include "query.h" +#include "tcommon.h" #define CTG_DEFAULT_CACHE_CLUSTER_NUMBER 6 -#define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100 -#define CTG_DEFAULT_CACHE_DB_NUMBER 20 +#define CTG_DEFAULT_CACHE_VGROUP_NUMBER 100 +#define CTG_DEFAULT_CACHE_DB_NUMBER 20 #define CTG_DEFAULT_CACHE_TBLMETA_NUMBER 1000 -#define CTG_DEFAULT_RENT_SECOND 10 -#define CTG_DEFAULT_RENT_SLOT_SIZE 10 -#define CTG_DEFAULT_MAX_RETRY_TIMES 3 -#define CTG_DEFAULT_BATCH_NUM 64 -#define CTG_DEFAULT_FETCH_NUM 8 +#define CTG_DEFAULT_RENT_SECOND 10 +#define CTG_DEFAULT_RENT_SLOT_SIZE 10 +#define CTG_DEFAULT_MAX_RETRY_TIMES 3 +#define CTG_DEFAULT_BATCH_NUM 64 +#define CTG_DEFAULT_FETCH_NUM 8 #define CTG_RENT_SLOT_SECOND 1.5 @@ -90,7 +90,6 @@ typedef enum { CTG_TASK_DONE, } CTG_TASK_STATUS; - typedef struct SCtgDebug { bool lockEnable; bool cacheEnable; @@ -108,19 +107,19 @@ typedef struct SCtgTbCacheInfo { typedef struct SCtgTbMetaCtx { SCtgTbCacheInfo tbInfo; - int32_t vgId; - SName* pName; - int32_t flag; + int32_t vgId; + SName* pName; + int32_t flag; } SCtgTbMetaCtx; typedef struct SCtgFetch { - int32_t dbIdx; - int32_t tbIdx; - int32_t fetchIdx; - int32_t resIdx; - int32_t flag; + int32_t dbIdx; + int32_t tbIdx; + int32_t fetchIdx; + int32_t resIdx; + int32_t flag; SCtgTbCacheInfo tbInfo; - int32_t vgId; + int32_t vgId; } SCtgFetch; typedef struct SCtgTbMetasCtx { @@ -153,7 +152,7 @@ typedef struct SCtgDbInfoCtx { } SCtgDbInfoCtx; typedef struct SCtgTbHashCtx { - char dbFName[TSDB_DB_FNAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; SName* pName; } SCtgTbHashCtx; @@ -164,7 +163,6 @@ typedef struct SCtgTbHashsCtx { SArray* pFetchs; } SCtgTbHashsCtx; - typedef struct SCtgIndexCtx { char indexFName[TSDB_INDEX_FNAME_LEN]; } SCtgIndexCtx; @@ -181,118 +179,116 @@ typedef STableIndexRsp STableIndex; typedef struct SCtgTbCache { SRWLatch metaLock; - STableMeta *pMeta; + STableMeta* pMeta; SRWLatch indexLock; - STableIndex *pIndex; + STableIndex* pIndex; } SCtgTbCache; typedef struct SCtgVgCache { - SRWLatch vgLock; - SDBVgInfo *vgInfo; + SRWLatch vgLock; + SDBVgInfo* vgInfo; } SCtgVgCache; typedef struct SCtgDBCache { - SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads - uint64_t dbId; - int8_t deleted; - SCtgVgCache vgCache; - SHashObj *tbCache; // key:tbname, value:SCtgTbCache - SHashObj *stbCache; // key:suid, value:char* + SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads + uint64_t dbId; + int8_t deleted; + SCtgVgCache vgCache; + SHashObj* tbCache; // key:tbname, value:SCtgTbCache + SHashObj* stbCache; // key:suid, value:char* } SCtgDBCache; typedef struct SCtgRentSlot { SRWLatch lock; bool needSort; - SArray *meta; // element is SDbVgVersion or SSTableVersion + SArray* meta; // element is SDbVgVersion or SSTableVersion } SCtgRentSlot; typedef struct SCtgRentMgmt { - int8_t type; - uint16_t slotNum; - uint16_t slotRIdx; - int64_t lastReadMsec; - SCtgRentSlot *slots; + int8_t type; + uint16_t slotNum; + uint16_t slotRIdx; + int64_t lastReadMsec; + SCtgRentSlot* slots; } SCtgRentMgmt; typedef struct SCtgUserAuth { int32_t version; SRWLatch lock; bool superUser; - SHashObj *createdDbs; - SHashObj *readDbs; - SHashObj *writeDbs; + SHashObj* createdDbs; + SHashObj* readDbs; + SHashObj* writeDbs; } SCtgUserAuth; typedef struct SCatalog { - uint64_t clusterId; - SHashObj *userCache; //key:user, value:SCtgUserAuth - SHashObj *dbCache; //key:dbname, value:SCtgDBCache - SCtgRentMgmt dbRent; - SCtgRentMgmt stbRent; + uint64_t clusterId; + SHashObj* userCache; // key:user, value:SCtgUserAuth + SHashObj* dbCache; // key:dbname, value:SCtgDBCache + SCtgRentMgmt dbRent; + SCtgRentMgmt stbRent; } SCatalog; typedef struct SCtgBatch { - int32_t batchId; - int32_t msgType; - int32_t msgSize; - SArray* pMsgs; + int32_t batchId; + int32_t msgType; + int32_t msgSize; + SArray* pMsgs; SRequestConnInfo conn; - char dbFName[TSDB_DB_FNAME_LEN]; - SArray* pTaskIds; - SArray* pMsgIdxs; + char dbFName[TSDB_DB_FNAME_LEN]; + SArray* pTaskIds; + SArray* pMsgIdxs; } SCtgBatch; typedef struct SCtgJob { - int64_t refId; - int32_t batchId; - SHashObj* pBatchs; - SArray* pTasks; - int32_t subTaskNum; - int32_t taskDone; - SMetaData jobRes; - int32_t jobResCode; - int32_t taskIdx; - SRWLatch taskLock; - - uint64_t queryId; - SCatalog* pCtg; - SRequestConnInfo conn; - void* userParam; - catalogCallback userFp; - int32_t tbMetaNum; - int32_t tbHashNum; - int32_t dbVgNum; - int32_t udfNum; - int32_t qnodeNum; - int32_t dnodeNum; - int32_t dbCfgNum; - int32_t indexNum; - int32_t userNum; - int32_t dbInfoNum; - int32_t tbIndexNum; - int32_t tbCfgNum; - int32_t svrVerNum; + int64_t refId; + int32_t batchId; + SHashObj* pBatchs; + SArray* pTasks; + int32_t subTaskNum; + int32_t taskDone; + SMetaData jobRes; + int32_t jobResCode; + int32_t taskIdx; + SRWLatch taskLock; + + uint64_t queryId; + SCatalog* pCtg; + SRequestConnInfo conn; + void* userParam; + catalogCallback userFp; + int32_t tbMetaNum; + int32_t tbHashNum; + int32_t dbVgNum; + int32_t udfNum; + int32_t qnodeNum; + int32_t dnodeNum; + int32_t dbCfgNum; + int32_t indexNum; + int32_t userNum; + int32_t dbInfoNum; + int32_t tbIndexNum; + int32_t tbCfgNum; + int32_t svrVerNum; } SCtgJob; typedef struct SCtgMsgCtx { - int32_t reqType; - void* lastOut; - void* out; - char* target; + int32_t reqType; + void* lastOut; + void* out; + char* target; SHashObj* pBatchs; } SCtgMsgCtx; - typedef struct SCtgTaskCallbackParam { - uint64_t queryId; - int64_t refId; - SArray* taskId; - int32_t reqType; - int32_t batchId; - SArray* msgIdx; + uint64_t queryId; + int64_t refId; + SArray* taskId; + int32_t reqType; + int32_t batchId; + SArray* msgIdx; } SCtgTaskCallbackParam; - typedef struct SCtgTask SCtgTask; typedef int32_t (*ctgSubTaskCbFp)(SCtgTask*); @@ -325,7 +321,7 @@ typedef struct SCtgTaskReq { typedef int32_t (*ctgInitTaskFp)(SCtgJob*, int32_t, void*); typedef int32_t (*ctgLanchTaskFp)(SCtgTask*); -typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTaskReq*, int32_t, const SDataBuf *, int32_t); +typedef int32_t (*ctgHandleTaskMsgRspFp)(SCtgTaskReq*, int32_t, const SDataBuf*, int32_t); typedef int32_t (*ctgDumpTaskResFp)(SCtgTask*); typedef int32_t (*ctgCloneTaskResFp)(SCtgTask*, void**); typedef int32_t (*ctgCompTaskFp)(SCtgTask*, void*, bool*); @@ -340,7 +336,6 @@ typedef struct SCtgAsyncFps { } SCtgAsyncFps; typedef struct SCtgApiStat { - #if defined(WINDOWS) || defined(_TD_DARWIN_64) size_t avoidCompilationErrors; #endif @@ -371,9 +366,9 @@ typedef struct SCtgCacheStat { } SCtgCacheStat; typedef struct SCatalogStat { - SCtgApiStat api; - SCtgRuntimeStat runtime; - SCtgCacheStat cache; + SCtgApiStat api; + SCtgRuntimeStat runtime; + SCtgCacheStat cache; } SCatalogStat; typedef struct SCtgUpdateMsgHeader { @@ -381,9 +376,9 @@ typedef struct SCtgUpdateMsgHeader { } SCtgUpdateMsgHeader; typedef struct SCtgUpdateVgMsg { - SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - uint64_t dbId; + SCatalog* pCtg; + char dbFName[TSDB_DB_FNAME_LEN]; + uint64_t dbId; SDBVgInfo* dbInfo; } SCtgUpdateVgMsg; @@ -394,33 +389,32 @@ typedef struct SCtgUpdateTbMetaMsg { typedef struct SCtgDropDBMsg { SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - uint64_t dbId; + char dbFName[TSDB_DB_FNAME_LEN]; + uint64_t dbId; } SCtgDropDBMsg; typedef struct SCtgDropDbVgroupMsg { SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; } SCtgDropDbVgroupMsg; - typedef struct SCtgDropStbMetaMsg { SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - char stbName[TSDB_TABLE_NAME_LEN]; - uint64_t dbId; - uint64_t suid; + char dbFName[TSDB_DB_FNAME_LEN]; + char stbName[TSDB_TABLE_NAME_LEN]; + uint64_t dbId; + uint64_t suid; } SCtgDropStbMetaMsg; typedef struct SCtgDropTblMetaMsg { SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - char tbName[TSDB_TABLE_NAME_LEN]; - uint64_t dbId; + char dbFName[TSDB_DB_FNAME_LEN]; + char tbName[TSDB_TABLE_NAME_LEN]; + uint64_t dbId; } SCtgDropTblMetaMsg; typedef struct SCtgUpdateUserMsg { - SCatalog* pCtg; + SCatalog* pCtg; SGetUserAuthRsp userAuth; } SCtgUpdateUserMsg; @@ -430,63 +424,63 @@ typedef struct SCtgUpdateTbIndexMsg { } SCtgUpdateTbIndexMsg; typedef struct SCtgDropTbIndexMsg { - SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - char tbName[TSDB_TABLE_NAME_LEN]; + SCatalog* pCtg; + char dbFName[TSDB_DB_FNAME_LEN]; + char tbName[TSDB_TABLE_NAME_LEN]; } SCtgDropTbIndexMsg; typedef struct SCtgClearCacheMsg { - SCatalog* pCtg; - bool freeCtg; + SCatalog* pCtg; + bool freeCtg; } SCtgClearCacheMsg; typedef struct SCtgUpdateEpsetMsg { SCatalog* pCtg; - char dbFName[TSDB_DB_FNAME_LEN]; - int32_t vgId; - SEpSet epSet; + char dbFName[TSDB_DB_FNAME_LEN]; + int32_t vgId; + SEpSet epSet; } SCtgUpdateEpsetMsg; typedef struct SCtgCacheOperation { - int32_t opId; - void *data; - bool syncOp; - tsem_t rspSem; - bool stopQueue; - bool unLocked; + int32_t opId; + void* data; + bool syncOp; + tsem_t rspSem; + bool stopQueue; + bool unLocked; } SCtgCacheOperation; typedef struct SCtgQNode { - SCtgCacheOperation *op; - struct SCtgQNode *next; + SCtgCacheOperation* op; + struct SCtgQNode* next; } SCtgQNode; typedef struct SCtgQueue { - SRWLatch qlock; - bool stopQueue; - SCtgQNode *head; - SCtgQNode *tail; - tsem_t reqSem; - uint64_t qRemainNum; + SRWLatch qlock; + bool stopQueue; + SCtgQNode* head; + SCtgQNode* tail; + tsem_t reqSem; + uint64_t qRemainNum; } SCtgQueue; typedef struct SCatalogMgmt { - bool exit; - int32_t jobPool; - SRWLatch lock; - SCtgQueue queue; - TdThread updateThread; - SHashObj *pCluster; //key: clusterId, value: SCatalog* - SCatalogStat stat; - SCatalogCfg cfg; + bool exit; + int32_t jobPool; + SRWLatch lock; + SCtgQueue queue; + TdThread updateThread; + SHashObj* pCluster; // key: clusterId, value: SCatalog* + SCatalogStat stat; + SCatalogCfg cfg; } SCatalogMgmt; -typedef uint32_t (*tableNameHashFp)(const char *, uint32_t); -typedef int32_t (*ctgOpFunc)(SCtgCacheOperation *); +typedef uint32_t (*tableNameHashFp)(const char*, uint32_t); +typedef int32_t (*ctgOpFunc)(SCtgCacheOperation*); typedef struct SCtgOperation { - int32_t opId; - char name[32]; + int32_t opId; + char name[32]; ctgOpFunc func; } SCtgOperation; @@ -495,16 +489,16 @@ typedef struct SCtgOperation { #define CTG_STAT_INC(_item, _n) atomic_add_fetch_64(&(_item), _n) #define CTG_STAT_DEC(_item, _n) atomic_sub_fetch_64(&(_item), _n) -#define CTG_STAT_GET(_item) atomic_load_64(&(_item)) +#define CTG_STAT_GET(_item) atomic_load_64(&(_item)) -#define CTG_RT_STAT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.runtime.item, n)) +#define CTG_RT_STAT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.runtime.item, n)) #define CTG_CACHE_STAT_INC(item, n) (CTG_STAT_INC(gCtgMgmt.stat.cache.item, n)) #define CTG_CACHE_STAT_DEC(item, n) (CTG_STAT_DEC(gCtgMgmt.stat.cache.item, n)) -#define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE) +#define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE) #define CTG_IS_META_CTABLE(type) ((type) == META_TYPE_CTABLE) -#define CTG_IS_META_TABLE(type) ((type) == META_TYPE_TABLE) -#define CTG_IS_META_BOTH(type) ((type) == META_TYPE_BOTH_TABLE) +#define CTG_IS_META_TABLE(type) ((type) == META_TYPE_TABLE) +#define CTG_IS_META_BOTH(type) ((type) == META_TYPE_BOTH_TABLE) #define CTG_FLAG_STB 0x1 #define CTG_FLAG_NOT_STB 0x2 @@ -514,199 +508,263 @@ typedef struct SCtgOperation { #define CTG_FLAG_SET(_flag, _v) ((_flag) |= (_v)) -#define CTG_FLAG_IS_STB(_flag) ((_flag) & CTG_FLAG_STB) -#define CTG_FLAG_IS_NOT_STB(_flag) ((_flag) & CTG_FLAG_NOT_STB) -#define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag) & CTG_FLAG_UNKNOWN_STB) -#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag) & CTG_FLAG_SYS_DB) -#define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag) & CTG_FLAG_FORCE_UPDATE) -#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB) -#define CTG_FLAG_SET_STB(_flag, tbType) do { (_flag) |= ((tbType) == TSDB_SUPER_TABLE) ? CTG_FLAG_STB : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); } while (0) -#define CTG_FLAG_MAKE_STB(_isStb) (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)) -#define CTG_FLAG_MATCH_STB(_flag, tbType) (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) +#define CTG_FLAG_IS_STB(_flag) ((_flag)&CTG_FLAG_STB) +#define CTG_FLAG_IS_NOT_STB(_flag) ((_flag)&CTG_FLAG_NOT_STB) +#define CTG_FLAG_IS_UNKNOWN_STB(_flag) ((_flag)&CTG_FLAG_UNKNOWN_STB) +#define CTG_FLAG_IS_SYS_DB(_flag) ((_flag)&CTG_FLAG_SYS_DB) +#define CTG_FLAG_IS_FORCE_UPDATE(_flag) ((_flag)&CTG_FLAG_FORCE_UPDATE) +#define CTG_FLAG_SET_SYS_DB(_flag) ((_flag) |= CTG_FLAG_SYS_DB) +#define CTG_FLAG_SET_STB(_flag, tbType) \ + do { \ + (_flag) |= ((tbType) == TSDB_SUPER_TABLE) \ + ? CTG_FLAG_STB \ + : ((tbType) > TSDB_SUPER_TABLE ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB); \ + } while (0) +#define CTG_FLAG_MAKE_STB(_isStb) \ + (((_isStb) == 1) ? CTG_FLAG_STB : ((_isStb) == 0 ? CTG_FLAG_NOT_STB : CTG_FLAG_UNKNOWN_STB)) +#define CTG_FLAG_MATCH_STB(_flag, tbType) \ + (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || \ + (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) -#define CTG_GET_TASK_MSGCTX(_task, _id) (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx) +#define CTG_GET_TASK_MSGCTX(_task, _id) \ + (((CTG_TASK_GET_TB_META_BATCH == (_task)->type) || (CTG_TASK_GET_TB_HASH_BATCH == (_task)->type)) \ + ? taosArrayGet((_task)->msgCtxs, (_id)) \ + : &(_task)->msgCtx) -#define CTG_META_SIZE(pMeta) (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) +#define CTG_META_SIZE(pMeta) \ + (sizeof(STableMeta) + ((pMeta)->tableInfo.numOfTags + (pMeta)->tableInfo.numOfColumns) * sizeof(SSchema)) #define CTG_TABLE_NOT_EXIST(code) (code == CTG_ERR_CODE_TABLE_NOT_EXIST) -#define CTG_DB_NOT_EXIST(code) (code == TSDB_CODE_MND_DB_NOT_EXIST) +#define CTG_DB_NOT_EXIST(code) (code == TSDB_CODE_MND_DB_NOT_EXIST) + +#define ctgFatal(param, ...) qFatal("CTG:%p " param, pCtg, __VA_ARGS__) +#define ctgError(param, ...) qError("CTG:%p " param, pCtg, __VA_ARGS__) +#define ctgWarn(param, ...) qWarn("CTG:%p " param, pCtg, __VA_ARGS__) +#define ctgInfo(param, ...) qInfo("CTG:%p " param, pCtg, __VA_ARGS__) +#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__) +#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__) + +#define CTG_LOCK_DEBUG(...) \ + do { \ + if (gCTGDebug.lockEnable) { \ + qDebug(__VA_ARGS__); \ + } \ + } while (0) +#define CTG_CACHE_DEBUG(...) \ + do { \ + if (gCTGDebug.cacheEnable) { \ + qDebug(__VA_ARGS__); \ + } \ + } while (0) +#define CTG_API_DEBUG(...) \ + do { \ + if (gCTGDebug.apiEnable) { \ + qDebug(__VA_ARGS__); \ + } \ + } while (0) -#define ctgFatal(param, ...) qFatal("CTG:%p " param, pCtg, __VA_ARGS__) -#define ctgError(param, ...) qError("CTG:%p " param, pCtg, __VA_ARGS__) -#define ctgWarn(param, ...) qWarn("CTG:%p " param, pCtg, __VA_ARGS__) -#define ctgInfo(param, ...) qInfo("CTG:%p " param, pCtg, __VA_ARGS__) -#define ctgDebug(param, ...) qDebug("CTG:%p " param, pCtg, __VA_ARGS__) -#define ctgTrace(param, ...) qTrace("CTG:%p " param, pCtg, __VA_ARGS__) +#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000 -#define CTG_LOCK_DEBUG(...) do { if (gCTGDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0) -#define CTG_CACHE_DEBUG(...) do { if (gCTGDebug.cacheEnable) { qDebug(__VA_ARGS__); } } while (0) -#define CTG_API_DEBUG(...) do { if (gCTGDebug.apiEnable) { qDebug(__VA_ARGS__); } } while (0) +#define CTG_LOCK(type, _lock) \ + do { \ + if (CTG_READ == (type)) { \ + assert(atomic_load_32((_lock)) >= 0); \ + CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRLockLatch(_lock); \ + CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) > 0); \ + } else { \ + assert(atomic_load_32((_lock)) >= 0); \ + CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWLockLatch(_lock); \ + CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + } \ + } while (0) -#define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000 +#define CTG_UNLOCK(type, _lock) \ + do { \ + if (CTG_READ == (type)) { \ + assert(atomic_load_32((_lock)) > 0); \ + CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRUnLockLatch(_lock); \ + CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } else { \ + assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ + CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWUnLockLatch(_lock); \ + CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } \ + } while (0) -#define CTG_LOCK(type, _lock) do { \ - if (CTG_READ == (type)) { \ - assert(atomic_load_32((_lock)) >= 0); \ - CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRLockLatch(_lock); \ - CTG_LOCK_DEBUG("CTG RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) > 0); \ - } else { \ - assert(atomic_load_32((_lock)) >= 0); \ - CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWLockLatch(_lock); \ - CTG_LOCK_DEBUG("CTG WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ - } \ -} while (0) - -#define CTG_UNLOCK(type, _lock) do { \ - if (CTG_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ - CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRUnLockLatch(_lock); \ - CTG_LOCK_DEBUG("CTG RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } else { \ - assert(atomic_load_32((_lock)) == TD_RWLATCH_WRITE_FLAG_COPY); \ - CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWUnLockLatch(_lock); \ - CTG_LOCK_DEBUG("CTG WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } \ -} while (0) - - -#define CTG_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define CTG_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define CTG_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) - -#define CTG_API_LEAVE(c) do { \ - int32_t __code = c; \ - CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); \ - CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); \ - CTG_RET(__code); \ -} while (0) - -#define CTG_API_ENTER() do { \ - CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ - CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \ - if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ - CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); \ - } \ -} while (0) - -#define CTG_API_JENTER() do { \ - CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ - CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \ - if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ - CTG_ERR_JRET(TSDB_CODE_CTG_OUT_OF_SERVICE); \ - } \ -} while (0) - - -#define CTG_API_LEAVE_NOLOCK(c) do { \ - int32_t __code = c; \ - CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); \ - CTG_RET(__code); \ +#define CTG_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define CTG_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define CTG_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ } while (0) -#define CTG_API_ENTER_NOLOCK() do { \ - CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ - if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ - CTG_API_LEAVE_NOLOCK(TSDB_CODE_CTG_OUT_OF_SERVICE); \ - } \ -} while (0) +#define CTG_API_LEAVE(c) \ + do { \ + int32_t __code = c; \ + CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); \ + CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); \ + CTG_RET(__code); \ + } while (0) +#define CTG_API_ENTER() \ + do { \ + CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ + CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \ + if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ + CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); \ + } \ + } while (0) + +#define CTG_API_JENTER() \ + do { \ + CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ + CTG_LOCK(CTG_READ, &gCtgMgmt.lock); \ + if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ + CTG_ERR_JRET(TSDB_CODE_CTG_OUT_OF_SERVICE); \ + } \ + } while (0) -void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p); +#define CTG_API_LEAVE_NOLOCK(c) \ + do { \ + int32_t __code = c; \ + CTG_API_DEBUG("CTG API leave %s", __FUNCTION__); \ + CTG_RET(__code); \ + } while (0) + +#define CTG_API_ENTER_NOLOCK() \ + do { \ + CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); \ + if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { \ + CTG_API_LEAVE_NOLOCK(TSDB_CODE_CTG_OUT_OF_SERVICE); \ + } \ + } while (0) + +void ctgdShowTableMeta(SCatalog* pCtg, const char* tbName, STableMeta* p); void ctgdShowClusterCache(SCatalog* pCtg); int32_t ctgdShowCacheInfo(void); int32_t ctgRemoveTbMetaFromCache(SCatalog* pCtg, SName* pTableName, bool syncReq); -int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta); -int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, int32_t *fetchIdx, int32_t baseResIdx, SArray* pList); - -int32_t ctgOpUpdateVgroup(SCtgCacheOperation *action); -int32_t ctgOpUpdateTbMeta(SCtgCacheOperation *action); -int32_t ctgOpDropDbCache(SCtgCacheOperation *action); -int32_t ctgOpDropDbVgroup(SCtgCacheOperation *action); -int32_t ctgOpDropStbMeta(SCtgCacheOperation *action); -int32_t ctgOpDropTbMeta(SCtgCacheOperation *action); -int32_t ctgOpUpdateUser(SCtgCacheOperation *action); -int32_t ctgOpUpdateEpset(SCtgCacheOperation *operation); -int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache); -void ctgReleaseDBCache(SCatalog *pCtg, SCtgDBCache *dbCache); -void ctgRUnlockVgInfo(SCtgDBCache *dbCache); -int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, int32_t *exist); +int32_t ctgGetTbMetaFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta); +int32_t ctgGetTbMetasFromCache(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetasCtx* ctx, int32_t dbIdx, + int32_t* fetchIdx, int32_t baseResIdx, SArray* pList); + +int32_t ctgOpUpdateVgroup(SCtgCacheOperation* action); +int32_t ctgOpUpdateTbMeta(SCtgCacheOperation* action); +int32_t ctgOpDropDbCache(SCtgCacheOperation* action); +int32_t ctgOpDropDbVgroup(SCtgCacheOperation* action); +int32_t ctgOpDropStbMeta(SCtgCacheOperation* action); +int32_t ctgOpDropTbMeta(SCtgCacheOperation* action); +int32_t ctgOpUpdateUser(SCtgCacheOperation* action); +int32_t ctgOpUpdateEpset(SCtgCacheOperation* operation); +int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char* dbFName, SCtgDBCache** pCache); +void ctgReleaseDBCache(SCatalog* pCtg, SCtgDBCache* dbCache); +void ctgRUnlockVgInfo(SCtgDBCache* dbCache); +int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char* dbFName, char* tbName, int32_t* exist); int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta); -int32_t ctgReadTbVerFromCache(SCatalog *pCtg, SName *pTableName, int32_t *sver, int32_t *tver, int32_t *tbType, uint64_t *suid, char *stbName); -int32_t ctgChkAuthFromCache(SCatalog* pCtg, char* user, char* dbFName, AUTH_TYPE type, bool *inCache, bool *pass); -int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId); -int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char *dbFName, bool syncReq); -int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *stbName, uint64_t suid, bool syncReq); -int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, const char *tbName, bool syncReq); -int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char *dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq); -int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput *output, bool syncReq); -int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syncReq); -int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char *dbFName, int32_t vgId, SEpSet* pEpSet); -int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex **pIndex, bool syncOp); +int32_t ctgReadTbVerFromCache(SCatalog* pCtg, SName* pTableName, int32_t* sver, int32_t* tver, int32_t* tbType, + uint64_t* suid, char* stbName); +int32_t ctgChkAuthFromCache(SCatalog* pCtg, char* user, char* dbFName, AUTH_TYPE type, bool* inCache, bool* pass); +int32_t ctgDropDbCacheEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId); +int32_t ctgDropDbVgroupEnqueue(SCatalog* pCtg, const char* dbFName, bool syncReq); +int32_t ctgDropStbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, const char* stbName, uint64_t suid, + bool syncReq); +int32_t ctgDropTbMetaEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, const char* tbName, bool syncReq); +int32_t ctgUpdateVgroupEnqueue(SCatalog* pCtg, const char* dbFName, int64_t dbId, SDBVgInfo* dbInfo, bool syncReq); +int32_t ctgUpdateTbMetaEnqueue(SCatalog* pCtg, STableMetaOutput* output, bool syncReq); +int32_t ctgUpdateUserEnqueue(SCatalog* pCtg, SGetUserAuthRsp* pAuth, bool syncReq); +int32_t ctgUpdateVgEpsetEnqueue(SCatalog* pCtg, char* dbFName, int32_t vgId, SEpSet* pEpSet); +int32_t ctgUpdateTbIndexEnqueue(SCatalog* pCtg, STableIndex** pIndex, bool syncOp); int32_t ctgClearCacheEnqueue(SCatalog* pCtg, bool freeCtg, bool stopQueue, bool syncOp); -int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type); -int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size); -int32_t ctgMetaRentGet(SCtgRentMgmt *mgmt, void **res, uint32_t *num, int32_t size); +int32_t ctgMetaRentInit(SCtgRentMgmt* mgmt, uint32_t rentSec, int8_t type); +int32_t ctgMetaRentAdd(SCtgRentMgmt* mgmt, void* meta, int64_t id, int32_t size); +int32_t ctgMetaRentGet(SCtgRentMgmt* mgmt, void** res, uint32_t* num, int32_t size); int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq); int32_t ctgStartUpdateThread(); -int32_t ctgRelaunchGetTbMetaTask(SCtgTask *pTask); -void ctgReleaseVgInfoToCache(SCatalog* pCtg, SCtgDBCache *dbCache); +int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask); +void ctgReleaseVgInfoToCache(SCatalog* pCtg, SCtgDBCache* dbCache); int32_t ctgReadTbIndexFromCache(SCatalog* pCtg, SName* pTableName, SArray** pRes); int32_t ctgDropTbIndexEnqueue(SCatalog* pCtg, SName* pName, bool syncOp); -int32_t ctgOpDropTbIndex(SCtgCacheOperation *operation); -int32_t ctgOpUpdateTbIndex(SCtgCacheOperation *operation); -int32_t ctgOpClearCache(SCtgCacheOperation *operation); -int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char *tableName, int32_t *tbType); -int32_t ctgGetTbHashVgroupFromCache(SCatalog *pCtg, const SName *pTableName, SVgroupInfo **pVgroup); - - - +int32_t ctgOpDropTbIndex(SCtgCacheOperation* operation); +int32_t ctgOpUpdateTbIndex(SCtgCacheOperation* operation); +int32_t ctgOpClearCache(SCtgCacheOperation* operation); +int32_t ctgReadTbTypeFromCache(SCatalog* pCtg, char* dbFName, char* tableName, int32_t* tbType); +int32_t ctgGetTbHashVgroupFromCache(SCatalog* pCtg, const SName* pTableName, SVgroupInfo** pVgroup); int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, int32_t rspCode, char* target); -int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SBuildUseDBInput *input, SUseDbOutput *out, SCtgTaskReq* tReq); -int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray *out, SCtgTask* pTask); -int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SArray **out, SCtgTask* pTask); -int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *dbFName, SDbCfgInfo *out, SCtgTask* pTask); -int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *indexName, SIndexInfo *out, SCtgTask* pTask); -int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, SName *name, STableIndex* out, SCtgTask* pTask); -int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *funcName, SFuncInfo *out, SCtgTask* pTask); -int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const char *user, SGetUserAuthRsp *out, SCtgTask* pTask); -int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo *pConn, char *dbFName, char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq); -int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMetaOutput* out, SCtgTaskReq* tReq); -int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableMetaOutput* out, SCtgTaskReq* tReq); -int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SVgroupInfo *vgroupInfo, STableCfg **out, SCtgTask* pTask); -int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg **out, SCtgTask* pTask); -int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo *pConn, char **out, SCtgTask* pTask); -int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob *pJob, SHashObj* pBatchs); - -int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, void* param); -int32_t ctgLaunchJob(SCtgJob *pJob); -int32_t ctgMakeAsyncRes(SCtgJob *pJob); -int32_t ctgLaunchSubTask(SCtgTask *pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param); -int32_t ctgGetTbCfgCb(SCtgTask *pTask); +int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildUseDBInput* input, SUseDbOutput* out, + SCtgTaskReq* tReq); +int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray* out, SCtgTask* pTask); +int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray** out, SCtgTask* pTask); +int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* out, + SCtgTask* pTask); +int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* indexName, SIndexInfo* out, + SCtgTask* pTask); +int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* name, STableIndex* out, SCtgTask* pTask); +int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* out, + SCtgTask* pTask); +int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, SGetUserAuthRsp* out, + SCtgTask* pTask); +int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName, + STableMetaOutput* out, SCtgTaskReq* tReq); +int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMetaOutput* out, + SCtgTaskReq* tReq); +int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* vgroupInfo, + STableMetaOutput* out, SCtgTaskReq* tReq); +int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + SVgroupInfo* vgroupInfo, STableCfg** out, SCtgTask* pTask); +int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** out, + SCtgTask* pTask); +int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** out, SCtgTask* pTask); +int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob* pJob, SHashObj* pBatchs); + +int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const SCatalogReq* pReq, catalogCallback fp, + void* param); +int32_t ctgLaunchJob(SCtgJob* pJob); +int32_t ctgMakeAsyncRes(SCtgJob* pJob); +int32_t ctgLaunchSubTask(SCtgTask* pTask, CTG_TASK_TYPE type, ctgSubTaskCbFp fp, void* param); +int32_t ctgGetTbCfgCb(SCtgTask* pTask); void ctgFreeHandle(SCatalog* pCatalog); void ctgFreeMsgSendParam(void* param); -void ctgFreeBatch(SCtgBatch *pBatch); -void ctgFreeBatchs(SHashObj *pBatchs); -int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst); -int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput); -int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList); +void ctgFreeBatch(SCtgBatch* pBatch); +void ctgFreeBatchs(SHashObj* pBatchs); +int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst); +int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput); +int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList); void ctgFreeJob(void* job); void ctgFreeHandleImpl(SCatalog* pCtg); -void ctgFreeVgInfo(SDBVgInfo *vgInfo); -int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup); -int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update); +void ctgFreeVgInfo(SDBVgInfo* vgInfo); +int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup); +int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx, + char* dbFName, SArray* pNames, bool update); void ctgResetTbMetaTask(SCtgTask* pTask); -void ctgFreeDbCache(SCtgDBCache *dbCache); +void ctgFreeDbCache(SCtgDBCache* dbCache); int32_t ctgStbVersionSortCompare(const void* key1, const void* key2); int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2); int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2); @@ -714,23 +772,22 @@ int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2); void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput); int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target); int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target); -char * ctgTaskTypeStr(CTG_TASK_TYPE type); -int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId); -int32_t ctgGetTablesReqNum(SArray *pList); -int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag); +char* ctgTaskTypeStr(CTG_TASK_TYPE type); +int32_t ctgUpdateSendTargetInfo(SMsgSendInfo* pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId); +int32_t ctgGetTablesReqNum(SArray* pList); +int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t* fetchIdx, int32_t resIdx, int32_t flag); int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes); -void ctgFreeSTableIndex(void *info); -void ctgClearSubTaskRes(SCtgSubRes *pRes); -void ctgFreeQNode(SCtgQNode *node); +void ctgFreeSTableIndex(void* info); +void ctgClearSubTaskRes(SCtgSubRes* pRes); +void ctgFreeQNode(SCtgQNode* node); void ctgClearHandle(SCatalog* pCtg); -void ctgFreeTbCacheImpl(SCtgTbCache *pCache); +void ctgFreeTbCacheImpl(SCtgTbCache* pCache); int32_t ctgRemoveTbMeta(SCatalog* pCtg, SName* pTableName); -int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup); +int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup); SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch); - extern SCatalogMgmt gCtgMgmt; -extern SCtgDebug gCTGDebug; +extern SCtgDebug gCTGDebug; extern SCtgAsyncFps gCtgAsyncFps[]; #ifdef __cplusplus diff --git a/source/libs/catalog/inc/ctgRemote.h b/source/libs/catalog/inc/ctgRemote.h index fe0762a88af49d8ed8ee873f03b719b0bc169a79..8edd3b3880994c60d9dc8e1ce27c64e3f271a26f 100644 --- a/source/libs/catalog/inc/ctgRemote.h +++ b/source/libs/catalog/inc/ctgRemote.h @@ -20,8 +20,6 @@ extern "C" { #endif - - #ifdef __cplusplus } #endif diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 7b32eadcd415116f67db8526449c8a6759f45bcd..b027dbcfa5ac9a91a2656778810ae84ae0b72eeb 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -22,7 +22,8 @@ SCatalogMgmt gCtgMgmt = {0}; -int32_t ctgGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, SCtgDBCache** dbCache, SDBVgInfo **pInfo) { +int32_t ctgGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SCtgDBCache** dbCache, + SDBVgInfo** pInfo) { int32_t code = 0; CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, dbCache)); @@ -53,8 +54,8 @@ _return: CTG_RET(code); } -int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName) { - int32_t code = 0; +int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName) { + int32_t code = 0; SCtgDBCache* dbCache = NULL; CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache)); @@ -87,7 +88,8 @@ int32_t ctgRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* return TSDB_CODE_SUCCESS; } -int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMetaOutput **pOutput, bool syncReq) { +int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMetaOutput** pOutput, + bool syncReq) { SVgroupInfo vgroupInfo = {0}; int32_t code = 0; @@ -105,7 +107,8 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* if (CTG_FLAG_IS_SYS_DB(ctx->flag)) { ctgDebug("will refresh tbmeta, supposed in information_schema, tbName:%s", tNameGetTableName(ctx->pName)); - CTG_ERR_JRET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char *)ctx->pName->dbname, (char *)ctx->pName->tname, output, NULL)); + CTG_ERR_JRET( + ctgGetTbMetaFromMnodeImpl(pCtg, pConn, (char*)ctx->pName->dbname, (char*)ctx->pName->tname, output, NULL)); } else if (CTG_FLAG_IS_STB(ctx->flag)) { ctgDebug("will refresh tbmeta, supposed to be stb, tbName:%s", tNameGetTableName(ctx->pName)); @@ -126,7 +129,7 @@ int32_t ctgRefreshTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctgDebug("will continue to refresh tbmeta since got stb, tbName:%s", tNameGetTableName(ctx->pName)); taosMemoryFreeClear(output->tbMeta); - + CTG_ERR_JRET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, output->dbFName, output->tbName, output, NULL)); } else if (CTG_IS_META_BOTH(output->metaType)) { int32_t exist = 0; @@ -182,9 +185,9 @@ _return: CTG_RET(code); } -int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo *pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) { - int32_t code = 0; - STableMetaOutput *output = NULL; +int32_t ctgGetTbMeta(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta) { + int32_t code = 0; + STableMetaOutput* output = NULL; CTG_ERR_RET(ctgGetTbMetaFromCache(pCtg, pConn, ctx, pTableMeta)); if (*pTableMeta) { @@ -299,12 +302,13 @@ _return: CTG_RET(code); } -int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass) { - bool inCache = false; +int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, + bool* pass) { + bool inCache = false; int32_t code = 0; *pass = false; - + CTG_ERR_RET(ctgChkAuthFromCache(pCtg, (char*)user, (char*)dbFName, type, &inCache, pass)); if (inCache) { @@ -313,7 +317,7 @@ int32_t ctgChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, co SGetUserAuthRsp authRsp = {0}; CTG_ERR_RET(ctgGetUserDbAuthFromMnode(pCtg, pConn, user, &authRsp, NULL)); - + if (authRsp.superAuth) { *pass = true; goto _return; @@ -337,7 +341,7 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, int32_t *tbType) { +int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, int32_t* tbType) { char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); CTG_ERR_RET(ctgReadTbTypeFromCache(pCtg, dbFName, pTableName->tname, tbType)); @@ -345,7 +349,7 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, return TSDB_CODE_SUCCESS; } - STableMeta* pMeta = NULL; + STableMeta* pMeta = NULL; SCtgTbMetaCtx ctx = {0}; ctx.pName = (SName*)pTableName; ctx.flag = CTG_FLAG_UNKNOWN_STB; @@ -357,24 +361,24 @@ int32_t ctgGetTbType(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, return TSDB_CODE_SUCCESS; } -int32_t ctgGetTbIndex(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pRes) { +int32_t ctgGetTbIndex(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) { CTG_ERR_RET(ctgReadTbIndexFromCache(pCtg, pTableName, pRes)); if (*pRes) { return TSDB_CODE_SUCCESS; } - STableIndex *pIndex = taosMemoryCalloc(1, sizeof(STableIndex)); + STableIndex* pIndex = taosMemoryCalloc(1, sizeof(STableIndex)); if (NULL == pIndex) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - + int32_t code = ctgGetTbIndexFromMnode(pCtg, pConn, (SName*)pTableName, pIndex, NULL); if (TSDB_CODE_MND_DB_INDEX_NOT_EXIST == code) { code = 0; goto _return; } CTG_ERR_JRET(code); - + SArray* pInfo = NULL; CTG_ERR_JRET(ctgCloneTableIndex(pIndex->pIndex, &pInfo)); @@ -395,7 +399,7 @@ _return: CTG_RET(code); } -int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, STableCfg** pCfg) { +int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, STableCfg** pCfg) { int32_t tbType = 0; CTG_ERR_RET(ctgGetTbType(pCtg, pConn, pTableName, &tbType)); @@ -410,25 +414,25 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, CTG_RET(TSDB_CODE_SUCCESS); } -int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, SName* pTableName, SArray** pVgList) { - STableMeta *tbMeta = NULL; - int32_t code = 0; - SVgroupInfo vgroupInfo = {0}; - SCtgDBCache* dbCache = NULL; - SArray *vgList = NULL; - SDBVgInfo *vgInfo = NULL; +int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) { + STableMeta* tbMeta = NULL; + int32_t code = 0; + SVgroupInfo vgroupInfo = {0}; + SCtgDBCache* dbCache = NULL; + SArray* vgList = NULL; + SDBVgInfo* vgInfo = NULL; SCtgTbMetaCtx ctx = {0}; ctx.pName = pTableName; ctx.flag = CTG_FLAG_UNKNOWN_STB; *pVgList = NULL; - + CTG_ERR_JRET(ctgGetTbMeta(pCtg, pConn, &ctx, &tbMeta)); char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); - SHashObj *vgHash = NULL; + SHashObj* vgHash = NULL; CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo)); if (dbCache) { @@ -489,8 +493,7 @@ _return: CTG_RET(code); } - -int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup) { +int32_t ctgGetTbHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SVgroupInfo* pVgroup) { if (IS_SYS_DBNAME(pTableName->dbname)) { ctgError("no valid vgInfo for db, dbname:%s", pTableName->dbname); CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); @@ -501,7 +504,7 @@ int32_t ctgGetTbHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); - SDBVgInfo *vgInfo = NULL; + SDBVgInfo* vgInfo = NULL; CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, db, &dbCache, &vgInfo)); CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, vgInfo ? vgInfo : dbCache->vgCache.vgInfo, pTableName, pVgroup)); @@ -539,7 +542,6 @@ _return: CTG_RET(code); } - int32_t catalogInit(SCatalogCfg* cfg) { if (gCtgMgmt.pCluster) { qError("catalog already initialized"); @@ -648,7 +650,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - clusterCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + clusterCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (NULL == clusterCtg->userCache) { qError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); @@ -714,7 +717,7 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, SArray** vgroupList) { +int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SArray** vgroupList) { CTG_API_ENTER(); if (NULL == pCtg || NULL == dbFName || NULL == pConn || NULL == vgroupList) { @@ -722,10 +725,10 @@ int32_t catalogGetDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* } SCtgDBCache* dbCache = NULL; - int32_t code = 0; - SArray *vgList = NULL; - SHashObj *vgHash = NULL; - SDBVgInfo *vgInfo = NULL; + int32_t code = 0; + SArray* vgList = NULL; + SHashObj* vgHash = NULL; + SDBVgInfo* vgInfo = NULL; CTG_ERR_JRET(ctgGetDBVgInfo(pCtg, pConn, dbFName, &dbCache, &vgInfo)); if (dbCache) { vgHash = dbCache->vgCache.vgInfo->vgHash; @@ -808,11 +811,11 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp) { +int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp* pRsp) { CTG_API_ENTER(); int32_t code = 0; - + if (NULL == pCtg || NULL == pRsp) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -827,11 +830,10 @@ int32_t catalogUpdateTableIndex(SCatalog* pCtg, STableIndexRsp *pRsp) { CTG_ERR_JRET(ctgUpdateTbIndexEnqueue(pCtg, &pIndex, false)); _return: - + CTG_API_LEAVE(code); } - int32_t catalogRemoveTableMeta(SCatalog* pCtg, SName* pTableName) { CTG_API_ENTER(); @@ -860,17 +862,18 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMeta** pTableMeta) { +int32_t catalogGetTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMeta** pTableMeta) { CTG_API_ENTER(); SCtgTbMetaCtx ctx = {0}; ctx.pName = (SName*)pTableName; ctx.flag = CTG_FLAG_UNKNOWN_STB; - + CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta)); } -int32_t catalogGetSTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMeta** pTableMeta) { +int32_t catalogGetSTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta) { CTG_API_ENTER(); SCtgTbMetaCtx ctx = {0}; @@ -895,7 +898,7 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray* pTables) { +int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo* pConn, SArray* pTables) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pTables) { @@ -944,7 +947,7 @@ int32_t catalogChkTbMetaVersion(SCatalog* pCtg, SRequestConnInfo *pConn, SArray* CTG_API_LEAVE(TSDB_CODE_SUCCESS); } -int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName) { +int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == dbFName) { @@ -954,7 +957,7 @@ int32_t catalogRefreshDBVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const ch CTG_API_LEAVE(ctgRefreshDBVgInfo(pCtg, pConn, dbFName)); } -int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, int32_t isSTable) { +int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, int32_t isSTable) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pTableName) { @@ -968,7 +971,8 @@ int32_t catalogRefreshTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const S CTG_API_LEAVE(ctgRefreshTbMeta(pCtg, pConn, &ctx, NULL, true)); } -int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableMeta** pTableMeta, int32_t isSTable) { +int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + STableMeta** pTableMeta, int32_t isSTable) { CTG_API_ENTER(); SCtgTbMetaCtx ctx = {0}; @@ -978,7 +982,7 @@ int32_t catalogRefreshGetTableMeta(SCatalog* pCtg, SRequestConnInfo *pConn, cons CTG_API_LEAVE(ctgGetTbMeta(pCtg, pConn, &ctx, pTableMeta)); } -int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SArray** pVgList) { +int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pVgList) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pVgList) { @@ -993,13 +997,14 @@ int32_t catalogGetTableDistVgInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const CTG_API_LEAVE(ctgGetTbDistVgInfo(pCtg, pConn, (SName*)pTableName, pVgList)); } -int32_t catalogGetTableHashVgroup(SCatalog *pCtg, SRequestConnInfo *pConn, const SName *pTableName, SVgroupInfo *pVgroup) { +int32_t catalogGetTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, + SVgroupInfo* pVgroup) { CTG_API_ENTER(); CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup)); } -int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalogReq* pReq, SMetaData* pRsp) { +int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pReq || NULL == pRsp) { @@ -1028,7 +1033,7 @@ int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalo SCtgTbMetaCtx ctx = {0}; ctx.pName = name; ctx.flag = CTG_FLAG_UNKNOWN_STB; - + CTG_ERR_JRET(ctgGetTbMeta(pCtg, pConn, &ctx, &pTableMeta)); if (NULL == taosArrayPush(pRsp->pTableMeta, &pTableMeta)) { @@ -1062,15 +1067,16 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId) { +int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp, + void* param, int64_t* jobId) { CTG_API_ENTER(); if (NULL == pCtg || NULL == pConn || NULL == pReq || NULL == fp || NULL == param) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - int32_t code = 0; - SCtgJob *pJob = NULL; + int32_t code = 0; + SCtgJob* pJob = NULL; CTG_ERR_JRET(ctgInitJob(pCtg, pConn, &pJob, pReq, fp, param)); CTG_ERR_JRET(ctgLaunchJob(pJob)); @@ -1091,7 +1097,7 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogGetQnodeList(SCatalog* pCtg, SRequestConnInfo *pConn, SArray* pQnodeList) { +int32_t catalogGetQnodeList(SCatalog* pCtg, SRequestConnInfo* pConn, SArray* pQnodeList) { CTG_API_ENTER(); int32_t code = 0; @@ -1121,14 +1127,14 @@ _return: CTG_API_LEAVE(TSDB_CODE_SUCCESS); } -int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion **stables, uint32_t *num) { +int32_t catalogGetExpiredSTables(SCatalog* pCtg, SSTableVersion** stables, uint32_t* num) { CTG_API_ENTER(); if (NULL == pCtg || NULL == stables || NULL == num) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void **)stables, num, sizeof(SSTableVersion))); + CTG_API_LEAVE(ctgMetaRentGet(&pCtg->stbRent, (void**)stables, num, sizeof(SSTableVersion))); } int32_t catalogGetExpiredDBs(SCatalog* pCtg, SDbVgVersion** dbs, uint32_t* num) { @@ -1152,7 +1158,7 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_ if (*num <= 0) { CTG_API_LEAVE(TSDB_CODE_SUCCESS); } - + *users = taosMemoryCalloc(*num, sizeof(SUserAuthVersion)); if (NULL == *users) { ctgError("calloc %d userAuthVersion failed", *num); @@ -1172,16 +1178,16 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_ taosHashCancelIterate(pCtg->userCache, pAuth); break; } - + pAuth = taosHashIterate(pCtg->userCache, pAuth); } CTG_API_LEAVE(TSDB_CODE_SUCCESS); } -int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbFName, SDbCfgInfo* pDbCfg) { +int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* pDbCfg) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == dbFName || NULL == pDbCfg) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -1189,9 +1195,9 @@ int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const char* dbF CTG_API_LEAVE(ctgGetDBCfgFromMnode(pCtg, pConn, dbFName, pDbCfg, NULL)); } -int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const char* indexName, SIndexInfo* pInfo) { +int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char* indexName, SIndexInfo* pInfo) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == indexName || NULL == pInfo) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -1199,24 +1205,24 @@ int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo *pConn, const char* CTG_API_LEAVE(ctgGetIndexInfoFromMnode(pCtg, pConn, indexName, pInfo, NULL)); } -int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, SArray** pRes) { +int32_t catalogGetTableIndex(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pRes) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } int32_t code = 0; CTG_ERR_JRET(ctgGetTbIndex(pCtg, pConn, (SName*)pTableName, pRes)); - + _return: CTG_API_LEAVE(code); } -int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo *pConn, const SName* pTableName, STableCfg** pCfg) { +int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pCfg) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } @@ -1231,52 +1237,52 @@ _return: CTG_API_LEAVE(code); } -int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo *pConn, const char* funcName, SFuncInfo* pInfo) { +int32_t catalogGetUdfInfo(SCatalog* pCtg, SRequestConnInfo* pConn, const char* funcName, SFuncInfo* pInfo) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == funcName || NULL == pInfo) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } int32_t code = 0; CTG_ERR_JRET(ctgGetUdfInfoFromMnode(pCtg, pConn, funcName, pInfo, NULL)); - + _return: CTG_API_LEAVE(code); } -int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo *pConn, const char* user, const char* dbFName, AUTH_TYPE type, bool *pass) { +int32_t catalogChkAuth(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, const char* dbFName, AUTH_TYPE type, + bool* pass) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == user || NULL == dbFName || NULL == pass) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } int32_t code = 0; CTG_ERR_JRET(ctgChkAuth(pCtg, pConn, user, dbFName, type, pass)); - + _return: CTG_API_LEAVE(code); } -int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo *pConn, char** pVersion) { +int32_t catalogGetServerVersion(SCatalog* pCtg, SRequestConnInfo* pConn, char** pVersion) { CTG_API_ENTER(); - + if (NULL == pCtg || NULL == pConn || NULL == pVersion) { CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } int32_t code = 0; CTG_ERR_JRET(ctgGetSvrVerFromMnode(pCtg, pConn, pVersion, NULL)); - + _return: CTG_API_LEAVE(code); } - int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth) { CTG_API_ENTER(); @@ -1299,11 +1305,10 @@ int32_t catalogClearCache(void) { int32_t code = ctgClearCacheEnqueue(NULL, false, false, true); qInfo("clear catalog cache end, code: %s", tstrerror(code)); - + CTG_API_LEAVE_NOLOCK(code); } - void catalogDestroy(void) { qInfo("start to destroy catalog"); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 463ea9340aed23217e00cedebe4403fb5070cc56..1305540a5082e59317969b8fdd574f59a059aaf6 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -636,7 +636,7 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const taosAcquireRef(gCtgMgmt.jobPool, pJob->refId); - double el = (taosGetTimestampUs() - st)/1000.0; + double el = (taosGetTimestampUs() - st) / 1000.0; qDebug("QID:0x%" PRIx64 ", jobId: 0x%" PRIx64 " initialized, task num %d, forceUpdate %d, elapsed time:%.2f ms", pJob->queryId, pJob->refId, taskNum, pReq->forceUpdate, el); return TSDB_CODE_SUCCESS; diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index d21524230736c47fb3c81de0c00e1402f09a585e..dbca2ad9776b8b278f6795bebcca4423c55bcc99 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -13,16 +13,16 @@ * along with this program. If not, see . */ -#include "trpc.h" +#include "catalogInt.h" #include "query.h" #include "tname.h" -#include "catalogInt.h" +#include "trpc.h" extern SCatalogMgmt gCtgMgmt; -SCtgDebug gCTGDebug = {0}; +SCtgDebug gCTGDebug = {0}; -void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { - ASSERT(*(int32_t*)param == 1); +void ctgdUserCallback(SMetaData *pResult, void *param, int32_t code) { + ASSERT(*(int32_t *)param == 1); taosMemoryFree(param); qDebug("async call result: %s", tstrerror(code)); @@ -36,16 +36,19 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pTableMeta && taosArrayGetSize(pResult->pTableMeta) > 0) { num = taosArrayGetSize(pResult->pTableMeta); for (int32_t i = 0; i < num; ++i) { - STableMeta *p = *(STableMeta **)taosArrayGet(pResult->pTableMeta, i); + STableMeta *p = *(STableMeta **)taosArrayGet(pResult->pTableMeta, i); STableComInfo *c = &p->tableInfo; - + if (TSDB_CHILD_TABLE == p->tableType) { - qDebug("table meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64, p->tableType, p->vgId, p->uid, p->suid); + qDebug("table meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64, p->tableType, p->vgId, p->uid, + p->suid); } else { - qDebug("table meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", - p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); + qDebug("table meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64 + ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, + c->numOfColumns, c->rowSize); } - + int32_t colNum = c->numOfColumns + c->numOfTags; for (int32_t j = 0; j < colNum; ++j) { SSchema *s = &p->schema[j]; @@ -59,11 +62,11 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pDbVgroup && taosArrayGetSize(pResult->pDbVgroup) > 0) { num = taosArrayGetSize(pResult->pDbVgroup); for (int32_t i = 0; i < num; ++i) { - SArray *pDb = *(SArray**)taosArrayGet(pResult->pDbVgroup, i); + SArray *pDb = *(SArray **)taosArrayGet(pResult->pDbVgroup, i); int32_t vgNum = taosArrayGetSize(pDb); qDebug("db %d vgInfo:", i); for (int32_t j = 0; j < vgNum; ++j) { - SVgroupInfo* pInfo = taosArrayGet(pDb, j); + SVgroupInfo *pInfo = taosArrayGet(pDb, j); qDebug("vg :%d info: vgId:%d", j, pInfo->vgId); } } @@ -84,7 +87,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pTableHash && taosArrayGetSize(pResult->pTableHash) > 0) { num = taosArrayGetSize(pResult->pTableHash); for (int32_t i = 0; i < num; ++i) { - SVgroupInfo* pInfo = taosArrayGet(pResult->pTableHash, i); + SVgroupInfo *pInfo = taosArrayGet(pResult->pTableHash, i); qDebug("table %d vg info: vgId:%d", i, pInfo->vgId); } } else { @@ -94,7 +97,7 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pUdfList && taosArrayGetSize(pResult->pUdfList) > 0) { num = taosArrayGetSize(pResult->pUdfList); for (int32_t i = 0; i < num; ++i) { - SFuncInfo* pInfo = taosArrayGet(pResult->pUdfList, i); + SFuncInfo *pInfo = taosArrayGet(pResult->pUdfList, i); qDebug("udf %d info: name:%s, funcType:%d", i, pInfo->name, pInfo->funcType); } } else { @@ -104,35 +107,34 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pDbCfg && taosArrayGetSize(pResult->pDbCfg) > 0) { num = taosArrayGetSize(pResult->pDbCfg); for (int32_t i = 0; i < num; ++i) { - SDbCfgInfo* pInfo = taosArrayGet(pResult->pDbCfg, i); + SDbCfgInfo *pInfo = taosArrayGet(pResult->pDbCfg, i); qDebug("db %d info: numOFVgroups:%d, numOfStables:%d", i, pInfo->numOfVgroups, pInfo->numOfStables); } } else { qDebug("empty db cfg info"); - } + } if (pResult->pUser && taosArrayGetSize(pResult->pUser) > 0) { num = taosArrayGetSize(pResult->pUser); for (int32_t i = 0; i < num; ++i) { - bool* auth = taosArrayGet(pResult->pUser, i); + bool *auth = taosArrayGet(pResult->pUser, i); qDebug("user auth %d info: %d", i, *auth); } } else { qDebug("empty user auth info"); - } + } if (pResult->pQnodeList && taosArrayGetSize(pResult->pQnodeList) > 0) { num = taosArrayGetSize(pResult->pQnodeList); for (int32_t i = 0; i < num; ++i) { - SQueryNodeAddr* qaddr = taosArrayGet(pResult->pQnodeList, i); + SQueryNodeAddr *qaddr = taosArrayGet(pResult->pQnodeList, i); qDebug("qnode %d info: id:%d", i, qaddr->nodeId); } } else { qDebug("empty qnode info"); - } + } } - /* prepare SQL: create database db1; @@ -147,8 +149,8 @@ grant write on db2.* to user1; create function udf1 as '/tmp/libudf1.so' outputtype int; create aggregate function udf2 as '/tmp/libudf2.so' outputtype int; */ -int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t reqId, bool forceUpdate) { - int32_t code = 0; +int32_t ctgdLaunchAsyncCall(SCatalog *pCtg, SRequestConnInfo *pConn, uint64_t reqId, bool forceUpdate) { + int32_t code = 0; SCatalogReq req = {0}; req.pTableMeta = taosArrayInit(2, sizeof(SName)); req.pDbVgroup = taosArrayInit(2, TSDB_DB_FNAME_LEN); @@ -156,16 +158,16 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re req.pTableHash = taosArrayInit(2, sizeof(SName)); req.pUdf = taosArrayInit(2, TSDB_FUNC_NAME_LEN); req.pDbCfg = taosArrayInit(2, TSDB_DB_FNAME_LEN); - req.pIndex = NULL;//taosArrayInit(2, TSDB_INDEX_FNAME_LEN); + req.pIndex = NULL; // taosArrayInit(2, TSDB_INDEX_FNAME_LEN); req.pUser = taosArrayInit(2, sizeof(SUserAuthInfo)); req.qNodeRequired = true; req.forceUpdate = forceUpdate; - SName name = {0}; - char dbFName[TSDB_DB_FNAME_LEN] = {0}; - char funcName[TSDB_FUNC_NAME_LEN] = {0}; + SName name = {0}; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + char funcName[TSDB_FUNC_NAME_LEN] = {0}; SUserAuthInfo user = {0}; - + tNameFromString(&name, "1.db1.tb1", T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); taosArrayPush(req.pTableMeta, &name); taosArrayPush(req.pTableHash, &name); @@ -207,7 +209,7 @@ int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, SRequestConnInfo* pConn, uint64_t re int32_t *param = taosMemoryCalloc(1, sizeof(int32_t)); *param = 1; - + int64_t jobId = 0; CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pConn, &req, ctgdUserCallback, param, &jobId)); @@ -221,7 +223,7 @@ _return: taosArrayDestroy(req.pDbCfg); taosArrayDestroy(req.pUser); - CTG_RET(code); + CTG_RET(code); } int32_t ctgdEnableDebug(char *option) { @@ -250,7 +252,7 @@ int32_t ctgdEnableDebug(char *option) { } qError("invalid debug option:%s", option); - + return TSDB_CODE_CTG_INTERNAL_ERROR; } @@ -261,7 +263,7 @@ int32_t ctgdGetStatNum(char *option, void *res) { } qError("invalid stat option:%s", option); - + return TSDB_CODE_CTG_INTERNAL_ERROR; } @@ -287,7 +289,7 @@ int32_t ctgdGetRentNum(SCtgRentMgmt *rent) { return num; } -int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) { +int32_t ctgdGetClusterCacheNum(SCatalog *pCtg, int32_t type) { if (NULL == pCtg || NULL == pCtg->dbCache) { return 0; } @@ -304,8 +306,8 @@ int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) { } SCtgDBCache *dbCache = NULL; - int32_t num = 0; - void *pIter = taosHashIterate(pCtg->dbCache, NULL); + int32_t num = 0; + void *pIter = taosHashIterate(pCtg->dbCache, NULL); while (pIter) { dbCache = (SCtgDBCache *)pIter; switch (type) { @@ -325,7 +327,7 @@ int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) { return num; } -void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { +void ctgdShowTableMeta(SCatalog *pCtg, const char *tbName, STableMeta *p) { if (!gCTGDebug.metaEnable) { return; } @@ -333,11 +335,14 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { STableComInfo *c = &p->tableInfo; if (TSDB_CHILD_TABLE == p->tableType) { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64, tbName, p->tableType, p->vgId, p->uid, p->suid); + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64, tbName, p->tableType, p->vgId, + p->uid, p->suid); return; } else { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", - tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:0x%" PRIx64 ",suid:0x%" PRIx64 + ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, + c->numOfColumns, c->rowSize); } int32_t colNum = c->numOfColumns + c->numOfTags; @@ -347,18 +352,18 @@ void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { } } -void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { +void ctgdShowDBCache(SCatalog *pCtg, SHashObj *dbHash) { if (NULL == dbHash || !gCTGDebug.cacheEnable) { return; } - int32_t i = 0; + int32_t i = 0; SCtgDBCache *dbCache = NULL; - void *pIter = taosHashIterate(dbHash, NULL); + void *pIter = taosHashIterate(dbHash, NULL); while (pIter) { - char *dbFName = NULL; + char *dbFName = NULL; size_t len = 0; - + dbCache = (SCtgDBCache *)pIter; dbFName = taosHashGetKey(pIter, &len); @@ -380,29 +385,29 @@ void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { vgNum = taosHashGetSize(dbCache->vgCache.vgInfo->vgHash); } } - - 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); + + 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); } } - - - -void ctgdShowClusterCache(SCatalog* pCtg) { +void ctgdShowClusterCache(SCatalog *pCtg) { if (!gCTGDebug.cacheEnable || NULL == pCtg) { return; } - ctgDebug("## cluster 0x%"PRIx64" %p cache Info BEGIN ##", pCtg->clusterId, pCtg); - ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), - ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); - + ctgDebug("## cluster 0x%" PRIx64 " %p cache Info BEGIN ##", pCtg->clusterId, pCtg); + ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); + ctgdShowDBCache(pCtg, pCtg->dbCache); - ctgDebug("## cluster 0x%"PRIx64" %p cache Info END ##", pCtg->clusterId, pCtg); + ctgDebug("## cluster 0x%" PRIx64 " %p cache Info END ##", pCtg->clusterId, pCtg); } int32_t ctgdShowCacheInfo(void) { @@ -413,19 +418,18 @@ int32_t ctgdShowCacheInfo(void) { CTG_API_ENTER(); qDebug("# total catalog cluster number %d #", taosHashGetSize(gCtgMgmt.pCluster)); - + SCatalog *pCtg = NULL; - void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); + void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); while (pIter) { pCtg = *(SCatalog **)pIter; if (pCtg) { ctgdShowClusterCache(pCtg); } - + pIter = taosHashIterate(gCtgMgmt.pCluster, pIter); } CTG_API_LEAVE(TSDB_CODE_SUCCESS); } - diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 7b8c66e36889dde2fe0c624c6adb099151455501..744d6eab0693293df5887e613539cc9935beba6d 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -638,7 +638,7 @@ int32_t ctgGetQnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_QNODE_LIST; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse); @@ -692,7 +692,7 @@ int32_t ctgGetDnodeListFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SArray char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_DNODE_LIST; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get dnode list from mnode, mgmtEpInUse:%d", pConn->mgmtEps.inUse); @@ -743,7 +743,7 @@ int32_t ctgGetDBVgInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SBuildU int32_t msgLen = 0; int32_t reqType = TDMT_MND_USE_DB; SCtgTask* pTask = tReq ? tReq->pTask : NULL; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db); @@ -795,7 +795,7 @@ int32_t ctgGetDBCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_DB_CFG; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName); @@ -850,7 +850,7 @@ int32_t ctgGetIndexInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_INDEX; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get index from mnode, indexName:%s", indexName); @@ -905,7 +905,7 @@ int32_t ctgGetTbIndexFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* n char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_TABLE_INDEX; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; char tbFName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(name, tbFName); @@ -962,7 +962,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_RETRIEVE_FUNC; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get udf info from mnode, funcName:%s", funcName); @@ -1017,7 +1017,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_USER_AUTH; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get user auth from mnode, user:%s", user); @@ -1077,7 +1077,7 @@ int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* int32_t reqType = TDMT_MND_TABLE_META; char tbFName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFName, "%s.%s", dbFName, tbName); - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName); @@ -1140,7 +1140,7 @@ int32_t ctgGetTbMetaFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SNa int32_t reqType = TDMT_VND_TABLE_META; char tbFName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFName, "%s.%s", dbFName, pTableName->tname); - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; ctgDebug("try to get table meta from vnode, vgId:%d, ep num:%d, ep %s:%d, tbFName:%s", vgroupInfo->vgId, @@ -1209,7 +1209,7 @@ int32_t ctgGetTableCfgFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S int32_t reqType = TDMT_VND_TABLE_CFG; char tbFName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pTableName, tbFName); - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); SBuildTableInput bInput = {.vgId = vgroupInfo->vgId, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; @@ -1274,7 +1274,7 @@ int32_t ctgGetTableCfgFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const S int32_t reqType = TDMT_MND_TABLE_CFG; char tbFName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pTableName, tbFName); - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; char dbFName[TSDB_DB_FNAME_LEN]; tNameGetFullDbName(pTableName, dbFName); SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = (char*)pTableName->tname}; @@ -1326,7 +1326,7 @@ int32_t ctgGetSvrVerFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, char** ou char* msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_SERVER_VERSION; - void* (*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; + void* (*mallocFp)(int64_t) = pTask ? taosMemoryMalloc : rpcMallocCont; qDebug("try to get svr ver from mnode"); diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 0c0ca9649a5962e0b1c4bd49796c25f7bc52912a..4a64a8666eabf645d09753ab404c34e2167f7df4 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -13,11 +13,11 @@ * along with this program. If not, see . */ -#include "trpc.h" -#include "query.h" -#include "tname.h" #include "catalogInt.h" +#include "query.h" #include "systable.h" +#include "tname.h" +#include "trpc.h" void ctgFreeMsgSendParam(void* param) { if (NULL == param) { @@ -39,16 +39,16 @@ void ctgFreeBatchMsg(void* msg) { taosMemoryFree(pMsg->msg); } -void ctgFreeBatch(SCtgBatch *pBatch) { +void ctgFreeBatch(SCtgBatch* pBatch) { if (NULL == pBatch) { return; } - + taosArrayDestroyEx(pBatch->pMsgs, ctgFreeBatchMsg); taosArrayDestroy(pBatch->pTaskIds); } -void ctgFreeBatchs(SHashObj *pBatchs) { +void ctgFreeBatchs(SHashObj* pBatchs) { void* p = taosHashIterate(pBatchs, NULL); while (NULL != p) { SCtgBatch* pBatch = (SCtgBatch*)p; @@ -61,7 +61,7 @@ void ctgFreeBatchs(SHashObj *pBatchs) { taosHashCleanup(pBatchs); } -char *ctgTaskTypeStr(CTG_TASK_TYPE type) { +char* ctgTaskTypeStr(CTG_TASK_TYPE type) { switch (type) { case CTG_TASK_GET_QNODE: return "[get qnode list]"; @@ -98,7 +98,7 @@ char *ctgTaskTypeStr(CTG_TASK_TYPE type) { } } -void ctgFreeQNode(SCtgQNode *node) { +void ctgFreeQNode(SCtgQNode* node) { if (NULL == node) { return; } @@ -107,16 +107,16 @@ void ctgFreeQNode(SCtgQNode *node) { taosMemoryFree(node->op->data); taosMemoryFree(node->op); } - + taosMemoryFree(node); } -void ctgFreeSTableIndex(void *info) { +void ctgFreeSTableIndex(void* info) { if (NULL == info) { return; } - STableIndex *pInfo = (STableIndex *)info; + STableIndex* pInfo = (STableIndex*)info; taosArrayDestroyEx(pInfo->pIndex, tFreeSTableIndexInfo); } @@ -125,42 +125,42 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pTableMeta); pData->pTableMeta = NULL; -/* - for (int32_t i = 0; i < taosArrayGetSize(pData->pDbVgroup); ++i) { - SArray** pArray = taosArrayGet(pData->pDbVgroup, i); - taosArrayDestroy(*pArray); - } -*/ + /* + for (int32_t i = 0; i < taosArrayGetSize(pData->pDbVgroup); ++i) { + SArray** pArray = taosArrayGet(pData->pDbVgroup, i); + taosArrayDestroy(*pArray); + } + */ taosArrayDestroy(pData->pDbVgroup); pData->pDbVgroup = NULL; - + taosArrayDestroy(pData->pTableHash); pData->pTableHash = NULL; taosArrayDestroy(pData->pTableIndex); pData->pTableIndex = NULL; - + taosArrayDestroy(pData->pUdfList); pData->pUdfList = NULL; -/* - for (int32_t i = 0; i < taosArrayGetSize(pData->pDbCfg); ++i) { - SDbCfgInfo* pInfo = taosArrayGet(pData->pDbCfg, i); - taosArrayDestroy(pInfo->pRetensions); - } -*/ + /* + for (int32_t i = 0; i < taosArrayGetSize(pData->pDbCfg); ++i) { + SDbCfgInfo* pInfo = taosArrayGet(pData->pDbCfg, i); + taosArrayDestroy(pInfo->pRetensions); + } + */ taosArrayDestroy(pData->pDbCfg); pData->pDbCfg = NULL; taosArrayDestroy(pData->pDbInfo); pData->pDbInfo = NULL; - + taosArrayDestroy(pData->pIndex); pData->pIndex = NULL; - + taosArrayDestroy(pData->pUser); pData->pUser = NULL; - + taosArrayDestroy(pData->pQnodeList); pData->pQnodeList = NULL; @@ -173,19 +173,19 @@ void ctgFreeSMetaData(SMetaData* pData) { taosMemoryFreeClear(pData->pSvrVer); } -void ctgFreeSCtgUserAuth(SCtgUserAuth *userCache) { +void ctgFreeSCtgUserAuth(SCtgUserAuth* userCache) { taosHashCleanup(userCache->createdDbs); taosHashCleanup(userCache->readDbs); taosHashCleanup(userCache->writeDbs); } -void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { +void ctgFreeMetaRent(SCtgRentMgmt* mgmt) { if (NULL == mgmt->slots) { return; } for (int32_t i = 0; i < mgmt->slotNum; ++i) { - SCtgRentSlot *slot = &mgmt->slots[i]; + SCtgRentSlot* slot = &mgmt->slots[i]; if (slot->meta) { taosArrayDestroy(slot->meta); slot->meta = NULL; @@ -195,18 +195,18 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { taosMemoryFreeClear(mgmt->slots); } -void ctgFreeStbMetaCache(SCtgDBCache *dbCache) { +void ctgFreeStbMetaCache(SCtgDBCache* dbCache) { if (NULL == dbCache->stbCache) { return; } - int32_t stbNum = taosHashGetSize(dbCache->stbCache); + int32_t stbNum = taosHashGetSize(dbCache->stbCache); taosHashCleanup(dbCache->stbCache); dbCache->stbCache = NULL; CTG_CACHE_STAT_DEC(numOfStb, stbNum); } -void ctgFreeTbCacheImpl(SCtgTbCache *pCache) { +void ctgFreeTbCacheImpl(SCtgTbCache* pCache) { qDebug("tbMeta freed, p:%p", pCache->pMeta); taosMemoryFreeClear(pCache->pMeta); if (pCache->pIndex) { @@ -215,13 +215,13 @@ void ctgFreeTbCacheImpl(SCtgTbCache *pCache) { } } -void ctgFreeTbCache(SCtgDBCache *dbCache) { +void ctgFreeTbCache(SCtgDBCache* dbCache) { if (NULL == dbCache->tbCache) { return; } - int32_t tblNum = taosHashGetSize(dbCache->tbCache); - SCtgTbCache *pCache = taosHashIterate(dbCache->tbCache, NULL); + int32_t tblNum = taosHashGetSize(dbCache->tbCache); + SCtgTbCache* pCache = taosHashIterate(dbCache->tbCache, NULL); while (NULL != pCache) { ctgFreeTbCacheImpl(pCache); pCache = taosHashIterate(dbCache->tbCache, pCache); @@ -231,7 +231,7 @@ void ctgFreeTbCache(SCtgDBCache *dbCache) { CTG_CACHE_STAT_DEC(numOfTbl, tblNum); } -void ctgFreeVgInfo(SDBVgInfo *vgInfo) { +void ctgFreeVgInfo(SDBVgInfo* vgInfo) { if (NULL == vgInfo) { return; } @@ -240,15 +240,13 @@ void ctgFreeVgInfo(SDBVgInfo *vgInfo) { taosHashCleanup(vgInfo->vgHash); vgInfo->vgHash = NULL; } - + taosMemoryFreeClear(vgInfo); } -void ctgFreeVgInfoCache(SCtgDBCache *dbCache) { - ctgFreeVgInfo(dbCache->vgCache.vgInfo); -} +void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { ctgFreeVgInfo(dbCache->vgCache.vgInfo); } -void ctgFreeDbCache(SCtgDBCache *dbCache) { +void ctgFreeDbCache(SCtgDBCache* dbCache) { if (NULL == dbCache) { return; } @@ -262,20 +260,20 @@ void ctgFreeInstDbCache(SHashObj* pDbCache) { if (NULL == pDbCache) { return; } - + int32_t dbNum = taosHashGetSize(pDbCache); - - void *pIter = taosHashIterate(pDbCache, NULL); + + void* pIter = taosHashIterate(pDbCache, NULL); while (pIter) { - SCtgDBCache *dbCache = pIter; + SCtgDBCache* dbCache = pIter; atomic_store_8(&dbCache->deleted, 1); ctgFreeDbCache(dbCache); - + pIter = taosHashIterate(pDbCache, pIter); - } + } taosHashCleanup(pDbCache); - + CTG_CACHE_STAT_DEC(numOfDb, dbNum); } @@ -283,19 +281,19 @@ void ctgFreeInstUserCache(SHashObj* pUserCache) { if (NULL == pUserCache) { return; } - + int32_t userNum = taosHashGetSize(pUserCache); - - void *pIter = taosHashIterate(pUserCache, NULL); + + void* pIter = taosHashIterate(pUserCache, NULL); while (pIter) { - SCtgUserAuth *userCache = pIter; + SCtgUserAuth* userCache = pIter; ctgFreeSCtgUserAuth(userCache); - + pIter = taosHashIterate(pUserCache, pIter); - } - + } + taosHashCleanup(pUserCache); - + CTG_CACHE_STAT_DEC(numOfUser, userNum); } @@ -309,7 +307,6 @@ void ctgFreeHandleImpl(SCatalog* pCtg) { taosMemoryFree(pCtg); } - void ctgFreeHandle(SCatalog* pCtg) { if (NULL == pCtg) { return; @@ -345,13 +342,15 @@ void ctgClearHandle(SCatalog* pCtg) { ctgMetaRentInit(&pCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB); ctgMetaRentInit(&pCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE); - - pCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + + pCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, + HASH_ENTRY_LOCK); if (NULL == pCtg->dbCache) { qError("taosHashInit %d dbCache failed", CTG_DEFAULT_CACHE_DB_NUMBER); } - - pCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + + pCtg->userCache = taosHashInit(gCtgMgmt.cfg.maxUserCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, + HASH_ENTRY_LOCK); if (NULL == pCtg->userCache) { ctgError("taosHashInit %d user cache failed", gCtgMgmt.cfg.maxUserCacheNum); } @@ -370,7 +369,7 @@ void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) { taosHashCleanup(pOutput->dbVgroup->vgHash); taosMemoryFreeClear(pOutput->dbVgroup); } - + taosMemoryFree(pOutput); } @@ -379,7 +378,7 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) { if (NULL == pCtx->out) { return; } - + switch (pCtx->reqType) { case TDMT_MND_GET_DB_CFG: { SDbCfgInfo* pOut = (SDbCfgInfo*)pCtx->out; @@ -387,7 +386,7 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) { taosMemoryFreeClear(pCtx->out); break; } - case TDMT_MND_USE_DB:{ + case TDMT_MND_USE_DB: { SUseDbOutput* pOut = (SUseDbOutput*)pCtx->out; ctgFreeSUseDbOutput(pOut); pCtx->out = NULL; @@ -459,17 +458,16 @@ void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput) { if (NULL == pOutput) { return; } - + taosMemoryFree(pOutput->tbMeta); taosMemoryFree(pOutput); } - void ctgResetTbMetaTask(SCtgTask* pTask) { SCtgTbMetaCtx* taskCtx = (SCtgTbMetaCtx*)pTask->taskCtx; memset(&taskCtx->tbInfo, 0, sizeof(taskCtx->tbInfo)); taskCtx->flag = CTG_FLAG_UNKNOWN_STB; - + if (pTask->msgCtx.lastOut) { ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut); pTask->msgCtx.lastOut = NULL; @@ -486,7 +484,7 @@ void ctgFreeBatchMeta(void* meta) { if (NULL == meta) { return; } - + SMetaRes* pRes = (SMetaRes*)meta; taosMemoryFreeClear(pRes->pRes); } @@ -495,13 +493,12 @@ void ctgFreeBatchHash(void* hash) { if (NULL == hash) { return; } - + SMetaRes* pRes = (SMetaRes*)hash; taosMemoryFreeClear(pRes->pRes); } - -void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { +void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) { switch (type) { case CTG_TASK_GET_QNODE: case CTG_TASK_GET_DNODE: @@ -534,8 +531,8 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { case CTG_TASK_GET_TB_HASH: case CTG_TASK_GET_DB_INFO: case CTG_TASK_GET_INDEX: - case CTG_TASK_GET_UDF: - case CTG_TASK_GET_USER: + case CTG_TASK_GET_UDF: + case CTG_TASK_GET_USER: case CTG_TASK_GET_SVR_VER: case CTG_TASK_GET_TB_META: { taosMemoryFreeClear(*pRes); @@ -547,7 +544,7 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { for (int32_t i = 0; i < num; ++i) { ctgFreeBatchMeta(taosArrayGet(pArray, i)); } - *pRes = NULL; // no need to free it + *pRes = NULL; // no need to free it break; } case CTG_TASK_GET_TB_HASH_BATCH: { @@ -556,17 +553,16 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void **pRes) { for (int32_t i = 0; i < num; ++i) { ctgFreeBatchHash(taosArrayGet(pArray, i)); } - *pRes = NULL; // no need to free it + *pRes = NULL; // no need to free it break; - } + } default: qError("invalid task type %d", type); break; } } - -void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { +void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void** pRes) { switch (type) { case CTG_TASK_GET_QNODE: case CTG_TASK_GET_DNODE: { @@ -603,12 +599,12 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { } break; } - case CTG_TASK_GET_TB_META: + case CTG_TASK_GET_TB_META: case CTG_TASK_GET_DB_INFO: case CTG_TASK_GET_TB_HASH: - case CTG_TASK_GET_INDEX: - case CTG_TASK_GET_UDF: - case CTG_TASK_GET_SVR_VER: + case CTG_TASK_GET_INDEX: + case CTG_TASK_GET_UDF: + case CTG_TASK_GET_SVR_VER: case CTG_TASK_GET_USER: { taosMemoryFreeClear(*pRes); break; @@ -629,8 +625,7 @@ void ctgFreeSubTaskRes(CTG_TASK_TYPE type, void **pRes) { } } - -void ctgClearSubTaskRes(SCtgSubRes *pRes) { +void ctgClearSubTaskRes(SCtgSubRes* pRes) { pRes->code = 0; if (NULL == pRes->res) { @@ -659,7 +654,7 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { // NO NEED TO FREE pNames taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeTbMetasMsgCtx); - + if (pTask->msgCtx.lastOut) { ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut); pTask->msgCtx.lastOut = NULL; @@ -670,7 +665,7 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { case CTG_TASK_GET_TB_HASH: { SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); - taosMemoryFreeClear(pTask->taskCtx); + taosMemoryFreeClear(pTask->taskCtx); break; } case CTG_TASK_GET_TB_HASH_BATCH: { @@ -680,10 +675,10 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { // NO NEED TO FREE pNames taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx); - + taosMemoryFreeClear(pTask->taskCtx); break; - } + } case CTG_TASK_GET_TB_INDEX: { SCtgTbIndexCtx* taskCtx = (SCtgTbIndexCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); @@ -699,10 +694,10 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { } case CTG_TASK_GET_DB_VGROUP: case CTG_TASK_GET_DB_CFG: - case CTG_TASK_GET_DB_INFO: + case CTG_TASK_GET_DB_INFO: case CTG_TASK_GET_INDEX: case CTG_TASK_GET_UDF: - case CTG_TASK_GET_QNODE: + case CTG_TASK_GET_QNODE: case CTG_TASK_GET_USER: { taosMemoryFreeClear(pTask->taskCtx); break; @@ -713,7 +708,6 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { } } - void ctgFreeTask(SCtgTask* pTask) { ctgFreeMsgCtx(&pTask->msgCtx); ctgFreeTaskRes(pTask->type, &pTask->res); @@ -741,10 +735,10 @@ void ctgFreeJob(void* job) { if (NULL == job) { return; } - + SCtgJob* pJob = (SCtgJob*)job; - int64_t rid = pJob->refId; + int64_t rid = pJob->refId; uint64_t qid = pJob->queryId; ctgFreeTasks(pJob->pTasks); @@ -776,7 +770,7 @@ int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* targ int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target) { SCtgMsgCtx ctx = {0}; - + ctx.reqType = reqType; ctx.out = out; if (target) { @@ -791,8 +785,7 @@ int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target) { return TSDB_CODE_SUCCESS; } - -int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) { +int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp* fp) { switch (hashMethod) { default: *fp = MurmurHash3_32; @@ -802,29 +795,29 @@ int32_t ctgGetHashFunction(int8_t hashMethod, tableNameHashFp *fp) { return TSDB_CODE_SUCCESS; } -int32_t ctgGenerateVgList(SCatalog *pCtg, SHashObj *vgHash, SArray** pList) { - SHashObj *vgroupHash = NULL; - SVgroupInfo *vgInfo = NULL; - SArray *vgList = NULL; - int32_t code = 0; - int32_t vgNum = taosHashGetSize(vgHash); +int32_t ctgGenerateVgList(SCatalog* pCtg, SHashObj* vgHash, SArray** pList) { + SHashObj* vgroupHash = NULL; + SVgroupInfo* vgInfo = NULL; + SArray* vgList = NULL; + int32_t code = 0; + int32_t vgNum = taosHashGetSize(vgHash); vgList = taosArrayInit(vgNum, sizeof(SVgroupInfo)); if (NULL == vgList) { ctgError("taosArrayInit failed, num:%d", vgNum); - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - void *pIter = taosHashIterate(vgHash, NULL); + void* pIter = taosHashIterate(vgHash, NULL); while (pIter) { vgInfo = pIter; if (NULL == taosArrayPush(vgList, vgInfo)) { ctgError("taosArrayPush failed, vgId:%d", vgInfo->vgId); - taosHashCancelIterate(vgHash, pIter); + taosHashCancelIterate(vgHash, pIter); CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); } - + pIter = taosHashIterate(vgHash, pIter); vgInfo = NULL; } @@ -844,12 +837,11 @@ _return: CTG_RET(code); } - -int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName *pTableName, SVgroupInfo *pVgroup) { +int32_t ctgGetVgInfoFromHashValue(SCatalog* pCtg, SDBVgInfo* dbInfo, const SName* pTableName, SVgroupInfo* pVgroup) { int32_t code = 0; - + int32_t vgNum = taosHashGetSize(dbInfo->vgHash); - char db[TSDB_DB_FNAME_LEN] = {0}; + char db[TSDB_DB_FNAME_LEN] = {0}; tNameGetFullDbName(pTableName, db); if (vgNum <= 0) { @@ -857,40 +849,43 @@ int32_t ctgGetVgInfoFromHashValue(SCatalog *pCtg, SDBVgInfo *dbInfo, const SName CTG_ERR_RET(TSDB_CODE_TSC_DB_NOT_SELECTED); } - SVgroupInfo *vgInfo = NULL; - char tbFullName[TSDB_TABLE_FNAME_LEN]; + SVgroupInfo* vgInfo = NULL; + char tbFullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pTableName, tbFullName); - uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix); + uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, + dbInfo->hashPrefix, dbInfo->hashSuffix); - void *pIter = taosHashIterate(dbInfo->vgHash, NULL); + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); while (pIter) { vgInfo = pIter; if (hashValue >= vgInfo->hashBegin && hashValue <= vgInfo->hashEnd) { taosHashCancelIterate(dbInfo->vgHash, pIter); break; } - + pIter = taosHashIterate(dbInfo->vgHash, pIter); vgInfo = NULL; } if (NULL == vgInfo) { - ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, taosHashGetSize(dbInfo->vgHash)); + ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, db, + taosHashGetSize(dbInfo->vgHash)); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } *pVgroup = *vgInfo; - ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps, - vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); + ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, + vgInfo->epSet.numOfEps, vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, + vgInfo->epSet.eps[vgInfo->epSet.inUse].port); CTG_RET(code); } -int32_t ctgHashValueComp(void const *lp, void const *rp) { - uint32_t *key = (uint32_t *)lp; - SVgroupInfo *pVg = *(SVgroupInfo **)rp; +int32_t ctgHashValueComp(void const* lp, void const* rp) { + uint32_t* key = (uint32_t*)lp; + SVgroupInfo* pVg = *(SVgroupInfo**)rp; if (*key < pVg->hashBegin) { return -1; @@ -902,8 +897,8 @@ int32_t ctgHashValueComp(void const *lp, void const *rp) { } int ctgVgInfoComp(const void* lp, const void* rp) { - SVgroupInfo *pLeft = *(SVgroupInfo **)lp; - SVgroupInfo *pRight = *(SVgroupInfo **)rp; + SVgroupInfo* pLeft = *(SVgroupInfo**)lp; + SVgroupInfo* pRight = *(SVgroupInfo**)rp; if (pLeft->hashBegin < pRight->hashBegin) { return -1; } else if (pLeft->hashBegin > pRight->hashBegin) { @@ -913,22 +908,22 @@ int ctgVgInfoComp(const void* lp, const void* rp) { return 0; } - -int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *dbInfo, SCtgTbHashsCtx *pCtx, char* dbFName, SArray* pNames, bool update) { - int32_t code = 0; +int32_t ctgGetVgInfosFromHashValue(SCatalog* pCtg, SCtgTaskReq* tReq, SDBVgInfo* dbInfo, SCtgTbHashsCtx* pCtx, + char* dbFName, SArray* pNames, bool update) { + int32_t code = 0; SCtgTask* pTask = tReq->pTask; - SMetaRes res = {0}; - int32_t vgNum = taosHashGetSize(dbInfo->vgHash); + SMetaRes res = {0}; + int32_t vgNum = taosHashGetSize(dbInfo->vgHash); if (vgNum <= 0) { ctgError("db vgroup cache invalid, db:%s, vgroup number:%d", dbFName, vgNum); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } - SVgroupInfo *vgInfo = NULL; - int32_t tbNum = taosArrayGetSize(pNames); + SVgroupInfo* vgInfo = NULL; + int32_t tbNum = taosArrayGetSize(pNames); if (1 == vgNum) { - void *pIter = taosHashIterate(dbInfo->vgHash, NULL); + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); for (int32_t i = 0; i < tbNum; ++i) { vgInfo = taosMemoryMalloc(sizeof(SVgroupInfo)); if (NULL == vgInfo) { @@ -939,11 +934,11 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *vgInfo = *(SVgroupInfo*)pIter; ctgDebug("Got tb hash vgroup, vgId:%d, epNum %d, current %s port %d", vgInfo->vgId, vgInfo->epSet.numOfEps, - vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); + vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); if (update) { SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx); - SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i); + SMetaRes* pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i); pRes->pRes = vgInfo; } else { res.pRes = vgInfo; @@ -956,7 +951,7 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo } SArray* pVgList = taosArrayInit(vgNum, POINTER_BYTES); - void *pIter = taosHashIterate(dbInfo->vgHash, NULL); + void* pIter = taosHashIterate(dbInfo->vgHash, NULL); while (pIter) { taosArrayPush(pVgList, &pIter); pIter = taosHashIterate(dbInfo->vgHash, pIter); @@ -967,21 +962,23 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo char tbFullName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFullName, "%s.", dbFName); int32_t offset = strlen(tbFullName); - SName* pName = NULL; + SName* pName = NULL; int32_t tbNameLen = 0; - + for (int32_t i = 0; i < tbNum; ++i) { pName = taosArrayGet(pNames, i); tbNameLen = offset + strlen(pName->tname); strcpy(tbFullName + offset, pName->tname); - uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, dbInfo->hashPrefix, dbInfo->hashSuffix); + uint32_t hashValue = taosGetTbHashVal(tbFullName, (uint32_t)strlen(tbFullName), dbInfo->hashMethod, + dbInfo->hashPrefix, dbInfo->hashSuffix); - SVgroupInfo **p = taosArraySearch(pVgList, &hashValue, ctgHashValueComp, TD_EQ); + SVgroupInfo** p = taosArraySearch(pVgList, &hashValue, ctgHashValueComp, TD_EQ); if (NULL == p) { - ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, taosHashGetSize(dbInfo->vgHash)); + ctgError("no hash range found for hash value [%u], db:%s, numOfVgId:%d", hashValue, dbFName, + taosHashGetSize(dbInfo->vgHash)); taosArrayDestroy(pVgList); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } @@ -996,17 +993,18 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo *pNewVg = *vgInfo; - ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, vgInfo->epSet.numOfEps, - vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, vgInfo->epSet.eps[vgInfo->epSet.inUse].port); + ctgDebug("Got tb %s hash vgroup, vgId:%d, epNum %d, current %s port %d", tbFullName, vgInfo->vgId, + vgInfo->epSet.numOfEps, vgInfo->epSet.eps[vgInfo->epSet.inUse].fqdn, + vgInfo->epSet.eps[vgInfo->epSet.inUse].port); if (update) { SCtgFetch* pFetch = taosArrayGet(pCtx->pFetchs, tReq->msgIdx); - SMetaRes *pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i); + SMetaRes* pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx + i); pRes->pRes = pNewVg; } else { res.pRes = pNewVg; taosArrayPush(pCtx->pResList, &res); - } + } } taosArrayDestroy(pVgList); @@ -1014,11 +1012,10 @@ int32_t ctgGetVgInfosFromHashValue(SCatalog *pCtg, SCtgTaskReq* tReq, SDBVgInfo CTG_RET(code); } - int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) { - if (*(uint64_t *)key1 < ((SSTableVersion*)key2)->suid) { + if (*(uint64_t*)key1 < ((SSTableVersion*)key2)->suid) { return -1; - } else if (*(uint64_t *)key1 > ((SSTableVersion*)key2)->suid) { + } else if (*(uint64_t*)key1 > ((SSTableVersion*)key2)->suid) { return 1; } else { return 0; @@ -1026,9 +1023,9 @@ int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2) { } int32_t ctgDbVgVersionSearchCompare(const void* key1, const void* key2) { - if (*(int64_t *)key1 < ((SDbVgVersion*)key2)->dbId) { + if (*(int64_t*)key1 < ((SDbVgVersion*)key2)->dbId) { return -1; - } else if (*(int64_t *)key1 > ((SDbVgVersion*)key2)->dbId) { + } else if (*(int64_t*)key1 > ((SDbVgVersion*)key2)->dbId) { return 1; } else { return 0; @@ -1055,10 +1052,7 @@ int32_t ctgDbVgVersionSortCompare(const void* key1, const void* key2) { } } - - - -int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) { +int32_t ctgCloneVgInfo(SDBVgInfo* src, SDBVgInfo** dst) { *dst = taosMemoryMalloc(sizeof(SDBVgInfo)); if (NULL == *dst) { qError("malloc %d failed", (int32_t)sizeof(SDBVgInfo)); @@ -1075,29 +1069,26 @@ int32_t ctgCloneVgInfo(SDBVgInfo *src, SDBVgInfo **dst) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - int32_t *vgId = NULL; - void *pIter = taosHashIterate(src->vgHash, NULL); + int32_t* vgId = NULL; + void* pIter = taosHashIterate(src->vgHash, NULL); while (pIter) { vgId = taosHashGetKey(pIter, NULL); - if (taosHashPut((*dst)->vgHash, (void *)vgId, sizeof(int32_t), pIter, sizeof(SVgroupInfo))) { + if (taosHashPut((*dst)->vgHash, (void*)vgId, sizeof(int32_t), pIter, sizeof(SVgroupInfo))) { qError("taosHashPut failed, hashSize:%d", (int32_t)hashSize); taosHashCancelIterate(src->vgHash, pIter); taosHashCleanup((*dst)->vgHash); taosMemoryFreeClear(*dst); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - + pIter = taosHashIterate(src->vgHash, pIter); } - return TSDB_CODE_SUCCESS; } - - -int32_t ctgCloneMetaOutput(STableMetaOutput *output, STableMetaOutput **pOutput) { +int32_t ctgCloneMetaOutput(STableMetaOutput* output, STableMetaOutput** pOutput) { *pOutput = taosMemoryMalloc(sizeof(STableMetaOutput)); if (NULL == *pOutput) { qError("malloc %d failed", (int32_t)sizeof(STableMetaOutput)); @@ -1135,7 +1126,7 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) { } for (int32_t i = 0; i < num; ++i) { - STableIndexInfo *pInfo = taosArrayGet(pIndex, i); + STableIndexInfo* pInfo = taosArrayGet(pIndex, i); pInfo = taosArrayPush(*pRes, pInfo); pInfo->expr = strdup(pInfo->expr); } @@ -1143,8 +1134,7 @@ int32_t ctgCloneTableIndex(SArray* pIndex, SArray** pRes) { return TSDB_CODE_SUCCESS; } - -int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId) { +int32_t ctgUpdateSendTargetInfo(SMsgSendInfo* pMsgSendInfo, int32_t msgType, char* dbFName, int32_t vgId) { if (msgType == TDMT_VND_TABLE_META || msgType == TDMT_VND_TABLE_CFG || msgType == TDMT_VND_BATCH_META) { pMsgSendInfo->target.type = TARGET_TYPE_VNODE; pMsgSendInfo->target.vgId = vgId; @@ -1156,7 +1146,7 @@ int32_t ctgUpdateSendTargetInfo(SMsgSendInfo *pMsgSendInfo, int32_t msgType, cha return TSDB_CODE_SUCCESS; } -int32_t ctgGetTablesReqNum(SArray *pList) { +int32_t ctgGetTablesReqNum(SArray* pList) { if (NULL == pList) { return 0; } @@ -1164,25 +1154,25 @@ int32_t ctgGetTablesReqNum(SArray *pList) { int32_t total = 0; int32_t n = taosArrayGetSize(pList); for (int32_t i = 0; i < n; ++i) { - STablesReq *pReq = taosArrayGet(pList, i); + STablesReq* pReq = taosArrayGet(pList, i); total += taosArrayGetSize(pReq->pTables); } return total; } -int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t *fetchIdx, int32_t resIdx, int32_t flag) { +int32_t ctgAddFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t* fetchIdx, int32_t resIdx, int32_t flag) { if (NULL == (*pFetchs)) { *pFetchs = taosArrayInit(CTG_DEFAULT_FETCH_NUM, sizeof(SCtgFetch)); } - + SCtgFetch fetch = {0}; fetch.dbIdx = dbIdx; fetch.tbIdx = tbIdx; fetch.fetchIdx = (*fetchIdx)++; fetch.resIdx = resIdx; fetch.flag = flag; - + taosArrayPush(*pFetchs, &fetch); return TSDB_CODE_SUCCESS; @@ -1193,13 +1183,9 @@ SName* ctgGetFetchName(SArray* pNames, SCtgFetch* pFetch) { return (SName*)taosArrayGet(pReq->pTables, pFetch->tbIdx); } -static void* ctgCloneDbVgroup(void* pSrc) { - return taosArrayDup((const SArray*)pSrc); -} +static void* ctgCloneDbVgroup(void* pSrc) { return taosArrayDup((const SArray*)pSrc); } -static void ctgFreeDbVgroup(void* p) { - taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); -} +static void ctgFreeDbVgroup(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } static void* ctgCloneDbCfgInfo(void* pSrc) { SDbCfgInfo* pDst = taosMemoryMalloc(sizeof(SDbCfgInfo)); @@ -1210,9 +1196,7 @@ static void* ctgCloneDbCfgInfo(void* pSrc) { return pDst; } -static void ctgFreeDbCfgInfo(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeDbCfgInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } static void* ctgCloneDbInfo(void* pSrc) { SDbInfo* pDst = taosMemoryMalloc(sizeof(SDbInfo)); @@ -1223,9 +1207,7 @@ static void* ctgCloneDbInfo(void* pSrc) { return pDst; } -static void ctgFreeDbInfo(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeDbInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } static void* ctgCloneTableMeta(void* pSrc) { STableMeta* pMeta = pSrc; @@ -1238,9 +1220,7 @@ static void* ctgCloneTableMeta(void* pSrc) { return pDst; } -static void ctgFreeTableMeta(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeTableMeta(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } static void* ctgCloneVgroupInfo(void* pSrc) { SVgroupInfo* pDst = taosMemoryMalloc(sizeof(SVgroupInfo)); @@ -1251,17 +1231,11 @@ static void* ctgCloneVgroupInfo(void* pSrc) { return pDst; } -static void ctgFreeVgroupInfo(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeVgroupInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } -static void* ctgCloneTableIndices(void* pSrc) { - return taosArrayDup((const SArray*)pSrc); -} +static void* ctgCloneTableIndices(void* pSrc) { return taosArrayDup((const SArray*)pSrc); } -static void ctgFreeTableIndices(void* p) { - taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); -} +static void ctgFreeTableIndices(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } static void* ctgCloneFuncInfo(void* pSrc) { SFuncInfo* pDst = taosMemoryMalloc(sizeof(SFuncInfo)); @@ -1272,9 +1246,7 @@ static void* ctgCloneFuncInfo(void* pSrc) { return pDst; } -static void ctgFreeFuncInfo(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeFuncInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } static void* ctgCloneIndexInfo(void* pSrc) { SIndexInfo* pDst = taosMemoryMalloc(sizeof(SIndexInfo)); @@ -1285,9 +1257,7 @@ static void* ctgCloneIndexInfo(void* pSrc) { return pDst; } -static void ctgFreeIndexInfo(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeIndexInfo(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } static void* ctgCloneUserAuth(void* pSrc) { bool* pDst = taosMemoryMalloc(sizeof(bool)); @@ -1298,17 +1268,11 @@ static void* ctgCloneUserAuth(void* pSrc) { return pDst; } -static void ctgFreeUserAuth(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeUserAuth(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } -static void* ctgCloneQnodeList(void* pSrc) { - return taosArrayDup((const SArray*)pSrc); -} +static void* ctgCloneQnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); } -static void ctgFreeQnodeList(void* p) { - taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); -} +static void ctgFreeQnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } static void* ctgCloneTableCfg(void* pSrc) { STableCfg* pDst = taosMemoryMalloc(sizeof(STableCfg)); @@ -1319,17 +1283,11 @@ static void* ctgCloneTableCfg(void* pSrc) { return pDst; } -static void ctgFreeTableCfg(void* p) { - taosMemoryFree(((SMetaRes*)p)->pRes); -} +static void ctgFreeTableCfg(void* p) { taosMemoryFree(((SMetaRes*)p)->pRes); } -static void* ctgCloneDnodeList(void* pSrc) { - return taosArrayDup((const SArray*)pSrc); -} +static void* ctgCloneDnodeList(void* pSrc) { return taosArrayDup((const SArray*)pSrc); } -static void ctgFreeDnodeList(void* p) { - taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); -} +static void ctgFreeDnodeList(void* p) { taosArrayDestroy((SArray*)((SMetaRes*)p)->pRes); } static int32_t ctgCloneMetaDataArray(SArray* pSrc, FCopy copyFunc, SArray** pDst) { if (NULL == pSrc) { @@ -1343,7 +1301,7 @@ static int32_t ctgCloneMetaDataArray(SArray* pSrc, FCopy copyFunc, SArray** pDst } for (int32_t i = 0; i < size; ++i) { SMetaRes* pRes = taosArrayGet(pSrc, i); - SMetaRes res = {.code = pRes->code, .pRes = copyFunc(pRes->pRes)}; + SMetaRes res = {.code = pRes->code, .pRes = copyFunc(pRes->pRes)}; if (NULL == res.pRes) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -1412,8 +1370,8 @@ void catalogFreeMetaData(SMetaData* pData) { taosArrayDestroyEx(pData->pDbInfo, ctgFreeDbInfo); taosArrayDestroyEx(pData->pTableMeta, ctgFreeTableMeta); taosArrayDestroyEx(pData->pTableHash, ctgFreeVgroupInfo); - taosArrayDestroyEx(pData->pTableIndex, ctgFreeTableIndices); - taosArrayDestroyEx(pData->pUdfList, ctgFreeFuncInfo); + taosArrayDestroyEx(pData->pTableIndex, ctgFreeTableIndices); + taosArrayDestroyEx(pData->pUdfList, ctgFreeFuncInfo); taosArrayDestroyEx(pData->pIndex, ctgFreeIndexInfo); taosArrayDestroyEx(pData->pUser, ctgFreeUserAuth); taosArrayDestroyEx(pData->pQnodeList, ctgFreeQnodeList); diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index c01c269e643b2a1f2a44817a74807c20db718d4b..bb4fd04aac51564144ce8c25d43662b8746aaa62 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -27,20 +27,20 @@ #ifdef WINDOWS #define TD_USE_WINSOCK #endif -#include "os.h" -#include "tglobal.h" #include "catalog.h" #include "catalogInt.h" +#include "os.h" #include "stub.h" #include "taos.h" #include "tdatablock.h" #include "tdef.h" +#include "tglobal.h" #include "trpc.h" #include "tvariant.h" namespace { -extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type); +extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog *pCatalog, int32_t type); extern "C" int32_t ctgdEnableDebug(char *option); extern "C" int32_t ctgdGetStatNum(char *option, void *res); @@ -49,7 +49,7 @@ void ctgTestSetRspCTableMeta(); void ctgTestSetRspSTableMeta(); void ctgTestSetRspMultiSTableMeta(); -//extern "C" SCatalogMgmt gCtgMgmt; +// extern "C" SCatalogMgmt gCtgMgmt; enum { CTGT_RSP_VGINFO = 1, @@ -131,7 +131,7 @@ void ctgTestInitLogFile() { if (!ctgTestEnableLog) { return; } - + const char *defaultLogFileNamePrefix = "taoslog"; const int32_t maxLogFileNum = 10; @@ -142,7 +142,7 @@ void ctgTestInitLogFile() { ctgdEnableDebug("api"); ctgdEnableDebug("meta"); ctgdEnableDebug("cache"); - + if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); } @@ -153,11 +153,11 @@ int32_t ctgTestGetVgNumFromVgVersion(int32_t vgVersion) { } void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) { - SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName cn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(cn.dbname, "db1"); strcpy(cn.tname, ctgTestCTablename); - SName sn = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName sn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(sn.dbname, "db1"); strcpy(sn.tname, ctgTestSTablename); @@ -175,7 +175,8 @@ void ctgTestBuildCTableMetaOutput(STableMetaOutput *output) { output->ctbMeta.uid = 3; output->ctbMeta.suid = 2; - output->tbMeta = (STableMeta *)taosMemoryCalloc(1, sizeof(STableMeta) + sizeof(SSchema) * (ctgTestColNum + ctgTestColNum)); + output->tbMeta = + (STableMeta *)taosMemoryCalloc(1, sizeof(STableMeta) + sizeof(SSchema) * (ctgTestColNum + ctgTestColNum)); output->tbMeta->vgId = 9; output->tbMeta->tableType = TSDB_SUPER_TABLE; output->tbMeta->uid = 2; @@ -211,7 +212,7 @@ void ctgTestBuildDBVgroup(SDBVgInfo **pdbVgroup) { static int32_t vgVersion = ctgTestVgVersion + 1; int32_t vgNum = 0; SVgroupInfo vgInfo = {0}; - SDBVgInfo *dbVgroup = (SDBVgInfo *)taosMemoryCalloc(1, sizeof(SDBVgInfo)); + SDBVgInfo *dbVgroup = (SDBVgInfo *)taosMemoryCalloc(1, sizeof(SDBVgInfo)); dbVgroup->vgVersion = vgVersion++; @@ -256,7 +257,7 @@ void ctgTestBuildSTableMetaRsp(STableMetaRsp *rspMsg) { rspMsg->suid = ctgTestSuid + 1; rspMsg->tuid = ctgTestSuid + 1; rspMsg->vgId = 1; - + rspMsg->pSchemas = (SSchema *)taosMemoryCalloc(rspMsg->numOfTags + rspMsg->numOfColumns, sizeof(SSchema)); SSchema *s = NULL; @@ -364,7 +365,6 @@ void ctgTestRspTableMetaNotExist(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, S pRsp->code = CTG_ERR_CODE_TABLE_NOT_EXIST; } - void ctgTestRspCTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { STableMetaRsp metaRsp = {0}; strcpy(metaRsp.dbFName, ctgTestDbname); @@ -573,8 +573,8 @@ void ctgTestSetRspDbVgroups() { stub.set(rpcSendRecv, ctgTestRspDbVgroups); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -593,8 +593,8 @@ void ctgTestSetRspTableMeta() { stub.set(rpcSendRecv, ctgTestRspTableMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -613,8 +613,8 @@ void ctgTestSetRspCTableMeta() { stub.set(rpcSendRecv, ctgTestRspCTableMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -633,8 +633,8 @@ void ctgTestSetRspSTableMeta() { stub.set(rpcSendRecv, ctgTestRspSTableMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -653,8 +653,8 @@ void ctgTestSetRspMultiSTableMeta() { stub.set(rpcSendRecv, ctgTestRspMultiSTableMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -673,8 +673,8 @@ void ctgTestSetRspByIdx() { stub.set(rpcSendRecv, ctgTestRspByIdx); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -688,14 +688,13 @@ void ctgTestSetRspByIdx() { } } - void ctgTestSetRspDbVgroupsAndNormalMeta() { static Stub stub; stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndNormalMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -714,8 +713,8 @@ void ctgTestSetRspDbVgroupsAndChildMeta() { stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndChildMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -734,8 +733,8 @@ void ctgTestSetRspDbVgroupsAndSuperMeta() { stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndSuperMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -754,8 +753,8 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() { stub.set(rpcSendRecv, ctgTestRspDbVgroupsAndMultiSuperMeta); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRecv", result); #endif #ifdef LINUX @@ -772,11 +771,11 @@ void ctgTestSetRspDbVgroupsAndMultiSuperMeta() { } // namespace void *ctgTestGetDbVgroupThread(void *param) { - struct SCatalog *pCtg = (struct SCatalog *)param; - int32_t code = 0; + struct SCatalog *pCtg = (struct SCatalog *)param; + int32_t code = 0; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SArray *vgList = NULL; - int32_t n = 0; + SArray *vgList = NULL; + int32_t n = 0; while (!ctgTestStop) { code = catalogGetDBVgInfo(pCtg, mockPointer, ctgTestDbname, &vgList); @@ -826,7 +825,7 @@ void *ctgTestSetSameDbVgroupThread(void *param) { void *ctgTestSetDiffDbVgroupThread(void *param) { struct SCatalog *pCtg = (struct SCatalog *)param; int32_t code = 0; - SDBVgInfo *dbVgroup = NULL; + SDBVgInfo *dbVgroup = NULL; int32_t n = 0; while (!ctgTestStop) { @@ -854,7 +853,7 @@ void *ctgTestGetCtableMetaThread(void *param) { STableMeta *tbMeta = NULL; bool inCache = false; - SName cn = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName cn = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(cn.dbname, "db1"); strcpy(cn.tname, ctgTestCTablename); @@ -883,14 +882,14 @@ void *ctgTestGetCtableMetaThread(void *param) { } void *ctgTestSetCtableMetaThread(void *param) { - struct SCatalog *pCtg = (struct SCatalog *)param; - int32_t code = 0; - SDBVgInfo dbVgroup = {0}; - int32_t n = 0; + struct SCatalog *pCtg = (struct SCatalog *)param; + int32_t code = 0; + SDBVgInfo dbVgroup = {0}; + int32_t n = 0; STableMetaOutput *output = NULL; SCtgCacheOperation operation = {0}; - + operation.opId = CTG_OP_UPDATE_TB_META; while (!ctgTestStop) { @@ -920,11 +919,10 @@ void *ctgTestSetCtableMetaThread(void *param) { #if 1 - TEST(tableMeta, normalTable) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; + SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -940,7 +938,7 @@ TEST(tableMeta, normalTable) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -952,7 +950,7 @@ TEST(tableMeta, normalTable) { while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) { taosMsleep(50); } - + ctgTestSetRspTableMeta(); STableMeta *tableMeta = NULL; @@ -977,7 +975,6 @@ TEST(tableMeta, normalTable) { } } - tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); @@ -990,10 +987,10 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(tableMeta->tableInfo.precision, 1); ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); - SDbVgVersion *dbs = NULL; + SDbVgVersion *dbs = NULL; SSTableVersion *stb = NULL; - uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; - int32_t i = 0; + uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; + int32_t i = 0; while (i < 5) { ++i; code = catalogGetExpiredDBs(pCtg, &dbs, &dbNum); @@ -1030,9 +1027,9 @@ TEST(tableMeta, normalTable) { } TEST(tableMeta, childTableCase) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; + SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1047,7 +1044,7 @@ TEST(tableMeta, childTableCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestCTablename); @@ -1072,7 +1069,6 @@ TEST(tableMeta, childTableCase) { } } - tableMeta = NULL; code = catalogGetTableMeta(pCtg, mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); @@ -1099,10 +1095,10 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(tableMeta->tableInfo.precision, 1); ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); - SDbVgVersion *dbs = NULL; + SDbVgVersion *dbs = NULL; SSTableVersion *stb = NULL; - uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; - int32_t i = 0; + uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; + int32_t i = 0; while (i < 5) { ++i; code = catalogGetExpiredDBs(pCtg, &dbs, &dbNum); @@ -1139,9 +1135,9 @@ TEST(tableMeta, childTableCase) { } TEST(tableMeta, superTableCase) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; + SVgroupInfo vgInfo = {0}; ctgTestSetRspDbVgroupsAndSuperMeta(); @@ -1154,7 +1150,7 @@ TEST(tableMeta, superTableCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestSTablename); @@ -1181,7 +1177,6 @@ TEST(tableMeta, superTableCase) { } } - ctgTestSetRspCTableMeta(); tableMeta = NULL; @@ -1208,7 +1203,6 @@ TEST(tableMeta, superTableCase) { } } - tableMeta = NULL; code = catalogRefreshGetTableMeta(pCtg, mockPointer, &n, &tableMeta, 0); ASSERT_EQ(code, 0); @@ -1221,10 +1215,10 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.precision, 1); ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); - SDbVgVersion *dbs = NULL; + SDbVgVersion *dbs = NULL; SSTableVersion *stb = NULL; - uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; - int32_t i = 0; + uint32_t dbNum = 0, stbNum = 0, allDbNum = 0, allStbNum = 0; + int32_t i = 0; while (i < 5) { ++i; code = catalogGetExpiredDBs(pCtg, &dbs, &dbNum); @@ -1262,9 +1256,9 @@ TEST(tableMeta, superTableCase) { } TEST(tableMeta, rmStbMeta) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; + SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1279,7 +1273,7 @@ TEST(tableMeta, rmStbMeta) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestSTablename); @@ -1306,7 +1300,6 @@ TEST(tableMeta, rmStbMeta) { } } - code = catalogRemoveStbMeta(pCtg, "1.db1", ctgTestDbId, ctgTestSTablename, ctgTestSuid - 1); ASSERT_EQ(code, 0); @@ -1320,7 +1313,6 @@ TEST(tableMeta, rmStbMeta) { } } - ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 0); ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 0); @@ -1332,9 +1324,9 @@ TEST(tableMeta, rmStbMeta) { } TEST(tableMeta, updateStbMeta) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; + SVgroupInfo vgInfo = {0}; ctgTestInitLogFile(); @@ -1349,7 +1341,7 @@ TEST(tableMeta, updateStbMeta) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestSTablename); @@ -1376,7 +1368,6 @@ TEST(tableMeta, updateStbMeta) { } } - taosMemoryFreeClear(tableMeta); STableMetaRsp rsp = {0}; @@ -1422,10 +1413,10 @@ TEST(tableMeta, updateStbMeta) { } TEST(refreshGetMeta, normal2normal) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1434,7 +1425,7 @@ TEST(refreshGetMeta, normal2normal) { ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; ctgTestRspFunc[2] = CTGT_RSP_TBMETA; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1447,7 +1438,7 @@ TEST(refreshGetMeta, normal2normal) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -1470,7 +1461,7 @@ TEST(refreshGetMeta, normal2normal) { ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); - ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); @@ -1487,7 +1478,7 @@ TEST(refreshGetMeta, normal2normal) { ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); - ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); @@ -1501,10 +1492,10 @@ TEST(refreshGetMeta, normal2normal) { } TEST(refreshGetMeta, normal2notexist) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1513,7 +1504,7 @@ TEST(refreshGetMeta, normal2notexist) { ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; ctgTestRspFunc[2] = CTGT_RSP_TBMETA_NOT_EXIST; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1526,7 +1517,7 @@ TEST(refreshGetMeta, normal2notexist) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -1549,7 +1540,7 @@ TEST(refreshGetMeta, normal2notexist) { ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); - ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); @@ -1570,12 +1561,11 @@ TEST(refreshGetMeta, normal2notexist) { memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); } - TEST(refreshGetMeta, normal2child) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1585,7 +1575,7 @@ TEST(refreshGetMeta, normal2child) { ctgTestRspFunc[1] = CTGT_RSP_TBMETA; ctgTestRspFunc[2] = CTGT_RSP_CTBMETA; ctgTestRspFunc[3] = CTGT_RSP_STBMETA; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1598,7 +1588,7 @@ TEST(refreshGetMeta, normal2child) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); ctgTestCurrentCTableName = ctgTestTablename; @@ -1623,7 +1613,7 @@ TEST(refreshGetMeta, normal2child) { ASSERT_EQ(code, 0); ASSERT_EQ(tableMeta->vgId, 8); ASSERT_EQ(tableMeta->tableType, TSDB_NORMAL_TABLE); - ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); + ASSERT_EQ(tableMeta->uid, ctgTestNormalTblUid - 1); ASSERT_EQ(tableMeta->sversion, ctgTestSVersion); ASSERT_EQ(tableMeta->tversion, ctgTestTVersion); ASSERT_EQ(tableMeta->tableInfo.numOfColumns, ctgTestColNum); @@ -1655,10 +1645,10 @@ TEST(refreshGetMeta, normal2child) { } TEST(refreshGetMeta, stable2child) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1669,7 +1659,7 @@ TEST(refreshGetMeta, stable2child) { ctgTestRspFunc[2] = CTGT_RSP_STBMETA; ctgTestRspFunc[3] = CTGT_RSP_CTBMETA; ctgTestRspFunc[4] = CTGT_RSP_STBMETA; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1682,7 +1672,7 @@ TEST(refreshGetMeta, stable2child) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); ctgTestCurrentSTableName = ctgTestTablename; @@ -1741,10 +1731,10 @@ TEST(refreshGetMeta, stable2child) { } TEST(refreshGetMeta, stable2stable) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1755,7 +1745,7 @@ TEST(refreshGetMeta, stable2stable) { ctgTestRspFunc[2] = CTGT_RSP_STBMETA; ctgTestRspFunc[3] = CTGT_RSP_STBMETA; ctgTestRspFunc[4] = CTGT_RSP_STBMETA; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1768,7 +1758,7 @@ TEST(refreshGetMeta, stable2stable) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); ctgTestCurrentSTableName = ctgTestTablename; @@ -1826,12 +1816,11 @@ TEST(refreshGetMeta, stable2stable) { ctgTestCurrentSTableName = NULL; } - TEST(refreshGetMeta, child2stable) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1842,7 +1831,7 @@ TEST(refreshGetMeta, child2stable) { ctgTestRspFunc[2] = CTGT_RSP_STBMETA; ctgTestRspFunc[3] = CTGT_RSP_STBMETA; ctgTestRspFunc[4] = CTGT_RSP_STBMETA; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1855,7 +1844,7 @@ TEST(refreshGetMeta, child2stable) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); ctgTestCurrentCTableName = ctgTestTablename; @@ -1913,12 +1902,11 @@ TEST(refreshGetMeta, child2stable) { ctgTestCurrentSTableName = NULL; } - TEST(tableDistVgroup, normalTable) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo *vgInfo = NULL; - SArray *vgList = NULL; + SVgroupInfo *vgInfo = NULL; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1927,7 +1915,7 @@ TEST(tableDistVgroup, normalTable) { ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; ctgTestRspFunc[2] = CTGT_RSP_VGINFO; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1940,7 +1928,7 @@ TEST(tableDistVgroup, normalTable) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -1956,10 +1944,10 @@ TEST(tableDistVgroup, normalTable) { } TEST(tableDistVgroup, childTableCase) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo *vgInfo = NULL; - SArray *vgList = NULL; + SVgroupInfo *vgInfo = NULL; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -1969,7 +1957,7 @@ TEST(tableDistVgroup, childTableCase) { ctgTestRspFunc[1] = CTGT_RSP_CTBMETA; ctgTestRspFunc[2] = CTGT_RSP_STBMETA; ctgTestRspFunc[3] = CTGT_RSP_VGINFO; - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -1982,7 +1970,7 @@ TEST(tableDistVgroup, childTableCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestCTablename); @@ -1998,10 +1986,10 @@ TEST(tableDistVgroup, childTableCase) { } TEST(tableDistVgroup, superTableCase) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo *vgInfo = NULL; - SArray *vgList = NULL; + SVgroupInfo *vgInfo = NULL; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -2011,10 +1999,8 @@ TEST(tableDistVgroup, superTableCase) { ctgTestRspFunc[1] = CTGT_RSP_STBMETA; ctgTestRspFunc[2] = CTGT_RSP_STBMETA; ctgTestRspFunc[3] = CTGT_RSP_VGINFO; - - ctgTestSetRspByIdx(); - + ctgTestSetRspByIdx(); initQueryModuleMsgHandle(); @@ -2025,7 +2011,7 @@ TEST(tableDistVgroup, superTableCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestSTablename); @@ -2047,12 +2033,12 @@ TEST(tableDistVgroup, superTableCase) { } TEST(dbVgroup, getSetDbVgroupCase) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SVgroupInfo *pvgInfo = NULL; - SDBVgInfo *dbVgroup = NULL; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SVgroupInfo *pvgInfo = NULL; + SDBVgInfo *dbVgroup = NULL; + SArray *vgList = NULL; ctgTestInitLogFile(); @@ -2061,10 +2047,8 @@ TEST(dbVgroup, getSetDbVgroupCase) { ctgTestRspFunc[0] = CTGT_RSP_VGINFO; ctgTestRspFunc[1] = CTGT_RSP_TBMETA; - ctgTestSetRspByIdx(); - initQueryModuleMsgHandle(); // sendCreateDbMsg(pConn->pTransporter, &pConn->pAppInfo->mgmtEp.epSet); @@ -2075,7 +2059,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -2119,7 +2103,6 @@ TEST(dbVgroup, getSetDbVgroupCase) { } } - code = catalogGetTableHashVgroup(pCtg, mockPointer, &n, &vgInfo); ASSERT_EQ(code, 0); ASSERT_EQ(vgInfo.vgId, 7); @@ -2138,12 +2121,12 @@ TEST(dbVgroup, getSetDbVgroupCase) { } TEST(multiThread, getSetRmSameDbVgroup) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SVgroupInfo *pvgInfo = NULL; - SDBVgInfo dbVgroup = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SVgroupInfo *pvgInfo = NULL; + SDBVgInfo dbVgroup = {0}; + SArray *vgList = NULL; ctgTestStop = false; ctgTestInitLogFile(); @@ -2160,7 +2143,7 @@ TEST(multiThread, getSetRmSameDbVgroup) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -2190,12 +2173,12 @@ TEST(multiThread, getSetRmSameDbVgroup) { } TEST(multiThread, getSetRmDiffDbVgroup) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SVgroupInfo *pvgInfo = NULL; - SDBVgInfo dbVgroup = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SVgroupInfo *pvgInfo = NULL; + SDBVgInfo dbVgroup = {0}; + SArray *vgList = NULL; ctgTestStop = false; ctgTestInitLogFile(); @@ -2212,7 +2195,7 @@ TEST(multiThread, getSetRmDiffDbVgroup) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -2242,12 +2225,12 @@ TEST(multiThread, getSetRmDiffDbVgroup) { } TEST(multiThread, ctableMeta) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SVgroupInfo *pvgInfo = NULL; - SDBVgInfo dbVgroup = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SVgroupInfo *pvgInfo = NULL; + SDBVgInfo dbVgroup = {0}; + SArray *vgList = NULL; ctgTestStop = false; ctgTestInitLogFile(); @@ -2264,7 +2247,7 @@ TEST(multiThread, ctableMeta) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); strcpy(n.tname, ctgTestTablename); @@ -2293,16 +2276,16 @@ TEST(multiThread, ctableMeta) { } TEST(rentTest, allRent) { - struct SCatalog *pCtg = NULL; + struct SCatalog *pCtg = NULL; SRequestConnInfo *mockPointer = (SRequestConnInfo *)0x1; - SVgroupInfo vgInfo = {0}; - SVgroupInfo *pvgInfo = NULL; - SDBVgInfo dbVgroup = {0}; - SArray *vgList = NULL; + SVgroupInfo vgInfo = {0}; + SVgroupInfo *pvgInfo = NULL; + SDBVgInfo dbVgroup = {0}; + SArray *vgList = NULL; ctgTestStop = false; - SDbVgVersion *dbs = NULL; + SDbVgVersion *dbs = NULL; SSTableVersion *stable = NULL; - uint32_t num = 0; + uint32_t num = 0; ctgTestInitLogFile(); @@ -2316,7 +2299,7 @@ TEST(rentTest, allRent) { code = catalogGetHandle(ctgTestClusterId, &pCtg); ASSERT_EQ(code, 0); - SName n = { TSDB_TABLE_NAME_T, 1, {0}, {0} }; + SName n = {TSDB_TABLE_NAME_T, 1, {0}, {0}}; strcpy(n.dbname, "db1"); for (int32_t i = 1; i <= 10; ++i) { diff --git a/source/libs/command/test/commandTest.cpp b/source/libs/command/test/commandTest.cpp index 59118c501ae8ec9225d310760d71973b22036ce7..8154ee31174cb8cc769abe2efaecabb5f02257fb 100644 --- a/source/libs/command/test/commandTest.cpp +++ b/source/libs/command/test/commandTest.cpp @@ -16,6 +16,6 @@ #include int main(int argc, char* argv[]) { - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } diff --git a/source/libs/executor/inc/dataSinkInt.h b/source/libs/executor/inc/dataSinkInt.h index 9426c99a0fc4fa55429fb1541f80be3efe0ef62f..220e9c0b6ced01edce3a36a4297f2c76151a4092 100644 --- a/source/libs/executor/inc/dataSinkInt.h +++ b/source/libs/executor/inc/dataSinkInt.h @@ -20,16 +20,16 @@ extern "C" { #endif -#include "tcommon.h" #include "dataSinkMgt.h" #include "plannodes.h" +#include "tcommon.h" struct SDataSink; struct SDataSinkHandle; typedef struct SDataSinkManager { SDataSinkMgtCfg cfg; - TdThreadMutex mutex; + TdThreadMutex mutex; } SDataSinkManager; typedef int32_t (*FPutDataBlock)(struct SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue); @@ -40,17 +40,19 @@ typedef int32_t (*FDestroyDataSinker)(struct SDataSinkHandle* pHandle); typedef int32_t (*FGetCacheSize)(struct SDataSinkHandle* pHandle, uint64_t* size); typedef struct SDataSinkHandle { - FPutDataBlock fPut; - FEndPut fEndPut; - FGetDataLength fGetLen; - FGetDataBlock fGetData; + FPutDataBlock fPut; + FEndPut fEndPut; + FGetDataLength fGetLen; + FGetDataBlock fGetData; FDestroyDataSinker fDestroy; - FGetCacheSize fGetCacheSize; + FGetCacheSize fGetCacheSize; } SDataSinkHandle; int32_t createDataDispatcher(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle); -int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam); -int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam); +int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, + void* pParam); +int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, + void* pParam); #ifdef __cplusplus } diff --git a/source/libs/executor/inc/executorInt.h b/source/libs/executor/inc/executorInt.h index c8546a1afef5a12ca4bf83e4a174dfaa6cb49bd8..d22a7460bb17f53e77c56ec33c177ab466919b47 100644 --- a/source/libs/executor/inc/executorInt.h +++ b/source/libs/executor/inc/executorInt.h @@ -23,10 +23,10 @@ extern "C" { extern int32_t exchangeObjRefPool; typedef struct { - char* pData; - bool isNull; - int16_t type; - int32_t bytes; + char* pData; + bool isNull; + int16_t type; + int32_t bytes; } SGroupKeys, SStateKeys; uint64_t calcGroupId(char* pData, int32_t len); diff --git a/source/libs/executor/inc/tlinearhash.h b/source/libs/executor/inc/tlinearhash.h index a4190582166d565d42faf062c78b87c65ccdf644..5ec1ae54e0f211b8bdf15e1a83f61aa2268a6498 100644 --- a/source/libs/executor/inc/tlinearhash.h +++ b/source/libs/executor/inc/tlinearhash.h @@ -24,7 +24,7 @@ extern "C" { enum { LINEAR_HASH_STATIS = 0x1, - LINEAR_HASH_DATA = 0x2, + LINEAR_HASH_DATA = 0x2, }; typedef struct SLHashObj SLHashObj; @@ -32,11 +32,11 @@ typedef struct SLHashObj SLHashObj; SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_t numOfTuplePerPage); void* tHashCleanup(SLHashObj* pHashObj); -int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data, size_t size); -char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen); -int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen); +int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size); +char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen); +int32_t tHashRemove(SLHashObj* pHashObj, const void* key, size_t keyLen); -void tHashPrint(const SLHashObj* pHashObj, int32_t type); +void tHashPrint(const SLHashObj* pHashObj, int32_t type); #ifdef __cplusplus } diff --git a/source/libs/executor/inc/tsimplehash.h b/source/libs/executor/inc/tsimplehash.h index 27191e3b7e674df4dcec9dabc7b8cc6fbb35f9f2..7344c3426133758aac51d94e4678bc9367163580 100644 --- a/source/libs/executor/inc/tsimplehash.h +++ b/source/libs/executor/inc/tsimplehash.h @@ -112,7 +112,7 @@ void tSimpleHashCleanup(SSHashObj *pHashObj); size_t tSimpleHashGetMemSize(const SSHashObj *pHashObj); #pragma pack(push, 4) -typedef struct SHNode{ +typedef struct SHNode { struct SHNode *next; uint32_t keyLen : 20; uint32_t dataLen : 12; diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index 972f4469e47cef127a0137d3d360cf98f7657976..5591299d308acc0277a31f351e743d4dacf4e60f 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -20,8 +20,8 @@ extern "C" { #endif -#include "tcommon.h" #include "os.h" +#include "tcommon.h" enum { SORT_MULTISOURCE_MERGE = 0x1, @@ -31,29 +31,29 @@ enum { typedef struct SMultiMergeSource { int32_t type; int32_t rowIndex; - SSDataBlock *pBlock; + SSDataBlock* pBlock; } SMultiMergeSource; typedef struct SSortSource { SMultiMergeSource src; - union{ - struct{ - SArray* pageIdList; - int32_t pageIndex; + union { + struct { + SArray* pageIdList; + int32_t pageIndex; }; - void *param; + void* param; }; } SSortSource; typedef struct SMsortComparParam { - void **pSources; - int32_t numOfSources; - SArray *orderInfo; // SArray - bool cmpGroupId; + void** pSources; + int32_t numOfSources; + SArray* orderInfo; // SArray + bool cmpGroupId; } SMsortComparParam; -typedef struct SSortHandle SSortHandle; +typedef struct SSortHandle SSortHandle; typedef struct STupleHandle STupleHandle; typedef SSDataBlock* (*_sort_fetch_block_fn_t)(void* param); @@ -64,7 +64,8 @@ typedef int32_t (*_sort_merge_compar_fn_t)(const void* p1, const void* p2, void* * @param type * @return */ -SSortHandle* tsortCreateSortHandle(SArray* pOrderInfo, int32_t type, int32_t pageSize, int32_t numOfPages, SSDataBlock* pBlock, const char* idstr); +SSortHandle* tsortCreateSortHandle(SArray* pOrderInfo, int32_t type, int32_t pageSize, int32_t numOfPages, + SSDataBlock* pBlock, const char* idstr); /** * @@ -90,7 +91,8 @@ int32_t tsortClose(SSortHandle* pHandle); * * @return */ -int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetchFp, void (*fp)(SSDataBlock*, void*), void* param); +int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetchFp, void (*fp)(SSDataBlock*, void*), + void* param); /** * diff --git a/source/libs/executor/src/cachescanoperator.c b/source/libs/executor/src/cachescanoperator.c index 1b7448712ead67d8a7b7a14e3520c11150a6efb6..ebf23ba6bc61e99832125bf652c84713d5eed4ed 100644 --- a/source/libs/executor/src/cachescanoperator.c +++ b/source/libs/executor/src/cachescanoperator.c @@ -13,8 +13,8 @@ * along with this program. If not, see . */ -#include "os.h" #include "function.h" +#include "os.h" #include "tname.h" #include "tdatablock.h" @@ -26,8 +26,8 @@ #include "ttypes.h" static SSDataBlock* doScanCache(SOperatorInfo* pOperator); -static void destroyLastrowScanOperator(void* param); -static int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds); +static void destroyLastrowScanOperator(void* param); +static int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds); SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle, SExecTaskInfo* pTaskInfo) { @@ -40,11 +40,11 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe } pInfo->readHandle = *readHandle; - pInfo->pRes = createResDataBlock(pScanNode->scan.node.pOutputDataBlockDesc); + pInfo->pRes = createResDataBlock(pScanNode->scan.node.pOutputDataBlockDesc); int32_t numOfCols = 0; - pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pScanNode->scan.node.pOutputDataBlockDesc, &numOfCols, - COL_MATCH_FROM_COL_ID); + pInfo->pColMatchInfo = extractColMatchInfo(pScanNode->scan.pScanCols, pScanNode->scan.node.pOutputDataBlockDesc, + &numOfCols, COL_MATCH_FROM_COL_ID); code = extractTargetSlotId(pInfo->pColMatchInfo, pTaskInfo, &pInfo->pSlotIds); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -58,7 +58,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe // partition by tbname if (taosArrayGetSize(pTableList->pGroupList) == taosArrayGetSize(pTableList->pTableList)) { - pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL|CACHESCAN_RETRIEVE_LAST_ROW; + pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_ALL | CACHESCAN_RETRIEVE_LAST_ROW; code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pTableList->pTableList, taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); if (code != TSDB_CODE_SUCCESS) { @@ -67,23 +67,24 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe pInfo->pBufferredRes = createOneDataBlock(pInfo->pRes, false); blockDataEnsureCapacity(pInfo->pBufferredRes, pOperator->resultInfo.capacity); - } else { // by tags - pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_SINGLE|CACHESCAN_RETRIEVE_LAST_ROW; + } else { // by tags + pInfo->retrieveType = CACHESCAN_RETRIEVE_TYPE_SINGLE | CACHESCAN_RETRIEVE_LAST_ROW; } if (pScanNode->scan.pScanPseudoCols != NULL) { SExprSupp* pPseudoExpr = &pInfo->pseudoExprSup; pPseudoExpr->pExprInfo = createExprInfo(pScanNode->scan.pScanPseudoCols, NULL, &pPseudoExpr->numOfExprs); - pPseudoExpr->pCtx = createSqlFunctionCtx(pPseudoExpr->pExprInfo, pPseudoExpr->numOfExprs, &pPseudoExpr->rowEntryInfoOffset); + pPseudoExpr->pCtx = + createSqlFunctionCtx(pPseudoExpr->pExprInfo, pPseudoExpr->numOfExprs, &pPseudoExpr->rowEntryInfoOffset); } - pOperator->name = "LastrowScanOperator"; + pOperator->name = "LastrowScanOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN; - pOperator->blocking = false; - pOperator->status = OP_NOT_OPENED; - pOperator->info = pInfo; - pOperator->pTaskInfo = pTaskInfo; + pOperator->blocking = false; + pOperator->status = OP_NOT_OPENED; + pOperator->info = pInfo; + pOperator->pTaskInfo = pTaskInfo; pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock); pOperator->fpSet = @@ -92,7 +93,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe pOperator->cost.openCost = 0; return pOperator; - _error: +_error: pTaskInfo->code = code; destroyLastrowScanOperator(pInfo); taosMemoryFree(pOperator); @@ -121,7 +122,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { blockDataCleanup(pInfo->pBufferredRes); taosArrayClear(pInfo->pUidList); - int32_t code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pBufferredRes, pInfo->pSlotIds, pInfo->pUidList); + int32_t code = + tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pBufferredRes, pInfo->pSlotIds, pInfo->pUidList); if (code != TSDB_CODE_SUCCESS) { T_LONG_JMP(pTaskInfo->env, code); } @@ -133,15 +135,15 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { } if (pInfo->indexOfBufferedRes < pInfo->pBufferredRes->info.rows) { - for(int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { + for (int32_t i = 0; i < taosArrayGetSize(pInfo->pColMatchInfo); ++i) { SColMatchInfo* pMatchInfo = taosArrayGet(pInfo->pColMatchInfo, i); - int32_t slotId = pMatchInfo->targetSlotId; + int32_t slotId = pMatchInfo->targetSlotId; SColumnInfoData* pSrc = taosArrayGet(pInfo->pBufferredRes->pDataBlock, slotId); SColumnInfoData* pDst = taosArrayGet(pInfo->pRes->pDataBlock, slotId); char* p = colDataGetData(pSrc, pInfo->indexOfBufferedRes); - bool isNull = colDataIsNull_s(pSrc, pInfo->indexOfBufferedRes); + bool isNull = colDataIsNull_s(pSrc, pInfo->indexOfBufferedRes); colDataAppend(pDst, 0, p, isNull); } @@ -150,8 +152,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { if (pInfo->pseudoExprSup.numOfExprs > 0) { SExprSupp* pSup = &pInfo->pseudoExprSup; - int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes, - GET_TASKID(pTaskInfo)); + int32_t code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes, + GET_TASKID(pTaskInfo)); if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = code; return NULL; @@ -180,7 +182,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { SArray* pGroupTableList = taosArrayGetP(pTableList->pGroupList, pInfo->currentGroupIndex); tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pGroupTableList, - taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); + taosArrayGetSize(pInfo->pColMatchInfo), &pInfo->pLastrowReader); taosArrayClear(pInfo->pUidList); int32_t code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList); @@ -200,8 +202,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) { pInfo->pRes->info.groupId = pKeyInfo->groupId; code = addTagPseudoColumnData(&pInfo->readHandle, pSup->pExprInfo, pSup->numOfExprs, pInfo->pRes, - GET_TASKID(pTaskInfo)); - if (code != TSDB_CODE_SUCCESS) { + GET_TASKID(pTaskInfo)); + if (code != TSDB_CODE_SUCCESS) { pTaskInfo->code = code; return NULL; } @@ -233,10 +235,10 @@ void destroyLastrowScanOperator(void* param) { } int32_t extractTargetSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds) { - size_t numOfCols = taosArrayGetSize(pColMatchInfo); + size_t numOfCols = taosArrayGetSize(pColMatchInfo); *pSlotIds = taosMemoryMalloc(numOfCols * sizeof(int32_t)); - if (*pSlotIds == NULL) { + if (*pSlotIds == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index 1697ed63fb196aa2a571aa26f8ffe29ee1d6c5d5..8f8e486b3a57576015d8350231b4d52d27e70d1f 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -93,8 +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)); + ASSERT(pEntry->numOfRows == *(int32_t*)(pEntry->data + 8)); + ASSERT(pEntry->numOfCols == *(int32_t*)(pEntry->data + 8 + 4)); pBuf->useSize += pEntry->dataLen; @@ -103,14 +103,14 @@ static void toDataCacheEntry(SDataDispatchHandle* pHandle, const SInputData* pIn } static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput, SDataDispatchBuf* pBuf) { -/* - uint32_t capacity = pDispatcher->pManager->cfg.maxDataBlockNumPerQuery; - if (taosQueueItemSize(pDispatcher->pDataBlocks) > capacity) { - qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity, - taosQueueItemSize(pDispatcher->pDataBlocks)); - return false; - } -*/ + /* + uint32_t capacity = pDispatcher->pManager->cfg.maxDataBlockNumPerQuery; + if (taosQueueItemSize(pDispatcher->pDataBlocks) > capacity) { + qError("SinkNode queue is full, no capacity, max:%d, current:%d, no capacity", capacity, + taosQueueItemSize(pDispatcher->pDataBlocks)); + return false; + } + */ pBuf->allocSize = sizeof(SDataCacheEntry) + blockGetEncodeSize(pInput->pData); @@ -176,11 +176,12 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE 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)); + 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); + qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, + ((SDataCacheEntry*)(pDispatcher->nextOutput.pData))->numOfRows); } static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) { @@ -199,8 +200,8 @@ 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)); + 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/dataInserter.c b/source/libs/executor/src/dataInserter.c index 26e1f0a3ee81a71af81bba97dec97e1a5978b745..6a43ea40c69e491f93c3a83f4394768beb86e8a0 100644 --- a/source/libs/executor/src/dataInserter.c +++ b/source/libs/executor/src/dataInserter.c @@ -27,7 +27,7 @@ extern SDataSinkStat gDataSinkStat; typedef struct SSubmitRes { int64_t affectedRows; int32_t code; - SSubmitRsp *pRsp; + SSubmitRsp* pRsp; } SSubmitRes; typedef struct SDataInserterHandle { @@ -44,7 +44,7 @@ typedef struct SDataInserterHandle { uint64_t useconds; uint64_t cachedSize; TdThreadMutex mutex; - tsem_t ready; + tsem_t ready; } SDataInserterHandle; typedef struct SSubmitRspParam { @@ -52,14 +52,14 @@ typedef struct SSubmitRspParam { } SSubmitRspParam; int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { - SSubmitRspParam* pParam = (SSubmitRspParam*)param; + SSubmitRspParam* pParam = (SSubmitRspParam*)param; SDataInserterHandle* pInserter = pParam->pInserter; pInserter->submitRes.code = code; - + if (code == TSDB_CODE_SUCCESS) { pInserter->submitRes.pRsp = taosMemoryCalloc(1, sizeof(SSubmitRsp)); - SDecoder coder = {0}; + SDecoder coder = {0}; tDecoderInit(&coder, pMsg->pData, pMsg->len); code = tDecodeSSubmitRsp(&coder, pInserter->submitRes.pRsp); if (code) { @@ -67,10 +67,10 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { pInserter->submitRes.code = code; goto _return; } - + if (pInserter->submitRes.pRsp->nBlocks > 0) { for (int32_t i = 0; i < pInserter->submitRes.pRsp->nBlocks; ++i) { - SSubmitBlkRsp *blk = pInserter->submitRes.pRsp->pBlocks + i; + SSubmitBlkRsp* blk = pInserter->submitRes.pRsp->pBlocks + i; if (TSDB_CODE_SUCCESS != blk->code) { code = blk->code; tFreeSSubmitRsp(pInserter->submitRes.pRsp); @@ -79,9 +79,10 @@ int32_t inserterCallback(void* param, SDataBuf* pMsg, int32_t code) { } } } - + pInserter->submitRes.affectedRows += pInserter->submitRes.pRsp->affectedRows; - qDebug("submit rsp received, affectedRows:%d, total:%d", pInserter->submitRes.pRsp->affectedRows, pInserter->submitRes.affectedRows); + qDebug("submit rsp received, affectedRows:%d, total:%d", pInserter->submitRes.pRsp->affectedRows, + pInserter->submitRes.affectedRows); tFreeSSubmitRsp(pInserter->submitRes.pRsp); } @@ -91,11 +92,10 @@ _return: tsem_post(&pInserter->ready); taosMemoryFree(pMsg->pData); - + return TSDB_CODE_SUCCESS; } - static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMsg, void* pTransporter, SEpSet* pEpset) { // send the fetch remote task result reques SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo)); @@ -109,7 +109,7 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs pParam->pInserter = pInserter; pMsgSendInfo->param = pParam; - pMsgSendInfo->paramFreeFp = taosMemoryFree; + pMsgSendInfo->paramFreeFp = taosMemoryFree; pMsgSendInfo->msgInfo.pData = pMsg; pMsgSendInfo->msgInfo.len = ntohl(pMsg->length); pMsgSendInfo->msgType = TDMT_VND_SUBMIT; @@ -119,17 +119,16 @@ static int32_t sendSubmitRequest(SDataInserterHandle* pInserter, SSubmitReq* pMs return asyncSendMsgToServer(pTransporter, pEpset, &transporterId, pMsgSendInfo); } - int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { - const SArray* pBlocks = pInserter->pDataBlocks; - const STSchema* pTSchema = pInserter->pSchema; - int64_t uid = pInserter->pNode->tableId; - int64_t suid = pInserter->pNode->stableId; - int32_t vgId = pInserter->pNode->vgId; - bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols); + const SArray* pBlocks = pInserter->pDataBlocks; + const STSchema* pTSchema = pInserter->pSchema; + int64_t uid = pInserter->pNode->tableId; + int64_t suid = pInserter->pNode->stableId; + int32_t vgId = pInserter->pNode->vgId; + bool fullCol = (pInserter->pNode->pCols->length == pTSchema->numOfCols); SSubmitReq* ret = NULL; - int32_t sz = taosArrayGetSize(pBlocks); + int32_t sz = taosArrayGetSize(pBlocks); // cal size int32_t cap = sizeof(SSubmitReq); @@ -164,7 +163,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { int32_t rows = 0; int32_t dataLen = 0; STSRow* rowData = POINTER_SHIFT(blkHead, sizeof(SSubmitBlk)); - int64_t lastTs = TSKEY_MIN; + int64_t lastTs = TSKEY_MIN; bool ignoreRow = false; for (int32_t j = 0; j < pDataBlock->info.rows; j++) { SRowBuilder rb = {0}; @@ -176,13 +175,13 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { for (int32_t k = 0; k < pTSchema->numOfCols; k++) { const STColumn* pColumn = &pTSchema->columns[k]; SColumnInfoData* pColData = NULL; - int16_t colIdx = k; + int16_t colIdx = k; if (!fullCol) { - int16_t *slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId)); + int16_t* slotId = taosHashGet(pInserter->pCols, &pColumn->colId, sizeof(pColumn->colId)); if (NULL == slotId) { continue; } - + colIdx = *slotId; } @@ -192,13 +191,13 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { terrno = TSDB_CODE_APP_ERROR; return TSDB_CODE_APP_ERROR; } - + if (colDataIsNull_s(pColData, j)) { if (0 == k && TSDB_DATA_TYPE_TIMESTAMP == pColumn->type) { ignoreRow = true; break; } - + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NULL, NULL, false, pColumn->offset, k); } else { void* data = colDataGetData(pColData, j); @@ -213,7 +212,7 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); } } - if(!fullCol) { + if (!fullCol) { rb.hasNone = true; } tdSRowEnd(&rb); @@ -221,13 +220,13 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { if (ignoreRow) { continue; } - + rows++; int32_t rowLen = TD_ROW_LEN(rowData); rowData = POINTER_SHIFT(rowData, rowLen); dataLen += rowLen; } - + blkHead->dataLen = htonl(dataLen); blkHead->numOfRows = htonl(rows); @@ -242,12 +241,11 @@ int32_t dataBlockToSubmit(SDataInserterHandle* pInserter, SSubmitReq** pReq) { return TSDB_CODE_SUCCESS; } - static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, bool* pContinue) { SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; taosArrayPush(pInserter->pDataBlocks, &pInput->pData); SSubmitReq* pMsg = NULL; - int32_t code = dataBlockToSubmit(pInserter, &pMsg); + int32_t code = dataBlockToSubmit(pInserter, &pMsg); if (code) { return code; } @@ -264,7 +262,7 @@ static int32_t putDataBlock(SDataSinkHandle* pHandle, const SInputData* pInput, } *pContinue = true; - + return TSDB_CODE_SUCCESS; } @@ -279,10 +277,9 @@ static void endPut(struct SDataSinkHandle* pHandle, uint64_t useconds) { static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryEnd) { SDataInserterHandle* pDispatcher = (SDataInserterHandle*)pHandle; *pLen = pDispatcher->submitRes.affectedRows; - qDebug("got total affectedRows %" PRId64 , *pLen); + qDebug("got total affectedRows %" PRId64, *pLen); } - static int32_t destroyDataSinker(SDataSinkHandle* pHandle) { SDataInserterHandle* pInserter = (SDataInserterHandle*)pHandle; atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pInserter->cachedSize); @@ -301,14 +298,15 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) { return TSDB_CODE_SUCCESS; } -int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam) { +int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, + void* pParam) { SDataInserterHandle* inserter = taosMemoryCalloc(1, sizeof(SDataInserterHandle)); if (NULL == inserter) { terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return TSDB_CODE_QRY_OUT_OF_MEMORY; } - SQueryInserterNode* pInserterNode = (SQueryInserterNode *)pDataSink; + SQueryInserterNode* pInserterNode = (SQueryInserterNode*)pDataSink; inserter->sink.fPut = putDataBlock; inserter->sink.fEndPut = endPut; inserter->sink.fGetLen = getDataLength; @@ -322,7 +320,8 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat inserter->queryEnd = false; int64_t suid = 0; - int32_t code = tsdbGetTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid); + int32_t code = + tsdbGetTableSchema(inserter->pParam->readHandle->vnode, pInserterNode->tableId, &inserter->pSchema, &suid); if (code) { return code; } @@ -339,15 +338,16 @@ int32_t createDataInserter(SDataSinkManager* pManager, const SDataSinkNode* pDat return TSDB_CODE_QRY_OUT_OF_MEMORY; } - inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), false, HASH_NO_LOCK); + inserter->pCols = taosHashInit(pInserterNode->pCols->length, taosGetDefaultHashFunction(TSDB_DATA_TYPE_SMALLINT), + false, HASH_NO_LOCK); SNode* pNode = NULL; FOREACH(pNode, pInserterNode->pCols) { SColumnNode* pCol = (SColumnNode*)pNode; taosHashPut(inserter->pCols, &pCol->colId, sizeof(pCol->colId), &pCol->slotId, sizeof(pCol->slotId)); } - + tsem_init(&inserter->ready, 0, 0); - + *pHandle = inserter; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/dataSinkMgt.c b/source/libs/executor/src/dataSinkMgt.c index 0aa5e6266c06ff2c0fed2dfc1ee33fc75db801ea..206f3719fa0ad7a175d630c1caa346a8cd203c4c 100644 --- a/source/libs/executor/src/dataSinkMgt.c +++ b/source/libs/executor/src/dataSinkMgt.c @@ -13,28 +13,27 @@ * along with this program. If not, see . */ -#include "tarray.h" #include "dataSinkMgt.h" #include "dataSinkInt.h" #include "planner.h" +#include "tarray.h" static SDataSinkManager gDataSinkManager = {0}; -SDataSinkStat gDataSinkStat = {0}; +SDataSinkStat gDataSinkStat = {0}; -int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg) { +int32_t dsDataSinkMgtInit(SDataSinkMgtCfg* cfg) { gDataSinkManager.cfg = *cfg; taosThreadMutexInit(&gDataSinkManager.mutex, NULL); - return 0; // to avoid compiler eror + return 0; // to avoid compiler eror } -int32_t dsDataSinkGetCacheSize(SDataSinkStat *pStat) { +int32_t dsDataSinkGetCacheSize(SDataSinkStat* pStat) { pStat->cachedSize = atomic_load_64(&gDataSinkStat.cachedSize); return 0; } - -int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHandle, void* pParam) { +int32_t dsCreateDataSinker(const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void* pParam) { switch ((int)nodeType(pDataSink)) { case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: return createDataDispatcher(&gDataSinkManager, pDataSink, pHandle); @@ -66,12 +65,11 @@ int32_t dsGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) { return pHandleImpl->fGetData(pHandleImpl, pOutput); } -int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t *pSize) { +int32_t dsGetCacheSize(DataSinkHandle handle, uint64_t* pSize) { SDataSinkHandle* pHandleImpl = (SDataSinkHandle*)handle; return pHandleImpl->fGetCacheSize(pHandleImpl, pSize); } - void dsScheduleProcess(void* ahandle, void* pItem) { // todo } diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 95ee2e5f80de85a6a3043637fe41c0a5e28c2fa6..b11f1c32589a976ae000486119e8285ff4ffee5b 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -1240,6 +1240,17 @@ void createExprFromOneNode(SExprInfo* pExp, SNode* pNode, int16_t slotId) { pExp->base.resSchema = createResSchema(pType->type, pType->bytes, slotId, pType->scale, pType->precision, pOpNode->node.aliasName); pExp->pExpr->_optrRoot.pRootNode = pNode; + } else if (type == QUERY_NODE_CASE_WHEN) { + pExp->pExpr->nodeType = QUERY_NODE_OPERATOR; + SCaseWhenNode* pCaseNode = (SCaseWhenNode*)pNode; + + pExp->base.pParam = taosMemoryCalloc(1, sizeof(SFunctParam)); + pExp->base.numOfParams = 1; + + SDataType* pType = &pCaseNode->node.resType; + pExp->base.resSchema = createResSchema(pType->type, pType->bytes, slotId, pType->scale, + pType->precision, pCaseNode->node.aliasName); + pExp->pExpr->_optrRoot.pRootNode = pNode; } else { ASSERT(0); } diff --git a/source/libs/executor/src/joinoperator.c b/source/libs/executor/src/joinoperator.c index 1bc7d458e0ee16decabea988a16713996d2468ce..b4aa6de0a890c2c226eb0b6d74f3648b87dc7871 100644 --- a/source/libs/executor/src/joinoperator.c +++ b/source/libs/executor/src/joinoperator.c @@ -267,18 +267,19 @@ static int32_t mergeJoinJoinDownstreamTsRanges(SOperatorInfo* pOperator, int64_t size_t rightNumJoin = taosArrayGetSize(rightRowLocations); code = blockDataEnsureCapacity(pRes, *nRows + leftNumJoin * rightNumJoin); if (code != TSDB_CODE_SUCCESS) { - qError("%s can not ensure block capacity for join. left: %zu, right: %zu", GET_TASKID(pOperator->pTaskInfo), leftNumJoin, rightNumJoin); + qError("%s can not ensure block capacity for join. left: %zu, right: %zu", GET_TASKID(pOperator->pTaskInfo), + leftNumJoin, rightNumJoin); } if (code == TSDB_CODE_SUCCESS) { - for (int32_t i = 0; i < leftNumJoin; ++i) { - for (int32_t j = 0; j < rightNumJoin; ++j) { - SRowLocation *leftRow = taosArrayGet(leftRowLocations, i); - SRowLocation *rightRow = taosArrayGet(rightRowLocations, j); - mergeJoinJoinLeftRight(pOperator, pRes, *nRows, leftRow->pDataBlock, leftRow->pos, rightRow->pDataBlock, - rightRow->pos); - ++*nRows; - } + for (int32_t i = 0; i < leftNumJoin; ++i) { + for (int32_t j = 0; j < rightNumJoin; ++j) { + SRowLocation* leftRow = taosArrayGet(leftRowLocations, i); + SRowLocation* rightRow = taosArrayGet(rightRowLocations, j); + mergeJoinJoinLeftRight(pOperator, pRes, *nRows, leftRow->pDataBlock, leftRow->pos, rightRow->pDataBlock, + rightRow->pos); + ++*nRows; } + } } for (int i = 0; i < taosArrayGetSize(rightCreatedBlocks); ++i) { diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 85fd22ef9751960ab401dd640c803ea45cc9dde6..1a668ad6bf26e62ddd263405445a1481fc7c6824 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -429,6 +429,8 @@ int32_t addTagPseudoColumnData(SReadHandle* pHandle, SExprInfo* pPseudoExpr, int return terrno; } + metaReaderReleaseLock(&mr); + for (int32_t j = 0; j < numOfPseudoExpr; ++j) { SExprInfo* pExpr = &pPseudoExpr[j]; @@ -2548,7 +2550,7 @@ static SSDataBlock* sysTableScanUserTags(SOperatorInfo* pOperator) { return NULL; } SMetaReader smrSuperTable = {0}; - metaReaderInit(&smrSuperTable, pInfo->readHandle.meta, 0); + metaReaderInit(&smrSuperTable, pInfo->readHandle.meta, META_READER_NOLOCK); metaGetTableEntryByUid(&smrSuperTable, smrChildTable.me.ctbEntry.suid); sysTableUserTagsFillOneTableTags(pInfo, &smrSuperTable, &smrChildTable, dbname, tableName, &numOfRows, dataBlock); metaReaderClear(&smrSuperTable); diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index e2014ec97320c863a6857e94c538bd8d8319c2a1..ed3247e10ed773c9de2c996ac8eb366d0c9b36bf 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -658,7 +658,8 @@ SSDataBlock* getMultiwaySortedBlockData(SSortHandle* pHandle, SSDataBlock* pData blockDataDestroy(p); - qDebug("%s get sorted block, groupId:%0x"PRIx64" rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.groupId, pDataBlock->info.rows); + qDebug("%s get sorted block, groupId:%0x" PRIx64 " rows:%d", GET_TASKID(pTaskInfo), pDataBlock->info.groupId, + pDataBlock->info.rows); return (pDataBlock->info.rows > 0) ? pDataBlock : NULL; } diff --git a/source/libs/executor/src/tfill.c b/source/libs/executor/src/tfill.c index 85c1d638684b718b280d6d341d73d7909e4b3d62..5be991818529dc8158881ee82084fdb7c9565954 100644 --- a/source/libs/executor/src/tfill.c +++ b/source/libs/executor/src/tfill.c @@ -561,7 +561,7 @@ int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, TSKEY ekey, int32_t ma int32_t numOfRows = taosNumOfRemainRows(pFillInfo); TSKEY ekey1 = ekey; - + int64_t numOfRes = -1; if (numOfRows > 0) { // still fill gap within current data block, not generating data after the result set. TSKEY lastKey = tsList[pFillInfo->numOfRows - 1]; diff --git a/source/libs/executor/src/timewindowoperator.c b/source/libs/executor/src/timewindowoperator.c index 560a1d319a8797e9c63049a3de9d1ceab8b5232e..df16914cb87c0bbd7d25f6e01985160be25bd74d 100644 --- a/source/libs/executor/src/timewindowoperator.c +++ b/source/libs/executor/src/timewindowoperator.c @@ -1218,7 +1218,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI pBlock->info.rows, numOfOutput); } -static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { +static int32_t openStateWindowAggOptr(SOperatorInfo* pOperator) { if (OPTR_IS_OPENED(pOperator)) { return TSDB_CODE_SUCCESS; } @@ -2757,7 +2757,7 @@ SOperatorInfo* createStatewindowOperatorInfo(SOperatorInfo* downstream, SStateWi if (pStateNode->window.pExprs != NULL) { int32_t numOfScalarExpr = 0; SExprInfo* pScalarExprInfo = createExprInfo(pStateNode->window.pExprs, NULL, &numOfScalarExpr); - int32_t code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr); + int32_t code = initExprSupp(&pInfo->scalarSup, pScalarExprInfo, numOfScalarExpr); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index cffabcb6aca1f1f5ba457fb765828889bc3c03e6..824e988c2f8ac388ff59576eb424697a57eed3b8 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -14,27 +14,27 @@ */ #include "tlinearhash.h" -#include "tdef.h" #include "taoserror.h" +#include "tdef.h" #include "tpagedbuf.h" #define LHASH_CAP_RATIO 0.85 // Always located in memory typedef struct SLHashBucket { - SArray *pPageIdList; - int32_t size; // the number of element in this entry + SArray* pPageIdList; + int32_t size; // the number of element in this entry } SLHashBucket; struct SLHashObj { - SDiskbasedBuf *pBuf; + SDiskbasedBuf* pBuf; _hash_fn_t hashFn; - SLHashBucket **pBucket; // entry list + SLHashBucket** pBucket; // entry list int32_t tuplesPerPage; - int32_t numOfAlloc; // number of allocated bucket ptr slot - int32_t bits; // the number of bits used in hash - int32_t numOfBuckets; // the number of buckets - int64_t size; // the number of total items + int32_t numOfAlloc; // number of allocated bucket ptr slot + int32_t bits; // the number of bits used in hash + int32_t numOfBuckets; // the number of buckets + int64_t size; // the number of total items }; /** @@ -44,19 +44,17 @@ struct SLHashObj { * +-----------+-------+--------+ */ typedef struct SLHashNode { - uint16_t keyLen; - uint16_t dataLen; + uint16_t keyLen; + uint16_t dataLen; } SLHashNode; -#define GET_LHASH_NODE_KEY(_n) (((char*)(_n)) + sizeof(SLHashNode)) -#define GET_LHASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SLHashNode) + ((SLHashNode*)(_n))->keyLen) -#define GET_LHASH_NODE_LEN(_n) (sizeof(SLHashNode) + ((SLHashNode*)(_n))->keyLen + ((SLHashNode*)(_n))->dataLen) +#define GET_LHASH_NODE_KEY(_n) (((char*)(_n)) + sizeof(SLHashNode)) +#define GET_LHASH_NODE_DATA(_n) ((char*)(_n) + sizeof(SLHashNode) + ((SLHashNode*)(_n))->keyLen) +#define GET_LHASH_NODE_LEN(_n) (sizeof(SLHashNode) + ((SLHashNode*)(_n))->keyLen + ((SLHashNode*)(_n))->dataLen) static int32_t doAddNewBucket(SLHashObj* pHashObj); -static int32_t doGetBucketIdFromHashVal(int32_t hashv, int32_t bits) { - return hashv & ((1ul << (bits)) - 1); -} +static int32_t doGetBucketIdFromHashVal(int32_t hashv, int32_t bits) { return hashv & ((1ul << (bits)) - 1); } static int32_t doGetAlternativeBucketId(int32_t bucketId, int32_t bits, int32_t numOfBuckets) { int32_t v = bucketId - (1ul << (bits - 1)); @@ -70,9 +68,9 @@ static int32_t doGetRelatedSplitBucketId(int32_t bucketId, int32_t bits) { } static void doCopyObject(char* p, const void* key, int32_t keyLen, const void* data, int32_t size) { - *(uint16_t*) p = keyLen; + *(uint16_t*)p = keyLen; p += sizeof(uint16_t); - *(uint16_t*) p = size; + *(uint16_t*)p = size; p += sizeof(uint16_t); memcpy(p, key, keyLen); @@ -86,7 +84,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t int32_t pageId = *(int32_t*)taosArrayGetLast(pBucket->pPageIdList); SFilePage* pPage = getBufPage(pHashObj->pBuf, pageId); - ASSERT (pPage != NULL); + ASSERT(pPage != NULL); // put to current buf page size_t nodeSize = sizeof(SLHashNode) + keyLen + size; @@ -96,7 +94,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t releaseBufPage(pHashObj->pBuf, pPage); // allocate the overflow buffer page to hold this k/v. - int32_t newPageId = -1; + int32_t newPageId = -1; SFilePage* pNewPage = getNewBufPage(pHashObj->pBuf, &newPageId); if (pNewPage == NULL) { return terrno; @@ -110,7 +108,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t setBufPageDirty(pNewPage, true); releaseBufPage(pHashObj->pBuf, pNewPage); } else { - char* p = (char*) pPage + pPage->num; + char* p = (char*)pPage + pPage->num; doCopyObject(p, key, keyLen, data, size); pPage->num += nodeSize; setBufPageDirty(pPage, true); @@ -118,7 +116,7 @@ static int32_t doAddToBucket(SLHashObj* pHashObj, SLHashBucket* pBucket, int32_t } pBucket->size += 1; -// printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key); + // printf("===> add to bucket:0x%x, num:%d, key:%d\n", index, pBucket->size, *(int*) key); return TSDB_CODE_SUCCESS; } @@ -127,7 +125,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket ASSERT(pPage != NULL && pNode != NULL && pBucket->size >= 1); int32_t len = GET_LHASH_NODE_LEN(pNode); - char* p = (char*) pNode + len; + char* p = (char*)pNode + len; char* pEnd = (char*)pPage + pPage->num; memmove(pNode, p, (pEnd - p)); @@ -141,7 +139,7 @@ static void doRemoveFromBucket(SFilePage* pPage, SLHashNode* pNode, SLHashBucket pBucket->size -= 1; } -static void doTrimBucketPages(SLHashObj *pHashObj, SLHashBucket* pBucket) { +static void doTrimBucketPages(SLHashObj* pHashObj, SLHashBucket* pBucket) { size_t numOfPages = taosArrayGetSize(pBucket->pPageIdList); if (numOfPages <= 1) { return; @@ -188,7 +186,7 @@ static void doTrimBucketPages(SLHashObj *pHashObj, SLHashBucket* pBucket) { } nodeSize = GET_LHASH_NODE_LEN(pStart); - } else { // move to the front of pLast page + } else { // move to the front of pLast page if (pStart != pLast->data) { memmove(pLast->data, pStart, (((char*)pLast) + pLast->num - pStart)); setBufPageDirty(pLast, true); @@ -214,7 +212,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) { } memset(p + POINTER_BYTES * pHashObj->numOfBuckets, 0, newLen - pHashObj->numOfBuckets); - pHashObj->pBucket = (SLHashBucket**) p; + pHashObj->pBucket = (SLHashBucket**)p; pHashObj->numOfAlloc = newLen; } @@ -226,7 +224,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) { return TSDB_CODE_OUT_OF_MEMORY; } - int32_t pageId = -1; + int32_t pageId = -1; SFilePage* p = getNewBufPage(pHashObj->pBuf, &pageId); if (p == NULL) { return terrno; @@ -239,7 +237,7 @@ static int32_t doAddNewBucket(SLHashObj* pHashObj) { taosArrayPush(pBucket->pPageIdList, &pageId); pHashObj->numOfBuckets += 1; -// printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets); + // printf("---------------add new bucket, id:0x%x, total:%d\n", pHashObj->numOfBuckets - 1, pHashObj->numOfBuckets); return TSDB_CODE_SUCCESS; } @@ -266,14 +264,14 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_ setBufPageCompressOnDisk(pHashObj->pBuf, false); /** - * The number of bits in the hash value, which is used to decide the exact bucket where the object should be located in. - * The initial value is 0. + * The number of bits in the hash value, which is used to decide the exact bucket where the object should be located + * in. The initial value is 0. */ - pHashObj->bits = 0; + pHashObj->bits = 0; pHashObj->hashFn = fn; pHashObj->tuplesPerPage = numOfTuplePerPage; - pHashObj->numOfAlloc = 4; // initial allocated array list + pHashObj->numOfAlloc = 4; // initial allocated array list pHashObj->pBucket = taosMemoryCalloc(pHashObj->numOfAlloc, POINTER_BYTES); code = doAddNewBucket(pHashObj); @@ -289,7 +287,7 @@ SLHashObj* tHashInit(int32_t inMemPages, int32_t pageSize, _hash_fn_t fn, int32_ void* tHashCleanup(SLHashObj* pHashObj) { destroyDiskbasedBuf(pHashObj->pBuf); - for(int32_t i = 0; i < pHashObj->numOfBuckets; ++i) { + for (int32_t i = 0; i < pHashObj->numOfBuckets; ++i) { taosArrayDestroy(pHashObj->pBucket[i]->pPageIdList); taosMemoryFreeClear(pHashObj->pBucket[i]); } @@ -299,7 +297,7 @@ void* tHashCleanup(SLHashObj* pHashObj) { return NULL; } -int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data, size_t size) { +int32_t tHashPut(SLHashObj* pHashObj, const void* key, size_t keyLen, void* data, size_t size) { ASSERT(pHashObj != NULL && key != NULL); if (pHashObj->bits == 0) { @@ -311,12 +309,12 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data if (v >= pHashObj->numOfBuckets) { int32_t newBucketId = doGetAlternativeBucketId(v, pHashObj->bits, pHashObj->numOfBuckets); -// printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId); + // printf("bucketId: 0x%x not exists, put it into 0x%x instead\n", v, newBucketId); v = newBucketId; } SLHashBucket* pBucket = pHashObj->pBucket[v]; - int32_t code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size); + int32_t code = doAddToBucket(pHashObj, pBucket, v, key, keyLen, data, size); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -335,7 +333,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data int32_t numOfBits = ceil(log(pHashObj->numOfBuckets) / log(2)); if (numOfBits > pHashObj->bits) { -// printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId); + // printf("extend the bits from %d to %d, new bucket:%d\n", pHashObj->bits, numOfBits, newBucketId); ASSERT(numOfBits == pHashObj->bits + 1); pHashObj->bits = numOfBits; } @@ -344,31 +342,31 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data // load all data in this bucket and check if the data needs to relocated into the new bucket SLHashBucket* pBucket = pHashObj->pBucket[splitBucketId]; -// printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId); + // printf("split %d items' bucket:0x%x to new bucket:0x%x\n", pBucket->size, splitBucketId, newBucketId); for (int32_t i = 0; i < taosArrayGetSize(pBucket->pPageIdList); ++i) { int32_t pageId = *(int32_t*)taosArrayGet(pBucket->pPageIdList, i); SFilePage* p = getBufPage(pHashObj->pBuf, pageId); char* pStart = p->data; - while (pStart - ((char*) p) < p->num) { + while (pStart - ((char*)p) < p->num) { SLHashNode* pNode = (SLHashNode*)pStart; ASSERT(pNode->keyLen > 0 && pNode->dataLen >= 0); - char* k = GET_LHASH_NODE_KEY(pNode); + char* k = GET_LHASH_NODE_KEY(pNode); int32_t hashv = pHashObj->hashFn(k, pNode->keyLen); int32_t v1 = doGetBucketIdFromHashVal(hashv, pHashObj->bits); if (v1 != splitBucketId) { // place it into the new bucket ASSERT(v1 == newBucketId); -// printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1); + // printf("move key:%d to 0x%x bucket, remain items:%d\n", *(int32_t*)k, v1, pBucket->size - 1); SLHashBucket* pNewBucket = pHashObj->pBucket[newBucketId]; doAddToBucket(pHashObj, pNewBucket, newBucketId, (void*)GET_LHASH_NODE_KEY(pNode), pNode->keyLen, GET_LHASH_NODE_KEY(pNode), pNode->dataLen); doRemoveFromBucket(p, pNode, pBucket); } else { -// printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1); + // printf("check key:%d, located into: %d, skip it\n", *(int*) k, v1); int32_t nodeSize = GET_LHASH_NODE_LEN(pStart); pStart += nodeSize; @@ -383,7 +381,7 @@ int32_t tHashPut(SLHashObj* pHashObj, const void *key, size_t keyLen, void *data return TSDB_CODE_SUCCESS; } -char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) { +char* tHashGet(SLHashObj* pHashObj, const void* key, size_t keyLen) { ASSERT(pHashObj != NULL && key != NULL && keyLen > 0); int32_t hashv = pHashObj->hashFn(key, keyLen); @@ -393,7 +391,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) { } SLHashBucket* pBucket = pHashObj->pBucket[bucketId]; - int32_t num = taosArrayGetSize(pBucket->pPageIdList); + int32_t num = taosArrayGetSize(pBucket->pPageIdList); for (int32_t i = 0; i < num; ++i) { int32_t pageId = *(int32_t*)taosArrayGet(pBucket->pPageIdList, i); @@ -418,7 +416,7 @@ char* tHashGet(SLHashObj* pHashObj, const void *key, size_t keyLen) { return NULL; } -int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen) { +int32_t tHashRemove(SLHashObj* pHashObj, const void* key, size_t keyLen) { // todo return TSDB_CODE_SUCCESS; } @@ -431,8 +429,8 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) { if (type == LINEAR_HASH_DATA) { for (int32_t i = 0; i < pHashObj->numOfBuckets; ++i) { -// printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size, -// (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList)); + // printf("bucket: 0x%x, obj:%d, page:%d\n", i, pHashObj->pBucket[i]->size, + // (int)taosArrayGetSize(pHashObj->pBucket[i]->pPageIdList)); } } else { dBufPrintStatis(pHashObj->pBuf); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 63fc9d9e1c553bc210c7f525b014cd3d0b4f852b..74da5c45ee1f56b552c3f95f8bfbffd95994606a 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -13,16 +13,16 @@ * along with this program. If not, see . */ -#include "tcommon.h" #include "query.h" +#include "tcommon.h" +#include "tcompare.h" #include "tdatablock.h" #include "tdef.h" #include "tlosertree.h" #include "tpagedbuf.h" #include "tsort.h" #include "tutil.h" -#include "tcompare.h" struct STupleHandle { SSDataBlock* pBlock; @@ -30,37 +30,37 @@ struct STupleHandle { }; struct SSortHandle { - int32_t type; - int32_t pageSize; - int32_t numOfPages; - SDiskbasedBuf *pBuf; + int32_t type; + int32_t pageSize; + int32_t numOfPages; + SDiskbasedBuf* pBuf; - SArray *pSortInfo; - SArray *pOrderedSource; + SArray* pSortInfo; + SArray* pOrderedSource; - int32_t loops; - uint64_t sortElapsed; - int64_t startTs; - uint64_t totalElapsed; + int32_t loops; + uint64_t sortElapsed; + int64_t startTs; + uint64_t totalElapsed; int32_t sourceId; - SSDataBlock *pDataBlock; + SSDataBlock* pDataBlock; SMsortComparParam cmpParam; int32_t numOfCompletedSources; bool opened; - const char *idStr; + const char* idStr; bool inMemSort; bool needAdjust; STupleHandle tupleHandle; - void *param; + void* param; void (*beforeFp)(SSDataBlock* pBlock, void* param); _sort_fetch_block_fn_t fetchfp; _sort_merge_compar_fn_t comparFn; - SMultiwayMergeTreeInfo *pMergeTree; + SMultiwayMergeTreeInfo* pMergeTree; }; -static int32_t msortComparFn(const void *pLeft, const void *pRight, void *param); +static int32_t msortComparFn(const void* pLeft, const void* pRight, void* param); SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) { return createOneDataBlock(pSortHandle->pDataBlock, false); @@ -71,20 +71,21 @@ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle) { * @param type * @return */ -SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize, int32_t numOfPages, SSDataBlock* pBlock, const char* idstr) { +SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t pageSize, int32_t numOfPages, + SSDataBlock* pBlock, const char* idstr) { SSortHandle* pSortHandle = taosMemoryCalloc(1, sizeof(SSortHandle)); - pSortHandle->type = type; - pSortHandle->pageSize = pageSize; + pSortHandle->type = type; + pSortHandle->pageSize = pageSize; pSortHandle->numOfPages = numOfPages; - pSortHandle->pSortInfo = pSortInfo; - pSortHandle->loops = 0; + pSortHandle->pSortInfo = pSortInfo; + pSortHandle->loops = 0; if (pBlock != NULL) { pSortHandle->pDataBlock = createOneDataBlock(pBlock, false); } - pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES); + pSortHandle->pOrderedSource = taosArrayInit(4, POINTER_BYTES); pSortHandle->cmpParam.orderInfo = pSortInfo; pSortHandle->cmpParam.cmpGroupId = false; @@ -98,8 +99,9 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, int32_t type, int32_t page } static int32_t sortComparCleanup(SMsortComparParam* cmpParam) { - for(int32_t i = 0; i < cmpParam->numOfSources; ++i) { - SSortSource* pSource = cmpParam->pSources[i]; // NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE + for (int32_t i = 0; i < cmpParam->numOfSources; ++i) { + SSortSource* pSource = + cmpParam->pSources[i]; // NOTICE: pSource may be SGenericSource *, if it is SORT_MULTISOURCE_MERGE blockDataDestroy(pSource->src.pBlock); taosMemoryFreeClear(pSource); } @@ -121,7 +123,7 @@ void tsortDestroySortHandle(SSortHandle* pSortHandle) { destroyDiskbasedBuf(pSortHandle->pBuf); taosMemoryFreeClear(pSortHandle->idStr); blockDataDestroy(pSortHandle->pDataBlock); - for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++){ + for (size_t i = 0; i < taosArrayGetSize(pSortHandle->pOrderedSource); i++) { SSortSource** pSource = taosArrayGet(pSortHandle->pOrderedSource, i); taosMemoryFreeClear(*pSource); } @@ -134,7 +136,8 @@ int32_t tsortAddSource(SSortHandle* pSortHandle, void* pSource) { return TSDB_CODE_SUCCESS; } -static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSources, SSDataBlock* pBlock, int32_t* sourceId, SArray* pPageIdList) { +static int32_t doAddNewExternalMemSource(SDiskbasedBuf* pBuf, SArray* pAllSources, SSDataBlock* pBlock, + int32_t* sourceId, SArray* pPageIdList) { SSortSource* pSource = taosMemoryCalloc(1, sizeof(SSortSource)); if (pSource == NULL) { return TSDB_CODE_QRY_OUT_OF_MEMORY; @@ -149,7 +152,8 @@ static int32_t doAddNewExternalMemSource(SDiskbasedBuf *pBuf, SArray* pAllSource int32_t rowSize = blockDataGetSerialRowSize(pSource->src.pBlock); // The value of numOfRows must be greater than 0, which is guaranteed by the previous memory allocation - int32_t numOfRows = (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(taosArrayGetSize(pBlock->pDataBlock)))/rowSize; + int32_t numOfRows = + (getBufPageSize(pBuf) - blockDataGetSerialMetaSize(taosArrayGetSize(pBlock->pDataBlock))) / rowSize; ASSERT(numOfRows > 0); return blockDataEnsureCapacity(pSource->src.pBlock, numOfRows); } @@ -163,7 +167,8 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { qError("Add to buf failed since %s", terrstr(terrno)); return terrno; } - int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "doAddToBuf", tsTempDir); + int32_t code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, + "doAddToBuf", tsTempDir); dBufSetPrintInfo(pHandle->pBuf); if (code != TSDB_CODE_SUCCESS) { return code; @@ -171,7 +176,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { } SArray* pPageIdList = taosArrayInit(4, sizeof(int32_t)); - while(start < pDataBlock->info.rows) { + while (start < pDataBlock->info.rows) { int32_t stop = 0; blockDataSplitRows(pDataBlock, pDataBlock->info.hasVarCol, start, &stop, pHandle->pageSize); SSDataBlock* p = blockDataExtractBlock(pDataBlock, start, stop - start + 1); @@ -180,7 +185,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { } int32_t pageId = -1; - void* pPage = getNewBufPage(pHandle->pBuf, &pageId); + void* pPage = getNewBufPage(pHandle->pBuf, &pageId); if (pPage == NULL) { blockDataDestroy(p); return terrno; @@ -188,7 +193,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { taosArrayPush(pPageIdList, &pageId); - int32_t size = blockDataGetSize(p) + sizeof(int32_t) + taosArrayGetSize(p->pDataBlock) * sizeof(int32_t); + int32_t size = blockDataGetSize(p) + sizeof(int32_t) + taosArrayGetSize(p->pDataBlock) * sizeof(int32_t); assert(size <= getBufPageSize(pHandle->pBuf)); blockDataToBuf(pPage, p); @@ -211,8 +216,9 @@ static void setCurrentSourceIsDone(SSortSource* pSource, SSortHandle* pHandle) { ++pHandle->numOfCompletedSources; } -static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int32_t startIndex, int32_t endIndex, SSortHandle* pHandle) { - cmpParam->pSources = taosArrayGet(pSources, startIndex); +static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int32_t startIndex, int32_t endIndex, + SSortHandle* pHandle) { + cmpParam->pSources = taosArrayGet(pSources, startIndex); cmpParam->numOfSources = (endIndex - startIndex + 1); int32_t code = 0; @@ -246,7 +252,8 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int qError("Sort compare init failed since %s", terrstr(terrno)); return code; } - code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, "sortComparInit", tsTempDir); + code = createDiskbasedBuf(&pHandle->pBuf, pHandle->pageSize, pHandle->numOfPages * pHandle->pageSize, + "sortComparInit", tsTempDir); dBufSetPrintInfo(pHandle->pBuf); if (code != TSDB_CODE_SUCCESS) { return code; @@ -267,12 +274,12 @@ static int32_t sortComparInit(SMsortComparParam* cmpParam, SArray* pSources, int return code; } -static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSource, int32_t* rowIndex) { +static void appendOneRowToDataBlock(SSDataBlock* pBlock, const SSDataBlock* pSource, int32_t* rowIndex) { for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) { SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, i); SColumnInfoData* pSrcColInfo = taosArrayGet(pSource->pDataBlock, i); - bool isNull = colDataIsNull(pSrcColInfo, pSource->info.rows, *rowIndex, NULL); + bool isNull = colDataIsNull(pSrcColInfo, pSource->info.rows, *rowIndex, NULL); if (isNull) { colDataAppend(pColInfo, pBlock->info.rows, NULL, true); @@ -286,7 +293,8 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, const SSDataBlock* pSou *rowIndex += 1; } -static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeTreeInfo *pTree, SSortHandle *pHandle, int32_t* numOfCompleted) { +static int32_t adjustMergeTreeForNextTuple(SSortSource* pSource, SMultiwayMergeTreeInfo* pTree, SSortHandle* pHandle, + int32_t* numOfCompleted) { /* * load a new SDataBlock into memory of a given intermediate data-set source, * since it's last record in buffer has been chosen to be processed, as the winner of loser-tree @@ -295,7 +303,7 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT pSource->src.rowIndex = 0; if (pHandle->type == SORT_SINGLESOURCE_SORT) { - pSource->pageIndex ++; + pSource->pageIndex++; if (pSource->pageIndex >= taosArrayGetSize(pSource->pageIdList)) { (*numOfCompleted) += 1; pSource->src.rowIndex = -1; @@ -304,8 +312,8 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT } else { int32_t* pPgId = taosArrayGet(pSource->pageIdList, pSource->pageIndex); - void* pPage = getBufPage(pHandle->pBuf, *pPgId); - int32_t code = blockDataFromBuf(pSource->src.pBlock, pPage); + void* pPage = getBufPage(pHandle->pBuf, *pPgId); + int32_t code = blockDataFromBuf(pSource->src.pBlock, pPage); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -344,14 +352,14 @@ static int32_t adjustMergeTreeForNextTuple(SSortSource *pSource, SMultiwayMergeT static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparParam* cmpParam, int32_t capacity) { blockDataCleanup(pHandle->pDataBlock); - while(1) { + while (1) { if (cmpParam->numOfSources == pHandle->numOfCompletedSources) { break; } int32_t index = tMergeTreeGetChosenIndex(pHandle->pMergeTree); - SSortSource *pSource = (*cmpParam).pSources[index]; + SSortSource* pSource = (*cmpParam).pSources[index]; appendOneRowToDataBlock(pHandle->pDataBlock, pSource->src.pBlock, &pSource->src.rowIndex); int32_t code = adjustMergeTreeForNextTuple(pSource, pHandle->pMergeTree, pHandle, &pHandle->numOfCompletedSources); @@ -365,18 +373,18 @@ static SSDataBlock* getSortedBlockDataInner(SSortHandle* pHandle, SMsortComparPa } } - return (pHandle->pDataBlock->info.rows > 0)? pHandle->pDataBlock:NULL; + return (pHandle->pDataBlock->info.rows > 0) ? pHandle->pDataBlock : NULL; } -int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) { - int32_t pLeftIdx = *(int32_t *)pLeft; - int32_t pRightIdx = *(int32_t *)pRight; +int32_t msortComparFn(const void* pLeft, const void* pRight, void* param) { + int32_t pLeftIdx = *(int32_t*)pLeft; + int32_t pRightIdx = *(int32_t*)pRight; - SMsortComparParam *pParam = (SMsortComparParam *)param; + SMsortComparParam* pParam = (SMsortComparParam*)param; - SArray *pInfo = pParam->orderInfo; + SArray* pInfo = pParam->orderInfo; - SSortSource* pLeftSource = pParam->pSources[pLeftIdx]; + SSortSource* pLeftSource = pParam->pSources[pLeftIdx]; SSortSource* pRightSource = pParam->pSources[pRightIdx]; // this input is exhausted, set the special value to denote this @@ -397,42 +405,44 @@ int32_t msortComparFn(const void *pLeft, const void *pRight, void *param) { } } - for(int32_t i = 0; i < pInfo->size; ++i) { + for (int32_t i = 0; i < pInfo->size; ++i) { SBlockOrderInfo* pOrder = TARRAY_GET_ELEM(pInfo, i); SColumnInfoData* pLeftColInfoData = TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId); - bool leftNull = false; + bool leftNull = false; if (pLeftColInfoData->hasNull) { if (pLeftBlock->pBlockAgg == NULL) { leftNull = colDataIsNull_s(pLeftColInfoData, pLeftSource->src.rowIndex); } else { - leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, pLeftBlock->pBlockAgg[i]); + leftNull = + colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, pLeftBlock->pBlockAgg[i]); } } SColumnInfoData* pRightColInfoData = TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId); - bool rightNull = false; + bool rightNull = false; if (pRightColInfoData->hasNull) { if (pLeftBlock->pBlockAgg == NULL) { rightNull = colDataIsNull_s(pRightColInfoData, pRightSource->src.rowIndex); } else { - rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, pRightBlock->pBlockAgg[i]); + rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, + pRightBlock->pBlockAgg[i]); } } if (leftNull && rightNull) { - continue; // continue to next slot + continue; // continue to next slot } if (rightNull) { - return pOrder->nullFirst? 1:-1; + return pOrder->nullFirst ? 1 : -1; } if (leftNull) { - return pOrder->nullFirst? -1:1; + return pOrder->nullFirst ? -1 : 1; } - void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); + void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); void* right1 = colDataGetData(pRightColInfoData, pRightSource->src.rowIndex); __compar_fn_t fn = getKeyComparFunc(pLeftColInfoData->info.type, pOrder->order); @@ -464,8 +474,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { ", sort elapsed:%" PRId64 ", total elapsed:%" PRId64, pHandle->idStr, (int32_t)(sortPass + 1), s, pHandle->sortElapsed, pHandle->totalElapsed); } else { - qDebug("%s ordered source:%"PRIzu", available buf:%d, no need internal sort", pHandle->idStr, numOfSources, - pHandle->numOfPages); + qDebug("%s ordered source:%" PRIzu ", available buf:%d, no need internal sort", pHandle->idStr, numOfSources, + pHandle->numOfPages); } int32_t numOfRows = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize); @@ -475,7 +485,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { pHandle->loops = sortPass + 2; size_t numOfSorted = taosArrayGetSize(pHandle->pOrderedSource); - for(int32_t t = 0; t < sortPass; ++t) { + for (int32_t t = 0; t < sortPass; ++t) { int64_t st = taosGetTimestampUs(); SArray* pResList = taosArrayInit(4, POINTER_BYTES); @@ -484,7 +494,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { int32_t sortGroup = (numOfSorted + numOfInputSources - 1) / numOfInputSources; // Only *numOfInputSources* can be loaded into buffer to perform the external sort. - for(int32_t i = 0; i < sortGroup; ++i) { + for (int32_t i = 0; i < sortGroup; ++i) { pHandle->sourceId += 1; int32_t end = (i + 1) * numOfInputSources - 1; @@ -499,7 +509,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { return code; } - code = tMergeTreeCreate(&pHandle->pMergeTree, pHandle->cmpParam.numOfSources, &pHandle->cmpParam, pHandle->comparFn); + code = + tMergeTreeCreate(&pHandle->pMergeTree, pHandle->cmpParam.numOfSources, &pHandle->cmpParam, pHandle->comparFn); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -512,14 +523,15 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { } int32_t pageId = -1; - void* pPage = getNewBufPage(pHandle->pBuf, &pageId); + void* pPage = getNewBufPage(pHandle->pBuf, &pageId); if (pPage == NULL) { return terrno; } taosArrayPush(pPageIdList, &pageId); - int32_t size = blockDataGetSize(pDataBlock) + sizeof(int32_t) + taosArrayGetSize(pDataBlock->pDataBlock) * sizeof(int32_t); + int32_t size = + blockDataGetSize(pDataBlock) + sizeof(int32_t) + taosArrayGetSize(pDataBlock->pDataBlock) * sizeof(int32_t); assert(size <= getBufPageSize(pHandle->pBuf)); blockDataToBuf(pPage, pDataBlock); @@ -551,8 +563,8 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { pHandle->totalElapsed += el; SDiskbasedBufStatis statis = getDBufStatis(pHandle->pBuf); - qDebug("%s %d round mergesort, elapsed:%"PRId64" readDisk:%.2f Kb, flushDisk:%.2f Kb", pHandle->idStr, t + 1, el, statis.loadBytes/1024.0, - statis.flushBytes/1024.0); + qDebug("%s %d round mergesort, elapsed:%" PRId64 " readDisk:%.2f Kb, flushDisk:%.2f Kb", pHandle->idStr, t + 1, el, + statis.loadBytes / 1024.0, statis.flushBytes / 1024.0); if (pHandle->type == SORT_MULTISOURCE_MERGE) { pHandle->type = SORT_SINGLESOURCE_SORT; @@ -645,7 +657,7 @@ static int32_t createInitialSources(SSortHandle* pHandle) { pHandle->inMemSort = true; pHandle->loops = 1; - pHandle->tupleHandle.rowIndex = -1; + pHandle->tupleHandle.rowIndex = -1; pHandle->tupleHandle.pBlock = pHandle->pDataBlock; return 0; } else { @@ -701,7 +713,8 @@ int32_t tsortClose(SSortHandle* pHandle) { return TSDB_CODE_SUCCESS; } -int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetchFp, void (*fp)(SSDataBlock*, void*), void* param) { +int32_t tsortSetFetchRawDataFp(SSortHandle* pHandle, _sort_fetch_block_fn_t fetchFp, void (*fp)(SSDataBlock*, void*), + void* param) { pHandle->fetchfp = fetchFp; pHandle->beforeFp = fp; pHandle->param = param; @@ -734,8 +747,8 @@ STupleHandle* tsortNextTuple(SSortHandle* pHandle) { return &pHandle->tupleHandle; } - int32_t index = tMergeTreeGetChosenIndex(pHandle->pMergeTree); - SSortSource *pSource = pHandle->cmpParam.pSources[index]; + int32_t index = tMergeTreeGetChosenIndex(pHandle->pMergeTree); + SSortSource* pSource = pHandle->cmpParam.pSources[index]; if (pHandle->needAdjust) { int32_t code = adjustMergeTreeForNextTuple(pSource, pHandle->pMergeTree, pHandle, &pHandle->numOfCompletedSources); @@ -778,16 +791,14 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) { } } -uint64_t tsortGetGroupId(STupleHandle* pVHandle) { - return pVHandle->pBlock->info.groupId; -} +uint64_t tsortGetGroupId(STupleHandle* pVHandle) { return pVHandle->pBlock->info.groupId; } SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) { SSortExecInfo info = {0}; info.sortBuffer = pHandle->pageSize * pHandle->numOfPages; - info.sortMethod = pHandle->inMemSort? SORT_QSORT_T:SORT_SPILLED_MERGE_SORT_T; - info.loops = pHandle->loops; + info.sortMethod = pHandle->inMemSort ? SORT_QSORT_T : SORT_SPILLED_MERGE_SORT_T; + info.loops = pHandle->loops; if (pHandle->pBuf != NULL) { SDiskbasedBufStatis st = getDBufStatis(pHandle->pBuf); @@ -797,4 +808,3 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) { return info; } - diff --git a/source/libs/executor/test/lhashTests.cpp b/source/libs/executor/test/lhashTests.cpp index c9b75395bce345802ff0e563762758601aca0a18..24570ff7889aa09dcd160a8703be88e57bbc35c9 100644 --- a/source/libs/executor/test/lhashTests.cpp +++ b/source/libs/executor/test/lhashTests.cpp @@ -32,41 +32,42 @@ TEST(testCase, linear_hash_Tests) { int64_t st = taosGetTimestampUs(); - SLHashObj* pHashObj = tHashInit(4098*4*2, 512, fn, 40); - for(int32_t i = 0; i < 1000000; ++i) { + SLHashObj* pHashObj = tHashInit(4098 * 4 * 2, 512, fn, 40); + for (int32_t i = 0; i < 1000000; ++i) { int32_t code = tHashPut(pHashObj, &i, sizeof(i), &i, sizeof(i)); assert(code == 0); } -// tHashPrint(pHashObj, LINEAR_HASH_STATIS); + // tHashPrint(pHashObj, LINEAR_HASH_STATIS); int64_t et = taosGetTimestampUs(); - for(int32_t i = 0; i < 1000000; ++i) { + for (int32_t i = 0; i < 1000000; ++i) { if (i == 950000) { printf("kf\n"); } char* v = tHashGet(pHashObj, &i, sizeof(i)); if (v != NULL) { -// printf("find value: %d, key:%d\n", *(int32_t*) v, i); + // printf("find value: %d, key:%d\n", *(int32_t*) v, i); } else { -// printf("failed to found key:%d in hash\n", i); + // printf("failed to found key:%d in hash\n", i); } } -// tHashPrint(pHashObj, LINEAR_HASH_STATIS); + // tHashPrint(pHashObj, LINEAR_HASH_STATIS); tHashCleanup(pHashObj); int64_t et1 = taosGetTimestampUs(); SHashObj* pHashObj1 = taosHashInit(1000, fn, false, HASH_NO_LOCK); - for(int32_t i = 0; i < 1000000; ++i) { + for (int32_t i = 0; i < 1000000; ++i) { taosHashPut(pHashObj1, &i, sizeof(i), &i, sizeof(i)); } - for(int32_t i = 0; i < 1000000; ++i) { + for (int32_t i = 0; i < 1000000; ++i) { void* v = taosHashGet(pHashObj1, &i, sizeof(i)); } taosHashCleanup(pHashObj1); int64_t et2 = taosGetTimestampUs(); - printf("linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f\n", (et1-st)/1000.0, (et-st)/1000.0, (et2-et1)/1000.0); + printf("linear hash time:%.2f ms, buildHash:%.2f ms, hash:%.2f\n", (et1 - st) / 1000.0, (et - st) / 1000.0, + (et2 - et1) / 1000.0); } \ No newline at end of file diff --git a/source/libs/executor/test/sortTests.cpp b/source/libs/executor/test/sortTests.cpp index 4ac15670ac5dca547572df102f7267de08c0306d..62813453a1398f51bc2667879e9b7cf07194b449 100644 --- a/source/libs/executor/test/sortTests.cpp +++ b/source/libs/executor/test/sortTests.cpp @@ -25,14 +25,14 @@ #pragma GCC diagnostic ignored "-Wsign-compare" #include "os.h" -#include "executorimpl.h" #include "executor.h" +#include "executorimpl.h" #include "taos.h" +#include "tcompare.h" #include "tdatablock.h" #include "tdef.h" #include "trpc.h" #include "tvariant.h" -#include "tcompare.h" namespace { typedef struct { @@ -44,8 +44,7 @@ typedef struct { int16_t VARCOUNT = 16; -float rand_f2() -{ +float rand_f2() { unsigned r = taosRand(); r &= 0x007fffff; r |= 0x40800000; @@ -53,10 +52,10 @@ float rand_f2() } static const int32_t TEST_NUMBER = 1; -#define bigendian() ((*(char *)&TEST_NUMBER) == 0) +#define bigendian() ((*(char*)&TEST_NUMBER) == 0) SSDataBlock* getSingleColDummyBlock(void* param) { - _info* pInfo = (_info*) param; + _info* pInfo = (_info*)param; if (--pInfo->count < 0) { return NULL; } @@ -65,11 +64,11 @@ SSDataBlock* getSingleColDummyBlock(void* param) { SColumnInfoData colInfo = {0}; colInfo.info.type = pInfo->type; - if (pInfo->type == TSDB_DATA_TYPE_NCHAR){ + if (pInfo->type == TSDB_DATA_TYPE_NCHAR) { colInfo.info.bytes = TSDB_NCHAR_SIZE * VARCOUNT + VARSTR_HEADER_SIZE; - } else if(pInfo->type == TSDB_DATA_TYPE_BINARY) { + } else if (pInfo->type == TSDB_DATA_TYPE_BINARY) { colInfo.info.bytes = VARCOUNT + VARSTR_HEADER_SIZE; - } else{ + } else { colInfo.info.bytes = tDataTypes[pInfo->type].bytes; } colInfo.info.colId = 1; @@ -80,39 +79,39 @@ SSDataBlock* getSingleColDummyBlock(void* param) { for (int32_t i = 0; i < pInfo->pageRows; ++i) { SColumnInfoData* pColInfo = static_cast(TARRAY_GET_ELEM(pBlock->pDataBlock, 0)); - if (pInfo->type == TSDB_DATA_TYPE_NCHAR){ + if (pInfo->type == TSDB_DATA_TYPE_NCHAR) { int32_t size = taosRand() % VARCOUNT; - char str[128] = {0}; - char strOri[128] = {0}; + char str[128] = {0}; + char strOri[128] = {0}; taosRandStr(strOri, size); int32_t len = 0; - bool ret = taosMbsToUcs4(strOri, size, (TdUcs4*)varDataVal(str), size * TSDB_NCHAR_SIZE, &len); - if (!ret){ + bool ret = taosMbsToUcs4(strOri, size, (TdUcs4*)varDataVal(str), size * TSDB_NCHAR_SIZE, &len); + if (!ret) { printf("error\n"); return NULL; } varDataSetLen(str, len); colDataAppend(pColInfo, i, reinterpret_cast(str), false); pBlock->info.hasVarCol = true; - printf("nchar: %s\n",strOri); - } else if(pInfo->type == TSDB_DATA_TYPE_BINARY){ + printf("nchar: %s\n", strOri); + } else if (pInfo->type == TSDB_DATA_TYPE_BINARY) { int32_t size = taosRand() % VARCOUNT; - char str[64] = {0}; + char str[64] = {0}; taosRandStr(varDataVal(str), size); varDataSetLen(str, size); colDataAppend(pColInfo, i, reinterpret_cast(str), false); pBlock->info.hasVarCol = true; printf("binary: %s\n", varDataVal(str)); - } else if(pInfo->type == TSDB_DATA_TYPE_DOUBLE || pInfo->type == TSDB_DATA_TYPE_FLOAT) { + } else if (pInfo->type == TSDB_DATA_TYPE_DOUBLE || pInfo->type == TSDB_DATA_TYPE_FLOAT) { double v = rand_f2(); colDataAppend(pColInfo, i, reinterpret_cast(&v), false); printf("float: %f\n", v); - } else{ + } else { int64_t v = ++pInfo->startVal; - char *result = static_cast(taosMemoryCalloc(tDataTypes[pInfo->type].bytes, 1)); - if (!bigendian()){ + char* result = static_cast(taosMemoryCalloc(tDataTypes[pInfo->type].bytes, 1)); + if (!bigendian()) { memcpy(result, &v, tDataTypes[pInfo->type].bytes); - }else{ + } else { memcpy(result, (char*)(&v) + sizeof(int64_t) - tDataTypes[pInfo->type].bytes, tDataTypes[pInfo->type].bytes); } @@ -126,17 +125,16 @@ SSDataBlock* getSingleColDummyBlock(void* param) { return pBlock; } - int32_t docomp(const void* p1, const void* p2, void* param) { - int32_t pLeftIdx = *(int32_t *)p1; - int32_t pRightIdx = *(int32_t *)p2; + int32_t pLeftIdx = *(int32_t*)p1; + int32_t pRightIdx = *(int32_t*)p2; - SMsortComparParam *pParam = (SMsortComparParam *)param; - SSortSource** px = reinterpret_cast(pParam->pSources); + SMsortComparParam* pParam = (SMsortComparParam*)param; + SSortSource** px = reinterpret_cast(pParam->pSources); - SArray *pInfo = pParam->orderInfo; + SArray* pInfo = pParam->orderInfo; - SSortSource* pLeftSource = px[pLeftIdx]; + SSortSource* pLeftSource = px[pLeftIdx]; SSortSource* pRightSource = px[pRightIdx]; // this input is exhausted, set the special value to denote this @@ -151,36 +149,38 @@ int32_t docomp(const void* p1, const void* p2, void* param) { SSDataBlock* pLeftBlock = pLeftSource->src.pBlock; SSDataBlock* pRightBlock = pRightSource->src.pBlock; - for(int32_t i = 0; i < pInfo->size; ++i) { + for (int32_t i = 0; i < pInfo->size; ++i) { SBlockOrderInfo* pOrder = (SBlockOrderInfo*)TARRAY_GET_ELEM(pInfo, i); SColumnInfoData* pLeftColInfoData = (SColumnInfoData*)TARRAY_GET_ELEM(pLeftBlock->pDataBlock, pOrder->slotId); - bool leftNull = false; + bool leftNull = false; if (pLeftColInfoData->hasNull) { - leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, pLeftBlock->pBlockAgg[pOrder->slotId]); + leftNull = colDataIsNull(pLeftColInfoData, pLeftBlock->info.rows, pLeftSource->src.rowIndex, + pLeftBlock->pBlockAgg[pOrder->slotId]); } - SColumnInfoData* pRightColInfoData = (SColumnInfoData*) TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId); - bool rightNull = false; + SColumnInfoData* pRightColInfoData = (SColumnInfoData*)TARRAY_GET_ELEM(pRightBlock->pDataBlock, pOrder->slotId); + bool rightNull = false; if (pRightColInfoData->hasNull) { - rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, pRightBlock->pBlockAgg[pOrder->slotId]); + rightNull = colDataIsNull(pRightColInfoData, pRightBlock->info.rows, pRightSource->src.rowIndex, + pRightBlock->pBlockAgg[pOrder->slotId]); } if (leftNull && rightNull) { - continue; // continue to next slot + continue; // continue to next slot } if (rightNull) { - return pOrder->nullFirst? 1:-1; + return pOrder->nullFirst ? 1 : -1; } if (leftNull) { - return pOrder->nullFirst? -1:1; + return pOrder->nullFirst ? -1 : 1; } - void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); - void* right1 = colDataGetData(pRightColInfoData, pRightSource->src.rowIndex); + void* left1 = colDataGetData(pLeftColInfoData, pLeftSource->src.rowIndex); + void* right1 = colDataGetData(pRightColInfoData, pRightSource->src.rowIndex); __compar_fn_t fn = getKeyComparFunc(pLeftColInfoData->info.type, pOrder->order); int ret = fn(left1, right1); diff --git a/source/libs/executor/test/tSimpleHashTests.cpp b/source/libs/executor/test/tSimpleHashTests.cpp index 3bf339ef9040879c0978f9bedffb2b23bd8ec806..3fbf2e7be8c894211e48ef2e33cfbac419fd18c0 100644 --- a/source/libs/executor/test/tSimpleHashTests.cpp +++ b/source/libs/executor/test/tSimpleHashTests.cpp @@ -31,8 +31,7 @@ // } TEST(testCase, tSimpleHashTest_intKey) { - SSHashObj *pHashObj = - tSimpleHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); + SSHashObj *pHashObj = tSimpleHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); assert(pHashObj != nullptr); @@ -76,10 +75,8 @@ TEST(testCase, tSimpleHashTest_intKey) { tSimpleHashCleanup(pHashObj); } - TEST(testCase, tSimpleHashTest_binaryKey) { - SSHashObj *pHashObj = - tSimpleHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); + SSHashObj *pHashObj = tSimpleHashInit(8, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT)); assert(pHashObj != nullptr); @@ -93,7 +90,7 @@ TEST(testCase, tSimpleHashTest_binaryKey) { size_t keyLen = sizeof(SCombineKey); size_t dataLen = sizeof(int64_t); - int64_t originDataSum = 0; + int64_t originDataSum = 0; SCombineKey combineKey = {0}; for (int64_t i = 1; i <= 100; ++i) { combineKey.suid = i; @@ -140,5 +137,4 @@ TEST(testCase, tSimpleHashTest_binaryKey) { tSimpleHashCleanup(pHashObj); } - #pragma GCC diagnostic pop \ No newline at end of file diff --git a/source/libs/function/inc/builtinsimpl.h b/source/libs/function/inc/builtinsimpl.h index 0880f2f5c73f5715174165e0325839ade28990c8..b5b7453e7a7ec98bd86038d8ffebf25ee2a1367f 100644 --- a/source/libs/function/inc/builtinsimpl.h +++ b/source/libs/function/inc/builtinsimpl.h @@ -23,37 +23,37 @@ extern "C" { #include "function.h" #include "functionMgt.h" -bool dummyGetEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* UNUSED_PARAM(pEnv)); -bool dummyInit(SqlFunctionCtx* UNUSED_PARAM(pCtx), SResultRowEntryInfo* UNUSED_PARAM(pResultInfo)); +bool dummyGetEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* UNUSED_PARAM(pEnv)); +bool dummyInit(SqlFunctionCtx* UNUSED_PARAM(pCtx), SResultRowEntryInfo* UNUSED_PARAM(pResultInfo)); int32_t dummyProcess(SqlFunctionCtx* UNUSED_PARAM(pCtx)); int32_t dummyFinalize(SqlFunctionCtx* UNUSED_PARAM(pCtx), SSDataBlock* UNUSED_PARAM(pBlock)); -bool functionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool functionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t functionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t functionFinalizeWithResultBuf(SqlFunctionCtx* pCtx, SSDataBlock* pBlock, char* finalResult); int32_t combineFunction(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); EFuncDataRequired countDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); -bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -int32_t countFunction(SqlFunctionCtx *pCtx); -int32_t countInvertFunction(SqlFunctionCtx *pCtx); +bool getCountFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +int32_t countFunction(SqlFunctionCtx* pCtx); +int32_t countInvertFunction(SqlFunctionCtx* pCtx); EFuncDataRequired statisDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow); -bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -int32_t sumFunction(SqlFunctionCtx *pCtx); -int32_t sumInvertFunction(SqlFunctionCtx *pCtx); -int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +bool getSumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +int32_t sumFunction(SqlFunctionCtx* pCtx); +int32_t sumInvertFunction(SqlFunctionCtx* pCtx); +int32_t sumCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool minmaxFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool minmaxFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +bool getMinmaxFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t minFunction(SqlFunctionCtx* pCtx); -int32_t maxFunction(SqlFunctionCtx *pCtx); +int32_t maxFunction(SqlFunctionCtx* pCtx); int32_t minmaxFunctionFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t minCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t maxCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getAvgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool avgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getAvgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool avgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t avgFunction(SqlFunctionCtx* pCtx); int32_t avgFunctionMerge(SqlFunctionCtx* pCtx); int32_t avgFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -62,8 +62,8 @@ int32_t avgInvertFunction(SqlFunctionCtx* pCtx); int32_t avgCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getAvgInfoSize(); -bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool stddevFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getStddevFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool stddevFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t stddevFunction(SqlFunctionCtx* pCtx); int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx); int32_t stddevFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -72,63 +72,63 @@ int32_t stddevInvertFunction(SqlFunctionCtx* pCtx); int32_t stddevCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getStddevInfoSize(); -bool getLeastSQRFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool leastSQRFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getLeastSQRFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool leastSQRFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t leastSQRFunction(SqlFunctionCtx* pCtx); int32_t leastSQRFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t leastSQRInvertFunction(SqlFunctionCtx* pCtx); int32_t leastSQRCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool percentileFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t percentileFunction(SqlFunctionCtx *pCtx); +bool getPercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool percentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t percentileFunction(SqlFunctionCtx* pCtx); int32_t percentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -bool getApercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool apercentileFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t apercentileFunction(SqlFunctionCtx *pCtx); +bool getApercentileFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool apercentileFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t apercentileFunction(SqlFunctionCtx* pCtx); int32_t apercentileFunctionMerge(SqlFunctionCtx* pCtx); int32_t apercentileFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t apercentilePartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t apercentileCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getApercentileMaxSize(); -bool getDiffFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool diffFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo); -int32_t diffFunction(SqlFunctionCtx *pCtx); +bool getDiffFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool diffFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo); +int32_t diffFunction(SqlFunctionCtx* pCtx); -bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool derivativeFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo); -int32_t derivativeFunction(SqlFunctionCtx *pCtx); +bool getDerivativeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool derivativeFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo); +int32_t derivativeFunction(SqlFunctionCtx* pCtx); -bool getIrateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool irateFuncSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResInfo); -int32_t irateFunction(SqlFunctionCtx *pCtx); +bool getIrateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool irateFuncSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResInfo); +int32_t irateFunction(SqlFunctionCtx* pCtx); int32_t irateFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t cachedLastRowFunction(SqlFunctionCtx* pCtx); -bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -int32_t firstFunction(SqlFunctionCtx *pCtx); -int32_t firstFunctionMerge(SqlFunctionCtx *pCtx); -int32_t lastFunction(SqlFunctionCtx *pCtx); -int32_t lastFunctionMerge(SqlFunctionCtx *pCtx); -int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -int32_t getFirstLastInfoSize(int32_t resBytes); +bool getFirstLastFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +int32_t firstFunction(SqlFunctionCtx* pCtx); +int32_t firstFunctionMerge(SqlFunctionCtx* pCtx); +int32_t lastFunction(SqlFunctionCtx* pCtx); +int32_t lastFunctionMerge(SqlFunctionCtx* pCtx); +int32_t firstLastFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t firstLastPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); +int32_t firstCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +int32_t lastCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); +int32_t getFirstLastInfoSize(int32_t resBytes); EFuncDataRequired lastDynDataReq(void* pRes, STimeWindow* pTimeWindow); -int32_t lastRowFunction(SqlFunctionCtx *pCtx); +int32_t lastRowFunction(SqlFunctionCtx* pCtx); -bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); -bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); -bool topBotFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t topFunction(SqlFunctionCtx *pCtx); -int32_t topFunctionMerge(SqlFunctionCtx *pCtx); -int32_t bottomFunction(SqlFunctionCtx *pCtx); -int32_t bottomFunctionMerge(SqlFunctionCtx *pCtx); +bool getTopBotFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); +bool getTopBotMergeFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv); +bool topBotFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t topFunction(SqlFunctionCtx* pCtx); +int32_t topFunctionMerge(SqlFunctionCtx* pCtx); +int32_t bottomFunction(SqlFunctionCtx* pCtx); +int32_t bottomFunctionMerge(SqlFunctionCtx* pCtx); int32_t topBotFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t topBotPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t topBotMergeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -136,8 +136,8 @@ int32_t topCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t bottomCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); int32_t getTopBotInfoSize(int64_t numOfItems); -bool getSpreadFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool spreadFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getSpreadFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool spreadFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t spreadFunction(SqlFunctionCtx* pCtx); int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx); int32_t spreadFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -145,8 +145,8 @@ int32_t spreadPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getSpreadInfoSize(); int32_t spreadCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getElapsedFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool elapsedFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getElapsedFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool elapsedFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t elapsedFunction(SqlFunctionCtx* pCtx); int32_t elapsedFunctionMerge(SqlFunctionCtx* pCtx); int32_t elapsedFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -154,8 +154,8 @@ int32_t elapsedPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getElapsedInfoSize(); int32_t elapsedCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getHistogramFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool histogramFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getHistogramFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool histogramFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t histogramFunction(SqlFunctionCtx* pCtx); int32_t histogramFunctionPartial(SqlFunctionCtx* pCtx); int32_t histogramFunctionMerge(SqlFunctionCtx* pCtx); @@ -164,7 +164,7 @@ int32_t histogramPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getHistogramInfoSize(); int32_t histogramCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getHLLFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getHLLFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t hllFunction(SqlFunctionCtx* pCtx); int32_t hllFunctionMerge(SqlFunctionCtx* pCtx); int32_t hllFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); @@ -172,48 +172,48 @@ int32_t hllPartialFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); int32_t getHLLInfoSize(); int32_t hllCombine(SqlFunctionCtx* pDestCtx, SqlFunctionCtx* pSourceCtx); -bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool stateFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getStateFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool stateFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t stateCountFunction(SqlFunctionCtx* pCtx); int32_t stateDurationFunction(SqlFunctionCtx* pCtx); -bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getCsumFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t csumFunction(SqlFunctionCtx* pCtx); -bool getMavgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool mavgFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getMavgFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool mavgFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t mavgFunction(SqlFunctionCtx* pCtx); -bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool sampleFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getSampleFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool sampleFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t sampleFunction(SqlFunctionCtx* pCtx); int32_t sampleFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -bool getTailFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool tailFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); +bool getTailFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool tailFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); int32_t tailFunction(SqlFunctionCtx* pCtx); -bool getUniqueFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool uniqueFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t uniqueFunction(SqlFunctionCtx *pCtx); +bool getUniqueFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool uniqueFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t uniqueFunction(SqlFunctionCtx* pCtx); -bool getModeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool modeFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t modeFunction(SqlFunctionCtx *pCtx); +bool getModeFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool modeFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t modeFunction(SqlFunctionCtx* pCtx); int32_t modeFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool twaFunctionSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t twaFunction(SqlFunctionCtx *pCtx); -int32_t twaFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); +bool getTwaFuncEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool twaFunctionSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t twaFunction(SqlFunctionCtx* pCtx); +int32_t twaFinalize(struct SqlFunctionCtx* pCtx, SSDataBlock* pBlock); bool getSelectivityFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool blockDistSetup(SqlFunctionCtx *pCtx, SResultRowEntryInfo* pResultInfo); -int32_t blockDistFunction(SqlFunctionCtx *pCtx); +bool blockDistSetup(SqlFunctionCtx* pCtx, SResultRowEntryInfo* pResultInfo); +int32_t blockDistFunction(SqlFunctionCtx* pCtx); int32_t blockDistFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); -bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); +bool getGroupKeyFuncEnv(SFunctionNode* pFunc, SFuncExecEnv* pEnv); int32_t groupKeyFunction(SqlFunctionCtx* pCtx); int32_t groupKeyFinalize(SqlFunctionCtx* pCtx, SSDataBlock* pBlock); diff --git a/source/libs/function/inc/tfunctionInt.h b/source/libs/function/inc/tfunctionInt.h index 8f6cbc977effcbab902cb01adf71a9dd42f0d724..821544106fc01ab1332c7bc531b5be26485e0300 100644 --- a/source/libs/function/inc/tfunctionInt.h +++ b/source/libs/function/inc/tfunctionInt.h @@ -22,11 +22,11 @@ extern "C" { #include "os.h" -#include "tname.h" -#include "taosdef.h" -#include "tvariant.h" #include "function.h" +#include "taosdef.h" +#include "tname.h" #include "tudf.h" +#include "tvariant.h" bool topbot_datablock_filter(SqlFunctionCtx *pCtx, const char *minval, const char *maxval); @@ -37,8 +37,8 @@ bool topbot_datablock_filter(SqlFunctionCtx *pCtx, const char *minval, const cha static FORCE_INLINE void initResultRowEntry(SResultRowEntryInfo *pResInfo, int32_t bufLen) { pResInfo->initialized = true; // the this struct has been initialized flag - pResInfo->complete = false; - pResInfo->numOfRes = 0; + pResInfo->complete = false; + pResInfo->numOfRes = 0; memset(GET_ROWCELL_INTERBUF(pResInfo), 0, bufLen); } diff --git a/source/libs/function/inc/thistogram.h b/source/libs/function/inc/thistogram.h index cb6560325bb959ec74a0b34eb89476b353038c24..20111086cd1342600f33cd7a36174d8fbaf5fc8a 100644 --- a/source/libs/function/inc/thistogram.h +++ b/source/libs/function/inc/thistogram.h @@ -43,15 +43,15 @@ typedef struct SHistogramInfo { int64_t numOfElems; int32_t numOfEntries; int32_t maxEntries; - double min; - double max; + double min; + double max; #if defined(USE_ARRAYLIST) SHistBin* elems; #else - tSkipList* pList; + tSkipList* pList; SMultiwayMergeTreeInfo* pLoserTree; - int32_t maxIndex; - bool ordered; + int32_t maxIndex; + bool ordered; #endif } SHistogramInfo; @@ -61,16 +61,16 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins); int32_t tHistogramAdd(SHistogramInfo** pHisto, double val); int64_t tHistogramSum(SHistogramInfo* pHisto, double v); -double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num); +double* tHistogramUniform(SHistogramInfo* pHisto, double* ratio, int32_t num); SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2, int32_t numOfEntries); -void tHistogramDestroy(SHistogramInfo** pHisto); +void tHistogramDestroy(SHistogramInfo** pHisto); void tHistogramPrint(SHistogramInfo* pHisto); int32_t histoBinarySearch(SHistBin* pEntry, int32_t len, double val); SHeapEntry* tHeapCreate(int32_t numOfEntries); -void tHeapSort(SHeapEntry* pEntry, int32_t len); +void tHeapSort(SHeapEntry* pEntry, int32_t len); #ifdef __cplusplus } diff --git a/source/libs/function/inc/tpercentile.h b/source/libs/function/inc/tpercentile.h index 554f9e567f35cc0272a2a9755153de1b54d34392..873dc46a0890bd6659e86feb294539dddc3a031a 100644 --- a/source/libs/function/inc/tpercentile.h +++ b/source/libs/function/inc/tpercentile.h @@ -61,10 +61,10 @@ typedef struct tMemBucket { MinMaxEntry range; // value range int32_t times; // count that has been checked for deciding the correct data value buckets. __compar_fn_t comparFn; - tMemBucketSlot* pSlots; - SDiskbasedBuf* pBuffer; + tMemBucketSlot *pSlots; + SDiskbasedBuf *pBuffer; __perc_hash_func_t hashFunc; - SHashObj* groupPagesMap; // disk page map for different groups; + SHashObj *groupPagesMap; // disk page map for different groups; } tMemBucket; tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, double maxval); diff --git a/source/libs/function/inc/tscript.h b/source/libs/function/inc/tscript.h index 823e2d61f2baa9a107c59608d757de0f673cc38b..730d29a8c9426f9485931ee13cd61e021c325375 100644 --- a/source/libs/function/inc/tscript.h +++ b/source/libs/function/inc/tscript.h @@ -17,18 +17,18 @@ #define TDENGINE_QSCRIPT_H #if 0 -#include #include +#include #include -#include "tutil.h" #include "hash.h" #include "tlist.h" #include "tudf.h" +#include "tutil.h" #define MAX_FUNC_NAME 64 -#define USER_FUNC_NAME "funcName" +#define USER_FUNC_NAME "funcName" #define USER_FUNC_NAME_LIMIT 48 enum ScriptState { @@ -81,4 +81,4 @@ void scriptEnvPoolCleanup(); bool isValidScript(char *script, int32_t len); #endif -#endif //TDENGINE_QSCRIPT_H +#endif // TDENGINE_QSCRIPT_H diff --git a/source/libs/function/inc/tudfInt.h b/source/libs/function/inc/tudfInt.h index 6f82542aee6966d8b4fd7c613263a0639be190a3..c1b0941d4bd7c7e987999a16357263f87e34dbfc 100644 --- a/source/libs/function/inc/tudfInt.h +++ b/source/libs/function/inc/tudfInt.h @@ -40,33 +40,31 @@ typedef struct SUdfSetupRequest { typedef struct SUdfSetupResponse { int64_t udfHandle; - int8_t outputType; + int8_t outputType; int32_t outputLen; int32_t bufSize; } SUdfSetupResponse; typedef struct SUdfCallRequest { int64_t udfHandle; - int8_t callType; + int8_t callType; - SSDataBlock block; + SSDataBlock block; SUdfInterBuf interBuf; SUdfInterBuf interBuf2; - int8_t initFirst; + int8_t initFirst; } SUdfCallRequest; typedef struct SUdfCallResponse { - int8_t callType; - SSDataBlock resultData; + int8_t callType; + SSDataBlock resultData; SUdfInterBuf resultBuf; } SUdfCallResponse; - typedef struct SUdfTeardownRequest { int64_t udfHandle; } SUdfTeardownRequest; - typedef struct SUdfTeardownResponse { #ifdef WINDOWS size_t avoidCompilationErrors; @@ -79,8 +77,8 @@ typedef struct SUdfRequest { int8_t type; union { - SUdfSetupRequest setup; - SUdfCallRequest call; + SUdfSetupRequest setup; + SUdfCallRequest call; SUdfTeardownRequest teardown; }; } SUdfRequest; @@ -89,29 +87,29 @@ typedef struct SUdfResponse { int32_t msgLen; int64_t seqNum; - int8_t type; + int8_t type; int32_t code; union { - SUdfSetupResponse setupRsp; - SUdfCallResponse callRsp; + SUdfSetupResponse setupRsp; + SUdfCallResponse callRsp; SUdfTeardownResponse teardownRsp; }; } SUdfResponse; -int32_t encodeUdfRequest(void **buf, const SUdfRequest* request); -void* decodeUdfRequest(const void *buf, SUdfRequest* request); +int32_t encodeUdfRequest(void **buf, const SUdfRequest *request); +void *decodeUdfRequest(const void *buf, SUdfRequest *request); int32_t encodeUdfResponse(void **buf, const SUdfResponse *response); -void* decodeUdfResponse(const void* buf, SUdfResponse *response); +void *decodeUdfResponse(const void *buf, SUdfResponse *response); void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta); -void freeUdfColumn(SUdfColumn* col); +void freeUdfColumn(SUdfColumn *col); void freeUdfDataDataBlock(SUdfDataBlock *block); int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlock); int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block); -int32_t getUdfdPipeName(char* pipeName, int32_t size); +int32_t getUdfdPipeName(char *pipeName, int32_t size); #ifdef __cplusplus } #endif diff --git a/source/libs/function/inc/udfc.h b/source/libs/function/inc/udfc.h index f414c2b29e85089404e74f03fa4dcb875650d41f..c46e500ccbf035fc9424a3bc961f6f0f81abe650 100644 --- a/source/libs/function/inc/udfc.h +++ b/source/libs/function/inc/udfc.h @@ -14,20 +14,20 @@ #endif enum { - UDF_TASK_SETUP = 0, - UDF_TASK_CALL = 1, - UDF_TASK_TEARDOWN = 2 + UDF_TASK_SETUP = 0, + UDF_TASK_CALL = 1, + UDF_TASK_TEARDOWN = 2 }; -typedef struct SSDataBlock{ - char *data; - int32_t size; +typedef struct SSDataBlock { + char *data; + int32_t size; } SSDataBlock; typedef struct SUdfInfo { - char *udfName; - char *path; + char *udfName; + char *path; } SUdfInfo; typedef void *UdfcFuncHandle; @@ -36,9 +36,9 @@ int32_t createUdfdProxy(); int32_t destroyUdfdProxy(); -//int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles); +// int32_t setupUdf(SUdfInfo *udf, int32_t numOfUdfs, UdfcFuncHandle *handles); -int32_t setupUdf(SUdfInfo* udf, UdfcFuncHandle* handle); +int32_t setupUdf(SUdfInfo *udf, UdfcFuncHandle *handle); int32_t callUdf(UdfcFuncHandle handle, int8_t step, char *state, int32_t stateSize, SSDataBlock input, char **newstate, int32_t *newStateSize, SSDataBlock *output); @@ -46,43 +46,39 @@ int32_t callUdf(UdfcFuncHandle handle, int8_t step, char *state, int32_t stateSi int32_t doTeardownUdf(UdfcFuncHandle handle); typedef struct SUdfSetupRequest { - char udfName[16]; // - int8_t scriptType; // 0:c, 1: lua, 2:js - int8_t udfType; //udaf, udf, udtf - int16_t pathSize; - char *path; + char udfName[16]; // + int8_t scriptType; // 0:c, 1: lua, 2:js + int8_t udfType; // udaf, udf, udtf + int16_t pathSize; + char *path; } SUdfSetupRequest; typedef struct SUdfSetupResponse { - int64_t udfHandle; + int64_t udfHandle; } SUdfSetupResponse; - typedef struct SUdfCallRequest { - int64_t udfHandle; - int8_t step; + int64_t udfHandle; + int8_t step; - int32_t inputBytes; - char *input; + int32_t inputBytes; + char *input; - int32_t stateBytes; - char *state; + int32_t stateBytes; + char *state; } SUdfCallRequest; - typedef struct SUdfCallResponse { - int32_t outputBytes; - char *output; - int32_t newStateBytes; - char *newState; + int32_t outputBytes; + char *output; + int32_t newStateBytes; + char *newState; } SUdfCallResponse; - typedef struct SUdfTeardownRequest { - int64_t udfHandle; + int64_t udfHandle; } SUdfTeardownRequest; - typedef struct SUdfTeardownResponse { #ifdef WINDOWS size_t avoidCompilationErrors; @@ -90,24 +86,24 @@ typedef struct SUdfTeardownResponse { } SUdfTeardownResponse; typedef struct SUdfRequest { - int32_t msgLen; - int64_t seqNum; + int32_t msgLen; + int64_t seqNum; - int8_t type; - void *subReq; + int8_t type; + void *subReq; } SUdfRequest; typedef struct SUdfResponse { - int32_t msgLen; - int64_t seqNum; + int32_t msgLen; + int64_t seqNum; - int8_t type; - int32_t code; - void *subRsp; + int8_t type; + int32_t code; + void *subRsp; } SUdfResponse; int32_t decodeRequest(char *buf, int32_t bufLen, SUdfRequest **pRequest); int32_t encodeResponse(char **buf, int32_t *bufLen, SUdfResponse *response); int32_t encodeRequest(char **buf, int32_t *bufLen, SUdfRequest *request); int32_t decodeResponse(char *buf, int32_t bufLen, SUdfResponse **pResponse); -#endif //UDF_UDF_H +#endif // UDF_UDF_H diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index d91423ab5c3adbde9932e409d17e59060460183e..7077a9b780c16ce7decc331cd553f62007b58648 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -1557,8 +1557,8 @@ int32_t doMinMaxHelper(SqlFunctionCtx* pCtx, int32_t isMinFunc) { numOfElems += 1; } } else if (type == TSDB_DATA_TYPE_FLOAT) { - float* pData = (float*)pCol->pData; - float* val = (float*)&pBuf->v; + float* pData = (float*)pCol->pData; + float* val = (float*)&pBuf->v; for (int32_t i = start; i < start + numOfRows; ++i) { if ((pCol->hasNull) && colDataIsNull_f(pCol->nullbitmap, i)) { @@ -2977,7 +2977,8 @@ int32_t lastFunction(SqlFunctionCtx* pCtx) { return TSDB_CODE_SUCCESS; } -static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, int32_t rowIndex) { +static void firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput, SFirstLastRes* pOutput, bool isFirst, + int32_t rowIndex) { SInputColumnInfoData* pColInfo = &pCtx->input; if (pOutput->hasResult) { diff --git a/source/libs/function/src/tfunctionInt.c b/source/libs/function/src/tfunctionInt.c index ff15b7714f7473794b48b28d9cbb46a910ec339f..70378df0c3315c03989ae673ec50ecf1a47d8278 100644 --- a/source/libs/function/src/tfunctionInt.c +++ b/source/libs/function/src/tfunctionInt.c @@ -15,8 +15,8 @@ #include "os.h" #include "taosdef.h" -#include "tmsg.h" #include "thash.h" +#include "tmsg.h" #include "ttypes.h" #include "function.h" @@ -29,15 +29,13 @@ #include "ttszip.h" #include "tudf.h" -void cleanupResultRowEntry(struct SResultRowEntryInfo* pCell) { - pCell->initialized = false; -} +void cleanupResultRowEntry(struct SResultRowEntryInfo* pCell) { pCell->initialized = false; } int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock) { int32_t maxRows = 0; for (int32_t j = 0; j < num; ++j) { - SResultRowEntryInfo *pResInfo = GET_RES_INFO(&pCtx[j]); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(&pCtx[j]); if (pResInfo != NULL && maxRows < pResInfo->numOfRes) { maxRows = pResInfo->numOfRes; } @@ -46,12 +44,12 @@ int32_t getNumOfResult(SqlFunctionCtx* pCtx, int32_t num, SSDataBlock* pResBlock assert(maxRows >= 0); blockDataEnsureCapacity(pResBlock, maxRows); - for(int32_t i = 0; i < num; ++i) { + for (int32_t i = 0; i < num; ++i) { SColumnInfoData* pCol = taosArrayGet(pResBlock->pDataBlock, i); - SResultRowEntryInfo *pResInfo = GET_RES_INFO(&pCtx[i]); + SResultRowEntryInfo* pResInfo = GET_RES_INFO(&pCtx[i]); if (pResInfo->numOfRes == 0) { - for(int32_t j = 0; j < pResInfo->numOfRes; ++j) { + for (int32_t j = 0; j < pResInfo->numOfRes; ++j) { colDataAppend(pCol, j, NULL, true); // TODO add set null data api } } else { @@ -70,6 +68,4 @@ bool isRowEntryCompleted(struct SResultRowEntryInfo* pEntry) { return pEntry->complete; } -bool isRowEntryInitialized(struct SResultRowEntryInfo* pEntry) { - return pEntry->initialized; -} +bool isRowEntryInitialized(struct SResultRowEntryInfo* pEntry) { return pEntry->initialized; } diff --git a/source/libs/function/src/thistogram.c b/source/libs/function/src/thistogram.c index 2e60498aba4d339edb5346107c44fac109d54761..b0f23f78df72afa23015a947632e024082cacd46 100644 --- a/source/libs/function/src/thistogram.c +++ b/source/libs/function/src/thistogram.c @@ -14,10 +14,10 @@ */ #include "os.h" -#include "thistogram.h" #include "taosdef.h" -#include "tmsg.h" +#include "thistogram.h" #include "tlosertree.h" +#include "tmsg.h" /** * @@ -54,7 +54,7 @@ SHistogramInfo* tHistogramCreateFrom(void* pBuf, int32_t numOfBins) { SHistogramInfo* pHisto = (SHistogramInfo*)pBuf; pHisto->elems = (SHistBin*)((char*)pBuf + sizeof(SHistogramInfo)); - for(int32_t i = 0; i < numOfBins; ++i) { + for (int32_t i = 0; i < numOfBins; ++i) { pHisto->elems[i].val = -DBL_MAX; } @@ -116,7 +116,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { pEntry1->delta = ((SHistBin*)pResNode->pForward[0]->pData)->val - val; if ((*pHisto)->ordered) { - int32_t lastIndex = (*pHisto)->maxIndex; + int32_t lastIndex = (*pHisto)->maxIndex; SMultiwayMergeTreeInfo* pTree = (*pHisto)->pLoserTree; (*pHisto)->pLoserTree->pNode[lastIndex + pTree->numOfEntries].pData = pResNode; @@ -156,7 +156,7 @@ int32_t tHistogramAdd(SHistogramInfo** pHisto, double val) { SSkipListPrint((*pHisto)->pList, 1); SMultiwayMergeTreeInfo* pTree = (*pHisto)->pLoserTree; - tSkipListNode* pHead = (*pHisto)->pList->pHead.pForward[0]; + tSkipListNode* pHead = (*pHisto)->pList->pHead.pForward[0]; tSkipListNode* p1 = pHead; @@ -357,7 +357,7 @@ void tHistogramDestroy(SHistogramInfo** pHisto) { } void tHistogramPrint(SHistogramInfo* pHisto) { - printf("total entries: %d, elements: %"PRId64 "\n", pHisto->numOfEntries, pHisto->numOfElems); + printf("total entries: %d, elements: %" PRId64 "\n", pHisto->numOfEntries, pHisto->numOfElems); #if defined(USE_ARRAYLIST) for (int32_t i = 0; i < pHisto->numOfEntries; ++i) { printf("%d: (%f, %" PRId64 ")\n", i + 1, pHisto->elems[i].val, pHisto->elems[i].num); @@ -536,7 +536,7 @@ SHistogramInfo* tHistogramMerge(SHistogramInfo* pHisto1, SHistogramInfo* pHisto2 } SHistBin* pHistoBins = taosMemoryCalloc(1, sizeof(SHistBin) * (pHisto1->numOfEntries + pHisto2->numOfEntries)); - int32_t i = 0, j = 0, k = 0; + int32_t i = 0, j = 0, k = 0; while (i < pHisto1->numOfEntries && j < pHisto2->numOfEntries) { if (pHisto1->elems[i].val < pHisto2->elems[j].val) { diff --git a/source/libs/function/src/tpercentile.c b/source/libs/function/src/tpercentile.c index 4c58c0abe50e5784314445934618265231d4805a..62c5e4b28b9b755b68402ef90405290f3c6d40d1 100644 --- a/source/libs/function/src/tpercentile.c +++ b/source/libs/function/src/tpercentile.c @@ -14,8 +14,8 @@ */ #include "taoserror.h" -#include "tglobal.h" #include "tcompare.h" +#include "tglobal.h" #include "taosdef.h" #include "tcompare.h" @@ -25,21 +25,20 @@ #define DEFAULT_NUM_OF_SLOT 1024 -int32_t getGroupId(int32_t numOfSlots, int32_t slotIndex, int32_t times) { - return (times * numOfSlots) + slotIndex; -} +int32_t getGroupId(int32_t numOfSlots, int32_t slotIndex, int32_t times) { return (times * numOfSlots) + slotIndex; } static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) { - SFilePage *buffer = (SFilePage *)taosMemoryCalloc(1, pMemBucket->bytes * pMemBucket->pSlots[slotIdx].info.size + sizeof(SFilePage)); + SFilePage *buffer = + (SFilePage *)taosMemoryCalloc(1, pMemBucket->bytes * pMemBucket->pSlots[slotIdx].info.size + sizeof(SFilePage)); int32_t groupId = getGroupId(pMemBucket->numOfSlots, slotIdx, pMemBucket->times); - SArray* pIdList = *(SArray**)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); + SArray *pIdList = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); int32_t offset = 0; - for(int32_t i = 0; i < taosArrayGetSize(pIdList); ++i) { - int32_t* pageId = taosArrayGet(pIdList, i); + for (int32_t i = 0; i < taosArrayGetSize(pIdList); ++i) { + int32_t *pageId = taosArrayGet(pIdList, i); - SFilePage* pg = getBufPage(pMemBucket->pBuffer, *pageId); + SFilePage *pg = getBufPage(pMemBucket->pBuffer, *pageId); memcpy(buffer->data + offset, pg->data, (size_t)(pg->num * pMemBucket->bytes)); offset += (int32_t)(pg->num * pMemBucket->bytes); @@ -49,7 +48,7 @@ static SFilePage *loadDataFromFilePage(tMemBucket *pMemBucket, int32_t slotIdx) return buffer; } -static void resetBoundingBox(MinMaxEntry* range, int32_t type) { +static void resetBoundingBox(MinMaxEntry *range, int32_t type) { if (IS_SIGNED_NUMERIC_TYPE(type)) { range->i64MaxVal = INT64_MIN; range->i64MinVal = INT64_MAX; @@ -62,17 +61,17 @@ static void resetBoundingBox(MinMaxEntry* range, int32_t type) { } } -static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, double maxval) { +static int32_t setBoundingBox(MinMaxEntry *range, int16_t type, double minval, double maxval) { if (minval > maxval) { return -1; } if (IS_SIGNED_NUMERIC_TYPE(type)) { - range->i64MinVal = (int64_t) minval; - range->i64MaxVal = (int64_t) maxval; - } else if (IS_UNSIGNED_NUMERIC_TYPE(type)){ - range->u64MinVal = (uint64_t) minval; - range->u64MaxVal = (uint64_t) maxval; + range->i64MinVal = (int64_t)minval; + range->i64MaxVal = (int64_t)maxval; + } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { + range->u64MinVal = (uint64_t)minval; + range->u64MaxVal = (uint64_t)maxval; } else { range->dMinVal = minval; range->dMaxVal = maxval; @@ -81,10 +80,10 @@ static int32_t setBoundingBox(MinMaxEntry* range, int16_t type, double minval, d return 0; } -static void resetPosInfo(SSlotInfo* pInfo) { - pInfo->size = 0; +static void resetPosInfo(SSlotInfo *pInfo) { + pInfo->size = 0; pInfo->pageId = -1; - pInfo->data = NULL; + pInfo->data = NULL; } double findOnlyResult(tMemBucket *pMemBucket) { @@ -92,16 +91,16 @@ double findOnlyResult(tMemBucket *pMemBucket) { for (int32_t i = 0; i < pMemBucket->numOfSlots; ++i) { tMemBucketSlot *pSlot = &pMemBucket->pSlots[i]; - if (pSlot->info.size == 0) { + if (pSlot->info.size == 0) { continue; } int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times); - SArray* list = *(SArray**)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); + SArray *list = *(SArray **)taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); assert(list->size == 1); - int32_t* pageId = taosArrayGet(list, 0); - SFilePage* pPage = getBufPage(pMemBucket->pBuffer, *pageId); + int32_t *pageId = taosArrayGet(list, 0); + SFilePage *pPage = getBufPage(pMemBucket->pBuffer, *pageId); assert(pPage->num == 1); double v = 0; @@ -121,14 +120,14 @@ int32_t tBucketIntHash(tMemBucket *pBucket, const void *value) { if (v > pBucket->range.i64MaxVal || v < pBucket->range.i64MinVal) { return index; } - + // divide the value range into 1024 buckets uint64_t span = pBucket->range.i64MaxVal - pBucket->range.i64MinVal; if (span < pBucket->numOfSlots) { int64_t delta = v - pBucket->range.i64MinVal; index = (delta % pBucket->numOfSlots); } else { - double slotSpan = ((double)span) / pBucket->numOfSlots; + double slotSpan = ((double)span) / pBucket->numOfSlots; uint64_t delta = v - pBucket->range.i64MinVal; index = (int32_t)(delta / slotSpan); @@ -150,12 +149,12 @@ int32_t tBucketUintHash(tMemBucket *pBucket, const void *value) { if (v > pBucket->range.u64MaxVal || v < pBucket->range.u64MinVal) { return index; } - + // divide the value range into 1024 buckets uint64_t span = pBucket->range.u64MaxVal - pBucket->range.u64MinVal; if (span < pBucket->numOfSlots) { int64_t delta = v - pBucket->range.u64MinVal; - index = (int32_t) (delta % pBucket->numOfSlots); + index = (int32_t)(delta % pBucket->numOfSlots); } else { double slotSpan = (double)span / pBucket->numOfSlots; index = (int32_t)((v - pBucket->range.u64MinVal) / slotSpan); @@ -209,9 +208,9 @@ static __perc_hash_func_t getHashFunc(int32_t type) { } } -static void resetSlotInfo(tMemBucket* pBucket) { +static void resetSlotInfo(tMemBucket *pBucket) { for (int32_t i = 0; i < pBucket->numOfSlots; ++i) { - tMemBucketSlot* pSlot = &pBucket->pSlots[i]; + tMemBucketSlot *pSlot = &pBucket->pSlots[i]; resetBoundingBox(&pSlot->range, pBucket->type); resetPosInfo(&pSlot->info); @@ -225,9 +224,9 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, } pBucket->numOfSlots = DEFAULT_NUM_OF_SLOT; - pBucket->bufPageSize = 16384 * 4; // 16k per page + pBucket->bufPageSize = 16384 * 4; // 16k per page - pBucket->type = dataType; + pBucket->type = dataType; pBucket->bytes = nElemSize; pBucket->total = 0; pBucket->times = 1; @@ -235,17 +234,17 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, pBucket->maxCapacity = 200000; pBucket->groupPagesMap = taosHashInit(128, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (setBoundingBox(&pBucket->range, pBucket->type, minval, maxval) != 0) { -// qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval); + // qError("MemBucket:%p, invalid value range: %f-%f", pBucket, minval, maxval); taosMemoryFree(pBucket); return NULL; } - pBucket->elemPerPage = (pBucket->bufPageSize - sizeof(SFilePage))/pBucket->bytes; + pBucket->elemPerPage = (pBucket->bufPageSize - sizeof(SFilePage)) / pBucket->bytes; pBucket->comparFn = getKeyComparFunc(pBucket->type, TSDB_ORDER_ASC); pBucket->hashFunc = getHashFunc(pBucket->type); if (pBucket->hashFunc == NULL) { -// qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type); + // qError("MemBucket:%p, not support data type %d, failed", pBucket, pBucket->type); taosMemoryFree(pBucket); return NULL; } @@ -270,8 +269,8 @@ tMemBucket *tMemBucketCreate(int16_t nElemSize, int16_t dataType, double minval, tMemBucketDestroy(pBucket); return NULL; } - -// qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes); + + // qDebug("MemBucket:%p, elem size:%d", pBucket, pBucket->bytes); return pBucket; } @@ -280,9 +279,9 @@ void tMemBucketDestroy(tMemBucket *pBucket) { return; } - void* p = taosHashIterate(pBucket->groupPagesMap, NULL); - while(p) { - SArray** p1 = p; + void *p = taosHashIterate(pBucket->groupPagesMap, NULL); + while (p) { + SArray **p1 = p; p = taosHashIterate(pBucket->groupPagesMap, p); taosArrayDestroy(*p1); } @@ -341,7 +340,7 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { int32_t count = 0; int32_t bytes = pBucket->bytes; for (int32_t i = 0; i < size; ++i) { - char *d = (char *) data + i * bytes; + char *d = (char *)data + i * bytes; int32_t index = (pBucket->hashFunc)(pBucket, d); if (index < 0) { continue; @@ -365,11 +364,11 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { pSlot->info.data = NULL; } - SArray* pPageIdList = (SArray*)taosHashGet(pBucket->groupPagesMap, &groupId, sizeof(groupId)); + SArray *pPageIdList = (SArray *)taosHashGet(pBucket->groupPagesMap, &groupId, sizeof(groupId)); if (pPageIdList == NULL) { - SArray* pList = taosArrayInit(4, sizeof(int32_t)); + SArray *pList = taosArrayInit(4, sizeof(int32_t)); taosHashPut(pBucket->groupPagesMap, &groupId, sizeof(groupId), &pList, POINTER_BYTES); - pPageIdList = pList; + pPageIdList = pList; } pSlot->info.data = getNewBufPage(pBucket->pBuffer, &pageId); @@ -396,29 +395,29 @@ int32_t tMemBucketPut(tMemBucket *pBucket, const void *data, size_t size) { * slot of the next segment. */ static MinMaxEntry getMinMaxEntryOfNextSlotWithData(tMemBucket *pMemBucket, int32_t slotIdx) { - int32_t j = slotIdx + 1; - while (j < pMemBucket->numOfSlots && (pMemBucket->pSlots[j].info.size == 0)) { - ++j; - } + int32_t j = slotIdx + 1; + while (j < pMemBucket->numOfSlots && (pMemBucket->pSlots[j].info.size == 0)) { + ++j; + } - assert(j < pMemBucket->numOfSlots); - return pMemBucket->pSlots[j].range; + assert(j < pMemBucket->numOfSlots); + return pMemBucket->pSlots[j].range; } static bool isIdenticalData(tMemBucket *pMemBucket, int32_t index); -static double getIdenticalDataVal(tMemBucket* pMemBucket, int32_t slotIndex) { +static double getIdenticalDataVal(tMemBucket *pMemBucket, int32_t slotIndex) { assert(isIdenticalData(pMemBucket, slotIndex)); tMemBucketSlot *pSlot = &pMemBucket->pSlots[slotIndex]; double finalResult = 0.0; if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { - finalResult = (double) pSlot->range.i64MinVal; + finalResult = (double)pSlot->range.i64MinVal; } else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) { - finalResult = (double) pSlot->range.u64MinVal; + finalResult = (double)pSlot->range.u64MinVal; } else { - finalResult = (double) pSlot->range.dMinVal; + finalResult = (double)pSlot->range.dMinVal; } return finalResult; @@ -445,14 +444,14 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) double maxOfThisSlot = 0; double minOfNextSlot = 0; if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { - maxOfThisSlot = (double) pSlot->range.i64MaxVal; - minOfNextSlot = (double) next.i64MinVal; + maxOfThisSlot = (double)pSlot->range.i64MaxVal; + minOfNextSlot = (double)next.i64MinVal; } else if (IS_UNSIGNED_NUMERIC_TYPE(pMemBucket->type)) { - maxOfThisSlot = (double) pSlot->range.u64MaxVal; - minOfNextSlot = (double) next.u64MinVal; + maxOfThisSlot = (double)pSlot->range.u64MaxVal; + minOfNextSlot = (double)next.u64MinVal; } else { - maxOfThisSlot = (double) pSlot->range.dMaxVal; - minOfNextSlot = (double) next.dMinVal; + maxOfThisSlot = (double)pSlot->range.dMaxVal; + minOfNextSlot = (double)next.dMinVal; } assert(minOfNextSlot > maxOfThisSlot); @@ -478,32 +477,32 @@ double getPercentileImpl(tMemBucket *pMemBucket, int32_t count, double fraction) return val; } else { // incur a second round bucket split - if (isIdenticalData(pMemBucket, i)) { - return getIdenticalDataVal(pMemBucket, i); - } + if (isIdenticalData(pMemBucket, i)) { + return getIdenticalDataVal(pMemBucket, i); + } - // try next round - pMemBucket->times += 1; -// qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times); + // try next round + pMemBucket->times += 1; + // qDebug("MemBucket:%p, start next round data bucketing, time:%d", pMemBucket, pMemBucket->times); - pMemBucket->range = pSlot->range; - pMemBucket->total = 0; + pMemBucket->range = pSlot->range; + pMemBucket->total = 0; - resetSlotInfo(pMemBucket); + resetSlotInfo(pMemBucket); - int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1); + int32_t groupId = getGroupId(pMemBucket->numOfSlots, i, pMemBucket->times - 1); SIDList list = taosHashGet(pMemBucket->groupPagesMap, &groupId, sizeof(groupId)); - assert(list->size > 0); + assert(list->size > 0); - for (int32_t f = 0; f < list->size; ++f) { - SPageInfo *pgInfo = *(SPageInfo **)taosArrayGet(list, f); - SFilePage *pg = getBufPage(pMemBucket->pBuffer, getPageId(pgInfo)); + for (int32_t f = 0; f < list->size; ++f) { + SPageInfo *pgInfo = *(SPageInfo **)taosArrayGet(list, f); + SFilePage *pg = getBufPage(pMemBucket->pBuffer, getPageId(pgInfo)); - tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num); - releaseBufPageInfo(pMemBucket->pBuffer, pgInfo); - } + tMemBucketPut(pMemBucket, pg->data, (int32_t)pg->num); + releaseBufPageInfo(pMemBucket->pBuffer, pgInfo); + } - return getPercentileImpl(pMemBucket, count - num, fraction); + return getPercentileImpl(pMemBucket, count - num, fraction); } } else { num += pSlot->info.size; @@ -527,7 +526,7 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { // find the min/max value, no need to scan all data in bucket if (fabs(percent - 100.0) < DBL_EPSILON || (percent < DBL_EPSILON)) { - MinMaxEntry* pRange = &pMemBucket->range; + MinMaxEntry *pRange = &pMemBucket->range; if (IS_SIGNED_NUMERIC_TYPE(pMemBucket->type)) { double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->i64MaxVal : pRange->i64MinVal); @@ -536,11 +535,11 @@ double getPercentile(tMemBucket *pMemBucket, double percent) { double v = (double)(fabs(percent - 100) < DBL_EPSILON ? pRange->u64MaxVal : pRange->u64MinVal); return v; } else { - return fabs(percent - 100) < DBL_EPSILON? pRange->dMaxVal:pRange->dMinVal; + return fabs(percent - 100) < DBL_EPSILON ? pRange->dMaxVal : pRange->dMinVal; } } - double percentVal = (percent * (pMemBucket->total - 1)) / ((double)100.0); + double percentVal = (percent * (pMemBucket->total - 1)) / ((double)100.0); // do put data by using buckets int32_t orderIdx = (int32_t)percentVal; diff --git a/source/libs/function/src/tscript.c b/source/libs/function/src/tscript.c index 93e8ecf5cfbc7aa67ed7bd12e404d850fa3eb4f4..768581285b58b969cdd916a5b442c2422285faae 100644 --- a/source/libs/function/src/tscript.c +++ b/source/libs/function/src/tscript.c @@ -13,10 +13,10 @@ * along with this program. If not, see . */ -#include "os.h" #include "tscript.h" -#include "ttypes.h" +#include "os.h" #include "tstrbuild.h" +#include "ttypes.h" //#include "queryLog.h" #include "ttokendef.h" #if 0 diff --git a/source/libs/function/src/tudf.c b/source/libs/function/src/tudf.c index 060a92f864ec6380a799c77a6790eeeb3175577b..14833945090c1ca9f6cf860e9d51253dcff5a182 100644 --- a/source/libs/function/src/tudf.c +++ b/source/libs/function/src/tudf.c @@ -13,33 +13,35 @@ * along with this program. If not, see . */ #include "uv.h" + #include "os.h" + +#include "builtinsimpl.h" #include "fnLog.h" -#include "tudf.h" -#include "tudfInt.h" +#include "functionMgt.h" +#include "querynodes.h" #include "tarray.h" -#include "tglobal.h" #include "tdatablock.h" -#include "querynodes.h" -#include "builtinsimpl.h" -#include "functionMgt.h" +#include "tglobal.h" +#include "tudf.h" +#include "tudfInt.h" typedef struct SUdfdData { - bool startCalled; - bool needCleanUp; - uv_loop_t loop; - uv_thread_t thread; - uv_barrier_t barrier; - uv_process_t process; + bool startCalled; + bool needCleanUp; + uv_loop_t loop; + uv_thread_t thread; + uv_barrier_t barrier; + uv_process_t process; #ifdef WINDOWS - HANDLE jobHandle; + HANDLE jobHandle; #endif - int spawnErr; - uv_pipe_t ctrlPipe; - uv_async_t stopAsync; - int32_t stopCalled; + int spawnErr; + uv_pipe_t ctrlPipe; + uv_async_t stopAsync; + int32_t stopCalled; - int32_t dnodeId; + int32_t dnodeId; } SUdfdData; SUdfdData udfdGlobal = {0}; @@ -48,11 +50,11 @@ int32_t udfStartUdfd(int32_t startDnodeId); int32_t udfStopUdfd(); static int32_t udfSpawnUdfd(SUdfdData *pData); -void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal); -static int32_t udfSpawnUdfd(SUdfdData* pData); -static void udfUdfdCloseWalkCb(uv_handle_t* handle, void* arg); -static void udfUdfdStopAsyncCb(uv_async_t *async); -static void udfWatchUdfd(void *args); +void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal); +static int32_t udfSpawnUdfd(SUdfdData *pData); +static void udfUdfdCloseWalkCb(uv_handle_t *handle, void *arg); +static void udfUdfdStopAsyncCb(uv_async_t *async); +static void udfWatchUdfd(void *args); void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) { fnInfo("udfd process exited with status %" PRId64 ", signal %d", exitStatus, termSignal); @@ -65,27 +67,27 @@ void udfUdfdExit(uv_process_t *process, int64_t exitStatus, int termSignal) { } } -static int32_t udfSpawnUdfd(SUdfdData* pData) { +static int32_t udfSpawnUdfd(SUdfdData *pData) { fnInfo("start to init udfd"); uv_process_options_t options = {0}; char path[PATH_MAX] = {0}; if (tsProcPath == NULL) { path[0] = '.'; - #ifdef WINDOWS +#ifdef WINDOWS GetModuleFileName(NULL, path, PATH_MAX); taosDirName(path); - #elif defined(_TD_DARWIN_64) +#elif defined(_TD_DARWIN_64) uint32_t pathSize = sizeof(path); _NSGetExecutablePath(path, &pathSize); taosDirName(path); - #endif +#endif } else { strncpy(path, tsProcPath, PATH_MAX); taosDirName(path); } #ifdef WINDOWS - if (strlen(path)==0) { + if (strlen(path) == 0) { strcat(path, "udfd.exe"); } else { strcat(path, "\\udfd.exe"); @@ -93,7 +95,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { #else strcat(path, "/udfd"); #endif - char* argsUdfd[] = {path, "-c", configDir, NULL}; + char *argsUdfd[] = {path, "-c", configDir, NULL}; options.args = argsUdfd; options.file = path; @@ -103,7 +105,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { uv_stdio_container_t child_stdio[3]; child_stdio[0].flags = UV_CREATE_PIPE | UV_READABLE_PIPE; - child_stdio[0].data.stream = (uv_stream_t*) &pData->ctrlPipe; + child_stdio[0].data.stream = (uv_stream_t *)&pData->ctrlPipe; child_stdio[1].flags = UV_IGNORE; child_stdio[2].flags = UV_INHERIT_FD; child_stdio[2].data.fd = 2; @@ -117,12 +119,12 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { snprintf(dnodeIdEnvItem, 32, "%s=%d", "DNODE_ID", pData->dnodeId); float numCpuCores = 4; taosGetCpuCores(&numCpuCores); - snprintf(thrdPoolSizeEnvItem,32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores*2); - char* envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, NULL}; + snprintf(thrdPoolSizeEnvItem, 32, "%s=%d", "UV_THREADPOOL_SIZE", (int)numCpuCores * 2); + char *envUdfd[] = {dnodeIdEnvItem, thrdPoolSizeEnvItem, NULL}; options.env = envUdfd; int err = uv_spawn(&pData->loop, &pData->process, &options); - pData->process.data = (void*)pData; + pData->process.data = (void *)pData; #ifdef WINDOWS // End udfd.exe by Job. @@ -135,7 +137,8 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { JOBOBJECT_EXTENDED_LIMIT_INFORMATION limit_info; memset(&limit_info, 0x0, sizeof(limit_info)); limit_info.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; - bool set_auto_kill_ok = SetInformationJobObject(pData->jobHandle, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info)); + bool set_auto_kill_ok = + SetInformationJobObject(pData->jobHandle, JobObjectExtendedLimitInformation, &limit_info, sizeof(limit_info)); if (!set_auto_kill_ok) { fnError("Set job auto kill udfd failed."); } @@ -150,7 +153,7 @@ static int32_t udfSpawnUdfd(SUdfdData* pData) { return err; } -static void udfUdfdCloseWalkCb(uv_handle_t* handle, void* arg) { +static void udfUdfdCloseWalkCb(uv_handle_t *handle, void *arg) { if (!uv_is_closing(handle)) { uv_close(handle, NULL); } @@ -180,8 +183,7 @@ static void udfWatchUdfd(void *args) { int32_t udfStartUdfd(int32_t startDnodeId) { if (!tsStartUdfd) { - fnInfo("start udfd is disabled.") - return 0; + fnInfo("start udfd is disabled.") return 0; } SUdfdData *pData = &udfdGlobal; if (pData->startCalled) { @@ -212,8 +214,7 @@ int32_t udfStartUdfd(int32_t startDnodeId) { int32_t udfStopUdfd() { SUdfdData *pData = &udfdGlobal; - fnInfo("udfd start to stop, need cleanup:%d, spawn err:%d", - pData->needCleanUp, pData->spawnErr); + fnInfo("udfd start to stop, need cleanup:%d, spawn err:%d", pData->needCleanUp, pData->spawnErr); if (!pData->needCleanUp || atomic_load_32(&pData->stopCalled)) { return 0; } @@ -237,107 +238,91 @@ int32_t udfStopUdfd() { typedef void *QUEUE[2]; /* Private macros. */ -#define QUEUE_NEXT(q) (*(QUEUE **) &((*(q))[0])) -#define QUEUE_PREV(q) (*(QUEUE **) &((*(q))[1])) -#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) -#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) +#define QUEUE_NEXT(q) (*(QUEUE **)&((*(q))[0])) +#define QUEUE_PREV(q) (*(QUEUE **)&((*(q))[1])) +#define QUEUE_PREV_NEXT(q) (QUEUE_NEXT(QUEUE_PREV(q))) +#define QUEUE_NEXT_PREV(q) (QUEUE_PREV(QUEUE_NEXT(q))) /* Public macros. */ -#define QUEUE_DATA(ptr, type, field) \ - ((type *) ((char *) (ptr) - offsetof(type, field))) +#define QUEUE_DATA(ptr, type, field) ((type *)((char *)(ptr)-offsetof(type, field))) /* Important note: mutating the list while QUEUE_FOREACH is * iterating over its elements results in undefined behavior. */ -#define QUEUE_FOREACH(q, h) \ - for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) - -#define QUEUE_EMPTY(q) \ - ((const QUEUE *) (q) == (const QUEUE *) QUEUE_NEXT(q)) - -#define QUEUE_HEAD(q) \ - (QUEUE_NEXT(q)) - -#define QUEUE_INIT(q) \ - do { \ - QUEUE_NEXT(q) = (q); \ - QUEUE_PREV(q) = (q); \ - } \ - while (0) - -#define QUEUE_ADD(h, n) \ - do { \ - QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ - QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV(h) = QUEUE_PREV(n); \ - QUEUE_PREV_NEXT(h) = (h); \ - } \ - while (0) - -#define QUEUE_SPLIT(h, q, n) \ - do { \ - QUEUE_PREV(n) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(n) = (n); \ - QUEUE_NEXT(n) = (q); \ - QUEUE_PREV(h) = QUEUE_PREV(q); \ - QUEUE_PREV_NEXT(h) = (h); \ - QUEUE_PREV(q) = (n); \ - } \ - while (0) - -#define QUEUE_MOVE(h, n) \ - do { \ - if (QUEUE_EMPTY(h)) \ - QUEUE_INIT(n); \ - else { \ - QUEUE* q = QUEUE_HEAD(h); \ - QUEUE_SPLIT(h, q, n); \ - } \ - } \ - while (0) - -#define QUEUE_INSERT_HEAD(h, q) \ - do { \ - QUEUE_NEXT(q) = QUEUE_NEXT(h); \ - QUEUE_PREV(q) = (h); \ - QUEUE_NEXT_PREV(q) = (q); \ - QUEUE_NEXT(h) = (q); \ - } \ - while (0) - -#define QUEUE_INSERT_TAIL(h, q) \ - do { \ - QUEUE_NEXT(q) = (h); \ - QUEUE_PREV(q) = QUEUE_PREV(h); \ - QUEUE_PREV_NEXT(q) = (q); \ - QUEUE_PREV(h) = (q); \ - } \ - while (0) - -#define QUEUE_REMOVE(q) \ - do { \ - QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ - QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ - } \ - while (0) - - -enum { - UV_TASK_CONNECT = 0, - UV_TASK_REQ_RSP = 1, - UV_TASK_DISCONNECT = 2 -}; +#define QUEUE_FOREACH(q, h) for ((q) = QUEUE_NEXT(h); (q) != (h); (q) = QUEUE_NEXT(q)) + +#define QUEUE_EMPTY(q) ((const QUEUE *)(q) == (const QUEUE *)QUEUE_NEXT(q)) + +#define QUEUE_HEAD(q) (QUEUE_NEXT(q)) + +#define QUEUE_INIT(q) \ + do { \ + QUEUE_NEXT(q) = (q); \ + QUEUE_PREV(q) = (q); \ + } while (0) + +#define QUEUE_ADD(h, n) \ + do { \ + QUEUE_PREV_NEXT(h) = QUEUE_NEXT(n); \ + QUEUE_NEXT_PREV(n) = QUEUE_PREV(h); \ + QUEUE_PREV(h) = QUEUE_PREV(n); \ + QUEUE_PREV_NEXT(h) = (h); \ + } while (0) + +#define QUEUE_SPLIT(h, q, n) \ + do { \ + QUEUE_PREV(n) = QUEUE_PREV(h); \ + QUEUE_PREV_NEXT(n) = (n); \ + QUEUE_NEXT(n) = (q); \ + QUEUE_PREV(h) = QUEUE_PREV(q); \ + QUEUE_PREV_NEXT(h) = (h); \ + QUEUE_PREV(q) = (n); \ + } while (0) + +#define QUEUE_MOVE(h, n) \ + do { \ + if (QUEUE_EMPTY(h)) \ + QUEUE_INIT(n); \ + else { \ + QUEUE *q = QUEUE_HEAD(h); \ + QUEUE_SPLIT(h, q, n); \ + } \ + } while (0) + +#define QUEUE_INSERT_HEAD(h, q) \ + do { \ + QUEUE_NEXT(q) = QUEUE_NEXT(h); \ + QUEUE_PREV(q) = (h); \ + QUEUE_NEXT_PREV(q) = (q); \ + QUEUE_NEXT(h) = (q); \ + } while (0) + +#define QUEUE_INSERT_TAIL(h, q) \ + do { \ + QUEUE_NEXT(q) = (h); \ + QUEUE_PREV(q) = QUEUE_PREV(h); \ + QUEUE_PREV_NEXT(q) = (q); \ + QUEUE_PREV(h) = (q); \ + } while (0) + +#define QUEUE_REMOVE(q) \ + do { \ + QUEUE_PREV_NEXT(q) = QUEUE_NEXT(q); \ + QUEUE_NEXT_PREV(q) = QUEUE_PREV(q); \ + } while (0) + +enum { UV_TASK_CONNECT = 0, UV_TASK_REQ_RSP = 1, UV_TASK_DISCONNECT = 2 }; int64_t gUdfTaskSeqNum = 0; typedef struct SUdfcFuncStub { - char udfName[TSDB_FUNC_NAME_LEN]; + char udfName[TSDB_FUNC_NAME_LEN]; UdfcFuncHandle handle; - int32_t refCount; - int64_t lastRefTime; + int32_t refCount; + int64_t lastRefTime; } SUdfcFuncStub; typedef struct SUdfcProxy { - char udfdPipeName[PATH_MAX + UDF_LISTEN_PIPE_NAME_LEN + 2]; + char udfdPipeName[PATH_MAX + UDF_LISTEN_PIPE_NAME_LEN + 2]; uv_barrier_t initBarrier; uv_loop_t uvLoop; @@ -352,7 +337,7 @@ typedef struct SUdfcProxy { QUEUE uvProcTaskQueue; uv_mutex_t udfStubsMutex; - SArray* udfStubs; // SUdfcFuncStub + SArray *udfStubs; // SUdfcFuncStub int8_t initialized; } SUdfcProxy; @@ -361,8 +346,8 @@ SUdfcProxy gUdfdProxy = {0}; typedef struct SUdfcUvSession { SUdfcProxy *udfc; - int64_t severHandle; - uv_pipe_t *udfUvPipe; + int64_t severHandle; + uv_pipe_t *udfUvPipe; int8_t outputType; int32_t outputLen; @@ -373,12 +358,12 @@ typedef struct SUdfcUvSession { typedef struct SClientUvTaskNode { SUdfcProxy *udfc; - int8_t type; - int errCode; + int8_t type; + int errCode; uv_pipe_t *pipe; - int64_t seqNum; + int64_t seqNum; uv_buf_t reqBuf; uv_sem_t taskSem; @@ -398,15 +383,15 @@ typedef struct SClientUdfTask { union { struct { - SUdfSetupRequest req; + SUdfSetupRequest req; SUdfSetupResponse rsp; } _setup; struct { - SUdfCallRequest req; + SUdfCallRequest req; SUdfCallResponse rsp; } _call; struct { - SUdfTeardownRequest req; + SUdfTeardownRequest req; SUdfTeardownResponse rsp; } _teardown; }; @@ -414,55 +399,55 @@ typedef struct SClientUdfTask { } SClientUdfTask; typedef struct SClientConnBuf { - char *buf; + char *buf; int32_t len; int32_t cap; int32_t total; } SClientConnBuf; typedef struct SClientUvConn { - uv_pipe_t *pipe; - QUEUE taskQueue; - SClientConnBuf readBuf; + uv_pipe_t *pipe; + QUEUE taskQueue; + SClientConnBuf readBuf; SUdfcUvSession *session; } SClientUvConn; enum { - UDFC_STATE_INITAL = 0, // initial state - UDFC_STATE_STARTNG, // starting after udfcOpen - UDFC_STATE_READY, // started and begin to receive quests - UDFC_STATE_STOPPING, // stopping after udfcClose + UDFC_STATE_INITAL = 0, // initial state + UDFC_STATE_STARTNG, // starting after udfcOpen + UDFC_STATE_READY, // started and begin to receive quests + UDFC_STATE_STOPPING, // stopping after udfcClose }; -int32_t getUdfdPipeName(char* pipeName, int32_t size); +int32_t getUdfdPipeName(char *pipeName, int32_t size); int32_t encodeUdfSetupRequest(void **buf, const SUdfSetupRequest *setup); -void* decodeUdfSetupRequest(const void* buf, SUdfSetupRequest *request); -int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf* state); -void* decodeUdfInterBuf(const void* buf, SUdfInterBuf* state); +void *decodeUdfSetupRequest(const void *buf, SUdfSetupRequest *request); +int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf *state); +void *decodeUdfInterBuf(const void *buf, SUdfInterBuf *state); int32_t encodeUdfCallRequest(void **buf, const SUdfCallRequest *call); -void* decodeUdfCallRequest(const void* buf, SUdfCallRequest* call); +void *decodeUdfCallRequest(const void *buf, SUdfCallRequest *call); int32_t encodeUdfTeardownRequest(void **buf, const SUdfTeardownRequest *teardown); -void* decodeUdfTeardownRequest(const void* buf, SUdfTeardownRequest *teardown); -int32_t encodeUdfRequest(void** buf, const SUdfRequest* request); -void* decodeUdfRequest(const void* buf, SUdfRequest* request); +void *decodeUdfTeardownRequest(const void *buf, SUdfTeardownRequest *teardown); +int32_t encodeUdfRequest(void **buf, const SUdfRequest *request); +void *decodeUdfRequest(const void *buf, SUdfRequest *request); int32_t encodeUdfSetupResponse(void **buf, const SUdfSetupResponse *setupRsp); -void* decodeUdfSetupResponse(const void* buf, SUdfSetupResponse* setupRsp); +void *decodeUdfSetupResponse(const void *buf, SUdfSetupResponse *setupRsp); int32_t encodeUdfCallResponse(void **buf, const SUdfCallResponse *callRsp); -void* decodeUdfCallResponse(const void* buf, SUdfCallResponse* callRsp); -int32_t encodeUdfTeardownResponse(void** buf, const SUdfTeardownResponse* teardownRsp); -void* decodeUdfTeardownResponse(const void* buf, SUdfTeardownResponse* teardownResponse); -int32_t encodeUdfResponse(void** buf, const SUdfResponse* rsp); -void* decodeUdfResponse(const void* buf, SUdfResponse* rsp); -void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta); -void freeUdfColumn(SUdfColumn* col); -void freeUdfDataDataBlock(SUdfDataBlock *block); -void freeUdfInterBuf(SUdfInterBuf *buf); +void *decodeUdfCallResponse(const void *buf, SUdfCallResponse *callRsp); +int32_t encodeUdfTeardownResponse(void **buf, const SUdfTeardownResponse *teardownRsp); +void *decodeUdfTeardownResponse(const void *buf, SUdfTeardownResponse *teardownResponse); +int32_t encodeUdfResponse(void **buf, const SUdfResponse *rsp); +void *decodeUdfResponse(const void *buf, SUdfResponse *rsp); +void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta); +void freeUdfColumn(SUdfColumn *col); +void freeUdfDataDataBlock(SUdfDataBlock *block); +void freeUdfInterBuf(SUdfInterBuf *buf); int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlock); int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block); int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SSDataBlock *output); int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output); -int32_t getUdfdPipeName(char* pipeName, int32_t size) { +int32_t getUdfdPipeName(char *pipeName, int32_t size) { char dnodeId[8] = {0}; size_t dnodeIdSize = sizeof(dnodeId); int32_t err = uv_os_getenv(UDF_DNODE_ID_ENV_NAME, dnodeId, &dnodeIdSize); @@ -471,7 +456,8 @@ int32_t getUdfdPipeName(char* pipeName, int32_t size) { dnodeId[0] = '1'; } #ifdef _WIN32 - snprintf(pipeName, size, "%s.%x.%s", UDF_LISTEN_PIPE_NAME_PREFIX,MurmurHash3_32(tsDataDir, strlen(tsDataDir)), dnodeId); + snprintf(pipeName, size, "%s.%x.%s", UDF_LISTEN_PIPE_NAME_PREFIX, MurmurHash3_32(tsDataDir, strlen(tsDataDir)), + dnodeId); #else snprintf(pipeName, size, "%s/%s%s", tsDataDir, UDF_LISTEN_PIPE_NAME_PREFIX, dnodeId); #endif @@ -485,12 +471,12 @@ int32_t encodeUdfSetupRequest(void **buf, const SUdfSetupRequest *setup) { return len; } -void* decodeUdfSetupRequest(const void* buf, SUdfSetupRequest *request) { +void *decodeUdfSetupRequest(const void *buf, SUdfSetupRequest *request) { buf = taosDecodeBinaryTo(buf, request->udfName, TSDB_FUNC_NAME_LEN); - return (void*)buf; + return (void *)buf; } -int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf* state) { +int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf *state) { int32_t len = 0; len += taosEncodeFixedI8(buf, state->numOfResult); len += taosEncodeFixedI32(buf, state->bufLen); @@ -498,11 +484,11 @@ int32_t encodeUdfInterBuf(void **buf, const SUdfInterBuf* state) { return len; } -void* decodeUdfInterBuf(const void* buf, SUdfInterBuf* state) { +void *decodeUdfInterBuf(const void *buf, SUdfInterBuf *state) { buf = taosDecodeFixedI8(buf, &state->numOfResult); buf = taosDecodeFixedI32(buf, &state->bufLen); - buf = taosDecodeBinary(buf, (void**)&state->buf, state->bufLen); - return (void*)buf; + buf = taosDecodeBinary(buf, (void **)&state->buf, state->bufLen); + return (void *)buf; } int32_t encodeUdfCallRequest(void **buf, const SUdfCallRequest *call) { @@ -525,7 +511,7 @@ int32_t encodeUdfCallRequest(void **buf, const SUdfCallRequest *call) { return len; } -void* decodeUdfCallRequest(const void* buf, SUdfCallRequest* call) { +void *decodeUdfCallRequest(const void *buf, SUdfCallRequest *call) { buf = taosDecodeFixedI64(buf, &call->udfHandle); buf = taosDecodeFixedI8(buf, &call->callType); switch (call->callType) { @@ -547,7 +533,7 @@ void* decodeUdfCallRequest(const void* buf, SUdfCallRequest* call) { buf = decodeUdfInterBuf(buf, &call->interBuf); break; } - return (void*)buf; + return (void *)buf; } int32_t encodeUdfTeardownRequest(void **buf, const SUdfTeardownRequest *teardown) { @@ -556,17 +542,17 @@ int32_t encodeUdfTeardownRequest(void **buf, const SUdfTeardownRequest *teardown return len; } -void* decodeUdfTeardownRequest(const void* buf, SUdfTeardownRequest *teardown) { +void *decodeUdfTeardownRequest(const void *buf, SUdfTeardownRequest *teardown) { buf = taosDecodeFixedI64(buf, &teardown->udfHandle); - return (void*)buf; + return (void *)buf; } -int32_t encodeUdfRequest(void** buf, const SUdfRequest* request) { +int32_t encodeUdfRequest(void **buf, const SUdfRequest *request) { int32_t len = 0; if (buf == NULL) { len += sizeof(request->msgLen); } else { - *(int32_t*)(*buf) = request->msgLen; + *(int32_t *)(*buf) = request->msgLen; *buf = POINTER_SHIFT(*buf, sizeof(request->msgLen)); } len += taosEncodeFixedI64(buf, request->seqNum); @@ -581,8 +567,8 @@ int32_t encodeUdfRequest(void** buf, const SUdfRequest* request) { return len; } -void* decodeUdfRequest(const void* buf, SUdfRequest* request) { - request->msgLen = *(int32_t*)(buf); +void *decodeUdfRequest(const void *buf, SUdfRequest *request) { + request->msgLen = *(int32_t *)(buf); buf = POINTER_SHIFT(buf, sizeof(request->msgLen)); buf = taosDecodeFixedI64(buf, &request->seqNum); @@ -595,7 +581,7 @@ void* decodeUdfRequest(const void* buf, SUdfRequest* request) { } else if (request->type == UDF_TASK_TEARDOWN) { buf = decodeUdfTeardownRequest(buf, &request->teardown); } - return (void*)buf; + return (void *)buf; } int32_t encodeUdfSetupResponse(void **buf, const SUdfSetupResponse *setupRsp) { @@ -607,12 +593,12 @@ int32_t encodeUdfSetupResponse(void **buf, const SUdfSetupResponse *setupRsp) { return len; } -void* decodeUdfSetupResponse(const void* buf, SUdfSetupResponse* setupRsp) { +void *decodeUdfSetupResponse(const void *buf, SUdfSetupResponse *setupRsp) { buf = taosDecodeFixedI64(buf, &setupRsp->udfHandle); buf = taosDecodeFixedI8(buf, &setupRsp->outputType); buf = taosDecodeFixedI32(buf, &setupRsp->outputLen); buf = taosDecodeFixedI32(buf, &setupRsp->bufSize); - return (void*)buf; + return (void *)buf; } int32_t encodeUdfCallResponse(void **buf, const SUdfCallResponse *callRsp) { @@ -638,7 +624,7 @@ int32_t encodeUdfCallResponse(void **buf, const SUdfCallResponse *callRsp) { return len; } -void* decodeUdfCallResponse(const void* buf, SUdfCallResponse* callRsp) { +void *decodeUdfCallResponse(const void *buf, SUdfCallResponse *callRsp) { buf = taosDecodeFixedI8(buf, &callRsp->callType); switch (callRsp->callType) { case TSDB_UDF_CALL_SCALA_PROC: @@ -657,30 +643,26 @@ void* decodeUdfCallResponse(const void* buf, SUdfCallResponse* callRsp) { buf = decodeUdfInterBuf(buf, &callRsp->resultBuf); break; } - return (void*)buf; + return (void *)buf; } -int32_t encodeUdfTeardownResponse(void** buf, const SUdfTeardownResponse* teardownRsp) { - return 0; -} +int32_t encodeUdfTeardownResponse(void **buf, const SUdfTeardownResponse *teardownRsp) { return 0; } -void* decodeUdfTeardownResponse(const void* buf, SUdfTeardownResponse* teardownResponse) { - return (void*)buf; -} +void *decodeUdfTeardownResponse(const void *buf, SUdfTeardownResponse *teardownResponse) { return (void *)buf; } -int32_t encodeUdfResponse(void** buf, const SUdfResponse* rsp) { +int32_t encodeUdfResponse(void **buf, const SUdfResponse *rsp) { int32_t len = 0; if (buf == NULL) { len += sizeof(rsp->msgLen); } else { - *(int32_t*)(*buf) = rsp->msgLen; + *(int32_t *)(*buf) = rsp->msgLen; *buf = POINTER_SHIFT(*buf, sizeof(rsp->msgLen)); } if (buf == NULL) { len += sizeof(rsp->seqNum); } else { - *(int64_t*)(*buf) = rsp->seqNum; + *(int64_t *)(*buf) = rsp->seqNum; *buf = POINTER_SHIFT(*buf, sizeof(rsp->seqNum)); } @@ -705,10 +687,10 @@ int32_t encodeUdfResponse(void** buf, const SUdfResponse* rsp) { return len; } -void* decodeUdfResponse(const void* buf, SUdfResponse* rsp) { - rsp->msgLen = *(int32_t*)(buf); +void *decodeUdfResponse(const void *buf, SUdfResponse *rsp) { + rsp->msgLen = *(int32_t *)(buf); buf = POINTER_SHIFT(buf, sizeof(rsp->msgLen)); - rsp->seqNum = *(int64_t*)(buf); + rsp->seqNum = *(int64_t *)(buf); buf = POINTER_SHIFT(buf, sizeof(rsp->seqNum)); buf = taosDecodeFixedI64(buf, &rsp->seqNum); buf = taosDecodeFixedI8(buf, &rsp->type); @@ -728,7 +710,7 @@ void* decodeUdfResponse(const void* buf, SUdfResponse* rsp) { fnError("decode udf response, invalid udf response type %d", rsp->type); break; } - return (void*)buf; + return (void *)buf; } void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta) { @@ -745,9 +727,7 @@ void freeUdfColumnData(SUdfColumnData *data, SUdfColumnMeta *meta) { } } -void freeUdfColumn(SUdfColumn* col) { - freeUdfColumnData(&col->colData, &col->colMeta); -} +void freeUdfColumn(SUdfColumn *col) { freeUdfColumnData(&col->colData, &col->colMeta); } void freeUdfDataDataBlock(SUdfDataBlock *block) { for (int32_t i = 0; i < block->numOfCols; ++i) { @@ -764,15 +744,14 @@ void freeUdfInterBuf(SUdfInterBuf *buf) { buf->buf = NULL; } - int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlock) { udfBlock->numOfRows = block->info.rows; udfBlock->numOfCols = taosArrayGetSize(block->pDataBlock); - udfBlock->udfCols = taosMemoryCalloc(taosArrayGetSize(block->pDataBlock), sizeof(SUdfColumn*)); + udfBlock->udfCols = taosMemoryCalloc(taosArrayGetSize(block->pDataBlock), sizeof(SUdfColumn *)); for (int32_t i = 0; i < udfBlock->numOfCols; ++i) { udfBlock->udfCols[i] = taosMemoryCalloc(1, sizeof(SUdfColumn)); - SColumnInfoData *col= (SColumnInfoData*)taosArrayGet(block->pDataBlock, i); - SUdfColumn *udfCol = udfBlock->udfCols[i]; + SColumnInfoData *col = (SColumnInfoData *)taosArrayGet(block->pDataBlock, i); + SUdfColumn *udfCol = udfBlock->udfCols[i]; udfCol->colMeta.type = col->info.type; udfCol->colMeta.bytes = col->info.bytes; udfCol->colMeta.scale = col->info.scale; @@ -790,12 +769,12 @@ int32_t convertDataBlockToUdfDataBlock(SSDataBlock *block, SUdfDataBlock *udfBlo udfCol->colData.fixLenCol.nullBitmapLen = BitmapLen(udfCol->colData.numOfRows); int32_t bitmapLen = udfCol->colData.fixLenCol.nullBitmapLen; udfCol->colData.fixLenCol.nullBitmap = taosMemoryMalloc(udfCol->colData.fixLenCol.nullBitmapLen); - char* bitmap = udfCol->colData.fixLenCol.nullBitmap; + char *bitmap = udfCol->colData.fixLenCol.nullBitmap; memcpy(bitmap, col->nullbitmap, bitmapLen); udfCol->colData.fixLenCol.dataLen = colDataGetLength(col, udfBlock->numOfRows); int32_t dataLen = udfCol->colData.fixLenCol.dataLen; udfCol->colData.fixLenCol.data = taosMemoryMalloc(udfCol->colData.fixLenCol.dataLen); - char* data = udfCol->colData.fixLenCol.data; + char *data = udfCol->colData.fixLenCol.data; memcpy(data, col->pData, dataLen); } } @@ -809,7 +788,7 @@ int32_t convertUdfColumnToDataBlock(SUdfColumn *udfCol, SSDataBlock *block) { block->pDataBlock = taosArrayInit(1, sizeof(SColumnInfoData)); taosArraySetSize(block->pDataBlock, 1); SColumnInfoData *col = taosArrayGet(block->pDataBlock, 0); - SUdfColumnMeta *meta = &udfCol->colMeta; + SUdfColumnMeta *meta = &udfCol->colMeta; col->info.precision = meta->precision; col->info.bytes = meta->bytes; col->info.scale = meta->scale; @@ -837,7 +816,7 @@ int32_t convertScalarParamToDataBlock(SScalarParam *input, int32_t numOfCols, SS for (int32_t i = 0; i < numOfCols; ++i) { taosArrayPush(output->pDataBlock, (input + i)->columnData); - if (IS_VAR_DATA_TYPE((input+i)->columnData->info.type)) { + if (IS_VAR_DATA_TYPE((input + i)->columnData->info.type)) { output->info.hasVarCol = true; } } @@ -852,71 +831,70 @@ int32_t convertDataBlockToScalarParm(SSDataBlock *input, SScalarParam *output) { output->numOfRows = input->info.rows; output->columnData = taosMemoryMalloc(sizeof(SColumnInfoData)); - memcpy(output->columnData, - taosArrayGet(input->pDataBlock, 0), - sizeof(SColumnInfoData)); - output->colAlloced = true; + memcpy(output->columnData, taosArrayGet(input->pDataBlock, 0), sizeof(SColumnInfoData)); + output->colAlloced = true; return 0; } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// -//memory layout |---SUdfAggRes----|-----final result-----|---inter result----| +// memory layout |---SUdfAggRes----|-----final result-----|---inter result----| typedef struct SUdfAggRes { int8_t finalResNum; int8_t interResNum; - char* finalResBuf; - char* interResBuf; + char *finalResBuf; + char *interResBuf; } SUdfAggRes; -void onUdfcPipeClose(uv_handle_t *handle); +void onUdfcPipeClose(uv_handle_t *handle); int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode *uvTask); -void udfcAllocateBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf); -bool isUdfcUvMsgComplete(SClientConnBuf *connBuf); -void udfcUvHandleRsp(SClientUvConn *conn); -void udfcUvHandleError(SClientUvConn *conn); -void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf); -void onUdfcPipeWrite(uv_write_t *write, int status); -void onUdfcPipeConnect(uv_connect_t *connect, int status); +void udfcAllocateBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf); +bool isUdfcUvMsgComplete(SClientConnBuf *connBuf); +void udfcUvHandleRsp(SClientUvConn *conn); +void udfcUvHandleError(SClientUvConn *conn); +void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf); +void onUdfcPipeWrite(uv_write_t *write, int status); +void onUdfcPipeConnect(uv_connect_t *connect, int status); int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvTaskNode *uvTask); int32_t udfcQueueUvTask(SClientUvTaskNode *uvTask); int32_t udfcStartUvTask(SClientUvTaskNode *uvTask); -void udfcAsyncTaskCb(uv_async_t *async); -void cleanUpUvTasks(SUdfcProxy *udfc); -void udfStopAsyncCb(uv_async_t *async); -void constructUdfService(void *argsThread); +void udfcAsyncTaskCb(uv_async_t *async); +void cleanUpUvTasks(SUdfcProxy *udfc); +void udfStopAsyncCb(uv_async_t *async); +void constructUdfService(void *argsThread); int32_t udfcRunUdfUvTask(SClientUdfTask *task, int8_t uvTaskType); int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle); -int compareUdfcFuncSub(const void* elem1, const void* elem2); +int compareUdfcFuncSub(const void *elem1, const void *elem2); int32_t doTeardownUdf(UdfcFuncHandle handle); int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdfInterBuf *state, SUdfInterBuf *state2, - SSDataBlock* output, SUdfInterBuf *newState); + SSDataBlock *output, SUdfInterBuf *newState); int32_t doCallUdfAggInit(UdfcFuncHandle handle, SUdfInterBuf *interBuf); int32_t doCallUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInterBuf *state, SUdfInterBuf *newState); -int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf); +int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, + SUdfInterBuf *resultBuf); int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData); -int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam* output); +int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output); int32_t udfcOpen(); int32_t udfcClose(); -int32_t acquireUdfFuncHandle(char* udfName, UdfcFuncHandle* pHandle); -void releaseUdfFuncHandle(char* udfName); +int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle); +void releaseUdfFuncHandle(char *udfName); int32_t cleanUpUdfs(); -bool udfAggGetEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv); -bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo); +bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv); +bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo); int32_t udfAggProcess(struct SqlFunctionCtx *pCtx); -int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock); +int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock); -int compareUdfcFuncSub(const void* elem1, const void* elem2) { +int compareUdfcFuncSub(const void *elem1, const void *elem2) { SUdfcFuncStub *stub1 = (SUdfcFuncStub *)elem1; SUdfcFuncStub *stub2 = (SUdfcFuncStub *)elem2; return strcmp(stub1->udfName, stub2->udfName); } -int32_t acquireUdfFuncHandle(char* udfName, UdfcFuncHandle* pHandle) { +int32_t acquireUdfFuncHandle(char *udfName, UdfcFuncHandle *pHandle) { int32_t code = 0; uv_mutex_lock(&gUdfdProxy.udfStubsMutex); SUdfcFuncStub key = {0}; @@ -925,15 +903,15 @@ int32_t acquireUdfFuncHandle(char* udfName, UdfcFuncHandle* pHandle) { if (stubIndex != -1) { SUdfcFuncStub *foundStub = taosArrayGet(gUdfdProxy.udfStubs, stubIndex); UdfcFuncHandle handle = foundStub->handle; - if (handle != NULL && ((SUdfcUvSession*)handle)->udfUvPipe != NULL) { + if (handle != NULL && ((SUdfcUvSession *)handle)->udfUvPipe != NULL) { *pHandle = foundStub->handle; ++foundStub->refCount; foundStub->lastRefTime = taosGetTimestampUs(); uv_mutex_unlock(&gUdfdProxy.udfStubsMutex); return 0; } else { - fnInfo("invalid handle for %s, refCount: %d, last ref time: %"PRId64". remove it from cache", - udfName, foundStub->refCount, foundStub->lastRefTime); + fnInfo("invalid handle for %s, refCount: %d, last ref time: %" PRId64 ". remove it from cache", udfName, + foundStub->refCount, foundStub->lastRefTime); taosArrayRemove(gUdfdProxy.udfStubs, stubIndex); } } @@ -955,7 +933,7 @@ int32_t acquireUdfFuncHandle(char* udfName, UdfcFuncHandle* pHandle) { return code; } -void releaseUdfFuncHandle(char* udfName) { +void releaseUdfFuncHandle(char *udfName) { uv_mutex_lock(&gUdfdProxy.udfStubsMutex); SUdfcFuncStub key = {0}; strcpy(key.udfName, udfName); @@ -977,11 +955,11 @@ int32_t cleanUpUdfs() { } uv_mutex_lock(&gUdfdProxy.udfStubsMutex); - if (gUdfdProxy.udfStubs == NULL || taosArrayGetSize(gUdfdProxy.udfStubs) == 0) { + if (gUdfdProxy.udfStubs == NULL || taosArrayGetSize(gUdfdProxy.udfStubs) == 0) { uv_mutex_unlock(&gUdfdProxy.udfStubsMutex); return TSDB_CODE_SUCCESS; } - SArray* udfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub)); + SArray *udfStubs = taosArrayInit(16, sizeof(SUdfcFuncStub)); int32_t i = 0; while (i < taosArrayGetSize(gUdfdProxy.udfStubs)) { SUdfcFuncStub *stub = taosArrayGet(gUdfdProxy.udfStubs, i); @@ -989,13 +967,13 @@ int32_t cleanUpUdfs() { fnInfo("tear down udf. udf name: %s, handle: %p, ref count: %d", stub->udfName, stub->handle, stub->refCount); doTeardownUdf(stub->handle); } else { - fnInfo("udf still in use. udf name: %s, ref count: %d, last ref time: %"PRId64", handle: %p", - stub->udfName, stub->refCount, stub->lastRefTime, stub->handle); + fnInfo("udf still in use. udf name: %s, ref count: %d, last ref time: %" PRId64 ", handle: %p", stub->udfName, + stub->refCount, stub->lastRefTime, stub->handle); UdfcFuncHandle handle = stub->handle; - if (handle != NULL && ((SUdfcUvSession*)handle)->udfUvPipe != NULL) { + if (handle != NULL && ((SUdfcUvSession *)handle)->udfUvPipe != NULL) { taosArrayPush(udfStubs, stub); } else { - fnInfo("udf invalid handle for %s, refCount: %d, last ref time: %"PRId64". remove it from cache", + fnInfo("udf invalid handle for %s, refCount: %d, last ref time: %" PRId64 ". remove it from cache", stub->udfName, stub->refCount, stub->lastRefTime); } } @@ -1009,7 +987,7 @@ int32_t cleanUpUdfs() { int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, SScalarParam *output) { UdfcFuncHandle handle = NULL; - int32_t code = acquireUdfFuncHandle(udfName, &handle); + int32_t code = acquireUdfFuncHandle(udfName, &handle); if (code != 0) { return code; } @@ -1020,8 +998,8 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, code = TSDB_CODE_UDF_INVALID_OUTPUT_TYPE; } else { if (session->outputType != output->columnData->info.type || session->outputLen != output->columnData->info.bytes) { - fnError("udfc scalar function calculate error. type mismatch. session type: %d(%d), output type: %d(%d)", session->outputType, - session->outputLen, output->columnData->info.type, output->columnData->info.bytes); + fnError("udfc scalar function calculate error. type mismatch. session type: %d(%d), output type: %d(%d)", + session->outputType, session->outputLen, output->columnData->info.type, output->columnData->info.bytes); code = TSDB_CODE_UDF_INVALID_OUTPUT_TYPE; } } @@ -1029,7 +1007,7 @@ int32_t callUdfScalarFunc(char *udfName, SScalarParam *input, int32_t numOfCols, return code; } -bool udfAggGetEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { +bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv) { if (fmIsScalarFunc(pFunc->funcId)) { return false; } @@ -1037,23 +1015,23 @@ bool udfAggGetEnv(struct SFunctionNode* pFunc, SFuncExecEnv* pEnv) { return true; } -bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResultCellInfo) { +bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo) { if (functionSetup(pCtx, pResultCellInfo) != true) { return false; } UdfcFuncHandle handle; - int32_t udfCode = 0; + int32_t udfCode = 0; if ((udfCode = acquireUdfFuncHandle((char *)pCtx->udfName, &handle)) != 0) { fnError("udfAggInit error. step doSetupUdf. udf code: %d", udfCode); return false; } SUdfcUvSession *session = (SUdfcUvSession *)handle; - SUdfAggRes *udfRes = (SUdfAggRes*)GET_ROWCELL_INTERBUF(pResultCellInfo); - int32_t envSize = sizeof(SUdfAggRes) + session->outputLen + session->bufSize; + SUdfAggRes *udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(pResultCellInfo); + int32_t envSize = sizeof(SUdfAggRes) + session->outputLen + session->bufSize; memset(udfRes, 0, envSize); - udfRes->finalResBuf = (char*)udfRes + sizeof(SUdfAggRes); - udfRes->interResBuf = (char*)udfRes + sizeof(SUdfAggRes) + session->outputLen; + udfRes->finalResBuf = (char *)udfRes + sizeof(SUdfAggRes); + udfRes->interResBuf = (char *)udfRes + sizeof(SUdfAggRes) + session->outputLen; SUdfInterBuf buf = {0}; if ((udfCode = doCallUdfAggInit(handle, &buf)) != 0) { @@ -1075,7 +1053,7 @@ bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo* pResult } int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { - int32_t udfCode = 0; + int32_t udfCode = 0; UdfcFuncHandle handle = 0; if ((udfCode = acquireUdfFuncHandle((char *)pCtx->udfName, &handle)) != 0) { fnError("udfAggProcess error. step acquireUdfFuncHandle. udf code: %d", udfCode); @@ -1083,16 +1061,16 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { } SUdfcUvSession *session = handle; - SUdfAggRes* udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - udfRes->finalResBuf = (char*)udfRes + sizeof(SUdfAggRes); - udfRes->interResBuf = (char*)udfRes + sizeof(SUdfAggRes) + session->outputLen; + SUdfAggRes *udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + udfRes->finalResBuf = (char *)udfRes + sizeof(SUdfAggRes); + udfRes->interResBuf = (char *)udfRes + sizeof(SUdfAggRes) + session->outputLen; - SInputColumnInfoData* pInput = &pCtx->input; - int32_t numOfCols = pInput->numOfInputCols; - int32_t start = pInput->startRowIndex; - int32_t numOfRows = pInput->numOfRows; + SInputColumnInfoData *pInput = &pCtx->input; + int32_t numOfCols = pInput->numOfInputCols; + int32_t start = pInput->startRowIndex; + int32_t numOfRows = pInput->numOfRows; - SSDataBlock* pTempBlock = createDataBlock(); + SSDataBlock *pTempBlock = createDataBlock(); pTempBlock->info.rows = pInput->totalRows; pTempBlock->info.uid = pInput->uid; for (int32_t i = 0; i < numOfCols; ++i) { @@ -1101,9 +1079,7 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { SSDataBlock *inputBlock = blockDataExtractBlock(pTempBlock, start, numOfRows); - SUdfInterBuf state = {.buf = udfRes->interResBuf, - .bufLen = session->bufSize, - .numOfResult = udfRes->interResNum}; + SUdfInterBuf state = {.buf = udfRes->interResBuf, .bufLen = session->bufSize, .numOfResult = udfRes->interResNum}; SUdfInterBuf newState = {0}; udfCode = doCallUdfAggProcess(session, inputBlock, &state, &newState); @@ -1133,8 +1109,8 @@ int32_t udfAggProcess(struct SqlFunctionCtx *pCtx) { return udfCode; } -int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) { - int32_t udfCode = 0; +int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock) { + int32_t udfCode = 0; UdfcFuncHandle handle = 0; if ((udfCode = acquireUdfFuncHandle((char *)pCtx->udfName, &handle)) != 0) { fnError("udfAggProcess error. step acquireUdfFuncHandle. udf code: %d", udfCode); @@ -1142,17 +1118,14 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) { } SUdfcUvSession *session = handle; - SUdfAggRes* udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); - udfRes->finalResBuf = (char*)udfRes + sizeof(SUdfAggRes); - udfRes->interResBuf = (char*)udfRes + sizeof(SUdfAggRes) + session->outputLen; - + SUdfAggRes *udfRes = (SUdfAggRes *)GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); + udfRes->finalResBuf = (char *)udfRes + sizeof(SUdfAggRes); + udfRes->interResBuf = (char *)udfRes + sizeof(SUdfAggRes) + session->outputLen; SUdfInterBuf resultBuf = {0}; - SUdfInterBuf state = {.buf = udfRes->interResBuf, - .bufLen = session->bufSize, - .numOfResult = udfRes->interResNum}; - int32_t udfCallCode= 0; - udfCallCode= doCallUdfAggFinalize(session, &state, &resultBuf); + SUdfInterBuf state = {.buf = udfRes->interResBuf, .bufLen = session->bufSize, .numOfResult = udfRes->interResNum}; + int32_t udfCallCode = 0; + udfCallCode = doCallUdfAggFinalize(session, &state, &resultBuf); if (udfCallCode != 0) { fnError("udfAggFinalize error. doCallUdfAggFinalize step. udf code:%d", udfCallCode); GET_RES_INFO(pCtx)->numOfRes = 0; @@ -1178,7 +1151,7 @@ int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock* pBlock) { void onUdfcPipeClose(uv_handle_t *handle) { SClientUvConn *conn = handle->data; if (!QUEUE_EMPTY(&conn->taskQueue)) { - QUEUE* h = QUEUE_HEAD(&conn->taskQueue); + QUEUE *h = QUEUE_HEAD(&conn->taskQueue); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, connTaskQueue); task->errCode = 0; QUEUE_REMOVE(&task->procTaskQueue); @@ -1189,7 +1162,7 @@ void onUdfcPipeClose(uv_handle_t *handle) { } taosMemoryFree(conn->readBuf.buf); taosMemoryFree(conn); - taosMemoryFree((uv_pipe_t *) handle); + taosMemoryFree((uv_pipe_t *)handle); } int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode *uvTask) { @@ -1197,7 +1170,7 @@ int32_t udfcGetUdfTaskResultFromUvTask(SClientUdfTask *task, SClientUvTaskNode * if (uvTask->type == UV_TASK_REQ_RSP) { if (uvTask->rspBuf.base != NULL) { SUdfResponse rsp = {0}; - void* buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp); + void *buf = decodeUdfResponse(uvTask->rspBuf.base, &rsp); assert(uvTask->rspBuf.len == POINTER_DISTANCE(buf, uvTask->rspBuf.base)); task->errCode = rsp.code; @@ -1273,7 +1246,7 @@ void udfcAllocateBuffer(uv_handle_t *handle, size_t suggestedSize, uv_buf_t *buf bool isUdfcUvMsgComplete(SClientConnBuf *connBuf) { if (connBuf->total == -1 && connBuf->len >= sizeof(int32_t)) { - connBuf->total = *(int32_t *) (connBuf->buf); + connBuf->total = *(int32_t *)(connBuf->buf); } if (connBuf->len == connBuf->cap && connBuf->total == connBuf->cap) { fnDebug("udfc complete message is received, now handle it"); @@ -1284,15 +1257,15 @@ bool isUdfcUvMsgComplete(SClientConnBuf *connBuf) { void udfcUvHandleRsp(SClientUvConn *conn) { SClientConnBuf *connBuf = &conn->readBuf; - int64_t seqNum = *(int64_t *) (connBuf->buf + sizeof(int32_t)); // msglen then seqnum + int64_t seqNum = *(int64_t *)(connBuf->buf + sizeof(int32_t)); // msglen then seqnum if (QUEUE_EMPTY(&conn->taskQueue)) { - fnError("udfc no task waiting on connection. response seqnum:%"PRId64, seqNum); + fnError("udfc no task waiting on connection. response seqnum:%" PRId64, seqNum); return; } - bool found = false; + bool found = false; SClientUvTaskNode *taskFound = NULL; - QUEUE* h = QUEUE_NEXT(&conn->taskQueue); + QUEUE *h = QUEUE_NEXT(&conn->taskQueue); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, connTaskQueue); while (h != &conn->taskQueue) { @@ -1327,7 +1300,7 @@ void udfcUvHandleRsp(SClientUvConn *conn) { void udfcUvHandleError(SClientUvConn *conn) { fnDebug("handle error on conn: %p, pipe: %p", conn, conn->pipe); while (!QUEUE_EMPTY(&conn->taskQueue)) { - QUEUE* h = QUEUE_HEAD(&conn->taskQueue); + QUEUE *h = QUEUE_HEAD(&conn->taskQueue); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, connTaskQueue); task->errCode = TSDB_CODE_UDF_PIPE_READ_ERR; QUEUE_REMOVE(&task->connTaskQueue); @@ -1335,14 +1308,14 @@ void udfcUvHandleError(SClientUvConn *conn) { uv_sem_post(&task->taskSem); } - uv_close((uv_handle_t *) conn->pipe, onUdfcPipeClose); + uv_close((uv_handle_t *)conn->pipe, onUdfcPipeClose); } void onUdfcPipeRead(uv_stream_t *client, ssize_t nread, const uv_buf_t *buf) { fnDebug("udfc client %p, client read from pipe. nread: %zd", client, nread); if (nread == 0) return; - SClientUvConn *conn = client->data; + SClientUvConn *conn = client->data; SClientConnBuf *connBuf = &conn->readBuf; if (nread > 0) { connBuf->len += nread; @@ -1373,7 +1346,7 @@ void onUdfcPipeWrite(uv_write_t *write, int status) { void onUdfcPipeConnect(uv_connect_t *connect, int status) { SClientUvTaskNode *uvTask = connect->data; if (status != 0) { - fnError("client connect error, task seq: %"PRId64", code: %s", uvTask->seqNum, uv_strerror(status)); + fnError("client connect error, task seq: %" PRId64 ", code: %s", uvTask->seqNum, uv_strerror(status)); } uvTask->errCode = status; @@ -1392,7 +1365,7 @@ int32_t udfcInitializeUvTask(SClientUdfTask *task, int8_t uvTaskType, SClientUvT uvTask->pipe = task->session->udfUvPipe; SUdfRequest request; request.type = task->type; - request.seqNum = atomic_fetch_add_64(&gUdfTaskSeqNum, 1); + request.seqNum = atomic_fetch_add_64(&gUdfTaskSeqNum, 1); if (task->type == UDF_TASK_SETUP) { request.setup = task->_setup.req; @@ -1430,14 +1403,14 @@ int32_t udfcQueueUvTask(SClientUvTaskNode *uvTask) { uv_async_send(&udfc->loopTaskAync); uv_sem_wait(&uvTask->taskSem); - fnInfo("udfc uvTask finished. uvTask:%"PRId64"-%d-%p", uvTask->seqNum, uvTask->type, uvTask); + fnInfo("udfc uvTask finished. uvTask:%" PRId64 "-%d-%p", uvTask->seqNum, uvTask->type, uvTask); uv_sem_destroy(&uvTask->taskSem); return 0; } int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { - fnDebug("event loop start uv task. uvTask: %"PRId64"-%d-%p", uvTask->seqNum, uvTask->type, uvTask); + fnDebug("event loop start uv task. uvTask: %" PRId64 "-%d-%p", uvTask->seqNum, uvTask->type, uvTask); int32_t code = 0; switch (uvTask->type) { @@ -1469,7 +1442,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { } else { uv_write_t *write = taosMemoryMalloc(sizeof(uv_write_t)); write->data = pipe->data; - QUEUE* connTaskQueue = &((SClientUvConn*)pipe->data)->taskQueue; + QUEUE *connTaskQueue = &((SClientUvConn *)pipe->data)->taskQueue; QUEUE_INSERT_TAIL(connTaskQueue, &uvTask->connTaskQueue); int err = uv_write(write, (uv_stream_t *)pipe, &uvTask->reqBuf, 1, onUdfcPipeWrite); if (err != 0) { @@ -1492,8 +1465,7 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { break; } default: { - fnError("udfc event loop unknown task type.") - break; + fnError("udfc event loop unknown task type.") break; } } @@ -1502,17 +1474,17 @@ int32_t udfcStartUvTask(SClientUvTaskNode *uvTask) { void udfcAsyncTaskCb(uv_async_t *async) { SUdfcProxy *udfc = async->data; - QUEUE wq; + QUEUE wq; uv_mutex_lock(&udfc->taskQueueMutex); QUEUE_MOVE(&udfc->taskQueue, &wq); uv_mutex_unlock(&udfc->taskQueueMutex); while (!QUEUE_EMPTY(&wq)) { - QUEUE* h = QUEUE_HEAD(&wq); + QUEUE *h = QUEUE_HEAD(&wq); QUEUE_REMOVE(h); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, recvTaskQueue); - int32_t code = udfcStartUvTask(task); + int32_t code = udfcStartUvTask(task); if (code == 0) { QUEUE_INSERT_TAIL(&udfc->uvProcTaskQueue, &task->procTaskQueue); } else { @@ -1520,19 +1492,17 @@ void udfcAsyncTaskCb(uv_async_t *async) { uv_sem_post(&task->taskSem); } } - } void cleanUpUvTasks(SUdfcProxy *udfc) { - fnDebug("clean up uv tasks") - QUEUE wq; + fnDebug("clean up uv tasks") QUEUE wq; uv_mutex_lock(&udfc->taskQueueMutex); QUEUE_MOVE(&udfc->taskQueue, &wq); uv_mutex_unlock(&udfc->taskQueueMutex); while (!QUEUE_EMPTY(&wq)) { - QUEUE* h = QUEUE_HEAD(&wq); + QUEUE *h = QUEUE_HEAD(&wq); QUEUE_REMOVE(h); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, recvTaskQueue); if (udfc->udfcState == UDFC_STATE_STOPPING) { @@ -1542,7 +1512,7 @@ void cleanUpUvTasks(SUdfcProxy *udfc) { } while (!QUEUE_EMPTY(&udfc->uvProcTaskQueue)) { - QUEUE* h = QUEUE_HEAD(&udfc->uvProcTaskQueue); + QUEUE *h = QUEUE_HEAD(&udfc->uvProcTaskQueue); QUEUE_REMOVE(h); SClientUvTaskNode *task = QUEUE_DATA(h, SClientUvTaskNode, procTaskQueue); if (udfc->udfcState == UDFC_STATE_STOPPING) { @@ -1572,7 +1542,7 @@ void constructUdfService(void *argsThread) { QUEUE_INIT(&udfc->taskQueue); QUEUE_INIT(&udfc->uvProcTaskQueue); uv_barrier_wait(&udfc->initBarrier); - //TODO return value of uv_run + // TODO return value of uv_run uv_run(&udfc->uvLoop, UV_RUN_DEFAULT); uv_loop_close(&udfc->uvLoop); @@ -1596,8 +1566,7 @@ int32_t udfcOpen() { uv_barrier_wait(&proxy->initBarrier); uv_mutex_init(&proxy->udfStubsMutex); proxy->udfStubs = taosArrayInit(8, sizeof(SUdfcFuncStub)); - fnInfo("udfc initialized") - return 0; + fnInfo("udfc initialized") return 0; } int32_t udfcClose() { @@ -1644,7 +1613,7 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { if (gUdfdProxy.udfcState != UDFC_STATE_READY) { return TSDB_CODE_UDF_INVALID_STATE; } - SClientUdfTask *task = taosMemoryCalloc(1,sizeof(SClientUdfTask)); + SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask)); task->errCode = 0; task->session = taosMemoryCalloc(1, sizeof(SUdfcUvSession)); task->session->udfc = &gUdfdProxy; @@ -1681,16 +1650,16 @@ int32_t doSetupUdf(char udfName[], UdfcFuncHandle *funcHandle) { } int32_t callUdf(UdfcFuncHandle handle, int8_t callType, SSDataBlock *input, SUdfInterBuf *state, SUdfInterBuf *state2, - SSDataBlock* output, SUdfInterBuf *newState) { + SSDataBlock *output, SUdfInterBuf *newState) { fnDebug("udfc call udf. callType: %d, funcHandle: %p", callType, handle); - SUdfcUvSession *session = (SUdfcUvSession *) handle; + SUdfcUvSession *session = (SUdfcUvSession *)handle; if (session->udfUvPipe == NULL) { fnError("No pipe to udfd"); return TSDB_CODE_UDF_PIPE_NO_PIPE; } SClientUdfTask *task = taosMemoryCalloc(1, sizeof(SClientUdfTask)); task->errCode = 0; - task->session = (SUdfcUvSession *) handle; + task->session = (SUdfcUvSession *)handle; task->type = UDF_TASK_CALL; SUdfCallRequest *req = &task->_call.req; @@ -1767,15 +1736,16 @@ int32_t doCallUdfAggInit(UdfcFuncHandle handle, SUdfInterBuf *interBuf) { // input: block, state // output: interbuf, int32_t doCallUdfAggProcess(UdfcFuncHandle handle, SSDataBlock *block, SUdfInterBuf *state, SUdfInterBuf *newState) { - int8_t callType = TSDB_UDF_CALL_AGG_PROC; + int8_t callType = TSDB_UDF_CALL_AGG_PROC; int32_t err = callUdf(handle, callType, block, state, NULL, NULL, newState); return err; } // input: interbuf1, interbuf2 // output: resultBuf -int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, SUdfInterBuf *resultBuf) { - int8_t callType = TSDB_UDF_CALL_AGG_MERGE; +int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfInterBuf *interBuf2, + SUdfInterBuf *resultBuf) { + int8_t callType = TSDB_UDF_CALL_AGG_MERGE; int32_t err = callUdf(handle, callType, NULL, interBuf1, interBuf2, NULL, resultBuf); return err; } @@ -1783,17 +1753,17 @@ int32_t doCallUdfAggMerge(UdfcFuncHandle handle, SUdfInterBuf *interBuf1, SUdfIn // input: interBuf // output: resultData int32_t doCallUdfAggFinalize(UdfcFuncHandle handle, SUdfInterBuf *interBuf, SUdfInterBuf *resultData) { - int8_t callType = TSDB_UDF_CALL_AGG_FIN; + int8_t callType = TSDB_UDF_CALL_AGG_FIN; int32_t err = callUdf(handle, callType, NULL, interBuf, NULL, NULL, resultData); return err; } -int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam* output) { - int8_t callType = TSDB_UDF_CALL_SCALA_PROC; +int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t numOfCols, SScalarParam *output) { + int8_t callType = TSDB_UDF_CALL_SCALA_PROC; SSDataBlock inputBlock = {0}; convertScalarParamToDataBlock(input, numOfCols, &inputBlock); SSDataBlock resultBlock = {0}; - int32_t err = callUdf(handle, callType, &inputBlock, NULL, NULL, &resultBlock, NULL); + int32_t err = callUdf(handle, callType, &inputBlock, NULL, NULL, &resultBlock, NULL); if (err == 0) { convertDataBlockToScalarParm(&resultBlock, output); taosArrayDestroy(resultBlock.pDataBlock); @@ -1804,7 +1774,7 @@ int32_t doCallUdfScalarFunc(UdfcFuncHandle handle, SScalarParam *input, int32_t } int32_t doTeardownUdf(UdfcFuncHandle handle) { - SUdfcUvSession *session = (SUdfcUvSession *) handle; + SUdfcUvSession *session = (SUdfcUvSession *)handle; if (session->udfUvPipe == NULL) { fnError("tear down udf. pipe to udfd does not exist. udf name: %s", session->udfName); @@ -1827,7 +1797,7 @@ 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 + // 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; diff --git a/source/libs/function/src/udfd.c b/source/libs/function/src/udfd.c index 14e358ea005c161b9281a0d8c14530f7cf600b79..a319b5a25b3bd168f7b52e365bf1b3ada8848077 100644 --- a/source/libs/function/src/udfd.c +++ b/source/libs/function/src/udfd.c @@ -657,7 +657,8 @@ int32_t udfdOpenClientRpc() { rpcInit.user = TSDB_DEFAULT_USER; rpcInit.parent = &global; rpcInit.rfp = udfdRpcRfp; - + rpcInit.compressSize = tsCompressMsgSize; + global.clientRpc = rpcOpen(&rpcInit); if (global.clientRpc == NULL) { fnError("failed to init dnode rpc client"); diff --git a/source/libs/function/test/runUdf.c b/source/libs/function/test/runUdf.c index 7395f1e14cfba22e497e8bc760a5883bbc4e11cd..f1e3f4c60c281ebac963ac65c7d7d9f8437652cd 100644 --- a/source/libs/function/test/runUdf.c +++ b/source/libs/function/test/runUdf.c @@ -53,7 +53,7 @@ int scalarFuncTest() { blockDataEnsureCapacity(pBlock, 1024); pBlock->info.rows = 1024; - SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, 0); + SColumnInfoData *pCol = taosArrayGet(pBlock->pDataBlock, 0); for (int32_t j = 0; j < pBlock->info.rows; ++j) { colDataAppendInt32(pCol, j, &j); } @@ -68,14 +68,13 @@ int scalarFuncTest() { SColumnInfoData *col = output.columnData; for (int32_t i = 0; i < output.numOfRows; ++i) { - if (i % 100 == 0) - fprintf(stderr, "%d\t%d\n", i, *(int32_t *)(col->pData + i * sizeof(int32_t))); + if (i % 100 == 0) fprintf(stderr, "%d\t%d\n", i, *(int32_t *)(col->pData + i * sizeof(int32_t))); } colDataDestroy(output.columnData); taosMemoryFree(output.columnData); } int64_t end = taosGetTimestampUs(); - fprintf(stderr, "time: %f\n", (end-beg)/1000.0); + fprintf(stderr, "time: %f\n", (end - beg) / 1000.0); doTeardownUdf(handle); return 0; @@ -92,13 +91,13 @@ int aggregateFuncTest() { SSDataBlock *pBlock = createDataBlock(); for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); ++i) { SColumnInfoData colInfo = createColumnInfoData(TSDB_DATA_TYPE_INT, sizeof(int32_t), 1); - blockDataAppendColInfo(pBlock, &colInfo); + blockDataAppendColInfo(pBlock, &colInfo); } blockDataEnsureCapacity(pBlock, 1024); pBlock->info.rows = 1024; - SColumnInfoData* pColInfo = bdGetColumnInfoData(pBlock, 0); + SColumnInfoData *pColInfo = bdGetColumnInfoData(pBlock, 0); for (int32_t j = 0; j < pBlock->info.rows; ++j) { colDataAppendInt32(pColInfo, j, &j); } @@ -111,7 +110,7 @@ int aggregateFuncTest() { taosArrayDestroy(pBlock->pDataBlock); doCallUdfAggFinalize(handle, &newBuf, &resultBuf); - fprintf(stderr, "agg result: %f\n", *(double*)resultBuf.buf); + fprintf(stderr, "agg result: %f\n", *(double *)resultBuf.buf); freeUdfInterBuf(&buf); freeUdfInterBuf(&newBuf); diff --git a/source/libs/function/test/udf1.c b/source/libs/function/test/udf1.c index 5be18af553498bf2b05607b69223c302d3826fae..71d30b67557847dcdf451cefb20c7b144d214cf8 100644 --- a/source/libs/function/test/udf1.c +++ b/source/libs/function/test/udf1.c @@ -1,6 +1,6 @@ -#include -#include #include +#include +#include #ifdef LINUX #include #endif @@ -9,16 +9,11 @@ #endif #include "taosudf.h" +DLL_EXPORT int32_t udf1_init() { return 0; } -DLL_EXPORT int32_t udf1_init() { - return 0; -} - -DLL_EXPORT int32_t udf1_destroy() { - return 0; -} +DLL_EXPORT int32_t udf1_destroy() { return 0; } -DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) { +DLL_EXPORT int32_t udf1(SUdfDataBlock *block, SUdfColumn *resultCol) { SUdfColumnMeta *meta = &resultCol->colMeta; meta->bytes = 4; meta->type = TSDB_DATA_TYPE_INT; @@ -35,14 +30,14 @@ DLL_EXPORT int32_t udf1(SUdfDataBlock* block, SUdfColumn *resultCol) { break; } } - if ( j == block->numOfCols) { + if (j == block->numOfCols) { int32_t luckyNum = 88; udfColDataSet(resultCol, i, (char *)&luckyNum, false); } } - //to simulate actual processing delay by udf + // to simulate actual processing delay by udf #ifdef LINUX - usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second) + usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second) #endif #ifdef WINDOWS Sleep(1); diff --git a/source/libs/function/test/udf2.c b/source/libs/function/test/udf2.c index 975832209eb6ec8e28967c54faf551b359ded455..e24789d0fb4095f2fdc75d8d1ce3e8dc1355e4c6 100644 --- a/source/libs/function/test/udf2.c +++ b/source/libs/function/test/udf2.c @@ -1,32 +1,27 @@ -#include -#include -#include #include +#include +#include +#include #include "taosudf.h" -DLL_EXPORT int32_t udf2_init() { - return 0; -} +DLL_EXPORT int32_t udf2_init() { return 0; } -DLL_EXPORT int32_t udf2_destroy() { - return 0; -} +DLL_EXPORT int32_t udf2_destroy() { return 0; } -DLL_EXPORT int32_t udf2_start(SUdfInterBuf *buf) { +DLL_EXPORT int32_t udf2_start(SUdfInterBuf* buf) { *(int64_t*)(buf->buf) = 0; buf->bufLen = sizeof(double); buf->numOfResult = 0; return 0; } -DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterBuf *newInterBuf) { +DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf* interBuf, SUdfInterBuf* newInterBuf) { double sumSquares = *(double*)interBuf->buf; int8_t numNotNull = 0; for (int32_t i = 0; i < block->numOfCols; ++i) { SUdfColumn* col = block->udfCols[i]; - if (!(col->colMeta.type == TSDB_DATA_TYPE_INT || - col->colMeta.type == TSDB_DATA_TYPE_DOUBLE)) { + if (!(col->colMeta.type == TSDB_DATA_TYPE_INT || col->colMeta.type == TSDB_DATA_TYPE_DOUBLE)) { return TSDB_CODE_UDF_INVALID_INPUT; } } @@ -38,18 +33,18 @@ DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterB } switch (col->colMeta.type) { case TSDB_DATA_TYPE_INT: { - char* cell = udfColDataGetData(col, j); + char* cell = udfColDataGetData(col, j); int32_t num = *(int32_t*)cell; sumSquares += (double)num * num; break; } case TSDB_DATA_TYPE_DOUBLE: { - char* cell = udfColDataGetData(col, j); + char* cell = udfColDataGetData(col, j); double num = *(double*)cell; sumSquares += num * num; break; } - default: + default: break; } ++numNotNull; @@ -67,7 +62,7 @@ DLL_EXPORT int32_t udf2(SUdfDataBlock* block, SUdfInterBuf *interBuf, SUdfInterB return 0; } -DLL_EXPORT int32_t udf2_finish(SUdfInterBuf* buf, SUdfInterBuf *resultData) { +DLL_EXPORT int32_t udf2_finish(SUdfInterBuf* buf, SUdfInterBuf* resultData) { if (buf->numOfResult == 0) { resultData->numOfResult = 0; return 0; diff --git a/source/libs/index/test/index_executor_tests.cpp b/source/libs/index/test/index_executor_tests.cpp index a0ac79a2976243a2097f3e4290951322b2b65f9a..8b03f3b251da4ae8698bf976753f6f7e3a86ab96 100644 --- a/source/libs/index/test/index_executor_tests.cpp +++ b/source/libs/index/test/index_executor_tests.cpp @@ -48,7 +48,7 @@ double sifLeftVd = 21.0, sifRightVd = 10.0; void sifFreeDataBlock(void *block) { blockDataDestroy(*(SSDataBlock **)block); } void sifInitLogFile() { - const char * defaultLogFileNamePrefix = "taoslog"; + const char *defaultLogFileNamePrefix = "taoslog"; const int32_t maxLogFileNum = 10; tsAsyncLog = 0; @@ -96,7 +96,7 @@ void sifAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t *sl } void sifMakeValueNode(SNode **pNode, int32_t dataType, void *value) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE); SValueNode *vnode = (SValueNode *)node; vnode->node.resType.type = dataType; @@ -113,7 +113,7 @@ void sifMakeValueNode(SNode **pNode, int32_t dataType, void *value) { } void sifMakeColumnNode(SNode **pNode, const char *db, const char *colName, EColumnType colType, uint8_t colValType) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN); SColumnNode *rnode = (SColumnNode *)node; memcpy(rnode->dbName, db, strlen(db)); memcpy(rnode->colName, colName, strlen(colName)); @@ -125,7 +125,7 @@ void sifMakeColumnNode(SNode **pNode, const char *db, const char *colName, EColu } void sifMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR); SOperatorNode *onode = (SOperatorNode *)node; onode->node.resType.type = resType; onode->node.resType.bytes = tDataTypes[resType].bytes; @@ -138,7 +138,7 @@ void sifMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode * } void sifMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); SNodeListNode *lnode = (SNodeListNode *)node; lnode->dataType.type = resType; lnode->pNodeList = list; @@ -147,7 +147,7 @@ void sifMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { } void sifMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); SLogicConditionNode *onode = (SLogicConditionNode *)node; onode->condType = opType; onode->node.resType.type = TSDB_DATA_TYPE_BOOL; @@ -162,7 +162,7 @@ void sifMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeLis } void sifMakeTargetNode(SNode **pNode, int16_t dataBlockId, int16_t slotId, SNode *snode) { - SNode * node = (SNode *)nodesMakeNode(QUERY_NODE_TARGET); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_TARGET); STargetNode *onode = (STargetNode *)node; onode->pExpr = snode; onode->dataBlockId = dataBlockId; diff --git a/source/libs/monitor/src/monMain.c b/source/libs/monitor/src/monMain.c index d387a432e13d12a55a03af089aab2228f6863ab0..eab5a334508765f876a2289af90190ec2648df2b 100644 --- a/source/libs/monitor/src/monMain.c +++ b/source/libs/monitor/src/monMain.c @@ -556,7 +556,7 @@ void monSendReport() { char *pCont = tjsonToString(pMonitor->pJson); // uDebugL("report cont:%s\n", pCont); - if (pCont != NULL) { + if (pCont != NULL) { EHttpCompFlag flag = tsMonitor.cfg.comp ? HTTP_GZIP : HTTP_FLAT; if (taosSendHttpReport(tsMonitor.cfg.server, tsMonitor.cfg.port, pCont, strlen(pCont), flag) != 0) { uError("failed to send monitor msg"); diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 7cad5df3a19339aab6fb96ec9fef5fdc6fb05f46..b9b365fb42c62ec9400b85450c3bca40ac920730 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -131,7 +131,7 @@ static int32_t valueNodeCopy(const SValueNode* pSrc, SValueNode* pDst) { COPY_SCALAR_FIELD(placeholderNo); COPY_SCALAR_FIELD(typeData); COPY_SCALAR_FIELD(unit); - if (!pSrc->translate) { + if (!pSrc->translate || pSrc->isNull) { return TSDB_CODE_SUCCESS; } switch (pSrc->node.resType.type) { @@ -383,6 +383,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(groupSort); CLONE_NODE_LIST_FIELD(pTags); CLONE_NODE_FIELD(pSubtable); + COPY_SCALAR_FIELD(igLastNull); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index e401a3da7fe4fdb9815eae3fedfec9e5b281689d..f0f1fc99756bacf892e9a7ce48677b94a06c0fd3 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -3011,7 +3011,7 @@ static int32_t valueNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkValueIsNull, pNode->isNull); } - if (TSDB_CODE_SUCCESS == code && pNode->translate) { + if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) { code = datumToJson(pNode, pJson); } @@ -3161,7 +3161,7 @@ static int32_t jsonToValueNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkValueIsNull, &pNode->isNull); } - if (TSDB_CODE_SUCCESS == code && pNode->translate) { + if (TSDB_CODE_SUCCESS == code && pNode->translate && !pNode->isNull) { code = jsonToDatum(pJson, pNode); } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 6e964fb53a7e36b435169f04daced63d43f6a786..9196f77124720b232f35cf3911b8745fb21dfb32 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -1604,7 +1604,7 @@ char* nodesGetStrValueFromNode(SValueNode* pNode) { bool nodesIsExprNode(const SNode* pNode) { ENodeType type = nodeType(pNode); return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || - QUERY_NODE_FUNCTION == type || QUERY_NODE_LOGIC_CONDITION == type); + QUERY_NODE_FUNCTION == type || QUERY_NODE_LOGIC_CONDITION == type || QUERY_NODE_CASE_WHEN == type); } bool nodesIsUnaryOp(const SOperatorNode* pOp) { diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 1a955b3f6b04aa4c14e85697706940d2de9bd001..627ea093e4601e8e7cc444d1d58a9b1b36d7b53c 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -95,6 +95,7 @@ SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName); SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral); +SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral); SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt); SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral); diff --git a/source/libs/parser/inc/parInsertData.h b/source/libs/parser/inc/parInsertData.h index ddfcd3a249afe1767cd50bdb433ce2f712354af8..6d0ba29eb71357b82371566f3e5024e2fcaff239 100644 --- a/source/libs/parser/inc/parInsertData.h +++ b/source/libs/parser/inc/parInsertData.h @@ -18,9 +18,9 @@ #include "catalog.h" #include "os.h" +#include "query.h" #include "tname.h" #include "ttypes.h" -#include "query.h" #define IS_DATA_COL_ORDERED(spd) ((spd->orderStatus) == (int8_t)ORDER_STATUS_ORDERED) diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 6af01eecd58315f1bda9d23e53e3e5dbcddd24ba..3eefd7fb44bd766173e05610403500e4f0df9204 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -393,7 +393,7 @@ cmd ::= SHOW db_name_cond_opt(A) TABLES like_pattern_opt(B). cmd ::= SHOW db_name_cond_opt(A) STABLES like_pattern_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, A, B, OP_TYPE_LIKE); } cmd ::= SHOW db_name_cond_opt(A) VGROUPS. { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, A, NULL, OP_TYPE_LIKE); } cmd ::= SHOW MNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -cmd ::= SHOW MODULES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } +//cmd ::= SHOW MODULES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, B, A, OP_TYPE_EQUAL); } @@ -425,15 +425,15 @@ cmd ::= SHOW VNODES NK_INTEGER(A). cmd ::= SHOW VNODES NK_STRING(A). { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &A)); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } -db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } +db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createIdentifierValueNode(pCxt, &B); } like_pattern_opt(A) ::= . { A = NULL; } like_pattern_opt(A) ::= LIKE NK_STRING(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } -table_name_cond(A) ::= table_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } +table_name_cond(A) ::= table_name(B). { A = createIdentifierValueNode(pCxt, &B); } from_db_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } -from_db_opt(A) ::= FROM db_name(B). { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } +from_db_opt(A) ::= FROM db_name(B). { A = createIdentifierValueNode(pCxt, &B); } /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) @@ -1043,5 +1043,5 @@ null_ordering_opt(A) ::= NULLS FIRST. null_ordering_opt(A) ::= NULLS LAST. { A = NULL_ORDER_LAST; } %fallback ABORT AFTER ATTACH BEFORE BEGIN BITAND BITNOT BITOR BLOCKS CHANGE COMMA COMPACT CONCAT CONFLICT COPY DEFERRED DELIMITERS DETACH DIVIDE DOT EACH END FAIL - FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT STRING + FILE FOR GLOB ID IMMEDIATE IMPORT INITIALLY INSTEAD ISNULL KEY MODULES NK_BITNOT NK_SEMI NOTNULL OF PLUS PRIVILEGE RAISE REPLACE RESTRICT ROW SEMI STAR STATEMENT STRING TIMES UPDATE VALUES VARIABLE VIEW WAL. diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 8998ffdbf3fa3cf2af280957df0b5ff9ad787dea..2e6f83936848b044b4f13f894ec44672db9bfec1 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -310,6 +310,11 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* return (SNode*)val; } +SNode* createIdentifierValueNode(SAstCreateContext* pCxt, SToken* pLiteral) { + trimEscape(pLiteral); + return createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, pLiteral); +} + SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) { CHECK_PARSER_STATUS(pCxt); SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index 27adb79e3ccef40a8b951841f2564d160522184f..64aa017a68f7cfb04d0b69c5b526ebeea179b251 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -97,7 +97,7 @@ typedef struct SCollectMetaKeyCxt { typedef struct SCollectMetaKeyFromExprCxt { SCollectMetaKeyCxt* pComCxt; - bool hasLastRow; + bool hasLastRowOrLast; int32_t errCode; } SCollectMetaKeyFromExprCxt; @@ -106,7 +106,8 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt); static EDealRes collectMetaKeyFromFunction(SCollectMetaKeyFromExprCxt* pCxt, SFunctionNode* pFunc) { switch (fmGetFuncType(pFunc->functionName)) { case FUNCTION_TYPE_LAST_ROW: - pCxt->hasLastRow = true; + case FUNCTION_TYPE_LAST: + pCxt->hasLastRowOrLast = true; break; case FUNCTION_TYPE_UDF: pCxt->errCode = reserveUdfInCache(pFunc->functionName, pCxt->pComCxt->pMetaCache); @@ -126,6 +127,9 @@ static bool needGetTableIndex(SNode* pStmt) { } static int32_t collectMetaKeyFromInsTagsImpl(SCollectMetaKeyCxt* pCxt, SName* pName) { + if (0 == pName->type) { + return TSDB_CODE_SUCCESS; + } if (TSDB_DB_NAME_T == pName->type) { return reserveDbVgInfoInCache(pName->acctId, pName->dbname, pCxt->pMetaCache); } @@ -218,9 +222,9 @@ static int32_t reserveDbCfgForLastRow(SCollectMetaKeyCxt* pCxt, SNode* pTable) { } static int32_t collectMetaKeyFromSelect(SCollectMetaKeyCxt* pCxt, SSelectStmt* pStmt) { - SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .hasLastRow = false, .errCode = TSDB_CODE_SUCCESS}; + SCollectMetaKeyFromExprCxt cxt = {.pComCxt = pCxt, .hasLastRowOrLast = false, .errCode = TSDB_CODE_SUCCESS}; nodesWalkSelectStmt(pStmt, SQL_CLAUSE_FROM, collectMetaKeyFromExprImpl, &cxt); - if (TSDB_CODE_SUCCESS == cxt.errCode && cxt.hasLastRow) { + if (TSDB_CODE_SUCCESS == cxt.errCode && cxt.hasLastRowOrLast) { cxt.errCode = reserveDbCfgForLastRow(pCxt, pStmt->pFromTable); } return cxt.errCode; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 1c7ef05087e1e29a73ef63d1205aa02a7e8e13cd..2cef80c4cb0cc61bdc3896b929eeabe8d73543b5 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -721,6 +721,14 @@ static bool isTimeLineQuery(SNode* pStmt) { } } +static bool isGlobalTimeLineQuery(SNode* pStmt) { + if (!isTimeLineQuery(pStmt)) { + return false; + } + SSelectStmt* pSelect = (SSelectStmt*)pStmt; + return NULL == pSelect->pPartitionByList || NULL != pSelect->pOrderByList; +} + static bool isPrimaryKeyImpl(SNode* pExpr) { if (QUERY_NODE_COLUMN == nodeType(pExpr)) { return (PRIMARYKEY_TIMESTAMP_COL_ID == ((SColumnNode*)pExpr)->colId); @@ -1601,6 +1609,7 @@ static void setFuncClassification(SNode* pCurrStmt, SFunctionNode* pFunc) { pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType); + pSelect->hasLastFunc = pSelect->hasLastFunc ? true : (FUNCTION_TYPE_LAST == pFunc->funcType); pSelect->hasTimeLineFunc = pSelect->hasTimeLineFunc ? true : fmIsTimelineFunc(pFunc->funcId); pSelect->hasUdaf = pSelect->hasUdaf ? true : fmIsUserDefinedFunc(pFunc->funcId) && fmIsAggFunc(pFunc->funcId); pSelect->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc ? fmIsKeepOrderFunc(pFunc->funcId) : false; @@ -1879,6 +1888,7 @@ static EDealRes translateCaseWhen(STranslateContext* pCxt, SCaseWhenNode* pCaseW pWhenThen->pWhen = pIsTrue; } if (first) { + first = false; pCaseWhen->node.resType = ((SExprNode*)pNode)->resType; } else if (!dataTypeEqual(&pCaseWhen->node.resType, &((SExprNode*)pNode)->resType)) { SNode* pCastFunc = NULL; @@ -2341,7 +2351,7 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo } static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSelect) { - if (!pSelect->hasLastRowFunc || QUERY_NODE_REAL_TABLE != nodeType(pSelect->pFromTable)) { + if ((!pSelect->hasLastRowFunc && !pSelect->hasLastFunc) || QUERY_NODE_REAL_TABLE != nodeType(pSelect->pFromTable)) { return TSDB_CODE_SUCCESS; } @@ -3012,8 +3022,9 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* return TSDB_CODE_SUCCESS; } -static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect, SIntervalWindowNode* pInterval) { - int32_t code = checkIntervalWindow(pCxt, pInterval); +static int32_t translateIntervalWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { + SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pSelect->pWindow; + int32_t code = checkIntervalWindow(pCxt, pInterval); if (TSDB_CODE_SUCCESS == code) { code = translateFill(pCxt, pSelect, pInterval); } @@ -3056,6 +3067,12 @@ static int32_t checkStateWindowForStream(STranslateContext* pCxt, SSelectStmt* p } static int32_t translateStateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && + !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TIMELINE_QUERY, + "STATE_WINDOW requires valid time series input"); + } + SStateWindowNode* pState = (SStateWindowNode*)pSelect->pWindow; nodesWalkExprPostOrder(pState->pExpr, checkStateExpr, pCxt); if (TSDB_CODE_SUCCESS == pCxt->errCode) { @@ -3064,7 +3081,14 @@ static int32_t translateStateWindow(STranslateContext* pCxt, SSelectStmt* pSelec return pCxt->errCode; } -static int32_t translateSessionWindow(STranslateContext* pCxt, SSessionWindowNode* pSession) { +static int32_t translateSessionWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (QUERY_NODE_TEMP_TABLE == nodeType(pSelect->pFromTable) && + !isGlobalTimeLineQuery(((STempTableNode*)pSelect->pFromTable)->pSubquery)) { + return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TIMELINE_QUERY, + "SESSION requires valid time series input"); + } + + SSessionWindowNode* pSession = (SSessionWindowNode*)pSelect->pWindow; if ('y' == pSession->pGap->unit || 'n' == pSession->pGap->unit || 0 == pSession->pGap->datum.i) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SESSION_GAP); } @@ -3079,9 +3103,9 @@ static int32_t translateSpecificWindow(STranslateContext* pCxt, SSelectStmt* pSe case QUERY_NODE_STATE_WINDOW: return translateStateWindow(pCxt, pSelect); case QUERY_NODE_SESSION_WINDOW: - return translateSessionWindow(pCxt, (SSessionWindowNode*)pSelect->pWindow); + return translateSessionWindow(pCxt, pSelect); case QUERY_NODE_INTERVAL_WINDOW: - return translateIntervalWindow(pCxt, pSelect, (SIntervalWindowNode*)pSelect->pWindow); + return translateIntervalWindow(pCxt, pSelect); default: break; } @@ -5156,6 +5180,13 @@ static int32_t translateDropComponentNode(STranslateContext* pCxt, SDropComponen (FSerializeFunc)tSerializeSCreateDropMQSBNodeReq, &dropReq); } +static int32_t checkTopicQuery(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (pSelect->hasAggFuncs || pSelect->hasInterpFunc || pSelect->hasIndefiniteRowsFunc) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TOPIC_QUERY); + } + return TSDB_CODE_SUCCESS; +} + static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pStmt, SCMCreateTopicReq* pReq) { SName name; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->topicName, strlen(pStmt->topicName)); @@ -5186,6 +5217,9 @@ static int32_t buildCreateTopicReq(STranslateContext* pCxt, SCreateTopicStmt* pS tNameGetFullDbName(&name, pReq->subDbName); pCxt->pParseCxt->topicQuery = true; code = translateQuery(pCxt, pStmt->pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = checkTopicQuery(pCxt, (SSelectStmt*)pStmt->pQuery); + } if (TSDB_CODE_SUCCESS == code) { code = nodesNodeToString(pStmt->pQuery, false, &pReq->ast, NULL); } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index aa44365b39938a46211f8e4d80e2e6b6eaad05a1..6daf06731f8204dcd478621c647567e69c0e32da 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -139,17 +139,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 695 -#define YYNRULE 523 +#define YYNSTATE 694 +#define YYNRULE 522 #define YYNTOKEN 317 -#define YY_MAX_SHIFT 694 -#define YY_MIN_SHIFTREDUCE 1026 -#define YY_MAX_SHIFTREDUCE 1548 -#define YY_ERROR_ACTION 1549 -#define YY_ACCEPT_ACTION 1550 -#define YY_NO_ACTION 1551 -#define YY_MIN_REDUCE 1552 -#define YY_MAX_REDUCE 2074 +#define YY_MAX_SHIFT 693 +#define YY_MIN_SHIFTREDUCE 1025 +#define YY_MAX_SHIFTREDUCE 1546 +#define YY_ERROR_ACTION 1547 +#define YY_ACCEPT_ACTION 1548 +#define YY_NO_ACTION 1549 +#define YY_MIN_REDUCE 1550 +#define YY_MAX_REDUCE 2071 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -216,791 +216,755 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2993) +#define YY_ACTTAB_COUNT (2819) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1876, 34, 267, 1876, 1805, 1059, 447, 1890, 448, 1587, - /* 10 */ 1692, 1872, 44, 42, 1872, 455, 394, 448, 1587, 1690, - /* 20 */ 349, 1872, 1329, 43, 41, 40, 39, 38, 1355, 40, - /* 30 */ 39, 38, 156, 1409, 1564, 1327, 1908, 1868, 1874, 337, - /* 40 */ 1868, 1874, 343, 587, 588, 1063, 1064, 1868, 1874, 1858, - /* 50 */ 594, 600, 30, 594, 310, 1575, 1404, 587, 37, 36, - /* 60 */ 594, 17, 43, 41, 40, 39, 38, 1890, 1335, 44, - /* 70 */ 42, 1479, 1888, 1076, 464, 1075, 1924, 349, 572, 1329, - /* 80 */ 97, 1889, 1891, 604, 1893, 1894, 599, 1574, 594, 2050, - /* 90 */ 1409, 637, 1327, 168, 1, 1977, 1908, 1858, 1355, 342, - /* 100 */ 1973, 587, 335, 1077, 601, 584, 1356, 2045, 1753, 1858, - /* 110 */ 154, 600, 173, 1404, 1573, 336, 691, 46, 17, 1703, - /* 120 */ 2003, 546, 571, 171, 1751, 1335, 1678, 2046, 573, 1858, - /* 130 */ 1411, 1412, 602, 52, 132, 1845, 1924, 1553, 1223, 1224, - /* 140 */ 98, 348, 1891, 604, 1893, 1894, 599, 533, 594, 354, - /* 150 */ 1701, 1, 1746, 1748, 334, 1977, 1858, 1802, 110, 314, - /* 160 */ 1973, 109, 108, 107, 106, 105, 104, 103, 102, 101, - /* 170 */ 2045, 130, 157, 691, 452, 46, 1330, 1656, 1328, 58, - /* 180 */ 1352, 1538, 371, 513, 1572, 571, 171, 1411, 1412, 227, - /* 190 */ 2046, 573, 586, 169, 1985, 1986, 511, 1990, 509, 1354, - /* 200 */ 1333, 1334, 1992, 1384, 1385, 1387, 1388, 1389, 1390, 1391, - /* 210 */ 1392, 1393, 1394, 596, 592, 1402, 1403, 1405, 1406, 1407, - /* 220 */ 1408, 1410, 1413, 3, 205, 446, 1858, 58, 450, 81, - /* 230 */ 1989, 454, 635, 1330, 450, 1328, 1617, 220, 161, 1676, - /* 240 */ 1731, 174, 1505, 481, 477, 473, 469, 204, 1877, 266, - /* 250 */ 47, 145, 144, 632, 631, 630, 629, 1333, 1334, 1872, - /* 260 */ 1384, 1385, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, - /* 270 */ 596, 592, 1402, 1403, 1405, 1406, 1407, 1408, 1410, 1413, - /* 280 */ 3, 44, 42, 11, 78, 1868, 1874, 202, 11, 349, - /* 290 */ 9, 1329, 559, 1503, 1504, 1506, 1507, 219, 594, 499, - /* 300 */ 498, 497, 1409, 584, 1327, 58, 110, 126, 493, 109, - /* 310 */ 108, 107, 106, 105, 104, 103, 102, 101, 492, 496, - /* 320 */ 567, 635, 174, 546, 491, 1404, 174, 62, 1747, 1748, - /* 330 */ 17, 2050, 132, 1890, 167, 176, 1679, 1335, 44, 42, - /* 340 */ 145, 144, 632, 631, 630, 635, 349, 1740, 1329, 584, - /* 350 */ 201, 195, 1701, 200, 79, 312, 1753, 460, 536, 1409, - /* 360 */ 2045, 1327, 1908, 1, 145, 144, 632, 631, 630, 130, - /* 370 */ 588, 1908, 1752, 193, 174, 1858, 2049, 600, 132, 566, - /* 380 */ 2046, 2048, 1404, 1141, 1354, 691, 387, 17, 386, 233, - /* 390 */ 234, 170, 1985, 1986, 1335, 1990, 464, 174, 1888, 1411, - /* 400 */ 1412, 87, 1924, 1552, 1353, 352, 97, 1889, 1891, 604, - /* 410 */ 1893, 1894, 599, 154, 594, 121, 1143, 58, 565, 168, - /* 420 */ 1, 1977, 1703, 1694, 546, 342, 1973, 119, 118, 117, - /* 430 */ 116, 115, 114, 113, 112, 111, 120, 264, 1985, 583, - /* 440 */ 77, 582, 691, 485, 2045, 1330, 2004, 1328, 312, 495, - /* 450 */ 494, 536, 174, 1701, 125, 1753, 1411, 1412, 58, 571, - /* 460 */ 171, 1571, 353, 1696, 2046, 573, 548, 1686, 1949, 1333, - /* 470 */ 1334, 1751, 1384, 1385, 1387, 1388, 1389, 1390, 1391, 1392, - /* 480 */ 1393, 1394, 596, 592, 1402, 1403, 1405, 1406, 1407, 1408, - /* 490 */ 1410, 1413, 3, 562, 11, 550, 1801, 1949, 307, 432, - /* 500 */ 662, 660, 1330, 1858, 1328, 77, 1181, 626, 625, 624, - /* 510 */ 1185, 623, 1187, 1188, 622, 1190, 619, 1570, 1196, 616, - /* 520 */ 1198, 1199, 613, 610, 1569, 2050, 1333, 1334, 1697, 1384, - /* 530 */ 1385, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 596, - /* 540 */ 592, 1402, 1403, 1405, 1406, 1407, 1408, 1410, 1413, 3, - /* 550 */ 44, 42, 533, 546, 2045, 185, 184, 1568, 349, 1858, - /* 560 */ 1329, 1076, 1803, 1075, 174, 120, 1858, 1992, 1063, 1064, - /* 570 */ 2049, 1409, 490, 1327, 2046, 2047, 483, 383, 568, 563, - /* 580 */ 37, 36, 1701, 1890, 43, 41, 40, 39, 38, 546, - /* 590 */ 1483, 1077, 1357, 1992, 1404, 1988, 1354, 385, 381, 1858, - /* 600 */ 128, 392, 1890, 1948, 546, 174, 1335, 44, 42, 1414, - /* 610 */ 181, 546, 1908, 1567, 546, 349, 393, 1329, 1701, 524, - /* 620 */ 601, 1987, 325, 403, 2049, 1858, 417, 600, 1409, 1753, - /* 630 */ 1327, 1908, 8, 1701, 1335, 1440, 319, 546, 1356, 601, - /* 640 */ 1701, 546, 649, 1701, 1858, 1751, 600, 74, 602, 418, - /* 650 */ 73, 1404, 1924, 462, 691, 1858, 294, 348, 1891, 604, - /* 660 */ 1893, 1894, 599, 1335, 594, 1476, 1701, 1888, 1411, 1412, - /* 670 */ 1701, 1924, 232, 2050, 572, 97, 1889, 1891, 604, 1893, - /* 680 */ 1894, 599, 326, 594, 324, 323, 2045, 487, 2065, 8, - /* 690 */ 1977, 489, 37, 36, 342, 1973, 43, 41, 40, 39, - /* 700 */ 38, 571, 171, 2045, 2011, 31, 2046, 573, 546, 395, - /* 710 */ 1795, 691, 1677, 488, 1330, 1445, 1328, 1550, 571, 171, - /* 720 */ 268, 179, 396, 2046, 573, 1411, 1412, 26, 1419, 1795, - /* 730 */ 13, 12, 1307, 1308, 1354, 243, 1566, 1701, 1333, 1334, - /* 740 */ 180, 1384, 1385, 1387, 1388, 1389, 1390, 1391, 1392, 1393, - /* 750 */ 1394, 596, 592, 1402, 1403, 1405, 1406, 1407, 1408, 1410, - /* 760 */ 1413, 3, 37, 36, 546, 1538, 43, 41, 40, 39, - /* 770 */ 38, 1330, 637, 1328, 1795, 489, 463, 364, 1858, 174, - /* 780 */ 1386, 266, 37, 36, 1563, 183, 43, 41, 40, 39, - /* 790 */ 38, 1357, 1562, 1701, 529, 1333, 1334, 488, 1384, 1385, - /* 800 */ 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, 596, 592, - /* 810 */ 1402, 1403, 1405, 1406, 1407, 1408, 1410, 1413, 3, 44, - /* 820 */ 42, 546, 1329, 2045, 1452, 1354, 1858, 349, 1800, 1329, - /* 830 */ 307, 1997, 1472, 1698, 1858, 1327, 1561, 94, 2051, 171, - /* 840 */ 1409, 546, 1327, 2046, 573, 546, 1560, 499, 498, 497, - /* 850 */ 1701, 127, 1890, 137, 1688, 126, 493, 525, 650, 1693, - /* 860 */ 1671, 546, 1559, 1404, 1558, 1557, 492, 496, 1335, 1556, - /* 870 */ 1701, 1890, 491, 530, 1701, 1335, 44, 42, 1858, 575, - /* 880 */ 546, 1908, 1555, 546, 349, 576, 1329, 143, 1858, 601, - /* 890 */ 1701, 7, 237, 546, 1858, 542, 600, 1409, 1684, 1327, - /* 900 */ 1908, 8, 355, 1475, 1858, 544, 1858, 1858, 601, 1701, - /* 910 */ 154, 1858, 1701, 1858, 226, 600, 691, 1888, 1386, 1703, - /* 920 */ 1404, 1924, 1701, 691, 1858, 158, 1889, 1891, 604, 1893, - /* 930 */ 1894, 599, 1335, 594, 242, 402, 1888, 1411, 1412, 51, - /* 940 */ 1924, 546, 1545, 546, 97, 1889, 1891, 604, 1893, 1894, - /* 950 */ 599, 154, 594, 545, 80, 356, 223, 2065, 1, 1977, - /* 960 */ 1704, 595, 633, 342, 1973, 1744, 551, 2014, 634, 591, - /* 970 */ 1701, 1744, 1701, 2039, 279, 1604, 1330, 1731, 1328, 45, - /* 980 */ 691, 48, 4, 1330, 72, 1328, 210, 212, 214, 208, - /* 990 */ 211, 213, 231, 216, 1411, 1412, 215, 500, 50, 528, - /* 1000 */ 1333, 1334, 1547, 1548, 13, 12, 138, 1333, 1334, 1386, - /* 1010 */ 1384, 1385, 1387, 1388, 1389, 1390, 1391, 1392, 1393, 1394, - /* 1020 */ 596, 592, 1402, 1403, 1405, 1406, 1407, 1408, 1410, 1413, - /* 1030 */ 3, 1278, 628, 1657, 1565, 579, 1338, 1544, 1599, 1597, - /* 1040 */ 1330, 142, 1328, 32, 235, 2017, 1879, 60, 261, 37, - /* 1050 */ 36, 143, 60, 43, 41, 40, 39, 38, 539, 1337, - /* 1060 */ 502, 505, 1103, 247, 1333, 1334, 1614, 1384, 1385, 1387, - /* 1070 */ 1388, 1389, 1390, 1391, 1392, 1393, 1394, 596, 592, 1402, - /* 1080 */ 1403, 1405, 1406, 1407, 1408, 1410, 1413, 3, 309, 482, - /* 1090 */ 1352, 93, 1472, 239, 1881, 1104, 643, 425, 644, 1446, - /* 1100 */ 437, 90, 577, 1174, 1502, 255, 37, 36, 1430, 560, - /* 1110 */ 43, 41, 40, 39, 38, 250, 45, 410, 1123, 438, - /* 1120 */ 1121, 412, 1909, 360, 1588, 1741, 2007, 585, 263, 668, - /* 1130 */ 667, 666, 665, 359, 45, 664, 663, 133, 658, 657, - /* 1140 */ 656, 655, 654, 653, 652, 651, 147, 647, 646, 645, - /* 1150 */ 358, 357, 642, 641, 640, 639, 638, 155, 260, 2, - /* 1160 */ 5, 370, 285, 322, 365, 320, 37, 36, 1395, 1294, - /* 1170 */ 43, 41, 40, 39, 38, 398, 283, 66, 388, 1341, - /* 1180 */ 65, 1593, 275, 608, 37, 36, 278, 182, 43, 41, - /* 1190 */ 40, 39, 38, 1515, 142, 529, 189, 443, 441, 1352, - /* 1200 */ 397, 401, 1340, 436, 419, 1890, 431, 430, 429, 428, - /* 1210 */ 427, 424, 423, 422, 421, 420, 416, 415, 414, 413, - /* 1220 */ 407, 406, 405, 404, 2045, 400, 399, 321, 1797, 686, - /* 1230 */ 426, 440, 434, 58, 1908, 1202, 143, 433, 122, 2051, - /* 1240 */ 171, 435, 601, 186, 2046, 573, 1206, 1858, 439, 600, - /* 1250 */ 142, 37, 36, 1495, 580, 43, 41, 40, 39, 38, - /* 1260 */ 442, 1358, 444, 445, 453, 1360, 456, 192, 457, 194, - /* 1270 */ 1888, 96, 1359, 1361, 1924, 458, 459, 197, 97, 1889, - /* 1280 */ 1891, 604, 1893, 1894, 599, 461, 594, 199, 1213, 129, - /* 1290 */ 1211, 141, 1948, 1977, 75, 465, 76, 342, 1973, 484, - /* 1300 */ 203, 532, 146, 362, 315, 486, 1691, 71, 70, 391, - /* 1310 */ 361, 100, 178, 311, 207, 1687, 1890, 516, 529, 209, - /* 1320 */ 529, 148, 149, 1689, 518, 1685, 276, 529, 150, 308, - /* 1330 */ 151, 1836, 379, 519, 377, 373, 369, 366, 363, 153, - /* 1340 */ 221, 520, 523, 224, 526, 1908, 1438, 2045, 228, 2045, - /* 1350 */ 531, 558, 139, 601, 140, 534, 2045, 541, 1858, 540, - /* 1360 */ 600, 517, 2051, 171, 2051, 171, 331, 2046, 573, 2046, - /* 1370 */ 573, 2051, 171, 1835, 1807, 84, 2046, 573, 529, 537, - /* 1380 */ 174, 1888, 277, 333, 86, 1924, 1702, 1357, 554, 97, - /* 1390 */ 1889, 1891, 604, 1893, 1894, 599, 561, 594, 2008, 2018, - /* 1400 */ 2023, 1439, 2065, 245, 1977, 556, 557, 2045, 342, 1973, - /* 1410 */ 694, 338, 249, 564, 2022, 6, 570, 254, 1996, 555, - /* 1420 */ 1999, 1890, 2051, 171, 274, 553, 257, 2046, 573, 552, - /* 1430 */ 339, 162, 581, 256, 259, 131, 2044, 2068, 165, 578, - /* 1440 */ 258, 1472, 1356, 684, 680, 676, 672, 272, 1993, 57, - /* 1450 */ 1908, 88, 606, 1958, 1745, 1672, 262, 280, 601, 584, - /* 1460 */ 271, 687, 49, 1858, 1890, 600, 688, 292, 690, 306, - /* 1470 */ 303, 33, 346, 1433, 1434, 1435, 1436, 1437, 1441, 1442, - /* 1480 */ 1443, 1444, 284, 1852, 95, 302, 1888, 240, 132, 1851, - /* 1490 */ 1924, 68, 282, 1908, 97, 1889, 1891, 604, 1893, 1894, - /* 1500 */ 599, 601, 594, 1850, 1849, 69, 1858, 1952, 600, 1977, - /* 1510 */ 1846, 345, 344, 342, 1973, 367, 368, 1890, 372, 1321, - /* 1520 */ 543, 1343, 1322, 177, 1844, 130, 374, 375, 376, 1888, - /* 1530 */ 1843, 378, 1409, 1924, 1336, 1842, 380, 97, 1889, 1891, - /* 1540 */ 604, 1893, 1894, 599, 384, 594, 1908, 172, 1985, 1986, - /* 1550 */ 1950, 1990, 1977, 229, 601, 1404, 342, 1973, 1841, 1858, - /* 1560 */ 382, 600, 1840, 1297, 1296, 1818, 1817, 1335, 389, 390, - /* 1570 */ 1890, 1301, 1816, 222, 1815, 1266, 1790, 1789, 1787, 134, - /* 1580 */ 1786, 1785, 1888, 1788, 135, 1784, 1924, 1783, 1782, 1781, - /* 1590 */ 97, 1889, 1891, 604, 1893, 1894, 599, 1780, 594, 1908, - /* 1600 */ 1779, 408, 409, 549, 411, 1977, 1778, 601, 1777, 342, - /* 1610 */ 1973, 1776, 1858, 1890, 600, 590, 1775, 1774, 1773, 1772, - /* 1620 */ 1771, 1770, 1769, 1768, 1767, 1766, 1765, 1764, 136, 1763, - /* 1630 */ 1762, 1761, 1760, 1759, 1758, 1888, 1268, 1757, 1756, 1924, - /* 1640 */ 1755, 1754, 1908, 98, 1889, 1891, 604, 1893, 1894, 599, - /* 1650 */ 601, 594, 1619, 1618, 187, 1858, 1616, 600, 1977, 188, - /* 1660 */ 1584, 449, 1976, 1973, 1066, 1065, 1890, 123, 1583, 1831, - /* 1670 */ 1149, 1825, 1814, 198, 1813, 1344, 1799, 1339, 1888, 166, - /* 1680 */ 1680, 190, 1924, 191, 124, 196, 98, 1889, 1891, 604, - /* 1690 */ 1893, 1894, 599, 1615, 594, 1908, 1613, 466, 468, 1347, - /* 1700 */ 1349, 1977, 467, 598, 451, 589, 1973, 1611, 1858, 472, - /* 1710 */ 600, 1096, 470, 592, 1402, 1403, 1405, 1406, 1407, 1408, - /* 1720 */ 471, 1609, 1890, 474, 476, 475, 1607, 478, 479, 480, - /* 1730 */ 1596, 1888, 1595, 1580, 1682, 1924, 1217, 1216, 1681, 300, - /* 1740 */ 1889, 1891, 604, 1893, 1894, 599, 597, 594, 547, 1942, - /* 1750 */ 1133, 1908, 1140, 659, 1139, 1138, 661, 59, 206, 601, - /* 1760 */ 1135, 1605, 1134, 327, 1858, 1600, 600, 328, 1598, 329, - /* 1770 */ 1132, 503, 506, 1579, 508, 1578, 1577, 510, 512, 99, - /* 1780 */ 1830, 1313, 1824, 25, 1890, 1303, 152, 1888, 521, 504, - /* 1790 */ 1812, 1924, 1810, 1811, 2050, 159, 1889, 1891, 604, 1893, - /* 1800 */ 1894, 599, 1809, 594, 514, 53, 1808, 522, 225, 230, - /* 1810 */ 18, 1806, 1311, 1908, 1798, 90, 241, 236, 218, 1421, - /* 1820 */ 83, 601, 19, 82, 330, 85, 1858, 538, 600, 20, - /* 1830 */ 527, 10, 507, 1420, 238, 15, 501, 27, 56, 1517, - /* 1840 */ 244, 217, 1890, 246, 1499, 248, 160, 574, 2066, 1888, - /* 1850 */ 1501, 535, 251, 1924, 28, 252, 253, 98, 1889, 1891, - /* 1860 */ 604, 1893, 1894, 599, 1890, 594, 1494, 1879, 89, 29, - /* 1870 */ 61, 1908, 1977, 1537, 22, 1532, 332, 1974, 64, 601, - /* 1880 */ 1531, 63, 1538, 340, 1858, 1536, 600, 1535, 341, 1469, - /* 1890 */ 265, 1468, 55, 1908, 12, 1345, 1399, 1878, 1431, 1927, - /* 1900 */ 163, 598, 593, 164, 1397, 175, 1858, 1888, 600, 35, - /* 1910 */ 14, 1924, 21, 1396, 23, 301, 1889, 1891, 604, 1893, - /* 1920 */ 1894, 599, 54, 594, 1890, 1369, 1377, 16, 24, 1888, - /* 1930 */ 605, 1203, 607, 1924, 351, 609, 611, 300, 1889, 1891, - /* 1940 */ 604, 1893, 1894, 599, 614, 594, 617, 1943, 620, 1180, - /* 1950 */ 1200, 1197, 612, 1908, 615, 603, 1191, 618, 1212, 1189, - /* 1960 */ 621, 601, 269, 1208, 1195, 1194, 1858, 1890, 600, 91, - /* 1970 */ 92, 67, 1094, 636, 1129, 627, 1147, 1128, 1127, 1126, - /* 1980 */ 1193, 1125, 1124, 270, 1890, 1122, 1192, 1120, 1119, 1888, - /* 1990 */ 1118, 648, 1116, 1924, 1115, 1114, 1908, 158, 1889, 1891, - /* 2000 */ 604, 1893, 1894, 599, 601, 594, 1113, 1112, 1100, 1858, - /* 2010 */ 1111, 600, 1110, 1908, 1109, 1142, 1106, 1144, 1105, 1102, - /* 2020 */ 1612, 601, 1101, 1099, 669, 670, 1858, 1610, 600, 671, - /* 2030 */ 673, 675, 1888, 1608, 677, 679, 1924, 1606, 1890, 2015, - /* 2040 */ 296, 1889, 1891, 604, 1893, 1894, 599, 674, 594, 1888, - /* 2050 */ 678, 681, 682, 1924, 683, 1594, 1890, 159, 1889, 1891, - /* 2060 */ 604, 1893, 1894, 599, 685, 594, 1056, 1908, 1576, 273, - /* 2070 */ 689, 692, 347, 1331, 281, 601, 693, 1551, 1551, 1551, - /* 2080 */ 1858, 1551, 600, 1551, 569, 1908, 1551, 1551, 1551, 1551, - /* 2090 */ 350, 1551, 1551, 601, 1551, 1551, 1551, 1551, 1858, 1551, - /* 2100 */ 600, 1551, 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, - /* 2110 */ 2067, 301, 1889, 1891, 604, 1893, 1894, 599, 1890, 594, - /* 2120 */ 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1551, 301, - /* 2130 */ 1889, 1891, 604, 1893, 1894, 599, 1551, 594, 1551, 1551, - /* 2140 */ 1551, 1551, 1890, 1551, 1551, 1551, 1551, 1908, 1551, 1551, - /* 2150 */ 1551, 1551, 1551, 1551, 1551, 601, 1551, 1551, 1551, 1551, - /* 2160 */ 1858, 1551, 600, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2170 */ 1551, 1908, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 601, - /* 2180 */ 1551, 1551, 1551, 515, 1858, 1890, 600, 1924, 1551, 1551, - /* 2190 */ 1551, 294, 1889, 1891, 604, 1893, 1894, 599, 1551, 594, - /* 2200 */ 1551, 1551, 1551, 1551, 1551, 1890, 1551, 1888, 1551, 1551, - /* 2210 */ 1551, 1924, 1551, 1551, 1908, 286, 1889, 1891, 604, 1893, - /* 2220 */ 1894, 599, 601, 594, 1551, 1551, 1551, 1858, 1551, 600, - /* 2230 */ 1551, 1551, 1551, 1551, 1908, 1551, 1551, 1551, 1551, 1551, - /* 2240 */ 1551, 1551, 601, 1551, 1551, 1551, 1551, 1858, 1551, 600, - /* 2250 */ 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1551, 287, 1889, - /* 2260 */ 1891, 604, 1893, 1894, 599, 1551, 594, 1551, 1890, 1551, - /* 2270 */ 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1551, 288, 1889, - /* 2280 */ 1891, 604, 1893, 1894, 599, 1551, 594, 1890, 1551, 1551, - /* 2290 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1908, 1551, 1551, - /* 2300 */ 1551, 1551, 1551, 1551, 1551, 601, 1551, 1551, 1551, 1551, - /* 2310 */ 1858, 1551, 600, 1551, 1551, 1551, 1908, 1551, 1551, 1551, - /* 2320 */ 1551, 1551, 1551, 1551, 601, 1551, 1551, 1551, 1551, 1858, - /* 2330 */ 1890, 600, 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, - /* 2340 */ 1551, 295, 1889, 1891, 604, 1893, 1894, 599, 1551, 594, - /* 2350 */ 1551, 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1908, - /* 2360 */ 297, 1889, 1891, 604, 1893, 1894, 599, 601, 594, 1551, - /* 2370 */ 1551, 1551, 1858, 1551, 600, 1551, 1551, 1551, 1551, 1551, - /* 2380 */ 1551, 1890, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2390 */ 1551, 1551, 1551, 1551, 1551, 1888, 1551, 1551, 1551, 1924, - /* 2400 */ 1551, 1890, 1551, 289, 1889, 1891, 604, 1893, 1894, 599, - /* 2410 */ 1908, 594, 1551, 1551, 1551, 1551, 1551, 1551, 601, 1551, - /* 2420 */ 1551, 1551, 1551, 1858, 1551, 600, 1551, 1551, 1551, 1551, - /* 2430 */ 1908, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 601, 1551, - /* 2440 */ 1551, 1551, 1551, 1858, 1551, 600, 1888, 1551, 1551, 1551, - /* 2450 */ 1924, 1551, 1890, 1551, 298, 1889, 1891, 604, 1893, 1894, - /* 2460 */ 599, 1551, 594, 1551, 1551, 1551, 1888, 1551, 1551, 1551, - /* 2470 */ 1924, 1551, 1551, 1551, 290, 1889, 1891, 604, 1893, 1894, - /* 2480 */ 599, 1908, 594, 1551, 1551, 1551, 1551, 1551, 1551, 601, - /* 2490 */ 1551, 1551, 1551, 1551, 1858, 1551, 600, 1551, 1551, 1551, - /* 2500 */ 1551, 1551, 1551, 1551, 1551, 1890, 1551, 1551, 1551, 1551, - /* 2510 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1888, 1551, 1551, - /* 2520 */ 1551, 1924, 1551, 1551, 1551, 299, 1889, 1891, 604, 1893, - /* 2530 */ 1894, 599, 1551, 594, 1908, 1551, 1551, 1551, 1551, 1551, - /* 2540 */ 1551, 1551, 601, 1551, 1551, 1551, 1551, 1858, 1890, 600, - /* 2550 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2560 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1890, 1551, - /* 2570 */ 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1908, 291, 1889, - /* 2580 */ 1891, 604, 1893, 1894, 599, 601, 594, 1551, 1551, 1551, - /* 2590 */ 1858, 1551, 600, 1551, 1551, 1551, 1551, 1908, 1551, 1551, - /* 2600 */ 1551, 1551, 1551, 1551, 1551, 601, 1551, 1551, 1551, 1551, - /* 2610 */ 1858, 1551, 600, 1888, 1551, 1551, 1551, 1924, 1551, 1551, - /* 2620 */ 1551, 304, 1889, 1891, 604, 1893, 1894, 599, 1551, 594, - /* 2630 */ 1551, 1890, 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, - /* 2640 */ 1551, 305, 1889, 1891, 604, 1893, 1894, 599, 1551, 594, - /* 2650 */ 1890, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2660 */ 1908, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 601, 1551, - /* 2670 */ 1551, 1551, 1551, 1858, 1551, 600, 1551, 1551, 1551, 1908, - /* 2680 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 601, 1551, 1551, - /* 2690 */ 1551, 1551, 1858, 1890, 600, 1551, 1888, 1551, 1551, 1551, - /* 2700 */ 1924, 1551, 1551, 1551, 1902, 1889, 1891, 604, 1893, 1894, - /* 2710 */ 599, 1551, 594, 1551, 1551, 1888, 1551, 1551, 1551, 1924, - /* 2720 */ 1551, 1551, 1908, 1901, 1889, 1891, 604, 1893, 1894, 599, - /* 2730 */ 601, 594, 1551, 1551, 1551, 1858, 1551, 600, 1551, 1551, - /* 2740 */ 1551, 1551, 1551, 1551, 1890, 1551, 1551, 1551, 1551, 1551, - /* 2750 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1888, 1551, - /* 2760 */ 1551, 1551, 1924, 1551, 1890, 1551, 1900, 1889, 1891, 604, - /* 2770 */ 1893, 1894, 599, 1908, 594, 1551, 1551, 1551, 1551, 1551, - /* 2780 */ 1551, 601, 1551, 1551, 1551, 1551, 1858, 1551, 600, 1551, - /* 2790 */ 1551, 1551, 1551, 1908, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2800 */ 1551, 601, 1551, 1551, 1551, 1551, 1858, 1551, 600, 1888, - /* 2810 */ 1551, 1551, 1551, 1924, 1551, 1890, 1551, 316, 1889, 1891, - /* 2820 */ 604, 1893, 1894, 599, 1551, 594, 1551, 1551, 1551, 1888, - /* 2830 */ 1551, 1551, 1551, 1924, 1551, 1551, 1551, 317, 1889, 1891, - /* 2840 */ 604, 1893, 1894, 599, 1908, 594, 1551, 1551, 1551, 1551, - /* 2850 */ 1551, 1551, 601, 1551, 1551, 1551, 1551, 1858, 1551, 600, - /* 2860 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1890, 1551, - /* 2870 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2880 */ 1888, 1551, 1551, 1551, 1924, 1551, 1551, 1551, 313, 1889, - /* 2890 */ 1891, 604, 1893, 1894, 599, 1551, 594, 1908, 1551, 1551, - /* 2900 */ 1551, 1551, 1551, 1551, 1551, 601, 1551, 1551, 1551, 1551, - /* 2910 */ 1858, 1890, 600, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2920 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2930 */ 1551, 1551, 1551, 1888, 1551, 1551, 1551, 1924, 1551, 1551, - /* 2940 */ 1908, 318, 1889, 1891, 604, 1893, 1894, 599, 601, 594, - /* 2950 */ 1551, 1551, 1551, 1858, 1551, 600, 1551, 1551, 1551, 1551, - /* 2960 */ 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, 1551, - /* 2970 */ 1551, 1551, 1551, 1551, 1551, 1551, 1888, 1551, 1551, 1551, - /* 2980 */ 1924, 1551, 1551, 1551, 293, 1889, 1891, 604, 1893, 1894, - /* 2990 */ 599, 1551, 594, + /* 0 */ 1873, 34, 267, 1873, 156, 1058, 1562, 1887, 62, 532, + /* 10 */ 1690, 1869, 44, 42, 1869, 446, 334, 447, 1585, 1799, + /* 20 */ 349, 1869, 1327, 43, 41, 40, 39, 38, 586, 157, + /* 30 */ 167, 1548, 1352, 1407, 1654, 1325, 1905, 1865, 1871, 337, + /* 40 */ 1865, 1871, 343, 1738, 587, 1062, 1063, 1865, 1871, 1855, + /* 50 */ 593, 599, 30, 593, 445, 1573, 1402, 449, 37, 36, + /* 60 */ 593, 17, 43, 41, 40, 39, 38, 1887, 1333, 44, + /* 70 */ 42, 1477, 1885, 1572, 503, 586, 1921, 349, 571, 1327, + /* 80 */ 97, 1886, 1888, 603, 1890, 1891, 598, 77, 593, 513, + /* 90 */ 1407, 364, 1325, 168, 1, 1974, 1905, 1855, 58, 342, + /* 100 */ 1970, 125, 46, 218, 600, 583, 58, 2042, 528, 1855, + /* 110 */ 1694, 599, 173, 1402, 463, 1855, 690, 506, 17, 1571, + /* 120 */ 2000, 500, 570, 171, 586, 1333, 217, 2043, 572, 2046, + /* 130 */ 1409, 1410, 601, 2047, 132, 583, 1921, 2042, 394, 1570, + /* 140 */ 98, 348, 1888, 603, 1890, 1891, 598, 454, 593, 447, + /* 150 */ 1585, 1, 2048, 171, 1075, 1974, 1074, 2043, 572, 314, + /* 160 */ 1970, 1855, 2042, 64, 132, 1474, 63, 58, 1481, 482, + /* 170 */ 2042, 130, 335, 690, 1352, 1328, 310, 1326, 2046, 219, + /* 180 */ 154, 1855, 2043, 2045, 1076, 570, 171, 1409, 1410, 1701, + /* 190 */ 2043, 572, 585, 169, 1982, 1983, 1353, 1987, 46, 1331, + /* 200 */ 1332, 121, 1382, 1383, 1385, 1386, 1387, 1388, 1389, 1390, + /* 210 */ 1391, 1392, 595, 591, 1400, 1401, 1403, 1404, 1405, 1406, + /* 220 */ 1408, 1411, 3, 264, 1982, 582, 1676, 581, 1745, 1746, + /* 230 */ 2042, 1417, 1328, 383, 1326, 79, 312, 1352, 388, 535, + /* 240 */ 174, 1503, 494, 493, 174, 570, 171, 387, 174, 386, + /* 250 */ 2043, 572, 174, 385, 381, 528, 1331, 1332, 58, 1382, + /* 260 */ 1383, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 595, + /* 270 */ 591, 1400, 1401, 1403, 1404, 1405, 1406, 1408, 1411, 3, + /* 280 */ 44, 42, 693, 181, 2042, 233, 234, 628, 349, 77, + /* 290 */ 1327, 558, 1501, 1502, 1504, 1505, 274, 545, 1887, 2048, + /* 300 */ 171, 1407, 545, 1325, 2043, 572, 1222, 1223, 1569, 52, + /* 310 */ 165, 1874, 1695, 174, 120, 683, 679, 675, 671, 272, + /* 320 */ 74, 484, 1869, 73, 1402, 220, 1699, 1905, 1729, 17, + /* 330 */ 354, 1699, 634, 1744, 1746, 600, 1333, 44, 42, 1075, + /* 340 */ 1855, 1074, 599, 312, 143, 349, 535, 1327, 1865, 1871, + /* 350 */ 1855, 145, 144, 631, 630, 629, 95, 1384, 1407, 240, + /* 360 */ 1325, 593, 1, 601, 451, 561, 545, 1921, 634, 1076, + /* 370 */ 1350, 294, 348, 1888, 603, 1890, 1891, 598, 120, 593, + /* 380 */ 47, 1402, 1551, 574, 690, 489, 17, 145, 144, 631, + /* 390 */ 630, 629, 542, 1333, 1568, 1699, 51, 453, 1409, 1410, + /* 400 */ 449, 2042, 1473, 110, 174, 1140, 109, 108, 107, 106, + /* 410 */ 105, 104, 103, 102, 101, 1352, 570, 171, 1989, 1, + /* 420 */ 1384, 2043, 572, 110, 229, 227, 109, 108, 107, 106, + /* 430 */ 105, 104, 103, 102, 101, 545, 1855, 545, 1142, 431, + /* 440 */ 545, 690, 1299, 1328, 222, 1326, 1986, 176, 1353, 392, + /* 450 */ 567, 562, 393, 37, 36, 1409, 1410, 43, 41, 40, + /* 460 */ 39, 38, 1567, 58, 1699, 81, 1699, 1331, 1332, 1699, + /* 470 */ 1382, 1383, 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, + /* 480 */ 595, 591, 1400, 1401, 1403, 1404, 1405, 1406, 1408, 1411, + /* 490 */ 3, 11, 11, 9, 7, 185, 184, 40, 39, 38, + /* 500 */ 1328, 547, 1326, 1946, 1855, 325, 1180, 625, 624, 623, + /* 510 */ 1184, 622, 1186, 1187, 621, 1189, 618, 636, 1195, 615, + /* 520 */ 1197, 1198, 612, 609, 1331, 1332, 174, 1382, 1383, 1385, + /* 530 */ 1386, 1387, 1388, 1389, 1390, 1391, 1392, 595, 591, 1400, + /* 540 */ 1401, 1403, 1404, 1405, 1406, 1408, 1411, 3, 44, 42, + /* 550 */ 1751, 545, 1905, 498, 497, 496, 349, 336, 1327, 1550, + /* 560 */ 565, 126, 492, 403, 545, 326, 1749, 324, 323, 1407, + /* 570 */ 486, 1325, 491, 495, 488, 1352, 417, 1566, 490, 1565, + /* 580 */ 1699, 1887, 512, 119, 118, 117, 116, 115, 114, 113, + /* 590 */ 112, 111, 1402, 1699, 352, 510, 487, 508, 1384, 564, + /* 600 */ 1887, 1751, 154, 1564, 1333, 44, 42, 1412, 353, 174, + /* 610 */ 1905, 1701, 1543, 349, 2047, 1327, 355, 1749, 600, 1855, + /* 620 */ 1354, 1855, 1677, 1855, 154, 599, 1407, 1751, 1325, 1905, + /* 630 */ 8, 1354, 1802, 1701, 319, 2047, 11, 600, 232, 545, + /* 640 */ 13, 12, 1855, 1749, 599, 1855, 1885, 1561, 1675, 1402, + /* 650 */ 1921, 418, 690, 531, 158, 1886, 1888, 603, 1890, 1891, + /* 660 */ 598, 1333, 593, 1842, 2042, 1885, 1409, 1410, 1699, 1921, + /* 670 */ 528, 545, 571, 97, 1886, 1888, 603, 1890, 1891, 598, + /* 680 */ 2046, 593, 463, 461, 2043, 2044, 2062, 8, 1974, 1855, + /* 690 */ 94, 1438, 342, 1970, 1470, 550, 2011, 1305, 1306, 2042, + /* 700 */ 1699, 2042, 2008, 566, 127, 87, 1536, 1542, 636, 690, + /* 710 */ 371, 1328, 1691, 1326, 2048, 171, 570, 171, 532, 2043, + /* 720 */ 572, 2043, 572, 1409, 1410, 37, 36, 1692, 1800, 43, + /* 730 */ 41, 40, 39, 38, 1450, 1331, 1332, 1355, 1382, 1383, + /* 740 */ 1385, 1386, 1387, 1388, 1389, 1390, 1391, 1392, 595, 591, + /* 750 */ 1400, 1401, 1403, 1404, 1405, 1406, 1408, 1411, 3, 37, + /* 760 */ 36, 31, 266, 43, 41, 40, 39, 38, 1328, 1615, + /* 770 */ 1326, 1443, 1351, 266, 37, 36, 174, 32, 43, 41, + /* 780 */ 40, 39, 38, 37, 36, 1560, 1559, 43, 41, 40, + /* 790 */ 39, 38, 1331, 1332, 1558, 1382, 1383, 1385, 1386, 1387, + /* 800 */ 1388, 1389, 1390, 1391, 1392, 595, 591, 1400, 1401, 1403, + /* 810 */ 1404, 1405, 1406, 1408, 1411, 3, 44, 42, 549, 583, + /* 820 */ 1946, 661, 659, 1798, 349, 307, 1327, 1855, 1855, 1797, + /* 830 */ 395, 307, 498, 497, 496, 1333, 1855, 1407, 545, 1325, + /* 840 */ 126, 492, 545, 396, 1792, 1792, 1513, 1355, 132, 1887, + /* 850 */ 462, 491, 495, 1557, 1696, 179, 180, 490, 37, 36, + /* 860 */ 1402, 1493, 43, 41, 40, 39, 38, 1699, 1887, 1792, + /* 870 */ 545, 1699, 1333, 44, 42, 545, 1688, 545, 1905, 243, + /* 880 */ 183, 349, 137, 1327, 1751, 130, 600, 524, 1989, 529, + /* 890 */ 545, 1855, 154, 599, 1407, 1855, 1325, 1905, 8, 1699, + /* 900 */ 1750, 1702, 237, 545, 1699, 600, 1699, 170, 1982, 1983, + /* 910 */ 1855, 1987, 599, 1336, 1885, 541, 1985, 1402, 1921, 1699, + /* 920 */ 690, 1887, 159, 1886, 1888, 603, 1890, 1891, 598, 1333, + /* 930 */ 593, 488, 1699, 1885, 1409, 1410, 1556, 1921, 1555, 402, + /* 940 */ 545, 97, 1886, 1888, 603, 1890, 1891, 598, 128, 593, + /* 950 */ 1905, 1945, 356, 487, 2062, 1, 1974, 1989, 600, 545, + /* 960 */ 342, 1970, 578, 1855, 545, 599, 649, 648, 1669, 1699, + /* 970 */ 2036, 543, 545, 575, 573, 2063, 544, 690, 1855, 1328, + /* 980 */ 1855, 1326, 1674, 1602, 268, 1984, 1885, 72, 1699, 242, + /* 990 */ 1921, 1409, 1410, 1699, 159, 1886, 1888, 603, 1890, 1891, + /* 1000 */ 598, 1699, 593, 1331, 1332, 499, 1382, 1383, 1385, 1386, + /* 1010 */ 1387, 1388, 1389, 1390, 1391, 1392, 595, 591, 1400, 1401, + /* 1020 */ 1403, 1404, 1405, 1406, 1408, 1411, 3, 37, 36, 205, + /* 1030 */ 1684, 43, 41, 40, 39, 38, 1328, 632, 1326, 362, + /* 1040 */ 1742, 633, 45, 161, 1742, 1554, 1335, 2064, 480, 476, + /* 1050 */ 472, 468, 204, 1553, 279, 1339, 528, 1729, 1062, 1063, + /* 1060 */ 1331, 1332, 1612, 1382, 1383, 1385, 1386, 1387, 1388, 1389, + /* 1070 */ 1390, 1391, 1392, 595, 591, 1400, 1401, 1403, 1404, 1405, + /* 1080 */ 1406, 1408, 1411, 3, 309, 2042, 1350, 1855, 634, 78, + /* 1090 */ 1994, 1470, 202, 425, 1276, 1855, 436, 48, 4, 210, + /* 1100 */ 2048, 171, 208, 50, 527, 2043, 572, 145, 144, 631, + /* 1110 */ 630, 629, 1686, 410, 231, 437, 212, 412, 214, 211, + /* 1120 */ 216, 213, 138, 215, 226, 667, 666, 665, 664, 359, + /* 1130 */ 1682, 663, 662, 133, 657, 656, 655, 654, 653, 652, + /* 1140 */ 651, 650, 147, 646, 645, 644, 358, 357, 641, 640, + /* 1150 */ 639, 638, 637, 155, 201, 195, 1597, 200, 285, 322, + /* 1160 */ 1595, 459, 1545, 1546, 80, 642, 235, 142, 13, 12, + /* 1170 */ 590, 398, 283, 66, 538, 143, 65, 193, 501, 60, + /* 1180 */ 579, 153, 504, 247, 1327, 1876, 60, 1122, 1338, 576, + /* 1190 */ 223, 45, 189, 442, 440, 1887, 594, 1325, 2047, 435, + /* 1200 */ 45, 607, 430, 429, 428, 427, 424, 423, 422, 421, + /* 1210 */ 420, 416, 415, 414, 413, 407, 406, 405, 404, 239, + /* 1220 */ 400, 399, 321, 142, 1905, 523, 627, 1173, 143, 58, + /* 1230 */ 1333, 1500, 600, 1878, 1563, 250, 1655, 1855, 1444, 599, + /* 1240 */ 2014, 37, 36, 1393, 122, 43, 41, 40, 39, 38, + /* 1250 */ 37, 36, 278, 1201, 43, 41, 40, 39, 38, 1102, + /* 1260 */ 1885, 142, 643, 261, 1921, 559, 481, 96, 97, 1886, + /* 1270 */ 1888, 603, 1890, 1891, 598, 1205, 593, 1887, 690, 129, + /* 1280 */ 1212, 141, 1945, 1974, 1120, 26, 1591, 342, 1970, 255, + /* 1290 */ 1536, 1906, 1103, 360, 315, 1586, 1210, 1739, 2004, 93, + /* 1300 */ 584, 260, 71, 70, 391, 263, 1905, 178, 1428, 90, + /* 1310 */ 2, 332, 5, 146, 600, 365, 370, 320, 1292, 1855, + /* 1320 */ 182, 599, 275, 397, 308, 401, 1350, 379, 1887, 377, + /* 1330 */ 373, 369, 366, 363, 685, 419, 1436, 1328, 1794, 1326, + /* 1340 */ 426, 433, 1885, 432, 434, 583, 1921, 438, 1356, 439, + /* 1350 */ 301, 1886, 1888, 603, 1890, 1891, 598, 1905, 593, 186, + /* 1360 */ 1358, 1331, 1332, 441, 361, 587, 443, 444, 452, 455, + /* 1370 */ 1855, 192, 599, 456, 132, 174, 194, 516, 1357, 457, + /* 1380 */ 1359, 528, 458, 197, 199, 75, 76, 464, 460, 203, + /* 1390 */ 1437, 483, 485, 1885, 528, 100, 1689, 1921, 207, 1685, + /* 1400 */ 515, 97, 1886, 1888, 603, 1890, 1891, 598, 311, 593, + /* 1410 */ 2042, 130, 209, 148, 168, 221, 1974, 517, 1833, 276, + /* 1420 */ 342, 1970, 149, 2042, 1687, 2048, 171, 1683, 518, 150, + /* 1430 */ 2043, 572, 151, 172, 1982, 1983, 522, 1987, 2048, 171, + /* 1440 */ 519, 2001, 224, 2043, 572, 525, 1887, 530, 228, 557, + /* 1450 */ 331, 533, 1832, 139, 1804, 536, 140, 333, 539, 84, + /* 1460 */ 33, 346, 1431, 1432, 1433, 1434, 1435, 1439, 1440, 1441, + /* 1470 */ 1442, 540, 277, 1700, 86, 1905, 1355, 553, 560, 2005, + /* 1480 */ 2015, 6, 245, 600, 555, 556, 249, 338, 1855, 2020, + /* 1490 */ 599, 569, 563, 1996, 2019, 554, 552, 551, 259, 339, + /* 1500 */ 580, 577, 1470, 131, 1354, 57, 162, 254, 1955, 88, + /* 1510 */ 256, 1885, 1990, 1887, 605, 1921, 1743, 1670, 257, 97, + /* 1520 */ 1886, 1888, 603, 1890, 1891, 598, 258, 593, 280, 271, + /* 1530 */ 686, 687, 2062, 689, 1974, 1887, 2041, 292, 342, 1970, + /* 1540 */ 262, 306, 1905, 49, 2065, 282, 303, 302, 1993, 284, + /* 1550 */ 600, 1849, 1848, 68, 1847, 1855, 69, 599, 1846, 1843, + /* 1560 */ 367, 368, 1319, 1320, 1905, 177, 372, 1841, 374, 375, + /* 1570 */ 376, 1840, 600, 378, 1839, 380, 1838, 1855, 1885, 599, + /* 1580 */ 1837, 384, 1921, 382, 1295, 1294, 97, 1886, 1888, 603, + /* 1590 */ 1890, 1891, 598, 1887, 593, 1815, 1814, 389, 390, 1949, + /* 1600 */ 1885, 1974, 1813, 1812, 1921, 342, 1970, 134, 97, 1886, + /* 1610 */ 1888, 603, 1890, 1891, 598, 1887, 593, 1787, 1264, 345, + /* 1620 */ 344, 1947, 1905, 1974, 1786, 1784, 1783, 342, 1970, 1341, + /* 1630 */ 600, 1782, 1785, 135, 1781, 1855, 408, 599, 1780, 1779, + /* 1640 */ 1407, 1778, 1334, 1777, 1905, 1776, 409, 1775, 411, 1774, + /* 1650 */ 1773, 1772, 600, 1771, 1770, 1769, 1768, 1855, 1885, 599, + /* 1660 */ 1767, 1766, 1921, 1402, 1765, 1764, 97, 1886, 1888, 603, + /* 1670 */ 1890, 1891, 598, 1763, 593, 1333, 1762, 1761, 1760, 548, + /* 1680 */ 1885, 1974, 136, 1759, 1921, 342, 1970, 1148, 98, 1886, + /* 1690 */ 1888, 603, 1890, 1891, 598, 1758, 593, 1757, 1756, 1755, + /* 1700 */ 1754, 1266, 1753, 1974, 1752, 1617, 1616, 1973, 1970, 1614, + /* 1710 */ 1582, 190, 448, 187, 188, 166, 450, 1065, 1581, 123, + /* 1720 */ 124, 1064, 1887, 589, 191, 1828, 1822, 1811, 196, 198, + /* 1730 */ 1810, 1796, 1678, 1095, 1613, 1611, 465, 466, 1609, 470, + /* 1740 */ 1607, 474, 1605, 478, 1594, 1593, 469, 467, 1578, 473, + /* 1750 */ 1680, 1905, 471, 1679, 475, 477, 479, 1216, 1215, 600, + /* 1760 */ 1603, 1598, 59, 206, 1855, 502, 599, 658, 1139, 1132, + /* 1770 */ 1596, 660, 1138, 327, 1137, 1577, 1134, 328, 1133, 329, + /* 1780 */ 1576, 1131, 1342, 1575, 1337, 511, 99, 1885, 1311, 505, + /* 1790 */ 1887, 1921, 1827, 507, 509, 98, 1886, 1888, 603, 1890, + /* 1800 */ 1891, 598, 1821, 593, 53, 152, 1345, 1347, 1301, 1887, + /* 1810 */ 1974, 520, 1809, 25, 588, 1970, 1807, 2047, 1808, 1905, + /* 1820 */ 591, 1400, 1401, 1403, 1404, 1405, 1406, 597, 1309, 521, + /* 1830 */ 330, 1806, 1855, 225, 599, 1805, 1803, 1795, 1905, 526, + /* 1840 */ 83, 241, 537, 18, 238, 1419, 600, 230, 19, 20, + /* 1850 */ 534, 1855, 15, 599, 10, 1885, 236, 253, 82, 1921, + /* 1860 */ 90, 1876, 85, 300, 1886, 1888, 603, 1890, 1891, 598, + /* 1870 */ 596, 593, 546, 1939, 1885, 27, 1887, 1515, 1921, 246, + /* 1880 */ 244, 248, 98, 1886, 1888, 603, 1890, 1891, 598, 1497, + /* 1890 */ 593, 56, 1499, 1887, 160, 252, 29, 1974, 251, 61, + /* 1900 */ 22, 28, 1971, 1492, 89, 1905, 265, 1530, 1418, 1529, + /* 1910 */ 340, 1534, 1535, 597, 1536, 1533, 341, 1467, 1855, 1466, + /* 1920 */ 599, 55, 1905, 1875, 12, 163, 1343, 1924, 1429, 54, + /* 1930 */ 600, 164, 21, 1397, 592, 1855, 1887, 599, 1395, 35, + /* 1940 */ 14, 1885, 1375, 175, 1394, 1921, 1367, 604, 23, 300, + /* 1950 */ 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1885, 1940, + /* 1960 */ 24, 606, 1921, 1202, 351, 1905, 158, 1886, 1888, 603, + /* 1970 */ 1890, 1891, 598, 600, 593, 602, 608, 610, 1855, 1199, + /* 1980 */ 599, 611, 613, 1196, 614, 1905, 1190, 616, 617, 619, + /* 1990 */ 347, 1194, 620, 600, 1188, 1179, 91, 92, 1855, 626, + /* 2000 */ 599, 1885, 1211, 67, 1193, 1921, 269, 1887, 2012, 296, + /* 2010 */ 1886, 1888, 603, 1890, 1891, 598, 16, 593, 1192, 1191, + /* 2020 */ 1207, 1885, 1093, 635, 1128, 1921, 1127, 1126, 1125, 301, + /* 2030 */ 1886, 1888, 603, 1890, 1891, 598, 1905, 593, 1124, 1123, + /* 2040 */ 1121, 350, 1119, 1118, 600, 1117, 1146, 647, 1115, 1855, + /* 2050 */ 1114, 599, 270, 568, 1113, 1112, 1111, 1110, 1109, 1108, + /* 2060 */ 1141, 1105, 1143, 1104, 1101, 1100, 1099, 1610, 1098, 1608, + /* 2070 */ 668, 1606, 1885, 672, 669, 670, 1921, 676, 673, 674, + /* 2080 */ 301, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 678, + /* 2090 */ 677, 1604, 680, 681, 682, 1592, 684, 1055, 1574, 273, + /* 2100 */ 688, 1549, 1329, 281, 691, 1887, 692, 1549, 1549, 1549, + /* 2110 */ 1549, 1549, 1549, 1549, 1549, 1549, 1905, 1549, 1549, 1549, + /* 2120 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2130 */ 1549, 599, 1549, 1549, 1905, 1549, 1549, 1549, 1549, 1549, + /* 2140 */ 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, 1887, 599, + /* 2150 */ 1549, 1549, 514, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2160 */ 294, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1549, + /* 2170 */ 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1905, 286, 1886, + /* 2180 */ 1888, 603, 1890, 1891, 598, 600, 593, 1549, 1549, 1549, + /* 2190 */ 1855, 1887, 599, 1549, 1549, 1549, 1905, 1549, 1549, 1549, + /* 2200 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2210 */ 1549, 599, 1549, 1885, 1549, 1549, 1549, 1921, 1549, 1549, + /* 2220 */ 1905, 287, 1886, 1888, 603, 1890, 1891, 598, 600, 593, + /* 2230 */ 1549, 1549, 1885, 1855, 1887, 599, 1921, 1549, 1549, 1549, + /* 2240 */ 288, 1886, 1888, 603, 1890, 1891, 598, 1549, 593, 1549, + /* 2250 */ 1549, 1887, 1549, 1549, 1549, 1549, 1885, 1549, 1549, 1549, + /* 2260 */ 1921, 1549, 1549, 1905, 295, 1886, 1888, 603, 1890, 1891, + /* 2270 */ 598, 600, 593, 1549, 1549, 1549, 1855, 1887, 599, 1549, + /* 2280 */ 1905, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 600, 1549, + /* 2290 */ 1549, 1549, 1549, 1855, 1887, 599, 1549, 1549, 1549, 1885, + /* 2300 */ 1549, 1549, 1549, 1921, 1549, 1549, 1905, 297, 1886, 1888, + /* 2310 */ 603, 1890, 1891, 598, 600, 593, 1885, 1549, 1549, 1855, + /* 2320 */ 1921, 599, 1549, 1905, 289, 1886, 1888, 603, 1890, 1891, + /* 2330 */ 598, 600, 593, 1549, 1549, 1549, 1855, 1549, 599, 1549, + /* 2340 */ 1549, 1549, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2350 */ 298, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1885, + /* 2360 */ 1549, 1549, 1549, 1921, 1549, 1549, 1549, 290, 1886, 1888, + /* 2370 */ 603, 1890, 1891, 598, 1887, 593, 1549, 1549, 1549, 1549, + /* 2380 */ 1549, 1549, 1549, 1549, 1549, 1549, 1905, 1549, 1549, 1549, + /* 2390 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2400 */ 1549, 599, 1549, 1905, 1549, 1549, 1549, 1549, 1549, 1549, + /* 2410 */ 1549, 600, 1549, 1549, 1549, 1549, 1855, 1549, 599, 1549, + /* 2420 */ 1549, 1549, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2430 */ 299, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1885, + /* 2440 */ 1549, 1549, 1549, 1921, 1549, 1549, 1549, 291, 1886, 1888, + /* 2450 */ 603, 1890, 1891, 598, 1549, 593, 1549, 1549, 1549, 1549, + /* 2460 */ 1549, 1549, 1549, 1887, 1549, 1549, 1905, 1549, 1549, 1549, + /* 2470 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2480 */ 1549, 599, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, + /* 2490 */ 1549, 1549, 1905, 1549, 1549, 1549, 1549, 1549, 1549, 1549, + /* 2500 */ 600, 1549, 1885, 1549, 1549, 1855, 1921, 599, 1549, 1549, + /* 2510 */ 304, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1549, + /* 2520 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1885, 1549, + /* 2530 */ 1549, 1549, 1921, 1549, 1887, 1549, 305, 1886, 1888, 603, + /* 2540 */ 1890, 1891, 598, 1549, 593, 1549, 1905, 1549, 1549, 1549, + /* 2550 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2560 */ 1549, 599, 1549, 1905, 1549, 1549, 1549, 1549, 1549, 1549, + /* 2570 */ 1549, 600, 1549, 1549, 1549, 1549, 1855, 1887, 599, 1549, + /* 2580 */ 1549, 1549, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2590 */ 1899, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1885, + /* 2600 */ 1549, 1549, 1549, 1921, 1549, 1549, 1905, 1898, 1886, 1888, + /* 2610 */ 603, 1890, 1891, 598, 600, 593, 1549, 1549, 1549, 1855, + /* 2620 */ 1549, 599, 1549, 1549, 1549, 1549, 1905, 1549, 1549, 1549, + /* 2630 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2640 */ 1887, 599, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2650 */ 1897, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1549, + /* 2660 */ 1549, 1549, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1905, + /* 2670 */ 316, 1886, 1888, 603, 1890, 1891, 598, 600, 593, 1549, + /* 2680 */ 1549, 1549, 1855, 1549, 599, 1549, 1905, 1549, 1549, 1549, + /* 2690 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2700 */ 1549, 599, 1549, 1549, 1549, 1885, 1549, 1549, 1549, 1921, + /* 2710 */ 1549, 1549, 1549, 317, 1886, 1888, 603, 1890, 1891, 598, + /* 2720 */ 1887, 593, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2730 */ 313, 1886, 1888, 603, 1890, 1891, 598, 1887, 593, 1549, + /* 2740 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1905, + /* 2750 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 600, 1549, 1549, + /* 2760 */ 1549, 1549, 1855, 1549, 599, 1549, 1905, 1549, 1549, 1549, + /* 2770 */ 1549, 1549, 1549, 1549, 600, 1549, 1549, 1549, 1549, 1855, + /* 2780 */ 1549, 599, 1549, 1549, 1549, 1885, 1549, 1549, 1549, 1921, + /* 2790 */ 1549, 1549, 1549, 318, 1886, 1888, 603, 1890, 1891, 598, + /* 2800 */ 1549, 593, 1885, 1549, 1549, 1549, 1921, 1549, 1549, 1549, + /* 2810 */ 293, 1886, 1888, 603, 1890, 1891, 598, 1549, 593, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 351, 409, 410, 351, 0, 4, 324, 320, 326, 327, - /* 10 */ 351, 362, 12, 13, 362, 324, 328, 326, 327, 350, - /* 20 */ 20, 362, 22, 12, 13, 14, 15, 16, 20, 14, - /* 30 */ 15, 16, 319, 33, 321, 35, 349, 388, 389, 390, - /* 40 */ 388, 389, 390, 20, 357, 44, 45, 388, 389, 362, - /* 50 */ 401, 364, 2, 401, 366, 320, 56, 20, 8, 9, + /* 0 */ 351, 409, 410, 351, 319, 4, 321, 320, 4, 364, + /* 10 */ 351, 362, 12, 13, 362, 324, 371, 326, 327, 374, + /* 20 */ 20, 362, 22, 12, 13, 14, 15, 16, 20, 333, + /* 30 */ 348, 317, 20, 33, 338, 35, 349, 388, 389, 390, + /* 40 */ 388, 389, 390, 361, 357, 44, 45, 388, 389, 362, + /* 50 */ 401, 364, 2, 401, 325, 320, 56, 328, 8, 9, /* 60 */ 401, 61, 12, 13, 14, 15, 16, 320, 68, 12, - /* 70 */ 13, 14, 385, 20, 60, 22, 389, 20, 394, 22, - /* 80 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 3, - /* 90 */ 33, 60, 35, 406, 94, 408, 349, 362, 20, 412, - /* 100 */ 413, 20, 341, 50, 357, 328, 20, 423, 349, 362, - /* 110 */ 349, 364, 425, 56, 320, 356, 116, 94, 61, 358, - /* 120 */ 433, 328, 438, 439, 365, 68, 0, 443, 444, 362, - /* 130 */ 130, 131, 385, 340, 357, 0, 389, 0, 130, 131, - /* 140 */ 393, 394, 395, 396, 397, 398, 399, 364, 401, 360, - /* 150 */ 357, 94, 363, 364, 371, 408, 362, 374, 21, 412, - /* 160 */ 413, 24, 25, 26, 27, 28, 29, 30, 31, 32, - /* 170 */ 423, 394, 333, 116, 14, 94, 176, 338, 178, 94, - /* 180 */ 20, 95, 47, 21, 320, 438, 439, 130, 131, 56, - /* 190 */ 443, 444, 415, 416, 417, 418, 34, 420, 36, 20, - /* 200 */ 200, 201, 391, 203, 204, 205, 206, 207, 208, 209, + /* 70 */ 13, 14, 385, 320, 4, 20, 389, 20, 394, 22, + /* 80 */ 393, 394, 395, 396, 397, 398, 399, 332, 401, 19, + /* 90 */ 33, 377, 35, 406, 94, 408, 349, 362, 94, 412, + /* 100 */ 413, 346, 94, 33, 357, 328, 94, 423, 394, 362, + /* 110 */ 355, 364, 425, 56, 60, 362, 116, 47, 61, 320, + /* 120 */ 433, 51, 438, 439, 20, 68, 56, 443, 444, 3, + /* 130 */ 130, 131, 385, 394, 357, 328, 389, 423, 328, 320, + /* 140 */ 393, 394, 395, 396, 397, 398, 399, 324, 401, 326, + /* 150 */ 327, 94, 438, 439, 20, 408, 22, 443, 444, 412, + /* 160 */ 413, 362, 423, 93, 357, 4, 96, 94, 14, 35, + /* 170 */ 423, 394, 341, 116, 20, 175, 366, 177, 439, 126, + /* 180 */ 349, 362, 443, 444, 50, 438, 439, 130, 131, 358, + /* 190 */ 443, 444, 415, 416, 417, 418, 20, 420, 94, 199, + /* 200 */ 200, 394, 202, 203, 204, 205, 206, 207, 208, 209, /* 210 */ 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, - /* 220 */ 220, 221, 222, 223, 33, 325, 362, 94, 328, 96, - /* 230 */ 419, 325, 106, 176, 328, 178, 0, 342, 47, 0, - /* 240 */ 345, 241, 200, 52, 53, 54, 55, 56, 351, 163, - /* 250 */ 94, 125, 126, 127, 128, 129, 105, 200, 201, 362, + /* 220 */ 220, 221, 222, 416, 417, 418, 0, 420, 363, 364, + /* 230 */ 423, 14, 175, 170, 177, 182, 183, 20, 377, 186, + /* 240 */ 240, 199, 335, 336, 240, 438, 439, 174, 240, 176, + /* 250 */ 443, 444, 240, 190, 191, 394, 199, 200, 94, 202, /* 260 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, /* 270 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - /* 280 */ 223, 12, 13, 225, 93, 388, 389, 96, 225, 20, - /* 290 */ 227, 22, 250, 251, 252, 253, 254, 126, 401, 63, - /* 300 */ 64, 65, 33, 328, 35, 94, 21, 71, 72, 24, - /* 310 */ 25, 26, 27, 28, 29, 30, 31, 32, 82, 83, - /* 320 */ 20, 106, 241, 328, 88, 56, 241, 4, 363, 364, - /* 330 */ 61, 394, 357, 320, 348, 340, 0, 68, 12, 13, - /* 340 */ 125, 126, 127, 128, 129, 106, 20, 361, 22, 328, - /* 350 */ 159, 160, 357, 162, 183, 184, 349, 166, 187, 33, - /* 360 */ 423, 35, 349, 94, 125, 126, 127, 128, 129, 394, - /* 370 */ 357, 349, 365, 182, 241, 362, 439, 364, 357, 357, - /* 380 */ 443, 444, 56, 35, 20, 116, 175, 61, 177, 125, - /* 390 */ 126, 416, 417, 418, 68, 420, 60, 241, 385, 130, - /* 400 */ 131, 330, 389, 0, 20, 341, 393, 394, 395, 396, - /* 410 */ 397, 398, 399, 349, 401, 394, 68, 94, 396, 406, - /* 420 */ 94, 408, 358, 352, 328, 412, 413, 24, 25, 26, - /* 430 */ 27, 28, 29, 30, 31, 32, 340, 416, 417, 418, - /* 440 */ 332, 420, 116, 347, 423, 176, 433, 178, 184, 335, - /* 450 */ 336, 187, 241, 357, 346, 349, 130, 131, 94, 438, - /* 460 */ 439, 320, 356, 355, 443, 444, 405, 350, 407, 200, - /* 470 */ 201, 365, 203, 204, 205, 206, 207, 208, 209, 210, - /* 480 */ 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, - /* 490 */ 221, 222, 223, 161, 225, 405, 373, 407, 375, 78, - /* 500 */ 335, 336, 176, 362, 178, 332, 107, 108, 109, 110, - /* 510 */ 111, 112, 113, 114, 115, 116, 117, 320, 119, 120, - /* 520 */ 121, 122, 123, 124, 320, 394, 200, 201, 355, 203, - /* 530 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, - /* 540 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, - /* 550 */ 12, 13, 364, 328, 423, 134, 135, 320, 20, 362, - /* 560 */ 22, 20, 374, 22, 241, 340, 362, 391, 44, 45, - /* 570 */ 439, 33, 347, 35, 443, 444, 35, 171, 246, 247, - /* 580 */ 8, 9, 357, 320, 12, 13, 14, 15, 16, 328, - /* 590 */ 14, 50, 20, 391, 56, 419, 20, 191, 192, 362, - /* 600 */ 404, 340, 320, 407, 328, 241, 68, 12, 13, 14, - /* 610 */ 56, 328, 349, 320, 328, 20, 340, 22, 357, 381, - /* 620 */ 357, 419, 37, 340, 3, 362, 340, 364, 33, 349, - /* 630 */ 35, 349, 94, 357, 68, 158, 356, 328, 20, 357, - /* 640 */ 357, 328, 68, 357, 362, 365, 364, 93, 385, 340, - /* 650 */ 96, 56, 389, 340, 116, 362, 393, 394, 395, 396, - /* 660 */ 397, 398, 399, 68, 401, 4, 357, 385, 130, 131, - /* 670 */ 357, 389, 125, 3, 394, 393, 394, 395, 396, 397, - /* 680 */ 398, 399, 97, 401, 99, 100, 423, 102, 406, 94, - /* 690 */ 408, 106, 8, 9, 412, 413, 12, 13, 14, 15, - /* 700 */ 16, 438, 439, 423, 422, 228, 443, 444, 328, 22, - /* 710 */ 357, 116, 0, 128, 176, 238, 178, 317, 438, 439, - /* 720 */ 340, 368, 35, 443, 444, 130, 131, 43, 14, 357, - /* 730 */ 1, 2, 185, 186, 20, 163, 320, 357, 200, 201, - /* 740 */ 368, 203, 204, 205, 206, 207, 208, 209, 210, 211, - /* 750 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, - /* 760 */ 222, 223, 8, 9, 328, 95, 12, 13, 14, 15, - /* 770 */ 16, 176, 60, 178, 357, 106, 340, 377, 362, 241, - /* 780 */ 204, 163, 8, 9, 320, 368, 12, 13, 14, 15, - /* 790 */ 16, 20, 320, 357, 394, 200, 201, 128, 203, 204, - /* 800 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, - /* 810 */ 215, 216, 217, 218, 219, 220, 221, 222, 223, 12, - /* 820 */ 13, 328, 22, 423, 95, 20, 362, 20, 373, 22, - /* 830 */ 375, 239, 240, 340, 362, 35, 320, 330, 438, 439, - /* 840 */ 33, 328, 35, 443, 444, 328, 320, 63, 64, 65, - /* 850 */ 357, 344, 320, 340, 350, 71, 72, 340, 337, 352, - /* 860 */ 339, 328, 320, 56, 320, 320, 82, 83, 68, 320, - /* 870 */ 357, 320, 88, 340, 357, 68, 12, 13, 362, 258, - /* 880 */ 328, 349, 320, 328, 20, 43, 22, 43, 362, 357, - /* 890 */ 357, 39, 340, 328, 362, 340, 364, 33, 350, 35, - /* 900 */ 349, 94, 341, 242, 362, 340, 362, 362, 357, 357, - /* 910 */ 349, 362, 357, 362, 56, 364, 116, 385, 204, 358, - /* 920 */ 56, 389, 357, 116, 362, 393, 394, 395, 396, 397, - /* 930 */ 398, 399, 68, 401, 163, 105, 385, 130, 131, 95, - /* 940 */ 389, 328, 168, 328, 393, 394, 395, 396, 397, 398, - /* 950 */ 399, 349, 401, 340, 96, 340, 350, 406, 94, 408, - /* 960 */ 358, 350, 359, 412, 413, 362, 434, 435, 359, 61, - /* 970 */ 357, 362, 357, 422, 342, 0, 176, 345, 178, 43, - /* 980 */ 116, 42, 43, 176, 154, 178, 98, 98, 98, 101, - /* 990 */ 101, 101, 43, 98, 130, 131, 101, 22, 163, 164, - /* 1000 */ 200, 201, 130, 131, 1, 2, 43, 200, 201, 204, - /* 1010 */ 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, - /* 1020 */ 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, - /* 1030 */ 223, 95, 350, 338, 321, 43, 35, 263, 0, 0, - /* 1040 */ 176, 43, 178, 2, 95, 392, 46, 43, 447, 8, - /* 1050 */ 9, 43, 43, 12, 13, 14, 15, 16, 95, 35, - /* 1060 */ 22, 22, 35, 43, 200, 201, 0, 203, 204, 205, - /* 1070 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, - /* 1080 */ 216, 217, 218, 219, 220, 221, 222, 223, 18, 329, - /* 1090 */ 20, 94, 240, 95, 94, 68, 13, 27, 13, 95, - /* 1100 */ 30, 104, 260, 95, 95, 430, 8, 9, 200, 436, - /* 1110 */ 12, 13, 14, 15, 16, 95, 43, 47, 35, 49, - /* 1120 */ 35, 51, 349, 329, 327, 361, 392, 421, 440, 63, - /* 1130 */ 64, 65, 66, 67, 43, 69, 70, 71, 72, 73, - /* 1140 */ 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, - /* 1150 */ 84, 85, 86, 87, 88, 89, 90, 18, 414, 424, - /* 1160 */ 243, 47, 23, 93, 387, 386, 8, 9, 95, 174, - /* 1170 */ 12, 13, 14, 15, 16, 105, 37, 38, 377, 178, - /* 1180 */ 41, 0, 379, 43, 8, 9, 95, 42, 12, 13, - /* 1190 */ 14, 15, 16, 95, 43, 394, 57, 58, 59, 20, - /* 1200 */ 369, 369, 178, 133, 328, 320, 136, 137, 138, 139, - /* 1210 */ 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, - /* 1220 */ 150, 151, 152, 153, 423, 155, 156, 157, 328, 48, - /* 1230 */ 369, 334, 158, 94, 349, 95, 43, 367, 43, 438, - /* 1240 */ 439, 367, 357, 328, 443, 444, 95, 362, 92, 364, - /* 1250 */ 43, 8, 9, 95, 262, 12, 13, 14, 15, 16, - /* 1260 */ 328, 20, 328, 322, 322, 20, 383, 332, 364, 332, - /* 1270 */ 385, 132, 20, 20, 389, 376, 378, 332, 393, 394, - /* 1280 */ 395, 396, 397, 398, 399, 376, 401, 332, 95, 404, - /* 1290 */ 95, 406, 407, 408, 332, 328, 332, 412, 413, 322, - /* 1300 */ 332, 377, 95, 377, 61, 349, 349, 168, 169, 170, - /* 1310 */ 377, 328, 173, 322, 349, 349, 320, 189, 394, 349, - /* 1320 */ 394, 349, 349, 349, 384, 349, 383, 394, 349, 190, - /* 1330 */ 349, 362, 193, 181, 195, 196, 197, 198, 199, 163, - /* 1340 */ 330, 382, 364, 330, 328, 349, 103, 423, 330, 423, - /* 1350 */ 328, 248, 372, 357, 372, 362, 423, 370, 362, 160, - /* 1360 */ 364, 377, 438, 439, 438, 439, 376, 443, 444, 443, - /* 1370 */ 444, 438, 439, 362, 362, 330, 443, 444, 394, 362, - /* 1380 */ 241, 385, 345, 362, 330, 389, 357, 20, 362, 393, - /* 1390 */ 394, 395, 396, 397, 398, 399, 249, 401, 392, 392, - /* 1400 */ 429, 158, 406, 372, 408, 362, 362, 423, 412, 413, - /* 1410 */ 19, 362, 372, 362, 429, 255, 167, 431, 422, 257, - /* 1420 */ 432, 320, 438, 439, 33, 256, 427, 443, 444, 244, - /* 1430 */ 264, 429, 261, 428, 387, 357, 442, 448, 47, 259, - /* 1440 */ 426, 240, 20, 52, 53, 54, 55, 56, 391, 94, - /* 1450 */ 349, 94, 353, 411, 362, 339, 441, 328, 357, 328, - /* 1460 */ 330, 36, 380, 362, 320, 364, 323, 343, 322, 375, - /* 1470 */ 343, 228, 229, 230, 231, 232, 233, 234, 235, 236, - /* 1480 */ 237, 238, 318, 0, 93, 343, 385, 96, 357, 0, - /* 1490 */ 389, 183, 331, 349, 393, 394, 395, 396, 397, 398, - /* 1500 */ 399, 357, 401, 0, 0, 42, 362, 406, 364, 408, - /* 1510 */ 0, 12, 13, 412, 413, 35, 194, 320, 194, 35, - /* 1520 */ 129, 22, 35, 35, 0, 394, 35, 35, 194, 385, - /* 1530 */ 0, 194, 33, 389, 35, 0, 35, 393, 394, 395, - /* 1540 */ 396, 397, 398, 399, 35, 401, 349, 416, 417, 418, - /* 1550 */ 406, 420, 408, 162, 357, 56, 412, 413, 0, 362, - /* 1560 */ 22, 364, 0, 178, 176, 0, 0, 68, 172, 171, - /* 1570 */ 320, 180, 0, 182, 0, 46, 0, 0, 0, 42, - /* 1580 */ 0, 0, 385, 0, 42, 0, 389, 0, 0, 0, - /* 1590 */ 393, 394, 395, 396, 397, 398, 399, 0, 401, 349, - /* 1600 */ 0, 149, 35, 406, 149, 408, 0, 357, 0, 412, - /* 1610 */ 413, 0, 362, 320, 364, 116, 0, 0, 0, 0, - /* 1620 */ 0, 0, 0, 0, 0, 0, 0, 0, 42, 0, - /* 1630 */ 0, 0, 0, 0, 0, 385, 22, 0, 0, 389, - /* 1640 */ 0, 0, 349, 393, 394, 395, 396, 397, 398, 399, - /* 1650 */ 357, 401, 0, 0, 56, 362, 0, 364, 408, 56, - /* 1660 */ 0, 46, 412, 413, 14, 14, 320, 39, 0, 0, - /* 1670 */ 35, 0, 0, 167, 0, 176, 0, 178, 385, 43, - /* 1680 */ 0, 42, 389, 40, 39, 39, 393, 394, 395, 396, - /* 1690 */ 397, 398, 399, 0, 401, 349, 0, 35, 39, 200, - /* 1700 */ 201, 408, 47, 357, 46, 412, 413, 0, 362, 39, - /* 1710 */ 364, 62, 35, 214, 215, 216, 217, 218, 219, 220, - /* 1720 */ 47, 0, 320, 35, 39, 47, 0, 35, 47, 39, - /* 1730 */ 0, 385, 0, 0, 0, 389, 35, 22, 0, 393, - /* 1740 */ 394, 395, 396, 397, 398, 399, 400, 401, 402, 403, - /* 1750 */ 22, 349, 35, 43, 35, 35, 43, 103, 101, 357, - /* 1760 */ 35, 0, 35, 22, 362, 0, 364, 22, 0, 22, - /* 1770 */ 35, 49, 35, 0, 35, 0, 0, 35, 22, 20, - /* 1780 */ 0, 95, 0, 94, 320, 35, 179, 385, 22, 4, - /* 1790 */ 0, 389, 0, 0, 3, 393, 394, 395, 396, 397, - /* 1800 */ 398, 399, 0, 401, 19, 163, 0, 163, 160, 95, - /* 1810 */ 94, 0, 35, 349, 0, 104, 46, 94, 33, 224, - /* 1820 */ 39, 357, 43, 94, 163, 94, 362, 161, 364, 43, - /* 1830 */ 165, 226, 47, 224, 159, 245, 51, 94, 43, 95, - /* 1840 */ 94, 56, 320, 95, 95, 94, 94, 445, 446, 385, - /* 1850 */ 95, 188, 94, 389, 94, 43, 46, 393, 394, 395, - /* 1860 */ 396, 397, 398, 399, 320, 401, 95, 46, 94, 43, - /* 1870 */ 3, 349, 408, 95, 43, 35, 354, 413, 93, 357, - /* 1880 */ 35, 96, 95, 35, 362, 35, 364, 35, 35, 95, - /* 1890 */ 46, 95, 43, 349, 2, 22, 95, 46, 200, 94, - /* 1900 */ 46, 357, 94, 46, 95, 46, 362, 385, 364, 94, - /* 1910 */ 94, 389, 245, 95, 94, 393, 394, 395, 396, 397, - /* 1920 */ 398, 399, 239, 401, 320, 95, 22, 245, 94, 385, - /* 1930 */ 105, 95, 35, 389, 35, 94, 35, 393, 394, 395, - /* 1940 */ 396, 397, 398, 399, 35, 401, 35, 403, 35, 22, - /* 1950 */ 95, 95, 94, 349, 94, 202, 95, 94, 35, 95, - /* 1960 */ 94, 357, 43, 22, 118, 118, 362, 320, 364, 94, - /* 1970 */ 94, 94, 62, 61, 35, 106, 68, 35, 35, 35, - /* 1980 */ 118, 35, 35, 43, 320, 35, 118, 35, 35, 385, - /* 1990 */ 35, 91, 35, 389, 35, 22, 349, 393, 394, 395, - /* 2000 */ 396, 397, 398, 399, 357, 401, 35, 22, 22, 362, - /* 2010 */ 35, 364, 35, 349, 35, 35, 35, 68, 35, 35, - /* 2020 */ 0, 357, 35, 35, 35, 47, 362, 0, 364, 39, - /* 2030 */ 35, 39, 385, 0, 35, 39, 389, 0, 320, 435, - /* 2040 */ 393, 394, 395, 396, 397, 398, 399, 47, 401, 385, - /* 2050 */ 47, 35, 47, 389, 39, 0, 320, 393, 394, 395, - /* 2060 */ 396, 397, 398, 399, 35, 401, 35, 349, 0, 22, - /* 2070 */ 21, 21, 354, 22, 22, 357, 20, 449, 449, 449, - /* 2080 */ 362, 449, 364, 449, 437, 349, 449, 449, 449, 449, - /* 2090 */ 354, 449, 449, 357, 449, 449, 449, 449, 362, 449, - /* 2100 */ 364, 449, 449, 385, 449, 449, 449, 389, 449, 449, - /* 2110 */ 446, 393, 394, 395, 396, 397, 398, 399, 320, 401, - /* 2120 */ 449, 385, 449, 449, 449, 389, 449, 449, 449, 393, - /* 2130 */ 394, 395, 396, 397, 398, 399, 449, 401, 449, 449, - /* 2140 */ 449, 449, 320, 449, 449, 449, 449, 349, 449, 449, - /* 2150 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, - /* 2160 */ 362, 449, 364, 449, 449, 449, 449, 449, 449, 449, - /* 2170 */ 449, 349, 449, 449, 449, 449, 449, 449, 449, 357, - /* 2180 */ 449, 449, 449, 385, 362, 320, 364, 389, 449, 449, - /* 2190 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, - /* 2200 */ 449, 449, 449, 449, 449, 320, 449, 385, 449, 449, - /* 2210 */ 449, 389, 449, 449, 349, 393, 394, 395, 396, 397, - /* 2220 */ 398, 399, 357, 401, 449, 449, 449, 362, 449, 364, - /* 2230 */ 449, 449, 449, 449, 349, 449, 449, 449, 449, 449, - /* 2240 */ 449, 449, 357, 449, 449, 449, 449, 362, 449, 364, - /* 2250 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, - /* 2260 */ 395, 396, 397, 398, 399, 449, 401, 449, 320, 449, - /* 2270 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, - /* 2280 */ 395, 396, 397, 398, 399, 449, 401, 320, 449, 449, - /* 2290 */ 449, 449, 449, 449, 449, 449, 449, 349, 449, 449, - /* 2300 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, - /* 2310 */ 362, 449, 364, 449, 449, 449, 349, 449, 449, 449, - /* 2320 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, - /* 2330 */ 320, 364, 449, 385, 449, 449, 449, 389, 449, 449, - /* 2340 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, - /* 2350 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 349, - /* 2360 */ 393, 394, 395, 396, 397, 398, 399, 357, 401, 449, - /* 2370 */ 449, 449, 362, 449, 364, 449, 449, 449, 449, 449, - /* 2380 */ 449, 320, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2390 */ 449, 449, 449, 449, 449, 385, 449, 449, 449, 389, - /* 2400 */ 449, 320, 449, 393, 394, 395, 396, 397, 398, 399, - /* 2410 */ 349, 401, 449, 449, 449, 449, 449, 449, 357, 449, - /* 2420 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 449, - /* 2430 */ 349, 449, 449, 449, 449, 449, 449, 449, 357, 449, - /* 2440 */ 449, 449, 449, 362, 449, 364, 385, 449, 449, 449, - /* 2450 */ 389, 449, 320, 449, 393, 394, 395, 396, 397, 398, - /* 2460 */ 399, 449, 401, 449, 449, 449, 385, 449, 449, 449, - /* 2470 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, - /* 2480 */ 399, 349, 401, 449, 449, 449, 449, 449, 449, 357, - /* 2490 */ 449, 449, 449, 449, 362, 449, 364, 449, 449, 449, - /* 2500 */ 449, 449, 449, 449, 449, 320, 449, 449, 449, 449, - /* 2510 */ 449, 449, 449, 449, 449, 449, 449, 385, 449, 449, - /* 2520 */ 449, 389, 449, 449, 449, 393, 394, 395, 396, 397, - /* 2530 */ 398, 399, 449, 401, 349, 449, 449, 449, 449, 449, - /* 2540 */ 449, 449, 357, 449, 449, 449, 449, 362, 320, 364, - /* 2550 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2560 */ 449, 449, 449, 449, 449, 449, 449, 449, 320, 449, - /* 2570 */ 385, 449, 449, 449, 389, 449, 449, 349, 393, 394, - /* 2580 */ 395, 396, 397, 398, 399, 357, 401, 449, 449, 449, - /* 2590 */ 362, 449, 364, 449, 449, 449, 449, 349, 449, 449, - /* 2600 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, - /* 2610 */ 362, 449, 364, 385, 449, 449, 449, 389, 449, 449, - /* 2620 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, - /* 2630 */ 449, 320, 449, 385, 449, 449, 449, 389, 449, 449, - /* 2640 */ 449, 393, 394, 395, 396, 397, 398, 399, 449, 401, - /* 2650 */ 320, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2660 */ 349, 449, 449, 449, 449, 449, 449, 449, 357, 449, - /* 2670 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 349, - /* 2680 */ 449, 449, 449, 449, 449, 449, 449, 357, 449, 449, - /* 2690 */ 449, 449, 362, 320, 364, 449, 385, 449, 449, 449, - /* 2700 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, - /* 2710 */ 399, 449, 401, 449, 449, 385, 449, 449, 449, 389, - /* 2720 */ 449, 449, 349, 393, 394, 395, 396, 397, 398, 399, - /* 2730 */ 357, 401, 449, 449, 449, 362, 449, 364, 449, 449, - /* 2740 */ 449, 449, 449, 449, 320, 449, 449, 449, 449, 449, - /* 2750 */ 449, 449, 449, 449, 449, 449, 449, 449, 385, 449, - /* 2760 */ 449, 449, 389, 449, 320, 449, 393, 394, 395, 396, - /* 2770 */ 397, 398, 399, 349, 401, 449, 449, 449, 449, 449, - /* 2780 */ 449, 357, 449, 449, 449, 449, 362, 449, 364, 449, - /* 2790 */ 449, 449, 449, 349, 449, 449, 449, 449, 449, 449, - /* 2800 */ 449, 357, 449, 449, 449, 449, 362, 449, 364, 385, - /* 2810 */ 449, 449, 449, 389, 449, 320, 449, 393, 394, 395, - /* 2820 */ 396, 397, 398, 399, 449, 401, 449, 449, 449, 385, - /* 2830 */ 449, 449, 449, 389, 449, 449, 449, 393, 394, 395, - /* 2840 */ 396, 397, 398, 399, 349, 401, 449, 449, 449, 449, - /* 2850 */ 449, 449, 357, 449, 449, 449, 449, 362, 449, 364, - /* 2860 */ 449, 449, 449, 449, 449, 449, 449, 449, 320, 449, - /* 2870 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2880 */ 385, 449, 449, 449, 389, 449, 449, 449, 393, 394, - /* 2890 */ 395, 396, 397, 398, 399, 449, 401, 349, 449, 449, - /* 2900 */ 449, 449, 449, 449, 449, 357, 449, 449, 449, 449, - /* 2910 */ 362, 320, 364, 449, 449, 449, 449, 449, 449, 449, - /* 2920 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2930 */ 449, 449, 449, 385, 449, 449, 449, 389, 449, 449, - /* 2940 */ 349, 393, 394, 395, 396, 397, 398, 399, 357, 401, - /* 2950 */ 449, 449, 449, 362, 449, 364, 449, 449, 449, 449, - /* 2960 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 449, - /* 2970 */ 449, 449, 449, 449, 449, 449, 385, 449, 449, 449, - /* 2980 */ 389, 449, 449, 449, 393, 394, 395, 396, 397, 398, - /* 2990 */ 399, 449, 401, + /* 280 */ 12, 13, 19, 56, 423, 125, 126, 105, 20, 332, + /* 290 */ 22, 249, 250, 251, 252, 253, 33, 328, 320, 438, + /* 300 */ 439, 33, 328, 35, 443, 444, 130, 131, 320, 340, + /* 310 */ 47, 351, 355, 240, 340, 52, 53, 54, 55, 56, + /* 320 */ 93, 347, 362, 96, 56, 342, 357, 349, 345, 61, + /* 330 */ 360, 357, 106, 363, 364, 357, 68, 12, 13, 20, + /* 340 */ 362, 22, 364, 183, 43, 20, 186, 22, 388, 389, + /* 350 */ 362, 125, 126, 127, 128, 129, 93, 203, 33, 96, + /* 360 */ 35, 401, 94, 385, 14, 160, 328, 389, 106, 50, + /* 370 */ 20, 393, 394, 395, 396, 397, 398, 399, 340, 401, + /* 380 */ 94, 56, 0, 257, 116, 347, 61, 125, 126, 127, + /* 390 */ 128, 129, 129, 68, 320, 357, 95, 325, 130, 131, + /* 400 */ 328, 423, 241, 21, 240, 35, 24, 25, 26, 27, + /* 410 */ 28, 29, 30, 31, 32, 20, 438, 439, 391, 94, + /* 420 */ 203, 443, 444, 21, 161, 56, 24, 25, 26, 27, + /* 430 */ 28, 29, 30, 31, 32, 328, 362, 328, 68, 78, + /* 440 */ 328, 116, 179, 175, 181, 177, 419, 340, 20, 340, + /* 450 */ 245, 246, 340, 8, 9, 130, 131, 12, 13, 14, + /* 460 */ 15, 16, 320, 94, 357, 96, 357, 199, 200, 357, + /* 470 */ 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, + /* 480 */ 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + /* 490 */ 222, 224, 224, 226, 39, 134, 135, 14, 15, 16, + /* 500 */ 175, 405, 177, 407, 362, 37, 107, 108, 109, 110, + /* 510 */ 111, 112, 113, 114, 115, 116, 117, 60, 119, 120, + /* 520 */ 121, 122, 123, 124, 199, 200, 240, 202, 203, 204, + /* 530 */ 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, + /* 540 */ 215, 216, 217, 218, 219, 220, 221, 222, 12, 13, + /* 550 */ 349, 328, 349, 63, 64, 65, 20, 356, 22, 0, + /* 560 */ 357, 71, 72, 340, 328, 97, 365, 99, 100, 33, + /* 570 */ 102, 35, 82, 83, 106, 20, 340, 320, 88, 320, + /* 580 */ 357, 320, 21, 24, 25, 26, 27, 28, 29, 30, + /* 590 */ 31, 32, 56, 357, 341, 34, 128, 36, 203, 396, + /* 600 */ 320, 349, 349, 320, 68, 12, 13, 14, 356, 240, + /* 610 */ 349, 358, 167, 20, 3, 22, 341, 365, 357, 362, + /* 620 */ 20, 362, 0, 362, 349, 364, 33, 349, 35, 349, + /* 630 */ 94, 20, 0, 358, 356, 394, 224, 357, 125, 328, + /* 640 */ 1, 2, 362, 365, 364, 362, 385, 320, 0, 56, + /* 650 */ 389, 340, 116, 377, 393, 394, 395, 396, 397, 398, + /* 660 */ 399, 68, 401, 0, 423, 385, 130, 131, 357, 389, + /* 670 */ 394, 328, 394, 393, 394, 395, 396, 397, 398, 399, + /* 680 */ 439, 401, 60, 340, 443, 444, 406, 94, 408, 362, + /* 690 */ 330, 157, 412, 413, 239, 434, 435, 184, 185, 423, + /* 700 */ 357, 423, 422, 20, 344, 330, 95, 262, 60, 116, + /* 710 */ 47, 175, 352, 177, 438, 439, 438, 439, 364, 443, + /* 720 */ 444, 443, 444, 130, 131, 8, 9, 352, 374, 12, + /* 730 */ 13, 14, 15, 16, 95, 199, 200, 20, 202, 203, + /* 740 */ 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, + /* 750 */ 214, 215, 216, 217, 218, 219, 220, 221, 222, 8, + /* 760 */ 9, 227, 162, 12, 13, 14, 15, 16, 175, 0, + /* 770 */ 177, 237, 20, 162, 8, 9, 240, 2, 12, 13, + /* 780 */ 14, 15, 16, 8, 9, 320, 320, 12, 13, 14, + /* 790 */ 15, 16, 199, 200, 320, 202, 203, 204, 205, 206, + /* 800 */ 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, + /* 810 */ 217, 218, 219, 220, 221, 222, 12, 13, 405, 328, + /* 820 */ 407, 335, 336, 373, 20, 375, 22, 362, 362, 373, + /* 830 */ 22, 375, 63, 64, 65, 68, 362, 33, 328, 35, + /* 840 */ 71, 72, 328, 35, 357, 357, 95, 20, 357, 320, + /* 850 */ 340, 82, 83, 320, 340, 368, 368, 88, 8, 9, + /* 860 */ 56, 95, 12, 13, 14, 15, 16, 357, 320, 357, + /* 870 */ 328, 357, 68, 12, 13, 328, 350, 328, 349, 162, + /* 880 */ 368, 20, 340, 22, 349, 394, 357, 340, 391, 340, + /* 890 */ 328, 362, 349, 364, 33, 362, 35, 349, 94, 357, + /* 900 */ 365, 358, 340, 328, 357, 357, 357, 416, 417, 418, + /* 910 */ 362, 420, 364, 35, 385, 340, 419, 56, 389, 357, + /* 920 */ 116, 320, 393, 394, 395, 396, 397, 398, 399, 68, + /* 930 */ 401, 106, 357, 385, 130, 131, 320, 389, 320, 105, + /* 940 */ 328, 393, 394, 395, 396, 397, 398, 399, 404, 401, + /* 950 */ 349, 407, 340, 128, 406, 94, 408, 391, 357, 328, + /* 960 */ 412, 413, 43, 362, 328, 364, 337, 68, 339, 357, + /* 970 */ 422, 340, 328, 43, 445, 446, 340, 116, 362, 175, + /* 980 */ 362, 177, 0, 0, 340, 419, 385, 153, 357, 162, + /* 990 */ 389, 130, 131, 357, 393, 394, 395, 396, 397, 398, + /* 1000 */ 399, 357, 401, 199, 200, 22, 202, 203, 204, 205, + /* 1010 */ 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, + /* 1020 */ 216, 217, 218, 219, 220, 221, 222, 8, 9, 33, + /* 1030 */ 350, 12, 13, 14, 15, 16, 175, 359, 177, 377, + /* 1040 */ 362, 359, 43, 47, 362, 320, 35, 446, 52, 53, + /* 1050 */ 54, 55, 56, 320, 342, 177, 394, 345, 44, 45, + /* 1060 */ 199, 200, 0, 202, 203, 204, 205, 206, 207, 208, + /* 1070 */ 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, + /* 1080 */ 219, 220, 221, 222, 18, 423, 20, 362, 106, 93, + /* 1090 */ 238, 239, 96, 27, 95, 362, 30, 42, 43, 98, + /* 1100 */ 438, 439, 101, 162, 163, 443, 444, 125, 126, 127, + /* 1110 */ 128, 129, 350, 47, 43, 49, 98, 51, 98, 101, + /* 1120 */ 98, 101, 43, 101, 56, 63, 64, 65, 66, 67, + /* 1130 */ 350, 69, 70, 71, 72, 73, 74, 75, 76, 77, + /* 1140 */ 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, + /* 1150 */ 88, 89, 90, 18, 158, 159, 0, 161, 23, 93, + /* 1160 */ 0, 165, 130, 131, 96, 13, 95, 43, 1, 2, + /* 1170 */ 61, 105, 37, 38, 95, 43, 41, 181, 22, 43, + /* 1180 */ 261, 162, 22, 43, 22, 46, 43, 35, 177, 259, + /* 1190 */ 350, 43, 57, 58, 59, 320, 350, 35, 3, 133, + /* 1200 */ 43, 43, 136, 137, 138, 139, 140, 141, 142, 143, + /* 1210 */ 144, 145, 146, 147, 148, 149, 150, 151, 152, 95, + /* 1220 */ 154, 155, 156, 43, 349, 381, 350, 95, 43, 94, + /* 1230 */ 68, 95, 357, 94, 321, 95, 338, 362, 95, 364, + /* 1240 */ 392, 8, 9, 95, 43, 12, 13, 14, 15, 16, + /* 1250 */ 8, 9, 95, 95, 12, 13, 14, 15, 16, 35, + /* 1260 */ 385, 43, 13, 447, 389, 436, 329, 132, 393, 394, + /* 1270 */ 395, 396, 397, 398, 399, 95, 401, 320, 116, 404, + /* 1280 */ 95, 406, 407, 408, 35, 43, 0, 412, 413, 430, + /* 1290 */ 95, 349, 68, 329, 61, 327, 95, 361, 392, 94, + /* 1300 */ 421, 414, 167, 168, 169, 440, 349, 172, 199, 104, + /* 1310 */ 424, 354, 242, 95, 357, 387, 47, 386, 173, 362, + /* 1320 */ 42, 364, 379, 369, 189, 369, 20, 192, 320, 194, + /* 1330 */ 195, 196, 197, 198, 48, 328, 103, 175, 328, 177, + /* 1340 */ 369, 157, 385, 367, 367, 328, 389, 92, 20, 334, + /* 1350 */ 393, 394, 395, 396, 397, 398, 399, 349, 401, 328, + /* 1360 */ 20, 199, 200, 328, 377, 357, 328, 322, 322, 383, + /* 1370 */ 362, 332, 364, 364, 357, 240, 332, 377, 20, 376, + /* 1380 */ 20, 394, 378, 332, 332, 332, 332, 328, 376, 332, + /* 1390 */ 157, 322, 349, 385, 394, 328, 349, 389, 349, 349, + /* 1400 */ 188, 393, 394, 395, 396, 397, 398, 399, 322, 401, + /* 1410 */ 423, 394, 349, 349, 406, 330, 408, 384, 362, 383, + /* 1420 */ 412, 413, 349, 423, 349, 438, 439, 349, 180, 349, + /* 1430 */ 443, 444, 349, 416, 417, 418, 364, 420, 438, 439, + /* 1440 */ 382, 433, 330, 443, 444, 328, 320, 328, 330, 247, + /* 1450 */ 376, 362, 362, 372, 362, 362, 372, 362, 159, 330, + /* 1460 */ 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, + /* 1470 */ 237, 370, 345, 357, 330, 349, 20, 362, 248, 392, + /* 1480 */ 392, 254, 372, 357, 362, 362, 372, 362, 362, 429, + /* 1490 */ 364, 166, 362, 432, 429, 256, 255, 243, 387, 263, + /* 1500 */ 260, 258, 239, 357, 20, 94, 429, 431, 411, 94, + /* 1510 */ 428, 385, 391, 320, 353, 389, 362, 339, 427, 393, + /* 1520 */ 394, 395, 396, 397, 398, 399, 426, 401, 328, 330, + /* 1530 */ 36, 323, 406, 322, 408, 320, 442, 343, 412, 413, + /* 1540 */ 441, 375, 349, 380, 448, 331, 343, 343, 422, 318, + /* 1550 */ 357, 0, 0, 182, 0, 362, 42, 364, 0, 0, + /* 1560 */ 35, 193, 35, 35, 349, 35, 193, 0, 35, 35, + /* 1570 */ 193, 0, 357, 193, 0, 35, 0, 362, 385, 364, + /* 1580 */ 0, 35, 389, 22, 177, 175, 393, 394, 395, 396, + /* 1590 */ 397, 398, 399, 320, 401, 0, 0, 171, 170, 406, + /* 1600 */ 385, 408, 0, 0, 389, 412, 413, 42, 393, 394, + /* 1610 */ 395, 396, 397, 398, 399, 320, 401, 0, 46, 12, + /* 1620 */ 13, 406, 349, 408, 0, 0, 0, 412, 413, 22, + /* 1630 */ 357, 0, 0, 42, 0, 362, 148, 364, 0, 0, + /* 1640 */ 33, 0, 35, 0, 349, 0, 35, 0, 148, 0, + /* 1650 */ 0, 0, 357, 0, 0, 0, 0, 362, 385, 364, + /* 1660 */ 0, 0, 389, 56, 0, 0, 393, 394, 395, 396, + /* 1670 */ 397, 398, 399, 0, 401, 68, 0, 0, 0, 406, + /* 1680 */ 385, 408, 42, 0, 389, 412, 413, 35, 393, 394, + /* 1690 */ 395, 396, 397, 398, 399, 0, 401, 0, 0, 0, + /* 1700 */ 0, 22, 0, 408, 0, 0, 0, 412, 413, 0, + /* 1710 */ 0, 42, 46, 56, 56, 43, 46, 14, 0, 39, + /* 1720 */ 39, 14, 320, 116, 40, 0, 0, 0, 39, 166, + /* 1730 */ 0, 0, 0, 62, 0, 0, 35, 47, 0, 47, + /* 1740 */ 0, 47, 0, 47, 0, 0, 35, 39, 0, 35, + /* 1750 */ 0, 349, 39, 0, 39, 35, 39, 35, 22, 357, + /* 1760 */ 0, 0, 103, 101, 362, 49, 364, 43, 35, 22, + /* 1770 */ 0, 43, 35, 22, 35, 0, 35, 22, 35, 22, + /* 1780 */ 0, 35, 175, 0, 177, 22, 20, 385, 95, 35, + /* 1790 */ 320, 389, 0, 35, 35, 393, 394, 395, 396, 397, + /* 1800 */ 398, 399, 0, 401, 162, 178, 199, 200, 35, 320, + /* 1810 */ 408, 22, 0, 94, 412, 413, 0, 3, 0, 349, + /* 1820 */ 213, 214, 215, 216, 217, 218, 219, 357, 35, 162, + /* 1830 */ 162, 0, 362, 159, 364, 0, 0, 0, 349, 164, + /* 1840 */ 39, 46, 160, 94, 158, 223, 357, 95, 43, 43, + /* 1850 */ 187, 362, 244, 364, 225, 385, 94, 46, 94, 389, + /* 1860 */ 104, 46, 94, 393, 394, 395, 396, 397, 398, 399, + /* 1870 */ 400, 401, 402, 403, 385, 94, 320, 95, 389, 95, + /* 1880 */ 94, 94, 393, 394, 395, 396, 397, 398, 399, 95, + /* 1890 */ 401, 43, 95, 320, 94, 43, 43, 408, 94, 3, + /* 1900 */ 43, 94, 413, 95, 94, 349, 46, 35, 223, 35, + /* 1910 */ 35, 35, 95, 357, 95, 35, 35, 95, 362, 95, + /* 1920 */ 364, 43, 349, 46, 2, 46, 22, 94, 199, 238, + /* 1930 */ 357, 46, 244, 95, 94, 362, 320, 364, 95, 94, + /* 1940 */ 94, 385, 22, 46, 95, 389, 95, 105, 94, 393, + /* 1950 */ 394, 395, 396, 397, 398, 399, 320, 401, 385, 403, + /* 1960 */ 94, 35, 389, 95, 35, 349, 393, 394, 395, 396, + /* 1970 */ 397, 398, 399, 357, 401, 201, 94, 35, 362, 95, + /* 1980 */ 364, 94, 35, 95, 94, 349, 95, 35, 94, 35, + /* 1990 */ 354, 118, 94, 357, 95, 22, 94, 94, 362, 106, + /* 2000 */ 364, 385, 35, 94, 118, 389, 43, 320, 435, 393, + /* 2010 */ 394, 395, 396, 397, 398, 399, 244, 401, 118, 118, + /* 2020 */ 22, 385, 62, 61, 35, 389, 35, 35, 35, 393, + /* 2030 */ 394, 395, 396, 397, 398, 399, 349, 401, 35, 35, + /* 2040 */ 35, 354, 35, 35, 357, 35, 68, 91, 35, 362, + /* 2050 */ 35, 364, 43, 437, 22, 35, 22, 35, 35, 35, + /* 2060 */ 35, 35, 68, 35, 35, 35, 22, 0, 35, 0, + /* 2070 */ 35, 0, 385, 35, 47, 39, 389, 35, 47, 39, + /* 2080 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 39, + /* 2090 */ 47, 0, 35, 47, 39, 0, 35, 35, 0, 22, + /* 2100 */ 21, 449, 22, 22, 21, 320, 20, 449, 449, 449, + /* 2110 */ 449, 449, 449, 449, 449, 449, 349, 449, 449, 449, + /* 2120 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2130 */ 449, 364, 449, 449, 349, 449, 449, 449, 449, 449, + /* 2140 */ 449, 449, 357, 449, 449, 449, 449, 362, 320, 364, + /* 2150 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2160 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 449, + /* 2170 */ 385, 449, 449, 449, 389, 449, 449, 349, 393, 394, + /* 2180 */ 395, 396, 397, 398, 399, 357, 401, 449, 449, 449, + /* 2190 */ 362, 320, 364, 449, 449, 449, 349, 449, 449, 449, + /* 2200 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2210 */ 449, 364, 449, 385, 449, 449, 449, 389, 449, 449, + /* 2220 */ 349, 393, 394, 395, 396, 397, 398, 399, 357, 401, + /* 2230 */ 449, 449, 385, 362, 320, 364, 389, 449, 449, 449, + /* 2240 */ 393, 394, 395, 396, 397, 398, 399, 449, 401, 449, + /* 2250 */ 449, 320, 449, 449, 449, 449, 385, 449, 449, 449, + /* 2260 */ 389, 449, 449, 349, 393, 394, 395, 396, 397, 398, + /* 2270 */ 399, 357, 401, 449, 449, 449, 362, 320, 364, 449, + /* 2280 */ 349, 449, 449, 449, 449, 449, 449, 449, 357, 449, + /* 2290 */ 449, 449, 449, 362, 320, 364, 449, 449, 449, 385, + /* 2300 */ 449, 449, 449, 389, 449, 449, 349, 393, 394, 395, + /* 2310 */ 396, 397, 398, 399, 357, 401, 385, 449, 449, 362, + /* 2320 */ 389, 364, 449, 349, 393, 394, 395, 396, 397, 398, + /* 2330 */ 399, 357, 401, 449, 449, 449, 362, 449, 364, 449, + /* 2340 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2350 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 385, + /* 2360 */ 449, 449, 449, 389, 449, 449, 449, 393, 394, 395, + /* 2370 */ 396, 397, 398, 399, 320, 401, 449, 449, 449, 449, + /* 2380 */ 449, 449, 449, 449, 449, 449, 349, 449, 449, 449, + /* 2390 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2400 */ 449, 364, 449, 349, 449, 449, 449, 449, 449, 449, + /* 2410 */ 449, 357, 449, 449, 449, 449, 362, 449, 364, 449, + /* 2420 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2430 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 385, + /* 2440 */ 449, 449, 449, 389, 449, 449, 449, 393, 394, 395, + /* 2450 */ 396, 397, 398, 399, 449, 401, 449, 449, 449, 449, + /* 2460 */ 449, 449, 449, 320, 449, 449, 349, 449, 449, 449, + /* 2470 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2480 */ 449, 364, 449, 449, 449, 449, 449, 449, 449, 449, + /* 2490 */ 449, 449, 349, 449, 449, 449, 449, 449, 449, 449, + /* 2500 */ 357, 449, 385, 449, 449, 362, 389, 364, 449, 449, + /* 2510 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 449, + /* 2520 */ 449, 449, 449, 449, 449, 449, 449, 449, 385, 449, + /* 2530 */ 449, 449, 389, 449, 320, 449, 393, 394, 395, 396, + /* 2540 */ 397, 398, 399, 449, 401, 449, 349, 449, 449, 449, + /* 2550 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2560 */ 449, 364, 449, 349, 449, 449, 449, 449, 449, 449, + /* 2570 */ 449, 357, 449, 449, 449, 449, 362, 320, 364, 449, + /* 2580 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2590 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 385, + /* 2600 */ 449, 449, 449, 389, 449, 449, 349, 393, 394, 395, + /* 2610 */ 396, 397, 398, 399, 357, 401, 449, 449, 449, 362, + /* 2620 */ 449, 364, 449, 449, 449, 449, 349, 449, 449, 449, + /* 2630 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2640 */ 320, 364, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2650 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 449, + /* 2660 */ 449, 449, 385, 449, 449, 449, 389, 449, 449, 349, + /* 2670 */ 393, 394, 395, 396, 397, 398, 399, 357, 401, 449, + /* 2680 */ 449, 449, 362, 449, 364, 449, 349, 449, 449, 449, + /* 2690 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2700 */ 449, 364, 449, 449, 449, 385, 449, 449, 449, 389, + /* 2710 */ 449, 449, 449, 393, 394, 395, 396, 397, 398, 399, + /* 2720 */ 320, 401, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2730 */ 393, 394, 395, 396, 397, 398, 399, 320, 401, 449, + /* 2740 */ 449, 449, 449, 449, 449, 449, 449, 449, 449, 349, + /* 2750 */ 449, 449, 449, 449, 449, 449, 449, 357, 449, 449, + /* 2760 */ 449, 449, 362, 449, 364, 449, 349, 449, 449, 449, + /* 2770 */ 449, 449, 449, 449, 357, 449, 449, 449, 449, 362, + /* 2780 */ 449, 364, 449, 449, 449, 385, 449, 449, 449, 389, + /* 2790 */ 449, 449, 449, 393, 394, 395, 396, 397, 398, 399, + /* 2800 */ 449, 401, 385, 449, 449, 449, 389, 449, 449, 449, + /* 2810 */ 393, 394, 395, 396, 397, 398, 399, 449, 401, }; -#define YY_SHIFT_COUNT (694) +#define YY_SHIFT_COUNT (693) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2068) +#define YY_SHIFT_MAX (2098) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1139, 0, 57, 269, 57, 326, 326, 326, 538, 326, - /* 10 */ 326, 326, 326, 326, 595, 807, 807, 864, 807, 807, - /* 20 */ 807, 807, 807, 807, 807, 807, 807, 807, 807, 807, - /* 30 */ 807, 807, 807, 807, 807, 807, 807, 807, 807, 807, - /* 40 */ 807, 807, 807, 807, 807, 807, 81, 364, 23, 211, - /* 50 */ 133, 85, 156, 85, 23, 23, 1499, 1499, 85, 1499, - /* 60 */ 1499, 323, 85, 37, 37, 1, 1, 8, 37, 37, - /* 70 */ 37, 37, 37, 37, 37, 37, 37, 37, 14, 37, - /* 80 */ 37, 37, 78, 37, 37, 179, 37, 37, 179, 300, - /* 90 */ 37, 179, 179, 179, 37, 31, 1070, 1243, 1243, 285, - /* 100 */ 784, 800, 800, 800, 800, 800, 800, 800, 800, 800, - /* 110 */ 800, 800, 800, 800, 800, 800, 800, 800, 800, 800, - /* 120 */ 585, 86, 8, 160, 160, 336, 348, 712, 63, 63, - /* 130 */ 618, 618, 618, 348, 384, 384, 384, 151, 78, 4, - /* 140 */ 4, 58, 179, 179, 566, 566, 151, 574, 399, 399, - /* 150 */ 399, 399, 399, 399, 399, 1391, 137, 236, 572, 774, - /* 160 */ 42, 541, 332, 576, 714, 53, 524, 669, 771, 592, - /* 170 */ 852, 621, 592, 939, 661, 805, 917, 1114, 995, 1145, - /* 180 */ 1145, 1179, 1179, 1145, 1074, 1074, 1156, 1179, 1179, 1179, - /* 190 */ 1241, 1241, 1245, 14, 78, 14, 1252, 1253, 14, 1252, - /* 200 */ 14, 14, 14, 1179, 14, 1241, 179, 179, 179, 179, - /* 210 */ 179, 179, 179, 179, 179, 179, 179, 1179, 1241, 566, - /* 220 */ 1128, 1245, 31, 1152, 78, 31, 1179, 1179, 1252, 31, - /* 230 */ 1103, 566, 566, 566, 566, 1103, 566, 1199, 31, 151, - /* 240 */ 31, 384, 1367, 1367, 566, 1147, 1103, 566, 566, 1147, - /* 250 */ 1103, 566, 566, 179, 1160, 1249, 1147, 1162, 1169, 1185, - /* 260 */ 917, 1166, 1171, 1180, 1201, 384, 1422, 1355, 1357, 566, - /* 270 */ 574, 1179, 31, 1425, 1241, 2993, 2993, 2993, 2993, 2993, - /* 280 */ 2993, 2993, 1066, 191, 403, 1785, 1098, 684, 1158, 50, - /* 290 */ 1041, 1176, 126, 754, 754, 754, 754, 754, 754, 754, - /* 300 */ 754, 754, 239, 215, 11, 11, 171, 264, 406, 554, - /* 310 */ 421, 162, 547, 15, 729, 477, 15, 15, 15, 844, - /* 320 */ 135, 687, 830, 888, 889, 890, 895, 975, 1038, 1039, - /* 330 */ 858, 835, 936, 949, 963, 998, 1008, 1009, 1020, 872, - /* 340 */ 842, 992, 1003, 1004, 1001, 1024, 908, 1073, 670, 1000, - /* 350 */ 1091, 1140, 1151, 1193, 1195, 1207, 997, 1083, 1085, 1027, - /* 360 */ 1181, 1483, 1489, 1308, 1503, 1504, 1463, 1510, 1480, 1322, - /* 370 */ 1484, 1487, 1488, 1324, 1524, 1491, 1492, 1334, 1530, 1337, - /* 380 */ 1535, 1501, 1558, 1538, 1562, 1509, 1385, 1388, 1565, 1566, - /* 390 */ 1396, 1398, 1572, 1574, 1529, 1576, 1577, 1578, 1537, 1580, - /* 400 */ 1581, 1583, 1542, 1585, 1587, 1588, 1589, 1597, 1600, 1452, - /* 410 */ 1567, 1606, 1455, 1608, 1611, 1616, 1617, 1618, 1619, 1620, - /* 420 */ 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1586, 1629, 1630, - /* 430 */ 1631, 1632, 1633, 1634, 1614, 1637, 1638, 1640, 1641, 1635, - /* 440 */ 1652, 1598, 1653, 1603, 1656, 1660, 1639, 1628, 1636, 1650, - /* 450 */ 1615, 1651, 1658, 1668, 1643, 1645, 1669, 1671, 1672, 1646, - /* 460 */ 1506, 1674, 1676, 1680, 1649, 1693, 1696, 1662, 1655, 1659, - /* 470 */ 1707, 1677, 1673, 1670, 1721, 1688, 1678, 1685, 1726, 1692, - /* 480 */ 1681, 1690, 1730, 1732, 1733, 1734, 1654, 1657, 1701, 1715, - /* 490 */ 1738, 1717, 1719, 1720, 1710, 1713, 1725, 1727, 1728, 1735, - /* 500 */ 1761, 1741, 1765, 1745, 1722, 1768, 1747, 1737, 1773, 1739, - /* 510 */ 1775, 1742, 1776, 1756, 1759, 1686, 1689, 1780, 1642, 1750, - /* 520 */ 1782, 1607, 1766, 1644, 1648, 1790, 1792, 1661, 1665, 1791, - /* 530 */ 1793, 1802, 1806, 1716, 1714, 1777, 1663, 1811, 1723, 1666, - /* 540 */ 1729, 1814, 1781, 1675, 1731, 1711, 1770, 1779, 1595, 1605, - /* 550 */ 1609, 1786, 1590, 1743, 1744, 1746, 1748, 1749, 1751, 1795, - /* 560 */ 1755, 1752, 1758, 1760, 1771, 1812, 1810, 1821, 1774, 1826, - /* 570 */ 1667, 1778, 1787, 1867, 1831, 1682, 1840, 1845, 1848, 1850, - /* 580 */ 1852, 1853, 1794, 1796, 1844, 1683, 1849, 1851, 1854, 1892, - /* 590 */ 1873, 1698, 1805, 1801, 1808, 1809, 1815, 1818, 1857, 1816, - /* 600 */ 1820, 1859, 1830, 1904, 1753, 1834, 1825, 1836, 1897, 1899, - /* 610 */ 1841, 1855, 1901, 1858, 1856, 1909, 1860, 1861, 1911, 1863, - /* 620 */ 1864, 1913, 1866, 1846, 1847, 1862, 1868, 1927, 1869, 1875, - /* 630 */ 1876, 1923, 1877, 1919, 1919, 1941, 1910, 1912, 1939, 1942, - /* 640 */ 1943, 1944, 1946, 1947, 1950, 1952, 1953, 1955, 1908, 1900, - /* 650 */ 1940, 1957, 1959, 1973, 1971, 1985, 1975, 1977, 1979, 1949, - /* 660 */ 1710, 1980, 1713, 1981, 1983, 1984, 1987, 1986, 1988, 2020, - /* 670 */ 1989, 1978, 1990, 2027, 1995, 2000, 1992, 2033, 1999, 2003, - /* 680 */ 1996, 2037, 2016, 2005, 2015, 2055, 2029, 2031, 2068, 2047, - /* 690 */ 2049, 2051, 2052, 2050, 2056, + /* 0 */ 1135, 0, 57, 268, 57, 325, 325, 325, 536, 325, + /* 10 */ 325, 325, 325, 325, 593, 804, 804, 861, 804, 804, + /* 20 */ 804, 804, 804, 804, 804, 804, 804, 804, 804, 804, + /* 30 */ 804, 804, 804, 804, 804, 804, 804, 804, 804, 804, + /* 40 */ 804, 804, 804, 804, 804, 804, 8, 12, 104, 73, + /* 50 */ 369, 164, 286, 164, 104, 104, 1607, 1607, 164, 1607, + /* 60 */ 1607, 4, 164, 55, 55, 1, 1, 176, 55, 55, + /* 70 */ 55, 55, 55, 55, 55, 55, 55, 55, 54, 55, + /* 80 */ 55, 55, 428, 55, 55, 555, 55, 55, 555, 683, + /* 90 */ 55, 555, 555, 555, 55, 457, 1066, 1233, 1233, 402, + /* 100 */ 490, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, + /* 110 */ 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, 1162, + /* 120 */ 468, 611, 176, 350, 350, 622, 370, 648, 267, 267, + /* 130 */ 600, 600, 600, 370, 752, 752, 752, 182, 428, 632, + /* 140 */ 632, 412, 555, 555, 767, 767, 182, 899, 399, 399, + /* 150 */ 399, 399, 399, 399, 399, 263, 382, 769, 717, 445, + /* 160 */ 42, 134, 205, 154, 217, 319, 1014, 825, 827, 852, + /* 170 */ 455, 126, 852, 1055, 161, 395, 1070, 1269, 1145, 1278, + /* 180 */ 1278, 1306, 1306, 1278, 1184, 1184, 1255, 1306, 1306, 1306, + /* 190 */ 1328, 1328, 1340, 54, 428, 54, 1358, 1360, 54, 1358, + /* 200 */ 54, 54, 54, 1306, 54, 1328, 555, 555, 555, 555, + /* 210 */ 555, 555, 555, 555, 555, 555, 555, 1306, 1328, 767, + /* 220 */ 1212, 1340, 457, 1248, 428, 457, 1306, 1306, 1358, 457, + /* 230 */ 1202, 767, 767, 767, 767, 1202, 767, 1299, 457, 182, + /* 240 */ 457, 752, 1456, 1456, 767, 1230, 1202, 767, 767, 1230, + /* 250 */ 1202, 767, 767, 555, 1227, 1325, 1230, 1239, 1241, 1254, + /* 260 */ 1070, 1236, 1240, 1243, 1263, 752, 1484, 1411, 1415, 767, + /* 270 */ 899, 1306, 457, 1494, 1328, 2819, 2819, 2819, 2819, 2819, + /* 280 */ 2819, 2819, 1062, 996, 559, 70, 751, 1242, 766, 50, + /* 290 */ 775, 1019, 226, 850, 850, 850, 850, 850, 850, 850, + /* 300 */ 850, 850, 982, 262, 11, 11, 53, 160, 63, 227, + /* 310 */ 361, 561, 513, 483, 639, 534, 483, 483, 483, 301, + /* 320 */ 663, 808, 834, 1001, 1018, 1020, 1022, 983, 1156, 1160, + /* 330 */ 1068, 941, 999, 1071, 1079, 1124, 1132, 1136, 1140, 1032, + /* 340 */ 930, 919, 1167, 1143, 878, 1011, 1109, 1148, 1195, 1139, + /* 350 */ 1157, 1158, 1180, 1185, 1201, 1218, 1205, 1152, 1249, 1224, + /* 360 */ 1286, 1551, 1552, 1371, 1554, 1558, 1514, 1559, 1525, 1368, + /* 370 */ 1527, 1528, 1530, 1373, 1567, 1533, 1534, 1377, 1571, 1380, + /* 380 */ 1574, 1540, 1576, 1561, 1580, 1546, 1407, 1410, 1595, 1596, + /* 390 */ 1426, 1428, 1602, 1603, 1572, 1617, 1624, 1625, 1565, 1626, + /* 400 */ 1631, 1632, 1591, 1634, 1638, 1639, 1641, 1643, 1645, 1488, + /* 410 */ 1611, 1647, 1500, 1649, 1650, 1651, 1653, 1654, 1655, 1656, + /* 420 */ 1660, 1661, 1664, 1665, 1673, 1676, 1677, 1640, 1678, 1683, + /* 430 */ 1695, 1697, 1698, 1679, 1699, 1700, 1702, 1704, 1652, 1705, + /* 440 */ 1657, 1706, 1658, 1709, 1710, 1669, 1680, 1672, 1703, 1666, + /* 450 */ 1707, 1670, 1718, 1684, 1681, 1725, 1726, 1727, 1689, 1563, + /* 460 */ 1730, 1731, 1732, 1671, 1734, 1735, 1701, 1690, 1708, 1738, + /* 470 */ 1711, 1692, 1713, 1740, 1714, 1694, 1715, 1742, 1720, 1696, + /* 480 */ 1717, 1744, 1745, 1748, 1750, 1659, 1662, 1722, 1736, 1753, + /* 490 */ 1733, 1737, 1739, 1724, 1728, 1741, 1743, 1747, 1746, 1760, + /* 500 */ 1751, 1761, 1755, 1716, 1770, 1757, 1754, 1775, 1758, 1780, + /* 510 */ 1759, 1783, 1763, 1766, 1693, 1719, 1792, 1642, 1773, 1802, + /* 520 */ 1627, 1789, 1667, 1674, 1812, 1816, 1668, 1675, 1814, 1818, + /* 530 */ 1831, 1835, 1749, 1752, 1793, 1663, 1836, 1762, 1682, 1764, + /* 540 */ 1837, 1801, 1686, 1768, 1756, 1795, 1805, 1622, 1629, 1685, + /* 550 */ 1806, 1608, 1781, 1782, 1786, 1784, 1794, 1787, 1848, 1797, + /* 560 */ 1800, 1804, 1807, 1808, 1852, 1811, 1815, 1810, 1853, 1688, + /* 570 */ 1817, 1819, 1896, 1857, 1772, 1872, 1874, 1875, 1876, 1880, + /* 580 */ 1881, 1822, 1824, 1860, 1691, 1878, 1877, 1879, 1922, 1904, + /* 590 */ 1729, 1833, 1838, 1840, 1843, 1845, 1849, 1885, 1846, 1854, + /* 600 */ 1897, 1851, 1920, 1774, 1866, 1842, 1868, 1926, 1929, 1882, + /* 610 */ 1884, 1942, 1887, 1888, 1947, 1890, 1891, 1952, 1894, 1899, + /* 620 */ 1954, 1898, 1873, 1886, 1900, 1901, 1973, 1893, 1902, 1903, + /* 630 */ 1967, 1909, 1963, 1963, 1998, 1960, 1962, 1989, 1991, 1992, + /* 640 */ 1993, 2003, 2004, 2005, 2007, 2008, 2010, 1978, 1956, 2009, + /* 650 */ 2013, 2015, 2032, 2020, 2034, 2022, 2023, 2024, 1994, 1724, + /* 660 */ 2025, 1728, 2026, 2028, 2029, 2030, 2044, 2033, 2067, 2035, + /* 670 */ 2027, 2036, 2069, 2038, 2031, 2040, 2071, 2042, 2043, 2050, + /* 680 */ 2091, 2057, 2046, 2055, 2095, 2061, 2062, 2098, 2077, 2079, + /* 690 */ 2080, 2081, 2083, 2086, }; #define YY_REDUCE_COUNT (281) #define YY_REDUCE_MIN (-408) -#define YY_REDUCE_MAX (2591) +#define YY_REDUCE_MAX (2417) static const short yy_reduce_ofst[] = { - /* 0 */ 400, -253, -313, 885, 13, 282, 551, 996, 263, 1101, - /* 10 */ 1144, 1197, 1250, 1293, 1346, 532, 1402, 1464, 1522, 1544, - /* 20 */ 1604, 1647, 1664, 1718, 1736, 1798, 1822, 1865, 1885, 1948, - /* 30 */ 1967, 2010, 2061, 2081, 2132, 2185, 2228, 2248, 2311, 2330, - /* 40 */ 2373, 2424, 2444, 2495, 2548, 2591, 21, 280, -223, 801, - /* 50 */ 924, 926, 933, 984, -25, 1131, -351, -348, -316, -341, - /* 60 */ -103, -63, 131, 96, 225, -318, -309, -211, -207, -5, - /* 70 */ 261, 276, 283, 286, 309, 313, 436, 493, 108, 513, - /* 80 */ 517, 533, -217, 552, 555, -239, 565, 613, -241, 22, - /* 90 */ 380, 64, 106, 561, 615, 507, -312, -408, -408, -287, - /* 100 */ -161, -265, -233, -206, -136, 141, 197, 204, 237, 293, - /* 110 */ 416, 464, 472, 516, 526, 542, 544, 545, 549, 562, - /* 120 */ -14, -189, -35, -100, -94, 173, 114, 71, 61, 90, - /* 130 */ -189, 176, 202, 165, 353, 372, 417, -105, 188, 123, - /* 140 */ 455, 196, 602, 7, 603, 609, 632, 521, -331, 117, - /* 150 */ 504, 548, 606, 611, 682, 238, 713, 695, 653, 601, - /* 160 */ 673, 760, 675, 773, 773, 794, 797, 764, 734, 706, - /* 170 */ 706, 688, 706, 744, 735, 773, 777, 779, 803, 831, - /* 180 */ 832, 876, 900, 861, 870, 874, 897, 915, 932, 934, - /* 190 */ 941, 942, 883, 935, 904, 937, 899, 898, 945, 909, - /* 200 */ 955, 962, 964, 967, 968, 977, 956, 957, 965, 966, - /* 210 */ 970, 972, 973, 974, 976, 979, 981, 983, 991, 969, - /* 220 */ 940, 943, 1010, 959, 978, 1013, 1016, 1022, 990, 1018, - /* 230 */ 980, 993, 1011, 1012, 1017, 982, 1021, 987, 1045, 1037, - /* 240 */ 1054, 1029, 1006, 1007, 1026, 971, 1031, 1043, 1044, 985, - /* 250 */ 1040, 1049, 1051, 773, 988, 986, 1002, 1005, 999, 1014, - /* 260 */ 1047, 989, 994, 1015, 706, 1078, 1057, 1042, 1099, 1092, - /* 270 */ 1116, 1129, 1130, 1143, 1146, 1082, 1094, 1124, 1127, 1142, - /* 280 */ 1161, 1164, + /* 0 */ -286, -253, -313, 875, 1008, 280, 548, 1126, -22, 1193, + /* 10 */ 1215, 1273, 1295, 1402, 1470, 261, 529, 1489, 957, 1556, + /* 20 */ 1573, 1616, 601, 1636, 1687, 1767, 1785, 1828, 1847, 1871, + /* 30 */ 1914, 1931, 1957, 1974, 2037, 2054, 2117, 2143, 2197, 2214, + /* 40 */ 2257, 2277, 2320, 2337, 2400, 2417, -193, 278, -223, -139, + /* 50 */ 276, 662, 987, 1000, 491, 1017, -351, -348, -316, -341, + /* 60 */ -40, -261, 241, -26, 38, -309, -177, -30, -31, 107, + /* 70 */ 109, 112, 223, 236, 311, 343, 510, 514, -245, 542, + /* 80 */ 547, 549, -355, 562, 575, -169, 631, 636, 201, 203, + /* 90 */ 644, 253, 252, 275, 612, 360, -190, -408, -408, -315, + /* 100 */ -304, -265, -247, -201, -181, -12, 74, 142, 257, 259, + /* 110 */ 283, 327, 465, 466, 474, 533, 616, 618, 725, 733, + /* 120 */ -318, 27, -135, -271, 72, -43, -93, 375, 96, 413, + /* 130 */ 27, 497, 566, 486, 487, 488, 512, -17, 354, 450, + /* 140 */ 456, 544, 543, 535, 678, 682, 712, 629, 526, 680, + /* 150 */ 762, 780, 840, 846, 876, 844, 913, 898, 848, 816, + /* 160 */ 829, 937, 859, 942, 942, 964, 968, 936, 906, 879, + /* 170 */ 879, 865, 879, 887, 886, 942, 928, 931, 943, 954, + /* 180 */ 956, 1007, 1010, 971, 976, 977, 1015, 1031, 1035, 1038, + /* 190 */ 1045, 1046, 986, 1039, 1009, 1044, 1003, 1004, 1051, 1012, + /* 200 */ 1052, 1053, 1054, 1059, 1057, 1069, 1043, 1047, 1049, 1050, + /* 210 */ 1063, 1064, 1073, 1075, 1078, 1080, 1083, 1067, 1086, 1056, + /* 220 */ 1033, 1036, 1085, 1058, 1072, 1112, 1117, 1119, 1074, 1118, + /* 230 */ 1081, 1089, 1090, 1092, 1093, 1084, 1095, 1101, 1129, 1127, + /* 240 */ 1144, 1116, 1087, 1088, 1115, 1060, 1110, 1122, 1123, 1065, + /* 250 */ 1114, 1125, 1130, 942, 1061, 1076, 1077, 1082, 1091, 1100, + /* 260 */ 1111, 1096, 1094, 1099, 879, 1146, 1121, 1097, 1161, 1154, + /* 270 */ 1178, 1200, 1199, 1208, 1211, 1163, 1166, 1194, 1203, 1204, + /* 280 */ 1214, 1231, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 10 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 20 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 30 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 40 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 50 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 60 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 70 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1623, 1549, - /* 80 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 90 */ 1549, 1549, 1549, 1549, 1549, 1621, 1791, 1979, 1549, 1549, - /* 100 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 110 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 120 */ 1549, 1991, 1549, 1549, 1549, 1623, 1549, 1621, 1951, 1951, - /* 130 */ 1991, 1991, 1991, 1549, 1549, 1549, 1549, 1730, 1549, 1832, - /* 140 */ 1832, 1549, 1549, 1549, 1549, 1549, 1730, 1549, 1549, 1549, - /* 150 */ 1549, 1549, 1549, 1549, 1549, 1826, 1549, 1549, 2016, 2069, - /* 160 */ 1549, 1549, 2019, 1549, 1549, 1549, 1549, 1683, 2006, 1983, - /* 170 */ 1997, 2053, 1984, 1981, 2000, 1549, 2010, 1549, 1819, 1796, - /* 180 */ 1796, 1549, 1549, 1796, 1793, 1793, 1674, 1549, 1549, 1549, - /* 190 */ 1549, 1549, 1549, 1623, 1549, 1623, 1549, 1549, 1623, 1549, - /* 200 */ 1623, 1623, 1623, 1549, 1623, 1549, 1549, 1549, 1549, 1549, - /* 210 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 220 */ 1838, 1549, 1621, 1828, 1549, 1621, 1549, 1549, 1549, 1621, - /* 230 */ 2024, 1549, 1549, 1549, 1549, 2024, 1549, 1549, 1621, 1549, - /* 240 */ 1621, 1549, 1549, 1549, 1549, 2026, 2024, 1549, 1549, 2026, - /* 250 */ 2024, 1549, 1549, 1549, 2038, 2034, 2026, 2042, 2040, 2012, - /* 260 */ 2010, 2072, 2059, 2055, 1997, 1549, 1549, 1549, 1699, 1549, - /* 270 */ 1549, 1549, 1621, 1581, 1549, 1821, 1832, 1733, 1733, 1733, - /* 280 */ 1624, 1554, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 290 */ 1549, 1549, 1549, 1907, 1549, 2037, 2036, 1955, 1954, 1953, - /* 300 */ 1944, 1906, 1549, 1695, 1905, 1904, 1549, 1549, 1549, 1549, - /* 310 */ 1549, 1549, 1549, 1898, 1549, 1549, 1899, 1897, 1896, 1549, - /* 320 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 330 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 340 */ 2056, 2060, 1980, 1549, 1549, 1549, 1549, 1549, 1889, 1880, - /* 350 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 360 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 370 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 380 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 390 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 400 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 410 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 420 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 430 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 440 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1586, 1549, - /* 450 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 460 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 470 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 480 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 490 */ 1549, 1549, 1549, 1549, 1663, 1662, 1549, 1549, 1549, 1549, - /* 500 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 510 */ 1549, 1549, 1549, 1549, 1549, 1888, 1549, 1549, 1549, 1549, - /* 520 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 2052, - /* 530 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1836, 1549, 1549, - /* 540 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1941, 1549, 1549, - /* 550 */ 1549, 2013, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 560 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1880, 1549, 2035, - /* 570 */ 1549, 1549, 2050, 1549, 2054, 1549, 1549, 1549, 1549, 1549, - /* 580 */ 1549, 1549, 1990, 1986, 1549, 1549, 1982, 1879, 1549, 1975, - /* 590 */ 1549, 1549, 1926, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 600 */ 1549, 1549, 1888, 1549, 1892, 1549, 1549, 1549, 1549, 1549, - /* 610 */ 1727, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 620 */ 1549, 1549, 1549, 1712, 1710, 1709, 1708, 1549, 1705, 1549, - /* 630 */ 1549, 1549, 1549, 1736, 1735, 1549, 1549, 1549, 1549, 1549, - /* 640 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 650 */ 1643, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 660 */ 1634, 1549, 1633, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 670 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 680 */ 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, 1549, - /* 690 */ 1549, 1549, 1549, 1549, 1549, + /* 0 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 10 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 20 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 30 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 40 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 50 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 60 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 70 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1621, 1547, + /* 80 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 90 */ 1547, 1547, 1547, 1547, 1547, 1619, 1788, 1976, 1547, 1547, + /* 100 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 110 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 120 */ 1547, 1988, 1547, 1547, 1547, 1621, 1547, 1619, 1948, 1948, + /* 130 */ 1988, 1988, 1988, 1547, 1547, 1547, 1547, 1728, 1547, 1829, + /* 140 */ 1829, 1547, 1547, 1547, 1547, 1547, 1728, 1547, 1547, 1547, + /* 150 */ 1547, 1547, 1547, 1547, 1547, 1823, 1547, 1547, 2013, 2066, + /* 160 */ 1547, 1547, 2016, 1547, 1547, 1547, 1547, 1681, 2003, 1980, + /* 170 */ 1994, 2050, 1981, 1978, 1997, 1547, 2007, 1547, 1816, 1793, + /* 180 */ 1793, 1547, 1547, 1793, 1790, 1790, 1672, 1547, 1547, 1547, + /* 190 */ 1547, 1547, 1547, 1621, 1547, 1621, 1547, 1547, 1621, 1547, + /* 200 */ 1621, 1621, 1621, 1547, 1621, 1547, 1547, 1547, 1547, 1547, + /* 210 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 220 */ 1835, 1547, 1619, 1825, 1547, 1619, 1547, 1547, 1547, 1619, + /* 230 */ 2021, 1547, 1547, 1547, 1547, 2021, 1547, 1547, 1619, 1547, + /* 240 */ 1619, 1547, 1547, 1547, 1547, 2023, 2021, 1547, 1547, 2023, + /* 250 */ 2021, 1547, 1547, 1547, 2035, 2031, 2023, 2039, 2037, 2009, + /* 260 */ 2007, 2069, 2056, 2052, 1994, 1547, 1547, 1547, 1697, 1547, + /* 270 */ 1547, 1547, 1619, 1579, 1547, 1818, 1829, 1731, 1731, 1731, + /* 280 */ 1622, 1552, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 290 */ 1547, 1547, 1547, 1904, 1547, 2034, 2033, 1952, 1951, 1950, + /* 300 */ 1941, 1903, 1547, 1693, 1902, 1901, 1547, 1547, 1547, 1547, + /* 310 */ 1547, 1547, 1547, 1895, 1547, 1547, 1896, 1894, 1893, 1547, + /* 320 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 330 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 340 */ 2053, 2057, 1977, 1547, 1547, 1547, 1547, 1547, 1886, 1877, + /* 350 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 360 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 370 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 380 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 390 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 400 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 410 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 420 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 430 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 440 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1584, 1547, 1547, + /* 450 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 460 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 470 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 480 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 490 */ 1547, 1547, 1547, 1661, 1660, 1547, 1547, 1547, 1547, 1547, + /* 500 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 510 */ 1547, 1547, 1547, 1547, 1885, 1547, 1547, 1547, 1547, 1547, + /* 520 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 2049, 1547, + /* 530 */ 1547, 1547, 1547, 1547, 1547, 1547, 1833, 1547, 1547, 1547, + /* 540 */ 1547, 1547, 1547, 1547, 1547, 1547, 1938, 1547, 1547, 1547, + /* 550 */ 2010, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 560 */ 1547, 1547, 1547, 1547, 1547, 1547, 1877, 1547, 2032, 1547, + /* 570 */ 1547, 2047, 1547, 2051, 1547, 1547, 1547, 1547, 1547, 1547, + /* 580 */ 1547, 1987, 1983, 1547, 1547, 1979, 1876, 1547, 1972, 1547, + /* 590 */ 1547, 1923, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 600 */ 1547, 1885, 1547, 1889, 1547, 1547, 1547, 1547, 1547, 1725, + /* 610 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 620 */ 1547, 1547, 1710, 1708, 1707, 1706, 1547, 1703, 1547, 1547, + /* 630 */ 1547, 1547, 1734, 1733, 1547, 1547, 1547, 1547, 1547, 1547, + /* 640 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1641, + /* 650 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1632, + /* 660 */ 1547, 1631, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 670 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 680 */ 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, 1547, + /* 690 */ 1547, 1547, 1547, 1547, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1157,7 +1121,6 @@ static const YYCODETYPE yyFallback[] = { 0, /* TABLES => nothing */ 0, /* STABLES => nothing */ 0, /* MNODES => nothing */ - 0, /* MODULES => nothing */ 0, /* QNODES => nothing */ 0, /* FUNCTIONS => nothing */ 0, /* INDEXES => nothing */ @@ -1244,7 +1207,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* CASE => nothing */ - 265, /* END => ABORT */ + 264, /* END => ABORT */ 0, /* WHEN => nothing */ 0, /* THEN => nothing */ 0, /* ELSE => nothing */ @@ -1286,57 +1249,58 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 265, /* AFTER => ABORT */ - 265, /* ATTACH => ABORT */ - 265, /* BEFORE => ABORT */ - 265, /* BEGIN => ABORT */ - 265, /* BITAND => ABORT */ - 265, /* BITNOT => ABORT */ - 265, /* BITOR => ABORT */ - 265, /* BLOCKS => ABORT */ - 265, /* CHANGE => ABORT */ - 265, /* COMMA => ABORT */ - 265, /* COMPACT => ABORT */ - 265, /* CONCAT => ABORT */ - 265, /* CONFLICT => ABORT */ - 265, /* COPY => ABORT */ - 265, /* DEFERRED => ABORT */ - 265, /* DELIMITERS => ABORT */ - 265, /* DETACH => ABORT */ - 265, /* DIVIDE => ABORT */ - 265, /* DOT => ABORT */ - 265, /* EACH => ABORT */ - 265, /* FAIL => ABORT */ - 265, /* FILE => ABORT */ - 265, /* FOR => ABORT */ - 265, /* GLOB => ABORT */ - 265, /* ID => ABORT */ - 265, /* IMMEDIATE => ABORT */ - 265, /* IMPORT => ABORT */ - 265, /* INITIALLY => ABORT */ - 265, /* INSTEAD => ABORT */ - 265, /* ISNULL => ABORT */ - 265, /* KEY => ABORT */ - 265, /* NK_BITNOT => ABORT */ - 265, /* NK_SEMI => ABORT */ - 265, /* NOTNULL => ABORT */ - 265, /* OF => ABORT */ - 265, /* PLUS => ABORT */ - 265, /* PRIVILEGE => ABORT */ - 265, /* RAISE => ABORT */ - 265, /* REPLACE => ABORT */ - 265, /* RESTRICT => ABORT */ - 265, /* ROW => ABORT */ - 265, /* SEMI => ABORT */ - 265, /* STAR => ABORT */ - 265, /* STATEMENT => ABORT */ - 265, /* STRING => ABORT */ - 265, /* TIMES => ABORT */ - 265, /* UPDATE => ABORT */ - 265, /* VALUES => ABORT */ - 265, /* VARIABLE => ABORT */ - 265, /* VIEW => ABORT */ - 265, /* WAL => ABORT */ + 264, /* AFTER => ABORT */ + 264, /* ATTACH => ABORT */ + 264, /* BEFORE => ABORT */ + 264, /* BEGIN => ABORT */ + 264, /* BITAND => ABORT */ + 264, /* BITNOT => ABORT */ + 264, /* BITOR => ABORT */ + 264, /* BLOCKS => ABORT */ + 264, /* CHANGE => ABORT */ + 264, /* COMMA => ABORT */ + 264, /* COMPACT => ABORT */ + 264, /* CONCAT => ABORT */ + 264, /* CONFLICT => ABORT */ + 264, /* COPY => ABORT */ + 264, /* DEFERRED => ABORT */ + 264, /* DELIMITERS => ABORT */ + 264, /* DETACH => ABORT */ + 264, /* DIVIDE => ABORT */ + 264, /* DOT => ABORT */ + 264, /* EACH => ABORT */ + 264, /* FAIL => ABORT */ + 264, /* FILE => ABORT */ + 264, /* FOR => ABORT */ + 264, /* GLOB => ABORT */ + 264, /* ID => ABORT */ + 264, /* IMMEDIATE => ABORT */ + 264, /* IMPORT => ABORT */ + 264, /* INITIALLY => ABORT */ + 264, /* INSTEAD => ABORT */ + 264, /* ISNULL => ABORT */ + 264, /* KEY => ABORT */ + 264, /* MODULES => ABORT */ + 264, /* NK_BITNOT => ABORT */ + 264, /* NK_SEMI => ABORT */ + 264, /* NOTNULL => ABORT */ + 264, /* OF => ABORT */ + 264, /* PLUS => ABORT */ + 264, /* PRIVILEGE => ABORT */ + 264, /* RAISE => ABORT */ + 264, /* REPLACE => ABORT */ + 264, /* RESTRICT => ABORT */ + 264, /* ROW => ABORT */ + 264, /* SEMI => ABORT */ + 264, /* STAR => ABORT */ + 264, /* STATEMENT => ABORT */ + 264, /* STRING => ABORT */ + 264, /* TIMES => ABORT */ + 264, /* UPDATE => ABORT */ + 264, /* VALUES => ABORT */ + 264, /* VARIABLE => ABORT */ + 264, /* VIEW => ABORT */ + 264, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1561,166 +1525,166 @@ static const char *const yyTokenName[] = { /* 134 */ "TABLES", /* 135 */ "STABLES", /* 136 */ "MNODES", - /* 137 */ "MODULES", - /* 138 */ "QNODES", - /* 139 */ "FUNCTIONS", - /* 140 */ "INDEXES", - /* 141 */ "ACCOUNTS", - /* 142 */ "APPS", - /* 143 */ "CONNECTIONS", - /* 144 */ "LICENCES", - /* 145 */ "GRANTS", - /* 146 */ "QUERIES", - /* 147 */ "SCORES", - /* 148 */ "TOPICS", - /* 149 */ "VARIABLES", - /* 150 */ "BNODES", - /* 151 */ "SNODES", - /* 152 */ "CLUSTER", - /* 153 */ "TRANSACTIONS", - /* 154 */ "DISTRIBUTED", - /* 155 */ "CONSUMERS", - /* 156 */ "SUBSCRIPTIONS", - /* 157 */ "VNODES", - /* 158 */ "LIKE", - /* 159 */ "INDEX", - /* 160 */ "FUNCTION", - /* 161 */ "INTERVAL", - /* 162 */ "TOPIC", - /* 163 */ "AS", - /* 164 */ "WITH", - /* 165 */ "META", - /* 166 */ "CONSUMER", - /* 167 */ "GROUP", - /* 168 */ "DESC", - /* 169 */ "DESCRIBE", - /* 170 */ "RESET", - /* 171 */ "QUERY", - /* 172 */ "CACHE", - /* 173 */ "EXPLAIN", - /* 174 */ "ANALYZE", - /* 175 */ "VERBOSE", - /* 176 */ "NK_BOOL", - /* 177 */ "RATIO", - /* 178 */ "NK_FLOAT", - /* 179 */ "OUTPUTTYPE", - /* 180 */ "AGGREGATE", - /* 181 */ "BUFSIZE", - /* 182 */ "STREAM", - /* 183 */ "INTO", - /* 184 */ "TRIGGER", - /* 185 */ "AT_ONCE", - /* 186 */ "WINDOW_CLOSE", - /* 187 */ "IGNORE", - /* 188 */ "EXPIRED", - /* 189 */ "SUBTABLE", - /* 190 */ "KILL", - /* 191 */ "CONNECTION", - /* 192 */ "TRANSACTION", - /* 193 */ "BALANCE", - /* 194 */ "VGROUP", - /* 195 */ "MERGE", - /* 196 */ "REDISTRIBUTE", - /* 197 */ "SPLIT", - /* 198 */ "DELETE", - /* 199 */ "INSERT", - /* 200 */ "NULL", - /* 201 */ "NK_QUESTION", - /* 202 */ "NK_ARROW", - /* 203 */ "ROWTS", - /* 204 */ "TBNAME", - /* 205 */ "QSTART", - /* 206 */ "QEND", - /* 207 */ "QDURATION", - /* 208 */ "WSTART", - /* 209 */ "WEND", - /* 210 */ "WDURATION", - /* 211 */ "IROWTS", - /* 212 */ "QTAGS", - /* 213 */ "CAST", - /* 214 */ "NOW", - /* 215 */ "TODAY", - /* 216 */ "TIMEZONE", - /* 217 */ "CLIENT_VERSION", - /* 218 */ "SERVER_VERSION", - /* 219 */ "SERVER_STATUS", - /* 220 */ "CURRENT_USER", - /* 221 */ "COUNT", - /* 222 */ "LAST_ROW", - /* 223 */ "CASE", - /* 224 */ "END", - /* 225 */ "WHEN", - /* 226 */ "THEN", - /* 227 */ "ELSE", - /* 228 */ "BETWEEN", - /* 229 */ "IS", - /* 230 */ "NK_LT", - /* 231 */ "NK_GT", - /* 232 */ "NK_LE", - /* 233 */ "NK_GE", - /* 234 */ "NK_NE", - /* 235 */ "MATCH", - /* 236 */ "NMATCH", - /* 237 */ "CONTAINS", - /* 238 */ "IN", - /* 239 */ "JOIN", - /* 240 */ "INNER", - /* 241 */ "SELECT", - /* 242 */ "DISTINCT", - /* 243 */ "WHERE", - /* 244 */ "PARTITION", - /* 245 */ "BY", - /* 246 */ "SESSION", - /* 247 */ "STATE_WINDOW", - /* 248 */ "SLIDING", - /* 249 */ "FILL", - /* 250 */ "VALUE", - /* 251 */ "NONE", - /* 252 */ "PREV", - /* 253 */ "LINEAR", - /* 254 */ "NEXT", - /* 255 */ "HAVING", - /* 256 */ "RANGE", - /* 257 */ "EVERY", - /* 258 */ "ORDER", - /* 259 */ "SLIMIT", - /* 260 */ "SOFFSET", - /* 261 */ "LIMIT", - /* 262 */ "OFFSET", - /* 263 */ "ASC", - /* 264 */ "NULLS", - /* 265 */ "ABORT", - /* 266 */ "AFTER", - /* 267 */ "ATTACH", - /* 268 */ "BEFORE", - /* 269 */ "BEGIN", - /* 270 */ "BITAND", - /* 271 */ "BITNOT", - /* 272 */ "BITOR", - /* 273 */ "BLOCKS", - /* 274 */ "CHANGE", - /* 275 */ "COMMA", - /* 276 */ "COMPACT", - /* 277 */ "CONCAT", - /* 278 */ "CONFLICT", - /* 279 */ "COPY", - /* 280 */ "DEFERRED", - /* 281 */ "DELIMITERS", - /* 282 */ "DETACH", - /* 283 */ "DIVIDE", - /* 284 */ "DOT", - /* 285 */ "EACH", - /* 286 */ "FAIL", - /* 287 */ "FILE", - /* 288 */ "FOR", - /* 289 */ "GLOB", - /* 290 */ "ID", - /* 291 */ "IMMEDIATE", - /* 292 */ "IMPORT", - /* 293 */ "INITIALLY", - /* 294 */ "INSTEAD", - /* 295 */ "ISNULL", - /* 296 */ "KEY", + /* 137 */ "QNODES", + /* 138 */ "FUNCTIONS", + /* 139 */ "INDEXES", + /* 140 */ "ACCOUNTS", + /* 141 */ "APPS", + /* 142 */ "CONNECTIONS", + /* 143 */ "LICENCES", + /* 144 */ "GRANTS", + /* 145 */ "QUERIES", + /* 146 */ "SCORES", + /* 147 */ "TOPICS", + /* 148 */ "VARIABLES", + /* 149 */ "BNODES", + /* 150 */ "SNODES", + /* 151 */ "CLUSTER", + /* 152 */ "TRANSACTIONS", + /* 153 */ "DISTRIBUTED", + /* 154 */ "CONSUMERS", + /* 155 */ "SUBSCRIPTIONS", + /* 156 */ "VNODES", + /* 157 */ "LIKE", + /* 158 */ "INDEX", + /* 159 */ "FUNCTION", + /* 160 */ "INTERVAL", + /* 161 */ "TOPIC", + /* 162 */ "AS", + /* 163 */ "WITH", + /* 164 */ "META", + /* 165 */ "CONSUMER", + /* 166 */ "GROUP", + /* 167 */ "DESC", + /* 168 */ "DESCRIBE", + /* 169 */ "RESET", + /* 170 */ "QUERY", + /* 171 */ "CACHE", + /* 172 */ "EXPLAIN", + /* 173 */ "ANALYZE", + /* 174 */ "VERBOSE", + /* 175 */ "NK_BOOL", + /* 176 */ "RATIO", + /* 177 */ "NK_FLOAT", + /* 178 */ "OUTPUTTYPE", + /* 179 */ "AGGREGATE", + /* 180 */ "BUFSIZE", + /* 181 */ "STREAM", + /* 182 */ "INTO", + /* 183 */ "TRIGGER", + /* 184 */ "AT_ONCE", + /* 185 */ "WINDOW_CLOSE", + /* 186 */ "IGNORE", + /* 187 */ "EXPIRED", + /* 188 */ "SUBTABLE", + /* 189 */ "KILL", + /* 190 */ "CONNECTION", + /* 191 */ "TRANSACTION", + /* 192 */ "BALANCE", + /* 193 */ "VGROUP", + /* 194 */ "MERGE", + /* 195 */ "REDISTRIBUTE", + /* 196 */ "SPLIT", + /* 197 */ "DELETE", + /* 198 */ "INSERT", + /* 199 */ "NULL", + /* 200 */ "NK_QUESTION", + /* 201 */ "NK_ARROW", + /* 202 */ "ROWTS", + /* 203 */ "TBNAME", + /* 204 */ "QSTART", + /* 205 */ "QEND", + /* 206 */ "QDURATION", + /* 207 */ "WSTART", + /* 208 */ "WEND", + /* 209 */ "WDURATION", + /* 210 */ "IROWTS", + /* 211 */ "QTAGS", + /* 212 */ "CAST", + /* 213 */ "NOW", + /* 214 */ "TODAY", + /* 215 */ "TIMEZONE", + /* 216 */ "CLIENT_VERSION", + /* 217 */ "SERVER_VERSION", + /* 218 */ "SERVER_STATUS", + /* 219 */ "CURRENT_USER", + /* 220 */ "COUNT", + /* 221 */ "LAST_ROW", + /* 222 */ "CASE", + /* 223 */ "END", + /* 224 */ "WHEN", + /* 225 */ "THEN", + /* 226 */ "ELSE", + /* 227 */ "BETWEEN", + /* 228 */ "IS", + /* 229 */ "NK_LT", + /* 230 */ "NK_GT", + /* 231 */ "NK_LE", + /* 232 */ "NK_GE", + /* 233 */ "NK_NE", + /* 234 */ "MATCH", + /* 235 */ "NMATCH", + /* 236 */ "CONTAINS", + /* 237 */ "IN", + /* 238 */ "JOIN", + /* 239 */ "INNER", + /* 240 */ "SELECT", + /* 241 */ "DISTINCT", + /* 242 */ "WHERE", + /* 243 */ "PARTITION", + /* 244 */ "BY", + /* 245 */ "SESSION", + /* 246 */ "STATE_WINDOW", + /* 247 */ "SLIDING", + /* 248 */ "FILL", + /* 249 */ "VALUE", + /* 250 */ "NONE", + /* 251 */ "PREV", + /* 252 */ "LINEAR", + /* 253 */ "NEXT", + /* 254 */ "HAVING", + /* 255 */ "RANGE", + /* 256 */ "EVERY", + /* 257 */ "ORDER", + /* 258 */ "SLIMIT", + /* 259 */ "SOFFSET", + /* 260 */ "LIMIT", + /* 261 */ "OFFSET", + /* 262 */ "ASC", + /* 263 */ "NULLS", + /* 264 */ "ABORT", + /* 265 */ "AFTER", + /* 266 */ "ATTACH", + /* 267 */ "BEFORE", + /* 268 */ "BEGIN", + /* 269 */ "BITAND", + /* 270 */ "BITNOT", + /* 271 */ "BITOR", + /* 272 */ "BLOCKS", + /* 273 */ "CHANGE", + /* 274 */ "COMMA", + /* 275 */ "COMPACT", + /* 276 */ "CONCAT", + /* 277 */ "CONFLICT", + /* 278 */ "COPY", + /* 279 */ "DEFERRED", + /* 280 */ "DELIMITERS", + /* 281 */ "DETACH", + /* 282 */ "DIVIDE", + /* 283 */ "DOT", + /* 284 */ "EACH", + /* 285 */ "FAIL", + /* 286 */ "FILE", + /* 287 */ "FOR", + /* 288 */ "GLOB", + /* 289 */ "ID", + /* 290 */ "IMMEDIATE", + /* 291 */ "IMPORT", + /* 292 */ "INITIALLY", + /* 293 */ "INSTEAD", + /* 294 */ "ISNULL", + /* 295 */ "KEY", + /* 296 */ "MODULES", /* 297 */ "NK_BITNOT", /* 298 */ "NK_SEMI", /* 299 */ "NOTNULL", @@ -2089,320 +2053,319 @@ static const char *const yyRuleName[] = { /* 206 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", /* 207 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", /* 208 */ "cmd ::= SHOW MNODES", - /* 209 */ "cmd ::= SHOW MODULES", - /* 210 */ "cmd ::= SHOW QNODES", - /* 211 */ "cmd ::= SHOW FUNCTIONS", - /* 212 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 213 */ "cmd ::= SHOW STREAMS", - /* 214 */ "cmd ::= SHOW ACCOUNTS", - /* 215 */ "cmd ::= SHOW APPS", - /* 216 */ "cmd ::= SHOW CONNECTIONS", - /* 217 */ "cmd ::= SHOW LICENCES", - /* 218 */ "cmd ::= SHOW GRANTS", - /* 219 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 220 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 221 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 222 */ "cmd ::= SHOW QUERIES", - /* 223 */ "cmd ::= SHOW SCORES", - /* 224 */ "cmd ::= SHOW TOPICS", - /* 225 */ "cmd ::= SHOW VARIABLES", - /* 226 */ "cmd ::= SHOW LOCAL VARIABLES", - /* 227 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", - /* 228 */ "cmd ::= SHOW BNODES", - /* 229 */ "cmd ::= SHOW SNODES", - /* 230 */ "cmd ::= SHOW CLUSTER", - /* 231 */ "cmd ::= SHOW TRANSACTIONS", - /* 232 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", - /* 233 */ "cmd ::= SHOW CONSUMERS", - /* 234 */ "cmd ::= SHOW SUBSCRIPTIONS", - /* 235 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", - /* 236 */ "cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt", - /* 237 */ "cmd ::= SHOW VNODES NK_INTEGER", - /* 238 */ "cmd ::= SHOW VNODES NK_STRING", - /* 239 */ "db_name_cond_opt ::=", - /* 240 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 241 */ "like_pattern_opt ::=", - /* 242 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 243 */ "table_name_cond ::= table_name", - /* 244 */ "from_db_opt ::=", - /* 245 */ "from_db_opt ::= FROM db_name", - /* 246 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", - /* 247 */ "cmd ::= DROP INDEX exists_opt full_table_name", - /* 248 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 249 */ "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", - /* 250 */ "func_list ::= func", - /* 251 */ "func_list ::= func_list NK_COMMA func", - /* 252 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 253 */ "sma_stream_opt ::=", - /* 254 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", - /* 255 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", - /* 256 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 257 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", - /* 258 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", - /* 259 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", - /* 260 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", - /* 261 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 262 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 263 */ "cmd ::= DESC full_table_name", - /* 264 */ "cmd ::= DESCRIBE full_table_name", - /* 265 */ "cmd ::= RESET QUERY CACHE", - /* 266 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 267 */ "analyze_opt ::=", - /* 268 */ "analyze_opt ::= ANALYZE", - /* 269 */ "explain_options ::=", - /* 270 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 271 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 272 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 273 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 274 */ "agg_func_opt ::=", - /* 275 */ "agg_func_opt ::= AGGREGATE", - /* 276 */ "bufsize_opt ::=", - /* 277 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 278 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", - /* 279 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 280 */ "stream_options ::=", - /* 281 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 282 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 283 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 284 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 285 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 286 */ "subtable_opt ::=", - /* 287 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 288 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 289 */ "cmd ::= KILL QUERY NK_STRING", - /* 290 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 291 */ "cmd ::= BALANCE VGROUP", - /* 292 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 293 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 294 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 295 */ "dnode_list ::= DNODE NK_INTEGER", - /* 296 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 297 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 298 */ "cmd ::= query_or_subquery", - /* 299 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 300 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", - /* 301 */ "literal ::= NK_INTEGER", - /* 302 */ "literal ::= NK_FLOAT", - /* 303 */ "literal ::= NK_STRING", - /* 304 */ "literal ::= NK_BOOL", - /* 305 */ "literal ::= TIMESTAMP NK_STRING", - /* 306 */ "literal ::= duration_literal", - /* 307 */ "literal ::= NULL", - /* 308 */ "literal ::= NK_QUESTION", - /* 309 */ "duration_literal ::= NK_VARIABLE", - /* 310 */ "signed ::= NK_INTEGER", - /* 311 */ "signed ::= NK_PLUS NK_INTEGER", - /* 312 */ "signed ::= NK_MINUS NK_INTEGER", - /* 313 */ "signed ::= NK_FLOAT", - /* 314 */ "signed ::= NK_PLUS NK_FLOAT", - /* 315 */ "signed ::= NK_MINUS NK_FLOAT", - /* 316 */ "signed_literal ::= signed", - /* 317 */ "signed_literal ::= NK_STRING", - /* 318 */ "signed_literal ::= NK_BOOL", - /* 319 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 320 */ "signed_literal ::= duration_literal", - /* 321 */ "signed_literal ::= NULL", - /* 322 */ "signed_literal ::= literal_func", - /* 323 */ "signed_literal ::= NK_QUESTION", - /* 324 */ "literal_list ::= signed_literal", - /* 325 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 326 */ "db_name ::= NK_ID", - /* 327 */ "table_name ::= NK_ID", - /* 328 */ "column_name ::= NK_ID", - /* 329 */ "function_name ::= NK_ID", - /* 330 */ "table_alias ::= NK_ID", - /* 331 */ "column_alias ::= NK_ID", - /* 332 */ "user_name ::= NK_ID", - /* 333 */ "topic_name ::= NK_ID", - /* 334 */ "stream_name ::= NK_ID", - /* 335 */ "cgroup_name ::= NK_ID", - /* 336 */ "expr_or_subquery ::= expression", - /* 337 */ "expr_or_subquery ::= subquery", - /* 338 */ "expression ::= literal", - /* 339 */ "expression ::= pseudo_column", - /* 340 */ "expression ::= column_reference", - /* 341 */ "expression ::= function_expression", - /* 342 */ "expression ::= case_when_expression", - /* 343 */ "expression ::= NK_LP expression NK_RP", - /* 344 */ "expression ::= NK_PLUS expr_or_subquery", - /* 345 */ "expression ::= NK_MINUS expr_or_subquery", - /* 346 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 347 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 348 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 349 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 350 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 351 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 352 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 353 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 354 */ "expression_list ::= expr_or_subquery", - /* 355 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 356 */ "column_reference ::= column_name", - /* 357 */ "column_reference ::= table_name NK_DOT column_name", - /* 358 */ "pseudo_column ::= ROWTS", - /* 359 */ "pseudo_column ::= TBNAME", - /* 360 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 361 */ "pseudo_column ::= QSTART", - /* 362 */ "pseudo_column ::= QEND", - /* 363 */ "pseudo_column ::= QDURATION", - /* 364 */ "pseudo_column ::= WSTART", - /* 365 */ "pseudo_column ::= WEND", - /* 366 */ "pseudo_column ::= WDURATION", - /* 367 */ "pseudo_column ::= IROWTS", - /* 368 */ "pseudo_column ::= QTAGS", - /* 369 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 370 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 371 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 372 */ "function_expression ::= literal_func", - /* 373 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 374 */ "literal_func ::= NOW", - /* 375 */ "noarg_func ::= NOW", - /* 376 */ "noarg_func ::= TODAY", - /* 377 */ "noarg_func ::= TIMEZONE", - /* 378 */ "noarg_func ::= DATABASE", - /* 379 */ "noarg_func ::= CLIENT_VERSION", - /* 380 */ "noarg_func ::= SERVER_VERSION", - /* 381 */ "noarg_func ::= SERVER_STATUS", - /* 382 */ "noarg_func ::= CURRENT_USER", - /* 383 */ "noarg_func ::= USER", - /* 384 */ "star_func ::= COUNT", - /* 385 */ "star_func ::= FIRST", - /* 386 */ "star_func ::= LAST", - /* 387 */ "star_func ::= LAST_ROW", - /* 388 */ "star_func_para_list ::= NK_STAR", - /* 389 */ "star_func_para_list ::= other_para_list", - /* 390 */ "other_para_list ::= star_func_para", - /* 391 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 392 */ "star_func_para ::= expr_or_subquery", - /* 393 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 394 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 395 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 396 */ "when_then_list ::= when_then_expr", - /* 397 */ "when_then_list ::= when_then_list when_then_expr", - /* 398 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 399 */ "case_when_else_opt ::=", - /* 400 */ "case_when_else_opt ::= ELSE common_expression", - /* 401 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 402 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 403 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 404 */ "predicate ::= expr_or_subquery IS NULL", - /* 405 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 406 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 407 */ "compare_op ::= NK_LT", - /* 408 */ "compare_op ::= NK_GT", - /* 409 */ "compare_op ::= NK_LE", - /* 410 */ "compare_op ::= NK_GE", - /* 411 */ "compare_op ::= NK_NE", - /* 412 */ "compare_op ::= NK_EQ", - /* 413 */ "compare_op ::= LIKE", - /* 414 */ "compare_op ::= NOT LIKE", - /* 415 */ "compare_op ::= MATCH", - /* 416 */ "compare_op ::= NMATCH", - /* 417 */ "compare_op ::= CONTAINS", - /* 418 */ "in_op ::= IN", - /* 419 */ "in_op ::= NOT IN", - /* 420 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 421 */ "boolean_value_expression ::= boolean_primary", - /* 422 */ "boolean_value_expression ::= NOT boolean_primary", - /* 423 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 424 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 425 */ "boolean_primary ::= predicate", - /* 426 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 427 */ "common_expression ::= expr_or_subquery", - /* 428 */ "common_expression ::= boolean_value_expression", - /* 429 */ "from_clause_opt ::=", - /* 430 */ "from_clause_opt ::= FROM table_reference_list", - /* 431 */ "table_reference_list ::= table_reference", - /* 432 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 433 */ "table_reference ::= table_primary", - /* 434 */ "table_reference ::= joined_table", - /* 435 */ "table_primary ::= table_name alias_opt", - /* 436 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 437 */ "table_primary ::= subquery alias_opt", - /* 438 */ "table_primary ::= parenthesized_joined_table", - /* 439 */ "alias_opt ::=", - /* 440 */ "alias_opt ::= table_alias", - /* 441 */ "alias_opt ::= AS table_alias", - /* 442 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 443 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 444 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 445 */ "join_type ::=", - /* 446 */ "join_type ::= INNER", - /* 447 */ "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", - /* 448 */ "set_quantifier_opt ::=", - /* 449 */ "set_quantifier_opt ::= DISTINCT", - /* 450 */ "set_quantifier_opt ::= ALL", - /* 451 */ "select_list ::= select_item", - /* 452 */ "select_list ::= select_list NK_COMMA select_item", - /* 453 */ "select_item ::= NK_STAR", - /* 454 */ "select_item ::= common_expression", - /* 455 */ "select_item ::= common_expression column_alias", - /* 456 */ "select_item ::= common_expression AS column_alias", - /* 457 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 458 */ "where_clause_opt ::=", - /* 459 */ "where_clause_opt ::= WHERE search_condition", - /* 460 */ "partition_by_clause_opt ::=", - /* 461 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 462 */ "partition_list ::= partition_item", - /* 463 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 464 */ "partition_item ::= expr_or_subquery", - /* 465 */ "partition_item ::= expr_or_subquery column_alias", - /* 466 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 467 */ "twindow_clause_opt ::=", - /* 468 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 469 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 470 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 471 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 472 */ "sliding_opt ::=", - /* 473 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 474 */ "fill_opt ::=", - /* 475 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 476 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 477 */ "fill_mode ::= NONE", - /* 478 */ "fill_mode ::= PREV", - /* 479 */ "fill_mode ::= NULL", - /* 480 */ "fill_mode ::= LINEAR", - /* 481 */ "fill_mode ::= NEXT", - /* 482 */ "group_by_clause_opt ::=", - /* 483 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 484 */ "group_by_list ::= expr_or_subquery", - /* 485 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 486 */ "having_clause_opt ::=", - /* 487 */ "having_clause_opt ::= HAVING search_condition", - /* 488 */ "range_opt ::=", - /* 489 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 490 */ "every_opt ::=", - /* 491 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 492 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 493 */ "query_simple ::= query_specification", - /* 494 */ "query_simple ::= union_query_expression", - /* 495 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 496 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 497 */ "query_simple_or_subquery ::= query_simple", - /* 498 */ "query_simple_or_subquery ::= subquery", - /* 499 */ "query_or_subquery ::= query_expression", - /* 500 */ "query_or_subquery ::= subquery", - /* 501 */ "order_by_clause_opt ::=", - /* 502 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 503 */ "slimit_clause_opt ::=", - /* 504 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 505 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 506 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 507 */ "limit_clause_opt ::=", - /* 508 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 509 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 510 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 511 */ "subquery ::= NK_LP query_expression NK_RP", - /* 512 */ "subquery ::= NK_LP subquery NK_RP", - /* 513 */ "search_condition ::= common_expression", - /* 514 */ "sort_specification_list ::= sort_specification", - /* 515 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 516 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 517 */ "ordering_specification_opt ::=", - /* 518 */ "ordering_specification_opt ::= ASC", - /* 519 */ "ordering_specification_opt ::= DESC", - /* 520 */ "null_ordering_opt ::=", - /* 521 */ "null_ordering_opt ::= NULLS FIRST", - /* 522 */ "null_ordering_opt ::= NULLS LAST", + /* 209 */ "cmd ::= SHOW QNODES", + /* 210 */ "cmd ::= SHOW FUNCTIONS", + /* 211 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 212 */ "cmd ::= SHOW STREAMS", + /* 213 */ "cmd ::= SHOW ACCOUNTS", + /* 214 */ "cmd ::= SHOW APPS", + /* 215 */ "cmd ::= SHOW CONNECTIONS", + /* 216 */ "cmd ::= SHOW LICENCES", + /* 217 */ "cmd ::= SHOW GRANTS", + /* 218 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 219 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 220 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 221 */ "cmd ::= SHOW QUERIES", + /* 222 */ "cmd ::= SHOW SCORES", + /* 223 */ "cmd ::= SHOW TOPICS", + /* 224 */ "cmd ::= SHOW VARIABLES", + /* 225 */ "cmd ::= SHOW LOCAL VARIABLES", + /* 226 */ "cmd ::= SHOW DNODE NK_INTEGER VARIABLES", + /* 227 */ "cmd ::= SHOW BNODES", + /* 228 */ "cmd ::= SHOW SNODES", + /* 229 */ "cmd ::= SHOW CLUSTER", + /* 230 */ "cmd ::= SHOW TRANSACTIONS", + /* 231 */ "cmd ::= SHOW TABLE DISTRIBUTED full_table_name", + /* 232 */ "cmd ::= SHOW CONSUMERS", + /* 233 */ "cmd ::= SHOW SUBSCRIPTIONS", + /* 234 */ "cmd ::= SHOW TAGS FROM table_name_cond from_db_opt", + /* 235 */ "cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt", + /* 236 */ "cmd ::= SHOW VNODES NK_INTEGER", + /* 237 */ "cmd ::= SHOW VNODES NK_STRING", + /* 238 */ "db_name_cond_opt ::=", + /* 239 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 240 */ "like_pattern_opt ::=", + /* 241 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 242 */ "table_name_cond ::= table_name", + /* 243 */ "from_db_opt ::=", + /* 244 */ "from_db_opt ::= FROM db_name", + /* 245 */ "cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options", + /* 246 */ "cmd ::= DROP INDEX exists_opt full_table_name", + /* 247 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 248 */ "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", + /* 249 */ "func_list ::= func", + /* 250 */ "func_list ::= func_list NK_COMMA func", + /* 251 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 252 */ "sma_stream_opt ::=", + /* 253 */ "sma_stream_opt ::= stream_options WATERMARK duration_literal", + /* 254 */ "sma_stream_opt ::= stream_options MAX_DELAY duration_literal", + /* 255 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 256 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name", + /* 257 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name", + /* 258 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name", + /* 259 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name", + /* 260 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 261 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 262 */ "cmd ::= DESC full_table_name", + /* 263 */ "cmd ::= DESCRIBE full_table_name", + /* 264 */ "cmd ::= RESET QUERY CACHE", + /* 265 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 266 */ "analyze_opt ::=", + /* 267 */ "analyze_opt ::= ANALYZE", + /* 268 */ "explain_options ::=", + /* 269 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 270 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 271 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 272 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 273 */ "agg_func_opt ::=", + /* 274 */ "agg_func_opt ::= AGGREGATE", + /* 275 */ "bufsize_opt ::=", + /* 276 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 277 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery", + /* 278 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 279 */ "stream_options ::=", + /* 280 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 281 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 282 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 283 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 284 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 285 */ "subtable_opt ::=", + /* 286 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 287 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 288 */ "cmd ::= KILL QUERY NK_STRING", + /* 289 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 290 */ "cmd ::= BALANCE VGROUP", + /* 291 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 292 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 293 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 294 */ "dnode_list ::= DNODE NK_INTEGER", + /* 295 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 296 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 297 */ "cmd ::= query_or_subquery", + /* 298 */ "cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 299 */ "cmd ::= INSERT INTO full_table_name query_or_subquery", + /* 300 */ "literal ::= NK_INTEGER", + /* 301 */ "literal ::= NK_FLOAT", + /* 302 */ "literal ::= NK_STRING", + /* 303 */ "literal ::= NK_BOOL", + /* 304 */ "literal ::= TIMESTAMP NK_STRING", + /* 305 */ "literal ::= duration_literal", + /* 306 */ "literal ::= NULL", + /* 307 */ "literal ::= NK_QUESTION", + /* 308 */ "duration_literal ::= NK_VARIABLE", + /* 309 */ "signed ::= NK_INTEGER", + /* 310 */ "signed ::= NK_PLUS NK_INTEGER", + /* 311 */ "signed ::= NK_MINUS NK_INTEGER", + /* 312 */ "signed ::= NK_FLOAT", + /* 313 */ "signed ::= NK_PLUS NK_FLOAT", + /* 314 */ "signed ::= NK_MINUS NK_FLOAT", + /* 315 */ "signed_literal ::= signed", + /* 316 */ "signed_literal ::= NK_STRING", + /* 317 */ "signed_literal ::= NK_BOOL", + /* 318 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 319 */ "signed_literal ::= duration_literal", + /* 320 */ "signed_literal ::= NULL", + /* 321 */ "signed_literal ::= literal_func", + /* 322 */ "signed_literal ::= NK_QUESTION", + /* 323 */ "literal_list ::= signed_literal", + /* 324 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 325 */ "db_name ::= NK_ID", + /* 326 */ "table_name ::= NK_ID", + /* 327 */ "column_name ::= NK_ID", + /* 328 */ "function_name ::= NK_ID", + /* 329 */ "table_alias ::= NK_ID", + /* 330 */ "column_alias ::= NK_ID", + /* 331 */ "user_name ::= NK_ID", + /* 332 */ "topic_name ::= NK_ID", + /* 333 */ "stream_name ::= NK_ID", + /* 334 */ "cgroup_name ::= NK_ID", + /* 335 */ "expr_or_subquery ::= expression", + /* 336 */ "expr_or_subquery ::= subquery", + /* 337 */ "expression ::= literal", + /* 338 */ "expression ::= pseudo_column", + /* 339 */ "expression ::= column_reference", + /* 340 */ "expression ::= function_expression", + /* 341 */ "expression ::= case_when_expression", + /* 342 */ "expression ::= NK_LP expression NK_RP", + /* 343 */ "expression ::= NK_PLUS expr_or_subquery", + /* 344 */ "expression ::= NK_MINUS expr_or_subquery", + /* 345 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 346 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 347 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 348 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 349 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 350 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 351 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 352 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 353 */ "expression_list ::= expr_or_subquery", + /* 354 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 355 */ "column_reference ::= column_name", + /* 356 */ "column_reference ::= table_name NK_DOT column_name", + /* 357 */ "pseudo_column ::= ROWTS", + /* 358 */ "pseudo_column ::= TBNAME", + /* 359 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 360 */ "pseudo_column ::= QSTART", + /* 361 */ "pseudo_column ::= QEND", + /* 362 */ "pseudo_column ::= QDURATION", + /* 363 */ "pseudo_column ::= WSTART", + /* 364 */ "pseudo_column ::= WEND", + /* 365 */ "pseudo_column ::= WDURATION", + /* 366 */ "pseudo_column ::= IROWTS", + /* 367 */ "pseudo_column ::= QTAGS", + /* 368 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 369 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 370 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 371 */ "function_expression ::= literal_func", + /* 372 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 373 */ "literal_func ::= NOW", + /* 374 */ "noarg_func ::= NOW", + /* 375 */ "noarg_func ::= TODAY", + /* 376 */ "noarg_func ::= TIMEZONE", + /* 377 */ "noarg_func ::= DATABASE", + /* 378 */ "noarg_func ::= CLIENT_VERSION", + /* 379 */ "noarg_func ::= SERVER_VERSION", + /* 380 */ "noarg_func ::= SERVER_STATUS", + /* 381 */ "noarg_func ::= CURRENT_USER", + /* 382 */ "noarg_func ::= USER", + /* 383 */ "star_func ::= COUNT", + /* 384 */ "star_func ::= FIRST", + /* 385 */ "star_func ::= LAST", + /* 386 */ "star_func ::= LAST_ROW", + /* 387 */ "star_func_para_list ::= NK_STAR", + /* 388 */ "star_func_para_list ::= other_para_list", + /* 389 */ "other_para_list ::= star_func_para", + /* 390 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 391 */ "star_func_para ::= expr_or_subquery", + /* 392 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 393 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 394 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 395 */ "when_then_list ::= when_then_expr", + /* 396 */ "when_then_list ::= when_then_list when_then_expr", + /* 397 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 398 */ "case_when_else_opt ::=", + /* 399 */ "case_when_else_opt ::= ELSE common_expression", + /* 400 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 401 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 402 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 403 */ "predicate ::= expr_or_subquery IS NULL", + /* 404 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 405 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 406 */ "compare_op ::= NK_LT", + /* 407 */ "compare_op ::= NK_GT", + /* 408 */ "compare_op ::= NK_LE", + /* 409 */ "compare_op ::= NK_GE", + /* 410 */ "compare_op ::= NK_NE", + /* 411 */ "compare_op ::= NK_EQ", + /* 412 */ "compare_op ::= LIKE", + /* 413 */ "compare_op ::= NOT LIKE", + /* 414 */ "compare_op ::= MATCH", + /* 415 */ "compare_op ::= NMATCH", + /* 416 */ "compare_op ::= CONTAINS", + /* 417 */ "in_op ::= IN", + /* 418 */ "in_op ::= NOT IN", + /* 419 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 420 */ "boolean_value_expression ::= boolean_primary", + /* 421 */ "boolean_value_expression ::= NOT boolean_primary", + /* 422 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 423 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 424 */ "boolean_primary ::= predicate", + /* 425 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 426 */ "common_expression ::= expr_or_subquery", + /* 427 */ "common_expression ::= boolean_value_expression", + /* 428 */ "from_clause_opt ::=", + /* 429 */ "from_clause_opt ::= FROM table_reference_list", + /* 430 */ "table_reference_list ::= table_reference", + /* 431 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 432 */ "table_reference ::= table_primary", + /* 433 */ "table_reference ::= joined_table", + /* 434 */ "table_primary ::= table_name alias_opt", + /* 435 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 436 */ "table_primary ::= subquery alias_opt", + /* 437 */ "table_primary ::= parenthesized_joined_table", + /* 438 */ "alias_opt ::=", + /* 439 */ "alias_opt ::= table_alias", + /* 440 */ "alias_opt ::= AS table_alias", + /* 441 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 442 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 443 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 444 */ "join_type ::=", + /* 445 */ "join_type ::= INNER", + /* 446 */ "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", + /* 447 */ "set_quantifier_opt ::=", + /* 448 */ "set_quantifier_opt ::= DISTINCT", + /* 449 */ "set_quantifier_opt ::= ALL", + /* 450 */ "select_list ::= select_item", + /* 451 */ "select_list ::= select_list NK_COMMA select_item", + /* 452 */ "select_item ::= NK_STAR", + /* 453 */ "select_item ::= common_expression", + /* 454 */ "select_item ::= common_expression column_alias", + /* 455 */ "select_item ::= common_expression AS column_alias", + /* 456 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 457 */ "where_clause_opt ::=", + /* 458 */ "where_clause_opt ::= WHERE search_condition", + /* 459 */ "partition_by_clause_opt ::=", + /* 460 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 461 */ "partition_list ::= partition_item", + /* 462 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 463 */ "partition_item ::= expr_or_subquery", + /* 464 */ "partition_item ::= expr_or_subquery column_alias", + /* 465 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 466 */ "twindow_clause_opt ::=", + /* 467 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 468 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 469 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 470 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 471 */ "sliding_opt ::=", + /* 472 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 473 */ "fill_opt ::=", + /* 474 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 475 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 476 */ "fill_mode ::= NONE", + /* 477 */ "fill_mode ::= PREV", + /* 478 */ "fill_mode ::= NULL", + /* 479 */ "fill_mode ::= LINEAR", + /* 480 */ "fill_mode ::= NEXT", + /* 481 */ "group_by_clause_opt ::=", + /* 482 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 483 */ "group_by_list ::= expr_or_subquery", + /* 484 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 485 */ "having_clause_opt ::=", + /* 486 */ "having_clause_opt ::= HAVING search_condition", + /* 487 */ "range_opt ::=", + /* 488 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 489 */ "every_opt ::=", + /* 490 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 491 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 492 */ "query_simple ::= query_specification", + /* 493 */ "query_simple ::= union_query_expression", + /* 494 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 495 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 496 */ "query_simple_or_subquery ::= query_simple", + /* 497 */ "query_simple_or_subquery ::= subquery", + /* 498 */ "query_or_subquery ::= query_expression", + /* 499 */ "query_or_subquery ::= subquery", + /* 500 */ "order_by_clause_opt ::=", + /* 501 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 502 */ "slimit_clause_opt ::=", + /* 503 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 504 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 505 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 506 */ "limit_clause_opt ::=", + /* 507 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 508 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 509 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 510 */ "subquery ::= NK_LP query_expression NK_RP", + /* 511 */ "subquery ::= NK_LP subquery NK_RP", + /* 512 */ "search_condition ::= common_expression", + /* 513 */ "sort_specification_list ::= sort_specification", + /* 514 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 515 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 516 */ "ordering_specification_opt ::=", + /* 517 */ "ordering_specification_opt ::= ASC", + /* 518 */ "ordering_specification_opt ::= DESC", + /* 519 */ "null_ordering_opt ::=", + /* 520 */ "null_ordering_opt ::= NULLS FIRST", + /* 521 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3220,320 +3183,319 @@ static const struct { { 317, -4 }, /* (206) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ { 317, -3 }, /* (207) cmd ::= SHOW db_name_cond_opt VGROUPS */ { 317, -2 }, /* (208) cmd ::= SHOW MNODES */ - { 317, -2 }, /* (209) cmd ::= SHOW MODULES */ - { 317, -2 }, /* (210) cmd ::= SHOW QNODES */ - { 317, -2 }, /* (211) cmd ::= SHOW FUNCTIONS */ - { 317, -5 }, /* (212) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 317, -2 }, /* (213) cmd ::= SHOW STREAMS */ - { 317, -2 }, /* (214) cmd ::= SHOW ACCOUNTS */ - { 317, -2 }, /* (215) cmd ::= SHOW APPS */ - { 317, -2 }, /* (216) cmd ::= SHOW CONNECTIONS */ - { 317, -2 }, /* (217) cmd ::= SHOW LICENCES */ - { 317, -2 }, /* (218) cmd ::= SHOW GRANTS */ - { 317, -4 }, /* (219) cmd ::= SHOW CREATE DATABASE db_name */ - { 317, -4 }, /* (220) cmd ::= SHOW CREATE TABLE full_table_name */ - { 317, -4 }, /* (221) cmd ::= SHOW CREATE STABLE full_table_name */ - { 317, -2 }, /* (222) cmd ::= SHOW QUERIES */ - { 317, -2 }, /* (223) cmd ::= SHOW SCORES */ - { 317, -2 }, /* (224) cmd ::= SHOW TOPICS */ - { 317, -2 }, /* (225) cmd ::= SHOW VARIABLES */ - { 317, -3 }, /* (226) cmd ::= SHOW LOCAL VARIABLES */ - { 317, -4 }, /* (227) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ - { 317, -2 }, /* (228) cmd ::= SHOW BNODES */ - { 317, -2 }, /* (229) cmd ::= SHOW SNODES */ - { 317, -2 }, /* (230) cmd ::= SHOW CLUSTER */ - { 317, -2 }, /* (231) cmd ::= SHOW TRANSACTIONS */ - { 317, -4 }, /* (232) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - { 317, -2 }, /* (233) cmd ::= SHOW CONSUMERS */ - { 317, -2 }, /* (234) cmd ::= SHOW SUBSCRIPTIONS */ - { 317, -5 }, /* (235) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - { 317, -6 }, /* (236) cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ - { 317, -3 }, /* (237) cmd ::= SHOW VNODES NK_INTEGER */ - { 317, -3 }, /* (238) cmd ::= SHOW VNODES NK_STRING */ - { 366, 0 }, /* (239) db_name_cond_opt ::= */ - { 366, -2 }, /* (240) db_name_cond_opt ::= db_name NK_DOT */ - { 367, 0 }, /* (241) like_pattern_opt ::= */ - { 367, -2 }, /* (242) like_pattern_opt ::= LIKE NK_STRING */ - { 368, -1 }, /* (243) table_name_cond ::= table_name */ - { 369, 0 }, /* (244) from_db_opt ::= */ - { 369, -2 }, /* (245) from_db_opt ::= FROM db_name */ - { 317, -8 }, /* (246) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ - { 317, -4 }, /* (247) cmd ::= DROP INDEX exists_opt full_table_name */ - { 370, -10 }, /* (248) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - { 370, -12 }, /* (249) 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 */ - { 371, -1 }, /* (250) func_list ::= func */ - { 371, -3 }, /* (251) func_list ::= func_list NK_COMMA func */ - { 374, -4 }, /* (252) func ::= function_name NK_LP expression_list NK_RP */ - { 373, 0 }, /* (253) sma_stream_opt ::= */ - { 373, -3 }, /* (254) sma_stream_opt ::= stream_options WATERMARK duration_literal */ - { 373, -3 }, /* (255) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ - { 317, -6 }, /* (256) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - { 317, -7 }, /* (257) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ - { 317, -9 }, /* (258) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ - { 317, -7 }, /* (259) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ - { 317, -9 }, /* (260) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ - { 317, -4 }, /* (261) cmd ::= DROP TOPIC exists_opt topic_name */ - { 317, -7 }, /* (262) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - { 317, -2 }, /* (263) cmd ::= DESC full_table_name */ - { 317, -2 }, /* (264) cmd ::= DESCRIBE full_table_name */ - { 317, -3 }, /* (265) cmd ::= RESET QUERY CACHE */ - { 317, -4 }, /* (266) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - { 379, 0 }, /* (267) analyze_opt ::= */ - { 379, -1 }, /* (268) analyze_opt ::= ANALYZE */ - { 380, 0 }, /* (269) explain_options ::= */ - { 380, -3 }, /* (270) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 380, -3 }, /* (271) explain_options ::= explain_options RATIO NK_FLOAT */ - { 317, -10 }, /* (272) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 317, -4 }, /* (273) cmd ::= DROP FUNCTION exists_opt function_name */ - { 381, 0 }, /* (274) agg_func_opt ::= */ - { 381, -1 }, /* (275) agg_func_opt ::= AGGREGATE */ - { 382, 0 }, /* (276) bufsize_opt ::= */ - { 382, -2 }, /* (277) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 317, -11 }, /* (278) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ - { 317, -4 }, /* (279) cmd ::= DROP STREAM exists_opt stream_name */ - { 375, 0 }, /* (280) stream_options ::= */ - { 375, -3 }, /* (281) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 375, -3 }, /* (282) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 375, -4 }, /* (283) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - { 375, -3 }, /* (284) stream_options ::= stream_options WATERMARK duration_literal */ - { 375, -4 }, /* (285) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - { 384, 0 }, /* (286) subtable_opt ::= */ - { 384, -4 }, /* (287) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - { 317, -3 }, /* (288) cmd ::= KILL CONNECTION NK_INTEGER */ - { 317, -3 }, /* (289) cmd ::= KILL QUERY NK_STRING */ - { 317, -3 }, /* (290) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 317, -2 }, /* (291) cmd ::= BALANCE VGROUP */ - { 317, -4 }, /* (292) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 317, -4 }, /* (293) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 317, -3 }, /* (294) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 386, -2 }, /* (295) dnode_list ::= DNODE NK_INTEGER */ - { 386, -3 }, /* (296) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 317, -4 }, /* (297) cmd ::= DELETE FROM full_table_name where_clause_opt */ - { 317, -1 }, /* (298) cmd ::= query_or_subquery */ - { 317, -7 }, /* (299) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - { 317, -4 }, /* (300) cmd ::= INSERT INTO full_table_name query_or_subquery */ - { 320, -1 }, /* (301) literal ::= NK_INTEGER */ - { 320, -1 }, /* (302) literal ::= NK_FLOAT */ - { 320, -1 }, /* (303) literal ::= NK_STRING */ - { 320, -1 }, /* (304) literal ::= NK_BOOL */ - { 320, -2 }, /* (305) literal ::= TIMESTAMP NK_STRING */ - { 320, -1 }, /* (306) literal ::= duration_literal */ - { 320, -1 }, /* (307) literal ::= NULL */ - { 320, -1 }, /* (308) literal ::= NK_QUESTION */ - { 362, -1 }, /* (309) duration_literal ::= NK_VARIABLE */ - { 388, -1 }, /* (310) signed ::= NK_INTEGER */ - { 388, -2 }, /* (311) signed ::= NK_PLUS NK_INTEGER */ - { 388, -2 }, /* (312) signed ::= NK_MINUS NK_INTEGER */ - { 388, -1 }, /* (313) signed ::= NK_FLOAT */ - { 388, -2 }, /* (314) signed ::= NK_PLUS NK_FLOAT */ - { 388, -2 }, /* (315) signed ::= NK_MINUS NK_FLOAT */ - { 351, -1 }, /* (316) signed_literal ::= signed */ - { 351, -1 }, /* (317) signed_literal ::= NK_STRING */ - { 351, -1 }, /* (318) signed_literal ::= NK_BOOL */ - { 351, -2 }, /* (319) signed_literal ::= TIMESTAMP NK_STRING */ - { 351, -1 }, /* (320) signed_literal ::= duration_literal */ - { 351, -1 }, /* (321) signed_literal ::= NULL */ - { 351, -1 }, /* (322) signed_literal ::= literal_func */ - { 351, -1 }, /* (323) signed_literal ::= NK_QUESTION */ - { 390, -1 }, /* (324) literal_list ::= signed_literal */ - { 390, -3 }, /* (325) literal_list ::= literal_list NK_COMMA signed_literal */ - { 328, -1 }, /* (326) db_name ::= NK_ID */ - { 357, -1 }, /* (327) table_name ::= NK_ID */ - { 349, -1 }, /* (328) column_name ::= NK_ID */ - { 364, -1 }, /* (329) function_name ::= NK_ID */ - { 391, -1 }, /* (330) table_alias ::= NK_ID */ - { 392, -1 }, /* (331) column_alias ::= NK_ID */ - { 322, -1 }, /* (332) user_name ::= NK_ID */ - { 376, -1 }, /* (333) topic_name ::= NK_ID */ - { 383, -1 }, /* (334) stream_name ::= NK_ID */ - { 378, -1 }, /* (335) cgroup_name ::= NK_ID */ - { 393, -1 }, /* (336) expr_or_subquery ::= expression */ - { 393, -1 }, /* (337) expr_or_subquery ::= subquery */ - { 385, -1 }, /* (338) expression ::= literal */ - { 385, -1 }, /* (339) expression ::= pseudo_column */ - { 385, -1 }, /* (340) expression ::= column_reference */ - { 385, -1 }, /* (341) expression ::= function_expression */ - { 385, -1 }, /* (342) expression ::= case_when_expression */ - { 385, -3 }, /* (343) expression ::= NK_LP expression NK_RP */ - { 385, -2 }, /* (344) expression ::= NK_PLUS expr_or_subquery */ - { 385, -2 }, /* (345) expression ::= NK_MINUS expr_or_subquery */ - { 385, -3 }, /* (346) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - { 385, -3 }, /* (347) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - { 385, -3 }, /* (348) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - { 385, -3 }, /* (349) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - { 385, -3 }, /* (350) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - { 385, -3 }, /* (351) expression ::= column_reference NK_ARROW NK_STRING */ - { 385, -3 }, /* (352) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - { 385, -3 }, /* (353) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - { 354, -1 }, /* (354) expression_list ::= expr_or_subquery */ - { 354, -3 }, /* (355) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - { 396, -1 }, /* (356) column_reference ::= column_name */ - { 396, -3 }, /* (357) column_reference ::= table_name NK_DOT column_name */ - { 395, -1 }, /* (358) pseudo_column ::= ROWTS */ - { 395, -1 }, /* (359) pseudo_column ::= TBNAME */ - { 395, -3 }, /* (360) pseudo_column ::= table_name NK_DOT TBNAME */ - { 395, -1 }, /* (361) pseudo_column ::= QSTART */ - { 395, -1 }, /* (362) pseudo_column ::= QEND */ - { 395, -1 }, /* (363) pseudo_column ::= QDURATION */ - { 395, -1 }, /* (364) pseudo_column ::= WSTART */ - { 395, -1 }, /* (365) pseudo_column ::= WEND */ - { 395, -1 }, /* (366) pseudo_column ::= WDURATION */ - { 395, -1 }, /* (367) pseudo_column ::= IROWTS */ - { 395, -1 }, /* (368) pseudo_column ::= QTAGS */ - { 397, -4 }, /* (369) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 397, -4 }, /* (370) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 397, -6 }, /* (371) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - { 397, -1 }, /* (372) function_expression ::= literal_func */ - { 389, -3 }, /* (373) literal_func ::= noarg_func NK_LP NK_RP */ - { 389, -1 }, /* (374) literal_func ::= NOW */ - { 401, -1 }, /* (375) noarg_func ::= NOW */ - { 401, -1 }, /* (376) noarg_func ::= TODAY */ - { 401, -1 }, /* (377) noarg_func ::= TIMEZONE */ - { 401, -1 }, /* (378) noarg_func ::= DATABASE */ - { 401, -1 }, /* (379) noarg_func ::= CLIENT_VERSION */ - { 401, -1 }, /* (380) noarg_func ::= SERVER_VERSION */ - { 401, -1 }, /* (381) noarg_func ::= SERVER_STATUS */ - { 401, -1 }, /* (382) noarg_func ::= CURRENT_USER */ - { 401, -1 }, /* (383) noarg_func ::= USER */ - { 399, -1 }, /* (384) star_func ::= COUNT */ - { 399, -1 }, /* (385) star_func ::= FIRST */ - { 399, -1 }, /* (386) star_func ::= LAST */ - { 399, -1 }, /* (387) star_func ::= LAST_ROW */ - { 400, -1 }, /* (388) star_func_para_list ::= NK_STAR */ - { 400, -1 }, /* (389) star_func_para_list ::= other_para_list */ - { 402, -1 }, /* (390) other_para_list ::= star_func_para */ - { 402, -3 }, /* (391) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 403, -1 }, /* (392) star_func_para ::= expr_or_subquery */ - { 403, -3 }, /* (393) star_func_para ::= table_name NK_DOT NK_STAR */ - { 398, -4 }, /* (394) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - { 398, -5 }, /* (395) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - { 404, -1 }, /* (396) when_then_list ::= when_then_expr */ - { 404, -2 }, /* (397) when_then_list ::= when_then_list when_then_expr */ - { 407, -4 }, /* (398) when_then_expr ::= WHEN common_expression THEN common_expression */ - { 405, 0 }, /* (399) case_when_else_opt ::= */ - { 405, -2 }, /* (400) case_when_else_opt ::= ELSE common_expression */ - { 408, -3 }, /* (401) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - { 408, -5 }, /* (402) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - { 408, -6 }, /* (403) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - { 408, -3 }, /* (404) predicate ::= expr_or_subquery IS NULL */ - { 408, -4 }, /* (405) predicate ::= expr_or_subquery IS NOT NULL */ - { 408, -3 }, /* (406) predicate ::= expr_or_subquery in_op in_predicate_value */ - { 409, -1 }, /* (407) compare_op ::= NK_LT */ - { 409, -1 }, /* (408) compare_op ::= NK_GT */ - { 409, -1 }, /* (409) compare_op ::= NK_LE */ - { 409, -1 }, /* (410) compare_op ::= NK_GE */ - { 409, -1 }, /* (411) compare_op ::= NK_NE */ - { 409, -1 }, /* (412) compare_op ::= NK_EQ */ - { 409, -1 }, /* (413) compare_op ::= LIKE */ - { 409, -2 }, /* (414) compare_op ::= NOT LIKE */ - { 409, -1 }, /* (415) compare_op ::= MATCH */ - { 409, -1 }, /* (416) compare_op ::= NMATCH */ - { 409, -1 }, /* (417) compare_op ::= CONTAINS */ - { 410, -1 }, /* (418) in_op ::= IN */ - { 410, -2 }, /* (419) in_op ::= NOT IN */ - { 411, -3 }, /* (420) in_predicate_value ::= NK_LP literal_list NK_RP */ - { 412, -1 }, /* (421) boolean_value_expression ::= boolean_primary */ - { 412, -2 }, /* (422) boolean_value_expression ::= NOT boolean_primary */ - { 412, -3 }, /* (423) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 412, -3 }, /* (424) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 413, -1 }, /* (425) boolean_primary ::= predicate */ - { 413, -3 }, /* (426) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 406, -1 }, /* (427) common_expression ::= expr_or_subquery */ - { 406, -1 }, /* (428) common_expression ::= boolean_value_expression */ - { 414, 0 }, /* (429) from_clause_opt ::= */ - { 414, -2 }, /* (430) from_clause_opt ::= FROM table_reference_list */ - { 415, -1 }, /* (431) table_reference_list ::= table_reference */ - { 415, -3 }, /* (432) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 416, -1 }, /* (433) table_reference ::= table_primary */ - { 416, -1 }, /* (434) table_reference ::= joined_table */ - { 417, -2 }, /* (435) table_primary ::= table_name alias_opt */ - { 417, -4 }, /* (436) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 417, -2 }, /* (437) table_primary ::= subquery alias_opt */ - { 417, -1 }, /* (438) table_primary ::= parenthesized_joined_table */ - { 419, 0 }, /* (439) alias_opt ::= */ - { 419, -1 }, /* (440) alias_opt ::= table_alias */ - { 419, -2 }, /* (441) alias_opt ::= AS table_alias */ - { 420, -3 }, /* (442) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 420, -3 }, /* (443) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 418, -6 }, /* (444) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 421, 0 }, /* (445) join_type ::= */ - { 421, -1 }, /* (446) join_type ::= INNER */ - { 423, -12 }, /* (447) 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 */ - { 424, 0 }, /* (448) set_quantifier_opt ::= */ - { 424, -1 }, /* (449) set_quantifier_opt ::= DISTINCT */ - { 424, -1 }, /* (450) set_quantifier_opt ::= ALL */ - { 425, -1 }, /* (451) select_list ::= select_item */ - { 425, -3 }, /* (452) select_list ::= select_list NK_COMMA select_item */ - { 433, -1 }, /* (453) select_item ::= NK_STAR */ - { 433, -1 }, /* (454) select_item ::= common_expression */ - { 433, -2 }, /* (455) select_item ::= common_expression column_alias */ - { 433, -3 }, /* (456) select_item ::= common_expression AS column_alias */ - { 433, -3 }, /* (457) select_item ::= table_name NK_DOT NK_STAR */ - { 387, 0 }, /* (458) where_clause_opt ::= */ - { 387, -2 }, /* (459) where_clause_opt ::= WHERE search_condition */ - { 426, 0 }, /* (460) partition_by_clause_opt ::= */ - { 426, -3 }, /* (461) partition_by_clause_opt ::= PARTITION BY partition_list */ - { 434, -1 }, /* (462) partition_list ::= partition_item */ - { 434, -3 }, /* (463) partition_list ::= partition_list NK_COMMA partition_item */ - { 435, -1 }, /* (464) partition_item ::= expr_or_subquery */ - { 435, -2 }, /* (465) partition_item ::= expr_or_subquery column_alias */ - { 435, -3 }, /* (466) partition_item ::= expr_or_subquery AS column_alias */ - { 430, 0 }, /* (467) twindow_clause_opt ::= */ - { 430, -6 }, /* (468) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 430, -4 }, /* (469) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - { 430, -6 }, /* (470) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 430, -8 }, /* (471) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 372, 0 }, /* (472) sliding_opt ::= */ - { 372, -4 }, /* (473) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 429, 0 }, /* (474) fill_opt ::= */ - { 429, -4 }, /* (475) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 429, -6 }, /* (476) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 436, -1 }, /* (477) fill_mode ::= NONE */ - { 436, -1 }, /* (478) fill_mode ::= PREV */ - { 436, -1 }, /* (479) fill_mode ::= NULL */ - { 436, -1 }, /* (480) fill_mode ::= LINEAR */ - { 436, -1 }, /* (481) fill_mode ::= NEXT */ - { 431, 0 }, /* (482) group_by_clause_opt ::= */ - { 431, -3 }, /* (483) group_by_clause_opt ::= GROUP BY group_by_list */ - { 437, -1 }, /* (484) group_by_list ::= expr_or_subquery */ - { 437, -3 }, /* (485) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - { 432, 0 }, /* (486) having_clause_opt ::= */ - { 432, -2 }, /* (487) having_clause_opt ::= HAVING search_condition */ - { 427, 0 }, /* (488) range_opt ::= */ - { 427, -6 }, /* (489) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - { 428, 0 }, /* (490) every_opt ::= */ - { 428, -4 }, /* (491) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 438, -4 }, /* (492) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 439, -1 }, /* (493) query_simple ::= query_specification */ - { 439, -1 }, /* (494) query_simple ::= union_query_expression */ - { 443, -4 }, /* (495) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - { 443, -3 }, /* (496) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - { 444, -1 }, /* (497) query_simple_or_subquery ::= query_simple */ - { 444, -1 }, /* (498) query_simple_or_subquery ::= subquery */ - { 377, -1 }, /* (499) query_or_subquery ::= query_expression */ - { 377, -1 }, /* (500) query_or_subquery ::= subquery */ - { 440, 0 }, /* (501) order_by_clause_opt ::= */ - { 440, -3 }, /* (502) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 441, 0 }, /* (503) slimit_clause_opt ::= */ - { 441, -2 }, /* (504) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 441, -4 }, /* (505) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 441, -4 }, /* (506) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 442, 0 }, /* (507) limit_clause_opt ::= */ - { 442, -2 }, /* (508) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 442, -4 }, /* (509) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 442, -4 }, /* (510) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 394, -3 }, /* (511) subquery ::= NK_LP query_expression NK_RP */ - { 394, -3 }, /* (512) subquery ::= NK_LP subquery NK_RP */ - { 422, -1 }, /* (513) search_condition ::= common_expression */ - { 445, -1 }, /* (514) sort_specification_list ::= sort_specification */ - { 445, -3 }, /* (515) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 446, -3 }, /* (516) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - { 447, 0 }, /* (517) ordering_specification_opt ::= */ - { 447, -1 }, /* (518) ordering_specification_opt ::= ASC */ - { 447, -1 }, /* (519) ordering_specification_opt ::= DESC */ - { 448, 0 }, /* (520) null_ordering_opt ::= */ - { 448, -2 }, /* (521) null_ordering_opt ::= NULLS FIRST */ - { 448, -2 }, /* (522) null_ordering_opt ::= NULLS LAST */ + { 317, -2 }, /* (209) cmd ::= SHOW QNODES */ + { 317, -2 }, /* (210) cmd ::= SHOW FUNCTIONS */ + { 317, -5 }, /* (211) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 317, -2 }, /* (212) cmd ::= SHOW STREAMS */ + { 317, -2 }, /* (213) cmd ::= SHOW ACCOUNTS */ + { 317, -2 }, /* (214) cmd ::= SHOW APPS */ + { 317, -2 }, /* (215) cmd ::= SHOW CONNECTIONS */ + { 317, -2 }, /* (216) cmd ::= SHOW LICENCES */ + { 317, -2 }, /* (217) cmd ::= SHOW GRANTS */ + { 317, -4 }, /* (218) cmd ::= SHOW CREATE DATABASE db_name */ + { 317, -4 }, /* (219) cmd ::= SHOW CREATE TABLE full_table_name */ + { 317, -4 }, /* (220) cmd ::= SHOW CREATE STABLE full_table_name */ + { 317, -2 }, /* (221) cmd ::= SHOW QUERIES */ + { 317, -2 }, /* (222) cmd ::= SHOW SCORES */ + { 317, -2 }, /* (223) cmd ::= SHOW TOPICS */ + { 317, -2 }, /* (224) cmd ::= SHOW VARIABLES */ + { 317, -3 }, /* (225) cmd ::= SHOW LOCAL VARIABLES */ + { 317, -4 }, /* (226) cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + { 317, -2 }, /* (227) cmd ::= SHOW BNODES */ + { 317, -2 }, /* (228) cmd ::= SHOW SNODES */ + { 317, -2 }, /* (229) cmd ::= SHOW CLUSTER */ + { 317, -2 }, /* (230) cmd ::= SHOW TRANSACTIONS */ + { 317, -4 }, /* (231) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + { 317, -2 }, /* (232) cmd ::= SHOW CONSUMERS */ + { 317, -2 }, /* (233) cmd ::= SHOW SUBSCRIPTIONS */ + { 317, -5 }, /* (234) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + { 317, -6 }, /* (235) cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ + { 317, -3 }, /* (236) cmd ::= SHOW VNODES NK_INTEGER */ + { 317, -3 }, /* (237) cmd ::= SHOW VNODES NK_STRING */ + { 366, 0 }, /* (238) db_name_cond_opt ::= */ + { 366, -2 }, /* (239) db_name_cond_opt ::= db_name NK_DOT */ + { 367, 0 }, /* (240) like_pattern_opt ::= */ + { 367, -2 }, /* (241) like_pattern_opt ::= LIKE NK_STRING */ + { 368, -1 }, /* (242) table_name_cond ::= table_name */ + { 369, 0 }, /* (243) from_db_opt ::= */ + { 369, -2 }, /* (244) from_db_opt ::= FROM db_name */ + { 317, -8 }, /* (245) cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + { 317, -4 }, /* (246) cmd ::= DROP INDEX exists_opt full_table_name */ + { 370, -10 }, /* (247) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + { 370, -12 }, /* (248) 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 */ + { 371, -1 }, /* (249) func_list ::= func */ + { 371, -3 }, /* (250) func_list ::= func_list NK_COMMA func */ + { 374, -4 }, /* (251) func ::= function_name NK_LP expression_list NK_RP */ + { 373, 0 }, /* (252) sma_stream_opt ::= */ + { 373, -3 }, /* (253) sma_stream_opt ::= stream_options WATERMARK duration_literal */ + { 373, -3 }, /* (254) sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + { 317, -6 }, /* (255) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + { 317, -7 }, /* (256) cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + { 317, -9 }, /* (257) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + { 317, -7 }, /* (258) cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + { 317, -9 }, /* (259) cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + { 317, -4 }, /* (260) cmd ::= DROP TOPIC exists_opt topic_name */ + { 317, -7 }, /* (261) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + { 317, -2 }, /* (262) cmd ::= DESC full_table_name */ + { 317, -2 }, /* (263) cmd ::= DESCRIBE full_table_name */ + { 317, -3 }, /* (264) cmd ::= RESET QUERY CACHE */ + { 317, -4 }, /* (265) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + { 379, 0 }, /* (266) analyze_opt ::= */ + { 379, -1 }, /* (267) analyze_opt ::= ANALYZE */ + { 380, 0 }, /* (268) explain_options ::= */ + { 380, -3 }, /* (269) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 380, -3 }, /* (270) explain_options ::= explain_options RATIO NK_FLOAT */ + { 317, -10 }, /* (271) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 317, -4 }, /* (272) cmd ::= DROP FUNCTION exists_opt function_name */ + { 381, 0 }, /* (273) agg_func_opt ::= */ + { 381, -1 }, /* (274) agg_func_opt ::= AGGREGATE */ + { 382, 0 }, /* (275) bufsize_opt ::= */ + { 382, -2 }, /* (276) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 317, -11 }, /* (277) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + { 317, -4 }, /* (278) cmd ::= DROP STREAM exists_opt stream_name */ + { 375, 0 }, /* (279) stream_options ::= */ + { 375, -3 }, /* (280) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 375, -3 }, /* (281) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 375, -4 }, /* (282) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + { 375, -3 }, /* (283) stream_options ::= stream_options WATERMARK duration_literal */ + { 375, -4 }, /* (284) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + { 384, 0 }, /* (285) subtable_opt ::= */ + { 384, -4 }, /* (286) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + { 317, -3 }, /* (287) cmd ::= KILL CONNECTION NK_INTEGER */ + { 317, -3 }, /* (288) cmd ::= KILL QUERY NK_STRING */ + { 317, -3 }, /* (289) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 317, -2 }, /* (290) cmd ::= BALANCE VGROUP */ + { 317, -4 }, /* (291) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 317, -4 }, /* (292) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 317, -3 }, /* (293) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 386, -2 }, /* (294) dnode_list ::= DNODE NK_INTEGER */ + { 386, -3 }, /* (295) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 317, -4 }, /* (296) cmd ::= DELETE FROM full_table_name where_clause_opt */ + { 317, -1 }, /* (297) cmd ::= query_or_subquery */ + { 317, -7 }, /* (298) cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + { 317, -4 }, /* (299) cmd ::= INSERT INTO full_table_name query_or_subquery */ + { 320, -1 }, /* (300) literal ::= NK_INTEGER */ + { 320, -1 }, /* (301) literal ::= NK_FLOAT */ + { 320, -1 }, /* (302) literal ::= NK_STRING */ + { 320, -1 }, /* (303) literal ::= NK_BOOL */ + { 320, -2 }, /* (304) literal ::= TIMESTAMP NK_STRING */ + { 320, -1 }, /* (305) literal ::= duration_literal */ + { 320, -1 }, /* (306) literal ::= NULL */ + { 320, -1 }, /* (307) literal ::= NK_QUESTION */ + { 362, -1 }, /* (308) duration_literal ::= NK_VARIABLE */ + { 388, -1 }, /* (309) signed ::= NK_INTEGER */ + { 388, -2 }, /* (310) signed ::= NK_PLUS NK_INTEGER */ + { 388, -2 }, /* (311) signed ::= NK_MINUS NK_INTEGER */ + { 388, -1 }, /* (312) signed ::= NK_FLOAT */ + { 388, -2 }, /* (313) signed ::= NK_PLUS NK_FLOAT */ + { 388, -2 }, /* (314) signed ::= NK_MINUS NK_FLOAT */ + { 351, -1 }, /* (315) signed_literal ::= signed */ + { 351, -1 }, /* (316) signed_literal ::= NK_STRING */ + { 351, -1 }, /* (317) signed_literal ::= NK_BOOL */ + { 351, -2 }, /* (318) signed_literal ::= TIMESTAMP NK_STRING */ + { 351, -1 }, /* (319) signed_literal ::= duration_literal */ + { 351, -1 }, /* (320) signed_literal ::= NULL */ + { 351, -1 }, /* (321) signed_literal ::= literal_func */ + { 351, -1 }, /* (322) signed_literal ::= NK_QUESTION */ + { 390, -1 }, /* (323) literal_list ::= signed_literal */ + { 390, -3 }, /* (324) literal_list ::= literal_list NK_COMMA signed_literal */ + { 328, -1 }, /* (325) db_name ::= NK_ID */ + { 357, -1 }, /* (326) table_name ::= NK_ID */ + { 349, -1 }, /* (327) column_name ::= NK_ID */ + { 364, -1 }, /* (328) function_name ::= NK_ID */ + { 391, -1 }, /* (329) table_alias ::= NK_ID */ + { 392, -1 }, /* (330) column_alias ::= NK_ID */ + { 322, -1 }, /* (331) user_name ::= NK_ID */ + { 376, -1 }, /* (332) topic_name ::= NK_ID */ + { 383, -1 }, /* (333) stream_name ::= NK_ID */ + { 378, -1 }, /* (334) cgroup_name ::= NK_ID */ + { 393, -1 }, /* (335) expr_or_subquery ::= expression */ + { 393, -1 }, /* (336) expr_or_subquery ::= subquery */ + { 385, -1 }, /* (337) expression ::= literal */ + { 385, -1 }, /* (338) expression ::= pseudo_column */ + { 385, -1 }, /* (339) expression ::= column_reference */ + { 385, -1 }, /* (340) expression ::= function_expression */ + { 385, -1 }, /* (341) expression ::= case_when_expression */ + { 385, -3 }, /* (342) expression ::= NK_LP expression NK_RP */ + { 385, -2 }, /* (343) expression ::= NK_PLUS expr_or_subquery */ + { 385, -2 }, /* (344) expression ::= NK_MINUS expr_or_subquery */ + { 385, -3 }, /* (345) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + { 385, -3 }, /* (346) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + { 385, -3 }, /* (347) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + { 385, -3 }, /* (348) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + { 385, -3 }, /* (349) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + { 385, -3 }, /* (350) expression ::= column_reference NK_ARROW NK_STRING */ + { 385, -3 }, /* (351) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + { 385, -3 }, /* (352) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + { 354, -1 }, /* (353) expression_list ::= expr_or_subquery */ + { 354, -3 }, /* (354) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + { 396, -1 }, /* (355) column_reference ::= column_name */ + { 396, -3 }, /* (356) column_reference ::= table_name NK_DOT column_name */ + { 395, -1 }, /* (357) pseudo_column ::= ROWTS */ + { 395, -1 }, /* (358) pseudo_column ::= TBNAME */ + { 395, -3 }, /* (359) pseudo_column ::= table_name NK_DOT TBNAME */ + { 395, -1 }, /* (360) pseudo_column ::= QSTART */ + { 395, -1 }, /* (361) pseudo_column ::= QEND */ + { 395, -1 }, /* (362) pseudo_column ::= QDURATION */ + { 395, -1 }, /* (363) pseudo_column ::= WSTART */ + { 395, -1 }, /* (364) pseudo_column ::= WEND */ + { 395, -1 }, /* (365) pseudo_column ::= WDURATION */ + { 395, -1 }, /* (366) pseudo_column ::= IROWTS */ + { 395, -1 }, /* (367) pseudo_column ::= QTAGS */ + { 397, -4 }, /* (368) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 397, -4 }, /* (369) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 397, -6 }, /* (370) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + { 397, -1 }, /* (371) function_expression ::= literal_func */ + { 389, -3 }, /* (372) literal_func ::= noarg_func NK_LP NK_RP */ + { 389, -1 }, /* (373) literal_func ::= NOW */ + { 401, -1 }, /* (374) noarg_func ::= NOW */ + { 401, -1 }, /* (375) noarg_func ::= TODAY */ + { 401, -1 }, /* (376) noarg_func ::= TIMEZONE */ + { 401, -1 }, /* (377) noarg_func ::= DATABASE */ + { 401, -1 }, /* (378) noarg_func ::= CLIENT_VERSION */ + { 401, -1 }, /* (379) noarg_func ::= SERVER_VERSION */ + { 401, -1 }, /* (380) noarg_func ::= SERVER_STATUS */ + { 401, -1 }, /* (381) noarg_func ::= CURRENT_USER */ + { 401, -1 }, /* (382) noarg_func ::= USER */ + { 399, -1 }, /* (383) star_func ::= COUNT */ + { 399, -1 }, /* (384) star_func ::= FIRST */ + { 399, -1 }, /* (385) star_func ::= LAST */ + { 399, -1 }, /* (386) star_func ::= LAST_ROW */ + { 400, -1 }, /* (387) star_func_para_list ::= NK_STAR */ + { 400, -1 }, /* (388) star_func_para_list ::= other_para_list */ + { 402, -1 }, /* (389) other_para_list ::= star_func_para */ + { 402, -3 }, /* (390) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 403, -1 }, /* (391) star_func_para ::= expr_or_subquery */ + { 403, -3 }, /* (392) star_func_para ::= table_name NK_DOT NK_STAR */ + { 398, -4 }, /* (393) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + { 398, -5 }, /* (394) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + { 404, -1 }, /* (395) when_then_list ::= when_then_expr */ + { 404, -2 }, /* (396) when_then_list ::= when_then_list when_then_expr */ + { 407, -4 }, /* (397) when_then_expr ::= WHEN common_expression THEN common_expression */ + { 405, 0 }, /* (398) case_when_else_opt ::= */ + { 405, -2 }, /* (399) case_when_else_opt ::= ELSE common_expression */ + { 408, -3 }, /* (400) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + { 408, -5 }, /* (401) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + { 408, -6 }, /* (402) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + { 408, -3 }, /* (403) predicate ::= expr_or_subquery IS NULL */ + { 408, -4 }, /* (404) predicate ::= expr_or_subquery IS NOT NULL */ + { 408, -3 }, /* (405) predicate ::= expr_or_subquery in_op in_predicate_value */ + { 409, -1 }, /* (406) compare_op ::= NK_LT */ + { 409, -1 }, /* (407) compare_op ::= NK_GT */ + { 409, -1 }, /* (408) compare_op ::= NK_LE */ + { 409, -1 }, /* (409) compare_op ::= NK_GE */ + { 409, -1 }, /* (410) compare_op ::= NK_NE */ + { 409, -1 }, /* (411) compare_op ::= NK_EQ */ + { 409, -1 }, /* (412) compare_op ::= LIKE */ + { 409, -2 }, /* (413) compare_op ::= NOT LIKE */ + { 409, -1 }, /* (414) compare_op ::= MATCH */ + { 409, -1 }, /* (415) compare_op ::= NMATCH */ + { 409, -1 }, /* (416) compare_op ::= CONTAINS */ + { 410, -1 }, /* (417) in_op ::= IN */ + { 410, -2 }, /* (418) in_op ::= NOT IN */ + { 411, -3 }, /* (419) in_predicate_value ::= NK_LP literal_list NK_RP */ + { 412, -1 }, /* (420) boolean_value_expression ::= boolean_primary */ + { 412, -2 }, /* (421) boolean_value_expression ::= NOT boolean_primary */ + { 412, -3 }, /* (422) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 412, -3 }, /* (423) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 413, -1 }, /* (424) boolean_primary ::= predicate */ + { 413, -3 }, /* (425) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 406, -1 }, /* (426) common_expression ::= expr_or_subquery */ + { 406, -1 }, /* (427) common_expression ::= boolean_value_expression */ + { 414, 0 }, /* (428) from_clause_opt ::= */ + { 414, -2 }, /* (429) from_clause_opt ::= FROM table_reference_list */ + { 415, -1 }, /* (430) table_reference_list ::= table_reference */ + { 415, -3 }, /* (431) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 416, -1 }, /* (432) table_reference ::= table_primary */ + { 416, -1 }, /* (433) table_reference ::= joined_table */ + { 417, -2 }, /* (434) table_primary ::= table_name alias_opt */ + { 417, -4 }, /* (435) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 417, -2 }, /* (436) table_primary ::= subquery alias_opt */ + { 417, -1 }, /* (437) table_primary ::= parenthesized_joined_table */ + { 419, 0 }, /* (438) alias_opt ::= */ + { 419, -1 }, /* (439) alias_opt ::= table_alias */ + { 419, -2 }, /* (440) alias_opt ::= AS table_alias */ + { 420, -3 }, /* (441) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 420, -3 }, /* (442) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 418, -6 }, /* (443) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 421, 0 }, /* (444) join_type ::= */ + { 421, -1 }, /* (445) join_type ::= INNER */ + { 423, -12 }, /* (446) 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 */ + { 424, 0 }, /* (447) set_quantifier_opt ::= */ + { 424, -1 }, /* (448) set_quantifier_opt ::= DISTINCT */ + { 424, -1 }, /* (449) set_quantifier_opt ::= ALL */ + { 425, -1 }, /* (450) select_list ::= select_item */ + { 425, -3 }, /* (451) select_list ::= select_list NK_COMMA select_item */ + { 433, -1 }, /* (452) select_item ::= NK_STAR */ + { 433, -1 }, /* (453) select_item ::= common_expression */ + { 433, -2 }, /* (454) select_item ::= common_expression column_alias */ + { 433, -3 }, /* (455) select_item ::= common_expression AS column_alias */ + { 433, -3 }, /* (456) select_item ::= table_name NK_DOT NK_STAR */ + { 387, 0 }, /* (457) where_clause_opt ::= */ + { 387, -2 }, /* (458) where_clause_opt ::= WHERE search_condition */ + { 426, 0 }, /* (459) partition_by_clause_opt ::= */ + { 426, -3 }, /* (460) partition_by_clause_opt ::= PARTITION BY partition_list */ + { 434, -1 }, /* (461) partition_list ::= partition_item */ + { 434, -3 }, /* (462) partition_list ::= partition_list NK_COMMA partition_item */ + { 435, -1 }, /* (463) partition_item ::= expr_or_subquery */ + { 435, -2 }, /* (464) partition_item ::= expr_or_subquery column_alias */ + { 435, -3 }, /* (465) partition_item ::= expr_or_subquery AS column_alias */ + { 430, 0 }, /* (466) twindow_clause_opt ::= */ + { 430, -6 }, /* (467) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 430, -4 }, /* (468) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + { 430, -6 }, /* (469) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 430, -8 }, /* (470) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 372, 0 }, /* (471) sliding_opt ::= */ + { 372, -4 }, /* (472) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 429, 0 }, /* (473) fill_opt ::= */ + { 429, -4 }, /* (474) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 429, -6 }, /* (475) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 436, -1 }, /* (476) fill_mode ::= NONE */ + { 436, -1 }, /* (477) fill_mode ::= PREV */ + { 436, -1 }, /* (478) fill_mode ::= NULL */ + { 436, -1 }, /* (479) fill_mode ::= LINEAR */ + { 436, -1 }, /* (480) fill_mode ::= NEXT */ + { 431, 0 }, /* (481) group_by_clause_opt ::= */ + { 431, -3 }, /* (482) group_by_clause_opt ::= GROUP BY group_by_list */ + { 437, -1 }, /* (483) group_by_list ::= expr_or_subquery */ + { 437, -3 }, /* (484) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + { 432, 0 }, /* (485) having_clause_opt ::= */ + { 432, -2 }, /* (486) having_clause_opt ::= HAVING search_condition */ + { 427, 0 }, /* (487) range_opt ::= */ + { 427, -6 }, /* (488) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + { 428, 0 }, /* (489) every_opt ::= */ + { 428, -4 }, /* (490) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 438, -4 }, /* (491) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 439, -1 }, /* (492) query_simple ::= query_specification */ + { 439, -1 }, /* (493) query_simple ::= union_query_expression */ + { 443, -4 }, /* (494) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + { 443, -3 }, /* (495) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + { 444, -1 }, /* (496) query_simple_or_subquery ::= query_simple */ + { 444, -1 }, /* (497) query_simple_or_subquery ::= subquery */ + { 377, -1 }, /* (498) query_or_subquery ::= query_expression */ + { 377, -1 }, /* (499) query_or_subquery ::= subquery */ + { 440, 0 }, /* (500) order_by_clause_opt ::= */ + { 440, -3 }, /* (501) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 441, 0 }, /* (502) slimit_clause_opt ::= */ + { 441, -2 }, /* (503) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 441, -4 }, /* (504) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 441, -4 }, /* (505) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 442, 0 }, /* (506) limit_clause_opt ::= */ + { 442, -2 }, /* (507) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 442, -4 }, /* (508) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 442, -4 }, /* (509) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 394, -3 }, /* (510) subquery ::= NK_LP query_expression NK_RP */ + { 394, -3 }, /* (511) subquery ::= NK_LP subquery NK_RP */ + { 422, -1 }, /* (512) search_condition ::= common_expression */ + { 445, -1 }, /* (513) sort_specification_list ::= sort_specification */ + { 445, -3 }, /* (514) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 446, -3 }, /* (515) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + { 447, 0 }, /* (516) ordering_specification_opt ::= */ + { 447, -1 }, /* (517) ordering_specification_opt ::= ASC */ + { 447, -1 }, /* (518) ordering_specification_opt ::= DESC */ + { 448, 0 }, /* (519) null_ordering_opt ::= */ + { 448, -2 }, /* (520) null_ordering_opt ::= NULLS FIRST */ + { 448, -2 }, /* (521) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3749,29 +3711,29 @@ 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 326: /* db_name ::= NK_ID */ yytestcase(yyruleno==326); - case 327: /* table_name ::= NK_ID */ yytestcase(yyruleno==327); - case 328: /* column_name ::= NK_ID */ yytestcase(yyruleno==328); - case 329: /* function_name ::= NK_ID */ yytestcase(yyruleno==329); - case 330: /* table_alias ::= NK_ID */ yytestcase(yyruleno==330); - case 331: /* column_alias ::= NK_ID */ yytestcase(yyruleno==331); - case 332: /* user_name ::= NK_ID */ yytestcase(yyruleno==332); - case 333: /* topic_name ::= NK_ID */ yytestcase(yyruleno==333); - case 334: /* stream_name ::= NK_ID */ yytestcase(yyruleno==334); - case 335: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==335); - case 375: /* noarg_func ::= NOW */ yytestcase(yyruleno==375); - case 376: /* noarg_func ::= TODAY */ yytestcase(yyruleno==376); - case 377: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==377); - case 378: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==378); - case 379: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==379); - case 380: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==380); - case 381: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==381); - case 382: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==382); - case 383: /* noarg_func ::= USER */ yytestcase(yyruleno==383); - case 384: /* star_func ::= COUNT */ yytestcase(yyruleno==384); - case 385: /* star_func ::= FIRST */ yytestcase(yyruleno==385); - case 386: /* star_func ::= LAST */ yytestcase(yyruleno==386); - case 387: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==387); + case 325: /* db_name ::= NK_ID */ yytestcase(yyruleno==325); + case 326: /* table_name ::= NK_ID */ yytestcase(yyruleno==326); + case 327: /* column_name ::= NK_ID */ yytestcase(yyruleno==327); + case 328: /* function_name ::= NK_ID */ yytestcase(yyruleno==328); + case 329: /* table_alias ::= NK_ID */ yytestcase(yyruleno==329); + case 330: /* column_alias ::= NK_ID */ yytestcase(yyruleno==330); + case 331: /* user_name ::= NK_ID */ yytestcase(yyruleno==331); + case 332: /* topic_name ::= NK_ID */ yytestcase(yyruleno==332); + case 333: /* stream_name ::= NK_ID */ yytestcase(yyruleno==333); + case 334: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==334); + case 374: /* noarg_func ::= NOW */ yytestcase(yyruleno==374); + case 375: /* noarg_func ::= TODAY */ yytestcase(yyruleno==375); + case 376: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==376); + case 377: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==377); + case 378: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==378); + case 379: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==379); + case 380: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==380); + case 381: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==381); + case 382: /* noarg_func ::= USER */ yytestcase(yyruleno==382); + case 383: /* star_func ::= COUNT */ yytestcase(yyruleno==383); + case 384: /* star_func ::= FIRST */ yytestcase(yyruleno==384); + case 385: /* star_func ::= LAST */ yytestcase(yyruleno==385); + case 386: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==386); { yylhsminor.yy181 = yymsp[0].minor.yy0; } yymsp[0].minor.yy181 = yylhsminor.yy181; break; @@ -3828,9 +3790,9 @@ static YYACTIONTYPE yy_reduce( break; case 69: /* not_exists_opt ::= */ case 71: /* exists_opt ::= */ yytestcase(yyruleno==71); - case 267: /* analyze_opt ::= */ yytestcase(yyruleno==267); - case 274: /* agg_func_opt ::= */ yytestcase(yyruleno==274); - case 448: /* set_quantifier_opt ::= */ yytestcase(yyruleno==448); + case 266: /* analyze_opt ::= */ yytestcase(yyruleno==266); + case 273: /* agg_func_opt ::= */ yytestcase(yyruleno==273); + case 447: /* set_quantifier_opt ::= */ yytestcase(yyruleno==447); { yymsp[1].minor.yy39 = false; } break; case 70: /* exists_opt ::= IF EXISTS */ @@ -4003,7 +3965,7 @@ static YYACTIONTYPE yy_reduce( yymsp[0].minor.yy282 = yylhsminor.yy282; break; case 116: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 296: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==296); + case 295: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==295); { yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } yymsp[-2].minor.yy282 = yylhsminor.yy282; break; @@ -4021,13 +3983,13 @@ static YYACTIONTYPE yy_reduce( case 151: /* column_def_list ::= column_def */ yytestcase(yyruleno==151); case 194: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==194); case 199: /* col_name_list ::= col_name */ yytestcase(yyruleno==199); - case 250: /* func_list ::= func */ yytestcase(yyruleno==250); - case 324: /* literal_list ::= signed_literal */ yytestcase(yyruleno==324); - case 390: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==390); - case 396: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==396); - case 451: /* select_list ::= select_item */ yytestcase(yyruleno==451); - case 462: /* partition_list ::= partition_item */ yytestcase(yyruleno==462); - case 514: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==514); + case 249: /* func_list ::= func */ yytestcase(yyruleno==249); + case 323: /* literal_list ::= signed_literal */ yytestcase(yyruleno==323); + case 389: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==389); + case 395: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==395); + case 450: /* select_list ::= select_item */ yytestcase(yyruleno==450); + case 461: /* partition_list ::= partition_item */ yytestcase(yyruleno==461); + case 513: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==513); { yylhsminor.yy282 = createNodeList(pCxt, yymsp[0].minor.yy778); } yymsp[0].minor.yy282 = yylhsminor.yy282; break; @@ -4035,12 +3997,12 @@ static YYACTIONTYPE yy_reduce( case 152: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==152); case 195: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==195); case 200: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==200); - case 251: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==251); - case 325: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==325); - case 391: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==391); - case 452: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==452); - case 463: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==463); - case 515: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==515); + case 250: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==250); + case 324: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==324); + case 390: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==390); + case 451: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==451); + case 462: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==462); + case 514: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==514); { yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, yymsp[0].minor.yy778); } yymsp[-2].minor.yy282 = yylhsminor.yy282; break; @@ -4049,11 +4011,11 @@ static YYACTIONTYPE yy_reduce( yymsp[-2].minor.yy778 = yylhsminor.yy778; break; case 122: /* speed_opt ::= */ - case 276: /* bufsize_opt ::= */ yytestcase(yyruleno==276); + case 275: /* bufsize_opt ::= */ yytestcase(yyruleno==275); { yymsp[1].minor.yy276 = 0; } break; case 123: /* speed_opt ::= MAX_SPEED NK_INTEGER */ - case 277: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==277); + case 276: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==276); { yymsp[-1].minor.yy276 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; case 124: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ @@ -4070,7 +4032,7 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy39, yymsp[0].minor.yy778); } break; case 129: /* cmd ::= ALTER TABLE alter_table_clause */ - case 298: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==298); + case 297: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==297); { pCxt->pRootNode = yymsp[0].minor.yy778; } break; case 130: /* cmd ::= ALTER STABLE alter_table_clause */ @@ -4118,7 +4080,7 @@ static YYACTIONTYPE yy_reduce( break; case 142: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 145: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==145); - case 397: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==397); + case 396: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==396); { yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-1].minor.yy282, yymsp[0].minor.yy778); } yymsp[-1].minor.yy282 = yylhsminor.yy282; break; @@ -4132,9 +4094,9 @@ static YYACTIONTYPE yy_reduce( break; case 147: /* specific_cols_opt ::= */ case 178: /* tags_def_opt ::= */ yytestcase(yyruleno==178); - case 460: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==460); - case 482: /* group_by_clause_opt ::= */ yytestcase(yyruleno==482); - case 501: /* order_by_clause_opt ::= */ yytestcase(yyruleno==501); + case 459: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==459); + case 481: /* group_by_clause_opt ::= */ yytestcase(yyruleno==481); + case 500: /* order_by_clause_opt ::= */ yytestcase(yyruleno==500); { yymsp[1].minor.yy282 = NULL; } break; case 148: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ @@ -4224,7 +4186,7 @@ static YYACTIONTYPE yy_reduce( { yymsp[-5].minor.yy380 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 179: /* tags_def_opt ::= tags_def */ - case 389: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==389); + case 388: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==388); { yylhsminor.yy282 = yymsp[0].minor.yy282; } yymsp[0].minor.yy282 = yylhsminor.yy282; break; @@ -4273,12 +4235,12 @@ static YYACTIONTYPE yy_reduce( { yymsp[-1].minor.yy645.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy645.val = yymsp[0].minor.yy0; } break; case 192: /* duration_list ::= duration_literal */ - case 354: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==354); + case 353: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==353); { yylhsminor.yy282 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } yymsp[0].minor.yy282 = yylhsminor.yy282; break; case 193: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 355: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==355); + case 354: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==354); { yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } yymsp[-2].minor.yy282 = yylhsminor.yy282; break; @@ -4316,334 +4278,331 @@ static YYACTIONTYPE yy_reduce( case 208: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } break; - case 209: /* cmd ::= SHOW MODULES */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT); } - break; - case 210: /* cmd ::= SHOW QNODES */ + case 209: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } break; - case 211: /* cmd ::= SHOW FUNCTIONS */ + case 210: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } break; - case 212: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + case 211: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } break; - case 213: /* cmd ::= SHOW STREAMS */ + case 212: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } break; - case 214: /* cmd ::= SHOW ACCOUNTS */ + case 213: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 215: /* cmd ::= SHOW APPS */ + case 214: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } break; - case 216: /* cmd ::= SHOW CONNECTIONS */ + case 215: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } break; - case 217: /* cmd ::= SHOW LICENCES */ - case 218: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==218); + case 216: /* cmd ::= SHOW LICENCES */ + case 217: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==217); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } break; - case 219: /* cmd ::= SHOW CREATE DATABASE db_name */ + case 218: /* cmd ::= SHOW CREATE DATABASE db_name */ { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy181); } break; - case 220: /* cmd ::= SHOW CREATE TABLE full_table_name */ + case 219: /* cmd ::= SHOW CREATE TABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy778); } break; - case 221: /* cmd ::= SHOW CREATE STABLE full_table_name */ + case 220: /* cmd ::= SHOW CREATE STABLE full_table_name */ { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy778); } break; - case 222: /* cmd ::= SHOW QUERIES */ + case 221: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } break; - case 223: /* cmd ::= SHOW SCORES */ + case 222: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } break; - case 224: /* cmd ::= SHOW TOPICS */ + case 223: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } break; - case 225: /* cmd ::= SHOW VARIABLES */ + case 224: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } break; - case 226: /* cmd ::= SHOW LOCAL VARIABLES */ + case 225: /* cmd ::= SHOW LOCAL VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } break; - case 227: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ + case 226: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES */ { pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-1].minor.yy0)); } break; - case 228: /* cmd ::= SHOW BNODES */ + case 227: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } break; - case 229: /* cmd ::= SHOW SNODES */ + case 228: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } break; - case 230: /* cmd ::= SHOW CLUSTER */ + case 229: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } break; - case 231: /* cmd ::= SHOW TRANSACTIONS */ + case 230: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } break; - case 232: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + case 231: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ { pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy778); } break; - case 233: /* cmd ::= SHOW CONSUMERS */ + case 232: /* cmd ::= SHOW CONSUMERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } break; - case 234: /* cmd ::= SHOW SUBSCRIPTIONS */ + case 233: /* cmd ::= SHOW SUBSCRIPTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } break; - case 235: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + case 234: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } break; - case 236: /* cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ + case 235: /* cmd ::= SHOW TABLE TAGS FROM table_name_cond from_db_opt */ { pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TABLE_TAGS_STMT, yymsp[0].minor.yy778, yymsp[-1].minor.yy778, OP_TYPE_EQUAL); } break; - case 237: /* cmd ::= SHOW VNODES NK_INTEGER */ + case 236: /* cmd ::= SHOW VNODES NK_INTEGER */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } break; - case 238: /* cmd ::= SHOW VNODES NK_STRING */ + case 237: /* cmd ::= SHOW VNODES NK_STRING */ { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, createValueNode(pCxt, TSDB_DATA_TYPE_VARCHAR, &yymsp[0].minor.yy0)); } break; - case 239: /* db_name_cond_opt ::= */ - case 244: /* from_db_opt ::= */ yytestcase(yyruleno==244); + case 238: /* db_name_cond_opt ::= */ + case 243: /* from_db_opt ::= */ yytestcase(yyruleno==243); { yymsp[1].minor.yy778 = createDefaultDatabaseCondValue(pCxt); } break; - case 240: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy181); } + case 239: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy778 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy181); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 241: /* like_pattern_opt ::= */ - case 286: /* subtable_opt ::= */ yytestcase(yyruleno==286); - case 399: /* case_when_else_opt ::= */ yytestcase(yyruleno==399); - case 429: /* from_clause_opt ::= */ yytestcase(yyruleno==429); - case 458: /* where_clause_opt ::= */ yytestcase(yyruleno==458); - case 467: /* twindow_clause_opt ::= */ yytestcase(yyruleno==467); - case 472: /* sliding_opt ::= */ yytestcase(yyruleno==472); - case 474: /* fill_opt ::= */ yytestcase(yyruleno==474); - case 486: /* having_clause_opt ::= */ yytestcase(yyruleno==486); - case 488: /* range_opt ::= */ yytestcase(yyruleno==488); - case 490: /* every_opt ::= */ yytestcase(yyruleno==490); - case 503: /* slimit_clause_opt ::= */ yytestcase(yyruleno==503); - case 507: /* limit_clause_opt ::= */ yytestcase(yyruleno==507); + case 240: /* like_pattern_opt ::= */ + case 285: /* subtable_opt ::= */ yytestcase(yyruleno==285); + case 398: /* case_when_else_opt ::= */ yytestcase(yyruleno==398); + case 428: /* from_clause_opt ::= */ yytestcase(yyruleno==428); + case 457: /* where_clause_opt ::= */ yytestcase(yyruleno==457); + case 466: /* twindow_clause_opt ::= */ yytestcase(yyruleno==466); + case 471: /* sliding_opt ::= */ yytestcase(yyruleno==471); + case 473: /* fill_opt ::= */ yytestcase(yyruleno==473); + case 485: /* having_clause_opt ::= */ yytestcase(yyruleno==485); + case 487: /* range_opt ::= */ yytestcase(yyruleno==487); + case 489: /* every_opt ::= */ yytestcase(yyruleno==489); + case 502: /* slimit_clause_opt ::= */ yytestcase(yyruleno==502); + case 506: /* limit_clause_opt ::= */ yytestcase(yyruleno==506); { yymsp[1].minor.yy778 = NULL; } break; - case 242: /* like_pattern_opt ::= LIKE NK_STRING */ + case 241: /* like_pattern_opt ::= LIKE NK_STRING */ { yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 243: /* table_name_cond ::= table_name */ -{ yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy181); } + case 242: /* table_name_cond ::= table_name */ +{ yylhsminor.yy778 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy181); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 245: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy181); } + case 244: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy778 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy181); } break; - case 246: /* cmd ::= CREATE SMA INDEX not_exists_opt full_table_name ON full_table_name index_options */ + case 245: /* 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.yy39, yymsp[-3].minor.yy778, yymsp[-1].minor.yy778, NULL, yymsp[0].minor.yy778); } break; - case 247: /* cmd ::= DROP INDEX exists_opt full_table_name */ + case 246: /* cmd ::= DROP INDEX exists_opt full_table_name */ { pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy39, yymsp[0].minor.yy778); } break; - case 248: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + case 247: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ { yymsp[-9].minor.yy778 = createIndexOption(pCxt, yymsp[-7].minor.yy282, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 249: /* 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 */ + case 248: /* 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.yy778 = createIndexOption(pCxt, yymsp[-9].minor.yy282, releaseRawExprNode(pCxt, yymsp[-5].minor.yy778), releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 252: /* func ::= function_name NK_LP expression_list NK_RP */ + case 251: /* func ::= function_name NK_LP expression_list NK_RP */ { yylhsminor.yy778 = createFunctionNode(pCxt, &yymsp[-3].minor.yy181, yymsp[-1].minor.yy282); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 253: /* sma_stream_opt ::= */ - case 280: /* stream_options ::= */ yytestcase(yyruleno==280); + case 252: /* sma_stream_opt ::= */ + case 279: /* stream_options ::= */ yytestcase(yyruleno==279); { yymsp[1].minor.yy778 = createStreamOptions(pCxt); } break; - case 254: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ - case 284: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==284); + case 253: /* sma_stream_opt ::= stream_options WATERMARK duration_literal */ + case 283: /* stream_options ::= stream_options WATERMARK duration_literal */ yytestcase(yyruleno==283); { ((SStreamOptions*)yymsp[-2].minor.yy778)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-2].minor.yy778; } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 255: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ + case 254: /* sma_stream_opt ::= stream_options MAX_DELAY duration_literal */ { ((SStreamOptions*)yymsp[-2].minor.yy778)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-2].minor.yy778; } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 256: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + case 255: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ { pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy39, &yymsp[-2].minor.yy181, yymsp[0].minor.yy778); } break; - case 257: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ + case 256: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy39, &yymsp[-3].minor.yy181, &yymsp[0].minor.yy181, false); } break; - case 258: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ + case 257: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS DATABASE db_name */ { pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-6].minor.yy39, &yymsp[-5].minor.yy181, &yymsp[0].minor.yy181, true); } break; - case 259: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ + case 258: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS STABLE full_table_name */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-4].minor.yy39, &yymsp[-3].minor.yy181, yymsp[0].minor.yy778, false); } break; - case 260: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ + case 259: /* cmd ::= CREATE TOPIC not_exists_opt topic_name WITH META AS STABLE full_table_name */ { pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-6].minor.yy39, &yymsp[-5].minor.yy181, yymsp[0].minor.yy778, true); } break; - case 261: /* cmd ::= DROP TOPIC exists_opt topic_name */ + case 260: /* cmd ::= DROP TOPIC exists_opt topic_name */ { pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 262: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + case 261: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ { pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy39, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181); } break; - case 263: /* cmd ::= DESC full_table_name */ - case 264: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==264); + case 262: /* cmd ::= DESC full_table_name */ + case 263: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==263); { pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy778); } break; - case 265: /* cmd ::= RESET QUERY CACHE */ + case 264: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 266: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 265: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ { pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy39, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 268: /* analyze_opt ::= ANALYZE */ - case 275: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==275); - case 449: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==449); + case 267: /* analyze_opt ::= ANALYZE */ + case 274: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==274); + case 448: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==448); { yymsp[0].minor.yy39 = true; } break; - case 269: /* explain_options ::= */ + case 268: /* explain_options ::= */ { yymsp[1].minor.yy778 = createDefaultExplainOptions(pCxt); } break; - case 270: /* explain_options ::= explain_options VERBOSE NK_BOOL */ + case 269: /* explain_options ::= explain_options VERBOSE NK_BOOL */ { yylhsminor.yy778 = setExplainVerbose(pCxt, yymsp[-2].minor.yy778, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 271: /* explain_options ::= explain_options RATIO NK_FLOAT */ + case 270: /* explain_options ::= explain_options RATIO NK_FLOAT */ { yylhsminor.yy778 = setExplainRatio(pCxt, yymsp[-2].minor.yy778, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 272: /* cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + case 271: /* 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.yy39, yymsp[-8].minor.yy39, &yymsp[-5].minor.yy181, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy380, yymsp[0].minor.yy276); } break; - case 273: /* cmd ::= DROP FUNCTION exists_opt function_name */ + case 272: /* cmd ::= DROP FUNCTION exists_opt function_name */ { pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 278: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ + case 277: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name tags_def_opt subtable_opt AS query_or_subquery */ { pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-8].minor.yy39, &yymsp[-7].minor.yy181, yymsp[-4].minor.yy778, yymsp[-6].minor.yy778, yymsp[-3].minor.yy282, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } break; - case 279: /* cmd ::= DROP STREAM exists_opt stream_name */ + case 278: /* cmd ::= DROP STREAM exists_opt stream_name */ { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy39, &yymsp[0].minor.yy181); } break; - case 281: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 280: /* stream_options ::= stream_options TRIGGER AT_ONCE */ { ((SStreamOptions*)yymsp[-2].minor.yy778)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy778 = yymsp[-2].minor.yy778; } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 282: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + case 281: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ { ((SStreamOptions*)yymsp[-2].minor.yy778)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy778 = yymsp[-2].minor.yy778; } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 283: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + case 282: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ { ((SStreamOptions*)yymsp[-3].minor.yy778)->triggerType = STREAM_TRIGGER_MAX_DELAY; ((SStreamOptions*)yymsp[-3].minor.yy778)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = yymsp[-3].minor.yy778; } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 285: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + case 284: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ { ((SStreamOptions*)yymsp[-3].minor.yy778)->ignoreExpired = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); yylhsminor.yy778 = yymsp[-3].minor.yy778; } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 287: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 473: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==473); - case 491: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==491); + case 286: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 472: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ yytestcase(yyruleno==472); + case 490: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==490); { yymsp[-3].minor.yy778 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy778); } break; - case 288: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 287: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 289: /* cmd ::= KILL QUERY NK_STRING */ + case 288: /* cmd ::= KILL QUERY NK_STRING */ { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 290: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 289: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 291: /* cmd ::= BALANCE VGROUP */ + case 290: /* cmd ::= BALANCE VGROUP */ { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } break; - case 292: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 291: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 293: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + case 292: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy282); } break; - case 294: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 293: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 295: /* dnode_list ::= DNODE NK_INTEGER */ + case 294: /* dnode_list ::= DNODE NK_INTEGER */ { yymsp[-1].minor.yy282 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 297: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ + case 296: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ { pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 299: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + case 298: /* cmd ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ { pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-4].minor.yy778, yymsp[-2].minor.yy282, yymsp[0].minor.yy778); } break; - case 300: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ + case 299: /* cmd ::= INSERT INTO full_table_name query_or_subquery */ { pCxt->pRootNode = createInsertStmt(pCxt, yymsp[-1].minor.yy778, NULL, yymsp[0].minor.yy778); } break; - case 301: /* literal ::= NK_INTEGER */ + case 300: /* literal ::= NK_INTEGER */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 302: /* literal ::= NK_FLOAT */ + case 301: /* literal ::= NK_FLOAT */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 303: /* literal ::= NK_STRING */ + case 302: /* literal ::= NK_STRING */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 304: /* literal ::= NK_BOOL */ + case 303: /* literal ::= NK_BOOL */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 305: /* literal ::= TIMESTAMP NK_STRING */ + case 304: /* literal ::= TIMESTAMP NK_STRING */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 306: /* literal ::= duration_literal */ - case 316: /* signed_literal ::= signed */ yytestcase(yyruleno==316); - case 336: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==336); - case 337: /* expr_or_subquery ::= subquery */ yytestcase(yyruleno==337); - case 338: /* expression ::= literal */ yytestcase(yyruleno==338); - case 339: /* expression ::= pseudo_column */ yytestcase(yyruleno==339); - case 340: /* expression ::= column_reference */ yytestcase(yyruleno==340); - case 341: /* expression ::= function_expression */ yytestcase(yyruleno==341); - case 342: /* expression ::= case_when_expression */ yytestcase(yyruleno==342); - case 372: /* function_expression ::= literal_func */ yytestcase(yyruleno==372); - case 421: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==421); - case 425: /* boolean_primary ::= predicate */ yytestcase(yyruleno==425); - case 427: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==427); - case 428: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==428); - case 431: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==431); - case 433: /* table_reference ::= table_primary */ yytestcase(yyruleno==433); - case 434: /* table_reference ::= joined_table */ yytestcase(yyruleno==434); - case 438: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==438); - case 493: /* query_simple ::= query_specification */ yytestcase(yyruleno==493); - case 494: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==494); - case 497: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==497); - case 499: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==499); + case 305: /* literal ::= duration_literal */ + case 315: /* signed_literal ::= signed */ yytestcase(yyruleno==315); + case 335: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==335); + case 336: /* expr_or_subquery ::= subquery */ yytestcase(yyruleno==336); + case 337: /* expression ::= literal */ yytestcase(yyruleno==337); + case 338: /* expression ::= pseudo_column */ yytestcase(yyruleno==338); + case 339: /* expression ::= column_reference */ yytestcase(yyruleno==339); + case 340: /* expression ::= function_expression */ yytestcase(yyruleno==340); + case 341: /* expression ::= case_when_expression */ yytestcase(yyruleno==341); + case 371: /* function_expression ::= literal_func */ yytestcase(yyruleno==371); + case 420: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==420); + case 424: /* boolean_primary ::= predicate */ yytestcase(yyruleno==424); + case 426: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==426); + case 427: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==427); + case 430: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==430); + case 432: /* table_reference ::= table_primary */ yytestcase(yyruleno==432); + case 433: /* table_reference ::= joined_table */ yytestcase(yyruleno==433); + case 437: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==437); + case 492: /* query_simple ::= query_specification */ yytestcase(yyruleno==492); + case 493: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==493); + case 496: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==496); + case 498: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==498); { yylhsminor.yy778 = yymsp[0].minor.yy778; } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 307: /* literal ::= NULL */ + case 306: /* literal ::= NULL */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 308: /* literal ::= NK_QUESTION */ + case 307: /* literal ::= NK_QUESTION */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 309: /* duration_literal ::= NK_VARIABLE */ + case 308: /* duration_literal ::= NK_VARIABLE */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 310: /* signed ::= NK_INTEGER */ + case 309: /* signed ::= NK_INTEGER */ { yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 311: /* signed ::= NK_PLUS NK_INTEGER */ + case 310: /* signed ::= NK_PLUS NK_INTEGER */ { yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } break; - case 312: /* signed ::= NK_MINUS NK_INTEGER */ + case 311: /* 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; @@ -4651,14 +4610,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 313: /* signed ::= NK_FLOAT */ + case 312: /* signed ::= NK_FLOAT */ { yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 314: /* signed ::= NK_PLUS NK_FLOAT */ + case 313: /* signed ::= NK_PLUS NK_FLOAT */ { yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 315: /* signed ::= NK_MINUS NK_FLOAT */ + case 314: /* 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; @@ -4666,57 +4625,57 @@ static YYACTIONTYPE yy_reduce( } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 317: /* signed_literal ::= NK_STRING */ + case 316: /* signed_literal ::= NK_STRING */ { yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 318: /* signed_literal ::= NK_BOOL */ + case 317: /* signed_literal ::= NK_BOOL */ { yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 319: /* signed_literal ::= TIMESTAMP NK_STRING */ + case 318: /* signed_literal ::= TIMESTAMP NK_STRING */ { yymsp[-1].minor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 320: /* signed_literal ::= duration_literal */ - case 322: /* signed_literal ::= literal_func */ yytestcase(yyruleno==322); - case 392: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==392); - case 454: /* select_item ::= common_expression */ yytestcase(yyruleno==454); - case 464: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==464); - case 498: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==498); - case 500: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==500); - case 513: /* search_condition ::= common_expression */ yytestcase(yyruleno==513); + case 319: /* signed_literal ::= duration_literal */ + case 321: /* signed_literal ::= literal_func */ yytestcase(yyruleno==321); + case 391: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==391); + case 453: /* select_item ::= common_expression */ yytestcase(yyruleno==453); + case 463: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==463); + case 497: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==497); + case 499: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==499); + case 512: /* search_condition ::= common_expression */ yytestcase(yyruleno==512); { yylhsminor.yy778 = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 321: /* signed_literal ::= NULL */ + case 320: /* signed_literal ::= NULL */ { yylhsminor.yy778 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 323: /* signed_literal ::= NK_QUESTION */ + case 322: /* signed_literal ::= NK_QUESTION */ { yylhsminor.yy778 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 343: /* expression ::= NK_LP expression NK_RP */ - case 426: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==426); - case 512: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==512); + case 342: /* expression ::= NK_LP expression NK_RP */ + case 425: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==425); + case 511: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==511); { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 344: /* expression ::= NK_PLUS expr_or_subquery */ + case 343: /* expression ::= NK_PLUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 345: /* expression ::= NK_MINUS expr_or_subquery */ + case 344: /* expression ::= NK_MINUS expr_or_subquery */ { SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy778), NULL)); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 346: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 345: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4724,7 +4683,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 347: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 346: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4732,7 +4691,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 348: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 347: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4740,7 +4699,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 349: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 348: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4748,7 +4707,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 350: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 349: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4756,14 +4715,14 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 351: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 350: /* expression ::= column_reference NK_ARROW NK_STRING */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 352: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 351: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4771,7 +4730,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 353: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 352: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4779,70 +4738,70 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 356: /* column_reference ::= column_name */ + case 355: /* column_reference ::= column_name */ { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy181, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy181)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 357: /* column_reference ::= table_name NK_DOT column_name */ + case 356: /* column_reference ::= table_name NK_DOT column_name */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181, createColumnNode(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy181)); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 358: /* pseudo_column ::= ROWTS */ - case 359: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==359); - case 361: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==361); - case 362: /* pseudo_column ::= QEND */ yytestcase(yyruleno==362); - case 363: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==363); - case 364: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==364); - case 365: /* pseudo_column ::= WEND */ yytestcase(yyruleno==365); - case 366: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==366); - case 367: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==367); - case 368: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==368); - case 374: /* literal_func ::= NOW */ yytestcase(yyruleno==374); + case 357: /* pseudo_column ::= ROWTS */ + case 358: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==358); + case 360: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==360); + case 361: /* pseudo_column ::= QEND */ yytestcase(yyruleno==361); + case 362: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==362); + case 363: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==363); + case 364: /* pseudo_column ::= WEND */ yytestcase(yyruleno==364); + case 365: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==365); + case 366: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==366); + case 367: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==367); + case 373: /* literal_func ::= NOW */ yytestcase(yyruleno==373); { yylhsminor.yy778 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 360: /* pseudo_column ::= table_name NK_DOT TBNAME */ + case 359: /* pseudo_column ::= table_name NK_DOT TBNAME */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy181)))); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 369: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 370: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==370); + case 368: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 369: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==369); { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy181, yymsp[-1].minor.yy282)); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 371: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 370: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy380)); } yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 373: /* literal_func ::= noarg_func NK_LP NK_RP */ + case 372: /* literal_func ::= noarg_func NK_LP NK_RP */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy181, NULL)); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 388: /* star_func_para_list ::= NK_STAR */ + case 387: /* star_func_para_list ::= NK_STAR */ { yylhsminor.yy282 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 393: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 457: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==457); + case 392: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 456: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==456); { yylhsminor.yy778 = createColumnNode(pCxt, &yymsp[-2].minor.yy181, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 394: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ + case 393: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy282, yymsp[-1].minor.yy778)); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 395: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + case 394: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-2].minor.yy282, yymsp[-1].minor.yy778)); } yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 398: /* when_then_expr ::= WHEN common_expression THEN common_expression */ + case 397: /* when_then_expr ::= WHEN common_expression THEN common_expression */ { yymsp[-3].minor.yy778 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), releaseRawExprNode(pCxt, yymsp[0].minor.yy778)); } break; - case 400: /* case_when_else_opt ::= ELSE common_expression */ + case 399: /* case_when_else_opt ::= ELSE common_expression */ { yymsp[-1].minor.yy778 = releaseRawExprNode(pCxt, yymsp[0].minor.yy778); } break; - case 401: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 406: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==406); + case 400: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 405: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==405); { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4850,7 +4809,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 402: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 401: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4858,7 +4817,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-4].minor.yy778 = yylhsminor.yy778; break; - case 403: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 402: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4866,71 +4825,71 @@ static YYACTIONTYPE yy_reduce( } yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 404: /* predicate ::= expr_or_subquery IS NULL */ + case 403: /* predicate ::= expr_or_subquery IS NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), NULL)); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 405: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 404: /* predicate ::= expr_or_subquery IS NOT NULL */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL)); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 407: /* compare_op ::= NK_LT */ + case 406: /* compare_op ::= NK_LT */ { yymsp[0].minor.yy682 = OP_TYPE_LOWER_THAN; } break; - case 408: /* compare_op ::= NK_GT */ + case 407: /* compare_op ::= NK_GT */ { yymsp[0].minor.yy682 = OP_TYPE_GREATER_THAN; } break; - case 409: /* compare_op ::= NK_LE */ + case 408: /* compare_op ::= NK_LE */ { yymsp[0].minor.yy682 = OP_TYPE_LOWER_EQUAL; } break; - case 410: /* compare_op ::= NK_GE */ + case 409: /* compare_op ::= NK_GE */ { yymsp[0].minor.yy682 = OP_TYPE_GREATER_EQUAL; } break; - case 411: /* compare_op ::= NK_NE */ + case 410: /* compare_op ::= NK_NE */ { yymsp[0].minor.yy682 = OP_TYPE_NOT_EQUAL; } break; - case 412: /* compare_op ::= NK_EQ */ + case 411: /* compare_op ::= NK_EQ */ { yymsp[0].minor.yy682 = OP_TYPE_EQUAL; } break; - case 413: /* compare_op ::= LIKE */ + case 412: /* compare_op ::= LIKE */ { yymsp[0].minor.yy682 = OP_TYPE_LIKE; } break; - case 414: /* compare_op ::= NOT LIKE */ + case 413: /* compare_op ::= NOT LIKE */ { yymsp[-1].minor.yy682 = OP_TYPE_NOT_LIKE; } break; - case 415: /* compare_op ::= MATCH */ + case 414: /* compare_op ::= MATCH */ { yymsp[0].minor.yy682 = OP_TYPE_MATCH; } break; - case 416: /* compare_op ::= NMATCH */ + case 415: /* compare_op ::= NMATCH */ { yymsp[0].minor.yy682 = OP_TYPE_NMATCH; } break; - case 417: /* compare_op ::= CONTAINS */ + case 416: /* compare_op ::= CONTAINS */ { yymsp[0].minor.yy682 = OP_TYPE_JSON_CONTAINS; } break; - case 418: /* in_op ::= IN */ + case 417: /* in_op ::= IN */ { yymsp[0].minor.yy682 = OP_TYPE_IN; } break; - case 419: /* in_op ::= NOT IN */ + case 418: /* in_op ::= NOT IN */ { yymsp[-1].minor.yy682 = OP_TYPE_NOT_IN; } break; - case 420: /* in_predicate_value ::= NK_LP literal_list NK_RP */ + case 419: /* in_predicate_value ::= NK_LP literal_list NK_RP */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy282)); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 422: /* boolean_value_expression ::= NOT boolean_primary */ + case 421: /* boolean_value_expression ::= NOT boolean_primary */ { SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy778), NULL)); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 423: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 422: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4938,7 +4897,7 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 424: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 423: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy778); SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy778); @@ -4946,52 +4905,52 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 430: /* from_clause_opt ::= FROM table_reference_list */ - case 459: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==459); - case 487: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==487); + case 429: /* from_clause_opt ::= FROM table_reference_list */ + case 458: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==458); + case 486: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==486); { yymsp[-1].minor.yy778 = yymsp[0].minor.yy778; } break; - case 432: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 431: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy778 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy778, yymsp[0].minor.yy778, NULL); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 435: /* table_primary ::= table_name alias_opt */ + case 434: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy778 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 436: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 435: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy778 = createRealTableNode(pCxt, &yymsp[-3].minor.yy181, &yymsp[-1].minor.yy181, &yymsp[0].minor.yy181); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 437: /* table_primary ::= subquery alias_opt */ + case 436: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy778 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778), &yymsp[0].minor.yy181); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 439: /* alias_opt ::= */ + case 438: /* alias_opt ::= */ { yymsp[1].minor.yy181 = nil_token; } break; - case 440: /* alias_opt ::= table_alias */ + case 439: /* alias_opt ::= table_alias */ { yylhsminor.yy181 = yymsp[0].minor.yy181; } yymsp[0].minor.yy181 = yylhsminor.yy181; break; - case 441: /* alias_opt ::= AS table_alias */ + case 440: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy181 = yymsp[0].minor.yy181; } break; - case 442: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 443: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==443); + case 441: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 442: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==442); { yymsp[-2].minor.yy778 = yymsp[-1].minor.yy778; } break; - case 444: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 443: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy778 = createJoinTableNode(pCxt, yymsp[-4].minor.yy202, yymsp[-5].minor.yy778, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } yymsp[-5].minor.yy778 = yylhsminor.yy778; break; - case 445: /* join_type ::= */ + case 444: /* join_type ::= */ { yymsp[1].minor.yy202 = JOIN_TYPE_INNER; } break; - case 446: /* join_type ::= INNER */ + case 445: /* join_type ::= INNER */ { yymsp[0].minor.yy202 = JOIN_TYPE_INNER; } break; - case 447: /* 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 446: /* 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.yy778 = createSelectStmt(pCxt, yymsp[-10].minor.yy39, yymsp[-9].minor.yy282, yymsp[-8].minor.yy778); yymsp[-11].minor.yy778 = addWhereClause(pCxt, yymsp[-11].minor.yy778, yymsp[-7].minor.yy778); @@ -5004,73 +4963,73 @@ static YYACTIONTYPE yy_reduce( yymsp[-11].minor.yy778 = addFillClause(pCxt, yymsp[-11].minor.yy778, yymsp[-3].minor.yy778); } break; - case 450: /* set_quantifier_opt ::= ALL */ + case 449: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy39 = false; } break; - case 453: /* select_item ::= NK_STAR */ + case 452: /* select_item ::= NK_STAR */ { yylhsminor.yy778 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } yymsp[0].minor.yy778 = yylhsminor.yy778; break; - case 455: /* select_item ::= common_expression column_alias */ - case 465: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==465); + case 454: /* select_item ::= common_expression column_alias */ + case 464: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==464); { yylhsminor.yy778 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778), &yymsp[0].minor.yy181); } yymsp[-1].minor.yy778 = yylhsminor.yy778; break; - case 456: /* select_item ::= common_expression AS column_alias */ - case 466: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==466); + case 455: /* select_item ::= common_expression AS column_alias */ + case 465: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==465); { yylhsminor.yy778 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), &yymsp[0].minor.yy181); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 461: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 483: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==483); - case 502: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==502); + case 460: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 482: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==482); + case 501: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==501); { yymsp[-2].minor.yy282 = yymsp[0].minor.yy282; } break; - case 468: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 467: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy778 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 469: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + case 468: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ { yymsp[-3].minor.yy778 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 470: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 469: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy778 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), NULL, yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 471: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 470: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy778 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy778), releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), yymsp[-1].minor.yy778, yymsp[0].minor.yy778); } break; - case 475: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 474: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy778 = createFillNode(pCxt, yymsp[-1].minor.yy381, NULL); } break; - case 476: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 475: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy778 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy282)); } break; - case 477: /* fill_mode ::= NONE */ + case 476: /* fill_mode ::= NONE */ { yymsp[0].minor.yy381 = FILL_MODE_NONE; } break; - case 478: /* fill_mode ::= PREV */ + case 477: /* fill_mode ::= PREV */ { yymsp[0].minor.yy381 = FILL_MODE_PREV; } break; - case 479: /* fill_mode ::= NULL */ + case 478: /* fill_mode ::= NULL */ { yymsp[0].minor.yy381 = FILL_MODE_NULL; } break; - case 480: /* fill_mode ::= LINEAR */ + case 479: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy381 = FILL_MODE_LINEAR; } break; - case 481: /* fill_mode ::= NEXT */ + case 480: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy381 = FILL_MODE_NEXT; } break; - case 484: /* group_by_list ::= expr_or_subquery */ + case 483: /* group_by_list ::= expr_or_subquery */ { yylhsminor.yy282 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } yymsp[0].minor.yy282 = yylhsminor.yy282; break; - case 485: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + case 484: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ { yylhsminor.yy282 = addNodeToList(pCxt, yymsp[-2].minor.yy282, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy778))); } yymsp[-2].minor.yy282 = yylhsminor.yy282; break; - case 489: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + case 488: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ { yymsp[-5].minor.yy778 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy778), releaseRawExprNode(pCxt, yymsp[-1].minor.yy778)); } break; - case 492: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 491: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy778 = addOrderByClause(pCxt, yymsp[-3].minor.yy778, yymsp[-2].minor.yy282); yylhsminor.yy778 = addSlimitClause(pCxt, yylhsminor.yy778, yymsp[-1].minor.yy778); @@ -5078,50 +5037,50 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 495: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + case 494: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ { yylhsminor.yy778 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy778, yymsp[0].minor.yy778); } yymsp[-3].minor.yy778 = yylhsminor.yy778; break; - case 496: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + case 495: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ { yylhsminor.yy778 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy778, yymsp[0].minor.yy778); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 504: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 508: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==508); + case 503: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 507: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==507); { yymsp[-1].minor.yy778 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 505: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 509: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==509); + case 504: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 508: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==508); { yymsp[-3].minor.yy778 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 506: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 510: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==510); + case 505: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 509: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==509); { yymsp[-3].minor.yy778 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 511: /* subquery ::= NK_LP query_expression NK_RP */ + case 510: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy778 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy778); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 516: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + case 515: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ { yylhsminor.yy778 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy778), yymsp[-1].minor.yy14, yymsp[0].minor.yy305); } yymsp[-2].minor.yy778 = yylhsminor.yy778; break; - case 517: /* ordering_specification_opt ::= */ + case 516: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy14 = ORDER_ASC; } break; - case 518: /* ordering_specification_opt ::= ASC */ + case 517: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy14 = ORDER_ASC; } break; - case 519: /* ordering_specification_opt ::= DESC */ + case 518: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy14 = ORDER_DESC; } break; - case 520: /* null_ordering_opt ::= */ + case 519: /* null_ordering_opt ::= */ { yymsp[1].minor.yy305 = NULL_ORDER_DEFAULT; } break; - case 521: /* null_ordering_opt ::= NULLS FIRST */ + case 520: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy305 = NULL_ORDER_FIRST; } break; - case 522: /* null_ordering_opt ::= NULLS LAST */ + case 521: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy305 = NULL_ORDER_LAST; } break; default: diff --git a/source/libs/parser/test/parShowToUse.cpp b/source/libs/parser/test/parShowToUse.cpp index 36e70dd01598e3806c88ae367548fb0b1b815ece..fe1e14797a680aee285c863c69325eaaa4f248c2 100644 --- a/source/libs/parser/test/parShowToUse.cpp +++ b/source/libs/parser/test/parShowToUse.cpp @@ -130,12 +130,6 @@ TEST_F(ParserShowToUseTest, showMnodes) { run("SHOW mnodes"); } -TEST_F(ParserShowToUseTest, showModules) { - useDb("root", "test"); - - run("SHOW modules"); -} - TEST_F(ParserShowToUseTest, showQnodes) { useDb("root", "test"); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 8c87f60b9f1e874d09e1e975a81d58c4fdbf04c9..e14946055041541a7ce94cd395fedee1a6a6f6a5 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -66,7 +66,8 @@ static EDealRes doRewriteExpr(SNode** pNode, void* pContext) { switch (nodeType(*pNode)) { case QUERY_NODE_OPERATOR: case QUERY_NODE_LOGIC_CONDITION: - case QUERY_NODE_FUNCTION: { + case QUERY_NODE_FUNCTION: + case QUERY_NODE_CASE_WHEN: { SRewriteExprCxt* pCxt = (SRewriteExprCxt*)pContext; SNode* pExpr; int32_t index = 0; @@ -118,6 +119,17 @@ static EDealRes doNameExpr(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } +static int32_t rewriteExprForSelect(SNode* pExpr, SSelectStmt* pSelect, ESqlClause clause) { + nodesWalkExpr(pExpr, doNameExpr, NULL); + SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = NULL}; + cxt.errCode = nodesListMakeAppend(&cxt.pExprs, pExpr); + if (TSDB_CODE_SUCCESS == cxt.errCode) { + nodesRewriteSelectStmt(pSelect, clause, doRewriteExpr, &cxt); + nodesClearList(cxt.pExprs); + } + return cxt.errCode; +} + static int32_t rewriteExprsForSelect(SNodeList* pExprs, SSelectStmt* pSelect, ESqlClause clause) { nodesWalkExprs(pExprs, doNameExpr, NULL); SRewriteExprCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pExprs = pExprs}; @@ -514,6 +526,7 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, } pAgg->hasLastRow = pSelect->hasLastRowFunc; + pAgg->hasLast = pSelect->hasLastFunc; pAgg->hasTimeLineFunc = pSelect->hasTimeLineFunc; pAgg->onlyHasKeepOrderFunc = pSelect->onlyHasKeepOrderFunc; pAgg->node.groupAction = getGroupAction(pCxt, pSelect); @@ -710,8 +723,13 @@ static int32_t createWindowLogicNodeByState(SLogicPlanContext* pCxt, SStateWindo nodesDestroyNode((SNode*)pWindow); return TSDB_CODE_OUT_OF_MEMORY; } - - return createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); + // rewrite the expression in subsequent clauses + int32_t code = rewriteExprForSelect(pWindow->pStateExpr, pSelect, SQL_CLAUSE_WINDOW); + if (TSDB_CODE_SUCCESS == code) { + code = createWindowLogicNodeFinalize(pCxt, pSelect, pWindow, pLogicNode); + } + + return code; } static int32_t createWindowLogicNodeBySession(SLogicPlanContext* pCxt, SSessionWindowNode* pSession, diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 927969bf9ceedbef2b56339a77af51041bf61f40..50f1f4b3691d4cdf474a9ecad3ac445e0e0a6af9 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -124,7 +124,8 @@ static void optSetParentOrder(SLogicNode* pNode, EOrder order) { EDealRes scanPathOptHaveNormalColImpl(SNode* pNode, void* pContext) { if (QUERY_NODE_COLUMN == nodeType(pNode)) { - // *((bool*)pContext) = (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType); + // *((bool*)pContext) = + // (COLUMN_TYPE_TAG != ((SColumnNode*)pNode)->colType && COLUMN_TYPE_TBNAME != ((SColumnNode*)pNode)->colType); *((bool*)pContext) = true; return *((bool*)pContext) ? DEAL_RES_END : DEAL_RES_IGNORE_CHILD; } @@ -2195,14 +2196,16 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) { SAggLogicNode* pAgg = (SAggLogicNode*)pNode; SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pNode->pChildren, 0); - if (!pAgg->hasLastRow || NULL != pAgg->pGroupKeys || NULL != pScan->node.pConditions || 0 == pScan->cacheLastMode || - IS_TSWINDOW_SPECIFIED(pScan->scanRange)) { + // Only one of LAST and LASTROW can appear + if (pAgg->hasLastRow == pAgg->hasLast || NULL != pAgg->pGroupKeys || NULL != pScan->node.pConditions || + 0 == pScan->cacheLastMode || IS_TSWINDOW_SPECIFIED(pScan->scanRange)) { return false; } SNode* pFunc = NULL; FOREACH(pFunc, ((SAggLogicNode*)pNode)->pAggFuncs) { if (FUNCTION_TYPE_LAST_ROW != ((SFunctionNode*)pFunc)->funcType && + // FUNCTION_TYPE_LAST != ((SFunctionNode*)pFunc)->funcType && FUNCTION_TYPE_SELECT_VALUE != ((SFunctionNode*)pFunc)->funcType && FUNCTION_TYPE_GROUP_KEY != ((SFunctionNode*)pFunc)->funcType) { return false; @@ -2222,7 +2225,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic SNode* pNode = NULL; FOREACH(pNode, pAgg->pAggFuncs) { SFunctionNode* pFunc = (SFunctionNode*)pNode; - if (FUNCTION_TYPE_LAST_ROW == pFunc->funcType) { + if (FUNCTION_TYPE_LAST_ROW == pFunc->funcType || FUNCTION_TYPE_LAST == pFunc->funcType) { int32_t len = snprintf(pFunc->functionName, sizeof(pFunc->functionName), "_cache_last_row"); pFunc->functionName[len] = '\0'; int32_t code = fmGetFuncInfo(pFunc, NULL, 0); @@ -2231,9 +2234,12 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic } } } - pAgg->hasLastRow = false; - ((SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0))->scanType = SCAN_TYPE_LAST_ROW; + SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pAgg->node.pChildren, 0); + pScan->scanType = SCAN_TYPE_LAST_ROW; + pScan->igLastNull = pAgg->hasLast ? true : false; + pAgg->hasLastRow = false; + pAgg->hasLast = false; pCxt->optimized = true; return TSDB_CODE_SUCCESS; @@ -2405,8 +2411,8 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, {.pName = "RewriteTail", .optimizeFunc = rewriteTailOptimize}, {.pName = "RewriteUnique", .optimizeFunc = rewriteUniqueOptimize}, - {.pName = "LastRowScan", .optimizeFunc = lastRowScanOptimize}, - {.pName = "TagScan", .optimizeFunc = tagScanOptimize} + {.pName = "LastRowScan", .optimizeFunc = lastRowScanOptimize}, + {.pName = "TagScan", .optimizeFunc = tagScanOptimize} }; // clang-format on diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 810b82b9fc21d2c311266f36575297f9543797b7..81a3a2cb1625a2ed82c0fdfd816a6cdbf962effc 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -521,6 +521,7 @@ static int32_t createLastRowScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSu } pScan->groupSort = pScanLogicNode->groupSort; + pScan->ignoreNull = pScanLogicNode->igLastNull; vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); vgroupInfoToNodeAddr(pScanLogicNode->pVgroupList->vgroups, &pSubplan->execNode); @@ -760,7 +761,8 @@ static EDealRes doRewritePrecalcExprs(SNode** pNode, void* pContext) { return collectAndRewrite(pCxt, pNode); } case QUERY_NODE_OPERATOR: - case QUERY_NODE_LOGIC_CONDITION: { + case QUERY_NODE_LOGIC_CONDITION: + case QUERY_NODE_CASE_WHEN: { return collectAndRewrite(pCxt, pNode); } case QUERY_NODE_FUNCTION: { diff --git a/source/libs/planner/src/planUtil.c b/source/libs/planner/src/planUtil.c index ac1589bec02a738ccb4e1f7d03b333628d012efe..a13e959a369ff03141e7c1a612529defdb1b5321 100644 --- a/source/libs/planner/src/planUtil.c +++ b/source/libs/planner/src/planUtil.c @@ -53,7 +53,8 @@ static EDealRes doCreateColumn(SNode* pNode, void* pContext) { } case QUERY_NODE_OPERATOR: case QUERY_NODE_LOGIC_CONDITION: - case QUERY_NODE_FUNCTION: { + case QUERY_NODE_FUNCTION: + case QUERY_NODE_CASE_WHEN: { SExprNode* pExpr = (SExprNode*)pNode; SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { diff --git a/source/libs/qcom/inc/queryInt.h b/source/libs/qcom/inc/queryInt.h index f120bf26cebdac19896c372ea73159e682f72c0d..8f52f21d231e6fb191bc57e05b22002bdd8375a7 100644 --- a/source/libs/qcom/inc/queryInt.h +++ b/source/libs/qcom/inc/queryInt.h @@ -20,7 +20,6 @@ extern "C" { #endif - #ifdef __cplusplus } #endif diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index e54937114cd1bc0e011e8dc9d8ed44a710bc1807..80ba356e8f194f13c21af403bf9be378a0599134 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -13,18 +13,19 @@ * along with this program. If not, see . */ -#include "tmsg.h" -#include "queryInt.h" #include "query.h" -#include "trpc.h" +#include "queryInt.h" #include "systable.h" +#include "tmsg.h" +#include "trpc.h" #pragma GCC diagnostic push #ifdef COMPILER_SUPPORTS_CXX13 #pragma GCC diagnostic ignored "-Wformat-truncation" #endif -int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)) = {0}; +int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, + void *(*mallocFp)(int64_t)) = {0}; int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0}; int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { @@ -46,7 +47,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { if (usedbRsp->vgNum <= 0) { return TSDB_CODE_SUCCESS; } - + pOut->dbVgroup->vgHash = taosHashInit(usedbRsp->vgNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); if (NULL == pOut->dbVgroup->vgHash) { @@ -57,7 +58,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { SVgroupInfo *pVgInfo = taosArrayGet(usedbRsp->pVgroupInfos, i); pOut->dbVgroup->numOfTable += pVgInfo->numOfTable; qDebug("the %dth vgroup, id %d, epNum %d, current %s port %d", i, pVgInfo->vgId, pVgInfo->epSet.numOfEps, - pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port); + pVgInfo->epSet.eps[pVgInfo->epSet.inUse].fqdn, pVgInfo->epSet.eps[pVgInfo->epSet.inUse].port); if (0 != taosHashPut(pOut->dbVgroup->vgHash, &pVgInfo->vgId, sizeof(int32_t), pVgInfo, sizeof(SVgroupInfo))) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } @@ -66,7 +67,8 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { return TSDB_CODE_SUCCESS; } -int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, + void *(*mallcFp)(int64_t)) { SBuildTableInput *pInput = input; if (NULL == input || NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; @@ -89,7 +91,7 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3 return TSDB_CODE_SUCCESS; } -int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { SBuildUseDBInput *pInput = input; if (NULL == pInput || NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; @@ -112,7 +114,7 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms return TSDB_CODE_SUCCESS; } -int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -130,7 +132,7 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -148,7 +150,7 @@ int32_t queryBuildDnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -165,8 +167,7 @@ int32_t queryBuildGetSerVerMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } - -int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -184,7 +185,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -202,7 +203,8 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, + void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -225,7 +227,7 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3 return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -243,7 +245,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32 return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } @@ -261,13 +263,13 @@ int32_t queryBuildGetTbIndexMsg(void *input, char **msg, int32_t msgSize, int32_ return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { +int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void *(*mallcFp)(int64_t)) { if (NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; } SBuildTableInput *pInput = input; - STableCfgReq cfgReq = {0}; + STableCfgReq cfgReq = {0}; cfgReq.header.vgId = pInput->vgId; strcpy(cfgReq.dbFName, pInput->dbFName); strcpy(cfgReq.tbName, pInput->tbName); @@ -282,7 +284,6 @@ int32_t queryBuildGetTbCfgMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } - int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) { SUseDbOutput *pOut = output; SUseDbRsp usedbRsp = {0}; @@ -362,13 +363,12 @@ int32_t queryCreateCTableMetaFromMsg(STableMetaRsp *msg, SCTableMeta *pMeta) { pMeta->uid = msg->tuid; pMeta->suid = msg->suid; - qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64 , - msg->tbName, pMeta->uid, pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid); + qDebug("ctable %s uid %" PRIx64 " meta returned, type %d vgId:%d db %s suid %" PRIx64, msg->tbName, pMeta->uid, + pMeta->tableType, pMeta->vgId, msg->dbFName, pMeta->suid); return TSDB_CODE_SUCCESS; } - int32_t queryCreateTableMetaFromMsg(STableMetaRsp *msg, bool isStb, STableMeta **pMeta) { int32_t total = msg->numOfColumns + msg->numOfTags; int32_t metaSize = sizeof(STableMeta) + sizeof(SSchema) * total; @@ -425,7 +425,8 @@ int32_t queryProcessTableMetaRsp(void *output, char *msg, int32_t msgSize) { goto PROCESS_META_OVER; } - if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) && !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) { + if (0 != strcmp(metaRsp.dbFName, TSDB_INFORMATION_SCHEMA_DB) && + !tIsValidSchema(metaRsp.pSchemas, metaRsp.numOfColumns, metaRsp.numOfTags)) { code = TSDB_CODE_TSC_INVALID_VALUE; goto PROCESS_META_OVER; } @@ -461,7 +462,6 @@ PROCESS_META_OVER: return code; } - int32_t queryProcessQnodeListRsp(void *output, char *msg, int32_t msgSize) { SQnodeListRsp out = {0}; int32_t code = 0; @@ -496,7 +496,7 @@ int32_t queryProcessDnodeListRsp(void *output, char *msg, int32_t msgSize) { return code; } - *(SArray**)output = out.dnodeList; + *(SArray **)output = out.dnodeList; return code; } @@ -516,12 +516,11 @@ int32_t queryProcessGetSerVerRsp(void *output, char *msg, int32_t msgSize) { return code; } - *(char**)output = strdup(out.ver); + *(char **)output = strdup(out.ver); return code; } - int32_t queryProcessGetDbCfgRsp(void *output, char *msg, int32_t msgSize) { SDbCfgRsp out = {0}; @@ -573,7 +572,7 @@ int32_t queryProcessRetrieveFuncRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_INVALID_MSG; } - SFuncInfo * funcInfo = taosArrayGet(out.pFuncInfos, 0); + SFuncInfo *funcInfo = taosArrayGet(out.pFuncInfos, 0); memcpy(output, funcInfo, sizeof(*funcInfo)); taosArrayDestroy(out.pFuncInfos); @@ -599,12 +598,12 @@ int32_t queryProcessGetTbIndexRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_TSC_INVALID_INPUT; } - STableIndexRsp *out = (STableIndexRsp*)output; + STableIndexRsp *out = (STableIndexRsp *)output; if (tDeserializeSTableIndexRsp(msg, msgSize, out) != 0) { qError("tDeserializeSTableIndexRsp failed, msgSize:%d", msgSize); return TSDB_CODE_INVALID_MSG; } - + return TSDB_CODE_SUCCESS; } @@ -619,39 +618,39 @@ int32_t queryProcessGetTbCfgRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_INVALID_MSG; } - *(STableCfgRsp**)output = out; - + *(STableCfgRsp **)output = out; + return TSDB_CODE_SUCCESS; } void initQueryModuleMsgHandle() { - queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg; - queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; - queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg; - - queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp; + queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_USE_DB)] = queryBuildUseDbMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryBuildQnodeListMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryBuildDnodeListMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryBuildGetDBCfgMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryBuildGetIndexMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryBuildRetrieveFuncMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryBuildGetUserAuthMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryBuildGetTbIndexMsg; + queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryBuildGetTbCfgMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg; + + queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_USE_DB)] = queryProcessUseDBRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_QNODE_LIST)] = queryProcessQnodeListRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_DNODE_LIST)] = queryProcessDnodeListRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_DB_CFG)] = queryProcessGetDbCfgRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_INDEX)] = queryProcessGetIndexRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_RETRIEVE_FUNC)] = queryProcessRetrieveFuncRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_USER_AUTH)] = queryProcessGetUserAuthRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_INDEX)] = queryProcessGetTbIndexRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; - queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_CFG)] = queryProcessGetTbCfgRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp; } #pragma GCC diagnostic pop diff --git a/source/libs/qcom/test/queryTest.cpp b/source/libs/qcom/test/queryTest.cpp index 9615557c883f6adf4a22f6a1d14417e4c5fe9839..7134f5c7b81e9c266c9279641105f8f75860567a 100644 --- a/source/libs/qcom/test/queryTest.cpp +++ b/source/libs/qcom/test/queryTest.cpp @@ -15,8 +15,9 @@ #include #include -#include "tmsg.h" + #include "query.h" +#include "tmsg.h" #include "trpc.h" #pragma GCC diagnostic push @@ -37,7 +38,7 @@ int32_t testPrint(void* p) { } int32_t testPrintError(void* p) { - SParam* param = (SParam*) p; + SParam* param = (SParam*)p; taosMemoryFreeClear(p); return -1; @@ -67,8 +68,8 @@ TEST(testCase, async_task_test) { } TEST(testCase, many_async_task_test) { - for(int32_t i = 0; i < 50; ++i) { - SParam* p = (SParam*) taosMemoryCalloc(1, sizeof(SParam)); + for (int32_t i = 0; i < 50; ++i) { + SParam* p = (SParam*)taosMemoryCalloc(1, sizeof(SParam)); p->v = i; taosAsyncExec(testPrint, p, NULL); } @@ -78,7 +79,7 @@ TEST(testCase, many_async_task_test) { TEST(testCase, error_in_async_test) { int32_t code = 0; - SParam* p = (SParam*) taosMemoryCalloc(1, sizeof(SParam)); + SParam* p = (SParam*)taosMemoryCalloc(1, sizeof(SParam)); taosAsyncExec(testPrintError, p, &code); taosMsleep(1); printf("Error code:%d after asynchronously exec function\n", code); diff --git a/source/libs/qworker/inc/qwInt.h b/source/libs/qworker/inc/qwInt.h index 3a3226359998d23da690aa361c5dffd1ce7d12fc..626e78b4d34c589d389e2854bdeaed6f0f117bd5 100644 --- a/source/libs/qworker/inc/qwInt.h +++ b/source/libs/qworker/inc/qwInt.h @@ -20,22 +20,22 @@ extern "C" { #endif +#include "executor.h" #include "osDef.h" +#include "plannodes.h" #include "qworker.h" #include "tlockfree.h" -#include "ttimer.h" #include "tref.h" -#include "plannodes.h" -#include "executor.h" #include "trpc.h" +#include "ttimer.h" #define QW_DEFAULT_SCHEDULER_NUMBER 100 #define QW_DEFAULT_TASK_NUMBER 10000 #define QW_DEFAULT_SCH_TASK_NUMBER 10000 #define QW_DEFAULT_SHORT_RUN_TIMES 2 #define QW_DEFAULT_HEARTBEAT_MSEC 5000 -#define QW_SCH_TIMEOUT_MSEC 180000 -#define QW_MIN_RES_ROWS 4096 +#define QW_SCH_TIMEOUT_MSEC 180000 +#define QW_MIN_RES_ROWS 4096 enum { QW_PHASE_PRE_QUERY = 1, @@ -128,16 +128,16 @@ typedef struct SQWTaskCtx { bool queryContinue; bool queryInQueue; int32_t rspCode; - int64_t affectedRows; // for insert ...select stmt + int64_t affectedRows; // for insert ...select stmt SRpcHandleInfo ctrlConnInfo; SRpcHandleInfo dataConnInfo; int8_t events[QW_EVENT_MAX]; - SArray *explainRes; - void *taskHandle; - void *sinkHandle; + SArray *explainRes; + void *taskHandle; + void *sinkHandle; STbVerInfo tbInfo; } SQWTaskCtx; @@ -157,14 +157,14 @@ typedef struct SQWTimeInQ { typedef struct SQWMsgStat { SQWTimeInQ waitTime[2]; - uint64_t queryProcessed; - uint64_t cqueryProcessed; - uint64_t fetchProcessed; - uint64_t rspProcessed; - uint64_t cancelProcessed; - uint64_t dropProcessed; - uint64_t hbProcessed; - uint64_t deleteProcessed; + uint64_t queryProcessed; + uint64_t cqueryProcessed; + uint64_t fetchProcessed; + uint64_t rspProcessed; + uint64_t cancelProcessed; + uint64_t dropProcessed; + uint64_t hbProcessed; + uint64_t deleteProcessed; } SQWMsgStat; typedef struct SQWRTStat { @@ -173,8 +173,8 @@ typedef struct SQWRTStat { } SQWRTStat; typedef struct SQWStat { - SQWMsgStat msgStat; - SQWRTStat rtStat; + SQWMsgStat msgStat; + SQWRTStat rtStat; } SQWStat; // Qnode/Vnode level task management @@ -183,15 +183,15 @@ typedef struct SQWorker { SQWorkerCfg cfg; int8_t nodeType; int32_t nodeId; - void * timer; + void *timer; tmr_h hbTimer; SRWLatch schLock; // SRWLatch ctxLock; - SHashObj *schHash; // key: schedulerId, value: SQWSchStatus - SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx - SMsgCb msgCb; - SQWStat stat; - int32_t *destroyed; + SHashObj *schHash; // key: schedulerId, value: SQWSchStatus + SHashObj *ctxHash; // key: queryId+taskId, value: SQWTaskCtx + SMsgCb msgCb; + SQWStat stat; + int32_t *destroyed; } SQWorker; typedef struct SQWorkerMgmt { @@ -208,16 +208,21 @@ typedef struct SQWorkerMgmt { #define QW_STAT_INC(_item, _n) atomic_add_fetch_64(&(_item), _n) #define QW_STAT_DEC(_item, _n) atomic_sub_fetch_64(&(_item), _n) -#define QW_STAT_GET(_item) atomic_load_64(&(_item)) +#define QW_STAT_GET(_item) atomic_load_64(&(_item)) -#define QW_GET_EVENT(ctx, event) atomic_load_8(&(ctx)->events[event]) -#define QW_EVENT_RECEIVED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_RECEIVED) -#define QW_EVENT_PROCESSED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_PROCESSED) +#define QW_GET_EVENT(ctx, event) atomic_load_8(&(ctx)->events[event]) +#define QW_EVENT_RECEIVED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_RECEIVED) +#define QW_EVENT_PROCESSED(ctx, event) (QW_GET_EVENT(ctx, event) == QW_EVENT_PROCESSED) #define QW_SET_EVENT_RECEIVED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_RECEIVED) #define QW_SET_EVENT_PROCESSED(ctx, event) atomic_store_8(&(ctx)->events[event], QW_EVENT_PROCESSED) #define QW_GET_PHASE(ctx) atomic_load_8(&(ctx)->phase) -#define QW_SET_PHASE(ctx, _value) do { if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { atomic_store_8(&(ctx)->phase, _value); } } while (0) +#define QW_SET_PHASE(ctx, _value) \ + do { \ + if ((_value) != QW_PHASE_PRE_FETCH && (_value) != QW_PHASE_POST_FETCH) { \ + atomic_store_8(&(ctx)->phase, _value); \ + } \ + } while (0) #define QW_SET_RSP_CODE(ctx, code) atomic_store_32(&(ctx)->rspCode, code) #define QW_UPDATE_RSP_CODE(ctx, code) atomic_val_compare_exchange_32(&(ctx)->rspCode, 0, code) @@ -230,7 +235,7 @@ typedef struct SQWorkerMgmt { *(uint64_t *)((char *)(id) + sizeof(qId)) = (tId); \ *(int32_t *)((char *)(id) + sizeof(qId) + sizeof(tId)) = (eId); \ } while (0) - + #define QW_GET_QTID(id, qId, tId, eId) \ do { \ (qId) = *(uint64_t *)(id); \ @@ -268,10 +273,10 @@ typedef struct SQWorkerMgmt { #define QW_TLOG(_param, ...) qTrace("QW:%p " _param, mgmt, __VA_ARGS__) #define QW_DUMP(_param, ...) \ - do { \ - if (gQWDebug.dumpEnable) { \ + do { \ + if (gQWDebug.dumpEnable) { \ qDebug("QW:%p " _param, mgmt, __VA_ARGS__); \ - } \ + } \ } while (0) #define QW_SCH_ELOG(param, ...) qError("QW:%p SID:%" PRIx64 " " param, mgmt, sId, __VA_ARGS__) @@ -287,12 +292,15 @@ typedef struct SQWorkerMgmt { #define QW_TASK_WLOG_E(param) qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId) #define QW_TASK_DLOG_E(param) qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, qId, tId, eId) -#define QW_SCH_TASK_ELOG(param, ...) \ - qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) -#define QW_SCH_TASK_WLOG(param, ...) \ - qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) -#define QW_SCH_TASK_DLOG(param, ...) \ - qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, __VA_ARGS__) +#define QW_SCH_TASK_ELOG(param, ...) \ + qError("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \ + __VA_ARGS__) +#define QW_SCH_TASK_WLOG(param, ...) \ + qWarn("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \ + __VA_ARGS__) +#define QW_SCH_TASK_DLOG(param, ...) \ + qDebug("QW:%p SID:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, mgmt, sId, qId, tId, eId, \ + __VA_ARGS__) #define QW_LOCK_DEBUG(...) \ do { \ @@ -337,41 +345,41 @@ typedef struct SQWorkerMgmt { } \ } while (0) - extern SQWorkerMgmt gQwMgmt; -static FORCE_INLINE SQWorker *qwAcquire(int64_t refId) { return (SQWorker *)taosAcquireRef(atomic_load_32(&gQwMgmt.qwRef), refId); } +static FORCE_INLINE SQWorker *qwAcquire(int64_t refId) { + return (SQWorker *)taosAcquireRef(atomic_load_32(&gQwMgmt.qwRef), refId); +} static FORCE_INLINE int32_t qwRelease(int64_t refId) { return taosReleaseRef(gQwMgmt.qwRef, refId); } -char *qwPhaseStr(int32_t phase); -char *qwBufStatusStr(int32_t bufStatus); +char *qwPhaseStr(int32_t phase); +char *qwBufStatusStr(int32_t bufStatus); int32_t qwAcquireAddScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch); -void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt); +void qwReleaseScheduler(int32_t rwType, SQWorker *mgmt); int32_t qwAddTaskStatus(QW_FPARAMS_DEF, int32_t status); int32_t qwAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); int32_t qwGetTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); int32_t qwAddAcquireTaskCtx(QW_FPARAMS_DEF, SQWTaskCtx **ctx); -void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx); +void qwReleaseTaskCtx(SQWorker *mgmt, void *ctx); int32_t qwKillTaskHandle(SQWTaskCtx *ctx); int32_t qwUpdateTaskStatus(QW_FPARAMS_DEF, int8_t status); int32_t qwDropTask(QW_FPARAMS_DEF); -void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx); +void qwSaveTbVersionInfo(qTaskInfo_t pTaskInfo, SQWTaskCtx *ctx); int32_t qwOpenRef(void); -void qwSetHbParam(int64_t refId, SQWHbParam **pParam); +void qwSetHbParam(int64_t refId, SQWHbParam **pParam); int32_t qwUpdateTimeInQueue(SQWorker *mgmt, int64_t ts, EQueueType type); int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type); -void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch); +void qwClearExpiredSch(SQWorker *mgmt, SArray *pExpiredSch); int32_t qwAcquireScheduler(SQWorker *mgmt, uint64_t sId, int32_t rwType, SQWSchStatus **sch); -void qwFreeTaskCtx(SQWTaskCtx *ctx); +void qwFreeTaskCtx(SQWTaskCtx *ctx); -void qwDbgDumpMgmtInfo(SQWorker *mgmt); +void qwDbgDumpMgmtInfo(SQWorker *mgmt); int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore); int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet); int32_t qwAddTaskCtx(QW_FPARAMS_DEF); -void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped); -void qwDbgSimulateSleep(void); -void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped); - +void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped); +void qwDbgSimulateSleep(void); +void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped); #ifdef __cplusplus } diff --git a/source/libs/qworker/inc/qwMsg.h b/source/libs/qworker/inc/qwMsg.h index b46c5d6baf90cdbba9883b7a0cfe24f175c7c4b5..f226b223f723c8d95d6c619b5c2f35e9c94574d3 100644 --- a/source/libs/qworker/inc/qwMsg.h +++ b/source/libs/qworker/inc/qwMsg.h @@ -20,12 +20,12 @@ extern "C" { #endif -#include "qwInt.h" #include "dataSinkMgt.h" +#include "qwInt.h" int32_t qwAbortPrerocessQuery(QW_FPARAMS_DEF); int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg); -int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char* sql); +int32_t qwProcessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg, char *sql); int32_t qwProcessCQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessReady(QW_FPARAMS_DEF, SQWMsg *qwMsg); int32_t qwProcessFetch(QW_FPARAMS_DEF, SQWMsg *qwMsg); @@ -35,11 +35,12 @@ int32_t qwProcessDelete(QW_FPARAMS_DEF, SQWMsg *qwMsg, SDeleteRes *pRes); int32_t qwBuildAndSendDropRsp(SRpcHandleInfo *pConn, int32_t code); int32_t qwBuildAndSendCancelRsp(SRpcHandleInfo *pConn, int32_t code); -int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, int32_t code); +int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, + int32_t code); void qwBuildFetchRsp(void *msg, SOutputData *input, int32_t len, bool qComplete); int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn); int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx); -int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList); +int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray *pExecList); int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code); void qwFreeFetchRsp(void *msg); int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp); diff --git a/source/libs/qworker/src/qwDbg.c b/source/libs/qworker/src/qwDbg.c index 98d7825b2c8d6de15991defc176ae35b3141c3da..6997bdfd9c937d19698e65f461b0f23472d9e359 100644 --- a/source/libs/qworker/src/qwDbg.c +++ b/source/libs/qworker/src/qwDbg.c @@ -1,15 +1,19 @@ -#include "qworker.h" #include "dataSinkMgt.h" #include "executor.h" #include "planner.h" #include "query.h" #include "qwInt.h" #include "qwMsg.h" +#include "qworker.h" #include "tcommon.h" #include "tmsg.h" #include "tname.h" -SQWDebug gQWDebug = {.statusEnable = true, .dumpEnable = false, .redirectSimulate = false, .deadSimulate = false, .sleepSimulate = false}; +SQWDebug gQWDebug = {.statusEnable = true, + .dumpEnable = false, + .redirectSimulate = false, + .deadSimulate = false, + .sleepSimulate = false}; int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, bool *ignore) { if (!gQWDebug.statusEnable) { @@ -29,15 +33,13 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, switch (oriStatus) { case JOB_TASK_STATUS_NULL: - if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL && - newStatus != JOB_TASK_STATUS_INIT) { + if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_INIT) { QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } break; case JOB_TASK_STATUS_INIT: - if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC - && newStatus != JOB_TASK_STATUS_FAIL) { + if (newStatus != JOB_TASK_STATUS_DROP && newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_FAIL) { QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } @@ -50,8 +52,8 @@ int32_t qwDbgValidateStatus(QW_FPARAMS_DEF, int8_t oriStatus, int8_t newStatus, break; case JOB_TASK_STATUS_PART_SUCC: - if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_SUCC && - newStatus != JOB_TASK_STATUS_FAIL && newStatus != JOB_TASK_STATUS_DROP) { + if (newStatus != JOB_TASK_STATUS_EXEC && newStatus != JOB_TASK_STATUS_SUCC && newStatus != JOB_TASK_STATUS_FAIL && + newStatus != JOB_TASK_STATUS_DROP) { QW_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } @@ -89,7 +91,8 @@ _return: void qwDbgDumpSchInfo(SQWorker *mgmt, SQWSchStatus *sch, int32_t i) { QW_LOCK(QW_READ, &sch->tasksLock); - QW_DLOG("the %dth scheduler status, hbBrokenTs:%" PRId64 ",taskNum:%d", i, sch->hbBrokenTs, taosHashGetSize(sch->tasksHash)); + QW_DLOG("the %dth scheduler status, hbBrokenTs:%" PRId64 ",taskNum:%d", i, sch->hbBrokenTs, + taosHashGetSize(sch->tasksHash)); QW_UNLOCK(QW_READ, &sch->tasksLock); } @@ -120,11 +123,10 @@ void qwDbgDumpMgmtInfo(SQWorker *mgmt) { QW_DUMP("total remain ctx num %d", taosHashGetSize(mgmt->ctxHash)); } - int32_t qwDbgBuildAndSendRedirectRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SEpSet *pEpSet) { int32_t contLen = 0; - char* rsp = NULL; - + char *rsp = NULL; + if (pEpSet) { contLen = tSerializeSEpSet(NULL, 0, pEpSet); rsp = rpcMallocCont(contLen); @@ -152,12 +154,12 @@ void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped) { if (*rsped) { return; } - + if (gQWDebug.redirectSimulate) { if (++ignoreTime <= 10) { return; } - + if (TDMT_SCH_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) { SEpSet epSet = {0}; epSet.inUse = 1; @@ -169,12 +171,12 @@ void qwDbgSimulateRedirect(SQWMsg *qwMsg, SQWTaskCtx *ctx, bool *rsped) { strcpy(epSet.eps[2].fqdn, "localhost"); epSet.eps[2].port = 7300; - ctx->phase = QW_PHASE_POST_QUERY; + ctx->phase = QW_PHASE_POST_QUERY; qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, &epSet); *rsped = true; return; } - + if (TDMT_SCH_MERGE_QUERY == qwMsg->msgType && (0 == taosRand() % 3)) { QW_SET_PHASE(ctx, QW_PHASE_POST_QUERY); qwDbgBuildAndSendRedirectRsp(qwMsg->msgType + 1, &qwMsg->connInfo, TSDB_CODE_RPC_REDIRECT, NULL); @@ -213,18 +215,18 @@ void qwDbgSimulateDead(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *rsped) { static int32_t ignoreTime = 0; if (++ignoreTime > 10 && 0 == taosRand() % 9) { - SRpcHandleInfo *pConn = ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo : &ctx->ctrlConnInfo); + SRpcHandleInfo *pConn = + ((ctx->msgType == TDMT_SCH_FETCH || ctx->msgType == TDMT_SCH_MERGE_FETCH) ? &ctx->dataConnInfo + : &ctx->ctrlConnInfo); qwBuildAndSendErrorRsp(ctx->msgType + 1, pConn, TSDB_CODE_RPC_BROKEN_LINK); qwBuildAndSendDropMsg(QW_FPARAMS(), pConn); *rsped = true; - + return; } } - - int32_t qwDbgEnableDebug(char *option) { if (0 == strcasecmp(option, "lock")) { gQWDebug.lockEnable = true; @@ -263,8 +265,6 @@ int32_t qwDbgEnableDebug(char *option) { } qError("invalid qw debug option:%s", option); - + return TSDB_CODE_APP_ERROR; } - - diff --git a/source/libs/qworker/src/qwMsg.c b/source/libs/qworker/src/qwMsg.c index e4271dfcdaf2579ce884646a52bee523e419c3c5..24ab45be2c156210989800cba01cea9300b36aae 100644 --- a/source/libs/qworker/src/qwMsg.c +++ b/source/libs/qworker/src/qwMsg.c @@ -3,8 +3,8 @@ #include "executor.h" #include "planner.h" #include "query.h" -#include "qworker.h" #include "qwInt.h" +#include "qworker.h" #include "tcommon.h" #include "tmsg.h" #include "tname.h" @@ -12,7 +12,8 @@ int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **rsp) { int32_t msgSize = sizeof(SRetrieveTableRsp) + length; - SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)(rpcMalloc ? rpcReallocCont(*rsp, msgSize) : taosMemoryRealloc(*rsp, msgSize)); + SRetrieveTableRsp *pRsp = + (SRetrieveTableRsp *)(rpcMalloc ? rpcReallocCont(*rsp, msgSize) : taosMemoryRealloc(*rsp, msgSize)); if (NULL == pRsp) { qError("rpcMallocCont %d failed", msgSize); QW_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -21,7 +22,7 @@ int32_t qwMallocFetchRsp(int8_t rpcMalloc, int32_t length, SRetrieveTableRsp **r if (NULL == *rsp) { memset(pRsp, 0, sizeof(SRetrieveTableRsp)); } - + *rsp = pRsp; return TSDB_CODE_SUCCESS; @@ -61,8 +62,8 @@ int32_t qwBuildAndSendErrorRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c } int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t code, SQWTaskCtx *ctx) { - STbVerInfo* tbInfo = ctx ? &ctx->tbInfo : NULL; - int64_t affectedRows = ctx ? ctx->affectedRows : 0; + STbVerInfo *tbInfo = ctx ? &ctx->tbInfo : NULL; + int64_t affectedRows = ctx ? ctx->affectedRows : 0; SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp)); pRsp->code = htonl(code); pRsp->affectedRows = htobe64(affectedRows); @@ -85,12 +86,12 @@ int32_t qwBuildAndSendQueryRsp(int32_t rspType, SRpcHandleInfo *pConn, int32_t c return TSDB_CODE_SUCCESS; } -int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) { - SExplainExecInfo* pInfo = taosArrayGet(pExecList, 0); - SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo}; +int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray *pExecList) { + SExplainExecInfo *pInfo = taosArrayGet(pExecList, 0); + SExplainRsp rsp = {.numOfPlans = taosArrayGetSize(pExecList), .subplanInfo = pInfo}; int32_t contLen = tSerializeSExplainRsp(NULL, 0, &rsp); - void * pRsp = rpcMallocCont(contLen); + void *pRsp = rpcMallocCont(contLen); tSerializeSExplainRsp(pRsp, contLen, &rsp); SRpcMsg rpcRsp = { @@ -108,7 +109,7 @@ int32_t qwBuildAndSendExplainRsp(SRpcHandleInfo *pConn, SArray* pExecList) { int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int32_t code) { int32_t contLen = tSerializeSSchedulerHbRsp(NULL, 0, pStatus); - void * pRsp = rpcMallocCont(contLen); + void *pRsp = rpcMallocCont(contLen); tSerializeSSchedulerHbRsp(pRsp, contLen, pStatus); SRpcMsg rpcRsp = { @@ -124,7 +125,8 @@ int32_t qwBuildAndSendHbRsp(SRpcHandleInfo *pConn, SSchedulerHbRsp *pStatus, int return TSDB_CODE_SUCCESS; } -int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, int32_t code) { +int32_t qwBuildAndSendFetchRsp(int32_t rspType, SRpcHandleInfo *pConn, SRetrieveTableRsp *pRsp, int32_t dataLength, + int32_t code) { if (NULL == pRsp) { pRsp = (SRetrieveTableRsp *)rpcMallocCont(sizeof(SRetrieveTableRsp)); memset(pRsp, 0, sizeof(SRetrieveTableRsp)); @@ -209,7 +211,6 @@ int32_t qwBuildAndSendDropMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { return TSDB_CODE_SUCCESS; } - int32_t qwBuildAndSendCQueryMsg(QW_FPARAMS_DEF, SRpcHandleInfo *pConn) { SQueryContinueReq *req = (SQueryContinueReq *)rpcMallocCont(sizeof(SQueryContinueReq)); if (NULL == req) { @@ -309,7 +310,7 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { int32_t code = 0; SSubQueryMsg *msg = pMsg->pCont; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; if (NULL == msg || pMsg->contLen <= sizeof(*msg)) { QW_ELOG("invalid query msg, msg:%p, msgLen:%d", msg, pMsg->contLen); @@ -330,7 +331,8 @@ int32_t qWorkerPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { int64_t rId = msg->refId; int32_t eId = msg->execId; - SQWMsg qwMsg = {.msgType = pMsg->msgType, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info}; + SQWMsg qwMsg = { + .msgType = pMsg->msgType, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info}; QW_SCH_TASK_DLOG("prerocessQuery start, handle:%p", pMsg->info.handle); QW_ERR_RET(qwPreprocessQuery(QW_FPARAMS(), &qwMsg)); @@ -345,7 +347,7 @@ int32_t qWorkerAbortPreprocessQueryMsg(void *qWorkerMgmt, SRpcMsg *pMsg) { } SSubQueryMsg *msg = pMsg->pCont; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; uint64_t sId = msg->sId; uint64_t qId = msg->queryId; @@ -367,7 +369,7 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int int32_t code = 0; SSubQueryMsg *msg = pMsg->pCont; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.queryProcessed, 1); @@ -383,13 +385,18 @@ int32_t qWorkerProcessQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int int64_t rId = msg->refId; int32_t eId = msg->execId; - SQWMsg qwMsg = {.node = node, .msg = msg->msg + msg->sqlLen, .msgLen = msg->phyLen, .connInfo = pMsg->info, .msgType = pMsg->msgType}; + SQWMsg qwMsg = {.node = node, + .msg = msg->msg + msg->sqlLen, + .msgLen = msg->phyLen, + .connInfo = pMsg->info, + .msgType = pMsg->msgType}; qwMsg.msgInfo.explain = msg->explain; qwMsg.msgInfo.taskType = msg->taskType; qwMsg.msgInfo.needFetch = msg->needFetch; - - char * sql = strndup(msg->msg, msg->sqlLen); - QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), pMsg->info.handle, sql); + + char *sql = strndup(msg->msg, msg->sqlLen); + QW_SCH_TASK_DLOG("processQuery start, node:%p, type:%s, handle:%p, SQL:%s", node, TMSG_INFO(pMsg->msgType), + pMsg->info.handle, sql); QW_ERR_JRET(qwProcessQuery(QW_FPARAMS(), &qwMsg, sql)); _return: @@ -405,8 +412,8 @@ int32_t qWorkerProcessCQueryMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in bool queryDone = false; SQueryContinueReq *msg = (SQueryContinueReq *)pMsg->pCont; bool needStop = false; - SQWTaskCtx * handles = NULL; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWTaskCtx *handles = NULL; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; qwUpdateTimeInQueue(mgmt, ts, QUERY_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.cqueryProcessed, 1); @@ -439,7 +446,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int } SResFetchReq *msg = pMsg->pCont; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.fetchProcessed, 1); @@ -472,7 +479,7 @@ int32_t qWorkerProcessFetchMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int } int32_t qWorkerProcessRspMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_t ts) { - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; if (mgmt) { qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.rspProcessed, 1); @@ -488,7 +495,7 @@ int32_t qWorkerProcessCancelMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, in return TSDB_CODE_QRY_INVALID_INPUT; } - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; int32_t code = 0; STaskCancelReq *msg = pMsg->pCont; @@ -531,7 +538,7 @@ int32_t qWorkerProcessDropMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int6 int32_t code = 0; STaskDropReq *msg = pMsg->pCont; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.dropProcessed, 1); @@ -575,7 +582,7 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_ int32_t code = 0; SSchedulerHbReq req = {0}; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; qwUpdateTimeInQueue(mgmt, ts, FETCH_QUEUE); QW_STAT_INC(mgmt->stat.msgStat.hbProcessed, 1); @@ -606,20 +613,19 @@ int32_t qWorkerProcessHbMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, int64_ return TSDB_CODE_SUCCESS; } - int32_t qWorkerProcessDeleteMsg(void *node, void *qWorkerMgmt, SRpcMsg *pMsg, SDeleteRes *pRes) { if (NULL == node || NULL == qWorkerMgmt || NULL == pMsg) { QW_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; + int32_t code = 0; SVDeleteReq req = {0}; - SQWorker * mgmt = (SQWorker *)qWorkerMgmt; + SQWorker *mgmt = (SQWorker *)qWorkerMgmt; QW_STAT_INC(mgmt->stat.msgStat.deleteProcessed, 1); tDeserializeSVDeleteReq(pMsg->pCont, pMsg->contLen, &req); - + uint64_t sId = req.sId; uint64_t qId = req.queryId; uint64_t tId = req.taskId; @@ -639,5 +645,3 @@ _return: QW_RET(code); } - - diff --git a/source/libs/qworker/src/qwUtil.c b/source/libs/qworker/src/qwUtil.c index 9f1a9a3146b0aeba875d051d731f750779b94e42..3038b8793074f5ab6b03070777eb7fea68bb2bcb 100644 --- a/source/libs/qworker/src/qwUtil.c +++ b/source/libs/qworker/src/qwUtil.c @@ -295,7 +295,7 @@ void qwFreeTaskCtx(SQWTaskCtx *ctx) { if (ctx->ctrlConnInfo.handle) { tmsgReleaseHandle(&ctx->ctrlConnInfo, TAOS_CONN_SERVER); } - + ctx->ctrlConnInfo.handle = NULL; ctx->ctrlConnInfo.refId = -1; @@ -454,21 +454,21 @@ void qwDestroySchStatus(SQWSchStatus *pStatus) { taosHashCleanup(pStatus->tasksH void qwDestroyImpl(void *pMgmt) { SQWorker *mgmt = (SQWorker *)pMgmt; - int8_t nodeType = mgmt->nodeType; - int32_t nodeId = mgmt->nodeId; - - qDebug("start to destroy qworker, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); + int8_t nodeType = mgmt->nodeType; + int32_t nodeId = mgmt->nodeId; + + qDebug("start to destroy qworker, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); taosTmrStop(mgmt->hbTimer); mgmt->hbTimer = NULL; taosTmrCleanUp(mgmt->timer); uint64_t qId, tId; - int32_t eId; - void *pIter = taosHashIterate(mgmt->ctxHash, NULL); + int32_t eId; + void *pIter = taosHashIterate(mgmt->ctxHash, NULL); while (pIter) { SQWTaskCtx *ctx = (SQWTaskCtx *)pIter; - void *key = taosHashGetKey(pIter, NULL); + void *key = taosHashGetKey(pIter, NULL); QW_GET_QTID(key, qId, tId, eId); qwFreeTaskCtx(ctx); @@ -486,14 +486,14 @@ void qwDestroyImpl(void *pMgmt) { taosHashCleanup(mgmt->schHash); *mgmt->destroyed = 1; - + taosMemoryFree(mgmt); atomic_sub_fetch_32(&gQwMgmt.qwNum, 1); qwCloseRef(); - qDebug("qworker destroyed, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); + qDebug("qworker destroyed, type:%d, id:%d, handle:%p", nodeType, nodeId, mgmt); } int32_t qwOpenRef(void) { @@ -550,11 +550,10 @@ int64_t qwGetTimeInQueue(SQWorker *mgmt, EQueueType type) { return -1; } - -void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch) { +void qwClearExpiredSch(SQWorker *mgmt, SArray *pExpiredSch) { int32_t num = taosArrayGetSize(pExpiredSch); for (int32_t i = 0; i < num; ++i) { - uint64_t *sId = taosArrayGet(pExpiredSch, i); + uint64_t *sId = taosArrayGet(pExpiredSch, i); SQWSchStatus *pSch = NULL; if (qwAcquireScheduler(mgmt, *sId, QW_WRITE, &pSch)) { continue; @@ -569,5 +568,3 @@ void qwClearExpiredSch(SQWorker *mgmt, SArray* pExpiredSch) { qwReleaseScheduler(QW_WRITE, mgmt); } } - - diff --git a/source/libs/qworker/src/qworker.c b/source/libs/qworker/src/qworker.c index ae9dd82a58eca25aab73a17bc43ef2441e3c08c0..9115c2d3aa5770cfdb5edc3ff448e74b14484386 100644 --- a/source/libs/qworker/src/qworker.c +++ b/source/libs/qworker/src/qworker.c @@ -7,9 +7,9 @@ #include "qwInt.h" #include "qwMsg.h" #include "tcommon.h" +#include "tdatablock.h" #include "tmsg.h" #include "tname.h" -#include "tdatablock.h" SQWorkerMgmt gQwMgmt = { .lock = 0, @@ -17,8 +17,8 @@ SQWorkerMgmt gQwMgmt = { .qwNum = 0, }; -static void freeBlock(void* param) { - SSDataBlock* pBlock = *(SSDataBlock**)param; +static void freeBlock(void *param) { + SSDataBlock *pBlock = *(SSDataBlock **)param; blockDataDestroy(pBlock); } @@ -100,7 +100,7 @@ int32_t qwExecTask(QW_FPARAMS_DEF, SQWTaskCtx *ctx, bool *queryStop) { int32_t execNum = 0; qTaskInfo_t taskHandle = ctx->taskHandle; DataSinkHandle sinkHandle = ctx->sinkHandle; - SLocalFetch localFetch = {(void*)mgmt, ctx->localExec, qWorkerProcessLocalFetch, ctx->explainRes}; + SLocalFetch localFetch = {(void *)mgmt, ctx->localExec, qWorkerProcessLocalFetch, ctx->explainRes}; SArray *pResList = taosArrayInit(4, POINTER_BYTES); while (true) { @@ -512,7 +512,7 @@ _return: QW_TASK_DLOG("query msg rsped, handle:%p, code:%x - %s", ctx->ctrlConnInfo.handle, code, tstrerror(code)); } } - + ctx->queryRsped = true; } @@ -541,8 +541,8 @@ int32_t qwAbortPrerocessQuery(QW_FPARAMS_DEF) { } int32_t qwPreprocessQuery(QW_FPARAMS_DEF, SQWMsg *qwMsg) { - int32_t code = 0; - SQWTaskCtx *ctx = NULL; + int32_t code = 0; + SQWTaskCtx *ctx = NULL; QW_ERR_JRET(qwRegisterQueryBrokenLinkArg(QW_FPARAMS(), &qwMsg->connInfo)); @@ -1113,10 +1113,10 @@ void qWorkerDestroy(void **qWorkerMgmt) { return; } - int32_t destroyed = 0; + int32_t destroyed = 0; SQWorker *mgmt = *qWorkerMgmt; mgmt->destroyed = &destroyed; - + if (taosRemoveRef(gQwMgmt.qwRef, mgmt->refId)) { qError("remove qw from ref list failed, refId:%" PRIx64, mgmt->refId); return; @@ -1153,15 +1153,16 @@ int32_t qWorkerGetStat(SReadHandle *handle, void *qWorkerMgmt, SQWorkerStat *pSt return TSDB_CODE_SUCCESS; } -int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, SQWMsg *qwMsg, SArray *explainRes) { - SQWorker *mgmt = (SQWorker*)pMgmt; +int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, + SQWMsg *qwMsg, SArray *explainRes) { + SQWorker *mgmt = (SQWorker *)pMgmt; int32_t code = 0; SQWTaskCtx *ctx = NULL; SSubplan *plan = (SSubplan *)qwMsg->msg; SQWPhaseInput input = {0}; qTaskInfo_t pTaskInfo = NULL; DataSinkHandle sinkHandle = NULL; - SReadHandle rHandle = {0}; + SReadHandle rHandle = {0}; QW_ERR_JRET(qwAddTaskCtx(QW_FPARAMS())); QW_ERR_JRET(qwAddTaskStatus(QW_FPARAMS(), JOB_TASK_STATUS_INIT)); @@ -1178,7 +1179,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64 rHandle.pMsgCb = taosMemoryCalloc(1, sizeof(SMsgCb)); rHandle.pMsgCb->clientRpc = qwMsg->connInfo.handle; - + code = qCreateExecTask(&rHandle, mgmt->nodeId, tId, plan, &pTaskInfo, &sinkHandle, NULL, OPTR_EXEC_MODEL_BATCH); if (code) { QW_TASK_ELOG("qCreateExecTask failed, code:%x - %s", code, tstrerror(code)); @@ -1199,7 +1200,7 @@ int32_t qWorkerProcessLocalQuery(void *pMgmt, uint64_t sId, uint64_t qId, uint64 _return: taosMemoryFree(rHandle.pMsgCb); - + input.code = code; input.msgType = qwMsg->msgType; code = qwHandlePostPhaseEvents(QW_FPARAMS(), QW_PHASE_POST_QUERY, &input, NULL); @@ -1212,13 +1213,14 @@ _return: QW_RET(code); } -int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, void** pRsp, SArray* explainRes) { - SQWorker *mgmt = (SQWorker*)pMgmt; - int32_t code = 0; - int32_t dataLen = 0; - SQWTaskCtx *ctx = NULL; - void *rsp = NULL; - bool queryStop = false; +int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64_t tId, int64_t rId, int32_t eId, + void **pRsp, SArray *explainRes) { + SQWorker *mgmt = (SQWorker *)pMgmt; + int32_t code = 0; + int32_t dataLen = 0; + SQWTaskCtx *ctx = NULL; + void *rsp = NULL; + bool queryStop = false; SQWPhaseInput input = {0}; @@ -1228,15 +1230,15 @@ int32_t qWorkerProcessLocalFetch(void *pMgmt, uint64_t sId, uint64_t qId, uint64 ctx->msgType = TDMT_SCH_MERGE_FETCH; ctx->explainRes = explainRes; - + SOutputData sOutput = {0}; - + while (true) { QW_ERR_JRET(qwGetQueryResFromSink(QW_FPARAMS(), ctx, &dataLen, &rsp, &sOutput)); if (NULL == rsp) { QW_ERR_JRET(qwExecTask(QW_FPARAMS(), ctx, &queryStop)); - + continue; } else { bool qComplete = (DS_BUF_EMPTY == sOutput.bufStatus && sOutput.queryEnd); @@ -1259,5 +1261,3 @@ _return: QW_RET(code); } - - diff --git a/source/libs/qworker/test/qworkerTests.cpp b/source/libs/qworker/test/qworkerTests.cpp index 60d6594c1b62389147fd7f8dd7c5de0ee4b4211b..c855f005e779e9871ccb7216130bb23b90f8772e 100644 --- a/source/libs/qworker/test/qworkerTests.cpp +++ b/source/libs/qworker/test/qworkerTests.cpp @@ -32,18 +32,17 @@ #endif #include "os.h" -#include "tglobal.h" -#include "taos.h" -#include "tdef.h" -#include "tvariant.h" -#include "tdatablock.h" -#include "trpc.h" +#include "dataSinkMgt.h" +#include "executor.h" #include "planner.h" #include "qworker.h" #include "stub.h" -#include "executor.h" -#include "dataSinkMgt.h" - +#include "taos.h" +#include "tdatablock.h" +#include "tdef.h" +#include "tglobal.h" +#include "trpc.h" +#include "tvariant.h" namespace { @@ -55,56 +54,52 @@ bool qwtEnableLog = true; int32_t qwtTestMaxExecTaskUsec = 2; int32_t qwtTestReqMaxDelayUsec = 2; -int64_t qwtTestQueryId = 0; -bool qwtTestEnableSleep = true; -bool qwtTestStop = false; -bool qwtTestDeadLoop = false; -int32_t qwtTestMTRunSec = 2; -int32_t qwtTestPrintNum = 10000; +int64_t qwtTestQueryId = 0; +bool qwtTestEnableSleep = true; +bool qwtTestStop = false; +bool qwtTestDeadLoop = false; +int32_t qwtTestMTRunSec = 2; +int32_t qwtTestPrintNum = 10000; uint64_t qwtTestCaseIdx = 0; uint64_t qwtTestCaseNum = 4; -bool qwtTestCaseFinished = false; -tsem_t qwtTestQuerySem; -tsem_t qwtTestFetchSem; -int32_t qwtTestQuitThreadNum = 0; - - -int32_t qwtTestQueryQueueRIdx = 0; -int32_t qwtTestQueryQueueWIdx = 0; -int32_t qwtTestQueryQueueNum = 0; -SRWLatch qwtTestQueryQueueLock = 0; +bool qwtTestCaseFinished = false; +tsem_t qwtTestQuerySem; +tsem_t qwtTestFetchSem; +int32_t qwtTestQuitThreadNum = 0; + +int32_t qwtTestQueryQueueRIdx = 0; +int32_t qwtTestQueryQueueWIdx = 0; +int32_t qwtTestQueryQueueNum = 0; +SRWLatch qwtTestQueryQueueLock = 0; struct SRpcMsg *qwtTestQueryQueue[qwtTestQueryQueueSize] = {0}; -int32_t qwtTestFetchQueueRIdx = 0; -int32_t qwtTestFetchQueueWIdx = 0; -int32_t qwtTestFetchQueueNum = 0; -SRWLatch qwtTestFetchQueueLock = 0; +int32_t qwtTestFetchQueueRIdx = 0; +int32_t qwtTestFetchQueueWIdx = 0; +int32_t qwtTestFetchQueueNum = 0; +SRWLatch qwtTestFetchQueueLock = 0; struct SRpcMsg *qwtTestFetchQueue[qwtTestFetchQueueSize] = {0}; - -int32_t qwtTestSinkBlockNum = 0; -int32_t qwtTestSinkMaxBlockNum = 0; -bool qwtTestSinkQueryEnd = false; +int32_t qwtTestSinkBlockNum = 0; +int32_t qwtTestSinkMaxBlockNum = 0; +bool qwtTestSinkQueryEnd = false; SRWLatch qwtTestSinkLock = 0; -int32_t qwtTestSinkLastLen = 0; - - -SSubQueryMsg qwtqueryMsg = {0}; -SRpcMsg qwtfetchRpc = {0}; -SResFetchReq qwtfetchMsg = {0}; -SRpcMsg qwtreadyRpc = {0}; -SResReadyReq qwtreadyMsg = {0}; -SRpcMsg qwtdropRpc = {0}; -STaskDropReq qwtdropMsg = {0}; +int32_t qwtTestSinkLastLen = 0; + +SSubQueryMsg qwtqueryMsg = {0}; +SRpcMsg qwtfetchRpc = {0}; +SResFetchReq qwtfetchMsg = {0}; +SRpcMsg qwtreadyRpc = {0}; +SResReadyReq qwtreadyMsg = {0}; +SRpcMsg qwtdropRpc = {0}; +STaskDropReq qwtdropMsg = {0}; SSchTasksStatusReq qwtstatusMsg = {0}; - void qwtInitLogFile() { if (!qwtEnableLog) { return; } - const char *defaultLogFileNamePrefix = "taosdlog"; - const int32_t maxLogFileNum = 10; + const char *defaultLogFileNamePrefix = "taosdlog"; + const int32_t maxLogFileNum = 10; tsAsyncLog = 0; qDebugFlag = 159; @@ -113,7 +108,6 @@ void qwtInitLogFile() { if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); } - } void qwtBuildQueryReqMsg(SRpcMsg *queryRpc) { @@ -145,7 +139,7 @@ void qwtBuildDropReqMsg(STaskDropReq *dropMsg, SRpcMsg *dropRpc) { dropRpc->contLen = sizeof(STaskDropReq); } -int32_t qwtStringToPlan(const char* str, SSubplan** subplan) { +int32_t qwtStringToPlan(const char *str, SSubplan **subplan) { *subplan = (SSubplan *)0x1; return 0; } @@ -153,12 +147,12 @@ int32_t qwtStringToPlan(const char* str, SSubplan** subplan) { int32_t qwtPutReqToFetchQueue(void *node, struct SRpcMsg *pMsg) { taosWLockLatch(&qwtTestFetchQueueLock); struct SRpcMsg *newMsg = (struct SRpcMsg *)taosMemoryCalloc(1, sizeof(struct SRpcMsg)); - memcpy(newMsg, pMsg, sizeof(struct SRpcMsg)); + memcpy(newMsg, pMsg, sizeof(struct SRpcMsg)); qwtTestFetchQueue[qwtTestFetchQueueWIdx++] = newMsg; if (qwtTestFetchQueueWIdx >= qwtTestFetchQueueSize) { qwtTestFetchQueueWIdx = 0; } - + qwtTestFetchQueueNum++; if (qwtTestFetchQueueWIdx == qwtTestFetchQueueRIdx) { @@ -166,9 +160,9 @@ int32_t qwtPutReqToFetchQueue(void *node, struct SRpcMsg *pMsg) { assert(0); } taosWUnLockLatch(&qwtTestFetchQueueLock); - + tsem_post(&qwtTestFetchSem); - + return 0; } @@ -188,19 +182,15 @@ int32_t qwtPutReqToQueue(void *node, EQueueType qtype, struct SRpcMsg *pMsg) { assert(0); } taosWUnLockLatch(&qwtTestQueryQueueLock); - + tsem_post(&qwtTestQuerySem); - - return 0; -} -void qwtSendReqToDnode(void* pVnode, struct SEpSet* epSet, struct SRpcMsg* pReq) { - + return 0; } +void qwtSendReqToDnode(void *pVnode, struct SEpSet *epSet, struct SRpcMsg *pReq) {} void qwtRpcSendResponse(const SRpcMsg *pRsp) { - switch (pRsp->msgType) { case TDMT_SCH_QUERY_RSP: case TDMT_SCH_MERGE_QUERY_RSP: { @@ -210,14 +200,14 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) { qwtBuildDropReqMsg(&qwtdropMsg, &qwtdropRpc); qwtPutReqToFetchQueue((void *)0x1, &qwtdropRpc); } - + rpcFreeCont(rsp); break; } case TDMT_SCH_FETCH_RSP: case TDMT_SCH_MERGE_FETCH_RSP: { SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)pRsp->pCont; - + if (0 == pRsp->code && 0 == rsp->completed) { qwtBuildFetchReqMsg(&qwtfetchMsg, &qwtfetchRpc); qwtPutReqToFetchQueue((void *)0x1, &qwtfetchRpc); @@ -228,7 +218,7 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) { qwtBuildDropReqMsg(&qwtdropMsg, &qwtdropRpc); qwtPutReqToFetchQueue((void *)0x1, &qwtdropRpc); rpcFreeCont(rsp); - + break; } case TDMT_SCH_DROP_TASK_RSP: { @@ -240,26 +230,26 @@ void qwtRpcSendResponse(const SRpcMsg *pRsp) { } } - return; } -int32_t qwtCreateExecTask(void* tsdb, int32_t vgId, uint64_t taskId, struct SSubplan* pPlan, qTaskInfo_t* pTaskInfo, DataSinkHandle* handle) { +int32_t qwtCreateExecTask(void *tsdb, int32_t vgId, uint64_t taskId, struct SSubplan *pPlan, qTaskInfo_t *pTaskInfo, + DataSinkHandle *handle) { qwtTestSinkBlockNum = 0; qwtTestSinkMaxBlockNum = taosRand() % 100 + 1; qwtTestSinkQueryEnd = false; - - *pTaskInfo = (qTaskInfo_t)((char*)qwtTestCaseIdx+1); - *handle = (DataSinkHandle)((char*)qwtTestCaseIdx+2); + + *pTaskInfo = (qTaskInfo_t)((char *)qwtTestCaseIdx + 1); + *handle = (DataSinkHandle)((char *)qwtTestCaseIdx + 2); ++qwtTestCaseIdx; - + return 0; } -int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) { +int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock **pRes, uint64_t *useconds) { int32_t endExec = 0; - + if (NULL == tinfo) { *pRes = NULL; *useconds = 0; @@ -269,9 +259,9 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) { *useconds = taosRand() % 10; return 0; } - + endExec = taosRand() % 5; - + int32_t runTime = 0; if (qwtTestEnableSleep && qwtTestMaxExecTaskUsec > 0) { runTime = taosRand() % qwtTestMaxExecTaskUsec; @@ -282,28 +272,24 @@ int32_t qwtExecTask(qTaskInfo_t tinfo, SSDataBlock** pRes, uint64_t *useconds) { taosUsleep(runTime); } } - + if (endExec) { - *pRes = (SSDataBlock*)taosMemoryCalloc(1, sizeof(SSDataBlock)); + *pRes = (SSDataBlock *)taosMemoryCalloc(1, sizeof(SSDataBlock)); (*pRes)->info.rows = taosRand() % 1000 + 1; } else { *pRes = NULL; *useconds = taosRand() % 10; } } - - return 0; -} -int32_t qwtKillTask(qTaskInfo_t qinfo) { return 0; } -void qwtDestroyTask(qTaskInfo_t qHandle) { -} +int32_t qwtKillTask(qTaskInfo_t qinfo) { return 0; } +void qwtDestroyTask(qTaskInfo_t qHandle) {} -int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* pContinue) { +int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData *pInput, bool *pContinue) { if (NULL == handle || NULL == pInput || NULL == pContinue) { assert(0); } @@ -320,7 +306,7 @@ int32_t qwtPutDataBlock(DataSinkHandle handle, const SInputData* pInput, bool* p *pContinue = true; } taosWUnLockLatch(&qwtTestSinkLock); - + return 0; } @@ -332,7 +318,7 @@ void qwtEndPut(DataSinkHandle handle, uint64_t useconds) { qwtTestSinkQueryEnd = true; } -void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) { +void qwtGetDataLength(DataSinkHandle handle, int64_t *pLen, bool *pQueryEnd) { static int32_t in = 0; if (in > 0) { @@ -340,7 +326,7 @@ void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) { } atomic_add_fetch_32(&in, 1); - + if (NULL == handle) { assert(0); } @@ -360,7 +346,7 @@ void qwtGetDataLength(DataSinkHandle handle, int64_t* pLen, bool* pQueryEnd) { atomic_sub_fetch_32(&in, 1); } -int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) { +int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData *pOutput) { taosWLockLatch(&qwtTestSinkLock); if (qwtTestSinkLastLen > 0) { pOutput->numOfRows = taosRand() % 10 + 1; @@ -368,7 +354,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) { pOutput->queryEnd = qwtTestSinkQueryEnd; if (qwtTestSinkBlockNum == 0) { pOutput->bufStatus = DS_BUF_EMPTY; - } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) { + } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum * 0.5) { pOutput->bufStatus = DS_BUF_LOW; } else { pOutput->bufStatus = DS_BUF_FULL; @@ -382,7 +368,7 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) { pOutput->queryEnd = qwtTestSinkQueryEnd; if (qwtTestSinkBlockNum == 0) { pOutput->bufStatus = DS_BUF_EMPTY; - } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum*0.5) { + } else if (qwtTestSinkBlockNum <= qwtTestSinkMaxBlockNum * 0.5) { pOutput->bufStatus = DS_BUF_LOW; } else { pOutput->bufStatus = DS_BUF_FULL; @@ -393,31 +379,27 @@ int32_t qwtGetDataBlock(DataSinkHandle handle, SOutputData* pOutput) { assert(0); } taosWUnLockLatch(&qwtTestSinkLock); - - return 0; -} - -void qwtDestroyDataSinker(DataSinkHandle handle) { + return 0; } - +void qwtDestroyDataSinker(DataSinkHandle handle) {} void stubSetStringToPlan() { static Stub stub; stub.set(qStringToSubplan, qwtStringToPlan); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qStringToSubplan", result); #endif #ifdef LINUX - AddrAny any("libplanner.so"); - std::map result; + AddrAny any("libplanner.so"); + std::map result; any.get_global_func_addr_dynsym("^qStringToSubplan$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtStringToPlan); } } @@ -428,38 +410,36 @@ void stubSetExecTask() { stub.set(qExecTask, qwtExecTask); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qExecTask", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^qExecTask$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtExecTask); } } } - - void stubSetCreateExecTask() { static Stub stub; stub.set(qCreateExecTask, qwtCreateExecTask); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qCreateExecTask", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^qCreateExecTask$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtCreateExecTask); } } @@ -470,16 +450,16 @@ void stubSetAsyncKillTask() { stub.set(qAsyncKillTask, qwtKillTask); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qAsyncKillTask", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^qAsyncKillTask$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtKillTask); } } @@ -490,37 +470,36 @@ void stubSetDestroyTask() { stub.set(qDestroyTask, qwtDestroyTask); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qDestroyTask", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^qDestroyTask$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtDestroyTask); } } } - void stubSetDestroyDataSinker() { static Stub stub; stub.set(dsDestroyDataSinker, qwtDestroyDataSinker); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("dsDestroyDataSinker", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^dsDestroyDataSinker$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtDestroyDataSinker); } } @@ -531,16 +510,16 @@ void stubSetGetDataLength() { stub.set(dsGetDataLength, qwtGetDataLength); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("dsGetDataLength", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^dsGetDataLength$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtGetDataLength); } } @@ -551,16 +530,16 @@ void stubSetEndPut() { stub.set(dsEndPut, qwtEndPut); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("dsEndPut", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^dsEndPut$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtEndPut); } } @@ -571,16 +550,16 @@ void stubSetPutDataBlock() { stub.set(dsPutDataBlock, qwtPutDataBlock); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("dsPutDataBlock", result); #endif #ifdef LINUX - AddrAny any("libexecutor.so"); - std::map result; + AddrAny any("libexecutor.so"); + std::map result; any.get_global_func_addr_dynsym("^dsPutDataBlock$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtPutDataBlock); } } @@ -591,16 +570,16 @@ void stubSetRpcSendResponse() { stub.set(rpcSendResponse, qwtRpcSendResponse); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendResponse", result); #endif #ifdef LINUX - AddrAny any("libtransport.so"); - std::map result; + AddrAny any("libtransport.so"); + std::map result; any.get_global_func_addr_dynsym("^rpcSendResponse$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtRpcSendResponse); } } @@ -611,34 +590,33 @@ void stubSetGetDataBlock() { stub.set(dsGetDataBlock, qwtGetDataBlock); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("dsGetDataBlock", result); #endif #ifdef LINUX - AddrAny any("libtransport.so"); - std::map result; + AddrAny any("libtransport.so"); + std::map result; any.get_global_func_addr_dynsym("^dsGetDataBlock$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, qwtGetDataBlock); } } } - void *queryThread(void *param) { - SRpcMsg queryRpc = {0}; - int32_t code = 0; + SRpcMsg queryRpc = {0}; + int32_t code = 0; uint32_t n = 0; - void *mockPointer = (void *)0x1; - void *mgmt = param; + void *mockPointer = (void *)0x1; + void *mgmt = param; while (!qwtTestStop) { qwtBuildQueryReqMsg(&queryRpc); - qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0); + qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0); if (qwtTestEnableSleep) { - taosUsleep(taosRand()%5); + taosUsleep(taosRand() % 5); } if (++n % qwtTestPrintNum == 0) { printf("query:%d\n", n); @@ -649,55 +627,55 @@ void *queryThread(void *param) { } void *fetchThread(void *param) { - SRpcMsg fetchRpc = {0}; - int32_t code = 0; - uint32_t n = 0; - void *mockPointer = (void *)0x1; - void *mgmt = param; + SRpcMsg fetchRpc = {0}; + int32_t code = 0; + uint32_t n = 0; + void *mockPointer = (void *)0x1; + void *mgmt = param; SResFetchReq fetchMsg = {0}; while (!qwtTestStop) { qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc); code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0); if (qwtTestEnableSleep) { - taosUsleep(taosRand()%5); + taosUsleep(taosRand() % 5); } if (++n % qwtTestPrintNum == 0) { printf("fetch:%d\n", n); - } + } } return NULL; } void *dropThread(void *param) { - SRpcMsg dropRpc = {0}; - int32_t code = 0; - uint32_t n = 0; - void *mockPointer = (void *)0x1; - void *mgmt = param; - STaskDropReq dropMsg = {0}; + SRpcMsg dropRpc = {0}; + int32_t code = 0; + uint32_t n = 0; + void *mockPointer = (void *)0x1; + void *mgmt = param; + STaskDropReq dropMsg = {0}; while (!qwtTestStop) { qwtBuildDropReqMsg(&dropMsg, &dropRpc); code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0); if (qwtTestEnableSleep) { - taosUsleep(taosRand()%5); + taosUsleep(taosRand() % 5); } if (++n % qwtTestPrintNum == 0) { printf("drop:%d\n", n); - } + } } return NULL; } void *qwtclientThread(void *param) { - int32_t code = 0; + int32_t code = 0; uint32_t n = 0; - void *mgmt = param; - void *mockPointer = (void *)0x1; - SRpcMsg queryRpc = {0}; + void *mgmt = param; + void *mockPointer = (void *)0x1; + SRpcMsg queryRpc = {0}; taosSsleep(1); @@ -710,8 +688,7 @@ void *qwtclientThread(void *param) { while (!qwtTestCaseFinished) { taosUsleep(1); } - - + if (++n % qwtTestPrintNum == 0) { printf("case run:%d\n", n); } @@ -723,9 +700,9 @@ void *qwtclientThread(void *param) { } void *queryQueueThread(void *param) { - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; SRpcMsg *queryRpc = NULL; - void *mgmt = param; + void *mgmt = param; while (true) { tsem_wait(&qwtTestQuerySem); @@ -739,17 +716,16 @@ void *queryQueueThread(void *param) { printf("query queue is empty\n"); assert(0); } - + queryRpc = qwtTestQueryQueue[qwtTestQueryQueueRIdx++]; - + if (qwtTestQueryQueueRIdx >= qwtTestQueryQueueSize) { qwtTestQueryQueueRIdx = 0; } - + qwtTestQueryQueueNum--; taosWUnLockLatch(&qwtTestQueryQueueLock); - if (qwtTestEnableSleep && qwtTestReqMaxDelayUsec > 0) { int32_t delay = taosRand() % qwtTestReqMaxDelayUsec; @@ -757,7 +733,7 @@ void *queryQueueThread(void *param) { taosUsleep(delay); } } - + if (TDMT_SCH_QUERY == queryRpc->msgType) { qWorkerProcessQueryMsg(mockPointer, mgmt, queryRpc, 0); } else if (TDMT_SCH_QUERY_CONTINUE == queryRpc->msgType) { @@ -780,29 +756,29 @@ void *queryQueueThread(void *param) { } void *fetchQueueThread(void *param) { - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; SRpcMsg *fetchRpc = NULL; - void *mgmt = param; + void *mgmt = param; while (true) { tsem_wait(&qwtTestFetchSem); if (qwtTestStop && qwtTestFetchQueueNum <= 0 && qwtTestCaseFinished) { break; - } + } taosWLockLatch(&qwtTestFetchQueueLock); if (qwtTestFetchQueueNum <= 0 || qwtTestFetchQueueRIdx == qwtTestFetchQueueWIdx) { printf("Fetch queue is empty\n"); assert(0); } - + fetchRpc = qwtTestFetchQueue[qwtTestFetchQueueRIdx++]; - + if (qwtTestFetchQueueRIdx >= qwtTestFetchQueueSize) { qwtTestFetchQueueRIdx = 0; } - + qwtTestFetchQueueNum--; taosWUnLockLatch(&qwtTestFetchQueueLock); @@ -835,7 +811,7 @@ void *fetchQueueThread(void *param) { if (qwtTestStop && qwtTestFetchQueueNum <= 0 && qwtTestCaseFinished) { break; - } + } } atomic_add_fetch_32(&qwtTestQuitThreadNum, 1); @@ -843,15 +819,12 @@ void *fetchQueueThread(void *param) { return NULL; } - - -} - +} // namespace TEST(seqTest, normalCase) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; SRpcMsg queryRpc = {0}; SRpcMsg fetchRpc = {0}; SRpcMsg dropRpc = {0}; @@ -861,7 +834,7 @@ TEST(seqTest, normalCase) { qwtBuildQueryReqMsg(&queryRpc); qwtBuildFetchReqMsg(&qwtfetchMsg, &fetchRpc); qwtBuildDropReqMsg(&qwtdropMsg, &dropRpc); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -873,7 +846,7 @@ TEST(seqTest, normalCase) { stubSetEndPut(); stubSetPutDataBlock(); stubSetGetDataBlock(); - + SMsgCb msgCb = {0}; msgCb.mgmt = (void *)mockPointer; msgCb.putToQueueFp = (PutToQueueFp)qwtPutReqToQueue; @@ -883,8 +856,8 @@ TEST(seqTest, normalCase) { code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0); ASSERT_EQ(code, 0); - //code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc); - //ASSERT_EQ(code, 0); + // code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc); + // ASSERT_EQ(code, 0); code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0); ASSERT_EQ(code, 0); @@ -896,14 +869,14 @@ TEST(seqTest, normalCase) { } TEST(seqTest, cancelFirst) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; SRpcMsg queryRpc = {0}; SRpcMsg dropRpc = {0}; qwtInitLogFile(); - + qwtBuildQueryReqMsg(&queryRpc); qwtBuildDropReqMsg(&qwtdropMsg, &dropRpc); @@ -926,21 +899,21 @@ TEST(seqTest, cancelFirst) { } TEST(seqTest, randCase) { - void *mgmt = NULL; - int32_t code = 0; - void *mockPointer = (void *)0x1; - SRpcMsg queryRpc = {0}; - SRpcMsg readyRpc = {0}; - SRpcMsg fetchRpc = {0}; - SRpcMsg dropRpc = {0}; - SRpcMsg statusRpc = {0}; - SResReadyReq readyMsg = {0}; - SResFetchReq fetchMsg = {0}; - STaskDropReq dropMsg = {0}; + void *mgmt = NULL; + int32_t code = 0; + void *mockPointer = (void *)0x1; + SRpcMsg queryRpc = {0}; + SRpcMsg readyRpc = {0}; + SRpcMsg fetchRpc = {0}; + SRpcMsg dropRpc = {0}; + SRpcMsg statusRpc = {0}; + SResReadyReq readyMsg = {0}; + SResFetchReq fetchMsg = {0}; + STaskDropReq dropMsg = {0}; SSchTasksStatusReq statusMsg = {0}; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetCreateExecTask(); @@ -957,37 +930,37 @@ TEST(seqTest, randCase) { int32_t maxr = 10001; while (true) { int32_t r = taosRand() % maxr; - - if (r >= 0 && r < maxr/5) { - printf("Query,%d\n", t++); + + if (r >= 0 && r < maxr / 5) { + printf("Query,%d\n", t++); qwtBuildQueryReqMsg(&queryRpc); code = qWorkerProcessQueryMsg(mockPointer, mgmt, &queryRpc, 0); - } else if (r >= maxr/5 && r < maxr * 2/5) { - //printf("Ready,%d\n", t++); - //qwtBuildReadyReqMsg(&readyMsg, &readyRpc); - //code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc); - //if (qwtTestEnableSleep) { - // taosUsleep(1); - //} - } else if (r >= maxr * 2/5 && r < maxr* 3/5) { + } else if (r >= maxr / 5 && r < maxr * 2 / 5) { + // printf("Ready,%d\n", t++); + // qwtBuildReadyReqMsg(&readyMsg, &readyRpc); + // code = qWorkerProcessReadyMsg(mockPointer, mgmt, &readyRpc); + // if (qwtTestEnableSleep) { + // taosUsleep(1); + // } + } else if (r >= maxr * 2 / 5 && r < maxr * 3 / 5) { printf("Fetch,%d\n", t++); qwtBuildFetchReqMsg(&fetchMsg, &fetchRpc); code = qWorkerProcessFetchMsg(mockPointer, mgmt, &fetchRpc, 0); if (qwtTestEnableSleep) { taosUsleep(1); } - } else if (r >= maxr * 3/5 && r < maxr * 4/5) { + } else if (r >= maxr * 3 / 5 && r < maxr * 4 / 5) { printf("Drop,%d\n", t++); qwtBuildDropReqMsg(&dropMsg, &dropRpc); code = qWorkerProcessDropMsg(mockPointer, mgmt, &dropRpc, 0); if (qwtTestEnableSleep) { taosUsleep(1); } - } else if (r >= maxr * 4/5 && r < maxr-1) { + } else if (r >= maxr * 4 / 5 && r < maxr - 1) { printf("Status,%d\n", t++); if (qwtTestEnableSleep) { taosUsleep(1); - } + } } else { printf("QUIT RAND NOW"); break; @@ -998,12 +971,12 @@ TEST(seqTest, randCase) { } TEST(seqTest, multithreadRand) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -1027,9 +1000,9 @@ TEST(seqTest, multithreadRand) { TdThreadAttr thattr; taosThreadAttrInit(&thattr); - TdThread t1,t2,t3,t4,t5,t6; + TdThread t1, t2, t3, t4, t5, t6; taosThreadCreate(&(t1), &thattr, queryThread, mgmt); - //taosThreadCreate(&(t2), &thattr, readyThread, NULL); + // taosThreadCreate(&(t2), &thattr, readyThread, NULL); taosThreadCreate(&(t3), &thattr, fetchThread, NULL); taosThreadCreate(&(t4), &thattr, dropThread, NULL); taosThreadCreate(&(t6), &thattr, fetchQueueThread, mgmt); @@ -1042,7 +1015,7 @@ TEST(seqTest, multithreadRand) { break; } } - + qwtTestStop = true; taosSsleep(3); @@ -1054,17 +1027,17 @@ TEST(seqTest, multithreadRand) { qwtTestFetchQueueRIdx = 0; qwtTestFetchQueueWIdx = 0; qwtTestFetchQueueLock = 0; - + qWorkerDestroy(&mgmt); } TEST(rcTest, shortExecshortDelay) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -1096,7 +1069,7 @@ TEST(rcTest, shortExecshortDelay) { TdThreadAttr thattr; taosThreadAttrInit(&thattr); - TdThread t1,t2,t3,t4,t5; + TdThread t1, t2, t3, t4, t5; taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt); taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt); taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt); @@ -1109,25 +1082,24 @@ TEST(rcTest, shortExecshortDelay) { break; } } - + qwtTestStop = true; while (true) { if (qwtTestQuitThreadNum == 3) { break; } - + taosSsleep(1); if (qwtTestCaseFinished) { - if (qwtTestQuitThreadNum < 3) { + if (qwtTestQuitThreadNum < 3) { tsem_post(&qwtTestQuerySem); tsem_post(&qwtTestFetchSem); taosUsleep(10); } } - } qwtTestQueryQueueNum = 0; @@ -1138,17 +1110,17 @@ TEST(rcTest, shortExecshortDelay) { qwtTestFetchQueueRIdx = 0; qwtTestFetchQueueWIdx = 0; qwtTestFetchQueueLock = 0; - - qWorkerDestroy(&mgmt); + + qWorkerDestroy(&mgmt); } TEST(rcTest, longExecshortDelay) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -1180,7 +1152,7 @@ TEST(rcTest, longExecshortDelay) { TdThreadAttr thattr; taosThreadAttrInit(&thattr); - TdThread t1,t2,t3,t4,t5; + TdThread t1, t2, t3, t4, t5; taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt); taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt); taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt); @@ -1193,26 +1165,24 @@ TEST(rcTest, longExecshortDelay) { break; } } - + qwtTestStop = true; - while (true) { if (qwtTestQuitThreadNum == 3) { break; } - + taosSsleep(1); if (qwtTestCaseFinished) { - if (qwtTestQuitThreadNum < 3) { + if (qwtTestQuitThreadNum < 3) { tsem_post(&qwtTestQuerySem); tsem_post(&qwtTestFetchSem); - + taosUsleep(10); } } - } qwtTestQueryQueueNum = 0; @@ -1223,18 +1193,17 @@ TEST(rcTest, longExecshortDelay) { qwtTestFetchQueueRIdx = 0; qwtTestFetchQueueWIdx = 0; qwtTestFetchQueueLock = 0; - + qWorkerDestroy(&mgmt); } - TEST(rcTest, shortExeclongDelay) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -1266,7 +1235,7 @@ TEST(rcTest, shortExeclongDelay) { TdThreadAttr thattr; taosThreadAttrInit(&thattr); - TdThread t1,t2,t3,t4,t5; + TdThread t1, t2, t3, t4, t5; taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt); taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt); taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt); @@ -1279,26 +1248,24 @@ TEST(rcTest, shortExeclongDelay) { break; } } - - qwtTestStop = true; + qwtTestStop = true; while (true) { if (qwtTestQuitThreadNum == 3) { break; } - + taosSsleep(1); if (qwtTestCaseFinished) { - if (qwtTestQuitThreadNum < 3) { + if (qwtTestQuitThreadNum < 3) { tsem_post(&qwtTestQuerySem); tsem_post(&qwtTestFetchSem); - + taosUsleep(10); } } - } qwtTestQueryQueueNum = 0; @@ -1309,18 +1276,17 @@ TEST(rcTest, shortExeclongDelay) { qwtTestFetchQueueRIdx = 0; qwtTestFetchQueueWIdx = 0; qwtTestFetchQueueLock = 0; - + qWorkerDestroy(&mgmt); } - TEST(rcTest, dropTest) { - void *mgmt = NULL; + void *mgmt = NULL; int32_t code = 0; - void *mockPointer = (void *)0x1; + void *mockPointer = (void *)0x1; qwtInitLogFile(); - + stubSetStringToPlan(); stubSetRpcSendResponse(); stubSetExecTask(); @@ -1347,7 +1313,7 @@ TEST(rcTest, dropTest) { TdThreadAttr thattr; taosThreadAttrInit(&thattr); - TdThread t1,t2,t3,t4,t5; + TdThread t1, t2, t3, t4, t5; taosThreadCreate(&(t1), &thattr, qwtclientThread, mgmt); taosThreadCreate(&(t2), &thattr, queryQueueThread, mgmt); taosThreadCreate(&(t3), &thattr, fetchQueueThread, mgmt); @@ -1360,15 +1326,14 @@ TEST(rcTest, dropTest) { break; } } - + qwtTestStop = true; taosSsleep(3); - + qWorkerDestroy(&mgmt); } - -int main(int argc, char** argv) { +int main(int argc, char **argv) { taosSeedRand(taosGetTimestampSec()); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index ef3d3f79f959805681d0bc0e2e0b101cd8518388..e26bc59d47e368487370d9f0c260d61b24dc84a7 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -28,19 +28,19 @@ extern "C" { #include "thash.h" #include "tname.h" -#define FILTER_DEFAULT_GROUP_SIZE 4 -#define FILTER_DEFAULT_UNIT_SIZE 4 -#define FILTER_DEFAULT_FIELD_SIZE 4 -#define FILTER_DEFAULT_VALUE_SIZE 4 +#define FILTER_DEFAULT_GROUP_SIZE 4 +#define FILTER_DEFAULT_UNIT_SIZE 4 +#define FILTER_DEFAULT_FIELD_SIZE 4 +#define FILTER_DEFAULT_VALUE_SIZE 4 #define FILTER_DEFAULT_GROUP_UNIT_SIZE 2 -#define FILTER_DUMMY_EMPTY_OPTR 127 +#define FILTER_DUMMY_EMPTY_OPTR 127 #define FILTER_RM_UNIT_MIN_ROWS 100 enum { FLD_TYPE_COLUMN = 1, - FLD_TYPE_VALUE = 2, + FLD_TYPE_VALUE = 2, FLD_TYPE_MAX = 3, FLD_DATA_NO_FREE = 8, FLD_DATA_IS_HASH = 16, @@ -56,10 +56,9 @@ enum { enum { RANGE_FLG_EXCLUDE = 1, RANGE_FLG_INCLUDE = 2, - RANGE_FLG_NULL = 4, + RANGE_FLG_NULL = 4, }; - enum { FI_STATUS_ALL = 1, FI_STATUS_EMPTY = 2, @@ -93,63 +92,63 @@ typedef struct OptrStr { typedef struct SFilterRange { int64_t s; int64_t e; - char sflag; - char eflag; + char sflag; + char eflag; } SFilterRange; -typedef bool (*rangeCompFunc) (const void *, const void *, const void *, const void *, __compar_fn_t); -typedef int32_t(*filter_desc_compare_func)(const void *, const void *); -typedef bool(*filter_exec_func)(void*, int32_t, SColumnInfoData*, SColumnDataAgg*, int16_t, int32_t*); -typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char*, void **); +typedef bool (*rangeCompFunc)(const void *, const void *, const void *, const void *, __compar_fn_t); +typedef int32_t (*filter_desc_compare_func)(const void *, const void *); +typedef bool (*filter_exec_func)(void *, int32_t, SColumnInfoData *, SColumnDataAgg *, int16_t, int32_t *); +typedef int32_t (*filer_get_col_from_name)(void *, int32_t, char *, void **); typedef struct SFilterRangeCompare { - int64_t s; - int64_t e; + int64_t s; + int64_t e; rangeCompFunc func; } SFilterRangeCompare; typedef struct SFilterRangeNode { - struct SFilterRangeNode* prev; - struct SFilterRangeNode* next; + struct SFilterRangeNode *prev; + struct SFilterRangeNode *next; union { - SFilterRange ra; + SFilterRange ra; SFilterRangeCompare rc; }; } SFilterRangeNode; typedef struct SFilterRangeCtx { - int32_t type; - int32_t options; - int8_t status; - bool isnull; - bool notnull; - bool isrange; - int16_t colId; - __compar_fn_t pCompareFunc; - SFilterRangeNode *rf; //freed + int32_t type; + int32_t options; + int8_t status; + bool isnull; + bool notnull; + bool isrange; + int16_t colId; + __compar_fn_t pCompareFunc; + SFilterRangeNode *rf; // freed SFilterRangeNode *rs; -} SFilterRangeCtx ; +} SFilterRangeCtx; typedef struct SFilterVarCtx { - int32_t type; - int32_t options; - int8_t status; - bool isnull; - bool notnull; - bool isrange; + int32_t type; + int32_t options; + int8_t status; + bool isnull; + bool notnull; + bool isrange; SHashObj *wild; SHashObj *value; } SFilterVarCtx; typedef struct SFilterField { uint16_t flag; - void* desc; - void* data; + void *desc; + void *data; } SFilterField; typedef struct SFilterFields { - uint32_t size; - uint32_t num; + uint32_t size; + uint32_t num; SFilterField *fields; } SFilterFields; @@ -174,40 +173,40 @@ typedef struct SFilterColInfo { } SFilterColInfo; typedef struct SFilterGroupCtx { - uint32_t colNum; - uint32_t *colIdx; - SFilterColInfo *colInfo; + uint32_t colNum; + uint32_t *colIdx; + SFilterColInfo *colInfo; } SFilterGroupCtx; typedef struct SFilterColCtx { - uint32_t colIdx; - void* ctx; + uint32_t colIdx; + void *ctx; } SFilterColCtx; typedef struct SFilterCompare { - uint8_t type; - int8_t precision; - uint8_t optr; - uint8_t optr2; + uint8_t type; + int8_t precision; + uint8_t optr; + uint8_t optr2; } SFilterCompare; typedef struct SFilterUnit { - SFilterCompare compare; - SFilterFieldId left; - SFilterFieldId right; - SFilterFieldId right2; + SFilterCompare compare; + SFilterFieldId left; + SFilterFieldId right; + SFilterFieldId right2; } SFilterUnit; typedef struct SFilterComUnit { - void *colData; // pointer to SColumnInfoData - void *valData; - void *valData2; + void *colData; // pointer to SColumnInfoData + void *valData; + void *valData2; uint16_t colId; uint16_t dataSize; - uint8_t dataType; - uint8_t optr; - int8_t func; - int8_t rfunc; + uint8_t dataType; + uint8_t optr; + int8_t func; + int8_t rfunc; } SFilterComUnit; typedef struct SFilterPCtx { @@ -219,8 +218,8 @@ typedef struct SFltTreeStat { int32_t code; int8_t precision; bool scalarMode; - SArray* nodeList; - SFilterInfo* info; + SArray *nodeList; + SFilterInfo *info; } SFltTreeStat; typedef struct SFltScalarCtx { @@ -237,7 +236,7 @@ struct SFilterInfo { bool scalarMode; SFltScalarCtx sclCtx; uint32_t options; - uint32_t status; + uint32_t status; uint32_t unitSize; uint32_t unitNum; uint32_t groupNum; @@ -249,7 +248,7 @@ struct SFilterInfo { uint8_t *unitRes; // result uint8_t *unitFlags; // got result SFilterRangeCtx **colRange; - filter_exec_func func; + filter_exec_func func; uint8_t blkFlag; uint32_t blkGroupNum; uint32_t *blkUnits; @@ -257,98 +256,231 @@ struct SFilterInfo { void *pTable; SArray *blkList; - SFilterPCtx pctx; + SFilterPCtx pctx; }; -#define FILTER_NO_MERGE_DATA_TYPE(t) ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON) +#define FILTER_NO_MERGE_DATA_TYPE(t) \ + ((t) == TSDB_DATA_TYPE_BINARY || (t) == TSDB_DATA_TYPE_NCHAR || (t) == TSDB_DATA_TYPE_JSON) #define FILTER_NO_MERGE_OPTR(o) ((o) == OP_TYPE_IS_NULL || (o) == OP_TYPE_IS_NOT_NULL || (o) == FILTER_DUMMY_EMPTY_OPTR) #define MR_EMPTY_RES(ctx) (ctx->rs == NULL) -#define SET_AND_OPTR(ctx, o) do {if (o == OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_NULL) { if (!(ctx)->isrange) { (ctx)->notnull = true; } } else if (o != FILTER_DUMMY_EMPTY_OPTR) { (ctx)->isrange = true; (ctx)->notnull = false; } } while (0) -#define SET_OR_OPTR(ctx,o) do {if (o == OP_TYPE_IS_NULL) { (ctx)->isnull = true; } else if (o == OP_TYPE_IS_NOT_NULL) { (ctx)->notnull = true; (ctx)->isrange = false; } else if (o != FILTER_DUMMY_EMPTY_OPTR) { if (!(ctx)->notnull) { (ctx)->isrange = true; } } } while (0) +#define SET_AND_OPTR(ctx, o) \ + do { \ + if (o == OP_TYPE_IS_NULL) { \ + (ctx)->isnull = true; \ + } else if (o == OP_TYPE_IS_NOT_NULL) { \ + if (!(ctx)->isrange) { \ + (ctx)->notnull = true; \ + } \ + } else if (o != FILTER_DUMMY_EMPTY_OPTR) { \ + (ctx)->isrange = true; \ + (ctx)->notnull = false; \ + } \ + } while (0) +#define SET_OR_OPTR(ctx, o) \ + do { \ + if (o == OP_TYPE_IS_NULL) { \ + (ctx)->isnull = true; \ + } else if (o == OP_TYPE_IS_NOT_NULL) { \ + (ctx)->notnull = true; \ + (ctx)->isrange = false; \ + } else if (o != FILTER_DUMMY_EMPTY_OPTR) { \ + if (!(ctx)->notnull) { \ + (ctx)->isrange = true; \ + } \ + } \ + } while (0) #define CHK_OR_OPTR(ctx) ((ctx)->isnull == true && (ctx)->notnull == true) -#define CHK_AND_OPTR(ctx) ((ctx)->isnull == true && (((ctx)->notnull == true) || ((ctx)->isrange == true))) - +#define CHK_AND_OPTR(ctx) ((ctx)->isnull == true && (((ctx)->notnull == true) || ((ctx)->isrange == true))) #define FILTER_GET_FLAG(st, f) (st & f) #define FILTER_SET_FLAG(st, f) st |= (f) #define FILTER_CLR_FLAG(st, f) st &= (~f) #define SIMPLE_COPY_VALUES(dst, src) *((int64_t *)dst) = *((int64_t *)src) -#define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) do { char *_t = (char *)(v); _t[0] = (op1); _t[1] = (op2); *(uint32_t *)(_t + 2) = (lidx); *(uint32_t *)(_t + 2 + sizeof(uint32_t)) = (ridx); } while (0) -#define FILTER_GREATER(cr,sflag,eflag) ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag,RANGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag,RANGE_FLG_EXCLUDE)))) -#define FILTER_COPY_RA(dst, src) do { (dst)->sflag = (src)->sflag; (dst)->eflag = (src)->eflag; (dst)->s = (src)->s; (dst)->e = (src)->e; } while (0) - -#define RESET_RANGE(ctx, r) do { (r)->next = (ctx)->rf; (ctx)->rf = r; } while (0) -#define FREE_RANGE(ctx, r) do { if ((r)->prev) { (r)->prev->next = (r)->next; } else { (ctx)->rs = (r)->next;} if ((r)->next) { (r)->next->prev = (r)->prev; } RESET_RANGE(ctx, r); } while (0) -#define FREE_FROM_RANGE(ctx, r) do { SFilterRangeNode *_r = r; if ((_r)->prev) { (_r)->prev->next = NULL; } else { (ctx)->rs = NULL;} while (_r) {SFilterRangeNode *n = (_r)->next; RESET_RANGE(ctx, _r); _r = n; } } while (0) -#define INSERT_RANGE(ctx, r, ra) do { SFilterRangeNode *n = filterNewRange(ctx, ra); n->prev = (r)->prev; if ((r)->prev) { (r)->prev->next = n; } else { (ctx)->rs = n; } (r)->prev = n; n->next = r; } while (0) -#define APPEND_RANGE(ctx, r, ra) do { SFilterRangeNode *n = filterNewRange(ctx, ra); n->prev = (r); if (r) { (r)->next = n; } else { (ctx)->rs = n; } } while (0) +#define FLT_PACKAGE_UNIT_HASH_KEY(v, op1, op2, lidx, ridx, ridx2) \ + do { \ + char *_t = (char *)(v); \ + _t[0] = (op1); \ + _t[1] = (op2); \ + *(uint32_t *)(_t + 2) = (lidx); \ + *(uint32_t *)(_t + 2 + sizeof(uint32_t)) = (ridx); \ + } while (0) +#define FILTER_GREATER(cr, sflag, eflag) \ + ((cr > 0) || ((cr == 0) && (FILTER_GET_FLAG(sflag, RANGE_FLG_EXCLUDE) || FILTER_GET_FLAG(eflag, RANGE_FLG_EXCLUDE)))) +#define FILTER_COPY_RA(dst, src) \ + do { \ + (dst)->sflag = (src)->sflag; \ + (dst)->eflag = (src)->eflag; \ + (dst)->s = (src)->s; \ + (dst)->e = (src)->e; \ + } while (0) + +#define RESET_RANGE(ctx, r) \ + do { \ + (r)->next = (ctx)->rf; \ + (ctx)->rf = r; \ + } while (0) +#define FREE_RANGE(ctx, r) \ + do { \ + if ((r)->prev) { \ + (r)->prev->next = (r)->next; \ + } else { \ + (ctx)->rs = (r)->next; \ + } \ + if ((r)->next) { \ + (r)->next->prev = (r)->prev; \ + } \ + RESET_RANGE(ctx, r); \ + } while (0) +#define FREE_FROM_RANGE(ctx, r) \ + do { \ + SFilterRangeNode *_r = r; \ + if ((_r)->prev) { \ + (_r)->prev->next = NULL; \ + } else { \ + (ctx)->rs = NULL; \ + } \ + while (_r) { \ + SFilterRangeNode *n = (_r)->next; \ + RESET_RANGE(ctx, _r); \ + _r = n; \ + } \ + } while (0) +#define INSERT_RANGE(ctx, r, ra) \ + do { \ + SFilterRangeNode *n = filterNewRange(ctx, ra); \ + n->prev = (r)->prev; \ + if ((r)->prev) { \ + (r)->prev->next = n; \ + } else { \ + (ctx)->rs = n; \ + } \ + (r)->prev = n; \ + n->next = r; \ + } while (0) +#define APPEND_RANGE(ctx, r, ra) \ + do { \ + SFilterRangeNode *n = filterNewRange(ctx, ra); \ + n->prev = (r); \ + if (r) { \ + (r)->next = n; \ + } else { \ + (ctx)->rs = n; \ + } \ + } while (0) #define FLT_IS_COMPARISON_OPERATOR(_op) ((_op) >= OP_TYPE_GREATER_THAN && (_op) < OP_TYPE_IS_NOT_UNKNOWN) -#define fltFatal(...) qFatal(__VA_ARGS__) -#define fltError(...) qError(__VA_ARGS__) -#define fltWarn(...) qWarn(__VA_ARGS__) -#define fltInfo(...) qInfo(__VA_ARGS__) -#define fltDebug(...) qDebug(__VA_ARGS__) -#define fltTrace(...) qTrace(__VA_ARGS__) - - -#define FLT_CHK_JMP(c) do { if (c) { goto _return; } } while (0) -#define FLT_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define FLT_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define FLT_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) - - -#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx])) -#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx])) -#define FILTER_GET_COL_FIELD_TYPE(fi) (((SColumnNode *)((fi)->desc))->node.resType.type) +#define fltFatal(...) qFatal(__VA_ARGS__) +#define fltError(...) qError(__VA_ARGS__) +#define fltWarn(...) qWarn(__VA_ARGS__) +#define fltInfo(...) qInfo(__VA_ARGS__) +#define fltDebug(...) qDebug(__VA_ARGS__) +#define fltTrace(...) qTrace(__VA_ARGS__) + +#define FLT_CHK_JMP(c) \ + do { \ + if (c) { \ + goto _return; \ + } \ + } while (0) +#define FLT_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define FLT_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define FLT_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ + } while (0) + +#define FILTER_GET_FIELD(i, id) (&((i)->fields[(id).type].fields[(id).idx])) +#define FILTER_GET_COL_FIELD(i, idx) (&((i)->fields[FLD_TYPE_COLUMN].fields[idx])) +#define FILTER_GET_COL_FIELD_TYPE(fi) (((SColumnNode *)((fi)->desc))->node.resType.type) #define FILTER_GET_COL_FIELD_PRECISION(fi) (((SColumnNode *)((fi)->desc))->node.resType.precision) -#define FILTER_GET_COL_FIELD_SIZE(fi) (((SColumnNode *)((fi)->desc))->node.resType.bytes) -#define FILTER_GET_COL_FIELD_ID(fi) (((SColumnNode *)((fi)->desc))->colId) -#define FILTER_GET_COL_FIELD_SLOT_ID(fi) (((SColumnNode *)((fi)->desc))->slotId) -#define FILTER_GET_COL_FIELD_DESC(fi) ((SColumnNode *)((fi)->desc)) -#define FILTER_GET_COL_FIELD_DATA(fi, ri) (colDataGetData(((SColumnInfoData *)(fi)->data), (ri))) -#define FILTER_GET_VAL_FIELD_TYPE(fi) (((SValueNode *)((fi)->desc))->node.resType.type) -#define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data) -#define FILTER_GET_TYPE(fl) ((fl) & FLD_TYPE_MAX) - -#define FILTER_GROUP_UNIT(i, g, uid) ((i)->units + (g)->unitIdxs[uid]) -#define FILTER_UNIT_LEFT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->left) -#define FILTER_UNIT_RIGHT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->right) +#define FILTER_GET_COL_FIELD_SIZE(fi) (((SColumnNode *)((fi)->desc))->node.resType.bytes) +#define FILTER_GET_COL_FIELD_ID(fi) (((SColumnNode *)((fi)->desc))->colId) +#define FILTER_GET_COL_FIELD_SLOT_ID(fi) (((SColumnNode *)((fi)->desc))->slotId) +#define FILTER_GET_COL_FIELD_DESC(fi) ((SColumnNode *)((fi)->desc)) +#define FILTER_GET_COL_FIELD_DATA(fi, ri) (colDataGetData(((SColumnInfoData *)(fi)->data), (ri))) +#define FILTER_GET_VAL_FIELD_TYPE(fi) (((SValueNode *)((fi)->desc))->node.resType.type) +#define FILTER_GET_VAL_FIELD_DATA(fi) ((char *)(fi)->data) +#define FILTER_GET_TYPE(fl) ((fl)&FLD_TYPE_MAX) + +#define FILTER_GROUP_UNIT(i, g, uid) ((i)->units + (g)->unitIdxs[uid]) +#define FILTER_UNIT_LEFT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->left) +#define FILTER_UNIT_RIGHT_FIELD(i, u) FILTER_GET_FIELD(i, (u)->right) #define FILTER_UNIT_RIGHT2_FIELD(i, u) FILTER_GET_FIELD(i, (u)->right2) -#define FILTER_UNIT_DATA_TYPE(u) ((u)->compare.type) -#define FILTER_UNIT_DATA_PRECISION(u) ((u)->compare.precision) -#define FILTER_UNIT_COL_DESC(i, u) FILTER_GET_COL_FIELD_DESC(FILTER_UNIT_LEFT_FIELD(i, u)) +#define FILTER_UNIT_DATA_TYPE(u) ((u)->compare.type) +#define FILTER_UNIT_DATA_PRECISION(u) ((u)->compare.precision) +#define FILTER_UNIT_COL_DESC(i, u) FILTER_GET_COL_FIELD_DESC(FILTER_UNIT_LEFT_FIELD(i, u)) #define FILTER_UNIT_COL_DATA(i, u, ri) FILTER_GET_COL_FIELD_DATA(FILTER_UNIT_LEFT_FIELD(i, u), ri) -#define FILTER_UNIT_COL_SIZE(i, u) FILTER_GET_COL_FIELD_SIZE(FILTER_UNIT_LEFT_FIELD(i, u)) -#define FILTER_UNIT_COL_ID(i, u) FILTER_GET_COL_FIELD_ID(FILTER_UNIT_LEFT_FIELD(i, u)) -#define FILTER_UNIT_VAL_DATA(i, u) FILTER_GET_VAL_FIELD_DATA(FILTER_UNIT_RIGHT_FIELD(i, u)) -#define FILTER_UNIT_COL_IDX(u) ((u)->left.idx) -#define FILTER_UNIT_OPTR(u) ((u)->compare.optr) -#define FILTER_UNIT_COMP_FUNC(u) ((u)->compare.func) - -#define FILTER_UNIT_CLR_F(i) memset((i)->unitFlags, 0, (i)->unitNum * sizeof(*info->unitFlags)) -#define FILTER_UNIT_SET_F(i, idx) (i)->unitFlags[idx] = 1 -#define FILTER_UNIT_GET_F(i, idx) ((i)->unitFlags[idx]) -#define FILTER_UNIT_GET_R(i, idx) ((i)->unitRes[idx]) +#define FILTER_UNIT_COL_SIZE(i, u) FILTER_GET_COL_FIELD_SIZE(FILTER_UNIT_LEFT_FIELD(i, u)) +#define FILTER_UNIT_COL_ID(i, u) FILTER_GET_COL_FIELD_ID(FILTER_UNIT_LEFT_FIELD(i, u)) +#define FILTER_UNIT_VAL_DATA(i, u) FILTER_GET_VAL_FIELD_DATA(FILTER_UNIT_RIGHT_FIELD(i, u)) +#define FILTER_UNIT_COL_IDX(u) ((u)->left.idx) +#define FILTER_UNIT_OPTR(u) ((u)->compare.optr) +#define FILTER_UNIT_COMP_FUNC(u) ((u)->compare.func) + +#define FILTER_UNIT_CLR_F(i) memset((i)->unitFlags, 0, (i)->unitNum * sizeof(*info->unitFlags)) +#define FILTER_UNIT_SET_F(i, idx) (i)->unitFlags[idx] = 1 +#define FILTER_UNIT_GET_F(i, idx) ((i)->unitFlags[idx]) +#define FILTER_UNIT_GET_R(i, idx) ((i)->unitRes[idx]) #define FILTER_UNIT_SET_R(i, idx, v) (i)->unitRes[idx] = (v) -#define FILTER_PUSH_UNIT(colInfo, u) do { (colInfo).type = RANGE_TYPE_UNIT; (colInfo).dataType = FILTER_UNIT_DATA_TYPE(u);taosArrayPush((SArray *)((colInfo).info), &u);} while (0) -#define FILTER_PUSH_VAR_HASH(colInfo, ha) do { (colInfo).type = RANGE_TYPE_VAR_HASH; (colInfo).info = ha;} while (0) -#define FILTER_PUSH_CTX(colInfo, ctx) do { (colInfo).type = RANGE_TYPE_MR_CTX; (colInfo).info = ctx;} while (0) - -#define FILTER_COPY_IDX(dst, src, n) do { *(dst) = taosMemoryMalloc(sizeof(uint32_t) * n); memcpy(*(dst), src, sizeof(uint32_t) * n);} while (0) - -#define FILTER_ADD_CTX_TO_GRES(gres, idx, ctx) do { if ((gres)->colCtxs == NULL) { (gres)->colCtxs = taosArrayInit(gres->colNum, sizeof(SFilterColCtx)); } SFilterColCtx cCtx = {idx, ctx}; taosArrayPush((gres)->colCtxs, &cCtx); } while (0) - - -#define FILTER_ALL_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_ALL) +#define FILTER_PUSH_UNIT(colInfo, u) \ + do { \ + (colInfo).type = RANGE_TYPE_UNIT; \ + (colInfo).dataType = FILTER_UNIT_DATA_TYPE(u); \ + taosArrayPush((SArray *)((colInfo).info), &u); \ + } while (0) +#define FILTER_PUSH_VAR_HASH(colInfo, ha) \ + do { \ + (colInfo).type = RANGE_TYPE_VAR_HASH; \ + (colInfo).info = ha; \ + } while (0) +#define FILTER_PUSH_CTX(colInfo, ctx) \ + do { \ + (colInfo).type = RANGE_TYPE_MR_CTX; \ + (colInfo).info = ctx; \ + } while (0) + +#define FILTER_COPY_IDX(dst, src, n) \ + do { \ + *(dst) = taosMemoryMalloc(sizeof(uint32_t) * n); \ + memcpy(*(dst), src, sizeof(uint32_t) * n); \ + } while (0) + +#define FILTER_ADD_CTX_TO_GRES(gres, idx, ctx) \ + do { \ + if ((gres)->colCtxs == NULL) { \ + (gres)->colCtxs = taosArrayInit(gres->colNum, sizeof(SFilterColCtx)); \ + } \ + SFilterColCtx cCtx = {idx, ctx}; \ + taosArrayPush((gres)->colCtxs, &cCtx); \ + } while (0) + +#define FILTER_ALL_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_ALL) #define FILTER_EMPTY_RES(i) FILTER_GET_FLAG((i)->status, FI_STATUS_EMPTY) -extern bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right); +extern bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right); extern __compar_fn_t filterGetCompFunc(int32_t type, int32_t optr); extern __compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr); diff --git a/source/libs/scalar/inc/sclInt.h b/source/libs/scalar/inc/sclInt.h index 15e9026ddbc2eea8ad4e066519dd4bbea9767b7e..d3f29c0e49f38954d4856e826595d17bdb426b9d 100644 --- a/source/libs/scalar/inc/sclInt.h +++ b/source/libs/scalar/inc/sclInt.h @@ -18,9 +18,9 @@ #ifdef __cplusplus extern "C" { #endif +#include "query.h" #include "tcommon.h" #include "thash.h" -#include "query.h" typedef struct SOperatorValueType { int32_t opResType; @@ -29,46 +29,77 @@ typedef struct SOperatorValueType { } SOperatorValueType; typedef struct SScalarCtx { - int32_t code; - bool dual; - SArray *pBlockList; /* element is SSDataBlock* */ - SHashObj *pRes; /* element is SScalarParam */ - void *param; // additional parameter (meta actually) for acquire value such as tbname/tags values + int32_t code; + bool dual; + SArray* pBlockList; /* element is SSDataBlock* */ + SHashObj* pRes; /* element is SScalarParam */ + void* param; // additional parameter (meta actually) for acquire value such as tbname/tags values SOperatorValueType type; } SScalarCtx; - #define SCL_DATA_TYPE_DUMMY_HASH 9000 -#define SCL_DEFAULT_OP_NUM 10 +#define SCL_DEFAULT_OP_NUM 10 -#define SCL_IS_CONST_NODE(_node) ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type)) +#define SCL_IS_CONST_NODE(_node) \ + ((NULL == (_node)) || (QUERY_NODE_VALUE == (_node)->type) || (QUERY_NODE_NODE_LIST == (_node)->type)) #define SCL_IS_CONST_CALC(_ctx) (NULL == (_ctx)->pBlockList) -//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0)) -#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode *)_node)->node.resType.type)) +//#define SCL_IS_NULL_VALUE_NODE(_node) ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode +//*)_node)->node.resType.type) && (((SValueNode *)_node)->placeholderNo <= 0)) +#define SCL_IS_NULL_VALUE_NODE(_node) \ + ((QUERY_NODE_VALUE == nodeType(_node)) && (TSDB_DATA_TYPE_NULL == ((SValueNode*)_node)->node.resType.type)) #define SCL_IS_COMPARISON_OPERATOR(_opType) ((_opType) >= OP_TYPE_GREATER_THAN && (_opType) < OP_TYPE_IS_NOT_UNKNOWN) -#define SCL_DOWNGRADE_DATETYPE(_type) ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT) -#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) (IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && ((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL)) +#define SCL_DOWNGRADE_DATETYPE(_type) \ + ((_type) == TSDB_DATA_TYPE_BIGINT || TSDB_DATA_TYPE_DOUBLE == (_type) || (_type) == TSDB_DATA_TYPE_UBIGINT) +#define SCL_NO_NEED_CONVERT_COMPARISION(_ltype, _rtype, _optr) \ + (IS_NUMERIC_TYPE(_ltype) && IS_NUMERIC_TYPE(_rtype) && \ + ((_optr) >= OP_TYPE_GREATER_THAN && (_optr) <= OP_TYPE_NOT_EQUAL)) -#define sclFatal(...) qFatal(__VA_ARGS__) -#define sclError(...) qError(__VA_ARGS__) -#define sclWarn(...) qWarn(__VA_ARGS__) -#define sclInfo(...) qInfo(__VA_ARGS__) -#define sclDebug(...) qDebug(__VA_ARGS__) -#define sclTrace(...) qTrace(__VA_ARGS__) +#define sclFatal(...) qFatal(__VA_ARGS__) +#define sclError(...) qError(__VA_ARGS__) +#define sclWarn(...) qWarn(__VA_ARGS__) +#define sclInfo(...) qInfo(__VA_ARGS__) +#define sclDebug(...) qDebug(__VA_ARGS__) +#define sclTrace(...) qTrace(__VA_ARGS__) -#define SCL_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) -#define SCL_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) -#define SCL_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) +#define SCL_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + return _code; \ + } \ + } while (0) +#define SCL_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + terrno = _code; \ + } \ + return _code; \ + } while (0) +#define SCL_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + terrno = code; \ + goto _return; \ + } \ + } while (0) -int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow); +int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow); int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam); int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode); -#define GET_PARAM_TYPE(_c) ((_c)->columnData ? (_c)->columnData->info.type : (_c)->hashValueType) -#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes) -#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision) +#define GET_PARAM_TYPE(_c) ((_c)->columnData ? (_c)->columnData->info.type : (_c)->hashValueType) +#define GET_PARAM_BYTES(_c) ((_c)->columnData->info.bytes) +#define GET_PARAM_PRECISON(_c) ((_c)->columnData->info.precision) -void sclFreeParam(SScalarParam *param); +void sclFreeParam(SScalarParam* param); +void doVectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, + int32_t _ord, int32_t optr); +void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, + int32_t _ord, int32_t optr); +void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr); #ifdef __cplusplus } diff --git a/source/libs/scalar/inc/sclvector.h b/source/libs/scalar/inc/sclvector.h index a1bf1ce1ef7fa899ccea3b40485925c5b519a97a..e633b3922359f00647a792d247454b38599badea 100644 --- a/source/libs/scalar/inc/sclvector.h +++ b/source/libs/scalar/inc/sclvector.h @@ -20,6 +20,15 @@ extern "C" { #endif +typedef struct SSclVectorConvCtx { + const SScalarParam* pIn; + SScalarParam* pOut; + int32_t startIndex; + int32_t endIndex; + int16_t inType; + int16_t outType; +} SSclVectorConvCtx; + typedef double (*_getDoubleValue_fn_t)(void *src, int32_t index); static FORCE_INLINE double getVectorDoubleValue_TINYINT(void *src, int32_t index) { @@ -94,12 +103,12 @@ static FORCE_INLINE _getDoubleValue_fn_t getVectorDoubleValueFn(int32_t srcType) return p; } -typedef void (*_bufConverteFunc)(char *buf, SScalarParam* pOut, int32_t outType, int32_t* overflow); -typedef void (*_bin_scalar_fn_t)(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *output, int32_t order); +typedef void (*_bufConverteFunc)(char *buf, SScalarParam *pOut, int32_t outType, int32_t *overflow); +typedef void (*_bin_scalar_fn_t)(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *output, int32_t order); _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binOperator); #ifdef __cplusplus } #endif -#endif /*_TD_COMMON_BIN_SCALAR_OPERATOR_H_*/ +#endif /*_TD_COMMON_BIN_SCALAR_OPERATOR_H_*/ diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index dbb5214415624c4215e2bfe33a7ed5aa3fd74729..81ee173648209c1f490e9e7778ea55c3f063cdf0 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -12,44 +12,44 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#include "os.h" #include +#include "os.h" #include "thash.h" //#include "queryLog.h" #include "filter.h" #include "filterInt.h" +#include "functionMgt.h" #include "sclInt.h" #include "tcompare.h" #include "tdatablock.h" #include "ttime.h" -#include "functionMgt.h" -bool filterRangeCompGi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompGi(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { int32_t result = cfunc(maxv, minr); return result >= 0; } -bool filterRangeCompGe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompGe(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { int32_t result = cfunc(maxv, minr); return result > 0; } -bool filterRangeCompLi (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompLi(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { int32_t result = cfunc(minv, maxr); return result <= 0; } -bool filterRangeCompLe (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompLe(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { int32_t result = cfunc(minv, maxr); return result < 0; } -bool filterRangeCompii (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompii(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { return cfunc(maxv, minr) >= 0 && cfunc(minv, maxr) <= 0; } -bool filterRangeCompee (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompee(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { return cfunc(maxv, minr) > 0 && cfunc(minv, maxr) < 0; } -bool filterRangeCompei (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompei(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { return cfunc(maxv, minr) > 0 && cfunc(minv, maxr) <= 0; } -bool filterRangeCompie (const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { +bool filterRangeCompie(const void *minv, const void *maxv, const void *minr, const void *maxr, __compar_fn_t cfunc) { return cfunc(maxv, minr) >= 0 && cfunc(minv, maxr) < 0; } @@ -85,9 +85,8 @@ rangeCompFunc filterGetRangeCompFunc(char sflag, char eflag) { return filterRangeCompii; } -rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRangeCompie, filterRangeCompii, filterRangeCompGe, - filterRangeCompGi, filterRangeCompLe, filterRangeCompLi}; - +rangeCompFunc gRangeCompare[] = {filterRangeCompee, filterRangeCompei, filterRangeCompie, filterRangeCompii, + filterRangeCompGe, filterRangeCompGi, filterRangeCompLe, filterRangeCompLi}; int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { if (optr2) { @@ -108,100 +107,91 @@ int8_t filterGetRangeCompFuncFromOptrs(uint8_t optr, uint8_t optr2) { return 3; } else { switch (optr) { - case OP_TYPE_GREATER_THAN: - return 4; - case OP_TYPE_GREATER_EQUAL: - return 5; - case OP_TYPE_LOWER_THAN: - return 6; - case OP_TYPE_LOWER_EQUAL: - return 7; - default: - break; + case OP_TYPE_GREATER_THAN: + return 4; + case OP_TYPE_GREATER_EQUAL: + return 5; + case OP_TYPE_LOWER_THAN: + return 6; + case OP_TYPE_LOWER_EQUAL: + return 7; + default: + break; } } return -1; } -__compar_fn_t gDataCompare[] = {compareInt32Val, compareInt8Val, compareInt16Val, compareInt64Val, compareFloatVal, - compareDoubleVal, compareLenPrefixedStr, compareStrPatternMatch, compareChkInString, compareWStrPatternMatch, - compareLenPrefixedWStr, compareUint8Val, compareUint16Val, compareUint32Val, compareUint64Val, - setChkInBytes1, setChkInBytes2, setChkInBytes4, setChkInBytes8, compareStrRegexCompMatch, - compareStrRegexCompNMatch, setChkNotInBytes1, setChkNotInBytes2, setChkNotInBytes4, setChkNotInBytes8, - compareChkNotInString, compareStrPatternNotMatch, compareWStrPatternNotMatch -}; - -__compar_fn_t gInt8SignCompare[] = { - compareInt8Val, compareInt8Int16, compareInt8Int32, compareInt8Int64, compareInt8Float, compareInt8Double -}; -__compar_fn_t gInt8UsignCompare[] = { - compareInt8Uint8, compareInt8Uint16, compareInt8Uint32, compareInt8Uint64 -}; - -__compar_fn_t gInt16SignCompare[] = { - compareInt16Int8, compareInt16Val, compareInt16Int32, compareInt16Int64, compareInt16Float, compareInt16Double -}; -__compar_fn_t gInt16UsignCompare[] = { - compareInt16Uint8, compareInt16Uint16, compareInt16Uint32, compareInt16Uint64 -}; - -__compar_fn_t gInt32SignCompare[] = { - compareInt32Int8, compareInt32Int16, compareInt32Val, compareInt32Int64, compareInt32Float, compareInt32Double -}; -__compar_fn_t gInt32UsignCompare[] = { - compareInt32Uint8, compareInt32Uint16, compareInt32Uint32, compareInt32Uint64 -}; - -__compar_fn_t gInt64SignCompare[] = { - compareInt64Int8, compareInt64Int16, compareInt64Int32, compareInt64Val, compareInt64Float, compareInt64Double -}; -__compar_fn_t gInt64UsignCompare[] = { - compareInt64Uint8, compareInt64Uint16, compareInt64Uint32, compareInt64Uint64 -}; - -__compar_fn_t gFloatSignCompare[] = { - compareFloatInt8, compareFloatInt16, compareFloatInt32, compareFloatInt64, compareFloatVal, compareFloatDouble -}; -__compar_fn_t gFloatUsignCompare[] = { - compareFloatUint8, compareFloatUint16, compareFloatUint32, compareFloatUint64 -}; - -__compar_fn_t gDoubleSignCompare[] = { - compareDoubleInt8, compareDoubleInt16, compareDoubleInt32, compareDoubleInt64, compareDoubleFloat, compareDoubleVal -}; -__compar_fn_t gDoubleUsignCompare[] = { - compareDoubleUint8, compareDoubleUint16, compareDoubleUint32, compareDoubleUint64 -}; - -__compar_fn_t gUint8SignCompare[] = { - compareUint8Int8, compareUint8Int16, compareUint8Int32, compareUint8Int64, compareUint8Float, compareUint8Double -}; -__compar_fn_t gUint8UsignCompare[] = { - compareUint8Val, compareUint8Uint16, compareUint8Uint32, compareUint8Uint64 -}; - -__compar_fn_t gUint16SignCompare[] = { - compareUint16Int8, compareUint16Int16, compareUint16Int32, compareUint16Int64, compareUint16Float, compareUint16Double -}; -__compar_fn_t gUint16UsignCompare[] = { - compareUint16Uint8, compareUint16Val, compareUint16Uint32, compareUint16Uint64 -}; - -__compar_fn_t gUint32SignCompare[] = { - compareUint32Int8, compareUint32Int16, compareUint32Int32, compareUint32Int64, compareUint32Float, compareUint32Double -}; -__compar_fn_t gUint32UsignCompare[] = { - compareUint32Uint8, compareUint32Uint16, compareUint32Val, compareUint32Uint64 -}; - -__compar_fn_t gUint64SignCompare[] = { - compareUint64Int8, compareUint64Int16, compareUint64Int32, compareUint64Int64, compareUint64Float, compareUint64Double -}; -__compar_fn_t gUint64UsignCompare[] = { - compareUint64Uint8, compareUint64Uint16, compareUint64Uint32, compareUint64Val -}; - +__compar_fn_t gDataCompare[] = {compareInt32Val, + compareInt8Val, + compareInt16Val, + compareInt64Val, + compareFloatVal, + compareDoubleVal, + compareLenPrefixedStr, + compareStrPatternMatch, + compareChkInString, + compareWStrPatternMatch, + compareLenPrefixedWStr, + compareUint8Val, + compareUint16Val, + compareUint32Val, + compareUint64Val, + setChkInBytes1, + setChkInBytes2, + setChkInBytes4, + setChkInBytes8, + compareStrRegexCompMatch, + compareStrRegexCompNMatch, + setChkNotInBytes1, + setChkNotInBytes2, + setChkNotInBytes4, + setChkNotInBytes8, + compareChkNotInString, + compareStrPatternNotMatch, + compareWStrPatternNotMatch}; + +__compar_fn_t gInt8SignCompare[] = {compareInt8Val, compareInt8Int16, compareInt8Int32, + compareInt8Int64, compareInt8Float, compareInt8Double}; +__compar_fn_t gInt8UsignCompare[] = {compareInt8Uint8, compareInt8Uint16, compareInt8Uint32, compareInt8Uint64}; + +__compar_fn_t gInt16SignCompare[] = {compareInt16Int8, compareInt16Val, compareInt16Int32, + compareInt16Int64, compareInt16Float, compareInt16Double}; +__compar_fn_t gInt16UsignCompare[] = {compareInt16Uint8, compareInt16Uint16, compareInt16Uint32, compareInt16Uint64}; + +__compar_fn_t gInt32SignCompare[] = {compareInt32Int8, compareInt32Int16, compareInt32Val, + compareInt32Int64, compareInt32Float, compareInt32Double}; +__compar_fn_t gInt32UsignCompare[] = {compareInt32Uint8, compareInt32Uint16, compareInt32Uint32, compareInt32Uint64}; + +__compar_fn_t gInt64SignCompare[] = {compareInt64Int8, compareInt64Int16, compareInt64Int32, + compareInt64Val, compareInt64Float, compareInt64Double}; +__compar_fn_t gInt64UsignCompare[] = {compareInt64Uint8, compareInt64Uint16, compareInt64Uint32, compareInt64Uint64}; + +__compar_fn_t gFloatSignCompare[] = {compareFloatInt8, compareFloatInt16, compareFloatInt32, + compareFloatInt64, compareFloatVal, compareFloatDouble}; +__compar_fn_t gFloatUsignCompare[] = {compareFloatUint8, compareFloatUint16, compareFloatUint32, compareFloatUint64}; + +__compar_fn_t gDoubleSignCompare[] = {compareDoubleInt8, compareDoubleInt16, compareDoubleInt32, + compareDoubleInt64, compareDoubleFloat, compareDoubleVal}; +__compar_fn_t gDoubleUsignCompare[] = {compareDoubleUint8, compareDoubleUint16, compareDoubleUint32, + compareDoubleUint64}; + +__compar_fn_t gUint8SignCompare[] = {compareUint8Int8, compareUint8Int16, compareUint8Int32, + compareUint8Int64, compareUint8Float, compareUint8Double}; +__compar_fn_t gUint8UsignCompare[] = {compareUint8Val, compareUint8Uint16, compareUint8Uint32, compareUint8Uint64}; + +__compar_fn_t gUint16SignCompare[] = {compareUint16Int8, compareUint16Int16, compareUint16Int32, + compareUint16Int64, compareUint16Float, compareUint16Double}; +__compar_fn_t gUint16UsignCompare[] = {compareUint16Uint8, compareUint16Val, compareUint16Uint32, compareUint16Uint64}; + +__compar_fn_t gUint32SignCompare[] = {compareUint32Int8, compareUint32Int16, compareUint32Int32, + compareUint32Int64, compareUint32Float, compareUint32Double}; +__compar_fn_t gUint32UsignCompare[] = {compareUint32Uint8, compareUint32Uint16, compareUint32Val, compareUint32Uint64}; + +__compar_fn_t gUint64SignCompare[] = {compareUint64Int8, compareUint64Int16, compareUint64Int32, + compareUint64Int64, compareUint64Float, compareUint64Double}; +__compar_fn_t gUint64UsignCompare[] = {compareUint64Uint8, compareUint64Uint16, compareUint64Uint32, compareUint64Val}; int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { int8_t comparFn = 0; @@ -262,16 +252,27 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { return 28; } - switch (type) { case TSDB_DATA_TYPE_BOOL: - case TSDB_DATA_TYPE_TINYINT: comparFn = 1; break; - case TSDB_DATA_TYPE_SMALLINT: comparFn = 2; break; - case TSDB_DATA_TYPE_INT: comparFn = 0; break; + case TSDB_DATA_TYPE_TINYINT: + comparFn = 1; + break; + case TSDB_DATA_TYPE_SMALLINT: + comparFn = 2; + break; + case TSDB_DATA_TYPE_INT: + comparFn = 0; + break; case TSDB_DATA_TYPE_BIGINT: - case TSDB_DATA_TYPE_TIMESTAMP: comparFn = 3; break; - case TSDB_DATA_TYPE_FLOAT: comparFn = 4; break; - case TSDB_DATA_TYPE_DOUBLE: comparFn = 5; break; + case TSDB_DATA_TYPE_TIMESTAMP: + comparFn = 3; + break; + case TSDB_DATA_TYPE_FLOAT: + comparFn = 4; + break; + case TSDB_DATA_TYPE_DOUBLE: + comparFn = 5; + break; case TSDB_DATA_TYPE_BINARY: { if (optr == OP_TYPE_MATCH) { comparFn = 19; @@ -311,10 +312,18 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { break; } - case TSDB_DATA_TYPE_UTINYINT: comparFn = 11; break; - case TSDB_DATA_TYPE_USMALLINT: comparFn = 12;break; - case TSDB_DATA_TYPE_UINT: comparFn = 13;break; - case TSDB_DATA_TYPE_UBIGINT: comparFn = 14;break; + case TSDB_DATA_TYPE_UTINYINT: + comparFn = 11; + break; + case TSDB_DATA_TYPE_USMALLINT: + comparFn = 12; + break; + case TSDB_DATA_TYPE_UINT: + comparFn = 13; + break; + case TSDB_DATA_TYPE_UBIGINT: + comparFn = 14; + break; default: comparFn = 0; @@ -324,9 +333,7 @@ int8_t filterGetCompFuncIdx(int32_t type, int32_t optr) { return comparFn; } -__compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { - return gDataCompare[filterGetCompFuncIdx(type, optr)]; -} +__compar_fn_t filterGetCompFunc(int32_t type, int32_t optr) { return gDataCompare[filterGetCompFuncIdx(type, optr)]; } __compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) { switch (lType) { @@ -417,7 +424,7 @@ __compar_fn_t filterGetCompFuncEx(int32_t lType, int32_t rType, int32_t optr) { } static FORCE_INLINE int32_t filterCompareGroupCtx(const void *pLeft, const void *pRight) { - SFilterGroupCtx *left = *((SFilterGroupCtx**)pLeft), *right = *((SFilterGroupCtx**)pRight); + SFilterGroupCtx *left = *((SFilterGroupCtx **)pLeft), *right = *((SFilterGroupCtx **)pRight); if (left->colNum > right->colNum) return 1; if (left->colNum < right->colNum) return -1; return 0; @@ -437,7 +444,7 @@ int32_t filterInitUnitsFields(SFilterInfo *info) { return TSDB_CODE_SUCCESS; } -static FORCE_INLINE SFilterRangeNode* filterNewRange(SFilterRangeCtx *ctx, SFilterRange* ra) { +static FORCE_INLINE SFilterRangeNode *filterNewRange(SFilterRangeCtx *ctx, SFilterRange *ra) { SFilterRangeNode *r = NULL; if (ctx->rf) { @@ -454,8 +461,9 @@ static FORCE_INLINE SFilterRangeNode* filterNewRange(SFilterRangeCtx *ctx, SFilt return r; } -void* filterInitRangeCtx(int32_t type, int32_t options) { - if (type > TSDB_DATA_TYPE_UBIGINT || type < TSDB_DATA_TYPE_BOOL || type == TSDB_DATA_TYPE_BINARY || type == TSDB_DATA_TYPE_NCHAR) { +void *filterInitRangeCtx(int32_t type, int32_t options) { + if (type > TSDB_DATA_TYPE_UBIGINT || type < TSDB_DATA_TYPE_BOOL || type == TSDB_DATA_TYPE_BINARY || + type == TSDB_DATA_TYPE_NCHAR) { qError("not supported range type:%d", type); return NULL; } @@ -469,7 +477,6 @@ void* filterInitRangeCtx(int32_t type, int32_t options) { return ctx; } - int32_t filterResetRangeCtx(SFilterRangeCtx *ctx) { ctx->status = 0; @@ -504,7 +511,6 @@ int32_t filterReuseRangeCtx(SFilterRangeCtx *ctx, int32_t type, int32_t options) return TSDB_CODE_SUCCESS; } - int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull) { if (!FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { int32_t sr = cur->pCompareFunc(&ra->s, getDataMin(cur->type)); @@ -520,7 +526,6 @@ int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull } } - if (FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL) && FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)) { *notNull = true; } else { @@ -530,7 +535,7 @@ int32_t filterConvertRange(SFilterRangeCtx *cur, SFilterRange *ra, bool *notNull return TSDB_CODE_SUCCESS; } -int32_t filterAddRangeOptr(void* h, uint8_t raOptr, int32_t optr, bool *empty, bool *all) { +int32_t filterAddRangeOptr(void *h, uint8_t raOptr, int32_t optr, bool *empty, bool *all) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; if (optr == LOGIC_COND_TYPE_AND) { @@ -550,15 +555,13 @@ int32_t filterAddRangeOptr(void* h, uint8_t raOptr, int32_t optr, bool *empty, b return TSDB_CODE_SUCCESS; } - - -int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { +int32_t filterAddRangeImpl(void *h, SFilterRange *ra, int32_t optr) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; if (ctx->rs == NULL) { - if ((FILTER_GET_FLAG(ctx->status, MR_ST_START) == 0) - || (FILTER_GET_FLAG(ctx->status, MR_ST_ALL) && (optr == LOGIC_COND_TYPE_AND)) - || ((!FILTER_GET_FLAG(ctx->status, MR_ST_ALL)) && (optr == LOGIC_COND_TYPE_OR))) { + if ((FILTER_GET_FLAG(ctx->status, MR_ST_START) == 0) || + (FILTER_GET_FLAG(ctx->status, MR_ST_ALL) && (optr == LOGIC_COND_TYPE_AND)) || + ((!FILTER_GET_FLAG(ctx->status, MR_ST_ALL)) && (optr == LOGIC_COND_TYPE_OR))) { APPEND_RANGE(ctx, ctx->rs, ra); FILTER_SET_FLAG(ctx->status, MR_ST_START); } @@ -568,7 +571,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { SFilterRangeNode *r = ctx->rs; SFilterRangeNode *rn = NULL; - int32_t cr = 0; + int32_t cr = 0; if (optr == LOGIC_COND_TYPE_AND) { while (r != NULL) { @@ -605,8 +608,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { return TSDB_CODE_SUCCESS; } - - //TSDB_RELATION_OR + // TSDB_RELATION_OR bool smerged = false; bool emerged = false; @@ -625,7 +627,7 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { cr = ctx->pCompareFunc(&ra->s, &r->ra.e); if (FILTER_GREATER(cr, ra->sflag, r->ra.eflag)) { if (r->next) { - r= r->next; + r = r->next; continue; } @@ -692,23 +694,22 @@ int32_t filterAddRangeImpl(void* h, SFilterRange* ra, int32_t optr) { return TSDB_CODE_SUCCESS; } -int32_t filterAddRange(void* h, SFilterRange* ra, int32_t optr) { +int32_t filterAddRange(void *h, SFilterRange *ra, int32_t optr) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; if (FILTER_GET_FLAG(ra->sflag, RANGE_FLG_NULL)) { SIMPLE_COPY_VALUES(&ra->s, getDataMin(ctx->type)); - //FILTER_CLR_FLAG(ra->sflag, RA_NULL); + // FILTER_CLR_FLAG(ra->sflag, RA_NULL); } if (FILTER_GET_FLAG(ra->eflag, RANGE_FLG_NULL)) { SIMPLE_COPY_VALUES(&ra->e, getDataMax(ctx->type)); - //FILTER_CLR_FLAG(ra->eflag, RA_NULL); + // FILTER_CLR_FLAG(ra->eflag, RA_NULL); } return filterAddRangeImpl(h, ra, optr); } - int32_t filterAddRangeCtx(void *dst, void *src, int32_t optr) { SFilterRangeCtx *dctx = (SFilterRangeCtx *)dst; SFilterRangeCtx *sctx = (SFilterRangeCtx *)src; @@ -755,9 +756,7 @@ int32_t filterCopyRangeCtx(void *dst, void *src) { return TSDB_CODE_SUCCESS; } - - -int32_t filterFinishRange(void* h) { +int32_t filterFinishRange(void *h) { SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; if (FILTER_GET_FLAG(ctx->status, MR_ST_FIN)) { @@ -789,7 +788,7 @@ int32_t filterFinishRange(void* h) { return TSDB_CODE_SUCCESS; } -int32_t filterGetRangeNum(void* h, int32_t* num) { +int32_t filterGetRangeNum(void *h, int32_t *num) { filterFinishRange(h); SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; @@ -806,13 +805,12 @@ int32_t filterGetRangeNum(void* h, int32_t* num) { return TSDB_CODE_SUCCESS; } - -int32_t filterGetRangeRes(void* h, SFilterRange *ra) { +int32_t filterGetRangeRes(void *h, SFilterRange *ra) { filterFinishRange(h); - SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; - uint32_t num = 0; - SFilterRangeNode* r = ctx->rs; + SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; + uint32_t num = 0; + SFilterRangeNode *r = ctx->rs; while (r) { if (num) { @@ -834,11 +832,10 @@ int32_t filterGetRangeRes(void* h, SFilterRange *ra) { return TSDB_CODE_SUCCESS; } - int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr, bool *empty, bool *all) { SFilterRangeCtx *src = (SFilterRangeCtx *)sctx; - if (src->isnull){ + if (src->isnull) { filterAddRangeOptr(ctx, OP_TYPE_IS_NULL, optr, empty, all); if (FILTER_GET_FLAG(ctx->status, MR_ST_ALL)) { *all = true; @@ -867,14 +864,12 @@ int32_t filterSourceRangeFromCtx(SFilterRangeCtx *ctx, void *sctx, int32_t optr, return TSDB_CODE_SUCCESS; } - - -int32_t filterFreeRangeCtx(void* h) { +int32_t filterFreeRangeCtx(void *h) { if (h == NULL) { return TSDB_CODE_SUCCESS; } - SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; + SFilterRangeCtx *ctx = (SFilterRangeCtx *)h; SFilterRangeNode *r = ctx->rs; SFilterRangeNode *rn = NULL; @@ -896,8 +891,7 @@ int32_t filterFreeRangeCtx(void* h) { return TSDB_CODE_SUCCESS; } - -int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray* group) { +int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray *group) { SFilterGroup gp = {0}; gp.unitNum = gp1->unitNum + gp2->unitNum; @@ -912,8 +906,7 @@ int32_t filterDetachCnfGroup(SFilterGroup *gp1, SFilterGroup *gp2, SArray* group return TSDB_CODE_SUCCESS; } - -int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { +int32_t filterDetachCnfGroups(SArray *group, SArray *left, SArray *right) { int32_t leftSize = (int32_t)taosArrayGetSize(left); int32_t rightSize = (int32_t)taosArrayGetSize(right); @@ -950,11 +943,10 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { } } - return TSDB_CODE_SUCCESS; } -int32_t filterGetFiledByDesc(SFilterFields* fields, int32_t type, void *v) { +int32_t filterGetFiledByDesc(SFilterFields *fields, int32_t type, void *v) { for (uint32_t i = 0; i < fields->num; ++i) { if (nodesEqualNode(fields->fields[i].desc, v)) { return i; @@ -964,7 +956,6 @@ int32_t filterGetFiledByDesc(SFilterFields* fields, int32_t type, void *v) { return -1; } - int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t dataLen) { if (type == FLD_TYPE_VALUE) { if (info->pctx.valHash == false) { @@ -981,10 +972,11 @@ int32_t filterGetFiledByData(SFilterInfo *info, int32_t type, void *v, int32_t d return -1; } -// In the params, we should use void *data instead of void **data, there is no need to use taosMemoryFreeClear(*data) to set *data = 0 -// Besides, fields data value is a pointer, so dataLen should be POINTER_BYTES for better. -int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, SFilterFieldId *fid, int32_t dataLen, bool freeIfExists) { - int32_t idx = -1; +// In the params, we should use void *data instead of void **data, there is no need to use taosMemoryFreeClear(*data) to +// set *data = 0 Besides, fields data value is a pointer, so dataLen should be POINTER_BYTES for better. +int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, SFilterFieldId *fid, int32_t dataLen, + bool freeIfExists) { + int32_t idx = -1; uint32_t *num; num = &info->fields[type].num; @@ -1001,7 +993,8 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, idx = *num; if (idx >= info->fields[type].size) { info->fields[type].size += FILTER_DEFAULT_FIELD_SIZE; - info->fields[type].fields = taosMemoryRealloc(info->fields[type].fields, info->fields[type].size * sizeof(SFilterField)); + info->fields[type].fields = + taosMemoryRealloc(info->fields[type].fields, info->fields[type].size * sizeof(SFilterField)); } info->fields[type].fields[idx].flag = type; @@ -1016,7 +1009,8 @@ int32_t filterAddField(SFilterInfo *info, void *desc, void **data, int32_t type, if (data && (*data) && dataLen > 0 && FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { if (info->pctx.valHash == NULL) { - info->pctx.valHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_VALUE_SIZE, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); + info->pctx.valHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_VALUE_SIZE, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, false); } taosHashPut(info->pctx.valHash, *data, dataLen, &idx, sizeof(idx)); @@ -1041,19 +1035,19 @@ static FORCE_INLINE int32_t filterAddColFieldFromField(SFilterInfo *info, SFilte return TSDB_CODE_SUCCESS; } - int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *fid) { if (node == NULL) { fltError("empty node"); FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } - if (nodeType(node) != QUERY_NODE_COLUMN && nodeType(node) != QUERY_NODE_VALUE && nodeType(node) != QUERY_NODE_NODE_LIST) { + if (nodeType(node) != QUERY_NODE_COLUMN && nodeType(node) != QUERY_NODE_VALUE && + nodeType(node) != QUERY_NODE_NODE_LIST) { FLT_ERR_RET(TSDB_CODE_QRY_APP_ERROR); } int32_t type; - void *v; + void *v; if (nodeType(node) == QUERY_NODE_COLUMN) { type = FLD_TYPE_COLUMN; @@ -1068,10 +1062,12 @@ int32_t filterAddFieldFromNode(SFilterInfo *info, SNode *node, SFilterFieldId *f return TSDB_CODE_SUCCESS; } -int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint8_t optr2, SFilterFieldId *right2, uint32_t *uidx) { +int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint8_t optr2, + SFilterFieldId *right2, uint32_t *uidx) { if (FILTER_GET_FLAG(info->options, FLT_OPTION_NEED_UNIQE)) { if (info->pctx.unitHash == NULL) { - info->pctx.unitHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_UNIT_SIZE, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, false); + info->pctx.unitHash = taosHashInit(FILTER_DEFAULT_GROUP_SIZE * FILTER_DEFAULT_UNIT_SIZE, + taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, false); } else { char v[14] = {0}; FLT_PACKAGE_UNIT_HASH_KEY(&v, optr, optr2, left->idx, (right ? right->idx : -1), (right2 ? right2->idx : -1)); @@ -1101,7 +1097,7 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, if (right2) { u->right2 = *right2; } - + if (u->right.type == FLD_TYPE_VALUE) { SFilterField *val = FILTER_UNIT_RIGHT_FIELD(info, u); assert(FILTER_GET_FLAG(val->flag, FLD_TYPE_VALUE)); @@ -1132,7 +1128,6 @@ int32_t filterAddUnitImpl(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, return TSDB_CODE_SUCCESS; } - int32_t filterAddUnit(SFilterInfo *info, uint8_t optr, SFilterFieldId *left, SFilterFieldId *right, uint32_t *uidx) { return filterAddUnitImpl(info, optr, left, right, 0, NULL, uidx); } @@ -1148,19 +1143,19 @@ int32_t filterAddUnitToGroup(SFilterGroup *group, uint32_t unitIdx) { return TSDB_CODE_SUCCESS; } -int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { +int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode *tree, SArray *group) { SOperatorNode *node = (SOperatorNode *)tree; - int32_t ret = TSDB_CODE_SUCCESS; + int32_t ret = TSDB_CODE_SUCCESS; SFilterFieldId left = {0}, right = {0}; filterAddFieldFromNode(info, node->pLeft, &left); - uint8_t type = FILTER_GET_COL_FIELD_TYPE(FILTER_GET_FIELD(info, left)); - int32_t len = 0; + uint8_t type = FILTER_GET_COL_FIELD_TYPE(FILTER_GET_FIELD(info, left)); + int32_t len = 0; uint32_t uidx = 0; - int32_t code = 0; + int32_t code = 0; if (node->opType == OP_TYPE_IN && (!IS_VAR_DATA_TYPE(type))) { SNodeListNode *listNode = (SNodeListNode *)node->pRight; - SListCell *cell = listNode->pNodeList->pHead; + SListCell *cell = listNode->pNodeList->pHead; SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; out.columnData->info.type = type; @@ -1170,9 +1165,9 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { SValueNode *valueNode = (SValueNode *)cell->pNode; if (valueNode->node.resType.type != type) { int32_t overflow = 0; - code = doConvertDataType(valueNode, &out, &overflow); + code = sclConvertValueToSclParam(valueNode, &out, &overflow); if (code) { - // fltError("convert from %d to %d failed", in.type, out.type); + // fltError("convert from %d to %d failed", in.type, out.type); FLT_ERR_RET(code); } @@ -1183,7 +1178,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { len = tDataTypes[type].bytes; - filterAddField(info, NULL, (void**) &out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); + filterAddField(info, NULL, (void **)&out.columnData->pData, FLD_TYPE_VALUE, &right, len, true); out.columnData->pData = NULL; } else { void *data = taosMemoryCalloc(1, tDataTypes[type].bytes); @@ -1191,7 +1186,7 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { FLT_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } memcpy(data, nodesGetValueFromNode(valueNode), tDataTypes[type].bytes); - filterAddField(info, NULL, (void**) &data, FLD_TYPE_VALUE, &right, len, true); + filterAddField(info, NULL, (void **)&data, FLD_TYPE_VALUE, &right, len, true); } filterAddUnit(info, OP_TYPE_EQUAL, &left, &right, &uidx); @@ -1217,11 +1212,10 @@ int32_t fltAddGroupUnitFromNode(SFilterInfo *info, SNode* tree, SArray *group) { return TSDB_CODE_SUCCESS; } - -int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u, uint32_t *uidx) { +int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit *u, uint32_t *uidx) { SFilterFieldId left, right, *pright = &right; - int32_t type = FILTER_UNIT_DATA_TYPE(u); - uint16_t flag = 0; + int32_t type = FILTER_UNIT_DATA_TYPE(u); + uint16_t flag = 0; filterAddField(dst, FILTER_UNIT_COL_DESC(src, u), NULL, FLD_TYPE_COLUMN, &left, 0, false); SFilterField *t = FILTER_UNIT_LEFT_FIELD(src, u); @@ -1229,8 +1223,9 @@ int32_t filterAddUnitFromUnit(SFilterInfo *dst, SFilterInfo *src, SFilterUnit* u if (u->right.type == FLD_TYPE_VALUE) { void *data = FILTER_UNIT_VAL_DATA(src, u); if (IS_VAR_DATA_TYPE(type)) { - if (FILTER_UNIT_OPTR(u) == OP_TYPE_IN) { - filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right. + if (FILTER_UNIT_OPTR(u) == OP_TYPE_IN) { + filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, POINTER_BYTES, + false); // POINTER_BYTES should be sizeof(SHashObj), but POINTER_BYTES is also right. t = FILTER_GET_FIELD(dst, right); FILTER_SET_FLAG(t->flag, FLD_DATA_IS_HASH); @@ -1259,9 +1254,10 @@ int32_t filterAddUnitRight(SFilterInfo *info, uint8_t optr, SFilterFieldId *righ return TSDB_CODE_SUCCESS; } -int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRangeCtx *ctx, uint32_t cidx, SFilterGroup *g, int32_t optr, SArray *res) { +int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRangeCtx *ctx, uint32_t cidx, + SFilterGroup *g, int32_t optr, SArray *res) { SFilterFieldId left, right, right2; - uint32_t uidx = 0; + uint32_t uidx = 0; SFilterField *col = FILTER_GET_COL_FIELD(src, cidx); @@ -1312,8 +1308,10 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan SIMPLE_COPY_VALUES(data2, &ra->e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - filterAddUnitImpl(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, - FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, &uidx); + filterAddUnitImpl( + dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, + &right, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, + &uidx); filterAddUnitToGroup(g, uidx); return TSDB_CODE_SUCCESS; } @@ -1323,7 +1321,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->s); filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); + filterAddUnit(dst, FILTER_GET_FLAG(ra->sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, + &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } @@ -1331,7 +1330,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &ra->e); filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); + filterAddUnit(dst, FILTER_GET_FLAG(ra->eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, + &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } @@ -1371,7 +1371,7 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan while (r) { memset(g, 0, sizeof(*g)); - if ((!FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) &&(!FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_NULL))) { + if ((!FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) && (!FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_NULL))) { __compar_fn_t func = getComparFunc(type, 0); if (func(&r->ra.s, &r->ra.e) == 0) { void *data = taosMemoryMalloc(sizeof(int64_t)); @@ -1387,8 +1387,10 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan SIMPLE_COPY_VALUES(data2, &r->ra.e); filterAddField(dst, NULL, &data2, FLD_TYPE_VALUE, &right2, tDataTypes[type].bytes, true); - filterAddUnitImpl(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, - FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, &uidx); + filterAddUnitImpl( + dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, + &right, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &right2, + &uidx); filterAddUnitToGroup(g, uidx); } @@ -1403,7 +1405,8 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.s); filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, &left, &right, &uidx); + filterAddUnit(dst, FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_GREATER_THAN : OP_TYPE_GREATER_EQUAL, + &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } @@ -1411,11 +1414,12 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan void *data = taosMemoryMalloc(sizeof(int64_t)); SIMPLE_COPY_VALUES(data, &r->ra.e); filterAddField(dst, NULL, &data, FLD_TYPE_VALUE, &right, tDataTypes[type].bytes, true); - filterAddUnit(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, &left, &right, &uidx); + filterAddUnit(dst, FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? OP_TYPE_LOWER_THAN : OP_TYPE_LOWER_EQUAL, + &left, &right, &uidx); filterAddUnitToGroup(g, uidx); } - assert (g->unitNum > 0); + assert(g->unitNum > 0); taosArrayPush(res, g); @@ -1427,24 +1431,22 @@ int32_t filterAddGroupUnitFromCtx(SFilterInfo *dst, SFilterInfo *src, SFilterRan return TSDB_CODE_SUCCESS; } - static void filterFreeGroup(void *pItem) { if (pItem == NULL) { return; } - SFilterGroup* p = (SFilterGroup*) pItem; + SFilterGroup *p = (SFilterGroup *)pItem; taosMemoryFreeClear(p->unitIdxs); taosMemoryFreeClear(p->unitFlags); } - -EDealRes fltTreeToGroup(SNode* pNode, void* pContext) { - int32_t code = TSDB_CODE_SUCCESS; - SArray* preGroup = NULL; - SArray* newGroup = NULL; - SArray* resGroup = NULL; - ENodeType nType = nodeType(pNode); +EDealRes fltTreeToGroup(SNode *pNode, void *pContext) { + int32_t code = TSDB_CODE_SUCCESS; + SArray *preGroup = NULL; + SArray *newGroup = NULL; + SArray *resGroup = NULL; + ENodeType nType = nodeType(pNode); SFltBuildGroupCtx *ctx = (SFltBuildGroupCtx *)pContext; if (QUERY_NODE_LOGIC_CONDITION == nodeType(pNode)) { @@ -1527,24 +1529,24 @@ int32_t fltConverToStr(char *str, int type, void *buf, int32_t bufSize, int32_t break; case TSDB_DATA_TYPE_BOOL: - n = sprintf(str, (*(int8_t*)buf) ? "true" : "false"); + n = sprintf(str, (*(int8_t *)buf) ? "true" : "false"); break; case TSDB_DATA_TYPE_TINYINT: - n = sprintf(str, "%d", *(int8_t*)buf); + n = sprintf(str, "%d", *(int8_t *)buf); break; case TSDB_DATA_TYPE_SMALLINT: - n = sprintf(str, "%d", *(int16_t*)buf); + n = sprintf(str, "%d", *(int16_t *)buf); break; case TSDB_DATA_TYPE_INT: - n = sprintf(str, "%d", *(int32_t*)buf); + n = sprintf(str, "%d", *(int32_t *)buf); break; case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: - n = sprintf(str, "%" PRId64, *(int64_t*)buf); + n = sprintf(str, "%" PRId64, *(int64_t *)buf); break; case TSDB_DATA_TYPE_FLOAT: @@ -1558,7 +1560,7 @@ int32_t fltConverToStr(char *str, int type, void *buf, int32_t bufSize, int32_t case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: if (bufSize < 0) { -// tscError("invalid buf size"); + // tscError("invalid buf size"); return TSDB_CODE_TSC_INVALID_VALUE; } @@ -1569,23 +1571,23 @@ int32_t fltConverToStr(char *str, int type, void *buf, int32_t bufSize, int32_t break; case TSDB_DATA_TYPE_UTINYINT: - n = sprintf(str, "%d", *(uint8_t*)buf); + n = sprintf(str, "%d", *(uint8_t *)buf); break; case TSDB_DATA_TYPE_USMALLINT: - n = sprintf(str, "%d", *(uint16_t*)buf); + n = sprintf(str, "%d", *(uint16_t *)buf); break; case TSDB_DATA_TYPE_UINT: - n = sprintf(str, "%u", *(uint32_t*)buf); + n = sprintf(str, "%u", *(uint32_t *)buf); break; case TSDB_DATA_TYPE_UBIGINT: - n = sprintf(str, "%" PRIu64, *(uint64_t*)buf); + n = sprintf(str, "%" PRIu64, *(uint64_t *)buf); break; default: -// tscError("unsupported type:%d", type); + // tscError("unsupported type:%d", type); return TSDB_CODE_TSC_INVALID_VALUE; } @@ -1606,7 +1608,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) qDebug("COLUMN Field Num:%u", info->fields[FLD_TYPE_COLUMN].num); for (uint32_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { SFilterField *field = &info->fields[FLD_TYPE_COLUMN].fields[i]; - SColumnNode *refNode = (SColumnNode *)field->desc; + SColumnNode *refNode = (SColumnNode *)field->desc; qDebug("COL%d => [%d][%d]", i, refNode->dataBlockId, refNode->slotId); } @@ -1615,39 +1617,41 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) SFilterField *field = &info->fields[FLD_TYPE_VALUE].fields[i]; if (field->desc) { if (QUERY_NODE_VALUE != nodeType(field->desc)) { - qDebug("VAL%d => [type:not value node][val:NIL]", i); //TODO + qDebug("VAL%d => [type:not value node][val:NIL]", i); // TODO continue; } SValueNode *var = (SValueNode *)field->desc; - SDataType *dType = &var->node.resType; + SDataType *dType = &var->node.resType; if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { - qDebug("VAL%d => [type:TS][val:[%" PRIi64"] - [%" PRId64 "]]", i, *(int64_t *)field->data, *(((int64_t *)field->data) + 1)); + qDebug("VAL%d => [type:TS][val:[%" PRIi64 "] - [%" PRId64 "]]", i, *(int64_t *)field->data, + *(((int64_t *)field->data) + 1)); } else { - qDebug("VAL%d => [type:%d][val:%" PRIx64"]", i, dType->type, var->datum.i); //TODO + qDebug("VAL%d => [type:%d][val:%" PRIx64 "]", i, dType->type, var->datum.i); // TODO } } else if (field->data) { - qDebug("VAL%d => [type:NIL][val:NIL]", i); //TODO + qDebug("VAL%d => [type:NIL][val:NIL]", i); // TODO } } qDebug("UNIT Num:%u", info->unitNum); for (uint32_t i = 0; i < info->unitNum; ++i) { SFilterUnit *unit = &info->units[i]; - int32_t type = FILTER_UNIT_DATA_TYPE(unit); - int32_t len = 0; - int32_t tlen = 0; - char str[512] = {0}; + int32_t type = FILTER_UNIT_DATA_TYPE(unit); + int32_t len = 0; + int32_t tlen = 0; + char str[512] = {0}; SFilterField *left = FILTER_UNIT_LEFT_FIELD(info, unit); - SColumnNode *refNode = (SColumnNode *)left->desc; - if (unit->compare.optr >= 0 && unit->compare.optr <= OP_TYPE_JSON_CONTAINS){ - len = sprintf(str, "UNIT[%d] => [%d][%d] %s [", i, refNode->dataBlockId, refNode->slotId, operatorTypeStr(unit->compare.optr)); + SColumnNode *refNode = (SColumnNode *)left->desc; + if (unit->compare.optr >= 0 && unit->compare.optr <= OP_TYPE_JSON_CONTAINS) { + len = sprintf(str, "UNIT[%d] => [%d][%d] %s [", i, refNode->dataBlockId, refNode->slotId, + operatorTypeStr(unit->compare.optr)); } if (unit->right.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { SFilterField *right = FILTER_UNIT_RIGHT_FIELD(info, unit); - char *data = right->data; + char *data = right->data; if (IS_VAR_DATA_TYPE(type)) { tlen = varDataLen(data); data += VARSTR_HEADER_SIZE; @@ -1660,13 +1664,14 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) if (unit->compare.optr2) { strcat(str, " && "); - if (unit->compare.optr2 >= 0 && unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS){ - sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, operatorTypeStr(unit->compare.optr2)); + if (unit->compare.optr2 >= 0 && unit->compare.optr2 <= OP_TYPE_JSON_CONTAINS) { + sprintf(str + strlen(str), "[%d][%d] %s [", refNode->dataBlockId, refNode->slotId, + operatorTypeStr(unit->compare.optr2)); } if (unit->right2.type == FLD_TYPE_VALUE && FILTER_UNIT_OPTR(unit) != OP_TYPE_IN) { SFilterField *right = FILTER_UNIT_RIGHT2_FIELD(info, unit); - char *data = right->data; + char *data = right->data; if (IS_VAR_DATA_TYPE(type)) { tlen = varDataLen(data); data += VARSTR_HEADER_SIZE; @@ -1678,7 +1683,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) strcat(str, "]"); } - qDebug("%s", str); //TODO + qDebug("%s", str); // TODO } qDebug("GROUP Num:%u", info->groupNum); @@ -1700,26 +1705,27 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) qDebug("RANGE Num:%u", info->colRangeNum); for (uint32_t i = 0; i < info->colRangeNum; ++i) { SFilterRangeCtx *ctx = info->colRange[i]; - qDebug("Column ID[%d] RANGE: isnull[%d],notnull[%d],range[%d]", ctx->colId, ctx->isnull, ctx->notnull, ctx->isrange); + qDebug("Column ID[%d] RANGE: isnull[%d],notnull[%d],range[%d]", ctx->colId, ctx->isnull, ctx->notnull, + ctx->isrange); if (ctx->isrange) { SFilterRangeNode *r = ctx->rs; while (r) { - char str[256] = {0}; + char str[256] = {0}; int32_t tlen = 0; if (FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_NULL)) { - strcat(str,"(NULL)"); + strcat(str, "(NULL)"); } else { - FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? strcat(str,"(") : strcat(str,"["); + FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? strcat(str, "(") : strcat(str, "["); fltConverToStr(str + strlen(str), ctx->type, &r->ra.s, tlen > 32 ? 32 : tlen, &tlen); - FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? strcat(str,")") : strcat(str,"]"); + FILTER_GET_FLAG(r->ra.sflag, RANGE_FLG_EXCLUDE) ? strcat(str, ")") : strcat(str, "]"); } strcat(str, " - "); if (FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_NULL)) { strcat(str, "(NULL)"); } else { - FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? strcat(str,"(") : strcat(str,"["); + FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? strcat(str, "(") : strcat(str, "["); fltConverToStr(str + strlen(str), ctx->type, &r->ra.e, tlen > 32 ? 32 : tlen, &tlen); - FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? strcat(str,")") : strcat(str,"]"); + FILTER_GET_FLAG(r->ra.eflag, RANGE_FLG_EXCLUDE) ? strcat(str, ")") : strcat(str, "]"); } qDebug("range: %s", str); @@ -1739,7 +1745,7 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) } else if (FILTER_GET_FLAG(info->blkFlag, FI_STATUS_BLK_EMPTY)) { qDebug("Flag:%s", "EMPTY"); return; - } else if (FILTER_GET_FLAG(info->blkFlag, FI_STATUS_BLK_ACTIVE)){ + } else if (FILTER_GET_FLAG(info->blkFlag, FI_STATUS_BLK_ACTIVE)) { qDebug("Flag:%s", "ACTIVE"); } @@ -1756,36 +1762,35 @@ void filterDumpInfoToString(SFilterInfo *info, const char *msg, int32_t options) } void filterFreeColInfo(void *data) { - SFilterColInfo* info = (SFilterColInfo *)data; + SFilterColInfo *info = (SFilterColInfo *)data; if (info->info == NULL) { return; } if (info->type == RANGE_TYPE_VAR_HASH) { - //TODO + // TODO } else if (info->type == RANGE_TYPE_MR_CTX) { filterFreeRangeCtx(info->info); } else if (info->type == RANGE_TYPE_UNIT) { taosArrayDestroy((SArray *)info->info); } - //NO NEED TO FREE UNIT + // NO NEED TO FREE UNIT info->type = 0; info->info = NULL; } void filterFreeColCtx(void *data) { - SFilterColCtx* ctx = (SFilterColCtx *)data; + SFilterColCtx *ctx = (SFilterColCtx *)data; if (ctx->ctx) { filterFreeRangeCtx(ctx->ctx); } } - -void filterFreeGroupCtx(SFilterGroupCtx* gRes) { +void filterFreeGroupCtx(SFilterGroupCtx *gRes) { if (gRes == NULL) { return; } @@ -1807,7 +1812,7 @@ void filterFreeGroupCtx(SFilterGroupCtx* gRes) { taosMemoryFreeClear(gRes); } -void filterFreeField(SFilterField* field, int32_t type) { +void filterFreeField(SFilterField *field, int32_t type) { if (field == NULL) { return; } @@ -1868,7 +1873,7 @@ void filterFreeInfo(SFilterInfo *info) { } } -int32_t filterHandleValueExtInfo(SFilterUnit* unit, char extInfo) { +int32_t filterHandleValueExtInfo(SFilterUnit *unit, char extInfo) { assert(extInfo > 0 || extInfo < 0); uint8_t optr = FILTER_UNIT_OPTR(unit); @@ -1891,24 +1896,23 @@ int32_t filterHandleValueExtInfo(SFilterUnit* unit, char extInfo) { return TSDB_CODE_SUCCESS; } - int32_t fltInitValFieldData(SFilterInfo *info) { for (uint32_t i = 0; i < info->unitNum; ++i) { - SFilterUnit* unit = &info->units[i]; + SFilterUnit *unit = &info->units[i]; if (unit->right.type != FLD_TYPE_VALUE) { assert(unit->compare.optr == FILTER_DUMMY_EMPTY_OPTR || scalarGetOperatorParamNum(unit->compare.optr) == 1); continue; } - SFilterField* right = FILTER_UNIT_RIGHT_FIELD(info, unit); + SFilterField *right = FILTER_UNIT_RIGHT_FIELD(info, unit); assert(FILTER_GET_FLAG(right->flag, FLD_TYPE_VALUE)); - uint32_t type = FILTER_UNIT_DATA_TYPE(unit); - int8_t precision = FILTER_UNIT_DATA_PRECISION(unit); - SFilterField* fi = right; + uint32_t type = FILTER_UNIT_DATA_TYPE(unit); + int8_t precision = FILTER_UNIT_DATA_PRECISION(unit); + SFilterField *fi = right; - SValueNode* var = (SValueNode *)fi->desc; + SValueNode *var = (SValueNode *)fi->desc; if (var == NULL) { assert(fi->data != NULL); continue; @@ -1927,27 +1931,29 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } SDataType *dType = &var->node.resType; - size_t bytes = 0; + size_t bytes = 0; if (type == TSDB_DATA_TYPE_BINARY) { - size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; + size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes + : MAX_NUM_STR_SIZE; bytes = len + 1 + VARSTR_HEADER_SIZE; fi->data = taosMemoryCalloc(1, bytes); } else if (type == TSDB_DATA_TYPE_NCHAR) { - size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes : MAX_NUM_STR_SIZE; + size_t len = (dType->type == TSDB_DATA_TYPE_BINARY || dType->type == TSDB_DATA_TYPE_NCHAR) ? dType->bytes + : MAX_NUM_STR_SIZE; bytes = (len + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; fi->data = taosMemoryCalloc(1, bytes); } else { - if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { //TIME RANGE -/* - fi->data = taosMemoryCalloc(dType->bytes, tDataTypes[type].bytes); - for (int32_t a = 0; a < dType->bytes; ++a) { - int64_t *v = taosArrayGet(var->arr, a); - assignVal((char *)fi->data + a * tDataTypes[type].bytes, (char *)v, 0, type); - } -*/ + if (dType->type == TSDB_DATA_TYPE_VALUE_ARRAY) { // TIME RANGE + /* + fi->data = taosMemoryCalloc(dType->bytes, tDataTypes[type].bytes); + for (int32_t a = 0; a < dType->bytes; ++a) { + int64_t *v = taosArrayGet(var->arr, a); + assignVal((char *)fi->data + a * tDataTypes[type].bytes, (char *)v, 0, type); + } + */ continue; } else { fi->data = taosMemoryCalloc(1, sizeof(int64_t)); @@ -1967,7 +1973,7 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } // todo refactor the convert - int32_t code = doConvertDataType(var, &out, NULL); + int32_t code = sclConvertValueToSclParam(var, &out, NULL); if (code != TSDB_CODE_SUCCESS) { qError("convert value to type[%d] failed", type); return TSDB_CODE_TSC_INVALID_OPERATION; @@ -1979,11 +1985,10 @@ int32_t fltInitValFieldData(SFilterInfo *info) { } // match/nmatch for nchar type need convert from ucs4 to mbs - if(type == TSDB_DATA_TYPE_NCHAR && - (unit->compare.optr == OP_TYPE_MATCH || unit->compare.optr == OP_TYPE_NMATCH)){ - char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; - int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); - if (len < 0){ + if (type == TSDB_DATA_TYPE_NCHAR && (unit->compare.optr == OP_TYPE_MATCH || unit->compare.optr == OP_TYPE_NMATCH)) { + char newValData[TSDB_REGEX_STRING_DEFAULT_LEN * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE] = {0}; + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(fi->data), varDataLen(fi->data), varDataVal(newValData)); + if (len < 0) { qError("filterInitValFieldData taosUcs4ToMbs error 1"); return TSDB_CODE_QRY_APP_ERROR; } @@ -1995,7 +2000,6 @@ int32_t fltInitValFieldData(SFilterInfo *info) { return TSDB_CODE_SUCCESS; } - bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) { int32_t ret = func(left, right); @@ -2044,13 +2048,12 @@ bool filterDoCompare(__compar_fn_t func, uint8_t optr, void *left, void *right) return true; } - -int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit* u, SFilterRangeCtx *ctx, int32_t optr) { - int32_t type = FILTER_UNIT_DATA_TYPE(u); - uint8_t uoptr = FILTER_UNIT_OPTR(u); - void *val = FILTER_UNIT_VAL_DATA(info, u); +int32_t filterAddUnitRange(SFilterInfo *info, SFilterUnit *u, SFilterRangeCtx *ctx, int32_t optr) { + int32_t type = FILTER_UNIT_DATA_TYPE(u); + uint8_t uoptr = FILTER_UNIT_OPTR(u); + void *val = FILTER_UNIT_VAL_DATA(info, u); SFilterRange ra = {0}; - int64_t tmp = 0; + int64_t tmp = 0; switch (uoptr) { case OP_TYPE_GREATER_THAN: @@ -2125,16 +2128,15 @@ _return: return TSDB_CODE_SUCCESS; } - -int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colIdx, bool *empty) { - SArray* colArray = (SArray *)gRes->colInfo[colIdx].info; - int32_t size = (int32_t)taosArrayGetSize(colArray); - int32_t type = gRes->colInfo[colIdx].dataType; - SFilterRangeCtx* ctx = filterInitRangeCtx(type, 0); +int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx *gRes, uint32_t colIdx, bool *empty) { + SArray *colArray = (SArray *)gRes->colInfo[colIdx].info; + int32_t size = (int32_t)taosArrayGetSize(colArray); + int32_t type = gRes->colInfo[colIdx].dataType; + SFilterRangeCtx *ctx = filterInitRangeCtx(type, 0); for (uint32_t i = 0; i < size; ++i) { - SFilterUnit* u = taosArrayGetP(colArray, i); - uint8_t optr = FILTER_UNIT_OPTR(u); + SFilterUnit *u = taosArrayGetP(colArray, i); + uint8_t optr = FILTER_UNIT_OPTR(u); filterAddRangeOptr(ctx, optr, LOGIC_COND_TYPE_AND, empty, NULL); FLT_CHK_JMP(*empty); @@ -2143,7 +2145,7 @@ int32_t filterMergeUnits(SFilterInfo *info, SFilterGroupCtx* gRes, uint32_t colI filterAddUnitRange(info, u, ctx, LOGIC_COND_TYPE_AND); FLT_CHK_JMP(MR_EMPTY_RES(ctx)); } - if(FILTER_UNIT_OPTR(u) == OP_TYPE_EQUAL && !FILTER_NO_MERGE_DATA_TYPE(FILTER_UNIT_DATA_TYPE(u))){ + if (FILTER_UNIT_OPTR(u) == OP_TYPE_EQUAL && !FILTER_NO_MERGE_DATA_TYPE(FILTER_UNIT_DATA_TYPE(u))) { gRes->colInfo[colIdx].optr = OP_TYPE_EQUAL; SIMPLE_COPY_VALUES(&gRes->colInfo[colIdx].value, FILTER_UNIT_VAL_DATA(info, u)); } @@ -2164,15 +2166,14 @@ _return: return TSDB_CODE_SUCCESS; } - -int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t* gResNum) { - bool empty = false; +int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gResNum) { + bool empty = false; uint32_t *colIdx = taosMemoryMalloc(info->fields[FLD_TYPE_COLUMN].num * sizeof(uint32_t)); - uint32_t colIdxi = 0; - uint32_t gResIdx = 0; + uint32_t colIdxi = 0; + uint32_t gResIdx = 0; for (uint32_t i = 0; i < info->groupNum; ++i) { - SFilterGroup* g = info->groups + i; + SFilterGroup *g = info->groups + i; gRes[gResIdx] = taosMemoryCalloc(1, sizeof(SFilterGroupCtx)); gRes[gResIdx]->colInfo = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(SFilterColInfo)); @@ -2180,8 +2181,8 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t empty = false; for (uint32_t j = 0; j < g->unitNum; ++j) { - SFilterUnit* u = FILTER_GROUP_UNIT(info, g, j); - uint32_t cidx = FILTER_UNIT_COL_IDX(u); + SFilterUnit *u = FILTER_GROUP_UNIT(info, g, j); + uint32_t cidx = FILTER_UNIT_COL_IDX(u); if (gRes[gResIdx]->colInfo[cidx].info == NULL) { gRes[gResIdx]->colInfo[cidx].info = (SArray *)taosArrayInit(4, POINTER_BYTES); @@ -2238,33 +2239,33 @@ int32_t filterMergeGroupUnits(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t return TSDB_CODE_SUCCESS; } -bool filterIsSameUnits(SFilterColInfo* pCol1, SFilterColInfo* pCol2) { +bool filterIsSameUnits(SFilterColInfo *pCol1, SFilterColInfo *pCol2) { if (pCol1->type != pCol2->type) { return false; } if (RANGE_TYPE_MR_CTX == pCol1->type) { - SFilterRangeCtx* pCtx1 = (SFilterRangeCtx*)pCol1->info; - SFilterRangeCtx* pCtx2 = (SFilterRangeCtx*)pCol2->info; + SFilterRangeCtx *pCtx1 = (SFilterRangeCtx *)pCol1->info; + SFilterRangeCtx *pCtx2 = (SFilterRangeCtx *)pCol2->info; if ((pCtx1->isnull != pCtx2->isnull) || (pCtx1->notnull != pCtx2->notnull) || (pCtx1->isrange != pCtx2->isrange)) { return false; } - - SFilterRangeNode* pNode1 = pCtx1->rs; - SFilterRangeNode* pNode2 = pCtx2->rs; + SFilterRangeNode *pNode1 = pCtx1->rs; + SFilterRangeNode *pNode2 = pCtx2->rs; while (true) { if (NULL == pNode1 && NULL == pNode2) { break; } - + if (NULL == pNode1 || NULL == pNode2) { return false; } - if (pNode1->ra.s != pNode2->ra.s || pNode1->ra.e != pNode2->ra.e || pNode1->ra.sflag != pNode2->ra.sflag || pNode1->ra.eflag != pNode2->ra.eflag) { + if (pNode1->ra.s != pNode2->ra.s || pNode1->ra.e != pNode2->ra.e || pNode1->ra.sflag != pNode2->ra.sflag || + pNode1->ra.eflag != pNode2->ra.eflag) { return false; } @@ -2276,9 +2277,9 @@ bool filterIsSameUnits(SFilterColInfo* pCol1, SFilterColInfo* pCol2) { return true; } -void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool *conflict) { +void filterCheckColConflict(SFilterGroupCtx *gRes1, SFilterGroupCtx *gRes2, bool *conflict) { uint32_t idx1 = 0, idx2 = 0, m = 0, n = 0; - bool equal = false; + bool equal = false; for (; m < gRes1->colNum; ++m) { idx1 = gRes1->colIdx[m]; @@ -2308,8 +2309,8 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool // for long in operation if (gRes1->colInfo[idx1].optr == OP_TYPE_EQUAL && gRes2->colInfo[idx2].optr == OP_TYPE_EQUAL) { - SFilterRangeCtx* ctx = gRes1->colInfo[idx1].info; - if (ctx->pCompareFunc(&gRes1->colInfo[idx1].value, &gRes2->colInfo[idx2].value)){ + SFilterRangeCtx *ctx = gRes1->colInfo[idx1].info; + if (ctx->pCompareFunc(&gRes1->colInfo[idx1].value, &gRes2->colInfo[idx2].value)) { *conflict = true; return; } @@ -2330,10 +2331,10 @@ void filterCheckColConflict(SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool return; } - -int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32_t optr, uint32_t cidx, SFilterGroupCtx* gRes1, SFilterGroupCtx* gRes2, bool *empty, bool *all) { +int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32_t optr, uint32_t cidx, + SFilterGroupCtx *gRes1, SFilterGroupCtx *gRes2, bool *empty, bool *all) { SFilterField *fi = FILTER_GET_COL_FIELD(info, cidx); - int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); + int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); if ((*ctx) == NULL) { *ctx = filterInitRangeCtx(type, 0); @@ -2350,8 +2351,7 @@ int32_t filterMergeTwoGroupsImpl(SFilterInfo *info, SFilterRangeCtx **ctx, int32 return TSDB_CODE_SUCCESS; } - -int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilterGroupCtx** gRes2, bool *all) { +int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx **gRes1, SFilterGroupCtx **gRes2, bool *all) { bool conflict = false; filterCheckColConflict(*gRes1, *gRes2, &conflict); @@ -2361,13 +2361,13 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter FILTER_SET_FLAG(info->status, FI_STATUS_REWRITE); - uint32_t idx1 = 0, idx2 = 0, m = 0, n = 0; - bool numEqual = (*gRes1)->colNum == (*gRes2)->colNum; - bool equal = false; - uint32_t equal1 = 0, equal2 = 0, merNum = 0; + uint32_t idx1 = 0, idx2 = 0, m = 0, n = 0; + bool numEqual = (*gRes1)->colNum == (*gRes2)->colNum; + bool equal = false; + uint32_t equal1 = 0, equal2 = 0, merNum = 0; SFilterRangeCtx *ctx = NULL; - SFilterColCtx colCtx = {0}; - SArray* colCtxs = taosArrayInit((*gRes2)->colNum, sizeof(SFilterColCtx)); + SFilterColCtx colCtx = {0}; + SArray *colCtxs = taosArrayInit((*gRes2)->colNum, sizeof(SFilterColCtx)); for (; m < (*gRes1)->colNum; ++m) { idx1 = (*gRes1)->colIdx[m]; @@ -2432,14 +2432,14 @@ int32_t filterMergeTwoGroups(SFilterInfo *info, SFilterGroupCtx** gRes1, SFilter assert(merNum > 0); SFilterColInfo *colInfo = NULL; - assert (merNum == equal1 || merNum == equal2); + assert(merNum == equal1 || merNum == equal2); filterFreeGroupCtx(*gRes2); *gRes2 = NULL; assert(colCtxs && taosArrayGetSize(colCtxs) > 0); - int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs); + int32_t ctxSize = (int32_t)taosArrayGetSize(colCtxs); SFilterColCtx *pctx = NULL; for (int32_t i = 0; i < ctxSize; ++i) { @@ -2469,18 +2469,17 @@ _return: return TSDB_CODE_SUCCESS; } - -int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gResNum) { +int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t *gResNum) { if (*gResNum <= 1) { return TSDB_CODE_SUCCESS; } taosSort(gRes, *gResNum, POINTER_BYTES, filterCompareGroupCtx); - int32_t pEnd = 0, cStart = 0, cEnd = 0; + int32_t pEnd = 0, cStart = 0, cEnd = 0; uint32_t pColNum = 0, cColNum = 0; - int32_t movedNum = 0; - bool all = false; + int32_t movedNum = 0; + bool all = false; cColNum = gRes[0]->colNum; @@ -2502,7 +2501,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR if (gRes[n] == NULL) { if (n < ((*gResNum) - 1)) { - memmove(&gRes[n], &gRes[n+1], (*gResNum-n-1) * POINTER_BYTES); + memmove(&gRes[n], &gRes[n + 1], (*gResNum - n - 1) * POINTER_BYTES); } --cEnd; @@ -2523,7 +2522,7 @@ int32_t filterMergeGroups(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t *gR if (gRes[n] == NULL) { if (n < ((*gResNum) - 1)) { - memmove(&gRes[n], &gRes[n+1], (*gResNum-n-1) * POINTER_BYTES); + memmove(&gRes[n], &gRes[n + 1], (*gResNum - n - 1) * POINTER_BYTES); } --cEnd; @@ -2556,7 +2555,7 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray* group) { +int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray *group) { size_t groupSize = taosArrayGetSize(group); info->groupNum = (uint32_t)groupSize; @@ -2574,7 +2573,7 @@ int32_t filterConvertGroupFromArray(SFilterInfo *info, SArray* group) { return TSDB_CODE_SUCCESS; } -int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum) { +int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum) { if (!FILTER_GET_FLAG(info->status, FI_STATUS_REWRITE)) { qDebug("no need rewrite"); return TSDB_CODE_SUCCESS; @@ -2584,11 +2583,11 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum FILTER_SET_FLAG(oinfo.status, FI_STATUS_CLONED); - SArray* group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); + SArray *group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); SFilterGroupCtx *res = NULL; - SFilterColInfo *colInfo = NULL; - int32_t optr = 0; - uint32_t uidx = 0; + SFilterColInfo *colInfo = NULL; + int32_t optr = 0; + uint32_t uidx = 0; memset(info, 0, sizeof(*info)); @@ -2615,7 +2614,7 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum int32_t usize = (int32_t)taosArrayGetSize((SArray *)colInfo->info); for (int32_t n = 0; n < usize; ++n) { - SFilterUnit* u = taosArrayGetP((SArray *)colInfo->info, n); + SFilterUnit *u = taosArrayGetP((SArray *)colInfo->info, n); filterAddUnitFromUnit(info, &oinfo, u, &uidx); filterAddUnitToGroup(&ng, uidx); @@ -2643,15 +2642,15 @@ int32_t filterRewrite(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum return TSDB_CODE_SUCCESS; } -int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_t gResNum) { - uint32_t *idxs = NULL; - uint32_t colNum = 0; +int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx **gRes, int32_t gResNum) { + uint32_t *idxs = NULL; + uint32_t colNum = 0; SFilterGroupCtx *res = NULL; - uint32_t *idxNum = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxNum)); + uint32_t *idxNum = taosMemoryCalloc(info->fields[FLD_TYPE_COLUMN].num, sizeof(*idxNum)); for (int32_t i = 0; i < gResNum; ++i) { for (uint32_t m = 0; m < gRes[i]->colNum; ++m) { - SFilterColInfo *colInfo = &gRes[i]->colInfo[gRes[i]->colIdx[m]]; + SFilterColInfo *colInfo = &gRes[i]->colInfo[gRes[i]->colIdx[m]]; if (FILTER_NO_MERGE_DATA_TYPE(colInfo->dataType)) { continue; } @@ -2691,10 +2690,10 @@ int32_t filterGenerateColRange(SFilterInfo *info, SFilterGroupCtx** gRes, int32_ assert(res->colIdx[n] == idxs[m]); - SFilterColInfo * colInfo = &res->colInfo[res->colIdx[n]]; + SFilterColInfo *colInfo = &res->colInfo[res->colIdx[n]]; if (info->colRange[m] == NULL) { info->colRange[m] = filterInitRangeCtx(colInfo->dataType, 0); - SFilterField* fi = FILTER_GET_COL_FIELD(info, res->colIdx[n]); + SFilterField *fi = FILTER_GET_COL_FIELD(info, res->colIdx[n]); info->colRange[m]->colId = FILTER_GET_COL_FIELD_ID(fi); } @@ -2732,7 +2731,7 @@ _return: int32_t filterPostProcessRange(SFilterInfo *info) { for (uint32_t i = 0; i < info->colRangeNum; ++i) { - SFilterRangeCtx* ctx = info->colRange[i]; + SFilterRangeCtx *ctx = info->colRange[i]; SFilterRangeNode *r = ctx->rs; while (r) { r->rc.func = filterGetRangeCompFunc(r->ra.sflag, r->ra.eflag); @@ -2743,7 +2742,6 @@ int32_t filterPostProcessRange(SFilterInfo *info) { return TSDB_CODE_SUCCESS; } - int32_t filterGenerateComInfo(SFilterInfo *info) { info->cunits = taosMemoryMalloc(info->unitNum * sizeof(*info->cunits)); info->blkUnitRes = taosMemoryMalloc(sizeof(*info->blkUnitRes) * info->unitNum); @@ -2787,21 +2785,20 @@ int32_t filterUpdateComUnits(SFilterInfo *info) { return TSDB_CODE_SUCCESS; } - int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows) { int32_t rmUnit = 0; memset(info->blkUnitRes, 0, sizeof(*info->blkUnitRes) * info->unitNum); for (uint32_t k = 0; k < info->unitNum; ++k) { - int32_t index = -1; + int32_t index = -1; SFilterComUnit *cunit = &info->cunits[k]; if (FILTER_NO_MERGE_DATA_TYPE(cunit->dataType)) { continue; } - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { if (pDataStatis[i].colId == cunit->colId) { index = i; break; @@ -2838,16 +2835,15 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 } } - if (cunit->optr == OP_TYPE_IS_NULL || cunit->optr == OP_TYPE_IS_NOT_NULL - || cunit->optr == OP_TYPE_IN || cunit->optr == OP_TYPE_LIKE || cunit->optr == OP_TYPE_MATCH - || cunit->optr == OP_TYPE_NOT_EQUAL) { + if (cunit->optr == OP_TYPE_IS_NULL || cunit->optr == OP_TYPE_IS_NOT_NULL || cunit->optr == OP_TYPE_IN || + cunit->optr == OP_TYPE_LIKE || cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NOT_EQUAL) { continue; } - SColumnDataAgg* pDataBlockst = &pDataStatis[index]; - void *minVal, *maxVal; - float minv = 0; - float maxv = 0; + SColumnDataAgg *pDataBlockst = &pDataStatis[index]; + void *minVal, *maxVal; + float minv = 0; + float maxv = 0; if (cunit->dataType == TSDB_DATA_TYPE_FLOAT) { minv = (float)(*(double *)(&pDataBlockst->min)); @@ -2863,8 +2859,10 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 bool minRes = false, maxRes = false; if (cunit->rfunc >= 0) { - minRes = (*gRangeCompare[cunit->rfunc])(minVal, minVal, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); - maxRes = (*gRangeCompare[cunit->rfunc])(maxVal, maxVal, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); + minRes = + (*gRangeCompare[cunit->rfunc])(minVal, minVal, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); + maxRes = + (*gRangeCompare[cunit->rfunc])(maxVal, maxVal, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); if (minRes && maxRes) { info->blkUnitRes[k] = 1; @@ -2903,7 +2901,6 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 rmUnit = 1; } } - } if (rmUnit == 0) { @@ -2915,7 +2912,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 uint32_t *unitNum = info->blkUnits; uint32_t *unitIdx = unitNum + 1; - int32_t all = 0, empty = 0; + int32_t all = 0, empty = 0; for (uint32_t g = 0; g < info->groupNum; ++g) { SFilterGroup *group = &info->groups[g]; @@ -2925,7 +2922,7 @@ int32_t filterRmUnitByRange(SFilterInfo *info, SColumnDataAgg *pDataStatis, int3 empty = 0; // save group idx start pointer - uint32_t * pGroupIdx = unitIdx; + uint32_t *pGroupIdx = unitIdx; for (uint32_t u = 0; u < group->unitNum; ++u) { uint32_t uidx = group->unitIdxs[u]; if (info->blkUnitRes[uidx] == 1) { @@ -2976,15 +2973,16 @@ _return: return TSDB_CODE_SUCCESS; } -bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols) { +bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, + int16_t numOfCols) { SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; - uint32_t *unitIdx = NULL; + bool all = true; + uint32_t *unitIdx = NULL; - int8_t* p = (int8_t*)pRes->pData; + int8_t *p = (int8_t *)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { - //FILTER_UNIT_CLR_F(info); + // FILTER_UNIT_CLR_F(info); unitIdx = info->blkUnits; @@ -2992,30 +2990,31 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoD uint32_t unitNum = *(unitIdx++); for (uint32_t u = 0; u < unitNum; ++u) { SFilterComUnit *cunit = &info->cunits[*(unitIdx + u)]; - void *colData = colDataGetData((SColumnInfoData *)cunit->colData, i); + void *colData = colDataGetData((SColumnInfoData *)cunit->colData, i); - //if (FILTER_UNIT_GET_F(info, uidx)) { - // p[i] = FILTER_UNIT_GET_R(info, uidx); - //} else { - uint8_t optr = cunit->optr; + // if (FILTER_UNIT_GET_F(info, uidx)) { + // p[i] = FILTER_UNIT_GET_R(info, uidx); + // } else { + uint8_t optr = cunit->optr; - if (colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { - p[i] = (optr == OP_TYPE_IS_NULL) ? true : false; + if (colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { + p[i] = (optr == OP_TYPE_IS_NULL) ? true : false; + } else { + if (optr == OP_TYPE_IS_NOT_NULL) { + p[i] = 1; + } else if (optr == OP_TYPE_IS_NULL) { + p[i] = 0; + } else if (cunit->rfunc >= 0) { + p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, + gDataCompare[cunit->func]); } else { - if (optr == OP_TYPE_IS_NOT_NULL) { - p[i] = 1; - } else if (optr == OP_TYPE_IS_NULL) { - p[i] = 0; - } else if (cunit->rfunc >= 0) { - p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); - } else { - p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); - } - - //FILTER_UNIT_SET_R(info, uidx, p[i]); - //FILTER_UNIT_SET_F(info, uidx); + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } + // FILTER_UNIT_SET_R(info, uidx, p[i]); + // FILTER_UNIT_SET_F(info, uidx); + } + if (p[i] == 0) { break; } @@ -3036,9 +3035,8 @@ bool filterExecuteBasedOnStatisImpl(void *pinfo, int32_t numOfRows, SColumnInfoD return all; } - - -int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols, bool* all) { +int32_t filterExecuteBasedOnStatis(SFilterInfo *info, int32_t numOfRows, SColumnInfoData *p, SColumnDataAgg *statis, + int16_t numOfCols, bool *all) { if (statis && numOfRows >= FILTER_RM_UNIT_MIN_ROWS) { info->blkFlag = 0; @@ -3067,20 +3065,22 @@ _return: return TSDB_CODE_SUCCESS; } -static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* numOfQualified) { +static FORCE_INLINE bool filterExecuteImplAll(void *info, int32_t numOfRows, SColumnInfoData *p, SColumnDataAgg *statis, + int16_t numOfCols, int32_t *numOfQualified) { return true; } -static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, SColumnInfoData* p, SColumnDataAgg *statis, int16_t numOfCols, int32_t* numOfQualified) { +static FORCE_INLINE bool filterExecuteImplEmpty(void *info, int32_t numOfRows, SColumnInfoData *p, + SColumnDataAgg *statis, int16_t numOfCols, int32_t *numOfQualified) { return false; } static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, int16_t numOfCols, int32_t *numOfQualified) { SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; + bool all = true; - int8_t* p = (int8_t*)pRes->pData; + int8_t *p = (int8_t *)pRes->pData; if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; @@ -3088,7 +3088,7 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; - void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); + void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); p[i] = ((colData == NULL) || colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); if (p[i] == 0) { @@ -3104,17 +3104,17 @@ static FORCE_INLINE bool filterExecuteImplIsNull(void *pinfo, int32_t numOfRows, static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, int16_t numOfCols, int32_t *numOfQualified) { SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; + bool all = true; if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - int8_t* p = (int8_t*)pRes->pData; + int8_t *p = (int8_t *)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; - void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); + void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); p[i] = ((colData != NULL) && !colDataIsNull((SColumnInfoData *)info->cunits[uidx].colData, 0, i, NULL)); if (p[i] == 0) { @@ -3127,23 +3127,24 @@ static FORCE_INLINE bool filterExecuteImplNotNull(void *pinfo, int32_t numOfRows return all; } -bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, SColumnInfoData* pRes, SColumnDataAgg *statis, int16_t numOfCols, int32_t* numOfQualified) { - SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; - uint16_t dataSize = info->cunits[0].dataSize; +bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, + int16_t numOfCols, int32_t *numOfQualified) { + SFilterInfo *info = (SFilterInfo *)pinfo; + bool all = true; + uint16_t dataSize = info->cunits[0].dataSize; rangeCompFunc rfunc = gRangeCompare[info->cunits[0].rfunc]; - void *valData = info->cunits[0].valData; - void *valData2 = info->cunits[0].valData2; + void *valData = info->cunits[0].valData; + void *valData2 = info->cunits[0].valData2; __compar_fn_t func = gDataCompare[info->cunits[0].func]; if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - int8_t* p = (int8_t*) pRes->pData; + int8_t *p = (int8_t *)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { - SColumnInfoData* pData = info->cunits[0].colData; + SColumnInfoData *pData = info->cunits[0].colData; void *colData = colDataGetData(pData, i); if (colData == NULL || colDataIsNull_s(pData, i)) { @@ -3166,17 +3167,17 @@ bool filterExecuteImplRange(void *pinfo, int32_t numOfRows, SColumnInfoData* pRe bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, int16_t numOfCols, int32_t *numOfQualified) { SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; + bool all = true; if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - int8_t* p = (int8_t*) pRes->pData; + int8_t *p = (int8_t *)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { uint32_t uidx = info->groups[0].unitIdxs[0]; - void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); + void *colData = colDataGetData((SColumnInfoData *)info->cunits[uidx].colData, i); if (colData == NULL || colDataIsNull_s((SColumnInfoData *)info->cunits[uidx].colData, i)) { p[i] = 0; all = false; @@ -3184,18 +3185,21 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes } // match/nmatch for nchar type need convert from ucs4 to mbs - if(info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)){ - char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); - if (len < 0){ + if (info->cunits[uidx].dataType == TSDB_DATA_TYPE_NCHAR && + (info->cunits[uidx].optr == OP_TYPE_MATCH || info->cunits[uidx].optr == OP_TYPE_NMATCH)) { + char *newColData = taosMemoryCalloc(info->cunits[uidx].dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + if (len < 0) { qError("castConvert1 taosUcs4ToMbs error"); - }else{ + } else { varDataSetLen(newColData, len); - p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, info->cunits[uidx].valData); + p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, newColData, + info->cunits[uidx].valData); } taosMemoryFreeClear(newColData); - }else{ - p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, info->cunits[uidx].valData); + } else { + p[i] = filterDoCompare(gDataCompare[info->cunits[uidx].func], info->cunits[uidx].optr, colData, + info->cunits[uidx].valData); } if (p[i] == 0) { @@ -3211,58 +3215,60 @@ bool filterExecuteImplMisc(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes bool filterExecuteImpl(void *pinfo, int32_t numOfRows, SColumnInfoData *pRes, SColumnDataAgg *statis, int16_t numOfCols, int32_t *numOfQualified) { SFilterInfo *info = (SFilterInfo *)pinfo; - bool all = true; + bool all = true; if (filterExecuteBasedOnStatis(info, numOfRows, pRes, statis, numOfCols, &all) == 0) { return all; } - int8_t* p = (int8_t*) pRes->pData; + int8_t *p = (int8_t *)pRes->pData; for (int32_t i = 0; i < numOfRows; ++i) { - //FILTER_UNIT_CLR_F(info); + // FILTER_UNIT_CLR_F(info); for (uint32_t g = 0; g < info->groupNum; ++g) { SFilterGroup *group = &info->groups[g]; for (uint32_t u = 0; u < group->unitNum; ++u) { - uint32_t uidx = group->unitIdxs[u]; + uint32_t uidx = group->unitIdxs[u]; SFilterComUnit *cunit = &info->cunits[uidx]; - void *colData = colDataGetData((SColumnInfoData *)(cunit->colData), i); + void *colData = colDataGetData((SColumnInfoData *)(cunit->colData), i); - //if (FILTER_UNIT_GET_F(info, uidx)) { - // p[i] = FILTER_UNIT_GET_R(info, uidx); - //} else { - uint8_t optr = cunit->optr; + // if (FILTER_UNIT_GET_F(info, uidx)) { + // p[i] = FILTER_UNIT_GET_R(info, uidx); + // } else { + uint8_t optr = cunit->optr; - if (colData == NULL || colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { - p[i] = optr == OP_TYPE_IS_NULL ? true : false; + if (colData == NULL || colDataIsNull((SColumnInfoData *)(cunit->colData), 0, i, NULL)) { + p[i] = optr == OP_TYPE_IS_NULL ? true : false; + } else { + if (optr == OP_TYPE_IS_NOT_NULL) { + p[i] = 1; + } else if (optr == OP_TYPE_IS_NULL) { + p[i] = 0; + } else if (cunit->rfunc >= 0) { + p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, + gDataCompare[cunit->func]); } else { - if (optr == OP_TYPE_IS_NOT_NULL) { - p[i] = 1; - } else if (optr == OP_TYPE_IS_NULL) { - p[i] = 0; - } else if (cunit->rfunc >= 0) { - p[i] = (*gRangeCompare[cunit->rfunc])(colData, colData, cunit->valData, cunit->valData2, gDataCompare[cunit->func]); - } else { - if(cunit->dataType == TSDB_DATA_TYPE_NCHAR && (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)){ - char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); - int32_t len = taosUcs4ToMbs((TdUcs4*)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); - if (len < 0){ - qError("castConvert1 taosUcs4ToMbs error"); - }else{ - varDataSetLen(newColData, len); - p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); - } - taosMemoryFreeClear(newColData); - }else{ - p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); + if (cunit->dataType == TSDB_DATA_TYPE_NCHAR && + (cunit->optr == OP_TYPE_MATCH || cunit->optr == OP_TYPE_NMATCH)) { + char *newColData = taosMemoryCalloc(cunit->dataSize * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE, 1); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(colData), varDataLen(colData), varDataVal(newColData)); + if (len < 0) { + qError("castConvert1 taosUcs4ToMbs error"); + } else { + varDataSetLen(newColData, len); + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, newColData, cunit->valData); } + taosMemoryFreeClear(newColData); + } else { + p[i] = filterDoCompare(gDataCompare[cunit->func], cunit->optr, colData, cunit->valData); } - - //FILTER_UNIT_SET_R(info, uidx, p[i]); - //FILTER_UNIT_SET_F(info, uidx); } + // FILTER_UNIT_SET_R(info, uidx, p[i]); + // FILTER_UNIT_SET_F(info, uidx); + } + if (p[i] == 0) { break; } @@ -3318,11 +3324,9 @@ int32_t filterSetExecFunc(SFilterInfo *info) { return TSDB_CODE_SUCCESS; } - - int32_t filterPreprocess(SFilterInfo *info) { - SFilterGroupCtx** gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *)); - int32_t gResNum = 0; + SFilterGroupCtx **gRes = taosMemoryCalloc(info->groupNum, sizeof(SFilterGroupCtx *)); + int32_t gResNum = 0; filterMergeGroupUnits(info, gRes, &gResNum); @@ -3333,7 +3337,6 @@ int32_t filterPreprocess(SFilterInfo *info) { goto _return; } - if (FILTER_GET_FLAG(info->status, FI_STATUS_EMPTY)) { fltInfo("Final - FilterInfo: [EMPTY]"); goto _return; @@ -3362,14 +3365,13 @@ _return: return TSDB_CODE_SUCCESS; } - int32_t fltSetColFieldDataImpl(SFilterInfo *info, void *param, filer_get_col_from_id fp, bool fromColId) { if (FILTER_ALL_RES(info) || FILTER_EMPTY_RES(info)) { return TSDB_CODE_SUCCESS; } for (uint32_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { - SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + SFilterField *fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; if (fromColId) { (*fp)(param, FILTER_GET_COL_FIELD_ID(fi), &fi->data); @@ -3383,11 +3385,10 @@ int32_t fltSetColFieldDataImpl(SFilterInfo *info, void *param, filer_get_col_fro return TSDB_CODE_SUCCESS; } - -int32_t fltInitFromNode(SNode* tree, SFilterInfo *info, uint32_t options) { +int32_t fltInitFromNode(SNode *tree, SFilterInfo *info, uint32_t options) { int32_t code = TSDB_CODE_SUCCESS; - SArray* group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); + SArray *group = taosArrayInit(FILTER_DEFAULT_GROUP_SIZE, sizeof(SFilterGroup)); filterInitUnitsFields(info); @@ -3436,13 +3437,13 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t return true; } - bool ret = true; + bool ret = true; void *minVal, *maxVal; for (uint32_t k = 0; k < info->colRangeNum; ++k) { - int32_t index = -1; + int32_t index = -1; SFilterRangeCtx *ctx = info->colRange[k]; - for(int32_t i = 0; i < numOfCols; ++i) { + for (int32_t i = 0; i < numOfCols; ++i) { if (pDataStatis[i] != NULL && pDataStatis[i]->colId == ctx->colId) { index = i; break; @@ -3479,11 +3480,11 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t } } - SColumnDataAgg* pDataBlockst = pDataStatis[index]; + SColumnDataAgg *pDataBlockst = pDataStatis[index]; SFilterRangeNode *r = ctx->rs; - float minv = 0; - float maxv = 0; + float minv = 0; + float maxv = 0; if (ctx->type == TSDB_DATA_TYPE_FLOAT) { minv = (float)(*(double *)(&pDataBlockst->min)); @@ -3512,17 +3513,15 @@ bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg **pDataStatis, int32_t return ret; } - - -int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool *isStrict) { - SFilterRange ra = {0}; +int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool *isStrict) { + SFilterRange ra = {0}; SFilterRangeCtx *prev = filterInitRangeCtx(TSDB_DATA_TYPE_TIMESTAMP, FLT_OPTION_TIMESTAMP); SFilterRangeCtx *tmpc = filterInitRangeCtx(TSDB_DATA_TYPE_TIMESTAMP, FLT_OPTION_TIMESTAMP); SFilterRangeCtx *cur = NULL; - int32_t num = 0; - int32_t optr = 0; - int32_t code = 0; - bool empty = false, all = false; + int32_t num = 0; + int32_t optr = 0; + int32_t code = 0; + bool empty = false, all = false; for (uint32_t i = 0; i < info->groupNum; ++i) { SFilterGroup *group = &info->groups[i]; @@ -3535,7 +3534,7 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool * } for (uint32_t u = 0; u < group->unitNum; ++u) { - uint32_t uidx = group->unitIdxs[u]; + uint32_t uidx = group->unitIdxs[u]; SFilterUnit *unit = &info->units[uidx]; uint8_t raOptr = FILTER_UNIT_OPTR(unit); @@ -3591,7 +3590,7 @@ int32_t filterGetTimeRangeImpl(SFilterInfo *info, STimeWindow *win, bool * filterFreeRangeCtx(prev); filterFreeRangeCtx(tmpc); - qDebug("qFilter time range:[%"PRId64 "]-[%"PRId64 "]", win->skey, win->ekey); + qDebug("qFilter time range:[%" PRId64 "]-[%" PRId64 "]", win->skey, win->ekey); return TSDB_CODE_SUCCESS; _return: @@ -3601,19 +3600,18 @@ _return: filterFreeRangeCtx(prev); filterFreeRangeCtx(tmpc); - qDebug("qFilter time range:[%"PRId64 "]-[%"PRId64 "]", win->skey, win->ekey); + qDebug("qFilter time range:[%" PRId64 "]-[%" PRId64 "]", win->skey, win->ekey); return code; } - int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict) { SFilterInfo *info = NULL; - int32_t code = 0; + int32_t code = 0; *isStrict = true; - FLT_ERR_RET(filterInitFromNode(pNode, &info, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP)); + FLT_ERR_RET(filterInitFromNode(pNode, &info, FLT_OPTION_NO_REWRITE | FLT_OPTION_TIMESTAMP)); if (info->scalarMode) { *win = TSWINDOW_INITIALIZER; @@ -3630,15 +3628,14 @@ _return: FLT_RET(code); } - -int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar) { +int32_t filterConverNcharColumns(SFilterInfo *info, int32_t rows, bool *gotNchar) { if (FILTER_EMPTY_RES(info) || FILTER_ALL_RES(info)) { return TSDB_CODE_SUCCESS; } for (uint32_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { - SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; - int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); + SFilterField *fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); if (type == TSDB_DATA_TYPE_NCHAR) { SFilterField nfi = {0}; nfi.desc = fi->desc; @@ -3646,20 +3643,21 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar nfi.data = taosMemoryMalloc(rows * bytes); int32_t bufSize = bytes - VARSTR_HEADER_SIZE; for (int32_t j = 0; j < rows; ++j) { - char *src = FILTER_GET_COL_FIELD_DATA(fi, j); - char *dst = FILTER_GET_COL_FIELD_DATA(&nfi, j); + char *src = FILTER_GET_COL_FIELD_DATA(fi, j); + char *dst = FILTER_GET_COL_FIELD_DATA(&nfi, j); int32_t len = 0; - char *varSrc = varDataVal(src); - size_t k = 0, varSrcLen = varDataLen(src); - while (k < varSrcLen && varSrc[k++] == -1) {} + char *varSrc = varDataVal(src); + size_t k = 0, varSrcLen = varDataLen(src); + while (k < varSrcLen && varSrc[k++] == -1) { + } if (k == varSrcLen) { /* NULL */ - varDataLen(dst) = (VarDataLenT) varSrcLen; + varDataLen(dst) = (VarDataLenT)varSrcLen; varDataCopy(dst, src); continue; } - bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), (TdUcs4*)varDataVal(dst), bufSize, &len); - if(!ret) { + bool ret = taosMbsToUcs4(varDataVal(src), varDataLen(src), (TdUcs4 *)varDataVal(dst), bufSize, &len); + if (!ret) { qError("filterConverNcharColumns taosMbsToUcs4 error"); return TSDB_CODE_FAILED; } @@ -3679,10 +3677,10 @@ int32_t filterConverNcharColumns(SFilterInfo* info, int32_t rows, bool *gotNchar return TSDB_CODE_SUCCESS; } -int32_t filterFreeNcharColumns(SFilterInfo* info) { +int32_t filterFreeNcharColumns(SFilterInfo *info) { for (uint32_t i = 0; i < info->fields[FLD_TYPE_COLUMN].num; ++i) { - SFilterField* fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; - int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); + SFilterField *fi = &info->fields[FLD_TYPE_COLUMN].fields[i]; + int32_t type = FILTER_GET_COL_FIELD_TYPE(fi); if (type == TSDB_DATA_TYPE_NCHAR) { taosMemoryFreeClear(fi->data); } @@ -3691,7 +3689,7 @@ int32_t filterFreeNcharColumns(SFilterInfo* info) { return TSDB_CODE_SUCCESS; } -int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode* pNode) { +int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode *pNode) { if (NULL == stat->nodeList) { stat->nodeList = taosArrayInit(10, POINTER_BYTES); if (NULL == stat->nodeList) { @@ -3706,12 +3704,12 @@ int32_t fltAddValueNodeToConverList(SFltTreeStat *stat, SValueNode* pNode) { return TSDB_CODE_SUCCESS; } -EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { +EDealRes fltReviseRewriter(SNode **pNode, void *pContext) { SFltTreeStat *stat = (SFltTreeStat *)pContext; if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pNode)) { SLogicConditionNode *node = (SLogicConditionNode *)*pNode; - SListCell *cell = node->pParameterList->pHead; + SListCell *cell = node->pParameterList->pHead; for (int32_t i = 0; i < node->pParameterList->length; ++i) { if (NULL == cell || NULL == cell->pNode) { fltError("invalid cell, cell:%p, pNode:%p", cell, cell->pNode); @@ -3777,8 +3775,8 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { } SValueNode *valueNode = (SValueNode *)listNode->pNodeList->pHead->pNode; - uint8_t type = valueNode->node.resType.type; - SNode *node = NULL; + uint8_t type = valueNode->node.resType.type; + SNode *node = NULL; FOREACH(node, listNode->pNodeList) { if (type != ((SValueNode *)node)->node.resType.type) { stat->scalarMode = true; @@ -3794,6 +3792,11 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } + if (QUERY_NODE_CASE_WHEN == nodeType(*pNode) || QUERY_NODE_WHEN_THEN == nodeType(*pNode)) { + stat->scalarMode = true; + return DEAL_RES_CONTINUE; + } + if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { SOperatorNode *node = (SOperatorNode *)*pNode; if (!FLT_IS_COMPARISON_OPERATOR(node->opType)) { @@ -3801,13 +3804,14 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } - if (node->opType == OP_TYPE_NOT_IN || node->opType == OP_TYPE_NOT_LIKE || node->opType > OP_TYPE_IS_NOT_NULL || node->opType == OP_TYPE_NOT_EQUAL) { + if (node->opType == OP_TYPE_NOT_IN || node->opType == OP_TYPE_NOT_LIKE || node->opType > OP_TYPE_IS_NOT_NULL || + node->opType == OP_TYPE_NOT_EQUAL) { stat->scalarMode = true; return DEAL_RES_CONTINUE; } - if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && - (node->opType >= OP_TYPE_NOT_EQUAL) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) { + if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && (node->opType >= OP_TYPE_NOT_EQUAL) && + (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL)) { stat->scalarMode = true; return DEAL_RES_CONTINUE; } @@ -3824,8 +3828,9 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } - if (OP_TYPE_IS_TRUE == node->opType || OP_TYPE_IS_FALSE == node->opType || OP_TYPE_IS_UNKNOWN == node->opType - || OP_TYPE_IS_NOT_TRUE == node->opType || OP_TYPE_IS_NOT_FALSE == node->opType || OP_TYPE_IS_NOT_UNKNOWN == node->opType) { + if (OP_TYPE_IS_TRUE == node->opType || OP_TYPE_IS_FALSE == node->opType || OP_TYPE_IS_UNKNOWN == node->opType || + OP_TYPE_IS_NOT_TRUE == node->opType || OP_TYPE_IS_NOT_FALSE == node->opType || + OP_TYPE_IS_NOT_UNKNOWN == node->opType) { stat->scalarMode = true; return DEAL_RES_CONTINUE; } @@ -3835,7 +3840,8 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } - if ((QUERY_NODE_COLUMN != nodeType(node->pRight)) && (QUERY_NODE_VALUE != nodeType(node->pRight)) && (QUERY_NODE_NODE_LIST != nodeType(node->pRight))) { + if ((QUERY_NODE_COLUMN != nodeType(node->pRight)) && (QUERY_NODE_VALUE != nodeType(node->pRight)) && + (QUERY_NODE_NODE_LIST != nodeType(node->pRight))) { stat->scalarMode = true; return DEAL_RES_CONTINUE; } @@ -3880,9 +3886,9 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { if (OP_TYPE_IN != node->opType) { SColumnNode *refNode = (SColumnNode *)node->pLeft; - SValueNode *valueNode = (SValueNode *)node->pRight; - if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) - && TSDB_DATA_TYPE_UBIGINT == valueNode->node.resType.type && valueNode->datum.u <= INT64_MAX) { + SValueNode *valueNode = (SValueNode *)node->pRight; + if (FILTER_GET_FLAG(stat->info->options, FLT_OPTION_TIMESTAMP) && + TSDB_DATA_TYPE_UBIGINT == valueNode->node.resType.type && valueNode->datum.u <= INT64_MAX) { valueNode->node.resType.type = TSDB_DATA_TYPE_BIGINT; } int32_t type = vectorGetConvertType(refNode->node.resType.type, valueNode->node.resType.type); @@ -3891,9 +3897,9 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_CONTINUE; } } else { - SColumnNode *refNode = (SColumnNode *)node->pLeft; + SColumnNode *refNode = (SColumnNode *)node->pLeft; SNodeListNode *listNode = (SNodeListNode *)node->pRight; - int32_t type = vectorGetConvertType(refNode->node.resType.type, listNode->dataType.type); + int32_t type = vectorGetConvertType(refNode->node.resType.type, listNode->dataType.type); if (0 != type && type != refNode->node.resType.type) { stat->scalarMode = true; return DEAL_RES_CONTINUE; @@ -3911,7 +3917,7 @@ EDealRes fltReviseRewriter(SNode** pNode, void* pContext) { return DEAL_RES_ERROR; } -int32_t fltReviseNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) { +int32_t fltReviseNodes(SFilterInfo *pInfo, SNode **pNode, SFltTreeStat *pStat) { int32_t code = 0; nodesRewriteExprPostOrder(pNode, fltReviseRewriter, (void *)pStat); @@ -3930,18 +3936,17 @@ _return: FLT_RET(code); } -int32_t fltOptimizeNodes(SFilterInfo *pInfo, SNode** pNode, SFltTreeStat *pStat) { - //TODO +int32_t fltOptimizeNodes(SFilterInfo *pInfo, SNode **pNode, SFltTreeStat *pStat) { + // TODO return TSDB_CODE_SUCCESS; } - int32_t fltGetDataFromColId(void *param, int32_t id, void **data) { int32_t numOfCols = ((SFilterColumnParam *)param)->numOfCols; - SArray* pDataBlock = ((SFilterColumnParam *)param)->pDataBlock; + SArray *pDataBlock = ((SFilterColumnParam *)param)->pDataBlock; for (int32_t j = 0; j < numOfCols; ++j) { - SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, j); + SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, j); if (id == pColInfo->info.colId) { *data = pColInfo; break; @@ -3953,20 +3958,19 @@ int32_t fltGetDataFromColId(void *param, int32_t id, void **data) { int32_t fltGetDataFromSlotId(void *param, int32_t id, void **data) { int32_t numOfCols = ((SFilterColumnParam *)param)->numOfCols; - SArray* pDataBlock = ((SFilterColumnParam *)param)->pDataBlock; + SArray *pDataBlock = ((SFilterColumnParam *)param)->pDataBlock; if (id < 0 || id >= numOfCols || id >= taosArrayGetSize(pDataBlock)) { - fltError("invalid slot id, id:%d, numOfCols:%d, arraySize:%d", id, numOfCols, (int32_t)taosArrayGetSize(pDataBlock)); + fltError("invalid slot id, id:%d, numOfCols:%d, arraySize:%d", id, numOfCols, + (int32_t)taosArrayGetSize(pDataBlock)); return TSDB_CODE_QRY_APP_ERROR; } - SColumnInfoData* pColInfo = taosArrayGet(pDataBlock, id); + SColumnInfoData *pColInfo = taosArrayGet(pDataBlock, id); *data = pColInfo; return TSDB_CODE_SUCCESS; } - - int32_t filterSetDataFromSlotId(SFilterInfo *info, void *param) { if (NULL == info) { return TSDB_CODE_QRY_INVALID_INPUT; @@ -3979,10 +3983,8 @@ int32_t filterSetDataFromColId(SFilterInfo *info, void *param) { return fltSetColFieldDataImpl(info, param, fltGetDataFromColId, true); } - - -int32_t filterInitFromNode(SNode* pNode, SFilterInfo **pInfo, uint32_t options) { - int32_t code = 0; +int32_t filterInitFromNode(SNode *pNode, SFilterInfo **pInfo, uint32_t options) { + int32_t code = 0; SFilterInfo *info = NULL; if (pNode == NULL || pInfo == NULL) { @@ -4028,14 +4030,15 @@ _return: FLT_RET(code); } -bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SColumnDataAgg *statis, int16_t numOfCols, int32_t *pResultStatus) { +bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData **p, SColumnDataAgg *statis, int16_t numOfCols, + int32_t *pResultStatus) { if (NULL == info) { *pResultStatus = FILTER_RESULT_ALL_QUALIFIED; return false; } SScalarParam output = {0}; - SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; + SDataType type = {.type = TSDB_DATA_TYPE_BOOL, .bytes = sizeof(bool)}; int32_t code = sclCreateColumnInfoData(&type, pSrc->info.rows, &output); if (code != TSDB_CODE_SUCCESS) { @@ -4067,8 +4070,8 @@ bool filterExecute(SFilterInfo *info, SSDataBlock *pSrc, SColumnInfoData** p, SC // todo this should be return during filter procedure int32_t num = 0; - for(int32_t i = 0; i < output.numOfRows; ++i) { - if (((int8_t*)((*p)->pData))[i] == 1) { + for (int32_t i = 0; i < output.numOfRows; ++i) { + if (((int8_t *)((*p)->pData))[i] == 1) { ++num; } } @@ -4092,10 +4095,10 @@ typedef struct SClassifyConditionCxt { bool hasOtherCol; } SClassifyConditionCxt; -static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) { - SClassifyConditionCxt* pCxt = (SClassifyConditionCxt*)pContext; +static EDealRes classifyConditionImpl(SNode *pNode, void *pContext) { + SClassifyConditionCxt *pCxt = (SClassifyConditionCxt *)pContext; if (QUERY_NODE_COLUMN == nodeType(pNode)) { - SColumnNode* pCol = (SColumnNode*)pNode; + SColumnNode *pCol = (SColumnNode *)pNode; if (PRIMARYKEY_TIMESTAMP_COL_ID == pCol->colId && TSDB_SYSTEM_TABLE != pCol->tableType) { pCxt->hasPrimaryKey = true; } else if (pCol->hasIndex) { @@ -4107,9 +4110,9 @@ static EDealRes classifyConditionImpl(SNode* pNode, void* pContext) { pCxt->hasOtherCol = true; } } else if (QUERY_NODE_FUNCTION == nodeType(pNode)) { - SFunctionNode* pFunc = (SFunctionNode*)pNode; + SFunctionNode *pFunc = (SFunctionNode *)pNode; if (fmIsPseudoColumnFunc(pFunc->funcId)) { - if (FUNCTION_TYPE_TBNAME==pFunc->funcType) { + if (FUNCTION_TYPE_TBNAME == pFunc->funcType) { pCxt->hasTagCol = true; } else { pCxt->hasOtherCol = true; @@ -4126,7 +4129,7 @@ typedef enum EConditionType { COND_TYPE_NORMAL } EConditionType; -static EConditionType classifyCondition(SNode* pNode) { +static EConditionType classifyCondition(SNode *pNode) { SClassifyConditionCxt cxt = {.hasPrimaryKey = false, .hasTagIndexCol = false, .hasOtherCol = false}; nodesWalkExpr(pNode, classifyConditionImpl, &cxt); return cxt.hasOtherCol ? COND_TYPE_NORMAL @@ -4136,16 +4139,16 @@ static EConditionType classifyCondition(SNode* pNode) { : (cxt.hasTagIndexCol ? COND_TYPE_TAG_INDEX : COND_TYPE_TAG))); } -static bool isCondColumnsFromMultiTable(SNode* pCond) { - SNodeList* pCondCols = nodesMakeList(); - int32_t code = nodesCollectColumnsFromNode(pCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols); +static bool isCondColumnsFromMultiTable(SNode *pCond) { + SNodeList *pCondCols = nodesMakeList(); + int32_t code = nodesCollectColumnsFromNode(pCond, NULL, COLLECT_COL_TYPE_ALL, &pCondCols); if (code == TSDB_CODE_SUCCESS) { if (LIST_LENGTH(pCondCols) >= 2) { - SColumnNode* pFirstCol = (SColumnNode*)nodesListGetNode(pCondCols, 0); - SNode* pColNode = NULL; + SColumnNode *pFirstCol = (SColumnNode *)nodesListGetNode(pCondCols, 0); + SNode *pColNode = NULL; FOREACH(pColNode, pCondCols) { - if (strcmp(((SColumnNode*)pColNode)->dbName, pFirstCol->dbName) != 0 || - strcmp(((SColumnNode*)pColNode)->tableAlias, pFirstCol->tableAlias) != 0) { + if (strcmp(((SColumnNode *)pColNode)->dbName, pFirstCol->dbName) != 0 || + strcmp(((SColumnNode *)pColNode)->tableAlias, pFirstCol->tableAlias) != 0) { nodesDestroyList(pCondCols); return true; } @@ -4156,17 +4159,17 @@ static bool isCondColumnsFromMultiTable(SNode* pCond) { return false; } -static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, - SNode** pOtherCond) { - SLogicConditionNode* pLogicCond = (SLogicConditionNode*)(*pCondition); +static int32_t partitionLogicCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond, + SNode **pOtherCond) { + SLogicConditionNode *pLogicCond = (SLogicConditionNode *)(*pCondition); int32_t code = TSDB_CODE_SUCCESS; - SNodeList* pPrimaryKeyConds = NULL; - SNodeList* pTagIndexConds = NULL; - SNodeList* pTagConds = NULL; - SNodeList* pOtherConds = NULL; - SNode* pCond = NULL; + SNodeList *pPrimaryKeyConds = NULL; + SNodeList *pTagIndexConds = NULL; + SNodeList *pTagConds = NULL; + SNodeList *pOtherConds = NULL; + SNode *pCond = NULL; FOREACH(pCond, pLogicCond->pParameterList) { if (isCondColumnsFromMultiTable(pCond)) { if (NULL != pOtherCond) { @@ -4205,10 +4208,10 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S } } - SNode* pTempPrimaryKeyCond = NULL; - SNode* pTempTagIndexCond = NULL; - SNode* pTempTagCond = NULL; - SNode* pTempOtherCond = NULL; + SNode *pTempPrimaryKeyCond = NULL; + SNode *pTempTagIndexCond = NULL; + SNode *pTempTagCond = NULL; + SNode *pTempOtherCond = NULL; if (TSDB_CODE_SUCCESS == code) { code = nodesMergeConds(&pTempPrimaryKeyCond, &pPrimaryKeyConds); } @@ -4251,10 +4254,10 @@ static int32_t partitionLogicCond(SNode** pCondition, SNode** pPrimaryKeyCond, S return code; } -int32_t filterPartitionCond(SNode** pCondition, SNode** pPrimaryKeyCond, SNode** pTagIndexCond, SNode** pTagCond, - SNode** pOtherCond) { +int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond, + SNode **pOtherCond) { if (QUERY_NODE_LOGIC_CONDITION == nodeType(*pCondition) && - LOGIC_COND_TYPE_AND == ((SLogicConditionNode*)*pCondition)->condType) { + LOGIC_COND_TYPE_AND == ((SLogicConditionNode *)*pCondition)->condType) { return partitionLogicCond(pCondition, pPrimaryKeyCond, pTagIndexCond, pTagCond, pOtherCond); } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b4b99be6362c31ac752df190920f55b22a6aec32..1f09fd4799d7ba87ed545d97ed931c88cb4e8517 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -1,3 +1,4 @@ +#include "scalar.h" #include "function.h" #include "functionMgt.h" #include "nodes.h" @@ -5,25 +6,25 @@ #include "sclInt.h" #include "sclvector.h" #include "tcommon.h" +#include "tcompare.h" #include "tdatablock.h" -#include "scalar.h" -#include "tudf.h" #include "ttime.h" -#include "tcompare.h" +#include "tudf.h" int32_t scalarGetOperatorParamNum(EOperatorType type) { - if (OP_TYPE_IS_NULL == type || OP_TYPE_IS_NOT_NULL == type || OP_TYPE_IS_TRUE == type || OP_TYPE_IS_NOT_TRUE == type - || OP_TYPE_IS_FALSE == type || OP_TYPE_IS_NOT_FALSE == type || OP_TYPE_IS_UNKNOWN == type || OP_TYPE_IS_NOT_UNKNOWN == type - || OP_TYPE_MINUS == type) { + if (OP_TYPE_IS_NULL == type || OP_TYPE_IS_NOT_NULL == type || OP_TYPE_IS_TRUE == type || + OP_TYPE_IS_NOT_TRUE == type || OP_TYPE_IS_FALSE == type || OP_TYPE_IS_NOT_FALSE == type || + OP_TYPE_IS_UNKNOWN == type || OP_TYPE_IS_NOT_UNKNOWN == type || OP_TYPE_MINUS == type) { return 1; } return 2; } -int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode) { - char *timeStr = valueNode->datum.p; - int32_t code = convertStringToTimestamp(valueNode->node.resType.type, valueNode->datum.p, precision, &valueNode->datum.i); +int32_t sclConvertToTsValueNode(int8_t precision, SValueNode *valueNode) { + char *timeStr = valueNode->datum.p; + int32_t code = + convertStringToTimestamp(valueNode->node.resType.type, valueNode->datum.p, precision, &valueNode->datum.i); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -36,16 +37,16 @@ int32_t sclConvertToTsValueNode(int8_t precision, SValueNode* valueNode) { return TSDB_CODE_SUCCESS; } -int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarParam* pParam) { - SColumnInfoData* pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); +int32_t sclCreateColumnInfoData(SDataType *pType, int32_t numOfRows, SScalarParam *pParam) { + SColumnInfoData *pColumnData = taosMemoryCalloc(1, sizeof(SColumnInfoData)); if (pColumnData == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; return terrno; } - pColumnData->info.type = pType->type; - pColumnData->info.bytes = pType->bytes; - pColumnData->info.scale = pType->scale; + pColumnData->info.type = pType->type; + pColumnData->info.bytes = pType->bytes; + pColumnData->info.scale = pType->scale; pColumnData->info.precision = pType->precision; int32_t code = colInfoDataEnsureCapacity(pColumnData, numOfRows); @@ -60,9 +61,9 @@ int32_t sclCreateColumnInfoData(SDataType* pType, int32_t numOfRows, SScalarPara return TSDB_CODE_SUCCESS; } -int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow) { +int32_t sclConvertValueToSclParam(SValueNode* pValueNode, SScalarParam* out, int32_t* overflow) { SScalarParam in = {.numOfRows = 1}; - int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in); + int32_t code = sclCreateColumnInfoData(&pValueNode->node.resType, 1, &in); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -70,12 +71,34 @@ int32_t doConvertDataType(SValueNode* pValueNode, SScalarParam* out, int32_t* ov colDataAppend(in.columnData, 0, nodesGetValueFromNode(pValueNode), false); colInfoDataEnsureCapacity(out->columnData, 1); - code = vectorConvertImpl(&in, out, overflow); + code = vectorConvertSingleColImpl(&in, out, overflow, -1, -1); sclFreeParam(&in); return code; } +int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) { + SSDataBlock* pb = taosArrayGetP(pBlockList, 0); + SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam)); + if (NULL == pLeft) { + sclError("calloc %d failed", (int32_t)sizeof(SScalarParam)); + SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + pLeft->numOfRows = pb->info.rows; + + if (pDst->numOfRows < pb->info.rows) { + colInfoDataEnsureCapacity(pDst->columnData, pb->info.rows); + } + + _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(OP_TYPE_ASSIGN); + OperatorFn(pLeft, pSrc, pDst, TSDB_ORDER_ASC); + + taosMemoryFree(pLeft); + + return TSDB_CODE_SUCCESS; +} + int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { SHashObj *pObj = taosHashInit(256, taosGetDefaultHashFunction(type), true, false); if (NULL == pObj) { @@ -85,13 +108,13 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { taosHashSetEqualFp(pObj, taosGetDefaultEqualFunction(type)); - int32_t code = 0; + int32_t code = 0; SNodeListNode *nodeList = (SNodeListNode *)pNode; - SListCell *cell = nodeList->pNodeList->pHead; - SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; + SListCell *cell = nodeList->pNodeList->pHead; + SScalarParam out = {.columnData = taosMemoryCalloc(1, sizeof(SColumnInfoData))}; int32_t len = 0; - void *buf = NULL; + void *buf = NULL; for (int32_t i = 0; i < nodeList->pNodeList->length; ++i) { SValueNode *valueNode = (SValueNode *)cell->pNode; @@ -109,9 +132,9 @@ int32_t scalarGenerateSetFromList(void **data, void *pNode, uint32_t type) { } int32_t overflow = 0; - code = doConvertDataType(valueNode, &out, &overflow); + code = sclConvertValueToSclParam(valueNode, &out, &overflow); if (code != TSDB_CODE_SUCCESS) { -// sclError("convert data from %d to %d failed", in.type, out.type); + // sclError("convert data from %d to %d failed", in.type, out.type); SCL_ERR_JRET(code); } @@ -164,7 +187,7 @@ _return: void sclFreeRes(SHashObj *res) { SScalarParam *p = NULL; - void *pIter = taosHashIterate(res, NULL); + void *pIter = taosHashIterate(res, NULL); while (pIter) { p = (SScalarParam *)pIter; @@ -177,10 +200,10 @@ void sclFreeRes(SHashObj *res) { } void sclFreeParam(SScalarParam *param) { - if (!param->colAlloced) { + if (NULL == param || !param->colAlloced) { return; } - + if (param->columnData != NULL) { colDataDestroy(param->columnData); taosMemoryFreeClear(param->columnData); @@ -213,7 +236,7 @@ void sclFreeParamList(SScalarParam *param, int32_t paramNum) { } for (int32_t i = 0; i < paramNum; ++i) { - SScalarParam* p = param + i; + SScalarParam *p = param + i; sclFreeParam(p); } @@ -226,33 +249,33 @@ void sclDowngradeValueType(SValueNode *valueNode) { int8_t i8 = valueNode->datum.i; if (i8 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_TINYINT; - *(int8_t*)&valueNode->typeData = i8; + *(int8_t *)&valueNode->typeData = i8; break; } int16_t i16 = valueNode->datum.i; if (i16 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_SMALLINT; - *(int16_t*)&valueNode->typeData = i16; + *(int16_t *)&valueNode->typeData = i16; break; } int32_t i32 = valueNode->datum.i; if (i32 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_INT; - *(int32_t*)&valueNode->typeData = i32; + *(int32_t *)&valueNode->typeData = i32; break; } break; } - case TSDB_DATA_TYPE_UBIGINT:{ + case TSDB_DATA_TYPE_UBIGINT: { uint8_t u8 = valueNode->datum.i; if (u8 == valueNode->datum.i) { int8_t i8 = valueNode->datum.i; if (i8 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_TINYINT; - *(int8_t*)&valueNode->typeData = i8; + *(int8_t *)&valueNode->typeData = i8; } else { valueNode->node.resType.type = TSDB_DATA_TYPE_UTINYINT; - *(uint8_t*)&valueNode->typeData = u8; + *(uint8_t *)&valueNode->typeData = u8; } break; } @@ -261,10 +284,10 @@ void sclDowngradeValueType(SValueNode *valueNode) { int16_t i16 = valueNode->datum.i; if (i16 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_SMALLINT; - *(int16_t*)&valueNode->typeData = i16; + *(int16_t *)&valueNode->typeData = i16; } else { valueNode->node.resType.type = TSDB_DATA_TYPE_USMALLINT; - *(uint16_t*)&valueNode->typeData = u16; + *(uint16_t *)&valueNode->typeData = u16; } break; } @@ -273,10 +296,10 @@ void sclDowngradeValueType(SValueNode *valueNode) { int32_t i32 = valueNode->datum.i; if (i32 == valueNode->datum.i) { valueNode->node.resType.type = TSDB_DATA_TYPE_INT; - *(int32_t*)&valueNode->typeData = i32; + *(int32_t *)&valueNode->typeData = i32; } else { valueNode->node.resType.type = TSDB_DATA_TYPE_UINT; - *(uint32_t*)&valueNode->typeData = u32; + *(uint32_t *)&valueNode->typeData = u32; } break; } @@ -286,7 +309,7 @@ void sclDowngradeValueType(SValueNode *valueNode) { float f = valueNode->datum.d; if (FLT_EQUAL(f, valueNode->datum.d)) { valueNode->node.resType.type = TSDB_DATA_TYPE_FLOAT; - *(float*)&valueNode->typeData = f; + *(float *)&valueNode->typeData = f; break; } break; @@ -296,10 +319,10 @@ void sclDowngradeValueType(SValueNode *valueNode) { } } -int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) { +int32_t sclInitParam(SNode *node, SScalarParam *param, SScalarCtx *ctx, int32_t *rowNum) { switch (nodeType(node)) { case QUERY_NODE_LEFT_VALUE: { - SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, 0); + SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, 0); param->numOfRows = pb->info.rows; break; } @@ -308,7 +331,7 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t ASSERT(param->columnData == NULL); param->numOfRows = 1; - /*int32_t code = */sclCreateColumnInfoData(&valueNode->node.resType, 1, param); + /*int32_t code = */ sclCreateColumnInfoData(&valueNode->node.resType, 1, param); if (TSDB_DATA_TYPE_NULL == valueNode->node.resType.type || valueNode->isNull) { colDataAppendNULL(param->columnData, 0); } else { @@ -349,8 +372,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t SColumnNode *ref = (SColumnNode *)node; int32_t index = -1; - for(int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) { - SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, i); + for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) { + SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i); if (pb->info.blockId == ref->dataBlockId) { index = i; break; @@ -358,7 +381,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t } if (index == -1) { - sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", ref->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList)); + sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", ref->dataBlockId, + (int32_t)taosArrayGetSize(ctx->pBlockList)); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -368,13 +392,15 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t } if (ref->slotId >= taosArrayGetSize(block->pDataBlock)) { - sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, (int32_t)taosArrayGetSize(block->pDataBlock)); + sclError("column slotId is too big, slodId:%d, dataBlockSize:%d", ref->slotId, + (int32_t)taosArrayGetSize(block->pDataBlock)); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } SColumnInfoData *columnData = (SColumnInfoData *)taosArrayGet(block->pDataBlock, ref->slotId); #if TAG_FILTER_DEBUG - qDebug("tagfilter column info, slotId:%d, colId:%d, type:%d", ref->slotId, columnData->info.colId, columnData->info.type); + qDebug("tagfilter column info, slotId:%d, colId:%d, type:%d", ref->slotId, columnData->info.colId, + columnData->info.type); #endif param->numOfRows = block->info.rows; param->columnData = columnData; @@ -382,7 +408,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t } case QUERY_NODE_FUNCTION: case QUERY_NODE_OPERATOR: - case QUERY_NODE_LOGIC_CONDITION: { + case QUERY_NODE_LOGIC_CONDITION: + case QUERY_NODE_CASE_WHEN: { SScalarParam *res = (SScalarParam *)taosHashGet(ctx->pRes, &node, POINTER_BYTES); if (NULL == res) { sclError("no result for node, type:%d, node:%p", nodeType(node), node); @@ -409,7 +436,8 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t return TSDB_CODE_SUCCESS; } -int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarCtx *ctx, int32_t *paramNum, int32_t *rowNum) { +int32_t sclInitParamList(SScalarParam **pParams, SNodeList *pParamList, SScalarCtx *ctx, int32_t *paramNum, + int32_t *rowNum) { int32_t code = 0; if (NULL == pParamList) { if (ctx->pBlockList) { @@ -431,10 +459,10 @@ int32_t sclInitParamList(SScalarParam **pParams, SNodeList* pParamList, SScalarC } if (pParamList) { - SNode *tnode = NULL; + SNode *tnode = NULL; int32_t i = 0; if (SCL_IS_CONST_CALC(ctx)) { - WHERE_EACH (tnode, pParamList) { + WHERE_EACH(tnode, pParamList) { if (!SCL_IS_CONST_NODE(tnode)) { WHERE_NEXT; } else { @@ -499,7 +527,6 @@ int32_t sclGetNodeType(SNode *pNode, SScalarCtx *ctx) { return -1; } - void sclSetOperatorValueType(SOperatorNode *node, SScalarCtx *ctx) { ctx->type.opResType = node->node.resType.type; ctx->type.selfType = sclGetNodeType(node->pLeft, ctx); @@ -536,11 +563,140 @@ _return: SCL_RET(code); } -int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) { - SScalarParam *params = NULL; +int32_t sclGetNodeRes(SNode* node, SScalarCtx *ctx, SScalarParam **res) { + if (NULL == node) { + return TSDB_CODE_SUCCESS; + } + int32_t rowNum = 0; - int32_t paramNum = 0; + *res = taosMemoryCalloc(1, sizeof(**res)); + if (NULL == *res) { + SCL_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + SCL_ERR_RET(sclInitParam(node, *res, ctx, &rowNum)); + + return TSDB_CODE_SUCCESS; +} + +int32_t sclWalkCaseWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCell, SScalarParam *pCase, SScalarParam *pElse, SScalarParam *pComp, SScalarParam *output, int32_t rowIdx, int32_t totalRows, bool *complete) { + SNode *node = NULL; + SWhenThenNode* pWhenThen = NULL; + SScalarParam *pWhen = NULL; + SScalarParam *pThen = NULL; + int32_t code = 0; + + for (SListCell* cell = pCell; (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) { + pWhenThen = (SWhenThenNode*)node; + + SCL_ERR_RET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen)); + SCL_ERR_RET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen)); + + vectorCompareImpl(pCase, pWhen, pComp, rowIdx, 1, TSDB_ORDER_ASC, OP_TYPE_EQUAL); + + bool *equal = (bool*)colDataGetData(pComp->columnData, rowIdx); + if (*equal) { + colDataAppend(output->columnData, rowIdx, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0))); + + if (0 == rowIdx && 1 == pCase->numOfRows && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + + goto _return; + } + } + + if (pElse) { + colDataAppend(output->columnData, rowIdx, colDataGetData(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0))); + + if (0 == rowIdx && 1 == pCase->numOfRows && 1 == pElse->numOfRows && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + + goto _return; + } + + colDataAppend(output->columnData, rowIdx, NULL, true); + + if (0 == rowIdx && 1 == pCase->numOfRows && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + +_return: + + sclFreeParam(pWhen); + sclFreeParam(pThen); + + SCL_RET(code); +} + +int32_t sclWalkWhenList(SScalarCtx *ctx, SNodeList* pList, struct SListCell* pCell, SScalarParam *pElse, SScalarParam *output, + int32_t rowIdx, int32_t totalRows, bool *complete, bool preSingle) { + SNode *node = NULL; + SWhenThenNode* pWhenThen = NULL; + SScalarParam *pWhen = NULL; + SScalarParam *pThen = NULL; int32_t code = 0; + + for (SListCell* cell = pCell; (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) { + pWhenThen = (SWhenThenNode*)node; + pWhen = NULL; + pThen = NULL; + + SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen)); + SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen)); + + bool *whenValue = (bool*)colDataGetData(pWhen->columnData, (pWhen->numOfRows > 1 ? rowIdx : 0)); + + if (*whenValue) { + colDataAppend(output->columnData, rowIdx, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? rowIdx : 0))); + + if (preSingle && 0 == rowIdx && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + + goto _return; + } + + sclFreeParam(pWhen); + sclFreeParam(pThen); + } + + if (pElse) { + colDataAppend(output->columnData, rowIdx, colDataGetData(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0)), colDataIsNull_s(pElse->columnData, (pElse->numOfRows > 1 ? rowIdx : 0))); + + if (preSingle && 0 == rowIdx && 1 == pElse->numOfRows && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + + goto _return; + } + + colDataAppend(output->columnData, rowIdx, NULL, true); + + if (preSingle && 0 == rowIdx && totalRows > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + *complete = true; + } + +_return: + + sclFreeParam(pWhen); + sclFreeParam(pThen); + + SCL_RET(code); +} + +int32_t sclExecFunction(SFunctionNode *node, SScalarCtx *ctx, SScalarParam *output) { + SScalarParam *params = NULL; + int32_t rowNum = 0; + int32_t paramNum = 0; + int32_t code = 0; SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, ¶mNum, &rowNum)); if (fmIsUserDefinedFunc(node->funcId)) { @@ -577,7 +733,8 @@ _return: int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *output) { if (NULL == node->pParameterList || node->pParameterList->length <= 0) { - sclError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, node->pParameterList ? node->pParameterList->length : 0); + sclError("invalid logic parameter list, list:%p, paramNum:%d", node->pParameterList, + node->pParameterList ? node->pParameterList->length : 0); SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -592,9 +749,9 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o } SScalarParam *params = NULL; - int32_t rowNum = 0; - int32_t paramNum = 0; - int32_t code = 0; + int32_t rowNum = 0; + int32_t paramNum = 0; + int32_t code = 0; SCL_ERR_RET(sclInitParamList(¶ms, node->pParameterList, ctx, ¶mNum, &rowNum)); if (NULL == params) { output->numOfRows = 0; @@ -621,7 +778,7 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o complete = false; continue; } - char* p = colDataGetData(params[m].columnData, i); + char *p = colDataGetData(params[m].columnData, i); GET_TYPED_DATA(value, bool, params[m].columnData->info.type, p); if (LOGIC_COND_TYPE_AND == node->condType && (false == value)) { @@ -636,7 +793,7 @@ int32_t sclExecLogic(SLogicConditionNode *node, SScalarCtx *ctx, SScalarParam *o } if (complete) { - colDataAppend(output->columnData, i, (char*) &value, false); + colDataAppend(output->columnData, i, (char *)&value, false); if (value) { numOfQualified++; } @@ -657,13 +814,14 @@ _return: int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *output) { SScalarParam *params = NULL; - int32_t rowNum = 0; - int32_t code = 0; + int32_t rowNum = 0; + int32_t code = 0; // json not support in in operator if (nodeType(node->pLeft) == QUERY_NODE_VALUE) { SValueNode *valueNode = (SValueNode *)node->pLeft; - if (valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)) { + if (valueNode->node.resType.type == TSDB_DATA_TYPE_JSON && + (node->opType == OP_TYPE_IN || node->opType == OP_TYPE_NOT_IN)) { SCL_RET(TSDB_CODE_QRY_JSON_IN_ERROR); } } @@ -678,9 +836,9 @@ int32_t sclExecOperator(SOperatorNode *node, SScalarCtx *ctx, SScalarParam *outp _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(node->opType); - int32_t paramNum = scalarGetOperatorParamNum(node->opType); - SScalarParam* pLeft = ¶ms[0]; - SScalarParam* pRight = paramNum > 1 ? ¶ms[1] : NULL; + int32_t paramNum = scalarGetOperatorParamNum(node->opType); + SScalarParam *pLeft = ¶ms[0]; + SScalarParam *pRight = paramNum > 1 ? ¶ms[1] : NULL; terrno = TSDB_CODE_SUCCESS; OperatorFn(pLeft, pRight, output, TSDB_ORDER_ASC); @@ -692,7 +850,102 @@ _return: SCL_RET(code); } -EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opType) { +int32_t sclExecCaseWhen(SCaseWhenNode *node, SScalarCtx *ctx, SScalarParam *output) { + int32_t code = 0; + SScalarParam *pCase = NULL; + SScalarParam *pElse = NULL; + SScalarParam *pWhen = NULL; + SScalarParam *pThen = NULL; + SScalarParam comp = {0}; + int32_t rowNum = 1; + bool complete = false; + + if (NULL == node->pWhenThenList || node->pWhenThenList->length <= 0) { + sclError("invalid whenThen list"); + SCL_ERR_RET(TSDB_CODE_INVALID_PARA); + } + + if (ctx->pBlockList) { + SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, 0); + rowNum = pb->info.rows; + output->numOfRows = pb->info.rows; + } + + SCL_ERR_JRET(sclCreateColumnInfoData(&node->node.resType, rowNum, output)); + + SCL_ERR_JRET(sclGetNodeRes(node->pCase, ctx, &pCase)); + SCL_ERR_JRET(sclGetNodeRes(node->pElse, ctx, &pElse)); + + SDataType compType = {0}; + compType.type = TSDB_DATA_TYPE_BOOL; + compType.bytes = tDataTypes[compType.type].bytes; + + SCL_ERR_JRET(sclCreateColumnInfoData(&compType, rowNum, &comp)); + + SNode* tnode = NULL; + SWhenThenNode* pWhenThen = (SWhenThenNode*)node->pWhenThenList->pHead->pNode; + + SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pWhen, ctx, &pWhen)); + SCL_ERR_JRET(sclGetNodeRes(pWhenThen->pThen, ctx, &pThen)); + + if (pCase) { + vectorCompare(pCase, pWhen, &comp, TSDB_ORDER_ASC, OP_TYPE_EQUAL); + + for (int32_t i = 0; i < rowNum; ++i) { + bool *equal = (bool*)colDataGetData(comp.columnData, (comp.numOfRows > 1 ? i : 0)); + if (*equal) { + colDataAppend(output->columnData, i, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? i : 0))); + if (0 == i && 1 == pCase->numOfRows && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && rowNum > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + break; + } + } else { + SCL_ERR_JRET(sclWalkCaseWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pCase, pElse, &comp, output, i, rowNum, &complete)); + if (complete) { + break; + } + } + } + } else { + for (int32_t i = 0; i < rowNum; ++i) { + bool *whenValue = (bool*)colDataGetData(pWhen->columnData, (pWhen->numOfRows > 1 ? i : 0)); + if (*whenValue) { + colDataAppend(output->columnData, i, colDataGetData(pThen->columnData, (pThen->numOfRows > 1 ? i : 0)), colDataIsNull_s(pThen->columnData, (pThen->numOfRows > 1 ? i : 0))); + if (0 == i && 1 == pWhen->numOfRows && 1 == pThen->numOfRows && rowNum > 1) { + SCL_ERR_JRET(sclExtendResRows(output, output, ctx->pBlockList)); + break; + } + } else { + SCL_ERR_JRET(sclWalkWhenList(ctx, node->pWhenThenList, node->pWhenThenList->pHead->pNext, pElse, output, i, rowNum, &complete, (pWhen->numOfRows == 1 && pThen->numOfRows == 1))); + if (complete) { + break; + } + } + } + } + + sclFreeParam(pCase); + sclFreeParam(pElse); + sclFreeParam(&comp); + sclFreeParam(pWhen); + sclFreeParam(pThen); + + return TSDB_CODE_SUCCESS; + +_return: + + sclFreeParam(pCase); + sclFreeParam(pElse); + sclFreeParam(&comp); + sclFreeParam(pWhen); + sclFreeParam(pThen); + sclFreeParam(output); + + SCL_RET(code); +} + + +EDealRes sclRewriteNullInOptr(SNode **pNode, SScalarCtx *ctx, EOperatorType opType) { if (opType <= OP_TYPE_CALC_MAX) { SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { @@ -704,7 +957,7 @@ EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opTy res->node.resType.type = TSDB_DATA_TYPE_NULL; nodesDestroyNode(*pNode); - *pNode = (SNode*)res; + *pNode = (SNode *)res; } else { SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); if (NULL == res) { @@ -718,17 +971,17 @@ EDealRes sclRewriteNullInOptr(SNode** pNode, SScalarCtx *ctx, EOperatorType opTy res->datum.b = false; nodesDestroyNode(*pNode); - *pNode = (SNode*)res; + *pNode = (SNode *)res; } return DEAL_RES_CONTINUE; } -EDealRes sclAggFuncWalker(SNode* pNode, void* pContext) { +EDealRes sclAggFuncWalker(SNode *pNode, void *pContext) { if (QUERY_NODE_FUNCTION == nodeType(pNode)) { - SFunctionNode* pFunc = (SFunctionNode*)pNode; - *(bool*)pContext = fmIsAggFunc(pFunc->funcId); - if (*(bool*)pContext) { + SFunctionNode *pFunc = (SFunctionNode *)pNode; + *(bool *)pContext = fmIsAggFunc(pFunc->funcId); + if (*(bool *)pContext) { return DEAL_RES_END; } } @@ -736,27 +989,26 @@ EDealRes sclAggFuncWalker(SNode* pNode, void* pContext) { return DEAL_RES_CONTINUE; } - -bool sclContainsAggFuncNode(SNode* pNode) { +bool sclContainsAggFuncNode(SNode *pNode) { bool aggFunc = false; nodesWalkExpr(pNode, sclAggFuncWalker, (void *)&aggFunc); return aggFunc; } -EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) { +EDealRes sclRewriteNonConstOperator(SNode **pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)*pNode; - int32_t code = 0; + int32_t code = 0; if (node->pLeft && (QUERY_NODE_VALUE == nodeType(node->pLeft))) { SValueNode *valueNode = (SValueNode *)node->pLeft; - if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) - && (!sclContainsAggFuncNode(node->pRight))) { + if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) && + (!sclContainsAggFuncNode(node->pRight))) { return sclRewriteNullInOptr(pNode, ctx, node->opType); } - if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight) - && ((SExprNode*)node->pRight)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) { - code = sclConvertToTsValueNode(((SExprNode*)node->pRight)->resType.precision, valueNode); + if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pRight && nodesIsExprNode(node->pRight) && + ((SExprNode *)node->pRight)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) { + code = sclConvertToTsValueNode(((SExprNode *)node->pRight)->resType.precision, valueNode); if (code) { ctx->code = code; return DEAL_RES_ERROR; @@ -765,19 +1017,19 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) { if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) { sclDowngradeValueType(valueNode); - } + } } if (node->pRight && (QUERY_NODE_VALUE == nodeType(node->pRight))) { SValueNode *valueNode = (SValueNode *)node->pRight; - if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) - && (!sclContainsAggFuncNode(node->pLeft))) { + if (SCL_IS_NULL_VALUE_NODE(valueNode) && (node->opType != OP_TYPE_IS_NULL && node->opType != OP_TYPE_IS_NOT_NULL) && + (!sclContainsAggFuncNode(node->pLeft))) { return sclRewriteNullInOptr(pNode, ctx, node->opType); } - if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft) - && ((SExprNode*)node->pLeft)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) { - code = sclConvertToTsValueNode(((SExprNode*)node->pLeft)->resType.precision, valueNode); + if (IS_STR_DATA_TYPE(valueNode->node.resType.type) && node->pLeft && nodesIsExprNode(node->pLeft) && + ((SExprNode *)node->pLeft)->resType.type == TSDB_DATA_TYPE_TIMESTAMP) { + code = sclConvertToTsValueNode(((SExprNode *)node->pLeft)->resType.precision, valueNode); if (code) { ctx->code = code; return DEAL_RES_ERROR; @@ -786,18 +1038,18 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) { if (SCL_IS_COMPARISON_OPERATOR(node->opType) && SCL_DOWNGRADE_DATETYPE(valueNode->node.resType.type)) { sclDowngradeValueType(valueNode); - } + } } if (node->pRight && (QUERY_NODE_NODE_LIST == nodeType(node->pRight))) { SNodeListNode *listNode = (SNodeListNode *)node->pRight; - SNode* tnode = NULL; + SNode *tnode = NULL; WHERE_EACH(tnode, listNode->pNodeList) { if (SCL_IS_NULL_VALUE_NODE(tnode)) { if (node->opType == OP_TYPE_IN) { ERASE_NODE(listNode->pNodeList); continue; - } else { //OP_TYPE_NOT_IN + } else { // OP_TYPE_NOT_IN return sclRewriteNullInOptr(pNode, ctx, node->opType); } } @@ -813,9 +1065,9 @@ EDealRes sclRewriteNonConstOperator(SNode** pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { +EDealRes sclRewriteFunction(SNode **pNode, SScalarCtx *ctx) { SFunctionNode *node = (SFunctionNode *)*pNode; - SNode* tnode = NULL; + SNode *tnode = NULL; if (!fmIsScalarFunc(node->funcId) && (!ctx->dual)) { return DEAL_RES_CONTINUE; } @@ -851,12 +1103,12 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { res->isNull = true; } else { int32_t type = output.columnData->info.type; - if (type == TSDB_DATA_TYPE_JSON){ + if (type == TSDB_DATA_TYPE_JSON) { int32_t len = getJsonValueLen(output.columnData->pData); res->datum.p = taosMemoryCalloc(len, 1); memcpy(res->datum.p, output.columnData->pData, len); } else if (IS_VAR_DATA_TYPE(type)) { - //res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1); + // res->datum.p = taosMemoryCalloc(res->node.resType.bytes + VARSTR_HEADER_SIZE + 1, 1); res->datum.p = taosMemoryCalloc(varDataTLen(output.columnData->pData) + 1, 1); res->node.resType.bytes = varDataTLen(output.columnData->pData); memcpy(res->datum.p, output.columnData->pData, varDataTLen(output.columnData->pData)); @@ -866,13 +1118,13 @@ EDealRes sclRewriteFunction(SNode** pNode, SScalarCtx *ctx) { } nodesDestroyNode(*pNode); - *pNode = (SNode*)res; + *pNode = (SNode *)res; sclFreeParam(&output); return DEAL_RES_CONTINUE; } -EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) { +EDealRes sclRewriteLogic(SNode **pNode, SScalarCtx *ctx) { SLogicConditionNode *node = (SLogicConditionNode *)*pNode; SScalarParam output = {0}; @@ -905,13 +1157,13 @@ EDealRes sclRewriteLogic(SNode** pNode, SScalarCtx *ctx) { } nodesDestroyNode(*pNode); - *pNode = (SNode*)res; + *pNode = (SNode *)res; sclFreeParam(&output); return DEAL_RES_CONTINUE; } -EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { +EDealRes sclRewriteOperator(SNode **pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)*pNode; if ((!SCL_IS_CONST_NODE(node->pLeft)) || (!SCL_IS_CONST_NODE(node->pRight))) { @@ -948,6 +1200,58 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { } } + nodesDestroyNode(*pNode); + *pNode = (SNode *)res; + + sclFreeParam(&output); + return DEAL_RES_CONTINUE; +} + +EDealRes sclRewriteCaseWhen(SNode** pNode, SScalarCtx *ctx) { + SCaseWhenNode *node = (SCaseWhenNode *)*pNode; + + if ((!SCL_IS_CONST_NODE(node->pCase)) || (!SCL_IS_CONST_NODE(node->pElse))) { + return DEAL_RES_CONTINUE; + } + + SNode* tnode = NULL; + FOREACH(tnode, node->pWhenThenList) { + SWhenThenNode* pWhenThen = (SWhenThenNode*)tnode; + if (!SCL_IS_CONST_NODE(pWhenThen->pWhen) || !SCL_IS_CONST_NODE(pWhenThen->pThen)) { + return DEAL_RES_CONTINUE; + } + } + + SScalarParam output = {0}; + ctx->code = sclExecCaseWhen(node, ctx, &output); + if (ctx->code) { + return DEAL_RES_ERROR; + } + + SValueNode *res = (SValueNode *)nodesMakeNode(QUERY_NODE_VALUE); + if (NULL == res) { + sclError("make value node failed"); + sclFreeParam(&output); + ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + + res->translate = true; + + res->node.resType = node->node.resType; + if (colDataIsNull_s(output.columnData, 0)) { + res->isNull = true; + res->node.resType = node->node.resType; + } else { + int32_t type = output.columnData->info.type; + if (IS_VAR_DATA_TYPE(type)) { // todo refactor + res->datum.p = output.columnData->pData; + output.columnData->pData = NULL; + } else { + nodesSetValueNodeValue(res, output.columnData->pData); + } + } + nodesDestroyNode(*pNode); *pNode = (SNode*)res; @@ -955,9 +1259,14 @@ EDealRes sclRewriteOperator(SNode** pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { + +EDealRes sclConstantsRewriter(SNode **pNode, void *pContext) { SScalarCtx *ctx = (SScalarCtx *)pContext; + if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { + return sclRewriteOperator(pNode, ctx); + } + if (QUERY_NODE_FUNCTION == nodeType(*pNode)) { return sclRewriteFunction(pNode, ctx); } @@ -966,16 +1275,16 @@ EDealRes sclConstantsRewriter(SNode** pNode, void* pContext) { return sclRewriteLogic(pNode, ctx); } - if (QUERY_NODE_OPERATOR == nodeType(*pNode)) { - return sclRewriteOperator(pNode, ctx); + if (QUERY_NODE_CASE_WHEN == nodeType(*pNode)) { + return sclRewriteCaseWhen(pNode, ctx); } return DEAL_RES_CONTINUE; } -EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { +EDealRes sclWalkFunction(SNode *pNode, SScalarCtx *ctx) { SFunctionNode *node = (SFunctionNode *)pNode; - SScalarParam output = {0}; + SScalarParam output = {0}; ctx->code = sclExecFunction(node, ctx, &output); if (ctx->code) { @@ -990,9 +1299,9 @@ EDealRes sclWalkFunction(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) { +EDealRes sclWalkLogic(SNode *pNode, SScalarCtx *ctx) { SLogicConditionNode *node = (SLogicConditionNode *)pNode; - SScalarParam output = {0}; + SScalarParam output = {0}; ctx->code = sclExecLogic(node, ctx, &output); if (ctx->code) { @@ -1007,9 +1316,9 @@ EDealRes sclWalkLogic(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) { +EDealRes sclWalkOperator(SNode *pNode, SScalarCtx *ctx) { SOperatorNode *node = (SOperatorNode *)pNode; - SScalarParam output = {0}; + SScalarParam output = {0}; ctx->code = sclExecOperator(node, ctx, &output); if (ctx->code) { @@ -1024,18 +1333,19 @@ EDealRes sclWalkOperator(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) { +EDealRes sclWalkTarget(SNode *pNode, SScalarCtx *ctx) { STargetNode *target = (STargetNode *)pNode; if (target->dataBlockId >= taosArrayGetSize(ctx->pBlockList)) { - sclError("target tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList)); + sclError("target tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, + (int32_t)taosArrayGetSize(ctx->pBlockList)); ctx->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } int32_t index = -1; - for(int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) { - SSDataBlock* pb = taosArrayGetP(ctx->pBlockList, i); + for (int32_t i = 0; i < taosArrayGetSize(ctx->pBlockList); ++i) { + SSDataBlock *pb = taosArrayGetP(ctx->pBlockList, i); if (pb->info.blockId == target->dataBlockId) { index = i; break; @@ -1043,7 +1353,8 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) { } if (index == -1) { - sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, (int32_t)taosArrayGetSize(ctx->pBlockList)); + sclError("column tupleId is too big, tupleId:%d, dataBlockNum:%d", target->dataBlockId, + (int32_t)taosArrayGetSize(ctx->pBlockList)); ctx->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } @@ -1051,7 +1362,8 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) { SSDataBlock *block = *(SSDataBlock **)taosArrayGet(ctx->pBlockList, index); if (target->slotId >= taosArrayGetSize(block->pDataBlock)) { - sclError("target slot not exist, dataBlockId:%d, slotId:%d, dataBlockNum:%d", target->dataBlockId, target->slotId, (int32_t)taosArrayGetSize(block->pDataBlock)); + sclError("target slot not exist, dataBlockId:%d, slotId:%d, dataBlockNum:%d", target->dataBlockId, target->slotId, + (int32_t)taosArrayGetSize(block->pDataBlock)); ctx->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } @@ -1074,12 +1386,36 @@ EDealRes sclWalkTarget(SNode* pNode, SScalarCtx *ctx) { return DEAL_RES_CONTINUE; } -EDealRes sclCalcWalker(SNode* pNode, void* pContext) { - if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) || QUERY_NODE_COLUMN == nodeType(pNode)|| QUERY_NODE_LEFT_VALUE == nodeType(pNode)) { +EDealRes sclWalkCaseWhen(SNode* pNode, SScalarCtx *ctx) { + SCaseWhenNode *node = (SCaseWhenNode *)pNode; + SScalarParam output = {0}; + + ctx->code = sclExecCaseWhen(node, ctx, &output); + if (ctx->code) { + return DEAL_RES_ERROR; + } + + if (taosHashPut(ctx->pRes, &pNode, POINTER_BYTES, &output, sizeof(output))) { + ctx->code = TSDB_CODE_QRY_OUT_OF_MEMORY; + return DEAL_RES_ERROR; + } + + return DEAL_RES_CONTINUE; +} + + +EDealRes sclCalcWalker(SNode *pNode, void *pContext) { + if (QUERY_NODE_VALUE == nodeType(pNode) || QUERY_NODE_NODE_LIST == nodeType(pNode) + || QUERY_NODE_COLUMN == nodeType(pNode) || QUERY_NODE_LEFT_VALUE == nodeType(pNode) + || QUERY_NODE_WHEN_THEN == nodeType(pNode)) { return DEAL_RES_CONTINUE; } SScalarCtx *ctx = (SScalarCtx *)pContext; + if (QUERY_NODE_OPERATOR == nodeType(pNode)) { + return sclWalkOperator(pNode, ctx); + } + if (QUERY_NODE_FUNCTION == nodeType(pNode)) { return sclWalkFunction(pNode, ctx); } @@ -1088,44 +1424,25 @@ EDealRes sclCalcWalker(SNode* pNode, void* pContext) { return sclWalkLogic(pNode, ctx); } - if (QUERY_NODE_OPERATOR == nodeType(pNode)) { - return sclWalkOperator(pNode, ctx); - } - if (QUERY_NODE_TARGET == nodeType(pNode)) { return sclWalkTarget(pNode, ctx); } + if (QUERY_NODE_CASE_WHEN == nodeType(pNode)) { + return sclWalkCaseWhen(pNode, ctx); + } + sclError("invalid node type for scalar calculating, type:%d", nodeType(pNode)); ctx->code = TSDB_CODE_QRY_INVALID_INPUT; return DEAL_RES_ERROR; } -int32_t sclExtendResRows(SScalarParam *pDst, SScalarParam *pSrc, SArray *pBlockList) { - SSDataBlock* pb = taosArrayGetP(pBlockList, 0); - SScalarParam *pLeft = taosMemoryCalloc(1, sizeof(SScalarParam)); - if (NULL == pLeft) { - sclError("calloc %d failed", (int32_t)sizeof(SScalarParam)); - SCL_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - pLeft->numOfRows = pb->info.rows; - colInfoDataEnsureCapacity(pDst->columnData, pb->info.rows); - - _bin_scalar_fn_t OperatorFn = getBinScalarOperatorFn(OP_TYPE_ASSIGN); - OperatorFn(pLeft, pSrc, pDst, TSDB_ORDER_ASC); - - taosMemoryFree(pLeft); - - return TSDB_CODE_SUCCESS; -} - int32_t sclCalcConstants(SNode *pNode, bool dual, SNode **pRes) { if (NULL == pNode) { SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; + int32_t code = 0; SScalarCtx ctx = {0}; ctx.dual = dual; ctx.pRes = taosHashInit(SCL_DEFAULT_OP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); @@ -1144,8 +1461,8 @@ _return: return code; } -static int32_t sclGetMinusOperatorResType(SOperatorNode* pOp) { - if (!IS_MATHABLE_TYPE(((SExprNode*)(pOp->pLeft))->resType.type)) { +static int32_t sclGetMinusOperatorResType(SOperatorNode *pOp) { + if (!IS_MATHABLE_TYPE(((SExprNode *)(pOp->pLeft))->resType.type)) { return TSDB_CODE_TSC_INVALID_OPERATION; } pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; @@ -1153,9 +1470,9 @@ static int32_t sclGetMinusOperatorResType(SOperatorNode* pOp) { return TSDB_CODE_SUCCESS; } -static int32_t sclGetMathOperatorResType(SOperatorNode* pOp) { - SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; - SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; +static int32_t sclGetMathOperatorResType(SOperatorNode *pOp) { + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; + SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; if ((TSDB_DATA_TYPE_TIMESTAMP == ldt.type && TSDB_DATA_TYPE_TIMESTAMP == rdt.type) || (TSDB_DATA_TYPE_TIMESTAMP == ldt.type && (IS_VAR_DATA_TYPE(rdt.type) || IS_FLOAT_TYPE(rdt.type))) || (TSDB_DATA_TYPE_TIMESTAMP == rdt.type && (IS_VAR_DATA_TYPE(ldt.type) || IS_FLOAT_TYPE(ldt.type)))) { @@ -1175,12 +1492,12 @@ static int32_t sclGetMathOperatorResType(SOperatorNode* pOp) { return TSDB_CODE_SUCCESS; } -static int32_t sclGetCompOperatorResType(SOperatorNode* pOp) { - SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; +static int32_t sclGetCompOperatorResType(SOperatorNode *pOp) { + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; if (OP_TYPE_IN == pOp->opType || OP_TYPE_NOT_IN == pOp->opType) { - ((SExprNode*)(pOp->pRight))->resType = ldt; + ((SExprNode *)(pOp->pRight))->resType = ldt; } else if (nodesIsRegularOp(pOp)) { - SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; + SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; if (!IS_VAR_DATA_TYPE(ldt.type) || QUERY_NODE_VALUE != nodeType(pOp->pRight) || (!IS_STR_DATA_TYPE(rdt.type) && (rdt.type != TSDB_DATA_TYPE_NULL))) { return TSDB_CODE_TSC_INVALID_OPERATION; @@ -1191,9 +1508,9 @@ static int32_t sclGetCompOperatorResType(SOperatorNode* pOp) { return TSDB_CODE_SUCCESS; } -static int32_t sclGetJsonOperatorResType(SOperatorNode* pOp) { - SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; - SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; +static int32_t sclGetJsonOperatorResType(SOperatorNode *pOp) { + SDataType ldt = ((SExprNode *)(pOp->pLeft))->resType; + SDataType rdt = ((SExprNode *)(pOp->pRight))->resType; if (TSDB_DATA_TYPE_JSON != ldt.type || !IS_STR_DATA_TYPE(rdt.type)) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -1206,27 +1523,22 @@ static int32_t sclGetJsonOperatorResType(SOperatorNode* pOp) { return TSDB_CODE_SUCCESS; } -static int32_t sclGetBitwiseOperatorResType(SOperatorNode* pOp) { +static int32_t sclGetBitwiseOperatorResType(SOperatorNode *pOp) { pOp->node.resType.type = TSDB_DATA_TYPE_BIGINT; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes; return TSDB_CODE_SUCCESS; } +int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, false, pRes); } -int32_t scalarCalculateConstants(SNode *pNode, SNode **pRes) { - return sclCalcConstants(pNode, false, pRes); -} - -int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) { - return sclCalcConstants(pNode, true, pRes); -} +int32_t scalarCalculateConstantsFromDual(SNode *pNode, SNode **pRes) { return sclCalcConstants(pNode, true, pRes); } int32_t scalarCalculate(SNode *pNode, SArray *pBlockList, SScalarParam *pDst) { if (NULL == pNode || NULL == pBlockList) { SCL_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; + int32_t code = 0; SScalarCtx ctx = {.code = 0, .pBlockList = pBlockList, .param = pDst ? pDst->param : NULL}; // TODO: OPT performance @@ -1264,9 +1576,9 @@ _return: return code; } -int32_t scalarGetOperatorResultType(SOperatorNode* pOp) { - if (TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pLeft))->resType.type || - (NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode*)(pOp->pRight))->resType.type)) { +int32_t scalarGetOperatorResultType(SOperatorNode *pOp) { + if (TSDB_DATA_TYPE_BLOB == ((SExprNode *)(pOp->pLeft))->resType.type || + (NULL != pOp->pRight && TSDB_DATA_TYPE_BLOB == ((SExprNode *)(pOp->pRight))->resType.type)) { return TSDB_CODE_TSC_INVALID_OPERATION; } @@ -1280,7 +1592,7 @@ int32_t scalarGetOperatorResultType(SOperatorNode* pOp) { case OP_TYPE_MINUS: return sclGetMinusOperatorResType(pOp); case OP_TYPE_ASSIGN: - pOp->node.resType = ((SExprNode*)(pOp->pLeft))->resType; + pOp->node.resType = ((SExprNode *)(pOp->pLeft))->resType; break; case OP_TYPE_BIT_AND: case OP_TYPE_BIT_OR: diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index 91044a96b53aed1c8d32c8fc57278f9b14499fd5..339065633bce5107df2879d45fbf259609a544a6 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -1,3 +1,4 @@ +#include "cJSON.h" #include "function.h" #include "scalar.h" #include "sclInt.h" @@ -5,20 +6,17 @@ #include "tdatablock.h" #include "tjson.h" #include "ttime.h" -#include "cJSON.h" #include "vnode.h" typedef float (*_float_fn)(float); typedef double (*_double_fn)(double); typedef double (*_double_fn_2)(double, double); typedef int (*_conv_fn)(int); -typedef void (*_trim_fn)(char *, char*, int32_t, int32_t); +typedef void (*_trim_fn)(char *, char *, int32_t, int32_t); typedef int16_t (*_len_fn)(char *, int32_t); /** Math functions **/ -static double tlog(double v) { - return log(v); -} +static double tlog(double v) { return log(v); } static double tlog2(double v, double base) { double a = log(v); @@ -33,86 +31,86 @@ static double tlog2(double v, double base) { } int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); switch (type) { case TSDB_DATA_TYPE_FLOAT: { - float *in = (float *)pInputData->pData; + float *in = (float *)pInputData->pData; float *out = (float *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } case TSDB_DATA_TYPE_DOUBLE: { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; double *out = (double *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } case TSDB_DATA_TYPE_TINYINT: { - int8_t *in = (int8_t *)pInputData->pData; + int8_t *in = (int8_t *)pInputData->pData; int8_t *out = (int8_t *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t *in = (int16_t *)pInputData->pData; + int16_t *in = (int16_t *)pInputData->pData; int16_t *out = (int16_t *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } case TSDB_DATA_TYPE_INT: { - int32_t *in = (int32_t *)pInputData->pData; + int32_t *in = (int32_t *)pInputData->pData; int32_t *out = (int32_t *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t *in = (int64_t *)pInputData->pData; + int64_t *in = (int64_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - out[i] = (in[i] >= 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0) ? in[i] : -in[i]; } break; } @@ -133,7 +131,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu return TSDB_CODE_SUCCESS; } -static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn valFn) { +static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _double_fn valFn) { int32_t type = GET_PARAM_TYPE(pInput); SColumnInfoData *pInputData = pInput->columnData; @@ -160,28 +158,26 @@ static int32_t doScalarFunctionUnique(SScalarParam *pInput, int32_t inputNum, SS return TSDB_CODE_SUCCESS; } -static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _double_fn_2 valFn) { - SColumnInfoData *pInputData[2]; - SColumnInfoData *pOutputData = pOutput->columnData; +static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, + _double_fn_2 valFn) { + SColumnInfoData *pInputData[2]; + SColumnInfoData *pOutputData = pOutput->columnData; _getDoubleValue_fn_t getValueFn[2]; for (int32_t i = 0; i < inputNum; ++i) { pInputData[i] = pInput[i].columnData; - getValueFn[i]= getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i])); + getValueFn[i] = getVectorDoubleValueFn(GET_PARAM_TYPE(&pInput[i])); } double *out = (double *)pOutputData->pData; - double result; + double result; - bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || - IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1]))); + bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1]))); int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows); if (pInput[0].numOfRows == pInput[1].numOfRows) { for (int32_t i = 0; i < numOfRows; ++i) { - if (colDataIsNull_s(pInputData[0], i) || - colDataIsNull_s(pInputData[1], i) || - hasNullType) { + if (colDataIsNull_s(pInputData[0], i) || colDataIsNull_s(pInputData[1], i) || hasNullType) { colDataAppendNULL(pOutputData, i); continue; } @@ -192,7 +188,7 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S out[i] = result; } } - } else if (pInput[0].numOfRows == 1) { //left operand is constant + } else if (pInput[0].numOfRows == 1) { // left operand is constant if (colDataIsNull_s(pInputData[0], 0) || hasNullType) { colDataAppendNNULL(pOutputData, 0, pInput[1].numOfRows); } else { @@ -236,15 +232,16 @@ static int32_t doScalarFunctionUnique2(SScalarParam *pInput, int32_t inputNum, S return TSDB_CODE_SUCCESS; } -static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam* pOutput, _float_fn f1, _double_fn d1) { +static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _float_fn f1, + _double_fn d1) { int32_t type = GET_PARAM_TYPE(pInput); - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; switch (type) { case TSDB_DATA_TYPE_FLOAT: { - float *in = (float *)pInputData->pData; + float *in = (float *)pInputData->pData; float *out = (float *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { @@ -258,7 +255,7 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP } case TSDB_DATA_TYPE_DOUBLE: { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; double *out = (double *)pOutputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { @@ -288,14 +285,12 @@ static int32_t doScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP } /** String functions **/ -static int16_t tlength(char *input, int32_t type) { - return varDataLen(input); -} +static int16_t tlength(char *input, int32_t type) { return varDataLen(input); } static int16_t tcharlength(char *input, int32_t type) { if (type == TSDB_DATA_TYPE_VARCHAR) { return varDataLen(input); - } else { //NCHAR + } else { // NCHAR return varDataLen(input) / TSDB_NCHAR_SIZE; } } @@ -309,7 +304,7 @@ static void tltrim(char *input, char *output, int32_t type, int32_t charLen) { } numOfSpaces++; } - } else { //NCHAR + } else { // NCHAR for (int32_t i = 0; i < charLen; ++i) { if (!iswspace(*((uint32_t *)varDataVal(input) + i))) { break; @@ -339,7 +334,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) { } numOfSpaces++; } - } else { //NCHAR + } else { // NCHAR for (int32_t i = charLen - 1; i >= 0; --i) { if (!iswspace(*((uint32_t *)varDataVal(input) + i))) { break; @@ -362,7 +357,7 @@ static void trtrim(char *input, char *output, int32_t type, int32_t charLen) { static int32_t doLengthFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _len_fn lenFn) { int32_t type = GET_PARAM_TYPE(pInput); - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; ASSERT(pOutputData->info.type == TSDB_DATA_TYPE_BIGINT); @@ -386,7 +381,7 @@ static int32_t concatCopyHelper(const char *input, char *output, bool hasNchar, if (hasNchar && type == TSDB_DATA_TYPE_VARCHAR) { TdUcs4 *newBuf = taosMemoryCalloc((varDataLen(input) + 1) * TSDB_NCHAR_SIZE, 1); int32_t len = varDataLen(input); - bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len); + bool ret = taosMbsToUcs4(varDataVal(input), len, newBuf, (varDataLen(input) + 1) * TSDB_NCHAR_SIZE, &len); if (!ret) { taosMemoryFree(newBuf); return TSDB_CODE_FAILED; @@ -415,15 +410,15 @@ static int32_t getNumOfNullEntries(SColumnInfoData *pColumnInfoData, int32_t num } int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int32_t ret = TSDB_CODE_SUCCESS; + int32_t ret = TSDB_CODE_SUCCESS; SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *)); - SColumnInfoData *pOutputData = pOutput->columnData; - char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); - char *outputBuf = NULL; + SColumnInfoData *pOutputData = pOutput->columnData; + char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); + char *outputBuf = NULL; int32_t inputLen = 0; int32_t numOfRows = 0; - bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; + bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; for (int32_t i = 0; i < inputNum; ++i) { if (pInput[i].numOfRows > numOfRows) { numOfRows = pInput[i].numOfRows; @@ -451,8 +446,7 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu for (int32_t k = 0; k < numOfRows; ++k) { bool hasNull = false; for (int32_t i = 0; i < inputNum; ++i) { - if (colDataIsNull_s(pInputData[i], k) || - IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) { + if (colDataIsNull_s(pInputData[i], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) { colDataAppendNULL(pOutputData, k); hasNull = true; break; @@ -463,7 +457,6 @@ int32_t concatFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu continue; } - int16_t dataLen = 0; for (int32_t i = 0; i < inputNum; ++i) { int32_t rowIdx = (pInput[i].numOfRows == 1) ? 0 : k; @@ -489,17 +482,16 @@ DONE: return ret; } - int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int32_t ret = TSDB_CODE_SUCCESS; + int32_t ret = TSDB_CODE_SUCCESS; SColumnInfoData **pInputData = taosMemoryCalloc(inputNum, sizeof(SColumnInfoData *)); - SColumnInfoData *pOutputData = pOutput->columnData; - char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); - char *outputBuf = NULL; + SColumnInfoData *pOutputData = pOutput->columnData; + char **input = taosMemoryCalloc(inputNum, POINTER_BYTES); + char *outputBuf = NULL; int32_t inputLen = 0; int32_t numOfRows = 0; - bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; + bool hasNchar = (GET_PARAM_TYPE(pOutput) == TSDB_DATA_TYPE_NCHAR) ? true : false; for (int32_t i = 1; i < inputNum; ++i) { if (pInput[i].numOfRows > numOfRows) { numOfRows = pInput[i].numOfRows; @@ -515,7 +507,8 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p int32_t numOfNulls = getNumOfNullEntries(pInputData[i], pInput[i].numOfRows); if (i == 0) { // calculate required separator space - inputLen += (pInputData[0]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * (inputNum - 2) * factor; + inputLen += + (pInputData[0]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * (inputNum - 2) * factor; } else if (pInput[i].numOfRows == 1) { inputLen += (pInputData[i]->varmeta.length - VARSTR_HEADER_SIZE) * (numOfRows - numOfNulls) * factor; } else { @@ -528,17 +521,15 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p char *output = outputBuf; for (int32_t k = 0; k < numOfRows; ++k) { - if (colDataIsNull_s(pInputData[0], k) || - IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0]))) { + if (colDataIsNull_s(pInputData[0], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0]))) { colDataAppendNULL(pOutputData, k); continue; } int16_t dataLen = 0; - bool hasNull = false; + bool hasNull = false; for (int32_t i = 1; i < inputNum; ++i) { - if (colDataIsNull_s(pInputData[i], k) || - IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) { + if (colDataIsNull_s(pInputData[i], k) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[i]))) { hasNull = true; break; } @@ -551,11 +542,10 @@ int32_t concatWsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p goto DONE; } - if (i < inputNum - 1) { - //insert the separator + // insert the separator char *sep = (pInput[0].numOfRows == 1) ? colDataGetData(pInputData[0], 0) : colDataGetData(pInputData[0], k); - ret = concatCopyHelper(sep, output, hasNchar, GET_PARAM_TYPE(&pInput[0]), &dataLen); + ret = concatCopyHelper(sep, output, hasNchar, GET_PARAM_TYPE(&pInput[0]), &dataLen); if (ret != TSDB_CODE_SUCCESS) { goto DONE; } @@ -585,12 +575,12 @@ DONE: static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _conv_fn convFn) { int32_t type = GET_PARAM_TYPE(pInput); - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t outputLen = pInputData->varmeta.length; - char *outputBuf = taosMemoryCalloc(outputLen, 1); - char *output = outputBuf; + char *outputBuf = taosMemoryCalloc(outputLen, 1); + char *output = outputBuf; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { @@ -598,13 +588,13 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala continue; } - char *input = colDataGetData(pInput[0].columnData, i); + char *input = colDataGetData(pInput[0].columnData, i); int32_t len = varDataLen(input); if (type == TSDB_DATA_TYPE_VARCHAR) { for (int32_t j = 0; j < len; ++j) { *(varDataVal(output) + j) = convFn(*(varDataVal(input) + j)); } - } else { //NCHAR + } else { // NCHAR for (int32_t j = 0; j < len / TSDB_NCHAR_SIZE; ++j) { *((uint32_t *)varDataVal(output) + j) = convFn(*((uint32_t *)varDataVal(input) + j)); } @@ -620,16 +610,15 @@ static int32_t doCaseConvFunction(SScalarParam *pInput, int32_t inputNum, SScala return TSDB_CODE_SUCCESS; } - static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, _trim_fn trimFn) { int32_t type = GET_PARAM_TYPE(pInput); - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t outputLen = pInputData->varmeta.length; - char *outputBuf = taosMemoryCalloc(outputLen, 1); - char *output = outputBuf; + char *outputBuf = taosMemoryCalloc(outputLen, 1); + char *output = outputBuf; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { @@ -637,7 +626,7 @@ static int32_t doTrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar continue; } - char *input = colDataGetData(pInputData, i); + char *input = colDataGetData(pInputData, i); int32_t len = varDataLen(input); int32_t charLen = (type == TSDB_DATA_TYPE_VARCHAR) ? len : len / TSDB_NCHAR_SIZE; trimFn(input, output, type, charLen); @@ -662,19 +651,19 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu subLen = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? subLen : subLen * TSDB_NCHAR_SIZE; } - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t outputLen = pInputData->varmeta.length * pInput->numOfRows; - char *outputBuf = taosMemoryCalloc(outputLen, 1); - char *output = outputBuf; + char *outputBuf = taosMemoryCalloc(outputLen, 1); + char *output = outputBuf; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { colDataAppendNULL(pOutputData, i); continue; } - char *input = colDataGetData(pInput[0].columnData, i); + char *input = colDataGetData(pInput[0].columnData, i); int32_t len = varDataLen(input); int32_t startPosBytes; @@ -682,7 +671,8 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? subPos - 1 : (subPos - 1) * TSDB_NCHAR_SIZE; startPosBytes = TMIN(startPosBytes, len); } else { - startPosBytes = (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE; + startPosBytes = + (GET_PARAM_TYPE(pInput) == TSDB_DATA_TYPE_VARCHAR) ? len + subPos : len + subPos * TSDB_NCHAR_SIZE; startPosBytes = TMAX(startPosBytes, 0); } @@ -692,7 +682,7 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu } varDataSetLen(output, resLen); - colDataAppend(pOutputData, i , output, false); + colDataAppend(pOutputData, i, output, false); output += varDataTLen(output); } @@ -704,14 +694,14 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu /** Conversion functions **/ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - int16_t inputType = GET_PARAM_TYPE(&pInput[0]); - int16_t inputLen = GET_PARAM_BYTES(&pInput[0]); + int16_t inputType = GET_PARAM_TYPE(&pInput[0]); + int16_t inputLen = GET_PARAM_BYTES(&pInput[0]); int16_t outputType = GET_PARAM_TYPE(&pOutput[0]); - int64_t outputLen = GET_PARAM_BYTES(&pOutput[0]); + int64_t outputLen = GET_PARAM_BYTES(&pOutput[0]); int32_t code = TSDB_CODE_SUCCESS; - char * convBuf = taosMemoryMalloc(inputLen); - char * output = taosMemoryCalloc(1, outputLen + TSDB_NCHAR_SIZE); + char *convBuf = taosMemoryMalloc(inputLen); + char *output = taosMemoryCalloc(1, outputLen + TSDB_NCHAR_SIZE); char buf[400] = {0}; if (convBuf == NULL || output == NULL) { @@ -727,14 +717,14 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp char *input = colDataGetData(pInput[0].columnData, i); - switch(outputType) { + switch (outputType) { case TSDB_DATA_TYPE_TINYINT: { if (inputType == TSDB_DATA_TYPE_BINARY) { memcpy(buf, varDataVal(input), varDataLen(input)); buf[varDataLen(input)] = 0; *(int8_t *)output = taosStr2Int8(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -753,7 +743,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(int16_t *)output = taosStr2Int16(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -771,7 +761,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(int32_t *)output = taosStr2Int32(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -790,7 +780,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(int64_t *)output = taosStr2Int64(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -881,7 +871,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(float *)output = taosStr2Float(buf, NULL); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -899,7 +889,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(double *)output = taosStr2Double(buf, NULL); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -917,7 +907,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp buf[varDataLen(input)] = 0; *(bool *)output = taosStr2Int8(buf, NULL, 10); } else if (inputType == TSDB_DATA_TYPE_NCHAR) { - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(input), varDataLen(input), convBuf); if (len < 0) { code = TSDB_CODE_FAILED; goto _end; @@ -948,7 +938,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp case TSDB_DATA_TYPE_BINARY: { if (inputType == TSDB_DATA_TYPE_BOOL) { // NOTE: sprintf will append '\0' at the end of string - int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), *(int8_t *)input ? "true" : "false"); + int32_t len = sprintf(varDataVal(output), "%.*s", (int32_t)(outputLen - VARSTR_HEADER_SIZE), + *(int8_t *)input ? "true" : "false"); varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_BINARY) { int32_t len = TMIN(varDataLen(input), outputLen - VARSTR_HEADER_SIZE); @@ -977,7 +968,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp int32_t len; if (inputType == TSDB_DATA_TYPE_BOOL) { char tmp[8] = {0}; - len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false" ); + len = sprintf(tmp, "%.*s", outputCharLen, *(int8_t *)input ? "true" : "false"); bool ret = taosMbsToUcs4(tmp, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len); if (!ret) { code = TSDB_CODE_FAILED; @@ -987,7 +978,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp varDataSetLen(output, len); } else if (inputType == TSDB_DATA_TYPE_BINARY) { len = outputCharLen > varDataLen(input) ? varDataLen(input) : outputCharLen; - bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output), outputLen - VARSTR_HEADER_SIZE, &len); + bool ret = taosMbsToUcs4(input + VARSTR_HEADER_SIZE, len, (TdUcs4 *)varDataVal(output), + outputLen - VARSTR_HEADER_SIZE, &len); if (!ret) { code = TSDB_CODE_FAILED; goto _end; @@ -1009,7 +1001,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp varDataSetLen(output, len); } - //for constant conversion, need to set proper length of pOutput description + // for constant conversion, need to set proper length of pOutput description if (len < outputLen) { pOutput->columnData->info.bytes = len + VARSTR_HEADER_SIZE; } @@ -1027,7 +1019,7 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp pOutput->numOfRows = pInput->numOfRows; - _end: +_end: taosMemoryFree(output); taosMemoryFree(convBuf); return code; @@ -1036,8 +1028,8 @@ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutp int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int32_t type = GET_PARAM_TYPE(pInput); - bool tzPresent = (inputNum == 2) ? true : false; - char* tz; + bool tzPresent = (inputNum == 2) ? true : false; + char *tz; int32_t tzLen; if (tzPresent) { tz = varDataVal(pInput[1].columnData->pData); @@ -1051,12 +1043,12 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * } char *input = colDataGetData(pInput[0].columnData, i); - char fraction[20] = {0}; - bool hasFraction = false; + char fraction[20] = {0}; + bool hasFraction = false; NUM_TO_STRING(type, input, sizeof(fraction), fraction); int32_t tsDigits = (int32_t)strlen(fraction); - char buf[64] = {0}; + char buf[64] = {0}; int64_t timeVal; GET_TYPED_DATA(timeVal, int64_t, type, input); if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS) { @@ -1079,7 +1071,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * strftime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tmInfo); int32_t len = (int32_t)strlen(buf); - //add timezone string + // add timezone string snprintf(buf + len, tzLen + 1, "%s", tz); len += tzLen; @@ -1095,7 +1087,7 @@ int32_t toISO8601Function(SScalarParam *pInput, int32_t inputNum, SScalarParam * if (tzInfo) { memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo)); } else { - //search '-' backwards + // search '-' backwards tzInfo = strrchr(buf, '-'); if (tzInfo) { memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo)); @@ -1151,25 +1143,25 @@ int32_t toJsonFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu char tmp[TSDB_MAX_JSON_TAG_LEN] = {0}; for (int32_t i = 0; i < pInput[0].numOfRows; ++i) { - SArray* pTagVals = taosArrayInit(8, sizeof(STagVal)); - STag* pTag = NULL; + SArray *pTagVals = taosArrayInit(8, sizeof(STagVal)); + STag *pTag = NULL; if (colDataIsNull_s(pInput[0].columnData, i)) { tTagNew(pTagVals, 1, true, &pTag); - }else{ + } else { char *input = pInput[0].columnData->pData + pInput[0].columnData->varmeta.offset[i]; - if (varDataLen(input) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE){ + if (varDataLen(input) > (TSDB_MAX_JSON_TAG_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE) { taosArrayDestroy(pTagVals); return TSDB_CODE_FAILED; } memcpy(tmp, varDataVal(input), varDataLen(input)); tmp[varDataLen(input)] = 0; - if(parseJsontoTagData(tmp, pTagVals, &pTag, NULL)){ + if (parseJsontoTagData(tmp, pTagVals, &pTag, NULL)) { tTagNew(pTagVals, 1, true, &pTag); } } - colDataAppend(pOutput->columnData, i, (const char*)pTag, false); + colDataAppend(pOutput->columnData, i, (const char *)pTag, false); tTagFree(pTag); taosArrayDestroy(pTagVals); } @@ -1186,8 +1178,8 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara GET_TYPED_DATA(timeUnit, int64_t, GET_PARAM_TYPE(&pInput[1]), pInput[1].columnData->pData); GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); - int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : - (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); + int64_t factor = + (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); int64_t unit = timeUnit * 1000 / factor; @@ -1205,7 +1197,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara colDataAppendNULL(pOutput->columnData, i); continue; } - //If converted value is less than 10digits in second, use value in second instead + // If converted value is less than 10digits in second, use value in second instead int64_t timeValSec = timeVal / 1000000000; if (timeValSec < 1000000000) { timeVal = timeValSec; @@ -1246,7 +1238,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara timeVal = timeVal / 1000 * 1000; } else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) { timeVal = timeVal / 1000000 * 1000000; - } else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS){ + } else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) { timeVal = timeVal * factor; } else { colDataAppendNULL(pOutput->columnData, i); @@ -1307,7 +1299,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) { timeVal = timeVal / 1000000000 / 86400 * 86400 * 1000000000; } else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) { - timeVal = timeVal * factor / factor / 86400* 86400 * factor; + timeVal = timeVal * factor / factor / 86400 * 86400 * factor; } else { colDataAppendNULL(pOutput->columnData, i); continue; @@ -1322,7 +1314,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } else if (tsDigits == TSDB_TIME_PRECISION_NANO_DIGITS) { timeVal = timeVal / 1000000000 / 604800 * 604800 * 1000000000; } else if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) { - timeVal = timeVal * factor / factor / 604800 * 604800* factor; + timeVal = timeVal * factor / factor / 604800 * 604800 * factor; } else { colDataAppendNULL(pOutput->columnData, i); continue; @@ -1335,7 +1327,7 @@ int32_t timeTruncateFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } } - //truncate the timestamp to db precision + // truncate the timestamp to db precision switch (timePrec) { case TSDB_TIME_PRECISION_MILLI: { if (tsDigits == TSDB_TIME_PRECISION_MICRO_DIGITS) { @@ -1380,8 +1372,8 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p GET_TYPED_DATA(timePrec, int64_t, GET_PARAM_TYPE(&pInput[2]), pInput[2].columnData->pData); } - int64_t factor = (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : - (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); + int64_t factor = + (timePrec == TSDB_TIME_PRECISION_MILLI) ? 1000 : (timePrec == TSDB_TIME_PRECISION_MICRO ? 1000000 : 1000000000); int32_t numOfRows = 0; for (int32_t i = 0; i < inputNum; ++i) { @@ -1441,11 +1433,10 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p continue; } - int64_t result = (timeVal[0] >= timeVal[1]) ? (timeVal[0] - timeVal[1]) : - (timeVal[1] - timeVal[0]); + int64_t result = (timeVal[0] >= timeVal[1]) ? (timeVal[0] - timeVal[1]) : (timeVal[1] - timeVal[0]); - if (timeUnit < 0) { // if no time unit given use db precision - switch(timePrec) { + if (timeUnit < 0) { // if no time unit given use db precision + switch (timePrec) { case TSDB_TIME_PRECISION_MILLI: { result = result / 1000000; break; @@ -1461,7 +1452,7 @@ int32_t timeDiffFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p } } else { int64_t unit = timeUnit * 1000 / factor; - switch(unit) { + switch (unit) { case 0: { /* 1u or 1b */ if (timePrec == TSDB_TIME_PRECISION_NANO && timeUnit == 1) { result = result / 1; @@ -1694,7 +1685,7 @@ static void reverseCopy(char* dest, const char* src, int16_t type, int32_t numOf } #endif -bool getTimePseudoFuncEnv(SFunctionNode* UNUSED_PARAM(pFunc), SFuncExecEnv* pEnv) { +bool getTimePseudoFuncEnv(SFunctionNode *UNUSED_PARAM(pFunc), SFuncExecEnv *pEnv) { pEnv->calcMemSize = sizeof(int64_t); return true; } @@ -1719,13 +1710,13 @@ int32_t winDurFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu int32_t winStartTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { ASSERT(inputNum == 1); - colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 3)); + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 3)); return TSDB_CODE_SUCCESS; } int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { ASSERT(inputNum == 1); - colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 4)); + colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t *)colDataGetData(pInput->columnData, 4)); return TSDB_CODE_SUCCESS; } @@ -1743,7 +1734,7 @@ int32_t qTbnameFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pO /** Aggregation functions **/ int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int64_t *out = (int64_t *)pOutputData->pData; @@ -1760,11 +1751,11 @@ int32_t countScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam } int32_t sumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); - bool hasNull = false; + bool hasNull = false; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { hasNull = true; @@ -1772,15 +1763,15 @@ int32_t sumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } if (IS_SIGNED_NUMERIC_TYPE(type)) { - int64_t *in = (int64_t *)pInputData->pData; + int64_t *in = (int64_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; *out += in[i]; } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - uint64_t *in = (uint64_t *)pInputData->pData; + uint64_t *in = (uint64_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; *out += in[i]; } else if (IS_FLOAT_TYPE(type)) { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; double *out = (double *)pOutputData->pData; *out += in[i]; } @@ -1795,7 +1786,7 @@ int32_t sumScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput, bool isMinFunc) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); @@ -1813,84 +1804,84 @@ static int32_t doMinMaxScalarFunction(SScalarParam *pInput, int32_t inputNum, SS break; } - switch(type) { + switch (type) { case TSDB_DATA_TYPE_BOOL: case TSDB_DATA_TYPE_TINYINT: { - int8_t *in = (int8_t *)pInputData->pData; + int8_t *in = (int8_t *)pInputData->pData; int8_t *out = (int8_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t *in = (int16_t *)pInputData->pData; + int16_t *in = (int16_t *)pInputData->pData; int16_t *out = (int16_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_INT: { - int32_t *in = (int32_t *)pInputData->pData; + int32_t *in = (int32_t *)pInputData->pData; int32_t *out = (int32_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t *in = (int64_t *)pInputData->pData; + int64_t *in = (int64_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t *in = (uint8_t *)pInputData->pData; + uint8_t *in = (uint8_t *)pInputData->pData; uint8_t *out = (uint8_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t *in = (uint16_t *)pInputData->pData; + uint16_t *in = (uint16_t *)pInputData->pData; uint16_t *out = (uint16_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_UINT: { - uint32_t *in = (uint32_t *)pInputData->pData; + uint32_t *in = (uint32_t *)pInputData->pData; uint32_t *out = (uint32_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t *in = (uint64_t *)pInputData->pData; + uint64_t *in = (uint64_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_FLOAT: { - float *in = (float *)pInputData->pData; + float *in = (float *)pInputData->pData; float *out = (float *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; } case TSDB_DATA_TYPE_DOUBLE: { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; double *out = (double *)pOutputData->pData; - if((in[i] > *out) ^ isMinFunc) { + if ((in[i] > *out) ^ isMinFunc) { *out = in[i]; } break; @@ -1915,12 +1906,12 @@ int32_t maxScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); int64_t count = 0; - bool hasNull = false; + bool hasNull = false; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { @@ -1928,72 +1919,72 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * break; } - switch(type) { + switch (type) { case TSDB_DATA_TYPE_TINYINT: { - int8_t *in = (int8_t *)pInputData->pData; + int8_t *in = (int8_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t *in = (int16_t *)pInputData->pData; + int16_t *in = (int16_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_INT: { - int32_t *in = (int32_t *)pInputData->pData; + int32_t *in = (int32_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t *in = (int64_t *)pInputData->pData; + int64_t *in = (int64_t *)pInputData->pData; int64_t *out = (int64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t *in = (uint8_t *)pInputData->pData; + uint8_t *in = (uint8_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t *in = (uint16_t *)pInputData->pData; + uint16_t *in = (uint16_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_UINT: { - uint32_t *in = (uint32_t *)pInputData->pData; + uint32_t *in = (uint32_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t *in = (uint64_t *)pInputData->pData; + uint64_t *in = (uint64_t *)pInputData->pData; uint64_t *out = (uint64_t *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_FLOAT: { - float *in = (float *)pInputData->pData; + float *in = (float *)pInputData->pData; float *out = (float *)pOutputData->pData; *out += in[i]; count++; break; } case TSDB_DATA_TYPE_DOUBLE: { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; double *out = (double *)pOutputData->pData; *out += in[i]; count++; @@ -2006,13 +1997,13 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * colDataAppendNULL(pOutputData, 0); } else { if (IS_SIGNED_NUMERIC_TYPE(type)) { - int64_t *out = (int64_t *)pOutputData->pData; + int64_t *out = (int64_t *)pOutputData->pData; *(double *)out = *out / (double)count; } else if (IS_UNSIGNED_NUMERIC_TYPE(type)) { - uint64_t *out = (uint64_t *)pOutputData->pData; + uint64_t *out = (uint64_t *)pOutputData->pData; *(double *)out = *out / (double)count; } else if (IS_FLOAT_TYPE(type)) { - double *out = (double *)pOutputData->pData; + double *out = (double *)pOutputData->pData; *(double *)out = *out / (double)count; } } @@ -2022,11 +2013,11 @@ int32_t avgScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam * } int32_t stddevScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); - //int64_t count = 0, sum = 0, qSum = 0; + // int64_t count = 0, sum = 0, qSum = 0; bool hasNull = false; for (int32_t i = 0; i < pInput->numOfRows; ++i) { @@ -2110,7 +2101,7 @@ int32_t stddevScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara #endif } - double *out = (double *)pOutputData->pData; + double *out = (double *)pOutputData->pData; if (hasNull) { colDataAppendNULL(pOutputData, 0); } else { @@ -2144,7 +2135,7 @@ int32_t stddevScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } while (0) int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; double startVal, stepVal; @@ -2155,9 +2146,9 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa int32_t type = GET_PARAM_TYPE(pInput); int64_t count = 0; - switch(type) { + switch (type) { case TSDB_DATA_TYPE_TINYINT: { - int8_t *in = (int8_t *)pInputData->pData; + int8_t *in = (int8_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2169,7 +2160,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t *in = (int16_t *)pInputData->pData; + int16_t *in = (int16_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2181,7 +2172,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_INT: { - int32_t *in = (int32_t *)pInputData->pData; + int32_t *in = (int32_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2193,7 +2184,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t *in = (int64_t *)pInputData->pData; + int64_t *in = (int64_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2205,7 +2196,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t *in = (uint8_t *)pInputData->pData; + uint8_t *in = (uint8_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2217,7 +2208,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t *in = (uint16_t *)pInputData->pData; + uint16_t *in = (uint16_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2229,7 +2220,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_UINT: { - uint32_t *in = (uint32_t *)pInputData->pData; + uint32_t *in = (uint32_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2241,7 +2232,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t *in = (uint64_t *)pInputData->pData; + uint64_t *in = (uint64_t *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2253,7 +2244,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_FLOAT: { - float *in = (float *)pInputData->pData; + float *in = (float *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2265,7 +2256,7 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa break; } case TSDB_DATA_TYPE_DOUBLE: { - double *in = (double *)pInputData->pData; + double *in = (double *)pInputData->pData; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { continue; @@ -2292,11 +2283,10 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa matrix12 /= matrix[1][1]; char buf[64] = {0}; - size_t len = - snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02, matrix12); + size_t len = snprintf(varDataVal(buf), sizeof(buf) - VARSTR_HEADER_SIZE, "{slop:%.6lf, intercept:%.6lf}", matrix02, + matrix12); varDataSetLen(buf, len); colDataAppend(pOutputData, 0, buf, false); - } pOutput->numOfRows = 1; @@ -2304,13 +2294,13 @@ int32_t leastSQRScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPa } int32_t percentileScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); double val; - bool hasNull = false; + bool hasNull = false; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { hasNull = true; @@ -2335,7 +2325,7 @@ int32_t apercentileScalarFunction(SScalarParam *pInput, int32_t inputNum, SScala } int32_t spreadScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); @@ -2377,11 +2367,11 @@ int32_t spreadScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara } int32_t nonCalcScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); - bool hasNull = false; + bool hasNull = false; for (int32_t i = 0; i < pInput->numOfRows; ++i) { if (colDataIsNull_s(pInputData, i)) { @@ -2390,7 +2380,7 @@ int32_t nonCalcScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPar } } - double *out = (double *)pOutputData->pData; + double *out = (double *)pOutputData->pData; if (hasNull) { colDataAppendNULL(pOutputData, 0); } else { @@ -2469,7 +2459,7 @@ typedef enum { } \ } while (0) -static int8_t getStateOpType(char* opStr) { +static int8_t getStateOpType(char *opStr) { int8_t opType; if (strncasecmp(opStr, "LT", 2) == 0) { opType = STATE_OPER_LT; @@ -2490,58 +2480,58 @@ static int8_t getStateOpType(char* opStr) { return opType; } -static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SScalarParam *pCondParam) { - char* data = colDataGetData(pCol, index); - char* param = pCondParam->columnData->pData; +static bool checkStateOp(int8_t op, SColumnInfoData *pCol, int32_t index, SScalarParam *pCondParam) { + char *data = colDataGetData(pCol, index); + char *param = pCondParam->columnData->pData; int32_t paramType = GET_PARAM_TYPE(pCondParam); switch (pCol->info.type) { case TSDB_DATA_TYPE_TINYINT: { - int8_t v = *(int8_t*)data; + int8_t v = *(int8_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_UTINYINT: { - uint8_t v = *(uint8_t*)data; + uint8_t v = *(uint8_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_SMALLINT: { - int16_t v = *(int16_t*)data; + int16_t v = *(int16_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_USMALLINT: { - uint16_t v = *(uint16_t*)data; + uint16_t v = *(uint16_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_INT: { - int32_t v = *(int32_t*)data; + int32_t v = *(int32_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_UINT: { - uint32_t v = *(uint32_t*)data; + uint32_t v = *(uint32_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_BIGINT: { - int64_t v = *(int64_t*)data; + int64_t v = *(int64_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_UBIGINT: { - uint64_t v = *(uint64_t*)data; + uint64_t v = *(uint64_t *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_FLOAT: { - float v = *(float*)data; + float v = *(float *)data; STATE_COMP(op, v, param, paramType); break; } case TSDB_DATA_TYPE_DOUBLE: { - double v = *(double*)data; + double v = *(double *)data; STATE_COMP(op, v, param, paramType); break; } @@ -2553,10 +2543,10 @@ static bool checkStateOp(int8_t op, SColumnInfoData* pCol, int32_t index, SScala } int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; - int8_t op = getStateOpType(varDataVal(pInput[1].columnData->pData)); + int8_t op = getStateOpType(varDataVal(pInput[1].columnData->pData)); int64_t count = 0; for (int32_t i = 0; i < pInput->numOfRows; ++i) { @@ -2565,14 +2555,14 @@ int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalar continue; } - bool ret = checkStateOp(op, pInputData, i, &pInput[2]); + bool ret = checkStateOp(op, pInputData, i, &pInput[2]); int64_t out = -1; if (ret) { out = ++count; } else { count = 0; } - colDataAppend(pOutputData, i, (char*)&out, false); + colDataAppend(pOutputData, i, (char *)&out, false); } pOutput->numOfRows = pInput->numOfRows; @@ -2580,7 +2570,7 @@ int32_t stateCountScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalar } int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int8_t op = getStateOpType(varDataVal(pInput[1].columnData->pData)); @@ -2591,12 +2581,12 @@ int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SSca continue; } - bool ret = checkStateOp(op, pInputData, i, &pInput[2]); + bool ret = checkStateOp(op, pInputData, i, &pInput[2]); int64_t out = -1; if (ret) { out = 0; } - colDataAppend(pOutputData, i, (char*)&out, false); + colDataAppend(pOutputData, i, (char *)&out, false); } pOutput->numOfRows = pInput->numOfRows; @@ -2605,7 +2595,7 @@ int32_t stateDurationScalarFunction(SScalarParam *pInput, int32_t inputNum, SSca typedef enum { UNKNOWN_BIN = 0, USER_INPUT_BIN, LINEAR_BIN, LOG_BIN } EHistoBinType; -static int8_t getHistogramBinType(char* binTypeStr) { +static int8_t getHistogramBinType(char *binTypeStr) { int8_t binType; if (strcasecmp(binTypeStr, "user_input") == 0) { binType = USER_INPUT_BIN; @@ -2627,10 +2617,11 @@ typedef struct SHistoFuncBin { double percentage; } SHistoFuncBin; -static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* binDescStr, int8_t binType, bool normalized) { - cJSON* binDesc = cJSON_Parse(binDescStr); +static bool getHistogramBinDesc(SHistoFuncBin **bins, int32_t *binNum, char *binDescStr, int8_t binType, + bool normalized) { + cJSON *binDesc = cJSON_Parse(binDescStr); int32_t numOfBins; - double* intervals; + double *intervals; if (cJSON_IsObject(binDesc)) { /* linaer/log bins */ int32_t numOfParams = cJSON_GetArraySize(binDesc); int32_t startIndex; @@ -2638,11 +2629,11 @@ static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* bin return false; } - cJSON* start = cJSON_GetObjectItem(binDesc, "start"); - cJSON* factor = cJSON_GetObjectItem(binDesc, "factor"); - cJSON* width = cJSON_GetObjectItem(binDesc, "width"); - cJSON* count = cJSON_GetObjectItem(binDesc, "count"); - cJSON* infinity = cJSON_GetObjectItem(binDesc, "infinity"); + cJSON *start = cJSON_GetObjectItem(binDesc, "start"); + cJSON *factor = cJSON_GetObjectItem(binDesc, "factor"); + cJSON *width = cJSON_GetObjectItem(binDesc, "width"); + cJSON *count = cJSON_GetObjectItem(binDesc, "count"); + cJSON *infinity = cJSON_GetObjectItem(binDesc, "infinity"); if (!cJSON_IsNumber(start) || !cJSON_IsNumber(count) || !cJSON_IsBool(infinity)) { return false; @@ -2719,7 +2710,7 @@ static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* bin } numOfBins = cJSON_GetArraySize(binDesc); intervals = taosMemoryCalloc(numOfBins, sizeof(double)); - cJSON* bin = binDesc->child; + cJSON *bin = binDesc->child; if (bin == NULL) { taosMemoryFree(intervals); return false; @@ -2756,15 +2747,15 @@ static bool getHistogramBinDesc(SHistoFuncBin** bins, int32_t* binNum, char* bin } int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; SHistoFuncBin *bins; - int32_t numOfBins = 0; - int32_t totalCount = 0; + int32_t numOfBins = 0; + int32_t totalCount = 0; - int8_t binType = getHistogramBinType(varDataVal(pInput[1].columnData->pData)); - char* binDesc = varDataVal(pInput[2].columnData->pData); + int8_t binType = getHistogramBinType(varDataVal(pInput[1].columnData->pData)); + char *binDesc = varDataVal(pInput[2].columnData->pData); int64_t normalized = *(int64_t *)(pInput[3].columnData->pData); int32_t type = GET_PARAM_TYPE(pInput); @@ -2777,7 +2768,7 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP continue; } - char* data = colDataGetData(pInputData, i); + char *data = colDataGetData(pInputData, i); double v; GET_TYPED_DATA(v, double, type, data); @@ -2804,11 +2795,11 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP int32_t len; char buf[512] = {0}; if (!normalized) { - len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}", - bins[k].lower, bins[k].upper, bins[k].count); + len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%" PRId64 "}", bins[k].lower, + bins[k].upper, bins[k].count); } else { - len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", - bins[k].lower, bins[k].upper, bins[k].percentage); + len = sprintf(varDataVal(buf), "{\"lower_bin\":%g, \"upper_bin\":%g, \"count\":%lf}", bins[k].lower, + bins[k].upper, bins[k].percentage); } varDataSetLen(buf, len); colDataAppend(pOutputData, k, buf, false); @@ -2820,7 +2811,7 @@ int32_t histogramScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarP } int32_t selectScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { - SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pInputData = pInput->columnData; SColumnInfoData *pOutputData = pOutput->columnData; int32_t type = GET_PARAM_TYPE(pInput); @@ -2831,11 +2822,10 @@ int32_t selectScalarFunction(SScalarParam *pInput, int32_t inputNum, SScalarPara continue; } - char* data = colDataGetData(pInputData, i); + char *data = colDataGetData(pInputData, i); colDataAppend(pOutputData, i, data, false); } - pOutput->numOfRows = 1; return TSDB_CODE_SUCCESS; } diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index 339b18bc06e20f5e42b75927c01429dbc32b06b3..f467721248a5949ac2cdf22abb81342c89d531b9 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -24,19 +24,20 @@ #include "tcompare.h" #include "tdatablock.h" #include "tdataformat.h" -#include "ttypes.h" #include "ttime.h" +#include "ttypes.h" -#define LEFT_COL ((pLeftCol->info.type == TSDB_DATA_TYPE_JSON ? (void*)pLeftCol : pLeftCol->pData)) -#define RIGHT_COL ((pRightCol->info.type == TSDB_DATA_TYPE_JSON ? (void*)pRightCol : pRightCol->pData)) +#define LEFT_COL ((pLeftCol->info.type == TSDB_DATA_TYPE_JSON ? (void *)pLeftCol : pLeftCol->pData)) +#define RIGHT_COL ((pRightCol->info.type == TSDB_DATA_TYPE_JSON ? (void *)pRightCol : pRightCol->pData)) -#define IS_NULL colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i) \ - || IS_JSON_NULL(pLeft->columnData->info.type, colDataGetVarData(pLeft->columnData, i)) \ - || IS_JSON_NULL(pRight->columnData->info.type, colDataGetVarData(pRight->columnData, i)) +#define IS_NULL \ + colDataIsNull_s(pLeft->columnData, i) || colDataIsNull_s(pRight->columnData, i) || \ + IS_JSON_NULL(pLeft->columnData->info.type, colDataGetVarData(pLeft->columnData, i)) || \ + IS_JSON_NULL(pRight->columnData->info.type, colDataGetVarData(pRight->columnData, i)) -#define IS_HELPER_NULL(col,i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i)) +#define IS_HELPER_NULL(col, i) colDataIsNull_s(col, i) || IS_JSON_NULL(col->info.type, colDataGetVarData(col, i)) -void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType){ +void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int8_t outType) { switch (outType) { case TSDB_DATA_TYPE_BOOL: { GET_TYPED_DATA(*((bool *)outData), bool, inType, inData); @@ -83,15 +84,15 @@ void convertNumberToNumber(const void *inData, void *outData, int8_t inType, int GET_TYPED_DATA(*((double *)outData), double, inType, inData); break; } - default:{ + default: { ASSERT(0); } } } -void convertNcharToDouble(const void *inData, void *outData){ +void convertNcharToDouble(const void *inData, void *outData) { char *tmp = taosMemoryMalloc(varDataTLen(inData)); - int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inData), varDataLen(inData), tmp); + int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(inData), varDataLen(inData), tmp); if (len < 0) { sclError("castConvert taosUcs4ToMbs error 1"); } @@ -104,9 +105,9 @@ void convertNcharToDouble(const void *inData, void *outData){ taosMemoryFreeClear(tmp); } -void convertBinaryToDouble(const void *inData, void *outData){ +void convertBinaryToDouble(const void *inData, void *outData) { char *tmp = taosMemoryCalloc(1, varDataTLen(inData)); - if(tmp == NULL){ + if (tmp == NULL) { *((double *)outData) = 0.; return; } @@ -118,165 +119,119 @@ void convertBinaryToDouble(const void *inData, void *outData){ typedef int64_t (*_getBigintValue_fn_t)(void *src, int32_t index); -int64_t getVectorBigintValue_TINYINT(void *src, int32_t index) { - return (int64_t)*((int8_t *)src + index); -} -int64_t getVectorBigintValue_UTINYINT(void *src, int32_t index) { - return (int64_t)*((uint8_t *)src + index); -} -int64_t getVectorBigintValue_SMALLINT(void *src, int32_t index) { - return (int64_t)*((int16_t *)src + index); -} -int64_t getVectorBigintValue_USMALLINT(void *src, int32_t index) { - return (int64_t)*((uint16_t *)src + index); -} -int64_t getVectorBigintValue_INT(void *src, int32_t index) { - return (int64_t)*((int32_t *)src + index); -} -int64_t getVectorBigintValue_UINT(void *src, int32_t index) { - return (int64_t)*((uint32_t *)src + index); -} -int64_t getVectorBigintValue_BIGINT(void *src, int32_t index) { - return (int64_t)*((int64_t *)src + index); -} -int64_t getVectorBigintValue_UBIGINT(void *src, int32_t index) { - return (int64_t)*((uint64_t *)src + index); -} -int64_t getVectorBigintValue_FLOAT(void *src, int32_t index) { - return (int64_t)*((float *)src + index); -} -int64_t getVectorBigintValue_DOUBLE(void *src, int32_t index) { - return (int64_t)*((double *)src + index); -} -int64_t getVectorBigintValue_BOOL(void *src, int32_t index) { - return (int64_t)*((bool *)src + index); -} - -int64_t getVectorBigintValue_JSON(void *src, int32_t index){ - ASSERT(!colDataIsNull_var(((SColumnInfoData*)src), index)); - char *data = colDataGetVarData((SColumnInfoData*)src, index); +int64_t getVectorBigintValue_TINYINT(void *src, int32_t index) { return (int64_t) * ((int8_t *)src + index); } +int64_t getVectorBigintValue_UTINYINT(void *src, int32_t index) { return (int64_t) * ((uint8_t *)src + index); } +int64_t getVectorBigintValue_SMALLINT(void *src, int32_t index) { return (int64_t) * ((int16_t *)src + index); } +int64_t getVectorBigintValue_USMALLINT(void *src, int32_t index) { return (int64_t) * ((uint16_t *)src + index); } +int64_t getVectorBigintValue_INT(void *src, int32_t index) { return (int64_t) * ((int32_t *)src + index); } +int64_t getVectorBigintValue_UINT(void *src, int32_t index) { return (int64_t) * ((uint32_t *)src + index); } +int64_t getVectorBigintValue_BIGINT(void *src, int32_t index) { return (int64_t) * ((int64_t *)src + index); } +int64_t getVectorBigintValue_UBIGINT(void *src, int32_t index) { return (int64_t) * ((uint64_t *)src + index); } +int64_t getVectorBigintValue_FLOAT(void *src, int32_t index) { return (int64_t) * ((float *)src + index); } +int64_t getVectorBigintValue_DOUBLE(void *src, int32_t index) { return (int64_t) * ((double *)src + index); } +int64_t getVectorBigintValue_BOOL(void *src, int32_t index) { return (int64_t) * ((bool *)src + index); } + +int64_t getVectorBigintValue_JSON(void *src, int32_t index) { + ASSERT(!colDataIsNull_var(((SColumnInfoData *)src), index)); + char *data = colDataGetVarData((SColumnInfoData *)src, index); double out = 0; - if (*data == TSDB_DATA_TYPE_NULL){ + if (*data == TSDB_DATA_TYPE_NULL) { return 0; - } else if(*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY - convertNcharToDouble(data+CHAR_BYTES, &out); - } else if(tTagIsJson(data)){ + } else if (*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY + convertNcharToDouble(data + CHAR_BYTES, &out); + } else if (tTagIsJson(data)) { terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; return 0; } else { - convertNumberToNumber(data+CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); + convertNumberToNumber(data + CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); } return (int64_t)out; } _getBigintValue_fn_t getVectorBigintValueFn(int32_t srcType) { - _getBigintValue_fn_t p = NULL; - if (srcType==TSDB_DATA_TYPE_TINYINT) { - p = getVectorBigintValue_TINYINT; - } else if (srcType==TSDB_DATA_TYPE_UTINYINT) { - p = getVectorBigintValue_UTINYINT; - } else if (srcType==TSDB_DATA_TYPE_SMALLINT) { - p = getVectorBigintValue_SMALLINT; - } else if (srcType==TSDB_DATA_TYPE_USMALLINT) { - p = getVectorBigintValue_USMALLINT; - } else if (srcType==TSDB_DATA_TYPE_INT) { - p = getVectorBigintValue_INT; - } else if (srcType==TSDB_DATA_TYPE_UINT) { - p = getVectorBigintValue_UINT; - } else if (srcType==TSDB_DATA_TYPE_BIGINT) { - p = getVectorBigintValue_BIGINT; - } else if (srcType==TSDB_DATA_TYPE_UBIGINT) { - p = getVectorBigintValue_UBIGINT; - } else if (srcType==TSDB_DATA_TYPE_FLOAT) { - p = getVectorBigintValue_FLOAT; - } else if (srcType==TSDB_DATA_TYPE_DOUBLE) { - p = getVectorBigintValue_DOUBLE; - } else if (srcType==TSDB_DATA_TYPE_TIMESTAMP) { - p = getVectorBigintValue_BIGINT; - } else if (srcType==TSDB_DATA_TYPE_BOOL) { - p = getVectorBigintValue_BOOL; - } else if (srcType==TSDB_DATA_TYPE_JSON) { - p = getVectorBigintValue_JSON; - } else if (srcType==TSDB_DATA_TYPE_NULL){ - p = NULL; - } else { - ASSERT(0); - } - return p; + _getBigintValue_fn_t p = NULL; + if (srcType == TSDB_DATA_TYPE_TINYINT) { + p = getVectorBigintValue_TINYINT; + } else if (srcType == TSDB_DATA_TYPE_UTINYINT) { + p = getVectorBigintValue_UTINYINT; + } else if (srcType == TSDB_DATA_TYPE_SMALLINT) { + p = getVectorBigintValue_SMALLINT; + } else if (srcType == TSDB_DATA_TYPE_USMALLINT) { + p = getVectorBigintValue_USMALLINT; + } else if (srcType == TSDB_DATA_TYPE_INT) { + p = getVectorBigintValue_INT; + } else if (srcType == TSDB_DATA_TYPE_UINT) { + p = getVectorBigintValue_UINT; + } else if (srcType == TSDB_DATA_TYPE_BIGINT) { + p = getVectorBigintValue_BIGINT; + } else if (srcType == TSDB_DATA_TYPE_UBIGINT) { + p = getVectorBigintValue_UBIGINT; + } else if (srcType == TSDB_DATA_TYPE_FLOAT) { + p = getVectorBigintValue_FLOAT; + } else if (srcType == TSDB_DATA_TYPE_DOUBLE) { + p = getVectorBigintValue_DOUBLE; + } else if (srcType == TSDB_DATA_TYPE_TIMESTAMP) { + p = getVectorBigintValue_BIGINT; + } else if (srcType == TSDB_DATA_TYPE_BOOL) { + p = getVectorBigintValue_BOOL; + } else if (srcType == TSDB_DATA_TYPE_JSON) { + p = getVectorBigintValue_JSON; + } else if (srcType == TSDB_DATA_TYPE_NULL) { + p = NULL; + } else { + ASSERT(0); + } + return p; } -typedef void* (*_getValueAddr_fn_t)(void *src, int32_t index); +typedef void *(*_getValueAddr_fn_t)(void *src, int32_t index); -void* getVectorValueAddr_TINYINT(void *src, int32_t index) { - return (void*)((int8_t *)src + index); -} -void* getVectorValueAddr_UTINYINT(void *src, int32_t index) { - return (void*)((uint8_t *)src + index); -} -void* getVectorValueAddr_SMALLINT(void *src, int32_t index) { - return (void*)((int16_t *)src + index); -} -void* getVectorValueAddr_USMALLINT(void *src, int32_t index) { - return (void*)((uint16_t *)src + index); -} -void* getVectorValueAddr_INT(void *src, int32_t index) { - return (void*)((int32_t *)src + index); -} -void* getVectorValueAddr_UINT(void *src, int32_t index) { - return (void*)((uint32_t *)src + index); -} -void* getVectorValueAddr_BIGINT(void *src, int32_t index) { - return (void*)((int64_t *)src + index); -} -void* getVectorValueAddr_UBIGINT(void *src, int32_t index) { - return (void*)((uint64_t *)src + index); -} -void* getVectorValueAddr_FLOAT(void *src, int32_t index) { - return (void*)((float *)src + index); -} -void* getVectorValueAddr_DOUBLE(void *src, int32_t index) { - return (void*)((double *)src + index); -} -void* getVectorValueAddr_default(void *src, int32_t index) { - return src; -} -void* getVectorValueAddr_VAR(void *src, int32_t index) { - return colDataGetData((SColumnInfoData *)src, index); -} +void *getVectorValueAddr_TINYINT(void *src, int32_t index) { return (void *)((int8_t *)src + index); } +void *getVectorValueAddr_UTINYINT(void *src, int32_t index) { return (void *)((uint8_t *)src + index); } +void *getVectorValueAddr_SMALLINT(void *src, int32_t index) { return (void *)((int16_t *)src + index); } +void *getVectorValueAddr_USMALLINT(void *src, int32_t index) { return (void *)((uint16_t *)src + index); } +void *getVectorValueAddr_INT(void *src, int32_t index) { return (void *)((int32_t *)src + index); } +void *getVectorValueAddr_UINT(void *src, int32_t index) { return (void *)((uint32_t *)src + index); } +void *getVectorValueAddr_BIGINT(void *src, int32_t index) { return (void *)((int64_t *)src + index); } +void *getVectorValueAddr_UBIGINT(void *src, int32_t index) { return (void *)((uint64_t *)src + index); } +void *getVectorValueAddr_FLOAT(void *src, int32_t index) { return (void *)((float *)src + index); } +void *getVectorValueAddr_DOUBLE(void *src, int32_t index) { return (void *)((double *)src + index); } +void *getVectorValueAddr_default(void *src, int32_t index) { return src; } +void *getVectorValueAddr_VAR(void *src, int32_t index) { return colDataGetData((SColumnInfoData *)src, index); } _getValueAddr_fn_t getVectorValueAddrFn(int32_t srcType) { - _getValueAddr_fn_t p = NULL; - if(srcType==TSDB_DATA_TYPE_TINYINT) { - p = getVectorValueAddr_TINYINT; - }else if(srcType==TSDB_DATA_TYPE_UTINYINT) { - p = getVectorValueAddr_UTINYINT; - }else if(srcType==TSDB_DATA_TYPE_SMALLINT) { - p = getVectorValueAddr_SMALLINT; - }else if(srcType==TSDB_DATA_TYPE_USMALLINT) { - p = getVectorValueAddr_USMALLINT; - }else if(srcType==TSDB_DATA_TYPE_INT) { - p = getVectorValueAddr_INT; - }else if(srcType==TSDB_DATA_TYPE_UINT) { - p = getVectorValueAddr_UINT; - }else if(srcType==TSDB_DATA_TYPE_BIGINT) { - p = getVectorValueAddr_BIGINT; - }else if(srcType==TSDB_DATA_TYPE_UBIGINT) { - p = getVectorValueAddr_UBIGINT; - }else if(srcType==TSDB_DATA_TYPE_FLOAT) { - p = getVectorValueAddr_FLOAT; - }else if(srcType==TSDB_DATA_TYPE_DOUBLE) { - p = getVectorValueAddr_DOUBLE; - }else if(srcType==TSDB_DATA_TYPE_BINARY) { - p = getVectorValueAddr_VAR; - }else if(srcType==TSDB_DATA_TYPE_NCHAR) { - p = getVectorValueAddr_VAR; - }else { - p = getVectorValueAddr_default; - } - return p; -} - -static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { + _getValueAddr_fn_t p = NULL; + if (srcType == TSDB_DATA_TYPE_TINYINT) { + p = getVectorValueAddr_TINYINT; + } else if (srcType == TSDB_DATA_TYPE_UTINYINT) { + p = getVectorValueAddr_UTINYINT; + } else if (srcType == TSDB_DATA_TYPE_SMALLINT) { + p = getVectorValueAddr_SMALLINT; + } else if (srcType == TSDB_DATA_TYPE_USMALLINT) { + p = getVectorValueAddr_USMALLINT; + } else if (srcType == TSDB_DATA_TYPE_INT) { + p = getVectorValueAddr_INT; + } else if (srcType == TSDB_DATA_TYPE_UINT) { + p = getVectorValueAddr_UINT; + } else if (srcType == TSDB_DATA_TYPE_BIGINT) { + p = getVectorValueAddr_BIGINT; + } else if (srcType == TSDB_DATA_TYPE_UBIGINT) { + p = getVectorValueAddr_UBIGINT; + } else if (srcType == TSDB_DATA_TYPE_FLOAT) { + p = getVectorValueAddr_FLOAT; + } else if (srcType == TSDB_DATA_TYPE_DOUBLE) { + p = getVectorValueAddr_DOUBLE; + } else if (srcType == TSDB_DATA_TYPE_BINARY) { + p = getVectorValueAddr_VAR; + } else if (srcType == TSDB_DATA_TYPE_NCHAR) { + p = getVectorValueAddr_VAR; + } else { + p = getVectorValueAddr_default; + } + return p; +} + +static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int64_t value = 0; if (taosParseTime(buf, &value, strlen(buf), pOut->columnData->info.precision, tsDaylight) != TSDB_CODE_SUCCESS) { value = 0; @@ -285,7 +240,7 @@ static FORCE_INLINE void varToTimestamp(char *buf, SScalarParam* pOut, int32_t r colDataAppendInt64(pOut->columnData, rowIndex, &value); } -static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void varToSigned(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { if (overflow) { int64_t minValue = tDataTypes[pOut->columnData->info.type].minValue; int64_t maxValue = tDataTypes[pOut->columnData->info.type].maxValue; @@ -305,28 +260,28 @@ static FORCE_INLINE void varToSigned(char *buf, SScalarParam* pOut, int32_t rowI case TSDB_DATA_TYPE_TINYINT: { int8_t value = (int8_t)taosStr2Int8(buf, NULL, 10); - colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value); + colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&value); break; } case TSDB_DATA_TYPE_SMALLINT: { int16_t value = (int16_t)taosStr2Int16(buf, NULL, 10); - colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value); + colDataAppendInt16(pOut->columnData, rowIndex, (int16_t *)&value); break; } case TSDB_DATA_TYPE_INT: { int32_t value = (int32_t)taosStr2Int32(buf, NULL, 10); - colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value); + colDataAppendInt32(pOut->columnData, rowIndex, (int32_t *)&value); break; } case TSDB_DATA_TYPE_BIGINT: { int64_t value = (int64_t)taosStr2Int64(buf, NULL, 10); - colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value); + colDataAppendInt64(pOut->columnData, rowIndex, (int64_t *)&value); break; } } } -static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { if (overflow) { uint64_t minValue = (uint64_t)tDataTypes[pOut->columnData->info.type].minValue; uint64_t maxValue = (uint64_t)tDataTypes[pOut->columnData->info.type].maxValue; @@ -345,28 +300,28 @@ static FORCE_INLINE void varToUnsigned(char *buf, SScalarParam* pOut, int32_t ro switch (pOut->columnData->info.type) { case TSDB_DATA_TYPE_UTINYINT: { uint8_t value = (uint8_t)taosStr2UInt8(buf, NULL, 10); - colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*)&value); + colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&value); break; } case TSDB_DATA_TYPE_USMALLINT: { uint16_t value = (uint16_t)taosStr2UInt16(buf, NULL, 10); - colDataAppendInt16(pOut->columnData, rowIndex, (int16_t*)&value); + colDataAppendInt16(pOut->columnData, rowIndex, (int16_t *)&value); break; } case TSDB_DATA_TYPE_UINT: { uint32_t value = (uint32_t)taosStr2UInt32(buf, NULL, 10); - colDataAppendInt32(pOut->columnData, rowIndex, (int32_t*)&value); + colDataAppendInt32(pOut->columnData, rowIndex, (int32_t *)&value); break; } case TSDB_DATA_TYPE_UBIGINT: { uint64_t value = (uint64_t)taosStr2UInt64(buf, NULL, 10); - colDataAppendInt64(pOut->columnData, rowIndex, (int64_t*)&value); + colDataAppendInt64(pOut->columnData, rowIndex, (int64_t *)&value); break; } } } -static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void varToFloat(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { if (TSDB_DATA_TYPE_FLOAT == pOut->columnData->info.type) { float value = taosStr2Float(buf, NULL); colDataAppendFloat(pOut->columnData, rowIndex, &value); @@ -377,30 +332,31 @@ static FORCE_INLINE void varToFloat(char *buf, SScalarParam* pOut, int32_t rowIn colDataAppendDouble(pOut->columnData, rowIndex, &value); } -static FORCE_INLINE void varToBool(char *buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void varToBool(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int64_t value = taosStr2Int64(buf, NULL, 10); - bool v = (value != 0)? true:false; - colDataAppendInt8(pOut->columnData, rowIndex, (int8_t*) &v); + bool v = (value != 0) ? true : false; + colDataAppendInt8(pOut->columnData, rowIndex, (int8_t *)&v); } -static FORCE_INLINE void varToNchar(char* buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void varToNchar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int32_t len = 0; int32_t inputLen = varDataLen(buf); int32_t outputMaxLen = (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE; - char* t = taosMemoryCalloc(1, outputMaxLen); - /*int32_t resLen = */taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4*) varDataVal(t), outputMaxLen - VARSTR_HEADER_SIZE, &len); + char *t = taosMemoryCalloc(1, outputMaxLen); + /*int32_t resLen = */ taosMbsToUcs4(varDataVal(buf), inputLen, (TdUcs4 *)varDataVal(t), + outputMaxLen - VARSTR_HEADER_SIZE, &len); varDataSetLen(t, len); colDataAppend(pOut->columnData, rowIndex, t, false); taosMemoryFree(t); } -static FORCE_INLINE void ncharToVar(char* buf, SScalarParam* pOut, int32_t rowIndex, int32_t* overflow) { +static FORCE_INLINE void ncharToVar(char *buf, SScalarParam *pOut, int32_t rowIndex, int32_t *overflow) { int32_t inputLen = varDataLen(buf); - char* t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE); - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); + char *t = taosMemoryCalloc(1, inputLen + VARSTR_HEADER_SIZE); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); if (len < 0) { taosMemoryFree(t); return; @@ -411,59 +367,58 @@ static FORCE_INLINE void ncharToVar(char* buf, SScalarParam* pOut, int32_t rowIn taosMemoryFree(t); } - //TODO opt performance, tmp is not needed. -int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, int32_t inType, int32_t outType, int32_t* overflow) { +int32_t vectorConvertFromVarData(SSclVectorConvCtx *pCtx, int32_t* overflow) { bool vton = false; _bufConverteFunc func = NULL; - if (TSDB_DATA_TYPE_BOOL == outType) { + if (TSDB_DATA_TYPE_BOOL == pCtx->outType) { func = varToBool; - } else if (IS_SIGNED_NUMERIC_TYPE(outType)) { + } else if (IS_SIGNED_NUMERIC_TYPE(pCtx->outType)) { func = varToSigned; - } else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) { + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->outType)) { func = varToUnsigned; - } else if (IS_FLOAT_TYPE(outType)) { + } else if (IS_FLOAT_TYPE(pCtx->outType)) { func = varToFloat; - } else if (outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary - ASSERT(inType == TSDB_DATA_TYPE_NCHAR); + } else if (pCtx->outType == TSDB_DATA_TYPE_BINARY) { // nchar -> binary + ASSERT(pCtx->inType == TSDB_DATA_TYPE_NCHAR); func = ncharToVar; vton = true; - } else if (outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar - ASSERT(inType == TSDB_DATA_TYPE_VARCHAR); + } else if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { // binary -> nchar + ASSERT(pCtx->inType == TSDB_DATA_TYPE_VARCHAR); func = varToNchar; vton = true; - } else if (TSDB_DATA_TYPE_TIMESTAMP == outType) { + } else if (TSDB_DATA_TYPE_TIMESTAMP == pCtx->outType) { func = varToTimestamp; } else { - sclError("invalid convert outType:%d", outType); + sclError("invalid convert outType:%d", pCtx->outType); return TSDB_CODE_QRY_APP_ERROR; } - pOut->numOfRows = pIn->numOfRows; - for (int32_t i = 0; i < pIn->numOfRows; ++i) { - if (IS_HELPER_NULL(pIn->columnData, i)) { - colDataAppendNULL(pOut->columnData, i); + pCtx->pOut->numOfRows = pCtx->pIn->numOfRows; + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { + if (IS_HELPER_NULL(pCtx->pIn->columnData, i)) { + colDataAppendNULL(pCtx->pOut->columnData, i); continue; } - char* data = colDataGetVarData(pIn->columnData, i); - int32_t convertType = inType; - if(inType == TSDB_DATA_TYPE_JSON){ + char* data = colDataGetVarData(pCtx->pIn->columnData, i); + int32_t convertType = pCtx->inType; + if(pCtx->inType == TSDB_DATA_TYPE_JSON){ if(*data == TSDB_DATA_TYPE_NULL) { ASSERT(0); - } else if(*data == TSDB_DATA_TYPE_NCHAR) { + } else if (*data == TSDB_DATA_TYPE_NCHAR) { data += CHAR_BYTES; convertType = TSDB_DATA_TYPE_NCHAR; - } else if(tTagIsJson(data)){ + } else if (tTagIsJson(data)) { terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; return terrno; } else { - convertNumberToNumber(data+CHAR_BYTES, colDataGetNumData(pOut->columnData, i), *data, outType); + convertNumberToNumber(data+CHAR_BYTES, colDataGetNumData(pCtx->pOut->columnData, i), *data, pCtx->outType); continue; } } - int32_t bufSize = pIn->columnData->info.bytes; + int32_t bufSize = pCtx->pIn->columnData->info.bytes; char *tmp = taosMemoryMalloc(varDataTLen(data)); if(!tmp){ sclError("out of memory in vectorConvertFromVarData"); @@ -475,7 +430,7 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in if (TSDB_DATA_TYPE_VARCHAR == convertType) { memcpy(tmp, varDataVal(data), varDataLen(data)); tmp[varDataLen(data)] = 0; - } else if (TSDB_DATA_TYPE_NCHAR == convertType){ + } else if (TSDB_DATA_TYPE_NCHAR == convertType) { ASSERT(varDataLen(data) <= bufSize); int len = taosUcs4ToMbs((TdUcs4 *)varDataVal(data), varDataLen(data), tmp); @@ -488,38 +443,38 @@ int32_t vectorConvertFromVarData(const SScalarParam* pIn, SScalarParam* pOut, in tmp[len] = 0; } } - - (*func)(tmp, pOut, i, overflow); + + (*func)(tmp, pCtx->pOut, i, overflow); taosMemoryFreeClear(tmp); } return TSDB_CODE_SUCCESS; } -double getVectorDoubleValue_JSON(void *src, int32_t index){ - char *data = colDataGetVarData((SColumnInfoData*)src, index); +double getVectorDoubleValue_JSON(void *src, int32_t index) { + char *data = colDataGetVarData((SColumnInfoData *)src, index); double out = 0; - if (*data == TSDB_DATA_TYPE_NULL){ + if (*data == TSDB_DATA_TYPE_NULL) { return out; - } else if(*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY - convertNcharToDouble(data+CHAR_BYTES, &out); - } else if(tTagIsJson(data)){ + } else if (*data == TSDB_DATA_TYPE_NCHAR) { // json inner type can not be BINARY + convertNcharToDouble(data + CHAR_BYTES, &out); + } else if (tTagIsJson(data)) { terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; return 0; - } else{ - convertNumberToNumber(data+CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); + } else { + convertNumberToNumber(data + CHAR_BYTES, &out, *data, TSDB_DATA_TYPE_DOUBLE); } return out; } -void* ncharTobinary(void *buf){ // todo need to remove , if tobinary is nchar +void *ncharTobinary(void *buf) { // todo need to remove , if tobinary is nchar int32_t inputLen = varDataTLen(buf); - void* t = taosMemoryCalloc(1, inputLen); - int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); + void *t = taosMemoryCalloc(1, inputLen); + int32_t len = taosUcs4ToMbs((TdUcs4 *)varDataVal(buf), varDataLen(buf), varDataVal(t)); if (len < 0) { sclError("charset:%s to %s. val:%s convert ncharTobinary failed.", DEFAULT_UNICODE_ENCODEC, tsCharset, - (char*)varDataVal(buf)); + (char *)varDataVal(buf)); taosMemoryFree(t); return NULL; } @@ -527,8 +482,9 @@ void* ncharTobinary(void *buf){ // todo need to remove , if tobinary return t; } -bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, char **pRightData, - void *pLeftOut, void *pRightOut, bool *isNull, bool *freeLeft, bool *freeRight){ +bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t typeRight, char **pLeftData, + char **pRightData, void *pLeftOut, void *pRightOut, bool *isNull, bool *freeLeft, + bool *freeRight) { if (optr == OP_TYPE_JSON_CONTAINS) { return true; } @@ -543,7 +499,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t return false; } typeLeft = **pLeftData; - (*pLeftData) ++; + (*pLeftData)++; } if (typeRight == TSDB_DATA_TYPE_JSON) { if (tTagIsJson(*pLeftData)) { @@ -551,7 +507,7 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t return false; } typeRight = **pRightData; - (*pRightData) ++; + (*pRightData)++; } if (optr == OP_TYPE_LIKE || optr == OP_TYPE_NOT_LIKE || optr == OP_TYPE_MATCH || optr == OP_TYPE_NMATCH) { @@ -569,7 +525,6 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t ((typeRight == TSDB_DATA_TYPE_BOOL) && (typeLeft != TSDB_DATA_TYPE_BOOL))) return false; - if (typeLeft == TSDB_DATA_TYPE_NULL || typeRight == TSDB_DATA_TYPE_NULL) { *isNull = true; return true; @@ -586,12 +541,12 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t if (IS_NUMERIC_TYPE(type)) { if (typeLeft == TSDB_DATA_TYPE_NCHAR) { ASSERT(0); -// convertNcharToDouble(*pLeftData, pLeftOut); -// *pLeftData = pLeftOut; + // convertNcharToDouble(*pLeftData, pLeftOut); + // *pLeftData = pLeftOut; } else if (typeLeft == TSDB_DATA_TYPE_BINARY) { ASSERT(0); -// convertBinaryToDouble(*pLeftData, pLeftOut); -// *pLeftData = pLeftOut; + // convertBinaryToDouble(*pLeftData, pLeftOut); + // *pLeftData = pLeftOut; } else if (typeLeft != type) { convertNumberToNumber(*pLeftData, pLeftOut, typeLeft, type); *pLeftData = pLeftOut; @@ -599,12 +554,12 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t if (typeRight == TSDB_DATA_TYPE_NCHAR) { ASSERT(0); -// convertNcharToDouble(*pRightData, pRightOut); -// *pRightData = pRightOut; + // convertNcharToDouble(*pRightData, pRightOut); + // *pRightData = pRightOut; } else if (typeRight == TSDB_DATA_TYPE_BINARY) { ASSERT(0); -// convertBinaryToDouble(*pRightData, pRightOut); -// *pRightData = pRightOut; + // convertBinaryToDouble(*pRightData, pRightOut); + // *pRightData = pRightOut; } else if (typeRight != type) { convertNumberToNumber(*pRightData, pRightOut, typeRight, type); *pRightData = pRightOut; @@ -625,64 +580,64 @@ bool convertJsonValue(__compar_fn_t *fp, int32_t optr, int8_t typeLeft, int8_t t return true; } -int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int16_t inType, int16_t outType) { - SColumnInfoData* pInputCol = pIn->columnData; - SColumnInfoData* pOutputCol = pOut->columnData; +int32_t vectorConvertToVarData(SSclVectorConvCtx *pCtx) { + SColumnInfoData* pInputCol = pCtx->pIn->columnData; + SColumnInfoData* pOutputCol = pCtx->pOut->columnData; char tmp[128] = {0}; - if (IS_SIGNED_NUMERIC_TYPE(inType) || inType == TSDB_DATA_TYPE_BOOL || inType == TSDB_DATA_TYPE_TIMESTAMP) { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + if (IS_SIGNED_NUMERIC_TYPE(pCtx->inType) || pCtx->inType == TSDB_DATA_TYPE_BOOL || pCtx->inType == TSDB_DATA_TYPE_TIMESTAMP) { + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } int64_t value = 0; - GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, int64_t, pCtx->inType, colDataGetData(pInputCol, i)); int32_t len = sprintf(varDataVal(tmp), "%" PRId64, value); varDataLen(tmp) = len; - if (outType == TSDB_DATA_TYPE_NCHAR) { - varToNchar(tmp, pOut, i, NULL); + if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { + varToNchar(tmp, pCtx->pOut, i, NULL); } else { colDataAppend(pOutputCol, i, (char *)tmp, false); } } - } else if (IS_UNSIGNED_NUMERIC_TYPE(inType)) { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + } else if (IS_UNSIGNED_NUMERIC_TYPE(pCtx->inType)) { + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } uint64_t value = 0; - GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, uint64_t, pCtx->inType, colDataGetData(pInputCol, i)); int32_t len = sprintf(varDataVal(tmp), "%" PRIu64, value); varDataLen(tmp) = len; - if (outType == TSDB_DATA_TYPE_NCHAR) { - varToNchar(tmp, pOut, i, NULL); + if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { + varToNchar(tmp, pCtx->pOut, i, NULL); } else { colDataAppend(pOutputCol, i, (char *)tmp, false); } } - } else if (IS_FLOAT_TYPE(inType)) { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + } else if (IS_FLOAT_TYPE(pCtx->inType)) { + for (int32_t i = pCtx->startIndex; i <= pCtx->endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } double value = 0; - GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, double, pCtx->inType, colDataGetData(pInputCol, i)); int32_t len = sprintf(varDataVal(tmp), "%lf", value); varDataLen(tmp) = len; - if (outType == TSDB_DATA_TYPE_NCHAR) { - varToNchar(tmp, pOut, i, NULL); + if (pCtx->outType == TSDB_DATA_TYPE_NCHAR) { + varToNchar(tmp, pCtx->pOut, i, NULL); } else { colDataAppend(pOutputCol, i, (char *)tmp, false); } } } else { - sclError("not supported input type:%d", inType); + sclError("not supported input type:%d", pCtx->inType); return TSDB_CODE_QRY_APP_ERROR; } @@ -690,7 +645,7 @@ int32_t vectorConvertToVarData(const SScalarParam* pIn, SScalarParam* pOut, int1 } // TODO opt performance -int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow) { +int32_t vectorConvertSingleColImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* overflow, int32_t startIndex, int32_t numOfRows) { SColumnInfoData* pInputCol = pIn->columnData; SColumnInfoData* pOutputCol = pOut->columnData; @@ -699,25 +654,26 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* return TSDB_CODE_APP_ERROR; } - int16_t inType = pInputCol->info.type; - int16_t outType = pOutputCol->info.type; + int32_t rstart = startIndex >= 0 ? startIndex : 0; + int32_t rend = numOfRows > 0 ? rstart + numOfRows - 1 : rstart + pIn->numOfRows - 1; + SSclVectorConvCtx cCtx = {pIn, pOut, rstart, rend, pInputCol->info.type, pOutputCol->info.type}; - if (IS_VAR_DATA_TYPE(inType)) { - return vectorConvertFromVarData(pIn, pOut, inType, outType, overflow); + if (IS_VAR_DATA_TYPE(cCtx.inType)) { + return vectorConvertFromVarData(&cCtx, overflow); } if (overflow) { ASSERT(1 == pIn->numOfRows); pOut->numOfRows = 0; - - if (IS_SIGNED_NUMERIC_TYPE(outType)) { - int64_t minValue = tDataTypes[outType].minValue; - int64_t maxValue = tDataTypes[outType].maxValue; - + + if (IS_SIGNED_NUMERIC_TYPE(cCtx.outType)) { + int64_t minValue = tDataTypes[cCtx.outType].minValue; + int64_t maxValue = tDataTypes[cCtx.outType].maxValue; + double value = 0; - GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0)); - + GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, 0)); + if (value > maxValue) { *overflow = 1; return TSDB_CODE_SUCCESS; @@ -727,13 +683,13 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* } else { *overflow = 0; } - } else if (IS_UNSIGNED_NUMERIC_TYPE(outType)) { - uint64_t minValue = (uint64_t)tDataTypes[outType].minValue; - uint64_t maxValue = (uint64_t)tDataTypes[outType].maxValue; - + } else if (IS_UNSIGNED_NUMERIC_TYPE(cCtx.outType)) { + uint64_t minValue = (uint64_t)tDataTypes[cCtx.outType].minValue; + uint64_t maxValue = (uint64_t)tDataTypes[cCtx.outType].maxValue; + double value = 0; - GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, 0)); - + GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, 0)); + if (value > maxValue) { *overflow = 1; return TSDB_CODE_SUCCESS; @@ -747,187 +703,184 @@ int32_t vectorConvertImpl(const SScalarParam* pIn, SScalarParam* pOut, int32_t* } pOut->numOfRows = pIn->numOfRows; - switch (outType) { + switch (cCtx.outType) { case TSDB_DATA_TYPE_BOOL: { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } bool value = 0; - GET_TYPED_DATA(value, bool, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, bool, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt8(pOutputCol, i, (int8_t *)&value); } break; } case TSDB_DATA_TYPE_TINYINT: { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } int8_t value = 0; - GET_TYPED_DATA(value, int8_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, int8_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt8(pOutputCol, i, (int8_t *)&value); } break; } case TSDB_DATA_TYPE_SMALLINT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } int16_t value = 0; - GET_TYPED_DATA(value, int16_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, int16_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt16(pOutputCol, i, (int16_t *)&value); } break; } case TSDB_DATA_TYPE_INT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } int32_t value = 0; - GET_TYPED_DATA(value, int32_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, int32_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt32(pOutputCol, i, (int32_t *)&value); } break; } case TSDB_DATA_TYPE_BIGINT: case TSDB_DATA_TYPE_TIMESTAMP: { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } int64_t value = 0; - GET_TYPED_DATA(value, int64_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, int64_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt64(pOutputCol, i, (int64_t *)&value); } break; } case TSDB_DATA_TYPE_UTINYINT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } uint8_t value = 0; - GET_TYPED_DATA(value, uint8_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, uint8_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt8(pOutputCol, i, (int8_t *)&value); } break; } case TSDB_DATA_TYPE_USMALLINT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } uint16_t value = 0; - GET_TYPED_DATA(value, uint16_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, uint16_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt16(pOutputCol, i, (int16_t *)&value); } break; } case TSDB_DATA_TYPE_UINT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } uint32_t value = 0; - GET_TYPED_DATA(value, uint32_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, uint32_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt32(pOutputCol, i, (int32_t *)&value); } break; } case TSDB_DATA_TYPE_UBIGINT: { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } uint64_t value = 0; - GET_TYPED_DATA(value, uint64_t, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, uint64_t, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendInt64(pOutputCol, i, (int64_t*)&value); } break; } case TSDB_DATA_TYPE_FLOAT:{ - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } float value = 0; - GET_TYPED_DATA(value, float, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, float, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendFloat(pOutputCol, i, (float*)&value); } break; } case TSDB_DATA_TYPE_DOUBLE: { - for (int32_t i = 0; i < pIn->numOfRows; ++i) { + for (int32_t i = cCtx.startIndex; i <= cCtx.endIndex; ++i) { if (colDataIsNull_f(pInputCol->nullbitmap, i)) { colDataAppendNULL(pOutputCol, i); continue; } double value = 0; - GET_TYPED_DATA(value, double, inType, colDataGetData(pInputCol, i)); + GET_TYPED_DATA(value, double, cCtx.inType, colDataGetData(pInputCol, i)); colDataAppendDouble(pOutputCol, i, (double*)&value); } break; } case TSDB_DATA_TYPE_BINARY: case TSDB_DATA_TYPE_NCHAR: { - return vectorConvertToVarData(pIn, pOut, inType, outType); + return vectorConvertToVarData(&cCtx); } default: - sclError("invalid convert output type:%d", outType); + sclError("invalid convert output type:%d", cCtx.outType); return TSDB_CODE_QRY_APP_ERROR; } return TSDB_CODE_SUCCESS; } - - -int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB+1][TSDB_DATA_TYPE_BLOB+1] = { -/* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB */ -/*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*BOOL*/ 0, 0, 2, 3, 4, 5, 6, 7, 7, 9, 7, 11, 12, 13, 14, 0, 7, 0, 0, -/*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, -/*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, -/*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 7, 9, 7, 4, 4, 5, 7, 0, 7, 0, 0, -/*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 7, 5, 5, 5, 7, 0, 7, 0, 0, -/*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 0, 7, 0, 0, -/*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 0, -/*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 7, 7, 7, 7, 0, 0, 0, 0, -/*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 7, 0, 7, 0, 0, -/*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, -/*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 0, 7, 0, 0, -/*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 7, 0, 0, -/*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 7, 0, 0, -/*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, -/*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -/*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; +int8_t gConvertTypes[TSDB_DATA_TYPE_BLOB + 1][TSDB_DATA_TYPE_BLOB + 1] = { + /* NULL BOOL TINY SMAL INT BIG FLOA DOUB VARC TIME NCHA UTIN USMA UINT UBIG JSON VARB DECI BLOB */ + /*NULL*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /*BOOL*/ 0, 0, 2, 3, 4, 5, 6, 7, 7, 9, 7, 11, 12, 13, 14, 0, 7, 0, 0, + /*TINY*/ 0, 0, 0, 3, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, + /*SMAL*/ 0, 0, 0, 0, 4, 5, 6, 7, 7, 9, 7, 3, 4, 5, 7, 0, 7, 0, 0, + /*INT */ 0, 0, 0, 0, 0, 5, 6, 7, 7, 9, 7, 4, 4, 5, 7, 0, 7, 0, 0, + /*BIGI*/ 0, 0, 0, 0, 0, 0, 6, 7, 7, 9, 7, 5, 5, 5, 7, 0, 7, 0, 0, + /*FLOA*/ 0, 0, 0, 0, 0, 0, 0, 7, 7, 6, 7, 6, 6, 6, 6, 0, 7, 0, 0, + /*DOUB*/ 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 7, 7, 7, 0, 7, 0, 0, + /*VARC*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 8, 7, 7, 7, 7, 0, 0, 0, 0, + /*TIME*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 9, 9, 9, 9, 7, 0, 7, 0, 0, + /*NCHA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 7, 7, 7, 0, 0, 0, 0, + /*UTIN*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12, 13, 14, 0, 7, 0, 0, + /*USMA*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 13, 14, 0, 7, 0, 0, + /*UINT*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 7, 0, 0, + /*UBIG*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, + /*JSON*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /*VARB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /*DECI*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /*BLOB*/ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int32_t vectorGetConvertType(int32_t type1, int32_t type2) { if (type1 == type2) { @@ -941,7 +894,7 @@ int32_t vectorGetConvertType(int32_t type1, int32_t type2) { return gConvertTypes[type2][type1]; } -int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int32_t type) { +int32_t vectorConvertSingleCol(SScalarParam *input, SScalarParam *output, int32_t type, int32_t startIndex, int32_t numOfRows) { SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; output->numOfRows = input->numOfRows; @@ -950,16 +903,15 @@ int32_t vectorConvertScalarParam(SScalarParam *input, SScalarParam *output, int3 return TSDB_CODE_OUT_OF_MEMORY; } - code = vectorConvertImpl(input, output, NULL); + code = vectorConvertSingleColImpl(input, output, NULL, startIndex, numOfRows); if (code) { -// taosMemoryFreeClear(paramOut1->data); return code; } return TSDB_CODE_SUCCESS; } -int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* pLeftOut, SScalarParam* pRightOut) { +int32_t vectorConvertCols(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* pLeftOut, SScalarParam* pRightOut, int32_t startIndex, int32_t numOfRows) { int32_t leftType = GET_PARAM_TYPE(pLeft); int32_t rightType = GET_PARAM_TYPE(pRight); if (leftType == rightType) { @@ -968,7 +920,7 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p SScalarParam *param1 = NULL, *paramOut1 = NULL; SScalarParam *param2 = NULL, *paramOut2 = NULL; - int32_t code = 0; + int32_t code = 0; if (leftType < rightType) { param1 = pLeft; @@ -988,14 +940,14 @@ int32_t vectorConvert(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam* p } if (type != GET_PARAM_TYPE(param1)) { - code = vectorConvertScalarParam(param1, paramOut1, type); + code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows); if (code) { return code; } } if (type != GET_PARAM_TYPE(param2)) { - code = vectorConvertScalarParam(param2, paramOut2, type); + code = vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows); if (code) { return code; } @@ -1009,34 +961,10 @@ enum { VECTOR_UN_CONVERT = 0x2, }; -static int32_t doConvertHelper(SScalarParam* pDest, int32_t* convert, const SScalarParam* pParam, int32_t type) { - SColumnInfoData* pCol = pParam->columnData; - - if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON) { - pDest->numOfRows = pParam->numOfRows; - - SDataType t = {.type = type, .bytes = tDataTypes[type].bytes}; - int32_t code = sclCreateColumnInfoData(&t, pParam->numOfRows, pDest); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - code = vectorConvertImpl(pParam, pDest, NULL); - if (code != TSDB_CODE_SUCCESS) { - return code; - } - - *convert = VECTOR_DO_CONVERT; - } else { - *convert = VECTOR_UN_CONVERT; - } - - return TSDB_CODE_SUCCESS; -} - // TODO not correct for descending order scan -static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); +static void vectorMathAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; @@ -1049,14 +977,14 @@ static void vectorMathAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig colDataAppendNULL(pOutputCol, i); continue; // TODO set null or ignore } - *output = getVectorDoubleValueFnLeft(LEFT_COL, i) - + getVectorDoubleValueFnRight(RIGHT_COL, 0); + *output = getVectorDoubleValueFnLeft(LEFT_COL, i) + getVectorDoubleValueFnRight(RIGHT_COL, 0); } } } -static void vectorMathTsAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); +static void vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1069,53 +997,60 @@ static void vectorMathTsAddHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR colDataAppendNULL(pOutputCol, i); continue; // TODO set null or ignore } - *output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), getVectorBigintValueFnRight(pRightCol->pData, 0), - pRightCol->info.scale, pRightCol->info.precision); + *output = + taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), getVectorBigintValueFnRight(pRightCol->pData, 0), + pRightCol->info.scale, pRightCol->info.precision); } } } -static SColumnInfoData* doVectorConvert(SScalarParam* pInput, int32_t* doConvert) { - SScalarParam convertParam = {0}; +static SColumnInfoData* vectorConvertVarToDouble(SScalarParam* pInput, int32_t* converted) { + SScalarParam output = {0}; + SColumnInfoData* pCol = pInput->columnData; - int32_t code = doConvertHelper(&convertParam, doConvert, pInput, TSDB_DATA_TYPE_DOUBLE); - if (code != TSDB_CODE_SUCCESS) { - terrno = code; - return NULL; - } + if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON) { + int32_t code = vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1); + if (code != TSDB_CODE_SUCCESS) { + terrno = code; + return NULL; + } - if (*doConvert == VECTOR_DO_CONVERT) { - return convertParam.columnData; - } else { - return pInput->columnData; + *converted = VECTOR_DO_CONVERT; + + return output.columnData; } + + *converted = VECTOR_UN_CONVERT; + + return pInput->columnData; } -static void doReleaseVec(SColumnInfoData* pCol, int32_t type) { +static void doReleaseVec(SColumnInfoData *pCol, int32_t type) { if (type == VECTOR_DO_CONVERT) { colDataDestroy(pCol); taosMemoryFree(pCol); } } -void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathAdd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pRight))) || (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && IS_INTEGER_TYPE(GET_PARAM_TYPE(pLeft))) || (GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BOOL) || - (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BOOL)) { //timestamp plus duration - int64_t *output = (int64_t *)pOutputCol->pData; - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && + GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BOOL)) { // timestamp plus duration + int64_t *output = (int64_t *)pOutputCol->pData; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) { @@ -1138,13 +1073,13 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } } } else { - double *output = (double *)pOutputCol->pData; - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + double *output = (double *)pOutputCol->pData; + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); if (pLeft->numOfRows == pRight->numOfRows) { for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { - if (IS_NULL){ + if (IS_NULL) { colDataAppendNULL(pOutputCol, i); continue; // TODO set null or ignore } @@ -1162,8 +1097,9 @@ void vectorMathAdd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } // TODO not correct for descending order scan -static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); +static void vectorMathSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; @@ -1176,14 +1112,14 @@ static void vectorMathSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRig colDataAppendNULL(pOutputCol, i); continue; // TODO set null or ignore } - *output = (getVectorDoubleValueFnLeft(LEFT_COL, i) - - getVectorDoubleValueFnRight(RIGHT_COL, 0)) * factor; + *output = (getVectorDoubleValueFnLeft(LEFT_COL, i) - getVectorDoubleValueFnRight(RIGHT_COL, 0)) * factor; } } } -static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); +static void vectorMathTsSubHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t factor, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1196,29 +1132,30 @@ static void vectorMathTsSubHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pR colDataAppendNULL(pOutputCol, i); continue; // TODO set null or ignore } - *output = taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), -getVectorBigintValueFnRight(pRightCol->pData, 0), - pRightCol->info.scale, pRightCol->info.precision); - + *output = + taosTimeAdd(getVectorBigintValueFnLeft(pLeftCol->pData, i), -getVectorBigintValueFnRight(pRightCol->pData, 0), + pRightCol->info.scale, pRightCol->info.precision); } } } -void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathSub(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); if ((GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_BIGINT) || - (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { //timestamp minus duration - int64_t *output = (int64_t *)pOutputCol->pData; - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + (GET_PARAM_TYPE(pRight) == TSDB_DATA_TYPE_TIMESTAMP && + GET_PARAM_TYPE(pLeft) == TSDB_DATA_TYPE_BIGINT)) { // timestamp minus duration + int64_t *output = (int64_t *)pOutputCol->pData; + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); if (pLeft->numOfRows == 1 && pRight->numOfRows == 1) { @@ -1237,8 +1174,8 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } } } else { - double *output = (double *)pOutputCol->pData; - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + double *output = (double *)pOutputCol->pData; + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); if (pLeft->numOfRows == pRight->numOfRows) { @@ -1256,13 +1193,14 @@ void vectorMathSub(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } } - doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pLeftCol, leftConvert); doReleaseVec(pRightCol, rightConvert); } // TODO not correct for descending order scan -static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); +static void vectorMathMultiplyHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t i) { + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; @@ -1280,18 +1218,18 @@ static void vectorMathMultiplyHelper(SColumnInfoData* pLeftCol, SColumnInfoData* } } -void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathMultiply(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; @@ -1313,45 +1251,44 @@ void vectorMathMultiply(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam doReleaseVec(pRightCol, rightConvert); } -void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathDivide(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; if (pLeft->numOfRows == pRight->numOfRows) { for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) { - if (IS_NULL || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { //divide by 0 check + if (IS_NULL || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { // divide by 0 check colDataAppendNULL(pOutputCol, i); continue; } - *output = getVectorDoubleValueFnLeft(LEFT_COL, i) - / getVectorDoubleValueFnRight(RIGHT_COL, i); + *output = getVectorDoubleValueFnLeft(LEFT_COL, i) / getVectorDoubleValueFnRight(RIGHT_COL, i); } } else if (pLeft->numOfRows == 1) { if (IS_HELPER_NULL(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value colDataAppendNNULL(pOutputCol, 0, pRight->numOfRows); } else { for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { - if (IS_HELPER_NULL(pRightCol, i) || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { // divide by 0 check + if (IS_HELPER_NULL(pRightCol, i) || (getVectorDoubleValueFnRight(RIGHT_COL, i) == 0)) { // divide by 0 check colDataAppendNULL(pOutputCol, i); continue; } - *output = getVectorDoubleValueFnLeft(LEFT_COL, 0) - / getVectorDoubleValueFnRight(RIGHT_COL, i); + *output = getVectorDoubleValueFnLeft(LEFT_COL, 0) / getVectorDoubleValueFnRight(RIGHT_COL, i); } } } else if (pRight->numOfRows == 1) { - if (IS_HELPER_NULL(pRightCol, 0) || (getVectorDoubleValueFnRight(RIGHT_COL, 0) == 0)) { // Set pLeft->numOfRows NULL value (divde by 0 check) + if (IS_HELPER_NULL(pRightCol, 0) || + (getVectorDoubleValueFnRight(RIGHT_COL, 0) == 0)) { // Set pLeft->numOfRows NULL value (divde by 0 check) colDataAppendNNULL(pOutputCol, 0, pLeft->numOfRows); } else { for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) { @@ -1359,28 +1296,27 @@ void vectorMathDivide(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *p colDataAppendNULL(pOutputCol, i); continue; } - *output = getVectorDoubleValueFnLeft(LEFT_COL, i) - / getVectorDoubleValueFnRight(RIGHT_COL, 0); + *output = getVectorDoubleValueFnLeft(LEFT_COL, i) / getVectorDoubleValueFnRight(RIGHT_COL, 0); } } } - doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pLeftCol, leftConvert); doReleaseVec(pRightCol, rightConvert); } -void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); _getDoubleValue_fn_t getVectorDoubleValueFnRight = getVectorDoubleValueFn(pRightCol->info.type); double *output = (double *)pOutputCol->pData; @@ -1447,18 +1383,18 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam doReleaseVec(pRightCol, rightConvert); } -void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMathMinus(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = pLeft->numOfRows; - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : (pLeft->numOfRows - 1); - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : (pLeft->numOfRows - 1); + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); - _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); + _getDoubleValue_fn_t getVectorDoubleValueFnLeft = getVectorDoubleValueFn(pLeftCol->info.type); double *output = (double *)pOutputCol->pData; for (; i < pLeft->numOfRows && i >= 0; i += step, output += 1) { @@ -1470,17 +1406,17 @@ void vectorMathMinus(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO *output = (result == 0) ? 0 : -result; } - doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pLeftCol, leftConvert); } -void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = pLeft->numOfRows; - if(colDataIsNull_s(pRight->columnData, 0)){ + if (colDataIsNull_s(pRight->columnData, 0)) { colDataAppendNNULL(pOutputCol, 0, pOut->numOfRows); } else { - char* d = colDataGetData(pRight->columnData, 0); + char *d = colDataGetData(pRight->columnData, 0); for (int32_t i = 0; i < pOut->numOfRows; ++i) { colDataAppend(pOutputCol, i, d, false); } @@ -1490,7 +1426,7 @@ void vectorAssign(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, pOut->numOfQualified = pRight->numOfQualified * pOut->numOfRows; } -void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t _ord) { +void vectorConcat(SScalarParam *pLeft, SScalarParam *pRight, void *out, int32_t _ord) { #if 0 int32_t len = pLeft->bytes + pRight->bytes; @@ -1541,8 +1477,9 @@ void vectorConcat(SScalarParam* pLeft, SScalarParam* pRight, void *out, int32_t #endif } -static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); +static void vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1560,7 +1497,7 @@ static void vectorBitAndHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRigh } } -void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); @@ -1568,10 +1505,10 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1589,12 +1526,13 @@ void vectorBitAnd(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, vectorBitAndHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); } - doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pLeftCol, leftConvert); doReleaseVec(pRightCol, rightConvert); } -static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRightCol, SColumnInfoData* pOutputCol, int32_t numOfRows, int32_t step, int32_t i) { - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); +static void vectorBitOrHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol, + int32_t numOfRows, int32_t step, int32_t i) { + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1613,7 +1551,7 @@ static void vectorBitOrHelper(SColumnInfoData* pLeftCol, SColumnInfoData* pRight } } -void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); @@ -1621,10 +1559,10 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t leftConvert = 0, rightConvert = 0; - SColumnInfoData *pLeftCol = doVectorConvert(pLeft, &leftConvert); - SColumnInfoData *pRightCol = doVectorConvert(pRight, &rightConvert); + SColumnInfoData *pLeftCol = vectorConvertVarToDouble(pLeft, &leftConvert); + SColumnInfoData *pRightCol = vectorConvertVarToDouble(pRight, &rightConvert); - _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); + _getBigintValue_fn_t getVectorBigintValueFnLeft = getVectorBigintValueFn(pLeftCol->info.type); _getBigintValue_fn_t getVectorBigintValueFnRight = getVectorBigintValueFn(pRightCol->info.type); int64_t *output = (int64_t *)pOutputCol->pData; @@ -1642,17 +1580,17 @@ void vectorBitOr(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, vectorBitOrHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i); } - doReleaseVec(pLeftCol, leftConvert); + doReleaseVec(pLeftCol, leftConvert); doReleaseVec(pRightCol, rightConvert); } -int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t startIndex, int32_t step, __compar_fn_t fp, - SScalarParam *pLeft, SScalarParam *pRight, int32_t optr) { +int32_t doVectorCompareImpl(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, + int32_t step, __compar_fn_t fp, int32_t optr) { int32_t num = 0; for (int32_t i = startIndex; i < numOfRows && i >= 0; i += step) { - int32_t leftIndex = (i >= pLeft->numOfRows)? 0:i; - int32_t rightIndex = (i >= pRight->numOfRows)? 0:i; + int32_t leftIndex = (i >= pLeft->numOfRows) ? 0 : i; + int32_t rightIndex = (i >= pRight->numOfRows) ? 0 : i; if (IS_HELPER_NULL(pLeft->columnData, leftIndex) || IS_HELPER_NULL(pRight->columnData, rightIndex)) { bool res = false; @@ -1660,15 +1598,15 @@ int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t start continue; } - char * pLeftData = colDataGetData(pLeft->columnData, leftIndex); - char * pRightData = colDataGetData(pRight->columnData, rightIndex); + char *pLeftData = colDataGetData(pLeft->columnData, leftIndex); + char *pRightData = colDataGetData(pRight->columnData, rightIndex); int64_t leftOut = 0; int64_t rightOut = 0; bool freeLeft = false; bool freeRight = false; bool isJsonnull = false; - bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, + bool result = convertJsonValue(&fp, optr, GET_PARAM_TYPE(pLeft), GET_PARAM_TYPE(pRight), &pLeftData, &pRightData, &leftOut, &rightOut, &isJsonnull, &freeLeft, &freeRight); if (isJsonnull) { ASSERT(0); @@ -1700,43 +1638,53 @@ int32_t doVectorCompareImpl(int32_t numOfRows, SScalarParam *pOut, int32_t start return num; } -void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { - int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; +void doVectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, + int32_t _ord, int32_t optr) { + int32_t i = 0; int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; int32_t lType = GET_PARAM_TYPE(pLeft); int32_t rType = GET_PARAM_TYPE(pRight); __compar_fn_t fp = NULL; - + int32_t compRows = 0; + if (lType == rType) { fp = filterGetCompFunc(lType, optr); } else { fp = filterGetCompFuncEx(lType, rType, optr); } - pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + if (startIndex < 0) { + i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); + compRows = pOut->numOfRows; + } else { + compRows = startIndex + numOfRows; + i = startIndex; + } if (pRight->pHashFilter != NULL) { for (; i >= 0 && i < pLeft->numOfRows; i += step) { if (IS_HELPER_NULL(pLeft->columnData, i)) { - bool res = false; - colDataAppendInt8(pOut->columnData, i, (int8_t*)&res); + bool res = false; + colDataAppendInt8(pOut->columnData, i, (int8_t *)&res); continue; } char *pLeftData = colDataGetData(pLeft->columnData, i); bool res = filterDoCompare(fp, optr, pLeftData, pRight->pHashFilter); - colDataAppendInt8(pOut->columnData, i, (int8_t*)&res); + colDataAppendInt8(pOut->columnData, i, (int8_t *)&res); if (res) { pOut->numOfQualified++; } } } else { // normal compare - pOut->numOfQualified = doVectorCompareImpl(pOut->numOfRows, pOut, i, step, fp, pLeft, pRight, optr); + pOut->numOfQualified = doVectorCompareImpl(pLeft, pRight, pOut, i, compRows, step, fp, optr); } } -void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { - SScalarParam pLeftOut = {0}; +void vectorCompareImpl(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t startIndex, int32_t numOfRows, + int32_t _ord, int32_t optr) { + SScalarParam pLeftOut = {0}; SScalarParam pRightOut = {0}; SScalarParam *param1 = NULL; SScalarParam *param2 = NULL; @@ -1745,7 +1693,7 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut param1 = pLeft; param2 = pRight; } else { - vectorConvert(pLeft, pRight, &pLeftOut, &pRightOut); + vectorConvertCols(pLeft, pRight, &pLeftOut, &pRightOut, startIndex, numOfRows); if (pLeftOut.columnData != NULL) { param1 = &pLeftOut; @@ -1760,69 +1708,74 @@ void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } } - vectorCompareImpl(param1, param2, pOut, _ord, optr); + doVectorCompare(param1, param2, pOut, startIndex, numOfRows, _ord, optr); + sclFreeParam(&pLeftOut); sclFreeParam(&pRightOut); } +void vectorCompare(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord, int32_t optr) { + vectorCompareImpl(pLeft, pRight, pOut, -1, -1, _ord, optr); +} + void vectorGreater(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_GREATER_THAN); } -void vectorGreaterEqual(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorGreaterEqual(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_GREATER_EQUAL); } -void vectorLower(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorLower(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_LOWER_THAN); } -void vectorLowerEqual(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorLowerEqual(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_LOWER_EQUAL); } -void vectorEqual(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorEqual(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_EQUAL); } -void vectorNotEqual(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorNotEqual(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_NOT_EQUAL); } -void vectorIn(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorIn(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_IN); } -void vectorNotIn(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorNotIn(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_NOT_IN); } -void vectorLike(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorLike(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_LIKE); } -void vectorNotLike(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorNotLike(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_NOT_LIKE); } -void vectorMatch(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorMatch(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_MATCH); } -void vectorNotMatch(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorNotMatch(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { vectorCompare(pLeft, pRight, pOut, _ord, OP_TYPE_NMATCH); } -void vectorIsNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - for(int32_t i = 0; i < pLeft->numOfRows; ++i) { +void vectorIsNull(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { + for (int32_t i = 0; i < pLeft->numOfRows; ++i) { int8_t v = IS_HELPER_NULL(pLeft->columnData, i) ? 1 : 0; colDataAppendInt8(pOut->columnData, i, &v); } pOut->numOfRows = pLeft->numOfRows; } -void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - for(int32_t i = 0; i < pLeft->numOfRows; ++i) { +void vectorNotNull(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { + for (int32_t i = 0; i < pLeft->numOfRows; ++i) { int8_t v = IS_HELPER_NULL(pLeft->columnData, i) ? 0 : 1; colDataAppendInt8(pOut->columnData, i, &v); } @@ -1830,7 +1783,7 @@ void vectorNotNull(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut } void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { - vectorConvertImpl(pLeft, pOut, NULL); + vectorConvertSingleColImpl(pLeft, pOut, NULL, -1, -1); for(int32_t i = 0; i < pOut->numOfRows; ++i) { if(colDataIsNull_s(pOut->columnData, i)) { int8_t v = 0; @@ -1843,26 +1796,26 @@ void vectorIsTrue(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, STagVal getJsonValue(char *json, char *key, bool *isExist) { STagVal val = {.pKey = key}; - if (tTagIsJson((const STag *)json) == false){ + if (tTagIsJson((const STag *)json) == false) { terrno = TSDB_CODE_QRY_JSON_NOT_SUPPORT_ERROR; - if(isExist){ + if (isExist) { *isExist = false; } return val; } bool find = tTagGet(((const STag *)json), &val); // json value is null and not exist is different - if(isExist){ + if (isExist) { *isExist = find; } return val; } -void vectorJsonContains(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorJsonContains(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); @@ -1877,17 +1830,16 @@ void vectorJsonContains(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam getJsonValue(pLeftData, jsonKey, &isExist); } - colDataAppend(pOutputCol, i, (const char*)(&isExist), false); - + colDataAppend(pOutputCol, i, (const char *)(&isExist), false); } taosMemoryFree(jsonKey); } -void vectorJsonArrow(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pOut, int32_t _ord) { +void vectorJsonArrow(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) { SColumnInfoData *pOutputCol = pOut->columnData; - int32_t i = ((_ord) == TSDB_ORDER_ASC)? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; - int32_t step = ((_ord) == TSDB_ORDER_ASC)? 1 : -1; + int32_t i = ((_ord) == TSDB_ORDER_ASC) ? 0 : TMAX(pLeft->numOfRows, pRight->numOfRows) - 1; + int32_t step = ((_ord) == TSDB_ORDER_ASC) ? 1 : -1; pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows); @@ -1900,12 +1852,12 @@ void vectorJsonArrow(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam *pO pOutputCol->hasNull = true; continue; } - char *pLeftData = colDataGetVarData(pLeft->columnData, i); - bool isExist = false; + char *pLeftData = colDataGetVarData(pLeft->columnData, i); + bool isExist = false; STagVal value = getJsonValue(pLeftData, jsonKey, &isExist); - char *data = isExist ? tTagValToData(&value, true) : NULL; + char *data = isExist ? tTagValToData(&value, true) : NULL; colDataAppend(pOutputCol, i, data, data == NULL); - if(isExist && IS_VAR_DATA_TYPE(value.type) && data){ + if (isExist && IS_VAR_DATA_TYPE(value.type) && data) { taosMemoryFree(data); } } @@ -1971,4 +1923,3 @@ _bin_scalar_fn_t getBinScalarOperatorFn(int32_t binFunctionId) { return NULL; } } - diff --git a/source/libs/scalar/test/filter/filterTests.cpp b/source/libs/scalar/test/filter/filterTests.cpp index bb7745dbd9a7af32e735e8131834d139221af9bd..ca304cd3291643d437083521409b997d327ffb1a 100644 --- a/source/libs/scalar/test/filter/filterTests.cpp +++ b/source/libs/scalar/test/filter/filterTests.cpp @@ -32,26 +32,21 @@ #endif #include "os.h" -#include "tglobal.h" -#include "taos.h" -#include "tdef.h" -#include "tvariant.h" -#include "tdatablock.h" -#include "stub.h" -#include "scalar.h" #include "filter.h" #include "nodes.h" #include "scalar.h" #include "stub.h" #include "taos.h" +#include "tdatablock.h" #include "tdef.h" +#include "tglobal.h" #include "tlog.h" #include "tvariant.h" namespace { int64_t flttLeftV = 21, flttRightV = 10; -double flttLeftVd = 21.0, flttRightVd = 10.0; +double flttLeftVd = 21.0, flttRightVd = 10.0; void flttInitLogFile() { const char *defaultLogFileNamePrefix = "taoslog"; @@ -66,9 +61,8 @@ void flttInitLogFile() { } } - void flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_VALUE); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE); SValueNode *vnode = (SValueNode *)node; vnode->node.resType.type = dataType; @@ -80,19 +74,20 @@ void flttMakeValueNode(SNode **pNode, int32_t dataType, void *value) { vnode->node.resType.bytes = tDataTypes[dataType].bytes; assignVal((char *)nodesGetValueFromNode(vnode), (const char *)value, 0, dataType); } - + *pNode = (SNode *)vnode; } -void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum, void *value) { +void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum, + void *value) { static uint64_t dbidx = 0; - - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_COLUMN); + + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN); SColumnNode *rnode = (SColumnNode *)node; rnode->node.resType.type = dataType; rnode->node.resType.bytes = dataBytes; rnode->dataBlockId = 0; - + sprintf(rnode->dbName, "%" PRIu64, dbidx++); if (NULL == block) { @@ -106,7 +101,7 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in if (NULL == *block) { SSDataBlock *res = createDataBlock(); for (int32_t i = 0; i < 2; ++i) { - SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1+i); + SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_NULL, 10, 1 + i); blockDataAppendColInfo(res, &idata); } @@ -131,9 +126,9 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in *block = res; } else { SSDataBlock *res = *block; - - int32_t idx = taosArrayGetSize(res->pDataBlock); - SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1+idx); + + int32_t idx = taosArrayGetSize(res->pDataBlock); + SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1 + idx); blockDataAppendColInfo(res, &idata); blockDataEnsureCapacity(res, rowNum); @@ -147,7 +142,7 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in value = (char *)value + dataBytes; } } - + rnode->slotId = idx; rnode->colId = 1 + idx; } @@ -156,11 +151,11 @@ void flttMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, in } void flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR); SOperatorNode *onode = (SOperatorNode *)node; onode->node.resType.type = resType; onode->node.resType.bytes = tDataTypes[resType].bytes; - + onode->opType = opType; onode->pLeft = pLeft; onode->pRight = pRight; @@ -169,7 +164,7 @@ void flttMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode } void flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); SLogicConditionNode *onode = (SLogicConditionNode *)node; onode->condType = opType; onode->node.resType.type = TSDB_DATA_TYPE_BOOL; @@ -179,24 +174,24 @@ void flttMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeLi for (int32_t i = 0; i < nodeNum; ++i) { nodesListAppend(onode->pParameterList, nodeList[i]); } - + *pNode = (SNode *)onode; } void flttMakeLogicNodeFromList(SNode **pNode, ELogicConditionType opType, SNodeList *nodeList) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); SLogicConditionNode *onode = (SLogicConditionNode *)node; onode->condType = opType; onode->node.resType.type = TSDB_DATA_TYPE_BOOL; onode->node.resType.bytes = sizeof(bool); onode->pParameterList = nodeList; - + *pNode = (SNode *)onode; } void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); SNodeListNode *lnode = (SNodeListNode *)node; lnode->dataType.type = resType; lnode->pNodeList = list; @@ -204,169 +199,166 @@ void flttMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { *pNode = (SNode *)lnode; } -void initScalarParam(SScalarParam* pParam) { +void initScalarParam(SScalarParam *pParam) { memset(pParam, 0, sizeof(SScalarParam)); pParam->colAlloced = true; } -} +} // namespace TEST(timerangeTest, greater) { - SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL; - bool eRes[5] = {false, false, true, true, true}; + SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL; + bool eRes[5] = {false, false, true, true, true}; SScalarParam res; initScalarParam(&res); int64_t tsmall = 222, tbig = 333; - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); - //SFilterInfo *filter = NULL; - //int32_t code = filterInitFromNode(opNode1, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); - //ASSERT_EQ(code, 0); + // SFilterInfo *filter = NULL; + // int32_t code = filterInitFromNode(opNode1, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); + // ASSERT_EQ(code, 0); STimeWindow win = {0}; - bool isStrict = false; - int32_t code = filterGetTimeRange(opNode1, &win, &isStrict); + bool isStrict = false; + int32_t code = filterGetTimeRange(opNode1, &win, &isStrict); ASSERT_EQ(code, 0); - ASSERT_EQ(isStrict, true); - ASSERT_EQ(win.skey, tsmall+1); - ASSERT_EQ(win.ekey, INT64_MAX); - //filterFreeInfo(filter); + ASSERT_EQ(isStrict, true); + ASSERT_EQ(win.skey, tsmall + 1); + ASSERT_EQ(win.ekey, INT64_MAX); + // filterFreeInfo(filter); nodesDestroyNode(opNode1); } TEST(timerangeTest, greater_and_lower) { - SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; - bool eRes[5] = {false, false, true, true, true}; + SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; + bool eRes[5] = {false, false, true, true, true}; SScalarParam res; initScalarParam(&res); int64_t tsmall = 222, tbig = 333; - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tbig); flttMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); SNode *list[2] = {0}; list[0] = opNode1; list[1] = opNode2; - + flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - //SFilterInfo *filter = NULL; - //int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); - //ASSERT_EQ(code, 0); + // SFilterInfo *filter = NULL; + // int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); + // ASSERT_EQ(code, 0); STimeWindow win = {0}; - bool isStrict = false; - int32_t code = filterGetTimeRange(logicNode, &win, &isStrict); + bool isStrict = false; + int32_t code = filterGetTimeRange(logicNode, &win, &isStrict); ASSERT_EQ(isStrict, true); ASSERT_EQ(code, 0); - ASSERT_EQ(win.skey, tsmall+1); - ASSERT_EQ(win.ekey, tbig-1); - //filterFreeInfo(filter); + ASSERT_EQ(win.skey, tsmall + 1); + ASSERT_EQ(win.ekey, tbig - 1); + // filterFreeInfo(filter); nodesDestroyNode(logicNode); } TEST(timerangeTest, greater_equal_and_lower_equal) { - SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; - bool eRes[5] = {false, false, true, true, true}; - SScalarParam res; + SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; + bool eRes[5] = {false, false, true, true, true}; + SScalarParam res; initScalarParam(&res); int64_t tsmall = 222, tbig = 333; - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_EQUAL, TSDB_DATA_TYPE_BOOL, pcol, pval); - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tbig); flttMakeOpNode(&opNode2, OP_TYPE_LOWER_EQUAL, TSDB_DATA_TYPE_BOOL, pcol, pval); SNode *list[2] = {0}; list[0] = opNode1; list[1] = opNode2; - + flttMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - //SFilterInfo *filter = NULL; - //int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); - //ASSERT_EQ(code, 0); + // SFilterInfo *filter = NULL; + // int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); + // ASSERT_EQ(code, 0); STimeWindow win = {0}; - bool isStrict = false; - int32_t code = filterGetTimeRange(logicNode, &win, &isStrict); + bool isStrict = false; + int32_t code = filterGetTimeRange(logicNode, &win, &isStrict); ASSERT_EQ(isStrict, true); ASSERT_EQ(code, 0); ASSERT_EQ(win.skey, tsmall); - ASSERT_EQ(win.ekey, tbig); - //filterFreeInfo(filter); + ASSERT_EQ(win.ekey, tbig); + // filterFreeInfo(filter); nodesDestroyNode(logicNode); } - TEST(timerangeTest, greater_and_lower_not_strict) { - SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL; - bool eRes[5] = {false, false, true, true, true}; + SNode *pcol = NULL, *pval = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode1 = NULL, *logicNode2 = NULL; + bool eRes[5] = {false, false, true, true, true}; SScalarParam res; initScalarParam(&res); int64_t tsmall1 = 222, tbig1 = 333; int64_t tsmall2 = 444, tbig2 = 555; - SNode *list[2] = {0}; + SNode *list[2] = {0}; - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall1); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tbig1); flttMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); list[0] = opNode1; list[1] = opNode2; - + flttMakeLogicNode(&logicNode1, LOGIC_COND_TYPE_AND, list, 2); - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tsmall2); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); - flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); + flttMakeColumnNode(&pcol, NULL, TSDB_DATA_TYPE_TIMESTAMP, sizeof(int64_t), 0, NULL); flttMakeValueNode(&pval, TSDB_DATA_TYPE_TIMESTAMP, &tbig2); flttMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pcol, pval); list[0] = opNode1; list[1] = opNode2; - + flttMakeLogicNode(&logicNode2, LOGIC_COND_TYPE_AND, list, 2); list[0] = logicNode1; list[1] = logicNode2; flttMakeLogicNode(&logicNode1, LOGIC_COND_TYPE_OR, list, 2); - //SFilterInfo *filter = NULL; - //int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); - //ASSERT_EQ(code, 0); + // SFilterInfo *filter = NULL; + // int32_t code = filterInitFromNode(logicNode, &filter, FLT_OPTION_NO_REWRITE|FLT_OPTION_TIMESTAMP); + // ASSERT_EQ(code, 0); STimeWindow win = {0}; - bool isStrict = false; - int32_t code = filterGetTimeRange(logicNode1, &win, &isStrict); + bool isStrict = false; + int32_t code = filterGetTimeRange(logicNode1, &win, &isStrict); ASSERT_EQ(isStrict, false); ASSERT_EQ(code, 0); - ASSERT_EQ(win.skey, tsmall1+1); - ASSERT_EQ(win.ekey, tbig2-1); - //filterFreeInfo(filter); + ASSERT_EQ(win.skey, tsmall1 + 1); + ASSERT_EQ(win.ekey, tbig2 - 1); + // filterFreeInfo(filter); nodesDestroyNode(logicNode1); } - - TEST(columnTest, smallint_column_greater_double_value) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - double rightv= 2.5; - int8_t eRes[5] = {0, 0, 1, 1, 1}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + double rightv = 2.5; + int8_t eRes[5] = {0, 0, 1, 1, 1}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - + SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); SColumnDataAgg stat = {0}; @@ -388,7 +380,7 @@ TEST(columnTest, smallint_column_greater_double_value) { keep = filterRangeExecute(filter, &stat, 1, rowNum); ASSERT_EQ(keep, true); - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -396,7 +388,7 @@ TEST(columnTest, smallint_column_greater_double_value) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -409,20 +401,20 @@ TEST(columnTest, smallint_column_greater_double_value) { } TEST(columnTest, int_column_greater_smallint_value) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int32_t leftv[5]= {1, 3, 5, 7, 9}; - int16_t rightv= 4; - int8_t eRes[5] = {0, 0, 1, 1, 1}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int32_t leftv[5] = {1, 3, 5, 7, 9}; + int16_t rightv = 4; + int8_t eRes[5] = {0, 0, 1, 1, 1}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); SColumnDataAgg stat = {0}; @@ -444,7 +436,7 @@ TEST(columnTest, int_column_greater_smallint_value) { keep = filterRangeExecute(filter, &stat, 1, rowNum); ASSERT_EQ(keep, false); - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -452,7 +444,7 @@ TEST(columnTest, int_column_greater_smallint_value) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -465,31 +457,31 @@ TEST(columnTest, int_column_greater_smallint_value) { } TEST(columnTest, int_column_in_double_list) { - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; - int32_t leftv[5] = {1, 2, 3, 4, 5}; - double rightv1 = 1.1,rightv2 = 2.2,rightv3 = 3.3; - bool eRes[5] = {true, true, true, false, false}; + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; + int32_t leftv[5] = {1, 2, 3, 4, 5}; + double rightv1 = 1.1, rightv2 = 2.2, rightv3 = 3.3; + bool eRes[5] = {true, true, true, false, false}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv1); nodesListAppend(list, pRight); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv2); nodesListAppend(list, pRight); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv3); nodesListAppend(list, pRight); - flttMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); + flttMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); flttMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -497,7 +489,7 @@ TEST(columnTest, int_column_in_double_list) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -511,13 +503,13 @@ TEST(columnTest, int_column_in_double_list) { } TEST(columnTest, binary_column_in_binary_list) { - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; - bool eRes[5] = {true, true, false, false, false}; + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; + bool eRes[5] = {true, true, false, false, false}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - char leftv[5][5]= {0}; - char rightv[3][5]= {0}; + char leftv[5][5] = {0}; + char rightv[3][5] = {0}; for (int32_t i = 0; i < 5; ++i) { leftv[i][2] = 'a' + i; leftv[i][3] = 'b' + i; @@ -537,24 +529,24 @@ TEST(columnTest, binary_column_in_binary_list) { varDataSetLen(rightv[i], 3); } - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[0]); nodesListAppend(list, pRight); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[1]); nodesListAppend(list, pRight); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[2]); nodesListAppend(list, pRight); - flttMakeListNode(&listNode,list, TSDB_DATA_TYPE_BINARY); + flttMakeListNode(&listNode, list, TSDB_DATA_TYPE_BINARY); flttMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -562,7 +554,7 @@ TEST(columnTest, binary_column_in_binary_list) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -575,9 +567,9 @@ TEST(columnTest, binary_column_in_binary_list) { } TEST(columnTest, binary_column_like_binary) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - char rightv[64] = {0}; - char leftv[5][5]= {0}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + char rightv[64] = {0}; + char leftv[5][5] = {0}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); @@ -590,7 +582,7 @@ TEST(columnTest, binary_column_like_binary) { varDataSetLen(leftv[i], 3); } - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); sprintf(&rightv[2], "%s", "__0"); @@ -599,11 +591,11 @@ TEST(columnTest, binary_column_like_binary) { flttMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -611,7 +603,7 @@ TEST(columnTest, binary_column_like_binary) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -624,8 +616,8 @@ TEST(columnTest, binary_column_like_binary) { } TEST(columnTest, binary_column_is_null) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); @@ -638,7 +630,7 @@ TEST(columnTest, binary_column_is_null) { varDataSetLen(leftv[i], 3); } - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); @@ -647,11 +639,11 @@ TEST(columnTest, binary_column_is_null) { flttMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -659,7 +651,7 @@ TEST(columnTest, binary_column_is_null) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -672,8 +664,8 @@ TEST(columnTest, binary_column_is_null) { } TEST(columnTest, binary_column_is_not_null) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); @@ -686,7 +678,7 @@ TEST(columnTest, binary_column_is_not_null) { varDataSetLen(leftv[i], 3); } - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); @@ -695,11 +687,11 @@ TEST(columnTest, binary_column_is_not_null) { flttMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -707,7 +699,7 @@ TEST(columnTest, binary_column_is_not_null) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -720,24 +712,24 @@ TEST(columnTest, binary_column_is_not_null) { } TEST(opTest, smallint_column_greater_int_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5] = {1, -6, -2, 11, 101}; - int32_t rightv[5]= {0, -5, -4, 23, 100}; - bool eRes[5] = {true, false, true, false, true}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, -6, -2, 11, 101}; + int32_t rightv[5] = {0, -5, -4, 23, 100}; + bool eRes[5] = {true, false, true, false, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, rightv); flttMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -745,7 +737,7 @@ TEST(opTest, smallint_column_greater_int_column) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -758,25 +750,25 @@ TEST(opTest, smallint_column_greater_int_column) { } TEST(opTest, smallint_value_add_int_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int32_t leftv = 1; - int16_t rightv[5]= {0, -1, -4, -1, 100}; - bool eRes[5] = {true, false, true, false, true}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int32_t leftv = 1; + int16_t rightv[5] = {0, -1, -4, -1, 100}; + bool eRes[5] = {true, false, true, false, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); flttMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, rightv); flttMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -784,7 +776,7 @@ TEST(opTest, smallint_value_add_int_column) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -797,30 +789,30 @@ TEST(opTest, smallint_value_add_int_column) { } TEST(opTest, bigint_column_multi_binary_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int64_t leftv[5]= {1, 2, 3, 4, 5}; - char rightv[5][5]= {0}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int64_t leftv[5] = {1, 2, 3, 4, 5}; + char rightv[5][5] = {0}; for (int32_t i = 0; i < 5; ++i) { rightv[i][2] = rightv[i][3] = '0'; rightv[i][4] = '0' + i; varDataSetLen(rightv[i], 3); } - bool eRes[5] = {false, true, true, true, true}; + bool eRes[5] = {false, true, true, true, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); flttMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -828,7 +820,7 @@ TEST(opTest, bigint_column_multi_binary_column) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -841,30 +833,30 @@ TEST(opTest, bigint_column_multi_binary_column) { } TEST(opTest, smallint_column_and_binary_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - char rightv[5][5]= {0}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + char rightv[5][5] = {0}; for (int32_t i = 0; i < 5; ++i) { rightv[i][2] = rightv[i][3] = '0'; rightv[i][4] = '0' + i; varDataSetLen(rightv[i], 3); } - bool eRes[5] = {false, false, true, false, true}; + bool eRes[5] = {false, false, true, false, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); flttMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -872,7 +864,7 @@ TEST(opTest, smallint_column_and_binary_column) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t) taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, (int32_t)taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -885,25 +877,25 @@ TEST(opTest, smallint_column_and_binary_column) { } TEST(opTest, smallint_column_or_float_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 0, 4, 5}; - float rightv[5]= {2.0, 3.0, 0, 5.2, 6.0}; - bool eRes[5] = {true, true, false, true, true}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 0, 4, 5}; + float rightv[5] = {2.0, 3.0, 0, 5.2, 6.0}; + bool eRes[5] = {true, true, false, true, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_FLOAT, sizeof(float), rowNum, rightv); flttMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -911,7 +903,7 @@ TEST(opTest, smallint_column_or_float_column) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -924,25 +916,25 @@ TEST(opTest, smallint_column_or_float_column) { } TEST(opTest, smallint_column_or_double_value) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {0, 2, 3, 0, -1}; - double rightv= 10.2; - bool eRes[5] = {true, true, true, true, true}; + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {0, 2, 3, 0, -1}; + double rightv = 10.2; + bool eRes[5] = {true, true, true, true, true}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); flttMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); flttMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -950,7 +942,7 @@ TEST(opTest, smallint_column_or_double_value) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, true); for (int32_t i = 0; i < rowNum; ++i) { @@ -963,8 +955,8 @@ TEST(opTest, smallint_column_or_double_value) { } TEST(opTest, binary_column_is_true) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; SSDataBlock *src = NULL; SScalarParam res; initScalarParam(&res); @@ -977,17 +969,17 @@ TEST(opTest, binary_column_is_true) { varDataSetLen(leftv[i], 3); } - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); flttMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); flttMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL); SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(opNode, &filter, 0); + int32_t code = filterInitFromNode(opNode, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -995,7 +987,7 @@ TEST(opTest, binary_column_is_true) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -1010,16 +1002,16 @@ TEST(opTest, binary_column_is_true) { TEST(filterModelogicTest, diff_columns_and_or_and) { flttInitLogFile(); - SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; - SNode *logicNode1 = NULL, *logicNode2 = NULL; - double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; - int32_t rightv1= 3, rightv2= 3; - int8_t eRes[8] = {1, 1, 0, 0, 1, 1, 1, 1}; + SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; + SNode *logicNode1 = NULL, *logicNode2 = NULL; + double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; + int32_t rightv1 = 3, rightv2 = 3; + int8_t eRes[8] = {1, 1, 0, 0, 1, 1, 1, 1}; SSDataBlock *src = NULL; - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); - int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]); + int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1); @@ -1032,7 +1024,6 @@ TEST(filterModelogicTest, diff_columns_and_or_and) { flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list); - list = nodesMakeList(); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); @@ -1052,13 +1043,12 @@ TEST(filterModelogicTest, diff_columns_and_or_and) { nodesListAppend(list, logicNode2); flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list); - SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(logicNode1, &filter, 0); + int32_t code = filterInitFromNode(logicNode1, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -1066,7 +1056,7 @@ TEST(filterModelogicTest, diff_columns_and_or_and) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -1079,16 +1069,16 @@ TEST(filterModelogicTest, diff_columns_and_or_and) { } TEST(filterModelogicTest, same_column_and_or_and) { - SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; - SNode *logicNode1 = NULL, *logicNode2 = NULL; - double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}; - int32_t rightv1= 3, rightv2= 0, rightv3 = 2, rightv4 = -2; - int8_t eRes[8] = {1, 1, 0, 0, 0, 1, 1, 0}; + SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; + SNode *logicNode1 = NULL, *logicNode2 = NULL; + double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}; + int32_t rightv1 = 3, rightv2 = 0, rightv3 = 2, rightv4 = -2; + int8_t eRes[8] = {1, 1, 0, 0, 0, 1, 1, 0}; SSDataBlock *src = NULL; - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); - int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]); + int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1); @@ -1101,7 +1091,6 @@ TEST(filterModelogicTest, same_column_and_or_and) { flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list); - list = nodesMakeList(); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); @@ -1121,13 +1110,12 @@ TEST(filterModelogicTest, same_column_and_or_and) { nodesListAppend(list, logicNode2); flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list); - SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(logicNode1, &filter, 0); + int32_t code = filterInitFromNode(logicNode1, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -1135,7 +1123,7 @@ TEST(filterModelogicTest, same_column_and_or_and) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -1148,16 +1136,16 @@ TEST(filterModelogicTest, same_column_and_or_and) { } TEST(filterModelogicTest, diff_columns_or_and_or) { - SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; - SNode *logicNode1 = NULL, *logicNode2 = NULL; - double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; - int32_t rightv1= 3, rightv2= 3; - int8_t eRes[8] = {1, 0, 1, 1, 0, 0, 0, 0}; + SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; + SNode *logicNode1 = NULL, *logicNode2 = NULL; + double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; + int32_t rightv1 = 3, rightv2 = 3; + int8_t eRes[8] = {1, 0, 1, 1, 0, 0, 0, 0}; SSDataBlock *src = NULL; - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); - int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]); + int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1); @@ -1170,7 +1158,6 @@ TEST(filterModelogicTest, diff_columns_or_and_or) { flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list); - list = nodesMakeList(); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); @@ -1190,13 +1177,12 @@ TEST(filterModelogicTest, diff_columns_or_and_or) { nodesListAppend(list, logicNode2); flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list); - SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(logicNode1, &filter, 0); + int32_t code = filterInitFromNode(logicNode1, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t) taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -1204,7 +1190,7 @@ TEST(filterModelogicTest, diff_columns_or_and_or) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -1217,16 +1203,16 @@ TEST(filterModelogicTest, diff_columns_or_and_or) { } TEST(filterModelogicTest, same_column_or_and_or) { - SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; - SNode *logicNode1 = NULL, *logicNode2 = NULL; - double leftv1[8]= {1, 2, 3, 4, 5,-1,-2,-3}; - int32_t rightv1= 3, rightv2= 0, rightv3 = 2, rightv4 = -2; - int8_t eRes[8] = {0, 0, 0, 1, 1, 1, 1, 1}; + SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; + SNode *logicNode1 = NULL, *logicNode2 = NULL; + double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}; + int32_t rightv1 = 3, rightv2 = 0, rightv3 = 2, rightv4 = -2; + int8_t eRes[8] = {0, 0, 0, 1, 1, 1, 1, 1}; SSDataBlock *src = NULL; - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); - int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]); + int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); flttMakeValueNode(&pRight1, TSDB_DATA_TYPE_INT, &rightv1); flttMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1); @@ -1239,7 +1225,6 @@ TEST(filterModelogicTest, same_column_or_and_or) { flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list); - list = nodesMakeList(); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); @@ -1259,13 +1244,12 @@ TEST(filterModelogicTest, same_column_or_and_or) { nodesListAppend(list, logicNode2); flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list); - SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(logicNode1, &filter, 0); + int32_t code = filterInitFromNode(logicNode1, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -1273,7 +1257,7 @@ TEST(filterModelogicTest, same_column_or_and_or) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); for (int32_t i = 0; i < rowNum; ++i) { @@ -1288,16 +1272,16 @@ TEST(filterModelogicTest, same_column_or_and_or) { TEST(scalarModelogicTest, diff_columns_or_and_or) { flttInitLogFile(); - SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; - SNode *logicNode1 = NULL, *logicNode2 = NULL; - double leftv1[8] = {1, 2, 3, 4, 5,-1,-2,-3}, leftv2[8]= {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; - int32_t rightv1[8]= {5, 8, 2, -3, 9,-7,10, 0}, rightv2[8]= {-3, 5, 8, 2, -9, 11, -4, 0}; - int8_t eRes[8] = {0, 1, 1, 0, 0, 1, 0, 0}; + SNode *pLeft1 = NULL, *pRight1 = NULL, *pLeft2 = NULL, *pRight2 = NULL, *opNode1 = NULL, *opNode2 = NULL; + SNode *logicNode1 = NULL, *logicNode2 = NULL; + double leftv1[8] = {1, 2, 3, 4, 5, -1, -2, -3}, leftv2[8] = {3.0, 4, 2, 9, -3, 3.9, 4.1, 5.2}; + int32_t rightv1[8] = {5, 8, 2, -3, 9, -7, 10, 0}, rightv2[8] = {-3, 5, 8, 2, -9, 11, -4, 0}; + int8_t eRes[8] = {0, 1, 1, 0, 0, 1, 0, 0}; SSDataBlock *src = NULL; - SNodeList* list = nodesMakeList(); + SNodeList *list = nodesMakeList(); - int32_t rowNum = sizeof(leftv1)/sizeof(leftv1[0]); + int32_t rowNum = sizeof(leftv1) / sizeof(leftv1[0]); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); flttMakeColumnNode(&pRight1, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, rightv1); flttMakeOpNode(&opNode1, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft1, pRight1); @@ -1310,7 +1294,6 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) { flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_OR, list); - list = nodesMakeList(); flttMakeColumnNode(&pLeft1, &src, TSDB_DATA_TYPE_DOUBLE, sizeof(double), rowNum, leftv1); @@ -1330,13 +1313,12 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) { nodesListAppend(list, logicNode2); flttMakeLogicNodeFromList(&logicNode1, LOGIC_COND_TYPE_AND, list); - SFilterInfo *filter = NULL; - int32_t code = filterInitFromNode(logicNode1, &filter, 0); + int32_t code = filterInitFromNode(logicNode1, &filter, 0); ASSERT_EQ(code, 0); - SColumnDataAgg stat = {0}; - SFilterColumnParam param = { (int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock }; + SColumnDataAgg stat = {0}; + SFilterColumnParam param = {(int32_t)taosArrayGetSize(src->pDataBlock), src->pDataBlock}; code = filterSetDataFromSlotId(filter, ¶m); ASSERT_EQ(code, 0); @@ -1344,9 +1326,9 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) { stat.min = 1; stat.numOfNull = 0; int8_t *rowRes = NULL; - bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); + bool keep = filterExecute(filter, src, &rowRes, &stat, taosArrayGetSize(src->pDataBlock)); ASSERT_EQ(keep, false); - + for (int32_t i = 0; i < rowNum; ++i) { ASSERT_EQ(*((int8_t *)rowRes + i), eRes[i]); } @@ -1356,7 +1338,7 @@ TEST(scalarModelogicTest, diff_columns_or_and_or) { blockDataDestroy(src); } -int main(int argc, char** argv) { +int main(int argc, char **argv) { taosSeedRand(taosGetTimestampSec()); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/source/libs/scalar/test/scalar/scalarTests.cpp b/source/libs/scalar/test/scalar/scalarTests.cpp index 7229fdec386b7df5bb626ea0524144d4f42dd995..39055b534d937ca74ecde5d017710534112fc91a 100644 --- a/source/libs/scalar/test/scalar/scalarTests.cpp +++ b/source/libs/scalar/test/scalar/scalarTests.cpp @@ -1,17 +1,17 @@ /* -* 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 . -*/ + * 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 @@ -32,17 +32,17 @@ #endif #include "os.h" -#include "tglobal.h" +#include "filterInt.h" +#include "nodes.h" +#include "parUtil.h" +#include "scalar.h" +#include "stub.h" #include "taos.h" -#include "tdef.h" -#include "tvariant.h" #include "tdatablock.h" -#include "stub.h" -#include "scalar.h" -#include "nodes.h" +#include "tdef.h" +#include "tglobal.h" #include "tlog.h" -#include "parUtil.h" -#include "filterInt.h" +#include "tvariant.h" #define _DEBUG_PRINT_ 0 @@ -55,3595 +55,3582 @@ namespace { SColumnInfo createColumnInfo(int32_t colId, int32_t type, int32_t bytes) { - SColumnInfo info = {0}; - info.colId = colId; - info.type = type; - info.bytes = bytes; - return info; + SColumnInfo info = {0}; + info.colId = colId; + info.type = type; + info.bytes = bytes; + return info; } int64_t scltLeftV = 21, scltRightV = 10; -double scltLeftVd = 21.0, scltRightVd = 10.0; +double scltLeftVd = 21.0, scltRightVd = 10.0; -void scltFreeDataBlock(void *block) { - blockDataDestroy(*(SSDataBlock **)block); -} +void scltFreeDataBlock(void *block) { blockDataDestroy(*(SSDataBlock **)block); } void scltInitLogFile() { - const char *defaultLogFileNamePrefix = "taoslog"; - const int32_t maxLogFileNum = 10; + const char *defaultLogFileNamePrefix = "taoslog"; + const int32_t maxLogFileNum = 10; - tsAsyncLog = 0; - qDebugFlag = 159; - strcpy(tsLogDir, TD_LOG_DIR_PATH); + tsAsyncLog = 0; + qDebugFlag = 159; + strcpy(tsLogDir, TD_LOG_DIR_PATH); - 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); + } } -void scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t *slotId, bool newBlock, int32_t rows, SColumnInfo *colInfo) { - if (newBlock) { - SSDataBlock *res = createDataBlock(); +void scltAppendReservedSlot(SArray *pBlockList, int16_t *dataBlockId, int16_t *slotId, bool newBlock, int32_t rows, + SColumnInfo *colInfo) { + if (newBlock) { + SSDataBlock *res = createDataBlock(); - SColumnInfoData idata = {0}; - idata.info = *colInfo; - colInfoDataEnsureCapacity(&idata, rows); + SColumnInfoData idata = {0}; + idata.info = *colInfo; + colInfoDataEnsureCapacity(&idata, rows); - blockDataAppendColInfo(res, &idata); + blockDataAppendColInfo(res, &idata); - res->info.capacity = rows; - res->info.rows = rows; - SColumnInfoData* p = static_cast(taosArrayGet(res->pDataBlock, 0)); - ASSERT(p->pData != NULL && p->nullbitmap != NULL); + res->info.capacity = rows; + res->info.rows = rows; + SColumnInfoData *p = static_cast(taosArrayGet(res->pDataBlock, 0)); + ASSERT(p->pData != NULL && p->nullbitmap != NULL); - taosArrayPush(pBlockList, &res); - *dataBlockId = taosArrayGetSize(pBlockList) - 1; - res->info.blockId = *dataBlockId; - *slotId = 0; - } else { - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(pBlockList); - SColumnInfoData idata = {0}; - idata.info = *colInfo; - colInfoDataEnsureCapacity(&idata, rows); - blockDataAppendColInfo(res, &idata); + taosArrayPush(pBlockList, &res); + *dataBlockId = taosArrayGetSize(pBlockList) - 1; + res->info.blockId = *dataBlockId; + *slotId = 0; + } else { + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(pBlockList); + SColumnInfoData idata = {0}; + idata.info = *colInfo; + colInfoDataEnsureCapacity(&idata, rows); + blockDataAppendColInfo(res, &idata); - *dataBlockId = taosArrayGetSize(pBlockList) - 1; - *slotId = taosArrayGetSize(res->pDataBlock) - 1; - } + *dataBlockId = taosArrayGetSize(pBlockList) - 1; + *slotId = taosArrayGetSize(res->pDataBlock) - 1; + } } void scltMakeValueNode(SNode **pNode, int32_t dataType, void *value) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_VALUE); - SValueNode *vnode = (SValueNode *)node; - vnode->node.resType.type = dataType; - - if (IS_VAR_DATA_TYPE(dataType)) { - vnode->datum.p = (char *)taosMemoryMalloc(varDataTLen(value)); - varDataCopy(vnode->datum.p, value); - vnode->node.resType.bytes = varDataTLen(value); - } else { - vnode->node.resType.bytes = tDataTypes[dataType].bytes; - assignVal((char *)nodesGetValueFromNode(vnode), (const char *)value, 0, dataType); - } - - *pNode = (SNode *)vnode; -} - -void scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum, void *value) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_COLUMN); - SColumnNode *rnode = (SColumnNode *)node; - rnode->node.resType.type = dataType; - rnode->node.resType.bytes = dataBytes; - rnode->dataBlockId = 0; - - if (NULL == block) { - *pNode = (SNode *)rnode; - return; - } - - if (NULL == *block) { - SSDataBlock *res = createDataBlock(); - for (int32_t i = 0; i < 2; ++i) { - SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_INT, 10, i + 1); - colInfoDataEnsureCapacity(&idata, rowNum); - blockDataAppendColInfo(res, &idata); - } - - SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 3); - colInfoDataEnsureCapacity(&idata, rowNum); - blockDataAppendColInfo(res, &idata); - res->info.capacity = rowNum; - - res->info.rows = rowNum; - SColumnInfoData *pColumn = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pColumn, i, (const char *)value, false); - if (IS_VAR_DATA_TYPE(dataType)) { - value = (char *)value + varDataTLen(value); - } else { - value = (char *)value + dataBytes; - } - } - - rnode->slotId = 2; - rnode->colId = 3; - - *block = res; - } else { - SSDataBlock *res = *block; - - int32_t idx = taosArrayGetSize(res->pDataBlock); - SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1 + idx); - colInfoDataEnsureCapacity(&idata, rowNum); - - res->info.capacity = rowNum; - blockDataAppendColInfo(res, &idata); - - SColumnInfoData *pColumn = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pColumn, i, (const char *)value, false); - if (IS_VAR_DATA_TYPE(dataType)) { - value = (char *)value + varDataTLen(value); - } else { - value = (char *)value + dataBytes; - } - } - - rnode->slotId = idx; - rnode->colId = 1 + idx; - } - - *pNode = (SNode *)rnode; -} - -void scltMakeOpNode2(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight, bool isReverse) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR); - SOperatorNode *onode = (SOperatorNode *)node; - onode->node.resType.type = resType; - onode->node.resType.bytes = tDataTypes[resType].bytes; - - onode->opType = opType; - if(isReverse){ - onode->pLeft = pRight; - onode->pRight = pLeft; - }else{ - onode->pLeft = pLeft; - onode->pRight = pRight; - } - - *pNode = (SNode *)onode; + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_VALUE); + SValueNode *vnode = (SValueNode *)node; + vnode->node.resType.type = dataType; + + if (IS_VAR_DATA_TYPE(dataType)) { + vnode->datum.p = (char *)taosMemoryMalloc(varDataTLen(value)); + varDataCopy(vnode->datum.p, value); + vnode->node.resType.bytes = varDataTLen(value); + } else { + vnode->node.resType.bytes = tDataTypes[dataType].bytes; + assignVal((char *)nodesGetValueFromNode(vnode), (const char *)value, 0, dataType); + } + + *pNode = (SNode *)vnode; +} + +void scltMakeColumnNode(SNode **pNode, SSDataBlock **block, int32_t dataType, int32_t dataBytes, int32_t rowNum, + void *value) { + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_COLUMN); + SColumnNode *rnode = (SColumnNode *)node; + rnode->node.resType.type = dataType; + rnode->node.resType.bytes = dataBytes; + rnode->dataBlockId = 0; + + if (NULL == block) { + *pNode = (SNode *)rnode; + return; + } + + if (NULL == *block) { + SSDataBlock *res = createDataBlock(); + for (int32_t i = 0; i < 2; ++i) { + SColumnInfoData idata = createColumnInfoData(TSDB_DATA_TYPE_INT, 10, i + 1); + colInfoDataEnsureCapacity(&idata, rowNum); + blockDataAppendColInfo(res, &idata); + } + + SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 3); + colInfoDataEnsureCapacity(&idata, rowNum); + blockDataAppendColInfo(res, &idata); + res->info.capacity = rowNum; + + res->info.rows = rowNum; + SColumnInfoData *pColumn = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pColumn, i, (const char *)value, false); + if (IS_VAR_DATA_TYPE(dataType)) { + value = (char *)value + varDataTLen(value); + } else { + value = (char *)value + dataBytes; + } + } + + rnode->slotId = 2; + rnode->colId = 3; + + *block = res; + } else { + SSDataBlock *res = *block; + + int32_t idx = taosArrayGetSize(res->pDataBlock); + SColumnInfoData idata = createColumnInfoData(dataType, dataBytes, 1 + idx); + colInfoDataEnsureCapacity(&idata, rowNum); + + res->info.capacity = rowNum; + blockDataAppendColInfo(res, &idata); + + SColumnInfoData *pColumn = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pColumn, i, (const char *)value, false); + if (IS_VAR_DATA_TYPE(dataType)) { + value = (char *)value + varDataTLen(value); + } else { + value = (char *)value + dataBytes; + } + } + + rnode->slotId = idx; + rnode->colId = 1 + idx; + } + + *pNode = (SNode *)rnode; +} + +void scltMakeOpNode2(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight, + bool isReverse) { + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode *onode = (SOperatorNode *)node; + onode->node.resType.type = resType; + onode->node.resType.bytes = tDataTypes[resType].bytes; + + onode->opType = opType; + if (isReverse) { + onode->pLeft = pRight; + onode->pRight = pLeft; + } else { + onode->pLeft = pLeft; + onode->pRight = pRight; + } + + *pNode = (SNode *)onode; } void scltMakeOpNode(SNode **pNode, EOperatorType opType, int32_t resType, SNode *pLeft, SNode *pRight) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_OPERATOR); - SOperatorNode *onode = (SOperatorNode *)node; - onode->node.resType.type = resType; - onode->node.resType.bytes = tDataTypes[resType].bytes; + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_OPERATOR); + SOperatorNode *onode = (SOperatorNode *)node; + onode->node.resType.type = resType; + onode->node.resType.bytes = tDataTypes[resType].bytes; - onode->opType = opType; - onode->pLeft = pLeft; - onode->pRight = pRight; + onode->opType = opType; + onode->pLeft = pLeft; + onode->pRight = pRight; - *pNode = (SNode *)onode; + *pNode = (SNode *)onode; } - void scltMakeListNode(SNode **pNode, SNodeList *list, int32_t resType) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - SNodeListNode *lnode = (SNodeListNode *)node; - lnode->dataType.type = resType; - lnode->pNodeList = list; + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SNodeListNode *lnode = (SNodeListNode *)node; + lnode->dataType.type = resType; + lnode->pNodeList = list; - *pNode = (SNode *)lnode; + *pNode = (SNode *)lnode; } - void scltMakeLogicNode(SNode **pNode, ELogicConditionType opType, SNode **nodeList, int32_t nodeNum) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); - SLogicConditionNode *onode = (SLogicConditionNode *)node; - onode->condType = opType; - onode->node.resType.type = TSDB_DATA_TYPE_BOOL; - onode->node.resType.bytes = sizeof(bool); + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode *onode = (SLogicConditionNode *)node; + onode->condType = opType; + onode->node.resType.type = TSDB_DATA_TYPE_BOOL; + onode->node.resType.bytes = sizeof(bool); - onode->pParameterList = nodesMakeList(); - for (int32_t i = 0; i < nodeNum; ++i) { - nodesListAppend(onode->pParameterList, nodeList[i]); - } + onode->pParameterList = nodesMakeList(); + for (int32_t i = 0; i < nodeNum; ++i) { + nodesListAppend(onode->pParameterList, nodeList[i]); + } - *pNode = (SNode *)onode; + *pNode = (SNode *)onode; } void scltMakeTargetNode(SNode **pNode, int16_t dataBlockId, int16_t slotId, SNode *snode) { - SNode *node = (SNode*)nodesMakeNode(QUERY_NODE_TARGET); - STargetNode *onode = (STargetNode *)node; - onode->pExpr = snode; - onode->dataBlockId = dataBlockId; - onode->slotId = slotId; + SNode *node = (SNode *)nodesMakeNode(QUERY_NODE_TARGET); + STargetNode *onode = (STargetNode *)node; + onode->pExpr = snode; + onode->dataBlockId = dataBlockId; + onode->slotId = slotId; - *pNode = (SNode *)onode; -} + *pNode = (SNode *)onode; } +} // namespace TEST(constantTest, bigint_add_bigint) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BIGINT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BIGINT, &scltRightV); - scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BIGINT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BIGINT, &scltRightV); + scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV)); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); + ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV)); + nodesDestroyNode(res); } TEST(constantTest, double_sub_bigint) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_DOUBLE, &scltLeftVd); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BIGINT, &scltRightV); - scltMakeOpNode(&opNode, OP_TYPE_SUB, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_DOUBLE, &scltLeftVd); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BIGINT, &scltRightV); + scltMakeOpNode(&opNode, OP_TYPE_SUB, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_FLOAT_EQ(v->datum.d, (scltLeftVd - scltRightV)); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_DOUBLE); + ASSERT_FLOAT_EQ(v->datum.d, (scltLeftVd - scltRightV)); + nodesDestroyNode(res); } TEST(constantTest, tinyint_and_smallint) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_TINYINT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &scltRightV); - scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_TINYINT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &scltRightV); + scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV); + nodesDestroyNode(res); } TEST(constantTest, bigint_or_double) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BIGINT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &scltRightVd); - scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BIGINT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &scltRightVd); + scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(v->datum.i, (int64_t)scltLeftV | (int64_t)scltRightVd); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(v->datum.i, (int64_t)scltLeftV | (int64_t)scltRightVd); + nodesDestroyNode(res); } TEST(constantTest, int_or_binary) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char binaryStr[64] = {0}; - sprintf(&binaryStr[2], "%d", scltRightV); - varDataSetLen(binaryStr, strlen(&binaryStr[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr); - scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(v->datum.b, scltLeftV | scltRightV); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char binaryStr[64] = {0}; + sprintf(&binaryStr[2], "%d", scltRightV); + varDataSetLen(binaryStr, strlen(&binaryStr[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr); + scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(v->datum.b, scltLeftV | scltRightV); + nodesDestroyNode(res); } TEST(constantTest, int_greater_double) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &scltRightVd); - scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &scltRightVd); + scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, scltLeftV > scltRightVd); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, scltLeftV > scltRightVd); + nodesDestroyNode(res); } TEST(constantTest, int_greater_equal_binary) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char binaryStr[64] = {0}; - sprintf(&binaryStr[2], "%d", scltRightV); - varDataSetLen(binaryStr, strlen(&binaryStr[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr); - scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, scltLeftV > scltRightVd); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char binaryStr[64] = {0}; + sprintf(&binaryStr[2], "%d", scltRightV); + varDataSetLen(binaryStr, strlen(&binaryStr[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr); + scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, scltLeftV > scltRightVd); + nodesDestroyNode(res); } TEST(constantTest, tinyint_lower_ubigint) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_TINYINT, &scltLeftV); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &scltRightV); - scltMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_TINYINT, &scltLeftV); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &scltRightV); + scltMakeOpNode(&opNode, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, scltLeftV < scltRightV); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, scltLeftV < scltRightV); + nodesDestroyNode(res); } TEST(constantTest, usmallint_lower_equal_ubigint) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1; - int64_t rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_USMALLINT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_LOWER_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, leftv <= rightv); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1; + int64_t rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_USMALLINT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_LOWER_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, leftv <= rightv); + nodesDestroyNode(res); } TEST(constantTest, int_equal_smallint1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1; - int16_t rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, leftv == rightv); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1; + int16_t rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, leftv == rightv); + nodesDestroyNode(res); } TEST(constantTest, int_equal_smallint2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 0, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, leftv == rightv); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 0, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, leftv == rightv); + nodesDestroyNode(res); } TEST(constantTest, int_not_equal_smallint1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_NOT_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, leftv != rightv); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_NOT_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, leftv != rightv); + nodesDestroyNode(res); } TEST(constantTest, int_not_equal_smallint2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 0, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_NOT_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, leftv != rightv); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 0, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_NOT_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, leftv != rightv); + nodesDestroyNode(res); } TEST(constantTest, int_in_smallint1) { - scltInitLogFile(); - - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; - int32_t leftv = 1, rightv1 = 1,rightv2 = 2,rightv3 = 3; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); - scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; + int32_t leftv = 1, rightv1 = 1, rightv2 = 2, rightv3 = 3; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); + scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, int_in_smallint2) { - scltInitLogFile(); - - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; - int32_t leftv = 4, rightv1 = 1,rightv2 = 2,rightv3 = 3; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); - scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; + int32_t leftv = 4, rightv1 = 1, rightv2 = 2, rightv3 = 3; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); + scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_not_in_smallint1) { - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; - int32_t leftv = 1, rightv1 = 1,rightv2 = 2,rightv3 = 3; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); - scltMakeOpNode(&opNode, OP_TYPE_NOT_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; + int32_t leftv = 1, rightv1 = 1, rightv2 = 2, rightv3 = 3; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); + scltMakeOpNode(&opNode, OP_TYPE_NOT_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_not_in_smallint2) { - scltInitLogFile(); - - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; - int32_t leftv = 4, rightv1 = 1,rightv2 = 2,rightv3 = 3; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); - scltMakeOpNode(&opNode, OP_TYPE_NOT_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *res = NULL, *opNode = NULL; + int32_t leftv = 4, rightv1 = 1, rightv2 = 2, rightv3 = 3; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv1); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv2); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_SMALLINT, &rightv3); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); + scltMakeOpNode(&opNode, OP_TYPE_NOT_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, binary_like_binary1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "a_c"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "a_c"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, binary_like_binary2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "ac"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "ac"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, binary_not_like_binary1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "a%c"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_NOT_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "a%c"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_NOT_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, binary_not_like_binary2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "ac"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_NOT_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "ac"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_NOT_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, binary_match_binary1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", ".*"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_MATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", ".*"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_MATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, binary_match_binary2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "abc.+"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_MATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "abc.+"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_MATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, binary_not_match_binary1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "a[1-9]c"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_NMATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "a[1-9]c"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_NMATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, binary_not_match_binary2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - char leftv[64] = {0}, rightv[64] = {0}; - sprintf(&leftv[2], "%s", "abc"); - varDataSetLen(leftv, strlen(&leftv[2])); - sprintf(&rightv[2], "%s", "a[ab]c"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_NMATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + char leftv[64] = {0}, rightv[64] = {0}; + sprintf(&leftv[2], "%s", "abc"); + varDataSetLen(leftv, strlen(&leftv[2])); + sprintf(&rightv[2], "%s", "a[ab]c"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_BINARY, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_NMATCH, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_is_null1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_is_null2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = TSDB_DATA_INT_NULL, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_NULL, &leftv); - scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = TSDB_DATA_INT_NULL, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_NULL, &leftv); + scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, int_is_not_null1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, int_is_not_null2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_NULL, &leftv); - scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_NULL, &leftv); + scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_add_int_is_true1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, int_add_int_is_true2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = -1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = -1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_greater_int_is_true1) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 1; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 1; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, int_greater_int_is_true2) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; - int32_t leftv = 1, rightv = 0; - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); - - int32_t code = scalarCalculateConstants(opNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL; + int32_t leftv = 1, rightv = 0; + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_INT, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, opNode, NULL); + + int32_t code = scalarCalculateConstants(opNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, greater_and_lower) { - scltInitLogFile(); - - SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; - bool eRes[5] = {false, false, true, true, true}; - int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; - SNode *list[2] = {0}; - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); - scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v4); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - - int32_t code = scalarCalculateConstants(logicNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; + bool eRes[5] = {false, false, true, true, true}; + int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; + SNode *list[2] = {0}; + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); + scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v4); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); + + int32_t code = scalarCalculateConstants(logicNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, column_and_value1) { - scltInitLogFile(); - - SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; - bool eRes[5] = {false, false, true, true, true}; - int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; - SNode *list[2] = {0}; - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); - scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); - scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - - int32_t code = scalarCalculateConstants(logicNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_LOGIC_CONDITION); - SLogicConditionNode *v = (SLogicConditionNode *)res; - ASSERT_EQ(v->condType, LOGIC_COND_TYPE_AND); - ASSERT_EQ(v->pParameterList->length, 1); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; + bool eRes[5] = {false, false, true, true, true}; + int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; + SNode *list[2] = {0}; + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); + scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); + scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); + + int32_t code = scalarCalculateConstants(logicNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode *v = (SLogicConditionNode *)res; + ASSERT_EQ(v->condType, LOGIC_COND_TYPE_AND); + ASSERT_EQ(v->pParameterList->length, 1); + nodesDestroyNode(res); } TEST(constantTest, column_and_value2) { - scltInitLogFile(); - - SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; - bool eRes[5] = {false, false, true, true, true}; - int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; - SNode *list[2] = {0}; - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); - scltMakeOpNode(&opNode1, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); - scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - - int32_t code = scalarCalculateConstants(logicNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, false); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; + bool eRes[5] = {false, false, true, true, true}; + int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; + SNode *list[2] = {0}; + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); + scltMakeOpNode(&opNode1, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); + scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); + + int32_t code = scalarCalculateConstants(logicNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, false); + nodesDestroyNode(res); } TEST(constantTest, column_and_value3) { - scltInitLogFile(); - - SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; - bool eRes[5] = {false, false, true, true, true}; - int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; - SNode *list[2] = {0}; - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); - scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); - scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_OR, list, 2); - - int32_t code = scalarCalculateConstants(logicNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); - SValueNode *v = (SValueNode *)res; - ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(v->datum.b, true); - nodesDestroyNode(res); + scltInitLogFile(); + + SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; + bool eRes[5] = {false, false, true, true, true}; + int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; + SNode *list[2] = {0}; + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); + scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); + scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_OR, list, 2); + + int32_t code = scalarCalculateConstants(logicNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE); + SValueNode *v = (SValueNode *)res; + ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(v->datum.b, true); + nodesDestroyNode(res); } TEST(constantTest, column_and_value4) { - scltInitLogFile(); - - SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; - bool eRes[5] = {false, false, true, true, true}; - int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; - SNode *list[2] = {0}; - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); - scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); - scltMakeOpNode(&opNode1, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); - scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_OR, list, 2); - - int32_t code = scalarCalculateConstants(logicNode, &res); - ASSERT_EQ(code, 0); - ASSERT_TRUE(res); - ASSERT_EQ(nodeType(res), QUERY_NODE_LOGIC_CONDITION); - SLogicConditionNode *v = (SLogicConditionNode *)res; - ASSERT_EQ(v->condType, LOGIC_COND_TYPE_OR); - ASSERT_EQ(v->pParameterList->length, 1); - nodesDestroyNode(res); -} - - -void makeJsonArrow(SSDataBlock **src, SNode **opNode, void *json, char *key){ - char keyVar[32] = {0}; - memcpy(varDataVal(keyVar), key, strlen(key)); - varDataLen(keyVar) = strlen(key); - - SNode *pLeft = NULL, *pRight = NULL; - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, keyVar); - scltMakeColumnNode(&pLeft, src, TSDB_DATA_TYPE_JSON, ((STag*)json)->len, 1, json); - scltMakeOpNode(opNode, OP_TYPE_JSON_GET_VALUE, TSDB_DATA_TYPE_JSON, pLeft, pRight); -} - -void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32_t rightType, void *rightData, bool isReverse){ - int32_t resType = TSDB_DATA_TYPE_NULL; - if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || - opType == OP_TYPE_DIV || opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){ - resType = TSDB_DATA_TYPE_DOUBLE; - }else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){ - resType = TSDB_DATA_TYPE_BIGINT; - }else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || - opType == OP_TYPE_LOWER_THAN || opType == OP_TYPE_LOWER_EQUAL || - opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || - opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE || - opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || - opType == OP_TYPE_NMATCH){ - resType = TSDB_DATA_TYPE_BOOL; - } - - SNode *right = NULL; - scltMakeValueNode(&right, rightType, rightData); - scltMakeOpNode2(opNode, opType, resType, *opNode, right, isReverse); - - SColumnInfo colInfo = createColumnInfo(1, resType, tDataTypes[resType].bytes); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, 1, &colInfo); - scltMakeTargetNode(opNode, dataBlockId, slotId, *opNode); -} - -void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, double exceptValue, EOperatorType opType, bool isReverse){ - SArray *blockList = taosArrayInit(2, POINTER_BYTES); - SSDataBlock *src = NULL; - SNode *opNode = NULL; - - makeJsonArrow(&src, &opNode, json, (char*)key); - taosArrayPush(blockList, &src); - - makeOperator(&opNode, blockList, opType, rightType, rightData, isReverse); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, 1); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - - if(colDataIsNull_f(column->nullbitmap, 0)){ - ASSERT_EQ(DBL_MAX, exceptValue); - printf("result:NULL\n"); - - }else if(opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV || - opType == OP_TYPE_REM || opType == OP_TYPE_MINUS){ - printf("op:%s,1result:%f,except:%f\n", operatorTypeStr(opType), *((double *)colDataGetData(column, 0)), exceptValue); - ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001); - }else if(opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR){ - printf("op:%s,2result:%" PRId64 ",except:%f\n", operatorTypeStr(opType), *((int64_t *)colDataGetData(column, 0)), exceptValue); - ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue); - }else if(opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN || - opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || - opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE || - opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || opType == OP_TYPE_NMATCH){ - printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue); - ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue); - } - - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + scltInitLogFile(); + + SNode *pval1 = NULL, *pval2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL, *res = NULL; + bool eRes[5] = {false, false, true, true, true}; + int64_t v1 = 333, v2 = 222, v3 = -10, v4 = 20; + SNode *list[2] = {0}; + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v1); + scltMakeValueNode(&pval2, TSDB_DATA_TYPE_BIGINT, &v2); + scltMakeOpNode(&opNode1, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + scltMakeValueNode(&pval1, TSDB_DATA_TYPE_BIGINT, &v3); + scltMakeColumnNode(&pval2, NULL, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), 0, NULL); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pval1, pval2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_OR, list, 2); + + int32_t code = scalarCalculateConstants(logicNode, &res); + ASSERT_EQ(code, 0); + ASSERT_TRUE(res); + ASSERT_EQ(nodeType(res), QUERY_NODE_LOGIC_CONDITION); + SLogicConditionNode *v = (SLogicConditionNode *)res; + ASSERT_EQ(v->condType, LOGIC_COND_TYPE_OR); + ASSERT_EQ(v->pParameterList->length, 1); + nodesDestroyNode(res); +} + +void makeJsonArrow(SSDataBlock **src, SNode **opNode, void *json, char *key) { + char keyVar[32] = {0}; + memcpy(varDataVal(keyVar), key, strlen(key)); + varDataLen(keyVar) = strlen(key); + + SNode *pLeft = NULL, *pRight = NULL; + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, keyVar); + scltMakeColumnNode(&pLeft, src, TSDB_DATA_TYPE_JSON, ((STag *)json)->len, 1, json); + scltMakeOpNode(opNode, OP_TYPE_JSON_GET_VALUE, TSDB_DATA_TYPE_JSON, pLeft, pRight); +} + +void makeOperator(SNode **opNode, SArray *blockList, EOperatorType opType, int32_t rightType, void *rightData, + bool isReverse) { + int32_t resType = TSDB_DATA_TYPE_NULL; + if (opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV || + opType == OP_TYPE_REM || opType == OP_TYPE_MINUS) { + resType = TSDB_DATA_TYPE_DOUBLE; + } else if (opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR) { + resType = TSDB_DATA_TYPE_BIGINT; + } else if (opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN || + opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || + opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE || + opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || + opType == OP_TYPE_NMATCH) { + resType = TSDB_DATA_TYPE_BOOL; + } + + SNode *right = NULL; + scltMakeValueNode(&right, rightType, rightData); + scltMakeOpNode2(opNode, opType, resType, *opNode, right, isReverse); + + SColumnInfo colInfo = createColumnInfo(1, resType, tDataTypes[resType].bytes); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, 1, &colInfo); + scltMakeTargetNode(opNode, dataBlockId, slotId, *opNode); +} + +void makeCalculate(void *json, void *key, int32_t rightType, void *rightData, double exceptValue, EOperatorType opType, + bool isReverse) { + SArray *blockList = taosArrayInit(2, POINTER_BYTES); + SSDataBlock *src = NULL; + SNode *opNode = NULL; + + makeJsonArrow(&src, &opNode, json, (char *)key); + taosArrayPush(blockList, &src); + + makeOperator(&opNode, blockList, opType, rightType, rightData, isReverse); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, 1); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + + if (colDataIsNull_f(column->nullbitmap, 0)) { + ASSERT_EQ(DBL_MAX, exceptValue); + printf("result:NULL\n"); + + } else if (opType == OP_TYPE_ADD || opType == OP_TYPE_SUB || opType == OP_TYPE_MULTI || opType == OP_TYPE_DIV || + opType == OP_TYPE_REM || opType == OP_TYPE_MINUS) { + printf("op:%s,1result:%f,except:%f\n", operatorTypeStr(opType), *((double *)colDataGetData(column, 0)), + exceptValue); + ASSERT_TRUE(fabs(*((double *)colDataGetData(column, 0)) - exceptValue) < 0.0001); + } else if (opType == OP_TYPE_BIT_AND || opType == OP_TYPE_BIT_OR) { + printf("op:%s,2result:%" PRId64 ",except:%f\n", operatorTypeStr(opType), *((int64_t *)colDataGetData(column, 0)), + exceptValue); + ASSERT_EQ(*((int64_t *)colDataGetData(column, 0)), exceptValue); + } else if (opType == OP_TYPE_GREATER_THAN || opType == OP_TYPE_GREATER_EQUAL || opType == OP_TYPE_LOWER_THAN || + opType == OP_TYPE_LOWER_EQUAL || opType == OP_TYPE_EQUAL || opType == OP_TYPE_NOT_EQUAL || + opType == OP_TYPE_IS_NULL || opType == OP_TYPE_IS_NOT_NULL || opType == OP_TYPE_IS_TRUE || + opType == OP_TYPE_LIKE || opType == OP_TYPE_NOT_LIKE || opType == OP_TYPE_MATCH || + opType == OP_TYPE_NMATCH) { + printf("op:%s,3result:%d,except:%f\n", operatorTypeStr(opType), *((bool *)colDataGetData(column, 0)), exceptValue); + ASSERT_EQ(*((bool *)colDataGetData(column, 0)), exceptValue); + } + + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, json_column_arith_op) { - scltInitLogFile(); - char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":\"8hel\"}"; - - char rightv[256] = {0}; - memcpy(rightv, rightvTmp, strlen(rightvTmp)); - SArray *tags = taosArrayInit(1, sizeof(STagVal)); - STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL); - - const int32_t len = 8; - EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, - OP_TYPE_REM, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR}; - int32_t input[len] = {1, 8, 2, 2, 3, 0, -4, 9}; - - printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); - char *key = "k1"; - double eRes00[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4&-4, 4|9}; - double eRes01[len] = {5.0, 4, 8.0, 0.5, 3, 0, 4&-4, 4|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes00[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes01[i], op[i], true); - } - - printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); - - key = "k2"; - double eRes10[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; - double eRes11[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes10[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes11[i], op[i], true); - } - - printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); - - key = "k3"; - double eRes20[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; - double eRes21[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes20[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes21[i], op[i], true); - } - - printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); - - key = "k4"; - double eRes30[len] = {2.0, -7, 2, 0.5, 1, -1, 1&-4, 1|9}; - double eRes31[len] = {2.0, 7, 2, 2, 0, 0, 1&-4, 1|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes30[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes31[i], op[i], true); - } - - printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k5"; - double eRes40[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5&-4, 5|9}; - double eRes41[len] = {6.44, 2.56, 10.88, 0.3676470588235294, 3, 0, 5&-4, 5|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes40[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes41[i], op[i], true); - } - - printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k6"; - double eRes50[len] = {-9, -18, -20, -5, -10%3, 10, -10&-4, -10|9}; - double eRes51[len] = {-9, 18, -20, -0.2, 3%-10, 0, -10&-4, -10|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes50[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes51[i], op[i], true); - } - - printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k7"; - double eRes60[len] = {-8.8, -17.8, -19.6, -4.9, -0.8, 9.8, -9&-4, -9|9}; - double eRes61[len] = {-8.8, 17.8, -19.6, -0.2040816326530612, 3, 0, -9&-4, -9|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes60[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes61[i], op[i], true); - } - - printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k8"; - double eRes70[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; - double eRes71[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes70[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes71[i], op[i], true); - } - - printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k9"; - double eRes80[len] = {9, 0, 16, 4, 8%3, -8, 8&-4, 8|9}; - double eRes81[len] = {9, 0, 16, 0.25, 3%8, 0, 8&-4, 8|9}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes80[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes81[i], op[i], true); - } - - printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); - - key = "k10"; - double eRes90[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; - double eRes91[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes90[i], op[i], false); - } - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes91[i], op[i], true); - } - - taosArrayDestroy(tags); - taosMemoryFree(row); -} - -void *prepareNchar(char* rightData){ - int32_t len = 0; - int32_t inputLen = strlen(rightData); - - char* t = (char*)taosMemoryCalloc(1,(inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); - taosMbsToUcs4(rightData, inputLen, (TdUcs4*) varDataVal(t), inputLen * TSDB_NCHAR_SIZE, &len); - varDataSetLen(t, len); - return t; + scltInitLogFile(); + char *rightvTmp = + "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":" + "\"8hel\"}"; + + char rightv[256] = {0}; + memcpy(rightv, rightvTmp, strlen(rightvTmp)); + SArray *tags = taosArrayInit(1, sizeof(STagVal)); + STag *row = NULL; + parseJsontoTagData(rightv, tags, &row, NULL); + + const int32_t len = 8; + EOperatorType op[len] = {OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, + OP_TYPE_REM, OP_TYPE_MINUS, OP_TYPE_BIT_AND, OP_TYPE_BIT_OR}; + int32_t input[len] = {1, 8, 2, 2, 3, 0, -4, 9}; + + printf("--------------------json int-4 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); + char *key = "k1"; + double eRes00[len] = {5.0, -4, 8.0, 2.0, 1.0, -4, 4 & -4, 4 | 9}; + double eRes01[len] = {5.0, 4, 8.0, 0.5, 3, 0, 4 & -4, 4 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes00[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes01[i], op[i], true); + } + + printf("--------------------json string- 0 op {1, 8, 2, 2, 3, 0, -4, 9}--------------------\n"); + + key = "k2"; + double eRes10[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; + double eRes11[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes10[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes11[i], op[i], true); + } + + printf("---------------------json null- null op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); + + key = "k3"; + double eRes20[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; + double eRes21[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes20[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes21[i], op[i], true); + } + + printf("---------------------json bool- true op {1, 8, 2, 2, 3, 0, -4, 9}-------------------\n"); + + key = "k4"; + double eRes30[len] = {2.0, -7, 2, 0.5, 1, -1, 1 & -4, 1 | 9}; + double eRes31[len] = {2.0, 7, 2, 2, 0, 0, 1 & -4, 1 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes30[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes31[i], op[i], true); + } + + printf("----------------------json double-- 5.44 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k5"; + double eRes40[len] = {6.44, -2.56, 10.88, 2.72, 2.44, -5.44, 5 & -4, 5 | 9}; + double eRes41[len] = {6.44, 2.56, 10.88, 0.3676470588235294, 3, 0, 5 & -4, 5 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes40[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes41[i], op[i], true); + } + + printf("----------------------json int-- -10 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k6"; + double eRes50[len] = {-9, -18, -20, -5, -10 % 3, 10, -10 & -4, -10 | 9}; + double eRes51[len] = {-9, 18, -20, -0.2, 3 % -10, 0, -10 & -4, -10 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes50[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes51[i], op[i], true); + } + + printf("----------------------json double-- -9.8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k7"; + double eRes60[len] = {-8.8, -17.8, -19.6, -4.9, -0.8, 9.8, -9 & -4, -9 | 9}; + double eRes61[len] = {-8.8, 17.8, -19.6, -0.2040816326530612, 3, 0, -9 & -4, -9 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes60[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes61[i], op[i], true); + } + + printf("----------------------json bool-- 0 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k8"; + double eRes70[len] = {1.0, -8, 0, 0, 0, 0, 0, 9}; + double eRes71[len] = {1.0, 8, 0, DBL_MAX, DBL_MAX, 0, 0, 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes70[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes71[i], op[i], true); + } + + printf("----------------------json string-- 8 op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k9"; + double eRes80[len] = {9, 0, 16, 4, 8 % 3, -8, 8 & -4, 8 | 9}; + double eRes81[len] = {9, 0, 16, 0.25, 3 % 8, 0, 8 & -4, 8 | 9}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes80[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes81[i], op[i], true); + } + + printf("---------------------json not exist-- NULL op {1, 8, 2, 2, 3, 0, -4, 9}------------------\n"); + + key = "k10"; + double eRes90[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX}; + double eRes91[len] = {DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, DBL_MAX, 0, DBL_MAX, DBL_MAX}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes90[i], op[i], false); + } + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes91[i], op[i], true); + } + + taosArrayDestroy(tags); + taosMemoryFree(row); +} + +void *prepareNchar(char *rightData) { + int32_t len = 0; + int32_t inputLen = strlen(rightData); + + char *t = (char *)taosMemoryCalloc(1, (inputLen + 1) * TSDB_NCHAR_SIZE + VARSTR_HEADER_SIZE); + taosMbsToUcs4(rightData, inputLen, (TdUcs4 *)varDataVal(t), inputLen * TSDB_NCHAR_SIZE, &len); + varDataSetLen(t, len); + return t; } TEST(columnTest, json_column_logic_op) { - scltInitLogFile(); - char *rightvTmp= "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":\"6.6hello\"}"; - - char rightv[256] = {0}; - memcpy(rightv, rightvTmp, strlen(rightvTmp)); - SArray *tags = taosArrayInit(1, sizeof(STagVal)); - STag* row = NULL; - parseJsontoTagData(rightv, tags, &row, NULL); - - const int32_t len0 = 6; - const int32_t len = 9; - const int32_t len1 = 4; - EOperatorType op[len+len1] = {OP_TYPE_GREATER_THAN, OP_TYPE_GREATER_EQUAL, OP_TYPE_LOWER_THAN, OP_TYPE_LOWER_EQUAL, OP_TYPE_EQUAL, OP_TYPE_NOT_EQUAL, - OP_TYPE_IS_NULL, OP_TYPE_IS_NOT_NULL, OP_TYPE_IS_TRUE, OP_TYPE_LIKE, OP_TYPE_NOT_LIKE, OP_TYPE_MATCH, OP_TYPE_NMATCH}; - - int32_t input[len] = {1, 8, 2, 2, 3, 0, 0, 0, 0}; - char *inputNchar[len1] = {"hell_", "hel%", "hell", "llll"}; - - printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); - char *key = "k1"; - bool eRes[len+len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes[i], op[i], false); - } - bool eRes_0[len0] = {false, true, true, true, false, true}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_0[i], op[i], true); - } - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k2"; - bool eRes1[len+len1] = {false, false, false, false, false, false, false, true, false, true, false, true, true}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes1[i], op[i], false); - } - bool eRes_1[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_1[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes1[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); - - key = "k3"; // (null is true) return NULL, so use DBL_MAX represent NULL - bool eRes2[len+len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes2[i], op[i], false); - } - bool eRes_2[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_2[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes2[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k4"; - bool eRes3[len+len1] = {false, false, false, false, false, false, false, true, true, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes3[i], op[i], false); - } - bool eRes_3[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_3[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes3[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k5"; - bool eRes4[len+len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes4[i], op[i], false); - } - bool eRes_4[len0] = {false, true, true, true, false, true}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_4[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes4[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k6"; - bool eRes5[len+len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes5[i], op[i], false); - } - bool eRes_5[len0] = {true, true, false, false, false, true}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_5[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes5[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k7"; - bool eRes6[len+len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes6[i], op[i], false); - } - bool eRes_6[len0] = {true, true, false, false, false, true}; - for(int i = 0; i < len0; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_6[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes6[i], op[i], false); - taosMemoryFree(rightData); - } - - - printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k8"; - bool eRes7[len+len1] = {false, false, false, false, false, false, false, true, false, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes7[i], op[i], false); - } - bool eRes_7[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++) { - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_7[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes7[i], op[i], false); - taosMemoryFree(rightData); - } - - - printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); - - key = "k9"; - bool eRes8[len+len1] = {false, false, false, false, false, false, false, true, true, false, true, false, true}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false); - } - bool eRes_8[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++) { - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_8[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false); - taosMemoryFree(rightData); - } - - printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); - - key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL - bool eRes9[len+len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; - for(int i = 0; i < len; i++){ - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes9[i], op[i], false); - } - bool eRes_9[len0] = {false, false, false, false, false, false}; - for(int i = 0; i < len0; i++) { - makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_9[i], op[i], true); - } - - for(int i = len; i < len + len1; i++){ - void* rightData = prepareNchar(inputNchar[i-len]); - makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes9[i], op[i], false); - taosMemoryFree(rightData); - } - - taosArrayDestroy(tags); - taosMemoryFree(row); + scltInitLogFile(); + char *rightvTmp = + "{\"k1\":4,\"k2\":\"hello\",\"k3\":null,\"k4\":true,\"k5\":5.44,\"k6\":-10,\"k7\":-9.8,\"k8\":false,\"k9\":\"6." + "6hello\"}"; + + char rightv[256] = {0}; + memcpy(rightv, rightvTmp, strlen(rightvTmp)); + SArray *tags = taosArrayInit(1, sizeof(STagVal)); + STag *row = NULL; + parseJsontoTagData(rightv, tags, &row, NULL); + + const int32_t len0 = 6; + const int32_t len = 9; + const int32_t len1 = 4; + EOperatorType op[len + len1] = {OP_TYPE_GREATER_THAN, OP_TYPE_GREATER_EQUAL, OP_TYPE_LOWER_THAN, OP_TYPE_LOWER_EQUAL, + OP_TYPE_EQUAL, OP_TYPE_NOT_EQUAL, OP_TYPE_IS_NULL, OP_TYPE_IS_NOT_NULL, + OP_TYPE_IS_TRUE, OP_TYPE_LIKE, OP_TYPE_NOT_LIKE, OP_TYPE_MATCH, + OP_TYPE_NMATCH}; + + int32_t input[len] = {1, 8, 2, 2, 3, 0, 0, 0, 0}; + char *inputNchar[len1] = {"hell_", "hel%", "hell", "llll"}; + + printf("--------------------json int---4 {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + char *key = "k1"; + bool eRes[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes[i], op[i], false); + } + bool eRes_0[len0] = {false, true, true, true, false, true}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_0[i], op[i], true); + } + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json string--0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k2"; + bool eRes1[len + len1] = {false, false, false, false, false, false, false, true, false, true, false, true, true}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes1[i], op[i], false); + } + bool eRes_1[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_1[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes1[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json null---null {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + + key = "k3"; // (null is true) return NULL, so use DBL_MAX represent NULL + bool eRes2[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes2[i], op[i], false); + } + bool eRes_2[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_2[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes2[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json bool--1 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k4"; + bool eRes3[len + len1] = {false, false, false, false, false, false, false, true, true, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes3[i], op[i], false); + } + bool eRes_3[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_3[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes3[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json double--5.44 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k5"; + bool eRes4[len + len1] = {true, false, false, false, false, true, false, true, true, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes4[i], op[i], false); + } + bool eRes_4[len0] = {false, true, true, true, false, true}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_4[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes4[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json int-- -10 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k6"; + bool eRes5[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes5[i], op[i], false); + } + bool eRes_5[len0] = {true, true, false, false, false, true}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_5[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes5[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json double-- -9.8 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k7"; + bool eRes6[len + len1] = {false, false, true, true, false, true, false, true, true, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes6[i], op[i], false); + } + bool eRes_6[len0] = {true, true, false, false, false, true}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_6[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes6[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json bool-- 0 {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k8"; + bool eRes7[len + len1] = {false, false, false, false, false, false, false, true, false, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes7[i], op[i], false); + } + bool eRes_7[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_7[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes7[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("--------------------json string-- 6.6hello {1, 8, 2, 2, 3, 0, 0, 0, 0}-------------------\n"); + + key = "k9"; + bool eRes8[len + len1] = {false, false, false, false, false, false, false, true, true, false, true, false, true}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes8[i], op[i], false); + } + bool eRes_8[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_8[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes8[i], op[i], false); + taosMemoryFree(rightData); + } + + printf("---------------------json not exist-- NULL {1, 8, 2, 2, 3, 0, 0, 0, 0}------------------\n"); + + key = "k10"; // (NULL is true) return NULL, so use DBL_MAX represent NULL + bool eRes9[len + len1] = {false, false, false, false, false, false, true, false, false, false, false, false, false}; + for (int i = 0; i < len; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes9[i], op[i], false); + } + bool eRes_9[len0] = {false, false, false, false, false, false}; + for (int i = 0; i < len0; i++) { + makeCalculate(row, key, TSDB_DATA_TYPE_INT, &input[i], eRes_9[i], op[i], true); + } + + for (int i = len; i < len + len1; i++) { + void *rightData = prepareNchar(inputNchar[i - len]); + makeCalculate(row, key, TSDB_DATA_TYPE_NCHAR, rightData, eRes9[i], op[i], false); + taosMemoryFree(rightData); + } + + taosArrayDestroy(tags); + taosMemoryFree(row); } TEST(columnTest, smallint_value_add_int_column) { - scltInitLogFile(); - - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int32_t leftv = 1; - int16_t rightv[5]= {0, -5, -4, 23, 100}; - double eRes[5] = {1.0, -4, -3, 24, 101}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); - scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); - scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, rightv); - scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - - SArray *blockList = taosArrayInit(2, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(column, i)), eRes[i]); - } - - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + scltInitLogFile(); + + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int32_t leftv = 1; + int16_t rightv[5] = {0, -5, -4, 23, 100}; + double eRes[5] = {1.0, -4, -3, 24, 101}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); + scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_INT, &leftv); + scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, rightv); + scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + + SArray *blockList = taosArrayInit(2, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_DOUBLE); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(column, i)), eRes[i]); + } + + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, bigint_column_multi_binary_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int64_t leftv[5]= {1, 2, 3, 4, 5}; - char rightv[5][5]= {0}; - for (int32_t i = 0; i < 5; ++i) { - rightv[i][2] = rightv[i][3] = '0'; - rightv[i][4] = '0' + i; - varDataSetLen(rightv[i], 3); - } - double eRes[5] = {0, 2, 6, 12, 20}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, leftv); - scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); - scltMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_DOUBLE); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int64_t leftv[5] = {1, 2, 3, 4, 5}; + char rightv[5][5] = {0}; + for (int32_t i = 0; i < 5; ++i) { + rightv[i][2] = rightv[i][3] = '0'; + rightv[i][4] = '0' + i; + varDataSetLen(rightv[i], 3); + } + double eRes[5] = {0, 2, 6, 12, 20}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, leftv); + scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); + scltMakeOpNode(&opNode, OP_TYPE_MULTI, TSDB_DATA_TYPE_DOUBLE, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_DOUBLE, sizeof(double)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_DOUBLE); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, smallint_column_and_binary_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - char rightv[5][5]= {0}; - for (int32_t i = 0; i < 5; ++i) { - rightv[i][2] = rightv[i][3] = '0'; - rightv[i][4] = '0' + i; - varDataSetLen(rightv[i], 3); - } - int64_t eRes[5] = {0, 0, 2, 0, 4}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); - scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); - scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + char rightv[5][5] = {0}; + for (int32_t i = 0; i < 5; ++i) { + rightv[i][2] = rightv[i][3] = '0'; + rightv[i][4] = '0' + i; + varDataSetLen(rightv[i], 3); + } + int64_t eRes[5] = {0, 0, 2, 0, 4}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); + scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, rightv); + scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, smallint_column_or_float_column) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - float rightv[5]= {2.0, 3.0, 4.1, 5.2, 6.0}; - int64_t eRes[5] = {3, 3, 7, 5, 7}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(rightv)/sizeof(rightv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); - scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_FLOAT, sizeof(float), rowNum, rightv); - scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + float rightv[5] = {2.0, 3.0, 4.1, 5.2, 6.0}; + int64_t eRes[5] = {3, 3, 7, 5, 7}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(rightv) / sizeof(rightv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); + scltMakeColumnNode(&pRight, &src, TSDB_DATA_TYPE_FLOAT, sizeof(float), rowNum, rightv); + scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, smallint_column_or_double_value) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - double rightv= 10.2; - int64_t eRes[5] = {11, 10, 11, 14, 15}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + double rightv = 10.2; + int64_t eRes[5] = {11, 10, 11, 14, 15}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_BIT_OR, TSDB_DATA_TYPE_BIGINT, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BIGINT); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int64_t *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, smallint_column_greater_double_value) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - int16_t leftv[5]= {1, 2, 3, 4, 5}; - double rightv= 2.5; - bool eRes[5] = {false, false, true, true, true}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); - scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + int16_t leftv[5] = {1, 2, 3, 4, 5}; + double rightv = 2.5; + bool eRes[5] = {false, false, true, true, true}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, leftv); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv); + scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, int_column_in_double_list) { - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; - int32_t leftv[5] = {1, 2, 3, 4, 5}; - double rightv1 = 1.1,rightv2 = 2.2,rightv3 = 3.3; - bool eRes[5] = {true, true, true, false, false}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv1); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv2); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv3); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_INT); - scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; + int32_t leftv[5] = {1, 2, 3, 4, 5}; + double rightv1 = 1.1, rightv2 = 2.2, rightv3 = 3.3; + bool eRes[5] = {true, true, true, false, false}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv1); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv2); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_DOUBLE, &rightv3); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_INT); + scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, true, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, binary_column_in_binary_list) { - SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; - bool eRes[5] = {true, true, false, false, false}; - SSDataBlock *src = NULL; - char leftv[5][5]= {0}; - char rightv[3][5]= {0}; - for (int32_t i = 0; i < 5; ++i) { - leftv[i][2] = 'a' + i; - leftv[i][3] = 'b' + i; - leftv[i][4] = '0' + i; - varDataSetLen(leftv[i], 3); - } - for (int32_t i = 0; i < 2; ++i) { - rightv[i][2] = 'a' + i; - rightv[i][3] = 'b' + i; - rightv[i][4] = '0' + i; - varDataSetLen(rightv[i], 3); - } - for (int32_t i = 2; i < 3; ++i) { - rightv[i][2] = 'a' + i; - rightv[i][3] = 'a' + i; - rightv[i][4] = 'a' + i; - varDataSetLen(rightv[i], 3); - } - - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); - SNodeList* list = nodesMakeList(); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[0]); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[1]); - nodesListAppend(list, pRight); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[2]); - nodesListAppend(list, pRight); - scltMakeListNode(&listNode,list, TSDB_DATA_TYPE_BINARY); - scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *listNode = NULL, *opNode = NULL; + bool eRes[5] = {true, true, false, false, false}; + SSDataBlock *src = NULL; + char leftv[5][5] = {0}; + char rightv[3][5] = {0}; + for (int32_t i = 0; i < 5; ++i) { + leftv[i][2] = 'a' + i; + leftv[i][3] = 'b' + i; + leftv[i][4] = '0' + i; + varDataSetLen(leftv[i], 3); + } + for (int32_t i = 0; i < 2; ++i) { + rightv[i][2] = 'a' + i; + rightv[i][3] = 'b' + i; + rightv[i][4] = '0' + i; + varDataSetLen(rightv[i], 3); + } + for (int32_t i = 2; i < 3; ++i) { + rightv[i][2] = 'a' + i; + rightv[i][3] = 'a' + i; + rightv[i][4] = 'a' + i; + varDataSetLen(rightv[i], 3); + } + + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); + SNodeList *list = nodesMakeList(); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[0]); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[1]); + nodesListAppend(list, pRight); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv[2]); + nodesListAppend(list, pRight); + scltMakeListNode(&listNode, list, TSDB_DATA_TYPE_BINARY); + scltMakeOpNode(&opNode, OP_TYPE_IN, TSDB_DATA_TYPE_BOOL, pLeft, listNode); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, binary_column_like_binary) { - SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; - char rightv[64] = {0}; - char leftv[5][5]= {0}; - SSDataBlock *src = NULL; - bool eRes[5] = {true, false, true, false, true}; - - for (int32_t i = 0; i < 5; ++i) { - leftv[i][2] = 'a'; - leftv[i][3] = 'a'; - leftv[i][4] = '0' + i % 2; - varDataSetLen(leftv[i], 3); - } - - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); - - sprintf(&rightv[2], "%s", "__0"); - varDataSetLen(rightv, strlen(&rightv[2])); - scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); - scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL; + char rightv[64] = {0}; + char leftv[5][5] = {0}; + SSDataBlock *src = NULL; + bool eRes[5] = {true, false, true, false, true}; + + for (int32_t i = 0; i < 5; ++i) { + leftv[i][2] = 'a'; + leftv[i][3] = 'a'; + leftv[i][4] = '0' + i % 2; + varDataSetLen(leftv[i], 3); + } + + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); + + sprintf(&rightv[2], "%s", "__0"); + varDataSetLen(rightv, strlen(&rightv[2])); + scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, rightv); + scltMakeOpNode(&opNode, OP_TYPE_LIKE, TSDB_DATA_TYPE_BOOL, pLeft, pRight); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, binary_column_is_true) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; - SSDataBlock *src = NULL; - bool eRes[5] = {false, true, false, true, false}; - - for (int32_t i = 0; i < 5; ++i) { - leftv[i][2] = '0' + i % 2; - leftv[i][3] = 'a'; - leftv[i][4] = '0' + i % 2; - varDataSetLen(leftv[i], 3); - } - - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, leftv); - - scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; + SSDataBlock *src = NULL; + bool eRes[5] = {false, true, false, true, false}; + + for (int32_t i = 0; i < 5; ++i) { + leftv[i][2] = '0' + i % 2; + leftv[i][3] = 'a'; + leftv[i][4] = '0' + i % 2; + varDataSetLen(leftv[i], 3); + } + + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 5, rowNum, leftv); + + scltMakeOpNode(&opNode, OP_TYPE_IS_TRUE, TSDB_DATA_TYPE_BOOL, pLeft, NULL); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, binary_column_is_null) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; - SSDataBlock *src = NULL; - bool eRes[5] = {false, false, true, false, true}; - - for (int32_t i = 0; i < 5; ++i) { - leftv[i][2] = '0' + i % 2; - leftv[i][3] = 'a'; - leftv[i][4] = '0' + i % 2; - varDataSetLen(leftv[i], 3); - } - - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); - - SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); - colDataAppend(pcolumn, 2, NULL, true); - colDataAppend(pcolumn, 4, NULL, true); - - scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; + SSDataBlock *src = NULL; + bool eRes[5] = {false, false, true, false, true}; + + for (int32_t i = 0; i < 5; ++i) { + leftv[i][2] = '0' + i % 2; + leftv[i][3] = 'a'; + leftv[i][4] = '0' + i % 2; + varDataSetLen(leftv[i], 3); + } + + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); + + SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); + colDataAppend(pcolumn, 2, NULL, true); + colDataAppend(pcolumn, 4, NULL, true); + + scltMakeOpNode(&opNode, OP_TYPE_IS_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, binary_column_is_not_null) { - SNode *pLeft = NULL, *opNode = NULL; - char leftv[5][5]= {0}; - SSDataBlock *src = NULL; - bool eRes[5] = {true, true, true, true, false}; - - for (int32_t i = 0; i < 5; ++i) { - leftv[i][2] = '0' + i % 2; - leftv[i][3] = 'a'; - leftv[i][4] = '0' + i % 2; - varDataSetLen(leftv[i], 3); - } - - int32_t rowNum = sizeof(leftv)/sizeof(leftv[0]); - scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); - - SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); - colDataAppend(pcolumn, 4, NULL, true); - - scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); - - int32_t code = scalarCalculate(opNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(opNode); + SNode *pLeft = NULL, *opNode = NULL; + char leftv[5][5] = {0}; + SSDataBlock *src = NULL; + bool eRes[5] = {true, true, true, true, false}; + + for (int32_t i = 0; i < 5; ++i) { + leftv[i][2] = '0' + i % 2; + leftv[i][3] = 'a'; + leftv[i][4] = '0' + i % 2; + varDataSetLen(leftv[i], 3); + } + + int32_t rowNum = sizeof(leftv) / sizeof(leftv[0]); + scltMakeColumnNode(&pLeft, &src, TSDB_DATA_TYPE_BINARY, 3, rowNum, leftv); + + SColumnInfoData *pcolumn = (SColumnInfoData *)taosArrayGetLast(src->pDataBlock); + colDataAppend(pcolumn, 4, NULL, true); + + scltMakeOpNode(&opNode, OP_TYPE_IS_NOT_NULL, TSDB_DATA_TYPE_BOOL, pLeft, NULL); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&opNode, dataBlockId, slotId, opNode); + + int32_t code = scalarCalculate(opNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(opNode); } TEST(columnTest, greater_and_lower) { - SNode *pcol1 = NULL, *pcol2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; - SNode *list[2] = {0}; - int16_t v1[5]= {1, 2, 3, 4, 5}; - int32_t v2[5]= {5, 1, 4, 2, 6}; - int64_t v3[5]= {1, 2, 3, 4, 5}; - int32_t v4[5]= {5, 3, 4, 2, 6}; - bool eRes[5] = {false, true, false, false, false}; - SSDataBlock *src = NULL; - int32_t rowNum = sizeof(v1)/sizeof(v1[0]); - scltMakeColumnNode(&pcol1, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, v1); - scltMakeColumnNode(&pcol2, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, v2); - scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol1, pcol2); - scltMakeColumnNode(&pcol1, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, v3); - scltMakeColumnNode(&pcol2, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, v4); - scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pcol1, pcol2); - list[0] = opNode1; - list[1] = opNode2; - scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); - - SArray *blockList = taosArrayInit(1, POINTER_BYTES); - taosArrayPush(blockList, &src); - SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); - int16_t dataBlockId = 0, slotId = 0; - scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); - scltMakeTargetNode(&logicNode, dataBlockId, slotId, logicNode); - - int32_t code = scalarCalculate(logicNode, blockList, NULL); - ASSERT_EQ(code, 0); - - SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); - ASSERT_EQ(res->info.rows, rowNum); - SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); - ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); - ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); - } - taosArrayDestroyEx(blockList, scltFreeDataBlock); - nodesDestroyNode(logicNode); + SNode *pcol1 = NULL, *pcol2 = NULL, *opNode1 = NULL, *opNode2 = NULL, *logicNode = NULL; + SNode *list[2] = {0}; + int16_t v1[5] = {1, 2, 3, 4, 5}; + int32_t v2[5] = {5, 1, 4, 2, 6}; + int64_t v3[5] = {1, 2, 3, 4, 5}; + int32_t v4[5] = {5, 3, 4, 2, 6}; + bool eRes[5] = {false, true, false, false, false}; + SSDataBlock *src = NULL; + int32_t rowNum = sizeof(v1) / sizeof(v1[0]); + scltMakeColumnNode(&pcol1, &src, TSDB_DATA_TYPE_SMALLINT, sizeof(int16_t), rowNum, v1); + scltMakeColumnNode(&pcol2, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, v2); + scltMakeOpNode(&opNode1, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pcol1, pcol2); + scltMakeColumnNode(&pcol1, &src, TSDB_DATA_TYPE_BIGINT, sizeof(int64_t), rowNum, v3); + scltMakeColumnNode(&pcol2, &src, TSDB_DATA_TYPE_INT, sizeof(int32_t), rowNum, v4); + scltMakeOpNode(&opNode2, OP_TYPE_LOWER_THAN, TSDB_DATA_TYPE_BOOL, pcol1, pcol2); + list[0] = opNode1; + list[1] = opNode2; + scltMakeLogicNode(&logicNode, LOGIC_COND_TYPE_AND, list, 2); + + SArray *blockList = taosArrayInit(1, POINTER_BYTES); + taosArrayPush(blockList, &src); + SColumnInfo colInfo = createColumnInfo(1, TSDB_DATA_TYPE_BOOL, sizeof(bool)); + int16_t dataBlockId = 0, slotId = 0; + scltAppendReservedSlot(blockList, &dataBlockId, &slotId, false, rowNum, &colInfo); + scltMakeTargetNode(&logicNode, dataBlockId, slotId, logicNode); + + int32_t code = scalarCalculate(logicNode, blockList, NULL); + ASSERT_EQ(code, 0); + + SSDataBlock *res = *(SSDataBlock **)taosArrayGetLast(blockList); + ASSERT_EQ(res->info.rows, rowNum); + SColumnInfoData *column = (SColumnInfoData *)taosArrayGetLast(res->pDataBlock); + ASSERT_EQ(column->info.type, TSDB_DATA_TYPE_BOOL); + ASSERT_EQ(column->info.bytes, tDataTypes[TSDB_DATA_TYPE_BOOL].bytes); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((bool *)colDataGetData(column, i)), eRes[i]); + } + taosArrayDestroyEx(blockList, scltFreeDataBlock); + nodesDestroyNode(logicNode); } void scltMakeDataBlock(SScalarParam **pInput, int32_t type, void *pVal, int32_t num, bool setVal) { - SScalarParam *input = (SScalarParam *)taosMemoryCalloc(1, sizeof(SScalarParam)); - int32_t bytes; - switch (type) { - case TSDB_DATA_TYPE_TINYINT: { - bytes = sizeof(int8_t); - break; - } - case TSDB_DATA_TYPE_SMALLINT: { - bytes = sizeof(int16_t); - break; - } - case TSDB_DATA_TYPE_INT: { - bytes = sizeof(int32_t); - break; - } - case TSDB_DATA_TYPE_BIGINT: { - bytes = sizeof(int64_t); - break; - } - case TSDB_DATA_TYPE_FLOAT: { - bytes = sizeof(float); - break; - } - case TSDB_DATA_TYPE_DOUBLE: { - bytes = sizeof(double); - break; - } - } - - input->columnData = (SColumnInfoData*) taosMemoryCalloc(1, sizeof(SColumnInfoData)); - input->numOfRows = num; - - input->columnData->info = createColumnInfo(0, type, bytes); - colInfoDataEnsureCapacity(input->columnData, num); - - if (setVal) { - for (int32_t i = 0; i < num; ++i) { - colDataAppend(input->columnData, i, (const char*) pVal, false); - } - } else { - // memset(input->data, 0, num * bytes); - } - - *pInput = input; + SScalarParam *input = (SScalarParam *)taosMemoryCalloc(1, sizeof(SScalarParam)); + int32_t bytes; + switch (type) { + case TSDB_DATA_TYPE_TINYINT: { + bytes = sizeof(int8_t); + break; + } + case TSDB_DATA_TYPE_SMALLINT: { + bytes = sizeof(int16_t); + break; + } + case TSDB_DATA_TYPE_INT: { + bytes = sizeof(int32_t); + break; + } + case TSDB_DATA_TYPE_BIGINT: { + bytes = sizeof(int64_t); + break; + } + case TSDB_DATA_TYPE_FLOAT: { + bytes = sizeof(float); + break; + } + case TSDB_DATA_TYPE_DOUBLE: { + bytes = sizeof(double); + break; + } + } + + input->columnData = (SColumnInfoData *)taosMemoryCalloc(1, sizeof(SColumnInfoData)); + input->numOfRows = num; + + input->columnData->info = createColumnInfo(0, type, bytes); + colInfoDataEnsureCapacity(input->columnData, num); + + if (setVal) { + for (int32_t i = 0; i < num; ++i) { + colDataAppend(input->columnData, i, (const char *)pVal, false); + } + } else { + // memset(input->data, 0, num * bytes); + } + + *pInput = input; } void scltDestroyDataBlock(SScalarParam *pInput) { - colDataDestroy(pInput->columnData); - taosMemoryFree(pInput->columnData); - taosMemoryFree(pInput); + colDataDestroy(pInput->columnData); + taosMemoryFree(pInput->columnData); + taosMemoryFree(pInput); } TEST(ScalarFunctionTest, absFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - - //TINYINT - int8_t val_tinyint = 10; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_tinyint = -10; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -val_tinyint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //SMALLINT - int16_t val_smallint = 10; - type = TSDB_DATA_TYPE_SMALLINT; - scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_smallint = -10; - scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -val_smallint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //INT - int32_t val_int = 10; - type = TSDB_DATA_TYPE_INT; - scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_int = -10; - scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -val_int); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //BIGINT - int64_t val_bigint = 10; - type = TSDB_DATA_TYPE_BIGINT; - scltMakeDataBlock(&pInput, type, &val_bigint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), val_bigint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_bigint = -10; - scltMakeDataBlock(&pInput, type, &val_bigint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), -val_bigint); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 10.15; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("float before ABS:%f\n", *(float *)pInput->data); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float); - PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_float = -10.15; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("float before ABS:%f\n", *(float *)pInput->data); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -val_float); - PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //DOUBLE - double val_double = 10.15; - type = TSDB_DATA_TYPE_DOUBLE; - scltMakeDataBlock(&pInput, type, &val_double, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_double = -10.15; - scltMakeDataBlock(&pInput, type, &val_double, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -val_double); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + + // TINYINT + int8_t val_tinyint = 10; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_tinyint = -10; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -val_tinyint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // SMALLINT + int16_t val_smallint = 10; + type = TSDB_DATA_TYPE_SMALLINT; + scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_smallint = -10; + scltMakeDataBlock(&pInput, type, &val_smallint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -val_smallint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // INT + int32_t val_int = 10; + type = TSDB_DATA_TYPE_INT; + scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_int = -10; + scltMakeDataBlock(&pInput, type, &val_int, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -val_int); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // BIGINT + int64_t val_bigint = 10; + type = TSDB_DATA_TYPE_BIGINT; + scltMakeDataBlock(&pInput, type, &val_bigint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), val_bigint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_bigint = -10; + scltMakeDataBlock(&pInput, type, &val_bigint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int64_t *)colDataGetData(pOutput->columnData, i)), -val_bigint); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 10.15; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("float before ABS:%f\n", *(float *)pInput->data); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_float = -10.15; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("float before ABS:%f\n", *(float *)pInput->data); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -val_float); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // DOUBLE + double val_double = 10.15; + type = TSDB_DATA_TYPE_DOUBLE; + scltMakeDataBlock(&pInput, type, &val_double, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_double = -10.15; + scltMakeDataBlock(&pInput, type, &val_double, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -val_double); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, absFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 5; - int32_t type; - - //TINYINT - int8_t val_tinyint = 10; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int8_t v = val_tinyint + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("tiny_int before ABS:%d\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint + i); - PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_tinyint = -10; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int8_t v = val_tinyint + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("tiny_int before ABS:%d\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -(val_tinyint + i)); - PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //SMALLINT - int16_t val_smallint = 10; - type = TSDB_DATA_TYPE_SMALLINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int16_t v = val_smallint + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("small_int before ABS:%d\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint + i); - PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_smallint = -10; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int16_t v = val_smallint + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("small_int before ABS:%d\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -(val_smallint + i)); - PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //INT - int32_t val_int = 10; - type = TSDB_DATA_TYPE_INT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int32_t v = val_int + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("int before ABS:%d\n", v); - } - - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int + i); - PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_int = -10; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - int32_t v = val_int + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("int before ABS:%d\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -(val_int + i)); - PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 10.15; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - float v = val_float + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("float before ABS:%f\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float + i); - PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_float = -10.15; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - float v = val_float + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("float before ABS:%f\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -(val_float + i)); - PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //DOUBLE - double val_double = 10.15; - type = TSDB_DATA_TYPE_DOUBLE; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - double v = val_double + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("double before ABS:%f\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double + i); - PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - val_double = -10.15; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - double v = val_double + i; - colDataAppend(pInput->columnData, i, (const char*) &v, false); - PRINTF("double before ABS:%f\n", v); - } - - code = absFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -(val_double + i)); - PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 5; + int32_t type; + + // TINYINT + int8_t val_tinyint = 10; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int8_t v = val_tinyint + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("tiny_int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), val_tinyint + i); + PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_tinyint = -10; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int8_t v = val_tinyint + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("tiny_int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), -(val_tinyint + i)); + PRINTF("tiny_int after ABS:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // SMALLINT + int16_t val_smallint = 10; + type = TSDB_DATA_TYPE_SMALLINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int16_t v = val_smallint + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("small_int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), val_smallint + i); + PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_smallint = -10; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int16_t v = val_smallint + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("small_int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int16_t *)colDataGetData(pOutput->columnData, i)), -(val_smallint + i)); + PRINTF("small_int after ABS:%d\n", *((int16_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // INT + int32_t val_int = 10; + type = TSDB_DATA_TYPE_INT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int32_t v = val_int + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), val_int + i); + PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_int = -10; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + int32_t v = val_int + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("int before ABS:%d\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int32_t *)colDataGetData(pOutput->columnData, i)), -(val_int + i)); + PRINTF("int after ABS:%d\n", *((int32_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 10.15; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + float v = val_float + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("float before ABS:%f\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), val_float + i); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_float = -10.15; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + float v = val_float + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("float before ABS:%f\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), -(val_float + i)); + PRINTF("float after ABS:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // DOUBLE + double val_double = 10.15; + type = TSDB_DATA_TYPE_DOUBLE; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + double v = val_double + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("double before ABS:%f\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), val_double + i); + PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + val_double = -10.15; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + double v = val_double + i; + colDataAppend(pInput->columnData, i, (const char *)&v, false); + PRINTF("double before ABS:%f\n", v); + } + + code = absFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), -(val_double + i)); + PRINTF("double after ABS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, sinFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 0.42016703682664092; - - //TINYINT - int8_t val_tinyint = 13; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before SIN:%d\n", *((int8_t *)pInput->data)); - - code = sinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 13.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before SIN:%f\n", *((float *)pInput->data)); - - code = sinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 0.42016703682664092; + + // TINYINT + int8_t val_tinyint = 13; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before SIN:%d\n", *((int8_t *)pInput->data)); + + code = sinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 13.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before SIN:%f\n", *((float *)pInput->data)); + + code = sinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, sinFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {0.42016703682664092, 0.99060735569487035, 0.65028784015711683}; - - - //TINYINT - int8_t val_tinyint[] = {13, 14, 15}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); - PRINTF("tiny_int before SIN:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); - } - - code = sinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {13.00, 14.00, 15.00}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); - PRINTF("float before SIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = sinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {0.42016703682664092, 0.99060735569487035, 0.65028784015711683}; + + // TINYINT + int8_t val_tinyint[] = {13, 14, 15}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_tinyint[i], false); + PRINTF("tiny_int before SIN:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); + } + + code = sinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {13.00, 14.00, 15.00}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_float[i], false); + PRINTF("float before SIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = sinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after SIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, cosFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 0.90744678145019619; - - //TINYINT - int8_t val_tinyint = 13; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before COS:%d\n", *((int8_t *)pInput->data)); - - code = cosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 13.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before COS:%f\n", *((float *)pInput->data)); - - code = cosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 0.90744678145019619; + + // TINYINT + int8_t val_tinyint = 13; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before COS:%d\n", *((int8_t *)pInput->data)); + + code = cosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 13.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before COS:%f\n", *((float *)pInput->data)); + + code = cosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, cosFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {0.90744678145019619, 0.13673721820783361, -0.75968791285882131}; - - //TINYINT - int8_t val_tinyint[] = {13, 14, 15}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); - PRINTF("tiny_int before COS:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); - } - - code = cosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {13.00, 14.00, 15.00}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); - PRINTF("float before COS:%f\n", *(float *)colDataGetData(pInput->columnData, i)); - } - - code = cosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {0.90744678145019619, 0.13673721820783361, -0.75968791285882131}; + + // TINYINT + int8_t val_tinyint[] = {13, 14, 15}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_tinyint[i], false); + PRINTF("tiny_int before COS:%d\n", *(int8_t *)colDataGetData(pInput->columnData, i)); + } + + code = cosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {13.00, 14.00, 15.00}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_float[i], false); + PRINTF("float before COS:%f\n", *(float *)colDataGetData(pInput->columnData, i)); + } + + code = cosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after COS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, tanFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 0.46302113293648961; - - //TINYINT - int8_t val_tinyint = 13; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before TAN:%d\n", *((int8_t *)pInput->data)); - - code = tanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 13.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before TAN:%f\n", *((float *)pInput->data)); - - code = tanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 0.46302113293648961; + + // TINYINT + int8_t val_tinyint = 13; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before TAN:%d\n", *((int8_t *)pInput->data)); + + code = tanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 13.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before TAN:%f\n", *((float *)pInput->data)); + + code = tanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, tanFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {0.46302113293648961, 7.24460661609480550, -0.85599340090851872}; - - //TINYINT - int8_t val_tinyint[] = {13, 14, 15}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); - PRINTF("tiny_int before TAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = tanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_NEAR(*((double *)colDataGetData(pOutput->columnData, i)), result[i], 1e-15); - PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {13.00, 14.00, 15.00}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_float[i], false); - PRINTF("float before TAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = tanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_NEAR(*((double *)colDataGetData(pOutput->columnData, i)), result[i], 1e-15); - PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {0.46302113293648961, 7.24460661609480550, -0.85599340090851872}; + + // TINYINT + int8_t val_tinyint[] = {13, 14, 15}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_tinyint[i], false); + PRINTF("tiny_int before TAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = tanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_NEAR(*((double *)colDataGetData(pOutput->columnData, i)), result[i], 1e-15); + PRINTF("tiny_int after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {13.00, 14.00, 15.00}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_float[i], false); + PRINTF("float before TAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = tanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_NEAR(*((double *)colDataGetData(pOutput->columnData, i)), result[i], 1e-15); + PRINTF("float after TAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, asinFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 1.57079632679489656; - - //TINYINT - int8_t val_tinyint = 1; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)pInput->data)); - - code = asinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 1.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before ASIN:%f\n", *((float *)pInput->data)); - - code = asinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 1.57079632679489656; + + // TINYINT + int8_t val_tinyint = 1; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)pInput->data)); + + code = asinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 1.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before ASIN:%f\n", *((float *)pInput->data)); + + code = asinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, asinFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {-1.57079632679489656, 0.0, 1.57079632679489656}; - - - //TINYINT - int8_t val_tinyint[] = {-1, 0, 1}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput->columnData, i, (const char*) &val_tinyint[i], false); - PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = asinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-1.0, 0.0, 1.0}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before ASIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = asinFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {-1.57079632679489656, 0.0, 1.57079632679489656}; + + // TINYINT + int8_t val_tinyint[] = {-1, 0, 1}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput->columnData, i, (const char *)&val_tinyint[i], false); + PRINTF("tiny_int before ASIN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = asinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-1.0, 0.0, 1.0}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ASIN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = asinFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ASIN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, acosFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 0.0; - - //TINYINT - int8_t val_tinyint = 1; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)pInput->data)); - - code = acosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 1.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before ACOS:%f\n", *((float *)pInput->data)); - - code = acosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 0.0; + + // TINYINT + int8_t val_tinyint = 1; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)pInput->data)); + + code = acosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 1.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before ACOS:%f\n", *((float *)pInput->data)); + + code = acosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, acosFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {3.14159265358979312, 1.57079632679489656, 0.0}; - - //TINYINT - int8_t val_tinyint[] = {-1, 0, 1}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = acosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-1.0, 0.0, 1.0}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before ACOS:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = acosFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {3.14159265358979312, 1.57079632679489656, 0.0}; + + // TINYINT + int8_t val_tinyint[] = {-1, 0, 1}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ACOS:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = acosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-1.0, 0.0, 1.0}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ACOS:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = acosFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ACOS:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, atanFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 0.78539816339744828; - - //TINYINT - int8_t val_tinyint = 1; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)pInput->data)); - - code = atanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 1.00; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before ATAN:%f\n", *((float *)pInput->data)); - - code = atanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 0.78539816339744828; + + // TINYINT + int8_t val_tinyint = 1; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)pInput->data)); + + code = atanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 1.00; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before ATAN:%f\n", *((float *)pInput->data)); + + code = atanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, atanFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {-0.78539816339744828, 0.0, 0.78539816339744828}; - - //TINYINT - int8_t val_tinyint[] = {-1, 0, 1}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = atanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-1.0, 0.0, 1.0}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before ATAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = atanFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {-0.78539816339744828, 0.0, 0.78539816339744828}; + + // TINYINT + int8_t val_tinyint[] = {-1, 0, 1}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ATAN:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = atanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-1.0, 0.0, 1.0}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ATAN:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = atanFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ATAN:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, ceilFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result = 10.0; - - //TINYINT - int8_t val_tinyint = 10; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)pInput->data)); - - code = ceilFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); - PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 9.5; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("float before CEIL:%f\n", *((float *)pInput->data)); - - code = ceilFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); - PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result = 10.0; + + // TINYINT + int8_t val_tinyint = 10; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)pInput->data)); + + code = ceilFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 9.5; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("float before CEIL:%f\n", *((float *)pInput->data)); + + code = ceilFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, ceilFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result[] = {-10.0, 0.0, 10.0}; - - //TINYINT - int8_t val_tinyint[] = {-10, 0, 10}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = ceilFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-10.5, 0.0, 9.5}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before CEIL:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = ceilFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result[] = {-10.0, 0.0, 10.0}; + + // TINYINT + int8_t val_tinyint[] = {-10, 0, 10}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before CEIL:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = ceilFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after CEIL:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-10.5, 0.0, 9.5}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before CEIL:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = ceilFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after CEIL:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, floorFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result = 10.0; - - //TINYINT - int8_t val_tinyint = 10; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)pInput->data)); - - code = floorFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); - PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 10.5; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("float before FLOOR:%f\n", *((float *)pInput->data)); - - code = floorFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); - PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result = 10.0; + + // TINYINT + int8_t val_tinyint = 10; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)pInput->data)); + + code = floorFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 10.5; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("float before FLOOR:%f\n", *((float *)pInput->data)); + + code = floorFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, floorFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result[] = {-10.0, 0.0, 10.0}; - - //TINYINT - int8_t val_tinyint[] = {-10, 0, 10}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = floorFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-9.5, 0.0, 10.5}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before FLOOR:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = floorFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result[] = {-10.0, 0.0, 10.0}; + + // TINYINT + int8_t val_tinyint[] = {-10, 0, 10}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before FLOOR:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = floorFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after FLOOR:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-9.5, 0.0, 10.5}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before FLOOR:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = floorFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after FLOOR:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, roundFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result = 10.0; - - //TINYINT - int8_t val_tinyint = 10; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)pInput->data)); - - code = roundFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); - PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 9.5; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - PRINTF("float before ROUND:%f\n", *((float *)pInput->data)); - - code = roundFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); - PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result = 10.0; + + // TINYINT + int8_t val_tinyint = 10; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)pInput->data)); + + code = roundFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), (int8_t)result); + PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 9.5; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + PRINTF("float before ROUND:%f\n", *((float *)pInput->data)); + + code = roundFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), (float)result); + PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, roundFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - double result[] = {-10.0, 0.0, 10.0}; - - //TINYINT - int8_t val_tinyint[] = {-10, 0, 10}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = roundFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {-9.5, 0.0, 9.5}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, type, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before ROUND:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = roundFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + double result[] = {-10.0, 0.0, 10.0}; + + // TINYINT + int8_t val_tinyint[] = {-10, 0, 10}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before ROUND:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = roundFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((int8_t *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after ROUND:%d\n", *((int8_t *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {-9.5, 0.0, 9.5}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, type, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before ROUND:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = roundFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((float *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after ROUND:%f\n", *((float *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, sqrtFunction_constant) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 5.0; - - //TINYINT - int8_t val_tinyint = 25; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)pInput->data)); - - code = sqrtFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float = 25.0; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before SQRT:%f\n", *((float *)pInput->data)); - - code = sqrtFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 5.0; + + // TINYINT + int8_t val_tinyint = 25; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, &val_tinyint, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)pInput->data)); + + code = sqrtFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float = 25.0; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, &val_float, rowNum, true); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before SQRT:%f\n", *((float *)pInput->data)); + + code = sqrtFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, sqrtFunction_column) { - SScalarParam *pInput, *pOutput; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {5.0, 9.0, 10.0}; - - //TINYINT - int8_t val_tinyint[] = {25, 81, 100}; - type = TSDB_DATA_TYPE_TINYINT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; - PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); - } - - code = sqrtFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {25.0, 81.0, 100.0}; - type = TSDB_DATA_TYPE_FLOAT; - scltMakeDataBlock(&pInput, type, 0, rowNum, false); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - for (int32_t i = 0; i < rowNum; ++i) { - *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; - PRINTF("float before SQRT:%f\n", *((float *)colDataGetData(pInput->columnData, i))); - } - - code = sqrtFunction(pInput, 1, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(pInput); - scltDestroyDataBlock(pOutput); + SScalarParam *pInput, *pOutput; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {5.0, 9.0, 10.0}; + + // TINYINT + int8_t val_tinyint[] = {25, 81, 100}; + type = TSDB_DATA_TYPE_TINYINT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((int8_t *)colDataGetData(pInput->columnData, i)) = val_tinyint[i]; + PRINTF("tiny_int before SQRT:%d\n", *((int8_t *)colDataGetData(pInput->columnData, i))); + } + + code = sqrtFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {25.0, 81.0, 100.0}; + type = TSDB_DATA_TYPE_FLOAT; + scltMakeDataBlock(&pInput, type, 0, rowNum, false); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + for (int32_t i = 0; i < rowNum; ++i) { + *((float *)colDataGetData(pInput->columnData, i)) = val_float[i]; + PRINTF("float before SQRT:%f\n", *((float *)colDataGetData(pInput->columnData, i))); + } + + code = sqrtFunction(pInput, 1, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after SQRT:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(pInput); + scltDestroyDataBlock(pOutput); } TEST(ScalarFunctionTest, logFunction_constant) { - SScalarParam *pInput, *pOutput; - SScalarParam *input[2]; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 3.0; - pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); - - //TINYINT - int8_t val_tinyint[] = {27, 3}; - type = TSDB_DATA_TYPE_TINYINT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); - pInput[i] = *input[i]; - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before LOG: %d,%d\n", *((int8_t *)pInput[0].data), - *((int8_t *)pInput[1].data)); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {64.0, 4.0}; - type = TSDB_DATA_TYPE_FLOAT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); - pInput[i] = *input[i]; - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before LOG: %f,%f\n", *((float *)pInput[0].data), - *((float *)pInput[1].data)); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //TINYINT AND FLOAT - int8_t param0 = 64; - float param1 = 4.0; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); - pInput[0] = *input[0]; - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); - pInput[1] = *input[1]; - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - PRINTF("tiny_int,float before LOG: %d,%f\n", *((int8_t *)pInput[0].data), *((float *)pInput[1].data)); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - taosMemoryFree(pInput); + SScalarParam *pInput, *pOutput; + SScalarParam *input[2]; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 3.0; + pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); + + // TINYINT + int8_t val_tinyint[] = {27, 3}; + type = TSDB_DATA_TYPE_TINYINT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); + pInput[i] = *input[i]; + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before LOG: %d,%d\n", *((int8_t *)pInput[0].data), *((int8_t *)pInput[1].data)); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {64.0, 4.0}; + type = TSDB_DATA_TYPE_FLOAT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); + pInput[i] = *input[i]; + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before LOG: %f,%f\n", *((float *)pInput[0].data), *((float *)pInput[1].data)); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // TINYINT AND FLOAT + int8_t param0 = 64; + float param1 = 4.0; + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); + pInput[0] = *input[0]; + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); + pInput[1] = *input[1]; + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + PRINTF("tiny_int,float before LOG: %d,%f\n", *((int8_t *)pInput[0].data), *((float *)pInput[1].data)); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + taosMemoryFree(pInput); } TEST(ScalarFunctionTest, logFunction_column) { - SScalarParam *pInput, *pOutput; - SScalarParam *input[2]; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {2.0, 3.0, 4.0}; - pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); - - //TINYINT - int8_t val_tinyint[2][3] = {{9, 27, 81}, {3, 3, 3}}; - type = TSDB_DATA_TYPE_TINYINT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, 0, rowNum, false); - pInput[i] = *input[i]; - for (int32_t j = 0; j < rowNum; ++j) { - colDataAppend(pInput[i].columnData, j, (const char*) &val_tinyint[i][j], false); - - } - PRINTF("tiny_int before LOG:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), - *((int8_t *)pInput[i].data + 1), - *((int8_t *)pInput[i].data + 2)); - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[2][3] = {{9.0, 27.0, 81.0}, {3.0, 3.0, 3.0}}; - type = TSDB_DATA_TYPE_FLOAT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, 0, rowNum, false); - pInput[i] = *input[i]; - for (int32_t j = 0; j < rowNum; ++j) { - colDataAppend(pInput[i].columnData, j, (const char*) &val_float[i][j], false); - } - PRINTF("float before LOG:%f,%f,%f\n", *((float *)colDataGetData(pInput[i], 0)), - *((float *)colDataGetData(pInput[i], 1)), - *((float *)colDataGetData(pInput[i], 2))); - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //TINYINT AND FLOAT - int8_t param0[] = {9, 27, 81}; - float param1[] = {3.0, 3.0, 3.0}; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); - pInput[0] = *input[0]; - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput[0].columnData, i, (const char*) ¶m0[i], false); - - } - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); - pInput[1] = *input[1]; - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput[1].columnData, i, (const char*) ¶m1[i], false); - - } - PRINTF("tiny_int, float before LOG:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), *((float *)pInput[1].data + 0), - *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), - *((int8_t *)pInput[0].data + 2), *((float *)pInput[1].data + 2)); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = logFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - taosMemoryFree(pInput); + SScalarParam *pInput, *pOutput; + SScalarParam *input[2]; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {2.0, 3.0, 4.0}; + pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); + + // TINYINT + int8_t val_tinyint[2][3] = {{9, 27, 81}, {3, 3, 3}}; + type = TSDB_DATA_TYPE_TINYINT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, 0, rowNum, false); + pInput[i] = *input[i]; + for (int32_t j = 0; j < rowNum; ++j) { + colDataAppend(pInput[i].columnData, j, (const char *)&val_tinyint[i][j], false); + } + PRINTF("tiny_int before LOG:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), *((int8_t *)pInput[i].data + 1), + *((int8_t *)pInput[i].data + 2)); + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[2][3] = {{9.0, 27.0, 81.0}, {3.0, 3.0, 3.0}}; + type = TSDB_DATA_TYPE_FLOAT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, 0, rowNum, false); + pInput[i] = *input[i]; + for (int32_t j = 0; j < rowNum; ++j) { + colDataAppend(pInput[i].columnData, j, (const char *)&val_float[i][j], false); + } + PRINTF("float before LOG:%f,%f,%f\n", *((float *)colDataGetData(pInput[i], 0)), + *((float *)colDataGetData(pInput[i], 1)), *((float *)colDataGetData(pInput[i], 2))); + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // TINYINT AND FLOAT + int8_t param0[] = {9, 27, 81}; + float param1[] = {3.0, 3.0, 3.0}; + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); + pInput[0] = *input[0]; + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput[0].columnData, i, (const char *)¶m0[i], false); + } + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); + pInput[1] = *input[1]; + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput[1].columnData, i, (const char *)¶m1[i], false); + } + PRINTF("tiny_int, float before LOG:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), + *((float *)pInput[1].data + 0), *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), + *((int8_t *)pInput[0].data + 2), *((float *)pInput[1].data + 2)); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = logFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int,float after LOG:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + taosMemoryFree(pInput); } TEST(ScalarFunctionTest, powFunction_constant) { - SScalarParam *pInput, *pOutput; - SScalarParam *input[2]; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result = 16.0; - pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); - - //TINYINT - int8_t val_tinyint[] = {2, 4}; - type = TSDB_DATA_TYPE_TINYINT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); - pInput[i] = *input[i]; - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("tiny_int before POW: %d,%d\n", *((int8_t *)pInput[0].data), - *((int8_t *)pInput[1].data)); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[] = {2.0, 4.0}; - type = TSDB_DATA_TYPE_FLOAT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); - pInput[i] = *input[i]; - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - PRINTF("float before POW: %f,%f\n", *((float *)pInput[0].data), - *((float *)pInput[1].data)); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //TINYINT AND FLOAT - int8_t param0 = 2; - float param1 = 4.0; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); - pInput[0] = *input[0]; - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); - pInput[1] = *input[1]; - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - PRINTF("tiny_int,float before POW: %d,%f\n", *((int8_t *)pInput[0].data), *((float *)pInput[1].data)); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); - PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - taosMemoryFree(pInput); + SScalarParam *pInput, *pOutput; + SScalarParam *input[2]; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result = 16.0; + pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); + + // TINYINT + int8_t val_tinyint[] = {2, 4}; + type = TSDB_DATA_TYPE_TINYINT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, &val_tinyint[i], rowNum, true); + pInput[i] = *input[i]; + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("tiny_int before POW: %d,%d\n", *((int8_t *)pInput[0].data), *((int8_t *)pInput[1].data)); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[] = {2.0, 4.0}; + type = TSDB_DATA_TYPE_FLOAT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, &val_float[i], rowNum, true); + pInput[i] = *input[i]; + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + PRINTF("float before POW: %f,%f\n", *((float *)pInput[0].data), *((float *)pInput[1].data)); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // TINYINT AND FLOAT + int8_t param0 = 2; + float param1 = 4.0; + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, ¶m0, rowNum, true); + pInput[0] = *input[0]; + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, ¶m1, rowNum, true); + pInput[1] = *input[1]; + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + PRINTF("tiny_int,float before POW: %d,%f\n", *((int8_t *)pInput[0].data), *((float *)pInput[1].data)); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result); + PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + taosMemoryFree(pInput); } TEST(ScalarFunctionTest, powFunction_column) { - SScalarParam *pInput, *pOutput; - SScalarParam *input[2]; - int32_t code = TSDB_CODE_SUCCESS; - int32_t rowNum = 3; - int32_t type; - int32_t otype = TSDB_DATA_TYPE_DOUBLE; - double result[] = {8.0, 27.0, 64.0}; - pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); - - //TINYINT - int8_t val_tinyint[2][3] = {{2, 3, 4}, {3, 3, 3}}; - type = TSDB_DATA_TYPE_TINYINT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, 0, rowNum, false); - pInput[i] = *input[i]; - for (int32_t j = 0; j < rowNum; ++j) { - colDataAppend(pInput[i].columnData, j, (const char*) &val_tinyint[i][j], false); - - } - PRINTF("tiny_int before POW:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), - *((int8_t *)pInput[i].data + 1), - *((int8_t *)pInput[i].data + 2)); - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //FLOAT - float val_float[2][3] = {{2.0, 3.0, 4.0}, {3.0, 3.0, 3.0}}; - type = TSDB_DATA_TYPE_FLOAT; - for (int32_t i = 0; i < 2; ++i) { - scltMakeDataBlock(&input[i], type, 0, rowNum, false); - pInput[i] = *input[i]; - for (int32_t j = 0; j < rowNum; ++j) { - colDataAppend(pInput[i].columnData, j, (const char*) &val_float[i][j], false); - } - PRINTF("float before POW:%f,%f,%f\n", *((float *)pInput[i].data + 0), - *((float *)pInput[i].data + 1), - *((float *)pInput[i].data + 2)); - } - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - - //TINYINT AND FLOAT - int8_t param0[] = {2, 3, 4}; - float param1[] = {3.0, 3.0, 3.0}; - scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); - pInput[0] = *input[0]; - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput[0].columnData, i, (const char*) ¶m0[i], false); - - } - scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); - pInput[1] = *input[1]; - for (int32_t i = 0; i < rowNum; ++i) { - colDataAppend(pInput[1].columnData, i, (const char*) ¶m1[i], false); - } - PRINTF("tiny_int, float before POW:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), *((float *)pInput[1].data + 0), - *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), - *((int8_t *)pInput[0].data + 2), *((float *)pInput[1].data + 2)); - scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); - - code = powFunction(pInput, 2, pOutput); - ASSERT_EQ(code, TSDB_CODE_SUCCESS); - for (int32_t i = 0; i < rowNum; ++i) { - ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); - PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); - } - - scltDestroyDataBlock(input[0]); - scltDestroyDataBlock(input[1]); - scltDestroyDataBlock(pOutput); - taosMemoryFree(pInput); -} - -int main(int argc, char** argv) { - taosSeedRand(taosGetTimestampSec()); - testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); + SScalarParam *pInput, *pOutput; + SScalarParam *input[2]; + int32_t code = TSDB_CODE_SUCCESS; + int32_t rowNum = 3; + int32_t type; + int32_t otype = TSDB_DATA_TYPE_DOUBLE; + double result[] = {8.0, 27.0, 64.0}; + pInput = (SScalarParam *)taosMemoryCalloc(2, sizeof(SScalarParam)); + + // TINYINT + int8_t val_tinyint[2][3] = {{2, 3, 4}, {3, 3, 3}}; + type = TSDB_DATA_TYPE_TINYINT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, 0, rowNum, false); + pInput[i] = *input[i]; + for (int32_t j = 0; j < rowNum; ++j) { + colDataAppend(pInput[i].columnData, j, (const char *)&val_tinyint[i][j], false); + } + PRINTF("tiny_int before POW:%d,%d,%d\n", *((int8_t *)pInput[i].data + 0), *((int8_t *)pInput[i].data + 1), + *((int8_t *)pInput[i].data + 2)); + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // FLOAT + float val_float[2][3] = {{2.0, 3.0, 4.0}, {3.0, 3.0, 3.0}}; + type = TSDB_DATA_TYPE_FLOAT; + for (int32_t i = 0; i < 2; ++i) { + scltMakeDataBlock(&input[i], type, 0, rowNum, false); + pInput[i] = *input[i]; + for (int32_t j = 0; j < rowNum; ++j) { + colDataAppend(pInput[i].columnData, j, (const char *)&val_float[i][j], false); + } + PRINTF("float before POW:%f,%f,%f\n", *((float *)pInput[i].data + 0), *((float *)pInput[i].data + 1), + *((float *)pInput[i].data + 2)); + } + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + + // TINYINT AND FLOAT + int8_t param0[] = {2, 3, 4}; + float param1[] = {3.0, 3.0, 3.0}; + scltMakeDataBlock(&input[0], TSDB_DATA_TYPE_TINYINT, 0, rowNum, false); + pInput[0] = *input[0]; + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput[0].columnData, i, (const char *)¶m0[i], false); + } + scltMakeDataBlock(&input[1], TSDB_DATA_TYPE_FLOAT, 0, rowNum, false); + pInput[1] = *input[1]; + for (int32_t i = 0; i < rowNum; ++i) { + colDataAppend(pInput[1].columnData, i, (const char *)¶m1[i], false); + } + PRINTF("tiny_int, float before POW:{%d,%f}, {%d,%f}, {%d,%f}\n", *((int8_t *)pInput[0].data + 0), + *((float *)pInput[1].data + 0), *((int8_t *)pInput[0].data + 1), *((float *)pInput[1].data + 1), + *((int8_t *)pInput[0].data + 2), *((float *)pInput[1].data + 2)); + scltMakeDataBlock(&pOutput, otype, 0, rowNum, false); + + code = powFunction(pInput, 2, pOutput); + ASSERT_EQ(code, TSDB_CODE_SUCCESS); + for (int32_t i = 0; i < rowNum; ++i) { + ASSERT_EQ(*((double *)colDataGetData(pOutput->columnData, i)), result[i]); + PRINTF("tiny_int,float after POW:%f\n", *((double *)colDataGetData(pOutput->columnData, i))); + } + + scltDestroyDataBlock(input[0]); + scltDestroyDataBlock(input[1]); + scltDestroyDataBlock(pOutput); + taosMemoryFree(pInput); +} + +int main(int argc, char **argv) { + taosSeedRand(taosGetTimestampSec()); + testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); } #pragma GCC diagnostic pop - diff --git a/source/libs/scheduler/inc/schInt.h b/source/libs/scheduler/inc/schInt.h index 7ced4f626c413d7f208d524e833c3b2626678751..1a88992840cd649d2538f66e19d86a96df34c594 100644 --- a/source/libs/scheduler/inc/schInt.h +++ b/source/libs/scheduler/inc/schInt.h @@ -20,13 +20,13 @@ extern "C" { #endif +#include "command.h" #include "os.h" -#include "tarray.h" #include "planner.h" #include "scheduler.h" +#include "tarray.h" #include "thash.h" #include "trpc.h" -#include "command.h" enum { SCH_READ = 1, @@ -51,20 +51,20 @@ typedef enum { SCH_ALL, } SCH_POLICY; -#define SCHEDULE_DEFAULT_MAX_JOB_NUM 1000 -#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000 +#define SCHEDULE_DEFAULT_MAX_JOB_NUM 1000 +#define SCHEDULE_DEFAULT_MAX_TASK_NUM 1000 #define SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM 200 // unit is TSDB_TABLE_NUM_UNIT -#define SCHEDULE_DEFAULT_POLICY SCH_LOAD_SEQ -#define SCHEDULE_DEFAULT_MAX_NODE_NUM 20 +#define SCHEDULE_DEFAULT_POLICY SCH_LOAD_SEQ +#define SCHEDULE_DEFAULT_MAX_NODE_NUM 20 #define SCH_DEFAULT_TASK_TIMEOUT_USEC 10000000 -#define SCH_MAX_TASK_TIMEOUT_USEC 60000000 -#define SCH_DEFAULT_MAX_RETRY_NUM 6 -#define SCH_MIN_AYSNC_EXEC_NUM 3 +#define SCH_MAX_TASK_TIMEOUT_USEC 60000000 +#define SCH_DEFAULT_MAX_RETRY_NUM 6 +#define SCH_MIN_AYSNC_EXEC_NUM 3 typedef struct SSchDebug { - bool lockEnable; - bool apiEnable; + bool lockEnable; + bool apiEnable; } SSchDebug; typedef struct SSchTrans { @@ -80,7 +80,6 @@ typedef struct SSchHbTrans { } SSchHbTrans; typedef struct SSchApiStat { - #if defined(WINDOWS) || defined(_TD_DARWIN_64) size_t avoidCompilationErrors; #endif @@ -88,7 +87,6 @@ typedef struct SSchApiStat { } SSchApiStat; typedef struct SSchRuntimeStat { - #if defined(WINDOWS) || defined(_TD_DARWIN_64) size_t avoidCompilationErrors; #endif @@ -96,7 +94,6 @@ typedef struct SSchRuntimeStat { } SSchRuntimeStat; typedef struct SSchJobStat { - #if defined(WINDOWS) || defined(_TD_DARWIN_64) size_t avoidCompilationErrors; #endif @@ -104,17 +101,17 @@ typedef struct SSchJobStat { } SSchJobStat; typedef struct SSchStat { - SSchApiStat api; - SSchRuntimeStat runtime; - SSchJobStat job; + SSchApiStat api; + SSchRuntimeStat runtime; + SSchJobStat job; } SSchStat; typedef struct SSchResInfo { - SExecResult* execRes; - void** fetchRes; - schedulerExecFp execFp; - schedulerFetchFp fetchFp; - void* cbParam; + SExecResult *execRes; + void **fetchRes; + schedulerExecFp execFp; + schedulerFetchFp fetchFp; + void *cbParam; } SSchResInfo; typedef struct SSchOpEvent { @@ -123,9 +120,9 @@ typedef struct SSchOpEvent { SSchedulerReq *pReq; } SSchOpEvent; -typedef int32_t (*schStatusEnterFp)(void* pHandle, void* pParam); -typedef int32_t (*schStatusLeaveFp)(void* pHandle, void* pParam); -typedef int32_t (*schStatusEventFp)(void* pHandle, void* pParam, void* pEvent); +typedef int32_t (*schStatusEnterFp)(void *pHandle, void *pParam); +typedef int32_t (*schStatusLeaveFp)(void *pHandle, void *pParam); +typedef int32_t (*schStatusEventFp)(void *pHandle, void *pParam, void *pEvent); typedef struct SSchStatusFps { EJobTaskType status; @@ -142,16 +139,16 @@ typedef struct SSchedulerCfg { } SSchedulerCfg; typedef struct SSchedulerMgmt { - uint64_t taskId; // sequential taksId - uint64_t sId; // schedulerId - SSchedulerCfg cfg; - bool exit; - int32_t jobRef; - int32_t jobNum; - SSchStat stat; - SRWLatch hbLock; - SHashObj *hbConnections; - void *queryMgmt; + uint64_t taskId; // sequential taksId + uint64_t sId; // schedulerId + SSchedulerCfg cfg; + bool exit; + int32_t jobRef; + int32_t jobNum; + SSchStat stat; + SRWLatch hbLock; + SHashObj *hbConnections; + void *queryMgmt; } SSchedulerMgmt; typedef struct SSchCallbackParamHeader { @@ -174,11 +171,11 @@ typedef struct SSchHbCallbackParam { } SSchHbCallbackParam; typedef struct SSchFlowControl { - SRWLatch lock; - bool sorted; - int32_t tableNumSum; - uint32_t execTaskNum; - SArray *taskList; // Element is SSchTask* + SRWLatch lock; + bool sorted; + int32_t tableNumSum; + uint32_t execTaskNum; + SArray *taskList; // Element is SSchTask* } SSchFlowControl; typedef struct SSchNodeInfo { @@ -187,50 +184,50 @@ typedef struct SSchNodeInfo { } SSchNodeInfo; typedef struct SSchLevel { - int32_t level; - int8_t status; - SRWLatch lock; - int32_t taskFailed; - int32_t taskSucceed; - int32_t taskNum; - int32_t taskLaunchedNum; - int32_t taskDoneNum; - SArray *subTasks; // Element is SSchTask + int32_t level; + int8_t status; + SRWLatch lock; + int32_t taskFailed; + int32_t taskSucceed; + int32_t taskNum; + int32_t taskLaunchedNum; + int32_t taskDoneNum; + SArray *subTasks; // Element is SSchTask } SSchLevel; typedef struct SSchTaskProfile { - int64_t startTs; - SArray* execTime; - int64_t waitTime; - int64_t endTs; + int64_t startTs; + SArray *execTime; + int64_t waitTime; + int64_t endTs; } SSchTaskProfile; typedef struct SSchTask { - uint64_t taskId; // task id - SRWLatch lock; // task reentrant lock - int32_t maxExecTimes; // task max exec times - int32_t maxRetryTimes; // task max retry times - int32_t retryTimes; // task retry times - bool waitRetry; // wait for retry - int32_t execId; // task current execute index - SSchLevel *level; // level - SRWLatch planLock; // task update plan lock - SSubplan *plan; // subplan - char *msg; // operator tree - int32_t msgLen; // msg length - int8_t status; // task status - int32_t lastMsgType; // last sent msg type - int64_t timeoutUsec; // task timeout useconds before reschedule - SQueryNodeAddr succeedAddr; // task executed success node address - int8_t candidateIdx; // current try condidation index - SArray *candidateAddrs; // condidate node addresses, element is SQueryNodeAddr - SHashObj *execNodes; // all tried node for current task, element is SSchNodeInfo - SSchTaskProfile profile; // task execution profile - int32_t childReady; // child task ready number - SArray *children; // the datasource tasks,from which to fetch the result, element is SQueryTask* - SArray *parents; // the data destination tasks, get data from current task, element is SQueryTask* - void* handle; // task send handle - bool registerdHb; // registered in hb + uint64_t taskId; // task id + SRWLatch lock; // task reentrant lock + int32_t maxExecTimes; // task max exec times + int32_t maxRetryTimes; // task max retry times + int32_t retryTimes; // task retry times + bool waitRetry; // wait for retry + int32_t execId; // task current execute index + SSchLevel *level; // level + SRWLatch planLock; // task update plan lock + SSubplan *plan; // subplan + char *msg; // operator tree + int32_t msgLen; // msg length + int8_t status; // task status + int32_t lastMsgType; // last sent msg type + int64_t timeoutUsec; // task timeout useconds before reschedule + SQueryNodeAddr succeedAddr; // task executed success node address + int8_t candidateIdx; // current try condidation index + SArray *candidateAddrs; // condidate node addresses, element is SQueryNodeAddr + SHashObj *execNodes; // all tried node for current task, element is SSchNodeInfo + SSchTaskProfile profile; // task execution profile + int32_t childReady; // child task ready number + SArray *children; // the datasource tasks,from which to fetch the result, element is SQueryTask* + SArray *parents; // the data destination tasks, get data from current task, element is SQueryTask* + void *handle; // task send handle + bool registerdHb; // registered in hb } SSchTask; typedef struct SSchJobAttr { @@ -243,46 +240,46 @@ typedef struct SSchJobAttr { } SSchJobAttr; typedef struct { - int32_t op; - SRWLatch lock; - bool syncReq; + int32_t op; + SRWLatch lock; + bool syncReq; } SSchOpStatus; typedef struct SSchJob { - int64_t refId; - uint64_t queryId; - SSchJobAttr attr; - int32_t levelNum; - int32_t taskNum; - SRequestConnInfo conn; - SArray *nodeList; // qnode/vnode list, SArray - SArray *levels; // starting from 0. SArray - SQueryPlan *pDag; - int64_t allocatorRefId; - - SArray *dataSrcTasks; // SArray - int32_t levelIdx; - SEpSet dataSrcEps; - SHashObj *taskList; - SHashObj *execTasks; // executing and executed tasks, key:taskid, value:SQueryTask* - SHashObj *flowCtrl; // key is ep, element is SSchFlowControl - - SExplainCtx *explainCtx; - int8_t status; - SQueryNodeAddr resNode; - tsem_t rspSem; - SSchOpStatus opStatus; - schedulerChkKillFp chkKillFp; - void* chkKillParam; - SSchTask *fetchTask; - int32_t errCode; - SRWLatch resLock; - SExecResult execRes; - void *fetchRes; //TODO free it or not - bool fetched; - int32_t resNumOfRows; - SSchResInfo userRes; - char *sql; + int64_t refId; + uint64_t queryId; + SSchJobAttr attr; + int32_t levelNum; + int32_t taskNum; + SRequestConnInfo conn; + SArray *nodeList; // qnode/vnode list, SArray + SArray *levels; // starting from 0. SArray + SQueryPlan *pDag; + int64_t allocatorRefId; + + SArray *dataSrcTasks; // SArray + int32_t levelIdx; + SEpSet dataSrcEps; + SHashObj *taskList; + SHashObj *execTasks; // executing and executed tasks, key:taskid, value:SQueryTask* + SHashObj *flowCtrl; // key is ep, element is SSchFlowControl + + SExplainCtx *explainCtx; + int8_t status; + SQueryNodeAddr resNode; + tsem_t rspSem; + SSchOpStatus opStatus; + schedulerChkKillFp chkKillFp; + void *chkKillParam; + SSchTask *fetchTask; + int32_t errCode; + SRWLatch resLock; + SExecResult execRes; + void *fetchRes; // TODO free it or not + bool fetched; + int32_t resNumOfRows; + SSchResInfo userRes; + char *sql; SQueryProfileSummary summary; } SSchJob; @@ -294,226 +291,282 @@ typedef struct SSchTaskCtx { extern SSchedulerMgmt schMgmt; -#define SCH_TASK_TIMEOUT(_task) ((taosGetTimestampUs() - *(int64_t*)taosArrayGet((_task)->profile.execTime, (_task)->execId)) > (_task)->timeoutUsec) +#define SCH_TASK_TIMEOUT(_task) \ + ((taosGetTimestampUs() - *(int64_t *)taosArrayGet((_task)->profile.execTime, (_task)->execId)) > (_task)->timeoutUsec) #define SCH_TASK_READY_FOR_LAUNCH(readyNum, task) ((readyNum) >= taosArrayGetSize((task)->children)) -#define SCH_LOCK_TASK(_task) SCH_LOCK(SCH_WRITE, &(_task)->lock) +#define SCH_LOCK_TASK(_task) SCH_LOCK(SCH_WRITE, &(_task)->lock) #define SCH_UNLOCK_TASK(_task) SCH_UNLOCK(SCH_WRITE, &(_task)->lock) -#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1) +#define SCH_TASK_ID(_task) ((_task) ? (_task)->taskId : -1) #define SCH_TASK_EID(_task) ((_task) ? (_task)->execId : -1) #define SCH_IS_DATA_BIND_QRY_TASK(task) ((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) -#define SCH_IS_DATA_BIND_TASK(task) (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) +#define SCH_IS_DATA_BIND_TASK(task) \ + (((task)->plan->subplanType == SUBPLAN_TYPE_SCAN) || ((task)->plan->subplanType == SUBPLAN_TYPE_MODIFY)) #define SCH_IS_LEAF_TASK(_job, _task) (((_task)->level->level + 1) == (_job)->levelNum) -#define SCH_IS_DATA_MERGE_TASK(task) (!SCH_IS_DATA_BIND_TASK(task)) -#define SCH_IS_LOCAL_EXEC_TASK(_job, _task) ((_job)->attr.localExec && SCH_IS_QUERY_JOB(_job) && (!SCH_IS_INSERT_JOB(_job)) && (!SCH_IS_DATA_BIND_QRY_TASK(_task))) +#define SCH_IS_DATA_MERGE_TASK(task) (!SCH_IS_DATA_BIND_TASK(task)) +#define SCH_IS_LOCAL_EXEC_TASK(_job, _task) \ + ((_job)->attr.localExec && SCH_IS_QUERY_JOB(_job) && (!SCH_IS_INSERT_JOB(_job)) && \ + (!SCH_IS_DATA_BIND_QRY_TASK(_task))) #define SCH_SET_TASK_STATUS(task, st) atomic_store_8(&(task)->status, st) -#define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status) +#define SCH_GET_TASK_STATUS(task) atomic_load_8(&(task)->status) #define SCH_GET_TASK_STATUS_STR(task) jobTaskStatusStr(SCH_GET_TASK_STATUS(task)) -#define SCH_GET_TASK_HANDLE(_task) ((_task) ? (_task)->handle : NULL) +#define SCH_GET_TASK_HANDLE(_task) ((_task) ? (_task)->handle : NULL) #define SCH_SET_TASK_HANDLE(_task, _handle) ((_task)->handle = (_handle)) #define SCH_SET_JOB_STATUS(job, st) atomic_store_8(&(job)->status, st) -#define SCH_GET_JOB_STATUS(job) atomic_load_8(&(job)->status) +#define SCH_GET_JOB_STATUS(job) atomic_load_8(&(job)->status) #define SCH_GET_JOB_STATUS_STR(job) jobTaskStatusStr(SCH_GET_JOB_STATUS(job)) #define SCH_JOB_IN_SYNC_OP(job) ((job)->opStatus.op && (job)->opStatus.syncReq) -#define SCH_JOB_IN_ASYNC_EXEC_OP(job) ((SCH_OP_EXEC == atomic_val_compare_exchange_32(&(job)->opStatus.op, SCH_OP_EXEC, SCH_OP_NULL)) && (!(job)->opStatus.syncReq)) -#define SCH_JOB_IN_ASYNC_FETCH_OP(job) ((SCH_OP_FETCH == atomic_val_compare_exchange_32(&(job)->opStatus.op, SCH_OP_FETCH, SCH_OP_NULL)) && (!(job)->opStatus.syncReq)) +#define SCH_JOB_IN_ASYNC_EXEC_OP(job) \ + ((SCH_OP_EXEC == atomic_val_compare_exchange_32(&(job)->opStatus.op, SCH_OP_EXEC, SCH_OP_NULL)) && \ + (!(job)->opStatus.syncReq)) +#define SCH_JOB_IN_ASYNC_FETCH_OP(job) \ + ((SCH_OP_FETCH == atomic_val_compare_exchange_32(&(job)->opStatus.op, SCH_OP_FETCH, SCH_OP_NULL)) && \ + (!(job)->opStatus.syncReq)) #define SCH_SET_JOB_NEED_FLOW_CTRL(_job) (_job)->attr.needFlowCtrl = true -#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl) -#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) (SCH_IS_DATA_BIND_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) -#define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_BIND_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) +#define SCH_JOB_NEED_FLOW_CTRL(_job) ((_job)->attr.needFlowCtrl) +#define SCH_TASK_NEED_FLOW_CTRL(_job, _task) \ + (SCH_IS_DATA_BIND_QRY_TASK(_task) && SCH_JOB_NEED_FLOW_CTRL(_job) && SCH_IS_LEVEL_UNFINISHED((_task)->level)) +#define SCH_FETCH_TYPE(_pSrcTask) (SCH_IS_DATA_BIND_QRY_TASK(_pSrcTask) ? TDMT_SCH_FETCH : TDMT_SCH_MERGE_FETCH) #define SCH_TASK_NEED_FETCH(_task) ((_task)->plan->subplanType != SUBPLAN_TYPE_MODIFY) -#define SCH_SET_JOB_TYPE(_job, type) do { if ((type) != SUBPLAN_TYPE_MODIFY) { (_job)->attr.queryJob = true; } else { (_job)->attr.insertJob = true; } } while (0) -#define SCH_IS_QUERY_JOB(_job) ((_job)->attr.queryJob) -#define SCH_IS_INSERT_JOB(_job) ((_job)->attr.insertJob) +#define SCH_SET_JOB_TYPE(_job, type) \ + do { \ + if ((type) != SUBPLAN_TYPE_MODIFY) { \ + (_job)->attr.queryJob = true; \ + } else { \ + (_job)->attr.insertJob = true; \ + } \ + } while (0) +#define SCH_IS_QUERY_JOB(_job) ((_job)->attr.queryJob) +#define SCH_IS_INSERT_JOB(_job) ((_job)->attr.insertJob) #define SCH_JOB_NEED_FETCH(_job) ((_job)->attr.needFetch) -#define SCH_JOB_NEED_WAIT(_job) (!SCH_IS_QUERY_JOB(_job)) -#define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job)) +#define SCH_JOB_NEED_WAIT(_job) (!SCH_IS_QUERY_JOB(_job)) +#define SCH_JOB_NEED_DROP(_job) (SCH_IS_QUERY_JOB(_job)) #define SCH_IS_EXPLAIN_JOB(_job) (EXPLAIN_MODE_ANALYZE == (_job)->attr.explainMode) -#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) -#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)))) -#define SCH_REDIRECT_MSGTYPE(_msgType) ((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) -#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) (SCH_REDIRECT_MSGTYPE(_msgType) && (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen)))) -#define SCH_NEED_RETRY(_msgType, _code) ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) +#define SCH_NETWORK_ERR(_code) ((_code) == TSDB_CODE_RPC_BROKEN_LINK || (_code) == TSDB_CODE_RPC_NETWORK_UNAVAIL) +#define SCH_MERGE_TASK_NETWORK_ERR(_task, _code, _len) \ + (SCH_NETWORK_ERR(_code) && (((_len) > 0) || (!SCH_IS_DATA_BIND_TASK(_task)))) +#define SCH_REDIRECT_MSGTYPE(_msgType) \ + ((_msgType) == TDMT_SCH_LINK_BROKEN || (_msgType) == TDMT_SCH_QUERY || (_msgType) == TDMT_SCH_MERGE_QUERY || \ + (_msgType) == TDMT_SCH_FETCH || (_msgType) == TDMT_SCH_MERGE_FETCH) +#define SCH_TASK_NEED_REDIRECT(_task, _msgType, _code, _rspLen) \ + (SCH_REDIRECT_MSGTYPE(_msgType) && \ + (NEED_SCHEDULER_REDIRECT_ERROR(_code) || SCH_MERGE_TASK_NETWORK_ERR((_task), (_code), (_rspLen)))) +#define SCH_NEED_RETRY(_msgType, _code) \ + ((SCH_NETWORK_ERR(_code) && SCH_REDIRECT_MSGTYPE(_msgType)) || (_code) == TSDB_CODE_SCH_TIMEOUT_ERROR) #define SCH_IS_LEVEL_UNFINISHED(_level) ((_level)->taskLaunchedNum < (_level)->taskNum) -#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse]) -#define SCH_SWITCH_EPSET(_addr) ((_addr)->epSet.inUse = ((_addr)->epSet.inUse + 1) % (_addr)->epSet.numOfEps) -#define SCH_TASK_NUM_OF_EPS(_addr) ((_addr)->epSet.numOfEps) - -#define SCH_LOG_TASK_START_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - taosArrayPush((_task)->profile.execTime, &us); \ - if (0 == (_task)->execId) { \ - (_task)->profile.startTs = us; \ - } \ - } while (0) - -#define SCH_LOG_TASK_WAIT_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - (_task)->profile.waitTime += us - *(int64_t*)taosArrayGet((_task)->profile.execTime, (_task)->execId); \ - } while (0) - - -#define SCH_LOG_TASK_END_TS(_task) \ - do { \ - int64_t us = taosGetTimestampUs(); \ - int32_t idx = (_task)->execId % (_task)->maxExecTimes; \ +#define SCH_GET_CUR_EP(_addr) (&(_addr)->epSet.eps[(_addr)->epSet.inUse]) +#define SCH_SWITCH_EPSET(_addr) ((_addr)->epSet.inUse = ((_addr)->epSet.inUse + 1) % (_addr)->epSet.numOfEps) +#define SCH_TASK_NUM_OF_EPS(_addr) ((_addr)->epSet.numOfEps) + +#define SCH_LOG_TASK_START_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + taosArrayPush((_task)->profile.execTime, &us); \ + if (0 == (_task)->execId) { \ + (_task)->profile.startTs = us; \ + } \ + } while (0) + +#define SCH_LOG_TASK_WAIT_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + (_task)->profile.waitTime += us - *(int64_t *)taosArrayGet((_task)->profile.execTime, (_task)->execId); \ + } while (0) + +#define SCH_LOG_TASK_END_TS(_task) \ + do { \ + int64_t us = taosGetTimestampUs(); \ + int32_t idx = (_task)->execId % (_task)->maxExecTimes; \ int64_t *startts = taosArrayGet((_task)->profile.execTime, (_task)->execId); \ - *startts = us - *startts; \ - (_task)->profile.endTs = us; \ - } while (0) - + *startts = us - *startts; \ + (_task)->profile.endTs = us; \ + } while (0) #define SCH_JOB_ELOG(param, ...) qError("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__) #define SCH_JOB_DLOG(param, ...) qDebug("QID:0x%" PRIx64 " " param, pJob->queryId, __VA_ARGS__) -#define SCH_TASK_ELOG(param, ...) \ - qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) -#define SCH_TASK_DLOG(param, ...) \ - qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) -#define SCH_TASK_TLOG(param, ...) \ - qTrace("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) -#define SCH_TASK_DLOGL(param, ...) \ - qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) -#define SCH_TASK_WLOG(param, ...) \ - qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask),__VA_ARGS__) - -#define SCH_SET_ERRNO(_err) do { if (TSDB_CODE_SCH_IGNORE_ERROR != (_err)) { terrno = (_err); } } while (0) -#define SCH_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(_code); return _code; } } while (0) -#define SCH_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(_code); } return _code; } while (0) -#define SCH_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { SCH_SET_ERRNO(code); goto _return; } } while (0) - -#define SCH_LOCK_DEBUG(...) do { if (gSCHDebug.lockEnable) { qDebug(__VA_ARGS__); } } while (0) +#define SCH_TASK_ELOG(param, ...) \ + qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask), \ + __VA_ARGS__) +#define SCH_TASK_DLOG(param, ...) \ + qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask), \ + __VA_ARGS__) +#define SCH_TASK_TLOG(param, ...) \ + qTrace("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask), \ + __VA_ARGS__) +#define SCH_TASK_DLOGL(param, ...) \ + qDebugL("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask), \ + __VA_ARGS__) +#define SCH_TASK_WLOG(param, ...) \ + qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ",EID:%d " param, pJob->queryId, SCH_TASK_ID(pTask), SCH_TASK_EID(pTask), \ + __VA_ARGS__) + +#define SCH_SET_ERRNO(_err) \ + do { \ + if (TSDB_CODE_SCH_IGNORE_ERROR != (_err)) { \ + terrno = (_err); \ + } \ + } while (0) +#define SCH_ERR_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + SCH_SET_ERRNO(_code); \ + return _code; \ + } \ + } while (0) +#define SCH_RET(c) \ + do { \ + int32_t _code = c; \ + if (_code != TSDB_CODE_SUCCESS) { \ + SCH_SET_ERRNO(_code); \ + } \ + return _code; \ + } while (0) +#define SCH_ERR_JRET(c) \ + do { \ + code = c; \ + if (code != TSDB_CODE_SUCCESS) { \ + SCH_SET_ERRNO(code); \ + goto _return; \ + } \ + } while (0) + +#define SCH_LOCK_DEBUG(...) \ + do { \ + if (gSCHDebug.lockEnable) { \ + qDebug(__VA_ARGS__); \ + } \ + } while (0) #define TD_RWLATCH_WRITE_FLAG_COPY 0x40000000 -#define SCH_LOCK(type, _lock) do { \ - if (SCH_READ == (type)) { \ - assert(atomic_load_32(_lock) >= 0); \ - SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRLockLatch(_lock); \ - SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32(_lock) > 0); \ - } else { \ - assert(atomic_load_32(_lock) >= 0); \ - SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWLockLatch(_lock); \ - SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32(_lock) == TD_RWLATCH_WRITE_FLAG_COPY); \ - } \ -} while (0) - -#define SCH_UNLOCK(type, _lock) do { \ - if (SCH_READ == (type)) { \ - assert(atomic_load_32((_lock)) > 0); \ - SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosRUnLockLatch(_lock); \ - SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } else { \ - assert(atomic_load_32((_lock)) & TD_RWLATCH_WRITE_FLAG_COPY); \ - SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - taosWUnLockLatch(_lock); \ - SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ - assert(atomic_load_32((_lock)) >= 0); \ - } \ -} while (0) - - -void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask); -void schCleanClusterHb(void* pTrans); -int32_t schLaunchTask(SSchJob *job, SSchTask *task); -int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, SQueryNodeAddr *addr, int32_t msgType); +#define SCH_LOCK(type, _lock) \ + do { \ + if (SCH_READ == (type)) { \ + assert(atomic_load_32(_lock) >= 0); \ + SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRLockLatch(_lock); \ + SCH_LOCK_DEBUG("SCH RLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32(_lock) > 0); \ + } else { \ + assert(atomic_load_32(_lock) >= 0); \ + SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWLockLatch(_lock); \ + SCH_LOCK_DEBUG("SCH WLOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32(_lock) == TD_RWLATCH_WRITE_FLAG_COPY); \ + } \ + } while (0) + +#define SCH_UNLOCK(type, _lock) \ + do { \ + if (SCH_READ == (type)) { \ + assert(atomic_load_32((_lock)) > 0); \ + SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosRUnLockLatch(_lock); \ + SCH_LOCK_DEBUG("SCH RULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } else { \ + assert(atomic_load_32((_lock)) & TD_RWLATCH_WRITE_FLAG_COPY); \ + SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d B", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + taosWUnLockLatch(_lock); \ + SCH_LOCK_DEBUG("SCH WULOCK%p:%d, %s:%d E", (_lock), atomic_load_32(_lock), __FILE__, __LINE__); \ + assert(atomic_load_32((_lock)) >= 0); \ + } \ + } while (0) + +void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask); +void schCleanClusterHb(void *pTrans); +int32_t schLaunchTask(SSchJob *job, SSchTask *task); +int32_t schBuildAndSendMsg(SSchJob *job, SSchTask *task, SQueryNodeAddr *addr, int32_t msgType); SSchJob *schAcquireJob(int64_t refId); -int32_t schReleaseJob(int64_t refId); -void schFreeFlowCtrl(SSchJob *pJob); -int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel); -int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask); -int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough); -int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask); -int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask); -int32_t schLaunchFetchTask(SSchJob *pJob); -int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode); -int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray* taskAction); -int32_t schCloneSMsgSendInfo(void *src, void **dst); -int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob); -void schFreeJobImpl(void *job); -int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx); -int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask); -int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans); -int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code); -void schFreeRpcCtx(SRpcCtx *pCtx); -int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp); -bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus); -int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask); -int32_t schSaveJobExecRes(SSchJob *pJob, SQueryTableRsp *rsp); -int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp); -void schProcessOnDataFetched(SSchJob *job); -int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask); -void schFreeRpcCtxVal(const void *arg); -int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb); -int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId); -int32_t schExecStaticExplainJob(SSchedulerReq *pReq, int64_t *job, bool sync); -int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus); -int32_t schCancelJob(SSchJob *pJob); -int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode); +int32_t schReleaseJob(int64_t refId); +void schFreeFlowCtrl(SSchJob *pJob); +int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel); +int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask); +int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough); +int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask); +int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask); +int32_t schLaunchFetchTask(SSchJob *pJob); +int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode); +int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId, SArray *taskAction); +int32_t schCloneSMsgSendInfo(void *src, void **dst); +int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob); +void schFreeJobImpl(void *job); +int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx); +int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask); +int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans); +int32_t schHandleHbCallback(void *param, SDataBuf *pMsg, int32_t code); +void schFreeRpcCtx(SRpcCtx *pCtx); +int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp); +bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus); +int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask); +int32_t schSaveJobExecRes(SSchJob *pJob, SQueryTableRsp *rsp); +int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp); +void schProcessOnDataFetched(SSchJob *job); +int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask); +void schFreeRpcCtxVal(const void *arg); +int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb); +int32_t schAppendTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t execId); +int32_t schExecStaticExplainJob(SSchedulerReq *pReq, int64_t *job, bool sync); +int32_t schUpdateJobStatus(SSchJob *pJob, int8_t newStatus); +int32_t schCancelJob(SSchJob *pJob); +int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode); uint64_t schGenTaskId(void); -void schCloseJobRef(void); -int32_t schAsyncExecJob(SSchedulerReq *pReq, int64_t *pJob); -int32_t schJobFetchRows(SSchJob *pJob); -int32_t schJobFetchRowsA(SSchJob *pJob); -int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId); -int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId* pEpId, SArray* pStatusList); -char* schGetOpStr(SCH_OP_TYPE type); -int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync); -int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq); -int32_t schExecJob(SSchJob *pJob, SSchedulerReq *pReq); -int32_t schDumpJobExecRes(SSchJob* pJob, SExecResult* pRes); -int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet* pEpSet); -int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf* pData, int32_t rspCode); -void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode); -int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq); -void schProcessOnCbEnd(SSchJob *pJob, SSchTask *pTask, int32_t errCode); -int32_t schProcessOnCbBegin(SSchJob** job, SSchTask** task, uint64_t qId, int64_t rId, uint64_t tId); -void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask); -bool schJobDone(SSchJob *pJob); -int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask); -int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask); -int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param); -int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SSchedulerReq* pReq); -int32_t schHandleOpEndEvent(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode); -int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask); -void schUpdateJobErrCode(SSchJob *pJob, int32_t errCode); -int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry); -int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode); -int32_t schProcessOnJobPartialSuccess(SSchJob *pJob); -void schFreeTask(SSchJob *pJob, SSchTask *pTask); -void schDropTaskInHashList(SSchJob *pJob, SHashObj *list); -int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level); -int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask); -int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel); -int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask); -void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode); -int32_t schHandleJobFailure(SSchJob *pJob, int32_t errCode); -int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode); -bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync); -int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode); -int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp); +void schCloseJobRef(void); +int32_t schAsyncExecJob(SSchedulerReq *pReq, int64_t *pJob); +int32_t schJobFetchRows(SSchJob *pJob); +int32_t schJobFetchRowsA(SSchJob *pJob); +int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, void *handle, int32_t execId); +int32_t schProcessOnTaskStatusRsp(SQueryNodeEpId *pEpId, SArray *pStatusList); +char *schGetOpStr(SCH_OP_TYPE type); +int32_t schBeginOperation(SSchJob *pJob, SCH_OP_TYPE type, bool sync); +int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq); +int32_t schExecJob(SSchJob *pJob, SSchedulerReq *pReq); +int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes); +int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet); +int32_t schHandleRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode); +void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq, int32_t errCode); +int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq); +void schProcessOnCbEnd(SSchJob *pJob, SSchTask *pTask, int32_t errCode); +int32_t schProcessOnCbBegin(SSchJob **job, SSchTask **task, uint64_t qId, int64_t rId, uint64_t tId); +void schDropTaskOnExecNode(SSchJob *pJob, SSchTask *pTask); +bool schJobDone(SSchJob *pJob); +int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask); +int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask); +int32_t schSwitchJobStatus(SSchJob *pJob, int32_t status, void *param); +int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob **job, SCH_OP_TYPE type, SSchedulerReq *pReq); +int32_t schHandleOpEndEvent(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq, int32_t errCode); +int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask); +void schUpdateJobErrCode(SSchJob *pJob, int32_t errCode); +int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry); +int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode); +int32_t schProcessOnJobPartialSuccess(SSchJob *pJob); +void schFreeTask(SSchJob *pJob, SSchTask *pTask); +void schDropTaskInHashList(SSchJob *pJob, SHashObj *list); +int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level); +int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTask); +int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel); +int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask); +void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode); +int32_t schHandleJobFailure(SSchJob *pJob, int32_t errCode); +int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode); +bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync); +int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode); +int32_t schProcessExplainRsp(SSchJob *pJob, SSchTask *pTask, SExplainRsp *rsp); extern SSchDebug gSCHDebug; - #ifdef __cplusplus } #endif diff --git a/source/libs/scheduler/src/schDbg.c b/source/libs/scheduler/src/schDbg.c index a6398522d3358a5867fae171f90a1e5d5fb30077..d6c2b638b8c223dedce533825af4a3c62cf4da3c 100644 --- a/source/libs/scheduler/src/schDbg.c +++ b/source/libs/scheduler/src/schDbg.c @@ -16,19 +16,17 @@ #include "query.h" #include "schInt.h" -tsem_t schdRspSem; +tsem_t schdRspSem; SSchDebug gSCHDebug = {0}; void schdExecCallback(SExecResult* pResult, void* param, int32_t code) { if (code) { pResult->code = code; } - + *(SExecResult*)param = *pResult; taosMemoryFree(pResult); tsem_post(&schdRspSem); } - - diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index c5c2bfb2bb943da6ff85e686cff46b95dc194821..8980d08e891d58f4bbc7e1e88d0d3ea5d1c067ee 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -13,10 +13,10 @@ * along with this program. If not, see . */ +#include "catalog.h" +#include "query.h" #include "schInt.h" #include "tmsg.h" -#include "query.h" -#include "catalog.h" #include "tref.h" void schFreeFlowCtrl(SSchJob *pJob) { @@ -25,14 +25,14 @@ void schFreeFlowCtrl(SSchJob *pJob) { } SSchFlowControl *ctrl = NULL; - void *pIter = taosHashIterate(pJob->flowCtrl, NULL); + void *pIter = taosHashIterate(pJob->flowCtrl, NULL); while (pIter) { ctrl = (SSchFlowControl *)pIter; if (ctrl->taskList) { taosArrayDestroy(ctrl->taskList); } - + pIter = taosHashIterate(pJob->flowCtrl, pIter); } @@ -59,7 +59,8 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) { return TSDB_CODE_SUCCESS; } - pJob->flowCtrl = taosHashInit(pJob->taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + pJob->flowCtrl = + taosHashInit(pJob->taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); if (NULL == pJob->flowCtrl) { SCH_JOB_ELOG("taosHashInit %d flowCtrl failed", pJob->taskNum); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -73,17 +74,17 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) { } int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask) { - SSchLevel *pLevel = pTask->level; + SSchLevel *pLevel = pTask->level; SSchFlowControl *ctrl = NULL; - int32_t code = 0; - SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); - + int32_t code = 0; + SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); + ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp)); if (NULL == ctrl) { SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - + SCH_LOCK(SCH_WRITE, &ctrl->lock); if (ctrl->execTaskNum <= 0) { SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port); @@ -93,8 +94,8 @@ int32_t schDecTaskFlowQuota(SSchJob *pJob, SSchTask *pTask) { --ctrl->execTaskNum; ctrl->tableNumSum -= pTask->plan->execNodeStat.tableNum; - SCH_TASK_DLOG("task quota removed, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", - ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); + SCH_TASK_DLOG("task quota removed, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, + ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); _return: @@ -104,11 +105,11 @@ _return: } int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) { - SSchLevel *pLevel = pTask->level; - int32_t code = 0; + SSchLevel *pLevel = pTask->level; + int32_t code = 0; SSchFlowControl *ctrl = NULL; - SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); - + SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); + do { ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp)); if (NULL == ctrl) { @@ -119,34 +120,34 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) { if (HASH_NODE_EXIST(code)) { continue; } - + SCH_TASK_ELOG("taosHashPut flowCtrl failed, size:%d", (int32_t)sizeof(nctrl)); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - SCH_TASK_DLOG("task quota added, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", - ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, nctrl.tableNumSum, nctrl.execTaskNum); + SCH_TASK_DLOG("task quota added, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, + ep->port, pTask->plan->execNodeStat.tableNum, nctrl.tableNumSum, nctrl.execTaskNum); *enough = true; return TSDB_CODE_SUCCESS; } SCH_LOCK(SCH_WRITE, &ctrl->lock); - + if (0 == ctrl->execTaskNum) { ctrl->tableNumSum = pTask->plan->execNodeStat.tableNum; ++ctrl->execTaskNum; - + *enough = true; break; } - + int32_t sum = pTask->plan->execNodeStat.tableNum + ctrl->tableNumSum; - + if (sum <= schMgmt.cfg.maxNodeTableNum) { ctrl->tableNumSum = sum; ++ctrl->execTaskNum; - + *enough = true; break; } @@ -166,24 +167,25 @@ int32_t schCheckIncTaskFlowQuota(SSchJob *pJob, SSchTask *pTask, bool *enough) { *enough = false; ctrl->sorted = false; - + break; } while (true); _return: - SCH_TASK_DLOG("task quota %s added, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", - ((*enough)?"":"NOT"), ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); + SCH_TASK_DLOG("task quota %s added, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", + ((*enough) ? "" : "NOT"), ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, + ctrl->execTaskNum); SCH_UNLOCK(SCH_WRITE, &ctrl->lock); - + SCH_RET(code); } -int32_t schTaskTableNumCompare(const void* key1, const void* key2) { +int32_t schTaskTableNumCompare(const void *key1, const void *key2) { SSchTask *pTask1 = *(SSchTask **)key1; SSchTask *pTask2 = *(SSchTask **)key2; - + if (pTask1->plan->execNodeStat.tableNum < pTask2->plan->execNodeStat.tableNum) { return 1; } else if (pTask1->plan->execNodeStat.tableNum > pTask2->plan->execNodeStat.tableNum) { @@ -193,22 +195,21 @@ int32_t schTaskTableNumCompare(const void* key1, const void* key2) { } } - int32_t schLaunchTasksInFlowCtrlListImpl(SSchJob *pJob, SSchFlowControl *ctrl) { SCH_LOCK(SCH_WRITE, &ctrl->lock); - + if (NULL == ctrl->taskList || taosArrayGetSize(ctrl->taskList) <= 0) { SCH_UNLOCK(SCH_WRITE, &ctrl->lock); return TSDB_CODE_SUCCESS; } - int32_t remainNum = schMgmt.cfg.maxNodeTableNum - ctrl->tableNumSum; - int32_t taskNum = taosArrayGetSize(ctrl->taskList); - int32_t code = 0; + int32_t remainNum = schMgmt.cfg.maxNodeTableNum - ctrl->tableNumSum; + int32_t taskNum = taosArrayGetSize(ctrl->taskList); + int32_t code = 0; SSchTask *pTask = NULL; - + if (taskNum > 1 && !ctrl->sorted) { - taosArraySort(ctrl->taskList, schTaskTableNumCompare); // desc order + taosArraySort(ctrl->taskList, schTaskTableNumCompare); // desc order } for (int32_t i = 0; i < taskNum; ++i) { @@ -216,36 +217,36 @@ int32_t schLaunchTasksInFlowCtrlListImpl(SSchJob *pJob, SSchFlowControl *ctrl) { SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); if (pTask->plan->execNodeStat.tableNum > remainNum && ctrl->execTaskNum > 0) { - SCH_TASK_DLOG("task NOT to launch, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", - ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); + SCH_TASK_DLOG("task NOT to launch, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, + ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); continue; } - + ctrl->tableNumSum += pTask->plan->execNodeStat.tableNum; ++ctrl->execTaskNum; taosArrayRemove(ctrl->taskList, i); - - SCH_TASK_DLOG("task to launch, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", - ep->fqdn, ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); - + + SCH_TASK_DLOG("task to launch, fqdn:%s, port:%d, tableNum:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, + ep->port, pTask->plan->execNodeStat.tableNum, ctrl->tableNumSum, ctrl->execTaskNum); + SCH_ERR_JRET(schAsyncLaunchTaskImpl(pJob, pTask)); - + remainNum -= pTask->plan->execNodeStat.tableNum; if (remainNum <= 0) { - SCH_TASK_DLOG("no more task to launch, fqdn:%s, port:%d, remainNum:%d, remainExecTaskNum:%d", - ep->fqdn, ep->port, ctrl->tableNumSum, ctrl->execTaskNum); - + SCH_TASK_DLOG("no more task to launch, fqdn:%s, port:%d, remainNum:%d, remainExecTaskNum:%d", ep->fqdn, ep->port, + ctrl->tableNumSum, ctrl->execTaskNum); + break; } if (i < (taskNum - 1)) { SSchTask *pLastTask = *(SSchTask **)taosArrayGetLast(ctrl->taskList); if (remainNum < pLastTask->plan->execNodeStat.tableNum) { - SCH_TASK_DLOG("no more task to launch, fqdn:%s, port:%d, remainNum:%d, remainExecTaskNum:%d, smallestInList:%d", - ep->fqdn, ep->port, ctrl->tableNumSum, ctrl->execTaskNum, pLastTask->plan->execNodeStat.tableNum); - + SCH_TASK_DLOG("no more task to launch, fqdn:%s, port:%d, remainNum:%d, remainExecTaskNum:%d, smallestInList:%d", + ep->fqdn, ep->port, ctrl->tableNumSum, ctrl->execTaskNum, pLastTask->plan->execNodeStat.tableNum); + break; } } @@ -253,7 +254,7 @@ int32_t schLaunchTasksInFlowCtrlListImpl(SSchJob *pJob, SSchFlowControl *ctrl) { --i; --taskNum; } - + _return: SCH_UNLOCK(SCH_WRITE, &ctrl->lock); @@ -261,11 +262,10 @@ _return: if (code) { code = schProcessOnTaskFailure(pJob, pTask, code); } - + SCH_RET(code); } - int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { if (!SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { return TSDB_CODE_SUCCESS; @@ -274,17 +274,16 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_RET(schDecTaskFlowQuota(pJob, pTask)); SEp *ep = SCH_GET_CUR_EP(&pTask->plan->execNode); - + SSchFlowControl *ctrl = (SSchFlowControl *)taosHashGet(pJob->flowCtrl, ep, sizeof(SEp)); if (NULL == ctrl) { SCH_TASK_ELOG("taosHashGet node from flowCtrl failed, fqdn:%s, port:%d", ep->fqdn, ep->port); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - - int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl);; - SCH_ERR_RET(code); - - return code; // to avoid compiler error -} + int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl); + ; + SCH_ERR_RET(code); + return code; // to avoid compiler error +} diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 69495c8b7aa0901807ed81a146418f0c6b6264db..bb8451ba37bf9dbc79e762f421cde624b440b9f7 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -52,9 +52,8 @@ _return: bool schJobDone(SSchJob *pJob) { int8_t status = SCH_GET_JOB_STATUS(pJob); - - return (status == JOB_TASK_STATUS_FAIL || status == JOB_TASK_STATUS_DROP || - status == JOB_TASK_STATUS_SUCC); + + return (status == JOB_TASK_STATUS_FAIL || status == JOB_TASK_STATUS_DROP || status == JOB_TASK_STATUS_SUCC); } FORCE_INLINE bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus) { @@ -221,7 +220,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - SCH_TASK_DLOG("parents info, the %d parent TID 0x%" PRIx64, n, (*parentTask)->taskId); + SCH_TASK_DLOG("parents info, the %d parent TID 0x%" PRIx64, n, (*parentTask)->taskId); } SCH_TASK_DLOG("level:%d, parentNum:%d, childNum:%d", i, parentNum, childNum); @@ -235,7 +234,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - SSchTask* pTask = taosArrayGet(pLevel->subTasks, 0); + SSchTask *pTask = taosArrayGet(pLevel->subTasks, 0); if (SUBPLAN_TYPE_MODIFY != pTask->plan->subplanType) { pJob->attr.needFetch = true; } @@ -244,7 +243,6 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { return TSDB_CODE_SUCCESS; } - int32_t schAppendJobDataSrc(SSchJob *pJob, SSchTask *pTask) { if (!SCH_IS_DATA_BIND_QRY_TASK(pTask)) { return TSDB_CODE_SUCCESS; @@ -255,7 +253,6 @@ int32_t schAppendJobDataSrc(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_SUCCESS; } - int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { int32_t code = 0; pJob->queryId = pDag->queryId; @@ -365,7 +362,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_ERR_JRET(schBuildTaskRalation(pJob, planToTask)); _return: - + if (planToTask) { taosHashCleanup(planToTask); } @@ -373,8 +370,7 @@ _return: SCH_RET(code); } - -int32_t schDumpJobExecRes(SSchJob* pJob, SExecResult* pRes) { +int32_t schDumpJobExecRes(SSchJob *pJob, SExecResult *pRes) { pRes->code = atomic_load_32(&pJob->errCode); pRes->numOfRows = pJob->resNumOfRows; pRes->res = pJob->execRes.res; @@ -387,13 +383,13 @@ int32_t schDumpJobExecRes(SSchJob* pJob, SExecResult* pRes) { return TSDB_CODE_SUCCESS; } -int32_t schDumpJobFetchRes(SSchJob* pJob, void** pData) { +int32_t schDumpJobFetchRes(SSchJob *pJob, void **pData) { int32_t code = 0; - + SCH_LOCK(SCH_WRITE, &pJob->resLock); pJob->fetched = true; - + if (pJob->fetchRes && ((SRetrieveTableRsp *)pJob->fetchRes)->completed) { SCH_ERR_JRET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_SUCC, NULL)); } @@ -422,12 +418,12 @@ int32_t schDumpJobFetchRes(SSchJob* pJob, void** pData) { _return: SCH_UNLOCK(SCH_WRITE, &pJob->resLock); - + return code; } -int32_t schNotifyUserExecRes(SSchJob* pJob) { - SExecResult* pRes = taosMemoryCalloc(1, sizeof(SExecResult)); +int32_t schNotifyUserExecRes(SSchJob *pJob) { + SExecResult *pRes = taosMemoryCalloc(1, sizeof(SExecResult)); if (pRes) { schDumpJobExecRes(pJob, pRes); } @@ -439,9 +435,9 @@ int32_t schNotifyUserExecRes(SSchJob* pJob) { return TSDB_CODE_SUCCESS; } -int32_t schNotifyUserFetchRes(SSchJob* pJob) { - void* pRes = NULL; - +int32_t schNotifyUserFetchRes(SSchJob *pJob) { + void *pRes = NULL; + schDumpJobFetchRes(pJob, &pRes); SCH_JOB_DLOG("sch start to invoke fetch cb, code: %s", tstrerror(pJob->errCode)); @@ -453,17 +449,17 @@ int32_t schNotifyUserFetchRes(SSchJob* pJob) { void schPostJobRes(SSchJob *pJob, SCH_OP_TYPE op) { SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock); - + if (SCH_OP_NULL == pJob->opStatus.op) { SCH_JOB_DLOG("job not in any operation, no need to post job res, status:%s", jobTaskStatusStr(pJob->status)); goto _return; } - + if (op && pJob->opStatus.op != op) { SCH_JOB_ELOG("job in operation %s mis-match with expected %s", schGetOpStr(pJob->opStatus.op), schGetOpStr(op)); goto _return; } - + if (SCH_JOB_IN_SYNC_OP(pJob)) { SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); tsem_post(&pJob->rspSem); @@ -487,7 +483,7 @@ _return: int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode) { schUpdateJobErrCode(pJob, errCode); - + int32_t code = atomic_load_32(&pJob->errCode); if (code) { SCH_JOB_DLOG("job failed with error %s", tstrerror(code)); @@ -507,9 +503,7 @@ int32_t schHandleJobFailure(SSchJob *pJob, int32_t errCode) { return TSDB_CODE_SCH_IGNORE_ERROR; } -int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode) { - SCH_RET(schProcessOnJobFailure(pJob, errCode)); -} +int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode) { SCH_RET(schProcessOnJobFailure(pJob, errCode)); } int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode) { if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) { @@ -520,8 +514,7 @@ int32_t schHandleJobDrop(SSchJob *pJob, int32_t errCode) { return TSDB_CODE_SCH_IGNORE_ERROR; } - -int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { +int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { if (schChkCurrentOp(pJob, SCH_OP_FETCH, -1)) { SCH_ERR_RET(schLaunchFetchTask(pJob)); } else { @@ -531,9 +524,7 @@ int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { return TSDB_CODE_SUCCESS; } -void schProcessOnDataFetched(SSchJob *pJob) { - schPostJobRes(pJob, SCH_OP_FETCH); -} +void schProcessOnDataFetched(SSchJob *pJob) { schPostJobRes(pJob, SCH_OP_FETCH); } int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRsp *pRsp) { SCH_TASK_DLOG("got explain rsp, rows:%d, complete:%d", htonl(pRsp->numOfRows), pRsp->completed); @@ -548,14 +539,13 @@ int32_t schProcessOnExplainDone(SSchJob *pJob, SSchTask *pTask, SRetrieveTableRs return TSDB_CODE_SUCCESS; } - int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { if (!SCH_IS_QUERY_JOB(pJob)) { return TSDB_CODE_SUCCESS; } SSchLevel *pLevel = pTask->level; - int32_t doneNum = atomic_add_fetch_32(&pLevel->taskDoneNum, 1); + int32_t doneNum = atomic_add_fetch_32(&pLevel->taskDoneNum, 1); if (doneNum == pLevel->taskNum) { pJob->levelIdx--; @@ -566,7 +556,7 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { if (pTask->children && taosArrayGetSize(pTask->children) > 0) { continue; } - + SCH_ERR_RET(schLaunchTask(pJob, pTask)); } } @@ -577,11 +567,11 @@ int32_t schLaunchJobLowerLevel(SSchJob *pJob, SSchTask *pTask) { int32_t schSaveJobExecRes(SSchJob *pJob, SQueryTableRsp *rsp) { if (rsp->tbFName[0]) { SCH_LOCK(SCH_WRITE, &pJob->resLock); - + if (NULL == pJob->execRes.res) { pJob->execRes.res = taosArrayInit(pJob->taskNum, sizeof(STbVerInfo)); if (NULL == pJob->execRes.res) { - SCH_UNLOCK(SCH_WRITE, &pJob->resLock); + SCH_UNLOCK(SCH_WRITE, &pJob->resLock); SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } @@ -610,7 +600,6 @@ int32_t schGetTaskInJob(SSchJob *pJob, uint64_t taskId, SSchTask **pTask) { return TSDB_CODE_SUCCESS; } - int32_t schLaunchJob(SSchJob *pJob) { if (EXPLAIN_MODE_STATIC == pJob->attr.explainMode) { SCH_ERR_RET(qExecStaticExplain(pJob->pDag, (SRetrieveTableRsp **)&pJob->fetchRes)); @@ -623,11 +612,10 @@ int32_t schLaunchJob(SSchJob *pJob) { return TSDB_CODE_SUCCESS; } - void schDropJobAllTasks(SSchJob *pJob) { schDropTaskInHashList(pJob, pJob->execTasks); -// schDropTaskInHashList(pJob, pJob->succTasks); -// schDropTaskInHashList(pJob, pJob->failTasks); + // schDropTaskInHashList(pJob, pJob->succTasks); + // schDropTaskInHashList(pJob, pJob->failTasks); } void schFreeJobImpl(void *job) { @@ -659,10 +647,10 @@ void schFreeJobImpl(void *job) { schFreeFlowCtrl(pJob); taosHashCleanup(pJob->execTasks); -// taosHashCleanup(pJob->failTasks); -// taosHashCleanup(pJob->succTasks); + // taosHashCleanup(pJob->failTasks); + // taosHashCleanup(pJob->succTasks); taosHashCleanup(pJob->taskList); - + taosArrayDestroy(pJob->levels); taosArrayDestroy(pJob->nodeList); taosArrayDestroy(pJob->dataSrcTasks); @@ -688,19 +676,19 @@ void schFreeJobImpl(void *job) { } int32_t schJobFetchRows(SSchJob *pJob) { - int32_t code = 0; + int32_t code = 0; if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { SCH_ERR_RET(schLaunchFetchTask(pJob)); - + if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) { SCH_JOB_DLOG("sync wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); tsem_wait(&pJob->rspSem); - SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes)); + SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes)); } } else { if (schChkCurrentOp(pJob, SCH_OP_FETCH, true)) { - SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes)); + SCH_RET(schDumpJobFetchRes(pJob, pJob->userRes.fetchRes)); } else { schPostJobRes(pJob, SCH_OP_FETCH); } @@ -736,9 +724,9 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { } else { pJob->nodeList = taosArrayDup(pReq->pNodeList); } - - pJob->taskList = - taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); + + pJob->taskList = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, + HASH_ENTRY_LOCK); if (NULL == pJob->taskList) { SCH_JOB_ELOG("taosHashInit %d taskList failed", pReq->pDag->numOfSubplans); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -750,8 +738,8 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { SCH_ERR_JRET(qExecExplainBegin(pReq->pDag, &pJob->explainCtx, pReq->startTs)); } - pJob->execTasks = - taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); + pJob->execTasks = taosHashInit(pReq->pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, + HASH_ENTRY_LOCK); if (NULL == pJob->execTasks) { SCH_JOB_ELOG("taosHashInit %d execTasks failed", pReq->pDag->numOfSubplans); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -769,7 +757,7 @@ int32_t schInitJob(int64_t *pJobId, SSchedulerReq *pReq) { *pJobId = pJob->refId; - SCH_JOB_DLOG("job refId:0x%" PRIx64" created", pJob->refId); + SCH_JOB_DLOG("job refId:0x%" PRIx64 " created", pJob->refId); return TSDB_CODE_SUCCESS; @@ -782,31 +770,31 @@ _return: } else { taosRemoveRef(schMgmt.jobRef, pJob->refId); } - + SCH_RET(code); } int32_t schExecJob(SSchJob *pJob, SSchedulerReq *pReq) { int32_t code = 0; - qDebug("QID:0x%" PRIx64 " sch job refId 0x%"PRIx64 " started", pReq->pDag->queryId, pJob->refId); + qDebug("QID:0x%" PRIx64 " sch job refId 0x%" PRIx64 " started", pReq->pDag->queryId, pJob->refId); SCH_ERR_RET(schLaunchJob(pJob)); - + if (pReq->syncReq) { SCH_JOB_DLOG("sync wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); tsem_wait(&pJob->rspSem); } SCH_JOB_DLOG("job exec done, job status:%s, jobId:0x%" PRIx64, SCH_GET_JOB_STATUS_STR(pJob), pJob->refId); - + return TSDB_CODE_SUCCESS; } -void schDirectPostJobRes(SSchedulerReq* pReq, int32_t errCode) { +void schDirectPostJobRes(SSchedulerReq *pReq, int32_t errCode) { if (NULL == pReq || pReq->syncReq) { return; } - + if (pReq->execFp) { (*pReq->execFp)(NULL, pReq->cbParam, errCode); } else if (pReq->fetchFp) { @@ -827,16 +815,17 @@ bool schChkCurrentOp(SSchJob *pJob, int32_t op, int8_t sync) { return r; } -void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode) { +void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq, int32_t errCode) { int32_t op = 0; - + switch (type) { case SCH_OP_EXEC: if (pReq && pReq->syncReq) { SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock); op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL); if (SCH_OP_NULL == op || op != type) { - SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status)); + SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), + jobTaskStatusStr(pJob->status)); } SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); schDumpJobExecRes(pJob, pReq->pExecRes); @@ -847,7 +836,8 @@ void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock); op = atomic_val_compare_exchange_32(&pJob->opStatus.op, type, SCH_OP_NULL); if (SCH_OP_NULL == op || op != type) { - SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), jobTaskStatusStr(pJob->status)); + SCH_JOB_ELOG("job not in %s operation, op:%s, status:%s", schGetOpStr(type), schGetOpStr(op), + jobTaskStatusStr(pJob->status)); } SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); } @@ -866,10 +856,10 @@ void schProcessOnOpEnd(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int SCH_JOB_DLOG("job end %s operation with code %s", schGetOpStr(type), tstrerror(errCode)); } -int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq) { +int32_t schProcessOnOpBegin(SSchJob *pJob, SCH_OP_TYPE type, SSchedulerReq *pReq) { int32_t code = 0; - int8_t status = SCH_GET_JOB_STATUS(pJob); - + int8_t status = SCH_GET_JOB_STATUS(pJob); + switch (type) { case SCH_OP_EXEC: SCH_LOCK(SCH_WRITE, &pJob->opStatus.lock); @@ -879,9 +869,9 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR); SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); } - + SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op)); - + pJob->opStatus.syncReq = pReq->syncReq; SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); break; @@ -893,16 +883,16 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq schDirectPostJobRes(pReq, TSDB_CODE_TSC_APP_ERROR); SCH_ERR_RET(TSDB_CODE_TSC_APP_ERROR); } - + SCH_JOB_DLOG("job start %s operation", schGetOpStr(pJob->opStatus.op)); - + pJob->userRes.fetchRes = pReq->pFetchRes; pJob->userRes.fetchFp = pReq->fetchFp; pJob->userRes.cbParam = pReq->cbParam; - + pJob->opStatus.syncReq = pReq->syncReq; SCH_UNLOCK(SCH_WRITE, &pJob->opStatus.lock); - + if (!SCH_JOB_NEED_FETCH(pJob)) { SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob)); SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); @@ -912,7 +902,7 @@ int32_t schProcessOnOpBegin(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + break; case SCH_OP_GET_STATUS: if (pJob->status < JOB_TASK_STATUS_INIT || pJob->levelNum <= 0 || NULL == pJob->levels) { @@ -941,23 +931,23 @@ void schProcessOnCbEnd(SSchJob *pJob, SSchTask *pTask, int32_t errCode) { if (errCode) { schHandleJobFailure(pJob, errCode); } - + if (pJob) { schReleaseJob(pJob->refId); } } -int32_t schProcessOnCbBegin(SSchJob** job, SSchTask** task, uint64_t qId, int64_t rId, uint64_t tId) { +int32_t schProcessOnCbBegin(SSchJob **job, SSchTask **task, uint64_t qId, int64_t rId, uint64_t tId) { int32_t code = 0; - int8_t status = 0; + int8_t status = 0; SSchTask *pTask = NULL; - SSchJob *pJob = schAcquireJob(rId); + SSchJob *pJob = schAcquireJob(rId); if (NULL == pJob) { qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "job no exist, may be dropped, refId:0x%" PRIx64, qId, tId, rId); SCH_ERR_RET(TSDB_CODE_QRY_JOB_NOT_EXIST); } - + if (schJobNeedToStop(pJob, &status)) { SCH_TASK_DLOG("will not do further processing cause of job status %s", jobTaskStatusStr(status)); SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); @@ -980,9 +970,6 @@ _return: if (pJob) { schReleaseJob(rId); } - + SCH_RET(code); } - - - diff --git a/source/libs/scheduler/src/schStatus.c b/source/libs/scheduler/src/schStatus.c index 64cda573f1fa8bd022a548787151b2b9fd64d44f..66d58c95d1c3a36938fb0b5b1fa420c558a33e4a 100644 --- a/source/libs/scheduler/src/schStatus.c +++ b/source/libs/scheduler/src/schStatus.c @@ -29,25 +29,25 @@ int32_t schSwitchJobStatus(SSchJob* pJob, int32_t status, void* param) { case JOB_TASK_STATUS_INIT: break; case JOB_TASK_STATUS_EXEC: - SCH_ERR_JRET(schExecJob(pJob, (SSchedulerReq*)param)); + SCH_ERR_JRET(schExecJob(pJob, (SSchedulerReq*)param)); break; case JOB_TASK_STATUS_PART_SUCC: SCH_ERR_JRET(schProcessOnJobPartialSuccess(pJob)); break; case JOB_TASK_STATUS_SUCC: break; - case JOB_TASK_STATUS_FAIL: + case JOB_TASK_STATUS_FAIL: SCH_RET(schProcessOnJobFailure(pJob, (param ? *(int32_t*)param : 0))); break; case JOB_TASK_STATUS_DROP: schProcessOnJobDropped(pJob, *(int32_t*)param); - + if (taosRemoveRef(schMgmt.jobRef, pJob->refId)) { SCH_JOB_ELOG("remove job from job list failed, refId:0x%" PRIx64, pJob->refId); } else { SCH_JOB_DLOG("job removed from jobRef list, refId:0x%" PRIx64, pJob->refId); } - break; + break; default: { SCH_JOB_ELOG("unknown job status %d", status); SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); @@ -62,7 +62,7 @@ _return: } int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SSchedulerReq* pReq) { - SSchJob *pJob = schAcquireJob(jobId); + SSchJob* pJob = schAcquireJob(jobId); if (NULL == pJob) { qWarn("Acquire sch job failed, may be dropped, jobId:0x%" PRIx64, jobId); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); @@ -75,12 +75,12 @@ int32_t schHandleOpBeginEvent(int64_t jobId, SSchJob** job, SCH_OP_TYPE type, SS int32_t schHandleOpEndEvent(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq, int32_t errCode) { int32_t code = errCode; - + if (NULL == pJob) { schDirectPostJobRes(pReq, errCode); SCH_RET(code); } - + schProcessOnOpEnd(pJob, type, pReq, errCode); if (TSDB_CODE_SCH_IGNORE_ERROR == errCode) { @@ -91,5 +91,3 @@ int32_t schHandleOpEndEvent(SSchJob* pJob, SCH_OP_TYPE type, SSchedulerReq* pReq return code; } - - diff --git a/source/libs/scheduler/src/schTask.c b/source/libs/scheduler/src/schTask.c index b6f96a188e4fc06f365b6ccf527c3587abb959af..2678a652a9d0d0cad2b274f226350d5740dc0016 100644 --- a/source/libs/scheduler/src/schTask.c +++ b/source/libs/scheduler/src/schTask.c @@ -16,12 +16,12 @@ #include "catalog.h" #include "command.h" #include "query.h" +#include "qworker.h" #include "schInt.h" +#include "tglobal.h" #include "tmsg.h" #include "tref.h" #include "trpc.h" -#include "qworker.h" -#include "tglobal.h" void schFreeTask(SSchJob *pJob, SSchTask *pTask) { schDeregisterTaskHb(pJob, pTask); @@ -94,7 +94,7 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_LOCAL_EXEC_TASK(pJob, pTask)) { return TSDB_CODE_SUCCESS; } - + SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); if (NULL == addr) { SCH_TASK_ELOG("taosArrayGet candidate addr failed, idx:%d, size:%d", pTask->candidateIdx, @@ -162,14 +162,15 @@ int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, v if (dropExecNode) { SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execId)); } - + schUpdateTaskExecNode(pJob, pTask, handle, execId); 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); SCH_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR); } - + SCH_SET_TASK_HANDLE(pTask, handle); return TSDB_CODE_SUCCESS; @@ -837,17 +838,18 @@ int32_t schHandleExplainRes(SArray *pExplainRes) { goto _return; } - SSchTask *pTask = NULL; - SSchJob *pJob = NULL; + SSchTask *pTask = NULL; + SSchJob *pJob = NULL; for (int32_t i = 0; i < resNum; ++i) { - SExplainLocalRsp* localRsp = taosArrayGet(pExplainRes, i); + SExplainLocalRsp *localRsp = taosArrayGet(pExplainRes, i); qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ", begin to handle LOCAL explain rsp msg", localRsp->qId, localRsp->tId); pJob = schAcquireJob(localRsp->rId); if (NULL == pJob) { - qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "job no exist, may be dropped, refId:0x%" PRIx64, localRsp->qId, localRsp->tId, localRsp->rId); + qWarn("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "job no exist, may be dropped, refId:0x%" PRIx64, localRsp->qId, + localRsp->tId, localRsp->rId); SCH_ERR_JRET(TSDB_CODE_QRY_JOB_NOT_EXIST); } @@ -857,16 +859,17 @@ int32_t schHandleExplainRes(SArray *pExplainRes) { schReleaseJob(pJob->refId); SCH_ERR_JRET(TSDB_CODE_SCH_IGNORE_ERROR); } - + code = schGetTaskInJob(pJob, localRsp->tId, &pTask); if (TSDB_CODE_SUCCESS == code) { code = schProcessExplainRsp(pJob, pTask, &localRsp->rsp); } - + schReleaseJob(pJob->refId); - qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ", end to handle LOCAL explain rsp msg, code:%x", localRsp->qId, localRsp->tId, code); + qDebug("QID:0x%" PRIx64 ",TID:0x%" PRIx64 ", end to handle LOCAL explain rsp msg, code:%x", localRsp->qId, + localRsp->tId, code); SCH_ERR_JRET(code); @@ -879,7 +882,7 @@ int32_t schHandleExplainRes(SArray *pExplainRes) { _return: for (int32_t i = 0; i < resNum; ++i) { - SExplainLocalRsp* localRsp = taosArrayGet(pExplainRes, i); + SExplainLocalRsp *localRsp = taosArrayGet(pExplainRes, i); tFreeSExplainRsp(&localRsp->rsp); } @@ -890,7 +893,7 @@ _return: int32_t schLaunchRemoteTask(SSchJob *pJob, SSchTask *pTask) { SSubplan *plan = pTask->plan; - int32_t code = 0; + int32_t code = 0; if (NULL == pTask->msg) { // TODO add more detailed reason for failure code = qSubPlanToMsg(plan, &pTask->msg, &pTask->msgLen); @@ -899,7 +902,7 @@ int32_t schLaunchRemoteTask(SSchJob *pJob, SSchTask *pTask) { pTask->msgLen); SCH_ERR_RET(code); } else if (tsQueryPlannerTrace) { - char *msg = NULL; + char *msg = NULL; int32_t msgLen = 0; qSubPlanToString(plan, &msg, &msgLen); SCH_TASK_DLOGL("physical plan len:%d, %s", msgLen, msg); @@ -912,18 +915,18 @@ int32_t schLaunchRemoteTask(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_QUERY_JOB(pJob)) { SCH_ERR_RET(schEnsureHbConnection(pJob, pTask)); } - + SCH_RET(schBuildAndSendMsg(pJob, pTask, NULL, plan->msgType)); } int32_t schLaunchLocalTask(SSchJob *pJob, SSchTask *pTask) { - //SCH_ERR_JRET(schSetTaskCandidateAddrs(pJob, pTask)); + // SCH_ERR_JRET(schSetTaskCandidateAddrs(pJob, pTask)); if (NULL == schMgmt.queryMgmt) { SCH_ERR_RET(qWorkerInit(NODE_TYPE_CLIENT, CLIENT_HANDLE, (void **)&schMgmt.queryMgmt, NULL)); } SArray *explainRes = NULL; - SQWMsg qwMsg = {0}; + SQWMsg qwMsg = {0}; qwMsg.msgInfo.taskType = TASK_TYPE_TEMP; qwMsg.msgInfo.explain = SCH_IS_EXPLAIN_JOB(pJob); qwMsg.msgInfo.needFetch = SCH_TASK_NEED_FETCH(pTask); @@ -934,8 +937,9 @@ int32_t schLaunchLocalTask(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_EXPLAIN_JOB(pJob)) { explainRes = taosArrayInit(pJob->taskNum, sizeof(SExplainLocalRsp)); } - - SCH_ERR_RET(qWorkerProcessLocalQuery(schMgmt.queryMgmt, schMgmt.sId, pJob->queryId, pTask->taskId, pJob->refId, pTask->execId, &qwMsg, explainRes)); + + SCH_ERR_RET(qWorkerProcessLocalQuery(schMgmt.queryMgmt, schMgmt.sId, pJob->queryId, pTask->taskId, pJob->refId, + pTask->execId, &qwMsg, explainRes)); if (SCH_IS_EXPLAIN_JOB(pJob)) { SCH_ERR_RET(schHandleExplainRes(explainRes)); @@ -958,17 +962,17 @@ int32_t schLaunchTaskImpl(void *param) { if (pCtx->asyncLaunch) { SCH_LOCK_TASK(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++; pTask->retryTimes++; pTask->waitRetry = false; - SCH_TASK_DLOG("start to launch %s task, execId %d, retry %d", SCH_IS_LOCAL_EXEC_TASK(pJob, pTask) ? "LOCAL" : "REMOTE", - pTask->execId, pTask->retryTimes); + SCH_TASK_DLOG("start to launch %s task, execId %d, retry %d", + SCH_IS_LOCAL_EXEC_TASK(pJob, pTask) ? "LOCAL" : "REMOTE", pTask->execId, pTask->retryTimes); SCH_LOG_TASK_START_TS(pTask); @@ -1086,19 +1090,20 @@ int32_t schExecRemoteFetch(SSchJob *pJob, SSchTask *pTask) { } int32_t schExecLocalFetch(SSchJob *pJob, SSchTask *pTask) { - void *pRsp = NULL; + void *pRsp = NULL; SArray *explainRes = NULL; if (SCH_IS_EXPLAIN_JOB(pJob)) { explainRes = taosArrayInit(pJob->taskNum, sizeof(SExplainLocalRsp)); } - SCH_ERR_RET(qWorkerProcessLocalFetch(schMgmt.queryMgmt, schMgmt.sId, pJob->queryId, pTask->taskId, pJob->refId, pTask->execId, &pRsp, explainRes)); + SCH_ERR_RET(qWorkerProcessLocalFetch(schMgmt.queryMgmt, schMgmt.sId, pJob->queryId, pTask->taskId, pJob->refId, + pTask->execId, &pRsp, explainRes)); if (SCH_IS_EXPLAIN_JOB(pJob)) { SCH_ERR_RET(schHandleExplainRes(explainRes)); } - + SCH_ERR_RET(schProcessFetchRsp(pJob, pTask, pRsp, TSDB_CODE_SUCCESS)); return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index 6f12780ff932a01a3303a175ec0d2be45b0875a2..7099dbb2c0c20682ee59bb4b3b0275c2684dedca 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -21,21 +21,21 @@ #include "tref.h" #include "trpc.h" -FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { - qDebug("sch acquire jobId:0x%"PRIx64, refId); - return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); +FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { + qDebug("sch acquire jobId:0x%" PRIx64, refId); + return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); } -FORCE_INLINE int32_t schReleaseJob(int64_t refId) { +FORCE_INLINE int32_t schReleaseJob(int64_t refId) { if (0 == refId) { return TSDB_CODE_SUCCESS; } - - qDebug("sch release jobId:0x%"PRIx64, refId); - return taosReleaseRef(schMgmt.jobRef, refId); + + qDebug("sch release jobId:0x%" PRIx64, refId); + return taosReleaseRef(schMgmt.jobRef, refId); } -char* schGetOpStr(SCH_OP_TYPE type) { +char *schGetOpStr(SCH_OP_TYPE type) { switch (type) { case SCH_OP_NULL: return "NULL"; @@ -53,28 +53,28 @@ char* schGetOpStr(SCH_OP_TYPE type) { void schFreeHbTrans(SSchHbTrans *pTrans) { rpcReleaseHandle(pTrans->trans.pHandle, TAOS_CONN_CLIENT); - schFreeRpcCtx(&pTrans->rpcCtx); + schFreeRpcCtx(&pTrans->rpcCtx); } -void schCleanClusterHb(void* pTrans) { +void schCleanClusterHb(void *pTrans) { SCH_LOCK(SCH_WRITE, &schMgmt.hbLock); SSchHbTrans *hb = taosHashIterate(schMgmt.hbConnections, NULL); while (hb) { if (hb->trans.pTrans == pTrans) { - SQueryNodeEpId* pEpId = taosHashGetKey(hb, NULL); + SQueryNodeEpId *pEpId = taosHashGetKey(hb, NULL); schFreeHbTrans(hb); taosHashRemove(schMgmt.hbConnections, pEpId, sizeof(SQueryNodeEpId)); } - + hb = taosHashIterate(schMgmt.hbConnections, hb); } - + SCH_UNLOCK(SCH_WRITE, &schMgmt.hbLock); } int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId) { - int32_t code = 0; + int32_t code = 0; SCH_LOCK(SCH_WRITE, &schMgmt.hbLock); SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId)); @@ -94,7 +94,6 @@ int32_t schRemoveHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *ep return TSDB_CODE_SUCCESS; } - int32_t schAddHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId *epId, bool *exist) { int32_t code = 0; SSchHbTrans hb = {0}; @@ -155,13 +154,13 @@ void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask) { if (!pTask->registerdHb) { return; } - + SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); SQueryNodeEpId epId = {0}; epId.nodeId = addr->nodeId; - SEp* pEp = SCH_GET_CUR_EP(addr); + SEp *pEp = SCH_GET_CUR_EP(addr); strcpy(epId.ep.fqdn, pEp->fqdn); epId.ep.port = pEp->port; @@ -180,24 +179,22 @@ void schDeregisterTaskHb(SSchJob *pJob, SSchTask *pTask) { } else { SCH_UNLOCK(SCH_READ, &schMgmt.hbLock); } - + pTask->registerdHb = false; } - - int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask) { SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); SQueryNodeEpId epId = {0}; epId.nodeId = addr->nodeId; - SEp* pEp = SCH_GET_CUR_EP(addr); + SEp *pEp = SCH_GET_CUR_EP(addr); strcpy(epId.ep.fqdn, pEp->fqdn); epId.ep.port = pEp->port; SCH_ERR_RET(schRegisterHbConnection(pJob, pTask, &epId)); - + pTask->registerdHb = true; return TSDB_CODE_SUCCESS; @@ -226,7 +223,6 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) { return TSDB_CODE_SUCCESS; } - void schCloseJobRef(void) { if (!atomic_load_8((int8_t *)&schMgmt.exit)) { return; @@ -242,7 +238,7 @@ uint64_t schGenTaskId(void) { return atomic_add_fetch_64(&schMgmt.taskId, 1); } uint64_t schGenUUID(void) { static uint64_t hashId = 0; - static int32_t requestSerialId = 0; + static int32_t requestSerialId = 0; if (hashId == 0) { char uid[64] = {0}; @@ -254,15 +250,14 @@ uint64_t schGenUUID(void) { } } - int64_t ts = taosGetTimestampMs(); - uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&requestSerialId, 1); + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&requestSerialId, 1); uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } - void schFreeRpcCtxVal(const void *arg) { if (NULL == arg) { return; @@ -307,5 +302,3 @@ int32_t schGetTaskFromList(SHashObj *pTaskList, uint64_t taskId, SSchTask **pTas return TSDB_CODE_SUCCESS; } - - diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 0ccaef385744738969973b19a38182cbac4399d9..813a11c056c17acf87a75871827bf4e637348b86 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -14,10 +14,10 @@ */ #include "query.h" +#include "qworker.h" #include "schInt.h" #include "tmsg.h" #include "tref.h" -#include "qworker.h" SSchedulerMgmt schMgmt = { .jobRef = -1, @@ -35,7 +35,7 @@ int32_t schedulerInit() { schMgmt.cfg.enableReSchedule = true; qDebug("schedule policy init to %d", schMgmt.cfg.schPolicy); - + schMgmt.jobRef = taosOpenRef(schMgmt.cfg.maxJobNum, schFreeJobImpl); if (schMgmt.jobRef < 0) { qError("init schduler jobRef failed, num:%u", schMgmt.cfg.maxJobNum); @@ -61,7 +61,7 @@ int32_t schedulerInit() { int32_t schedulerExecJob(SSchedulerReq *pReq, int64_t *pJobId) { qDebug("scheduler %s exec job start", pReq->syncReq ? "SYNC" : "ASYNC"); - int32_t code = 0; + int32_t code = 0; SSchJob *pJob = NULL; SCH_ERR_JRET(schInitJob(pJobId, pReq)); @@ -73,7 +73,7 @@ int32_t schedulerExecJob(SSchedulerReq *pReq, int64_t *pJobId) { SCH_ERR_JRET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_EXEC, pReq)); _return: - + SCH_RET(schHandleOpEndEvent(pJob, SCH_OP_EXEC, pReq, code)); } @@ -144,7 +144,7 @@ int32_t schedulerEnableReSchedule(bool enableResche) { return TSDB_CODE_SUCCESS; } -void schedulerFreeJob(int64_t* jobId, int32_t errCode) { +void schedulerFreeJob(int64_t *jobId, int32_t errCode) { if (0 == *jobId) { return; } @@ -158,7 +158,7 @@ void schedulerFreeJob(int64_t* jobId, int32_t errCode) { SCH_JOB_DLOG("start to free job 0x%" PRIx64 ", errCode:0x%x", *jobId, errCode); schHandleJobDrop(pJob, errCode); - + schReleaseJob(*jobId); *jobId = 0; } diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index ca2122ed8f433c4b8dd70eb120e0eba972dda9fe..97e14b617c1304f7b3003e2f77e9bfee79f05d0b 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -30,15 +30,12 @@ #endif #include "os.h" -#include "tglobal.h" -#include "taos.h" -#include "tdef.h" -#include "tvariant.h" #include "catalog.h" #include "scheduler.h" #include "taos.h" #include "tdatablock.h" #include "tdef.h" +#include "tglobal.h" #include "trpc.h" #include "tvariant.h" @@ -56,8 +53,9 @@ namespace { -extern "C" int32_t schHandleResponseMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode); -extern "C" int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, int32_t rspCode); +extern "C" int32_t schHandleResponseMsg(SSchJob *job, SSchTask *task, int32_t msgType, char *msg, int32_t msgSize, + int32_t rspCode); +extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode); int64_t insertJobRefId = 0; int64_t queryJobRefId = 0; @@ -66,16 +64,15 @@ uint64_t schtMergeTemplateId = 0x4; uint64_t schtFetchTaskId = 0; uint64_t schtQueryId = 1; -bool schtTestStop = false; -bool schtTestDeadLoop = false; +bool schtTestStop = false; +bool schtTestDeadLoop = false; int32_t schtTestMTRunSec = 10; int32_t schtTestPrintNum = 1000; int32_t schtStartFetch = 0; - void schtInitLogFile() { - const char *defaultLogFileNamePrefix = "taoslog"; - const int32_t maxLogFileNum = 10; + const char *defaultLogFileNamePrefix = "taoslog"; + const int32_t maxLogFileNum = 10; tsAsyncLog = 0; qDebugFlag = 159; @@ -84,24 +81,22 @@ void schtInitLogFile() { if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); } - } -void schtQueryCb(SExecResult* pResult, void* param, int32_t code) { +void schtQueryCb(SExecResult *pResult, void *param, int32_t code) { assert(TSDB_CODE_SUCCESS == code); - *(int32_t*)param = 1; + *(int32_t *)param = 1; } - void schtBuildQueryDag(SQueryPlan *dag) { uint64_t qId = schtQueryId; - + dag->queryId = qId; dag->numOfSubplans = 2; dag->pSubplans = nodesMakeList(); - SNodeListNode *scan = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - SNodeListNode *merge = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - + SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SSubplan *scanPlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); SSubplan *mergePlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); @@ -117,7 +112,7 @@ void schtBuildQueryDag(SQueryPlan *dag) { scanPlan->pChildren = NULL; scanPlan->level = 1; scanPlan->pParents = nodesMakeList(); - scanPlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); + scanPlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); scanPlan->msgType = TDMT_SCH_QUERY; mergePlan->id.queryId = qId; @@ -129,32 +124,32 @@ void schtBuildQueryDag(SQueryPlan *dag) { mergePlan->pChildren = nodesMakeList(); mergePlan->pParents = NULL; - mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); + mergePlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); mergePlan->msgType = TDMT_SCH_QUERY; merge->pNodeList = nodesMakeList(); scan->pNodeList = nodesMakeList(); - nodesListAppend(merge->pNodeList, (SNode*)mergePlan); - nodesListAppend(scan->pNodeList, (SNode*)scanPlan); + nodesListAppend(merge->pNodeList, (SNode *)mergePlan); + nodesListAppend(scan->pNodeList, (SNode *)scanPlan); - nodesListAppend(mergePlan->pChildren, (SNode*)scanPlan); - nodesListAppend(scanPlan->pParents, (SNode*)mergePlan); + nodesListAppend(mergePlan->pChildren, (SNode *)scanPlan); + nodesListAppend(scanPlan->pParents, (SNode *)mergePlan); - nodesListAppend(dag->pSubplans, (SNode*)merge); - nodesListAppend(dag->pSubplans, (SNode*)scan); + nodesListAppend(dag->pSubplans, (SNode *)merge); + nodesListAppend(dag->pSubplans, (SNode *)scan); } void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { uint64_t qId = schtQueryId; - int32_t scanPlanNum = 20; - + int32_t scanPlanNum = 20; + dag->queryId = qId; dag->numOfSubplans = 2; dag->pSubplans = nodesMakeList(); - SNodeListNode *scan = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - SNodeListNode *merge = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - + SNodeListNode *scan = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SNodeListNode *merge = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SSubplan *scanPlan = (SSubplan *)taosMemoryCalloc(scanPlanNum, sizeof(SSubplan)); SSubplan *mergePlan = (SSubplan *)taosMemoryCalloc(1, sizeof(SSubplan)); @@ -180,13 +175,13 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { scanPlan[i].pChildren = NULL; scanPlan[i].level = 1; scanPlan[i].pParents = nodesMakeList(); - scanPlan[i].pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); + scanPlan[i].pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); scanPlan[i].msgType = TDMT_SCH_QUERY; - nodesListAppend(scanPlan[i].pParents, (SNode*)mergePlan); - nodesListAppend(mergePlan->pChildren, (SNode*)(scanPlan + i)); + nodesListAppend(scanPlan[i].pParents, (SNode *)mergePlan); + nodesListAppend(mergePlan->pChildren, (SNode *)(scanPlan + i)); - nodesListAppend(scan->pNodeList, (SNode*)(scanPlan + i)); + nodesListAppend(scan->pNodeList, (SNode *)(scanPlan + i)); } mergePlan->id.queryId = qId; @@ -197,29 +192,25 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) { mergePlan->execNode.epSet.numOfEps = 0; mergePlan->pParents = NULL; - mergePlan->pNode = (SPhysiNode*)taosMemoryCalloc(1, sizeof(SPhysiNode)); + mergePlan->pNode = (SPhysiNode *)taosMemoryCalloc(1, sizeof(SPhysiNode)); mergePlan->msgType = TDMT_SCH_QUERY; - nodesListAppend(merge->pNodeList, (SNode*)mergePlan); - - nodesListAppend(dag->pSubplans, (SNode*)merge); - nodesListAppend(dag->pSubplans, (SNode*)scan); -} - - -void schtFreeQueryDag(SQueryPlan *dag) { + nodesListAppend(merge->pNodeList, (SNode *)mergePlan); + nodesListAppend(dag->pSubplans, (SNode *)merge); + nodesListAppend(dag->pSubplans, (SNode *)scan); } +void schtFreeQueryDag(SQueryPlan *dag) {} void schtBuildInsertDag(SQueryPlan *dag) { uint64_t qId = 0x0000000000000002; - + dag->queryId = qId; dag->numOfSubplans = 2; dag->pSubplans = nodesMakeList(); - SNodeListNode *inserta = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); - + SNodeListNode *inserta = (SNodeListNode *)nodesMakeNode(QUERY_NODE_NODE_LIST); + SSubplan *insertPlan = (SSubplan *)taosMemoryCalloc(2, sizeof(SSubplan)); insertPlan[0].id.queryId = qId; @@ -235,7 +226,7 @@ void schtBuildInsertDag(SQueryPlan *dag) { insertPlan[0].pChildren = NULL; insertPlan[0].pParents = NULL; insertPlan[0].pNode = NULL; - insertPlan[0].pDataSink = (SDataSinkNode*)taosMemoryCalloc(1, sizeof(SDataSinkNode)); + insertPlan[0].pDataSink = (SDataSinkNode *)taosMemoryCalloc(1, sizeof(SDataSinkNode)); insertPlan[0].msgType = TDMT_VND_SUBMIT; insertPlan[1].id.queryId = qId; @@ -251,48 +242,43 @@ void schtBuildInsertDag(SQueryPlan *dag) { insertPlan[1].pChildren = NULL; insertPlan[1].pParents = NULL; insertPlan[1].pNode = NULL; - insertPlan[1].pDataSink = (SDataSinkNode*)taosMemoryCalloc(1, sizeof(SDataSinkNode)); + insertPlan[1].pDataSink = (SDataSinkNode *)taosMemoryCalloc(1, sizeof(SDataSinkNode)); insertPlan[1].msgType = TDMT_VND_SUBMIT; inserta->pNodeList = nodesMakeList(); - nodesListAppend(inserta->pNodeList, (SNode*)insertPlan); + nodesListAppend(inserta->pNodeList, (SNode *)insertPlan); insertPlan += 1; - nodesListAppend(inserta->pNodeList, (SNode*)insertPlan); + nodesListAppend(inserta->pNodeList, (SNode *)insertPlan); - nodesListAppend(dag->pSubplans, (SNode*)inserta); + nodesListAppend(dag->pSubplans, (SNode *)inserta); } - -int32_t schtPlanToString(const SSubplan *subplan, char** str, int32_t* len) { +int32_t schtPlanToString(const SSubplan *subplan, char **str, int32_t *len) { *str = (char *)taosMemoryCalloc(1, 20); *len = 20; return 0; } -void schtExecNode(SSubplan* subplan, uint64_t groupId, SQueryNodeAddr* ep) { +void schtExecNode(SSubplan *subplan, uint64_t groupId, SQueryNodeAddr *ep) {} -} - -void schtRpcSendRequest(void *shandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *pRid) { - -} +void schtRpcSendRequest(void *shandle, const SEpSet *pEpSet, SRpcMsg *pMsg, int64_t *pRid) {} void schtSetPlanToString() { static Stub stub; stub.set(qSubPlanToString, schtPlanToString); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qSubPlanToString", result); #endif #ifdef LINUX - AddrAny any("libplanner.so"); - std::map result; + AddrAny any("libplanner.so"); + std::map result; any.get_global_func_addr_dynsym("^qSubPlanToString$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, schtPlanToString); } } @@ -303,16 +289,16 @@ void schtSetExecNode() { stub.set(qSetSubplanExecutionNode, schtExecNode); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("qSetSubplanExecutionNode", result); #endif #ifdef LINUX - AddrAny any("libplanner.so"); - std::map result; + AddrAny any("libplanner.so"); + std::map result; any.get_global_func_addr_dynsym("^qSetSubplanExecutionNode$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, schtExecNode); } } @@ -323,22 +309,22 @@ void schtSetRpcSendRequest() { stub.set(rpcSendRequest, schtRpcSendRequest); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("rpcSendRequest", result); #endif #ifdef LINUX - AddrAny any("libtransport.so"); - std::map result; + AddrAny any("libtransport.so"); + std::map result; any.get_global_func_addr_dynsym("^rpcSendRequest$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, schtRpcSendRequest); } } } -int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet* epSet, int64_t* pTransporterId, SMsgSendInfo* pInfo) { +int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet *epSet, int64_t *pTransporterId, SMsgSendInfo *pInfo) { if (pInfo) { taosMemoryFreeClear(pInfo->param); taosMemoryFreeClear(pInfo->msgInfo.pData); @@ -347,32 +333,30 @@ int32_t schtAsyncSendMsgToServer(void *pTransporter, SEpSet* epSet, int64_t* pTr return 0; } - void schtSetAsyncSendMsgToServer() { static Stub stub; stub.set(asyncSendMsgToServer, schtAsyncSendMsgToServer); { #ifdef WINDOWS - AddrAny any; - std::map result; + AddrAny any; + std::map result; any.get_func_addr("asyncSendMsgToServer", result); #endif #ifdef LINUX - AddrAny any("libtransport.so"); - std::map result; + AddrAny any("libtransport.so"); + std::map result; any.get_global_func_addr_dynsym("^asyncSendMsgToServer$", result); #endif - for (const auto& f : result) { + for (const auto &f : result) { stub.set(f.second, schtAsyncSendMsgToServer); } } } - void *schtSendRsp(void *param) { SSchJob *pJob = NULL; - int64_t job = 0; - int32_t code = 0; + int64_t job = 0; + int32_t code = 0; while (true) { job = *(int64_t *)param; @@ -384,7 +368,7 @@ void *schtSendRsp(void *param) { } pJob = schAcquireJob(job); - + void *pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; @@ -392,9 +376,9 @@ void *schtSendRsp(void *param) { SSubmitRsp rsp = {0}; rsp.affectedRows = 10; schHandleResponseMsg(pJob, task, TDMT_VND_SUBMIT_RSP, (char *)&rsp, sizeof(rsp), 0); - + pIter = taosHashIterate(pJob->execTasks, pIter); - } + } schReleaseJob(job); @@ -402,28 +386,27 @@ void *schtSendRsp(void *param) { } void *schtCreateFetchRspThread(void *param) { - int64_t job = *(int64_t *)param; - SSchJob* pJob = schAcquireJob(job); + int64_t job = *(int64_t *)param; + SSchJob *pJob = schAcquireJob(job); taosSsleep(1); - int32_t code = 0; + int32_t code = 0; SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, sizeof(SRetrieveTableRsp)); rsp->completed = 1; rsp->numOfRows = 10; - + code = schHandleResponseMsg(pJob, pJob->fetchTask, TDMT_SCH_FETCH_RSP, (char *)rsp, sizeof(*rsp), 0); schReleaseJob(job); - + assert(code == 0); return NULL; } - void *schtFetchRspThread(void *aa) { - SDataBuf dataBuf = {0}; - SSchTaskCallbackParam* param = NULL; + SDataBuf dataBuf = {0}; + SSchTaskCallbackParam *param = NULL; while (!schtTestStop) { if (0 == atomic_val_compare_exchange_32(&schtStartFetch, 1, 0)) { @@ -431,13 +414,13 @@ void *schtFetchRspThread(void *aa) { } taosUsleep(1); - + param = (SSchTaskCallbackParam *)taosMemoryCalloc(1, sizeof(*param)); - param->queryId = schtQueryId; + param->queryId = schtQueryId; param->taskId = schtFetchTaskId; - int32_t code = 0; + int32_t code = 0; SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, sizeof(SRetrieveTableRsp)); rsp->completed = 1; rsp->numOfRows = 10; @@ -446,7 +429,7 @@ void *schtFetchRspThread(void *aa) { dataBuf.len = sizeof(*rsp); code = schHandleCallback(param, &dataBuf, TDMT_SCH_FETCH_RSP, 0); - + assert(code == 0 || code); } return NULL; @@ -454,8 +437,8 @@ void *schtFetchRspThread(void *aa) { void schtFreeQueryJob(int32_t freeThread) { static uint32_t freeNum = 0; - int64_t job = queryJobRefId; - + int64_t job = queryJobRefId; + if (job && atomic_val_compare_exchange_64(&queryJobRefId, job, 0)) { schedulerFreeJob(&job, 0); if (freeThread) { @@ -466,31 +449,29 @@ void schtFreeQueryJob(int32_t freeThread) { } } -void* schtRunJobThread(void *aa) { - void *mockPointer = (void *)0x1; - char *clusterId = "cluster1"; - char *dbname = "1.db1"; - char *tablename = "table1"; +void *schtRunJobThread(void *aa) { + void *mockPointer = (void *)0x1; + char *clusterId = "cluster1"; + char *dbname = "1.db1"; + char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - SQueryPlan dag; + SQueryPlan dag; schtInitLogFile(); - int32_t code = schedulerInit(); assert(code == 0); - schtSetPlanToString(); schtSetExecNode(); schtSetAsyncSendMsgToServer(); - SSchJob *pJob = NULL; + SSchJob *pJob = NULL; SSchTaskCallbackParam *param = NULL; - SHashObj *execTasks = NULL; - SDataBuf dataBuf = {0}; - uint32_t jobFinished = 0; - int32_t queryDone = 0; + SHashObj *execTasks = NULL; + SDataBuf dataBuf = {0}; + uint32_t jobFinished = 0; + int32_t queryDone = 0; while (!schtTestStop) { schtBuildQueryDag(&dag); @@ -503,10 +484,10 @@ void* schtRunJobThread(void *aa) { taosArrayPush(qnodeList, &qnodeAddr); queryDone = 0; - + SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; - SSchedulerReq req = {0}; + SSchedulerReq req = {0}; req.syncReq = false; req.pConn = &conn; req.pNodeList = qnodeList; @@ -514,8 +495,8 @@ void* schtRunJobThread(void *aa) { req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; - - code = schedulerExecJob(&req, &queryJobRefId); + + code = schedulerExecJob(&req, &queryJobRefId); assert(code == 0); pJob = schAcquireJob(queryJobRefId); @@ -524,20 +505,20 @@ void* schtRunJobThread(void *aa) { schtFreeQueryDag(&dag); continue; } - + execTasks = taosHashInit(5, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); void *pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; schtFetchTaskId = task->taskId - 1; - + taosHashPut(execTasks, &task->taskId, sizeof(task->taskId), task, sizeof(*task)); pIter = taosHashIterate(pJob->execTasks, pIter); - } + } param = (SSchTaskCallbackParam *)taosMemoryCalloc(1, sizeof(*param)); param->refId = queryJobRefId; - param->queryId = pJob->queryId; + param->queryId = pJob->queryId; pIter = taosHashIterate(execTasks, NULL); while (pIter) { @@ -547,16 +528,16 @@ void* schtRunJobThread(void *aa) { SQueryTableRsp rsp = {0}; dataBuf.pData = &rsp; dataBuf.len = sizeof(rsp); - + code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); assert(code == 0 || code); pIter = taosHashIterate(execTasks, pIter); - } + } param = (SSchTaskCallbackParam *)taosMemoryCalloc(1, sizeof(*param)); param->refId = queryJobRefId; - param->queryId = pJob->queryId; + param->queryId = pJob->queryId; pIter = taosHashIterate(execTasks, NULL); while (pIter) { @@ -566,28 +547,27 @@ void* schtRunJobThread(void *aa) { SQueryTableRsp rsp = {0}; dataBuf.pData = &rsp; dataBuf.len = sizeof(rsp); - + code = schHandleCallback(param, &dataBuf, TDMT_SCH_QUERY_RSP, 0); assert(code == 0 || code); - - pIter = taosHashIterate(execTasks, pIter); - } + pIter = taosHashIterate(execTasks, pIter); + } while (true) { if (queryDone) { break; } - + taosUsleep(10000); } atomic_store_32(&schtStartFetch, 1); - void *data = NULL; + void *data = NULL; req.syncReq = true; req.pFetchRes = &data; - + code = schedulerFetchRows(queryJobRefId, &req); assert(code == 0 || code); @@ -600,7 +580,7 @@ void* schtRunJobThread(void *aa) { data = NULL; code = schedulerFetchRows(queryJobRefId, &req); assert(code == 0 || code); - + schtFreeQueryJob(0); taosHashCleanup(execTasks); @@ -620,7 +600,7 @@ void* schtRunJobThread(void *aa) { return NULL; } -void* schtFreeJobThread(void *aa) { +void *schtFreeJobThread(void *aa) { while (!schtTestStop) { taosUsleep(taosRand() % 100); schtFreeQueryJob(1); @@ -628,17 +608,16 @@ void* schtFreeJobThread(void *aa) { return NULL; } - -} +} // namespace TEST(queryTest, normalCase) { - void *mockPointer = (void *)0x1; - char *clusterId = "cluster1"; - char *dbname = "1.db1"; - char *tablename = "table1"; + void *mockPointer = (void *)0x1; + char *clusterId = "cluster1"; + char *dbname = "1.db1"; + char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - int64_t job = 0; - SQueryPlan dag; + int64_t job = 0; + SQueryPlan dag; memset(&dag, 0, sizeof(dag)); @@ -648,7 +627,7 @@ TEST(queryTest, normalCase) { strcpy(qnodeAddr.fqdn, "qnode0.ep"); qnodeAddr.port = 6031; taosArrayPush(qnodeList, &qnodeAddr); - + int32_t code = schedulerInit(); ASSERT_EQ(code, 0); @@ -662,30 +641,29 @@ TEST(queryTest, normalCase) { SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; - SSchedulerReq req = {0}; + SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "select * from tb"; req.execFp = schtQueryCb; req.cbParam = &queryDone; - - code = schedulerExecJob(&req, &job); + + code = schedulerExecJob(&req, &job); ASSERT_EQ(code, 0); - SSchJob *pJob = schAcquireJob(job); - + void *pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); - } + } pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { @@ -693,10 +671,10 @@ TEST(queryTest, normalCase) { SQueryTableRsp rsp = {0}; code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); - } + } while (true) { if (queryDone) { @@ -705,14 +683,14 @@ TEST(queryTest, normalCase) { taosUsleep(10000); } - + TdThreadAttr thattr; taosThreadAttrInit(&thattr); TdThread thread1; taosThreadCreate(&(thread1), &thattr, schtCreateFetchRspThread, &job); - void *data = NULL; + void *data = NULL; req.syncReq = true; req.pFetchRes = &data; @@ -739,13 +717,13 @@ TEST(queryTest, normalCase) { } TEST(queryTest, readyFirstCase) { - void *mockPointer = (void *)0x1; - char *clusterId = "cluster1"; - char *dbname = "1.db1"; - char *tablename = "table1"; + void *mockPointer = (void *)0x1; + char *clusterId = "cluster1"; + char *dbname = "1.db1"; + char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - int64_t job = 0; - SQueryPlan dag; + int64_t job = 0; + SQueryPlan dag; memset(&dag, 0, sizeof(dag)); @@ -755,7 +733,7 @@ TEST(queryTest, readyFirstCase) { strcpy(qnodeAddr.fqdn, "qnode0.ep"); qnodeAddr.port = 6031; taosArrayPush(qnodeList, &qnodeAddr); - + int32_t code = schedulerInit(); ASSERT_EQ(code, 0); @@ -765,11 +743,11 @@ TEST(queryTest, readyFirstCase) { schtSetExecNode(); schtSetAsyncSendMsgToServer(); - int32_t queryDone = 0; + int32_t queryDone = 0; SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; - SSchedulerReq req = {0}; + SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; req.pDag = &dag; @@ -779,19 +757,18 @@ TEST(queryTest, readyFirstCase) { code = schedulerExecJob(&req, &job); ASSERT_EQ(code, 0); - SSchJob *pJob = schAcquireJob(job); - + void *pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { SSchTask *task = *(SSchTask **)pIter; SQueryTableRsp rsp = {0}; code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); - } + } pIter = taosHashIterate(pJob->execTasks, NULL); while (pIter) { @@ -799,10 +776,10 @@ TEST(queryTest, readyFirstCase) { SQueryTableRsp rsp = {0}; code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + ASSERT_EQ(code, 0); pIter = taosHashIterate(pJob->execTasks, pIter); - } + } while (true) { if (queryDone) { @@ -812,14 +789,13 @@ TEST(queryTest, readyFirstCase) { taosUsleep(10000); } - TdThreadAttr thattr; taosThreadAttrInit(&thattr); TdThread thread1; taosThreadCreate(&(thread1), &thattr, schtCreateFetchRspThread, &job); - void *data = NULL; + void *data = NULL; req.syncReq = true; req.pFetchRes = &data; code = schedulerFetchRows(job, &req); @@ -844,28 +820,26 @@ TEST(queryTest, readyFirstCase) { schedulerDestroy(); } - - TEST(queryTest, flowCtrlCase) { - void *mockPointer = (void *)0x1; - char *clusterId = "cluster1"; - char *dbname = "1.db1"; - char *tablename = "table1"; + void *mockPointer = (void *)0x1; + char *clusterId = "cluster1"; + char *dbname = "1.db1"; + char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - int64_t job = 0; - SQueryPlan dag; + int64_t job = 0; + SQueryPlan dag; schtInitLogFile(); taosSeedRand(taosGetTimestampSec()); - + SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); SEp qnodeAddr = {0}; strcpy(qnodeAddr.fqdn, "qnode0.ep"); qnodeAddr.port = 6031; taosArrayPush(qnodeList, &qnodeAddr); - + int32_t code = schedulerInit(); ASSERT_EQ(code, 0); @@ -875,10 +849,10 @@ TEST(queryTest, flowCtrlCase) { schtSetExecNode(); schtSetAsyncSendMsgToServer(); - int32_t queryDone = 0; + int32_t queryDone = 0; SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; - SSchedulerReq req = {0}; + SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; req.pDag = &dag; @@ -889,17 +863,16 @@ TEST(queryTest, flowCtrlCase) { code = schedulerExecJob(&req, &job); ASSERT_EQ(code, 0); - SSchJob *pJob = schAcquireJob(job); bool qDone = false; - + while (!qDone) { void *pIter = taosHashIterate(pJob->execTasks, NULL); if (NULL == pIter) { break; } - + while (pIter) { SSchTask *task = *(SSchTask **)pIter; @@ -908,15 +881,15 @@ TEST(queryTest, flowCtrlCase) { if (task->lastMsgType == TDMT_SCH_QUERY) { SQueryTableRsp rsp = {0}; code = schHandleResponseMsg(pJob, task, TDMT_SCH_QUERY_RSP, (char *)&rsp, sizeof(rsp), 0); - + ASSERT_EQ(code, 0); } else { qDone = true; break; } - + pIter = NULL; - } + } } while (true) { @@ -933,7 +906,7 @@ TEST(queryTest, flowCtrlCase) { TdThread thread1; taosThreadCreate(&(thread1), &thattr, schtCreateFetchRspThread, &job); - void *data = NULL; + void *data = NULL; req.syncReq = true; req.pFetchRes = &data; code = schedulerFetchRows(job, &req); @@ -958,15 +931,14 @@ TEST(queryTest, flowCtrlCase) { schedulerDestroy(); } - TEST(insertTest, normalCase) { - void *mockPointer = (void *)0x1; - char *clusterId = "cluster1"; - char *dbname = "1.db1"; - char *tablename = "table1"; + void *mockPointer = (void *)0x1; + char *clusterId = "cluster1"; + char *dbname = "1.db1"; + char *tablename = "table1"; SVgroupInfo vgInfo = {0}; - SQueryPlan dag; - uint64_t numOfRows = 0; + SQueryPlan dag; + uint64_t numOfRows = 0; SArray *qnodeList = taosArrayInit(1, sizeof(SEp)); @@ -974,7 +946,7 @@ TEST(insertTest, normalCase) { strcpy(qnodeAddr.fqdn, "qnode0.ep"); qnodeAddr.port = 6031; taosArrayPush(qnodeList, &qnodeAddr); - + int32_t code = schedulerInit(); ASSERT_EQ(code, 0); @@ -993,21 +965,21 @@ TEST(insertTest, normalCase) { SRequestConnInfo conn = {0}; conn.pTrans = mockPointer; - SSchedulerReq req = {0}; + SSchedulerReq req = {0}; req.pConn = &conn; req.pNodeList = qnodeList; req.pDag = &dag; req.sql = "insert into tb values(now,1)"; req.execFp = schtQueryCb; req.cbParam = NULL; - + code = schedulerExecJob(&req, &insertJobRefId); ASSERT_EQ(code, 0); ASSERT_EQ(res.numOfRows, 20); schedulerFreeJob(&insertJobRefId, 0); - schedulerDestroy(); + schedulerDestroy(); } TEST(multiThread, forceFree) { @@ -1027,12 +999,12 @@ TEST(multiThread, forceFree) { break; } } - + schtTestStop = true; taosSsleep(3); } -int main(int argc, char** argv) { +int main(int argc, char **argv) { taosSeedRand(taosGetTimestampSec()); testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/source/libs/stream/src/streamState.c b/source/libs/stream/src/streamState.c index 85592881cd9b160077fa6d8c8ada783db6ef6cfd..ea590c57e66f615872eecee0f66dce581dca52f5 100644 --- a/source/libs/stream/src/streamState.c +++ b/source/libs/stream/src/streamState.c @@ -49,7 +49,9 @@ static inline int stateKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, return 0; } -SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { +SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages) { + szPage = szPage < 0 ? 4096 : szPage; + pages = pages < 0 ? 256 : pages; SStreamState* pState = taosMemoryCalloc(1, sizeof(SStreamState)); if (pState == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -63,7 +65,7 @@ SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath) { memset(statePath, 0, 300); strncpy(statePath, path, 300); } - if (tdbOpen(statePath, 4096, 256, &pState->db) < 0) { + if (tdbOpen(statePath, szPage, pages, &pState->db) < 0) { goto _err; } diff --git a/source/libs/stream/src/streamUpdate.c b/source/libs/stream/src/streamUpdate.c index 332f7ad2fd7be60f532b1394eb2d72adf985b82a..7c4aaba6ce117be00b00259254029bc9982db49e 100644 --- a/source/libs/stream/src/streamUpdate.c +++ b/source/libs/stream/src/streamUpdate.c @@ -174,13 +174,14 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { if (res == TSDB_CODE_SUCCESS) { return false; } else { - qDebug("===stream===Update close window sbf. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, - maxTs, *pMapMaxTs, ts); + qDebug("===stream===Update close window sbf. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 + ", ts:%" PRIu64, + tableId, maxTs, *pMapMaxTs, ts); return true; } } - qDebug("===stream===Update close window. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, - maxTs, *pMapMaxTs, ts); + qDebug("===stream===Update close window. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, + tableId, maxTs, *pMapMaxTs, ts); return true; } @@ -202,8 +203,8 @@ bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts) { } if (ts < pInfo->minTS) { - qDebug("===stream===Update min ts. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, tableId, - maxTs, *pMapMaxTs, ts); + qDebug("===stream===Update min ts. tableId:%" PRIu64 ", maxTs:%" PRIu64 ", mapMaxTs:%" PRIu64 ", ts:%" PRIu64, + tableId, maxTs, *pMapMaxTs, ts); return true; } else if (res == TSDB_CODE_SUCCESS) { return false; diff --git a/source/libs/stream/test/tstreamUpdateTest.cpp b/source/libs/stream/test/tstreamUpdateTest.cpp index 933549b8a6b423bc5a3a497ecdbee13ffc7fb448..adfd7cf87675cc18020bdfaa99fa69e6cc3ca00d 100644 --- a/source/libs/stream/test/tstreamUpdateTest.cpp +++ b/source/libs/stream/test/tstreamUpdateTest.cpp @@ -4,17 +4,17 @@ #include "ttime.h" using namespace std; -#define MAX_NUM_SCALABLE_BF 100000 +#define MAX_NUM_SCALABLE_BF 100000 -bool equalSBF(SScalableBf* left, SScalableBf* right) { +bool equalSBF(SScalableBf *left, SScalableBf *right) { if (left->growth != right->growth) return false; if (left->numBits != right->numBits) return false; int lsize = taosArrayGetSize(left->bfArray); int rsize = taosArrayGetSize(right->bfArray); if (lsize != rsize) return false; for (int32_t i = 0; i < lsize; i++) { - SBloomFilter* pLeftBF = (SBloomFilter*)taosArrayGetP(left->bfArray, i); - SBloomFilter* pRightBF = (SBloomFilter*)taosArrayGetP(right->bfArray, i); + SBloomFilter *pLeftBF = (SBloomFilter *)taosArrayGetP(left->bfArray, i); + SBloomFilter *pRightBF = (SBloomFilter *)taosArrayGetP(right->bfArray, i); if (pLeftBF->errorRate != pRightBF->errorRate) return false; if (pLeftBF->expectedEntries != pRightBF->expectedEntries) return false; if (pLeftBF->hashFn1 != pRightBF->hashFn1) return false; @@ -23,8 +23,8 @@ bool equalSBF(SScalableBf* left, SScalableBf* right) { if (pLeftBF->numBits != pRightBF->numBits) return false; if (pLeftBF->numUnits != pRightBF->numUnits) return false; if (pLeftBF->size != pRightBF->size) return false; - uint64_t* leftUint = (uint64_t*) pLeftBF->buffer; - uint64_t* rightUint = (uint64_t*) pRightBF->buffer; + uint64_t *leftUint = (uint64_t *)pLeftBF->buffer; + uint64_t *rightUint = (uint64_t *)pRightBF->buffer; for (int32_t j = 0; j < pLeftBF->numUnits; j++) { if (leftUint[j] != rightUint[j]) return false; } @@ -35,86 +35,86 @@ bool equalSBF(SScalableBf* left, SScalableBf* right) { TEST(TD_STREAM_UPDATE_TEST, update) { const int64_t interval = 20 * 1000; const int64_t watermark = 10 * 60 * 1000; - SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,1, 0), false); - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,1, -1), true); + SUpdateInfo *pSU = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, 1, 0), false); + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, 1, -1), true); - for(int i=0; i < 1024; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), false); + for (int i = 0; i < 1024; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, i, 1), false); } - for(int i=0; i < 1024; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), true); + for (int i = 0; i < 1024; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, i, 1), true); } - for(int i=0; i < 1024; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 2), false); + for (int i = 0; i < 1024; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, i, 2), false); } - for(int i=0; i < 1024; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 2), true); + for (int i = 0; i < 1024; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, i, 2), true); } - for(int i=0; i < 1024; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU,i, 1), true); + for (int i = 0; i < 1024; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, i, 1), true); } TSKEY uid = 0; - for(int i=3; i < 1024; i++) { + for (int i = 3; i < 1024; i++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, uid, i), false); } - GTEST_ASSERT_EQ(*(TSKEY*)taosHashGet(pSU->pMap, &uid, sizeof(uint64_t)), 1023); + GTEST_ASSERT_EQ(*(TSKEY *)taosHashGet(pSU->pMap, &uid, sizeof(uint64_t)), 1023); - for(int i=3; i < 1024; i++) { + for (int i = 3; i < 1024; i++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU, uid, i), true); } - GTEST_ASSERT_EQ(*(TSKEY*)taosHashGet(pSU->pMap, &uid, sizeof(uint64_t)), 1023); + GTEST_ASSERT_EQ(*(TSKEY *)taosHashGet(pSU->pMap, &uid, sizeof(uint64_t)), 1023); SUpdateInfo *pSU1 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); - for(int i=1; i <= watermark / interval; i++) { + for (int i = 1; i <= watermark / interval; i++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false); GTEST_ASSERT_EQ(pSU1->minTS, interval); GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval); } - for(int i=0; i < pSU1->numSBFs; i++) { - SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, i); + for (int i = 0; i < pSU1->numSBFs; i++) { + SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, i); SBloomFilter *pBF = (SBloomFilter *)taosArrayGetP(pSBF->bfArray, 0); GTEST_ASSERT_EQ(pBF->size, 1); } - for(int i= watermark / interval + 1, j = 2 ; i <= watermark / interval + 10; i++,j++) { + for (int i = watermark / interval + 1, j = 2; i <= watermark / interval + 10; i++, j++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false); - GTEST_ASSERT_EQ(pSU1->minTS, interval*j); + GTEST_ASSERT_EQ(pSU1->minTS, interval * j); GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval); - SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, pSU1->numSBFs - 1); + SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU1->pTsSBFs, pSU1->numSBFs - 1); SBloomFilter *pBF = (SBloomFilter *)taosArrayGetP(pSBF->bfArray, 0); GTEST_ASSERT_EQ(pBF->size, 1); } - - for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 2), j++) { + + for (int i = watermark / interval * 100, j = 0; j < 10; i += (watermark / interval * 2), j++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU1, 1, i * interval + 5), false); - GTEST_ASSERT_EQ(pSU1->minTS, (i-(pSU1->numSBFs-1))*interval); + GTEST_ASSERT_EQ(pSU1->minTS, (i - (pSU1->numSBFs - 1)) * interval); GTEST_ASSERT_EQ(pSU1->numSBFs, watermark / interval); } SUpdateInfo *pSU2 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU2, 1, 1 * interval + 5), false); GTEST_ASSERT_EQ(pSU2->minTS, interval); - for(int i= watermark / interval * 100, j = 0; j < 10; i+= (watermark / interval * 10), j++) { + for (int i = watermark / interval * 100, j = 0; j < 10; i += (watermark / interval * 10), j++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU2, 1, i * interval + 5), false); - GTEST_ASSERT_EQ(pSU2->minTS, (i-(pSU2->numSBFs-1))*interval); + GTEST_ASSERT_EQ(pSU2->minTS, (i - (pSU2->numSBFs - 1)) * interval); GTEST_ASSERT_EQ(pSU2->numSBFs, watermark / interval); TSKEY uid2 = 1; - GTEST_ASSERT_EQ(*(TSKEY*)taosHashGet(pSU2->pMap, &uid2, sizeof(uint64_t)), i * interval + 5); + GTEST_ASSERT_EQ(*(TSKEY *)taosHashGet(pSU2->pMap, &uid2, sizeof(uint64_t)), i * interval + 5); } - + SUpdateInfo *pSU3 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); - for(int j = 1; j < 100; j++) { - for(int i = 0; i < pSU3->numSBFs; i++) { + for (int j = 1; j < 100; j++) { + for (int i = 0; i < pSU3->numSBFs; i++) { GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU3, i, i * interval + 5 * j), false); GTEST_ASSERT_EQ(pSU3->minTS, 0); GTEST_ASSERT_EQ(pSU3->numSBFs, watermark / interval); uint64_t uid3 = i; - GTEST_ASSERT_EQ(*(TSKEY*)taosHashGet(pSU3->pMap, &uid3, sizeof(uint64_t)), i * interval + 5 * j); - SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU3->pTsSBFs, i); + GTEST_ASSERT_EQ(*(TSKEY *)taosHashGet(pSU3->pMap, &uid3, sizeof(uint64_t)), i * interval + 5 * j); + SScalableBf *pSBF = (SScalableBf *)taosArrayGetP(pSU3->pTsSBFs, i); SBloomFilter *pBF = (SBloomFilter *)taosArrayGetP(pSBF->bfArray, 0); GTEST_ASSERT_EQ(pBF->size, j); } @@ -130,19 +130,19 @@ TEST(TD_STREAM_UPDATE_TEST, update) { SUpdateInfo *pSU7 = updateInfoInit(interval, TSDB_TIME_PRECISION_MILLI, watermark); updateInfoAddCloseWindowSBF(pSU7); - for(int64_t i = 1; i < 2048000; i++) { - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7,i, i), false); + for (int64_t i = 1; i < 2048000; i++) { + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7, i, i), false); } - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7,100, 1), true); - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7,110, 10), true); - GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7,200, 20), true); + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7, 100, 1), true); + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7, 110, 10), true); + GTEST_ASSERT_EQ(updateInfoIsUpdated(pSU7, 200, 20), true); int32_t bufLen = updateInfoSerialize(NULL, 0, pSU7); - void* buf = taosMemoryCalloc(1, bufLen); + void *buf = taosMemoryCalloc(1, bufLen); int32_t resSize = updateInfoSerialize(buf, bufLen, pSU7); SUpdateInfo *pSU6 = updateInfoInit(0, TSDB_TIME_PRECISION_MILLI, 0); - int32_t desSize = updateInfoDeserialize(buf, bufLen, pSU6); + int32_t desSize = updateInfoDeserialize(buf, bufLen, pSU6); GTEST_ASSERT_EQ(desSize, 0); GTEST_ASSERT_EQ(pSU7->interval, pSU6->interval); @@ -150,7 +150,7 @@ TEST(TD_STREAM_UPDATE_TEST, update) { GTEST_ASSERT_EQ(pSU7->minTS, pSU6->minTS); GTEST_ASSERT_EQ(pSU7->numBuckets, pSU6->numBuckets); GTEST_ASSERT_EQ(pSU7->numSBFs, pSU6->numSBFs); - GTEST_ASSERT_EQ(pSU7->scanGroupId, pSU6->scanGroupId); + GTEST_ASSERT_EQ(pSU7->scanGroupId, pSU6->scanGroupId); GTEST_ASSERT_EQ(pSU7->scanWindow.ekey, pSU6->scanWindow.ekey); GTEST_ASSERT_EQ(pSU7->scanWindow.skey, pSU6->scanWindow.skey); GTEST_ASSERT_EQ(pSU7->watermark, pSU6->watermark); @@ -158,27 +158,27 @@ TEST(TD_STREAM_UPDATE_TEST, update) { int32_t mapSize = taosHashGetSize(pSU7->pMap); GTEST_ASSERT_EQ(mapSize, taosHashGetSize(pSU6->pMap)); - void* pIte = NULL; + void *pIte = NULL; size_t keyLen = 0; while ((pIte = taosHashIterate(pSU7->pMap, pIte)) != NULL) { - void* key = taosHashGetKey(pIte, &keyLen); - void* value6 = taosHashGet(pSU6->pMap, key, keyLen); - GTEST_ASSERT_EQ(*(TSKEY*)pIte, *(TSKEY*)value6); + void *key = taosHashGetKey(pIte, &keyLen); + void *value6 = taosHashGet(pSU6->pMap, key, keyLen); + GTEST_ASSERT_EQ(*(TSKEY *)pIte, *(TSKEY *)value6); } int32_t buSize = taosArrayGetSize(pSU7->pTsBuckets); GTEST_ASSERT_EQ(buSize, taosArrayGetSize(pSU6->pTsBuckets)); for (int32_t i = 0; i < buSize; i++) { - TSKEY ts1 = *(TSKEY*)taosArrayGet(pSU7->pTsBuckets, i); - TSKEY ts2 = *(TSKEY*)taosArrayGet(pSU6->pTsBuckets, i); + TSKEY ts1 = *(TSKEY *)taosArrayGet(pSU7->pTsBuckets, i); + TSKEY ts2 = *(TSKEY *)taosArrayGet(pSU6->pTsBuckets, i); GTEST_ASSERT_EQ(ts1, ts2); } int32_t lSize = taosArrayGetSize(pSU7->pTsSBFs); int32_t rSize = taosArrayGetSize(pSU6->pTsSBFs); GTEST_ASSERT_EQ(lSize, rSize); for (int32_t i = 0; i < lSize; i++) { - SScalableBf* pLeftSBF = (SScalableBf*)taosArrayGetP(pSU7->pTsSBFs, i); - SScalableBf* pRightSBF = (SScalableBf*)taosArrayGetP(pSU6->pTsSBFs, i); + SScalableBf *pLeftSBF = (SScalableBf *)taosArrayGetP(pSU7->pTsSBFs, i); + SScalableBf *pRightSBF = (SScalableBf *)taosArrayGetP(pSU6->pTsSBFs, i); GTEST_ASSERT_EQ(equalSBF(pLeftSBF, pRightSBF), true); } @@ -190,10 +190,9 @@ TEST(TD_STREAM_UPDATE_TEST, update) { updateInfoDestroy(pSU5); updateInfoDestroy(pSU6); updateInfoDestroy(pSU7); - } -int main(int argc, char* argv[]) { +int main(int argc, char *argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } \ No newline at end of file diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index f3064e668df575d51dbd1efc333e373543522de1..68d2334101b3e9bff70b7e77c2fcbfaf84fa8d57 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -29,15 +29,15 @@ extern "C" { #include "tqueue.h" #include "trpc.h" -#define TICK_Q_TIMER_MS 1000 +#define TICK_Q_TIMER_MS 1000 #define TICK_Ping_TIMER_MS 1000 typedef struct SSyncIO { STaosQueue *pMsgQ; - STaosQset * pQset; + STaosQset *pQset; TdThread consumerTid; - void * serverRpc; - void * clientRpc; + void *serverRpc; + void *clientRpc; SEpSet myAddr; SMsgCb msgcb; diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index e0cbcf074458f90e861a27ca4a0a1c026ed0fa03..ac298c537510e77982bc2edc1d6f026dc16e7f95 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -28,7 +28,7 @@ extern "C" { #include "taosdef.h" #define RAFT_STORE_BLOCK_SIZE 512 -#define RAFT_STORE_PATH_LEN (TSDB_FILENAME_LEN * 2) +#define RAFT_STORE_PATH_LEN (TSDB_FILENAME_LEN * 2) typedef struct SRaftStore { SyncTerm currentTerm; @@ -49,8 +49,8 @@ void raftStoreClearVote(SRaftStore *pRaftStore); void raftStoreNextTerm(SRaftStore *pRaftStore); void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson); -cJSON * raftStore2Json(SRaftStore *pRaftStore); -char * raftStore2Str(SRaftStore *pRaftStore); +cJSON *raftStore2Json(SRaftStore *pRaftStore); +char *raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/inc/syncVoteMgr.h b/source/libs/sync/inc/syncVoteMgr.h index 716d2f620c09bdf0b842f7661e5f238d2821644f..aa245ce32c20a02ea450581daed949076704e446 100644 --- a/source/libs/sync/inc/syncVoteMgr.h +++ b/source/libs/sync/inc/syncVoteMgr.h @@ -46,8 +46,8 @@ void voteGrantedUpdate(SVotesGranted *pVotesGranted, SSyncNode *pSyncN bool voteGrantedMajority(SVotesGranted *pVotesGranted); void voteGrantedVote(SVotesGranted *pVotesGranted, SyncRequestVoteReply *pMsg); void voteGrantedReset(SVotesGranted *pVotesGranted, SyncTerm term); -cJSON * voteGranted2Json(SVotesGranted *pVotesGranted); -char * voteGranted2Str(SVotesGranted *pVotesGranted); +cJSON *voteGranted2Json(SVotesGranted *pVotesGranted); +char *voteGranted2Str(SVotesGranted *pVotesGranted); // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj); @@ -70,8 +70,8 @@ void votesRespondUpdate(SVotesRespond *pVotesRespond, SSyncNode *pSync bool votesResponded(SVotesRespond *pVotesRespond, const SRaftId *pRaftId); void votesRespondAdd(SVotesRespond *pVotesRespond, const SyncRequestVoteReply *pMsg); void votesRespondReset(SVotesRespond *pVotesRespond, SyncTerm term); -cJSON * votesRespond2Json(SVotesRespond *pVotesRespond); -char * votesRespond2Str(SVotesRespond *pVotesRespond); +cJSON *votesRespond2Json(SVotesRespond *pVotesRespond); +char *votesRespond2Str(SVotesRespond *pVotesRespond); // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj); diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index b00be6edb6a6b9473ea1483a4bb508033151f313..e9899a3e33701d425b85878cfa1253e111e3964c 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -30,7 +30,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void * syncIOConsumerFunc(void *param); +static void *syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -242,9 +242,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO * io = param; + SSyncIO *io = param; STaosQall *qall = taosAllocateQall(); - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; SQueueInfo qinfo = {0}; while (1) { diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 76fd345bdd1226a960c13c94de9d86ea7d954f1e..378ac743b33df0b78d042ac28deaecc0c573397f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -52,9 +52,9 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg); int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg); // --------------------------------- -static void syncNodeFreeCb(void *param) { - syncNodeClose(param); - param = NULL; +static void syncNodeFreeCb(void* param) { + syncNodeClose(param); + param = NULL; } int32_t syncInit() { @@ -947,15 +947,15 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { meta.batchSize = pSyncInfo->batchSize; ret = raftCfgCreateFile((SSyncCfg*)&(pSyncInfo->syncCfg), meta, pSyncNode->configPath); if (ret != 0) { - sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); - goto _error; + sError("failed to create raft cfg file. configPath: %s", pSyncNode->configPath); + goto _error; } } else { // update syncCfg by raft_config.json pSyncNode->pRaftCfg = raftCfgOpen(pSyncNode->configPath); if (pSyncNode->pRaftCfg == NULL) { - sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); - goto _error; + sError("failed to open raft cfg file. path:%s", pSyncNode->configPath); + goto _error; } pSyncInfo->syncCfg = pSyncNode->pRaftCfg->cfg; @@ -985,8 +985,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { // init internal pSyncNode->myNodeInfo = pSyncNode->pRaftCfg->cfg.nodeInfo[pSyncNode->pRaftCfg->cfg.myIndex]; if (!syncUtilnodeInfo2raftId(&pSyncNode->myNodeInfo, pSyncNode->vgId, &pSyncNode->myRaftId)) { - sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); - goto _error; + sError("failed to determine my raft member id. vgId:%d", pSyncNode->vgId); + goto _error; } // init peersNum, peers, peersId @@ -1000,17 +1000,17 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { } for (int i = 0; i < pSyncNode->peersNum; ++i) { if (!syncUtilnodeInfo2raftId(&pSyncNode->peersNodeInfo[i], pSyncNode->vgId, &pSyncNode->peersId[i])) { - sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); - goto _error; + sError("failed to determine raft member id. vgId:%d, peer:%d", pSyncNode->vgId, i); + goto _error; } } // init replicaNum, replicasId pSyncNode->replicaNum = pSyncNode->pRaftCfg->cfg.replicaNum; for (int i = 0; i < pSyncNode->pRaftCfg->cfg.replicaNum; ++i) { - if(!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { - sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); - goto _error; + if (!syncUtilnodeInfo2raftId(&pSyncNode->pRaftCfg->cfg.nodeInfo[i], pSyncNode->vgId, &pSyncNode->replicasId[i])) { + sError("failed to determine raft member id. vgId:%d, replica:%d", pSyncNode->vgId, i); + goto _error; } } @@ -1090,8 +1090,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { SSnapshot snapshot = {0}; int32_t code = pSyncNode->pFsm->FpGetSnapshotInfo(pSyncNode->pFsm, &snapshot); if (code != 0) { - sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); - goto _error; + sError("failed to get snapshot info. vgId:%d, code:%d", pSyncNode->vgId, code); + goto _error; } if (snapshot.lastApplyIndex > commitIndex) { commitIndex = snapshot.lastApplyIndex; @@ -1191,8 +1191,8 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pOldSyncInfo) { _error: if (pSyncInfo->pFsm) { - taosMemoryFree(pSyncInfo->pFsm); - pSyncInfo->pFsm = NULL; + taosMemoryFree(pSyncInfo->pFsm); + pSyncInfo->pFsm = NULL; } syncNodeClose(pSyncNode); pSyncNode = NULL; diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 22b47a2c45e14216b1554c9e606f2d66b1d07b5e..6d4d54a9b1708fb5db6eac81df1addc2536b8cfb 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -218,7 +218,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { char *raftStore2Str(SRaftStore *pRaftStore) { cJSON *pJson = raftStore2Json(pRaftStore); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncSnapshot.c b/source/libs/sync/src/syncSnapshot.c index 68d81813ac760a37b78bfdc12aee59624b296c48..6167d41141735e1800848a989e1d3a0b75454e41 100644 --- a/source/libs/sync/src/syncSnapshot.c +++ b/source/libs/sync/src/syncSnapshot.c @@ -36,8 +36,8 @@ SSyncSnapshotSender *snapshotSenderCreate(SSyncNode *pSyncNode, int32_t replicaI if (condition) { pSender = taosMemoryMalloc(sizeof(SSyncSnapshotSender)); if (pSender == NULL) { - terrno = TSDB_CODE_OUT_OF_MEMORY; - return NULL; + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } memset(pSender, 0, sizeof(*pSender)); diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 641bb32d2d56a0bf745c6cb4c5fb43ccaaaa6f75..09b79825d04f83ebe8e729b362fd05f95d3b24a4 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -130,7 +130,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -259,7 +259,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/syncAppendEntriesReplyTest.cpp b/source/libs/sync/test/syncAppendEntriesReplyTest.cpp index 72d3fd5ef34d83d9a2db7c674abd58a989bfed3e..a5e96233c24bf7746bec6330958a2cfe12621f70 100644 --- a/source/libs/sync/test/syncAppendEntriesReplyTest.cpp +++ b/source/libs/sync/test/syncAppendEntriesReplyTest.cpp @@ -37,7 +37,7 @@ void test1() { void test2() { SyncAppendEntriesReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncAppendEntriesReplySerialize(pMsg, serialized, len); SyncAppendEntriesReply *pMsg2 = syncAppendEntriesReplyBuild(1000); syncAppendEntriesReplyDeserialize(serialized, len, pMsg2); @@ -52,7 +52,7 @@ void test2() { void test3() { SyncAppendEntriesReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncAppendEntriesReplySerialize2(pMsg, &len); + char *serialized = syncAppendEntriesReplySerialize2(pMsg, &len); SyncAppendEntriesReply *pMsg2 = syncAppendEntriesReplyDeserialize2(serialized, len); syncAppendEntriesReplyLog2((char *)"test3: syncAppendEntriesReplySerialize3 -> syncAppendEntriesReplyDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncAppendEntriesTest.cpp b/source/libs/sync/test/syncAppendEntriesTest.cpp index 98b392274ec86937a6e4c6e99f130d9973d7a33a..256c13e26749b432f627d90f814661566fbf9d21 100644 --- a/source/libs/sync/test/syncAppendEntriesTest.cpp +++ b/source/libs/sync/test/syncAppendEntriesTest.cpp @@ -37,7 +37,7 @@ void test1() { void test2() { SyncAppendEntries *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncAppendEntriesSerialize(pMsg, serialized, len); SyncAppendEntries *pMsg2 = syncAppendEntriesBuild(pMsg->dataLen, 1000); syncAppendEntriesDeserialize(serialized, len, pMsg2); @@ -51,7 +51,7 @@ void test2() { void test3() { SyncAppendEntries *pMsg = createMsg(); uint32_t len; - char * serialized = syncAppendEntriesSerialize2(pMsg, &len); + char *serialized = syncAppendEntriesSerialize2(pMsg, &len); SyncAppendEntries *pMsg2 = syncAppendEntriesDeserialize2(serialized, len); syncAppendEntriesLog2((char *)"test3: syncAppendEntriesSerialize3 -> syncAppendEntriesDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncApplyMsgTest.cpp b/source/libs/sync/test/syncApplyMsgTest.cpp index 30019f71e5d6ffa327a0e3fd2731883397c9ec7b..9d5e7dd8e1de635ea5cbc64352eb25bafa40d99d 100644 --- a/source/libs/sync/test/syncApplyMsgTest.cpp +++ b/source/libs/sync/test/syncApplyMsgTest.cpp @@ -43,7 +43,7 @@ void test1() { void test2() { SyncApplyMsg *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncApplyMsgSerialize(pMsg, serialized, len); SyncApplyMsg *pMsg2 = syncApplyMsgBuild(pMsg->dataLen); syncApplyMsgDeserialize(serialized, len, pMsg2); @@ -57,7 +57,7 @@ void test2() { void test3() { SyncApplyMsg *pMsg = createMsg(); uint32_t len; - char * serialized = syncApplyMsgSerialize2(pMsg, &len); + char *serialized = syncApplyMsgSerialize2(pMsg, &len); SyncApplyMsg *pMsg2 = syncApplyMsgDeserialize2(serialized, len); syncApplyMsgLog2((char *)"test3: syncApplyMsgSerialize2 -> syncApplyMsgDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncClientRequestBatchTest.cpp b/source/libs/sync/test/syncClientRequestBatchTest.cpp index 84d037be01028167584bfcaf912fc090540c0c7e..5586b7a6ce55c8f4f6aa6aebbd5c295e6562e1d4 100644 --- a/source/libs/sync/test/syncClientRequestBatchTest.cpp +++ b/source/libs/sync/test/syncClientRequestBatchTest.cpp @@ -33,7 +33,7 @@ SyncClientRequestBatch *createMsg() { for (int32_t i = 0; i < 5; ++i) { SRpcMsg *pRpcMsg = createRpcMsg(i, 20); rpcMsgPArr[i] = pRpcMsg; - //taosMemoryFree(pRpcMsg); + // taosMemoryFree(pRpcMsg); } SRaftMeta raftArr[5]; diff --git a/source/libs/sync/test/syncClientRequestTest.cpp b/source/libs/sync/test/syncClientRequestTest.cpp index 9376aca91f8c31a2133f6e860568ffd4f3ba5072..56e53cc1c93bbb5d024797c47936d10bf8fa8a3b 100644 --- a/source/libs/sync/test/syncClientRequestTest.cpp +++ b/source/libs/sync/test/syncClientRequestTest.cpp @@ -35,7 +35,7 @@ void test1() { void test2() { SyncClientRequest *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncClientRequestSerialize(pMsg, serialized, len); SyncClientRequest *pMsg2 = syncClientRequestBuild(pMsg->dataLen); syncClientRequestDeserialize(serialized, len, pMsg2); @@ -49,7 +49,7 @@ void test2() { void test3() { SyncClientRequest *pMsg = createMsg(); uint32_t len; - char * serialized = syncClientRequestSerialize2(pMsg, &len); + char *serialized = syncClientRequestSerialize2(pMsg, &len); SyncClientRequest *pMsg2 = syncClientRequestDeserialize2(serialized, len); syncClientRequestLog2((char *)"test3: syncClientRequestSerialize3 -> syncClientRequestDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp index fbfc4cda8eb01de93b8d50c3002b1d59c97faaa9..c523fbc1c3115b2c27c0dd48b2f08cffc234c18c 100644 --- a/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp +++ b/source/libs/sync/test/syncConfigChangeSnapshotTest.cpp @@ -149,7 +149,7 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_ void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } diff --git a/source/libs/sync/test/syncConfigChangeTest.cpp b/source/libs/sync/test/syncConfigChangeTest.cpp index cfab3b6ae37133155cc8b2de91edf44abd33a76c..c04ab9b000e1f595d03838e36e555eff9541c08f 100644 --- a/source/libs/sync/test/syncConfigChangeTest.cpp +++ b/source/libs/sync/test/syncConfigChangeTest.cpp @@ -80,7 +80,7 @@ int32_t GetSnapshotCb(struct SSyncFSM* pFsm, SSnapshot* pSnapshot) { void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb=="); } -void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta *cbMeta) { +void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) { sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64, cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term); } diff --git a/source/libs/sync/test/syncEncodeTest.cpp b/source/libs/sync/test/syncEncodeTest.cpp index 454c823c6a501ac0cb2532892159957056d7e1fa..4016f0744201e69aaab2531ab4e64932327b4df0 100644 --- a/source/libs/sync/test/syncEncodeTest.cpp +++ b/source/libs/sync/test/syncEncodeTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *pSyncNode; SSyncNode *syncNodeInit() { @@ -187,8 +187,8 @@ int main(int argc, char **argv) { // step5 uint32_t len; - char * pMsg5 = step5(pMsg4, &len); - char * s = syncUtilprintBin(pMsg5, len); + char *pMsg5 = step5(pMsg4, &len); + char *s = syncUtilprintBin(pMsg5, len); printf("==step5== [%s] \n", s); taosMemoryFree(s); diff --git a/source/libs/sync/test/syncHeartbeatReplyTest.cpp b/source/libs/sync/test/syncHeartbeatReplyTest.cpp index 0ccd7b70bb8f552fa14c0a615993abbab678a8a0..f5519fe6d4bd4870813937eaaddab088ec3889ca 100644 --- a/source/libs/sync/test/syncHeartbeatReplyTest.cpp +++ b/source/libs/sync/test/syncHeartbeatReplyTest.cpp @@ -35,13 +35,12 @@ void test1() { void test2() { SyncHeartbeatReply *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + 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); + syncHeartbeatReplyLog2((char *)"test2: syncHeartbeatReplySerialize -> syncHeartbeatReplyDeserialize ", pMsg2); taosMemoryFree(serialized); syncHeartbeatReplyDestroy(pMsg); @@ -50,11 +49,10 @@ void test2() { void test3() { SyncHeartbeatReply *pMsg = createMsg(); - uint32_t len; - char * serialized = syncHeartbeatReplySerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncHeartbeatReplySerialize2(pMsg, &len); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyDeserialize2(serialized, len); - syncHeartbeatReplyLog2((char *)"test3: syncHeartbeatReplySerialize3 -> syncHeartbeatReplyDeserialize2 ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test3: syncHeartbeatReplySerialize3 -> syncHeartbeatReplyDeserialize2 ", pMsg2); taosMemoryFree(serialized); syncHeartbeatReplyDestroy(pMsg); @@ -63,12 +61,11 @@ void test3() { void test4() { SyncHeartbeatReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyBuild(1000); syncHeartbeatReplyFromRpcMsg(&rpcMsg, pMsg2); - syncHeartbeatReplyLog2((char *)"test4: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test4: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg ", pMsg2); rpcFreeCont(rpcMsg.pCont); syncHeartbeatReplyDestroy(pMsg); @@ -77,11 +74,10 @@ void test4() { void test5() { SyncHeartbeatReply *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeatReply2RpcMsg(pMsg, &rpcMsg); SyncHeartbeatReply *pMsg2 = syncHeartbeatReplyFromRpcMsg2(&rpcMsg); - syncHeartbeatReplyLog2((char *)"test5: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg2 ", - pMsg2); + syncHeartbeatReplyLog2((char *)"test5: syncHeartbeatReply2RpcMsg -> syncHeartbeatReplyFromRpcMsg2 ", pMsg2); rpcFreeCont(rpcMsg.pCont); syncHeartbeatReplyDestroy(pMsg); diff --git a/source/libs/sync/test/syncHeartbeatTest.cpp b/source/libs/sync/test/syncHeartbeatTest.cpp index d910c828f1e13f4e6484c7b8ad7ea6758f626750..577af33b9c2587ceff1412e499fbc9670d7e98a1 100644 --- a/source/libs/sync/test/syncHeartbeatTest.cpp +++ b/source/libs/sync/test/syncHeartbeatTest.cpp @@ -19,7 +19,7 @@ SyncHeartbeat *createMsg() { 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->destId.vgId = 100; pMsg->term = 8; pMsg->commitIndex = 33; pMsg->privateTerm = 44; @@ -34,8 +34,8 @@ void test1() { void test2() { SyncHeartbeat *pMsg = createMsg(); - uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + uint32_t len = pMsg->bytes; + char *serialized = (char *)taosMemoryMalloc(len); syncHeartbeatSerialize(pMsg, serialized, len); SyncHeartbeat *pMsg2 = syncHeartbeatBuild(789); syncHeartbeatDeserialize(serialized, len, pMsg2); @@ -48,8 +48,8 @@ void test2() { void test3() { SyncHeartbeat *pMsg = createMsg(); - uint32_t len; - char * serialized = syncHeartbeatSerialize2(pMsg, &len); + uint32_t len; + char *serialized = syncHeartbeatSerialize2(pMsg, &len); SyncHeartbeat *pMsg2 = syncHeartbeatDeserialize2(serialized, len); syncHeartbeatLog2((char *)"test3: syncHeartbeatSerialize2 -> syncHeartbeatDeserialize2 ", pMsg2); @@ -60,7 +60,7 @@ void test3() { void test4() { SyncHeartbeat *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeat2RpcMsg(pMsg, &rpcMsg); SyncHeartbeat *pMsg2 = (SyncHeartbeat *)taosMemoryMalloc(rpcMsg.contLen); syncHeartbeatFromRpcMsg(&rpcMsg, pMsg2); @@ -73,9 +73,9 @@ void test4() { void test5() { SyncHeartbeat *pMsg = createMsg(); - SRpcMsg rpcMsg; + SRpcMsg rpcMsg; syncHeartbeat2RpcMsg(pMsg, &rpcMsg); - SyncHeartbeat *pMsg2 =syncHeartbeatFromRpcMsg2(&rpcMsg); + SyncHeartbeat *pMsg2 = syncHeartbeatFromRpcMsg2(&rpcMsg); syncHeartbeatLog2((char *)"test5: syncHeartbeat2RpcMsg -> syncHeartbeatFromRpcMsg2 ", pMsg2); rpcFreeCont(rpcMsg.pCont); diff --git a/source/libs/sync/test/syncIndexTest.cpp b/source/libs/sync/test/syncIndexTest.cpp index 91c7800756a05495942f33a1adcc02fba65502b6..93cd5f79f07ab5da62f0255b2b7409b43547b9a3 100644 --- a/source/libs/sync/test/syncIndexTest.cpp +++ b/source/libs/sync/test/syncIndexTest.cpp @@ -9,7 +9,7 @@ void print(SHashObj *pNextIndex) { uint64_t *p = (uint64_t *)taosHashIterate(pNextIndex, NULL); while (p) { size_t len; - void * key = taosHashGetKey(p, &len); + void *key = taosHashGetKey(p, &len); SRaftId *pRaftId = (SRaftId *)key; diff --git a/source/libs/sync/test/syncLeaderTransferTest.cpp b/source/libs/sync/test/syncLeaderTransferTest.cpp index 1c3891d49219a142b532246fa36e36e631095568..62a9106c159123545f412d7040619af64c5a7ef2 100644 --- a/source/libs/sync/test/syncLeaderTransferTest.cpp +++ b/source/libs/sync/test/syncLeaderTransferTest.cpp @@ -36,7 +36,7 @@ void test1() { void test2() { SyncLeaderTransfer *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncLeaderTransferSerialize(pMsg, serialized, len); SyncLeaderTransfer *pMsg2 = syncLeaderTransferBuild(1000); syncLeaderTransferDeserialize(serialized, len, pMsg2); @@ -50,7 +50,7 @@ void test2() { void test3() { SyncLeaderTransfer *pMsg = createMsg(); uint32_t len; - char * serialized = syncLeaderTransferSerialize2(pMsg, &len); + char *serialized = syncLeaderTransferSerialize2(pMsg, &len); SyncLeaderTransfer *pMsg2 = syncLeaderTransferDeserialize2(serialized, len); syncLeaderTransferLog2((char *)"test3: syncLeaderTransferSerialize2 -> syncLeaderTransferDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncPingReplyTest.cpp b/source/libs/sync/test/syncPingReplyTest.cpp index 2bd8671e6c8dbd7bb2e7b5f3f97c13cc46f8213f..e5158a7932f63cf50399727e03e6f49274d5d0ad 100644 --- a/source/libs/sync/test/syncPingReplyTest.cpp +++ b/source/libs/sync/test/syncPingReplyTest.cpp @@ -33,7 +33,7 @@ void test1() { void test2() { SyncPingReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncPingReplySerialize(pMsg, serialized, len); SyncPingReply *pMsg2 = syncPingReplyBuild(pMsg->dataLen); syncPingReplyDeserialize(serialized, len, pMsg2); @@ -47,7 +47,7 @@ void test2() { void test3() { SyncPingReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncPingReplySerialize2(pMsg, &len); + char *serialized = syncPingReplySerialize2(pMsg, &len); SyncPingReply *pMsg2 = syncPingReplyDeserialize2(serialized, len); syncPingReplyLog2((char *)"test3: syncPingReplySerialize2 -> syncPingReplyDeserialize2 ", pMsg2); @@ -84,7 +84,7 @@ void test5() { void test6() { SyncPingReply *pMsg = createMsg(); int32_t bufLen = syncPingReplySerialize3(pMsg, NULL, 0); - char * serialized = (char *)taosMemoryMalloc(bufLen); + char *serialized = (char *)taosMemoryMalloc(bufLen); syncPingReplySerialize3(pMsg, serialized, bufLen); SyncPingReply *pMsg2 = syncPingReplyDeserialize3(serialized, bufLen); assert(pMsg2 != NULL); diff --git a/source/libs/sync/test/syncPingTest.cpp b/source/libs/sync/test/syncPingTest.cpp index a02f5e4b43b177b618e4150ad96423dd23236af0..1777b9b9e2c494b25fd8b5af99f9335d82d09b5d 100644 --- a/source/libs/sync/test/syncPingTest.cpp +++ b/source/libs/sync/test/syncPingTest.cpp @@ -33,7 +33,7 @@ void test1() { void test2() { SyncPing *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncPingSerialize(pMsg, serialized, len); SyncPing *pMsg2 = syncPingBuild(pMsg->dataLen); syncPingDeserialize(serialized, len, pMsg2); @@ -47,7 +47,7 @@ void test2() { void test3() { SyncPing *pMsg = createMsg(); uint32_t len; - char * serialized = syncPingSerialize2(pMsg, &len); + char *serialized = syncPingSerialize2(pMsg, &len); SyncPing *pMsg2 = syncPingDeserialize2(serialized, len); syncPingLog2((char *)"test3: syncPingSerialize2 -> syncPingDeserialize2 ", pMsg2); @@ -84,7 +84,7 @@ void test5() { void test6() { SyncPing *pMsg = createMsg(); int32_t bufLen = syncPingSerialize3(pMsg, NULL, 0); - char * serialized = (char *)taosMemoryMalloc(bufLen); + char *serialized = (char *)taosMemoryMalloc(bufLen); syncPingSerialize3(pMsg, serialized, bufLen); SyncPing *pMsg2 = syncPingDeserialize3(serialized, bufLen); assert(pMsg2 != NULL); diff --git a/source/libs/sync/test/syncRaftCfgIndexTest.cpp b/source/libs/sync/test/syncRaftCfgIndexTest.cpp index 6338383f92ceac88549753a415a5c7ba729c976f..bd8ffc45b6bcaf5780aa6f7a5331316cc37224fe 100644 --- a/source/libs/sync/test/syncRaftCfgIndexTest.cpp +++ b/source/libs/sync/test/syncRaftCfgIndexTest.cpp @@ -53,20 +53,20 @@ SSyncCfg* createSyncCfg() { return pCfg; } -const char *pFile = "./raft_config_index.json"; +const char* pFile = "./raft_config_index.json"; void test1() { int32_t code = raftCfgIndexCreateFile(pFile); ASSERT(code == 0); - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); raftCfgIndexLog2((char*)"==test1==", pRaftCfgIndex); raftCfgIndexClose(pRaftCfgIndex); } void test2() { - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); for (int i = 0; i < 500; ++i) { raftCfgIndexAddConfigIndex(pRaftCfgIndex, i); } @@ -77,7 +77,7 @@ void test2() { } void test3() { - SRaftCfgIndex *pRaftCfgIndex = raftCfgIndexOpen(pFile); + SRaftCfgIndex* pRaftCfgIndex = raftCfgIndexOpen(pFile); raftCfgIndexLog2((char*)"==test3==", pRaftCfgIndex); raftCfgIndexClose(pRaftCfgIndex); diff --git a/source/libs/sync/test/syncReconfigFinishTest.cpp b/source/libs/sync/test/syncReconfigFinishTest.cpp index 2aac38bbd1c71effe2662fa90b5cdfff3fa2db19..5b283c5829464891e6a2529a1b038bd2a1501c48 100644 --- a/source/libs/sync/test/syncReconfigFinishTest.cpp +++ b/source/libs/sync/test/syncReconfigFinishTest.cpp @@ -69,7 +69,7 @@ void test1() { void test2() { SyncReconfigFinish *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncReconfigFinishSerialize(pMsg, serialized, len); SyncReconfigFinish *pMsg2 = syncReconfigFinishBuild(1000); syncReconfigFinishDeserialize(serialized, len, pMsg2); @@ -83,7 +83,7 @@ void test2() { void test3() { SyncReconfigFinish *pMsg = createMsg(); uint32_t len; - char * serialized = syncReconfigFinishSerialize2(pMsg, &len); + char *serialized = syncReconfigFinishSerialize2(pMsg, &len); SyncReconfigFinish *pMsg2 = syncReconfigFinishDeserialize2(serialized, len); syncReconfigFinishLog2((char *)"test3: SyncReconfigFinishSerialize2 -> syncReconfigFinishDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncRefTest.cpp b/source/libs/sync/test/syncRefTest.cpp index 90923a87ee98031898351147bdd355aa5ba89beb..c5132018a22f525bd74b934a6ea0906120d90172 100644 --- a/source/libs/sync/test/syncRefTest.cpp +++ b/source/libs/sync/test/syncRefTest.cpp @@ -25,7 +25,7 @@ int g = 100; typedef struct SyncObj { int64_t rid; - void * data; + void *data; char name[32]; int counter; } SyncObj; diff --git a/source/libs/sync/test/syncRequestVoteReplyTest.cpp b/source/libs/sync/test/syncRequestVoteReplyTest.cpp index d9fe6fa0118ea3daee3adf679816e0cd81c4980f..3d9db17725adfa76333e1368bbae27774384f85c 100644 --- a/source/libs/sync/test/syncRequestVoteReplyTest.cpp +++ b/source/libs/sync/test/syncRequestVoteReplyTest.cpp @@ -34,7 +34,7 @@ void test1() { void test2() { SyncRequestVoteReply *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncRequestVoteReplySerialize(pMsg, serialized, len); SyncRequestVoteReply *pMsg2 = syncRequestVoteReplyBuild(1000); syncRequestVoteReplyDeserialize(serialized, len, pMsg2); @@ -48,7 +48,7 @@ void test2() { void test3() { SyncRequestVoteReply *pMsg = createMsg(); uint32_t len; - char * serialized = syncRequestVoteReplySerialize2(pMsg, &len); + char *serialized = syncRequestVoteReplySerialize2(pMsg, &len); SyncRequestVoteReply *pMsg2 = syncRequestVoteReplyDeserialize2(serialized, len); syncRequestVoteReplyLog2((char *)"test3: syncRequestVoteReplySerialize3 -> syncRequestVoteReplyDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncRequestVoteTest.cpp b/source/libs/sync/test/syncRequestVoteTest.cpp index 4c6d7f94ad940e56264b17e80bb1e2b7b2a17997..94e1504add73294cc445b59b1a7158bb38af39b1 100644 --- a/source/libs/sync/test/syncRequestVoteTest.cpp +++ b/source/libs/sync/test/syncRequestVoteTest.cpp @@ -35,7 +35,7 @@ void test1() { void test2() { SyncRequestVote *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncRequestVoteSerialize(pMsg, serialized, len); SyncRequestVote *pMsg2 = syncRequestVoteBuild(1000); syncRequestVoteDeserialize(serialized, len, pMsg2); @@ -49,7 +49,7 @@ void test2() { void test3() { SyncRequestVote *pMsg = createMsg(); uint32_t len; - char * serialized = syncRequestVoteSerialize2(pMsg, &len); + char *serialized = syncRequestVoteSerialize2(pMsg, &len); SyncRequestVote *pMsg2 = syncRequestVoteDeserialize2(serialized, len); syncRequestVoteLog2((char *)"test3: syncRequestVoteSerialize3 -> syncRequestVoteDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotRspTest.cpp b/source/libs/sync/test/syncSnapshotRspTest.cpp index f689d47aaffc938138838f96ee3a3b6e999a509c..89348da6175403f36d9edf25d70a587e3e3617f7 100644 --- a/source/libs/sync/test/syncSnapshotRspTest.cpp +++ b/source/libs/sync/test/syncSnapshotRspTest.cpp @@ -38,7 +38,7 @@ void test1() { void test2() { SyncSnapshotRsp *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncSnapshotRspSerialize(pMsg, serialized, len); SyncSnapshotRsp *pMsg2 = syncSnapshotRspBuild(1000); syncSnapshotRspDeserialize(serialized, len, pMsg2); @@ -52,7 +52,7 @@ void test2() { void test3() { SyncSnapshotRsp *pMsg = createMsg(); uint32_t len; - char * serialized = syncSnapshotRspSerialize2(pMsg, &len); + char *serialized = syncSnapshotRspSerialize2(pMsg, &len); SyncSnapshotRsp *pMsg2 = syncSnapshotRspDeserialize2(serialized, len); syncSnapshotRspLog2((char *)"test3: syncSnapshotRspSerialize2 -> syncSnapshotRspDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotSendTest.cpp b/source/libs/sync/test/syncSnapshotSendTest.cpp index ca7916359ef2338dea9bf56e6a84cbf52abc839b..6fcfa6f6c490134e13a581963b200e0d7c466d42 100644 --- a/source/libs/sync/test/syncSnapshotSendTest.cpp +++ b/source/libs/sync/test/syncSnapshotSendTest.cpp @@ -48,7 +48,7 @@ void test1() { void test2() { SyncSnapshotSend *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncSnapshotSendSerialize(pMsg, serialized, len); SyncSnapshotSend *pMsg2 = syncSnapshotSendBuild(pMsg->dataLen, 1000); syncSnapshotSendDeserialize(serialized, len, pMsg2); @@ -62,7 +62,7 @@ void test2() { void test3() { SyncSnapshotSend *pMsg = createMsg(); uint32_t len; - char * serialized = syncSnapshotSendSerialize2(pMsg, &len); + char *serialized = syncSnapshotSendSerialize2(pMsg, &len); SyncSnapshotSend *pMsg2 = syncSnapshotSendDeserialize2(serialized, len); syncSnapshotSendLog2((char *)"test3: syncSnapshotSendSerialize2 -> syncSnapshotSendDeserialize2 ", pMsg2); diff --git a/source/libs/sync/test/syncSnapshotTest.cpp b/source/libs/sync/test/syncSnapshotTest.cpp index e0d33598b0706fe1ad000313e34bdcebc19fea2a..3dc85180728c4a287758156b47309e48a7cc01cd 100644 --- a/source/libs/sync/test/syncSnapshotTest.cpp +++ b/source/libs/sync/test/syncSnapshotTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *gSyncNode; SyncIndex snapshotLastApplyIndex = SYNC_INDEX_INVALID; diff --git a/source/libs/sync/test/syncTimeoutTest.cpp b/source/libs/sync/test/syncTimeoutTest.cpp index e60fabe38bd007d3f7d0b62bbe275cfacc1cc10b..bb0d71f00327722644273a62a3dd592b88207561 100644 --- a/source/libs/sync/test/syncTimeoutTest.cpp +++ b/source/libs/sync/test/syncTimeoutTest.cpp @@ -30,7 +30,7 @@ void test1() { void test2() { SyncTimeout *pMsg = createMsg(); uint32_t len = pMsg->bytes; - char * serialized = (char *)taosMemoryMalloc(len); + char *serialized = (char *)taosMemoryMalloc(len); syncTimeoutSerialize(pMsg, serialized, len); SyncTimeout *pMsg2 = syncTimeoutBuild(); syncTimeoutDeserialize(serialized, len, pMsg2); @@ -44,7 +44,7 @@ void test2() { void test3() { SyncTimeout *pMsg = createMsg(); uint32_t len; - char * serialized = syncTimeoutSerialize2(pMsg, &len); + char *serialized = syncTimeoutSerialize2(pMsg, &len); SyncTimeout *pMsg2 = syncTimeoutDeserialize2(serialized, len); syncTimeoutLog2((char *)"test3: syncTimeoutSerialize3 -> syncTimeoutDeserialize2 ", pMsg2); @@ -80,7 +80,7 @@ void test5() { void test6() { SyncTimeout *pMsg = createMsg(); - char * jsonStr = syncTimeout2Str(pMsg); + char *jsonStr = syncTimeout2Str(pMsg); sTrace("jsonStr: %s", jsonStr); syncUtilJson2Line(jsonStr); diff --git a/source/libs/sync/test/syncWriteTest.cpp b/source/libs/sync/test/syncWriteTest.cpp index 3bf068e3c7c45025f13b614d0ef73df6017d6a10..b185f52f7547d1a60541177f3a7374f3ed694081 100644 --- a/source/libs/sync/test/syncWriteTest.cpp +++ b/source/libs/sync/test/syncWriteTest.cpp @@ -25,8 +25,8 @@ int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; SSyncInfo syncInfo; -SSyncFSM * pFsm; -SWal * pWal; +SSyncFSM *pFsm; +SWal *pWal; SSyncNode *gSyncNode; const char *pDir = "./syncWriteTest"; diff --git a/source/libs/tfs/inc/tfsInt.h b/source/libs/tfs/inc/tfsInt.h index 8e77dc8c0cfbc69d116a2f874aa24a5b01256e1d..713f548e9ece3486f744097c42ddd81614175b94 100644 --- a/source/libs/tfs/inc/tfsInt.h +++ b/source/libs/tfs/inc/tfsInt.h @@ -26,12 +26,14 @@ #include "tlog.h" // For debug purpose +// clang-format off #define fFatal(...) { if (fsDebugFlag & DEBUG_FATAL) { taosPrintLog("TFS FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} #define fError(...) { if (fsDebugFlag & DEBUG_ERROR) { taosPrintLog("TFS ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} #define fWarn(...) { if (fsDebugFlag & DEBUG_WARN) { taosPrintLog("TFS WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} #define fInfo(...) { if (fsDebugFlag & DEBUG_INFO) { taosPrintLog("TFS ", DEBUG_INFO, 255, __VA_ARGS__); }} #define fDebug(...) { if (fsDebugFlag & DEBUG_DEBUG) { taosPrintLog("TFS ", DEBUG_DEBUG, fsDebugFlag, __VA_ARGS__); }} #define fTrace(...) { if (fsDebugFlag & DEBUG_TRACE) { taosPrintLog("TFS ", DEBUG_TRACE, fsDebugFlag, __VA_ARGS__); }} +// clang-format on typedef struct { int32_t level; @@ -42,12 +44,12 @@ typedef struct { typedef struct { TdThreadSpinlock lock; - int32_t level; - int32_t nextid; // next disk id to allocate - int32_t ndisk; // # of disks mounted to this tier - int32_t nAvailDisks; // # of Available disks - STfsDisk *disks[TFS_MAX_DISKS_PER_TIER]; - SDiskSize size; + int32_t level; + int32_t nextid; // next disk id to allocate + int32_t ndisk; // # of disks mounted to this tier + int32_t nAvailDisks; // # of Available disks + STfsDisk *disks[TFS_MAX_DISKS_PER_TIER]; + SDiskSize size; } STfsTier; typedef struct { @@ -65,10 +67,10 @@ typedef struct STfsDir { typedef struct STfs { TdThreadSpinlock lock; - SDiskSize size; - int32_t nlevel; - STfsTier tiers[TFS_MAX_TIERS]; - SHashObj *hash; // name to did map + SDiskSize size; + int32_t nlevel; + STfsTier tiers[TFS_MAX_TIERS]; + SHashObj *hash; // name to did map } STfs; STfsDisk *tfsNewDisk(int32_t level, int32_t id, const char *dir); @@ -82,15 +84,15 @@ void tfsUpdateTierSize(STfsTier *pTier); int32_t tfsAllocDiskOnTier(STfsTier *pTier); void tfsPosNextId(STfsTier *pTier); -#define tfsLockTier(pTier) taosThreadSpinLock(&(pTier)->lock) +#define tfsLockTier(pTier) taosThreadSpinLock(&(pTier)->lock) #define tfsUnLockTier(pTier) taosThreadSpinUnlock(&(pTier)->lock) -#define tfsLock(pTfs) taosThreadSpinLock(&(pTfs)->lock) +#define tfsLock(pTfs) taosThreadSpinLock(&(pTfs)->lock) #define tfsUnLock(pTfs) taosThreadSpinUnlock(&(pTfs)->lock) #define TFS_TIER_AT(pTfs, level) (&(pTfs)->tiers[level]) -#define TFS_DISK_AT(pTfs, did) ((pTfs)->tiers[(did).level].disks[(did).id]) -#define TFS_PRIMARY_DISK(pTfs) ((pTfs)->tiers[0].disks[0]) +#define TFS_DISK_AT(pTfs, did) ((pTfs)->tiers[(did).level].disks[(did).id]) +#define TFS_PRIMARY_DISK(pTfs) ((pTfs)->tiers[0].disks[0]) #define TMPNAME_LEN (TSDB_FILENAME_LEN * 2 + 32) diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index b8786a85a971b658ebc91b2040c5b7078ac9fbfb..943611ee27c6f1d6bfa51dfff211bf723764f88f 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -213,7 +213,7 @@ void tfsDirname(const STfsFile *pFile, char *dest) { void tfsAbsoluteName(STfs *pTfs, SDiskID diskId, const char *rname, char *aname) { STfsDisk *pDisk = TFS_DISK_AT(pTfs, diskId); - + snprintf(aname, TSDB_FILENAME_LEN, "%s%s%s", pDisk->path, TD_DIRSEP, rname); } @@ -285,7 +285,7 @@ int32_t tfsMkdir(STfs *pTfs, const char *rname) { int32_t tfsRmdir(STfs *pTfs, const char *rname) { ASSERT(rname[0] != 0); - + char aname[TMPNAME_LEN] = "\0"; for (int32_t level = 0; level < pTfs->nlevel; level++) { diff --git a/source/libs/tfs/test/tfsTest.cpp b/source/libs/tfs/test/tfsTest.cpp index b7858a22ebce50046e48ab05a32874639ab43aba..f4b0adf1f7256618f80e09ce234997719edbb004 100644 --- a/source/libs/tfs/test/tfsTest.cpp +++ b/source/libs/tfs/test/tfsTest.cpp @@ -16,7 +16,7 @@ class TfsTest : public ::testing::Test { protected: - #ifdef _TD_DARWIN_64 +#ifdef _TD_DARWIN_64 static void SetUpTestSuite() { root = "/private" TD_TMP_DIR_PATH "tfsTest"; } #else static void SetUpTestSuite() { root = TD_TMP_DIR_PATH "tfsTest"; } @@ -303,7 +303,7 @@ TEST_F(TfsTest, 04_File) { TEST_F(TfsTest, 05_MultiDisk) { int32_t code = 0; - #ifdef _TD_DARWIN_64 +#ifdef _TD_DARWIN_64 const char *root00 = "/private" TD_TMP_DIR_PATH "tfsTest00"; const char *root01 = "/private" TD_TMP_DIR_PATH "tfsTest01"; const char *root10 = "/private" TD_TMP_DIR_PATH "tfsTest10"; diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index c6f3066be72c289b3e2bd57d1b4b995c15fc7dac..b83f84e3f2ea1a0e008a1277599848b6c3b6ea43 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -200,15 +200,13 @@ typedef enum { ConnNormal, ConnAcquire, ConnRelease, ConnBroken, ConnInPool } Co #define TRANS_MSG_OVERHEAD (sizeof(STransMsgHead)) #define transHeadFromCont(cont) ((STransMsgHead*)((char*)cont - sizeof(STransMsgHead))) -#define transContFromHead(msg) (msg + sizeof(STransMsgHead)) +#define transContFromHead(msg) (((char*)msg) + sizeof(STransMsgHead)) #define transMsgLenFromCont(contLen) (contLen + sizeof(STransMsgHead)) #define transContLenFromMsg(msgLen) (msgLen - sizeof(STransMsgHead)); #define transIsReq(type) (type & 1U) #define transLabel(trans) ((STrans*)trans)->label -void transFreeMsg(void* msg); -// typedef struct SConnBuffer { char* buf; int len; @@ -415,6 +413,10 @@ void transThreadOnce(); void transInit(); void transCleanup(); +void transFreeMsg(void* msg); +int32_t transCompressMsg(char* msg, int32_t len); +int32_t transDecompressMsg(char** msg, int32_t len); + int32_t transOpenRefMgt(int size, void (*func)(void*)); void transCloseRefMgt(int32_t refMgt); int64_t transAddExHandle(int32_t refMgt, void* p); diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index 6aeeffa1925038050f14b25f2d422177a072c95a..b9167501e279fcf4432e68782390a1e93d56b1d8 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -16,9 +16,7 @@ #ifndef _TD_TRANSPORT_INT_H_ #define _TD_TRANSPORT_INT_H_ -#ifdef USE_UV #include -#endif #include "lz4.h" #include "os.h" #include "taoserror.h" @@ -34,8 +32,6 @@ extern "C" { #endif -#ifdef USE_UV - void* taosInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle); void* taosInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle); @@ -51,19 +47,20 @@ typedef struct { char label[TSDB_LABEL_LEN]; char user[TSDB_UNI_LEN]; // meter ID + int32_t compressSize; // -1: no compress, 0 : all data compressed, size: compress data if larger than size + int8_t encryption; // encrypt or not + void (*cfp)(void* parent, SRpcMsg*, SEpSet*); bool (*retry)(int32_t code, tmsg_t msgType); bool (*startTimer)(int32_t code, tmsg_t msgType); - int index; + int index; void* parent; void* tcphandle; // returned handle from TCP initialization int64_t refId; TdThreadMutex mutex; } SRpcInfo; -#endif // USE_LIBUV - #ifdef __cplusplus } #endif diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 9e0a8f2a10c282cc8ef20e59f89aed477d5c1eef..c82af0d0e9b68a3606718bdef47bb783c7289c54 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -45,6 +45,10 @@ void* rpcOpen(const SRpcInit* pInit) { if (pInit->label) { tstrncpy(pRpc->label, pInit->label, TSDB_LABEL_LEN); } + + pRpc->compressSize = pInit->compressSize; + pRpc->encryption = pInit->encryption; + // register callback handle pRpc->cfp = pInit->cfp; pRpc->retry = pInit->rfp; @@ -96,8 +100,8 @@ void rpcCloseImpl(void* arg) { taosMemoryFree(pRpc); } -void* rpcMallocCont(int32_t contLen) { - int32_t size = contLen + TRANS_MSG_OVERHEAD; +void* rpcMallocCont(int64_t contLen) { + int64_t size = contLen + TRANS_MSG_OVERHEAD; char* start = taosMemoryCalloc(1, size); if (start == NULL) { tError("failed to malloc msg, size:%d", size); @@ -116,11 +120,11 @@ void rpcFreeCont(void* cont) { tTrace("rpc free cont:%p", (char*)cont - TRANS_MSG_OVERHEAD); } -void* rpcReallocCont(void* ptr, int32_t contLen) { +void* rpcReallocCont(void* ptr, int64_t contLen) { if (ptr == NULL) return rpcMallocCont(contLen); char* st = (char*)ptr - TRANS_MSG_OVERHEAD; - int32_t sz = contLen + TRANS_MSG_OVERHEAD; + int64_t sz = contLen + TRANS_MSG_OVERHEAD; st = taosMemoryRealloc(st, sz); if (st == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; @@ -130,9 +134,6 @@ void* rpcReallocCont(void* ptr, int32_t contLen) { return st + TRANS_MSG_OVERHEAD; } -int32_t rpcReportProgress(void* pConn, char* pCont, int32_t contLen) { return -1; } -void rpcCancelRequest(int64_t rid) { return; } - int rpcSendRequest(void* shandle, const SEpSet* pEpSet, SRpcMsg* pMsg, int64_t* pRid) { return transSendRequest(shandle, pEpSet, pMsg, NULL); } diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index bd99a23267e740e188ca4bbf02034cafc1c257a6..83323725bed859b755490f56029bb1bab6f621d0 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -319,13 +319,18 @@ void cliHandleResp(SCliConn* conn) { } STransMsgHead* pHead = NULL; - if (transDumpFromBuffer(&conn->readBuf, (char**)&pHead) <= 0) { + + int32_t msgLen = transDumpFromBuffer(&conn->readBuf, (char**)&pHead); + if (msgLen <= 0) { tDebug("%s conn %p recv invalid packet ", CONN_GET_INST_LABEL(conn), conn); return; } + + if (transDecompressMsg((char**)&pHead, msgLen) < 0) { + tDebug("%s conn %p recv invalid packet, failed to decompress", CONN_GET_INST_LABEL(conn), conn); + } pHead->code = htonl(pHead->code); pHead->msgLen = htonl(pHead->msgLen); - if (cliRecvReleaseReq(conn, pHead)) { return; } @@ -374,7 +379,7 @@ void cliHandleResp(SCliConn* conn) { STraceId* trace = &transMsg.info.traceId; tGDebug("%s conn %p %s received from %s, local info:%s, len:%d, code str:%s", CONN_GET_INST_LABEL(conn), conn, - TMSG_INFO(pHead->msgType), conn->dst, conn->src, transMsg.contLen, tstrerror(transMsg.code)); + TMSG_INFO(pHead->msgType), conn->dst, conn->src, msgLen, tstrerror(transMsg.code)); if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { tDebug("%s except, conn %p read while cli ignore it", CONN_GET_INST_LABEL(conn), conn); @@ -553,7 +558,7 @@ static void addConnToPool(void* pool, SCliConn* conn) { if (conn->list->size >= 50) { STaskArg* arg = taosMemoryCalloc(1, sizeof(STaskArg)); arg->param1 = conn; - arg->param2 = thrd; + arg->param2 = NULL; STrans* pTransInst = thrd->pTransInst; conn->task = transDQSched(thrd->timeoutQueue, doCloseIdleConn, arg, CONN_PERSIST_TIME(pTransInst->idleTime)); @@ -772,20 +777,17 @@ void cliSend(SCliConn* pConn) { memcpy(pHead->user, pTransInst->user, strlen(pTransInst->user)); pHead->traceId = pMsg->info.traceId; pHead->magicNum = htonl(TRANS_MAGIC_NUM); - - STraceId* trace = &pMsg->info.traceId; - tGDebug("%s conn %p %s is sent to %s, local info %s, len:%d", CONN_GET_INST_LABEL(pConn), pConn, - TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, pMsg->contLen); - if (pHead->persist == 1) { CONN_SET_PERSIST_BY_APP(pConn); } + STraceId* trace = &pMsg->info.traceId; + if (pTransInst->startTimer != NULL && pTransInst->startTimer(0, pMsg->msgType)) { uv_timer_t* timer = taosArrayGetSize(pThrd->timerList) > 0 ? *(uv_timer_t**)taosArrayPop(pThrd->timerList) : NULL; if (timer == NULL) { - tDebug("no avaiable timer, create"); timer = taosMemoryCalloc(1, sizeof(uv_timer_t)); + tDebug("no available timer, create a timer %p", timer); uv_timer_init(pThrd->loop, timer); } timer->data = pConn; @@ -795,6 +797,13 @@ void cliSend(SCliConn* pConn) { uv_timer_start((uv_timer_t*)pConn->timer, cliReadTimeoutCb, TRANS_READ_TIMEOUT, 0); } + if (pTransInst->compressSize != -1 && pTransInst->compressSize < pMsg->contLen) { + msgLen = transCompressMsg(pMsg->pCont, pMsg->contLen) + sizeof(STransMsgHead); + pHead->msgLen = (int32_t)htonl((uint32_t)msgLen); + } + tGDebug("%s conn %p %s is sent to %s, local info %s, len:%d", CONN_GET_INST_LABEL(pConn), pConn, + TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, msgLen); + uv_buf_t wb = uv_buf_init((char*)pHead, msgLen); uv_write_t* req = transReqQueuePush(&pConn->wreqQueue); @@ -1275,17 +1284,13 @@ FORCE_INLINE int cliRBChoseIdx(STrans* pTransInst) { } static FORCE_INLINE void doDelayTask(void* param) { STaskArg* arg = param; - SCliMsg* pMsg = arg->param1; - SCliThrd* pThrd = arg->param2; + cliHandleReq((SCliMsg*)arg->param1, (SCliThrd*)arg->param2); taosMemoryFree(arg); - - cliHandleReq(pMsg, pThrd); } static void doCloseIdleConn(void* param) { STaskArg* arg = param; SCliConn* conn = arg->param1; - SCliThrd* pThrd = arg->param2; tTrace("%s conn %p idle, close it", CONN_GET_INST_LABEL(conn), conn); conn->task = NULL; cliDestroyConn(conn, true); diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index e86314d4bd7f4dc7b15881ac063ddf2a24965ba4..42079ff005bf7fac9802c2435fbb64ed8912c68d 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -23,52 +23,63 @@ static TdThreadOnce transModuleInit = PTHREAD_ONCE_INIT; static int32_t refMgt; static int32_t instMgt; -bool transCompressMsg(char* msg, int32_t len, int32_t* flen) { - return false; - // SRpcHead* pHead = rpcHeadFromCont(pCont); - bool succ = false; - int overhead = sizeof(STransCompMsg); - if (!NEEDTO_COMPRESSS_MSG(len)) { - return succ; - } +int32_t transCompressMsg(char* msg, int32_t len) { + int32_t ret = 0; + int compHdr = sizeof(STransCompMsg); + STransMsgHead* pHead = transHeadFromCont(msg); - char* buf = taosMemoryMalloc(len + overhead + 8); // 8 extra bytes + char* buf = taosMemoryMalloc(len + compHdr + 8); // 8 extra bytes if (buf == NULL) { tError("failed to allocate memory for rpc msg compression, contLen:%d", len); - *flen = len; - return succ; + ret = len; + return ret; } - int32_t clen = LZ4_compress_default(msg, buf, len, len + overhead); - tDebug("compress rpc msg, before:%d, after:%d, overhead:%d", len, clen, overhead); + int32_t clen = LZ4_compress_default(msg, buf, len, len + compHdr); /* * only the compressed size is less than the value of contLen - overhead, the compression is applied * The first four bytes is set to 0, the second four bytes are utilized to keep the original length of message */ - if (clen > 0 && clen < len - overhead) { + if (clen > 0 && clen < len - compHdr) { STransCompMsg* pComp = (STransCompMsg*)msg; pComp->reserved = 0; pComp->contLen = htonl(len); - memcpy(msg + overhead, buf, clen); + memcpy(msg + compHdr, buf, clen); tDebug("compress rpc msg, before:%d, after:%d", len, clen); - *flen = clen + overhead; - succ = true; + ret = clen + compHdr; + pHead->comp = 1; } else { - *flen = len; - succ = false; + ret = len; + pHead->comp = 0; } taosMemoryFree(buf); - return succ; + return ret; } -bool transDecompressMsg(char* msg, int32_t len, int32_t* flen) { - // impl later - return false; - STransCompMsg* pComp = (STransCompMsg*)msg; +int32_t transDecompressMsg(char** msg, int32_t len) { + STransMsgHead* pHead = (STransMsgHead*)(*msg); + if (pHead->comp == 0) return 0; + + char* pCont = transContFromHead(pHead); + STransCompMsg* pComp = (STransCompMsg*)pCont; + int32_t oriLen = htonl(pComp->contLen); + + char* buf = taosMemoryCalloc(1, oriLen + sizeof(STransMsgHead)); + STransMsgHead* pNewHead = (STransMsgHead*)buf; + + int32_t decompLen = LZ4_decompress_safe(pCont + sizeof(STransCompMsg), pNewHead->content, + len - sizeof(STransMsgHead) - sizeof(STransCompMsg), oriLen); + memcpy((char*)pNewHead, (char*)pHead, sizeof(STransMsgHead)); - int overhead = sizeof(STransCompMsg); - int clen = 0; - return false; + pNewHead->msgLen = htonl(oriLen + sizeof(STransMsgHead)); + + taosMemoryFree(pHead); + + *msg = buf; + if (decompLen != oriLen) { + return -1; + } + return 0; } void transFreeMsg(void* msg) { diff --git a/source/libs/transport/src/transSvr.c b/source/libs/transport/src/transSvr.c index c63f8f398b1c6d8ebb64992c8aeaefe05d010211..57bf8a34b3c9dc0d74516b456deab8eba27083f4 100644 --- a/source/libs/transport/src/transSvr.c +++ b/source/libs/transport/src/transSvr.c @@ -186,16 +186,22 @@ static void uvHandleActivityTimeout(uv_timer_t* handle) { static bool uvHandleReq(SSvrConn* pConn) { STrans* pTransInst = pConn->pTransInst; - STransMsgHead* msg = NULL; - int msgLen = transDumpFromBuffer(&pConn->readBuf, (char**)&msg); + STransMsgHead* pHead = NULL; + + int msgLen = transDumpFromBuffer(&pConn->readBuf, (char**)&pHead); if (msgLen <= 0) { tError("%s conn %p read invalid packet", transLabel(pTransInst), pConn); return false; } - STransMsgHead* pHead = (STransMsgHead*)msg; + if (transDecompressMsg((char**)&pHead, msgLen) < 0) { + tDebug("%s conn %p recv invalid packet, failed to decompress", transLabel(pTransInst), pConn); + return false; + } + pHead->code = htonl(pHead->code); pHead->msgLen = htonl(pHead->msgLen); + memcpy(pConn->user, pHead->user, strlen(pHead->user)); if (uvRecvReleaseReq(pConn, pHead)) { @@ -229,10 +235,10 @@ static bool uvHandleReq(SSvrConn* pConn) { transRefSrvHandle(pConn); tGDebug("%s conn %p %s received from %s, local info:%s, len:%d", transLabel(pTransInst), pConn, - TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen); + TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen); } else { tGDebug("%s conn %p %s received from %s, local info:%s, len:%d, resp:%d, code:%d", transLabel(pTransInst), pConn, - TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, transMsg.contLen, pHead->noResp, transMsg.code); + TMSG_INFO(transMsg.msgType), pConn->dst, pConn->src, msgLen, pHead->noResp, transMsg.code); } // pHead->noResp = 1, @@ -399,17 +405,22 @@ static void uvPrepareSendData(SSvrMsg* smsg, uv_buf_t* wb) { pHead->release = smsg->type == Release ? 1 : 0; pHead->code = htonl(pMsg->code); + pHead->msgLen = htonl(pMsg->contLen + sizeof(STransMsgHead)); char* msg = (char*)pHead; int32_t len = transMsgLenFromCont(pMsg->contLen); - STrans* pTransInst = pConn->pTransInst; + STrans* pTransInst = pConn->pTransInst; + if (pTransInst->compressSize != -1 && pTransInst->compressSize < pMsg->contLen) { + len = transCompressMsg(pMsg->pCont, pMsg->contLen) + sizeof(STransMsgHead); + pHead->msgLen = (int32_t)htonl((uint32_t)len); + } + STraceId* trace = &pMsg->info.traceId; tGDebug("%s conn %p %s is sent to %s, local info:%s, len:%d", transLabel(pTransInst), pConn, - TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, pMsg->contLen); - pHead->msgLen = htonl(len); + TMSG_INFO(pHead->msgType), pConn->dst, pConn->src, len); - wb->base = msg; + wb->base = (char*)pHead; wb->len = len; } @@ -1160,6 +1171,11 @@ _return2: return -1; } int transSendResponse(const STransMsg* msg) { + if (msg->info.noResp) { + rpcFreeCont(msg->pCont); + tTrace("no need send resp"); + return 0; + } SExHandle* exh = msg->info.handle; int64_t refId = msg->info.refId; ASYNC_CHECK_HANDLE(exh, refId); @@ -1198,6 +1214,8 @@ int transRegisterMsg(const STransMsg* msg) { ASYNC_CHECK_HANDLE(exh, refId); STransMsg tmsg = *msg; + tmsg.info.noResp = 1; + tmsg.info.refId = refId; SWorkThrd* pThrd = exh->pThrd; diff --git a/source/libs/transport/test/transUT.cpp b/source/libs/transport/test/transUT.cpp index b55f771ebd5181503d1f85cd1dccb986218f88d1..92f0bf11cf8fae8670cf625f3f0453f66ba5aef4 100644 --- a/source/libs/transport/test/transUT.cpp +++ b/source/libs/transport/test/transUT.cpp @@ -99,7 +99,7 @@ class Client { private: tsem_t sem; SRpcInit rpcInit_; - void * transCli; + void *transCli; SRpcMsg resp; }; class Server { @@ -146,7 +146,7 @@ class Server { private: SRpcInit rpcInit_; - void * transSrv; + void *transSrv; }; static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { SRpcMsg rpcMsg = {0}; @@ -330,7 +330,7 @@ TEST_F(TransEnv, clientUserDefined) { TEST_F(TransEnv, cliPersistHandle) { SRpcMsg resp = {0}; - void * handle = NULL; + void *handle = NULL; for (int i = 0; i < 10; i++) { SRpcMsg req = {0}; req.info = resp.info; @@ -366,7 +366,7 @@ TEST_F(TransEnv, srvReleaseHandle) { SRpcMsg resp = {0}; tr->SetSrvContinueSend(processReleaseHandleCb); // tr->Restart(processReleaseHandleCb); - void * handle = NULL; + void *handle = NULL; SRpcMsg req = {0}; for (int i = 0; i < 1; i++) { memset(&req, 0, sizeof(req)); diff --git a/source/libs/transport/test/uv.c b/source/libs/transport/test/uv.c index 1d99bf8fef2a2882d6d59bee4ce04af0a3b3b556..a44f1ca4357b4376891f8f941cfcf29799fd4f2e 100644 --- a/source/libs/transport/test/uv.c +++ b/source/libs/transport/test/uv.c @@ -11,23 +11,23 @@ typedef struct SThreadObj { TdThread thread; - uv_pipe_t * pipe; - uv_loop_t * loop; + uv_pipe_t *pipe; + uv_loop_t *loop; uv_async_t *workerAsync; // int fd; } SThreadObj; typedef struct SServerObj { uv_tcp_t server; - uv_loop_t * loop; + uv_loop_t *loop; int workerIdx; int numOfThread; SThreadObj **pThreadObj; - uv_pipe_t ** pipe; + uv_pipe_t **pipe; } SServerObj; typedef struct SConnCtx { - uv_tcp_t * pClient; + uv_tcp_t *pClient; uv_timer_t *pTimer; uv_async_t *pWorkerAsync; int ref; diff --git a/source/os/src/osAtomic.c b/source/os/src/osAtomic.c index a9eb23abba4066bad4c54322fa0b65aa63458f71..a54c301de9fddd09622c5204c2ac501067457527 100644 --- a/source/os/src/osAtomic.c +++ b/source/os/src/osAtomic.c @@ -193,11 +193,11 @@ void* interlocked_sub_fetch_ptr(void* volatile* ptr, void* val) { } int32_t interlocked_fetch_sub_32(int32_t volatile* ptr, int32_t val) { return _InterlockedExchangeAdd(ptr, -val); } -int64_t interlocked_fetch_sub_64(int64_t volatile* ptr, int64_t val) { +int64_t interlocked_fetch_sub_64(int64_t volatile* ptr, int64_t val) { #ifdef _TD_WINDOWS_32 - return _InterlockedExchangeAdd((int32_t volatile*)ptr, -(int32_t)val); + return _InterlockedExchangeAdd((int32_t volatile*)ptr, -(int32_t)val); #else - return _InterlockedExchangeAdd64(ptr, -val); + return _InterlockedExchangeAdd64(ptr, -val); #endif } diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index 0cc946ac2182bd351f703a4acab295d1bb223c0f..2902f90f7bca791d08c99c86d4c12d19170229ab 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -31,14 +31,13 @@ typedef struct TdDir { HANDLE hFind; } TdDir; -enum - { - WRDE_NOSPACE = 1, /* Ran out of memory. */ - WRDE_BADCHAR, /* A metachar appears in the wrong place. */ - WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */ - WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */ - WRDE_SYNTAX /* Shell syntax error. */ - }; +enum { + WRDE_NOSPACE = 1, /* Ran out of memory. */ + WRDE_BADCHAR, /* A metachar appears in the wrong place. */ + WRDE_BADVAL, /* Undefined var reference with WRDE_UNDEF. */ + WRDE_CMDSUB, /* Command substitution with WRDE_NOCMD. */ + WRDE_SYNTAX /* Shell syntax error. */ +}; int wordexp(char *words, wordexp_t *pwordexp, int flags) { pwordexp->we_offs = 0; @@ -175,7 +174,7 @@ int32_t taosMulMkDir(const char *dirname) { #ifdef WINDOWS code = _mkdir(temp, 0755); #elif defined(DARWIN) - code = mkdir(dirname, 0777); + code = mkdir(dirname, 0777); #else code = mkdir(temp, 0755); #endif @@ -237,7 +236,7 @@ int32_t taosMulModeMkDir(const char *dirname, int mode) { #ifdef WINDOWS code = _mkdir(temp, mode); #elif defined(DARWIN) - code = mkdir(dirname, 0777); + code = mkdir(dirname, 0777); #else code = mkdir(temp, mode); #endif @@ -301,22 +300,24 @@ void taosRemoveOldFiles(const char *dirname, int32_t keepDays) { int32_t taosExpandDir(const char *dirname, char *outname, int32_t maxlen) { wordexp_t full_path; - switch (wordexp (dirname, &full_path, 0)) { - case 0: - break; - case WRDE_NOSPACE: - wordfree (&full_path); - // printf("failed to expand path:%s since Out of memory\n", dirname); - return -1; - case WRDE_BADCHAR: - // printf("failed to expand path:%s since illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }\n", dirname); - return -1; - case WRDE_SYNTAX: - // printf("failed to expand path:%s since Shell syntax error, such as unbalanced parentheses or unmatched quotes\n", dirname); - return -1; - default: - // printf("failed to expand path:%s since %s\n", dirname, strerror(errno)); - return -1; + switch (wordexp(dirname, &full_path, 0)) { + case 0: + break; + case WRDE_NOSPACE: + wordfree(&full_path); + // printf("failed to expand path:%s since Out of memory\n", dirname); + return -1; + case WRDE_BADCHAR: + // printf("failed to expand path:%s since illegal occurrence of newline or one of |, &, ;, <, >, (, ), {, }\n", + // dirname); + return -1; + case WRDE_SYNTAX: + // printf("failed to expand path:%s since Shell syntax error, such as unbalanced parentheses or unmatched + // quotes\n", dirname); + return -1; + default: + // printf("failed to expand path:%s since %s\n", dirname, strerror(errno)); + return -1; } if (full_path.we_wordv != NULL && full_path.we_wordv[0] != NULL) { @@ -417,7 +418,7 @@ TdDirPtr taosOpenDir(const char *dirname) { DIR *pDir = opendir(dirname); if (pDir == NULL) return NULL; TdDirPtr dirPtr = (TdDirPtr)taosMemoryMalloc(sizeof(TdDir)); - dirPtr->dirEntryPtr = (TdDirEntryPtr)&(dirPtr->dirEntry1); + dirPtr->dirEntryPtr = (TdDirEntryPtr) & (dirPtr->dirEntry1); dirPtr->pDir = pDir; return dirPtr; #else @@ -435,7 +436,7 @@ TdDirEntryPtr taosReadDir(TdDirPtr pDir) { } return (TdDirEntryPtr) & (pDir->dirEntry.findFileData); #elif defined(DARWIN) - if (readdir_r(pDir->pDir, (dirent*)&(pDir->dirEntry), (dirent**)&(pDir->dirEntryPtr)) == 0) { + if (readdir_r(pDir->pDir, (dirent *)&(pDir->dirEntry), (dirent **)&(pDir->dirEntryPtr)) == 0) { return pDir->dirEntryPtr; } else { return NULL; diff --git a/source/os/src/osEnv.c b/source/os/src/osEnv.c index 9511230f8d7ee98e8353b9758d246e963bdc6960..f0442c6fd12a352bc41c36104ed87551de8236e2 100644 --- a/source/os/src/osEnv.c +++ b/source/os/src/osEnv.c @@ -35,7 +35,7 @@ int64_t tsOpenMax = 0; int64_t tsStreamMax = 0; float tsNumOfCores = 0; int64_t tsTotalMemoryKB = 0; -char* tsProcPath = NULL; +char *tsProcPath = NULL; void osDefaultInit() { taosSeedRand(taosSafeRand()); diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index fab933755a73ba23be962cb76b34da002b8a3702..d332d913ca89ff0a80cefd9fececdb2c6279114e 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -58,14 +58,14 @@ typedef struct TdFile { #define FILE_WITH_LOCK 1 -typedef struct AutoDelFile * AutoDelFilePtr; +typedef struct AutoDelFile *AutoDelFilePtr; typedef struct AutoDelFile { - char *name; - AutoDelFilePtr lastAutoDelFilePtr; + char *name; + AutoDelFilePtr lastAutoDelFilePtr; } AutoDelFile; -static TdThreadMutex autoDelFileLock; +static TdThreadMutex autoDelFileLock; static AutoDelFilePtr nowAutoDelFilePtr = NULL; -static TdThreadOnce autoDelFileInit = PTHREAD_ONCE_INIT; +static TdThreadOnce autoDelFileInit = PTHREAD_ONCE_INIT; void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #ifdef WINDOWS @@ -205,10 +205,10 @@ int32_t taosRenameFile(const char *oldName, const char *newName) { int32_t taosStatFile(const char *path, int64_t *size, int32_t *mtime) { #ifdef WINDOWS struct _stati64 fileStat; - int32_t code = _stati64(path, &fileStat); + int32_t code = _stati64(path, &fileStat); #else struct stat fileStat; - int32_t code = stat(path, &fileStat); + int32_t code = stat(path, &fileStat); #endif if (code < 0) { return code; @@ -706,11 +706,11 @@ int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, in int64_t sentbytes; while (leftbytes > 0) { - #ifdef _TD_ARM_32 - sentbytes = sendfile(pFileOut->fd, pFileIn->fd, (long int*)offset, leftbytes); - #else +#ifdef _TD_ARM_32 + sentbytes = sendfile(pFileOut->fd, pFileIn->fd, (long int *)offset, leftbytes); +#else sentbytes = sendfile(pFileOut->fd, pFileIn->fd, offset, leftbytes); - #endif +#endif if (sentbytes == -1) { if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) { continue; diff --git a/source/os/src/osLocale.c b/source/os/src/osLocale.c index c2d10f3668ba2856380eccbdadde74f5d6ed23ef..89216ecaf49e088272c3564377e35bbac4745e7b 100644 --- a/source/os/src/osLocale.c +++ b/source/os/src/osLocale.c @@ -77,7 +77,7 @@ void taosSetSystemLocale(const char *inLocale, const char *inCharSet) { // default locale or user specified locale is not valid, abort launch if (inLocale == NULL || strlen(inLocale) == 0) { - //printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale); + // printf("Invalid locale:%s, please set the valid locale in config file\n", inLocale); } if (!taosValidateEncodec(inCharSet)) { diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index 5d17536874db144591f156de6a3e22adc52111e7..75a963d5c7551ad290d1d2190c24ab07e1ed0953 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -52,36 +52,38 @@ int32_t taosBackTrace(void **buffer, int32_t size) { #pragma comment(lib, "dbghelp.lib") void taosPrintBackTrace() { - #define MAX_STACK_FRAMES 20 - - void *pStack[MAX_STACK_FRAMES]; - - HANDLE process = GetCurrentProcess(); - SymInitialize(process, NULL, TRUE); - WORD frames = CaptureStackBackTrace(1, MAX_STACK_FRAMES, pStack, NULL); - +#define MAX_STACK_FRAMES 20 + + void *pStack[MAX_STACK_FRAMES]; + + HANDLE process = GetCurrentProcess(); + SymInitialize(process, NULL, TRUE); + WORD frames = CaptureStackBackTrace(1, MAX_STACK_FRAMES, pStack, NULL); + char buf_tmp[1024]; - for (WORD i = 0; i < frames; ++i) { - DWORD64 address = (DWORD64)(pStack[i]); - - DWORD64 displacementSym = 0; - char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; - PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; - pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); - pSymbol->MaxNameLen = MAX_SYM_NAME; - - DWORD displacementLine = 0; - IMAGEHLP_LINE64 line; - //SymSetOptions(SYMOPT_LOAD_LINES); - line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); - - if (SymFromAddr(process, address, &displacementSym, pSymbol) && SymGetLineFromAddr64(process, address, &displacementLine, &line)) { - snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName, line.LineNumber, pSymbol->Name); - } else { - snprintf(buf_tmp,sizeof(buf_tmp),"BackTrace error: %d\n",GetLastError()); - } - write(1,buf_tmp,strlen(buf_tmp)); - } + for (WORD i = 0; i < frames; ++i) { + DWORD64 address = (DWORD64)(pStack[i]); + + DWORD64 displacementSym = 0; + char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)]; + PSYMBOL_INFO pSymbol = (PSYMBOL_INFO)buffer; + pSymbol->SizeOfStruct = sizeof(SYMBOL_INFO); + pSymbol->MaxNameLen = MAX_SYM_NAME; + + DWORD displacementLine = 0; + IMAGEHLP_LINE64 line; + // SymSetOptions(SYMOPT_LOAD_LINES); + line.SizeOfStruct = sizeof(IMAGEHLP_LINE64); + + if (SymFromAddr(process, address, &displacementSym, pSymbol) && + SymGetLineFromAddr64(process, address, &displacementLine, &line)) { + snprintf(buf_tmp, sizeof(buf_tmp), "BackTrace %08" PRId64 " %s:%d %s\n", taosGetSelfPthreadId(), line.FileName, + line.LineNumber, pSymbol->Name); + } else { + snprintf(buf_tmp, sizeof(buf_tmp), "BackTrace error: %d\n", GetLastError()); + } + write(1, buf_tmp, strlen(buf_tmp)); + } } #endif #else @@ -126,27 +128,26 @@ int32_t taosBackTrace(void **buffer, int32_t size) { #ifdef USE_ADDR2LINE -#include "osThread.h" -#include "libdwarf.h" #include "dwarf.h" +#include "libdwarf.h" +#include "osThread.h" #define DW_PR_DUu "llu" -typedef struct lookup_table -{ - Dwarf_Line *table; - Dwarf_Line_Context *ctxts; - int cnt; - Dwarf_Addr low; - Dwarf_Addr high; +typedef struct lookup_table { + Dwarf_Line *table; + Dwarf_Line_Context *ctxts; + int cnt; + Dwarf_Addr low; + Dwarf_Addr high; } lookup_tableT; -extern int create_lookup_table(Dwarf_Debug dbg, lookup_tableT *lookup_table); +extern int create_lookup_table(Dwarf_Debug dbg, lookup_tableT *lookup_table); extern void delete_lookup_table(lookup_tableT *lookup_table); -size_t addr = 0; -lookup_tableT lookup_table; -Dwarf_Debug tDbg; +size_t addr = 0; +lookup_tableT lookup_table; +Dwarf_Debug tDbg; static TdThreadOnce traceThreadInit = PTHREAD_ONCE_INIT; void endTrace() { @@ -157,7 +158,7 @@ void endTrace() { } } void startTrace() { - int ret; + int ret; Dwarf_Ptr errarg = 0; FILE *fp = fopen("/proc/self/maps", "r"); @@ -178,7 +179,7 @@ void startTrace() { atexit(endTrace); } static void print_line(Dwarf_Debug dbg, Dwarf_Line line, Dwarf_Addr pc) { - char *linesrc = "??"; + char *linesrc = "??"; Dwarf_Unsigned lineno = 0; if (line) { @@ -189,18 +190,18 @@ static void print_line(Dwarf_Debug dbg, Dwarf_Line line, Dwarf_Addr pc) { if (line) dwarf_dealloc(dbg, linesrc, DW_DLA_STRING); } void taosPrintBackTrace() { - int size = 20; - void **buffer[20]; + int size = 20; + void **buffer[20]; Dwarf_Addr pc; - int32_t frame = 0; - void **ebp; - void **ret = NULL; - size_t func_frame_distance = 0; + int32_t frame = 0; + void **ebp; + void **ret = NULL; + size_t func_frame_distance = 0; taosThreadOnce(&traceThreadInit, startTrace); if (buffer != NULL && size > 0) { - ebp = taosGetEbp(); + ebp = taosGetEbp(); func_frame_distance = (size_t)*ebp - (size_t)ebp; while (ebp && frame < size && (func_frame_distance < (1ULL << 24)) && (func_frame_distance > 0)) { ret = ebp + 1; @@ -227,7 +228,7 @@ void taosPrintBackTrace() { void taosPrintBackTrace() { return; } #endif -void *taosMemoryMalloc(int32_t size) { +void *taosMemoryMalloc(int64_t size) { #ifdef USE_TD_MEMORY void *tmp = malloc(size + sizeof(TdMemoryInfo)); if (tmp == NULL) return NULL; @@ -243,7 +244,7 @@ void *taosMemoryMalloc(int32_t size) { #endif } -void *taosMemoryCalloc(int32_t num, int32_t size) { +void *taosMemoryCalloc(int64_t num, int64_t size) { #ifdef USE_TD_MEMORY int32_t memorySize = num * size; char *tmp = calloc(memorySize + sizeof(TdMemoryInfo), 1); @@ -260,7 +261,7 @@ void *taosMemoryCalloc(int32_t num, int32_t size) { #endif } -void *taosMemoryRealloc(void *ptr, int32_t size) { +void *taosMemoryRealloc(void *ptr, int64_t size) { #ifdef USE_TD_MEMORY if (ptr == NULL) return taosMemoryMalloc(size); @@ -317,7 +318,7 @@ void taosMemoryFree(void *ptr) { #endif } -int32_t taosMemorySize(void *ptr) { +int64_t taosMemorySize(void *ptr) { if (ptr == NULL) return 0; #ifdef USE_TD_MEMORY diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c index 74f1356abf3e24a7b997571989471da761273c4d..f060ab48c9bb9fd45b385c36a77db1e0adba0e6f 100644 --- a/source/os/src/osProc.c +++ b/source/os/src/osProc.c @@ -44,11 +44,11 @@ void taosWaitProc(int32_t pid) { #endif } -void taosKillProc(int32_t pid) { +void taosKillProc(int32_t pid) { #ifdef WINDOWS assert(0); #else - kill(pid, SIGINT); + kill(pid, SIGINT); #endif } diff --git a/source/os/src/osRand.c b/source/os/src/osRand.c index bd2bfa486ec88c87f31c3e95e589ffad777d9be1..4998eb45a4527fd52d9559f5f99fe7f1e5362428 100644 --- a/source/os/src/osRand.c +++ b/source/os/src/osRand.c @@ -16,8 +16,8 @@ #define _DEFAULT_SOURCE #include "os.h" #ifdef WINDOWS -#include "windows.h" #include "wincrypt.h" +#include "windows.h" #else #include #include @@ -27,17 +27,17 @@ void taosSeedRand(uint32_t seed) { return srand(seed); } uint32_t taosRand(void) { return rand(); } -uint32_t taosRandR(uint32_t *pSeed) { +uint32_t taosRandR(uint32_t* pSeed) { #ifdef WINDOWS - return rand_s(pSeed); + return rand_s(pSeed); #else - return rand_r(pSeed); + return rand_r(pSeed); #endif } uint32_t taosSafeRand(void) { #ifdef WINDOWS - uint32_t seed = taosRand(); + uint32_t seed = taosRand(); HCRYPTPROV hCryptProv; if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) { if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) { @@ -51,7 +51,7 @@ uint32_t taosSafeRand(void) { return seed; #else TdFilePtr pFile; - int seed; + int seed; pFile = taosOpenFile("/dev/urandom", TD_FILE_READ); if (pFile == NULL) { diff --git a/source/os/src/osSignal.c b/source/os/src/osSignal.c index 327beb8999e6fec31a404d2201bce967c6849d1e..cb13523b24fc77ea287bf001f94578d0d5debcd8 100644 --- a/source/os/src/osSignal.c +++ b/source/os/src/osSignal.c @@ -47,7 +47,7 @@ void taosDflSignal(int32_t signum) { signal(signum, SIG_DFL); } -void taosKillChildOnParentStopped() { } +void taosKillChildOnParentStopped() {} #else @@ -73,9 +73,9 @@ void taosIgnSignal(int32_t signum) { signal(signum, SIG_IGN); } void taosDflSignal(int32_t signum) { signal(signum, SIG_DFL); } -void taosKillChildOnParentStopped() { +void taosKillChildOnParentStopped() { #ifndef _TD_DARWIN_64 - prctl(PR_SET_PDEATHSIG, SIGKILL); + prctl(PR_SET_PDEATHSIG, SIGKILL); #endif } diff --git a/source/os/src/osSleep.c b/source/os/src/osSleep.c index 870467ceef398bbc78a162819032800b8d6474ac..a2373f952f6a22a7fd34a12b052502c04206598f 100644 --- a/source/os/src/osSleep.c +++ b/source/os/src/osSleep.c @@ -17,14 +17,13 @@ #define _DEFAULT_SOURCE #include "os.h" - #if !(defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #include #endif void taosSsleep(int32_t s) { #ifdef WINDOWS - Sleep(1000 * s); + Sleep(1000 * s); #else sleep(s); #endif @@ -32,7 +31,7 @@ void taosSsleep(int32_t s) { void taosMsleep(int32_t ms) { #ifdef WINDOWS - Sleep(ms); + Sleep(ms); #else usleep(ms * 1000); #endif @@ -40,14 +39,14 @@ void taosMsleep(int32_t ms) { void taosUsleep(int32_t us) { #ifdef WINDOWS - HANDLE timer; - LARGE_INTEGER interval; - interval.QuadPart = (10 * us); + HANDLE timer; + LARGE_INTEGER interval; + interval.QuadPart = (10 * us); - timer = CreateWaitableTimer(NULL, TRUE, NULL); - SetWaitableTimer(timer, &interval, 0, NULL, NULL, 0); - WaitForSingleObject(timer, INFINITE); - CloseHandle(timer); + timer = CreateWaitableTimer(NULL, TRUE, NULL); + SetWaitableTimer(timer, &interval, 0, NULL, NULL, 0); + WaitForSingleObject(timer, INFINITE); + CloseHandle(timer); #else usleep(us); #endif diff --git a/source/os/src/osString.c b/source/os/src/osString.c index 3619e9584791900321647399b01e76be3af928a3..e2d8ce95dbdfe7c2f23949df317b9a9e9fa6f99c 100644 --- a/source/os/src/osString.c +++ b/source/os/src/osString.c @@ -26,10 +26,10 @@ extern int wcswidth(const wchar_t *s, size_t n); #ifdef WINDOWS char *strsep(char **stringp, const char *delim) { - char * s; + char *s; const char *spanp; int32_t c, sc; - char * tok; + char *tok; if ((s = *stringp) == NULL) return (NULL); for (tok = s;;) { c = *s++; @@ -50,7 +50,7 @@ char *strsep(char **stringp, const char *delim) { /* Duplicate a string, up to at most size characters */ char *strndup(const char *s, int size) { size_t l; - char * s2; + char *s2; l = strlen(s); if (l > size) l = size; s2 = malloc(l + 1); @@ -139,7 +139,7 @@ typedef struct { int8_t inUse; } SConv; -SConv *gConv = NULL; +SConv *gConv = NULL; int32_t convUsed = 0; int32_t gConvMaxNum = 0; @@ -167,7 +167,7 @@ iconv_t taosAcquireConv(int32_t *idx) { *idx = -1; return iconv_open(DEFAULT_UNICODE_ENCODEC, tsCharset); } - + while (true) { int32_t used = atomic_add_fetch_32(&convUsed, 1); if (used > gConvMaxNum) { @@ -175,7 +175,7 @@ iconv_t taosAcquireConv(int32_t *idx) { sched_yield(); continue; } - + break; } diff --git a/source/os/src/osSysinfo.c b/source/os/src/osSysinfo.c index f5f02676af65b4d04f4190221cf05c5aafb9dce3..0a6dad4819a302af7e3c491ec69fee06ac648095 100644 --- a/source/os/src/osSysinfo.c +++ b/source/os/src/osSysinfo.c @@ -136,7 +136,7 @@ static int32_t taosGetSysCpuInfo(SysCpuInfo *cpuInfo) { FILETIME idleTime; FILETIME kernelTime; FILETIME userTime; - bool res = GetSystemTimes(&idleTime, &kernelTime, &userTime); + bool res = GetSystemTimes(&idleTime, &kernelTime, &userTime); if (res) { cpuInfo->idle = CompareFileTime(&pre_idleTime, &idleTime); cpuInfo->system = CompareFileTime(&pre_kernelTime, &kernelTime); @@ -174,14 +174,14 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { #ifdef WINDOWS FILETIME pre_krnlTm = {0}; FILETIME pre_usrTm = {0}; - FILETIME creatTm, exitTm, krnlTm, usrTm; + FILETIME creatTm, exitTm, krnlTm, usrTm; - if (GetThreadTimes(GetCurrentThread(), &creatTm, &exitTm, &krnlTm, &usrTm)) { + if (GetThreadTimes(GetCurrentThread(), &creatTm, &exitTm, &krnlTm, &usrTm)) { cpuInfo->stime = CompareFileTime(&pre_krnlTm, &krnlTm); cpuInfo->utime = CompareFileTime(&pre_usrTm, &usrTm); cpuInfo->cutime = 0; cpuInfo->cstime = 0; - } + } #elif defined(DARWIN) cpuInfo->stime = 0; cpuInfo->utime = 0; @@ -214,7 +214,6 @@ static int32_t taosGetProcCpuInfo(ProcCpuInfo *cpuInfo) { return 0; } - bool taosCheckSystemIsLittleEnd() { union check { int16_t i; @@ -336,12 +335,13 @@ int32_t taosGetOsReleaseName(char *releaseName, int32_t maxLen) { int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { #ifdef WINDOWS - char value[100]; + char value[100]; DWORD bufferSize = sizeof(value); - RegGetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); + RegGetValue(HKEY_LOCAL_MACHINE, "HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", "ProcessorNameString", + RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); tstrncpy(cpuModel, value, maxLen); SYSTEM_INFO si; - memset(&si,0,sizeof(SYSTEM_INFO)); + memset(&si, 0, sizeof(SYSTEM_INFO)); GetSystemInfo(&si); *numOfCores = si.dwNumberOfProcessors; return 0; @@ -416,10 +416,10 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) { } if ((done & 2) == 0) { - *numOfCores = coreCount; - done |= 2; + *numOfCores = coreCount; + done |= 2; } - + return code; #endif } @@ -702,7 +702,7 @@ int32_t taosGetCardInfo(int64_t *receive_bytes, int64_t *transmit_bytes) { if (pFile == NULL) return -1; ssize_t _bytes = 0; - char line[1024]; + char line[1024]; while (!taosEOFFile(pFile)) { int64_t o_rbytes = 0; @@ -776,13 +776,14 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen) { #ifdef WINDOWS GUID guid; CoCreateGuid(&guid); - snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], - guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); + snprintf(uid, uidlen, "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", guid.Data1, guid.Data2, guid.Data3, + guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], + guid.Data4[7]); return 0; #elif defined(_TD_DARWIN_64) uuid_t uuid = {0}; - char buf[37] = {0}; + char buf[37] = {0}; uuid_generate(uuid); // it's caller's responsibility to make enough space for `uid`, that's 36-char + 1-null uuid_unparse_lower(uuid, buf); @@ -929,7 +930,7 @@ void taosSetCoreDump(bool enable) { SysNameInfo taosGetSysNameInfo() { #ifdef WINDOWS SysNameInfo info = {0}; - DWORD dwVersion = GetVersion(); + DWORD dwVersion = GetVersion(); char *tmp = NULL; tmp = getenv("OS"); @@ -971,14 +972,17 @@ SysNameInfo taosGetSysNameInfo() { #endif } - bool taosCheckCurrentInDll() { #ifdef WINDOWS MEMORY_BASIC_INFORMATION mbi; - char path[PATH_MAX] = {0}; - GetModuleFileName(((VirtualQuery(taosCheckCurrentInDll,&mbi,sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL), path, PATH_MAX); + char path[PATH_MAX] = {0}; + GetModuleFileName( + ((VirtualQuery(taosCheckCurrentInDll, &mbi, sizeof(mbi)) != 0) ? (HMODULE)mbi.AllocationBase : NULL), path, + PATH_MAX); int strLastIndex = strlen(path); - if ((path[strLastIndex-3] == 'd' || path[strLastIndex-3] == 'D') && (path[strLastIndex-2] == 'l' || path[strLastIndex-2] == 'L') && (path[strLastIndex-1] == 'l' || path[strLastIndex-1] == 'L')) { + if ((path[strLastIndex - 3] == 'd' || path[strLastIndex - 3] == 'D') && + (path[strLastIndex - 2] == 'l' || path[strLastIndex - 2] == 'L') && + (path[strLastIndex - 1] == 'l' || path[strLastIndex - 1] == 'L')) { return true; } return false; diff --git a/source/os/src/osSystem.c b/source/os/src/osSystem.c index b6f6637601300e9b578d17faeb9397c44292122e..c972aebbcaf8e89b7104e9c9241b5f7d11b6449d 100644 --- a/source/os/src/osSystem.c +++ b/source/os/src/osSystem.c @@ -18,52 +18,52 @@ #include "os.h" #if defined(WINDOWS) -typedef void (*MainWindows)(int argc,char** argv); +typedef void (*MainWindows)(int argc, char** argv); MainWindows mainWindowsFunc = NULL; -SERVICE_STATUS ServiceStatus; +SERVICE_STATUS ServiceStatus; SERVICE_STATUS_HANDLE hServiceStatusHandle; -void WINAPI windowsServiceCtrlHandle(DWORD request) { - switch (request) { - case SERVICE_CONTROL_STOP: - case SERVICE_CONTROL_SHUTDOWN: - raise(SIGINT); - ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; - if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { - DWORD nError = GetLastError(); - printf("failed to send stopped status to windows service: %d",nError); - } - break; - default: - return; - } +void WINAPI windowsServiceCtrlHandle(DWORD request) { + switch (request) { + case SERVICE_CONTROL_STOP: + case SERVICE_CONTROL_SHUTDOWN: + raise(SIGINT); + ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING; + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d", nError); + } + break; + default: + return; + } } -void WINAPI mainWindowsService(int argc,char** argv) { - int ret = 0; - ServiceStatus.dwServiceType = SERVICE_WIN32; - ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; - ServiceStatus.dwCurrentState = SERVICE_START_PENDING; - ServiceStatus.dwWin32ExitCode = 0; - ServiceStatus.dwCheckPoint = 0; - ServiceStatus.dwWaitHint = 0; - ServiceStatus.dwServiceSpecificExitCode = 0; - hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle); - if (hServiceStatusHandle == 0) { - DWORD nError = GetLastError(); - printf("failed to register windows service ctrl handler: %d",nError); - } - - ServiceStatus.dwCurrentState = SERVICE_RUNNING; - if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { - DWORD nError = GetLastError(); - printf("failed to send running status to windows service: %d",nError); - } +void WINAPI mainWindowsService(int argc, char** argv) { + int ret = 0; + ServiceStatus.dwServiceType = SERVICE_WIN32; + ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_PAUSE_CONTINUE | SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN; + ServiceStatus.dwCurrentState = SERVICE_START_PENDING; + ServiceStatus.dwWin32ExitCode = 0; + ServiceStatus.dwCheckPoint = 0; + ServiceStatus.dwWaitHint = 0; + ServiceStatus.dwServiceSpecificExitCode = 0; + hServiceStatusHandle = RegisterServiceCtrlHandler("taosd", &windowsServiceCtrlHandle); + if (hServiceStatusHandle == 0) { + DWORD nError = GetLastError(); + printf("failed to register windows service ctrl handler: %d", nError); + } + + ServiceStatus.dwCurrentState = SERVICE_RUNNING; + if (SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send running status to windows service: %d", nError); + } if (mainWindowsFunc != NULL) mainWindowsFunc(argc, argv); ServiceStatus.dwCurrentState = SERVICE_STOPPED; - if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { - DWORD nError = GetLastError(); - printf("failed to send stopped status to windows service: %d",nError); - } + if (!SetServiceStatus(hServiceStatusHandle, &ServiceStatus)) { + DWORD nError = GetLastError(); + printf("failed to send stopped status to windows service: %d", nError); + } } void stratWindowsService(MainWindows mainWindows) { mainWindowsFunc = mainWindows; @@ -248,7 +248,7 @@ TdCmdPtr taosOpenCmd(const char* cmd) { #endif } -int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char *__restrict buf) { +int64_t taosGetsCmd(TdCmdPtr pCmd, int32_t maxSize, char* __restrict buf) { if (pCmd == NULL || buf == NULL) { return -1; } diff --git a/source/os/src/osThread.c b/source/os/src/osThread.c index 39b68d6b54ef7d2e553b5115dc0620151d98d64e..32c58695cfdac108e38112ccbfc73f35faf5ed42 100644 --- a/source/os/src/osThread.c +++ b/source/os/src/osThread.c @@ -17,179 +17,135 @@ #include #include "os.h" -int32_t taosThreadCreate(TdThread * tid, const TdThreadAttr * attr, void *(*start)(void *), void *arg) { +int32_t taosThreadCreate(TdThread *tid, const TdThreadAttr *attr, void *(*start)(void *), void *arg) { return pthread_create(tid, attr, start, arg); } -int32_t taosThreadAttrDestroy(TdThreadAttr * attr) { - return pthread_attr_destroy(attr); -} +int32_t taosThreadAttrDestroy(TdThreadAttr *attr) { return pthread_attr_destroy(attr); } -int32_t taosThreadAttrGetDetachState(const TdThreadAttr * attr, int32_t *detachstate) { +int32_t taosThreadAttrGetDetachState(const TdThreadAttr *attr, int32_t *detachstate) { return pthread_attr_getdetachstate(attr, detachstate); } -int32_t taosThreadAttrGetInheritSched(const TdThreadAttr * attr, int32_t *inheritsched) { +int32_t taosThreadAttrGetInheritSched(const TdThreadAttr *attr, int32_t *inheritsched) { return pthread_attr_getinheritsched(attr, inheritsched); } -int32_t taosThreadAttrGetSchedParam(const TdThreadAttr * attr, struct sched_param *param) { +int32_t taosThreadAttrGetSchedParam(const TdThreadAttr *attr, struct sched_param *param) { return pthread_attr_getschedparam(attr, param); } -int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr * attr, int32_t *policy) { +int32_t taosThreadAttrGetSchedPolicy(const TdThreadAttr *attr, int32_t *policy) { return pthread_attr_getschedpolicy(attr, policy); } -int32_t taosThreadAttrGetScope(const TdThreadAttr * attr, int32_t *contentionscope) { +int32_t taosThreadAttrGetScope(const TdThreadAttr *attr, int32_t *contentionscope) { return pthread_attr_getscope(attr, contentionscope); } -int32_t taosThreadAttrGetStackSize(const TdThreadAttr * attr, size_t * stacksize) { +int32_t taosThreadAttrGetStackSize(const TdThreadAttr *attr, size_t *stacksize) { return pthread_attr_getstacksize(attr, stacksize); } -int32_t taosThreadAttrInit(TdThreadAttr * attr) { - return pthread_attr_init(attr); -} +int32_t taosThreadAttrInit(TdThreadAttr *attr) { return pthread_attr_init(attr); } -int32_t taosThreadAttrSetDetachState(TdThreadAttr * attr, int32_t detachstate) { +int32_t taosThreadAttrSetDetachState(TdThreadAttr *attr, int32_t detachstate) { return pthread_attr_setdetachstate(attr, detachstate); } -int32_t taosThreadAttrSetInheritSched(TdThreadAttr * attr, int32_t inheritsched) { +int32_t taosThreadAttrSetInheritSched(TdThreadAttr *attr, int32_t inheritsched) { return pthread_attr_setinheritsched(attr, inheritsched); } -int32_t taosThreadAttrSetSchedParam(TdThreadAttr * attr, const struct sched_param *param) { +int32_t taosThreadAttrSetSchedParam(TdThreadAttr *attr, const struct sched_param *param) { return pthread_attr_setschedparam(attr, param); } -int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr * attr, int32_t policy) { +int32_t taosThreadAttrSetSchedPolicy(TdThreadAttr *attr, int32_t policy) { return pthread_attr_setschedpolicy(attr, policy); } -int32_t taosThreadAttrSetScope(TdThreadAttr * attr, int32_t contentionscope) { +int32_t taosThreadAttrSetScope(TdThreadAttr *attr, int32_t contentionscope) { return pthread_attr_setscope(attr, contentionscope); } -int32_t taosThreadAttrSetStackSize(TdThreadAttr * attr, size_t stacksize) { +int32_t taosThreadAttrSetStackSize(TdThreadAttr *attr, size_t stacksize) { return pthread_attr_setstacksize(attr, stacksize); } -int32_t taosThreadCancel(TdThread thread) { - return pthread_cancel(thread); -} +int32_t taosThreadCancel(TdThread thread) { return pthread_cancel(thread); } -int32_t taosThreadCondDestroy(TdThreadCond * cond) { - return pthread_cond_destroy(cond); -} +int32_t taosThreadCondDestroy(TdThreadCond *cond) { return pthread_cond_destroy(cond); } -int32_t taosThreadCondInit(TdThreadCond * cond, const TdThreadCondAttr * attr) { - return pthread_cond_init(cond, attr); -} +int32_t taosThreadCondInit(TdThreadCond *cond, const TdThreadCondAttr *attr) { return pthread_cond_init(cond, attr); } -int32_t taosThreadCondSignal(TdThreadCond * cond) { - return pthread_cond_signal(cond); -} +int32_t taosThreadCondSignal(TdThreadCond *cond) { return pthread_cond_signal(cond); } -int32_t taosThreadCondBroadcast(TdThreadCond * cond) { - return pthread_cond_broadcast(cond); -} +int32_t taosThreadCondBroadcast(TdThreadCond *cond) { return pthread_cond_broadcast(cond); } -int32_t taosThreadCondWait(TdThreadCond * cond, TdThreadMutex * mutex) { - return pthread_cond_wait(cond, mutex); -} +int32_t taosThreadCondWait(TdThreadCond *cond, TdThreadMutex *mutex) { return pthread_cond_wait(cond, mutex); } -int32_t taosThreadCondTimedWait(TdThreadCond * cond, TdThreadMutex * mutex, const struct timespec *abstime) { +int32_t taosThreadCondTimedWait(TdThreadCond *cond, TdThreadMutex *mutex, const struct timespec *abstime) { return pthread_cond_timedwait(cond, mutex, abstime); } -int32_t taosThreadCondAttrDestroy(TdThreadCondAttr * attr) { - return pthread_condattr_destroy(attr); -} +int32_t taosThreadCondAttrDestroy(TdThreadCondAttr *attr) { return pthread_condattr_destroy(attr); } -int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr * attr, int32_t *pshared) { +int32_t taosThreadCondAttrGetPshared(const TdThreadCondAttr *attr, int32_t *pshared) { return pthread_condattr_getpshared(attr, pshared); } -int32_t taosThreadCondAttrInit(TdThreadCondAttr * attr) { - return pthread_condattr_init(attr); -} +int32_t taosThreadCondAttrInit(TdThreadCondAttr *attr) { return pthread_condattr_init(attr); } -int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr * attr, int32_t pshared) { +int32_t taosThreadCondAttrSetPshared(TdThreadCondAttr *attr, int32_t pshared) { return pthread_condattr_setpshared(attr, pshared); } -int32_t taosThreadDetach(TdThread thread) { - return pthread_detach(thread); -} +int32_t taosThreadDetach(TdThread thread) { return pthread_detach(thread); } -int32_t taosThreadEqual(TdThread t1, TdThread t2) { - return pthread_equal(t1, t2); -} +int32_t taosThreadEqual(TdThread t1, TdThread t2) { return pthread_equal(t1, t2); } -void taosThreadExit(void *valuePtr) { - return pthread_exit(valuePtr); -} +void taosThreadExit(void *valuePtr) { return pthread_exit(valuePtr); } int32_t taosThreadGetSchedParam(TdThread thread, int32_t *policy, struct sched_param *param) { return pthread_getschedparam(thread, policy, param); } -void *taosThreadGetSpecific(TdThreadKey key) { - return pthread_getspecific(key); -} +void *taosThreadGetSpecific(TdThreadKey key) { return pthread_getspecific(key); } -int32_t taosThreadJoin(TdThread thread, void **valuePtr) { - return pthread_join(thread, valuePtr); -} +int32_t taosThreadJoin(TdThread thread, void **valuePtr) { return pthread_join(thread, valuePtr); } -int32_t taosThreadKeyCreate(TdThreadKey * key, void(*destructor)(void *)) { +int32_t taosThreadKeyCreate(TdThreadKey *key, void (*destructor)(void *)) { return pthread_key_create(key, destructor); } -int32_t taosThreadKeyDelete(TdThreadKey key) { - return pthread_key_delete(key); -} +int32_t taosThreadKeyDelete(TdThreadKey key) { return pthread_key_delete(key); } -int32_t taosThreadKill(TdThread thread, int32_t sig) { - return pthread_kill(thread, sig); -} +int32_t taosThreadKill(TdThread thread, int32_t sig) { return pthread_kill(thread, sig); } // int32_t taosThreadMutexConsistent(TdThreadMutex* mutex) { // return pthread_mutex_consistent(mutex); // } -int32_t taosThreadMutexDestroy(TdThreadMutex * mutex) { - return pthread_mutex_destroy(mutex); -} +int32_t taosThreadMutexDestroy(TdThreadMutex *mutex) { return pthread_mutex_destroy(mutex); } -int32_t taosThreadMutexInit(TdThreadMutex * mutex, const TdThreadMutexAttr * attr) { +int32_t taosThreadMutexInit(TdThreadMutex *mutex, const TdThreadMutexAttr *attr) { return pthread_mutex_init(mutex, attr); } -int32_t taosThreadMutexLock(TdThreadMutex * mutex) { - return pthread_mutex_lock(mutex); -} +int32_t taosThreadMutexLock(TdThreadMutex *mutex) { return pthread_mutex_lock(mutex); } // int32_t taosThreadMutexTimedLock(TdThreadMutex * mutex, const struct timespec *abstime) { // return pthread_mutex_timedlock(mutex, abstime); // } -int32_t taosThreadMutexTryLock(TdThreadMutex * mutex) { - return pthread_mutex_trylock(mutex); -} +int32_t taosThreadMutexTryLock(TdThreadMutex *mutex) { return pthread_mutex_trylock(mutex); } -int32_t taosThreadMutexUnlock(TdThreadMutex * mutex) { - return pthread_mutex_unlock(mutex); -} +int32_t taosThreadMutexUnlock(TdThreadMutex *mutex) { return pthread_mutex_unlock(mutex); } -int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr * attr) { - return pthread_mutexattr_destroy(attr); -} +int32_t taosThreadMutexAttrDestroy(TdThreadMutexAttr *attr) { return pthread_mutexattr_destroy(attr); } -int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *pshared) { +int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr *attr, int32_t *pshared) { return pthread_mutexattr_getpshared(attr, pshared); } @@ -197,15 +153,13 @@ int32_t taosThreadMutexAttrGetPshared(const TdThreadMutexAttr * attr, int32_t *p // return pthread_mutexattr_getrobust(attr, robust); // } -int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr * attr, int32_t *kind) { +int32_t taosThreadMutexAttrGetType(const TdThreadMutexAttr *attr, int32_t *kind) { return pthread_mutexattr_gettype(attr, kind); } -int32_t taosThreadMutexAttrInit(TdThreadMutexAttr * attr) { - return pthread_mutexattr_init(attr); -} +int32_t taosThreadMutexAttrInit(TdThreadMutexAttr *attr) { return pthread_mutexattr_init(attr); } -int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared) { +int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr *attr, int32_t pshared) { return pthread_mutexattr_setpshared(attr, pshared); } @@ -213,25 +167,21 @@ int32_t taosThreadMutexAttrSetPshared(TdThreadMutexAttr * attr, int32_t pshared) // return pthread_mutexattr_setrobust(attr, robust); // } -int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr * attr, int32_t kind) { +int32_t taosThreadMutexAttrSetType(TdThreadMutexAttr *attr, int32_t kind) { return pthread_mutexattr_settype(attr, kind); } -int32_t taosThreadOnce(TdThreadOnce * onceControl, void(*initRoutine)(void)) { +int32_t taosThreadOnce(TdThreadOnce *onceControl, void (*initRoutine)(void)) { return pthread_once(onceControl, initRoutine); } -int32_t taosThreadRwlockDestroy(TdThreadRwlock * rwlock) { - return pthread_rwlock_destroy(rwlock); -} +int32_t taosThreadRwlockDestroy(TdThreadRwlock *rwlock) { return pthread_rwlock_destroy(rwlock); } -int32_t taosThreadRwlockInit(TdThreadRwlock * rwlock, const TdThreadRwlockAttr * attr) { +int32_t taosThreadRwlockInit(TdThreadRwlock *rwlock, const TdThreadRwlockAttr *attr) { return pthread_rwlock_init(rwlock, attr); } -int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) { - return pthread_rwlock_rdlock(rwlock); -} +int32_t taosThreadRwlockRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_rdlock(rwlock); } // int32_t taosThreadRwlockTimedRdlock(TdThreadRwlock * rwlock, const struct timespec *abstime) { // return pthread_rwlock_timedrdlock(rwlock, abstime); @@ -241,103 +191,79 @@ int32_t taosThreadRwlockRdlock(TdThreadRwlock * rwlock) { // return pthread_rwlock_timedwrlock(rwlock, abstime); // } -int32_t taosThreadRwlockTryRdlock(TdThreadRwlock * rwlock) { - return pthread_rwlock_tryrdlock(rwlock); -} +int32_t taosThreadRwlockTryRdlock(TdThreadRwlock *rwlock) { return pthread_rwlock_tryrdlock(rwlock); } -int32_t taosThreadRwlockTryWrlock(TdThreadRwlock * rwlock) { - return pthread_rwlock_trywrlock(rwlock); -} +int32_t taosThreadRwlockTryWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_trywrlock(rwlock); } -int32_t taosThreadRwlockUnlock(TdThreadRwlock * rwlock) { - return pthread_rwlock_unlock(rwlock); -} +int32_t taosThreadRwlockUnlock(TdThreadRwlock *rwlock) { return pthread_rwlock_unlock(rwlock); } -int32_t taosThreadRwlockWrlock(TdThreadRwlock * rwlock) { - return pthread_rwlock_wrlock(rwlock); -} +int32_t taosThreadRwlockWrlock(TdThreadRwlock *rwlock) { return pthread_rwlock_wrlock(rwlock); } -int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr * attr) { - return pthread_rwlockattr_destroy(attr); -} +int32_t taosThreadRwlockAttrDestroy(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_destroy(attr); } -int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr * attr, int32_t *pshared) { +int32_t taosThreadRwlockAttrGetPshared(const TdThreadRwlockAttr *attr, int32_t *pshared) { return pthread_rwlockattr_getpshared(attr, pshared); } -int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr * attr) { - return pthread_rwlockattr_init(attr); -} +int32_t taosThreadRwlockAttrInit(TdThreadRwlockAttr *attr) { return pthread_rwlockattr_init(attr); } -int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr * attr, int32_t pshared) { +int32_t taosThreadRwlockAttrSetPshared(TdThreadRwlockAttr *attr, int32_t pshared) { return pthread_rwlockattr_setpshared(attr, pshared); } -TdThread taosThreadSelf(void) { - return pthread_self(); -} +TdThread taosThreadSelf(void) { return pthread_self(); } -int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) { - return pthread_setcancelstate(state, oldstate); -} +int32_t taosThreadSetCancelState(int32_t state, int32_t *oldstate) { return pthread_setcancelstate(state, oldstate); } -int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) { - return pthread_setcanceltype(type, oldtype); -} +int32_t taosThreadSetCancelType(int32_t type, int32_t *oldtype) { return pthread_setcanceltype(type, oldtype); } int32_t taosThreadSetSchedParam(TdThread thread, int32_t policy, const struct sched_param *param) { return pthread_setschedparam(thread, policy, param); } -int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { - return pthread_setspecific(key, value); -} +int32_t taosThreadSetSpecific(TdThreadKey key, const void *value) { return pthread_setspecific(key, value); } -int32_t taosThreadSpinDestroy(TdThreadSpinlock * lock) { +int32_t taosThreadSpinDestroy(TdThreadSpinlock *lock) { #ifdef TD_USE_SPINLOCK_AS_MUTEX - return pthread_mutex_destroy((pthread_mutex_t*)lock); + return pthread_mutex_destroy((pthread_mutex_t *)lock); #else - return pthread_spin_destroy((pthread_spinlock_t*)lock); + return pthread_spin_destroy((pthread_spinlock_t *)lock); #endif } -int32_t taosThreadSpinInit(TdThreadSpinlock * lock, int32_t pshared) { +int32_t taosThreadSpinInit(TdThreadSpinlock *lock, int32_t pshared) { #ifdef TD_USE_SPINLOCK_AS_MUTEX assert(pshared == 0); - return pthread_mutex_init((pthread_mutex_t*)lock, NULL); + return pthread_mutex_init((pthread_mutex_t *)lock, NULL); #else - return pthread_spin_init((pthread_spinlock_t*)lock, pshared); + return pthread_spin_init((pthread_spinlock_t *)lock, pshared); #endif } -int32_t taosThreadSpinLock(TdThreadSpinlock * lock) { +int32_t taosThreadSpinLock(TdThreadSpinlock *lock) { #ifdef TD_USE_SPINLOCK_AS_MUTEX - return pthread_mutex_lock((pthread_mutex_t*)lock); + return pthread_mutex_lock((pthread_mutex_t *)lock); #else - return pthread_spin_lock((pthread_spinlock_t*)lock); + return pthread_spin_lock((pthread_spinlock_t *)lock); #endif } -int32_t taosThreadSpinTrylock(TdThreadSpinlock * lock) { +int32_t taosThreadSpinTrylock(TdThreadSpinlock *lock) { #ifdef TD_USE_SPINLOCK_AS_MUTEX - return pthread_mutex_trylock((pthread_mutex_t*)lock); + return pthread_mutex_trylock((pthread_mutex_t *)lock); #else - return pthread_spin_trylock((pthread_spinlock_t*)lock); + return pthread_spin_trylock((pthread_spinlock_t *)lock); #endif } -int32_t taosThreadSpinUnlock(TdThreadSpinlock * lock) { +int32_t taosThreadSpinUnlock(TdThreadSpinlock *lock) { #ifdef TD_USE_SPINLOCK_AS_MUTEX - return pthread_mutex_unlock((pthread_mutex_t*)lock); + return pthread_mutex_unlock((pthread_mutex_t *)lock); #else - return pthread_spin_unlock((pthread_spinlock_t*)lock); + return pthread_spin_unlock((pthread_spinlock_t *)lock); #endif } -void taosThreadTestCancel(void) { - return pthread_testcancel(); -} +void taosThreadTestCancel(void) { return pthread_testcancel(); } -void taosThreadClear(TdThread *thread) { - memset(thread, 0, sizeof(TdThread)); -} \ No newline at end of file +void taosThreadClear(TdThread *thread) { memset(thread, 0, sizeof(TdThread)); } \ No newline at end of file diff --git a/source/os/src/osTimer.c b/source/os/src/osTimer.c index 2992b2909848d4ac175e5557976ec8062a5e8e4d..d1c233ea9c2a06de6f4f973395276fcae6246188 100644 --- a/source/os/src/osTimer.c +++ b/source/os/src/osTimer.c @@ -44,7 +44,7 @@ static MMRESULT timerId; static void (*timer_callback)(int); static int timer_ms = 0; -static TdThread timer_thread; +static TdThread timer_thread; static int timer_kq = -1; static volatile int timer_stop = 0; @@ -83,11 +83,11 @@ static void taosDeleteTimer(void *tharg) { timer_delete(*pTimer); } -static TdThread timerThread; +static TdThread timerThread; static timer_t timerId; static volatile bool stopTimer = false; -static void * taosProcessAlarmSignal(void *tharg) { - // Block the signal +static void *taosProcessAlarmSignal(void *tharg) { + // Block the signal sigset_t sigset; sigemptyset(&sigset); sigaddset(&sigset, SIGALRM); @@ -109,7 +109,7 @@ static void * taosProcessAlarmSignal(void *tharg) { sevent.sigev_signo = SIGALRM; if (timer_create(CLOCK_REALTIME, &sevent, &timerId) == -1) { - // printf("Failed to create timer"); + // printf("Failed to create timer"); } taosThreadCleanupPush(taosDeleteTimer, &timerId); @@ -121,19 +121,19 @@ static void * taosProcessAlarmSignal(void *tharg) { ts.it_interval.tv_nsec = 1000000 * MSECONDS_PER_TICK; if (timer_settime(timerId, 0, &ts, NULL)) { - // printf("Failed to init timer"); + // printf("Failed to init timer"); return NULL; } int signo; while (!stopTimer) { - if (sigwait(&sigset, &signo)) { - // printf("Failed to wait signal: number %d", signo); + if (sigwait(&sigset, &signo)) { + // printf("Failed to wait signal: number %d", signo); continue; } - /* //printf("Signal handling: number %d ......\n", signo); */ + /* //printf("Signal handling: number %d ......\n", signo); */ - callback(0); + callback(0); } taosThreadCleanupPop(1); @@ -167,7 +167,8 @@ int taosInitTimer(void (*callback)(int), int ms) { r = taosThreadCreate(&timer_thread, NULL, timer_routine, NULL); if (r) { - fprintf(stderr, "==%s[%d]%s()==failed to create timer thread\n", taosDirEntryBaseName(__FILE__), __LINE__, __func__); + fprintf(stderr, "==%s[%d]%s()==failed to create timer thread\n", taosDirEntryBaseName(__FILE__), __LINE__, + __func__); // since no caller of this func checks the return value for the moment abort(); } diff --git a/source/os/src/osTimezone.c b/source/os/src/osTimezone.c index 34a09c3e6c6610ec1114238867cf9f068ebd5557..64cb007abafebd36856bccad3b2bb2730a288c2a 100644 --- a/source/os/src/osTimezone.c +++ b/source/os/src/osTimezone.c @@ -33,699 +33,699 @@ #include #pragma warning(pop) -char *win_tz[139][2]={{"China Standard Time", "Asia/Shanghai"}, - {"AUS Central Standard Time", "Australia/Darwin"}, - {"AUS Eastern Standard Time", "Australia/Sydney"}, - {"Afghanistan Standard Time", "Asia/Kabul"}, - {"Alaskan Standard Time", "America/Anchorage"}, - {"Aleutian Standard Time", "America/Adak"}, - {"Altai Standard Time", "Asia/Barnaul"}, - {"Arab Standard Time", "Asia/Riyadh"}, - {"Arabian Standard Time", "Asia/Dubai"}, - {"Arabic Standard Time", "Asia/Baghdad"}, - {"Argentina Standard Time", "America/Buenos_Aires"}, - {"Astrakhan Standard Time", "Europe/Astrakhan"}, - {"Atlantic Standard Time", "America/Halifax"}, - {"Aus Central W. Standard Time", "Australia/Eucla"}, - {"Azerbaijan Standard Time", "Asia/Baku"}, - {"Azores Standard Time", "Atlantic/Azores"}, - {"Bahia Standard Time", "America/Bahia"}, - {"Bangladesh Standard Time", "Asia/Dhaka"}, - {"Belarus Standard Time", "Europe/Minsk"}, - {"Bougainville Standard Time", "Pacific/Bougainville"}, - {"Canada Central Standard Time", "America/Regina"}, - {"Cape Verde Standard Time", "Atlantic/Cape_Verde"}, - {"Caucasus Standard Time", "Asia/Yerevan"}, - {"Cen. Australia Standard Time", "Australia/Adelaide"}, - {"Central America Standard Time", "America/Guatemala"}, - {"Central Asia Standard Time", "Asia/Almaty"}, - {"Central Brazilian Standard Time", "America/Cuiaba"}, - {"Central Europe Standard Time", "Europe/Budapest"}, - {"Central European Standard Time", "Europe/Warsaw"}, - {"Central Pacific Standard Time", "Pacific/Guadalcanal"}, - {"Central Standard Time", "America/Chicago"}, - {"Central Standard Time (Mexico)", "America/Mexico_City"}, - {"Chatham Islands Standard Time", "Pacific/Chatham"}, - {"Cuba Standard Time", "America/Havana"}, - {"Dateline Standard Time", "Etc/GMT+12"}, - {"E. Africa Standard Time", "Africa/Nairobi"}, - {"E. Australia Standard Time", "Australia/Brisbane"}, - {"E. Europe Standard Time", "Europe/Chisinau"}, - {"E. South America Standard Time", "America/Sao_Paulo"}, - {"Easter Island Standard Time", "Pacific/Easter"}, - {"Eastern Standard Time", "America/New_York"}, - {"Eastern Standard Time (Mexico)", "America/Cancun"}, - {"Egypt Standard Time", "Africa/Cairo"}, - {"Ekaterinburg Standard Time", "Asia/Yekaterinburg"}, - {"FLE Standard Time", "Europe/Kiev"}, - {"Fiji Standard Time", "Pacific/Fiji"}, - {"GMT Standard Time", "Europe/London"}, - {"GTB Standard Time", "Europe/Bucharest"}, - {"Georgian Standard Time", "Asia/Tbilisi"}, - {"Greenland Standard Time", "America/Godthab"}, - {"Greenwich Standard Time", "Atlantic/Reykjavik"}, - {"Haiti Standard Time", "America/Port-au-Prince"}, - {"Hawaiian Standard Time", "Pacific/Honolulu"}, - {"India Standard Time", "Asia/Calcutta"}, - {"Iran Standard Time", "Asia/Tehran"}, - {"Israel Standard Time", "Asia/Jerusalem"}, - {"Jordan Standard Time", "Asia/Amman"}, - {"Kaliningrad Standard Time", "Europe/Kaliningrad"}, - {"Korea Standard Time", "Asia/Seoul"}, - {"Libya Standard Time", "Africa/Tripoli"}, - {"Line Islands Standard Time", "Pacific/Kiritimati"}, - {"Lord Howe Standard Time", "Australia/Lord_Howe"}, - {"Magadan Standard Time", "Asia/Magadan"}, - {"Magallanes Standard Time", "America/Punta_Arenas"}, - {"Marquesas Standard Time", "Pacific/Marquesas"}, - {"Mauritius Standard Time", "Indian/Mauritius"}, - {"Middle East Standard Time", "Asia/Beirut"}, - {"Montevideo Standard Time", "America/Montevideo"}, - {"Morocco Standard Time", "Africa/Casablanca"}, - {"Mountain Standard Time", "America/Denver"}, - {"Mountain Standard Time (Mexico)", "America/Chihuahua"}, - {"Myanmar Standard Time", "Asia/Rangoon"}, - {"N. Central Asia Standard Time", "Asia/Novosibirsk"}, - {"Namibia Standard Time", "Africa/Windhoek"}, - {"Nepal Standard Time", "Asia/Katmandu"}, - {"New Zealand Standard Time", "Pacific/Auckland"}, - {"Newfoundland Standard Time", "America/St_Johns"}, - {"Norfolk Standard Time", "Pacific/Norfolk"}, - {"North Asia East Standard Time", "Asia/Irkutsk"}, - {"North Asia Standard Time", "Asia/Krasnoyarsk"}, - {"North Korea Standard Time", "Asia/Pyongyang"}, - {"Omsk Standard Time", "Asia/Omsk"}, - {"Pacific SA Standard Time", "America/Santiago"}, - {"Pacific Standard Time", "America/Los_Angeles"}, - {"Pacific Standard Time (Mexico)", "America/Tijuana"}, - {"Pakistan Standard Time", "Asia/Karachi"}, - {"Paraguay Standard Time", "America/Asuncion"}, - {"Qyzylorda Standard Time", "Asia/Qyzylorda"}, - {"Romance Standard Time", "Europe/Paris"}, - {"Russia Time Zone 10", "Asia/Srednekolymsk"}, - {"Russia Time Zone 11", "Asia/Kamchatka"}, - {"Russia Time Zone 3", "Europe/Samara"}, - {"Russian Standard Time", "Europe/Moscow"}, - {"SA Eastern Standard Time", "America/Cayenne"}, - {"SA Pacific Standard Time", "America/Bogota"}, - {"SA Western Standard Time", "America/La_Paz"}, - {"SE Asia Standard Time", "Asia/Bangkok"}, - {"Saint Pierre Standard Time", "America/Miquelon"}, - {"Sakhalin Standard Time", "Asia/Sakhalin"}, - {"Samoa Standard Time", "Pacific/Apia"}, - {"Sao Tome Standard Time", "Africa/Sao_Tome"}, - {"Saratov Standard Time", "Europe/Saratov"}, - {"Singapore Standard Time", "Asia/Singapore"}, - {"South Africa Standard Time", "Africa/Johannesburg"}, - {"South Sudan Standard Time", "Africa/Juba"}, - {"Sri Lanka Standard Time", "Asia/Colombo"}, - {"Sudan Standard Time", "Africa/Khartoum"}, - {"Syria Standard Time", "Asia/Damascus"}, - {"Taipei Standard Time", "Asia/Taipei"}, - {"Tasmania Standard Time", "Australia/Hobart"}, - {"Tocantins Standard Time", "America/Araguaina"}, - {"Tokyo Standard Time", "Asia/Tokyo"}, - {"Tomsk Standard Time", "Asia/Tomsk"}, - {"Tonga Standard Time", "Pacific/Tongatapu"}, - {"Transbaikal Standard Time", "Asia/Chita"}, - {"Turkey Standard Time", "Europe/Istanbul"}, - {"Turks And Caicos Standard Time", "America/Grand_Turk"}, - {"US Eastern Standard Time", "America/Indianapolis"}, - {"US Mountain Standard Time", "America/Phoenix"}, - {"UTC", "Etc/UTC"}, - {"UTC+12", "Etc/GMT-12"}, - {"UTC+13", "Etc/GMT-13"}, - {"UTC-02", "Etc/GMT+2"}, - {"UTC-08", "Etc/GMT+8"}, - {"UTC-09", "Etc/GMT+9"}, - {"UTC-11", "Etc/GMT+11"}, - {"Ulaanbaatar Standard Time", "Asia/Ulaanbaatar"}, - {"Venezuela Standard Time", "America/Caracas"}, - {"Vladivostok Standard Time", "Asia/Vladivostok"}, - {"Volgograd Standard Time", "Europe/Volgograd"}, - {"W. Australia Standard Time", "Australia/Perth"}, - {"W. Central Africa Standard Time", "Africa/Lagos"}, - {"W. Europe Standard Time", "Europe/Berlin"}, - {"W. Mongolia Standard Time", "Asia/Hovd"}, - {"West Asia Standard Time", "Asia/Tashkent"}, - {"West Bank Standard Time", "Asia/Hebron"}, - {"West Pacific Standard Time", "Pacific/Port_Moresby"}, - {"Yakutsk Standard Time", "Asia/Yakutsk"}, - {"Yukon Standard Time", "America/Whitehorse"}}; -char *tz_win[554][2]={{"Asia/Shanghai", "China Standard Time"}, -{"Africa/Abidjan", "Greenwich Standard Time"}, -{"Africa/Accra", "Greenwich Standard Time"}, -{"Africa/Addis_Ababa", "E. Africa Standard Time"}, -{"Africa/Algiers", "W. Central Africa Standard Time"}, -{"Africa/Asmera", "E. Africa Standard Time"}, -{"Africa/Bamako", "Greenwich Standard Time"}, -{"Africa/Bangui", "W. Central Africa Standard Time"}, -{"Africa/Banjul", "Greenwich Standard Time"}, -{"Africa/Bissau", "Greenwich Standard Time"}, -{"Africa/Blantyre", "South Africa Standard Time"}, -{"Africa/Brazzaville", "W. Central Africa Standard Time"}, -{"Africa/Bujumbura", "South Africa Standard Time"}, -{"Africa/Cairo", "Egypt Standard Time"}, -{"Africa/Casablanca", "Morocco Standard Time"}, -{"Africa/Ceuta", "Romance Standard Time"}, -{"Africa/Conakry", "Greenwich Standard Time"}, -{"Africa/Dakar", "Greenwich Standard Time"}, -{"Africa/Dar_es_Salaam", "E. Africa Standard Time"}, -{"Africa/Djibouti", "E. Africa Standard Time"}, -{"Africa/Douala", "W. Central Africa Standard Time"}, -{"Africa/El_Aaiun", "Morocco Standard Time"}, -{"Africa/Freetown", "Greenwich Standard Time"}, -{"Africa/Gaborone", "South Africa Standard Time"}, -{"Africa/Harare", "South Africa Standard Time"}, -{"Africa/Johannesburg", "South Africa Standard Time"}, -{"Africa/Juba", "South Sudan Standard Time"}, -{"Africa/Kampala", "E. Africa Standard Time"}, -{"Africa/Khartoum", "Sudan Standard Time"}, -{"Africa/Kigali", "South Africa Standard Time"}, -{"Africa/Kinshasa", "W. Central Africa Standard Time"}, -{"Africa/Lagos", "W. Central Africa Standard Time"}, -{"Africa/Libreville", "W. Central Africa Standard Time"}, -{"Africa/Lome", "Greenwich Standard Time"}, -{"Africa/Luanda", "W. Central Africa Standard Time"}, -{"Africa/Lubumbashi", "South Africa Standard Time"}, -{"Africa/Lusaka", "South Africa Standard Time"}, -{"Africa/Malabo", "W. Central Africa Standard Time"}, -{"Africa/Maputo", "South Africa Standard Time"}, -{"Africa/Maseru", "South Africa Standard Time"}, -{"Africa/Mbabane", "South Africa Standard Time"}, -{"Africa/Mogadishu", "E. Africa Standard Time"}, -{"Africa/Monrovia", "Greenwich Standard Time"}, -{"Africa/Nairobi", "E. Africa Standard Time"}, -{"Africa/Ndjamena", "W. Central Africa Standard Time"}, -{"Africa/Niamey", "W. Central Africa Standard Time"}, -{"Africa/Nouakchott", "Greenwich Standard Time"}, -{"Africa/Ouagadougou", "Greenwich Standard Time"}, -{"Africa/Porto-Novo", "W. Central Africa Standard Time"}, -{"Africa/Sao_Tome", "Sao Tome Standard Time"}, -{"Africa/Timbuktu", "Greenwich Standard Time"}, -{"Africa/Tripoli", "Libya Standard Time"}, -{"Africa/Tunis", "W. Central Africa Standard Time"}, -{"Africa/Windhoek", "Namibia Standard Time"}, -{"America/Adak", "Aleutian Standard Time"}, -{"America/Anchorage", "Alaskan Standard Time"}, -{"America/Anguilla", "SA Western Standard Time"}, -{"America/Antigua", "SA Western Standard Time"}, -{"America/Araguaina", "Tocantins Standard Time"}, -{"America/Argentina/La_Rioja", "Argentina Standard Time"}, -{"America/Argentina/Rio_Gallegos", "Argentina Standard Time"}, -{"America/Argentina/Salta", "Argentina Standard Time"}, -{"America/Argentina/San_Juan", "Argentina Standard Time"}, -{"America/Argentina/San_Luis", "Argentina Standard Time"}, -{"America/Argentina/Tucuman", "Argentina Standard Time"}, -{"America/Argentina/Ushuaia", "Argentina Standard Time"}, -{"America/Aruba", "SA Western Standard Time"}, -{"America/Asuncion", "Paraguay Standard Time"}, -{"America/Atka", "Aleutian Standard Time"}, -{"America/Bahia", "Bahia Standard Time"}, -{"America/Bahia_Banderas", "Central Standard Time (Mexico)"}, -{"America/Barbados", "SA Western Standard Time"}, -{"America/Belem", "SA Eastern Standard Time"}, -{"America/Belize", "Central America Standard Time"}, -{"America/Blanc-Sablon", "SA Western Standard Time"}, -{"America/Boa_Vista", "SA Western Standard Time"}, -{"America/Bogota", "SA Pacific Standard Time"}, -{"America/Boise", "Mountain Standard Time"}, -{"America/Buenos_Aires", "Argentina Standard Time"}, -{"America/Cambridge_Bay", "Mountain Standard Time"}, -{"America/Campo_Grande", "Central Brazilian Standard Time"}, -{"America/Cancun", "Eastern Standard Time (Mexico)"}, -{"America/Caracas", "Venezuela Standard Time"}, -{"America/Catamarca", "Argentina Standard Time"}, -{"America/Cayenne", "SA Eastern Standard Time"}, -{"America/Cayman", "SA Pacific Standard Time"}, -{"America/Chicago", "Central Standard Time"}, -{"America/Chihuahua", "Mountain Standard Time (Mexico)"}, -{"America/Coral_Harbour", "SA Pacific Standard Time"}, -{"America/Cordoba", "Argentina Standard Time"}, -{"America/Costa_Rica", "Central America Standard Time"}, -{"America/Creston", "US Mountain Standard Time"}, -{"America/Cuiaba", "Central Brazilian Standard Time"}, -{"America/Curacao", "SA Western Standard Time"}, -{"America/Danmarkshavn", "Greenwich Standard Time"}, -{"America/Dawson", "Yukon Standard Time"}, -{"America/Dawson_Creek", "US Mountain Standard Time"}, -{"America/Denver", "Mountain Standard Time"}, -{"America/Detroit", "Eastern Standard Time"}, -{"America/Dominica", "SA Western Standard Time"}, -{"America/Edmonton", "Mountain Standard Time"}, -{"America/Eirunepe", "SA Pacific Standard Time"}, -{"America/El_Salvador", "Central America Standard Time"}, -{"America/Ensenada", "Pacific Standard Time (Mexico)"}, -{"America/Fort_Nelson", "US Mountain Standard Time"}, -{"America/Fortaleza", "SA Eastern Standard Time"}, -{"America/Glace_Bay", "Atlantic Standard Time"}, -{"America/Godthab", "Greenland Standard Time"}, -{"America/Goose_Bay", "Atlantic Standard Time"}, -{"America/Grand_Turk", "Turks And Caicos Standard Time"}, -{"America/Grenada", "SA Western Standard Time"}, -{"America/Guadeloupe", "SA Western Standard Time"}, -{"America/Guatemala", "Central America Standard Time"}, -{"America/Guayaquil", "SA Pacific Standard Time"}, -{"America/Guyana", "SA Western Standard Time"}, -{"America/Halifax", "Atlantic Standard Time"}, -{"America/Havana", "Cuba Standard Time"}, -{"America/Hermosillo", "US Mountain Standard Time"}, -{"America/Indiana/Knox", "Central Standard Time"}, -{"America/Indiana/Marengo", "US Eastern Standard Time"}, -{"America/Indiana/Petersburg", "Eastern Standard Time"}, -{"America/Indiana/Tell_City", "Central Standard Time"}, -{"America/Indiana/Vevay", "US Eastern Standard Time"}, -{"America/Indiana/Vincennes", "Eastern Standard Time"}, -{"America/Indiana/Winamac", "Eastern Standard Time"}, -{"America/Indianapolis", "US Eastern Standard Time"}, -{"America/Inuvik", "Mountain Standard Time"}, -{"America/Iqaluit", "Eastern Standard Time"}, -{"America/Jamaica", "SA Pacific Standard Time"}, -{"America/Jujuy", "Argentina Standard Time"}, -{"America/Juneau", "Alaskan Standard Time"}, -{"America/Kentucky/Monticello", "Eastern Standard Time"}, -{"America/Knox_IN", "Central Standard Time"}, -{"America/Kralendijk", "SA Western Standard Time"}, -{"America/La_Paz", "SA Western Standard Time"}, -{"America/Lima", "SA Pacific Standard Time"}, -{"America/Los_Angeles", "Pacific Standard Time"}, -{"America/Louisville", "Eastern Standard Time"}, -{"America/Lower_Princes", "SA Western Standard Time"}, -{"America/Maceio", "SA Eastern Standard Time"}, -{"America/Managua", "Central America Standard Time"}, -{"America/Manaus", "SA Western Standard Time"}, -{"America/Marigot", "SA Western Standard Time"}, -{"America/Martinique", "SA Western Standard Time"}, -{"America/Matamoros", "Central Standard Time"}, -{"America/Mazatlan", "Mountain Standard Time (Mexico)"}, -{"America/Mendoza", "Argentina Standard Time"}, -{"America/Menominee", "Central Standard Time"}, -{"America/Merida", "Central Standard Time (Mexico)"}, -{"America/Metlakatla", "Alaskan Standard Time"}, -{"America/Mexico_City", "Central Standard Time (Mexico)"}, -{"America/Miquelon", "Saint Pierre Standard Time"}, -{"America/Moncton", "Atlantic Standard Time"}, -{"America/Monterrey", "Central Standard Time (Mexico)"}, -{"America/Montevideo", "Montevideo Standard Time"}, -{"America/Montreal", "Eastern Standard Time"}, -{"America/Montserrat", "SA Western Standard Time"}, -{"America/Nassau", "Eastern Standard Time"}, -{"America/New_York", "Eastern Standard Time"}, -{"America/Nipigon", "Eastern Standard Time"}, -{"America/Nome", "Alaskan Standard Time"}, -{"America/Noronha", "UTC-02"}, -{"America/North_Dakota/Beulah", "Central Standard Time"}, -{"America/North_Dakota/Center", "Central Standard Time"}, -{"America/North_Dakota/New_Salem", "Central Standard Time"}, -{"America/Ojinaga", "Mountain Standard Time"}, -{"America/Panama", "SA Pacific Standard Time"}, -{"America/Pangnirtung", "Eastern Standard Time"}, -{"America/Paramaribo", "SA Eastern Standard Time"}, -{"America/Phoenix", "US Mountain Standard Time"}, -{"America/Port-au-Prince", "Haiti Standard Time"}, -{"America/Port_of_Spain", "SA Western Standard Time"}, -{"America/Porto_Acre", "SA Pacific Standard Time"}, -{"America/Porto_Velho", "SA Western Standard Time"}, -{"America/Puerto_Rico", "SA Western Standard Time"}, -{"America/Punta_Arenas", "Magallanes Standard Time"}, -{"America/Rainy_River", "Central Standard Time"}, -{"America/Rankin_Inlet", "Central Standard Time"}, -{"America/Recife", "SA Eastern Standard Time"}, -{"America/Regina", "Canada Central Standard Time"}, -{"America/Resolute", "Central Standard Time"}, -{"America/Rio_Branco", "SA Pacific Standard Time"}, -{"America/Santa_Isabel", "Pacific Standard Time (Mexico)"}, -{"America/Santarem", "SA Eastern Standard Time"}, -{"America/Santiago", "Pacific SA Standard Time"}, -{"America/Santo_Domingo", "SA Western Standard Time"}, -{"America/Sao_Paulo", "E. South America Standard Time"}, -{"America/Scoresbysund", "Azores Standard Time"}, -{"America/Shiprock", "Mountain Standard Time"}, -{"America/Sitka", "Alaskan Standard Time"}, -{"America/St_Barthelemy", "SA Western Standard Time"}, -{"America/St_Johns", "Newfoundland Standard Time"}, -{"America/St_Kitts", "SA Western Standard Time"}, -{"America/St_Lucia", "SA Western Standard Time"}, -{"America/St_Thomas", "SA Western Standard Time"}, -{"America/St_Vincent", "SA Western Standard Time"}, -{"America/Swift_Current", "Canada Central Standard Time"}, -{"America/Tegucigalpa", "Central America Standard Time"}, -{"America/Thule", "Atlantic Standard Time"}, -{"America/Thunder_Bay", "Eastern Standard Time"}, -{"America/Tijuana", "Pacific Standard Time (Mexico)"}, -{"America/Toronto", "Eastern Standard Time"}, -{"America/Tortola", "SA Western Standard Time"}, -{"America/Vancouver", "Pacific Standard Time"}, -{"America/Virgin", "SA Western Standard Time"}, -{"America/Whitehorse", "Yukon Standard Time"}, -{"America/Winnipeg", "Central Standard Time"}, -{"America/Yakutat", "Alaskan Standard Time"}, -{"America/Yellowknife", "Mountain Standard Time"}, -{"Antarctica/Casey", "Central Pacific Standard Time"}, -{"Antarctica/Davis", "SE Asia Standard Time"}, -{"Antarctica/DumontDUrville", "West Pacific Standard Time"}, -{"Antarctica/Macquarie", "Tasmania Standard Time"}, -{"Antarctica/Mawson", "West Asia Standard Time"}, -{"Antarctica/McMurdo", "New Zealand Standard Time"}, -{"Antarctica/Palmer", "SA Eastern Standard Time"}, -{"Antarctica/Rothera", "SA Eastern Standard Time"}, -{"Antarctica/South_Pole", "New Zealand Standard Time"}, -{"Antarctica/Syowa", "E. Africa Standard Time"}, -{"Antarctica/Vostok", "Central Asia Standard Time"}, -{"Arctic/Longyearbyen", "W. Europe Standard Time"}, -{"Asia/Aden", "Arab Standard Time"}, -{"Asia/Almaty", "Central Asia Standard Time"}, -{"Asia/Amman", "Jordan Standard Time"}, -{"Asia/Anadyr", "Russia Time Zone 11"}, -{"Asia/Aqtau", "West Asia Standard Time"}, -{"Asia/Aqtobe", "West Asia Standard Time"}, -{"Asia/Ashgabat", "West Asia Standard Time"}, -{"Asia/Ashkhabad", "West Asia Standard Time"}, -{"Asia/Atyrau", "West Asia Standard Time"}, -{"Asia/Baghdad", "Arabic Standard Time"}, -{"Asia/Bahrain", "Arab Standard Time"}, -{"Asia/Baku", "Azerbaijan Standard Time"}, -{"Asia/Bangkok", "SE Asia Standard Time"}, -{"Asia/Barnaul", "Altai Standard Time"}, -{"Asia/Beirut", "Middle East Standard Time"}, -{"Asia/Bishkek", "Central Asia Standard Time"}, -{"Asia/Brunei", "Singapore Standard Time"}, -{"Asia/Calcutta", "India Standard Time"}, -{"Asia/Chita", "Transbaikal Standard Time"}, -{"Asia/Choibalsan", "Ulaanbaatar Standard Time"}, -{"Asia/Chongqing", "China Standard Time"}, -{"Asia/Chungking", "China Standard Time"}, -{"Asia/Colombo", "Sri Lanka Standard Time"}, -{"Asia/Dacca", "Bangladesh Standard Time"}, -{"Asia/Damascus", "Syria Standard Time"}, -{"Asia/Dhaka", "Bangladesh Standard Time"}, -{"Asia/Dili", "Tokyo Standard Time"}, -{"Asia/Dubai", "Arabian Standard Time"}, -{"Asia/Dushanbe", "West Asia Standard Time"}, -{"Asia/Famagusta", "GTB Standard Time"}, -{"Asia/Gaza", "West Bank Standard Time"}, -{"Asia/Harbin", "China Standard Time"}, -{"Asia/Hebron", "West Bank Standard Time"}, -{"Asia/Hong_Kong", "China Standard Time"}, -{"Asia/Hovd", "W. Mongolia Standard Time"}, -{"Asia/Irkutsk", "North Asia East Standard Time"}, -{"Asia/Jakarta", "SE Asia Standard Time"}, -{"Asia/Jayapura", "Tokyo Standard Time"}, -{"Asia/Jerusalem", "Israel Standard Time"}, -{"Asia/Kabul", "Afghanistan Standard Time"}, -{"Asia/Kamchatka", "Russia Time Zone 11"}, -{"Asia/Karachi", "Pakistan Standard Time"}, -{"Asia/Kashgar", "Central Asia Standard Time"}, -{"Asia/Katmandu", "Nepal Standard Time"}, -{"Asia/Khandyga", "Yakutsk Standard Time"}, -{"Asia/Krasnoyarsk", "North Asia Standard Time"}, -{"Asia/Kuala_Lumpur", "Singapore Standard Time"}, -{"Asia/Kuching", "Singapore Standard Time"}, -{"Asia/Kuwait", "Arab Standard Time"}, -{"Asia/Macao", "China Standard Time"}, -{"Asia/Macau", "China Standard Time"}, -{"Asia/Magadan", "Magadan Standard Time"}, -{"Asia/Makassar", "Singapore Standard Time"}, -{"Asia/Manila", "Singapore Standard Time"}, -{"Asia/Muscat", "Arabian Standard Time"}, -{"Asia/Nicosia", "GTB Standard Time"}, -{"Asia/Novokuznetsk", "North Asia Standard Time"}, -{"Asia/Novosibirsk", "N. Central Asia Standard Time"}, -{"Asia/Omsk", "Omsk Standard Time"}, -{"Asia/Oral", "West Asia Standard Time"}, -{"Asia/Phnom_Penh", "SE Asia Standard Time"}, -{"Asia/Pontianak", "SE Asia Standard Time"}, -{"Asia/Pyongyang", "North Korea Standard Time"}, -{"Asia/Qatar", "Arab Standard Time"}, -{"Asia/Qostanay", "Central Asia Standard Time"}, -{"Asia/Qyzylorda", "Qyzylorda Standard Time"}, -{"Asia/Rangoon", "Myanmar Standard Time"}, -{"Asia/Riyadh", "Arab Standard Time"}, -{"Asia/Saigon", "SE Asia Standard Time"}, -{"Asia/Sakhalin", "Sakhalin Standard Time"}, -{"Asia/Samarkand", "West Asia Standard Time"}, -{"Asia/Seoul", "Korea Standard Time"}, -{"Asia/Singapore", "Singapore Standard Time"}, -{"Asia/Srednekolymsk", "Russia Time Zone 10"}, -{"Asia/Taipei", "Taipei Standard Time"}, -{"Asia/Tashkent", "West Asia Standard Time"}, -{"Asia/Tbilisi", "Georgian Standard Time"}, -{"Asia/Tehran", "Iran Standard Time"}, -{"Asia/Tel_Aviv", "Israel Standard Time"}, -{"Asia/Thimbu", "Bangladesh Standard Time"}, -{"Asia/Thimphu", "Bangladesh Standard Time"}, -{"Asia/Tokyo", "Tokyo Standard Time"}, -{"Asia/Tomsk", "Tomsk Standard Time"}, -{"Asia/Ujung_Pandang", "Singapore Standard Time"}, -{"Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"}, -{"Asia/Ulan_Bator", "Ulaanbaatar Standard Time"}, -{"Asia/Urumqi", "Central Asia Standard Time"}, -{"Asia/Ust-Nera", "Vladivostok Standard Time"}, -{"Asia/Vientiane", "SE Asia Standard Time"}, -{"Asia/Vladivostok", "Vladivostok Standard Time"}, -{"Asia/Yakutsk", "Yakutsk Standard Time"}, -{"Asia/Yekaterinburg", "Ekaterinburg Standard Time"}, -{"Asia/Yerevan", "Caucasus Standard Time"}, -{"Atlantic/Azores", "Azores Standard Time"}, -{"Atlantic/Bermuda", "Atlantic Standard Time"}, -{"Atlantic/Canary", "GMT Standard Time"}, -{"Atlantic/Cape_Verde", "Cape Verde Standard Time"}, -{"Atlantic/Faeroe", "GMT Standard Time"}, -{"Atlantic/Jan_Mayen", "W. Europe Standard Time"}, -{"Atlantic/Madeira", "GMT Standard Time"}, -{"Atlantic/Reykjavik", "Greenwich Standard Time"}, -{"Atlantic/South_Georgia", "UTC-02"}, -{"Atlantic/St_Helena", "Greenwich Standard Time"}, -{"Atlantic/Stanley", "SA Eastern Standard Time"}, -{"Australia/ACT", "AUS Eastern Standard Time"}, -{"Australia/Adelaide", "Cen. Australia Standard Time"}, -{"Australia/Brisbane", "E. Australia Standard Time"}, -{"Australia/Broken_Hill", "Cen. Australia Standard Time"}, -{"Australia/Canberra", "AUS Eastern Standard Time"}, -{"Australia/Currie", "Tasmania Standard Time"}, -{"Australia/Darwin", "AUS Central Standard Time"}, -{"Australia/Eucla", "Aus Central W. Standard Time"}, -{"Australia/Hobart", "Tasmania Standard Time"}, -{"Australia/LHI", "Lord Howe Standard Time"}, -{"Australia/Lindeman", "E. Australia Standard Time"}, -{"Australia/Lord_Howe", "Lord Howe Standard Time"}, -{"Australia/Melbourne", "AUS Eastern Standard Time"}, -{"Australia/NSW", "AUS Eastern Standard Time"}, -{"Australia/North", "AUS Central Standard Time"}, -{"Australia/Perth", "W. Australia Standard Time"}, -{"Australia/Queensland", "E. Australia Standard Time"}, -{"Australia/South", "Cen. Australia Standard Time"}, -{"Australia/Sydney", "AUS Eastern Standard Time"}, -{"Australia/Tasmania", "Tasmania Standard Time"}, -{"Australia/Victoria", "AUS Eastern Standard Time"}, -{"Australia/West", "W. Australia Standard Time"}, -{"Australia/Yancowinna", "Cen. Australia Standard Time"}, -{"Brazil/Acre", "SA Pacific Standard Time"}, -{"Brazil/DeNoronha", "UTC-02"}, -{"Brazil/East", "E. South America Standard Time"}, -{"Brazil/West", "SA Western Standard Time"}, -{"CST6CDT", "Central Standard Time"}, -{"Canada/Atlantic", "Atlantic Standard Time"}, -{"Canada/Central", "Central Standard Time"}, -{"Canada/Eastern", "Eastern Standard Time"}, -{"Canada/Mountain", "Mountain Standard Time"}, -{"Canada/Newfoundland", "Newfoundland Standard Time"}, -{"Canada/Pacific", "Pacific Standard Time"}, -{"Canada/Saskatchewan", "Canada Central Standard Time"}, -{"Canada/Yukon", "Yukon Standard Time"}, -{"Chile/Continental", "Pacific SA Standard Time"}, -{"Chile/EasterIsland", "Easter Island Standard Time"}, -{"Cuba", "Cuba Standard Time"}, -{"EST5EDT", "Eastern Standard Time"}, -{"Egypt", "Egypt Standard Time"}, -{"Eire", "GMT Standard Time"}, -{"Etc/GMT", "UTC"}, -{"Etc/GMT+1", "Cape Verde Standard Time"}, -{"Etc/GMT+10", "Hawaiian Standard Time"}, -{"Etc/GMT+11", "UTC-11"}, -{"Etc/GMT+12", "Dateline Standard Time"}, -{"Etc/GMT+2", "UTC-02"}, -{"Etc/GMT+3", "SA Eastern Standard Time"}, -{"Etc/GMT+4", "SA Western Standard Time"}, -{"Etc/GMT+5", "SA Pacific Standard Time"}, -{"Etc/GMT+6", "Central America Standard Time"}, -{"Etc/GMT+7", "US Mountain Standard Time"}, -{"Etc/GMT+8", "UTC-08"}, -{"Etc/GMT+9", "UTC-09"}, -{"Etc/GMT-1", "W. Central Africa Standard Time"}, -{"Etc/GMT-10", "West Pacific Standard Time"}, -{"Etc/GMT-11", "Central Pacific Standard Time"}, -{"Etc/GMT-12", "UTC+12"}, -{"Etc/GMT-13", "UTC+13"}, -{"Etc/GMT-14", "Line Islands Standard Time"}, -{"Etc/GMT-2", "South Africa Standard Time"}, -{"Etc/GMT-3", "E. Africa Standard Time"}, -{"Etc/GMT-4", "Arabian Standard Time"}, -{"Etc/GMT-5", "West Asia Standard Time"}, -{"Etc/GMT-6", "Central Asia Standard Time"}, -{"Etc/GMT-7", "SE Asia Standard Time"}, -{"Etc/GMT-8", "Singapore Standard Time"}, -{"Etc/GMT-9", "Tokyo Standard Time"}, -{"Etc/UCT", "UTC"}, -{"Etc/UTC", "UTC"}, -{"Europe/Amsterdam", "W. Europe Standard Time"}, -{"Europe/Andorra", "W. Europe Standard Time"}, -{"Europe/Astrakhan", "Astrakhan Standard Time"}, -{"Europe/Athens", "GTB Standard Time"}, -{"Europe/Belfast", "GMT Standard Time"}, -{"Europe/Belgrade", "Central Europe Standard Time"}, -{"Europe/Berlin", "W. Europe Standard Time"}, -{"Europe/Bratislava", "Central Europe Standard Time"}, -{"Europe/Brussels", "Romance Standard Time"}, -{"Europe/Bucharest", "GTB Standard Time"}, -{"Europe/Budapest", "Central Europe Standard Time"}, -{"Europe/Busingen", "W. Europe Standard Time"}, -{"Europe/Chisinau", "E. Europe Standard Time"}, -{"Europe/Copenhagen", "Romance Standard Time"}, -{"Europe/Dublin", "GMT Standard Time"}, -{"Europe/Gibraltar", "W. Europe Standard Time"}, -{"Europe/Guernsey", "GMT Standard Time"}, -{"Europe/Helsinki", "FLE Standard Time"}, -{"Europe/Isle_of_Man", "GMT Standard Time"}, -{"Europe/Istanbul", "Turkey Standard Time"}, -{"Europe/Jersey", "GMT Standard Time"}, -{"Europe/Kaliningrad", "Kaliningrad Standard Time"}, -{"Europe/Kiev", "FLE Standard Time"}, -{"Europe/Kirov", "Russian Standard Time"}, -{"Europe/Lisbon", "GMT Standard Time"}, -{"Europe/Ljubljana", "Central Europe Standard Time"}, -{"Europe/London", "GMT Standard Time"}, -{"Europe/Luxembourg", "W. Europe Standard Time"}, -{"Europe/Madrid", "Romance Standard Time"}, -{"Europe/Malta", "W. Europe Standard Time"}, -{"Europe/Mariehamn", "FLE Standard Time"}, -{"Europe/Minsk", "Belarus Standard Time"}, -{"Europe/Monaco", "W. Europe Standard Time"}, -{"Europe/Moscow", "Russian Standard Time"}, -{"Europe/Oslo", "W. Europe Standard Time"}, -{"Europe/Paris", "Romance Standard Time"}, -{"Europe/Podgorica", "Central Europe Standard Time"}, -{"Europe/Prague", "Central Europe Standard Time"}, -{"Europe/Riga", "FLE Standard Time"}, -{"Europe/Rome", "W. Europe Standard Time"}, -{"Europe/Samara", "Russia Time Zone 3"}, -{"Europe/San_Marino", "W. Europe Standard Time"}, -{"Europe/Sarajevo", "Central European Standard Time"}, -{"Europe/Saratov", "Saratov Standard Time"}, -{"Europe/Simferopol", "Russian Standard Time"}, -{"Europe/Skopje", "Central European Standard Time"}, -{"Europe/Sofia", "FLE Standard Time"}, -{"Europe/Stockholm", "W. Europe Standard Time"}, -{"Europe/Tallinn", "FLE Standard Time"}, -{"Europe/Tirane", "Central Europe Standard Time"}, -{"Europe/Tiraspol", "E. Europe Standard Time"}, -{"Europe/Ulyanovsk", "Astrakhan Standard Time"}, -{"Europe/Uzhgorod", "FLE Standard Time"}, -{"Europe/Vaduz", "W. Europe Standard Time"}, -{"Europe/Vatican", "W. Europe Standard Time"}, -{"Europe/Vienna", "W. Europe Standard Time"}, -{"Europe/Vilnius", "FLE Standard Time"}, -{"Europe/Volgograd", "Volgograd Standard Time"}, -{"Europe/Warsaw", "Central European Standard Time"}, -{"Europe/Zagreb", "Central European Standard Time"}, -{"Europe/Zaporozhye", "FLE Standard Time"}, -{"Europe/Zurich", "W. Europe Standard Time"}, -{"GB", "GMT Standard Time"}, -{"GB-Eire", "GMT Standard Time"}, -{"GMT+0", "UTC"}, -{"GMT-0", "UTC"}, -{"GMT0", "UTC"}, -{"Greenwich", "UTC"}, -{"Hongkong", "China Standard Time"}, -{"Iceland", "Greenwich Standard Time"}, -{"Indian/Antananarivo", "E. Africa Standard Time"}, -{"Indian/Chagos", "Central Asia Standard Time"}, -{"Indian/Christmas", "SE Asia Standard Time"}, -{"Indian/Cocos", "Myanmar Standard Time"}, -{"Indian/Comoro", "E. Africa Standard Time"}, -{"Indian/Kerguelen", "West Asia Standard Time"}, -{"Indian/Mahe", "Mauritius Standard Time"}, -{"Indian/Maldives", "West Asia Standard Time"}, -{"Indian/Mauritius", "Mauritius Standard Time"}, -{"Indian/Mayotte", "E. Africa Standard Time"}, -{"Indian/Reunion", "Mauritius Standard Time"}, -{"Iran", "Iran Standard Time"}, -{"Israel", "Israel Standard Time"}, -{"Jamaica", "SA Pacific Standard Time"}, -{"Japan", "Tokyo Standard Time"}, -{"Kwajalein", "UTC+12"}, -{"Libya", "Libya Standard Time"}, -{"MST7MDT", "Mountain Standard Time"}, -{"Mexico/BajaNorte", "Pacific Standard Time (Mexico)"}, -{"Mexico/BajaSur", "Mountain Standard Time (Mexico)"}, -{"Mexico/General", "Central Standard Time (Mexico)"}, -{"NZ", "New Zealand Standard Time"}, -{"NZ-CHAT", "Chatham Islands Standard Time"}, -{"Navajo", "Mountain Standard Time"}, -{"PRC", "China Standard Time"}, -{"PST8PDT", "Pacific Standard Time"}, -{"Pacific/Apia", "Samoa Standard Time"}, -{"Pacific/Auckland", "New Zealand Standard Time"}, -{"Pacific/Bougainville", "Bougainville Standard Time"}, -{"Pacific/Chatham", "Chatham Islands Standard Time"}, -{"Pacific/Easter", "Easter Island Standard Time"}, -{"Pacific/Efate", "Central Pacific Standard Time"}, -{"Pacific/Enderbury", "UTC+13"}, -{"Pacific/Fakaofo", "UTC+13"}, -{"Pacific/Fiji", "Fiji Standard Time"}, -{"Pacific/Funafuti", "UTC+12"}, -{"Pacific/Galapagos", "Central America Standard Time"}, -{"Pacific/Gambier", "UTC-09"}, -{"Pacific/Guadalcanal", "Central Pacific Standard Time"}, -{"Pacific/Guam", "West Pacific Standard Time"}, -{"Pacific/Honolulu", "Hawaiian Standard Time"}, -{"Pacific/Johnston", "Hawaiian Standard Time"}, -{"Pacific/Kiritimati", "Line Islands Standard Time"}, -{"Pacific/Kosrae", "Central Pacific Standard Time"}, -{"Pacific/Kwajalein", "UTC+12"}, -{"Pacific/Majuro", "UTC+12"}, -{"Pacific/Marquesas", "Marquesas Standard Time"}, -{"Pacific/Midway", "UTC-11"}, -{"Pacific/Nauru", "UTC+12"}, -{"Pacific/Niue", "UTC-11"}, -{"Pacific/Norfolk", "Norfolk Standard Time"}, -{"Pacific/Noumea", "Central Pacific Standard Time"}, -{"Pacific/Pago_Pago", "UTC-11"}, -{"Pacific/Palau", "Tokyo Standard Time"}, -{"Pacific/Pitcairn", "UTC-08"}, -{"Pacific/Ponape", "Central Pacific Standard Time"}, -{"Pacific/Port_Moresby", "West Pacific Standard Time"}, -{"Pacific/Rarotonga", "Hawaiian Standard Time"}, -{"Pacific/Saipan", "West Pacific Standard Time"}, -{"Pacific/Samoa", "UTC-11"}, -{"Pacific/Tahiti", "Hawaiian Standard Time"}, -{"Pacific/Tarawa", "UTC+12"}, -{"Pacific/Tongatapu", "Tonga Standard Time"}, -{"Pacific/Truk", "West Pacific Standard Time"}, -{"Pacific/Wake", "UTC+12"}, -{"Pacific/Wallis", "UTC+12"}, -{"Poland", "Central European Standard Time"}, -{"Portugal", "GMT Standard Time"}, -{"ROC", "Taipei Standard Time"}, -{"ROK", "Korea Standard Time"}, -{"Singapore", "Singapore Standard Time"}, -{"Turkey", "Turkey Standard Time"}, -{"UCT", "UTC"}, -{"US/Alaska", "Alaskan Standard Time"}, -{"US/Aleutian", "Aleutian Standard Time"}, -{"US/Arizona", "US Mountain Standard Time"}, -{"US/Central", "Central Standard Time"}, -{"US/Eastern", "Eastern Standard Time"}, -{"US/Hawaii", "Hawaiian Standard Time"}, -{"US/Indiana-Starke", "Central Standard Time"}, -{"US/Michigan", "Eastern Standard Time"}, -{"US/Mountain", "Mountain Standard Time"}, -{"US/Pacific", "Pacific Standard Time"}, -{"US/Samoa", "UTC-11"}, -{"UTC", "UTC"}, -{"Universal", "UTC"}, -{"W-SU", "Russian Standard Time"}, -{"Zulu", "UTC"}}; +char *win_tz[139][2] = {{"China Standard Time", "Asia/Shanghai"}, + {"AUS Central Standard Time", "Australia/Darwin"}, + {"AUS Eastern Standard Time", "Australia/Sydney"}, + {"Afghanistan Standard Time", "Asia/Kabul"}, + {"Alaskan Standard Time", "America/Anchorage"}, + {"Aleutian Standard Time", "America/Adak"}, + {"Altai Standard Time", "Asia/Barnaul"}, + {"Arab Standard Time", "Asia/Riyadh"}, + {"Arabian Standard Time", "Asia/Dubai"}, + {"Arabic Standard Time", "Asia/Baghdad"}, + {"Argentina Standard Time", "America/Buenos_Aires"}, + {"Astrakhan Standard Time", "Europe/Astrakhan"}, + {"Atlantic Standard Time", "America/Halifax"}, + {"Aus Central W. Standard Time", "Australia/Eucla"}, + {"Azerbaijan Standard Time", "Asia/Baku"}, + {"Azores Standard Time", "Atlantic/Azores"}, + {"Bahia Standard Time", "America/Bahia"}, + {"Bangladesh Standard Time", "Asia/Dhaka"}, + {"Belarus Standard Time", "Europe/Minsk"}, + {"Bougainville Standard Time", "Pacific/Bougainville"}, + {"Canada Central Standard Time", "America/Regina"}, + {"Cape Verde Standard Time", "Atlantic/Cape_Verde"}, + {"Caucasus Standard Time", "Asia/Yerevan"}, + {"Cen. Australia Standard Time", "Australia/Adelaide"}, + {"Central America Standard Time", "America/Guatemala"}, + {"Central Asia Standard Time", "Asia/Almaty"}, + {"Central Brazilian Standard Time", "America/Cuiaba"}, + {"Central Europe Standard Time", "Europe/Budapest"}, + {"Central European Standard Time", "Europe/Warsaw"}, + {"Central Pacific Standard Time", "Pacific/Guadalcanal"}, + {"Central Standard Time", "America/Chicago"}, + {"Central Standard Time (Mexico)", "America/Mexico_City"}, + {"Chatham Islands Standard Time", "Pacific/Chatham"}, + {"Cuba Standard Time", "America/Havana"}, + {"Dateline Standard Time", "Etc/GMT+12"}, + {"E. Africa Standard Time", "Africa/Nairobi"}, + {"E. Australia Standard Time", "Australia/Brisbane"}, + {"E. Europe Standard Time", "Europe/Chisinau"}, + {"E. South America Standard Time", "America/Sao_Paulo"}, + {"Easter Island Standard Time", "Pacific/Easter"}, + {"Eastern Standard Time", "America/New_York"}, + {"Eastern Standard Time (Mexico)", "America/Cancun"}, + {"Egypt Standard Time", "Africa/Cairo"}, + {"Ekaterinburg Standard Time", "Asia/Yekaterinburg"}, + {"FLE Standard Time", "Europe/Kiev"}, + {"Fiji Standard Time", "Pacific/Fiji"}, + {"GMT Standard Time", "Europe/London"}, + {"GTB Standard Time", "Europe/Bucharest"}, + {"Georgian Standard Time", "Asia/Tbilisi"}, + {"Greenland Standard Time", "America/Godthab"}, + {"Greenwich Standard Time", "Atlantic/Reykjavik"}, + {"Haiti Standard Time", "America/Port-au-Prince"}, + {"Hawaiian Standard Time", "Pacific/Honolulu"}, + {"India Standard Time", "Asia/Calcutta"}, + {"Iran Standard Time", "Asia/Tehran"}, + {"Israel Standard Time", "Asia/Jerusalem"}, + {"Jordan Standard Time", "Asia/Amman"}, + {"Kaliningrad Standard Time", "Europe/Kaliningrad"}, + {"Korea Standard Time", "Asia/Seoul"}, + {"Libya Standard Time", "Africa/Tripoli"}, + {"Line Islands Standard Time", "Pacific/Kiritimati"}, + {"Lord Howe Standard Time", "Australia/Lord_Howe"}, + {"Magadan Standard Time", "Asia/Magadan"}, + {"Magallanes Standard Time", "America/Punta_Arenas"}, + {"Marquesas Standard Time", "Pacific/Marquesas"}, + {"Mauritius Standard Time", "Indian/Mauritius"}, + {"Middle East Standard Time", "Asia/Beirut"}, + {"Montevideo Standard Time", "America/Montevideo"}, + {"Morocco Standard Time", "Africa/Casablanca"}, + {"Mountain Standard Time", "America/Denver"}, + {"Mountain Standard Time (Mexico)", "America/Chihuahua"}, + {"Myanmar Standard Time", "Asia/Rangoon"}, + {"N. Central Asia Standard Time", "Asia/Novosibirsk"}, + {"Namibia Standard Time", "Africa/Windhoek"}, + {"Nepal Standard Time", "Asia/Katmandu"}, + {"New Zealand Standard Time", "Pacific/Auckland"}, + {"Newfoundland Standard Time", "America/St_Johns"}, + {"Norfolk Standard Time", "Pacific/Norfolk"}, + {"North Asia East Standard Time", "Asia/Irkutsk"}, + {"North Asia Standard Time", "Asia/Krasnoyarsk"}, + {"North Korea Standard Time", "Asia/Pyongyang"}, + {"Omsk Standard Time", "Asia/Omsk"}, + {"Pacific SA Standard Time", "America/Santiago"}, + {"Pacific Standard Time", "America/Los_Angeles"}, + {"Pacific Standard Time (Mexico)", "America/Tijuana"}, + {"Pakistan Standard Time", "Asia/Karachi"}, + {"Paraguay Standard Time", "America/Asuncion"}, + {"Qyzylorda Standard Time", "Asia/Qyzylorda"}, + {"Romance Standard Time", "Europe/Paris"}, + {"Russia Time Zone 10", "Asia/Srednekolymsk"}, + {"Russia Time Zone 11", "Asia/Kamchatka"}, + {"Russia Time Zone 3", "Europe/Samara"}, + {"Russian Standard Time", "Europe/Moscow"}, + {"SA Eastern Standard Time", "America/Cayenne"}, + {"SA Pacific Standard Time", "America/Bogota"}, + {"SA Western Standard Time", "America/La_Paz"}, + {"SE Asia Standard Time", "Asia/Bangkok"}, + {"Saint Pierre Standard Time", "America/Miquelon"}, + {"Sakhalin Standard Time", "Asia/Sakhalin"}, + {"Samoa Standard Time", "Pacific/Apia"}, + {"Sao Tome Standard Time", "Africa/Sao_Tome"}, + {"Saratov Standard Time", "Europe/Saratov"}, + {"Singapore Standard Time", "Asia/Singapore"}, + {"South Africa Standard Time", "Africa/Johannesburg"}, + {"South Sudan Standard Time", "Africa/Juba"}, + {"Sri Lanka Standard Time", "Asia/Colombo"}, + {"Sudan Standard Time", "Africa/Khartoum"}, + {"Syria Standard Time", "Asia/Damascus"}, + {"Taipei Standard Time", "Asia/Taipei"}, + {"Tasmania Standard Time", "Australia/Hobart"}, + {"Tocantins Standard Time", "America/Araguaina"}, + {"Tokyo Standard Time", "Asia/Tokyo"}, + {"Tomsk Standard Time", "Asia/Tomsk"}, + {"Tonga Standard Time", "Pacific/Tongatapu"}, + {"Transbaikal Standard Time", "Asia/Chita"}, + {"Turkey Standard Time", "Europe/Istanbul"}, + {"Turks And Caicos Standard Time", "America/Grand_Turk"}, + {"US Eastern Standard Time", "America/Indianapolis"}, + {"US Mountain Standard Time", "America/Phoenix"}, + {"UTC", "Etc/UTC"}, + {"UTC+12", "Etc/GMT-12"}, + {"UTC+13", "Etc/GMT-13"}, + {"UTC-02", "Etc/GMT+2"}, + {"UTC-08", "Etc/GMT+8"}, + {"UTC-09", "Etc/GMT+9"}, + {"UTC-11", "Etc/GMT+11"}, + {"Ulaanbaatar Standard Time", "Asia/Ulaanbaatar"}, + {"Venezuela Standard Time", "America/Caracas"}, + {"Vladivostok Standard Time", "Asia/Vladivostok"}, + {"Volgograd Standard Time", "Europe/Volgograd"}, + {"W. Australia Standard Time", "Australia/Perth"}, + {"W. Central Africa Standard Time", "Africa/Lagos"}, + {"W. Europe Standard Time", "Europe/Berlin"}, + {"W. Mongolia Standard Time", "Asia/Hovd"}, + {"West Asia Standard Time", "Asia/Tashkent"}, + {"West Bank Standard Time", "Asia/Hebron"}, + {"West Pacific Standard Time", "Pacific/Port_Moresby"}, + {"Yakutsk Standard Time", "Asia/Yakutsk"}, + {"Yukon Standard Time", "America/Whitehorse"}}; +char *tz_win[554][2] = {{"Asia/Shanghai", "China Standard Time"}, + {"Africa/Abidjan", "Greenwich Standard Time"}, + {"Africa/Accra", "Greenwich Standard Time"}, + {"Africa/Addis_Ababa", "E. Africa Standard Time"}, + {"Africa/Algiers", "W. Central Africa Standard Time"}, + {"Africa/Asmera", "E. Africa Standard Time"}, + {"Africa/Bamako", "Greenwich Standard Time"}, + {"Africa/Bangui", "W. Central Africa Standard Time"}, + {"Africa/Banjul", "Greenwich Standard Time"}, + {"Africa/Bissau", "Greenwich Standard Time"}, + {"Africa/Blantyre", "South Africa Standard Time"}, + {"Africa/Brazzaville", "W. Central Africa Standard Time"}, + {"Africa/Bujumbura", "South Africa Standard Time"}, + {"Africa/Cairo", "Egypt Standard Time"}, + {"Africa/Casablanca", "Morocco Standard Time"}, + {"Africa/Ceuta", "Romance Standard Time"}, + {"Africa/Conakry", "Greenwich Standard Time"}, + {"Africa/Dakar", "Greenwich Standard Time"}, + {"Africa/Dar_es_Salaam", "E. Africa Standard Time"}, + {"Africa/Djibouti", "E. Africa Standard Time"}, + {"Africa/Douala", "W. Central Africa Standard Time"}, + {"Africa/El_Aaiun", "Morocco Standard Time"}, + {"Africa/Freetown", "Greenwich Standard Time"}, + {"Africa/Gaborone", "South Africa Standard Time"}, + {"Africa/Harare", "South Africa Standard Time"}, + {"Africa/Johannesburg", "South Africa Standard Time"}, + {"Africa/Juba", "South Sudan Standard Time"}, + {"Africa/Kampala", "E. Africa Standard Time"}, + {"Africa/Khartoum", "Sudan Standard Time"}, + {"Africa/Kigali", "South Africa Standard Time"}, + {"Africa/Kinshasa", "W. Central Africa Standard Time"}, + {"Africa/Lagos", "W. Central Africa Standard Time"}, + {"Africa/Libreville", "W. Central Africa Standard Time"}, + {"Africa/Lome", "Greenwich Standard Time"}, + {"Africa/Luanda", "W. Central Africa Standard Time"}, + {"Africa/Lubumbashi", "South Africa Standard Time"}, + {"Africa/Lusaka", "South Africa Standard Time"}, + {"Africa/Malabo", "W. Central Africa Standard Time"}, + {"Africa/Maputo", "South Africa Standard Time"}, + {"Africa/Maseru", "South Africa Standard Time"}, + {"Africa/Mbabane", "South Africa Standard Time"}, + {"Africa/Mogadishu", "E. Africa Standard Time"}, + {"Africa/Monrovia", "Greenwich Standard Time"}, + {"Africa/Nairobi", "E. Africa Standard Time"}, + {"Africa/Ndjamena", "W. Central Africa Standard Time"}, + {"Africa/Niamey", "W. Central Africa Standard Time"}, + {"Africa/Nouakchott", "Greenwich Standard Time"}, + {"Africa/Ouagadougou", "Greenwich Standard Time"}, + {"Africa/Porto-Novo", "W. Central Africa Standard Time"}, + {"Africa/Sao_Tome", "Sao Tome Standard Time"}, + {"Africa/Timbuktu", "Greenwich Standard Time"}, + {"Africa/Tripoli", "Libya Standard Time"}, + {"Africa/Tunis", "W. Central Africa Standard Time"}, + {"Africa/Windhoek", "Namibia Standard Time"}, + {"America/Adak", "Aleutian Standard Time"}, + {"America/Anchorage", "Alaskan Standard Time"}, + {"America/Anguilla", "SA Western Standard Time"}, + {"America/Antigua", "SA Western Standard Time"}, + {"America/Araguaina", "Tocantins Standard Time"}, + {"America/Argentina/La_Rioja", "Argentina Standard Time"}, + {"America/Argentina/Rio_Gallegos", "Argentina Standard Time"}, + {"America/Argentina/Salta", "Argentina Standard Time"}, + {"America/Argentina/San_Juan", "Argentina Standard Time"}, + {"America/Argentina/San_Luis", "Argentina Standard Time"}, + {"America/Argentina/Tucuman", "Argentina Standard Time"}, + {"America/Argentina/Ushuaia", "Argentina Standard Time"}, + {"America/Aruba", "SA Western Standard Time"}, + {"America/Asuncion", "Paraguay Standard Time"}, + {"America/Atka", "Aleutian Standard Time"}, + {"America/Bahia", "Bahia Standard Time"}, + {"America/Bahia_Banderas", "Central Standard Time (Mexico)"}, + {"America/Barbados", "SA Western Standard Time"}, + {"America/Belem", "SA Eastern Standard Time"}, + {"America/Belize", "Central America Standard Time"}, + {"America/Blanc-Sablon", "SA Western Standard Time"}, + {"America/Boa_Vista", "SA Western Standard Time"}, + {"America/Bogota", "SA Pacific Standard Time"}, + {"America/Boise", "Mountain Standard Time"}, + {"America/Buenos_Aires", "Argentina Standard Time"}, + {"America/Cambridge_Bay", "Mountain Standard Time"}, + {"America/Campo_Grande", "Central Brazilian Standard Time"}, + {"America/Cancun", "Eastern Standard Time (Mexico)"}, + {"America/Caracas", "Venezuela Standard Time"}, + {"America/Catamarca", "Argentina Standard Time"}, + {"America/Cayenne", "SA Eastern Standard Time"}, + {"America/Cayman", "SA Pacific Standard Time"}, + {"America/Chicago", "Central Standard Time"}, + {"America/Chihuahua", "Mountain Standard Time (Mexico)"}, + {"America/Coral_Harbour", "SA Pacific Standard Time"}, + {"America/Cordoba", "Argentina Standard Time"}, + {"America/Costa_Rica", "Central America Standard Time"}, + {"America/Creston", "US Mountain Standard Time"}, + {"America/Cuiaba", "Central Brazilian Standard Time"}, + {"America/Curacao", "SA Western Standard Time"}, + {"America/Danmarkshavn", "Greenwich Standard Time"}, + {"America/Dawson", "Yukon Standard Time"}, + {"America/Dawson_Creek", "US Mountain Standard Time"}, + {"America/Denver", "Mountain Standard Time"}, + {"America/Detroit", "Eastern Standard Time"}, + {"America/Dominica", "SA Western Standard Time"}, + {"America/Edmonton", "Mountain Standard Time"}, + {"America/Eirunepe", "SA Pacific Standard Time"}, + {"America/El_Salvador", "Central America Standard Time"}, + {"America/Ensenada", "Pacific Standard Time (Mexico)"}, + {"America/Fort_Nelson", "US Mountain Standard Time"}, + {"America/Fortaleza", "SA Eastern Standard Time"}, + {"America/Glace_Bay", "Atlantic Standard Time"}, + {"America/Godthab", "Greenland Standard Time"}, + {"America/Goose_Bay", "Atlantic Standard Time"}, + {"America/Grand_Turk", "Turks And Caicos Standard Time"}, + {"America/Grenada", "SA Western Standard Time"}, + {"America/Guadeloupe", "SA Western Standard Time"}, + {"America/Guatemala", "Central America Standard Time"}, + {"America/Guayaquil", "SA Pacific Standard Time"}, + {"America/Guyana", "SA Western Standard Time"}, + {"America/Halifax", "Atlantic Standard Time"}, + {"America/Havana", "Cuba Standard Time"}, + {"America/Hermosillo", "US Mountain Standard Time"}, + {"America/Indiana/Knox", "Central Standard Time"}, + {"America/Indiana/Marengo", "US Eastern Standard Time"}, + {"America/Indiana/Petersburg", "Eastern Standard Time"}, + {"America/Indiana/Tell_City", "Central Standard Time"}, + {"America/Indiana/Vevay", "US Eastern Standard Time"}, + {"America/Indiana/Vincennes", "Eastern Standard Time"}, + {"America/Indiana/Winamac", "Eastern Standard Time"}, + {"America/Indianapolis", "US Eastern Standard Time"}, + {"America/Inuvik", "Mountain Standard Time"}, + {"America/Iqaluit", "Eastern Standard Time"}, + {"America/Jamaica", "SA Pacific Standard Time"}, + {"America/Jujuy", "Argentina Standard Time"}, + {"America/Juneau", "Alaskan Standard Time"}, + {"America/Kentucky/Monticello", "Eastern Standard Time"}, + {"America/Knox_IN", "Central Standard Time"}, + {"America/Kralendijk", "SA Western Standard Time"}, + {"America/La_Paz", "SA Western Standard Time"}, + {"America/Lima", "SA Pacific Standard Time"}, + {"America/Los_Angeles", "Pacific Standard Time"}, + {"America/Louisville", "Eastern Standard Time"}, + {"America/Lower_Princes", "SA Western Standard Time"}, + {"America/Maceio", "SA Eastern Standard Time"}, + {"America/Managua", "Central America Standard Time"}, + {"America/Manaus", "SA Western Standard Time"}, + {"America/Marigot", "SA Western Standard Time"}, + {"America/Martinique", "SA Western Standard Time"}, + {"America/Matamoros", "Central Standard Time"}, + {"America/Mazatlan", "Mountain Standard Time (Mexico)"}, + {"America/Mendoza", "Argentina Standard Time"}, + {"America/Menominee", "Central Standard Time"}, + {"America/Merida", "Central Standard Time (Mexico)"}, + {"America/Metlakatla", "Alaskan Standard Time"}, + {"America/Mexico_City", "Central Standard Time (Mexico)"}, + {"America/Miquelon", "Saint Pierre Standard Time"}, + {"America/Moncton", "Atlantic Standard Time"}, + {"America/Monterrey", "Central Standard Time (Mexico)"}, + {"America/Montevideo", "Montevideo Standard Time"}, + {"America/Montreal", "Eastern Standard Time"}, + {"America/Montserrat", "SA Western Standard Time"}, + {"America/Nassau", "Eastern Standard Time"}, + {"America/New_York", "Eastern Standard Time"}, + {"America/Nipigon", "Eastern Standard Time"}, + {"America/Nome", "Alaskan Standard Time"}, + {"America/Noronha", "UTC-02"}, + {"America/North_Dakota/Beulah", "Central Standard Time"}, + {"America/North_Dakota/Center", "Central Standard Time"}, + {"America/North_Dakota/New_Salem", "Central Standard Time"}, + {"America/Ojinaga", "Mountain Standard Time"}, + {"America/Panama", "SA Pacific Standard Time"}, + {"America/Pangnirtung", "Eastern Standard Time"}, + {"America/Paramaribo", "SA Eastern Standard Time"}, + {"America/Phoenix", "US Mountain Standard Time"}, + {"America/Port-au-Prince", "Haiti Standard Time"}, + {"America/Port_of_Spain", "SA Western Standard Time"}, + {"America/Porto_Acre", "SA Pacific Standard Time"}, + {"America/Porto_Velho", "SA Western Standard Time"}, + {"America/Puerto_Rico", "SA Western Standard Time"}, + {"America/Punta_Arenas", "Magallanes Standard Time"}, + {"America/Rainy_River", "Central Standard Time"}, + {"America/Rankin_Inlet", "Central Standard Time"}, + {"America/Recife", "SA Eastern Standard Time"}, + {"America/Regina", "Canada Central Standard Time"}, + {"America/Resolute", "Central Standard Time"}, + {"America/Rio_Branco", "SA Pacific Standard Time"}, + {"America/Santa_Isabel", "Pacific Standard Time (Mexico)"}, + {"America/Santarem", "SA Eastern Standard Time"}, + {"America/Santiago", "Pacific SA Standard Time"}, + {"America/Santo_Domingo", "SA Western Standard Time"}, + {"America/Sao_Paulo", "E. South America Standard Time"}, + {"America/Scoresbysund", "Azores Standard Time"}, + {"America/Shiprock", "Mountain Standard Time"}, + {"America/Sitka", "Alaskan Standard Time"}, + {"America/St_Barthelemy", "SA Western Standard Time"}, + {"America/St_Johns", "Newfoundland Standard Time"}, + {"America/St_Kitts", "SA Western Standard Time"}, + {"America/St_Lucia", "SA Western Standard Time"}, + {"America/St_Thomas", "SA Western Standard Time"}, + {"America/St_Vincent", "SA Western Standard Time"}, + {"America/Swift_Current", "Canada Central Standard Time"}, + {"America/Tegucigalpa", "Central America Standard Time"}, + {"America/Thule", "Atlantic Standard Time"}, + {"America/Thunder_Bay", "Eastern Standard Time"}, + {"America/Tijuana", "Pacific Standard Time (Mexico)"}, + {"America/Toronto", "Eastern Standard Time"}, + {"America/Tortola", "SA Western Standard Time"}, + {"America/Vancouver", "Pacific Standard Time"}, + {"America/Virgin", "SA Western Standard Time"}, + {"America/Whitehorse", "Yukon Standard Time"}, + {"America/Winnipeg", "Central Standard Time"}, + {"America/Yakutat", "Alaskan Standard Time"}, + {"America/Yellowknife", "Mountain Standard Time"}, + {"Antarctica/Casey", "Central Pacific Standard Time"}, + {"Antarctica/Davis", "SE Asia Standard Time"}, + {"Antarctica/DumontDUrville", "West Pacific Standard Time"}, + {"Antarctica/Macquarie", "Tasmania Standard Time"}, + {"Antarctica/Mawson", "West Asia Standard Time"}, + {"Antarctica/McMurdo", "New Zealand Standard Time"}, + {"Antarctica/Palmer", "SA Eastern Standard Time"}, + {"Antarctica/Rothera", "SA Eastern Standard Time"}, + {"Antarctica/South_Pole", "New Zealand Standard Time"}, + {"Antarctica/Syowa", "E. Africa Standard Time"}, + {"Antarctica/Vostok", "Central Asia Standard Time"}, + {"Arctic/Longyearbyen", "W. Europe Standard Time"}, + {"Asia/Aden", "Arab Standard Time"}, + {"Asia/Almaty", "Central Asia Standard Time"}, + {"Asia/Amman", "Jordan Standard Time"}, + {"Asia/Anadyr", "Russia Time Zone 11"}, + {"Asia/Aqtau", "West Asia Standard Time"}, + {"Asia/Aqtobe", "West Asia Standard Time"}, + {"Asia/Ashgabat", "West Asia Standard Time"}, + {"Asia/Ashkhabad", "West Asia Standard Time"}, + {"Asia/Atyrau", "West Asia Standard Time"}, + {"Asia/Baghdad", "Arabic Standard Time"}, + {"Asia/Bahrain", "Arab Standard Time"}, + {"Asia/Baku", "Azerbaijan Standard Time"}, + {"Asia/Bangkok", "SE Asia Standard Time"}, + {"Asia/Barnaul", "Altai Standard Time"}, + {"Asia/Beirut", "Middle East Standard Time"}, + {"Asia/Bishkek", "Central Asia Standard Time"}, + {"Asia/Brunei", "Singapore Standard Time"}, + {"Asia/Calcutta", "India Standard Time"}, + {"Asia/Chita", "Transbaikal Standard Time"}, + {"Asia/Choibalsan", "Ulaanbaatar Standard Time"}, + {"Asia/Chongqing", "China Standard Time"}, + {"Asia/Chungking", "China Standard Time"}, + {"Asia/Colombo", "Sri Lanka Standard Time"}, + {"Asia/Dacca", "Bangladesh Standard Time"}, + {"Asia/Damascus", "Syria Standard Time"}, + {"Asia/Dhaka", "Bangladesh Standard Time"}, + {"Asia/Dili", "Tokyo Standard Time"}, + {"Asia/Dubai", "Arabian Standard Time"}, + {"Asia/Dushanbe", "West Asia Standard Time"}, + {"Asia/Famagusta", "GTB Standard Time"}, + {"Asia/Gaza", "West Bank Standard Time"}, + {"Asia/Harbin", "China Standard Time"}, + {"Asia/Hebron", "West Bank Standard Time"}, + {"Asia/Hong_Kong", "China Standard Time"}, + {"Asia/Hovd", "W. Mongolia Standard Time"}, + {"Asia/Irkutsk", "North Asia East Standard Time"}, + {"Asia/Jakarta", "SE Asia Standard Time"}, + {"Asia/Jayapura", "Tokyo Standard Time"}, + {"Asia/Jerusalem", "Israel Standard Time"}, + {"Asia/Kabul", "Afghanistan Standard Time"}, + {"Asia/Kamchatka", "Russia Time Zone 11"}, + {"Asia/Karachi", "Pakistan Standard Time"}, + {"Asia/Kashgar", "Central Asia Standard Time"}, + {"Asia/Katmandu", "Nepal Standard Time"}, + {"Asia/Khandyga", "Yakutsk Standard Time"}, + {"Asia/Krasnoyarsk", "North Asia Standard Time"}, + {"Asia/Kuala_Lumpur", "Singapore Standard Time"}, + {"Asia/Kuching", "Singapore Standard Time"}, + {"Asia/Kuwait", "Arab Standard Time"}, + {"Asia/Macao", "China Standard Time"}, + {"Asia/Macau", "China Standard Time"}, + {"Asia/Magadan", "Magadan Standard Time"}, + {"Asia/Makassar", "Singapore Standard Time"}, + {"Asia/Manila", "Singapore Standard Time"}, + {"Asia/Muscat", "Arabian Standard Time"}, + {"Asia/Nicosia", "GTB Standard Time"}, + {"Asia/Novokuznetsk", "North Asia Standard Time"}, + {"Asia/Novosibirsk", "N. Central Asia Standard Time"}, + {"Asia/Omsk", "Omsk Standard Time"}, + {"Asia/Oral", "West Asia Standard Time"}, + {"Asia/Phnom_Penh", "SE Asia Standard Time"}, + {"Asia/Pontianak", "SE Asia Standard Time"}, + {"Asia/Pyongyang", "North Korea Standard Time"}, + {"Asia/Qatar", "Arab Standard Time"}, + {"Asia/Qostanay", "Central Asia Standard Time"}, + {"Asia/Qyzylorda", "Qyzylorda Standard Time"}, + {"Asia/Rangoon", "Myanmar Standard Time"}, + {"Asia/Riyadh", "Arab Standard Time"}, + {"Asia/Saigon", "SE Asia Standard Time"}, + {"Asia/Sakhalin", "Sakhalin Standard Time"}, + {"Asia/Samarkand", "West Asia Standard Time"}, + {"Asia/Seoul", "Korea Standard Time"}, + {"Asia/Singapore", "Singapore Standard Time"}, + {"Asia/Srednekolymsk", "Russia Time Zone 10"}, + {"Asia/Taipei", "Taipei Standard Time"}, + {"Asia/Tashkent", "West Asia Standard Time"}, + {"Asia/Tbilisi", "Georgian Standard Time"}, + {"Asia/Tehran", "Iran Standard Time"}, + {"Asia/Tel_Aviv", "Israel Standard Time"}, + {"Asia/Thimbu", "Bangladesh Standard Time"}, + {"Asia/Thimphu", "Bangladesh Standard Time"}, + {"Asia/Tokyo", "Tokyo Standard Time"}, + {"Asia/Tomsk", "Tomsk Standard Time"}, + {"Asia/Ujung_Pandang", "Singapore Standard Time"}, + {"Asia/Ulaanbaatar", "Ulaanbaatar Standard Time"}, + {"Asia/Ulan_Bator", "Ulaanbaatar Standard Time"}, + {"Asia/Urumqi", "Central Asia Standard Time"}, + {"Asia/Ust-Nera", "Vladivostok Standard Time"}, + {"Asia/Vientiane", "SE Asia Standard Time"}, + {"Asia/Vladivostok", "Vladivostok Standard Time"}, + {"Asia/Yakutsk", "Yakutsk Standard Time"}, + {"Asia/Yekaterinburg", "Ekaterinburg Standard Time"}, + {"Asia/Yerevan", "Caucasus Standard Time"}, + {"Atlantic/Azores", "Azores Standard Time"}, + {"Atlantic/Bermuda", "Atlantic Standard Time"}, + {"Atlantic/Canary", "GMT Standard Time"}, + {"Atlantic/Cape_Verde", "Cape Verde Standard Time"}, + {"Atlantic/Faeroe", "GMT Standard Time"}, + {"Atlantic/Jan_Mayen", "W. Europe Standard Time"}, + {"Atlantic/Madeira", "GMT Standard Time"}, + {"Atlantic/Reykjavik", "Greenwich Standard Time"}, + {"Atlantic/South_Georgia", "UTC-02"}, + {"Atlantic/St_Helena", "Greenwich Standard Time"}, + {"Atlantic/Stanley", "SA Eastern Standard Time"}, + {"Australia/ACT", "AUS Eastern Standard Time"}, + {"Australia/Adelaide", "Cen. Australia Standard Time"}, + {"Australia/Brisbane", "E. Australia Standard Time"}, + {"Australia/Broken_Hill", "Cen. Australia Standard Time"}, + {"Australia/Canberra", "AUS Eastern Standard Time"}, + {"Australia/Currie", "Tasmania Standard Time"}, + {"Australia/Darwin", "AUS Central Standard Time"}, + {"Australia/Eucla", "Aus Central W. Standard Time"}, + {"Australia/Hobart", "Tasmania Standard Time"}, + {"Australia/LHI", "Lord Howe Standard Time"}, + {"Australia/Lindeman", "E. Australia Standard Time"}, + {"Australia/Lord_Howe", "Lord Howe Standard Time"}, + {"Australia/Melbourne", "AUS Eastern Standard Time"}, + {"Australia/NSW", "AUS Eastern Standard Time"}, + {"Australia/North", "AUS Central Standard Time"}, + {"Australia/Perth", "W. Australia Standard Time"}, + {"Australia/Queensland", "E. Australia Standard Time"}, + {"Australia/South", "Cen. Australia Standard Time"}, + {"Australia/Sydney", "AUS Eastern Standard Time"}, + {"Australia/Tasmania", "Tasmania Standard Time"}, + {"Australia/Victoria", "AUS Eastern Standard Time"}, + {"Australia/West", "W. Australia Standard Time"}, + {"Australia/Yancowinna", "Cen. Australia Standard Time"}, + {"Brazil/Acre", "SA Pacific Standard Time"}, + {"Brazil/DeNoronha", "UTC-02"}, + {"Brazil/East", "E. South America Standard Time"}, + {"Brazil/West", "SA Western Standard Time"}, + {"CST6CDT", "Central Standard Time"}, + {"Canada/Atlantic", "Atlantic Standard Time"}, + {"Canada/Central", "Central Standard Time"}, + {"Canada/Eastern", "Eastern Standard Time"}, + {"Canada/Mountain", "Mountain Standard Time"}, + {"Canada/Newfoundland", "Newfoundland Standard Time"}, + {"Canada/Pacific", "Pacific Standard Time"}, + {"Canada/Saskatchewan", "Canada Central Standard Time"}, + {"Canada/Yukon", "Yukon Standard Time"}, + {"Chile/Continental", "Pacific SA Standard Time"}, + {"Chile/EasterIsland", "Easter Island Standard Time"}, + {"Cuba", "Cuba Standard Time"}, + {"EST5EDT", "Eastern Standard Time"}, + {"Egypt", "Egypt Standard Time"}, + {"Eire", "GMT Standard Time"}, + {"Etc/GMT", "UTC"}, + {"Etc/GMT+1", "Cape Verde Standard Time"}, + {"Etc/GMT+10", "Hawaiian Standard Time"}, + {"Etc/GMT+11", "UTC-11"}, + {"Etc/GMT+12", "Dateline Standard Time"}, + {"Etc/GMT+2", "UTC-02"}, + {"Etc/GMT+3", "SA Eastern Standard Time"}, + {"Etc/GMT+4", "SA Western Standard Time"}, + {"Etc/GMT+5", "SA Pacific Standard Time"}, + {"Etc/GMT+6", "Central America Standard Time"}, + {"Etc/GMT+7", "US Mountain Standard Time"}, + {"Etc/GMT+8", "UTC-08"}, + {"Etc/GMT+9", "UTC-09"}, + {"Etc/GMT-1", "W. Central Africa Standard Time"}, + {"Etc/GMT-10", "West Pacific Standard Time"}, + {"Etc/GMT-11", "Central Pacific Standard Time"}, + {"Etc/GMT-12", "UTC+12"}, + {"Etc/GMT-13", "UTC+13"}, + {"Etc/GMT-14", "Line Islands Standard Time"}, + {"Etc/GMT-2", "South Africa Standard Time"}, + {"Etc/GMT-3", "E. Africa Standard Time"}, + {"Etc/GMT-4", "Arabian Standard Time"}, + {"Etc/GMT-5", "West Asia Standard Time"}, + {"Etc/GMT-6", "Central Asia Standard Time"}, + {"Etc/GMT-7", "SE Asia Standard Time"}, + {"Etc/GMT-8", "Singapore Standard Time"}, + {"Etc/GMT-9", "Tokyo Standard Time"}, + {"Etc/UCT", "UTC"}, + {"Etc/UTC", "UTC"}, + {"Europe/Amsterdam", "W. Europe Standard Time"}, + {"Europe/Andorra", "W. Europe Standard Time"}, + {"Europe/Astrakhan", "Astrakhan Standard Time"}, + {"Europe/Athens", "GTB Standard Time"}, + {"Europe/Belfast", "GMT Standard Time"}, + {"Europe/Belgrade", "Central Europe Standard Time"}, + {"Europe/Berlin", "W. Europe Standard Time"}, + {"Europe/Bratislava", "Central Europe Standard Time"}, + {"Europe/Brussels", "Romance Standard Time"}, + {"Europe/Bucharest", "GTB Standard Time"}, + {"Europe/Budapest", "Central Europe Standard Time"}, + {"Europe/Busingen", "W. Europe Standard Time"}, + {"Europe/Chisinau", "E. Europe Standard Time"}, + {"Europe/Copenhagen", "Romance Standard Time"}, + {"Europe/Dublin", "GMT Standard Time"}, + {"Europe/Gibraltar", "W. Europe Standard Time"}, + {"Europe/Guernsey", "GMT Standard Time"}, + {"Europe/Helsinki", "FLE Standard Time"}, + {"Europe/Isle_of_Man", "GMT Standard Time"}, + {"Europe/Istanbul", "Turkey Standard Time"}, + {"Europe/Jersey", "GMT Standard Time"}, + {"Europe/Kaliningrad", "Kaliningrad Standard Time"}, + {"Europe/Kiev", "FLE Standard Time"}, + {"Europe/Kirov", "Russian Standard Time"}, + {"Europe/Lisbon", "GMT Standard Time"}, + {"Europe/Ljubljana", "Central Europe Standard Time"}, + {"Europe/London", "GMT Standard Time"}, + {"Europe/Luxembourg", "W. Europe Standard Time"}, + {"Europe/Madrid", "Romance Standard Time"}, + {"Europe/Malta", "W. Europe Standard Time"}, + {"Europe/Mariehamn", "FLE Standard Time"}, + {"Europe/Minsk", "Belarus Standard Time"}, + {"Europe/Monaco", "W. Europe Standard Time"}, + {"Europe/Moscow", "Russian Standard Time"}, + {"Europe/Oslo", "W. Europe Standard Time"}, + {"Europe/Paris", "Romance Standard Time"}, + {"Europe/Podgorica", "Central Europe Standard Time"}, + {"Europe/Prague", "Central Europe Standard Time"}, + {"Europe/Riga", "FLE Standard Time"}, + {"Europe/Rome", "W. Europe Standard Time"}, + {"Europe/Samara", "Russia Time Zone 3"}, + {"Europe/San_Marino", "W. Europe Standard Time"}, + {"Europe/Sarajevo", "Central European Standard Time"}, + {"Europe/Saratov", "Saratov Standard Time"}, + {"Europe/Simferopol", "Russian Standard Time"}, + {"Europe/Skopje", "Central European Standard Time"}, + {"Europe/Sofia", "FLE Standard Time"}, + {"Europe/Stockholm", "W. Europe Standard Time"}, + {"Europe/Tallinn", "FLE Standard Time"}, + {"Europe/Tirane", "Central Europe Standard Time"}, + {"Europe/Tiraspol", "E. Europe Standard Time"}, + {"Europe/Ulyanovsk", "Astrakhan Standard Time"}, + {"Europe/Uzhgorod", "FLE Standard Time"}, + {"Europe/Vaduz", "W. Europe Standard Time"}, + {"Europe/Vatican", "W. Europe Standard Time"}, + {"Europe/Vienna", "W. Europe Standard Time"}, + {"Europe/Vilnius", "FLE Standard Time"}, + {"Europe/Volgograd", "Volgograd Standard Time"}, + {"Europe/Warsaw", "Central European Standard Time"}, + {"Europe/Zagreb", "Central European Standard Time"}, + {"Europe/Zaporozhye", "FLE Standard Time"}, + {"Europe/Zurich", "W. Europe Standard Time"}, + {"GB", "GMT Standard Time"}, + {"GB-Eire", "GMT Standard Time"}, + {"GMT+0", "UTC"}, + {"GMT-0", "UTC"}, + {"GMT0", "UTC"}, + {"Greenwich", "UTC"}, + {"Hongkong", "China Standard Time"}, + {"Iceland", "Greenwich Standard Time"}, + {"Indian/Antananarivo", "E. Africa Standard Time"}, + {"Indian/Chagos", "Central Asia Standard Time"}, + {"Indian/Christmas", "SE Asia Standard Time"}, + {"Indian/Cocos", "Myanmar Standard Time"}, + {"Indian/Comoro", "E. Africa Standard Time"}, + {"Indian/Kerguelen", "West Asia Standard Time"}, + {"Indian/Mahe", "Mauritius Standard Time"}, + {"Indian/Maldives", "West Asia Standard Time"}, + {"Indian/Mauritius", "Mauritius Standard Time"}, + {"Indian/Mayotte", "E. Africa Standard Time"}, + {"Indian/Reunion", "Mauritius Standard Time"}, + {"Iran", "Iran Standard Time"}, + {"Israel", "Israel Standard Time"}, + {"Jamaica", "SA Pacific Standard Time"}, + {"Japan", "Tokyo Standard Time"}, + {"Kwajalein", "UTC+12"}, + {"Libya", "Libya Standard Time"}, + {"MST7MDT", "Mountain Standard Time"}, + {"Mexico/BajaNorte", "Pacific Standard Time (Mexico)"}, + {"Mexico/BajaSur", "Mountain Standard Time (Mexico)"}, + {"Mexico/General", "Central Standard Time (Mexico)"}, + {"NZ", "New Zealand Standard Time"}, + {"NZ-CHAT", "Chatham Islands Standard Time"}, + {"Navajo", "Mountain Standard Time"}, + {"PRC", "China Standard Time"}, + {"PST8PDT", "Pacific Standard Time"}, + {"Pacific/Apia", "Samoa Standard Time"}, + {"Pacific/Auckland", "New Zealand Standard Time"}, + {"Pacific/Bougainville", "Bougainville Standard Time"}, + {"Pacific/Chatham", "Chatham Islands Standard Time"}, + {"Pacific/Easter", "Easter Island Standard Time"}, + {"Pacific/Efate", "Central Pacific Standard Time"}, + {"Pacific/Enderbury", "UTC+13"}, + {"Pacific/Fakaofo", "UTC+13"}, + {"Pacific/Fiji", "Fiji Standard Time"}, + {"Pacific/Funafuti", "UTC+12"}, + {"Pacific/Galapagos", "Central America Standard Time"}, + {"Pacific/Gambier", "UTC-09"}, + {"Pacific/Guadalcanal", "Central Pacific Standard Time"}, + {"Pacific/Guam", "West Pacific Standard Time"}, + {"Pacific/Honolulu", "Hawaiian Standard Time"}, + {"Pacific/Johnston", "Hawaiian Standard Time"}, + {"Pacific/Kiritimati", "Line Islands Standard Time"}, + {"Pacific/Kosrae", "Central Pacific Standard Time"}, + {"Pacific/Kwajalein", "UTC+12"}, + {"Pacific/Majuro", "UTC+12"}, + {"Pacific/Marquesas", "Marquesas Standard Time"}, + {"Pacific/Midway", "UTC-11"}, + {"Pacific/Nauru", "UTC+12"}, + {"Pacific/Niue", "UTC-11"}, + {"Pacific/Norfolk", "Norfolk Standard Time"}, + {"Pacific/Noumea", "Central Pacific Standard Time"}, + {"Pacific/Pago_Pago", "UTC-11"}, + {"Pacific/Palau", "Tokyo Standard Time"}, + {"Pacific/Pitcairn", "UTC-08"}, + {"Pacific/Ponape", "Central Pacific Standard Time"}, + {"Pacific/Port_Moresby", "West Pacific Standard Time"}, + {"Pacific/Rarotonga", "Hawaiian Standard Time"}, + {"Pacific/Saipan", "West Pacific Standard Time"}, + {"Pacific/Samoa", "UTC-11"}, + {"Pacific/Tahiti", "Hawaiian Standard Time"}, + {"Pacific/Tarawa", "UTC+12"}, + {"Pacific/Tongatapu", "Tonga Standard Time"}, + {"Pacific/Truk", "West Pacific Standard Time"}, + {"Pacific/Wake", "UTC+12"}, + {"Pacific/Wallis", "UTC+12"}, + {"Poland", "Central European Standard Time"}, + {"Portugal", "GMT Standard Time"}, + {"ROC", "Taipei Standard Time"}, + {"ROK", "Korea Standard Time"}, + {"Singapore", "Singapore Standard Time"}, + {"Turkey", "Turkey Standard Time"}, + {"UCT", "UTC"}, + {"US/Alaska", "Alaskan Standard Time"}, + {"US/Aleutian", "Aleutian Standard Time"}, + {"US/Arizona", "US Mountain Standard Time"}, + {"US/Central", "Central Standard Time"}, + {"US/Eastern", "Eastern Standard Time"}, + {"US/Hawaii", "Hawaiian Standard Time"}, + {"US/Indiana-Starke", "Central Standard Time"}, + {"US/Michigan", "Eastern Standard Time"}, + {"US/Mountain", "Mountain Standard Time"}, + {"US/Pacific", "Pacific Standard Time"}, + {"US/Samoa", "UTC-11"}, + {"UTC", "UTC"}, + {"Universal", "UTC"}, + {"W-SU", "Russian Standard Time"}, + {"Zulu", "UTC"}}; #elif defined(_TD_DARWIN_64) #include #include @@ -740,28 +740,29 @@ char *tz_win[554][2]={{"Asia/Shanghai", "China Standard Time"}, #include #endif -void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight, enum TdTimezone *tsTimezone) { +void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8_t *outDaylight, + enum TdTimezone *tsTimezone) { if (inTimezoneStr == NULL || inTimezoneStr[0] == 0) return; char *buf = taosMemoryMalloc(strlen(inTimezoneStr) + 1); buf[strlen(inTimezoneStr)] = 0; for (int32_t i = 0; i < strlen(inTimezoneStr); i++) { - if(inTimezoneStr[i]==' ' || inTimezoneStr[i]=='(') { - buf[i] = 0; - break; - } - buf[i] = inTimezoneStr[i]; + if (inTimezoneStr[i] == ' ' || inTimezoneStr[i] == '(') { + buf[i] = 0; + break; + } + buf[i] = inTimezoneStr[i]; } #ifdef WINDOWS char winStr[TD_LOCALE_LEN * 2]; memset(winStr, 0, sizeof(winStr)); for (size_t i = 0; i < 554; i++) { - if (strcmp(tz_win[i][0],buf) == 0) { - char keyPath[100]; - char keyValue[100]; + if (strcmp(tz_win[i][0], buf) == 0) { + char keyPath[100]; + char keyValue[100]; DWORD keyValueSize = sizeof(keyValue); - sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s",tz_win[i][1]); + sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s", tz_win[i][1]); RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&keyValue, &keyValueSize); if (keyValueSize > 0) { keyValue[4] = (keyValue[4] == '+' ? '-' : '+'); @@ -778,7 +779,7 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 if (p != NULL) { char *pp = strchr(inTimezoneStr, '('); char *ppp = strchr(inTimezoneStr, ','); - int indexStr; + int indexStr; if (pp == NULL || ppp == NULL) { indexStr = sprintf(winStr, "TZ=UTC"); } else { @@ -787,7 +788,7 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 memcpy(&winStr[3], pp, ppp - pp); indexStr = ppp - pp + 3; } - sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (p[0] == '+'? '-' : '+'), p[1], p[2], p[3], p[4]); + sprintf(&winStr[indexStr], "%c%c%c:%c%c:00", (p[0] == '+' ? '-' : '+'), p[1], p[2], p[3], p[4]); *tsTimezone = taosStr2Int32(p, NULL, 10); } else { *tsTimezone = 0; @@ -824,23 +825,25 @@ void taosSetSystemTimezone(const char *inTimezoneStr, char *outTimezoneStr, int8 } void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { -#ifdef WINDOWS - char value[100]; - char keyPath[100]; +#ifdef WINDOWS + char value[100]; + char keyPath[100]; DWORD bufferSize = sizeof(value); - RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); + RegGetValue(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation", "TimeZoneKeyName", + RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); strcpy(outTimezoneStr, "not configured"); *tsTimezone = 0; if (bufferSize > 0) { for (size_t i = 0; i < 139; i++) { - if (strcmp(win_tz[i][0],value) == 0) { + if (strcmp(win_tz[i][0], value) == 0) { strcpy(outTimezoneStr, win_tz[i][1]); bufferSize = sizeof(value); - sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s",value); + sprintf(keyPath, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones\\%s", value); RegGetValue(HKEY_LOCAL_MACHINE, keyPath, "Display", RRF_RT_ANY, NULL, (PVOID)&value, &bufferSize); if (bufferSize > 0) { // value[4] = (value[4] == '+' ? '-' : '+'); - sprintf(outTimezoneStr, "%s (UTC, %c%c%c%c%c)", outTimezoneStr, value[4], value[5], value[6], value[8], value[9]); + sprintf(outTimezoneStr, "%s (UTC, %c%c%c%c%c)", outTimezoneStr, value[4], value[5], value[6], value[8], + value[9]); *tsTimezone = taosStr2Int32(&value[4], NULL, 10); } break; @@ -865,19 +868,19 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { } tz = zi + strlen("zoneinfo") + 1; - //for (int i = n - 1; i >= 0; --i) { - // if (buf[i] == '/') { - // if (tz) { - // tz = buf + i + 1; - // break; - // } - // tz = buf + i + 1; - // } - //} - //if (!tz || 0 == strchr(tz, '/')) { - // printf("parsing /etc/localtime failed"); - // return; - //} + // for (int i = n - 1; i >= 0; --i) { + // if (buf[i] == '/') { + // if (tz) { + // tz = buf + i + 1; + // break; + // } + // tz = buf + i + 1; + // } + // } + // if (!tz || 0 == strchr(tz, '/')) { + // printf("parsing /etc/localtime failed"); + // return; + // } setenv("TZ", tz, 1); tzset(); @@ -912,10 +915,10 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { if (taosCheckExistFile("/etc/timezone")) { /* - * NOTE: do not remove it. - * Enforce set the correct daylight saving time(DST) flag according - * to current time - */ + * NOTE: do not remove it. + * Enforce set the correct daylight saving time(DST) flag according + * to current time + */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; taosLocalTime(&tx1, &tm1); @@ -923,7 +926,7 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { // FILE *f = fopen("/etc/timezone", "r"); errno = 0; TdFilePtr pFile = taosOpenFile("/etc/timezone", TD_FILE_READ); - char buf[68] = {0}; + char buf[68] = {0}; if (pFile != NULL) { int len = taosReadFile(pFile, buf, 64); if (len < 64 && taosGetErrorFile(pFile)) { @@ -948,23 +951,24 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { // get and set default timezone tzset(); /* - * get CURRENT time zone. - * system current time zone is affected by daylight saving time(DST) - * - * e.g., the local time zone of London in DST is GMT+01:00, - * otherwise is GMT+00:00 - */ + * get CURRENT time zone. + * system current time zone is affected by daylight saving time(DST) + * + * e.g., the local time zone of London in DST is GMT+01:00, + * otherwise is GMT+00:00 + */ int32_t tz = (-timezone * MILLISECOND_PER_SECOND) / MILLISECOND_PER_HOUR; *tsTimezone = tz; tz += daylight; /* - * format example: - * - * Asia/Shanghai (CST, +0800) - * Europe/London (BST, +0100) - */ - snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", abs(tz)); + * format example: + * + * Asia/Shanghai (CST, +0800) + * Europe/London (BST, +0100) + */ + snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %s%02d00)", buf, tzname[daylight], tz >= 0 ? "+" : "-", + abs(tz)); } else { printf("There is not /etc/timezone.\n"); } @@ -979,40 +983,40 @@ void taosGetSystemTimezone(char *outTimezoneStr, enum TdTimezone *tsTimezone) { } tz = zi + strlen("zoneinfo") + 1; - //for (int i = n - 1; i >= 0; --i) { - // if (buf[i] == '/') { - // if (tz) { - // tz = buf + i + 1; - // break; - // } - // tz = buf + i + 1; - // } - //} - //if (!tz || 0 == strchr(tz, '/')) { - // printf("parsing /etc/localtime failed"); - // return; - //} + // for (int i = n - 1; i >= 0; --i) { + // if (buf[i] == '/') { + // if (tz) { + // tz = buf + i + 1; + // break; + // } + // tz = buf + i + 1; + // } + // } + // if (!tz || 0 == strchr(tz, '/')) { + // printf("parsing /etc/localtime failed"); + // return; + // } setenv("TZ", tz, 1); tzset(); } /* - * NOTE: do not remove it. - * Enforce set the correct daylight saving time(DST) flag according - * to current time - */ + * NOTE: do not remove it. + * Enforce set the correct daylight saving time(DST) flag according + * to current time + */ time_t tx1 = taosGetTimestampSec(); struct tm tm1; taosLocalTime(&tx1, &tm1); /* - * format example: - * - * Asia/Shanghai (CST, +0800) - * Europe/London (BST, +0100) - */ + * format example: + * + * Asia/Shanghai (CST, +0800) + * Europe/London (BST, +0100) + */ snprintf(outTimezoneStr, TD_TIMEZONE_LEN, "%s (%s, %+03ld00)", tz, tm1.tm_isdst ? tzname[daylight] : tzname[0], - -timezone / 3600); + -timezone / 3600); #endif } diff --git a/source/util/src/talgo.c b/source/util/src/talgo.c index 699f0db7a193b1e0390efd12de6f639de5b69f86..4d6875d26376cad79b2361a772cfd6f6f5f1829a 100644 --- a/source/util/src/talgo.c +++ b/source/util/src/talgo.c @@ -175,11 +175,11 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size c = compar(key, p); if (c == 0) { - if (flags == TD_GT){ + if (flags == TD_GT) { lidx = midx + 1; - } else if(flags == TD_LT){ + } else if (flags == TD_LT) { ridx = midx - 1; - }else{ + } else { break; } } else if (c < 0) { diff --git a/source/util/src/tbloomfilter.c b/source/util/src/tbloomfilter.c index 945cb58fcc58ebee4c64c9fcdcabe89921e53116..7e1506c14071e9522eb45e10d9d6309eff217fa0 100644 --- a/source/util/src/tbloomfilter.c +++ b/source/util/src/tbloomfilter.c @@ -19,7 +19,7 @@ #include "taos.h" #include "taoserror.h" -#define UNIT_NUM_BITS 64 +#define UNIT_NUM_BITS 64 #define UNIT_ADDR_NUM_BITS 6 static FORCE_INLINE bool setBit(uint64_t *buf, uint64_t index) { @@ -51,12 +51,12 @@ SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate) { // ln(2)^2 = 0.480453013918201 // m = - n * ln(P) / ( ln(2) )^2 // m is the size of bloom filter, n is expected entries, P is false positive probability - pBF->numUnits = (uint64_t) ceil(expectedEntries * lnRate / 0.480453013918201 / UNIT_NUM_BITS); + pBF->numUnits = (uint64_t)ceil(expectedEntries * lnRate / 0.480453013918201 / UNIT_NUM_BITS); pBF->numBits = pBF->numUnits * 64; pBF->size = 0; // ln(2) = 0.693147180559945 - pBF->hashFunctions = (uint32_t) ceil(lnRate / 0.693147180559945); + pBF->hashFunctions = (uint32_t)ceil(lnRate / 0.693147180559945); pBF->hashFn1 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_TIMESTAMP); pBF->hashFn2 = taosGetDefaultHashFunction(TSDB_DATA_TYPE_NCHAR); pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t)); @@ -69,11 +69,11 @@ SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate) { int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len) { ASSERT(!tBloomFilterIsFull(pBF)); - uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len); - uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len); - bool hasChange = false; + uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len); + uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len); + bool hasChange = false; const register uint64_t size = pBF->numBits; - uint64_t cbHash = h1; + uint64_t cbHash = h1; for (uint64_t i = 0; i < pBF->hashFunctions; ++i) { hasChange |= setBit(pBF->buffer, cbHash % size); cbHash += h2; @@ -85,12 +85,11 @@ int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len) { return TSDB_CODE_FAILED; } -int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, - uint32_t len) { - uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len); - uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len); +int32_t tBloomFilterNoContain(const SBloomFilter *pBF, const void *keyBuf, uint32_t len) { + uint64_t h1 = (uint64_t)pBF->hashFn1(keyBuf, len); + uint64_t h2 = (uint64_t)pBF->hashFn2(keyBuf, len); const register uint64_t size = pBF->numBits; - uint64_t cbHash = h1; + uint64_t cbHash = h1; for (uint64_t i = 0; i < pBF->hashFunctions; ++i) { if (!getBit(pBF->buffer, cbHash % size)) { return TSDB_CODE_SUCCESS; @@ -108,21 +107,21 @@ void tBloomFilterDestroy(SBloomFilter *pBF) { taosMemoryFree(pBF); } -int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder* pEncoder) { +int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder *pEncoder) { if (tEncodeU32(pEncoder, pBF->hashFunctions) < 0) return -1; if (tEncodeU64(pEncoder, pBF->expectedEntries) < 0) return -1; if (tEncodeU64(pEncoder, pBF->numUnits) < 0) return -1; if (tEncodeU64(pEncoder, pBF->numBits) < 0) return -1; if (tEncodeU64(pEncoder, pBF->size) < 0) return -1; for (uint64_t i = 0; i < pBF->numUnits; i++) { - uint64_t* pUnits = (uint64_t*)pBF->buffer; + uint64_t *pUnits = (uint64_t *)pBF->buffer; if (tEncodeU64(pEncoder, pUnits[i]) < 0) return -1; } if (tEncodeDouble(pEncoder, pBF->errorRate) < 0) return -1; return 0; } -SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder) { +SBloomFilter *tBloomFilterDecode(SDecoder *pDecoder) { SBloomFilter *pBF = taosMemoryCalloc(1, sizeof(SBloomFilter)); pBF->buffer = NULL; if (tDecodeU32(pDecoder, &pBF->hashFunctions) < 0) goto _error; @@ -132,7 +131,7 @@ SBloomFilter* tBloomFilterDecode(SDecoder* pDecoder) { if (tDecodeU64(pDecoder, &pBF->size) < 0) goto _error; pBF->buffer = taosMemoryCalloc(pBF->numUnits, sizeof(uint64_t)); for (int32_t i = 0; i < pBF->numUnits; i++) { - uint64_t* pUnits = (uint64_t*)pBF->buffer; + uint64_t *pUnits = (uint64_t *)pBF->buffer; if (tDecodeU64(pDecoder, pUnits + i) < 0) goto _error; } if (tDecodeDouble(pDecoder, &pBF->errorRate) < 0) goto _error; @@ -145,6 +144,4 @@ _error: return NULL; } -bool tBloomFilterIsFull(const SBloomFilter *pBF) { - return pBF->size >= pBF->expectedEntries; -} \ No newline at end of file +bool tBloomFilterIsFull(const SBloomFilter *pBF) { return pBF->size >= pBF->expectedEntries; } \ No newline at end of file diff --git a/source/util/src/tcache.c b/source/util/src/tcache.c index f9f42aa103d2b7ccbb95c60e5ae7e45c95e51699..a559a9c000f4a4d336a8440d17db0629b0caf3a4 100644 --- a/source/util/src/tcache.c +++ b/source/util/src/tcache.c @@ -15,8 +15,8 @@ #define _DEFAULT_SOURCE #include "tcache.h" -#include "taoserror.h" #include "osThread.h" +#include "taoserror.h" #include "tlog.h" #include "tutil.h" @@ -35,7 +35,7 @@ typedef struct SCacheNode { uint64_t addedTime; // the added time when this element is added or updated into cache uint64_t lifespan; // life duration when this element should be remove from cache int64_t expireTime; // expire time - void* signature; + void *signature; struct STrashElem *pTNodeHeader; // point to trash node head uint16_t keyLen : 15; // max key size: 32kb bool inTrashcan : 1; // denote if it is in trash or not @@ -279,7 +279,7 @@ static void removeNodeInEntryList(SCacheEntry *pe, SCacheNode *prev, SCacheNode pNode->pNext = NULL; pe->num -= 1; - ASSERT((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0)); + ASSERT((pe->next && pe->num > 0) || (NULL == pe->next && pe->num == 0)); } static FORCE_INLINE SCacheEntry *doFindEntry(SCacheObj *pCacheObj, const void *key, size_t keyLen) { @@ -660,7 +660,7 @@ void doTraverseElems(SCacheObj *pCacheObj, bool (*fp)(void *param, SCacheNode *p taosWLockLatch(&pEntry->latch); SCacheNode **pPre = &pEntry->next; - SCacheNode *pNode = pEntry->next; + SCacheNode *pNode = pEntry->next; while (pNode != NULL) { SCacheNode *next = pNode->pNext; @@ -945,7 +945,7 @@ bool taosCacheIterNext(SCacheIter *pIter) { char *p = pIter->pCurrent[i]->data; taosCacheRelease(pCacheObj, (void **)&p, false); pIter->pCurrent[i] = NULL; - } + } if (pIter->entryIndex + 1 >= pCacheObj->capacity) { return false; diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index cbda4e46557e7931d1ce5dea31c2baa4f2d6ddef..5d73a1464b9fbfda2ef84a289681243ed49fd470 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -226,30 +226,30 @@ int32_t compareLenPrefixedWStrDesc(const void *pLeft, const void *pRight) { // string > number > bool > null // ref: https://dev.mysql.com/doc/refman/8.0/en/json.html#json-comparison int32_t compareJsonVal(const void *pLeft, const void *pRight) { - char leftType = *(char*)pLeft; - char rightType = *(char*)pRight; - if(leftType != rightType){ + char leftType = *(char *)pLeft; + char rightType = *(char *)pRight; + if (leftType != rightType) { return leftType > rightType ? 1 : -1; } - char* realDataLeft = POINTER_SHIFT(pLeft, CHAR_BYTES); - char* realDataRight = POINTER_SHIFT(pRight, CHAR_BYTES); - if(leftType == TSDB_DATA_TYPE_BOOL) { + char *realDataLeft = POINTER_SHIFT(pLeft, CHAR_BYTES); + char *realDataRight = POINTER_SHIFT(pRight, CHAR_BYTES); + if (leftType == TSDB_DATA_TYPE_BOOL) { DEFAULT_COMP(GET_INT8_VAL(realDataLeft), GET_INT8_VAL(realDataRight)); - }else if(leftType == TSDB_DATA_TYPE_DOUBLE){ + } else if (leftType == TSDB_DATA_TYPE_DOUBLE) { DEFAULT_DOUBLE_COMP(GET_DOUBLE_VAL(realDataLeft), GET_DOUBLE_VAL(realDataRight)); - }else if(leftType == TSDB_DATA_TYPE_NCHAR){ + } else if (leftType == TSDB_DATA_TYPE_NCHAR) { return compareLenPrefixedWStr(realDataLeft, realDataRight); - }else if(leftType == TSDB_DATA_TYPE_NULL) { + } else if (leftType == TSDB_DATA_TYPE_NULL) { return 0; - }else{ + } else { assert(0); return 0; } } int32_t compareInt8Int16(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -257,7 +257,7 @@ int32_t compareInt8Int16(const void *pLeft, const void *pRight) { } int32_t compareInt8Int32(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -265,7 +265,7 @@ int32_t compareInt8Int32(const void *pLeft, const void *pRight) { } int32_t compareInt8Int64(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -274,7 +274,7 @@ int32_t compareInt8Int64(const void *pLeft, const void *pRight) { int32_t compareInt8Float(const void *pLeft, const void *pRight) { int8_t left = GET_INT32_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -289,7 +289,7 @@ int32_t compareInt8Double(const void *pLeft, const void *pRight) { } int32_t compareInt8Uint8(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -297,7 +297,7 @@ int32_t compareInt8Uint8(const void *pLeft, const void *pRight) { } int32_t compareInt8Uint16(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -305,7 +305,7 @@ int32_t compareInt8Uint16(const void *pLeft, const void *pRight) { } int32_t compareInt8Uint32(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -313,7 +313,7 @@ int32_t compareInt8Uint32(const void *pLeft, const void *pRight) { } int32_t compareInt8Uint64(const void *pLeft, const void *pRight) { - int8_t left = GET_INT32_VAL(pLeft); + int8_t left = GET_INT32_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -322,7 +322,7 @@ int32_t compareInt8Uint64(const void *pLeft, const void *pRight) { int32_t compareInt16Int8(const void *pLeft, const void *pRight) { int16_t left = GET_INT32_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -346,7 +346,7 @@ int32_t compareInt16Int64(const void *pLeft, const void *pRight) { int32_t compareInt16Float(const void *pLeft, const void *pRight) { int16_t left = GET_INT32_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -354,7 +354,7 @@ int32_t compareInt16Float(const void *pLeft, const void *pRight) { int32_t compareInt16Double(const void *pLeft, const void *pRight) { int16_t left = GET_INT32_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -369,7 +369,7 @@ int32_t compareInt16Uint8(const void *pLeft, const void *pRight) { } int32_t compareInt16Uint16(const void *pLeft, const void *pRight) { - int16_t left = GET_INT32_VAL(pLeft); + int16_t left = GET_INT32_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -377,7 +377,7 @@ int32_t compareInt16Uint16(const void *pLeft, const void *pRight) { } int32_t compareInt16Uint32(const void *pLeft, const void *pRight) { - int16_t left = GET_INT32_VAL(pLeft); + int16_t left = GET_INT32_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -385,17 +385,16 @@ int32_t compareInt16Uint32(const void *pLeft, const void *pRight) { } int32_t compareInt16Uint64(const void *pLeft, const void *pRight) { - int16_t left = GET_INT32_VAL(pLeft); + int16_t left = GET_INT32_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; } - int32_t compareInt32Int8(const void *pLeft, const void *pRight) { int32_t left = GET_INT32_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -419,7 +418,7 @@ int32_t compareInt32Int64(const void *pLeft, const void *pRight) { int32_t compareInt32Float(const void *pLeft, const void *pRight) { int32_t left = GET_INT32_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -427,7 +426,7 @@ int32_t compareInt32Float(const void *pLeft, const void *pRight) { int32_t compareInt32Double(const void *pLeft, const void *pRight) { int32_t left = GET_INT32_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -442,7 +441,7 @@ int32_t compareInt32Uint8(const void *pLeft, const void *pRight) { } int32_t compareInt32Uint16(const void *pLeft, const void *pRight) { - int32_t left = GET_INT32_VAL(pLeft); + int32_t left = GET_INT32_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -450,7 +449,7 @@ int32_t compareInt32Uint16(const void *pLeft, const void *pRight) { } int32_t compareInt32Uint32(const void *pLeft, const void *pRight) { - int32_t left = GET_INT32_VAL(pLeft); + int32_t left = GET_INT32_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -458,7 +457,7 @@ int32_t compareInt32Uint32(const void *pLeft, const void *pRight) { } int32_t compareInt32Uint64(const void *pLeft, const void *pRight) { - int32_t left = GET_INT32_VAL(pLeft); + int32_t left = GET_INT32_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -467,7 +466,7 @@ int32_t compareInt32Uint64(const void *pLeft, const void *pRight) { int32_t compareInt64Int8(const void *pLeft, const void *pRight) { int64_t left = GET_INT64_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -491,7 +490,7 @@ int32_t compareInt64Int32(const void *pLeft, const void *pRight) { int32_t compareInt64Float(const void *pLeft, const void *pRight) { int64_t left = GET_INT64_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -499,7 +498,7 @@ int32_t compareInt64Float(const void *pLeft, const void *pRight) { int32_t compareInt64Double(const void *pLeft, const void *pRight) { int64_t left = GET_INT64_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -514,7 +513,7 @@ int32_t compareInt64Uint8(const void *pLeft, const void *pRight) { } int32_t compareInt64Uint16(const void *pLeft, const void *pRight) { - int64_t left = GET_INT64_VAL(pLeft); + int64_t left = GET_INT64_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -522,7 +521,7 @@ int32_t compareInt64Uint16(const void *pLeft, const void *pRight) { } int32_t compareInt64Uint32(const void *pLeft, const void *pRight) { - int64_t left = GET_INT64_VAL(pLeft); + int64_t left = GET_INT64_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -530,7 +529,7 @@ int32_t compareInt64Uint32(const void *pLeft, const void *pRight) { } int32_t compareInt64Uint64(const void *pLeft, const void *pRight) { - int64_t left = GET_INT64_VAL(pLeft); + int64_t left = GET_INT64_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -538,7 +537,7 @@ int32_t compareInt64Uint64(const void *pLeft, const void *pRight) { } int32_t compareFloatInt8(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -546,7 +545,7 @@ int32_t compareFloatInt8(const void *pLeft, const void *pRight) { } int32_t compareFloatInt16(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -554,7 +553,7 @@ int32_t compareFloatInt16(const void *pLeft, const void *pRight) { } int32_t compareFloatInt32(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -562,7 +561,7 @@ int32_t compareFloatInt32(const void *pLeft, const void *pRight) { } int32_t compareFloatInt64(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -570,7 +569,7 @@ int32_t compareFloatInt64(const void *pLeft, const void *pRight) { } int32_t compareFloatDouble(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); double right = GET_DOUBLE_VAL(pRight); if (isnan(left) && isnan(right)) { @@ -592,7 +591,7 @@ int32_t compareFloatDouble(const void *pLeft, const void *pRight) { } int32_t compareFloatUint8(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -600,7 +599,7 @@ int32_t compareFloatUint8(const void *pLeft, const void *pRight) { } int32_t compareFloatUint16(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -608,7 +607,7 @@ int32_t compareFloatUint16(const void *pLeft, const void *pRight) { } int32_t compareFloatUint32(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -616,7 +615,7 @@ int32_t compareFloatUint32(const void *pLeft, const void *pRight) { } int32_t compareFloatUint64(const void *pLeft, const void *pRight) { - float left = GET_FLOAT_VAL(pLeft); + float left = GET_FLOAT_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -632,7 +631,7 @@ int32_t compareDoubleInt8(const void *pLeft, const void *pRight) { } int32_t compareDoubleInt16(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -640,7 +639,7 @@ int32_t compareDoubleInt16(const void *pLeft, const void *pRight) { } int32_t compareDoubleInt32(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -648,7 +647,7 @@ int32_t compareDoubleInt32(const void *pLeft, const void *pRight) { } int32_t compareDoubleInt64(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -657,7 +656,7 @@ int32_t compareDoubleInt64(const void *pLeft, const void *pRight) { int32_t compareDoubleFloat(const void *pLeft, const void *pRight) { double left = GET_DOUBLE_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (isnan(left) && isnan(right)) { return 0; @@ -678,7 +677,7 @@ int32_t compareDoubleFloat(const void *pLeft, const void *pRight) { } int32_t compareDoubleUint8(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -686,7 +685,7 @@ int32_t compareDoubleUint8(const void *pLeft, const void *pRight) { } int32_t compareDoubleUint16(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -694,7 +693,7 @@ int32_t compareDoubleUint16(const void *pLeft, const void *pRight) { } int32_t compareDoubleUint32(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -702,7 +701,7 @@ int32_t compareDoubleUint32(const void *pLeft, const void *pRight) { } int32_t compareDoubleUint64(const void *pLeft, const void *pRight) { - double left = GET_DOUBLE_VAL(pLeft); + double left = GET_DOUBLE_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -711,7 +710,7 @@ int32_t compareDoubleUint64(const void *pLeft, const void *pRight) { int32_t compareUint8Int8(const void *pLeft, const void *pRight) { uint8_t left = GET_UINT8_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -743,7 +742,7 @@ int32_t compareUint8Int64(const void *pLeft, const void *pRight) { int32_t compareUint8Float(const void *pLeft, const void *pRight) { uint8_t left = GET_UINT8_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -751,14 +750,14 @@ int32_t compareUint8Float(const void *pLeft, const void *pRight) { int32_t compareUint8Double(const void *pLeft, const void *pRight) { uint8_t left = GET_UINT8_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; } int32_t compareUint8Uint16(const void *pLeft, const void *pRight) { - uint8_t left = GET_UINT8_VAL(pLeft); + uint8_t left = GET_UINT8_VAL(pLeft); uint16_t right = GET_UINT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -766,7 +765,7 @@ int32_t compareUint8Uint16(const void *pLeft, const void *pRight) { } int32_t compareUint8Uint32(const void *pLeft, const void *pRight) { - uint8_t left = GET_UINT8_VAL(pLeft); + uint8_t left = GET_UINT8_VAL(pLeft); uint32_t right = GET_UINT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -774,7 +773,7 @@ int32_t compareUint8Uint32(const void *pLeft, const void *pRight) { } int32_t compareUint8Uint64(const void *pLeft, const void *pRight) { - uint8_t left = GET_UINT8_VAL(pLeft); + uint8_t left = GET_UINT8_VAL(pLeft); uint64_t right = GET_UINT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; @@ -783,7 +782,7 @@ int32_t compareUint8Uint64(const void *pLeft, const void *pRight) { int32_t compareUint16Int8(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -791,7 +790,7 @@ int32_t compareUint16Int8(const void *pLeft, const void *pRight) { int32_t compareUint16Int16(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - int16_t right = GET_INT16_VAL(pRight); + int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -799,7 +798,7 @@ int32_t compareUint16Int16(const void *pLeft, const void *pRight) { int32_t compareUint16Int32(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - int32_t right = GET_INT32_VAL(pRight); + int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -807,7 +806,7 @@ int32_t compareUint16Int32(const void *pLeft, const void *pRight) { int32_t compareUint16Int64(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - int64_t right = GET_INT64_VAL(pRight); + int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -815,7 +814,7 @@ int32_t compareUint16Int64(const void *pLeft, const void *pRight) { int32_t compareUint16Float(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -823,7 +822,7 @@ int32_t compareUint16Float(const void *pLeft, const void *pRight) { int32_t compareUint16Double(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -831,7 +830,7 @@ int32_t compareUint16Double(const void *pLeft, const void *pRight) { int32_t compareUint16Uint8(const void *pLeft, const void *pRight) { uint16_t left = GET_UINT16_VAL(pLeft); - uint8_t right = GET_UINT8_VAL(pRight); + uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -855,7 +854,7 @@ int32_t compareUint16Uint64(const void *pLeft, const void *pRight) { int32_t compareUint32Int8(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -863,7 +862,7 @@ int32_t compareUint32Int8(const void *pLeft, const void *pRight) { int32_t compareUint32Int16(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - int16_t right = GET_INT16_VAL(pRight); + int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -871,7 +870,7 @@ int32_t compareUint32Int16(const void *pLeft, const void *pRight) { int32_t compareUint32Int32(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - int32_t right = GET_INT32_VAL(pRight); + int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -879,7 +878,7 @@ int32_t compareUint32Int32(const void *pLeft, const void *pRight) { int32_t compareUint32Int64(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - int64_t right = GET_INT64_VAL(pRight); + int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -887,7 +886,7 @@ int32_t compareUint32Int64(const void *pLeft, const void *pRight) { int32_t compareUint32Float(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -895,7 +894,7 @@ int32_t compareUint32Float(const void *pLeft, const void *pRight) { int32_t compareUint32Double(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -903,7 +902,7 @@ int32_t compareUint32Double(const void *pLeft, const void *pRight) { int32_t compareUint32Uint8(const void *pLeft, const void *pRight) { uint32_t left = GET_UINT32_VAL(pLeft); - uint8_t right = GET_UINT8_VAL(pRight); + uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -927,7 +926,7 @@ int32_t compareUint32Uint64(const void *pLeft, const void *pRight) { int32_t compareUint64Int8(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - int8_t right = GET_INT8_VAL(pRight); + int8_t right = GET_INT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -935,7 +934,7 @@ int32_t compareUint64Int8(const void *pLeft, const void *pRight) { int32_t compareUint64Int16(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - int16_t right = GET_INT16_VAL(pRight); + int16_t right = GET_INT16_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -943,7 +942,7 @@ int32_t compareUint64Int16(const void *pLeft, const void *pRight) { int32_t compareUint64Int32(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - int32_t right = GET_INT32_VAL(pRight); + int32_t right = GET_INT32_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -951,7 +950,7 @@ int32_t compareUint64Int32(const void *pLeft, const void *pRight) { int32_t compareUint64Int64(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - int64_t right = GET_INT64_VAL(pRight); + int64_t right = GET_INT64_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -959,7 +958,7 @@ int32_t compareUint64Int64(const void *pLeft, const void *pRight) { int32_t compareUint64Float(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - float right = GET_FLOAT_VAL(pRight); + float right = GET_FLOAT_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -967,7 +966,7 @@ int32_t compareUint64Float(const void *pLeft, const void *pRight) { int32_t compareUint64Double(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - double right = GET_DOUBLE_VAL(pRight); + double right = GET_DOUBLE_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -975,7 +974,7 @@ int32_t compareUint64Double(const void *pLeft, const void *pRight) { int32_t compareUint64Uint8(const void *pLeft, const void *pRight) { uint64_t left = GET_UINT64_VAL(pLeft); - uint8_t right = GET_UINT8_VAL(pRight); + uint8_t right = GET_UINT8_VAL(pRight); if (left > right) return 1; if (left < right) return -1; return 0; @@ -997,10 +996,7 @@ int32_t compareUint64Uint32(const void *pLeft, const void *pRight) { return 0; } - -int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { - return compareJsonVal(pRight, pLeft); -} +int32_t compareJsonValDesc(const void *pLeft, const void *pRight) { return compareJsonVal(pRight, pLeft); } /* * Compare two strings * TSDB_MATCH: Match diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 58f90b68c9cb7c054f6a701dba49749cadf84ed7..edb2f0380efbbfa384e8c611ade240e25a22664f 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -15,13 +15,13 @@ #define _DEFAULT_SOURCE #include "tconfig.h" +#include "cJSON.h" #include "taoserror.h" -#include "tlog.h" -#include "tutil.h" #include "tenv.h" -#include "cJSON.h" -#include "tjson.h" #include "tgrant.h" +#include "tjson.h" +#include "tlog.h" +#include "tutil.h" #define CFG_NAME_PRINT_LEN 24 #define CFG_SRC_PRINT_LEN 12 @@ -508,7 +508,7 @@ const char *cfgDtypeStr(ECfgDataType type) { } } -void cfgDumpItemValue(SConfigItem *pItem, char* buf, int32_t bufSize, int32_t* pLen) { +void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen) { int32_t len = 0; switch (pItem->dtype) { case CFG_DTYPE_BOOL: @@ -629,16 +629,16 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } int32_t cfgLoadFromEnvVar(SConfig *pConfig) { - char line[1024], *name, *value, *value2, *value3; + char line[1024], *name, *value, *value2, *value3; int32_t olen, vlen, vlen2, vlen3; int32_t code = 0; - char **pEnv = environ; + char **pEnv = environ; line[1023] = 0; - while(*pEnv != NULL) { + while (*pEnv != NULL) { name = value = value2 = value3 = NULL; olen = vlen = vlen2 = vlen3 = 0; - strncpy(line, *pEnv, sizeof(line)-1); + strncpy(line, *pEnv, sizeof(line) - 1); pEnv++; taosEnvToCfg(line, line); @@ -676,12 +676,12 @@ int32_t cfgLoadFromEnvCmd(SConfig *pConfig, const char **envCmd) { int32_t code = 0; int32_t index = 0; if (envCmd == NULL) return 0; - while (envCmd[index]!=NULL) { - strncpy(buf, envCmd[index], sizeof(buf)-1); - buf[sizeof(buf)-1] = 0; + while (envCmd[index] != NULL) { + strncpy(buf, envCmd[index], sizeof(buf) - 1); + buf[sizeof(buf) - 1] = 0; taosEnvToCfg(buf, buf); index++; - + name = value = value2 = value3 = NULL; olen = vlen = vlen2 = vlen3 = 0; @@ -720,13 +720,13 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { ssize_t _bytes = 0; const char *filepath = ".env"; - if (envFile != NULL && strlen(envFile)>0) { + if (envFile != NULL && strlen(envFile) > 0) { if (!taosCheckExistFile(envFile)) { uError("failed to load env file: %s", envFile); return -1; } filepath = envFile; - }else { + } else { if (!taosCheckExistFile(filepath)) { uInfo("failed to load env file: %s", filepath); return 0; @@ -747,7 +747,7 @@ int32_t cfgLoadFromEnvFile(SConfig *pConfig, const char *envFile) { if (_bytes <= 0) { break; } - if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; + if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; taosEnvToCfg(line, line); paGetToken(line, &name, &olen); @@ -808,7 +808,7 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { break; } - if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; + if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; paGetToken(line, &name, &olen); if (olen == 0) continue; @@ -918,7 +918,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uInfo("fail to load apoll url"); return 0; } - + char *p = strchr(url, ':'); if (p == NULL) { uError("fail to load apoll url: %s, unknown format", url); @@ -939,15 +939,15 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { return -1; } size_t fileSize = taosLSeekFile(pFile, 0, SEEK_END); - char *buf = taosMemoryMalloc(fileSize); + char *buf = taosMemoryMalloc(fileSize); taosLSeekFile(pFile, 0, SEEK_SET); - if(taosReadFile(pFile, buf, fileSize) <= 0) { + if (taosReadFile(pFile, buf, fileSize) <= 0) { taosCloseFile(&pFile); uError("load json file error: %s", filepath); return -1; } taosCloseFile(&pFile); - SJson* pJson = tjsonParse(buf); + SJson *pJson = tjsonParse(buf); if (NULL == pJson) { const char *jsonParseError = tjsonGetError(); if (jsonParseError != NULL) { @@ -958,8 +958,8 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { taosMemoryFreeClear(buf); int32_t jsonArraySize = tjsonGetArraySize(pJson); - for(int32_t i = 0; i < jsonArraySize; i++) { - cJSON* item = tjsonGetArrayItem(pJson, i); + for (int32_t i = 0; i < jsonArraySize; i++) { + cJSON *item = tjsonGetArrayItem(pJson, i); if (item == NULL) break; char *itemName = NULL, *itemValueString = NULL; tjsonGetObjectName(item, &itemName); @@ -971,7 +971,7 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { cfgLineBuf = taosMemoryMalloc(itemNameLen + itemValueStringLen + 2); memcpy(cfgLineBuf, itemName, itemNameLen); cfgLineBuf[itemNameLen] = ' '; - memcpy(&cfgLineBuf[itemNameLen+1], itemValueString, itemValueStringLen); + memcpy(&cfgLineBuf[itemNameLen + 1], itemValueString, itemValueStringLen); cfgLineBuf[itemNameLen + itemValueStringLen + 1] = '\0'; paGetToken(cfgLineBuf, &name, &olen); @@ -999,8 +999,8 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { } tjsonDelete(pJson); - // } else if (strncmp(url, "jsonUrl", 7) == 0) { - // } else if (strncmp(url, "etcdUrl", 7) == 0) { + // } else if (strncmp(url, "jsonUrl", 7) == 0) { + // } else if (strncmp(url, "etcdUrl", 7) == 0) { } else { uError("Unsupported url: %s", url); return -1; @@ -1010,19 +1010,19 @@ int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { return 0; } -int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl) { +int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl) { int32_t index = 0; if (envCmd == NULL) return 0; - while (envCmd[index]!=NULL) { + while (envCmd[index] != NULL) { if (strncmp(envCmd[index], "TAOS_APOLLO_URL", 14) == 0) { char *p = strchr(envCmd[index], '='); if (p != NULL) { p++; if (*p == '\'') { p++; - p[strlen(p)-1] = '\0'; + p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); + memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); uInfo("get apollo url from env cmd success"); return 0; } @@ -1033,8 +1033,8 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl char line[1024]; char **pEnv = environ; line[1023] = 0; - while(*pEnv != NULL) { - strncpy(line, *pEnv, sizeof(line)-1); + while (*pEnv != NULL) { + strncpy(line, *pEnv, sizeof(line) - 1); pEnv++; if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) { char *p = strchr(line, '='); @@ -1042,29 +1042,29 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl p++; if (*p == '\'') { p++; - p[strlen(p)-1] = '\0'; + p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); - uInfo("get apollo url from env variables success, apolloUrl=%s",apolloUrl); + memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); + uInfo("get apollo url from env variables success, apolloUrl=%s", apolloUrl); return 0; } } } const char *filepath = ".env"; - if (envFile != NULL && strlen(envFile)>0) { + if (envFile != NULL && strlen(envFile) > 0) { if (!taosCheckExistFile(envFile)) { uError("failed to load env file: %s", envFile); return -1; } filepath = envFile; - }else { + } else { if (!taosCheckExistFile(filepath)) { uInfo("failed to load env file: %s", filepath); return 0; } } - int64_t _bytes; + int64_t _bytes; TdFilePtr pFile = taosOpenFile(filepath, TD_FILE_READ | TD_FILE_STREAM); if (pFile != NULL) { while (!taosEOFFile(pFile)) { @@ -1072,16 +1072,16 @@ int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char* apolloUrl if (_bytes <= 0) { break; } - if(line[_bytes - 1] == '\n') line[_bytes - 1] = 0; + if (line[_bytes - 1] == '\n') line[_bytes - 1] = 0; if (strncmp(line, "TAOS_APOLLO_URL", 14) == 0) { char *p = strchr(line, '='); if (p != NULL) { p++; if (*p == '\'') { p++; - p[strlen(p)-1] = '\0'; + p[strlen(p) - 1] = '\0'; } - memcpy(apolloUrl, p, TMIN(strlen(p)+1,PATH_MAX)); + memcpy(apolloUrl, p, TMIN(strlen(p) + 1, PATH_MAX)); taosCloseFile(&pFile); uInfo("get apollo url from env file success"); return 0; diff --git a/source/util/src/tcrc32c.c b/source/util/src/tcrc32c.c index 66e9240cd59aec61acb97a3284d37fa10a79698e..bd662fa02cfd4d3e7c512f6e696b74b5d7e7c543 100644 --- a/source/util/src/tcrc32c.c +++ b/source/util/src/tcrc32c.c @@ -1,22 +1,22 @@ /* - Copyright (c) 2013 - 2014, 2016 Mark Adler, Robert Vazan, Max Vysokikh - - This software is provided 'as-is', without any express or implied - warranty. In no event will the author be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - */ + Copyright (c) 2013 - 2014, 2016 Mark Adler, Robert Vazan, Max Vysokikh + + This software is provided 'as-is', without any express or implied + warranty. In no event will the author be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ #define _DEFAULT_SOURCE #if !defined(_TD_ARM_) && !defined(_TD_MIPS_) @@ -26,1069 +26,733 @@ #include "tcrc32c.h" #include "tdef.h" -#define POLY 0x82f63b78 -#define LONG_SHIFT 8192 +#define POLY 0x82f63b78 +#define LONG_SHIFT 8192 #define SHORT_SHIFT 256 static uint32_t table[16][256] = { - {0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, - 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, 0x78b2dbcc, 0x6be22838, 0x9989ab3b, - 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c, - 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, - 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, - 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, - 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512, - 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, - 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, - 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, - 0x7da08661, 0x8fcb0562, 0x9c9bf696, 0x6ef07595, 0x417b1dbc, 0xb3109ebf, - 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, - 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, - 0xed03a29b, 0x1f682198, 0x5125dad3, 0xa34e59d0, 0xb01eaa24, 0x42752927, - 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f, - 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, - 0x61c69362, 0x93ad1061, 0x80fde395, 0x72966096, 0xa65c047d, 0x5437877e, - 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, - 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e, - 0x90a324fa, 0x62c8a7f9, 0xb602c312, 0x44694011, 0x5739b3e5, 0xa55230e6, - 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, - 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, - 0x456cac67, 0xb7072f64, 0xa457dc90, 0x563c5f93, 0x082f63b7, 0xfa44e0b4, - 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, - 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, - 0xb4091bff, 0x466298fc, 0x1871a4d8, 0xea1a27db, 0xf94ad42f, 0x0b21572c, - 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5, - 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, - 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, 0x3bc21e9d, 0xef087a76, 0x1d63f975, - 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, - 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905, - 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, - 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, - 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, - 0x8ecee914, 0x7ca56a17, 0x6ff599e3, 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8, - 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, - 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, - 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, 0x115b2b19, 0x020bd8ed, 0xf0605bee, - 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6, - 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, - 0xf36e6f75, 0x0105ec76, 0x12551f82, 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, - 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, + {0x00000000, 0xf26b8303, 0xe13b70f7, 0x1350f3f4, 0xc79a971f, 0x35f1141c, 0x26a1e7e8, 0xd4ca64eb, 0x8ad958cf, + 0x78b2dbcc, 0x6be22838, 0x9989ab3b, 0x4d43cfd0, 0xbf284cd3, 0xac78bf27, 0x5e133c24, 0x105ec76f, 0xe235446c, + 0xf165b798, 0x030e349b, 0xd7c45070, 0x25afd373, 0x36ff2087, 0xc494a384, 0x9a879fa0, 0x68ec1ca3, 0x7bbcef57, + 0x89d76c54, 0x5d1d08bf, 0xaf768bbc, 0xbc267848, 0x4e4dfb4b, 0x20bd8ede, 0xd2d60ddd, 0xc186fe29, 0x33ed7d2a, + 0xe72719c1, 0x154c9ac2, 0x061c6936, 0xf477ea35, 0xaa64d611, 0x580f5512, 0x4b5fa6e6, 0xb93425e5, 0x6dfe410e, + 0x9f95c20d, 0x8cc531f9, 0x7eaeb2fa, 0x30e349b1, 0xc288cab2, 0xd1d83946, 0x23b3ba45, 0xf779deae, 0x05125dad, + 0x1642ae59, 0xe4292d5a, 0xba3a117e, 0x4851927d, 0x5b016189, 0xa96ae28a, 0x7da08661, 0x8fcb0562, 0x9c9bf696, + 0x6ef07595, 0x417b1dbc, 0xb3109ebf, 0xa0406d4b, 0x522bee48, 0x86e18aa3, 0x748a09a0, 0x67dafa54, 0x95b17957, + 0xcba24573, 0x39c9c670, 0x2a993584, 0xd8f2b687, 0x0c38d26c, 0xfe53516f, 0xed03a29b, 0x1f682198, 0x5125dad3, + 0xa34e59d0, 0xb01eaa24, 0x42752927, 0x96bf4dcc, 0x64d4cecf, 0x77843d3b, 0x85efbe38, 0xdbfc821c, 0x2997011f, + 0x3ac7f2eb, 0xc8ac71e8, 0x1c661503, 0xee0d9600, 0xfd5d65f4, 0x0f36e6f7, 0x61c69362, 0x93ad1061, 0x80fde395, + 0x72966096, 0xa65c047d, 0x5437877e, 0x4767748a, 0xb50cf789, 0xeb1fcbad, 0x197448ae, 0x0a24bb5a, 0xf84f3859, + 0x2c855cb2, 0xdeeedfb1, 0xcdbe2c45, 0x3fd5af46, 0x7198540d, 0x83f3d70e, 0x90a324fa, 0x62c8a7f9, 0xb602c312, + 0x44694011, 0x5739b3e5, 0xa55230e6, 0xfb410cc2, 0x092a8fc1, 0x1a7a7c35, 0xe811ff36, 0x3cdb9bdd, 0xceb018de, + 0xdde0eb2a, 0x2f8b6829, 0x82f63b78, 0x709db87b, 0x63cd4b8f, 0x91a6c88c, 0x456cac67, 0xb7072f64, 0xa457dc90, + 0x563c5f93, 0x082f63b7, 0xfa44e0b4, 0xe9141340, 0x1b7f9043, 0xcfb5f4a8, 0x3dde77ab, 0x2e8e845f, 0xdce5075c, + 0x92a8fc17, 0x60c37f14, 0x73938ce0, 0x81f80fe3, 0x55326b08, 0xa759e80b, 0xb4091bff, 0x466298fc, 0x1871a4d8, + 0xea1a27db, 0xf94ad42f, 0x0b21572c, 0xdfeb33c7, 0x2d80b0c4, 0x3ed04330, 0xccbbc033, 0xa24bb5a6, 0x502036a5, + 0x4370c551, 0xb11b4652, 0x65d122b9, 0x97baa1ba, 0x84ea524e, 0x7681d14d, 0x2892ed69, 0xdaf96e6a, 0xc9a99d9e, + 0x3bc21e9d, 0xef087a76, 0x1d63f975, 0x0e330a81, 0xfc588982, 0xb21572c9, 0x407ef1ca, 0x532e023e, 0xa145813d, + 0x758fe5d6, 0x87e466d5, 0x94b49521, 0x66df1622, 0x38cc2a06, 0xcaa7a905, 0xd9f75af1, 0x2b9cd9f2, 0xff56bd19, + 0x0d3d3e1a, 0x1e6dcdee, 0xec064eed, 0xc38d26c4, 0x31e6a5c7, 0x22b65633, 0xd0ddd530, 0x0417b1db, 0xf67c32d8, + 0xe52cc12c, 0x1747422f, 0x49547e0b, 0xbb3ffd08, 0xa86f0efc, 0x5a048dff, 0x8ecee914, 0x7ca56a17, 0x6ff599e3, + 0x9d9e1ae0, 0xd3d3e1ab, 0x21b862a8, 0x32e8915c, 0xc083125f, 0x144976b4, 0xe622f5b7, 0xf5720643, 0x07198540, + 0x590ab964, 0xab613a67, 0xb831c993, 0x4a5a4a90, 0x9e902e7b, 0x6cfbad78, 0x7fab5e8c, 0x8dc0dd8f, 0xe330a81a, + 0x115b2b19, 0x020bd8ed, 0xf0605bee, 0x24aa3f05, 0xd6c1bc06, 0xc5914ff2, 0x37faccf1, 0x69e9f0d5, 0x9b8273d6, + 0x88d28022, 0x7ab90321, 0xae7367ca, 0x5c18e4c9, 0x4f48173d, 0xbd23943e, 0xf36e6f75, 0x0105ec76, 0x12551f82, + 0xe03e9c81, 0x34f4f86a, 0xc69f7b69, 0xd5cf889d, 0x27a40b9e, 0x79b737ba, 0x8bdcb4b9, 0x988c474d, 0x6ae7c44e, 0xbe2da0a5, 0x4c4623a6, 0x5f16d052, 0xad7d5351}, - {0x00000000, 0x13a29877, 0x274530ee, 0x34e7a899, 0x4e8a61dc, 0x5d28f9ab, - 0x69cf5132, 0x7a6dc945, 0x9d14c3b8, 0x8eb65bcf, 0xba51f356, 0xa9f36b21, - 0xd39ea264, 0xc03c3a13, 0xf4db928a, 0xe7790afd, 0x3fc5f181, 0x2c6769f6, - 0x1880c16f, 0x0b225918, 0x714f905d, 0x62ed082a, 0x560aa0b3, 0x45a838c4, - 0xa2d13239, 0xb173aa4e, 0x859402d7, 0x96369aa0, 0xec5b53e5, 0xfff9cb92, - 0xcb1e630b, 0xd8bcfb7c, 0x7f8be302, 0x6c297b75, 0x58ced3ec, 0x4b6c4b9b, - 0x310182de, 0x22a31aa9, 0x1644b230, 0x05e62a47, 0xe29f20ba, 0xf13db8cd, - 0xc5da1054, 0xd6788823, 0xac154166, 0xbfb7d911, 0x8b507188, 0x98f2e9ff, - 0x404e1283, 0x53ec8af4, 0x670b226d, 0x74a9ba1a, 0x0ec4735f, 0x1d66eb28, - 0x298143b1, 0x3a23dbc6, 0xdd5ad13b, 0xcef8494c, 0xfa1fe1d5, 0xe9bd79a2, - 0x93d0b0e7, 0x80722890, 0xb4958009, 0xa737187e, 0xff17c604, 0xecb55e73, - 0xd852f6ea, 0xcbf06e9d, 0xb19da7d8, 0xa23f3faf, 0x96d89736, 0x857a0f41, - 0x620305bc, 0x71a19dcb, 0x45463552, 0x56e4ad25, 0x2c896460, 0x3f2bfc17, - 0x0bcc548e, 0x186eccf9, 0xc0d23785, 0xd370aff2, 0xe797076b, 0xf4359f1c, - 0x8e585659, 0x9dface2e, 0xa91d66b7, 0xbabffec0, 0x5dc6f43d, 0x4e646c4a, - 0x7a83c4d3, 0x69215ca4, 0x134c95e1, 0x00ee0d96, 0x3409a50f, 0x27ab3d78, - 0x809c2506, 0x933ebd71, 0xa7d915e8, 0xb47b8d9f, 0xce1644da, 0xddb4dcad, - 0xe9537434, 0xfaf1ec43, 0x1d88e6be, 0x0e2a7ec9, 0x3acdd650, 0x296f4e27, - 0x53028762, 0x40a01f15, 0x7447b78c, 0x67e52ffb, 0xbf59d487, 0xacfb4cf0, - 0x981ce469, 0x8bbe7c1e, 0xf1d3b55b, 0xe2712d2c, 0xd69685b5, 0xc5341dc2, - 0x224d173f, 0x31ef8f48, 0x050827d1, 0x16aabfa6, 0x6cc776e3, 0x7f65ee94, - 0x4b82460d, 0x5820de7a, 0xfbc3faf9, 0xe861628e, 0xdc86ca17, 0xcf245260, - 0xb5499b25, 0xa6eb0352, 0x920cabcb, 0x81ae33bc, 0x66d73941, 0x7575a136, - 0x419209af, 0x523091d8, 0x285d589d, 0x3bffc0ea, 0x0f186873, 0x1cbaf004, - 0xc4060b78, 0xd7a4930f, 0xe3433b96, 0xf0e1a3e1, 0x8a8c6aa4, 0x992ef2d3, - 0xadc95a4a, 0xbe6bc23d, 0x5912c8c0, 0x4ab050b7, 0x7e57f82e, 0x6df56059, - 0x1798a91c, 0x043a316b, 0x30dd99f2, 0x237f0185, 0x844819fb, 0x97ea818c, - 0xa30d2915, 0xb0afb162, 0xcac27827, 0xd960e050, 0xed8748c9, 0xfe25d0be, - 0x195cda43, 0x0afe4234, 0x3e19eaad, 0x2dbb72da, 0x57d6bb9f, 0x447423e8, - 0x70938b71, 0x63311306, 0xbb8de87a, 0xa82f700d, 0x9cc8d894, 0x8f6a40e3, - 0xf50789a6, 0xe6a511d1, 0xd242b948, 0xc1e0213f, 0x26992bc2, 0x353bb3b5, - 0x01dc1b2c, 0x127e835b, 0x68134a1e, 0x7bb1d269, 0x4f567af0, 0x5cf4e287, - 0x04d43cfd, 0x1776a48a, 0x23910c13, 0x30339464, 0x4a5e5d21, 0x59fcc556, - 0x6d1b6dcf, 0x7eb9f5b8, 0x99c0ff45, 0x8a626732, 0xbe85cfab, 0xad2757dc, - 0xd74a9e99, 0xc4e806ee, 0xf00fae77, 0xe3ad3600, 0x3b11cd7c, 0x28b3550b, - 0x1c54fd92, 0x0ff665e5, 0x759baca0, 0x663934d7, 0x52de9c4e, 0x417c0439, - 0xa6050ec4, 0xb5a796b3, 0x81403e2a, 0x92e2a65d, 0xe88f6f18, 0xfb2df76f, - 0xcfca5ff6, 0xdc68c781, 0x7b5fdfff, 0x68fd4788, 0x5c1aef11, 0x4fb87766, - 0x35d5be23, 0x26772654, 0x12908ecd, 0x013216ba, 0xe64b1c47, 0xf5e98430, - 0xc10e2ca9, 0xd2acb4de, 0xa8c17d9b, 0xbb63e5ec, 0x8f844d75, 0x9c26d502, - 0x449a2e7e, 0x5738b609, 0x63df1e90, 0x707d86e7, 0x0a104fa2, 0x19b2d7d5, - 0x2d557f4c, 0x3ef7e73b, 0xd98eedc6, 0xca2c75b1, 0xfecbdd28, 0xed69455f, + {0x00000000, 0x13a29877, 0x274530ee, 0x34e7a899, 0x4e8a61dc, 0x5d28f9ab, 0x69cf5132, 0x7a6dc945, 0x9d14c3b8, + 0x8eb65bcf, 0xba51f356, 0xa9f36b21, 0xd39ea264, 0xc03c3a13, 0xf4db928a, 0xe7790afd, 0x3fc5f181, 0x2c6769f6, + 0x1880c16f, 0x0b225918, 0x714f905d, 0x62ed082a, 0x560aa0b3, 0x45a838c4, 0xa2d13239, 0xb173aa4e, 0x859402d7, + 0x96369aa0, 0xec5b53e5, 0xfff9cb92, 0xcb1e630b, 0xd8bcfb7c, 0x7f8be302, 0x6c297b75, 0x58ced3ec, 0x4b6c4b9b, + 0x310182de, 0x22a31aa9, 0x1644b230, 0x05e62a47, 0xe29f20ba, 0xf13db8cd, 0xc5da1054, 0xd6788823, 0xac154166, + 0xbfb7d911, 0x8b507188, 0x98f2e9ff, 0x404e1283, 0x53ec8af4, 0x670b226d, 0x74a9ba1a, 0x0ec4735f, 0x1d66eb28, + 0x298143b1, 0x3a23dbc6, 0xdd5ad13b, 0xcef8494c, 0xfa1fe1d5, 0xe9bd79a2, 0x93d0b0e7, 0x80722890, 0xb4958009, + 0xa737187e, 0xff17c604, 0xecb55e73, 0xd852f6ea, 0xcbf06e9d, 0xb19da7d8, 0xa23f3faf, 0x96d89736, 0x857a0f41, + 0x620305bc, 0x71a19dcb, 0x45463552, 0x56e4ad25, 0x2c896460, 0x3f2bfc17, 0x0bcc548e, 0x186eccf9, 0xc0d23785, + 0xd370aff2, 0xe797076b, 0xf4359f1c, 0x8e585659, 0x9dface2e, 0xa91d66b7, 0xbabffec0, 0x5dc6f43d, 0x4e646c4a, + 0x7a83c4d3, 0x69215ca4, 0x134c95e1, 0x00ee0d96, 0x3409a50f, 0x27ab3d78, 0x809c2506, 0x933ebd71, 0xa7d915e8, + 0xb47b8d9f, 0xce1644da, 0xddb4dcad, 0xe9537434, 0xfaf1ec43, 0x1d88e6be, 0x0e2a7ec9, 0x3acdd650, 0x296f4e27, + 0x53028762, 0x40a01f15, 0x7447b78c, 0x67e52ffb, 0xbf59d487, 0xacfb4cf0, 0x981ce469, 0x8bbe7c1e, 0xf1d3b55b, + 0xe2712d2c, 0xd69685b5, 0xc5341dc2, 0x224d173f, 0x31ef8f48, 0x050827d1, 0x16aabfa6, 0x6cc776e3, 0x7f65ee94, + 0x4b82460d, 0x5820de7a, 0xfbc3faf9, 0xe861628e, 0xdc86ca17, 0xcf245260, 0xb5499b25, 0xa6eb0352, 0x920cabcb, + 0x81ae33bc, 0x66d73941, 0x7575a136, 0x419209af, 0x523091d8, 0x285d589d, 0x3bffc0ea, 0x0f186873, 0x1cbaf004, + 0xc4060b78, 0xd7a4930f, 0xe3433b96, 0xf0e1a3e1, 0x8a8c6aa4, 0x992ef2d3, 0xadc95a4a, 0xbe6bc23d, 0x5912c8c0, + 0x4ab050b7, 0x7e57f82e, 0x6df56059, 0x1798a91c, 0x043a316b, 0x30dd99f2, 0x237f0185, 0x844819fb, 0x97ea818c, + 0xa30d2915, 0xb0afb162, 0xcac27827, 0xd960e050, 0xed8748c9, 0xfe25d0be, 0x195cda43, 0x0afe4234, 0x3e19eaad, + 0x2dbb72da, 0x57d6bb9f, 0x447423e8, 0x70938b71, 0x63311306, 0xbb8de87a, 0xa82f700d, 0x9cc8d894, 0x8f6a40e3, + 0xf50789a6, 0xe6a511d1, 0xd242b948, 0xc1e0213f, 0x26992bc2, 0x353bb3b5, 0x01dc1b2c, 0x127e835b, 0x68134a1e, + 0x7bb1d269, 0x4f567af0, 0x5cf4e287, 0x04d43cfd, 0x1776a48a, 0x23910c13, 0x30339464, 0x4a5e5d21, 0x59fcc556, + 0x6d1b6dcf, 0x7eb9f5b8, 0x99c0ff45, 0x8a626732, 0xbe85cfab, 0xad2757dc, 0xd74a9e99, 0xc4e806ee, 0xf00fae77, + 0xe3ad3600, 0x3b11cd7c, 0x28b3550b, 0x1c54fd92, 0x0ff665e5, 0x759baca0, 0x663934d7, 0x52de9c4e, 0x417c0439, + 0xa6050ec4, 0xb5a796b3, 0x81403e2a, 0x92e2a65d, 0xe88f6f18, 0xfb2df76f, 0xcfca5ff6, 0xdc68c781, 0x7b5fdfff, + 0x68fd4788, 0x5c1aef11, 0x4fb87766, 0x35d5be23, 0x26772654, 0x12908ecd, 0x013216ba, 0xe64b1c47, 0xf5e98430, + 0xc10e2ca9, 0xd2acb4de, 0xa8c17d9b, 0xbb63e5ec, 0x8f844d75, 0x9c26d502, 0x449a2e7e, 0x5738b609, 0x63df1e90, + 0x707d86e7, 0x0a104fa2, 0x19b2d7d5, 0x2d557f4c, 0x3ef7e73b, 0xd98eedc6, 0xca2c75b1, 0xfecbdd28, 0xed69455f, 0x97048c1a, 0x84a6146d, 0xb041bcf4, 0xa3e32483}, - {0x00000000, 0xa541927e, 0x4f6f520d, 0xea2ec073, 0x9edea41a, 0x3b9f3664, - 0xd1b1f617, 0x74f06469, 0x38513ec5, 0x9d10acbb, 0x773e6cc8, 0xd27ffeb6, - 0xa68f9adf, 0x03ce08a1, 0xe9e0c8d2, 0x4ca15aac, 0x70a27d8a, 0xd5e3eff4, - 0x3fcd2f87, 0x9a8cbdf9, 0xee7cd990, 0x4b3d4bee, 0xa1138b9d, 0x045219e3, - 0x48f3434f, 0xedb2d131, 0x079c1142, 0xa2dd833c, 0xd62de755, 0x736c752b, - 0x9942b558, 0x3c032726, 0xe144fb14, 0x4405696a, 0xae2ba919, 0x0b6a3b67, - 0x7f9a5f0e, 0xdadbcd70, 0x30f50d03, 0x95b49f7d, 0xd915c5d1, 0x7c5457af, - 0x967a97dc, 0x333b05a2, 0x47cb61cb, 0xe28af3b5, 0x08a433c6, 0xade5a1b8, - 0x91e6869e, 0x34a714e0, 0xde89d493, 0x7bc846ed, 0x0f382284, 0xaa79b0fa, - 0x40577089, 0xe516e2f7, 0xa9b7b85b, 0x0cf62a25, 0xe6d8ea56, 0x43997828, - 0x37691c41, 0x92288e3f, 0x78064e4c, 0xdd47dc32, 0xc76580d9, 0x622412a7, - 0x880ad2d4, 0x2d4b40aa, 0x59bb24c3, 0xfcfab6bd, 0x16d476ce, 0xb395e4b0, - 0xff34be1c, 0x5a752c62, 0xb05bec11, 0x151a7e6f, 0x61ea1a06, 0xc4ab8878, - 0x2e85480b, 0x8bc4da75, 0xb7c7fd53, 0x12866f2d, 0xf8a8af5e, 0x5de93d20, - 0x29195949, 0x8c58cb37, 0x66760b44, 0xc337993a, 0x8f96c396, 0x2ad751e8, - 0xc0f9919b, 0x65b803e5, 0x1148678c, 0xb409f5f2, 0x5e273581, 0xfb66a7ff, - 0x26217bcd, 0x8360e9b3, 0x694e29c0, 0xcc0fbbbe, 0xb8ffdfd7, 0x1dbe4da9, - 0xf7908dda, 0x52d11fa4, 0x1e704508, 0xbb31d776, 0x511f1705, 0xf45e857b, - 0x80aee112, 0x25ef736c, 0xcfc1b31f, 0x6a802161, 0x56830647, 0xf3c29439, - 0x19ec544a, 0xbcadc634, 0xc85da25d, 0x6d1c3023, 0x8732f050, 0x2273622e, - 0x6ed23882, 0xcb93aafc, 0x21bd6a8f, 0x84fcf8f1, 0xf00c9c98, 0x554d0ee6, - 0xbf63ce95, 0x1a225ceb, 0x8b277743, 0x2e66e53d, 0xc448254e, 0x6109b730, - 0x15f9d359, 0xb0b84127, 0x5a968154, 0xffd7132a, 0xb3764986, 0x1637dbf8, - 0xfc191b8b, 0x595889f5, 0x2da8ed9c, 0x88e97fe2, 0x62c7bf91, 0xc7862def, - 0xfb850ac9, 0x5ec498b7, 0xb4ea58c4, 0x11abcaba, 0x655baed3, 0xc01a3cad, - 0x2a34fcde, 0x8f756ea0, 0xc3d4340c, 0x6695a672, 0x8cbb6601, 0x29faf47f, - 0x5d0a9016, 0xf84b0268, 0x1265c21b, 0xb7245065, 0x6a638c57, 0xcf221e29, - 0x250cde5a, 0x804d4c24, 0xf4bd284d, 0x51fcba33, 0xbbd27a40, 0x1e93e83e, - 0x5232b292, 0xf77320ec, 0x1d5de09f, 0xb81c72e1, 0xccec1688, 0x69ad84f6, - 0x83834485, 0x26c2d6fb, 0x1ac1f1dd, 0xbf8063a3, 0x55aea3d0, 0xf0ef31ae, - 0x841f55c7, 0x215ec7b9, 0xcb7007ca, 0x6e3195b4, 0x2290cf18, 0x87d15d66, - 0x6dff9d15, 0xc8be0f6b, 0xbc4e6b02, 0x190ff97c, 0xf321390f, 0x5660ab71, - 0x4c42f79a, 0xe90365e4, 0x032da597, 0xa66c37e9, 0xd29c5380, 0x77ddc1fe, - 0x9df3018d, 0x38b293f3, 0x7413c95f, 0xd1525b21, 0x3b7c9b52, 0x9e3d092c, - 0xeacd6d45, 0x4f8cff3b, 0xa5a23f48, 0x00e3ad36, 0x3ce08a10, 0x99a1186e, - 0x738fd81d, 0xd6ce4a63, 0xa23e2e0a, 0x077fbc74, 0xed517c07, 0x4810ee79, - 0x04b1b4d5, 0xa1f026ab, 0x4bdee6d8, 0xee9f74a6, 0x9a6f10cf, 0x3f2e82b1, - 0xd50042c2, 0x7041d0bc, 0xad060c8e, 0x08479ef0, 0xe2695e83, 0x4728ccfd, - 0x33d8a894, 0x96993aea, 0x7cb7fa99, 0xd9f668e7, 0x9557324b, 0x3016a035, - 0xda386046, 0x7f79f238, 0x0b899651, 0xaec8042f, 0x44e6c45c, 0xe1a75622, - 0xdda47104, 0x78e5e37a, 0x92cb2309, 0x378ab177, 0x437ad51e, 0xe63b4760, - 0x0c158713, 0xa954156d, 0xe5f54fc1, 0x40b4ddbf, 0xaa9a1dcc, 0x0fdb8fb2, + {0x00000000, 0xa541927e, 0x4f6f520d, 0xea2ec073, 0x9edea41a, 0x3b9f3664, 0xd1b1f617, 0x74f06469, 0x38513ec5, + 0x9d10acbb, 0x773e6cc8, 0xd27ffeb6, 0xa68f9adf, 0x03ce08a1, 0xe9e0c8d2, 0x4ca15aac, 0x70a27d8a, 0xd5e3eff4, + 0x3fcd2f87, 0x9a8cbdf9, 0xee7cd990, 0x4b3d4bee, 0xa1138b9d, 0x045219e3, 0x48f3434f, 0xedb2d131, 0x079c1142, + 0xa2dd833c, 0xd62de755, 0x736c752b, 0x9942b558, 0x3c032726, 0xe144fb14, 0x4405696a, 0xae2ba919, 0x0b6a3b67, + 0x7f9a5f0e, 0xdadbcd70, 0x30f50d03, 0x95b49f7d, 0xd915c5d1, 0x7c5457af, 0x967a97dc, 0x333b05a2, 0x47cb61cb, + 0xe28af3b5, 0x08a433c6, 0xade5a1b8, 0x91e6869e, 0x34a714e0, 0xde89d493, 0x7bc846ed, 0x0f382284, 0xaa79b0fa, + 0x40577089, 0xe516e2f7, 0xa9b7b85b, 0x0cf62a25, 0xe6d8ea56, 0x43997828, 0x37691c41, 0x92288e3f, 0x78064e4c, + 0xdd47dc32, 0xc76580d9, 0x622412a7, 0x880ad2d4, 0x2d4b40aa, 0x59bb24c3, 0xfcfab6bd, 0x16d476ce, 0xb395e4b0, + 0xff34be1c, 0x5a752c62, 0xb05bec11, 0x151a7e6f, 0x61ea1a06, 0xc4ab8878, 0x2e85480b, 0x8bc4da75, 0xb7c7fd53, + 0x12866f2d, 0xf8a8af5e, 0x5de93d20, 0x29195949, 0x8c58cb37, 0x66760b44, 0xc337993a, 0x8f96c396, 0x2ad751e8, + 0xc0f9919b, 0x65b803e5, 0x1148678c, 0xb409f5f2, 0x5e273581, 0xfb66a7ff, 0x26217bcd, 0x8360e9b3, 0x694e29c0, + 0xcc0fbbbe, 0xb8ffdfd7, 0x1dbe4da9, 0xf7908dda, 0x52d11fa4, 0x1e704508, 0xbb31d776, 0x511f1705, 0xf45e857b, + 0x80aee112, 0x25ef736c, 0xcfc1b31f, 0x6a802161, 0x56830647, 0xf3c29439, 0x19ec544a, 0xbcadc634, 0xc85da25d, + 0x6d1c3023, 0x8732f050, 0x2273622e, 0x6ed23882, 0xcb93aafc, 0x21bd6a8f, 0x84fcf8f1, 0xf00c9c98, 0x554d0ee6, + 0xbf63ce95, 0x1a225ceb, 0x8b277743, 0x2e66e53d, 0xc448254e, 0x6109b730, 0x15f9d359, 0xb0b84127, 0x5a968154, + 0xffd7132a, 0xb3764986, 0x1637dbf8, 0xfc191b8b, 0x595889f5, 0x2da8ed9c, 0x88e97fe2, 0x62c7bf91, 0xc7862def, + 0xfb850ac9, 0x5ec498b7, 0xb4ea58c4, 0x11abcaba, 0x655baed3, 0xc01a3cad, 0x2a34fcde, 0x8f756ea0, 0xc3d4340c, + 0x6695a672, 0x8cbb6601, 0x29faf47f, 0x5d0a9016, 0xf84b0268, 0x1265c21b, 0xb7245065, 0x6a638c57, 0xcf221e29, + 0x250cde5a, 0x804d4c24, 0xf4bd284d, 0x51fcba33, 0xbbd27a40, 0x1e93e83e, 0x5232b292, 0xf77320ec, 0x1d5de09f, + 0xb81c72e1, 0xccec1688, 0x69ad84f6, 0x83834485, 0x26c2d6fb, 0x1ac1f1dd, 0xbf8063a3, 0x55aea3d0, 0xf0ef31ae, + 0x841f55c7, 0x215ec7b9, 0xcb7007ca, 0x6e3195b4, 0x2290cf18, 0x87d15d66, 0x6dff9d15, 0xc8be0f6b, 0xbc4e6b02, + 0x190ff97c, 0xf321390f, 0x5660ab71, 0x4c42f79a, 0xe90365e4, 0x032da597, 0xa66c37e9, 0xd29c5380, 0x77ddc1fe, + 0x9df3018d, 0x38b293f3, 0x7413c95f, 0xd1525b21, 0x3b7c9b52, 0x9e3d092c, 0xeacd6d45, 0x4f8cff3b, 0xa5a23f48, + 0x00e3ad36, 0x3ce08a10, 0x99a1186e, 0x738fd81d, 0xd6ce4a63, 0xa23e2e0a, 0x077fbc74, 0xed517c07, 0x4810ee79, + 0x04b1b4d5, 0xa1f026ab, 0x4bdee6d8, 0xee9f74a6, 0x9a6f10cf, 0x3f2e82b1, 0xd50042c2, 0x7041d0bc, 0xad060c8e, + 0x08479ef0, 0xe2695e83, 0x4728ccfd, 0x33d8a894, 0x96993aea, 0x7cb7fa99, 0xd9f668e7, 0x9557324b, 0x3016a035, + 0xda386046, 0x7f79f238, 0x0b899651, 0xaec8042f, 0x44e6c45c, 0xe1a75622, 0xdda47104, 0x78e5e37a, 0x92cb2309, + 0x378ab177, 0x437ad51e, 0xe63b4760, 0x0c158713, 0xa954156d, 0xe5f54fc1, 0x40b4ddbf, 0xaa9a1dcc, 0x0fdb8fb2, 0x7b2bebdb, 0xde6a79a5, 0x3444b9d6, 0x91052ba8}, - {0x00000000, 0xdd45aab8, 0xbf672381, 0x62228939, 0x7b2231f3, 0xa6679b4b, - 0xc4451272, 0x1900b8ca, 0xf64463e6, 0x2b01c95e, 0x49234067, 0x9466eadf, - 0x8d665215, 0x5023f8ad, 0x32017194, 0xef44db2c, 0xe964b13d, 0x34211b85, - 0x560392bc, 0x8b463804, 0x924680ce, 0x4f032a76, 0x2d21a34f, 0xf06409f7, - 0x1f20d2db, 0xc2657863, 0xa047f15a, 0x7d025be2, 0x6402e328, 0xb9474990, - 0xdb65c0a9, 0x06206a11, 0xd725148b, 0x0a60be33, 0x6842370a, 0xb5079db2, - 0xac072578, 0x71428fc0, 0x136006f9, 0xce25ac41, 0x2161776d, 0xfc24ddd5, - 0x9e0654ec, 0x4343fe54, 0x5a43469e, 0x8706ec26, 0xe524651f, 0x3861cfa7, - 0x3e41a5b6, 0xe3040f0e, 0x81268637, 0x5c632c8f, 0x45639445, 0x98263efd, - 0xfa04b7c4, 0x27411d7c, 0xc805c650, 0x15406ce8, 0x7762e5d1, 0xaa274f69, - 0xb327f7a3, 0x6e625d1b, 0x0c40d422, 0xd1057e9a, 0xaba65fe7, 0x76e3f55f, - 0x14c17c66, 0xc984d6de, 0xd0846e14, 0x0dc1c4ac, 0x6fe34d95, 0xb2a6e72d, - 0x5de23c01, 0x80a796b9, 0xe2851f80, 0x3fc0b538, 0x26c00df2, 0xfb85a74a, - 0x99a72e73, 0x44e284cb, 0x42c2eeda, 0x9f874462, 0xfda5cd5b, 0x20e067e3, - 0x39e0df29, 0xe4a57591, 0x8687fca8, 0x5bc25610, 0xb4868d3c, 0x69c32784, - 0x0be1aebd, 0xd6a40405, 0xcfa4bccf, 0x12e11677, 0x70c39f4e, 0xad8635f6, - 0x7c834b6c, 0xa1c6e1d4, 0xc3e468ed, 0x1ea1c255, 0x07a17a9f, 0xdae4d027, - 0xb8c6591e, 0x6583f3a6, 0x8ac7288a, 0x57828232, 0x35a00b0b, 0xe8e5a1b3, - 0xf1e51979, 0x2ca0b3c1, 0x4e823af8, 0x93c79040, 0x95e7fa51, 0x48a250e9, - 0x2a80d9d0, 0xf7c57368, 0xeec5cba2, 0x3380611a, 0x51a2e823, 0x8ce7429b, - 0x63a399b7, 0xbee6330f, 0xdcc4ba36, 0x0181108e, 0x1881a844, 0xc5c402fc, - 0xa7e68bc5, 0x7aa3217d, 0x52a0c93f, 0x8fe56387, 0xedc7eabe, 0x30824006, - 0x2982f8cc, 0xf4c75274, 0x96e5db4d, 0x4ba071f5, 0xa4e4aad9, 0x79a10061, - 0x1b838958, 0xc6c623e0, 0xdfc69b2a, 0x02833192, 0x60a1b8ab, 0xbde41213, - 0xbbc47802, 0x6681d2ba, 0x04a35b83, 0xd9e6f13b, 0xc0e649f1, 0x1da3e349, - 0x7f816a70, 0xa2c4c0c8, 0x4d801be4, 0x90c5b15c, 0xf2e73865, 0x2fa292dd, - 0x36a22a17, 0xebe780af, 0x89c50996, 0x5480a32e, 0x8585ddb4, 0x58c0770c, - 0x3ae2fe35, 0xe7a7548d, 0xfea7ec47, 0x23e246ff, 0x41c0cfc6, 0x9c85657e, - 0x73c1be52, 0xae8414ea, 0xcca69dd3, 0x11e3376b, 0x08e38fa1, 0xd5a62519, - 0xb784ac20, 0x6ac10698, 0x6ce16c89, 0xb1a4c631, 0xd3864f08, 0x0ec3e5b0, - 0x17c35d7a, 0xca86f7c2, 0xa8a47efb, 0x75e1d443, 0x9aa50f6f, 0x47e0a5d7, - 0x25c22cee, 0xf8878656, 0xe1873e9c, 0x3cc29424, 0x5ee01d1d, 0x83a5b7a5, - 0xf90696d8, 0x24433c60, 0x4661b559, 0x9b241fe1, 0x8224a72b, 0x5f610d93, - 0x3d4384aa, 0xe0062e12, 0x0f42f53e, 0xd2075f86, 0xb025d6bf, 0x6d607c07, - 0x7460c4cd, 0xa9256e75, 0xcb07e74c, 0x16424df4, 0x106227e5, 0xcd278d5d, - 0xaf050464, 0x7240aedc, 0x6b401616, 0xb605bcae, 0xd4273597, 0x09629f2f, - 0xe6264403, 0x3b63eebb, 0x59416782, 0x8404cd3a, 0x9d0475f0, 0x4041df48, - 0x22635671, 0xff26fcc9, 0x2e238253, 0xf36628eb, 0x9144a1d2, 0x4c010b6a, - 0x5501b3a0, 0x88441918, 0xea669021, 0x37233a99, 0xd867e1b5, 0x05224b0d, - 0x6700c234, 0xba45688c, 0xa345d046, 0x7e007afe, 0x1c22f3c7, 0xc167597f, - 0xc747336e, 0x1a0299d6, 0x782010ef, 0xa565ba57, 0xbc65029d, 0x6120a825, - 0x0302211c, 0xde478ba4, 0x31035088, 0xec46fa30, 0x8e647309, 0x5321d9b1, + {0x00000000, 0xdd45aab8, 0xbf672381, 0x62228939, 0x7b2231f3, 0xa6679b4b, 0xc4451272, 0x1900b8ca, 0xf64463e6, + 0x2b01c95e, 0x49234067, 0x9466eadf, 0x8d665215, 0x5023f8ad, 0x32017194, 0xef44db2c, 0xe964b13d, 0x34211b85, + 0x560392bc, 0x8b463804, 0x924680ce, 0x4f032a76, 0x2d21a34f, 0xf06409f7, 0x1f20d2db, 0xc2657863, 0xa047f15a, + 0x7d025be2, 0x6402e328, 0xb9474990, 0xdb65c0a9, 0x06206a11, 0xd725148b, 0x0a60be33, 0x6842370a, 0xb5079db2, + 0xac072578, 0x71428fc0, 0x136006f9, 0xce25ac41, 0x2161776d, 0xfc24ddd5, 0x9e0654ec, 0x4343fe54, 0x5a43469e, + 0x8706ec26, 0xe524651f, 0x3861cfa7, 0x3e41a5b6, 0xe3040f0e, 0x81268637, 0x5c632c8f, 0x45639445, 0x98263efd, + 0xfa04b7c4, 0x27411d7c, 0xc805c650, 0x15406ce8, 0x7762e5d1, 0xaa274f69, 0xb327f7a3, 0x6e625d1b, 0x0c40d422, + 0xd1057e9a, 0xaba65fe7, 0x76e3f55f, 0x14c17c66, 0xc984d6de, 0xd0846e14, 0x0dc1c4ac, 0x6fe34d95, 0xb2a6e72d, + 0x5de23c01, 0x80a796b9, 0xe2851f80, 0x3fc0b538, 0x26c00df2, 0xfb85a74a, 0x99a72e73, 0x44e284cb, 0x42c2eeda, + 0x9f874462, 0xfda5cd5b, 0x20e067e3, 0x39e0df29, 0xe4a57591, 0x8687fca8, 0x5bc25610, 0xb4868d3c, 0x69c32784, + 0x0be1aebd, 0xd6a40405, 0xcfa4bccf, 0x12e11677, 0x70c39f4e, 0xad8635f6, 0x7c834b6c, 0xa1c6e1d4, 0xc3e468ed, + 0x1ea1c255, 0x07a17a9f, 0xdae4d027, 0xb8c6591e, 0x6583f3a6, 0x8ac7288a, 0x57828232, 0x35a00b0b, 0xe8e5a1b3, + 0xf1e51979, 0x2ca0b3c1, 0x4e823af8, 0x93c79040, 0x95e7fa51, 0x48a250e9, 0x2a80d9d0, 0xf7c57368, 0xeec5cba2, + 0x3380611a, 0x51a2e823, 0x8ce7429b, 0x63a399b7, 0xbee6330f, 0xdcc4ba36, 0x0181108e, 0x1881a844, 0xc5c402fc, + 0xa7e68bc5, 0x7aa3217d, 0x52a0c93f, 0x8fe56387, 0xedc7eabe, 0x30824006, 0x2982f8cc, 0xf4c75274, 0x96e5db4d, + 0x4ba071f5, 0xa4e4aad9, 0x79a10061, 0x1b838958, 0xc6c623e0, 0xdfc69b2a, 0x02833192, 0x60a1b8ab, 0xbde41213, + 0xbbc47802, 0x6681d2ba, 0x04a35b83, 0xd9e6f13b, 0xc0e649f1, 0x1da3e349, 0x7f816a70, 0xa2c4c0c8, 0x4d801be4, + 0x90c5b15c, 0xf2e73865, 0x2fa292dd, 0x36a22a17, 0xebe780af, 0x89c50996, 0x5480a32e, 0x8585ddb4, 0x58c0770c, + 0x3ae2fe35, 0xe7a7548d, 0xfea7ec47, 0x23e246ff, 0x41c0cfc6, 0x9c85657e, 0x73c1be52, 0xae8414ea, 0xcca69dd3, + 0x11e3376b, 0x08e38fa1, 0xd5a62519, 0xb784ac20, 0x6ac10698, 0x6ce16c89, 0xb1a4c631, 0xd3864f08, 0x0ec3e5b0, + 0x17c35d7a, 0xca86f7c2, 0xa8a47efb, 0x75e1d443, 0x9aa50f6f, 0x47e0a5d7, 0x25c22cee, 0xf8878656, 0xe1873e9c, + 0x3cc29424, 0x5ee01d1d, 0x83a5b7a5, 0xf90696d8, 0x24433c60, 0x4661b559, 0x9b241fe1, 0x8224a72b, 0x5f610d93, + 0x3d4384aa, 0xe0062e12, 0x0f42f53e, 0xd2075f86, 0xb025d6bf, 0x6d607c07, 0x7460c4cd, 0xa9256e75, 0xcb07e74c, + 0x16424df4, 0x106227e5, 0xcd278d5d, 0xaf050464, 0x7240aedc, 0x6b401616, 0xb605bcae, 0xd4273597, 0x09629f2f, + 0xe6264403, 0x3b63eebb, 0x59416782, 0x8404cd3a, 0x9d0475f0, 0x4041df48, 0x22635671, 0xff26fcc9, 0x2e238253, + 0xf36628eb, 0x9144a1d2, 0x4c010b6a, 0x5501b3a0, 0x88441918, 0xea669021, 0x37233a99, 0xd867e1b5, 0x05224b0d, + 0x6700c234, 0xba45688c, 0xa345d046, 0x7e007afe, 0x1c22f3c7, 0xc167597f, 0xc747336e, 0x1a0299d6, 0x782010ef, + 0xa565ba57, 0xbc65029d, 0x6120a825, 0x0302211c, 0xde478ba4, 0x31035088, 0xec46fa30, 0x8e647309, 0x5321d9b1, 0x4a21617b, 0x9764cbc3, 0xf54642fa, 0x2803e842}, - {0x00000000, 0x38116fac, 0x7022df58, 0x4833b0f4, 0xe045beb0, 0xd854d11c, - 0x906761e8, 0xa8760e44, 0xc5670b91, 0xfd76643d, 0xb545d4c9, 0x8d54bb65, - 0x2522b521, 0x1d33da8d, 0x55006a79, 0x6d1105d5, 0x8f2261d3, 0xb7330e7f, - 0xff00be8b, 0xc711d127, 0x6f67df63, 0x5776b0cf, 0x1f45003b, 0x27546f97, - 0x4a456a42, 0x725405ee, 0x3a67b51a, 0x0276dab6, 0xaa00d4f2, 0x9211bb5e, - 0xda220baa, 0xe2336406, 0x1ba8b557, 0x23b9dafb, 0x6b8a6a0f, 0x539b05a3, - 0xfbed0be7, 0xc3fc644b, 0x8bcfd4bf, 0xb3debb13, 0xdecfbec6, 0xe6ded16a, - 0xaeed619e, 0x96fc0e32, 0x3e8a0076, 0x069b6fda, 0x4ea8df2e, 0x76b9b082, - 0x948ad484, 0xac9bbb28, 0xe4a80bdc, 0xdcb96470, 0x74cf6a34, 0x4cde0598, - 0x04edb56c, 0x3cfcdac0, 0x51eddf15, 0x69fcb0b9, 0x21cf004d, 0x19de6fe1, - 0xb1a861a5, 0x89b90e09, 0xc18abefd, 0xf99bd151, 0x37516aae, 0x0f400502, - 0x4773b5f6, 0x7f62da5a, 0xd714d41e, 0xef05bbb2, 0xa7360b46, 0x9f2764ea, - 0xf236613f, 0xca270e93, 0x8214be67, 0xba05d1cb, 0x1273df8f, 0x2a62b023, - 0x625100d7, 0x5a406f7b, 0xb8730b7d, 0x806264d1, 0xc851d425, 0xf040bb89, - 0x5836b5cd, 0x6027da61, 0x28146a95, 0x10050539, 0x7d1400ec, 0x45056f40, - 0x0d36dfb4, 0x3527b018, 0x9d51be5c, 0xa540d1f0, 0xed736104, 0xd5620ea8, - 0x2cf9dff9, 0x14e8b055, 0x5cdb00a1, 0x64ca6f0d, 0xccbc6149, 0xf4ad0ee5, - 0xbc9ebe11, 0x848fd1bd, 0xe99ed468, 0xd18fbbc4, 0x99bc0b30, 0xa1ad649c, - 0x09db6ad8, 0x31ca0574, 0x79f9b580, 0x41e8da2c, 0xa3dbbe2a, 0x9bcad186, - 0xd3f96172, 0xebe80ede, 0x439e009a, 0x7b8f6f36, 0x33bcdfc2, 0x0badb06e, - 0x66bcb5bb, 0x5eadda17, 0x169e6ae3, 0x2e8f054f, 0x86f90b0b, 0xbee864a7, - 0xf6dbd453, 0xcecabbff, 0x6ea2d55c, 0x56b3baf0, 0x1e800a04, 0x269165a8, - 0x8ee76bec, 0xb6f60440, 0xfec5b4b4, 0xc6d4db18, 0xabc5decd, 0x93d4b161, - 0xdbe70195, 0xe3f66e39, 0x4b80607d, 0x73910fd1, 0x3ba2bf25, 0x03b3d089, - 0xe180b48f, 0xd991db23, 0x91a26bd7, 0xa9b3047b, 0x01c50a3f, 0x39d46593, - 0x71e7d567, 0x49f6bacb, 0x24e7bf1e, 0x1cf6d0b2, 0x54c56046, 0x6cd40fea, - 0xc4a201ae, 0xfcb36e02, 0xb480def6, 0x8c91b15a, 0x750a600b, 0x4d1b0fa7, - 0x0528bf53, 0x3d39d0ff, 0x954fdebb, 0xad5eb117, 0xe56d01e3, 0xdd7c6e4f, - 0xb06d6b9a, 0x887c0436, 0xc04fb4c2, 0xf85edb6e, 0x5028d52a, 0x6839ba86, - 0x200a0a72, 0x181b65de, 0xfa2801d8, 0xc2396e74, 0x8a0ade80, 0xb21bb12c, - 0x1a6dbf68, 0x227cd0c4, 0x6a4f6030, 0x525e0f9c, 0x3f4f0a49, 0x075e65e5, - 0x4f6dd511, 0x777cbabd, 0xdf0ab4f9, 0xe71bdb55, 0xaf286ba1, 0x9739040d, - 0x59f3bff2, 0x61e2d05e, 0x29d160aa, 0x11c00f06, 0xb9b60142, 0x81a76eee, - 0xc994de1a, 0xf185b1b6, 0x9c94b463, 0xa485dbcf, 0xecb66b3b, 0xd4a70497, - 0x7cd10ad3, 0x44c0657f, 0x0cf3d58b, 0x34e2ba27, 0xd6d1de21, 0xeec0b18d, - 0xa6f30179, 0x9ee26ed5, 0x36946091, 0x0e850f3d, 0x46b6bfc9, 0x7ea7d065, - 0x13b6d5b0, 0x2ba7ba1c, 0x63940ae8, 0x5b856544, 0xf3f36b00, 0xcbe204ac, - 0x83d1b458, 0xbbc0dbf4, 0x425b0aa5, 0x7a4a6509, 0x3279d5fd, 0x0a68ba51, - 0xa21eb415, 0x9a0fdbb9, 0xd23c6b4d, 0xea2d04e1, 0x873c0134, 0xbf2d6e98, - 0xf71ede6c, 0xcf0fb1c0, 0x6779bf84, 0x5f68d028, 0x175b60dc, 0x2f4a0f70, - 0xcd796b76, 0xf56804da, 0xbd5bb42e, 0x854adb82, 0x2d3cd5c6, 0x152dba6a, - 0x5d1e0a9e, 0x650f6532, 0x081e60e7, 0x300f0f4b, 0x783cbfbf, 0x402dd013, + {0x00000000, 0x38116fac, 0x7022df58, 0x4833b0f4, 0xe045beb0, 0xd854d11c, 0x906761e8, 0xa8760e44, 0xc5670b91, + 0xfd76643d, 0xb545d4c9, 0x8d54bb65, 0x2522b521, 0x1d33da8d, 0x55006a79, 0x6d1105d5, 0x8f2261d3, 0xb7330e7f, + 0xff00be8b, 0xc711d127, 0x6f67df63, 0x5776b0cf, 0x1f45003b, 0x27546f97, 0x4a456a42, 0x725405ee, 0x3a67b51a, + 0x0276dab6, 0xaa00d4f2, 0x9211bb5e, 0xda220baa, 0xe2336406, 0x1ba8b557, 0x23b9dafb, 0x6b8a6a0f, 0x539b05a3, + 0xfbed0be7, 0xc3fc644b, 0x8bcfd4bf, 0xb3debb13, 0xdecfbec6, 0xe6ded16a, 0xaeed619e, 0x96fc0e32, 0x3e8a0076, + 0x069b6fda, 0x4ea8df2e, 0x76b9b082, 0x948ad484, 0xac9bbb28, 0xe4a80bdc, 0xdcb96470, 0x74cf6a34, 0x4cde0598, + 0x04edb56c, 0x3cfcdac0, 0x51eddf15, 0x69fcb0b9, 0x21cf004d, 0x19de6fe1, 0xb1a861a5, 0x89b90e09, 0xc18abefd, + 0xf99bd151, 0x37516aae, 0x0f400502, 0x4773b5f6, 0x7f62da5a, 0xd714d41e, 0xef05bbb2, 0xa7360b46, 0x9f2764ea, + 0xf236613f, 0xca270e93, 0x8214be67, 0xba05d1cb, 0x1273df8f, 0x2a62b023, 0x625100d7, 0x5a406f7b, 0xb8730b7d, + 0x806264d1, 0xc851d425, 0xf040bb89, 0x5836b5cd, 0x6027da61, 0x28146a95, 0x10050539, 0x7d1400ec, 0x45056f40, + 0x0d36dfb4, 0x3527b018, 0x9d51be5c, 0xa540d1f0, 0xed736104, 0xd5620ea8, 0x2cf9dff9, 0x14e8b055, 0x5cdb00a1, + 0x64ca6f0d, 0xccbc6149, 0xf4ad0ee5, 0xbc9ebe11, 0x848fd1bd, 0xe99ed468, 0xd18fbbc4, 0x99bc0b30, 0xa1ad649c, + 0x09db6ad8, 0x31ca0574, 0x79f9b580, 0x41e8da2c, 0xa3dbbe2a, 0x9bcad186, 0xd3f96172, 0xebe80ede, 0x439e009a, + 0x7b8f6f36, 0x33bcdfc2, 0x0badb06e, 0x66bcb5bb, 0x5eadda17, 0x169e6ae3, 0x2e8f054f, 0x86f90b0b, 0xbee864a7, + 0xf6dbd453, 0xcecabbff, 0x6ea2d55c, 0x56b3baf0, 0x1e800a04, 0x269165a8, 0x8ee76bec, 0xb6f60440, 0xfec5b4b4, + 0xc6d4db18, 0xabc5decd, 0x93d4b161, 0xdbe70195, 0xe3f66e39, 0x4b80607d, 0x73910fd1, 0x3ba2bf25, 0x03b3d089, + 0xe180b48f, 0xd991db23, 0x91a26bd7, 0xa9b3047b, 0x01c50a3f, 0x39d46593, 0x71e7d567, 0x49f6bacb, 0x24e7bf1e, + 0x1cf6d0b2, 0x54c56046, 0x6cd40fea, 0xc4a201ae, 0xfcb36e02, 0xb480def6, 0x8c91b15a, 0x750a600b, 0x4d1b0fa7, + 0x0528bf53, 0x3d39d0ff, 0x954fdebb, 0xad5eb117, 0xe56d01e3, 0xdd7c6e4f, 0xb06d6b9a, 0x887c0436, 0xc04fb4c2, + 0xf85edb6e, 0x5028d52a, 0x6839ba86, 0x200a0a72, 0x181b65de, 0xfa2801d8, 0xc2396e74, 0x8a0ade80, 0xb21bb12c, + 0x1a6dbf68, 0x227cd0c4, 0x6a4f6030, 0x525e0f9c, 0x3f4f0a49, 0x075e65e5, 0x4f6dd511, 0x777cbabd, 0xdf0ab4f9, + 0xe71bdb55, 0xaf286ba1, 0x9739040d, 0x59f3bff2, 0x61e2d05e, 0x29d160aa, 0x11c00f06, 0xb9b60142, 0x81a76eee, + 0xc994de1a, 0xf185b1b6, 0x9c94b463, 0xa485dbcf, 0xecb66b3b, 0xd4a70497, 0x7cd10ad3, 0x44c0657f, 0x0cf3d58b, + 0x34e2ba27, 0xd6d1de21, 0xeec0b18d, 0xa6f30179, 0x9ee26ed5, 0x36946091, 0x0e850f3d, 0x46b6bfc9, 0x7ea7d065, + 0x13b6d5b0, 0x2ba7ba1c, 0x63940ae8, 0x5b856544, 0xf3f36b00, 0xcbe204ac, 0x83d1b458, 0xbbc0dbf4, 0x425b0aa5, + 0x7a4a6509, 0x3279d5fd, 0x0a68ba51, 0xa21eb415, 0x9a0fdbb9, 0xd23c6b4d, 0xea2d04e1, 0x873c0134, 0xbf2d6e98, + 0xf71ede6c, 0xcf0fb1c0, 0x6779bf84, 0x5f68d028, 0x175b60dc, 0x2f4a0f70, 0xcd796b76, 0xf56804da, 0xbd5bb42e, + 0x854adb82, 0x2d3cd5c6, 0x152dba6a, 0x5d1e0a9e, 0x650f6532, 0x081e60e7, 0x300f0f4b, 0x783cbfbf, 0x402dd013, 0xe85bde57, 0xd04ab1fb, 0x9879010f, 0xa0686ea3}, - {0x00000000, 0xef306b19, 0xdb8ca0c3, 0x34bccbda, 0xb2f53777, 0x5dc55c6e, - 0x697997b4, 0x8649fcad, 0x6006181f, 0x8f367306, 0xbb8ab8dc, 0x54bad3c5, - 0xd2f32f68, 0x3dc34471, 0x097f8fab, 0xe64fe4b2, 0xc00c303e, 0x2f3c5b27, - 0x1b8090fd, 0xf4b0fbe4, 0x72f90749, 0x9dc96c50, 0xa975a78a, 0x4645cc93, - 0xa00a2821, 0x4f3a4338, 0x7b8688e2, 0x94b6e3fb, 0x12ff1f56, 0xfdcf744f, - 0xc973bf95, 0x2643d48c, 0x85f4168d, 0x6ac47d94, 0x5e78b64e, 0xb148dd57, - 0x370121fa, 0xd8314ae3, 0xec8d8139, 0x03bdea20, 0xe5f20e92, 0x0ac2658b, - 0x3e7eae51, 0xd14ec548, 0x570739e5, 0xb83752fc, 0x8c8b9926, 0x63bbf23f, - 0x45f826b3, 0xaac84daa, 0x9e748670, 0x7144ed69, 0xf70d11c4, 0x183d7add, - 0x2c81b107, 0xc3b1da1e, 0x25fe3eac, 0xcace55b5, 0xfe729e6f, 0x1142f576, - 0x970b09db, 0x783b62c2, 0x4c87a918, 0xa3b7c201, 0x0e045beb, 0xe13430f2, - 0xd588fb28, 0x3ab89031, 0xbcf16c9c, 0x53c10785, 0x677dcc5f, 0x884da746, - 0x6e0243f4, 0x813228ed, 0xb58ee337, 0x5abe882e, 0xdcf77483, 0x33c71f9a, - 0x077bd440, 0xe84bbf59, 0xce086bd5, 0x213800cc, 0x1584cb16, 0xfab4a00f, - 0x7cfd5ca2, 0x93cd37bb, 0xa771fc61, 0x48419778, 0xae0e73ca, 0x413e18d3, - 0x7582d309, 0x9ab2b810, 0x1cfb44bd, 0xf3cb2fa4, 0xc777e47e, 0x28478f67, - 0x8bf04d66, 0x64c0267f, 0x507ceda5, 0xbf4c86bc, 0x39057a11, 0xd6351108, - 0xe289dad2, 0x0db9b1cb, 0xebf65579, 0x04c63e60, 0x307af5ba, 0xdf4a9ea3, - 0x5903620e, 0xb6330917, 0x828fc2cd, 0x6dbfa9d4, 0x4bfc7d58, 0xa4cc1641, - 0x9070dd9b, 0x7f40b682, 0xf9094a2f, 0x16392136, 0x2285eaec, 0xcdb581f5, - 0x2bfa6547, 0xc4ca0e5e, 0xf076c584, 0x1f46ae9d, 0x990f5230, 0x763f3929, - 0x4283f2f3, 0xadb399ea, 0x1c08b7d6, 0xf338dccf, 0xc7841715, 0x28b47c0c, - 0xaefd80a1, 0x41cdebb8, 0x75712062, 0x9a414b7b, 0x7c0eafc9, 0x933ec4d0, - 0xa7820f0a, 0x48b26413, 0xcefb98be, 0x21cbf3a7, 0x1577387d, 0xfa475364, - 0xdc0487e8, 0x3334ecf1, 0x0788272b, 0xe8b84c32, 0x6ef1b09f, 0x81c1db86, - 0xb57d105c, 0x5a4d7b45, 0xbc029ff7, 0x5332f4ee, 0x678e3f34, 0x88be542d, - 0x0ef7a880, 0xe1c7c399, 0xd57b0843, 0x3a4b635a, 0x99fca15b, 0x76ccca42, - 0x42700198, 0xad406a81, 0x2b09962c, 0xc439fd35, 0xf08536ef, 0x1fb55df6, - 0xf9fab944, 0x16cad25d, 0x22761987, 0xcd46729e, 0x4b0f8e33, 0xa43fe52a, - 0x90832ef0, 0x7fb345e9, 0x59f09165, 0xb6c0fa7c, 0x827c31a6, 0x6d4c5abf, - 0xeb05a612, 0x0435cd0b, 0x308906d1, 0xdfb96dc8, 0x39f6897a, 0xd6c6e263, - 0xe27a29b9, 0x0d4a42a0, 0x8b03be0d, 0x6433d514, 0x508f1ece, 0xbfbf75d7, - 0x120cec3d, 0xfd3c8724, 0xc9804cfe, 0x26b027e7, 0xa0f9db4a, 0x4fc9b053, - 0x7b757b89, 0x94451090, 0x720af422, 0x9d3a9f3b, 0xa98654e1, 0x46b63ff8, - 0xc0ffc355, 0x2fcfa84c, 0x1b736396, 0xf443088f, 0xd200dc03, 0x3d30b71a, - 0x098c7cc0, 0xe6bc17d9, 0x60f5eb74, 0x8fc5806d, 0xbb794bb7, 0x544920ae, - 0xb206c41c, 0x5d36af05, 0x698a64df, 0x86ba0fc6, 0x00f3f36b, 0xefc39872, - 0xdb7f53a8, 0x344f38b1, 0x97f8fab0, 0x78c891a9, 0x4c745a73, 0xa344316a, - 0x250dcdc7, 0xca3da6de, 0xfe816d04, 0x11b1061d, 0xf7fee2af, 0x18ce89b6, - 0x2c72426c, 0xc3422975, 0x450bd5d8, 0xaa3bbec1, 0x9e87751b, 0x71b71e02, - 0x57f4ca8e, 0xb8c4a197, 0x8c786a4d, 0x63480154, 0xe501fdf9, 0x0a3196e0, - 0x3e8d5d3a, 0xd1bd3623, 0x37f2d291, 0xd8c2b988, 0xec7e7252, 0x034e194b, + {0x00000000, 0xef306b19, 0xdb8ca0c3, 0x34bccbda, 0xb2f53777, 0x5dc55c6e, 0x697997b4, 0x8649fcad, 0x6006181f, + 0x8f367306, 0xbb8ab8dc, 0x54bad3c5, 0xd2f32f68, 0x3dc34471, 0x097f8fab, 0xe64fe4b2, 0xc00c303e, 0x2f3c5b27, + 0x1b8090fd, 0xf4b0fbe4, 0x72f90749, 0x9dc96c50, 0xa975a78a, 0x4645cc93, 0xa00a2821, 0x4f3a4338, 0x7b8688e2, + 0x94b6e3fb, 0x12ff1f56, 0xfdcf744f, 0xc973bf95, 0x2643d48c, 0x85f4168d, 0x6ac47d94, 0x5e78b64e, 0xb148dd57, + 0x370121fa, 0xd8314ae3, 0xec8d8139, 0x03bdea20, 0xe5f20e92, 0x0ac2658b, 0x3e7eae51, 0xd14ec548, 0x570739e5, + 0xb83752fc, 0x8c8b9926, 0x63bbf23f, 0x45f826b3, 0xaac84daa, 0x9e748670, 0x7144ed69, 0xf70d11c4, 0x183d7add, + 0x2c81b107, 0xc3b1da1e, 0x25fe3eac, 0xcace55b5, 0xfe729e6f, 0x1142f576, 0x970b09db, 0x783b62c2, 0x4c87a918, + 0xa3b7c201, 0x0e045beb, 0xe13430f2, 0xd588fb28, 0x3ab89031, 0xbcf16c9c, 0x53c10785, 0x677dcc5f, 0x884da746, + 0x6e0243f4, 0x813228ed, 0xb58ee337, 0x5abe882e, 0xdcf77483, 0x33c71f9a, 0x077bd440, 0xe84bbf59, 0xce086bd5, + 0x213800cc, 0x1584cb16, 0xfab4a00f, 0x7cfd5ca2, 0x93cd37bb, 0xa771fc61, 0x48419778, 0xae0e73ca, 0x413e18d3, + 0x7582d309, 0x9ab2b810, 0x1cfb44bd, 0xf3cb2fa4, 0xc777e47e, 0x28478f67, 0x8bf04d66, 0x64c0267f, 0x507ceda5, + 0xbf4c86bc, 0x39057a11, 0xd6351108, 0xe289dad2, 0x0db9b1cb, 0xebf65579, 0x04c63e60, 0x307af5ba, 0xdf4a9ea3, + 0x5903620e, 0xb6330917, 0x828fc2cd, 0x6dbfa9d4, 0x4bfc7d58, 0xa4cc1641, 0x9070dd9b, 0x7f40b682, 0xf9094a2f, + 0x16392136, 0x2285eaec, 0xcdb581f5, 0x2bfa6547, 0xc4ca0e5e, 0xf076c584, 0x1f46ae9d, 0x990f5230, 0x763f3929, + 0x4283f2f3, 0xadb399ea, 0x1c08b7d6, 0xf338dccf, 0xc7841715, 0x28b47c0c, 0xaefd80a1, 0x41cdebb8, 0x75712062, + 0x9a414b7b, 0x7c0eafc9, 0x933ec4d0, 0xa7820f0a, 0x48b26413, 0xcefb98be, 0x21cbf3a7, 0x1577387d, 0xfa475364, + 0xdc0487e8, 0x3334ecf1, 0x0788272b, 0xe8b84c32, 0x6ef1b09f, 0x81c1db86, 0xb57d105c, 0x5a4d7b45, 0xbc029ff7, + 0x5332f4ee, 0x678e3f34, 0x88be542d, 0x0ef7a880, 0xe1c7c399, 0xd57b0843, 0x3a4b635a, 0x99fca15b, 0x76ccca42, + 0x42700198, 0xad406a81, 0x2b09962c, 0xc439fd35, 0xf08536ef, 0x1fb55df6, 0xf9fab944, 0x16cad25d, 0x22761987, + 0xcd46729e, 0x4b0f8e33, 0xa43fe52a, 0x90832ef0, 0x7fb345e9, 0x59f09165, 0xb6c0fa7c, 0x827c31a6, 0x6d4c5abf, + 0xeb05a612, 0x0435cd0b, 0x308906d1, 0xdfb96dc8, 0x39f6897a, 0xd6c6e263, 0xe27a29b9, 0x0d4a42a0, 0x8b03be0d, + 0x6433d514, 0x508f1ece, 0xbfbf75d7, 0x120cec3d, 0xfd3c8724, 0xc9804cfe, 0x26b027e7, 0xa0f9db4a, 0x4fc9b053, + 0x7b757b89, 0x94451090, 0x720af422, 0x9d3a9f3b, 0xa98654e1, 0x46b63ff8, 0xc0ffc355, 0x2fcfa84c, 0x1b736396, + 0xf443088f, 0xd200dc03, 0x3d30b71a, 0x098c7cc0, 0xe6bc17d9, 0x60f5eb74, 0x8fc5806d, 0xbb794bb7, 0x544920ae, + 0xb206c41c, 0x5d36af05, 0x698a64df, 0x86ba0fc6, 0x00f3f36b, 0xefc39872, 0xdb7f53a8, 0x344f38b1, 0x97f8fab0, + 0x78c891a9, 0x4c745a73, 0xa344316a, 0x250dcdc7, 0xca3da6de, 0xfe816d04, 0x11b1061d, 0xf7fee2af, 0x18ce89b6, + 0x2c72426c, 0xc3422975, 0x450bd5d8, 0xaa3bbec1, 0x9e87751b, 0x71b71e02, 0x57f4ca8e, 0xb8c4a197, 0x8c786a4d, + 0x63480154, 0xe501fdf9, 0x0a3196e0, 0x3e8d5d3a, 0xd1bd3623, 0x37f2d291, 0xd8c2b988, 0xec7e7252, 0x034e194b, 0x8507e5e6, 0x6a378eff, 0x5e8b4525, 0xb1bb2e3c}, - {0x00000000, 0x68032cc8, 0xd0065990, 0xb8057558, 0xa5e0c5d1, 0xcde3e919, - 0x75e69c41, 0x1de5b089, 0x4e2dfd53, 0x262ed19b, 0x9e2ba4c3, 0xf628880b, - 0xebcd3882, 0x83ce144a, 0x3bcb6112, 0x53c84dda, 0x9c5bfaa6, 0xf458d66e, - 0x4c5da336, 0x245e8ffe, 0x39bb3f77, 0x51b813bf, 0xe9bd66e7, 0x81be4a2f, - 0xd27607f5, 0xba752b3d, 0x02705e65, 0x6a7372ad, 0x7796c224, 0x1f95eeec, - 0xa7909bb4, 0xcf93b77c, 0x3d5b83bd, 0x5558af75, 0xed5dda2d, 0x855ef6e5, - 0x98bb466c, 0xf0b86aa4, 0x48bd1ffc, 0x20be3334, 0x73767eee, 0x1b755226, - 0xa370277e, 0xcb730bb6, 0xd696bb3f, 0xbe9597f7, 0x0690e2af, 0x6e93ce67, - 0xa100791b, 0xc90355d3, 0x7106208b, 0x19050c43, 0x04e0bcca, 0x6ce39002, - 0xd4e6e55a, 0xbce5c992, 0xef2d8448, 0x872ea880, 0x3f2bddd8, 0x5728f110, - 0x4acd4199, 0x22ce6d51, 0x9acb1809, 0xf2c834c1, 0x7ab7077a, 0x12b42bb2, - 0xaab15eea, 0xc2b27222, 0xdf57c2ab, 0xb754ee63, 0x0f519b3b, 0x6752b7f3, - 0x349afa29, 0x5c99d6e1, 0xe49ca3b9, 0x8c9f8f71, 0x917a3ff8, 0xf9791330, - 0x417c6668, 0x297f4aa0, 0xe6ecfddc, 0x8eefd114, 0x36eaa44c, 0x5ee98884, - 0x430c380d, 0x2b0f14c5, 0x930a619d, 0xfb094d55, 0xa8c1008f, 0xc0c22c47, - 0x78c7591f, 0x10c475d7, 0x0d21c55e, 0x6522e996, 0xdd279cce, 0xb524b006, - 0x47ec84c7, 0x2fefa80f, 0x97eadd57, 0xffe9f19f, 0xe20c4116, 0x8a0f6dde, - 0x320a1886, 0x5a09344e, 0x09c17994, 0x61c2555c, 0xd9c72004, 0xb1c40ccc, - 0xac21bc45, 0xc422908d, 0x7c27e5d5, 0x1424c91d, 0xdbb77e61, 0xb3b452a9, - 0x0bb127f1, 0x63b20b39, 0x7e57bbb0, 0x16549778, 0xae51e220, 0xc652cee8, - 0x959a8332, 0xfd99affa, 0x459cdaa2, 0x2d9ff66a, 0x307a46e3, 0x58796a2b, - 0xe07c1f73, 0x887f33bb, 0xf56e0ef4, 0x9d6d223c, 0x25685764, 0x4d6b7bac, - 0x508ecb25, 0x388de7ed, 0x808892b5, 0xe88bbe7d, 0xbb43f3a7, 0xd340df6f, - 0x6b45aa37, 0x034686ff, 0x1ea33676, 0x76a01abe, 0xcea56fe6, 0xa6a6432e, - 0x6935f452, 0x0136d89a, 0xb933adc2, 0xd130810a, 0xccd53183, 0xa4d61d4b, - 0x1cd36813, 0x74d044db, 0x27180901, 0x4f1b25c9, 0xf71e5091, 0x9f1d7c59, - 0x82f8ccd0, 0xeafbe018, 0x52fe9540, 0x3afdb988, 0xc8358d49, 0xa036a181, - 0x1833d4d9, 0x7030f811, 0x6dd54898, 0x05d66450, 0xbdd31108, 0xd5d03dc0, - 0x8618701a, 0xee1b5cd2, 0x561e298a, 0x3e1d0542, 0x23f8b5cb, 0x4bfb9903, - 0xf3feec5b, 0x9bfdc093, 0x546e77ef, 0x3c6d5b27, 0x84682e7f, 0xec6b02b7, - 0xf18eb23e, 0x998d9ef6, 0x2188ebae, 0x498bc766, 0x1a438abc, 0x7240a674, - 0xca45d32c, 0xa246ffe4, 0xbfa34f6d, 0xd7a063a5, 0x6fa516fd, 0x07a63a35, - 0x8fd9098e, 0xe7da2546, 0x5fdf501e, 0x37dc7cd6, 0x2a39cc5f, 0x423ae097, - 0xfa3f95cf, 0x923cb907, 0xc1f4f4dd, 0xa9f7d815, 0x11f2ad4d, 0x79f18185, - 0x6414310c, 0x0c171dc4, 0xb412689c, 0xdc114454, 0x1382f328, 0x7b81dfe0, - 0xc384aab8, 0xab878670, 0xb66236f9, 0xde611a31, 0x66646f69, 0x0e6743a1, - 0x5daf0e7b, 0x35ac22b3, 0x8da957eb, 0xe5aa7b23, 0xf84fcbaa, 0x904ce762, - 0x2849923a, 0x404abef2, 0xb2828a33, 0xda81a6fb, 0x6284d3a3, 0x0a87ff6b, - 0x17624fe2, 0x7f61632a, 0xc7641672, 0xaf673aba, 0xfcaf7760, 0x94ac5ba8, - 0x2ca92ef0, 0x44aa0238, 0x594fb2b1, 0x314c9e79, 0x8949eb21, 0xe14ac7e9, - 0x2ed97095, 0x46da5c5d, 0xfedf2905, 0x96dc05cd, 0x8b39b544, 0xe33a998c, - 0x5b3fecd4, 0x333cc01c, 0x60f48dc6, 0x08f7a10e, 0xb0f2d456, 0xd8f1f89e, + {0x00000000, 0x68032cc8, 0xd0065990, 0xb8057558, 0xa5e0c5d1, 0xcde3e919, 0x75e69c41, 0x1de5b089, 0x4e2dfd53, + 0x262ed19b, 0x9e2ba4c3, 0xf628880b, 0xebcd3882, 0x83ce144a, 0x3bcb6112, 0x53c84dda, 0x9c5bfaa6, 0xf458d66e, + 0x4c5da336, 0x245e8ffe, 0x39bb3f77, 0x51b813bf, 0xe9bd66e7, 0x81be4a2f, 0xd27607f5, 0xba752b3d, 0x02705e65, + 0x6a7372ad, 0x7796c224, 0x1f95eeec, 0xa7909bb4, 0xcf93b77c, 0x3d5b83bd, 0x5558af75, 0xed5dda2d, 0x855ef6e5, + 0x98bb466c, 0xf0b86aa4, 0x48bd1ffc, 0x20be3334, 0x73767eee, 0x1b755226, 0xa370277e, 0xcb730bb6, 0xd696bb3f, + 0xbe9597f7, 0x0690e2af, 0x6e93ce67, 0xa100791b, 0xc90355d3, 0x7106208b, 0x19050c43, 0x04e0bcca, 0x6ce39002, + 0xd4e6e55a, 0xbce5c992, 0xef2d8448, 0x872ea880, 0x3f2bddd8, 0x5728f110, 0x4acd4199, 0x22ce6d51, 0x9acb1809, + 0xf2c834c1, 0x7ab7077a, 0x12b42bb2, 0xaab15eea, 0xc2b27222, 0xdf57c2ab, 0xb754ee63, 0x0f519b3b, 0x6752b7f3, + 0x349afa29, 0x5c99d6e1, 0xe49ca3b9, 0x8c9f8f71, 0x917a3ff8, 0xf9791330, 0x417c6668, 0x297f4aa0, 0xe6ecfddc, + 0x8eefd114, 0x36eaa44c, 0x5ee98884, 0x430c380d, 0x2b0f14c5, 0x930a619d, 0xfb094d55, 0xa8c1008f, 0xc0c22c47, + 0x78c7591f, 0x10c475d7, 0x0d21c55e, 0x6522e996, 0xdd279cce, 0xb524b006, 0x47ec84c7, 0x2fefa80f, 0x97eadd57, + 0xffe9f19f, 0xe20c4116, 0x8a0f6dde, 0x320a1886, 0x5a09344e, 0x09c17994, 0x61c2555c, 0xd9c72004, 0xb1c40ccc, + 0xac21bc45, 0xc422908d, 0x7c27e5d5, 0x1424c91d, 0xdbb77e61, 0xb3b452a9, 0x0bb127f1, 0x63b20b39, 0x7e57bbb0, + 0x16549778, 0xae51e220, 0xc652cee8, 0x959a8332, 0xfd99affa, 0x459cdaa2, 0x2d9ff66a, 0x307a46e3, 0x58796a2b, + 0xe07c1f73, 0x887f33bb, 0xf56e0ef4, 0x9d6d223c, 0x25685764, 0x4d6b7bac, 0x508ecb25, 0x388de7ed, 0x808892b5, + 0xe88bbe7d, 0xbb43f3a7, 0xd340df6f, 0x6b45aa37, 0x034686ff, 0x1ea33676, 0x76a01abe, 0xcea56fe6, 0xa6a6432e, + 0x6935f452, 0x0136d89a, 0xb933adc2, 0xd130810a, 0xccd53183, 0xa4d61d4b, 0x1cd36813, 0x74d044db, 0x27180901, + 0x4f1b25c9, 0xf71e5091, 0x9f1d7c59, 0x82f8ccd0, 0xeafbe018, 0x52fe9540, 0x3afdb988, 0xc8358d49, 0xa036a181, + 0x1833d4d9, 0x7030f811, 0x6dd54898, 0x05d66450, 0xbdd31108, 0xd5d03dc0, 0x8618701a, 0xee1b5cd2, 0x561e298a, + 0x3e1d0542, 0x23f8b5cb, 0x4bfb9903, 0xf3feec5b, 0x9bfdc093, 0x546e77ef, 0x3c6d5b27, 0x84682e7f, 0xec6b02b7, + 0xf18eb23e, 0x998d9ef6, 0x2188ebae, 0x498bc766, 0x1a438abc, 0x7240a674, 0xca45d32c, 0xa246ffe4, 0xbfa34f6d, + 0xd7a063a5, 0x6fa516fd, 0x07a63a35, 0x8fd9098e, 0xe7da2546, 0x5fdf501e, 0x37dc7cd6, 0x2a39cc5f, 0x423ae097, + 0xfa3f95cf, 0x923cb907, 0xc1f4f4dd, 0xa9f7d815, 0x11f2ad4d, 0x79f18185, 0x6414310c, 0x0c171dc4, 0xb412689c, + 0xdc114454, 0x1382f328, 0x7b81dfe0, 0xc384aab8, 0xab878670, 0xb66236f9, 0xde611a31, 0x66646f69, 0x0e6743a1, + 0x5daf0e7b, 0x35ac22b3, 0x8da957eb, 0xe5aa7b23, 0xf84fcbaa, 0x904ce762, 0x2849923a, 0x404abef2, 0xb2828a33, + 0xda81a6fb, 0x6284d3a3, 0x0a87ff6b, 0x17624fe2, 0x7f61632a, 0xc7641672, 0xaf673aba, 0xfcaf7760, 0x94ac5ba8, + 0x2ca92ef0, 0x44aa0238, 0x594fb2b1, 0x314c9e79, 0x8949eb21, 0xe14ac7e9, 0x2ed97095, 0x46da5c5d, 0xfedf2905, + 0x96dc05cd, 0x8b39b544, 0xe33a998c, 0x5b3fecd4, 0x333cc01c, 0x60f48dc6, 0x08f7a10e, 0xb0f2d456, 0xd8f1f89e, 0xc5144817, 0xad1764df, 0x15121187, 0x7d113d4f}, - {0x00000000, 0x493c7d27, 0x9278fa4e, 0xdb448769, 0x211d826d, 0x6821ff4a, - 0xb3657823, 0xfa590504, 0x423b04da, 0x0b0779fd, 0xd043fe94, 0x997f83b3, - 0x632686b7, 0x2a1afb90, 0xf15e7cf9, 0xb86201de, 0x847609b4, 0xcd4a7493, - 0x160ef3fa, 0x5f328edd, 0xa56b8bd9, 0xec57f6fe, 0x37137197, 0x7e2f0cb0, - 0xc64d0d6e, 0x8f717049, 0x5435f720, 0x1d098a07, 0xe7508f03, 0xae6cf224, - 0x7528754d, 0x3c14086a, 0x0d006599, 0x443c18be, 0x9f789fd7, 0xd644e2f0, - 0x2c1de7f4, 0x65219ad3, 0xbe651dba, 0xf759609d, 0x4f3b6143, 0x06071c64, - 0xdd439b0d, 0x947fe62a, 0x6e26e32e, 0x271a9e09, 0xfc5e1960, 0xb5626447, - 0x89766c2d, 0xc04a110a, 0x1b0e9663, 0x5232eb44, 0xa86bee40, 0xe1579367, - 0x3a13140e, 0x732f6929, 0xcb4d68f7, 0x827115d0, 0x593592b9, 0x1009ef9e, - 0xea50ea9a, 0xa36c97bd, 0x782810d4, 0x31146df3, 0x1a00cb32, 0x533cb615, - 0x8878317c, 0xc1444c5b, 0x3b1d495f, 0x72213478, 0xa965b311, 0xe059ce36, - 0x583bcfe8, 0x1107b2cf, 0xca4335a6, 0x837f4881, 0x79264d85, 0x301a30a2, - 0xeb5eb7cb, 0xa262caec, 0x9e76c286, 0xd74abfa1, 0x0c0e38c8, 0x453245ef, - 0xbf6b40eb, 0xf6573dcc, 0x2d13baa5, 0x642fc782, 0xdc4dc65c, 0x9571bb7b, - 0x4e353c12, 0x07094135, 0xfd504431, 0xb46c3916, 0x6f28be7f, 0x2614c358, - 0x1700aeab, 0x5e3cd38c, 0x857854e5, 0xcc4429c2, 0x361d2cc6, 0x7f2151e1, - 0xa465d688, 0xed59abaf, 0x553baa71, 0x1c07d756, 0xc743503f, 0x8e7f2d18, - 0x7426281c, 0x3d1a553b, 0xe65ed252, 0xaf62af75, 0x9376a71f, 0xda4ada38, - 0x010e5d51, 0x48322076, 0xb26b2572, 0xfb575855, 0x2013df3c, 0x692fa21b, - 0xd14da3c5, 0x9871dee2, 0x4335598b, 0x0a0924ac, 0xf05021a8, 0xb96c5c8f, - 0x6228dbe6, 0x2b14a6c1, 0x34019664, 0x7d3deb43, 0xa6796c2a, 0xef45110d, - 0x151c1409, 0x5c20692e, 0x8764ee47, 0xce589360, 0x763a92be, 0x3f06ef99, - 0xe44268f0, 0xad7e15d7, 0x572710d3, 0x1e1b6df4, 0xc55fea9d, 0x8c6397ba, - 0xb0779fd0, 0xf94be2f7, 0x220f659e, 0x6b3318b9, 0x916a1dbd, 0xd856609a, - 0x0312e7f3, 0x4a2e9ad4, 0xf24c9b0a, 0xbb70e62d, 0x60346144, 0x29081c63, - 0xd3511967, 0x9a6d6440, 0x4129e329, 0x08159e0e, 0x3901f3fd, 0x703d8eda, - 0xab7909b3, 0xe2457494, 0x181c7190, 0x51200cb7, 0x8a648bde, 0xc358f6f9, - 0x7b3af727, 0x32068a00, 0xe9420d69, 0xa07e704e, 0x5a27754a, 0x131b086d, - 0xc85f8f04, 0x8163f223, 0xbd77fa49, 0xf44b876e, 0x2f0f0007, 0x66337d20, - 0x9c6a7824, 0xd5560503, 0x0e12826a, 0x472eff4d, 0xff4cfe93, 0xb67083b4, - 0x6d3404dd, 0x240879fa, 0xde517cfe, 0x976d01d9, 0x4c2986b0, 0x0515fb97, - 0x2e015d56, 0x673d2071, 0xbc79a718, 0xf545da3f, 0x0f1cdf3b, 0x4620a21c, - 0x9d642575, 0xd4585852, 0x6c3a598c, 0x250624ab, 0xfe42a3c2, 0xb77edee5, - 0x4d27dbe1, 0x041ba6c6, 0xdf5f21af, 0x96635c88, 0xaa7754e2, 0xe34b29c5, - 0x380faeac, 0x7133d38b, 0x8b6ad68f, 0xc256aba8, 0x19122cc1, 0x502e51e6, - 0xe84c5038, 0xa1702d1f, 0x7a34aa76, 0x3308d751, 0xc951d255, 0x806daf72, - 0x5b29281b, 0x1215553c, 0x230138cf, 0x6a3d45e8, 0xb179c281, 0xf845bfa6, - 0x021cbaa2, 0x4b20c785, 0x906440ec, 0xd9583dcb, 0x613a3c15, 0x28064132, - 0xf342c65b, 0xba7ebb7c, 0x4027be78, 0x091bc35f, 0xd25f4436, 0x9b633911, - 0xa777317b, 0xee4b4c5c, 0x350fcb35, 0x7c33b612, 0x866ab316, 0xcf56ce31, - 0x14124958, 0x5d2e347f, 0xe54c35a1, 0xac704886, 0x7734cfef, 0x3e08b2c8, + {0x00000000, 0x493c7d27, 0x9278fa4e, 0xdb448769, 0x211d826d, 0x6821ff4a, 0xb3657823, 0xfa590504, 0x423b04da, + 0x0b0779fd, 0xd043fe94, 0x997f83b3, 0x632686b7, 0x2a1afb90, 0xf15e7cf9, 0xb86201de, 0x847609b4, 0xcd4a7493, + 0x160ef3fa, 0x5f328edd, 0xa56b8bd9, 0xec57f6fe, 0x37137197, 0x7e2f0cb0, 0xc64d0d6e, 0x8f717049, 0x5435f720, + 0x1d098a07, 0xe7508f03, 0xae6cf224, 0x7528754d, 0x3c14086a, 0x0d006599, 0x443c18be, 0x9f789fd7, 0xd644e2f0, + 0x2c1de7f4, 0x65219ad3, 0xbe651dba, 0xf759609d, 0x4f3b6143, 0x06071c64, 0xdd439b0d, 0x947fe62a, 0x6e26e32e, + 0x271a9e09, 0xfc5e1960, 0xb5626447, 0x89766c2d, 0xc04a110a, 0x1b0e9663, 0x5232eb44, 0xa86bee40, 0xe1579367, + 0x3a13140e, 0x732f6929, 0xcb4d68f7, 0x827115d0, 0x593592b9, 0x1009ef9e, 0xea50ea9a, 0xa36c97bd, 0x782810d4, + 0x31146df3, 0x1a00cb32, 0x533cb615, 0x8878317c, 0xc1444c5b, 0x3b1d495f, 0x72213478, 0xa965b311, 0xe059ce36, + 0x583bcfe8, 0x1107b2cf, 0xca4335a6, 0x837f4881, 0x79264d85, 0x301a30a2, 0xeb5eb7cb, 0xa262caec, 0x9e76c286, + 0xd74abfa1, 0x0c0e38c8, 0x453245ef, 0xbf6b40eb, 0xf6573dcc, 0x2d13baa5, 0x642fc782, 0xdc4dc65c, 0x9571bb7b, + 0x4e353c12, 0x07094135, 0xfd504431, 0xb46c3916, 0x6f28be7f, 0x2614c358, 0x1700aeab, 0x5e3cd38c, 0x857854e5, + 0xcc4429c2, 0x361d2cc6, 0x7f2151e1, 0xa465d688, 0xed59abaf, 0x553baa71, 0x1c07d756, 0xc743503f, 0x8e7f2d18, + 0x7426281c, 0x3d1a553b, 0xe65ed252, 0xaf62af75, 0x9376a71f, 0xda4ada38, 0x010e5d51, 0x48322076, 0xb26b2572, + 0xfb575855, 0x2013df3c, 0x692fa21b, 0xd14da3c5, 0x9871dee2, 0x4335598b, 0x0a0924ac, 0xf05021a8, 0xb96c5c8f, + 0x6228dbe6, 0x2b14a6c1, 0x34019664, 0x7d3deb43, 0xa6796c2a, 0xef45110d, 0x151c1409, 0x5c20692e, 0x8764ee47, + 0xce589360, 0x763a92be, 0x3f06ef99, 0xe44268f0, 0xad7e15d7, 0x572710d3, 0x1e1b6df4, 0xc55fea9d, 0x8c6397ba, + 0xb0779fd0, 0xf94be2f7, 0x220f659e, 0x6b3318b9, 0x916a1dbd, 0xd856609a, 0x0312e7f3, 0x4a2e9ad4, 0xf24c9b0a, + 0xbb70e62d, 0x60346144, 0x29081c63, 0xd3511967, 0x9a6d6440, 0x4129e329, 0x08159e0e, 0x3901f3fd, 0x703d8eda, + 0xab7909b3, 0xe2457494, 0x181c7190, 0x51200cb7, 0x8a648bde, 0xc358f6f9, 0x7b3af727, 0x32068a00, 0xe9420d69, + 0xa07e704e, 0x5a27754a, 0x131b086d, 0xc85f8f04, 0x8163f223, 0xbd77fa49, 0xf44b876e, 0x2f0f0007, 0x66337d20, + 0x9c6a7824, 0xd5560503, 0x0e12826a, 0x472eff4d, 0xff4cfe93, 0xb67083b4, 0x6d3404dd, 0x240879fa, 0xde517cfe, + 0x976d01d9, 0x4c2986b0, 0x0515fb97, 0x2e015d56, 0x673d2071, 0xbc79a718, 0xf545da3f, 0x0f1cdf3b, 0x4620a21c, + 0x9d642575, 0xd4585852, 0x6c3a598c, 0x250624ab, 0xfe42a3c2, 0xb77edee5, 0x4d27dbe1, 0x041ba6c6, 0xdf5f21af, + 0x96635c88, 0xaa7754e2, 0xe34b29c5, 0x380faeac, 0x7133d38b, 0x8b6ad68f, 0xc256aba8, 0x19122cc1, 0x502e51e6, + 0xe84c5038, 0xa1702d1f, 0x7a34aa76, 0x3308d751, 0xc951d255, 0x806daf72, 0x5b29281b, 0x1215553c, 0x230138cf, + 0x6a3d45e8, 0xb179c281, 0xf845bfa6, 0x021cbaa2, 0x4b20c785, 0x906440ec, 0xd9583dcb, 0x613a3c15, 0x28064132, + 0xf342c65b, 0xba7ebb7c, 0x4027be78, 0x091bc35f, 0xd25f4436, 0x9b633911, 0xa777317b, 0xee4b4c5c, 0x350fcb35, + 0x7c33b612, 0x866ab316, 0xcf56ce31, 0x14124958, 0x5d2e347f, 0xe54c35a1, 0xac704886, 0x7734cfef, 0x3e08b2c8, 0xc451b7cc, 0x8d6dcaeb, 0x56294d82, 0x1f1530a5}, - {0x00000000, 0xf43ed648, 0xed91da61, 0x19af0c29, 0xdecfc233, 0x2af1147b, - 0x335e1852, 0xc760ce1a, 0xb873f297, 0x4c4d24df, 0x55e228f6, 0xa1dcfebe, - 0x66bc30a4, 0x9282e6ec, 0x8b2deac5, 0x7f133c8d, 0x750b93df, 0x81354597, - 0x989a49be, 0x6ca49ff6, 0xabc451ec, 0x5ffa87a4, 0x46558b8d, 0xb26b5dc5, - 0xcd786148, 0x3946b700, 0x20e9bb29, 0xd4d76d61, 0x13b7a37b, 0xe7897533, - 0xfe26791a, 0x0a18af52, 0xea1727be, 0x1e29f1f6, 0x0786fddf, 0xf3b82b97, - 0x34d8e58d, 0xc0e633c5, 0xd9493fec, 0x2d77e9a4, 0x5264d529, 0xa65a0361, - 0xbff50f48, 0x4bcbd900, 0x8cab171a, 0x7895c152, 0x613acd7b, 0x95041b33, - 0x9f1cb461, 0x6b226229, 0x728d6e00, 0x86b3b848, 0x41d37652, 0xb5eda01a, - 0xac42ac33, 0x587c7a7b, 0x276f46f6, 0xd35190be, 0xcafe9c97, 0x3ec04adf, - 0xf9a084c5, 0x0d9e528d, 0x14315ea4, 0xe00f88ec, 0xd1c2398d, 0x25fcefc5, - 0x3c53e3ec, 0xc86d35a4, 0x0f0dfbbe, 0xfb332df6, 0xe29c21df, 0x16a2f797, - 0x69b1cb1a, 0x9d8f1d52, 0x8420117b, 0x701ec733, 0xb77e0929, 0x4340df61, - 0x5aefd348, 0xaed10500, 0xa4c9aa52, 0x50f77c1a, 0x49587033, 0xbd66a67b, - 0x7a066861, 0x8e38be29, 0x9797b200, 0x63a96448, 0x1cba58c5, 0xe8848e8d, - 0xf12b82a4, 0x051554ec, 0xc2759af6, 0x364b4cbe, 0x2fe44097, 0xdbda96df, - 0x3bd51e33, 0xcfebc87b, 0xd644c452, 0x227a121a, 0xe51adc00, 0x11240a48, - 0x088b0661, 0xfcb5d029, 0x83a6eca4, 0x77983aec, 0x6e3736c5, 0x9a09e08d, - 0x5d692e97, 0xa957f8df, 0xb0f8f4f6, 0x44c622be, 0x4ede8dec, 0xbae05ba4, - 0xa34f578d, 0x577181c5, 0x90114fdf, 0x642f9997, 0x7d8095be, 0x89be43f6, - 0xf6ad7f7b, 0x0293a933, 0x1b3ca51a, 0xef027352, 0x2862bd48, 0xdc5c6b00, - 0xc5f36729, 0x31cdb161, 0xa66805eb, 0x5256d3a3, 0x4bf9df8a, 0xbfc709c2, - 0x78a7c7d8, 0x8c991190, 0x95361db9, 0x6108cbf1, 0x1e1bf77c, 0xea252134, - 0xf38a2d1d, 0x07b4fb55, 0xc0d4354f, 0x34eae307, 0x2d45ef2e, 0xd97b3966, - 0xd3639634, 0x275d407c, 0x3ef24c55, 0xcacc9a1d, 0x0dac5407, 0xf992824f, - 0xe03d8e66, 0x1403582e, 0x6b1064a3, 0x9f2eb2eb, 0x8681bec2, 0x72bf688a, - 0xb5dfa690, 0x41e170d8, 0x584e7cf1, 0xac70aab9, 0x4c7f2255, 0xb841f41d, - 0xa1eef834, 0x55d02e7c, 0x92b0e066, 0x668e362e, 0x7f213a07, 0x8b1fec4f, - 0xf40cd0c2, 0x0032068a, 0x199d0aa3, 0xeda3dceb, 0x2ac312f1, 0xdefdc4b9, - 0xc752c890, 0x336c1ed8, 0x3974b18a, 0xcd4a67c2, 0xd4e56beb, 0x20dbbda3, - 0xe7bb73b9, 0x1385a5f1, 0x0a2aa9d8, 0xfe147f90, 0x8107431d, 0x75399555, - 0x6c96997c, 0x98a84f34, 0x5fc8812e, 0xabf65766, 0xb2595b4f, 0x46678d07, - 0x77aa3c66, 0x8394ea2e, 0x9a3be607, 0x6e05304f, 0xa965fe55, 0x5d5b281d, - 0x44f42434, 0xb0caf27c, 0xcfd9cef1, 0x3be718b9, 0x22481490, 0xd676c2d8, - 0x11160cc2, 0xe528da8a, 0xfc87d6a3, 0x08b900eb, 0x02a1afb9, 0xf69f79f1, - 0xef3075d8, 0x1b0ea390, 0xdc6e6d8a, 0x2850bbc2, 0x31ffb7eb, 0xc5c161a3, - 0xbad25d2e, 0x4eec8b66, 0x5743874f, 0xa37d5107, 0x641d9f1d, 0x90234955, - 0x898c457c, 0x7db29334, 0x9dbd1bd8, 0x6983cd90, 0x702cc1b9, 0x841217f1, - 0x4372d9eb, 0xb74c0fa3, 0xaee3038a, 0x5addd5c2, 0x25cee94f, 0xd1f03f07, - 0xc85f332e, 0x3c61e566, 0xfb012b7c, 0x0f3ffd34, 0x1690f11d, 0xe2ae2755, - 0xe8b68807, 0x1c885e4f, 0x05275266, 0xf119842e, 0x36794a34, 0xc2479c7c, - 0xdbe89055, 0x2fd6461d, 0x50c57a90, 0xa4fbacd8, 0xbd54a0f1, 0x496a76b9, + {0x00000000, 0xf43ed648, 0xed91da61, 0x19af0c29, 0xdecfc233, 0x2af1147b, 0x335e1852, 0xc760ce1a, 0xb873f297, + 0x4c4d24df, 0x55e228f6, 0xa1dcfebe, 0x66bc30a4, 0x9282e6ec, 0x8b2deac5, 0x7f133c8d, 0x750b93df, 0x81354597, + 0x989a49be, 0x6ca49ff6, 0xabc451ec, 0x5ffa87a4, 0x46558b8d, 0xb26b5dc5, 0xcd786148, 0x3946b700, 0x20e9bb29, + 0xd4d76d61, 0x13b7a37b, 0xe7897533, 0xfe26791a, 0x0a18af52, 0xea1727be, 0x1e29f1f6, 0x0786fddf, 0xf3b82b97, + 0x34d8e58d, 0xc0e633c5, 0xd9493fec, 0x2d77e9a4, 0x5264d529, 0xa65a0361, 0xbff50f48, 0x4bcbd900, 0x8cab171a, + 0x7895c152, 0x613acd7b, 0x95041b33, 0x9f1cb461, 0x6b226229, 0x728d6e00, 0x86b3b848, 0x41d37652, 0xb5eda01a, + 0xac42ac33, 0x587c7a7b, 0x276f46f6, 0xd35190be, 0xcafe9c97, 0x3ec04adf, 0xf9a084c5, 0x0d9e528d, 0x14315ea4, + 0xe00f88ec, 0xd1c2398d, 0x25fcefc5, 0x3c53e3ec, 0xc86d35a4, 0x0f0dfbbe, 0xfb332df6, 0xe29c21df, 0x16a2f797, + 0x69b1cb1a, 0x9d8f1d52, 0x8420117b, 0x701ec733, 0xb77e0929, 0x4340df61, 0x5aefd348, 0xaed10500, 0xa4c9aa52, + 0x50f77c1a, 0x49587033, 0xbd66a67b, 0x7a066861, 0x8e38be29, 0x9797b200, 0x63a96448, 0x1cba58c5, 0xe8848e8d, + 0xf12b82a4, 0x051554ec, 0xc2759af6, 0x364b4cbe, 0x2fe44097, 0xdbda96df, 0x3bd51e33, 0xcfebc87b, 0xd644c452, + 0x227a121a, 0xe51adc00, 0x11240a48, 0x088b0661, 0xfcb5d029, 0x83a6eca4, 0x77983aec, 0x6e3736c5, 0x9a09e08d, + 0x5d692e97, 0xa957f8df, 0xb0f8f4f6, 0x44c622be, 0x4ede8dec, 0xbae05ba4, 0xa34f578d, 0x577181c5, 0x90114fdf, + 0x642f9997, 0x7d8095be, 0x89be43f6, 0xf6ad7f7b, 0x0293a933, 0x1b3ca51a, 0xef027352, 0x2862bd48, 0xdc5c6b00, + 0xc5f36729, 0x31cdb161, 0xa66805eb, 0x5256d3a3, 0x4bf9df8a, 0xbfc709c2, 0x78a7c7d8, 0x8c991190, 0x95361db9, + 0x6108cbf1, 0x1e1bf77c, 0xea252134, 0xf38a2d1d, 0x07b4fb55, 0xc0d4354f, 0x34eae307, 0x2d45ef2e, 0xd97b3966, + 0xd3639634, 0x275d407c, 0x3ef24c55, 0xcacc9a1d, 0x0dac5407, 0xf992824f, 0xe03d8e66, 0x1403582e, 0x6b1064a3, + 0x9f2eb2eb, 0x8681bec2, 0x72bf688a, 0xb5dfa690, 0x41e170d8, 0x584e7cf1, 0xac70aab9, 0x4c7f2255, 0xb841f41d, + 0xa1eef834, 0x55d02e7c, 0x92b0e066, 0x668e362e, 0x7f213a07, 0x8b1fec4f, 0xf40cd0c2, 0x0032068a, 0x199d0aa3, + 0xeda3dceb, 0x2ac312f1, 0xdefdc4b9, 0xc752c890, 0x336c1ed8, 0x3974b18a, 0xcd4a67c2, 0xd4e56beb, 0x20dbbda3, + 0xe7bb73b9, 0x1385a5f1, 0x0a2aa9d8, 0xfe147f90, 0x8107431d, 0x75399555, 0x6c96997c, 0x98a84f34, 0x5fc8812e, + 0xabf65766, 0xb2595b4f, 0x46678d07, 0x77aa3c66, 0x8394ea2e, 0x9a3be607, 0x6e05304f, 0xa965fe55, 0x5d5b281d, + 0x44f42434, 0xb0caf27c, 0xcfd9cef1, 0x3be718b9, 0x22481490, 0xd676c2d8, 0x11160cc2, 0xe528da8a, 0xfc87d6a3, + 0x08b900eb, 0x02a1afb9, 0xf69f79f1, 0xef3075d8, 0x1b0ea390, 0xdc6e6d8a, 0x2850bbc2, 0x31ffb7eb, 0xc5c161a3, + 0xbad25d2e, 0x4eec8b66, 0x5743874f, 0xa37d5107, 0x641d9f1d, 0x90234955, 0x898c457c, 0x7db29334, 0x9dbd1bd8, + 0x6983cd90, 0x702cc1b9, 0x841217f1, 0x4372d9eb, 0xb74c0fa3, 0xaee3038a, 0x5addd5c2, 0x25cee94f, 0xd1f03f07, + 0xc85f332e, 0x3c61e566, 0xfb012b7c, 0x0f3ffd34, 0x1690f11d, 0xe2ae2755, 0xe8b68807, 0x1c885e4f, 0x05275266, + 0xf119842e, 0x36794a34, 0xc2479c7c, 0xdbe89055, 0x2fd6461d, 0x50c57a90, 0xa4fbacd8, 0xbd54a0f1, 0x496a76b9, 0x8e0ab8a3, 0x7a346eeb, 0x639b62c2, 0x97a5b48a}, - {0x00000000, 0xcb567ba5, 0x934081bb, 0x5816fa1e, 0x236d7587, 0xe83b0e22, - 0xb02df43c, 0x7b7b8f99, 0x46daeb0e, 0x8d8c90ab, 0xd59a6ab5, 0x1ecc1110, - 0x65b79e89, 0xaee1e52c, 0xf6f71f32, 0x3da16497, 0x8db5d61c, 0x46e3adb9, - 0x1ef557a7, 0xd5a32c02, 0xaed8a39b, 0x658ed83e, 0x3d982220, 0xf6ce5985, - 0xcb6f3d12, 0x003946b7, 0x582fbca9, 0x9379c70c, 0xe8024895, 0x23543330, - 0x7b42c92e, 0xb014b28b, 0x1e87dac9, 0xd5d1a16c, 0x8dc75b72, 0x469120d7, - 0x3deaaf4e, 0xf6bcd4eb, 0xaeaa2ef5, 0x65fc5550, 0x585d31c7, 0x930b4a62, - 0xcb1db07c, 0x004bcbd9, 0x7b304440, 0xb0663fe5, 0xe870c5fb, 0x2326be5e, - 0x93320cd5, 0x58647770, 0x00728d6e, 0xcb24f6cb, 0xb05f7952, 0x7b0902f7, - 0x231ff8e9, 0xe849834c, 0xd5e8e7db, 0x1ebe9c7e, 0x46a86660, 0x8dfe1dc5, - 0xf685925c, 0x3dd3e9f9, 0x65c513e7, 0xae936842, 0x3d0fb592, 0xf659ce37, - 0xae4f3429, 0x65194f8c, 0x1e62c015, 0xd534bbb0, 0x8d2241ae, 0x46743a0b, - 0x7bd55e9c, 0xb0832539, 0xe895df27, 0x23c3a482, 0x58b82b1b, 0x93ee50be, - 0xcbf8aaa0, 0x00aed105, 0xb0ba638e, 0x7bec182b, 0x23fae235, 0xe8ac9990, - 0x93d71609, 0x58816dac, 0x009797b2, 0xcbc1ec17, 0xf6608880, 0x3d36f325, - 0x6520093b, 0xae76729e, 0xd50dfd07, 0x1e5b86a2, 0x464d7cbc, 0x8d1b0719, - 0x23886f5b, 0xe8de14fe, 0xb0c8eee0, 0x7b9e9545, 0x00e51adc, 0xcbb36179, - 0x93a59b67, 0x58f3e0c2, 0x65528455, 0xae04fff0, 0xf61205ee, 0x3d447e4b, - 0x463ff1d2, 0x8d698a77, 0xd57f7069, 0x1e290bcc, 0xae3db947, 0x656bc2e2, - 0x3d7d38fc, 0xf62b4359, 0x8d50ccc0, 0x4606b765, 0x1e104d7b, 0xd54636de, - 0xe8e75249, 0x23b129ec, 0x7ba7d3f2, 0xb0f1a857, 0xcb8a27ce, 0x00dc5c6b, - 0x58caa675, 0x939cddd0, 0x7a1f6b24, 0xb1491081, 0xe95fea9f, 0x2209913a, - 0x59721ea3, 0x92246506, 0xca329f18, 0x0164e4bd, 0x3cc5802a, 0xf793fb8f, - 0xaf850191, 0x64d37a34, 0x1fa8f5ad, 0xd4fe8e08, 0x8ce87416, 0x47be0fb3, - 0xf7aabd38, 0x3cfcc69d, 0x64ea3c83, 0xafbc4726, 0xd4c7c8bf, 0x1f91b31a, - 0x47874904, 0x8cd132a1, 0xb1705636, 0x7a262d93, 0x2230d78d, 0xe966ac28, - 0x921d23b1, 0x594b5814, 0x015da20a, 0xca0bd9af, 0x6498b1ed, 0xafceca48, - 0xf7d83056, 0x3c8e4bf3, 0x47f5c46a, 0x8ca3bfcf, 0xd4b545d1, 0x1fe33e74, - 0x22425ae3, 0xe9142146, 0xb102db58, 0x7a54a0fd, 0x012f2f64, 0xca7954c1, - 0x926faedf, 0x5939d57a, 0xe92d67f1, 0x227b1c54, 0x7a6de64a, 0xb13b9def, - 0xca401276, 0x011669d3, 0x590093cd, 0x9256e868, 0xaff78cff, 0x64a1f75a, - 0x3cb70d44, 0xf7e176e1, 0x8c9af978, 0x47cc82dd, 0x1fda78c3, 0xd48c0366, - 0x4710deb6, 0x8c46a513, 0xd4505f0d, 0x1f0624a8, 0x647dab31, 0xaf2bd094, - 0xf73d2a8a, 0x3c6b512f, 0x01ca35b8, 0xca9c4e1d, 0x928ab403, 0x59dccfa6, - 0x22a7403f, 0xe9f13b9a, 0xb1e7c184, 0x7ab1ba21, 0xcaa508aa, 0x01f3730f, - 0x59e58911, 0x92b3f2b4, 0xe9c87d2d, 0x229e0688, 0x7a88fc96, 0xb1de8733, - 0x8c7fe3a4, 0x47299801, 0x1f3f621f, 0xd46919ba, 0xaf129623, 0x6444ed86, - 0x3c521798, 0xf7046c3d, 0x5997047f, 0x92c17fda, 0xcad785c4, 0x0181fe61, - 0x7afa71f8, 0xb1ac0a5d, 0xe9baf043, 0x22ec8be6, 0x1f4def71, 0xd41b94d4, - 0x8c0d6eca, 0x475b156f, 0x3c209af6, 0xf776e153, 0xaf601b4d, 0x643660e8, - 0xd422d263, 0x1f74a9c6, 0x476253d8, 0x8c34287d, 0xf74fa7e4, 0x3c19dc41, - 0x640f265f, 0xaf595dfa, 0x92f8396d, 0x59ae42c8, 0x01b8b8d6, 0xcaeec373, + {0x00000000, 0xcb567ba5, 0x934081bb, 0x5816fa1e, 0x236d7587, 0xe83b0e22, 0xb02df43c, 0x7b7b8f99, 0x46daeb0e, + 0x8d8c90ab, 0xd59a6ab5, 0x1ecc1110, 0x65b79e89, 0xaee1e52c, 0xf6f71f32, 0x3da16497, 0x8db5d61c, 0x46e3adb9, + 0x1ef557a7, 0xd5a32c02, 0xaed8a39b, 0x658ed83e, 0x3d982220, 0xf6ce5985, 0xcb6f3d12, 0x003946b7, 0x582fbca9, + 0x9379c70c, 0xe8024895, 0x23543330, 0x7b42c92e, 0xb014b28b, 0x1e87dac9, 0xd5d1a16c, 0x8dc75b72, 0x469120d7, + 0x3deaaf4e, 0xf6bcd4eb, 0xaeaa2ef5, 0x65fc5550, 0x585d31c7, 0x930b4a62, 0xcb1db07c, 0x004bcbd9, 0x7b304440, + 0xb0663fe5, 0xe870c5fb, 0x2326be5e, 0x93320cd5, 0x58647770, 0x00728d6e, 0xcb24f6cb, 0xb05f7952, 0x7b0902f7, + 0x231ff8e9, 0xe849834c, 0xd5e8e7db, 0x1ebe9c7e, 0x46a86660, 0x8dfe1dc5, 0xf685925c, 0x3dd3e9f9, 0x65c513e7, + 0xae936842, 0x3d0fb592, 0xf659ce37, 0xae4f3429, 0x65194f8c, 0x1e62c015, 0xd534bbb0, 0x8d2241ae, 0x46743a0b, + 0x7bd55e9c, 0xb0832539, 0xe895df27, 0x23c3a482, 0x58b82b1b, 0x93ee50be, 0xcbf8aaa0, 0x00aed105, 0xb0ba638e, + 0x7bec182b, 0x23fae235, 0xe8ac9990, 0x93d71609, 0x58816dac, 0x009797b2, 0xcbc1ec17, 0xf6608880, 0x3d36f325, + 0x6520093b, 0xae76729e, 0xd50dfd07, 0x1e5b86a2, 0x464d7cbc, 0x8d1b0719, 0x23886f5b, 0xe8de14fe, 0xb0c8eee0, + 0x7b9e9545, 0x00e51adc, 0xcbb36179, 0x93a59b67, 0x58f3e0c2, 0x65528455, 0xae04fff0, 0xf61205ee, 0x3d447e4b, + 0x463ff1d2, 0x8d698a77, 0xd57f7069, 0x1e290bcc, 0xae3db947, 0x656bc2e2, 0x3d7d38fc, 0xf62b4359, 0x8d50ccc0, + 0x4606b765, 0x1e104d7b, 0xd54636de, 0xe8e75249, 0x23b129ec, 0x7ba7d3f2, 0xb0f1a857, 0xcb8a27ce, 0x00dc5c6b, + 0x58caa675, 0x939cddd0, 0x7a1f6b24, 0xb1491081, 0xe95fea9f, 0x2209913a, 0x59721ea3, 0x92246506, 0xca329f18, + 0x0164e4bd, 0x3cc5802a, 0xf793fb8f, 0xaf850191, 0x64d37a34, 0x1fa8f5ad, 0xd4fe8e08, 0x8ce87416, 0x47be0fb3, + 0xf7aabd38, 0x3cfcc69d, 0x64ea3c83, 0xafbc4726, 0xd4c7c8bf, 0x1f91b31a, 0x47874904, 0x8cd132a1, 0xb1705636, + 0x7a262d93, 0x2230d78d, 0xe966ac28, 0x921d23b1, 0x594b5814, 0x015da20a, 0xca0bd9af, 0x6498b1ed, 0xafceca48, + 0xf7d83056, 0x3c8e4bf3, 0x47f5c46a, 0x8ca3bfcf, 0xd4b545d1, 0x1fe33e74, 0x22425ae3, 0xe9142146, 0xb102db58, + 0x7a54a0fd, 0x012f2f64, 0xca7954c1, 0x926faedf, 0x5939d57a, 0xe92d67f1, 0x227b1c54, 0x7a6de64a, 0xb13b9def, + 0xca401276, 0x011669d3, 0x590093cd, 0x9256e868, 0xaff78cff, 0x64a1f75a, 0x3cb70d44, 0xf7e176e1, 0x8c9af978, + 0x47cc82dd, 0x1fda78c3, 0xd48c0366, 0x4710deb6, 0x8c46a513, 0xd4505f0d, 0x1f0624a8, 0x647dab31, 0xaf2bd094, + 0xf73d2a8a, 0x3c6b512f, 0x01ca35b8, 0xca9c4e1d, 0x928ab403, 0x59dccfa6, 0x22a7403f, 0xe9f13b9a, 0xb1e7c184, + 0x7ab1ba21, 0xcaa508aa, 0x01f3730f, 0x59e58911, 0x92b3f2b4, 0xe9c87d2d, 0x229e0688, 0x7a88fc96, 0xb1de8733, + 0x8c7fe3a4, 0x47299801, 0x1f3f621f, 0xd46919ba, 0xaf129623, 0x6444ed86, 0x3c521798, 0xf7046c3d, 0x5997047f, + 0x92c17fda, 0xcad785c4, 0x0181fe61, 0x7afa71f8, 0xb1ac0a5d, 0xe9baf043, 0x22ec8be6, 0x1f4def71, 0xd41b94d4, + 0x8c0d6eca, 0x475b156f, 0x3c209af6, 0xf776e153, 0xaf601b4d, 0x643660e8, 0xd422d263, 0x1f74a9c6, 0x476253d8, + 0x8c34287d, 0xf74fa7e4, 0x3c19dc41, 0x640f265f, 0xaf595dfa, 0x92f8396d, 0x59ae42c8, 0x01b8b8d6, 0xcaeec373, 0xb1954cea, 0x7ac3374f, 0x22d5cd51, 0xe983b6f4}, - {0x00000000, 0x9771f7c1, 0x2b0f9973, 0xbc7e6eb2, 0x561f32e6, 0xc16ec527, - 0x7d10ab95, 0xea615c54, 0xac3e65cc, 0x3b4f920d, 0x8731fcbf, 0x10400b7e, - 0xfa21572a, 0x6d50a0eb, 0xd12ece59, 0x465f3998, 0x5d90bd69, 0xcae14aa8, - 0x769f241a, 0xe1eed3db, 0x0b8f8f8f, 0x9cfe784e, 0x208016fc, 0xb7f1e13d, - 0xf1aed8a5, 0x66df2f64, 0xdaa141d6, 0x4dd0b617, 0xa7b1ea43, 0x30c01d82, - 0x8cbe7330, 0x1bcf84f1, 0xbb217ad2, 0x2c508d13, 0x902ee3a1, 0x075f1460, - 0xed3e4834, 0x7a4fbff5, 0xc631d147, 0x51402686, 0x171f1f1e, 0x806ee8df, - 0x3c10866d, 0xab6171ac, 0x41002df8, 0xd671da39, 0x6a0fb48b, 0xfd7e434a, - 0xe6b1c7bb, 0x71c0307a, 0xcdbe5ec8, 0x5acfa909, 0xb0aef55d, 0x27df029c, - 0x9ba16c2e, 0x0cd09bef, 0x4a8fa277, 0xddfe55b6, 0x61803b04, 0xf6f1ccc5, - 0x1c909091, 0x8be16750, 0x379f09e2, 0xa0eefe23, 0x73ae8355, 0xe4df7494, - 0x58a11a26, 0xcfd0ede7, 0x25b1b1b3, 0xb2c04672, 0x0ebe28c0, 0x99cfdf01, - 0xdf90e699, 0x48e11158, 0xf49f7fea, 0x63ee882b, 0x898fd47f, 0x1efe23be, - 0xa2804d0c, 0x35f1bacd, 0x2e3e3e3c, 0xb94fc9fd, 0x0531a74f, 0x9240508e, - 0x78210cda, 0xef50fb1b, 0x532e95a9, 0xc45f6268, 0x82005bf0, 0x1571ac31, - 0xa90fc283, 0x3e7e3542, 0xd41f6916, 0x436e9ed7, 0xff10f065, 0x686107a4, - 0xc88ff987, 0x5ffe0e46, 0xe38060f4, 0x74f19735, 0x9e90cb61, 0x09e13ca0, - 0xb59f5212, 0x22eea5d3, 0x64b19c4b, 0xf3c06b8a, 0x4fbe0538, 0xd8cff2f9, - 0x32aeaead, 0xa5df596c, 0x19a137de, 0x8ed0c01f, 0x951f44ee, 0x026eb32f, - 0xbe10dd9d, 0x29612a5c, 0xc3007608, 0x547181c9, 0xe80fef7b, 0x7f7e18ba, - 0x39212122, 0xae50d6e3, 0x122eb851, 0x855f4f90, 0x6f3e13c4, 0xf84fe405, - 0x44318ab7, 0xd3407d76, 0xe75d06aa, 0x702cf16b, 0xcc529fd9, 0x5b236818, - 0xb142344c, 0x2633c38d, 0x9a4dad3f, 0x0d3c5afe, 0x4b636366, 0xdc1294a7, - 0x606cfa15, 0xf71d0dd4, 0x1d7c5180, 0x8a0da641, 0x3673c8f3, 0xa1023f32, - 0xbacdbbc3, 0x2dbc4c02, 0x91c222b0, 0x06b3d571, 0xecd28925, 0x7ba37ee4, - 0xc7dd1056, 0x50ace797, 0x16f3de0f, 0x818229ce, 0x3dfc477c, 0xaa8db0bd, - 0x40ecece9, 0xd79d1b28, 0x6be3759a, 0xfc92825b, 0x5c7c7c78, 0xcb0d8bb9, - 0x7773e50b, 0xe00212ca, 0x0a634e9e, 0x9d12b95f, 0x216cd7ed, 0xb61d202c, - 0xf04219b4, 0x6733ee75, 0xdb4d80c7, 0x4c3c7706, 0xa65d2b52, 0x312cdc93, - 0x8d52b221, 0x1a2345e0, 0x01ecc111, 0x969d36d0, 0x2ae35862, 0xbd92afa3, - 0x57f3f3f7, 0xc0820436, 0x7cfc6a84, 0xeb8d9d45, 0xadd2a4dd, 0x3aa3531c, - 0x86dd3dae, 0x11acca6f, 0xfbcd963b, 0x6cbc61fa, 0xd0c20f48, 0x47b3f889, - 0x94f385ff, 0x0382723e, 0xbffc1c8c, 0x288deb4d, 0xc2ecb719, 0x559d40d8, - 0xe9e32e6a, 0x7e92d9ab, 0x38cde033, 0xafbc17f2, 0x13c27940, 0x84b38e81, - 0x6ed2d2d5, 0xf9a32514, 0x45dd4ba6, 0xd2acbc67, 0xc9633896, 0x5e12cf57, - 0xe26ca1e5, 0x751d5624, 0x9f7c0a70, 0x080dfdb1, 0xb4739303, 0x230264c2, - 0x655d5d5a, 0xf22caa9b, 0x4e52c429, 0xd92333e8, 0x33426fbc, 0xa433987d, - 0x184df6cf, 0x8f3c010e, 0x2fd2ff2d, 0xb8a308ec, 0x04dd665e, 0x93ac919f, - 0x79cdcdcb, 0xeebc3a0a, 0x52c254b8, 0xc5b3a379, 0x83ec9ae1, 0x149d6d20, - 0xa8e30392, 0x3f92f453, 0xd5f3a807, 0x42825fc6, 0xfefc3174, 0x698dc6b5, - 0x72424244, 0xe533b585, 0x594ddb37, 0xce3c2cf6, 0x245d70a2, 0xb32c8763, - 0x0f52e9d1, 0x98231e10, 0xde7c2788, 0x490dd049, 0xf573befb, 0x6202493a, + {0x00000000, 0x9771f7c1, 0x2b0f9973, 0xbc7e6eb2, 0x561f32e6, 0xc16ec527, 0x7d10ab95, 0xea615c54, 0xac3e65cc, + 0x3b4f920d, 0x8731fcbf, 0x10400b7e, 0xfa21572a, 0x6d50a0eb, 0xd12ece59, 0x465f3998, 0x5d90bd69, 0xcae14aa8, + 0x769f241a, 0xe1eed3db, 0x0b8f8f8f, 0x9cfe784e, 0x208016fc, 0xb7f1e13d, 0xf1aed8a5, 0x66df2f64, 0xdaa141d6, + 0x4dd0b617, 0xa7b1ea43, 0x30c01d82, 0x8cbe7330, 0x1bcf84f1, 0xbb217ad2, 0x2c508d13, 0x902ee3a1, 0x075f1460, + 0xed3e4834, 0x7a4fbff5, 0xc631d147, 0x51402686, 0x171f1f1e, 0x806ee8df, 0x3c10866d, 0xab6171ac, 0x41002df8, + 0xd671da39, 0x6a0fb48b, 0xfd7e434a, 0xe6b1c7bb, 0x71c0307a, 0xcdbe5ec8, 0x5acfa909, 0xb0aef55d, 0x27df029c, + 0x9ba16c2e, 0x0cd09bef, 0x4a8fa277, 0xddfe55b6, 0x61803b04, 0xf6f1ccc5, 0x1c909091, 0x8be16750, 0x379f09e2, + 0xa0eefe23, 0x73ae8355, 0xe4df7494, 0x58a11a26, 0xcfd0ede7, 0x25b1b1b3, 0xb2c04672, 0x0ebe28c0, 0x99cfdf01, + 0xdf90e699, 0x48e11158, 0xf49f7fea, 0x63ee882b, 0x898fd47f, 0x1efe23be, 0xa2804d0c, 0x35f1bacd, 0x2e3e3e3c, + 0xb94fc9fd, 0x0531a74f, 0x9240508e, 0x78210cda, 0xef50fb1b, 0x532e95a9, 0xc45f6268, 0x82005bf0, 0x1571ac31, + 0xa90fc283, 0x3e7e3542, 0xd41f6916, 0x436e9ed7, 0xff10f065, 0x686107a4, 0xc88ff987, 0x5ffe0e46, 0xe38060f4, + 0x74f19735, 0x9e90cb61, 0x09e13ca0, 0xb59f5212, 0x22eea5d3, 0x64b19c4b, 0xf3c06b8a, 0x4fbe0538, 0xd8cff2f9, + 0x32aeaead, 0xa5df596c, 0x19a137de, 0x8ed0c01f, 0x951f44ee, 0x026eb32f, 0xbe10dd9d, 0x29612a5c, 0xc3007608, + 0x547181c9, 0xe80fef7b, 0x7f7e18ba, 0x39212122, 0xae50d6e3, 0x122eb851, 0x855f4f90, 0x6f3e13c4, 0xf84fe405, + 0x44318ab7, 0xd3407d76, 0xe75d06aa, 0x702cf16b, 0xcc529fd9, 0x5b236818, 0xb142344c, 0x2633c38d, 0x9a4dad3f, + 0x0d3c5afe, 0x4b636366, 0xdc1294a7, 0x606cfa15, 0xf71d0dd4, 0x1d7c5180, 0x8a0da641, 0x3673c8f3, 0xa1023f32, + 0xbacdbbc3, 0x2dbc4c02, 0x91c222b0, 0x06b3d571, 0xecd28925, 0x7ba37ee4, 0xc7dd1056, 0x50ace797, 0x16f3de0f, + 0x818229ce, 0x3dfc477c, 0xaa8db0bd, 0x40ecece9, 0xd79d1b28, 0x6be3759a, 0xfc92825b, 0x5c7c7c78, 0xcb0d8bb9, + 0x7773e50b, 0xe00212ca, 0x0a634e9e, 0x9d12b95f, 0x216cd7ed, 0xb61d202c, 0xf04219b4, 0x6733ee75, 0xdb4d80c7, + 0x4c3c7706, 0xa65d2b52, 0x312cdc93, 0x8d52b221, 0x1a2345e0, 0x01ecc111, 0x969d36d0, 0x2ae35862, 0xbd92afa3, + 0x57f3f3f7, 0xc0820436, 0x7cfc6a84, 0xeb8d9d45, 0xadd2a4dd, 0x3aa3531c, 0x86dd3dae, 0x11acca6f, 0xfbcd963b, + 0x6cbc61fa, 0xd0c20f48, 0x47b3f889, 0x94f385ff, 0x0382723e, 0xbffc1c8c, 0x288deb4d, 0xc2ecb719, 0x559d40d8, + 0xe9e32e6a, 0x7e92d9ab, 0x38cde033, 0xafbc17f2, 0x13c27940, 0x84b38e81, 0x6ed2d2d5, 0xf9a32514, 0x45dd4ba6, + 0xd2acbc67, 0xc9633896, 0x5e12cf57, 0xe26ca1e5, 0x751d5624, 0x9f7c0a70, 0x080dfdb1, 0xb4739303, 0x230264c2, + 0x655d5d5a, 0xf22caa9b, 0x4e52c429, 0xd92333e8, 0x33426fbc, 0xa433987d, 0x184df6cf, 0x8f3c010e, 0x2fd2ff2d, + 0xb8a308ec, 0x04dd665e, 0x93ac919f, 0x79cdcdcb, 0xeebc3a0a, 0x52c254b8, 0xc5b3a379, 0x83ec9ae1, 0x149d6d20, + 0xa8e30392, 0x3f92f453, 0xd5f3a807, 0x42825fc6, 0xfefc3174, 0x698dc6b5, 0x72424244, 0xe533b585, 0x594ddb37, + 0xce3c2cf6, 0x245d70a2, 0xb32c8763, 0x0f52e9d1, 0x98231e10, 0xde7c2788, 0x490dd049, 0xf573befb, 0x6202493a, 0x8863156e, 0x1f12e2af, 0xa36c8c1d, 0x341d7bdc}, - {0x00000000, 0x3171d430, 0x62e3a860, 0x53927c50, 0xc5c750c0, 0xf4b684f0, - 0xa724f8a0, 0x96552c90, 0x8e62d771, 0xbf130341, 0xec817f11, 0xddf0ab21, - 0x4ba587b1, 0x7ad45381, 0x29462fd1, 0x1837fbe1, 0x1929d813, 0x28580c23, - 0x7bca7073, 0x4abba443, 0xdcee88d3, 0xed9f5ce3, 0xbe0d20b3, 0x8f7cf483, - 0x974b0f62, 0xa63adb52, 0xf5a8a702, 0xc4d97332, 0x528c5fa2, 0x63fd8b92, - 0x306ff7c2, 0x011e23f2, 0x3253b026, 0x03226416, 0x50b01846, 0x61c1cc76, - 0xf794e0e6, 0xc6e534d6, 0x95774886, 0xa4069cb6, 0xbc316757, 0x8d40b367, - 0xded2cf37, 0xefa31b07, 0x79f63797, 0x4887e3a7, 0x1b159ff7, 0x2a644bc7, - 0x2b7a6835, 0x1a0bbc05, 0x4999c055, 0x78e81465, 0xeebd38f5, 0xdfccecc5, - 0x8c5e9095, 0xbd2f44a5, 0xa518bf44, 0x94696b74, 0xc7fb1724, 0xf68ac314, - 0x60dfef84, 0x51ae3bb4, 0x023c47e4, 0x334d93d4, 0x64a7604c, 0x55d6b47c, - 0x0644c82c, 0x37351c1c, 0xa160308c, 0x9011e4bc, 0xc38398ec, 0xf2f24cdc, - 0xeac5b73d, 0xdbb4630d, 0x88261f5d, 0xb957cb6d, 0x2f02e7fd, 0x1e7333cd, - 0x4de14f9d, 0x7c909bad, 0x7d8eb85f, 0x4cff6c6f, 0x1f6d103f, 0x2e1cc40f, - 0xb849e89f, 0x89383caf, 0xdaaa40ff, 0xebdb94cf, 0xf3ec6f2e, 0xc29dbb1e, - 0x910fc74e, 0xa07e137e, 0x362b3fee, 0x075aebde, 0x54c8978e, 0x65b943be, - 0x56f4d06a, 0x6785045a, 0x3417780a, 0x0566ac3a, 0x933380aa, 0xa242549a, - 0xf1d028ca, 0xc0a1fcfa, 0xd896071b, 0xe9e7d32b, 0xba75af7b, 0x8b047b4b, - 0x1d5157db, 0x2c2083eb, 0x7fb2ffbb, 0x4ec32b8b, 0x4fdd0879, 0x7eacdc49, - 0x2d3ea019, 0x1c4f7429, 0x8a1a58b9, 0xbb6b8c89, 0xe8f9f0d9, 0xd98824e9, - 0xc1bfdf08, 0xf0ce0b38, 0xa35c7768, 0x922da358, 0x04788fc8, 0x35095bf8, - 0x669b27a8, 0x57eaf398, 0xc94ec098, 0xf83f14a8, 0xabad68f8, 0x9adcbcc8, - 0x0c899058, 0x3df84468, 0x6e6a3838, 0x5f1bec08, 0x472c17e9, 0x765dc3d9, - 0x25cfbf89, 0x14be6bb9, 0x82eb4729, 0xb39a9319, 0xe008ef49, 0xd1793b79, - 0xd067188b, 0xe116ccbb, 0xb284b0eb, 0x83f564db, 0x15a0484b, 0x24d19c7b, - 0x7743e02b, 0x4632341b, 0x5e05cffa, 0x6f741bca, 0x3ce6679a, 0x0d97b3aa, - 0x9bc29f3a, 0xaab34b0a, 0xf921375a, 0xc850e36a, 0xfb1d70be, 0xca6ca48e, - 0x99fed8de, 0xa88f0cee, 0x3eda207e, 0x0fabf44e, 0x5c39881e, 0x6d485c2e, - 0x757fa7cf, 0x440e73ff, 0x179c0faf, 0x26eddb9f, 0xb0b8f70f, 0x81c9233f, - 0xd25b5f6f, 0xe32a8b5f, 0xe234a8ad, 0xd3457c9d, 0x80d700cd, 0xb1a6d4fd, - 0x27f3f86d, 0x16822c5d, 0x4510500d, 0x7461843d, 0x6c567fdc, 0x5d27abec, - 0x0eb5d7bc, 0x3fc4038c, 0xa9912f1c, 0x98e0fb2c, 0xcb72877c, 0xfa03534c, - 0xade9a0d4, 0x9c9874e4, 0xcf0a08b4, 0xfe7bdc84, 0x682ef014, 0x595f2424, - 0x0acd5874, 0x3bbc8c44, 0x238b77a5, 0x12faa395, 0x4168dfc5, 0x70190bf5, - 0xe64c2765, 0xd73df355, 0x84af8f05, 0xb5de5b35, 0xb4c078c7, 0x85b1acf7, - 0xd623d0a7, 0xe7520497, 0x71072807, 0x4076fc37, 0x13e48067, 0x22955457, - 0x3aa2afb6, 0x0bd37b86, 0x584107d6, 0x6930d3e6, 0xff65ff76, 0xce142b46, - 0x9d865716, 0xacf78326, 0x9fba10f2, 0xaecbc4c2, 0xfd59b892, 0xcc286ca2, - 0x5a7d4032, 0x6b0c9402, 0x389ee852, 0x09ef3c62, 0x11d8c783, 0x20a913b3, - 0x733b6fe3, 0x424abbd3, 0xd41f9743, 0xe56e4373, 0xb6fc3f23, 0x878deb13, - 0x8693c8e1, 0xb7e21cd1, 0xe4706081, 0xd501b4b1, 0x43549821, 0x72254c11, - 0x21b73041, 0x10c6e471, 0x08f11f90, 0x3980cba0, 0x6a12b7f0, 0x5b6363c0, + {0x00000000, 0x3171d430, 0x62e3a860, 0x53927c50, 0xc5c750c0, 0xf4b684f0, 0xa724f8a0, 0x96552c90, 0x8e62d771, + 0xbf130341, 0xec817f11, 0xddf0ab21, 0x4ba587b1, 0x7ad45381, 0x29462fd1, 0x1837fbe1, 0x1929d813, 0x28580c23, + 0x7bca7073, 0x4abba443, 0xdcee88d3, 0xed9f5ce3, 0xbe0d20b3, 0x8f7cf483, 0x974b0f62, 0xa63adb52, 0xf5a8a702, + 0xc4d97332, 0x528c5fa2, 0x63fd8b92, 0x306ff7c2, 0x011e23f2, 0x3253b026, 0x03226416, 0x50b01846, 0x61c1cc76, + 0xf794e0e6, 0xc6e534d6, 0x95774886, 0xa4069cb6, 0xbc316757, 0x8d40b367, 0xded2cf37, 0xefa31b07, 0x79f63797, + 0x4887e3a7, 0x1b159ff7, 0x2a644bc7, 0x2b7a6835, 0x1a0bbc05, 0x4999c055, 0x78e81465, 0xeebd38f5, 0xdfccecc5, + 0x8c5e9095, 0xbd2f44a5, 0xa518bf44, 0x94696b74, 0xc7fb1724, 0xf68ac314, 0x60dfef84, 0x51ae3bb4, 0x023c47e4, + 0x334d93d4, 0x64a7604c, 0x55d6b47c, 0x0644c82c, 0x37351c1c, 0xa160308c, 0x9011e4bc, 0xc38398ec, 0xf2f24cdc, + 0xeac5b73d, 0xdbb4630d, 0x88261f5d, 0xb957cb6d, 0x2f02e7fd, 0x1e7333cd, 0x4de14f9d, 0x7c909bad, 0x7d8eb85f, + 0x4cff6c6f, 0x1f6d103f, 0x2e1cc40f, 0xb849e89f, 0x89383caf, 0xdaaa40ff, 0xebdb94cf, 0xf3ec6f2e, 0xc29dbb1e, + 0x910fc74e, 0xa07e137e, 0x362b3fee, 0x075aebde, 0x54c8978e, 0x65b943be, 0x56f4d06a, 0x6785045a, 0x3417780a, + 0x0566ac3a, 0x933380aa, 0xa242549a, 0xf1d028ca, 0xc0a1fcfa, 0xd896071b, 0xe9e7d32b, 0xba75af7b, 0x8b047b4b, + 0x1d5157db, 0x2c2083eb, 0x7fb2ffbb, 0x4ec32b8b, 0x4fdd0879, 0x7eacdc49, 0x2d3ea019, 0x1c4f7429, 0x8a1a58b9, + 0xbb6b8c89, 0xe8f9f0d9, 0xd98824e9, 0xc1bfdf08, 0xf0ce0b38, 0xa35c7768, 0x922da358, 0x04788fc8, 0x35095bf8, + 0x669b27a8, 0x57eaf398, 0xc94ec098, 0xf83f14a8, 0xabad68f8, 0x9adcbcc8, 0x0c899058, 0x3df84468, 0x6e6a3838, + 0x5f1bec08, 0x472c17e9, 0x765dc3d9, 0x25cfbf89, 0x14be6bb9, 0x82eb4729, 0xb39a9319, 0xe008ef49, 0xd1793b79, + 0xd067188b, 0xe116ccbb, 0xb284b0eb, 0x83f564db, 0x15a0484b, 0x24d19c7b, 0x7743e02b, 0x4632341b, 0x5e05cffa, + 0x6f741bca, 0x3ce6679a, 0x0d97b3aa, 0x9bc29f3a, 0xaab34b0a, 0xf921375a, 0xc850e36a, 0xfb1d70be, 0xca6ca48e, + 0x99fed8de, 0xa88f0cee, 0x3eda207e, 0x0fabf44e, 0x5c39881e, 0x6d485c2e, 0x757fa7cf, 0x440e73ff, 0x179c0faf, + 0x26eddb9f, 0xb0b8f70f, 0x81c9233f, 0xd25b5f6f, 0xe32a8b5f, 0xe234a8ad, 0xd3457c9d, 0x80d700cd, 0xb1a6d4fd, + 0x27f3f86d, 0x16822c5d, 0x4510500d, 0x7461843d, 0x6c567fdc, 0x5d27abec, 0x0eb5d7bc, 0x3fc4038c, 0xa9912f1c, + 0x98e0fb2c, 0xcb72877c, 0xfa03534c, 0xade9a0d4, 0x9c9874e4, 0xcf0a08b4, 0xfe7bdc84, 0x682ef014, 0x595f2424, + 0x0acd5874, 0x3bbc8c44, 0x238b77a5, 0x12faa395, 0x4168dfc5, 0x70190bf5, 0xe64c2765, 0xd73df355, 0x84af8f05, + 0xb5de5b35, 0xb4c078c7, 0x85b1acf7, 0xd623d0a7, 0xe7520497, 0x71072807, 0x4076fc37, 0x13e48067, 0x22955457, + 0x3aa2afb6, 0x0bd37b86, 0x584107d6, 0x6930d3e6, 0xff65ff76, 0xce142b46, 0x9d865716, 0xacf78326, 0x9fba10f2, + 0xaecbc4c2, 0xfd59b892, 0xcc286ca2, 0x5a7d4032, 0x6b0c9402, 0x389ee852, 0x09ef3c62, 0x11d8c783, 0x20a913b3, + 0x733b6fe3, 0x424abbd3, 0xd41f9743, 0xe56e4373, 0xb6fc3f23, 0x878deb13, 0x8693c8e1, 0xb7e21cd1, 0xe4706081, + 0xd501b4b1, 0x43549821, 0x72254c11, 0x21b73041, 0x10c6e471, 0x08f11f90, 0x3980cba0, 0x6a12b7f0, 0x5b6363c0, 0xcd364f50, 0xfc479b60, 0xafd5e730, 0x9ea43300}, - {0x00000000, 0x30d23865, 0x61a470ca, 0x517648af, 0xc348e194, 0xf39ad9f1, - 0xa2ec915e, 0x923ea93b, 0x837db5d9, 0xb3af8dbc, 0xe2d9c513, 0xd20bfd76, - 0x4035544d, 0x70e76c28, 0x21912487, 0x11431ce2, 0x03171d43, 0x33c52526, - 0x62b36d89, 0x526155ec, 0xc05ffcd7, 0xf08dc4b2, 0xa1fb8c1d, 0x9129b478, - 0x806aa89a, 0xb0b890ff, 0xe1ced850, 0xd11ce035, 0x4322490e, 0x73f0716b, - 0x228639c4, 0x125401a1, 0x062e3a86, 0x36fc02e3, 0x678a4a4c, 0x57587229, - 0xc566db12, 0xf5b4e377, 0xa4c2abd8, 0x941093bd, 0x85538f5f, 0xb581b73a, - 0xe4f7ff95, 0xd425c7f0, 0x461b6ecb, 0x76c956ae, 0x27bf1e01, 0x176d2664, - 0x053927c5, 0x35eb1fa0, 0x649d570f, 0x544f6f6a, 0xc671c651, 0xf6a3fe34, - 0xa7d5b69b, 0x97078efe, 0x8644921c, 0xb696aa79, 0xe7e0e2d6, 0xd732dab3, - 0x450c7388, 0x75de4bed, 0x24a80342, 0x147a3b27, 0x0c5c750c, 0x3c8e4d69, - 0x6df805c6, 0x5d2a3da3, 0xcf149498, 0xffc6acfd, 0xaeb0e452, 0x9e62dc37, - 0x8f21c0d5, 0xbff3f8b0, 0xee85b01f, 0xde57887a, 0x4c692141, 0x7cbb1924, - 0x2dcd518b, 0x1d1f69ee, 0x0f4b684f, 0x3f99502a, 0x6eef1885, 0x5e3d20e0, - 0xcc0389db, 0xfcd1b1be, 0xada7f911, 0x9d75c174, 0x8c36dd96, 0xbce4e5f3, - 0xed92ad5c, 0xdd409539, 0x4f7e3c02, 0x7fac0467, 0x2eda4cc8, 0x1e0874ad, - 0x0a724f8a, 0x3aa077ef, 0x6bd63f40, 0x5b040725, 0xc93aae1e, 0xf9e8967b, - 0xa89eded4, 0x984ce6b1, 0x890ffa53, 0xb9ddc236, 0xe8ab8a99, 0xd879b2fc, - 0x4a471bc7, 0x7a9523a2, 0x2be36b0d, 0x1b315368, 0x096552c9, 0x39b76aac, - 0x68c12203, 0x58131a66, 0xca2db35d, 0xfaff8b38, 0xab89c397, 0x9b5bfbf2, - 0x8a18e710, 0xbacadf75, 0xebbc97da, 0xdb6eafbf, 0x49500684, 0x79823ee1, - 0x28f4764e, 0x18264e2b, 0x18b8ea18, 0x286ad27d, 0x791c9ad2, 0x49cea2b7, - 0xdbf00b8c, 0xeb2233e9, 0xba547b46, 0x8a864323, 0x9bc55fc1, 0xab1767a4, - 0xfa612f0b, 0xcab3176e, 0x588dbe55, 0x685f8630, 0x3929ce9f, 0x09fbf6fa, - 0x1baff75b, 0x2b7dcf3e, 0x7a0b8791, 0x4ad9bff4, 0xd8e716cf, 0xe8352eaa, - 0xb9436605, 0x89915e60, 0x98d24282, 0xa8007ae7, 0xf9763248, 0xc9a40a2d, - 0x5b9aa316, 0x6b489b73, 0x3a3ed3dc, 0x0aecebb9, 0x1e96d09e, 0x2e44e8fb, - 0x7f32a054, 0x4fe09831, 0xddde310a, 0xed0c096f, 0xbc7a41c0, 0x8ca879a5, - 0x9deb6547, 0xad395d22, 0xfc4f158d, 0xcc9d2de8, 0x5ea384d3, 0x6e71bcb6, - 0x3f07f419, 0x0fd5cc7c, 0x1d81cddd, 0x2d53f5b8, 0x7c25bd17, 0x4cf78572, - 0xdec92c49, 0xee1b142c, 0xbf6d5c83, 0x8fbf64e6, 0x9efc7804, 0xae2e4061, - 0xff5808ce, 0xcf8a30ab, 0x5db49990, 0x6d66a1f5, 0x3c10e95a, 0x0cc2d13f, - 0x14e49f14, 0x2436a771, 0x7540efde, 0x4592d7bb, 0xd7ac7e80, 0xe77e46e5, - 0xb6080e4a, 0x86da362f, 0x97992acd, 0xa74b12a8, 0xf63d5a07, 0xc6ef6262, - 0x54d1cb59, 0x6403f33c, 0x3575bb93, 0x05a783f6, 0x17f38257, 0x2721ba32, - 0x7657f29d, 0x4685caf8, 0xd4bb63c3, 0xe4695ba6, 0xb51f1309, 0x85cd2b6c, - 0x948e378e, 0xa45c0feb, 0xf52a4744, 0xc5f87f21, 0x57c6d61a, 0x6714ee7f, - 0x3662a6d0, 0x06b09eb5, 0x12caa592, 0x22189df7, 0x736ed558, 0x43bced3d, - 0xd1824406, 0xe1507c63, 0xb02634cc, 0x80f40ca9, 0x91b7104b, 0xa165282e, - 0xf0136081, 0xc0c158e4, 0x52fff1df, 0x622dc9ba, 0x335b8115, 0x0389b970, - 0x11ddb8d1, 0x210f80b4, 0x7079c81b, 0x40abf07e, 0xd2955945, 0xe2476120, - 0xb331298f, 0x83e311ea, 0x92a00d08, 0xa272356d, 0xf3047dc2, 0xc3d645a7, + {0x00000000, 0x30d23865, 0x61a470ca, 0x517648af, 0xc348e194, 0xf39ad9f1, 0xa2ec915e, 0x923ea93b, 0x837db5d9, + 0xb3af8dbc, 0xe2d9c513, 0xd20bfd76, 0x4035544d, 0x70e76c28, 0x21912487, 0x11431ce2, 0x03171d43, 0x33c52526, + 0x62b36d89, 0x526155ec, 0xc05ffcd7, 0xf08dc4b2, 0xa1fb8c1d, 0x9129b478, 0x806aa89a, 0xb0b890ff, 0xe1ced850, + 0xd11ce035, 0x4322490e, 0x73f0716b, 0x228639c4, 0x125401a1, 0x062e3a86, 0x36fc02e3, 0x678a4a4c, 0x57587229, + 0xc566db12, 0xf5b4e377, 0xa4c2abd8, 0x941093bd, 0x85538f5f, 0xb581b73a, 0xe4f7ff95, 0xd425c7f0, 0x461b6ecb, + 0x76c956ae, 0x27bf1e01, 0x176d2664, 0x053927c5, 0x35eb1fa0, 0x649d570f, 0x544f6f6a, 0xc671c651, 0xf6a3fe34, + 0xa7d5b69b, 0x97078efe, 0x8644921c, 0xb696aa79, 0xe7e0e2d6, 0xd732dab3, 0x450c7388, 0x75de4bed, 0x24a80342, + 0x147a3b27, 0x0c5c750c, 0x3c8e4d69, 0x6df805c6, 0x5d2a3da3, 0xcf149498, 0xffc6acfd, 0xaeb0e452, 0x9e62dc37, + 0x8f21c0d5, 0xbff3f8b0, 0xee85b01f, 0xde57887a, 0x4c692141, 0x7cbb1924, 0x2dcd518b, 0x1d1f69ee, 0x0f4b684f, + 0x3f99502a, 0x6eef1885, 0x5e3d20e0, 0xcc0389db, 0xfcd1b1be, 0xada7f911, 0x9d75c174, 0x8c36dd96, 0xbce4e5f3, + 0xed92ad5c, 0xdd409539, 0x4f7e3c02, 0x7fac0467, 0x2eda4cc8, 0x1e0874ad, 0x0a724f8a, 0x3aa077ef, 0x6bd63f40, + 0x5b040725, 0xc93aae1e, 0xf9e8967b, 0xa89eded4, 0x984ce6b1, 0x890ffa53, 0xb9ddc236, 0xe8ab8a99, 0xd879b2fc, + 0x4a471bc7, 0x7a9523a2, 0x2be36b0d, 0x1b315368, 0x096552c9, 0x39b76aac, 0x68c12203, 0x58131a66, 0xca2db35d, + 0xfaff8b38, 0xab89c397, 0x9b5bfbf2, 0x8a18e710, 0xbacadf75, 0xebbc97da, 0xdb6eafbf, 0x49500684, 0x79823ee1, + 0x28f4764e, 0x18264e2b, 0x18b8ea18, 0x286ad27d, 0x791c9ad2, 0x49cea2b7, 0xdbf00b8c, 0xeb2233e9, 0xba547b46, + 0x8a864323, 0x9bc55fc1, 0xab1767a4, 0xfa612f0b, 0xcab3176e, 0x588dbe55, 0x685f8630, 0x3929ce9f, 0x09fbf6fa, + 0x1baff75b, 0x2b7dcf3e, 0x7a0b8791, 0x4ad9bff4, 0xd8e716cf, 0xe8352eaa, 0xb9436605, 0x89915e60, 0x98d24282, + 0xa8007ae7, 0xf9763248, 0xc9a40a2d, 0x5b9aa316, 0x6b489b73, 0x3a3ed3dc, 0x0aecebb9, 0x1e96d09e, 0x2e44e8fb, + 0x7f32a054, 0x4fe09831, 0xddde310a, 0xed0c096f, 0xbc7a41c0, 0x8ca879a5, 0x9deb6547, 0xad395d22, 0xfc4f158d, + 0xcc9d2de8, 0x5ea384d3, 0x6e71bcb6, 0x3f07f419, 0x0fd5cc7c, 0x1d81cddd, 0x2d53f5b8, 0x7c25bd17, 0x4cf78572, + 0xdec92c49, 0xee1b142c, 0xbf6d5c83, 0x8fbf64e6, 0x9efc7804, 0xae2e4061, 0xff5808ce, 0xcf8a30ab, 0x5db49990, + 0x6d66a1f5, 0x3c10e95a, 0x0cc2d13f, 0x14e49f14, 0x2436a771, 0x7540efde, 0x4592d7bb, 0xd7ac7e80, 0xe77e46e5, + 0xb6080e4a, 0x86da362f, 0x97992acd, 0xa74b12a8, 0xf63d5a07, 0xc6ef6262, 0x54d1cb59, 0x6403f33c, 0x3575bb93, + 0x05a783f6, 0x17f38257, 0x2721ba32, 0x7657f29d, 0x4685caf8, 0xd4bb63c3, 0xe4695ba6, 0xb51f1309, 0x85cd2b6c, + 0x948e378e, 0xa45c0feb, 0xf52a4744, 0xc5f87f21, 0x57c6d61a, 0x6714ee7f, 0x3662a6d0, 0x06b09eb5, 0x12caa592, + 0x22189df7, 0x736ed558, 0x43bced3d, 0xd1824406, 0xe1507c63, 0xb02634cc, 0x80f40ca9, 0x91b7104b, 0xa165282e, + 0xf0136081, 0xc0c158e4, 0x52fff1df, 0x622dc9ba, 0x335b8115, 0x0389b970, 0x11ddb8d1, 0x210f80b4, 0x7079c81b, + 0x40abf07e, 0xd2955945, 0xe2476120, 0xb331298f, 0x83e311ea, 0x92a00d08, 0xa272356d, 0xf3047dc2, 0xc3d645a7, 0x51e8ec9c, 0x613ad4f9, 0x304c9c56, 0x009ea433}, - {0x00000000, 0x54075546, 0xa80eaa8c, 0xfc09ffca, 0x55f123e9, 0x01f676af, - 0xfdff8965, 0xa9f8dc23, 0xabe247d2, 0xffe51294, 0x03eced5e, 0x57ebb818, - 0xfe13643b, 0xaa14317d, 0x561dceb7, 0x021a9bf1, 0x5228f955, 0x062fac13, - 0xfa2653d9, 0xae21069f, 0x07d9dabc, 0x53de8ffa, 0xafd77030, 0xfbd02576, - 0xf9cabe87, 0xadcdebc1, 0x51c4140b, 0x05c3414d, 0xac3b9d6e, 0xf83cc828, - 0x043537e2, 0x503262a4, 0xa451f2aa, 0xf056a7ec, 0x0c5f5826, 0x58580d60, - 0xf1a0d143, 0xa5a78405, 0x59ae7bcf, 0x0da92e89, 0x0fb3b578, 0x5bb4e03e, - 0xa7bd1ff4, 0xf3ba4ab2, 0x5a429691, 0x0e45c3d7, 0xf24c3c1d, 0xa64b695b, - 0xf6790bff, 0xa27e5eb9, 0x5e77a173, 0x0a70f435, 0xa3882816, 0xf78f7d50, - 0x0b86829a, 0x5f81d7dc, 0x5d9b4c2d, 0x099c196b, 0xf595e6a1, 0xa192b3e7, - 0x086a6fc4, 0x5c6d3a82, 0xa064c548, 0xf463900e, 0x4d4f93a5, 0x1948c6e3, - 0xe5413929, 0xb1466c6f, 0x18beb04c, 0x4cb9e50a, 0xb0b01ac0, 0xe4b74f86, - 0xe6add477, 0xb2aa8131, 0x4ea37efb, 0x1aa42bbd, 0xb35cf79e, 0xe75ba2d8, - 0x1b525d12, 0x4f550854, 0x1f676af0, 0x4b603fb6, 0xb769c07c, 0xe36e953a, - 0x4a964919, 0x1e911c5f, 0xe298e395, 0xb69fb6d3, 0xb4852d22, 0xe0827864, - 0x1c8b87ae, 0x488cd2e8, 0xe1740ecb, 0xb5735b8d, 0x497aa447, 0x1d7df101, - 0xe91e610f, 0xbd193449, 0x4110cb83, 0x15179ec5, 0xbcef42e6, 0xe8e817a0, - 0x14e1e86a, 0x40e6bd2c, 0x42fc26dd, 0x16fb739b, 0xeaf28c51, 0xbef5d917, - 0x170d0534, 0x430a5072, 0xbf03afb8, 0xeb04fafe, 0xbb36985a, 0xef31cd1c, - 0x133832d6, 0x473f6790, 0xeec7bbb3, 0xbac0eef5, 0x46c9113f, 0x12ce4479, - 0x10d4df88, 0x44d38ace, 0xb8da7504, 0xecdd2042, 0x4525fc61, 0x1122a927, - 0xed2b56ed, 0xb92c03ab, 0x9a9f274a, 0xce98720c, 0x32918dc6, 0x6696d880, - 0xcf6e04a3, 0x9b6951e5, 0x6760ae2f, 0x3367fb69, 0x317d6098, 0x657a35de, - 0x9973ca14, 0xcd749f52, 0x648c4371, 0x308b1637, 0xcc82e9fd, 0x9885bcbb, - 0xc8b7de1f, 0x9cb08b59, 0x60b97493, 0x34be21d5, 0x9d46fdf6, 0xc941a8b0, - 0x3548577a, 0x614f023c, 0x635599cd, 0x3752cc8b, 0xcb5b3341, 0x9f5c6607, - 0x36a4ba24, 0x62a3ef62, 0x9eaa10a8, 0xcaad45ee, 0x3eced5e0, 0x6ac980a6, - 0x96c07f6c, 0xc2c72a2a, 0x6b3ff609, 0x3f38a34f, 0xc3315c85, 0x973609c3, - 0x952c9232, 0xc12bc774, 0x3d2238be, 0x69256df8, 0xc0ddb1db, 0x94dae49d, - 0x68d31b57, 0x3cd44e11, 0x6ce62cb5, 0x38e179f3, 0xc4e88639, 0x90efd37f, - 0x39170f5c, 0x6d105a1a, 0x9119a5d0, 0xc51ef096, 0xc7046b67, 0x93033e21, - 0x6f0ac1eb, 0x3b0d94ad, 0x92f5488e, 0xc6f21dc8, 0x3afbe202, 0x6efcb744, - 0xd7d0b4ef, 0x83d7e1a9, 0x7fde1e63, 0x2bd94b25, 0x82219706, 0xd626c240, - 0x2a2f3d8a, 0x7e2868cc, 0x7c32f33d, 0x2835a67b, 0xd43c59b1, 0x803b0cf7, - 0x29c3d0d4, 0x7dc48592, 0x81cd7a58, 0xd5ca2f1e, 0x85f84dba, 0xd1ff18fc, - 0x2df6e736, 0x79f1b270, 0xd0096e53, 0x840e3b15, 0x7807c4df, 0x2c009199, - 0x2e1a0a68, 0x7a1d5f2e, 0x8614a0e4, 0xd213f5a2, 0x7beb2981, 0x2fec7cc7, - 0xd3e5830d, 0x87e2d64b, 0x73814645, 0x27861303, 0xdb8fecc9, 0x8f88b98f, - 0x267065ac, 0x727730ea, 0x8e7ecf20, 0xda799a66, 0xd8630197, 0x8c6454d1, - 0x706dab1b, 0x246afe5d, 0x8d92227e, 0xd9957738, 0x259c88f2, 0x719bddb4, - 0x21a9bf10, 0x75aeea56, 0x89a7159c, 0xdda040da, 0x74589cf9, 0x205fc9bf, - 0xdc563675, 0x88516333, 0x8a4bf8c2, 0xde4cad84, 0x2245524e, 0x76420708, + {0x00000000, 0x54075546, 0xa80eaa8c, 0xfc09ffca, 0x55f123e9, 0x01f676af, 0xfdff8965, 0xa9f8dc23, 0xabe247d2, + 0xffe51294, 0x03eced5e, 0x57ebb818, 0xfe13643b, 0xaa14317d, 0x561dceb7, 0x021a9bf1, 0x5228f955, 0x062fac13, + 0xfa2653d9, 0xae21069f, 0x07d9dabc, 0x53de8ffa, 0xafd77030, 0xfbd02576, 0xf9cabe87, 0xadcdebc1, 0x51c4140b, + 0x05c3414d, 0xac3b9d6e, 0xf83cc828, 0x043537e2, 0x503262a4, 0xa451f2aa, 0xf056a7ec, 0x0c5f5826, 0x58580d60, + 0xf1a0d143, 0xa5a78405, 0x59ae7bcf, 0x0da92e89, 0x0fb3b578, 0x5bb4e03e, 0xa7bd1ff4, 0xf3ba4ab2, 0x5a429691, + 0x0e45c3d7, 0xf24c3c1d, 0xa64b695b, 0xf6790bff, 0xa27e5eb9, 0x5e77a173, 0x0a70f435, 0xa3882816, 0xf78f7d50, + 0x0b86829a, 0x5f81d7dc, 0x5d9b4c2d, 0x099c196b, 0xf595e6a1, 0xa192b3e7, 0x086a6fc4, 0x5c6d3a82, 0xa064c548, + 0xf463900e, 0x4d4f93a5, 0x1948c6e3, 0xe5413929, 0xb1466c6f, 0x18beb04c, 0x4cb9e50a, 0xb0b01ac0, 0xe4b74f86, + 0xe6add477, 0xb2aa8131, 0x4ea37efb, 0x1aa42bbd, 0xb35cf79e, 0xe75ba2d8, 0x1b525d12, 0x4f550854, 0x1f676af0, + 0x4b603fb6, 0xb769c07c, 0xe36e953a, 0x4a964919, 0x1e911c5f, 0xe298e395, 0xb69fb6d3, 0xb4852d22, 0xe0827864, + 0x1c8b87ae, 0x488cd2e8, 0xe1740ecb, 0xb5735b8d, 0x497aa447, 0x1d7df101, 0xe91e610f, 0xbd193449, 0x4110cb83, + 0x15179ec5, 0xbcef42e6, 0xe8e817a0, 0x14e1e86a, 0x40e6bd2c, 0x42fc26dd, 0x16fb739b, 0xeaf28c51, 0xbef5d917, + 0x170d0534, 0x430a5072, 0xbf03afb8, 0xeb04fafe, 0xbb36985a, 0xef31cd1c, 0x133832d6, 0x473f6790, 0xeec7bbb3, + 0xbac0eef5, 0x46c9113f, 0x12ce4479, 0x10d4df88, 0x44d38ace, 0xb8da7504, 0xecdd2042, 0x4525fc61, 0x1122a927, + 0xed2b56ed, 0xb92c03ab, 0x9a9f274a, 0xce98720c, 0x32918dc6, 0x6696d880, 0xcf6e04a3, 0x9b6951e5, 0x6760ae2f, + 0x3367fb69, 0x317d6098, 0x657a35de, 0x9973ca14, 0xcd749f52, 0x648c4371, 0x308b1637, 0xcc82e9fd, 0x9885bcbb, + 0xc8b7de1f, 0x9cb08b59, 0x60b97493, 0x34be21d5, 0x9d46fdf6, 0xc941a8b0, 0x3548577a, 0x614f023c, 0x635599cd, + 0x3752cc8b, 0xcb5b3341, 0x9f5c6607, 0x36a4ba24, 0x62a3ef62, 0x9eaa10a8, 0xcaad45ee, 0x3eced5e0, 0x6ac980a6, + 0x96c07f6c, 0xc2c72a2a, 0x6b3ff609, 0x3f38a34f, 0xc3315c85, 0x973609c3, 0x952c9232, 0xc12bc774, 0x3d2238be, + 0x69256df8, 0xc0ddb1db, 0x94dae49d, 0x68d31b57, 0x3cd44e11, 0x6ce62cb5, 0x38e179f3, 0xc4e88639, 0x90efd37f, + 0x39170f5c, 0x6d105a1a, 0x9119a5d0, 0xc51ef096, 0xc7046b67, 0x93033e21, 0x6f0ac1eb, 0x3b0d94ad, 0x92f5488e, + 0xc6f21dc8, 0x3afbe202, 0x6efcb744, 0xd7d0b4ef, 0x83d7e1a9, 0x7fde1e63, 0x2bd94b25, 0x82219706, 0xd626c240, + 0x2a2f3d8a, 0x7e2868cc, 0x7c32f33d, 0x2835a67b, 0xd43c59b1, 0x803b0cf7, 0x29c3d0d4, 0x7dc48592, 0x81cd7a58, + 0xd5ca2f1e, 0x85f84dba, 0xd1ff18fc, 0x2df6e736, 0x79f1b270, 0xd0096e53, 0x840e3b15, 0x7807c4df, 0x2c009199, + 0x2e1a0a68, 0x7a1d5f2e, 0x8614a0e4, 0xd213f5a2, 0x7beb2981, 0x2fec7cc7, 0xd3e5830d, 0x87e2d64b, 0x73814645, + 0x27861303, 0xdb8fecc9, 0x8f88b98f, 0x267065ac, 0x727730ea, 0x8e7ecf20, 0xda799a66, 0xd8630197, 0x8c6454d1, + 0x706dab1b, 0x246afe5d, 0x8d92227e, 0xd9957738, 0x259c88f2, 0x719bddb4, 0x21a9bf10, 0x75aeea56, 0x89a7159c, + 0xdda040da, 0x74589cf9, 0x205fc9bf, 0xdc563675, 0x88516333, 0x8a4bf8c2, 0xde4cad84, 0x2245524e, 0x76420708, 0xdfbadb2b, 0x8bbd8e6d, 0x77b471a7, 0x23b324e1}, - {0x00000000, 0x678efd01, 0xcf1dfa02, 0xa8930703, 0x9bd782f5, 0xfc597ff4, - 0x54ca78f7, 0x334485f6, 0x3243731b, 0x55cd8e1a, 0xfd5e8919, 0x9ad07418, - 0xa994f1ee, 0xce1a0cef, 0x66890bec, 0x0107f6ed, 0x6486e636, 0x03081b37, - 0xab9b1c34, 0xcc15e135, 0xff5164c3, 0x98df99c2, 0x304c9ec1, 0x57c263c0, - 0x56c5952d, 0x314b682c, 0x99d86f2f, 0xfe56922e, 0xcd1217d8, 0xaa9cead9, - 0x020fedda, 0x658110db, 0xc90dcc6c, 0xae83316d, 0x0610366e, 0x619ecb6f, - 0x52da4e99, 0x3554b398, 0x9dc7b49b, 0xfa49499a, 0xfb4ebf77, 0x9cc04276, - 0x34534575, 0x53ddb874, 0x60993d82, 0x0717c083, 0xaf84c780, 0xc80a3a81, - 0xad8b2a5a, 0xca05d75b, 0x6296d058, 0x05182d59, 0x365ca8af, 0x51d255ae, - 0xf94152ad, 0x9ecfafac, 0x9fc85941, 0xf846a440, 0x50d5a343, 0x375b5e42, - 0x041fdbb4, 0x639126b5, 0xcb0221b6, 0xac8cdcb7, 0x97f7ee29, 0xf0791328, - 0x58ea142b, 0x3f64e92a, 0x0c206cdc, 0x6bae91dd, 0xc33d96de, 0xa4b36bdf, - 0xa5b49d32, 0xc23a6033, 0x6aa96730, 0x0d279a31, 0x3e631fc7, 0x59ede2c6, - 0xf17ee5c5, 0x96f018c4, 0xf371081f, 0x94fff51e, 0x3c6cf21d, 0x5be20f1c, - 0x68a68aea, 0x0f2877eb, 0xa7bb70e8, 0xc0358de9, 0xc1327b04, 0xa6bc8605, - 0x0e2f8106, 0x69a17c07, 0x5ae5f9f1, 0x3d6b04f0, 0x95f803f3, 0xf276fef2, - 0x5efa2245, 0x3974df44, 0x91e7d847, 0xf6692546, 0xc52da0b0, 0xa2a35db1, - 0x0a305ab2, 0x6dbea7b3, 0x6cb9515e, 0x0b37ac5f, 0xa3a4ab5c, 0xc42a565d, - 0xf76ed3ab, 0x90e02eaa, 0x387329a9, 0x5ffdd4a8, 0x3a7cc473, 0x5df23972, - 0xf5613e71, 0x92efc370, 0xa1ab4686, 0xc625bb87, 0x6eb6bc84, 0x09384185, - 0x083fb768, 0x6fb14a69, 0xc7224d6a, 0xa0acb06b, 0x93e8359d, 0xf466c89c, - 0x5cf5cf9f, 0x3b7b329e, 0x2a03aaa3, 0x4d8d57a2, 0xe51e50a1, 0x8290ada0, - 0xb1d42856, 0xd65ad557, 0x7ec9d254, 0x19472f55, 0x1840d9b8, 0x7fce24b9, - 0xd75d23ba, 0xb0d3debb, 0x83975b4d, 0xe419a64c, 0x4c8aa14f, 0x2b045c4e, - 0x4e854c95, 0x290bb194, 0x8198b697, 0xe6164b96, 0xd552ce60, 0xb2dc3361, - 0x1a4f3462, 0x7dc1c963, 0x7cc63f8e, 0x1b48c28f, 0xb3dbc58c, 0xd455388d, - 0xe711bd7b, 0x809f407a, 0x280c4779, 0x4f82ba78, 0xe30e66cf, 0x84809bce, - 0x2c139ccd, 0x4b9d61cc, 0x78d9e43a, 0x1f57193b, 0xb7c41e38, 0xd04ae339, - 0xd14d15d4, 0xb6c3e8d5, 0x1e50efd6, 0x79de12d7, 0x4a9a9721, 0x2d146a20, - 0x85876d23, 0xe2099022, 0x878880f9, 0xe0067df8, 0x48957afb, 0x2f1b87fa, - 0x1c5f020c, 0x7bd1ff0d, 0xd342f80e, 0xb4cc050f, 0xb5cbf3e2, 0xd2450ee3, - 0x7ad609e0, 0x1d58f4e1, 0x2e1c7117, 0x49928c16, 0xe1018b15, 0x868f7614, - 0xbdf4448a, 0xda7ab98b, 0x72e9be88, 0x15674389, 0x2623c67f, 0x41ad3b7e, - 0xe93e3c7d, 0x8eb0c17c, 0x8fb73791, 0xe839ca90, 0x40aacd93, 0x27243092, - 0x1460b564, 0x73ee4865, 0xdb7d4f66, 0xbcf3b267, 0xd972a2bc, 0xbefc5fbd, - 0x166f58be, 0x71e1a5bf, 0x42a52049, 0x252bdd48, 0x8db8da4b, 0xea36274a, - 0xeb31d1a7, 0x8cbf2ca6, 0x242c2ba5, 0x43a2d6a4, 0x70e65352, 0x1768ae53, - 0xbffba950, 0xd8755451, 0x74f988e6, 0x137775e7, 0xbbe472e4, 0xdc6a8fe5, - 0xef2e0a13, 0x88a0f712, 0x2033f011, 0x47bd0d10, 0x46bafbfd, 0x213406fc, - 0x89a701ff, 0xee29fcfe, 0xdd6d7908, 0xbae38409, 0x1270830a, 0x75fe7e0b, - 0x107f6ed0, 0x77f193d1, 0xdf6294d2, 0xb8ec69d3, 0x8ba8ec25, 0xec261124, - 0x44b51627, 0x233beb26, 0x223c1dcb, 0x45b2e0ca, 0xed21e7c9, 0x8aaf1ac8, + {0x00000000, 0x678efd01, 0xcf1dfa02, 0xa8930703, 0x9bd782f5, 0xfc597ff4, 0x54ca78f7, 0x334485f6, 0x3243731b, + 0x55cd8e1a, 0xfd5e8919, 0x9ad07418, 0xa994f1ee, 0xce1a0cef, 0x66890bec, 0x0107f6ed, 0x6486e636, 0x03081b37, + 0xab9b1c34, 0xcc15e135, 0xff5164c3, 0x98df99c2, 0x304c9ec1, 0x57c263c0, 0x56c5952d, 0x314b682c, 0x99d86f2f, + 0xfe56922e, 0xcd1217d8, 0xaa9cead9, 0x020fedda, 0x658110db, 0xc90dcc6c, 0xae83316d, 0x0610366e, 0x619ecb6f, + 0x52da4e99, 0x3554b398, 0x9dc7b49b, 0xfa49499a, 0xfb4ebf77, 0x9cc04276, 0x34534575, 0x53ddb874, 0x60993d82, + 0x0717c083, 0xaf84c780, 0xc80a3a81, 0xad8b2a5a, 0xca05d75b, 0x6296d058, 0x05182d59, 0x365ca8af, 0x51d255ae, + 0xf94152ad, 0x9ecfafac, 0x9fc85941, 0xf846a440, 0x50d5a343, 0x375b5e42, 0x041fdbb4, 0x639126b5, 0xcb0221b6, + 0xac8cdcb7, 0x97f7ee29, 0xf0791328, 0x58ea142b, 0x3f64e92a, 0x0c206cdc, 0x6bae91dd, 0xc33d96de, 0xa4b36bdf, + 0xa5b49d32, 0xc23a6033, 0x6aa96730, 0x0d279a31, 0x3e631fc7, 0x59ede2c6, 0xf17ee5c5, 0x96f018c4, 0xf371081f, + 0x94fff51e, 0x3c6cf21d, 0x5be20f1c, 0x68a68aea, 0x0f2877eb, 0xa7bb70e8, 0xc0358de9, 0xc1327b04, 0xa6bc8605, + 0x0e2f8106, 0x69a17c07, 0x5ae5f9f1, 0x3d6b04f0, 0x95f803f3, 0xf276fef2, 0x5efa2245, 0x3974df44, 0x91e7d847, + 0xf6692546, 0xc52da0b0, 0xa2a35db1, 0x0a305ab2, 0x6dbea7b3, 0x6cb9515e, 0x0b37ac5f, 0xa3a4ab5c, 0xc42a565d, + 0xf76ed3ab, 0x90e02eaa, 0x387329a9, 0x5ffdd4a8, 0x3a7cc473, 0x5df23972, 0xf5613e71, 0x92efc370, 0xa1ab4686, + 0xc625bb87, 0x6eb6bc84, 0x09384185, 0x083fb768, 0x6fb14a69, 0xc7224d6a, 0xa0acb06b, 0x93e8359d, 0xf466c89c, + 0x5cf5cf9f, 0x3b7b329e, 0x2a03aaa3, 0x4d8d57a2, 0xe51e50a1, 0x8290ada0, 0xb1d42856, 0xd65ad557, 0x7ec9d254, + 0x19472f55, 0x1840d9b8, 0x7fce24b9, 0xd75d23ba, 0xb0d3debb, 0x83975b4d, 0xe419a64c, 0x4c8aa14f, 0x2b045c4e, + 0x4e854c95, 0x290bb194, 0x8198b697, 0xe6164b96, 0xd552ce60, 0xb2dc3361, 0x1a4f3462, 0x7dc1c963, 0x7cc63f8e, + 0x1b48c28f, 0xb3dbc58c, 0xd455388d, 0xe711bd7b, 0x809f407a, 0x280c4779, 0x4f82ba78, 0xe30e66cf, 0x84809bce, + 0x2c139ccd, 0x4b9d61cc, 0x78d9e43a, 0x1f57193b, 0xb7c41e38, 0xd04ae339, 0xd14d15d4, 0xb6c3e8d5, 0x1e50efd6, + 0x79de12d7, 0x4a9a9721, 0x2d146a20, 0x85876d23, 0xe2099022, 0x878880f9, 0xe0067df8, 0x48957afb, 0x2f1b87fa, + 0x1c5f020c, 0x7bd1ff0d, 0xd342f80e, 0xb4cc050f, 0xb5cbf3e2, 0xd2450ee3, 0x7ad609e0, 0x1d58f4e1, 0x2e1c7117, + 0x49928c16, 0xe1018b15, 0x868f7614, 0xbdf4448a, 0xda7ab98b, 0x72e9be88, 0x15674389, 0x2623c67f, 0x41ad3b7e, + 0xe93e3c7d, 0x8eb0c17c, 0x8fb73791, 0xe839ca90, 0x40aacd93, 0x27243092, 0x1460b564, 0x73ee4865, 0xdb7d4f66, + 0xbcf3b267, 0xd972a2bc, 0xbefc5fbd, 0x166f58be, 0x71e1a5bf, 0x42a52049, 0x252bdd48, 0x8db8da4b, 0xea36274a, + 0xeb31d1a7, 0x8cbf2ca6, 0x242c2ba5, 0x43a2d6a4, 0x70e65352, 0x1768ae53, 0xbffba950, 0xd8755451, 0x74f988e6, + 0x137775e7, 0xbbe472e4, 0xdc6a8fe5, 0xef2e0a13, 0x88a0f712, 0x2033f011, 0x47bd0d10, 0x46bafbfd, 0x213406fc, + 0x89a701ff, 0xee29fcfe, 0xdd6d7908, 0xbae38409, 0x1270830a, 0x75fe7e0b, 0x107f6ed0, 0x77f193d1, 0xdf6294d2, + 0xb8ec69d3, 0x8ba8ec25, 0xec261124, 0x44b51627, 0x233beb26, 0x223c1dcb, 0x45b2e0ca, 0xed21e7c9, 0x8aaf1ac8, 0xb9eb9f3e, 0xde65623f, 0x76f6653c, 0x1178983d}, - {0x00000000, 0xf20c0dfe, 0xe1f46d0d, 0x13f860f3, 0xc604aceb, 0x3408a115, - 0x27f0c1e6, 0xd5fccc18, 0x89e52f27, 0x7be922d9, 0x6811422a, 0x9a1d4fd4, - 0x4fe183cc, 0xbded8e32, 0xae15eec1, 0x5c19e33f, 0x162628bf, 0xe42a2541, - 0xf7d245b2, 0x05de484c, 0xd0228454, 0x222e89aa, 0x31d6e959, 0xc3dae4a7, - 0x9fc30798, 0x6dcf0a66, 0x7e376a95, 0x8c3b676b, 0x59c7ab73, 0xabcba68d, - 0xb833c67e, 0x4a3fcb80, 0x2c4c517e, 0xde405c80, 0xcdb83c73, 0x3fb4318d, - 0xea48fd95, 0x1844f06b, 0x0bbc9098, 0xf9b09d66, 0xa5a97e59, 0x57a573a7, - 0x445d1354, 0xb6511eaa, 0x63add2b2, 0x91a1df4c, 0x8259bfbf, 0x7055b241, - 0x3a6a79c1, 0xc866743f, 0xdb9e14cc, 0x29921932, 0xfc6ed52a, 0x0e62d8d4, - 0x1d9ab827, 0xef96b5d9, 0xb38f56e6, 0x41835b18, 0x527b3beb, 0xa0773615, - 0x758bfa0d, 0x8787f7f3, 0x947f9700, 0x66739afe, 0x5898a2fc, 0xaa94af02, - 0xb96ccff1, 0x4b60c20f, 0x9e9c0e17, 0x6c9003e9, 0x7f68631a, 0x8d646ee4, - 0xd17d8ddb, 0x23718025, 0x3089e0d6, 0xc285ed28, 0x17792130, 0xe5752cce, - 0xf68d4c3d, 0x048141c3, 0x4ebe8a43, 0xbcb287bd, 0xaf4ae74e, 0x5d46eab0, - 0x88ba26a8, 0x7ab62b56, 0x694e4ba5, 0x9b42465b, 0xc75ba564, 0x3557a89a, - 0x26afc869, 0xd4a3c597, 0x015f098f, 0xf3530471, 0xe0ab6482, 0x12a7697c, - 0x74d4f382, 0x86d8fe7c, 0x95209e8f, 0x672c9371, 0xb2d05f69, 0x40dc5297, - 0x53243264, 0xa1283f9a, 0xfd31dca5, 0x0f3dd15b, 0x1cc5b1a8, 0xeec9bc56, - 0x3b35704e, 0xc9397db0, 0xdac11d43, 0x28cd10bd, 0x62f2db3d, 0x90fed6c3, - 0x8306b630, 0x710abbce, 0xa4f677d6, 0x56fa7a28, 0x45021adb, 0xb70e1725, - 0xeb17f41a, 0x191bf9e4, 0x0ae39917, 0xf8ef94e9, 0x2d1358f1, 0xdf1f550f, - 0xcce735fc, 0x3eeb3802, 0xb13145f8, 0x433d4806, 0x50c528f5, 0xa2c9250b, - 0x7735e913, 0x8539e4ed, 0x96c1841e, 0x64cd89e0, 0x38d46adf, 0xcad86721, - 0xd92007d2, 0x2b2c0a2c, 0xfed0c634, 0x0cdccbca, 0x1f24ab39, 0xed28a6c7, - 0xa7176d47, 0x551b60b9, 0x46e3004a, 0xb4ef0db4, 0x6113c1ac, 0x931fcc52, - 0x80e7aca1, 0x72eba15f, 0x2ef24260, 0xdcfe4f9e, 0xcf062f6d, 0x3d0a2293, - 0xe8f6ee8b, 0x1afae375, 0x09028386, 0xfb0e8e78, 0x9d7d1486, 0x6f711978, - 0x7c89798b, 0x8e857475, 0x5b79b86d, 0xa975b593, 0xba8dd560, 0x4881d89e, - 0x14983ba1, 0xe694365f, 0xf56c56ac, 0x07605b52, 0xd29c974a, 0x20909ab4, - 0x3368fa47, 0xc164f7b9, 0x8b5b3c39, 0x795731c7, 0x6aaf5134, 0x98a35cca, - 0x4d5f90d2, 0xbf539d2c, 0xacabfddf, 0x5ea7f021, 0x02be131e, 0xf0b21ee0, - 0xe34a7e13, 0x114673ed, 0xc4babff5, 0x36b6b20b, 0x254ed2f8, 0xd742df06, - 0xe9a9e704, 0x1ba5eafa, 0x085d8a09, 0xfa5187f7, 0x2fad4bef, 0xdda14611, - 0xce5926e2, 0x3c552b1c, 0x604cc823, 0x9240c5dd, 0x81b8a52e, 0x73b4a8d0, - 0xa64864c8, 0x54446936, 0x47bc09c5, 0xb5b0043b, 0xff8fcfbb, 0x0d83c245, - 0x1e7ba2b6, 0xec77af48, 0x398b6350, 0xcb876eae, 0xd87f0e5d, 0x2a7303a3, - 0x766ae09c, 0x8466ed62, 0x979e8d91, 0x6592806f, 0xb06e4c77, 0x42624189, - 0x519a217a, 0xa3962c84, 0xc5e5b67a, 0x37e9bb84, 0x2411db77, 0xd61dd689, - 0x03e11a91, 0xf1ed176f, 0xe215779c, 0x10197a62, 0x4c00995d, 0xbe0c94a3, - 0xadf4f450, 0x5ff8f9ae, 0x8a0435b6, 0x78083848, 0x6bf058bb, 0x99fc5545, - 0xd3c39ec5, 0x21cf933b, 0x3237f3c8, 0xc03bfe36, 0x15c7322e, 0xe7cb3fd0, - 0xf4335f23, 0x063f52dd, 0x5a26b1e2, 0xa82abc1c, 0xbbd2dcef, 0x49ded111, + {0x00000000, 0xf20c0dfe, 0xe1f46d0d, 0x13f860f3, 0xc604aceb, 0x3408a115, 0x27f0c1e6, 0xd5fccc18, 0x89e52f27, + 0x7be922d9, 0x6811422a, 0x9a1d4fd4, 0x4fe183cc, 0xbded8e32, 0xae15eec1, 0x5c19e33f, 0x162628bf, 0xe42a2541, + 0xf7d245b2, 0x05de484c, 0xd0228454, 0x222e89aa, 0x31d6e959, 0xc3dae4a7, 0x9fc30798, 0x6dcf0a66, 0x7e376a95, + 0x8c3b676b, 0x59c7ab73, 0xabcba68d, 0xb833c67e, 0x4a3fcb80, 0x2c4c517e, 0xde405c80, 0xcdb83c73, 0x3fb4318d, + 0xea48fd95, 0x1844f06b, 0x0bbc9098, 0xf9b09d66, 0xa5a97e59, 0x57a573a7, 0x445d1354, 0xb6511eaa, 0x63add2b2, + 0x91a1df4c, 0x8259bfbf, 0x7055b241, 0x3a6a79c1, 0xc866743f, 0xdb9e14cc, 0x29921932, 0xfc6ed52a, 0x0e62d8d4, + 0x1d9ab827, 0xef96b5d9, 0xb38f56e6, 0x41835b18, 0x527b3beb, 0xa0773615, 0x758bfa0d, 0x8787f7f3, 0x947f9700, + 0x66739afe, 0x5898a2fc, 0xaa94af02, 0xb96ccff1, 0x4b60c20f, 0x9e9c0e17, 0x6c9003e9, 0x7f68631a, 0x8d646ee4, + 0xd17d8ddb, 0x23718025, 0x3089e0d6, 0xc285ed28, 0x17792130, 0xe5752cce, 0xf68d4c3d, 0x048141c3, 0x4ebe8a43, + 0xbcb287bd, 0xaf4ae74e, 0x5d46eab0, 0x88ba26a8, 0x7ab62b56, 0x694e4ba5, 0x9b42465b, 0xc75ba564, 0x3557a89a, + 0x26afc869, 0xd4a3c597, 0x015f098f, 0xf3530471, 0xe0ab6482, 0x12a7697c, 0x74d4f382, 0x86d8fe7c, 0x95209e8f, + 0x672c9371, 0xb2d05f69, 0x40dc5297, 0x53243264, 0xa1283f9a, 0xfd31dca5, 0x0f3dd15b, 0x1cc5b1a8, 0xeec9bc56, + 0x3b35704e, 0xc9397db0, 0xdac11d43, 0x28cd10bd, 0x62f2db3d, 0x90fed6c3, 0x8306b630, 0x710abbce, 0xa4f677d6, + 0x56fa7a28, 0x45021adb, 0xb70e1725, 0xeb17f41a, 0x191bf9e4, 0x0ae39917, 0xf8ef94e9, 0x2d1358f1, 0xdf1f550f, + 0xcce735fc, 0x3eeb3802, 0xb13145f8, 0x433d4806, 0x50c528f5, 0xa2c9250b, 0x7735e913, 0x8539e4ed, 0x96c1841e, + 0x64cd89e0, 0x38d46adf, 0xcad86721, 0xd92007d2, 0x2b2c0a2c, 0xfed0c634, 0x0cdccbca, 0x1f24ab39, 0xed28a6c7, + 0xa7176d47, 0x551b60b9, 0x46e3004a, 0xb4ef0db4, 0x6113c1ac, 0x931fcc52, 0x80e7aca1, 0x72eba15f, 0x2ef24260, + 0xdcfe4f9e, 0xcf062f6d, 0x3d0a2293, 0xe8f6ee8b, 0x1afae375, 0x09028386, 0xfb0e8e78, 0x9d7d1486, 0x6f711978, + 0x7c89798b, 0x8e857475, 0x5b79b86d, 0xa975b593, 0xba8dd560, 0x4881d89e, 0x14983ba1, 0xe694365f, 0xf56c56ac, + 0x07605b52, 0xd29c974a, 0x20909ab4, 0x3368fa47, 0xc164f7b9, 0x8b5b3c39, 0x795731c7, 0x6aaf5134, 0x98a35cca, + 0x4d5f90d2, 0xbf539d2c, 0xacabfddf, 0x5ea7f021, 0x02be131e, 0xf0b21ee0, 0xe34a7e13, 0x114673ed, 0xc4babff5, + 0x36b6b20b, 0x254ed2f8, 0xd742df06, 0xe9a9e704, 0x1ba5eafa, 0x085d8a09, 0xfa5187f7, 0x2fad4bef, 0xdda14611, + 0xce5926e2, 0x3c552b1c, 0x604cc823, 0x9240c5dd, 0x81b8a52e, 0x73b4a8d0, 0xa64864c8, 0x54446936, 0x47bc09c5, + 0xb5b0043b, 0xff8fcfbb, 0x0d83c245, 0x1e7ba2b6, 0xec77af48, 0x398b6350, 0xcb876eae, 0xd87f0e5d, 0x2a7303a3, + 0x766ae09c, 0x8466ed62, 0x979e8d91, 0x6592806f, 0xb06e4c77, 0x42624189, 0x519a217a, 0xa3962c84, 0xc5e5b67a, + 0x37e9bb84, 0x2411db77, 0xd61dd689, 0x03e11a91, 0xf1ed176f, 0xe215779c, 0x10197a62, 0x4c00995d, 0xbe0c94a3, + 0xadf4f450, 0x5ff8f9ae, 0x8a0435b6, 0x78083848, 0x6bf058bb, 0x99fc5545, 0xd3c39ec5, 0x21cf933b, 0x3237f3c8, + 0xc03bfe36, 0x15c7322e, 0xe7cb3fd0, 0xf4335f23, 0x063f52dd, 0x5a26b1e2, 0xa82abc1c, 0xbbd2dcef, 0x49ded111, 0x9c221d09, 0x6e2e10f7, 0x7dd67004, 0x8fda7dfa} }; #if !defined(_TD_ARM_) && !defined(_TD_MIPS_) static uint32_t long_shifts[4][256] = { - {0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f, - 0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2, - 0x94b55c14, 0x74f5bcb8, 0x51d8ebbd, 0xb1980b11, 0x37048b6e, 0xd7446bc2, - 0xf2693cc7, 0x1229dc6b, 0xb83392cd, 0x58737261, 0x7d5e2564, 0x9d1ec5c8, - 0x2c86ced9, 0xccc62e75, 0xe9eb7970, 0x09ab99dc, 0xa3b1d77a, 0x43f137d6, - 0x66dc60d3, 0x869c807f, 0x6e0916dc, 0x8e49f670, 0xab64a175, 0x4b2441d9, - 0xe13e0f7f, 0x017eefd3, 0x2453b8d6, 0xc413587a, 0x758b536b, 0x95cbb3c7, - 0xb0e6e4c2, 0x50a6046e, 0xfabc4ac8, 0x1afcaa64, 0x3fd1fd61, 0xdf911dcd, - 0x590d9db2, 0xb94d7d1e, 0x9c602a1b, 0x7c20cab7, 0xd63a8411, 0x367a64bd, - 0x135733b8, 0xf317d314, 0x428fd805, 0xa2cf38a9, 0x87e26fac, 0x67a28f00, - 0xcdb8c1a6, 0x2df8210a, 0x08d5760f, 0xe89596a3, 0xdc122db8, 0x3c52cd14, - 0x197f9a11, 0xf93f7abd, 0x5325341b, 0xb365d4b7, 0x964883b2, 0x7608631e, - 0xc790680f, 0x27d088a3, 0x02fddfa6, 0xe2bd3f0a, 0x48a771ac, 0xa8e79100, - 0x8dcac605, 0x6d8a26a9, 0xeb16a6d6, 0x0b56467a, 0x2e7b117f, 0xce3bf1d3, - 0x6421bf75, 0x84615fd9, 0xa14c08dc, 0x410ce870, 0xf094e361, 0x10d403cd, - 0x35f954c8, 0xd5b9b464, 0x7fa3fac2, 0x9fe31a6e, 0xbace4d6b, 0x5a8eadc7, - 0xb21b3b64, 0x525bdbc8, 0x77768ccd, 0x97366c61, 0x3d2c22c7, 0xdd6cc26b, - 0xf841956e, 0x180175c2, 0xa9997ed3, 0x49d99e7f, 0x6cf4c97a, 0x8cb429d6, - 0x26ae6770, 0xc6ee87dc, 0xe3c3d0d9, 0x03833075, 0x851fb00a, 0x655f50a6, - 0x407207a3, 0xa032e70f, 0x0a28a9a9, 0xea684905, 0xcf451e00, 0x2f05feac, - 0x9e9df5bd, 0x7edd1511, 0x5bf04214, 0xbbb0a2b8, 0x11aaec1e, 0xf1ea0cb2, - 0xd4c75bb7, 0x3487bb1b, 0xbdc82d81, 0x5d88cd2d, 0x78a59a28, 0x98e57a84, - 0x32ff3422, 0xd2bfd48e, 0xf792838b, 0x17d26327, 0xa64a6836, 0x460a889a, - 0x6327df9f, 0x83673f33, 0x297d7195, 0xc93d9139, 0xec10c63c, 0x0c502690, - 0x8acca6ef, 0x6a8c4643, 0x4fa11146, 0xafe1f1ea, 0x05fbbf4c, 0xe5bb5fe0, - 0xc09608e5, 0x20d6e849, 0x914ee358, 0x710e03f4, 0x542354f1, 0xb463b45d, - 0x1e79fafb, 0xfe391a57, 0xdb144d52, 0x3b54adfe, 0xd3c13b5d, 0x3381dbf1, - 0x16ac8cf4, 0xf6ec6c58, 0x5cf622fe, 0xbcb6c252, 0x999b9557, 0x79db75fb, - 0xc8437eea, 0x28039e46, 0x0d2ec943, 0xed6e29ef, 0x47746749, 0xa73487e5, - 0x8219d0e0, 0x6259304c, 0xe4c5b033, 0x0485509f, 0x21a8079a, 0xc1e8e736, - 0x6bf2a990, 0x8bb2493c, 0xae9f1e39, 0x4edffe95, 0xff47f584, 0x1f071528, - 0x3a2a422d, 0xda6aa281, 0x7070ec27, 0x90300c8b, 0xb51d5b8e, 0x555dbb22, - 0x61da0039, 0x819ae095, 0xa4b7b790, 0x44f7573c, 0xeeed199a, 0x0eadf936, - 0x2b80ae33, 0xcbc04e9f, 0x7a58458e, 0x9a18a522, 0xbf35f227, 0x5f75128b, - 0xf56f5c2d, 0x152fbc81, 0x3002eb84, 0xd0420b28, 0x56de8b57, 0xb69e6bfb, - 0x93b33cfe, 0x73f3dc52, 0xd9e992f4, 0x39a97258, 0x1c84255d, 0xfcc4c5f1, - 0x4d5ccee0, 0xad1c2e4c, 0x88317949, 0x687199e5, 0xc26bd743, 0x222b37ef, - 0x070660ea, 0xe7468046, 0x0fd316e5, 0xef93f649, 0xcabea14c, 0x2afe41e0, - 0x80e40f46, 0x60a4efea, 0x4589b8ef, 0xa5c95843, 0x14515352, 0xf411b3fe, - 0xd13ce4fb, 0x317c0457, 0x9b664af1, 0x7b26aa5d, 0x5e0bfd58, 0xbe4b1df4, - 0x38d79d8b, 0xd8977d27, 0xfdba2a22, 0x1dfaca8e, 0xb7e08428, 0x57a06484, - 0x728d3381, 0x92cdd32d, 0x2355d83c, 0xc3153890, 0xe6386f95, 0x06788f39, + {0x00000000, 0xe040e0ac, 0xc56db7a9, 0x252d5705, 0x8f3719a3, 0x6f77f90f, 0x4a5aae0a, 0xaa1a4ea6, 0x1b8245b7, + 0xfbc2a51b, 0xdeeff21e, 0x3eaf12b2, 0x94b55c14, 0x74f5bcb8, 0x51d8ebbd, 0xb1980b11, 0x37048b6e, 0xd7446bc2, + 0xf2693cc7, 0x1229dc6b, 0xb83392cd, 0x58737261, 0x7d5e2564, 0x9d1ec5c8, 0x2c86ced9, 0xccc62e75, 0xe9eb7970, + 0x09ab99dc, 0xa3b1d77a, 0x43f137d6, 0x66dc60d3, 0x869c807f, 0x6e0916dc, 0x8e49f670, 0xab64a175, 0x4b2441d9, + 0xe13e0f7f, 0x017eefd3, 0x2453b8d6, 0xc413587a, 0x758b536b, 0x95cbb3c7, 0xb0e6e4c2, 0x50a6046e, 0xfabc4ac8, + 0x1afcaa64, 0x3fd1fd61, 0xdf911dcd, 0x590d9db2, 0xb94d7d1e, 0x9c602a1b, 0x7c20cab7, 0xd63a8411, 0x367a64bd, + 0x135733b8, 0xf317d314, 0x428fd805, 0xa2cf38a9, 0x87e26fac, 0x67a28f00, 0xcdb8c1a6, 0x2df8210a, 0x08d5760f, + 0xe89596a3, 0xdc122db8, 0x3c52cd14, 0x197f9a11, 0xf93f7abd, 0x5325341b, 0xb365d4b7, 0x964883b2, 0x7608631e, + 0xc790680f, 0x27d088a3, 0x02fddfa6, 0xe2bd3f0a, 0x48a771ac, 0xa8e79100, 0x8dcac605, 0x6d8a26a9, 0xeb16a6d6, + 0x0b56467a, 0x2e7b117f, 0xce3bf1d3, 0x6421bf75, 0x84615fd9, 0xa14c08dc, 0x410ce870, 0xf094e361, 0x10d403cd, + 0x35f954c8, 0xd5b9b464, 0x7fa3fac2, 0x9fe31a6e, 0xbace4d6b, 0x5a8eadc7, 0xb21b3b64, 0x525bdbc8, 0x77768ccd, + 0x97366c61, 0x3d2c22c7, 0xdd6cc26b, 0xf841956e, 0x180175c2, 0xa9997ed3, 0x49d99e7f, 0x6cf4c97a, 0x8cb429d6, + 0x26ae6770, 0xc6ee87dc, 0xe3c3d0d9, 0x03833075, 0x851fb00a, 0x655f50a6, 0x407207a3, 0xa032e70f, 0x0a28a9a9, + 0xea684905, 0xcf451e00, 0x2f05feac, 0x9e9df5bd, 0x7edd1511, 0x5bf04214, 0xbbb0a2b8, 0x11aaec1e, 0xf1ea0cb2, + 0xd4c75bb7, 0x3487bb1b, 0xbdc82d81, 0x5d88cd2d, 0x78a59a28, 0x98e57a84, 0x32ff3422, 0xd2bfd48e, 0xf792838b, + 0x17d26327, 0xa64a6836, 0x460a889a, 0x6327df9f, 0x83673f33, 0x297d7195, 0xc93d9139, 0xec10c63c, 0x0c502690, + 0x8acca6ef, 0x6a8c4643, 0x4fa11146, 0xafe1f1ea, 0x05fbbf4c, 0xe5bb5fe0, 0xc09608e5, 0x20d6e849, 0x914ee358, + 0x710e03f4, 0x542354f1, 0xb463b45d, 0x1e79fafb, 0xfe391a57, 0xdb144d52, 0x3b54adfe, 0xd3c13b5d, 0x3381dbf1, + 0x16ac8cf4, 0xf6ec6c58, 0x5cf622fe, 0xbcb6c252, 0x999b9557, 0x79db75fb, 0xc8437eea, 0x28039e46, 0x0d2ec943, + 0xed6e29ef, 0x47746749, 0xa73487e5, 0x8219d0e0, 0x6259304c, 0xe4c5b033, 0x0485509f, 0x21a8079a, 0xc1e8e736, + 0x6bf2a990, 0x8bb2493c, 0xae9f1e39, 0x4edffe95, 0xff47f584, 0x1f071528, 0x3a2a422d, 0xda6aa281, 0x7070ec27, + 0x90300c8b, 0xb51d5b8e, 0x555dbb22, 0x61da0039, 0x819ae095, 0xa4b7b790, 0x44f7573c, 0xeeed199a, 0x0eadf936, + 0x2b80ae33, 0xcbc04e9f, 0x7a58458e, 0x9a18a522, 0xbf35f227, 0x5f75128b, 0xf56f5c2d, 0x152fbc81, 0x3002eb84, + 0xd0420b28, 0x56de8b57, 0xb69e6bfb, 0x93b33cfe, 0x73f3dc52, 0xd9e992f4, 0x39a97258, 0x1c84255d, 0xfcc4c5f1, + 0x4d5ccee0, 0xad1c2e4c, 0x88317949, 0x687199e5, 0xc26bd743, 0x222b37ef, 0x070660ea, 0xe7468046, 0x0fd316e5, + 0xef93f649, 0xcabea14c, 0x2afe41e0, 0x80e40f46, 0x60a4efea, 0x4589b8ef, 0xa5c95843, 0x14515352, 0xf411b3fe, + 0xd13ce4fb, 0x317c0457, 0x9b664af1, 0x7b26aa5d, 0x5e0bfd58, 0xbe4b1df4, 0x38d79d8b, 0xd8977d27, 0xfdba2a22, + 0x1dfaca8e, 0xb7e08428, 0x57a06484, 0x728d3381, 0x92cdd32d, 0x2355d83c, 0xc3153890, 0xe6386f95, 0x06788f39, 0xac62c19f, 0x4c222133, 0x690f7636, 0x894f969a}, - {0x00000000, 0x7e7c2df3, 0xfcf85be6, 0x82847615, 0xfc1cc13d, 0x8260ecce, - 0x00e49adb, 0x7e98b728, 0xfdd5f48b, 0x83a9d978, 0x012daf6d, 0x7f51829e, - 0x01c935b6, 0x7fb51845, 0xfd316e50, 0x834d43a3, 0xfe479fe7, 0x803bb214, - 0x02bfc401, 0x7cc3e9f2, 0x025b5eda, 0x7c277329, 0xfea3053c, 0x80df28cf, - 0x03926b6c, 0x7dee469f, 0xff6a308a, 0x81161d79, 0xff8eaa51, 0x81f287a2, - 0x0376f1b7, 0x7d0adc44, 0xf963493f, 0x871f64cc, 0x059b12d9, 0x7be73f2a, - 0x057f8802, 0x7b03a5f1, 0xf987d3e4, 0x87fbfe17, 0x04b6bdb4, 0x7aca9047, - 0xf84ee652, 0x8632cba1, 0xf8aa7c89, 0x86d6517a, 0x0452276f, 0x7a2e0a9c, - 0x0724d6d8, 0x7958fb2b, 0xfbdc8d3e, 0x85a0a0cd, 0xfb3817e5, 0x85443a16, - 0x07c04c03, 0x79bc61f0, 0xfaf12253, 0x848d0fa0, 0x060979b5, 0x78755446, - 0x06ede36e, 0x7891ce9d, 0xfa15b888, 0x8469957b, 0xf72ae48f, 0x8956c97c, - 0x0bd2bf69, 0x75ae929a, 0x0b3625b2, 0x754a0841, 0xf7ce7e54, 0x89b253a7, - 0x0aff1004, 0x74833df7, 0xf6074be2, 0x887b6611, 0xf6e3d139, 0x889ffcca, - 0x0a1b8adf, 0x7467a72c, 0x096d7b68, 0x7711569b, 0xf595208e, 0x8be90d7d, - 0xf571ba55, 0x8b0d97a6, 0x0989e1b3, 0x77f5cc40, 0xf4b88fe3, 0x8ac4a210, - 0x0840d405, 0x763cf9f6, 0x08a44ede, 0x76d8632d, 0xf45c1538, 0x8a2038cb, - 0x0e49adb0, 0x70358043, 0xf2b1f656, 0x8ccddba5, 0xf2556c8d, 0x8c29417e, - 0x0ead376b, 0x70d11a98, 0xf39c593b, 0x8de074c8, 0x0f6402dd, 0x71182f2e, - 0x0f809806, 0x71fcb5f5, 0xf378c3e0, 0x8d04ee13, 0xf00e3257, 0x8e721fa4, - 0x0cf669b1, 0x728a4442, 0x0c12f36a, 0x726ede99, 0xf0eaa88c, 0x8e96857f, - 0x0ddbc6dc, 0x73a7eb2f, 0xf1239d3a, 0x8f5fb0c9, 0xf1c707e1, 0x8fbb2a12, - 0x0d3f5c07, 0x734371f4, 0xebb9bfef, 0x95c5921c, 0x1741e409, 0x693dc9fa, - 0x17a57ed2, 0x69d95321, 0xeb5d2534, 0x952108c7, 0x166c4b64, 0x68106697, - 0xea941082, 0x94e83d71, 0xea708a59, 0x940ca7aa, 0x1688d1bf, 0x68f4fc4c, - 0x15fe2008, 0x6b820dfb, 0xe9067bee, 0x977a561d, 0xe9e2e135, 0x979eccc6, - 0x151abad3, 0x6b669720, 0xe82bd483, 0x9657f970, 0x14d38f65, 0x6aafa296, - 0x143715be, 0x6a4b384d, 0xe8cf4e58, 0x96b363ab, 0x12daf6d0, 0x6ca6db23, - 0xee22ad36, 0x905e80c5, 0xeec637ed, 0x90ba1a1e, 0x123e6c0b, 0x6c4241f8, - 0xef0f025b, 0x91732fa8, 0x13f759bd, 0x6d8b744e, 0x1313c366, 0x6d6fee95, - 0xefeb9880, 0x9197b573, 0xec9d6937, 0x92e144c4, 0x106532d1, 0x6e191f22, - 0x1081a80a, 0x6efd85f9, 0xec79f3ec, 0x9205de1f, 0x11489dbc, 0x6f34b04f, - 0xedb0c65a, 0x93cceba9, 0xed545c81, 0x93287172, 0x11ac0767, 0x6fd02a94, - 0x1c935b60, 0x62ef7693, 0xe06b0086, 0x9e172d75, 0xe08f9a5d, 0x9ef3b7ae, - 0x1c77c1bb, 0x620bec48, 0xe146afeb, 0x9f3a8218, 0x1dbef40d, 0x63c2d9fe, - 0x1d5a6ed6, 0x63264325, 0xe1a23530, 0x9fde18c3, 0xe2d4c487, 0x9ca8e974, - 0x1e2c9f61, 0x6050b292, 0x1ec805ba, 0x60b42849, 0xe2305e5c, 0x9c4c73af, - 0x1f01300c, 0x617d1dff, 0xe3f96bea, 0x9d854619, 0xe31df131, 0x9d61dcc2, - 0x1fe5aad7, 0x61998724, 0xe5f0125f, 0x9b8c3fac, 0x190849b9, 0x6774644a, - 0x19ecd362, 0x6790fe91, 0xe5148884, 0x9b68a577, 0x1825e6d4, 0x6659cb27, - 0xe4ddbd32, 0x9aa190c1, 0xe43927e9, 0x9a450a1a, 0x18c17c0f, 0x66bd51fc, - 0x1bb78db8, 0x65cba04b, 0xe74fd65e, 0x9933fbad, 0xe7ab4c85, 0x99d76176, - 0x1b531763, 0x652f3a90, 0xe6627933, 0x981e54c0, 0x1a9a22d5, 0x64e60f26, + {0x00000000, 0x7e7c2df3, 0xfcf85be6, 0x82847615, 0xfc1cc13d, 0x8260ecce, 0x00e49adb, 0x7e98b728, 0xfdd5f48b, + 0x83a9d978, 0x012daf6d, 0x7f51829e, 0x01c935b6, 0x7fb51845, 0xfd316e50, 0x834d43a3, 0xfe479fe7, 0x803bb214, + 0x02bfc401, 0x7cc3e9f2, 0x025b5eda, 0x7c277329, 0xfea3053c, 0x80df28cf, 0x03926b6c, 0x7dee469f, 0xff6a308a, + 0x81161d79, 0xff8eaa51, 0x81f287a2, 0x0376f1b7, 0x7d0adc44, 0xf963493f, 0x871f64cc, 0x059b12d9, 0x7be73f2a, + 0x057f8802, 0x7b03a5f1, 0xf987d3e4, 0x87fbfe17, 0x04b6bdb4, 0x7aca9047, 0xf84ee652, 0x8632cba1, 0xf8aa7c89, + 0x86d6517a, 0x0452276f, 0x7a2e0a9c, 0x0724d6d8, 0x7958fb2b, 0xfbdc8d3e, 0x85a0a0cd, 0xfb3817e5, 0x85443a16, + 0x07c04c03, 0x79bc61f0, 0xfaf12253, 0x848d0fa0, 0x060979b5, 0x78755446, 0x06ede36e, 0x7891ce9d, 0xfa15b888, + 0x8469957b, 0xf72ae48f, 0x8956c97c, 0x0bd2bf69, 0x75ae929a, 0x0b3625b2, 0x754a0841, 0xf7ce7e54, 0x89b253a7, + 0x0aff1004, 0x74833df7, 0xf6074be2, 0x887b6611, 0xf6e3d139, 0x889ffcca, 0x0a1b8adf, 0x7467a72c, 0x096d7b68, + 0x7711569b, 0xf595208e, 0x8be90d7d, 0xf571ba55, 0x8b0d97a6, 0x0989e1b3, 0x77f5cc40, 0xf4b88fe3, 0x8ac4a210, + 0x0840d405, 0x763cf9f6, 0x08a44ede, 0x76d8632d, 0xf45c1538, 0x8a2038cb, 0x0e49adb0, 0x70358043, 0xf2b1f656, + 0x8ccddba5, 0xf2556c8d, 0x8c29417e, 0x0ead376b, 0x70d11a98, 0xf39c593b, 0x8de074c8, 0x0f6402dd, 0x71182f2e, + 0x0f809806, 0x71fcb5f5, 0xf378c3e0, 0x8d04ee13, 0xf00e3257, 0x8e721fa4, 0x0cf669b1, 0x728a4442, 0x0c12f36a, + 0x726ede99, 0xf0eaa88c, 0x8e96857f, 0x0ddbc6dc, 0x73a7eb2f, 0xf1239d3a, 0x8f5fb0c9, 0xf1c707e1, 0x8fbb2a12, + 0x0d3f5c07, 0x734371f4, 0xebb9bfef, 0x95c5921c, 0x1741e409, 0x693dc9fa, 0x17a57ed2, 0x69d95321, 0xeb5d2534, + 0x952108c7, 0x166c4b64, 0x68106697, 0xea941082, 0x94e83d71, 0xea708a59, 0x940ca7aa, 0x1688d1bf, 0x68f4fc4c, + 0x15fe2008, 0x6b820dfb, 0xe9067bee, 0x977a561d, 0xe9e2e135, 0x979eccc6, 0x151abad3, 0x6b669720, 0xe82bd483, + 0x9657f970, 0x14d38f65, 0x6aafa296, 0x143715be, 0x6a4b384d, 0xe8cf4e58, 0x96b363ab, 0x12daf6d0, 0x6ca6db23, + 0xee22ad36, 0x905e80c5, 0xeec637ed, 0x90ba1a1e, 0x123e6c0b, 0x6c4241f8, 0xef0f025b, 0x91732fa8, 0x13f759bd, + 0x6d8b744e, 0x1313c366, 0x6d6fee95, 0xefeb9880, 0x9197b573, 0xec9d6937, 0x92e144c4, 0x106532d1, 0x6e191f22, + 0x1081a80a, 0x6efd85f9, 0xec79f3ec, 0x9205de1f, 0x11489dbc, 0x6f34b04f, 0xedb0c65a, 0x93cceba9, 0xed545c81, + 0x93287172, 0x11ac0767, 0x6fd02a94, 0x1c935b60, 0x62ef7693, 0xe06b0086, 0x9e172d75, 0xe08f9a5d, 0x9ef3b7ae, + 0x1c77c1bb, 0x620bec48, 0xe146afeb, 0x9f3a8218, 0x1dbef40d, 0x63c2d9fe, 0x1d5a6ed6, 0x63264325, 0xe1a23530, + 0x9fde18c3, 0xe2d4c487, 0x9ca8e974, 0x1e2c9f61, 0x6050b292, 0x1ec805ba, 0x60b42849, 0xe2305e5c, 0x9c4c73af, + 0x1f01300c, 0x617d1dff, 0xe3f96bea, 0x9d854619, 0xe31df131, 0x9d61dcc2, 0x1fe5aad7, 0x61998724, 0xe5f0125f, + 0x9b8c3fac, 0x190849b9, 0x6774644a, 0x19ecd362, 0x6790fe91, 0xe5148884, 0x9b68a577, 0x1825e6d4, 0x6659cb27, + 0xe4ddbd32, 0x9aa190c1, 0xe43927e9, 0x9a450a1a, 0x18c17c0f, 0x66bd51fc, 0x1bb78db8, 0x65cba04b, 0xe74fd65e, + 0x9933fbad, 0xe7ab4c85, 0x99d76176, 0x1b531763, 0x652f3a90, 0xe6627933, 0x981e54c0, 0x1a9a22d5, 0x64e60f26, 0x1a7eb80e, 0x640295fd, 0xe686e3e8, 0x98face1b}, - {0x00000000, 0xd29f092f, 0xa0d264af, 0x724d6d80, 0x4448bfaf, 0x96d7b680, - 0xe49adb00, 0x3605d22f, 0x88917f5e, 0x5a0e7671, 0x28431bf1, 0xfadc12de, - 0xccd9c0f1, 0x1e46c9de, 0x6c0ba45e, 0xbe94ad71, 0x14ce884d, 0xc6518162, - 0xb41cece2, 0x6683e5cd, 0x508637e2, 0x82193ecd, 0xf054534d, 0x22cb5a62, - 0x9c5ff713, 0x4ec0fe3c, 0x3c8d93bc, 0xee129a93, 0xd81748bc, 0x0a884193, - 0x78c52c13, 0xaa5a253c, 0x299d109a, 0xfb0219b5, 0x894f7435, 0x5bd07d1a, - 0x6dd5af35, 0xbf4aa61a, 0xcd07cb9a, 0x1f98c2b5, 0xa10c6fc4, 0x739366eb, - 0x01de0b6b, 0xd3410244, 0xe544d06b, 0x37dbd944, 0x4596b4c4, 0x9709bdeb, - 0x3d5398d7, 0xefcc91f8, 0x9d81fc78, 0x4f1ef557, 0x791b2778, 0xab842e57, - 0xd9c943d7, 0x0b564af8, 0xb5c2e789, 0x675deea6, 0x15108326, 0xc78f8a09, - 0xf18a5826, 0x23155109, 0x51583c89, 0x83c735a6, 0x533a2134, 0x81a5281b, - 0xf3e8459b, 0x21774cb4, 0x17729e9b, 0xc5ed97b4, 0xb7a0fa34, 0x653ff31b, - 0xdbab5e6a, 0x09345745, 0x7b793ac5, 0xa9e633ea, 0x9fe3e1c5, 0x4d7ce8ea, - 0x3f31856a, 0xedae8c45, 0x47f4a979, 0x956ba056, 0xe726cdd6, 0x35b9c4f9, - 0x03bc16d6, 0xd1231ff9, 0xa36e7279, 0x71f17b56, 0xcf65d627, 0x1dfadf08, - 0x6fb7b288, 0xbd28bba7, 0x8b2d6988, 0x59b260a7, 0x2bff0d27, 0xf9600408, - 0x7aa731ae, 0xa8383881, 0xda755501, 0x08ea5c2e, 0x3eef8e01, 0xec70872e, - 0x9e3deaae, 0x4ca2e381, 0xf2364ef0, 0x20a947df, 0x52e42a5f, 0x807b2370, - 0xb67ef15f, 0x64e1f870, 0x16ac95f0, 0xc4339cdf, 0x6e69b9e3, 0xbcf6b0cc, - 0xcebbdd4c, 0x1c24d463, 0x2a21064c, 0xf8be0f63, 0x8af362e3, 0x586c6bcc, - 0xe6f8c6bd, 0x3467cf92, 0x462aa212, 0x94b5ab3d, 0xa2b07912, 0x702f703d, - 0x02621dbd, 0xd0fd1492, 0xa6744268, 0x74eb4b47, 0x06a626c7, 0xd4392fe8, - 0xe23cfdc7, 0x30a3f4e8, 0x42ee9968, 0x90719047, 0x2ee53d36, 0xfc7a3419, - 0x8e375999, 0x5ca850b6, 0x6aad8299, 0xb8328bb6, 0xca7fe636, 0x18e0ef19, - 0xb2baca25, 0x6025c30a, 0x1268ae8a, 0xc0f7a7a5, 0xf6f2758a, 0x246d7ca5, - 0x56201125, 0x84bf180a, 0x3a2bb57b, 0xe8b4bc54, 0x9af9d1d4, 0x4866d8fb, - 0x7e630ad4, 0xacfc03fb, 0xdeb16e7b, 0x0c2e6754, 0x8fe952f2, 0x5d765bdd, - 0x2f3b365d, 0xfda43f72, 0xcba1ed5d, 0x193ee472, 0x6b7389f2, 0xb9ec80dd, - 0x07782dac, 0xd5e72483, 0xa7aa4903, 0x7535402c, 0x43309203, 0x91af9b2c, - 0xe3e2f6ac, 0x317dff83, 0x9b27dabf, 0x49b8d390, 0x3bf5be10, 0xe96ab73f, - 0xdf6f6510, 0x0df06c3f, 0x7fbd01bf, 0xad220890, 0x13b6a5e1, 0xc129acce, - 0xb364c14e, 0x61fbc861, 0x57fe1a4e, 0x85611361, 0xf72c7ee1, 0x25b377ce, - 0xf54e635c, 0x27d16a73, 0x559c07f3, 0x87030edc, 0xb106dcf3, 0x6399d5dc, - 0x11d4b85c, 0xc34bb173, 0x7ddf1c02, 0xaf40152d, 0xdd0d78ad, 0x0f927182, - 0x3997a3ad, 0xeb08aa82, 0x9945c702, 0x4bdace2d, 0xe180eb11, 0x331fe23e, - 0x41528fbe, 0x93cd8691, 0xa5c854be, 0x77575d91, 0x051a3011, 0xd785393e, - 0x6911944f, 0xbb8e9d60, 0xc9c3f0e0, 0x1b5cf9cf, 0x2d592be0, 0xffc622cf, - 0x8d8b4f4f, 0x5f144660, 0xdcd373c6, 0x0e4c7ae9, 0x7c011769, 0xae9e1e46, - 0x989bcc69, 0x4a04c546, 0x3849a8c6, 0xead6a1e9, 0x54420c98, 0x86dd05b7, - 0xf4906837, 0x260f6118, 0x100ab337, 0xc295ba18, 0xb0d8d798, 0x6247deb7, - 0xc81dfb8b, 0x1a82f2a4, 0x68cf9f24, 0xba50960b, 0x8c554424, 0x5eca4d0b, - 0x2c87208b, 0xfe1829a4, 0x408c84d5, 0x92138dfa, 0xe05ee07a, 0x32c1e955, + {0x00000000, 0xd29f092f, 0xa0d264af, 0x724d6d80, 0x4448bfaf, 0x96d7b680, 0xe49adb00, 0x3605d22f, 0x88917f5e, + 0x5a0e7671, 0x28431bf1, 0xfadc12de, 0xccd9c0f1, 0x1e46c9de, 0x6c0ba45e, 0xbe94ad71, 0x14ce884d, 0xc6518162, + 0xb41cece2, 0x6683e5cd, 0x508637e2, 0x82193ecd, 0xf054534d, 0x22cb5a62, 0x9c5ff713, 0x4ec0fe3c, 0x3c8d93bc, + 0xee129a93, 0xd81748bc, 0x0a884193, 0x78c52c13, 0xaa5a253c, 0x299d109a, 0xfb0219b5, 0x894f7435, 0x5bd07d1a, + 0x6dd5af35, 0xbf4aa61a, 0xcd07cb9a, 0x1f98c2b5, 0xa10c6fc4, 0x739366eb, 0x01de0b6b, 0xd3410244, 0xe544d06b, + 0x37dbd944, 0x4596b4c4, 0x9709bdeb, 0x3d5398d7, 0xefcc91f8, 0x9d81fc78, 0x4f1ef557, 0x791b2778, 0xab842e57, + 0xd9c943d7, 0x0b564af8, 0xb5c2e789, 0x675deea6, 0x15108326, 0xc78f8a09, 0xf18a5826, 0x23155109, 0x51583c89, + 0x83c735a6, 0x533a2134, 0x81a5281b, 0xf3e8459b, 0x21774cb4, 0x17729e9b, 0xc5ed97b4, 0xb7a0fa34, 0x653ff31b, + 0xdbab5e6a, 0x09345745, 0x7b793ac5, 0xa9e633ea, 0x9fe3e1c5, 0x4d7ce8ea, 0x3f31856a, 0xedae8c45, 0x47f4a979, + 0x956ba056, 0xe726cdd6, 0x35b9c4f9, 0x03bc16d6, 0xd1231ff9, 0xa36e7279, 0x71f17b56, 0xcf65d627, 0x1dfadf08, + 0x6fb7b288, 0xbd28bba7, 0x8b2d6988, 0x59b260a7, 0x2bff0d27, 0xf9600408, 0x7aa731ae, 0xa8383881, 0xda755501, + 0x08ea5c2e, 0x3eef8e01, 0xec70872e, 0x9e3deaae, 0x4ca2e381, 0xf2364ef0, 0x20a947df, 0x52e42a5f, 0x807b2370, + 0xb67ef15f, 0x64e1f870, 0x16ac95f0, 0xc4339cdf, 0x6e69b9e3, 0xbcf6b0cc, 0xcebbdd4c, 0x1c24d463, 0x2a21064c, + 0xf8be0f63, 0x8af362e3, 0x586c6bcc, 0xe6f8c6bd, 0x3467cf92, 0x462aa212, 0x94b5ab3d, 0xa2b07912, 0x702f703d, + 0x02621dbd, 0xd0fd1492, 0xa6744268, 0x74eb4b47, 0x06a626c7, 0xd4392fe8, 0xe23cfdc7, 0x30a3f4e8, 0x42ee9968, + 0x90719047, 0x2ee53d36, 0xfc7a3419, 0x8e375999, 0x5ca850b6, 0x6aad8299, 0xb8328bb6, 0xca7fe636, 0x18e0ef19, + 0xb2baca25, 0x6025c30a, 0x1268ae8a, 0xc0f7a7a5, 0xf6f2758a, 0x246d7ca5, 0x56201125, 0x84bf180a, 0x3a2bb57b, + 0xe8b4bc54, 0x9af9d1d4, 0x4866d8fb, 0x7e630ad4, 0xacfc03fb, 0xdeb16e7b, 0x0c2e6754, 0x8fe952f2, 0x5d765bdd, + 0x2f3b365d, 0xfda43f72, 0xcba1ed5d, 0x193ee472, 0x6b7389f2, 0xb9ec80dd, 0x07782dac, 0xd5e72483, 0xa7aa4903, + 0x7535402c, 0x43309203, 0x91af9b2c, 0xe3e2f6ac, 0x317dff83, 0x9b27dabf, 0x49b8d390, 0x3bf5be10, 0xe96ab73f, + 0xdf6f6510, 0x0df06c3f, 0x7fbd01bf, 0xad220890, 0x13b6a5e1, 0xc129acce, 0xb364c14e, 0x61fbc861, 0x57fe1a4e, + 0x85611361, 0xf72c7ee1, 0x25b377ce, 0xf54e635c, 0x27d16a73, 0x559c07f3, 0x87030edc, 0xb106dcf3, 0x6399d5dc, + 0x11d4b85c, 0xc34bb173, 0x7ddf1c02, 0xaf40152d, 0xdd0d78ad, 0x0f927182, 0x3997a3ad, 0xeb08aa82, 0x9945c702, + 0x4bdace2d, 0xe180eb11, 0x331fe23e, 0x41528fbe, 0x93cd8691, 0xa5c854be, 0x77575d91, 0x051a3011, 0xd785393e, + 0x6911944f, 0xbb8e9d60, 0xc9c3f0e0, 0x1b5cf9cf, 0x2d592be0, 0xffc622cf, 0x8d8b4f4f, 0x5f144660, 0xdcd373c6, + 0x0e4c7ae9, 0x7c011769, 0xae9e1e46, 0x989bcc69, 0x4a04c546, 0x3849a8c6, 0xead6a1e9, 0x54420c98, 0x86dd05b7, + 0xf4906837, 0x260f6118, 0x100ab337, 0xc295ba18, 0xb0d8d798, 0x6247deb7, 0xc81dfb8b, 0x1a82f2a4, 0x68cf9f24, + 0xba50960b, 0x8c554424, 0x5eca4d0b, 0x2c87208b, 0xfe1829a4, 0x408c84d5, 0x92138dfa, 0xe05ee07a, 0x32c1e955, 0x04c43b7a, 0xd65b3255, 0xa4165fd5, 0x768956fa}, - {0x00000000, 0x4904f221, 0x9209e442, 0xdb0d1663, 0x21ffbe75, 0x68fb4c54, - 0xb3f65a37, 0xfaf2a816, 0x43ff7cea, 0x0afb8ecb, 0xd1f698a8, 0x98f26a89, - 0x6200c29f, 0x2b0430be, 0xf00926dd, 0xb90dd4fc, 0x87fef9d4, 0xcefa0bf5, - 0x15f71d96, 0x5cf3efb7, 0xa60147a1, 0xef05b580, 0x3408a3e3, 0x7d0c51c2, - 0xc401853e, 0x8d05771f, 0x5608617c, 0x1f0c935d, 0xe5fe3b4b, 0xacfac96a, - 0x77f7df09, 0x3ef32d28, 0x0a118559, 0x43157778, 0x9818611b, 0xd11c933a, - 0x2bee3b2c, 0x62eac90d, 0xb9e7df6e, 0xf0e32d4f, 0x49eef9b3, 0x00ea0b92, - 0xdbe71df1, 0x92e3efd0, 0x681147c6, 0x2115b5e7, 0xfa18a384, 0xb31c51a5, - 0x8def7c8d, 0xc4eb8eac, 0x1fe698cf, 0x56e26aee, 0xac10c2f8, 0xe51430d9, - 0x3e1926ba, 0x771dd49b, 0xce100067, 0x8714f246, 0x5c19e425, 0x151d1604, - 0xefefbe12, 0xa6eb4c33, 0x7de65a50, 0x34e2a871, 0x14230ab2, 0x5d27f893, - 0x862aeef0, 0xcf2e1cd1, 0x35dcb4c7, 0x7cd846e6, 0xa7d55085, 0xeed1a2a4, - 0x57dc7658, 0x1ed88479, 0xc5d5921a, 0x8cd1603b, 0x7623c82d, 0x3f273a0c, - 0xe42a2c6f, 0xad2ede4e, 0x93ddf366, 0xdad90147, 0x01d41724, 0x48d0e505, - 0xb2224d13, 0xfb26bf32, 0x202ba951, 0x692f5b70, 0xd0228f8c, 0x99267dad, - 0x422b6bce, 0x0b2f99ef, 0xf1dd31f9, 0xb8d9c3d8, 0x63d4d5bb, 0x2ad0279a, - 0x1e328feb, 0x57367dca, 0x8c3b6ba9, 0xc53f9988, 0x3fcd319e, 0x76c9c3bf, - 0xadc4d5dc, 0xe4c027fd, 0x5dcdf301, 0x14c90120, 0xcfc41743, 0x86c0e562, - 0x7c324d74, 0x3536bf55, 0xee3ba936, 0xa73f5b17, 0x99cc763f, 0xd0c8841e, - 0x0bc5927d, 0x42c1605c, 0xb833c84a, 0xf1373a6b, 0x2a3a2c08, 0x633ede29, - 0xda330ad5, 0x9337f8f4, 0x483aee97, 0x013e1cb6, 0xfbccb4a0, 0xb2c84681, - 0x69c550e2, 0x20c1a2c3, 0x28461564, 0x6142e745, 0xba4ff126, 0xf34b0307, - 0x09b9ab11, 0x40bd5930, 0x9bb04f53, 0xd2b4bd72, 0x6bb9698e, 0x22bd9baf, - 0xf9b08dcc, 0xb0b47fed, 0x4a46d7fb, 0x034225da, 0xd84f33b9, 0x914bc198, - 0xafb8ecb0, 0xe6bc1e91, 0x3db108f2, 0x74b5fad3, 0x8e4752c5, 0xc743a0e4, - 0x1c4eb687, 0x554a44a6, 0xec47905a, 0xa543627b, 0x7e4e7418, 0x374a8639, - 0xcdb82e2f, 0x84bcdc0e, 0x5fb1ca6d, 0x16b5384c, 0x2257903d, 0x6b53621c, - 0xb05e747f, 0xf95a865e, 0x03a82e48, 0x4aacdc69, 0x91a1ca0a, 0xd8a5382b, - 0x61a8ecd7, 0x28ac1ef6, 0xf3a10895, 0xbaa5fab4, 0x405752a2, 0x0953a083, - 0xd25eb6e0, 0x9b5a44c1, 0xa5a969e9, 0xecad9bc8, 0x37a08dab, 0x7ea47f8a, - 0x8456d79c, 0xcd5225bd, 0x165f33de, 0x5f5bc1ff, 0xe6561503, 0xaf52e722, - 0x745ff141, 0x3d5b0360, 0xc7a9ab76, 0x8ead5957, 0x55a04f34, 0x1ca4bd15, - 0x3c651fd6, 0x7561edf7, 0xae6cfb94, 0xe76809b5, 0x1d9aa1a3, 0x549e5382, - 0x8f9345e1, 0xc697b7c0, 0x7f9a633c, 0x369e911d, 0xed93877e, 0xa497755f, - 0x5e65dd49, 0x17612f68, 0xcc6c390b, 0x8568cb2a, 0xbb9be602, 0xf29f1423, - 0x29920240, 0x6096f061, 0x9a645877, 0xd360aa56, 0x086dbc35, 0x41694e14, - 0xf8649ae8, 0xb16068c9, 0x6a6d7eaa, 0x23698c8b, 0xd99b249d, 0x909fd6bc, - 0x4b92c0df, 0x029632fe, 0x36749a8f, 0x7f7068ae, 0xa47d7ecd, 0xed798cec, - 0x178b24fa, 0x5e8fd6db, 0x8582c0b8, 0xcc863299, 0x758be665, 0x3c8f1444, - 0xe7820227, 0xae86f006, 0x54745810, 0x1d70aa31, 0xc67dbc52, 0x8f794e73, - 0xb18a635b, 0xf88e917a, 0x23838719, 0x6a877538, 0x9075dd2e, 0xd9712f0f, - 0x027c396c, 0x4b78cb4d, 0xf2751fb1, 0xbb71ed90, 0x607cfbf3, 0x297809d2, + {0x00000000, 0x4904f221, 0x9209e442, 0xdb0d1663, 0x21ffbe75, 0x68fb4c54, 0xb3f65a37, 0xfaf2a816, 0x43ff7cea, + 0x0afb8ecb, 0xd1f698a8, 0x98f26a89, 0x6200c29f, 0x2b0430be, 0xf00926dd, 0xb90dd4fc, 0x87fef9d4, 0xcefa0bf5, + 0x15f71d96, 0x5cf3efb7, 0xa60147a1, 0xef05b580, 0x3408a3e3, 0x7d0c51c2, 0xc401853e, 0x8d05771f, 0x5608617c, + 0x1f0c935d, 0xe5fe3b4b, 0xacfac96a, 0x77f7df09, 0x3ef32d28, 0x0a118559, 0x43157778, 0x9818611b, 0xd11c933a, + 0x2bee3b2c, 0x62eac90d, 0xb9e7df6e, 0xf0e32d4f, 0x49eef9b3, 0x00ea0b92, 0xdbe71df1, 0x92e3efd0, 0x681147c6, + 0x2115b5e7, 0xfa18a384, 0xb31c51a5, 0x8def7c8d, 0xc4eb8eac, 0x1fe698cf, 0x56e26aee, 0xac10c2f8, 0xe51430d9, + 0x3e1926ba, 0x771dd49b, 0xce100067, 0x8714f246, 0x5c19e425, 0x151d1604, 0xefefbe12, 0xa6eb4c33, 0x7de65a50, + 0x34e2a871, 0x14230ab2, 0x5d27f893, 0x862aeef0, 0xcf2e1cd1, 0x35dcb4c7, 0x7cd846e6, 0xa7d55085, 0xeed1a2a4, + 0x57dc7658, 0x1ed88479, 0xc5d5921a, 0x8cd1603b, 0x7623c82d, 0x3f273a0c, 0xe42a2c6f, 0xad2ede4e, 0x93ddf366, + 0xdad90147, 0x01d41724, 0x48d0e505, 0xb2224d13, 0xfb26bf32, 0x202ba951, 0x692f5b70, 0xd0228f8c, 0x99267dad, + 0x422b6bce, 0x0b2f99ef, 0xf1dd31f9, 0xb8d9c3d8, 0x63d4d5bb, 0x2ad0279a, 0x1e328feb, 0x57367dca, 0x8c3b6ba9, + 0xc53f9988, 0x3fcd319e, 0x76c9c3bf, 0xadc4d5dc, 0xe4c027fd, 0x5dcdf301, 0x14c90120, 0xcfc41743, 0x86c0e562, + 0x7c324d74, 0x3536bf55, 0xee3ba936, 0xa73f5b17, 0x99cc763f, 0xd0c8841e, 0x0bc5927d, 0x42c1605c, 0xb833c84a, + 0xf1373a6b, 0x2a3a2c08, 0x633ede29, 0xda330ad5, 0x9337f8f4, 0x483aee97, 0x013e1cb6, 0xfbccb4a0, 0xb2c84681, + 0x69c550e2, 0x20c1a2c3, 0x28461564, 0x6142e745, 0xba4ff126, 0xf34b0307, 0x09b9ab11, 0x40bd5930, 0x9bb04f53, + 0xd2b4bd72, 0x6bb9698e, 0x22bd9baf, 0xf9b08dcc, 0xb0b47fed, 0x4a46d7fb, 0x034225da, 0xd84f33b9, 0x914bc198, + 0xafb8ecb0, 0xe6bc1e91, 0x3db108f2, 0x74b5fad3, 0x8e4752c5, 0xc743a0e4, 0x1c4eb687, 0x554a44a6, 0xec47905a, + 0xa543627b, 0x7e4e7418, 0x374a8639, 0xcdb82e2f, 0x84bcdc0e, 0x5fb1ca6d, 0x16b5384c, 0x2257903d, 0x6b53621c, + 0xb05e747f, 0xf95a865e, 0x03a82e48, 0x4aacdc69, 0x91a1ca0a, 0xd8a5382b, 0x61a8ecd7, 0x28ac1ef6, 0xf3a10895, + 0xbaa5fab4, 0x405752a2, 0x0953a083, 0xd25eb6e0, 0x9b5a44c1, 0xa5a969e9, 0xecad9bc8, 0x37a08dab, 0x7ea47f8a, + 0x8456d79c, 0xcd5225bd, 0x165f33de, 0x5f5bc1ff, 0xe6561503, 0xaf52e722, 0x745ff141, 0x3d5b0360, 0xc7a9ab76, + 0x8ead5957, 0x55a04f34, 0x1ca4bd15, 0x3c651fd6, 0x7561edf7, 0xae6cfb94, 0xe76809b5, 0x1d9aa1a3, 0x549e5382, + 0x8f9345e1, 0xc697b7c0, 0x7f9a633c, 0x369e911d, 0xed93877e, 0xa497755f, 0x5e65dd49, 0x17612f68, 0xcc6c390b, + 0x8568cb2a, 0xbb9be602, 0xf29f1423, 0x29920240, 0x6096f061, 0x9a645877, 0xd360aa56, 0x086dbc35, 0x41694e14, + 0xf8649ae8, 0xb16068c9, 0x6a6d7eaa, 0x23698c8b, 0xd99b249d, 0x909fd6bc, 0x4b92c0df, 0x029632fe, 0x36749a8f, + 0x7f7068ae, 0xa47d7ecd, 0xed798cec, 0x178b24fa, 0x5e8fd6db, 0x8582c0b8, 0xcc863299, 0x758be665, 0x3c8f1444, + 0xe7820227, 0xae86f006, 0x54745810, 0x1d70aa31, 0xc67dbc52, 0x8f794e73, 0xb18a635b, 0xf88e917a, 0x23838719, + 0x6a877538, 0x9075dd2e, 0xd9712f0f, 0x027c396c, 0x4b78cb4d, 0xf2751fb1, 0xbb71ed90, 0x607cfbf3, 0x297809d2, 0xd38aa1c4, 0x9a8e53e5, 0x41834586, 0x0887b7a7}}; static uint32_t short_shifts[4][256] = { - {0x00000000, 0xdcb17aa4, 0xbc8e83b9, 0x603ff91d, 0x7cf17183, 0xa0400b27, - 0xc07ff23a, 0x1cce889e, 0xf9e2e306, 0x255399a2, 0x456c60bf, 0x99dd1a1b, - 0x85139285, 0x59a2e821, 0x399d113c, 0xe52c6b98, 0xf629b0fd, 0x2a98ca59, - 0x4aa73344, 0x961649e0, 0x8ad8c17e, 0x5669bbda, 0x365642c7, 0xeae73863, - 0x0fcb53fb, 0xd37a295f, 0xb345d042, 0x6ff4aae6, 0x733a2278, 0xaf8b58dc, - 0xcfb4a1c1, 0x1305db65, 0xe9bf170b, 0x350e6daf, 0x553194b2, 0x8980ee16, - 0x954e6688, 0x49ff1c2c, 0x29c0e531, 0xf5719f95, 0x105df40d, 0xccec8ea9, - 0xacd377b4, 0x70620d10, 0x6cac858e, 0xb01dff2a, 0xd0220637, 0x0c937c93, - 0x1f96a7f6, 0xc327dd52, 0xa318244f, 0x7fa95eeb, 0x6367d675, 0xbfd6acd1, - 0xdfe955cc, 0x03582f68, 0xe67444f0, 0x3ac53e54, 0x5afac749, 0x864bbded, - 0x9a853573, 0x46344fd7, 0x260bb6ca, 0xfabacc6e, 0xd69258e7, 0x0a232243, - 0x6a1cdb5e, 0xb6ada1fa, 0xaa632964, 0x76d253c0, 0x16edaadd, 0xca5cd079, - 0x2f70bbe1, 0xf3c1c145, 0x93fe3858, 0x4f4f42fc, 0x5381ca62, 0x8f30b0c6, - 0xef0f49db, 0x33be337f, 0x20bbe81a, 0xfc0a92be, 0x9c356ba3, 0x40841107, - 0x5c4a9999, 0x80fbe33d, 0xe0c41a20, 0x3c756084, 0xd9590b1c, 0x05e871b8, - 0x65d788a5, 0xb966f201, 0xa5a87a9f, 0x7919003b, 0x1926f926, 0xc5978382, - 0x3f2d4fec, 0xe39c3548, 0x83a3cc55, 0x5f12b6f1, 0x43dc3e6f, 0x9f6d44cb, - 0xff52bdd6, 0x23e3c772, 0xc6cfacea, 0x1a7ed64e, 0x7a412f53, 0xa6f055f7, - 0xba3edd69, 0x668fa7cd, 0x06b05ed0, 0xda012474, 0xc904ff11, 0x15b585b5, - 0x758a7ca8, 0xa93b060c, 0xb5f58e92, 0x6944f436, 0x097b0d2b, 0xd5ca778f, - 0x30e61c17, 0xec5766b3, 0x8c689fae, 0x50d9e50a, 0x4c176d94, 0x90a61730, - 0xf099ee2d, 0x2c289489, 0xa8c8c73f, 0x7479bd9b, 0x14464486, 0xc8f73e22, - 0xd439b6bc, 0x0888cc18, 0x68b73505, 0xb4064fa1, 0x512a2439, 0x8d9b5e9d, - 0xeda4a780, 0x3115dd24, 0x2ddb55ba, 0xf16a2f1e, 0x9155d603, 0x4de4aca7, - 0x5ee177c2, 0x82500d66, 0xe26ff47b, 0x3ede8edf, 0x22100641, 0xfea17ce5, - 0x9e9e85f8, 0x422fff5c, 0xa70394c4, 0x7bb2ee60, 0x1b8d177d, 0xc73c6dd9, - 0xdbf2e547, 0x07439fe3, 0x677c66fe, 0xbbcd1c5a, 0x4177d034, 0x9dc6aa90, - 0xfdf9538d, 0x21482929, 0x3d86a1b7, 0xe137db13, 0x8108220e, 0x5db958aa, - 0xb8953332, 0x64244996, 0x041bb08b, 0xd8aaca2f, 0xc46442b1, 0x18d53815, - 0x78eac108, 0xa45bbbac, 0xb75e60c9, 0x6bef1a6d, 0x0bd0e370, 0xd76199d4, - 0xcbaf114a, 0x171e6bee, 0x772192f3, 0xab90e857, 0x4ebc83cf, 0x920df96b, - 0xf2320076, 0x2e837ad2, 0x324df24c, 0xeefc88e8, 0x8ec371f5, 0x52720b51, - 0x7e5a9fd8, 0xa2ebe57c, 0xc2d41c61, 0x1e6566c5, 0x02abee5b, 0xde1a94ff, - 0xbe256de2, 0x62941746, 0x87b87cde, 0x5b09067a, 0x3b36ff67, 0xe78785c3, - 0xfb490d5d, 0x27f877f9, 0x47c78ee4, 0x9b76f440, 0x88732f25, 0x54c25581, - 0x34fdac9c, 0xe84cd638, 0xf4825ea6, 0x28332402, 0x480cdd1f, 0x94bda7bb, - 0x7191cc23, 0xad20b687, 0xcd1f4f9a, 0x11ae353e, 0x0d60bda0, 0xd1d1c704, - 0xb1ee3e19, 0x6d5f44bd, 0x97e588d3, 0x4b54f277, 0x2b6b0b6a, 0xf7da71ce, - 0xeb14f950, 0x37a583f4, 0x579a7ae9, 0x8b2b004d, 0x6e076bd5, 0xb2b61171, - 0xd289e86c, 0x0e3892c8, 0x12f61a56, 0xce4760f2, 0xae7899ef, 0x72c9e34b, - 0x61cc382e, 0xbd7d428a, 0xdd42bb97, 0x01f3c133, 0x1d3d49ad, 0xc18c3309, - 0xa1b3ca14, 0x7d02b0b0, 0x982edb28, 0x449fa18c, 0x24a05891, 0xf8112235, + {0x00000000, 0xdcb17aa4, 0xbc8e83b9, 0x603ff91d, 0x7cf17183, 0xa0400b27, 0xc07ff23a, 0x1cce889e, 0xf9e2e306, + 0x255399a2, 0x456c60bf, 0x99dd1a1b, 0x85139285, 0x59a2e821, 0x399d113c, 0xe52c6b98, 0xf629b0fd, 0x2a98ca59, + 0x4aa73344, 0x961649e0, 0x8ad8c17e, 0x5669bbda, 0x365642c7, 0xeae73863, 0x0fcb53fb, 0xd37a295f, 0xb345d042, + 0x6ff4aae6, 0x733a2278, 0xaf8b58dc, 0xcfb4a1c1, 0x1305db65, 0xe9bf170b, 0x350e6daf, 0x553194b2, 0x8980ee16, + 0x954e6688, 0x49ff1c2c, 0x29c0e531, 0xf5719f95, 0x105df40d, 0xccec8ea9, 0xacd377b4, 0x70620d10, 0x6cac858e, + 0xb01dff2a, 0xd0220637, 0x0c937c93, 0x1f96a7f6, 0xc327dd52, 0xa318244f, 0x7fa95eeb, 0x6367d675, 0xbfd6acd1, + 0xdfe955cc, 0x03582f68, 0xe67444f0, 0x3ac53e54, 0x5afac749, 0x864bbded, 0x9a853573, 0x46344fd7, 0x260bb6ca, + 0xfabacc6e, 0xd69258e7, 0x0a232243, 0x6a1cdb5e, 0xb6ada1fa, 0xaa632964, 0x76d253c0, 0x16edaadd, 0xca5cd079, + 0x2f70bbe1, 0xf3c1c145, 0x93fe3858, 0x4f4f42fc, 0x5381ca62, 0x8f30b0c6, 0xef0f49db, 0x33be337f, 0x20bbe81a, + 0xfc0a92be, 0x9c356ba3, 0x40841107, 0x5c4a9999, 0x80fbe33d, 0xe0c41a20, 0x3c756084, 0xd9590b1c, 0x05e871b8, + 0x65d788a5, 0xb966f201, 0xa5a87a9f, 0x7919003b, 0x1926f926, 0xc5978382, 0x3f2d4fec, 0xe39c3548, 0x83a3cc55, + 0x5f12b6f1, 0x43dc3e6f, 0x9f6d44cb, 0xff52bdd6, 0x23e3c772, 0xc6cfacea, 0x1a7ed64e, 0x7a412f53, 0xa6f055f7, + 0xba3edd69, 0x668fa7cd, 0x06b05ed0, 0xda012474, 0xc904ff11, 0x15b585b5, 0x758a7ca8, 0xa93b060c, 0xb5f58e92, + 0x6944f436, 0x097b0d2b, 0xd5ca778f, 0x30e61c17, 0xec5766b3, 0x8c689fae, 0x50d9e50a, 0x4c176d94, 0x90a61730, + 0xf099ee2d, 0x2c289489, 0xa8c8c73f, 0x7479bd9b, 0x14464486, 0xc8f73e22, 0xd439b6bc, 0x0888cc18, 0x68b73505, + 0xb4064fa1, 0x512a2439, 0x8d9b5e9d, 0xeda4a780, 0x3115dd24, 0x2ddb55ba, 0xf16a2f1e, 0x9155d603, 0x4de4aca7, + 0x5ee177c2, 0x82500d66, 0xe26ff47b, 0x3ede8edf, 0x22100641, 0xfea17ce5, 0x9e9e85f8, 0x422fff5c, 0xa70394c4, + 0x7bb2ee60, 0x1b8d177d, 0xc73c6dd9, 0xdbf2e547, 0x07439fe3, 0x677c66fe, 0xbbcd1c5a, 0x4177d034, 0x9dc6aa90, + 0xfdf9538d, 0x21482929, 0x3d86a1b7, 0xe137db13, 0x8108220e, 0x5db958aa, 0xb8953332, 0x64244996, 0x041bb08b, + 0xd8aaca2f, 0xc46442b1, 0x18d53815, 0x78eac108, 0xa45bbbac, 0xb75e60c9, 0x6bef1a6d, 0x0bd0e370, 0xd76199d4, + 0xcbaf114a, 0x171e6bee, 0x772192f3, 0xab90e857, 0x4ebc83cf, 0x920df96b, 0xf2320076, 0x2e837ad2, 0x324df24c, + 0xeefc88e8, 0x8ec371f5, 0x52720b51, 0x7e5a9fd8, 0xa2ebe57c, 0xc2d41c61, 0x1e6566c5, 0x02abee5b, 0xde1a94ff, + 0xbe256de2, 0x62941746, 0x87b87cde, 0x5b09067a, 0x3b36ff67, 0xe78785c3, 0xfb490d5d, 0x27f877f9, 0x47c78ee4, + 0x9b76f440, 0x88732f25, 0x54c25581, 0x34fdac9c, 0xe84cd638, 0xf4825ea6, 0x28332402, 0x480cdd1f, 0x94bda7bb, + 0x7191cc23, 0xad20b687, 0xcd1f4f9a, 0x11ae353e, 0x0d60bda0, 0xd1d1c704, 0xb1ee3e19, 0x6d5f44bd, 0x97e588d3, + 0x4b54f277, 0x2b6b0b6a, 0xf7da71ce, 0xeb14f950, 0x37a583f4, 0x579a7ae9, 0x8b2b004d, 0x6e076bd5, 0xb2b61171, + 0xd289e86c, 0x0e3892c8, 0x12f61a56, 0xce4760f2, 0xae7899ef, 0x72c9e34b, 0x61cc382e, 0xbd7d428a, 0xdd42bb97, + 0x01f3c133, 0x1d3d49ad, 0xc18c3309, 0xa1b3ca14, 0x7d02b0b0, 0x982edb28, 0x449fa18c, 0x24a05891, 0xf8112235, 0xe4dfaaab, 0x386ed00f, 0x58512912, 0x84e053b6}, - {0x00000000, 0x547df88f, 0xa8fbf11e, 0xfc860991, 0x541b94cd, 0x00666c42, - 0xfce065d3, 0xa89d9d5c, 0xa837299a, 0xfc4ad115, 0x00ccd884, 0x54b1200b, - 0xfc2cbd57, 0xa85145d8, 0x54d74c49, 0x00aab4c6, 0x558225c5, 0x01ffdd4a, - 0xfd79d4db, 0xa9042c54, 0x0199b108, 0x55e44987, 0xa9624016, 0xfd1fb899, - 0xfdb50c5f, 0xa9c8f4d0, 0x554efd41, 0x013305ce, 0xa9ae9892, 0xfdd3601d, - 0x0155698c, 0x55289103, 0xab044b8a, 0xff79b305, 0x03ffba94, 0x5782421b, - 0xff1fdf47, 0xab6227c8, 0x57e42e59, 0x0399d6d6, 0x03336210, 0x574e9a9f, - 0xabc8930e, 0xffb56b81, 0x5728f6dd, 0x03550e52, 0xffd307c3, 0xabaeff4c, - 0xfe866e4f, 0xaafb96c0, 0x567d9f51, 0x020067de, 0xaa9dfa82, 0xfee0020d, - 0x02660b9c, 0x561bf313, 0x56b147d5, 0x02ccbf5a, 0xfe4ab6cb, 0xaa374e44, - 0x02aad318, 0x56d72b97, 0xaa512206, 0xfe2cda89, 0x53e4e1e5, 0x0799196a, - 0xfb1f10fb, 0xaf62e874, 0x07ff7528, 0x53828da7, 0xaf048436, 0xfb797cb9, - 0xfbd3c87f, 0xafae30f0, 0x53283961, 0x0755c1ee, 0xafc85cb2, 0xfbb5a43d, - 0x0733adac, 0x534e5523, 0x0666c420, 0x521b3caf, 0xae9d353e, 0xfae0cdb1, - 0x527d50ed, 0x0600a862, 0xfa86a1f3, 0xaefb597c, 0xae51edba, 0xfa2c1535, - 0x06aa1ca4, 0x52d7e42b, 0xfa4a7977, 0xae3781f8, 0x52b18869, 0x06cc70e6, - 0xf8e0aa6f, 0xac9d52e0, 0x501b5b71, 0x0466a3fe, 0xacfb3ea2, 0xf886c62d, - 0x0400cfbc, 0x507d3733, 0x50d783f5, 0x04aa7b7a, 0xf82c72eb, 0xac518a64, - 0x04cc1738, 0x50b1efb7, 0xac37e626, 0xf84a1ea9, 0xad628faa, 0xf91f7725, - 0x05997eb4, 0x51e4863b, 0xf9791b67, 0xad04e3e8, 0x5182ea79, 0x05ff12f6, - 0x0555a630, 0x51285ebf, 0xadae572e, 0xf9d3afa1, 0x514e32fd, 0x0533ca72, - 0xf9b5c3e3, 0xadc83b6c, 0xa7c9c3ca, 0xf3b43b45, 0x0f3232d4, 0x5b4fca5b, - 0xf3d25707, 0xa7afaf88, 0x5b29a619, 0x0f545e96, 0x0ffeea50, 0x5b8312df, - 0xa7051b4e, 0xf378e3c1, 0x5be57e9d, 0x0f988612, 0xf31e8f83, 0xa763770c, - 0xf24be60f, 0xa6361e80, 0x5ab01711, 0x0ecdef9e, 0xa65072c2, 0xf22d8a4d, - 0x0eab83dc, 0x5ad67b53, 0x5a7ccf95, 0x0e01371a, 0xf2873e8b, 0xa6fac604, - 0x0e675b58, 0x5a1aa3d7, 0xa69caa46, 0xf2e152c9, 0x0ccd8840, 0x58b070cf, - 0xa436795e, 0xf04b81d1, 0x58d61c8d, 0x0cabe402, 0xf02ded93, 0xa450151c, - 0xa4faa1da, 0xf0875955, 0x0c0150c4, 0x587ca84b, 0xf0e13517, 0xa49ccd98, - 0x581ac409, 0x0c673c86, 0x594fad85, 0x0d32550a, 0xf1b45c9b, 0xa5c9a414, - 0x0d543948, 0x5929c1c7, 0xa5afc856, 0xf1d230d9, 0xf178841f, 0xa5057c90, - 0x59837501, 0x0dfe8d8e, 0xa56310d2, 0xf11ee85d, 0x0d98e1cc, 0x59e51943, - 0xf42d222f, 0xa050daa0, 0x5cd6d331, 0x08ab2bbe, 0xa036b6e2, 0xf44b4e6d, - 0x08cd47fc, 0x5cb0bf73, 0x5c1a0bb5, 0x0867f33a, 0xf4e1faab, 0xa09c0224, - 0x08019f78, 0x5c7c67f7, 0xa0fa6e66, 0xf48796e9, 0xa1af07ea, 0xf5d2ff65, - 0x0954f6f4, 0x5d290e7b, 0xf5b49327, 0xa1c96ba8, 0x5d4f6239, 0x09329ab6, - 0x09982e70, 0x5de5d6ff, 0xa163df6e, 0xf51e27e1, 0x5d83babd, 0x09fe4232, - 0xf5784ba3, 0xa105b32c, 0x5f2969a5, 0x0b54912a, 0xf7d298bb, 0xa3af6034, - 0x0b32fd68, 0x5f4f05e7, 0xa3c90c76, 0xf7b4f4f9, 0xf71e403f, 0xa363b8b0, - 0x5fe5b121, 0x0b9849ae, 0xa305d4f2, 0xf7782c7d, 0x0bfe25ec, 0x5f83dd63, - 0x0aab4c60, 0x5ed6b4ef, 0xa250bd7e, 0xf62d45f1, 0x5eb0d8ad, 0x0acd2022, - 0xf64b29b3, 0xa236d13c, 0xa29c65fa, 0xf6e19d75, 0x0a6794e4, 0x5e1a6c6b, + {0x00000000, 0x547df88f, 0xa8fbf11e, 0xfc860991, 0x541b94cd, 0x00666c42, 0xfce065d3, 0xa89d9d5c, 0xa837299a, + 0xfc4ad115, 0x00ccd884, 0x54b1200b, 0xfc2cbd57, 0xa85145d8, 0x54d74c49, 0x00aab4c6, 0x558225c5, 0x01ffdd4a, + 0xfd79d4db, 0xa9042c54, 0x0199b108, 0x55e44987, 0xa9624016, 0xfd1fb899, 0xfdb50c5f, 0xa9c8f4d0, 0x554efd41, + 0x013305ce, 0xa9ae9892, 0xfdd3601d, 0x0155698c, 0x55289103, 0xab044b8a, 0xff79b305, 0x03ffba94, 0x5782421b, + 0xff1fdf47, 0xab6227c8, 0x57e42e59, 0x0399d6d6, 0x03336210, 0x574e9a9f, 0xabc8930e, 0xffb56b81, 0x5728f6dd, + 0x03550e52, 0xffd307c3, 0xabaeff4c, 0xfe866e4f, 0xaafb96c0, 0x567d9f51, 0x020067de, 0xaa9dfa82, 0xfee0020d, + 0x02660b9c, 0x561bf313, 0x56b147d5, 0x02ccbf5a, 0xfe4ab6cb, 0xaa374e44, 0x02aad318, 0x56d72b97, 0xaa512206, + 0xfe2cda89, 0x53e4e1e5, 0x0799196a, 0xfb1f10fb, 0xaf62e874, 0x07ff7528, 0x53828da7, 0xaf048436, 0xfb797cb9, + 0xfbd3c87f, 0xafae30f0, 0x53283961, 0x0755c1ee, 0xafc85cb2, 0xfbb5a43d, 0x0733adac, 0x534e5523, 0x0666c420, + 0x521b3caf, 0xae9d353e, 0xfae0cdb1, 0x527d50ed, 0x0600a862, 0xfa86a1f3, 0xaefb597c, 0xae51edba, 0xfa2c1535, + 0x06aa1ca4, 0x52d7e42b, 0xfa4a7977, 0xae3781f8, 0x52b18869, 0x06cc70e6, 0xf8e0aa6f, 0xac9d52e0, 0x501b5b71, + 0x0466a3fe, 0xacfb3ea2, 0xf886c62d, 0x0400cfbc, 0x507d3733, 0x50d783f5, 0x04aa7b7a, 0xf82c72eb, 0xac518a64, + 0x04cc1738, 0x50b1efb7, 0xac37e626, 0xf84a1ea9, 0xad628faa, 0xf91f7725, 0x05997eb4, 0x51e4863b, 0xf9791b67, + 0xad04e3e8, 0x5182ea79, 0x05ff12f6, 0x0555a630, 0x51285ebf, 0xadae572e, 0xf9d3afa1, 0x514e32fd, 0x0533ca72, + 0xf9b5c3e3, 0xadc83b6c, 0xa7c9c3ca, 0xf3b43b45, 0x0f3232d4, 0x5b4fca5b, 0xf3d25707, 0xa7afaf88, 0x5b29a619, + 0x0f545e96, 0x0ffeea50, 0x5b8312df, 0xa7051b4e, 0xf378e3c1, 0x5be57e9d, 0x0f988612, 0xf31e8f83, 0xa763770c, + 0xf24be60f, 0xa6361e80, 0x5ab01711, 0x0ecdef9e, 0xa65072c2, 0xf22d8a4d, 0x0eab83dc, 0x5ad67b53, 0x5a7ccf95, + 0x0e01371a, 0xf2873e8b, 0xa6fac604, 0x0e675b58, 0x5a1aa3d7, 0xa69caa46, 0xf2e152c9, 0x0ccd8840, 0x58b070cf, + 0xa436795e, 0xf04b81d1, 0x58d61c8d, 0x0cabe402, 0xf02ded93, 0xa450151c, 0xa4faa1da, 0xf0875955, 0x0c0150c4, + 0x587ca84b, 0xf0e13517, 0xa49ccd98, 0x581ac409, 0x0c673c86, 0x594fad85, 0x0d32550a, 0xf1b45c9b, 0xa5c9a414, + 0x0d543948, 0x5929c1c7, 0xa5afc856, 0xf1d230d9, 0xf178841f, 0xa5057c90, 0x59837501, 0x0dfe8d8e, 0xa56310d2, + 0xf11ee85d, 0x0d98e1cc, 0x59e51943, 0xf42d222f, 0xa050daa0, 0x5cd6d331, 0x08ab2bbe, 0xa036b6e2, 0xf44b4e6d, + 0x08cd47fc, 0x5cb0bf73, 0x5c1a0bb5, 0x0867f33a, 0xf4e1faab, 0xa09c0224, 0x08019f78, 0x5c7c67f7, 0xa0fa6e66, + 0xf48796e9, 0xa1af07ea, 0xf5d2ff65, 0x0954f6f4, 0x5d290e7b, 0xf5b49327, 0xa1c96ba8, 0x5d4f6239, 0x09329ab6, + 0x09982e70, 0x5de5d6ff, 0xa163df6e, 0xf51e27e1, 0x5d83babd, 0x09fe4232, 0xf5784ba3, 0xa105b32c, 0x5f2969a5, + 0x0b54912a, 0xf7d298bb, 0xa3af6034, 0x0b32fd68, 0x5f4f05e7, 0xa3c90c76, 0xf7b4f4f9, 0xf71e403f, 0xa363b8b0, + 0x5fe5b121, 0x0b9849ae, 0xa305d4f2, 0xf7782c7d, 0x0bfe25ec, 0x5f83dd63, 0x0aab4c60, 0x5ed6b4ef, 0xa250bd7e, + 0xf62d45f1, 0x5eb0d8ad, 0x0acd2022, 0xf64b29b3, 0xa236d13c, 0xa29c65fa, 0xf6e19d75, 0x0a6794e4, 0x5e1a6c6b, 0xf687f137, 0xa2fa09b8, 0x5e7c0029, 0x0a01f8a6}, - {0x00000000, 0x4a7ff165, 0x94ffe2ca, 0xde8013af, 0x2c13b365, 0x666c4200, - 0xb8ec51af, 0xf293a0ca, 0x582766ca, 0x125897af, 0xccd88400, 0x86a77565, - 0x7434d5af, 0x3e4b24ca, 0xe0cb3765, 0xaab4c600, 0xb04ecd94, 0xfa313cf1, - 0x24b12f5e, 0x6ecede3b, 0x9c5d7ef1, 0xd6228f94, 0x08a29c3b, 0x42dd6d5e, - 0xe869ab5e, 0xa2165a3b, 0x7c964994, 0x36e9b8f1, 0xc47a183b, 0x8e05e95e, - 0x5085faf1, 0x1afa0b94, 0x6571edd9, 0x2f0e1cbc, 0xf18e0f13, 0xbbf1fe76, - 0x49625ebc, 0x031dafd9, 0xdd9dbc76, 0x97e24d13, 0x3d568b13, 0x77297a76, - 0xa9a969d9, 0xe3d698bc, 0x11453876, 0x5b3ac913, 0x85badabc, 0xcfc52bd9, - 0xd53f204d, 0x9f40d128, 0x41c0c287, 0x0bbf33e2, 0xf92c9328, 0xb353624d, - 0x6dd371e2, 0x27ac8087, 0x8d184687, 0xc767b7e2, 0x19e7a44d, 0x53985528, - 0xa10bf5e2, 0xeb740487, 0x35f41728, 0x7f8be64d, 0xcae3dbb2, 0x809c2ad7, - 0x5e1c3978, 0x1463c81d, 0xe6f068d7, 0xac8f99b2, 0x720f8a1d, 0x38707b78, - 0x92c4bd78, 0xd8bb4c1d, 0x063b5fb2, 0x4c44aed7, 0xbed70e1d, 0xf4a8ff78, - 0x2a28ecd7, 0x60571db2, 0x7aad1626, 0x30d2e743, 0xee52f4ec, 0xa42d0589, - 0x56bea543, 0x1cc15426, 0xc2414789, 0x883eb6ec, 0x228a70ec, 0x68f58189, - 0xb6759226, 0xfc0a6343, 0x0e99c389, 0x44e632ec, 0x9a662143, 0xd019d026, - 0xaf92366b, 0xe5edc70e, 0x3b6dd4a1, 0x711225c4, 0x8381850e, 0xc9fe746b, - 0x177e67c4, 0x5d0196a1, 0xf7b550a1, 0xbdcaa1c4, 0x634ab26b, 0x2935430e, - 0xdba6e3c4, 0x91d912a1, 0x4f59010e, 0x0526f06b, 0x1fdcfbff, 0x55a30a9a, - 0x8b231935, 0xc15ce850, 0x33cf489a, 0x79b0b9ff, 0xa730aa50, 0xed4f5b35, - 0x47fb9d35, 0x0d846c50, 0xd3047fff, 0x997b8e9a, 0x6be82e50, 0x2197df35, - 0xff17cc9a, 0xb5683dff, 0x902bc195, 0xda5430f0, 0x04d4235f, 0x4eabd23a, - 0xbc3872f0, 0xf6478395, 0x28c7903a, 0x62b8615f, 0xc80ca75f, 0x8273563a, - 0x5cf34595, 0x168cb4f0, 0xe41f143a, 0xae60e55f, 0x70e0f6f0, 0x3a9f0795, - 0x20650c01, 0x6a1afd64, 0xb49aeecb, 0xfee51fae, 0x0c76bf64, 0x46094e01, - 0x98895dae, 0xd2f6accb, 0x78426acb, 0x323d9bae, 0xecbd8801, 0xa6c27964, - 0x5451d9ae, 0x1e2e28cb, 0xc0ae3b64, 0x8ad1ca01, 0xf55a2c4c, 0xbf25dd29, - 0x61a5ce86, 0x2bda3fe3, 0xd9499f29, 0x93366e4c, 0x4db67de3, 0x07c98c86, - 0xad7d4a86, 0xe702bbe3, 0x3982a84c, 0x73fd5929, 0x816ef9e3, 0xcb110886, - 0x15911b29, 0x5feeea4c, 0x4514e1d8, 0x0f6b10bd, 0xd1eb0312, 0x9b94f277, - 0x690752bd, 0x2378a3d8, 0xfdf8b077, 0xb7874112, 0x1d338712, 0x574c7677, - 0x89cc65d8, 0xc3b394bd, 0x31203477, 0x7b5fc512, 0xa5dfd6bd, 0xefa027d8, - 0x5ac81a27, 0x10b7eb42, 0xce37f8ed, 0x84480988, 0x76dba942, 0x3ca45827, - 0xe2244b88, 0xa85bbaed, 0x02ef7ced, 0x48908d88, 0x96109e27, 0xdc6f6f42, - 0x2efccf88, 0x64833eed, 0xba032d42, 0xf07cdc27, 0xea86d7b3, 0xa0f926d6, - 0x7e793579, 0x3406c41c, 0xc69564d6, 0x8cea95b3, 0x526a861c, 0x18157779, - 0xb2a1b179, 0xf8de401c, 0x265e53b3, 0x6c21a2d6, 0x9eb2021c, 0xd4cdf379, - 0x0a4de0d6, 0x403211b3, 0x3fb9f7fe, 0x75c6069b, 0xab461534, 0xe139e451, - 0x13aa449b, 0x59d5b5fe, 0x8755a651, 0xcd2a5734, 0x679e9134, 0x2de16051, - 0xf36173fe, 0xb91e829b, 0x4b8d2251, 0x01f2d334, 0xdf72c09b, 0x950d31fe, - 0x8ff73a6a, 0xc588cb0f, 0x1b08d8a0, 0x517729c5, 0xa3e4890f, 0xe99b786a, - 0x371b6bc5, 0x7d649aa0, 0xd7d05ca0, 0x9dafadc5, 0x432fbe6a, 0x09504f0f, + {0x00000000, 0x4a7ff165, 0x94ffe2ca, 0xde8013af, 0x2c13b365, 0x666c4200, 0xb8ec51af, 0xf293a0ca, 0x582766ca, + 0x125897af, 0xccd88400, 0x86a77565, 0x7434d5af, 0x3e4b24ca, 0xe0cb3765, 0xaab4c600, 0xb04ecd94, 0xfa313cf1, + 0x24b12f5e, 0x6ecede3b, 0x9c5d7ef1, 0xd6228f94, 0x08a29c3b, 0x42dd6d5e, 0xe869ab5e, 0xa2165a3b, 0x7c964994, + 0x36e9b8f1, 0xc47a183b, 0x8e05e95e, 0x5085faf1, 0x1afa0b94, 0x6571edd9, 0x2f0e1cbc, 0xf18e0f13, 0xbbf1fe76, + 0x49625ebc, 0x031dafd9, 0xdd9dbc76, 0x97e24d13, 0x3d568b13, 0x77297a76, 0xa9a969d9, 0xe3d698bc, 0x11453876, + 0x5b3ac913, 0x85badabc, 0xcfc52bd9, 0xd53f204d, 0x9f40d128, 0x41c0c287, 0x0bbf33e2, 0xf92c9328, 0xb353624d, + 0x6dd371e2, 0x27ac8087, 0x8d184687, 0xc767b7e2, 0x19e7a44d, 0x53985528, 0xa10bf5e2, 0xeb740487, 0x35f41728, + 0x7f8be64d, 0xcae3dbb2, 0x809c2ad7, 0x5e1c3978, 0x1463c81d, 0xe6f068d7, 0xac8f99b2, 0x720f8a1d, 0x38707b78, + 0x92c4bd78, 0xd8bb4c1d, 0x063b5fb2, 0x4c44aed7, 0xbed70e1d, 0xf4a8ff78, 0x2a28ecd7, 0x60571db2, 0x7aad1626, + 0x30d2e743, 0xee52f4ec, 0xa42d0589, 0x56bea543, 0x1cc15426, 0xc2414789, 0x883eb6ec, 0x228a70ec, 0x68f58189, + 0xb6759226, 0xfc0a6343, 0x0e99c389, 0x44e632ec, 0x9a662143, 0xd019d026, 0xaf92366b, 0xe5edc70e, 0x3b6dd4a1, + 0x711225c4, 0x8381850e, 0xc9fe746b, 0x177e67c4, 0x5d0196a1, 0xf7b550a1, 0xbdcaa1c4, 0x634ab26b, 0x2935430e, + 0xdba6e3c4, 0x91d912a1, 0x4f59010e, 0x0526f06b, 0x1fdcfbff, 0x55a30a9a, 0x8b231935, 0xc15ce850, 0x33cf489a, + 0x79b0b9ff, 0xa730aa50, 0xed4f5b35, 0x47fb9d35, 0x0d846c50, 0xd3047fff, 0x997b8e9a, 0x6be82e50, 0x2197df35, + 0xff17cc9a, 0xb5683dff, 0x902bc195, 0xda5430f0, 0x04d4235f, 0x4eabd23a, 0xbc3872f0, 0xf6478395, 0x28c7903a, + 0x62b8615f, 0xc80ca75f, 0x8273563a, 0x5cf34595, 0x168cb4f0, 0xe41f143a, 0xae60e55f, 0x70e0f6f0, 0x3a9f0795, + 0x20650c01, 0x6a1afd64, 0xb49aeecb, 0xfee51fae, 0x0c76bf64, 0x46094e01, 0x98895dae, 0xd2f6accb, 0x78426acb, + 0x323d9bae, 0xecbd8801, 0xa6c27964, 0x5451d9ae, 0x1e2e28cb, 0xc0ae3b64, 0x8ad1ca01, 0xf55a2c4c, 0xbf25dd29, + 0x61a5ce86, 0x2bda3fe3, 0xd9499f29, 0x93366e4c, 0x4db67de3, 0x07c98c86, 0xad7d4a86, 0xe702bbe3, 0x3982a84c, + 0x73fd5929, 0x816ef9e3, 0xcb110886, 0x15911b29, 0x5feeea4c, 0x4514e1d8, 0x0f6b10bd, 0xd1eb0312, 0x9b94f277, + 0x690752bd, 0x2378a3d8, 0xfdf8b077, 0xb7874112, 0x1d338712, 0x574c7677, 0x89cc65d8, 0xc3b394bd, 0x31203477, + 0x7b5fc512, 0xa5dfd6bd, 0xefa027d8, 0x5ac81a27, 0x10b7eb42, 0xce37f8ed, 0x84480988, 0x76dba942, 0x3ca45827, + 0xe2244b88, 0xa85bbaed, 0x02ef7ced, 0x48908d88, 0x96109e27, 0xdc6f6f42, 0x2efccf88, 0x64833eed, 0xba032d42, + 0xf07cdc27, 0xea86d7b3, 0xa0f926d6, 0x7e793579, 0x3406c41c, 0xc69564d6, 0x8cea95b3, 0x526a861c, 0x18157779, + 0xb2a1b179, 0xf8de401c, 0x265e53b3, 0x6c21a2d6, 0x9eb2021c, 0xd4cdf379, 0x0a4de0d6, 0x403211b3, 0x3fb9f7fe, + 0x75c6069b, 0xab461534, 0xe139e451, 0x13aa449b, 0x59d5b5fe, 0x8755a651, 0xcd2a5734, 0x679e9134, 0x2de16051, + 0xf36173fe, 0xb91e829b, 0x4b8d2251, 0x01f2d334, 0xdf72c09b, 0x950d31fe, 0x8ff73a6a, 0xc588cb0f, 0x1b08d8a0, + 0x517729c5, 0xa3e4890f, 0xe99b786a, 0x371b6bc5, 0x7d649aa0, 0xd7d05ca0, 0x9dafadc5, 0x432fbe6a, 0x09504f0f, 0xfbc3efc5, 0xb1bc1ea0, 0x6f3c0d0f, 0x2543fc6a}, - {0x00000000, 0x25bbf5db, 0x4b77ebb6, 0x6ecc1e6d, 0x96efd76c, 0xb35422b7, - 0xdd983cda, 0xf823c901, 0x2833d829, 0x0d882df2, 0x6344339f, 0x46ffc644, - 0xbedc0f45, 0x9b67fa9e, 0xf5abe4f3, 0xd0101128, 0x5067b052, 0x75dc4589, - 0x1b105be4, 0x3eabae3f, 0xc688673e, 0xe33392e5, 0x8dff8c88, 0xa8447953, - 0x7854687b, 0x5def9da0, 0x332383cd, 0x16987616, 0xeebbbf17, 0xcb004acc, - 0xa5cc54a1, 0x8077a17a, 0xa0cf60a4, 0x8574957f, 0xebb88b12, 0xce037ec9, - 0x3620b7c8, 0x139b4213, 0x7d575c7e, 0x58eca9a5, 0x88fcb88d, 0xad474d56, - 0xc38b533b, 0xe630a6e0, 0x1e136fe1, 0x3ba89a3a, 0x55648457, 0x70df718c, - 0xf0a8d0f6, 0xd513252d, 0xbbdf3b40, 0x9e64ce9b, 0x6647079a, 0x43fcf241, - 0x2d30ec2c, 0x088b19f7, 0xd89b08df, 0xfd20fd04, 0x93ece369, 0xb65716b2, - 0x4e74dfb3, 0x6bcf2a68, 0x05033405, 0x20b8c1de, 0x4472b7b9, 0x61c94262, - 0x0f055c0f, 0x2abea9d4, 0xd29d60d5, 0xf726950e, 0x99ea8b63, 0xbc517eb8, - 0x6c416f90, 0x49fa9a4b, 0x27368426, 0x028d71fd, 0xfaaeb8fc, 0xdf154d27, - 0xb1d9534a, 0x9462a691, 0x141507eb, 0x31aef230, 0x5f62ec5d, 0x7ad91986, - 0x82fad087, 0xa741255c, 0xc98d3b31, 0xec36ceea, 0x3c26dfc2, 0x199d2a19, - 0x77513474, 0x52eac1af, 0xaac908ae, 0x8f72fd75, 0xe1bee318, 0xc40516c3, - 0xe4bdd71d, 0xc10622c6, 0xafca3cab, 0x8a71c970, 0x72520071, 0x57e9f5aa, - 0x3925ebc7, 0x1c9e1e1c, 0xcc8e0f34, 0xe935faef, 0x87f9e482, 0xa2421159, - 0x5a61d858, 0x7fda2d83, 0x111633ee, 0x34adc635, 0xb4da674f, 0x91619294, - 0xffad8cf9, 0xda167922, 0x2235b023, 0x078e45f8, 0x69425b95, 0x4cf9ae4e, - 0x9ce9bf66, 0xb9524abd, 0xd79e54d0, 0xf225a10b, 0x0a06680a, 0x2fbd9dd1, - 0x417183bc, 0x64ca7667, 0x88e56f72, 0xad5e9aa9, 0xc39284c4, 0xe629711f, - 0x1e0ab81e, 0x3bb14dc5, 0x557d53a8, 0x70c6a673, 0xa0d6b75b, 0x856d4280, - 0xeba15ced, 0xce1aa936, 0x36396037, 0x138295ec, 0x7d4e8b81, 0x58f57e5a, - 0xd882df20, 0xfd392afb, 0x93f53496, 0xb64ec14d, 0x4e6d084c, 0x6bd6fd97, - 0x051ae3fa, 0x20a11621, 0xf0b10709, 0xd50af2d2, 0xbbc6ecbf, 0x9e7d1964, - 0x665ed065, 0x43e525be, 0x2d293bd3, 0x0892ce08, 0x282a0fd6, 0x0d91fa0d, - 0x635de460, 0x46e611bb, 0xbec5d8ba, 0x9b7e2d61, 0xf5b2330c, 0xd009c6d7, - 0x0019d7ff, 0x25a22224, 0x4b6e3c49, 0x6ed5c992, 0x96f60093, 0xb34df548, - 0xdd81eb25, 0xf83a1efe, 0x784dbf84, 0x5df64a5f, 0x333a5432, 0x1681a1e9, - 0xeea268e8, 0xcb199d33, 0xa5d5835e, 0x806e7685, 0x507e67ad, 0x75c59276, - 0x1b098c1b, 0x3eb279c0, 0xc691b0c1, 0xe32a451a, 0x8de65b77, 0xa85daeac, - 0xcc97d8cb, 0xe92c2d10, 0x87e0337d, 0xa25bc6a6, 0x5a780fa7, 0x7fc3fa7c, - 0x110fe411, 0x34b411ca, 0xe4a400e2, 0xc11ff539, 0xafd3eb54, 0x8a681e8f, - 0x724bd78e, 0x57f02255, 0x393c3c38, 0x1c87c9e3, 0x9cf06899, 0xb94b9d42, - 0xd787832f, 0xf23c76f4, 0x0a1fbff5, 0x2fa44a2e, 0x41685443, 0x64d3a198, - 0xb4c3b0b0, 0x9178456b, 0xffb45b06, 0xda0faedd, 0x222c67dc, 0x07979207, - 0x695b8c6a, 0x4ce079b1, 0x6c58b86f, 0x49e34db4, 0x272f53d9, 0x0294a602, - 0xfab76f03, 0xdf0c9ad8, 0xb1c084b5, 0x947b716e, 0x446b6046, 0x61d0959d, - 0x0f1c8bf0, 0x2aa77e2b, 0xd284b72a, 0xf73f42f1, 0x99f35c9c, 0xbc48a947, - 0x3c3f083d, 0x1984fde6, 0x7748e38b, 0x52f31650, 0xaad0df51, 0x8f6b2a8a, - 0xe1a734e7, 0xc41cc13c, 0x140cd014, 0x31b725cf, 0x5f7b3ba2, 0x7ac0ce79, + {0x00000000, 0x25bbf5db, 0x4b77ebb6, 0x6ecc1e6d, 0x96efd76c, 0xb35422b7, 0xdd983cda, 0xf823c901, 0x2833d829, + 0x0d882df2, 0x6344339f, 0x46ffc644, 0xbedc0f45, 0x9b67fa9e, 0xf5abe4f3, 0xd0101128, 0x5067b052, 0x75dc4589, + 0x1b105be4, 0x3eabae3f, 0xc688673e, 0xe33392e5, 0x8dff8c88, 0xa8447953, 0x7854687b, 0x5def9da0, 0x332383cd, + 0x16987616, 0xeebbbf17, 0xcb004acc, 0xa5cc54a1, 0x8077a17a, 0xa0cf60a4, 0x8574957f, 0xebb88b12, 0xce037ec9, + 0x3620b7c8, 0x139b4213, 0x7d575c7e, 0x58eca9a5, 0x88fcb88d, 0xad474d56, 0xc38b533b, 0xe630a6e0, 0x1e136fe1, + 0x3ba89a3a, 0x55648457, 0x70df718c, 0xf0a8d0f6, 0xd513252d, 0xbbdf3b40, 0x9e64ce9b, 0x6647079a, 0x43fcf241, + 0x2d30ec2c, 0x088b19f7, 0xd89b08df, 0xfd20fd04, 0x93ece369, 0xb65716b2, 0x4e74dfb3, 0x6bcf2a68, 0x05033405, + 0x20b8c1de, 0x4472b7b9, 0x61c94262, 0x0f055c0f, 0x2abea9d4, 0xd29d60d5, 0xf726950e, 0x99ea8b63, 0xbc517eb8, + 0x6c416f90, 0x49fa9a4b, 0x27368426, 0x028d71fd, 0xfaaeb8fc, 0xdf154d27, 0xb1d9534a, 0x9462a691, 0x141507eb, + 0x31aef230, 0x5f62ec5d, 0x7ad91986, 0x82fad087, 0xa741255c, 0xc98d3b31, 0xec36ceea, 0x3c26dfc2, 0x199d2a19, + 0x77513474, 0x52eac1af, 0xaac908ae, 0x8f72fd75, 0xe1bee318, 0xc40516c3, 0xe4bdd71d, 0xc10622c6, 0xafca3cab, + 0x8a71c970, 0x72520071, 0x57e9f5aa, 0x3925ebc7, 0x1c9e1e1c, 0xcc8e0f34, 0xe935faef, 0x87f9e482, 0xa2421159, + 0x5a61d858, 0x7fda2d83, 0x111633ee, 0x34adc635, 0xb4da674f, 0x91619294, 0xffad8cf9, 0xda167922, 0x2235b023, + 0x078e45f8, 0x69425b95, 0x4cf9ae4e, 0x9ce9bf66, 0xb9524abd, 0xd79e54d0, 0xf225a10b, 0x0a06680a, 0x2fbd9dd1, + 0x417183bc, 0x64ca7667, 0x88e56f72, 0xad5e9aa9, 0xc39284c4, 0xe629711f, 0x1e0ab81e, 0x3bb14dc5, 0x557d53a8, + 0x70c6a673, 0xa0d6b75b, 0x856d4280, 0xeba15ced, 0xce1aa936, 0x36396037, 0x138295ec, 0x7d4e8b81, 0x58f57e5a, + 0xd882df20, 0xfd392afb, 0x93f53496, 0xb64ec14d, 0x4e6d084c, 0x6bd6fd97, 0x051ae3fa, 0x20a11621, 0xf0b10709, + 0xd50af2d2, 0xbbc6ecbf, 0x9e7d1964, 0x665ed065, 0x43e525be, 0x2d293bd3, 0x0892ce08, 0x282a0fd6, 0x0d91fa0d, + 0x635de460, 0x46e611bb, 0xbec5d8ba, 0x9b7e2d61, 0xf5b2330c, 0xd009c6d7, 0x0019d7ff, 0x25a22224, 0x4b6e3c49, + 0x6ed5c992, 0x96f60093, 0xb34df548, 0xdd81eb25, 0xf83a1efe, 0x784dbf84, 0x5df64a5f, 0x333a5432, 0x1681a1e9, + 0xeea268e8, 0xcb199d33, 0xa5d5835e, 0x806e7685, 0x507e67ad, 0x75c59276, 0x1b098c1b, 0x3eb279c0, 0xc691b0c1, + 0xe32a451a, 0x8de65b77, 0xa85daeac, 0xcc97d8cb, 0xe92c2d10, 0x87e0337d, 0xa25bc6a6, 0x5a780fa7, 0x7fc3fa7c, + 0x110fe411, 0x34b411ca, 0xe4a400e2, 0xc11ff539, 0xafd3eb54, 0x8a681e8f, 0x724bd78e, 0x57f02255, 0x393c3c38, + 0x1c87c9e3, 0x9cf06899, 0xb94b9d42, 0xd787832f, 0xf23c76f4, 0x0a1fbff5, 0x2fa44a2e, 0x41685443, 0x64d3a198, + 0xb4c3b0b0, 0x9178456b, 0xffb45b06, 0xda0faedd, 0x222c67dc, 0x07979207, 0x695b8c6a, 0x4ce079b1, 0x6c58b86f, + 0x49e34db4, 0x272f53d9, 0x0294a602, 0xfab76f03, 0xdf0c9ad8, 0xb1c084b5, 0x947b716e, 0x446b6046, 0x61d0959d, + 0x0f1c8bf0, 0x2aa77e2b, 0xd284b72a, 0xf73f42f1, 0x99f35c9c, 0xbc48a947, 0x3c3f083d, 0x1984fde6, 0x7748e38b, + 0x52f31650, 0xaad0df51, 0x8f6b2a8a, 0xe1a734e7, 0xc41cc13c, 0x140cd014, 0x31b725cf, 0x5f7b3ba2, 0x7ac0ce79, 0x82e30778, 0xa758f2a3, 0xc994ecce, 0xec2f1915}}; #endif #if 0 @@ -1151,14 +815,11 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) { while (length >= 16) { crc ^= *(uint64_t *)next; uint64_t high = *(uint64_t *)(next + 8); - crc = table[15][crc & 0xff] ^ table[14][(crc >> 8) & 0xff] ^ - table[13][(crc >> 16) & 0xff] ^ table[12][(crc >> 24) & 0xff] ^ - table[11][(crc >> 32) & 0xff] ^ table[10][(crc >> 40) & 0xff] ^ - table[9][(crc >> 48) & 0xff] ^ table[8][crc >> 56] ^ - table[7][high & 0xff] ^ table[6][(high >> 8) & 0xff] ^ - table[5][(high >> 16) & 0xff] ^ table[4][(high >> 24) & 0xff] ^ - table[3][(high >> 32) & 0xff] ^ table[2][(high >> 40) & 0xff] ^ - table[1][(high >> 48) & 0xff] ^ table[0][high >> 56]; + crc = table[15][crc & 0xff] ^ table[14][(crc >> 8) & 0xff] ^ table[13][(crc >> 16) & 0xff] ^ + table[12][(crc >> 24) & 0xff] ^ table[11][(crc >> 32) & 0xff] ^ table[10][(crc >> 40) & 0xff] ^ + table[9][(crc >> 48) & 0xff] ^ table[8][crc >> 56] ^ table[7][high & 0xff] ^ table[6][(high >> 8) & 0xff] ^ + table[5][(high >> 16) & 0xff] ^ table[4][(high >> 24) & 0xff] ^ table[3][(high >> 32) & 0xff] ^ + table[2][(high >> 40) & 0xff] ^ table[1][(high >> 48) & 0xff] ^ table[0][high >> 56]; next += 16; length -= 16; } @@ -1171,12 +832,10 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) { crc ^= *(uint32_t *)next; uint32_t high = *(uint32_t *)(next + 4); uint32_t high2 = *(uint32_t *)(next + 8); - crc = table[11][crc & 0xff] ^ table[10][(crc >> 8) & 0xff] ^ - table[9][(crc >> 16) & 0xff] ^ table[8][crc >> 24] ^ - table[7][high & 0xff] ^ table[6][(high >> 8) & 0xff] ^ - table[5][(high >> 16) & 0xff] ^ table[4][high >> 24] ^ - table[3][high2 & 0xff] ^ table[2][(high2 >> 8) & 0xff] ^ - table[1][(high2 >> 16) & 0xff] ^ table[0][high2 >> 24]; + crc = table[11][crc & 0xff] ^ table[10][(crc >> 8) & 0xff] ^ table[9][(crc >> 16) & 0xff] ^ table[8][crc >> 24] ^ + table[7][high & 0xff] ^ table[6][(high >> 8) & 0xff] ^ table[5][(high >> 16) & 0xff] ^ table[4][high >> 24] ^ + table[3][high2 & 0xff] ^ table[2][(high2 >> 8) & 0xff] ^ table[1][(high2 >> 16) & 0xff] ^ + table[0][high2 >> 24]; next += 12; length -= 12; } @@ -1190,8 +849,8 @@ uint32_t crc32c_sf(uint32_t crci, crc_stream input, size_t length) { #if !defined(_TD_ARM_) && !defined(_TD_MIPS_) /* Apply the zeros operator table to crc. */ static uint32_t shift_crc(uint32_t shift_table[][256], uint32_t crc) { - return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^ - shift_table[2][(crc >> 16) & 0xff] ^ shift_table[3][crc >> 24]; + return shift_table[0][crc & 0xff] ^ shift_table[1][(crc >> 8) & 0xff] ^ shift_table[2][(crc >> 16) & 0xff] ^ + shift_table[3][crc >> 24]; } #endif /* Compute a CRC-32C. If the crc32 instruction is available, use the hardware @@ -1350,28 +1009,27 @@ uint32_t crc32c_hw(uint32_t crc, crc_stream buf, size_t len) { (have) = (ecx >> 20) & 1; \ } while (0) -#endif // #ifndef _TD_ARM_ +#endif // #ifndef _TD_ARM_ -void taosResolveCRC() { +void taosResolveCRC() { #if defined _TD_ARM_ || defined _TD_MIPS_ || defined WINDOWS crc32c = crc32c_sf; #else int32_t sse42; SSE42(sse42); crc32c = sse42 ? crc32c_hw : crc32c_sf; -#endif +#endif /* return sse42 ? crc32c_hw(crci, bytes, len) : crc32c_sf(crci, bytes, len); */ } - #ifdef TEST_CRC32C_MAIN #include #include int32_t main(int32_t argc, char *argv[]) { - char str[1024] = "\0"; - char *ptr = str; + char str[1024] = "\0"; + char *ptr = str; int32_t count = 0; while ((count = read(0, ptr, 10)) > 0) { ptr += count; diff --git a/source/util/src/tdigest.c b/source/util/src/tdigest.c index a722cfeee2abc51ac7ec975b47ebc9243991c084..067580708eca28bb8a1cb29b484e08927e0c716a 100644 --- a/source/util/src/tdigest.c +++ b/source/util/src/tdigest.c @@ -24,296 +24,273 @@ * Copyright (c) 2016, Usman Masood */ +#include "tdigest.h" #include "os.h" #include "osMath.h" -#include "tdigest.h" #define INTERPOLATE(x, x0, x1) (((x) - (x0)) / ((x1) - (x0))) //#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (q) - 1) + M_PI / 2) / M_PI) -#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (double)(q) - 1)/M_PI + (double)1/2)) -#define FLOAT_EQ(f1, f2) (fabs((f1) - (f2)) <= FLT_EPSILON) +#define INTEGRATED_LOCATION(compression, q) ((compression) * (asin(2 * (double)(q)-1) / M_PI + (double)1 / 2)) +#define FLOAT_EQ(f1, f2) (fabs((f1) - (f2)) <= FLT_EPSILON) typedef struct SMergeArgs { - TDigest *t; - SCentroid *centroids; - int32_t idx; - double weight_so_far; - double k1; - double min; - double max; -}SMergeArgs; - -void tdigestAutoFill(TDigest* t, int32_t compression) { - t->centroids = (SCentroid*)((char*)t + sizeof(TDigest)); - t->buffered_pts = (SPt*) ((char*)t + sizeof(TDigest) + sizeof(SCentroid) * (int32_t)GET_CENTROID(compression)); + TDigest *t; + SCentroid *centroids; + int32_t idx; + double weight_so_far; + double k1; + double min; + double max; +} SMergeArgs; + +void tdigestAutoFill(TDigest *t, int32_t compression) { + t->centroids = (SCentroid *)((char *)t + sizeof(TDigest)); + t->buffered_pts = (SPt *)((char *)t + sizeof(TDigest) + sizeof(SCentroid) * (int32_t)GET_CENTROID(compression)); } -TDigest *tdigestNewFrom(void* pBuf, int32_t compression) { - memset(pBuf, 0, (size_t)TDIGEST_SIZE(compression)); - TDigest* t = (TDigest*)pBuf; - tdigestAutoFill(t, compression); +TDigest *tdigestNewFrom(void *pBuf, int32_t compression) { + memset(pBuf, 0, (size_t)TDIGEST_SIZE(compression)); + TDigest *t = (TDigest *)pBuf; + tdigestAutoFill(t, compression); - t->compression = compression; - t->size = (int64_t)GET_CENTROID(compression); - t->threshold = (int32_t)GET_THRESHOLD(compression); - t->min = DOUBLE_MAX; - t->max = -DOUBLE_MAX; + t->compression = compression; + t->size = (int64_t)GET_CENTROID(compression); + t->threshold = (int32_t)GET_THRESHOLD(compression); + t->min = DOUBLE_MAX; + t->max = -DOUBLE_MAX; - return t; + return t; } static int32_t cmpCentroid(const void *a, const void *b) { - SCentroid *c1 = (SCentroid *) a; - SCentroid *c2 = (SCentroid *) b; - if (c1->mean < c2->mean) - return -1; - if (c1->mean > c2->mean) - return 1; - return 0; + SCentroid *c1 = (SCentroid *)a; + SCentroid *c2 = (SCentroid *)b; + if (c1->mean < c2->mean) return -1; + if (c1->mean > c2->mean) return 1; + return 0; } - static void mergeCentroid(SMergeArgs *args, SCentroid *merge) { - double k2; - SCentroid *c = &args->centroids[args->idx]; - - args->weight_so_far += merge->weight; - k2 = INTEGRATED_LOCATION(args->t->size, - args->weight_so_far / args->t->total_weight); - //idx++ - if(k2 - args->k1 > 1 && c->weight > 0) { - if(args->idx + 1 < args->t->size - && merge->mean != args->centroids[args->idx].mean) { - args->idx++; - } - args->k1 = k2; + double k2; + SCentroid *c = &args->centroids[args->idx]; + + args->weight_so_far += merge->weight; + k2 = INTEGRATED_LOCATION(args->t->size, args->weight_so_far / args->t->total_weight); + // idx++ + if (k2 - args->k1 > 1 && c->weight > 0) { + if (args->idx + 1 < args->t->size && merge->mean != args->centroids[args->idx].mean) { + args->idx++; } - - c = &args->centroids[args->idx]; - if(c->mean == merge->mean) { - c->weight += merge->weight; - } else { - c->weight += merge->weight; - c->mean += (merge->mean - c->mean) * merge->weight / c->weight; - - if (merge->weight > 0) { - args->min = TMIN(merge->mean, args->min); - args->max = TMAX(merge->mean, args->max); - } + args->k1 = k2; + } + + c = &args->centroids[args->idx]; + if (c->mean == merge->mean) { + c->weight += merge->weight; + } else { + c->weight += merge->weight; + c->mean += (merge->mean - c->mean) * merge->weight / c->weight; + + if (merge->weight > 0) { + args->min = TMIN(merge->mean, args->min); + args->max = TMAX(merge->mean, args->max); } + } } void tdigestCompress(TDigest *t) { - SCentroid *unmerged_centroids; - int64_t unmerged_weight = 0; - int32_t num_unmerged = t->num_buffered_pts; - int32_t i, j; - SMergeArgs args; - - if (t->num_buffered_pts <= 0) - return; - - unmerged_centroids = (SCentroid*)taosMemoryMalloc(sizeof(SCentroid) * t->num_buffered_pts); - for (i = 0; i < num_unmerged; i++) { - SPt *p = t->buffered_pts + i; - SCentroid *c = &unmerged_centroids[i]; - c->mean = p->value; - c->weight = p->weight; - unmerged_weight += c->weight; + SCentroid *unmerged_centroids; + int64_t unmerged_weight = 0; + int32_t num_unmerged = t->num_buffered_pts; + int32_t i, j; + SMergeArgs args; + + if (t->num_buffered_pts <= 0) return; + + unmerged_centroids = (SCentroid *)taosMemoryMalloc(sizeof(SCentroid) * t->num_buffered_pts); + for (i = 0; i < num_unmerged; i++) { + SPt *p = t->buffered_pts + i; + SCentroid *c = &unmerged_centroids[i]; + c->mean = p->value; + c->weight = p->weight; + unmerged_weight += c->weight; + } + t->num_buffered_pts = 0; + t->total_weight += unmerged_weight; + + taosSort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid); + memset(&args, 0, sizeof(SMergeArgs)); + args.centroids = (SCentroid *)taosMemoryMalloc((size_t)(sizeof(SCentroid) * t->size)); + memset(args.centroids, 0, (size_t)(sizeof(SCentroid) * t->size)); + + args.t = t; + args.min = DOUBLE_MAX; + args.max = -DOUBLE_MAX; + + i = 0; + j = 0; + while (i < num_unmerged && j < t->num_centroids) { + SCentroid *a = &unmerged_centroids[i]; + SCentroid *b = &t->centroids[j]; + + if (a->mean <= b->mean) { + mergeCentroid(&args, a); + assert(args.idx < t->size); + i++; + } else { + mergeCentroid(&args, b); + assert(args.idx < t->size); + j++; } - t->num_buffered_pts = 0; - t->total_weight += unmerged_weight; - - taosSort(unmerged_centroids, num_unmerged, sizeof(SCentroid), cmpCentroid); - memset(&args, 0, sizeof(SMergeArgs)); - args.centroids = (SCentroid*)taosMemoryMalloc((size_t)(sizeof(SCentroid) * t->size)); - memset(args.centroids, 0, (size_t)(sizeof(SCentroid) * t->size)); - - args.t = t; - args.min = DOUBLE_MAX; - args.max = -DOUBLE_MAX; - - i = 0; - j = 0; - while (i < num_unmerged && j < t->num_centroids) { - SCentroid *a = &unmerged_centroids[i]; - SCentroid *b = &t->centroids[j]; - - if (a->mean <= b->mean) { - mergeCentroid(&args, a); - assert(args.idx < t->size); - i++; - } else { - mergeCentroid(&args, b); - assert(args.idx < t->size); - j++; - } + } + + while (i < num_unmerged) { + mergeCentroid(&args, &unmerged_centroids[i++]); + assert(args.idx < t->size); + } + taosMemoryFree((void *)unmerged_centroids); + + while (j < t->num_centroids) { + mergeCentroid(&args, &t->centroids[j++]); + assert(args.idx < t->size); + } + + if (t->total_weight > 0) { + t->min = TMIN(t->min, args.min); + if (args.centroids[args.idx].weight <= 0) { + args.idx--; } + t->num_centroids = args.idx + 1; + t->max = TMAX(t->max, args.max); + } - while (i < num_unmerged) { - mergeCentroid(&args, &unmerged_centroids[i++]); - assert(args.idx < t->size); - } - taosMemoryFree((void*)unmerged_centroids); + memcpy(t->centroids, args.centroids, sizeof(SCentroid) * t->num_centroids); + taosMemoryFree((void *)args.centroids); +} - while (j < t->num_centroids) { - mergeCentroid(&args, &t->centroids[j++]); - assert(args.idx < t->size); - } +void tdigestAdd(TDigest *t, double x, int64_t w) { + if (w == 0) return; - if (t->total_weight > 0) { - t->min = TMIN(t->min, args.min); - if (args.centroids[args.idx].weight <= 0) { - args.idx--; - } - t->num_centroids = args.idx + 1; - t->max = TMAX(t->max, args.max); - } + int32_t i = t->num_buffered_pts; + if (i > 0 && t->buffered_pts[i - 1].value == x) { + t->buffered_pts[i].weight = w; + } else { + t->buffered_pts[i].value = x; + t->buffered_pts[i].weight = w; + t->num_buffered_pts++; + } - memcpy(t->centroids, args.centroids, sizeof(SCentroid) * t->num_centroids); - taosMemoryFree((void*)args.centroids); + if (t->num_buffered_pts >= t->threshold) tdigestCompress(t); } -void tdigestAdd(TDigest* t, double x, int64_t w) { - if (w == 0) - return; +double tdigestCDF(TDigest *t, double x) { + if (t == NULL) return 0; - int32_t i = t->num_buffered_pts; - if(i > 0 && t->buffered_pts[i-1].value == x ) { - t->buffered_pts[i].weight = w; - } else { - t->buffered_pts[i].value = x; - t->buffered_pts[i].weight = w; - t->num_buffered_pts++; - } + int32_t i; + double left, right; + int64_t weight_so_far; + SCentroid *a, *b, tmp; + tdigestCompress(t); + if (t->num_centroids == 0) return NAN; + if (x < t->min) return 0; + if (x > t->max) return 1; + if (t->num_centroids == 1) { + if (FLOAT_EQ(t->max, t->min)) return 0.5; - if (t->num_buffered_pts >= t->threshold) - tdigestCompress(t); -} + return INTERPOLATE(x, t->min, t->max); + } -double tdigestCDF(TDigest *t, double x) { - if (t == NULL) - return 0; - - int32_t i; - double left, right; - int64_t weight_so_far; - SCentroid *a, *b, tmp; - - tdigestCompress(t); - if (t->num_centroids == 0) - return NAN; - if (x < t->min) - return 0; - if (x > t->max) - return 1; - if (t->num_centroids == 1) { - if (FLOAT_EQ(t->max, t->min)) - return 0.5; - - return INTERPOLATE(x, t->min, t->max); - } + weight_so_far = 0; + a = b = &tmp; + b->mean = t->min; + b->weight = 0; + right = 0; - weight_so_far = 0; - a = b = &tmp; - b->mean = t->min; - b->weight = 0; - right = 0; - - for (i = 0; i < t->num_centroids; i++) { - SCentroid *c = &t->centroids[i]; - - left = b->mean - (a->mean + right); - a = b; - b = c; - right = (b->mean - a->mean) * a->weight / (a->weight + b->weight); - - if (x < a->mean + right) { - double cdf = (weight_so_far - + a->weight - * INTERPOLATE(x, a->mean - left, a->mean + right)) - / t->total_weight; - return TMAX(cdf, 0.0); - } - - weight_so_far += a->weight; - } + for (i = 0; i < t->num_centroids; i++) { + SCentroid *c = &t->centroids[i]; left = b->mean - (a->mean + right); a = b; - right = t->max - a->mean; + b = c; + right = (b->mean - a->mean) * a->weight / (a->weight + b->weight); if (x < a->mean + right) { - return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) - / t->total_weight; + double cdf = (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight; + return TMAX(cdf, 0.0); } - return 1; + weight_so_far += a->weight; + } + + left = b->mean - (a->mean + right); + a = b; + right = t->max - a->mean; + + if (x < a->mean + right) { + return (weight_so_far + a->weight * INTERPOLATE(x, a->mean - left, a->mean + right)) / t->total_weight; + } + + return 1; } double tdigestQuantile(TDigest *t, double q) { - if (t == NULL) - return 0; - - int32_t i; - double left, right, idx; - int64_t weight_so_far; - SCentroid *a, *b, tmp; - - tdigestCompress(t); - if (t->num_centroids == 0) - return NAN; - if (t->num_centroids == 1) - return t->centroids[0].mean; - if (FLOAT_EQ(q, 0.0)) - return t->min; - if (FLOAT_EQ(q, 1.0)) - return t->max; - - idx = q * t->total_weight; - weight_so_far = 0; - b = &tmp; - b->mean = t->min; - b->weight = 0; - right = t->min; - - for (i = 0; i < t->num_centroids; i++) { - SCentroid *c = &t->centroids[i]; - a = b; - left = right; - - b = c; - right = (b->weight * a->mean + a->weight * b->mean)/ (a->weight + b->weight); - if (idx < weight_so_far + a->weight) { - double p = (idx - weight_so_far) / a->weight; - return left * (1 - p) + right * p; - } - weight_so_far += a->weight; - } - - left = right; + if (t == NULL) return 0; + + int32_t i; + double left, right, idx; + int64_t weight_so_far; + SCentroid *a, *b, tmp; + + tdigestCompress(t); + if (t->num_centroids == 0) return NAN; + if (t->num_centroids == 1) return t->centroids[0].mean; + if (FLOAT_EQ(q, 0.0)) return t->min; + if (FLOAT_EQ(q, 1.0)) return t->max; + + idx = q * t->total_weight; + weight_so_far = 0; + b = &tmp; + b->mean = t->min; + b->weight = 0; + right = t->min; + + for (i = 0; i < t->num_centroids; i++) { + SCentroid *c = &t->centroids[i]; a = b; - right = t->max; + left = right; - if (idx < weight_so_far + a->weight && a->weight != 0) { - double p = (idx - weight_so_far) / a->weight; - return left * (1 - p) + right * p; + b = c; + right = (b->weight * a->mean + a->weight * b->mean) / (a->weight + b->weight); + if (idx < weight_so_far + a->weight) { + double p = (idx - weight_so_far) / a->weight; + return left * (1 - p) + right * p; } + weight_so_far += a->weight; + } + + left = right; + a = b; + right = t->max; - return t->max; + if (idx < weight_so_far + a->weight && a->weight != 0) { + double p = (idx - weight_so_far) / a->weight; + return left * (1 - p) + right * p; + } + + return t->max; } void tdigestMerge(TDigest *t1, TDigest *t2) { - // SPoints - int32_t num_pts = t2->num_buffered_pts; - for(int32_t i = num_pts - 1; i >= 0; i--) { - SPt* p = t2->buffered_pts + i; - tdigestAdd(t1, p->value, p->weight); - t2->num_buffered_pts --; - } - // centroids - for (int32_t i = 0; i < t2->num_centroids; i++) { - tdigestAdd(t1, t2->centroids[i].mean, t2->centroids[i].weight); - } + // SPoints + int32_t num_pts = t2->num_buffered_pts; + for (int32_t i = num_pts - 1; i >= 0; i--) { + SPt *p = t2->buffered_pts + i; + tdigestAdd(t1, p->value, p->weight); + t2->num_buffered_pts--; + } + // centroids + for (int32_t i = 0; i < t2->num_centroids; i++) { + tdigestAdd(t1, t2->centroids[i].mean, t2->centroids[i].weight); + } } diff --git a/source/util/src/tenv.c b/source/util/src/tenv.c index 4fc0542816397e780a962f9b6a52055114f97197..027918f2c6e97e67a894cfc161f13968be226a87 100644 --- a/source/util/src/tenv.c +++ b/source/util/src/tenv.c @@ -59,12 +59,12 @@ int32_t taosEnvToCfg(const char *envStr, char *cfgStr) { } if (cfgStr != envStr) strcpy(cfgStr, envStr); char *p = strchr(cfgStr, '='); - + if (p != NULL) { char buf[CFG_NAME_MAX_LEN]; - if (*(p+1) == '\'') { - *(p+1)= ' '; - char *pEnd = &cfgStr[strlen(cfgStr)-1]; + if (*(p + 1) == '\'') { + *(p + 1) = ' '; + char *pEnd = &cfgStr[strlen(cfgStr) - 1]; if (*pEnd == '\'') *pEnd = '\0'; } *p = '\0'; diff --git a/source/util/src/thash.c b/source/util/src/thash.c index b69d8ea52866055668ce4937836c5eb46842f1c2..e7b2d9638fd9c6fc853f2ca859be23c32a47e9a4 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -333,7 +333,7 @@ int32_t taosHashPut(SHashObj *pHashObj, const void *key, size_t keyLen, const vo // disable resize taosHashRLock(pHashObj); - uint32_t slot = HASH_INDEX(hashVal, pHashObj->capacity); + uint32_t slot = HASH_INDEX(hashVal, pHashObj->capacity); SHashEntry *pe = pHashObj->hashList[slot]; taosHashEntryWLock(pHashObj, pe); @@ -890,5 +890,3 @@ void *taosHashAcquire(SHashObj *pHashObj, const void *key, size_t keyLen) { void taosHashRelease(SHashObj *pHashObj, void *p) { taosHashCancelIterate(pHashObj, p); } int64_t taosHashGetCompTimes(SHashObj *pHashObj) { return atomic_load_64(&pHashObj->compTimes); } - - diff --git a/source/util/src/thashutil.c b/source/util/src/thashutil.c index c2382550a64530515933dfcb0941e00fe2f0551a..e646e9aa36ec3026d687c09beb084738db503e31 100644 --- a/source/util/src/thashutil.c +++ b/source/util/src/thashutil.c @@ -14,13 +14,13 @@ */ #define _DEFAULT_SOURCE -#include "thash.h" #include "tcompare.h" +#include "thash.h" #include "types.h" #define ROTL32(x, r) ((x) << (r) | (x) >> (32u - (r))) -#define DLT (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON) +#define DLT (FLT_COMPAR_TOL_FACTOR * FLT_EPSILON) #define BASE 1000 #define FMIX32(h) \ @@ -29,11 +29,12 @@ (h) *= 0x85ebca6b; \ (h) ^= (h) >> 13; \ (h) *= 0xc2b2ae35; \ - (h) ^= (h) >> 16; } while (0) + (h) ^= (h) >> 16; \ + } while (0) uint32_t MurmurHash3_32(const char *key, uint32_t len) { const uint8_t *data = (const uint8_t *)key; - const int32_t nblocks = len >> 2u; + const int32_t nblocks = len >> 2u; uint32_t h1 = 0x12345678; @@ -80,14 +81,14 @@ uint32_t MurmurHash3_32(const char *key, uint32_t len) { uint64_t MurmurHash3_64(const char *key, uint32_t len) { const uint64_t m = 0x87c37b91114253d5; - const int r = 47; - uint32_t seed = 0x12345678; - uint64_t h = seed ^ (len * m); + const int r = 47; + uint32_t seed = 0x12345678; + uint64_t h = seed ^ (len * m); const uint8_t *data = (const uint8_t *)key; - const uint8_t *end = data + (len-(len&7)); + const uint8_t *end = data + (len - (len & 7)); - while(data != end) { - uint64_t k = *((uint64_t*)data); + while (data != end) { + uint64_t k = *((uint64_t *)data); k *= m; k ^= k >> r; @@ -97,14 +98,21 @@ uint64_t MurmurHash3_64(const char *key, uint32_t len) { data += 8; } - switch(len & 7) { - case 7: h ^= (uint64_t)data[6] << 48; /* fall-thru */ - case 6: h ^= (uint64_t)data[5] << 40; /* fall-thru */ - case 5: h ^= (uint64_t)data[4] << 32; /* fall-thru */ - case 4: h ^= (uint64_t)data[3] << 24; /* fall-thru */ - case 3: h ^= (uint64_t)data[2] << 16; /* fall-thru */ - case 2: h ^= (uint64_t)data[1] << 8; /* fall-thru */ - case 1: h ^= (uint64_t)data[0]; + switch (len & 7) { + case 7: + h ^= (uint64_t)data[6] << 48; /* fall-thru */ + case 6: + h ^= (uint64_t)data[5] << 40; /* fall-thru */ + case 5: + h ^= (uint64_t)data[4] << 32; /* fall-thru */ + case 4: + h ^= (uint64_t)data[3] << 24; /* fall-thru */ + case 3: + h ^= (uint64_t)data[2] << 16; /* fall-thru */ + case 2: + h ^= (uint64_t)data[1] << 8; /* fall-thru */ + case 1: + h ^= (uint64_t)data[0]; h *= m; /* fall-thru */ }; @@ -126,11 +134,11 @@ uint32_t taosFloatHash(const char *key, uint32_t UNUSED_PARAM(len)) { if (FLT_EQUAL(f, 0.0)) { return 0; } - if (fabs(f) < FLT_MAX/BASE - DLT) { - int32_t t = (int32_t)(round(BASE * (f + DLT))); - return (uint32_t)t; + if (fabs(f) < FLT_MAX / BASE - DLT) { + int32_t t = (int32_t)(round(BASE * (f + DLT))); + return (uint32_t)t; } else { - return 0x7fc00000; + return 0x7fc00000; } } uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) { @@ -142,11 +150,11 @@ uint32_t taosDoubleHash(const char *key, uint32_t UNUSED_PARAM(len)) { if (FLT_EQUAL(f, 0.0)) { return 0; } - if (fabs(f) < DBL_MAX/BASE - DLT) { - int32_t t = (int32_t)(round(BASE * (f + DLT))); - return (uint32_t)t; + if (fabs(f) < DBL_MAX / BASE - DLT) { + int32_t t = (int32_t)(round(BASE * (f + DLT))); + return (uint32_t)t; } else { - return 0x7fc00000; + return 0x7fc00000; } } uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) { @@ -160,7 +168,7 @@ uint32_t taosIntHash_64(const char *key, uint32_t UNUSED_PARAM(len)) { _hash_fn_t taosGetDefaultHashFunction(int32_t type) { _hash_fn_t fn = NULL; - switch(type) { + switch (type) { case TSDB_DATA_TYPE_TIMESTAMP: case TSDB_DATA_TYPE_UBIGINT: case TSDB_DATA_TYPE_BIGINT: @@ -210,9 +218,15 @@ int32_t taosDoubleEqual(const void *a, const void *b, size_t UNUSED_PARAM(sz)) { _equal_fn_t taosGetDefaultEqualFunction(int32_t type) { _equal_fn_t fn = NULL; switch (type) { - case TSDB_DATA_TYPE_FLOAT: fn = taosFloatEqual; break; - case TSDB_DATA_TYPE_DOUBLE: fn = taosDoubleEqual; break; - default: fn = memcmp; break; + case TSDB_DATA_TYPE_FLOAT: + fn = taosFloatEqual; + break; + case TSDB_DATA_TYPE_DOUBLE: + fn = taosDoubleEqual; + break; + default: + fn = memcmp; + break; } return fn; } diff --git a/source/util/src/tmempool.c b/source/util/src/tmempool.c index 7bf8e94de9d434f140fc9c35fb0f521486b22367..8a57715c22d215429ab7d617cf717a1fceba5005 100644 --- a/source/util/src/tmempool.c +++ b/source/util/src/tmempool.c @@ -19,12 +19,12 @@ #include "tutil.h" typedef struct { - int32_t numOfFree; /* number of free slots */ - int32_t first; /* the first free slot */ - int32_t numOfBlock; /* the number of blocks */ - int32_t blockSize; /* block size in bytes */ - int32_t *freeList; /* the index list */ - char *pool; /* the actual mem block */ + int32_t numOfFree; /* number of free slots */ + int32_t first; /* the first free slot */ + int32_t numOfBlock; /* the number of blocks */ + int32_t blockSize; /* block size in bytes */ + int32_t *freeList; /* the index list */ + char *pool; /* the actual mem block */ TdThreadMutex mutex; } pool_t; diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index e1a8697ad53519b3f0db59f28ee6f82355ac82dd..94d90104aabf83b87bba1f3a586cbfaa6b467b7b 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -42,13 +42,14 @@ struct SDiskbasedBuf { bool comp; // compressed before flushed to disk uint64_t nextPos; // next page flush position - char* id; // for debug purpose - bool printStatis; // Print statistics info when closing this buffer. + char* id; // for debug purpose + bool printStatis; // Print statistics info when closing this buffer. SDiskbasedBufStatis statis; }; static int32_t createDiskFile(SDiskbasedBuf* pBuf) { - pBuf->pFile = taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); + pBuf->pFile = + taosOpenFile(pBuf->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_READ | TD_FILE_TRUNC | TD_FILE_AUTO_DEL); if (pBuf->pFile == NULL) { return TAOS_SYSTEM_ERROR(errno); } @@ -247,12 +248,12 @@ static SPageInfo* registerPage(SDiskbasedBuf* pBuf, int32_t pageId) { SPageInfo* ppi = taosMemoryMalloc(sizeof(SPageInfo)); ppi->pageId = pageId; - ppi->pData = NULL; + ppi->pData = NULL; ppi->offset = -1; ppi->length = -1; - ppi->used = true; - ppi->pn = NULL; - ppi->dirty = false; + ppi->used = true; + ppi->pn = NULL; + ppi->dirty = false; return *(SPageInfo**)taosArrayPush(pBuf->pIdList, &ppi); } @@ -318,7 +319,7 @@ static void lruListMoveToFront(SList* pList, SPageInfo* pi) { } static SPageInfo* getPageInfoFromPayload(void* page) { - char* p = (char *)page - POINTER_BYTES; + char* p = (char*)page - POINTER_BYTES; SPageInfo* ppi = ((SPageInfo**)p)[0]; return ppi; @@ -334,12 +335,12 @@ int32_t createDiskbasedBuf(SDiskbasedBuf** pBuf, int32_t pagesize, int32_t inMem } pPBuf->pageSize = pagesize; - pPBuf->numOfPages = 0; // all pages are in buffer in the first place + pPBuf->numOfPages = 0; // all pages are in buffer in the first place pPBuf->totalBufSize = 0; pPBuf->inMemPages = inMemBufSize / pagesize; // maximum allowed pages, it is a soft limit. pPBuf->allocateId = -1; - pPBuf->pFile = NULL; - pPBuf->id = strdup(id); + pPBuf->pFile = NULL; + pPBuf->id = strdup(id); pPBuf->fileSize = 0; pPBuf->pFree = taosArrayInit(4, sizeof(SFreeListItem)); pPBuf->freePgList = tdListNew(POINTER_BYTES); @@ -402,14 +403,15 @@ void* getNewBufPage(SDiskbasedBuf* pBuf, int32_t* pageId) { // allocate buf if (availablePage == NULL) { - pi->pData = taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased. + pi->pData = + taosMemoryCalloc(1, getAllocPageSize(pBuf->pageSize)); // add extract bytes in case of zipped buffer increased. } else { pi->pData = availablePage; } ((void**)pi->pData)[0] = pi; #ifdef BUF_PAGE_DEBUG - uDebug("page_getNewBufPage , pi->pData:%p, pageId:%d, offset:%"PRId64, pi->pData, pi->pageId, pi->offset); + uDebug("page_getNewBufPage , pi->pData:%p, pageId:%d, offset:%" PRId64, pi->pData, pi->pageId, pi->offset); #endif return (void*)(GET_DATA_PAYLOAD(pi)); } @@ -434,11 +436,12 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { lruListMoveToFront(pBuf->lruList, (*pi)); (*pi)->used = true; #ifdef BUF_PAGE_DEBUG - uDebug("page_getBufPage1 pageId:%d, offset:%"PRId64, (*pi)->pageId, (*pi)->offset); + uDebug("page_getBufPage1 pageId:%d, offset:%" PRId64, (*pi)->pageId, (*pi)->offset); #endif return (void*)(GET_DATA_PAYLOAD(*pi)); } else { // not in memory - assert((*pi)->pData == NULL && (*pi)->pn == NULL && (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1))); + assert((*pi)->pData == NULL && (*pi)->pn == NULL && + (((*pi)->length >= 0 && (*pi)->offset >= 0) || ((*pi)->length == -1 && (*pi)->offset == -1))); char* availablePage = NULL; if (NO_IN_MEM_AVAILABLE_PAGES(pBuf)) { @@ -468,7 +471,7 @@ void* getBufPage(SDiskbasedBuf* pBuf, int32_t id) { } } #ifdef BUF_PAGE_DEBUG - uDebug("page_getBufPage2 pageId:%d, offset:%"PRId64, (*pi)->pageId, (*pi)->offset); + uDebug("page_getBufPage2 pageId:%d, offset:%" PRId64, (*pi)->pageId, (*pi)->offset); #endif return (void*)(GET_DATA_PAYLOAD(*pi)); } @@ -482,7 +485,7 @@ void releaseBufPage(SDiskbasedBuf* pBuf, void* page) { void releaseBufPageInfo(SDiskbasedBuf* pBuf, SPageInfo* pi) { #ifdef BUF_PAGE_DEBUG - uDebug("page_releaseBufPageInfo pageId:%d, used:%d, offset:%"PRId64, pi->pageId, pi->used, pi->offset); + uDebug("page_releaseBufPageInfo pageId:%d, used:%d, offset:%" PRId64, pi->pageId, pi->used, pi->offset); #endif // assert(pi->pData != NULL && pi->used == true); assert(pi->pData != NULL); @@ -520,12 +523,12 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { { SDiskbasedBufStatis* ps = &pBuf->statis; if (ps->loadPages == 0) { - uDebug( - "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages)", - ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages); + uDebug("Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages)", ps->getPages, + ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages); } else { uDebug( - "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f Kb", + "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f " + "Kb", ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); } @@ -614,7 +617,8 @@ void dBufPrintStatis(const SDiskbasedBuf* pBuf) { if (ps->loadPages > 0) { printf( - "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f Kb\n", + "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f " + "Kb\n", ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); } else { @@ -640,7 +644,7 @@ void clearDiskbasedBuf(SDiskbasedBuf* pBuf) { taosHashClear(pBuf->all); - pBuf->numOfPages = 0; // all pages are in buffer in the first place + pBuf->numOfPages = 0; // all pages are in buffer in the first place pBuf->totalBufSize = 0; pBuf->allocateId = -1; pBuf->fileSize = 0; diff --git a/source/util/src/tscalablebf.c b/source/util/src/tscalablebf.c index 108eb348034afb8bd9eae458df5a78e674651833..797f3a924dee0b5c1297192f3bb1313c853d4a4b 100644 --- a/source/util/src/tscalablebf.c +++ b/source/util/src/tscalablebf.c @@ -18,11 +18,10 @@ #include "tscalablebf.h" #include "taoserror.h" -#define DEFAULT_GROWTH 2 +#define DEFAULT_GROWTH 2 #define DEFAULT_TIGHTENING_RATIO 0.5 -static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, - double errorRate); +static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, double errorRate); SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate) { const uint32_t defaultSize = 8; @@ -35,7 +34,7 @@ SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate) { } pSBf->numBits = 0; pSBf->bfArray = taosArrayInit(defaultSize, sizeof(void *)); - if (tScalableBfAddFilter(pSBf, expectedEntries, errorRate * DEFAULT_TIGHTENING_RATIO) == NULL ) { + if (tScalableBfAddFilter(pSBf, expectedEntries, errorRate * DEFAULT_TIGHTENING_RATIO) == NULL) { tScalableBfDestroy(pSBf); return NULL; } @@ -46,8 +45,7 @@ SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate) { int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) { int32_t size = taosArrayGetSize(pSBf->bfArray); for (int32_t i = size - 2; i >= 0; --i) { - if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), - keyBuf, len) != TSDB_CODE_SUCCESS) { + if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), keyBuf, len) != TSDB_CODE_SUCCESS) { return TSDB_CODE_FAILED; } } @@ -55,8 +53,7 @@ int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) { SBloomFilter *pNormalBf = taosArrayGetP(pSBf->bfArray, size - 1); ASSERT(pNormalBf); if (tBloomFilterIsFull(pNormalBf)) { - pNormalBf = tScalableBfAddFilter(pSBf, - pNormalBf->expectedEntries * pSBf->growth, + pNormalBf = tScalableBfAddFilter(pSBf, pNormalBf->expectedEntries * pSBf->growth, pNormalBf->errorRate * DEFAULT_TIGHTENING_RATIO); if (pNormalBf == NULL) { return TSDB_CODE_OUT_OF_MEMORY; @@ -65,25 +62,22 @@ int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len) { return tBloomFilterPut(pNormalBf, keyBuf, len); } -int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, - uint32_t len) { +int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len) { int32_t size = taosArrayGetSize(pSBf->bfArray); for (int32_t i = size - 1; i >= 0; --i) { - if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), - keyBuf, len) != TSDB_CODE_SUCCESS) { + if (tBloomFilterNoContain(taosArrayGetP(pSBf->bfArray, i), keyBuf, len) != TSDB_CODE_SUCCESS) { return TSDB_CODE_FAILED; } } return TSDB_CODE_SUCCESS; } -static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, - double errorRate) { +static SBloomFilter *tScalableBfAddFilter(SScalableBf *pSBf, uint64_t expectedEntries, double errorRate) { SBloomFilter *pNormalBf = tBloomFilterInit(expectedEntries, errorRate); if (pNormalBf == NULL) { return NULL; } - if(taosArrayPush(pSBf->bfArray, &pNormalBf) == NULL) { + if (taosArrayPush(pSBf->bfArray, &pNormalBf) == NULL) { tBloomFilterDestroy(pNormalBf); return NULL; } @@ -101,7 +95,7 @@ void tScalableBfDestroy(SScalableBf *pSBf) { taosMemoryFree(pSBf); } -int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder) { +int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder *pEncoder) { if (!pSBf) { if (tEncodeI32(pEncoder, 0) < 0) return -1; return 0; @@ -109,7 +103,7 @@ int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder) { int32_t size = taosArrayGetSize(pSBf->bfArray); if (tEncodeI32(pEncoder, size) < 0) return -1; for (int32_t i = 0; i < size; i++) { - SBloomFilter* pBF = taosArrayGetP(pSBf->bfArray, i); + SBloomFilter *pBF = taosArrayGetP(pSBf->bfArray, i); if (tBloomFilterEncode(pBF, pEncoder) < 0) return -1; } if (tEncodeU32(pEncoder, pSBf->growth) < 0) return -1; @@ -117,7 +111,7 @@ int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder* pEncoder) { return 0; } -SScalableBf* tScalableBfDecode(SDecoder* pDecoder) { +SScalableBf *tScalableBfDecode(SDecoder *pDecoder) { SScalableBf *pSBf = taosMemoryCalloc(1, sizeof(SScalableBf)); pSBf->bfArray = NULL; int32_t size = 0; @@ -128,7 +122,7 @@ SScalableBf* tScalableBfDecode(SDecoder* pDecoder) { } pSBf->bfArray = taosArrayInit(size * 2, sizeof(void *)); for (int32_t i = 0; i < size; i++) { - SBloomFilter* pBF = tBloomFilterDecode(pDecoder); + SBloomFilter *pBF = tBloomFilterDecode(pDecoder); if (!pBF) goto _error; taosArrayPush(pSBf->bfArray, &pBF); } diff --git a/source/util/src/tthread.c b/source/util/src/tthread.c index 5c409935ffba5bf4eb18beb9c81d28e72033edd5..b0ab54f89a59e2d60a6ead8d595de25e3ae672f0 100644 --- a/source/util/src/tthread.c +++ b/source/util/src/tthread.c @@ -17,7 +17,7 @@ #include "tthread.h" TdThread* taosCreateThread(void* (*__start_routine)(void*), void* param) { - TdThread* pthread = (TdThread*)taosMemoryMalloc(sizeof(TdThread)); + TdThread* pthread = (TdThread*)taosMemoryMalloc(sizeof(TdThread)); TdThreadAttr thattr; taosThreadAttrInit(&thattr); taosThreadAttrSetDetachState(&thattr, PTHREAD_CREATE_JOINABLE); diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 3a868c7f979b19e4c61bcb82985055e05569d486..51d0a59d001b12cd64775cf43b20f83ee0f1a638 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -16,9 +16,9 @@ #define _DEFAULT_SOURCE #include "ttimer.h" #include "taoserror.h" +#include "tdef.h" #include "tlog.h" #include "tsched.h" -#include "tdef.h" #define tmrFatal(...) \ { \ @@ -104,21 +104,21 @@ typedef struct timer_map_t { typedef struct time_wheel_t { TdThreadMutex mutex; - int64_t nextScanAt; - uint32_t resolution; - uint16_t size; - uint16_t index; - tmr_obj_t** slots; + int64_t nextScanAt; + uint32_t resolution; + uint16_t size; + uint16_t index; + tmr_obj_t** slots; } time_wheel_t; static int32_t tsMaxTmrCtrl = TSDB_MAX_VNODES_PER_DB + 100; static TdThreadOnce tmrModuleInit = PTHREAD_ONCE_INIT; static TdThreadMutex tmrCtrlMutex; -static tmr_ctrl_t* tmrCtrls; -static tmr_ctrl_t* unusedTmrCtrl = NULL; -static void* tmrQhandle; -static int32_t numOfTmrCtrl = 0; +static tmr_ctrl_t* tmrCtrls; +static tmr_ctrl_t* unusedTmrCtrl = NULL; +static void* tmrQhandle; +static int32_t numOfTmrCtrl = 0; int32_t taosTmrThreads = 1; static uintptr_t nextTimerId = 0; @@ -133,7 +133,7 @@ static timer_map_t timerMap; static uintptr_t getNextTimerId() { uintptr_t id; do { - id = (uintptr_t)atomic_add_fetch_ptr((void **)&nextTimerId, 1); + id = (uintptr_t)atomic_add_fetch_ptr((void**)&nextTimerId, 1); } while (id == 0); return id; } diff --git a/source/util/src/tworker.c b/source/util/src/tworker.c index d9ded20070f1f290c777a4e768540bba77fc15f7..e353546ca7a359a970accd6071ef6018e45eaa64 100644 --- a/source/util/src/tworker.c +++ b/source/util/src/tworker.c @@ -79,7 +79,7 @@ static void *tQWorkerThreadFp(SQWorker *worker) { uDebug("worker:%s:%d is running", pool->name, worker->id); while (1) { - if (taosReadQitemFromQset(pool->qset, (void **)&msg, &qinfo) == 0) { + if (taosReadQitemFromQset(pool->qset, (void **)&msg, &qinfo) == 0) { uDebug("worker:%s:%d qset:%p, got no message and exiting", pool->name, worker->id, pool->qset); break; } diff --git a/source/util/test/arrayTest.cpp b/source/util/test/arrayTest.cpp index d8ace0939273ec24c410d80edef7946f0392e3a4..1dfb17b8cfe9488eafc2fa9a28e6d70700bca861 100644 --- a/source/util/test/arrayTest.cpp +++ b/source/util/test/arrayTest.cpp @@ -9,21 +9,21 @@ namespace { static void remove_batch_test() { - SArray *pa = (SArray*) taosArrayInit(4, sizeof(int32_t)); + SArray* pa = (SArray*)taosArrayInit(4, sizeof(int32_t)); - for(int32_t i = 0; i < 20; ++i) { + for (int32_t i = 0; i < 20; ++i) { int32_t a = i; taosArrayPush(pa, &a); } SArray* delList = (SArray*)taosArrayInit(4, sizeof(int32_t)); - taosArrayRemoveBatch(pa, (const int32_t*) TARRAY_GET_START(delList), taosArrayGetSize(delList)); + taosArrayRemoveBatch(pa, (const int32_t*)TARRAY_GET_START(delList), taosArrayGetSize(delList)); EXPECT_EQ(taosArrayGetSize(pa), 20); int32_t a = 5; taosArrayPush(delList, &a); - taosArrayRemoveBatch(pa, (const int32_t*) TARRAY_GET_START(delList), taosArrayGetSize(delList)); + taosArrayRemoveBatch(pa, (const int32_t*)TARRAY_GET_START(delList), taosArrayGetSize(delList)); EXPECT_EQ(taosArrayGetSize(pa), 19); EXPECT_EQ(*(int*)taosArrayGet(pa, 5), 6); @@ -41,7 +41,7 @@ static void remove_batch_test() { a = 14; taosArrayPush(delList, &a); - taosArrayRemoveBatch(pa, (const int32_t*) TARRAY_GET_START(delList), taosArrayGetSize(delList)); + taosArrayRemoveBatch(pa, (const int32_t*)TARRAY_GET_START(delList), taosArrayGetSize(delList)); EXPECT_EQ(taosArrayGetSize(pa), 17); taosArrayDestroy(pa); @@ -49,24 +49,22 @@ static void remove_batch_test() { } } // namespace -TEST(arrayTest, array_list_test) { - remove_batch_test(); -} +TEST(arrayTest, array_list_test) { remove_batch_test(); } TEST(arrayTest, array_search_test) { - SArray *pa = (SArray*) taosArrayInit(4, sizeof(int32_t)); + SArray* pa = (SArray*)taosArrayInit(4, sizeof(int32_t)); - for(int32_t i = 10; i < 20; ++i) { + for (int32_t i = 10; i < 20; ++i) { int32_t a = i; taosArrayPush(pa, &a); } - for(int i = 0; i < 30; i++) { - int32_t k = i; + for (int i = 0; i < 30; i++) { + int32_t k = i; int32_t* pRet = (int32_t*)taosArraySearch(pa, &k, compareInt32Val, TD_GE); - int32_t idx = taosArraySearchIdx(pa, &k, compareInt32Val, TD_GE); + int32_t idx = taosArraySearchIdx(pa, &k, compareInt32Val, TD_GE); - if(pRet == NULL) { + if (pRet == NULL) { ASSERT_EQ(idx, -1); } else { ASSERT_EQ(taosArrayGet(pa, idx), pRet); @@ -75,12 +73,11 @@ TEST(arrayTest, array_search_test) { pRet = (int32_t*)taosArraySearch(pa, &k, compareInt32Val, TD_LE); idx = taosArraySearchIdx(pa, &k, compareInt32Val, TD_LE); - if(pRet == NULL) { + if (pRet == NULL) { ASSERT_EQ(idx, -1); } else { ASSERT_EQ(taosArrayGet(pa, idx), pRet); } - } taosArrayDestroy(pa); diff --git a/source/util/test/bloomFilterTest.cpp b/source/util/test/bloomFilterTest.cpp index fcb1b4f0aef180bc509a75b9de3cb45303789529..2e021291640edff46279696b3ac29cc326f43049 100644 --- a/source/util/test/bloomFilterTest.cpp +++ b/source/util/test/bloomFilterTest.cpp @@ -1,7 +1,7 @@ #include -#include "tscalablebf.h" #include "taoserror.h" +#include "tscalablebf.h" using namespace std; @@ -15,38 +15,38 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, normal_bloomFilter) { SBloomFilter *pBF1 = tBloomFilterInit(100, 0.005); GTEST_ASSERT_EQ(pBF1->numBits, 1152); - GTEST_ASSERT_EQ(pBF1->numUnits, 1152/64); + GTEST_ASSERT_EQ(pBF1->numUnits, 1152 / 64); int64_t count = 0; - for(int64_t i = 0; count < 100; i++) { + for (int64_t i = 0; count < 100; i++) { int64_t ts = i + ts1; - if(tBloomFilterPut(pBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS ) { + if (tBloomFilterPut(pBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS) { count++; } } ASSERT_TRUE(tBloomFilterIsFull(pBF1)); - SBloomFilter *pBF2 = tBloomFilterInit(1000*10000, 0.1); + SBloomFilter *pBF2 = tBloomFilterInit(1000 * 10000, 0.1); GTEST_ASSERT_EQ(pBF2->numBits, 47925312); - GTEST_ASSERT_EQ(pBF2->numUnits, 47925312/64); + GTEST_ASSERT_EQ(pBF2->numUnits, 47925312 / 64); - SBloomFilter *pBF3 = tBloomFilterInit(10000*10000, 0.001); + SBloomFilter *pBF3 = tBloomFilterInit(10000 * 10000, 0.001); GTEST_ASSERT_EQ(pBF3->numBits, 1437758784); - GTEST_ASSERT_EQ(pBF3->numUnits, 1437758784/64); - - int64_t size = 10000; + GTEST_ASSERT_EQ(pBF3->numUnits, 1437758784 / 64); + + int64_t size = 10000; SBloomFilter *pBF4 = tBloomFilterInit(size, 0.001); - for(int64_t i = 0; i < 1000; i++) { + for (int64_t i = 0; i < 1000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tBloomFilterPut(pBF4, &ts, sizeof(int64_t)), TSDB_CODE_SUCCESS); } ASSERT_TRUE(!tBloomFilterIsFull(pBF4)); - for(int64_t i = 0; i < 1000; i++) { + for (int64_t i = 0; i < 1000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tBloomFilterNoContain(pBF4, &ts, sizeof(int64_t)), TSDB_CODE_FAILED); } - for(int64_t i = 2000; i < 3000; i++) { + for (int64_t i = 2000; i < 3000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tBloomFilterNoContain(pBF4, &ts, sizeof(int64_t)), TSDB_CODE_SUCCESS); } @@ -55,7 +55,6 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, normal_bloomFilter) { tBloomFilterDestroy(pBF2); tBloomFilterDestroy(pBF3); tBloomFilterDestroy(pBF4); - } TEST(TD_UTIL_BLOOMFILTER_TEST, scalable_bloomFilter) { @@ -70,71 +69,69 @@ TEST(TD_UTIL_BLOOMFILTER_TEST, scalable_bloomFilter) { GTEST_ASSERT_EQ(pSBF1->numBits, 1152); int64_t count = 0; int64_t index = 0; - for( ; count < 100; index++) { + for (; count < 100; index++) { int64_t ts = index + ts1; - if(tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS ) { + if (tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS) { count++; } } GTEST_ASSERT_EQ(pSBF1->numBits, 1152); - for( ; count < 300; index++) { + for (; count < 300; index++) { int64_t ts = index + ts1; - if(tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS ) { + if (tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS) { count++; } } - GTEST_ASSERT_EQ(pSBF1->numBits, 1152+2496); + GTEST_ASSERT_EQ(pSBF1->numBits, 1152 + 2496); - for( ; count < 700; index++) { + for (; count < 700; index++) { int64_t ts = index + ts1; - if(tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS ) { + if (tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS) { count++; } } - GTEST_ASSERT_EQ(pSBF1->numBits, 1152+2496+5568); + GTEST_ASSERT_EQ(pSBF1->numBits, 1152 + 2496 + 5568); - for( ; count < 1500; index++) { + for (; count < 1500; index++) { int64_t ts = index + ts1; - if(tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS ) { + if (tScalableBfPut(pSBF1, &ts, sizeof(int64_t)) == TSDB_CODE_SUCCESS) { count++; } } - GTEST_ASSERT_EQ(pSBF1->numBits, 1152+2496+5568+12288); - + GTEST_ASSERT_EQ(pSBF1->numBits, 1152 + 2496 + 5568 + 12288); + int32_t aSize = taosArrayGetSize(pSBF1->bfArray); int64_t totalBits = 0; - for(int64_t i = 0; i < aSize; i++) { + for (int64_t i = 0; i < aSize; i++) { SBloomFilter *pBF = (SBloomFilter *)taosArrayGetP(pSBF1->bfArray, i); - ASSERT_TRUE(tBloomFilterIsFull(pBF)); + ASSERT_TRUE(tBloomFilterIsFull(pBF)); totalBits += pBF->numBits; } GTEST_ASSERT_EQ(pSBF1->numBits, totalBits); - for(int64_t i = 0; i < index; i++) { + for (int64_t i = 0; i < index; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tScalableBfNoContain(pSBF1, &ts, sizeof(int64_t)), TSDB_CODE_FAILED); } - - int64_t size = 10000; + int64_t size = 10000; SScalableBf *pSBF4 = tScalableBfInit(size, 0.001); - for(int64_t i = 0; i < 1000; i++) { + for (int64_t i = 0; i < 1000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tScalableBfPut(pSBF4, &ts, sizeof(int64_t)), TSDB_CODE_SUCCESS); } - for(int64_t i = 0; i < 1000; i++) { + for (int64_t i = 0; i < 1000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tScalableBfNoContain(pSBF4, &ts, sizeof(int64_t)), TSDB_CODE_FAILED); } - for(int64_t i = 2000; i < 3000; i++) { + for (int64_t i = 2000; i < 3000; i++) { int64_t ts = i + ts1; GTEST_ASSERT_EQ(tScalableBfNoContain(pSBF4, &ts, sizeof(int64_t)), TSDB_CODE_SUCCESS); } tScalableBfDestroy(pSBF1); tScalableBfDestroy(pSBF4); - } \ No newline at end of file diff --git a/source/util/test/hashTest.cpp b/source/util/test/hashTest.cpp index 97e67ea36e7120b5e09f1097b5fb979b6fc12224..7c9283464eec311b1cfa48b7eee75b5c89fa3018 100644 --- a/source/util/test/hashTest.cpp +++ b/source/util/test/hashTest.cpp @@ -3,162 +3,163 @@ #include #include "os.h" +#include "taos.h" #include "taosdef.h" #include "thash.h" -#include "taos.h" namespace { typedef struct TESTSTRUCT { - char *p; -}TESTSTRUCT; + char* p; +} TESTSTRUCT; // the simple test code for basic operations void simpleTest() { - SHashObj* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); + SHashObj* hashTable = + (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_ENTRY_LOCK); ASSERT_EQ(taosHashGetSize(hashTable), 0); - + // put 400 elements in the hash table - for(int32_t i = -200; i < 200; ++i) { - taosHashPut(hashTable, (const char*) &i, sizeof(int32_t), (char*) &i, sizeof(int32_t)); + for (int32_t i = -200; i < 200; ++i) { + taosHashPut(hashTable, (const char*)&i, sizeof(int32_t), (char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), 400); - - for(int32_t i = 0; i < 200; ++i) { - char* p = (char*) taosHashGet(hashTable, (const char*) &i, sizeof(int32_t)); + + for (int32_t i = 0; i < 200; ++i) { + char* p = (char*)taosHashGet(hashTable, (const char*)&i, sizeof(int32_t)); ASSERT_TRUE(p != nullptr); ASSERT_EQ(*reinterpret_cast(p), i); } - - for(int32_t i = 1000; i < 2000; ++i) { - taosHashRemove(hashTable, (const char*) &i, sizeof(int32_t)); + + for (int32_t i = 1000; i < 2000; ++i) { + taosHashRemove(hashTable, (const char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), 400); - - for(int32_t i = 0; i < 100; ++i) { - taosHashRemove(hashTable, (const char*) &i, sizeof(int32_t)); + + for (int32_t i = 0; i < 100; ++i) { + taosHashRemove(hashTable, (const char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), 300); - - for(int32_t i = 100; i < 150; ++i) { - taosHashRemove(hashTable, (const char*) &i, sizeof(int32_t)); + + for (int32_t i = 100; i < 150; ++i) { + taosHashRemove(hashTable, (const char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), 250); taosHashCleanup(hashTable); } void stringKeyTest() { - auto* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + auto* hashTable = + (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); ASSERT_EQ(taosHashGetSize(hashTable), 0); - + char key[128] = {0}; - + // put 200 elements in the hash table - for(int32_t i = 0; i < 1000; ++i) { + for (int32_t i = 0; i < 1000; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - taosHashPut(hashTable, key, len, (char*) &i, sizeof(int32_t)); + taosHashPut(hashTable, key, len, (char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), 1000); - - for(int32_t i = 0; i < 1000; ++i) { + + for (int32_t i = 0; i < 1000; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - - char* p = (char*) taosHashGet(hashTable, key, len); + + char* p = (char*)taosHashGet(hashTable, key, len); ASSERT_TRUE(p != nullptr); - + ASSERT_EQ(*reinterpret_cast(p), i); } - - for(int32_t i = 500; i < 1000; ++i) { + + for (int32_t i = 500; i < 1000; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - + taosHashRemove(hashTable, key, len); } - + ASSERT_EQ(taosHashGetSize(hashTable), 500); - - for(int32_t i = 0; i < 499; ++i) { + + for (int32_t i = 0; i < 499; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - + taosHashRemove(hashTable, key, len); } - + ASSERT_EQ(taosHashGetSize(hashTable), 1); - + taosHashCleanup(hashTable); } -void functionTest() { - -} +void functionTest() {} /** * evaluate the performance issue, by add 10million elements in to hash table in * a single threads situation */ void noLockPerformanceTest() { - auto* hashTable = (SHashObj*) taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); + auto* hashTable = + (SHashObj*)taosHashInit(4096, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); ASSERT_EQ(taosHashGetSize(hashTable), 0); - - char key[128] = {0}; + + char key[128] = {0}; int32_t num = 5000; - + int64_t st = taosGetTimestampUs(); - + // put 10M elements in the hash table - for(int32_t i = 0; i < num; ++i) { + for (int32_t i = 0; i < num; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - taosHashPut(hashTable, key, len, (char*) &i, sizeof(int32_t)); + taosHashPut(hashTable, key, len, (char*)&i, sizeof(int32_t)); } - + ASSERT_EQ(taosHashGetSize(hashTable), num); - + int64_t et = taosGetTimestampUs(); - printf("Elpased time:%" PRId64 " us to add %d elements, avg cost:%lf us\n", et - st, num, (et - st)/(double) num); - + printf("Elpased time:%" PRId64 " us to add %d elements, avg cost:%lf us\n", et - st, num, (et - st) / (double)num); + st = taosGetTimestampUs(); - for(int32_t i = 0; i < num; ++i) { + for (int32_t i = 0; i < num; ++i) { int32_t len = sprintf(key, "%d_1_%dabcefg_", i, i + 10); - char* p = (char*) taosHashGet(hashTable, key, len); + char* p = (char*)taosHashGet(hashTable, key, len); ASSERT_TRUE(p != nullptr); - + ASSERT_EQ(*reinterpret_cast(p), i); } - + et = taosGetTimestampUs(); - printf("Elpased time:%" PRId64 " us to fetch all %d elements, avg cost:%lf us\n", et - st, num, (et - st)/(double) num); - + printf("Elpased time:%" PRId64 " us to fetch all %d elements, avg cost:%lf us\n", et - st, num, + (et - st) / (double)num); + printf("The maximum length of overflow linklist in hash table is:%d\n", taosHashGetMaxOverflowLinkLength(hashTable)); taosHashCleanup(hashTable); } void multithreadsTest() { - //todo + // todo } // check the function robustness -void invalidOperationTest() { - -} +void invalidOperationTest() {} void acquireRleaseTest() { - SHashObj* hashTable = (SHashObj*) taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); + SHashObj* hashTable = + (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_ENTRY_LOCK); ASSERT_EQ(taosHashGetSize(hashTable), 0); - int32_t key = 2; - int32_t code = 0; - int32_t num = 0; - TESTSTRUCT data = {0}; - const char *str1 = "abcdefg"; - const char *str2 = "aaaaaaa"; - const char *str3 = "123456789"; + int32_t key = 2; + int32_t code = 0; + int32_t num = 0; + TESTSTRUCT data = {0}; + const char* str1 = "abcdefg"; + const char* str2 = "aaaaaaa"; + const char* str3 = "123456789"; - data.p = (char *)taosMemoryMalloc(10); + data.p = (char*)taosMemoryMalloc(10); strcpy(data.p, str1); code = taosHashPut(hashTable, &key, sizeof(key), &data, sizeof(data)); @@ -167,17 +168,17 @@ void acquireRleaseTest() { TESTSTRUCT* pdata = (TESTSTRUCT*)taosHashAcquire(hashTable, &key, sizeof(key)); ASSERT_TRUE(pdata != nullptr); ASSERT_TRUE(strcmp(pdata->p, str1) == 0); - + code = taosHashRemove(hashTable, &key, sizeof(key)); ASSERT_EQ(code, 0); ASSERT_TRUE(strcmp(pdata->p, str1) == 0); num = taosHashGetSize(hashTable); ASSERT_EQ(num, 1); - + strcpy(pdata->p, str3); - data.p = (char *)taosMemoryMalloc(10); + data.p = (char*)taosMemoryMalloc(10); strcpy(data.p, str2); code = taosHashPut(hashTable, &key, sizeof(key), &data, sizeof(data)); ASSERT_EQ(code, 0); @@ -198,19 +199,26 @@ void acquireRleaseTest() { } void perfTest() { - SHashObj* hash1h = (SHashObj*) taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash1s = (SHashObj*) taosHashInit(1000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash10s = (SHashObj*) taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash100s = (SHashObj*) taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash1m = (SHashObj*) taosHashInit(1000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash10m = (SHashObj*) taosHashInit(10000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - SHashObj* hash100m = (SHashObj*) taosHashInit(100000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); - - char *name = (char*)taosMemoryCalloc(50000000, 9); + SHashObj* hash1h = + (SHashObj*)taosHashInit(100, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash1s = + (SHashObj*)taosHashInit(1000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash10s = + (SHashObj*)taosHashInit(10000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash100s = + (SHashObj*)taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash1m = + (SHashObj*)taosHashInit(1000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash10m = + (SHashObj*)taosHashInit(10000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + SHashObj* hash100m = + (SHashObj*)taosHashInit(100000000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + + char* name = (char*)taosMemoryCalloc(50000000, 9); for (int64_t i = 0; i < 50000000; ++i) { sprintf(name + i * 9, "t%08d", i); } - + for (int64_t i = 0; i < 50; ++i) { taosHashPut(hash1h, name + i * 9, 9, &i, sizeof(i)); } @@ -295,22 +303,21 @@ void perfTest() { int64_t end100m = taosGetTimestampMs(); int64_t end100mCt = taosHashGetCompTimes(hash100m); - - SArray *sArray[1000] = {0}; + SArray* sArray[1000] = {0}; for (int64_t i = 0; i < 1000; ++i) { sArray[i] = taosArrayInit(100000, 9); } int64_t cap = 4; while (cap < 100000000) cap = (cap << 1u); - + _hash_fn_t hashFp = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - int32_t slotR = cap / 1000 + 1; + int32_t slotR = cap / 1000 + 1; for (int64_t i = 0; i < 10000000; ++i) { - char* p = name + (i % 50000000) * 9; + char* p = name + (i % 50000000) * 9; uint32_t v = (*hashFp)(p, 9); - taosArrayPush(sArray[(v%cap)/slotR], p); + taosArrayPush(sArray[(v % cap) / slotR], p); } - SArray *slArray = taosArrayInit(100000000, 9); + SArray* slArray = taosArrayInit(100000000, 9); for (int64_t i = 0; i < 1000; ++i) { int32_t num = taosArrayGetSize(sArray[i]); SArray* pArray = sArray[i]; @@ -349,17 +356,17 @@ void perfTest() { taosHashCleanup(hash10m); taosHashCleanup(hash100m); - SHashObj *mhash[1000] = {0}; + SHashObj* mhash[1000] = {0}; for (int64_t i = 0; i < 1000; ++i) { - mhash[i] = (SHashObj*) taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + mhash[i] = (SHashObj*)taosHashInit(100000, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); } for (int64_t i = 0; i < 50000000; ++i) { #if 0 taosHashPut(mhash[i%1000], name + i * 9, 9, &i, sizeof(i)); #else - taosHashPut(mhash[i/50000], name + i * 9, 9, &i, sizeof(i)); -#endif + taosHashPut(mhash[i / 50000], name + i * 9, 9, &i, sizeof(i)); +#endif } int64_t startMhashCt = 0; @@ -373,15 +380,15 @@ void perfTest() { ASSERT(taosHashGet(mhash[i%1000], name + i * 9, 9)); } #else -// for (int64_t i = 0; i < 10000000; ++i) { - for (int64_t i = 0; i < 50000000; i+=5) { - ASSERT(taosHashGet(mhash[i/50000], name + i * 9, 9)); + // for (int64_t i = 0; i < 10000000; ++i) { + for (int64_t i = 0; i < 50000000; i += 5) { + ASSERT(taosHashGet(mhash[i / 50000], name + i * 9, 9)); } -#endif +#endif int64_t endMhash = taosGetTimestampMs(); int64_t endMhashCt = 0; for (int64_t i = 0; i < 1000; ++i) { - printf(" %" PRId64 , taosHashGetCompTimes(mhash[i])); + printf(" %" PRId64, taosHashGetCompTimes(mhash[i])); endMhashCt += taosHashGetCompTimes(mhash[i]); } printf("\n100m \t %" PRId64 "ms,%" PRId64 "\n", endMhash - startMhash, endMhashCt - startMhashCt); @@ -391,8 +398,7 @@ void perfTest() { } } - -} +} // namespace int main(int argc, char** argv) { testing::InitGoogleTest(&argc, argv); @@ -405,5 +411,5 @@ TEST(testCase, hashTest) { noLockPerformanceTest(); multithreadsTest(); acquireRleaseTest(); - //perfTest(); + // perfTest(); } diff --git a/source/util/test/pageBufferTest.cpp b/source/util/test/pageBufferTest.cpp index 534c17758714820e9a9f2bf6b81d23ac121fcaf4..869bb2a76d5e58392bb79c5477c20469097eab22 100644 --- a/source/util/test/pageBufferTest.cpp +++ b/source/util/test/pageBufferTest.cpp @@ -13,19 +13,19 @@ namespace { // simple test void simpleTest() { SDiskbasedBuf* pBuf = NULL; - int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4096, "", TD_TMP_DIR_PATH); - + int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4096, "", TD_TMP_DIR_PATH); + int32_t pageId = 0; int32_t groupId = 0; - + SFilePage* pBufPage = static_cast(getNewBufPage(pBuf, &pageId)); ASSERT_TRUE(pBufPage != NULL); - + ASSERT_EQ(getTotalBufSize(pBuf), 1024); - + SIDList list = getDataBufPagesIdList(pBuf); ASSERT_EQ(taosArrayGetSize(list), 1); - //ASSERT_EQ(getNumOfBufGroupId(pBuf), 1); + // ASSERT_EQ(getNumOfBufGroupId(pBuf), 1); releaseBufPage(pBuf, pBufPage); @@ -38,17 +38,17 @@ void simpleTest() { SFilePage* t1 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t1 == pBufPage2); - SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t2 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t2 == pBufPage3); - SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t3 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t3 == pBufPage4); releaseBufPage(pBuf, pBufPage2); - SFilePage* pBufPage5 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage5 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t4 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t4 == pBufPage5); @@ -57,19 +57,19 @@ void simpleTest() { void writeDownTest() { SDiskbasedBuf* pBuf = NULL; - int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4*1024, "1", TD_TMP_DIR_PATH); + int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4 * 1024, "1", TD_TMP_DIR_PATH); int32_t pageId = 0; int32_t writePageId = 0; int32_t groupId = 0; int32_t nx = 12345; - SFilePage* pBufPage = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage = static_cast(getNewBufPage(pBuf, &pageId)); ASSERT_TRUE(pBufPage != NULL); *(int32_t*)(pBufPage->data) = nx; writePageId = pageId; - + setBufPageDirty(pBufPage, true); releaseBufPage(pBuf, pBufPage); @@ -83,12 +83,12 @@ void writeDownTest() { ASSERT_TRUE(t2 == pBufPage2); ASSERT_TRUE(pageId == 2); - SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t3 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t3 == pBufPage3); ASSERT_TRUE(pageId == 3); - SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t4 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t4 == pBufPage4); ASSERT_TRUE(pageId == 4); @@ -106,39 +106,39 @@ void writeDownTest() { void recyclePageTest() { SDiskbasedBuf* pBuf = NULL; - int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4*1024, "1", TD_TMP_DIR_PATH); + int32_t ret = createDiskbasedBuf(&pBuf, 1024, 4 * 1024, "1", TD_TMP_DIR_PATH); int32_t pageId = 0; int32_t writePageId = 0; int32_t groupId = 0; int32_t nx = 12345; - SFilePage* pBufPage = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage = static_cast(getNewBufPage(pBuf, &pageId)); ASSERT_TRUE(pBufPage != NULL); releaseBufPage(pBuf, pBufPage); - SFilePage* pBufPage1 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage1 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t1 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t1 == pBufPage1); ASSERT_TRUE(pageId == 1); - SFilePage* pBufPage2 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage2 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t2 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t2 == pBufPage2); ASSERT_TRUE(pageId == 2); - SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage3 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t3 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t3 == pBufPage3); ASSERT_TRUE(pageId == 3); - SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage4 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t4 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t4 == pBufPage4); ASSERT_TRUE(pageId == 4); releaseBufPage(pBuf, t4); - SFilePage* pBufPage5 = static_cast(getNewBufPage(pBuf, &pageId)); + SFilePage* pBufPage5 = static_cast(getNewBufPage(pBuf, &pageId)); SFilePage* t5 = static_cast(getBufPage(pBuf, pageId)); ASSERT_TRUE(t5 == pBufPage5); ASSERT_TRUE(pageId == 5); @@ -147,7 +147,7 @@ void recyclePageTest() { // flush the written page to disk, and read it out again SFilePage* pBufPagex = static_cast(getBufPage(pBuf, writePageId)); *(int32_t*)(pBufPagex->data) = nx; - writePageId = pageId; // update the data + writePageId = pageId; // update the data releaseBufPage(pBuf, pBufPagex); SFilePage* pBufPagex1 = static_cast(getBufPage(pBuf, 1)); @@ -157,8 +157,7 @@ void recyclePageTest() { destroyDiskbasedBuf(pBuf); } -} // namespace - +} // namespace TEST(testCase, resultBufferTest) { taosSeedRand(taosGetTimestampSec()); diff --git a/source/util/test/stringTest.cpp b/source/util/test/stringTest.cpp index dee5fb30d30661d38413b2610a331b7c19bddd15..137971f2efb1b661b63f1ea6a7da3212719d67f8 100644 --- a/source/util/test/stringTest.cpp +++ b/source/util/test/stringTest.cpp @@ -19,7 +19,7 @@ TEST(testCase, string_dequote_test) { EXPECT_EQ(3, len); EXPECT_STRCASEEQ(t1, "abc"); - char t21[] = " abc "; + char t21[] = " abc "; int32_t lx = strtrim(t21); EXPECT_STREQ("abc", t21); diff --git a/source/util/test/taosbsearchTest.cpp b/source/util/test/taosbsearchTest.cpp index b8fa3a44767d029b51e5e596aaac62b351290734..d4a601324723e8e5e5b4734dd2102774a87138bd 100644 --- a/source/util/test/taosbsearchTest.cpp +++ b/source/util/test/taosbsearchTest.cpp @@ -5,247 +5,247 @@ static int compareFunc(const void *arg1, const void *arg2) { return (*(int *)arg1) - (*(int *)arg2); } TEST(testCase, taosbsearch_equal) { - // For equal test - int key = 3; - void *pRet = NULL; + // For equal test + int key = 3; + void *pRet = NULL; - pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - // 1 element - int array1[1] = {5}; + // 1 element + int array1[1] = {5}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 5; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); - ASSERT_NE(pRet, nullptr); - ASSERT_EQ(*(int *)pRet, key); + key = 5; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_EQ); + ASSERT_NE(pRet, nullptr); + ASSERT_EQ(*(int *)pRet, key); - // 2 element - int array2[2] = {3, 6}; + // 2 element + int array2[2] = {3, 6}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(*(int *)pRet, key); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(*(int *)pRet, key); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - // 3 element - int array3[3] = {3, 6, 8}; + // 3 element + int array3[3] = {3, 6, 8}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); - ASSERT_EQ(pRet, nullptr); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_EQ); + ASSERT_EQ(pRet, nullptr); } TEST(testCase, taosbsearch_greater_or_equal) { - // For equal test - int key = 3; - void *pRet = NULL; + // For equal test + int key = 3; + void *pRet = NULL; - pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); - // 1 element - int array1[1] = {5}; + // 1 element + int array1[1] = {5}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 5); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 5); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); - key = 5; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); - ASSERT_NE(pRet, nullptr); - ASSERT_EQ(*(int *)pRet, 5); + key = 5; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_GE); + ASSERT_NE(pRet, nullptr); + ASSERT_EQ(*(int *)pRet, 5); - // 2 element - int array2[2] = {3, 6}; + // 2 element + int array2[2] = {3, 6}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); - // 3 element - int array3[3] = {3, 6, 8}; + // 3 element + int array3[3] = {3, 6, 8}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); - // 4 element - int array4[4] = {3, 6, 8, 11}; + // 4 element + int array4[4] = {3, 6, 8, 11}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 11); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 11); - key = 11; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 11); + key = 11; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 11); - key = 13; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + key = 13; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); - // 5 element - int array5[5] = {3, 6, 8, 11, 15}; + // 5 element + int array5[5] = {3, 6, 8, 11, 15}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 11); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 11); - key = 11; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 11); + key = 11; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 11); - key = 13; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 15); + key = 13; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 15); - key = 15; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(*(int *)pRet, 15); + key = 15; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(*(int *)pRet, 15); - key = 17; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); - ASSERT_EQ(pRet, nullptr); + key = 17; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_GE); + ASSERT_EQ(pRet, nullptr); } TEST(testCase, taosbsearch_greater) { @@ -413,168 +413,168 @@ TEST(testCase, taosbsearch_greater) { } TEST(testCase, taosbsearch_less_or_equal) { - // For equal test - int key = 3; - void *pRet = NULL; + // For equal test + int key = 3; + void *pRet = NULL; - pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + pRet = taosbsearch((void *)&key, NULL, 0, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - // 1 element - int array1[1] = {5}; + // 1 element + int array1[1] = {5}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 5); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 5); - key = 5; - pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); - ASSERT_NE(pRet, nullptr); - ASSERT_EQ(*(int *)pRet, 5); + key = 5; + pRet = taosbsearch((void *)&key, (void *)array1, 1, sizeof(int), compareFunc, TD_LE); + ASSERT_NE(pRet, nullptr); + ASSERT_EQ(*(int *)pRet, 5); - // 2 element - int array2[2] = {3, 6}; + // 2 element + int array2[2] = {3, 6}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array2, 2, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - // 3 element - int array3[3] = {3, 6, 8}; + // 3 element + int array3[3] = {3, 6, 8}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array3, 3, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - // 4 element - int array4[4] = {3, 6, 8, 11}; + // 4 element + int array4[4] = {3, 6, 8, 11}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - key = 11; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 11); + key = 11; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 11); - key = 13; - pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 11); + key = 13; + pRet = taosbsearch((void *)&key, (void *)array4, 4, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 11); - // 5 element - int array5[5] = {3, 6, 8, 11, 15}; + // 5 element + int array5[5] = {3, 6, 8, 11, 15}; - key = 1; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(pRet, nullptr); + key = 1; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(pRet, nullptr); - key = 3; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 3; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 4; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 3); + key = 4; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 3); - key = 6; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 6; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 7; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 6); + key = 7; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 6); - key = 8; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 8; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - key = 9; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 8); + key = 9; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 8); - key = 11; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 11); + key = 11; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 11); - key = 13; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 11); + key = 13; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 11); - key = 15; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 15); + key = 15; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 15); - key = 17; - pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); - ASSERT_EQ(*(int *)pRet, 15); + key = 17; + pRet = taosbsearch((void *)&key, (void *)array5, 5, sizeof(int), compareFunc, TD_LE); + ASSERT_EQ(*(int *)pRet, 15); } TEST(testCase, taosbsearch_less) { diff --git a/source/util/test/trefTest.c b/source/util/test/trefTest.c index 5a6790ef1da3b5a6b015c836d09150b06e0a003f..46656d7776e2d609a7ddf8c1309b1aad6da8ec36 100644 --- a/source/util/test/trefTest.c +++ b/source/util/test/trefTest.c @@ -1,91 +1,88 @@ +#include "tref.h" #include #include #include #include #include "os.h" -#include "tref.h" -#include "tlog.h" -#include "tglobal.h" #include "taoserror.h" +#include "tglobal.h" #include "tlog.h" typedef struct { - int refNum; - int steps; - int rsetId; - int64_t*rid; - void **p; + int refNum; + int steps; + int rsetId; + int64_t *rid; + void **p; } SRefSpace; void iterateRefs(int rsetId) { - int count = 0; + int count = 0; void *p = taosIterateRef(rsetId, 0); while (p) { // process P count++; - p = taosIterateRef(rsetId, (int64_t) p); - } + p = taosIterateRef(rsetId, (int64_t)p); + } - printf(" %d ", count); + printf(" %d ", count); } void *addRef(void *param) { SRefSpace *pSpace = (SRefSpace *)param; - int id; + int id; - for (int i=0; i < pSpace->steps; ++i) { + for (int i = 0; i < pSpace->steps; ++i) { printf("a"); - id = taosRand() % pSpace->refNum; + id = taosRand() % pSpace->refNum; if (pSpace->rid[id] <= 0) { pSpace->p[id] = taosMemoryMalloc(128); pSpace->rid[id] = taosAddRef(pSpace->rsetId, pSpace->p[id]); } taosUsleep(100); - } + } return NULL; } - + void *removeRef(void *param) { SRefSpace *pSpace = (SRefSpace *)param; - int id, code; + int id, code; - for (int i=0; i < pSpace->steps; ++i) { + for (int i = 0; i < pSpace->steps; ++i) { printf("d"); - id = taosRand() % pSpace->refNum; + id = taosRand() % pSpace->refNum; if (pSpace->rid[id] > 0) { code = taosRemoveRef(pSpace->rsetId, pSpace->rid[id]); if (code == 0) pSpace->rid[id] = 0; } taosUsleep(100); - } + } return NULL; } - + void *acquireRelease(void *param) { SRefSpace *pSpace = (SRefSpace *)param; - int id; + int id; - for (int i=0; i < pSpace->steps; ++i) { + for (int i = 0; i < pSpace->steps; ++i) { printf("a"); - - id = taosRand() % pSpace->refNum; - void *p = taosAcquireRef(pSpace->rsetId, (int64_t) pSpace->p[id]); + + id = taosRand() % pSpace->refNum; + void *p = taosAcquireRef(pSpace->rsetId, (int64_t)pSpace->p[id]); if (p) { taosUsleep(id % 5 + 1); - taosReleaseRef(pSpace->rsetId, (int64_t) pSpace->p[id]); + taosReleaseRef(pSpace->rsetId, (int64_t)pSpace->p[id]); } - } + } return NULL; } - -void myfree(void *p) { - taosMemoryFree(p); -} + +void myfree(void *p) { taosMemoryFree(p); } void *openRefSpace(void *param) { SRefSpace *pSpace = (SRefSpace *)param; @@ -96,9 +93,9 @@ void *openRefSpace(void *param) { if (pSpace->rsetId < 0) { printf("failed to open ref, reason:%s\n", tstrerror(pSpace->rsetId)); return NULL; - } + } - pSpace->p = (void **) taosMemoryCalloc(sizeof(void *), pSpace->refNum); + pSpace->p = (void **)taosMemoryCalloc(sizeof(void *), pSpace->refNum); pSpace->rid = taosMemoryCalloc(pSpace->refNum, sizeof(int64_t)); TdThreadAttr thattr; @@ -114,7 +111,7 @@ void *openRefSpace(void *param) { taosThreadJoin(thread2, NULL); taosThreadJoin(thread3, NULL); - for (int i=0; irefNum; ++i) { + for (int i = 0; i < pSpace->refNum; ++i) { taosRemoveRef(pSpace->rsetId, pSpace->rid[i]); } @@ -130,21 +127,21 @@ void *openRefSpace(void *param) { int main(int argc, char *argv[]) { int refNum = 100; int threads = 10; - int steps = 10000; + int steps = 10000; int loops = 1; uDebugFlag = 143; - for (int i=1; i 0 then 1 < 2 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case when 1 > 2 then 1 < 2 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case when abs(3) then abs(-1) end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case when abs(1+1) then abs(-1)+abs(3) end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi +if $data10 != 4.000000000 then + return -1 +endi +if $data20 != 4.000000000 then + return -1 +endi +if $data30 != 4.000000000 then + return -1 +endi + +sql select case when 0 then 1 else 3 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 3 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 3 then + return -1 +endi + +sql select case when 0 then 1 when 1 then 0 else 3 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 0 then + return -1 +endi +if $data30 != 0 then + return -1 +endi + +sql select case when 0 then 1 when 1 then 0 when 2 then 3 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 0 then + return -1 +endi +if $data30 != 0 then + return -1 +endi + +sql select case when 'a' then 'b' when null then 0 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case when '2' then 'b' when null then 0 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != b then + return -1 +endi +if $data10 != b then + return -1 +endi +if $data20 != b then + return -1 +endi +if $data30 != b then + return -1 +endi + +sql select case when 0 then 'b' else null end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case when 0 then 'b' else 2 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 2 then + return -1 +endi + +sql select case when sum(2) then sum(2)-sum(1) end from tba1; +if $rows != 1 then + return -1 +endi +if $data00 != 4.000000000 then + return -1 +endi + +sql select case when sum(2) then abs(-2) end from tba1; +if $rows != 1 then + return -1 +endi +if $data00 != 2 then + return -1 +endi + +sql select case when ts then ts end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != @22-09-26 15:15:01.000@ then + return -1 +endi +if $data10 != @22-09-26 15:15:02.000@ then + return -1 +endi +if $data20 != @22-09-26 15:15:03.000@ then + return -1 +endi +if $data30 != @22-09-26 15:15:04.000@ then + return -1 +endi + +sql select case when f1 then ts end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != @22-09-26 15:15:02.000@ then + return -1 +endi +if $data20 != @22-09-26 15:15:03.000@ then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case when f1 then f1 when f1 + 1 then f1 + 1 else f1 is null end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 5 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case when f1 then 3 when ts then ts end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1664176501000 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 1664176504000 then + return -1 +endi + +sql select case when 3 then f1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 5 then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case when f1 then 3 when 1 then 2 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 3 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 2 then + return -1 +endi + +sql select case when sum(f1) then sum(f1)-abs(-1) end from tba1; +if $rows != 1 then + return -1 +endi +if $data00 != 5.000000000 then + return -1 +endi + +sql select case when sum(f1) then sum(f1)-abs(f1) end from tba1 group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != 0.000000000 then + return -1 +endi +if $data30 != 0.000000000 then + return -1 +endi + +sql select case when f1 then sum(f1) when f1 is not null then 9 else 8 end from tba1 group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != 8 then + return -1 +endi +if $data10 != 9 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 5 then + return -1 +endi + +sql select f1 from tba1 where f1 > case when f1 then 0 else 3 end; +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 5 then + return -1 +endi + +sql select f1 from tba1 where ts > case when ts then ts end; +if $rows != 0 then + return -1 +endi + +sql select sum(f1),count(f1) from tba1 partition by case when f1 then f1 when 1 then 1 end; +if $rows != 2 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data10 != 5 then + return -1 +endi +if $data11 != 1 then + return -1 +endi + +sql select case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end caseWhen, sum(f1),count(f1) from tba1 group by case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end order by caseWhen; +if $rows != 3 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 5 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != 0 then + return -1 +endi + +sql select f1 from tba1 order by case when f1 <= 0 then 3 when f1 = 1 then 4 when f1 >= 3 then 2 else 1 end desc; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 5 then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select cast(case f1 when f1 then f1 + 1 else f1 is null end as double) from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1.000000000 then + return -1 +endi +if $data10 != 2.000000000 then + return -1 +endi +if $data20 != 6.000000000 then + return -1 +endi +if $data30 != 1.000000000 then + return -1 +endi + +sql select sum(case f1 when f1 then f1 + 1 else f1 is null end + 1) from tba1; +if $rows != 1 then + return -1 +endi +if $data00 != 14.000000000 then + return -1 +endi + +sql select case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end,sum(f1),count(f1) from tba1 state_window(case when f1 < 3 then 1 when f1 >= 3 then 2 else 3 end); +if $rows != 3 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data02 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data11 != 5 then + return -1 +endi +if $data12 != 1 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data22 != 0 then + return -1 +endi + +sql select f1 from tba1 where case when case when f1 <= 0 then 3 when f1 = 1 then 4 when f1 >= 3 then 2 else 1 end > 2 then 1 else 0 end > 0; +if $rows != 2 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi + +sql select case when f1 is not null then case when f1 <= 0 then f1 else f1 * 10 end else -1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 10 then + return -1 +endi +if $data20 != 50 then + return -1 +endi +if $data30 != -1 then + return -1 +endi + + +print ======== case xx when xx + +sql select case 3 when 3 then 4 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 4 then + return -1 +endi +if $data20 != 4 then + return -1 +endi +if $data30 != 4 then + return -1 +endi + +sql select case 3 when 1 then 4 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case 3 when 1 then 4 else 2 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 2 then + return -1 +endi +if $data30 != 2 then + return -1 +endi + +sql select case 3 when null then 4 when '3' then 1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case '3' when null then 4 when 3 then 1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case null when null then 4 when 3 then 1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != NULL then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case 3.0 when null then 4 when '3' then 1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data30 != 1 then + return -1 +endi + +sql select case f2 when 'a' then 4 when '0' then 1 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 4 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi + +sql select case f2 when f1 then f1 when f1 - 1 then f1 else 99 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 0 then + return -1 +endi +if $data10 != 1 then + return -1 +endi +if $data20 != 5 then + return -1 +endi +if $data30 != 99 then + return -1 +endi + +sql select case cast(f2 as int) when 0 then f2 when f1 then 11 else ts end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != a then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data20 != 11 then + return -1 +endi +if $data30 != 1664176504 then + return -1 +endi + +sql select case f1 + 1 when 1 then 1 when 2 then 2 else 3 end from tba1; +if $rows != 4 then + return -1 +endi +if $data00 != 1 then + return -1 +endi +if $data10 != 2 then + return -1 +endi +if $data20 != 3 then + return -1 +endi +if $data30 != 3 then + return -1 +endi + +sql select case f1 when sum(f1) then sum(f1)-abs(f1) end from tba1 group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 0.000000000 then + return -1 +endi +if $data20 != 0.000000000 then + return -1 +endi +if $data30 != 0.000000000 then + return -1 +endi + +sql select f1, case sum(f1) when 1 then f1 + 99 when f1 then f1 -99 else f1 end from tba1 group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data10 != 0 then + return -1 +endi +if $data11 != -99.000000000 then + return -1 +endi +if $data20 != 1 then + return -1 +endi +if $data21 != 100.000000000 then + return -1 +endi +if $data30 != 5 then + return -1 +endi +if $data31 != -94.000000000 then + return -1 +endi + +sql select case when 3 then 4 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 4 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when null then 4 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 1 then 4+1 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 1-1 then 0 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 1+1 then 0 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when abs(3) then abs(-1) end from sta; +if $rows != 20 then + return -1 +endi +sql select case when abs(1+1) then abs(-1)+abs(3) end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 1 else 3 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 1 when 1 then 0 else 3 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 1 when 1 then 0 when 2 then 3 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 'a' then 'b' when null then 0 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when '2' then 'b' when null then 0 end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 'b' else null end from sta; +if $rows != 20 then + return -1 +endi +sql select case when 0 then 'b' else 2+abs(-2) end from sta; +if $rows != 20 then + return -1 +endi +sql select case 3 when 3 then 4 end from sta; +if $rows != 20 then + return -1 +endi +sql select case 3 when 1 then 4 end from sta; +if $rows != 20 then + return -1 +endi +sql select case 3 when 1 then 4 else 2 end from sta; +if $rows != 20 then + return -1 +endi +sql select case 3 when null then 4 when '3' then 1 end from sta; +if $rows != 20 then + return -1 +endi +sql select case null when null then 4 when 3 then 1 end from sta; +if $rows != 20 then + return -1 +endi +sql select case 3.0 when null then 4 when '3' then 1 end from sta; +if $rows != 20 then + return -1 +endi +sql select f2,case f2 when 'a' then 4 when '0' then 1 end from sta order by f2; +if $rows != 20 then + return -1 +endi +sql select f2,f1,case f2 when f1 then f1 when f1 - 1 then f1 else 99 end from sta order by f2; +if $rows != 20 then + return -1 +endi +sql select case cast(f2 as int) when 0 then f2 when f1 then 11 else ts end from sta; +if $rows != 20 then + return -1 +endi +sql select f1, case f1 + 1 when 1 then 1 when 2 then 2 else 3 end from sta order by f1; +if $rows != 20 then + return -1 +endi +sql select case f1 when sum(f1) then sum(f1)-abs(f1) end from sta group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != 0.000000000 then + return -1 +endi +if $data20 != NULL then + return -1 +endi +if $data30 != NULL then + return -1 +endi +sql select case sum(f1) when 1 then f1 + 99 when f1 then f1 -99 else f1 end from sta group by f1 order by f1; +if $rows != 4 then + return -1 +endi +if $data00 != NULL then + return -1 +endi +if $data10 != -99.000000000 then + return -1 +endi +if $data20 != 1.000000000 then + return -1 +endi +if $data30 != 5.000000000 then + return -1 +endi + +sql select distinct tbname, case t1 when t2 then t1 else t1 + 100 end from sta order by tbname; +if $rows != 5 then + return -1 +endi +if $data01 != 0 then + return -1 +endi +if $data11 != 1 then + return -1 +endi +if $data21 != NULL then + return -1 +endi +if $data31 != 101 then + return -1 +endi +if $data41 != 103 then + return -1 +endi + +sql_error select case when sum(f1) then sum(f1)-abs(f1) end from tba1; + +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tools/scripts/codeFormat.py b/tools/scripts/codeFormat.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/tools/scripts/codeFormat.sh b/tools/scripts/codeFormat.sh new file mode 100755 index 0000000000000000000000000000000000000000..cc7db5c723efcac9182956dda43c50aae4494e4f --- /dev/null +++ b/tools/scripts/codeFormat.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +PRJ_ROOT_DIR=$(readlink -f -- "$(dirname $0)/../..") +FORMAT_BIN=clang-format-14 + +ORIGIN_DIR=$(pwd) + +cd ${PRJ_ROOT_DIR} + +FORMAT_DIR_LIST=( + "${PRJ_ROOT_DIR}/include" + "${PRJ_ROOT_DIR}/source/os" + "${PRJ_ROOT_DIR}/source/util" + "${PRJ_ROOT_DIR}/source/common" + "${PRJ_ROOT_DIR}/source/libs" + "${PRJ_ROOT_DIR}/source/client/inc" + "${PRJ_ROOT_DIR}/source/client/src" + "${PRJ_ROOT_DIR}/source/client/test" + "${PRJ_ROOT_DIR}/source/dnode" +) + +EXCLUDE_DIR_LIST=( +) + +EXCLUDE_FILE_LIST=( + "source/libs/parser/sql.c" +) + +for d in ${FORMAT_DIR_LIST[@]}; do + for f in $(find $d -type f -not -name '*sql.c' -regex '.*\.\(cpp\|hpp\|c\|h\)'); do + ${FORMAT_BIN} -i $f + done +done + +cd ${ORIGIN_DIR} + +# find source -type f -regex '.*\.\(cpp\|hpp\|c\|h\)' ! -name