chore: merge 3.0
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 3588b3d
|
||||
GIT_TAG e7270c9
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -5,7 +5,9 @@ title: Reserved Keywords
|
|||
|
||||
## Keyword List
|
||||
|
||||
There are about 200 keywords reserved by TDengine, they can't be used as the name of database, STable or table with either upper case, lower case or mixed case. The following list shows all reserved keywords:
|
||||
There are more than 200 keywords reserved by TDengine, they can't be used as the name of database, table, STable, subtable, column or tag with either upper case, lower case or mixed case. If you need to use these keywords, use the symbol `` ` `` to enclose the keywords, e.g. \`ADD\`.
|
||||
|
||||
The following list shows all reserved keywords:
|
||||
|
||||
### A
|
||||
|
||||
|
@ -14,15 +16,20 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- ACCOUNTS
|
||||
- ADD
|
||||
- AFTER
|
||||
- AGGREGATE
|
||||
- ALL
|
||||
- ALTER
|
||||
- ANALYZE
|
||||
- AND
|
||||
- APPS
|
||||
- AS
|
||||
- ASC
|
||||
- AT_ONCE
|
||||
- ATTACH
|
||||
|
||||
### B
|
||||
|
||||
- BALANCE
|
||||
- BEFORE
|
||||
- BEGIN
|
||||
- BETWEEN
|
||||
|
@ -32,19 +39,27 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- BITNOT
|
||||
- BITOR
|
||||
- BLOCKS
|
||||
- BNODE
|
||||
- BNODES
|
||||
- BOOL
|
||||
- BUFFER
|
||||
- BUFSIZE
|
||||
- BY
|
||||
|
||||
### C
|
||||
|
||||
- CACHE
|
||||
- CACHELAST
|
||||
- CACHEMODEL
|
||||
- CACHESIZE
|
||||
- CASCADE
|
||||
- CAST
|
||||
- CHANGE
|
||||
- CLIENT_VERSION
|
||||
- CLUSTER
|
||||
- COLON
|
||||
- COLUMN
|
||||
- COMMA
|
||||
- COMMENT
|
||||
- COMP
|
||||
- COMPACT
|
||||
- CONCAT
|
||||
|
@ -52,15 +67,18 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- CONNECTION
|
||||
- CONNECTIONS
|
||||
- CONNS
|
||||
- CONSUMER
|
||||
- CONSUMERS
|
||||
- CONTAINS
|
||||
- COPY
|
||||
- COUNT
|
||||
- CREATE
|
||||
- CTIME
|
||||
- CURRENT_USER
|
||||
|
||||
### D
|
||||
|
||||
- DATABASE
|
||||
- DATABASES
|
||||
- DAYS
|
||||
- DBS
|
||||
- DEFERRED
|
||||
- DELETE
|
||||
|
@ -69,18 +87,23 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- DESCRIBE
|
||||
- DETACH
|
||||
- DISTINCT
|
||||
- DISTRIBUTED
|
||||
- DIVIDE
|
||||
- DNODE
|
||||
- DNODES
|
||||
- DOT
|
||||
- DOUBLE
|
||||
- DROP
|
||||
- DURATION
|
||||
|
||||
### E
|
||||
|
||||
- EACH
|
||||
- ENABLE
|
||||
- END
|
||||
- EQ
|
||||
- EVERY
|
||||
- EXISTS
|
||||
- EXPIRED
|
||||
- EXPLAIN
|
||||
|
||||
### F
|
||||
|
@ -88,18 +111,20 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- FAIL
|
||||
- FILE
|
||||
- FILL
|
||||
- FIRST
|
||||
- FLOAT
|
||||
- FLUSH
|
||||
- FOR
|
||||
- FROM
|
||||
- FSYNC
|
||||
- FUNCTION
|
||||
- FUNCTIONS
|
||||
|
||||
### G
|
||||
|
||||
- GE
|
||||
- GLOB
|
||||
- GRANT
|
||||
- GRANTS
|
||||
- GROUP
|
||||
- GT
|
||||
|
||||
### H
|
||||
|
||||
|
@ -110,15 +135,18 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- ID
|
||||
- IF
|
||||
- IGNORE
|
||||
- IMMEDIA
|
||||
- IMMEDIATE
|
||||
- IMPORT
|
||||
- IN
|
||||
- INITIAL
|
||||
- INDEX
|
||||
- INDEXES
|
||||
- INITIALLY
|
||||
- INNER
|
||||
- INSERT
|
||||
- INSTEAD
|
||||
- INT
|
||||
- INTEGER
|
||||
- INTERVA
|
||||
- INTERVAL
|
||||
- INTO
|
||||
- IS
|
||||
- ISNULL
|
||||
|
@ -126,6 +154,7 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
### J
|
||||
|
||||
- JOIN
|
||||
- JSON
|
||||
|
||||
### K
|
||||
|
||||
|
@ -135,46 +164,57 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
|
||||
### L
|
||||
|
||||
- LE
|
||||
- LAST
|
||||
- LAST_ROW
|
||||
- LICENCES
|
||||
- LIKE
|
||||
- LIMIT
|
||||
- LINEAR
|
||||
- LOCAL
|
||||
- LP
|
||||
- LSHIFT
|
||||
- LT
|
||||
|
||||
### M
|
||||
|
||||
- MATCH
|
||||
- MAX_DELAY
|
||||
- MAXROWS
|
||||
- MERGE
|
||||
- META
|
||||
- MINROWS
|
||||
- MINUS
|
||||
- MNODE
|
||||
- MNODES
|
||||
- MODIFY
|
||||
- MODULES
|
||||
|
||||
### N
|
||||
|
||||
- NE
|
||||
- NCHAR
|
||||
- NEXT
|
||||
- NMATCH
|
||||
- NONE
|
||||
- NOT
|
||||
- NOTNULL
|
||||
- NOW
|
||||
- NULL
|
||||
- NULLS
|
||||
|
||||
### O
|
||||
|
||||
- OF
|
||||
- OFFSET
|
||||
- ON
|
||||
- OR
|
||||
- ORDER
|
||||
- OUTPUTTYPE
|
||||
|
||||
### P
|
||||
|
||||
- PARTITION
|
||||
- PAGES
|
||||
- PAGESIZE
|
||||
- PARTITIONS
|
||||
- PASS
|
||||
- PLUS
|
||||
- PORT
|
||||
- PPS
|
||||
- PRECISION
|
||||
- PREV
|
||||
|
@ -182,47 +222,63 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
|
||||
### Q
|
||||
|
||||
- QNODE
|
||||
- QNODES
|
||||
- QTIME
|
||||
- QUERIE
|
||||
- QUERIES
|
||||
- QUERY
|
||||
- QUORUM
|
||||
|
||||
### R
|
||||
|
||||
- RAISE
|
||||
- REM
|
||||
- RANGE
|
||||
- RATIO
|
||||
- READ
|
||||
- REDISTRIBUTE
|
||||
- RENAME
|
||||
- REPLACE
|
||||
- REPLICA
|
||||
- RESET
|
||||
- RESTRIC
|
||||
- RESTRICT
|
||||
- RETENTIONS
|
||||
- REVOKE
|
||||
- ROLLUP
|
||||
- ROW
|
||||
- RP
|
||||
- RSHIFT
|
||||
|
||||
### S
|
||||
|
||||
- SCHEMALESS
|
||||
- SCORES
|
||||
- SELECT
|
||||
- SEMI
|
||||
- SERVER_STATUS
|
||||
- SERVER_VERSION
|
||||
- SESSION
|
||||
- SET
|
||||
- SHOW
|
||||
- SLASH
|
||||
- SINGLE_STABLE
|
||||
- SLIDING
|
||||
- SLIMIT
|
||||
- SMALLIN
|
||||
- SMA
|
||||
- SMALLINT
|
||||
- SNODE
|
||||
- SNODES
|
||||
- SOFFSET
|
||||
- STable
|
||||
- STableS
|
||||
- SPLIT
|
||||
- STABLE
|
||||
- STABLES
|
||||
- STAR
|
||||
- STATE
|
||||
- STATEMEN
|
||||
- STATE_WI
|
||||
- STATE_WINDOW
|
||||
- STATEMENT
|
||||
- STORAGE
|
||||
- STREAM
|
||||
- STREAMS
|
||||
- STRICT
|
||||
- STRING
|
||||
- SUBSCRIPTIONS
|
||||
- SYNCDB
|
||||
- SYSINFO
|
||||
|
||||
### T
|
||||
|
||||
|
@ -233,20 +289,24 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
- TBNAME
|
||||
- TIMES
|
||||
- TIMESTAMP
|
||||
- TIMEZONE
|
||||
- TINYINT
|
||||
- TO
|
||||
- TODAY
|
||||
- TOPIC
|
||||
- TOPICS
|
||||
- TRANSACTION
|
||||
- TRANSACTIONS
|
||||
- TRIGGER
|
||||
- TRIM
|
||||
- TSERIES
|
||||
- TTL
|
||||
|
||||
### U
|
||||
|
||||
- UMINUS
|
||||
- UNION
|
||||
- UNSIGNED
|
||||
- UPDATE
|
||||
- UPLUS
|
||||
- USE
|
||||
- USER
|
||||
- USERS
|
||||
|
@ -256,8 +316,11 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
|
||||
- VALUE
|
||||
- VALUES
|
||||
- VARCHAR
|
||||
- VARIABLE
|
||||
- VARIABLES
|
||||
- VERBOSE
|
||||
- VGROUP
|
||||
- VGROUPS
|
||||
- VIEW
|
||||
- VNODES
|
||||
|
@ -265,14 +328,25 @@ There are about 200 keywords reserved by TDengine, they can't be used as the nam
|
|||
### W
|
||||
|
||||
- WAL
|
||||
- WAL_FSYNC_PERIOD
|
||||
- WAL_LEVEL
|
||||
- WAL_RETENTION_PERIOD
|
||||
- WAL_RETENTION_SIZE
|
||||
- WAL_ROLL_PERIOD
|
||||
- WAL_SEGMENT_SIZE
|
||||
- WATERMARK
|
||||
- WHERE
|
||||
- WINDOW_CLOSE
|
||||
- WITH
|
||||
- WRITE
|
||||
|
||||
### \_
|
||||
|
||||
- \_C0
|
||||
- \_QSTART
|
||||
- \_QSTOP
|
||||
- \_QDURATION
|
||||
- \_WSTART
|
||||
- \_WSTOP
|
||||
- \_QEND
|
||||
- \_QSTART
|
||||
- \_ROWTS
|
||||
- \_WDURATION
|
||||
- \_WEND
|
||||
- \_WSTART
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
title: TDengine Monitoring
|
||||
---
|
||||
|
||||
After TDengine is started, a database named `log` is created automatically to help with monitoring. Information that includes CPU, memory and disk usage, bandwidth, number of requests, disk I/O speed, slow queries, is written into the `log` database at a predefined interval. Additionally, some important system operations, like logon, create user, drop database, and alerts and warnings generated in TDengine are written into the `log` database too. A system operator can view the data in `log` database from TDengine CLI or from a web console.
|
||||
After TDengine is started, it automatically writes monitoring data including CPU, memory and disk usage, bandwidth, number of requests, disk I/O speed, slow queries, into a designated database at a predefined interval through taosKeeper. Additionally, some important system operations, like logon, create user, drop database, and alerts and warnings generated in TDengine are written into the `log` database too. A system operator can view the data in `log` database from TDengine CLI or from a web console.
|
||||
|
||||
The collection of the monitoring information is enabled by default, but can be disabled by parameter `monitor` in the configuration file.
|
||||
|
||||
|
@ -10,7 +10,7 @@ The collection of the monitoring information is enabled by default, but can be d
|
|||
|
||||
TDinsight is a complete solution which uses the monitoring database `log` mentioned previously, and Grafana, to monitor a TDengine cluster.
|
||||
|
||||
From version 2.3.3.0, more monitoring data has been added in the `log` database. Please refer to [TDinsight Grafana Dashboard](https://grafana.com/grafana/dashboards/15167) to learn more details about using TDinsight to monitor TDengine.
|
||||
Please refer to [TDinsight Grafana Dashboard](../../reference/tdinsight) to learn more details about using TDinsight to monitor TDengine.
|
||||
|
||||
A script `TDinsight.sh` is provided to deploy TDinsight automatically.
|
||||
|
||||
|
@ -30,31 +30,14 @@ Prepare:
|
|||
|
||||
2. Grafana Alert Notification
|
||||
|
||||
There are two ways to setup Grafana alert notification.
|
||||
You can use below command to setup Grafana alert notification.
|
||||
|
||||
- An existing Grafana Notification Channel can be specified with parameter `-E`, the notifier uid of the channel can be obtained by `curl -u admin:admin localhost:3000/api/alert-notifications |jq`
|
||||
An existing Grafana Notification Channel can be specified with parameter `-E`, the notifier uid of the channel can be obtained by `curl -u admin:admin localhost:3000/api/alert-notifications |jq`
|
||||
|
||||
```bash
|
||||
sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -E <notifier uid>
|
||||
```
|
||||
|
||||
- The AliCloud SMS alert built in TDengine data source plugin can be enabled with parameter `-s`, the parameters of enabling this plugin are listed below:
|
||||
|
||||
- `-I`: AliCloud SMS Key ID
|
||||
- `-K`: AliCloud SMS Key Secret
|
||||
- `-S`: AliCloud SMS Signature
|
||||
- `-C`: SMS notification template
|
||||
- `-T`: Input parameters in JSON format for the SMS notification template, for example`{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}`
|
||||
- `-B`: List of mobile numbers to be notified
|
||||
|
||||
Below is an example of the full command using the AliCloud SMS alert.
|
||||
|
||||
```bash
|
||||
sudo ./TDinsight.sh -a http://localhost:6041 -u root -p taosdata -s \
|
||||
-I XXXXXXX -K XXXXXXXX -S taosdata -C SMS_1111111 -B 18900000000 \
|
||||
-T '{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}'
|
||||
```
|
||||
|
||||
Launch `TDinsight.sh` with the command above and restart Grafana, then open Dashboard `http://localhost:3000/d/tdinsight`.
|
||||
|
||||
For more use cases and restrictions please refer to [TDinsight](/reference/tdinsight/).
|
||||
|
|
|
@ -211,7 +211,7 @@
|
|||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Leader MNode",
|
||||
"title": "Master MNode",
|
||||
"transformations": [
|
||||
{
|
||||
"id": "filterByValue",
|
||||
|
@ -221,7 +221,7 @@
|
|||
"config": {
|
||||
"id": "regex",
|
||||
"options": {
|
||||
"value": "leader"
|
||||
"value": "master"
|
||||
}
|
||||
},
|
||||
"fieldName": "role"
|
||||
|
@ -300,7 +300,7 @@
|
|||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Leader MNode Create Time",
|
||||
"title": "Master MNode Create Time",
|
||||
"transformations": [
|
||||
{
|
||||
"id": "filterByValue",
|
||||
|
@ -310,7 +310,7 @@
|
|||
"config": {
|
||||
"id": "regex",
|
||||
"options": {
|
||||
"value": "leader"
|
||||
"value": "master"
|
||||
}
|
||||
},
|
||||
"fieldName": "role"
|
||||
|
|
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 8.1 KiB After Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 94 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 7.1 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 6.2 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 23 KiB |
|
@ -153,7 +153,7 @@
|
|||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Leader MNode",
|
||||
"title": "Master MNode",
|
||||
"transformations": [
|
||||
{
|
||||
"id": "filterByValue",
|
||||
|
@ -163,7 +163,7 @@
|
|||
"config": {
|
||||
"id": "regex",
|
||||
"options": {
|
||||
"value": "leader"
|
||||
"value": "master"
|
||||
}
|
||||
},
|
||||
"fieldName": "role"
|
||||
|
@ -246,7 +246,7 @@
|
|||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Leader MNode Create Time",
|
||||
"title": "Master MNode Create Time",
|
||||
"transformations": [
|
||||
{
|
||||
"id": "filterByValue",
|
||||
|
@ -256,7 +256,7 @@
|
|||
"config": {
|
||||
"id": "regex",
|
||||
"options": {
|
||||
"value": "leader"
|
||||
"value": "master"
|
||||
}
|
||||
},
|
||||
"fieldName": "role"
|
||||
|
|
|
@ -5,15 +5,23 @@ sidebar_label: TDinsight
|
|||
|
||||
TDinsight is a solution for monitoring TDengine using the builtin native monitoring database and [Grafana].
|
||||
|
||||
After TDengine starts, it will automatically create a monitoring database `log`. TDengine will automatically write many metrics in specific intervals into the `log` database. The metrics may include the server's CPU, memory, hard disk space, network bandwidth, number of requests, disk read/write speed, slow queries, other information like important system operations (user login, database creation, database deletion, etc.), and error alarms. With [Grafana] and [TDengine Data Source Plugin](https://github.com/taosdata/grafanaplugin/releases), TDinsight can visualize cluster status, node information, insertion and query requests, resource usage, vnode, dnode, and mnode status, exception alerts and many other metrics. This is very convenient for developers who want to monitor TDengine cluster status in real-time. This article will guide users to install the Grafana server, automatically install the TDengine data source plug-in, and deploy the TDinsight visualization panel using the `TDinsight.sh` installation script.
|
||||
After TDengine starts, it automatically writes many metrics in specific intervals into a designated database. The metrics may include the server's CPU, memory, hard disk space, network bandwidth, number of requests, disk read/write speed, slow queries, other information like important system operations (user login, database creation, database deletion, etc.), and error alarms. With [Grafana] and [TDengine Data Source Plugin](https://github.com/taosdata/grafanaplugin/releases), TDinsight can visualize cluster status, node information, insertion and query requests, resource usage, vnode, dnode, and mnode status, exception alerts and many other metrics. This is very convenient for developers who want to monitor TDengine cluster status in real-time. This article will guide users to install the Grafana server, automatically install the TDengine data source plug-in, and deploy the TDinsight visualization panel using the `TDinsight.sh` installation script.
|
||||
|
||||
## System Requirements
|
||||
|
||||
To deploy TDinsight, a single-node TDengine server or a multi-node TDengine cluster and a [Grafana] server are required. This dashboard requires TDengine 2.3.3.0 and above, with the `log` database enabled (`monitor = 1`).
|
||||
To deploy TDinsight, we need
|
||||
- a single-node TDengine server or a multi-node TDengine cluster and a [Grafana] server are required. This dashboard requires TDengine 3.0.1.0 and above, with the monitoring feature enabled. For detailed configuration, please refer to [TDengine monitoring configuration](../config/#monitoring-parameters).
|
||||
- taosAdapter has been instaleld and running, please refer to [taosAdapter](../taosadapter).
|
||||
- taosKeeper has been installed and running, please refer to [taosKeeper](../taoskeeper).
|
||||
|
||||
Please record
|
||||
- The endpoint of taosAdapter REST service, for example `http://tdengine.local:6041`
|
||||
- Authentication of taosAdapter, e.g. user name and password
|
||||
- The database name used by taosKeeper to store monitoring data
|
||||
|
||||
## Installing Grafana
|
||||
|
||||
We recommend using the latest [Grafana] version 7 or 8 here. You can install Grafana on any [supported operating system](https://grafana.com/docs/grafana/latest/installation/requirements/#supported-operating-systems) by following the [official Grafana documentation Instructions](https://grafana.com/docs/grafana/latest/installation/) to install [Grafana].
|
||||
We recommend using the latest [Grafana] version 8 or 9 here. You can install Grafana on any [supported operating system](https://grafana.com/docs/grafana/latest/installation/requirements/#supported-operating-systems) by following the [official Grafana documentation Instructions](https://grafana.com/docs/grafana/latest/installation/) to install [Grafana].
|
||||
|
||||
### Installing Grafana on Debian or Ubuntu
|
||||
|
||||
|
@ -71,7 +79,7 @@ chmod +x TDinsight.sh
|
|||
./TDinsight.sh
|
||||
```
|
||||
|
||||
This script will automatically download the latest [Grafana TDengine data source plugin](https://github.com/taosdata/grafanaplugin/releases/latest) and [TDinsight dashboard](https://grafana.com/grafana/dashboards/15167) with configurable parameters for command-line options to the [Grafana Provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) configuration file to automate deployment and updates, etc. With the alert setting options provided by this script, you can also get built-in support for AliCloud SMS alert notifications.
|
||||
This script will automatically download the latest [Grafana TDengine data source plugin](https://github.com/taosdata/grafanaplugin/releases/latest) and [TDinsight dashboard](https://github.com/taosdata/grafanaplugin/blob/master/dashboards/TDinsightV3.json) with configurable parameters for command-line options to the [Grafana Provisioning](https://grafana.com/docs/grafana/latest/administration/provisioning/) configuration file to automate deployment and updates, etc. With the alert setting options provided by this script, you can also get built-in support for AliCloud SMS alert notifications.
|
||||
|
||||
Assume you use TDengine and Grafana's default services on the same host. Run `. /TDinsight.sh` and open the Grafana browser window to see the TDinsight dashboard.
|
||||
|
||||
|
@ -106,18 +114,6 @@ Install and configure TDinsight dashboard in Grafana on Ubuntu 18.04/20.04 syste
|
|||
|
||||
-E, --external-notifier <string> Apply external notifier uid to TDinsight dashboard.
|
||||
|
||||
Alibaba Cloud SMS as Notifier:
|
||||
-s, --sms-enabled To enable tdengine-datasource plugin builtin Alibaba Cloud SMS webhook.
|
||||
-N, --sms-notifier-name <string> Provisioning notifier name.[default: TDinsight Builtin SMS]
|
||||
-U, --sms-notifier-uid <string> Provisioning notifier uid, use lowercase notifier name by default.
|
||||
-D, --sms-notifier-is-default Set notifier as default.
|
||||
-I, --sms-access-key-id <string> Alibaba Cloud SMS access key id
|
||||
-K, --sms-access-key-secret <string> Alibaba Cloud SMS access key secret
|
||||
-S, --sms-sign-name <string> Sign name
|
||||
-C, --sms-template-code <string> Template code
|
||||
-T, --sms-template-param <string> Template param, a escaped JSON string like '{"alarm_level":"%s","time":"%s","name":"%s","content":"%s"}'
|
||||
-B, --sms-phone-numbers <string> Comma-separated numbers list, eg "189xxxxxxxx,132xxxxxxxx"
|
||||
-L, --sms-listen-addr <string> [default: 127.0.0.1:9100]
|
||||
```
|
||||
|
||||
Most command-line options can take effect the same as environment variables.
|
||||
|
@ -136,17 +132,6 @@ Most command-line options can take effect the same as environment variables.
|
|||
| -t | --tdinsight-title | TDINSIGHT_DASHBOARD_TITLE | TDinsight dashboard title. [Default: TDinsight] | -e | -tdinsight-title
|
||||
| -e | --tdinsight-editable | TDINSIGHT_DASHBOARD_EDITABLE | If the dashboard is configured to be editable. [Default: false] | -e | --external
|
||||
| -E | --external-notifier | EXTERNAL_NOTIFIER | Apply the external notifier uid to the TDinsight dashboard. | -s
|
||||
| -s | --sms-enabled | SMS_ENABLED | Enable the tdengine-datasource plugin built into Alibaba Cloud SMS webhook. | -s
|
||||
| -N | --sms-notifier-name | SMS_NOTIFIER_NAME | The name of the provisioning notifier. [Default: `TDinsight Builtin SMS`] | -U
|
||||
| -U | --sms-notifier-uid | SMS_NOTIFIER_UID | "Notification Channel" `uid`, lowercase of the program name is used by default, other characters are replaced by "-". |-sms
|
||||
| -D | --sms-notifier-is-default | SMS_NOTIFIER_IS_DEFAULT | Set built-in SMS notification to default value. |-sms-notifier-is-default
|
||||
| -I | --sms-access-key-id | SMS_ACCESS_KEY_ID | Alibaba Cloud SMS access key id |
|
||||
| -K | --sms-access-key-secret | SMS_ACCESS_KEY_SECRET | AliCloud SMS-access-secret-key |
|
||||
| -S | --sms-sign-name | SMS_SIGN_NAME | Signature |
|
||||
| -C | --sms-template-code | SMS_TEMPLATE_CODE | Template code |
|
||||
| -T | --sms-template-param | SMS_TEMPLATE_PARAM | JSON template for template parameters |
|
||||
| -B | --sms-phone-numbers | SMS_PHONE_NUMBERS | A comma-separated list of phone numbers, e.g. `"189xxxxxxxx,132xxxxxxxx"` |
|
||||
| -L | --sms-listen-addr | SMS_LISTEN_ADDR | Built-in SMS webhook listener address, default is `127.0.0.1:9100` |
|
||||
|
||||
Suppose you start a TDengine database on host `tdengine` with HTTP API port `6041`, user `root1`, and password `pass5ord`. Execute the script.
|
||||
|
||||
|
@ -166,24 +151,10 @@ Use the `uid` value obtained above as `-E` input.
|
|||
sudo ./TDinsight.sh -a http://tdengine:6041 -u root1 -p pass5ord -E existing-notifier
|
||||
```
|
||||
|
||||
If you want to use the [Alibaba Cloud SMS](https://www.aliyun.com/product/sms) service as a notification channel, you should enable it with the `-s` flag add the following parameters.
|
||||
|
||||
- `-N`: Notification Channel name, default is `TDinsight Builtin SMS`.
|
||||
- `-U`: Channel uid, default is lowercase of `name`, any other character is replaced with -, for the default `-N`, its uid is `tdinsight-builtin-sms`.
|
||||
- `-I`: Alibaba Cloud SMS access key id.
|
||||
- `-K`: Alibaba Cloud SMS access secret key.
|
||||
- `-S`: Alibaba Cloud SMS signature.
|
||||
- `-C`: Alibaba Cloud SMS template id.
|
||||
- `-T`: Alibaba Cloud SMS template parameters, for JSON format template, example is as follows `'{"alarm_level":"%s", "time":"%s", "name":"%s", "content":"%s"}'`. There are four parameters: alarm level, time, name and alarm content.
|
||||
- `-B`: a list of phone numbers, separated by a comma `,`.
|
||||
|
||||
If you want to monitor multiple TDengine clusters, you need to set up numerous TDinsight dashboards. Setting up non-default TDinsight requires some changes: the `-n` `-i` `-t` options need to be changed to non-default names, and `-N` and `-L` should also be changed if using the built-in SMS alerting feature.
|
||||
|
||||
```bash
|
||||
sudo . /TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1'
|
||||
# If using built-in SMS notifications
|
||||
sudo . /TDengine.sh -n TDengine-Env1 -a http://another:6041 -u root -p taosdata -i tdinsight-env1 -t 'TDinsight Env1' \
|
||||
-s -N 'Env1 SMS' -I xx -K xx -S xx -C SMS_XX -T '' -B 00000000000 -L 127.0.0.01:10611
|
||||
```
|
||||
|
||||
Please note that the configuration data source, notification channel, and dashboard are not changeable on the front end. You should update the configuration again via this script or manually change the configuration file in the `/etc/grafana/provisioning` directory (this is the default directory for Grafana, use the `-P` option to change it as needed).
|
||||
|
@ -249,21 +220,23 @@ Save and test. It will report 'TDengine Data source is working' under normal cir
|
|||
|
||||
### Importing dashboards
|
||||
|
||||
Point to **+** / **Create** - **import** (or `/dashboard/import` url).
|
||||
In the page of configuring data source, click **Dashboards** tab.
|
||||
|
||||

|
||||
|
||||
Type the dashboard ID `15167` in the **Import via grafana.com** location and **Load**.
|
||||
Choose `TDengine for 3.x` and click `import`.
|
||||
|
||||

|
||||
After the importing is done, `TDinsight for 3.x` dashboard is available on the page of `search dashboards by name`.
|
||||
|
||||
Once the import is complete, the full page view of TDinsight is shown below.
|
||||

|
||||
|
||||

|
||||
In the `TDinsight for 3.x` dashboard, choose the database used by taosKeeper to store monitoring data, you can see the monitoring result.
|
||||
|
||||

|
||||
|
||||
## TDinsight dashboard details
|
||||
|
||||
The TDinsight dashboard is designed to provide the usage and status of TDengine-related resources [dnodes, mnodes, vnodes](../../taos-sql/node/) or databases.
|
||||
The TDinsight dashboard is designed to provide the usage and status of TDengine-related resources, e.g. dnodes, mnodes, vnodes and databases.
|
||||
|
||||
Details of the metrics are as follows.
|
||||
|
||||
|
@ -285,7 +258,6 @@ This section contains the current information and status of the cluster, the ale
|
|||
- **Measuring Points Used**: The number of measuring points used to enable the alert rule (no data available in the community version, healthy by default).
|
||||
- **Grants Expire Time**: the expiration time of the enterprise version of the enabled alert rule (no data available for the community version, healthy by default).
|
||||
- **Error Rate**: Aggregate error rate (average number of errors per second) for alert-enabled clusters.
|
||||
- **Variables**: `show variables` table display.
|
||||
|
||||
### DNodes Status
|
||||
|
||||
|
@ -294,7 +266,6 @@ This section contains the current information and status of the cluster, the ale
|
|||
- **DNodes Status**: simple table view of `show dnodes`.
|
||||
- **DNodes Lifetime**: the time elapsed since the dnode was created.
|
||||
- **DNodes Number**: the number of DNodes changes.
|
||||
- **Offline Reason**: if any dnode status is offline, the reason for offline is shown as a pie chart.
|
||||
|
||||
### MNode Overview
|
||||
|
||||
|
@ -309,7 +280,6 @@ This section contains the current information and status of the cluster, the ale
|
|||
|
||||
1. **Requests Rate(Inserts per Second)**: average number of inserts per second.
|
||||
2. **Requests (Selects)**: number of query requests and change rate (count of second).
|
||||
3. **Requests (HTTP)**: number of HTTP requests and request rate (count of second).
|
||||
|
||||
### Database
|
||||
|
||||
|
@ -319,9 +289,8 @@ Database usage, repeated for each value of the variable `$database` i.e. multipl
|
|||
|
||||
1. **STables**: number of super tables.
|
||||
2. **Total Tables**: number of all tables.
|
||||
3. **Sub Tables**: the number of all super table subtables.
|
||||
4. **Tables**: graph of all normal table numbers over time.
|
||||
5. **Tables Number Foreach VGroups**: The number of tables contained in each VGroups.
|
||||
3. **Tables**: number of normal tables.
|
||||
4. **Table number for each vgroup**: number of tables per vgroup.
|
||||
|
||||
### DNode Resource Usage
|
||||
|
||||
|
@ -356,12 +325,11 @@ Currently, only the number of logins per minute is reported.
|
|||
|
||||
Support monitoring taosAdapter request statistics and status details. Includes.
|
||||
|
||||
1. **http_request**: contains the total number of requests, the number of failed requests, and the number of requests being processed
|
||||
2. **top 3 request endpoint**: data of the top 3 requests by endpoint group
|
||||
3. **Memory Used**: taosAdapter memory usage
|
||||
4. **latency_quantile(ms)**: quantile of (1, 2, 5, 9, 99) stages
|
||||
5. **top 3 failed request endpoint**: data of the top 3 failed requests by endpoint grouping
|
||||
6. **CPU Used**: taosAdapter CPU usage
|
||||
1. **http_request_inflight**: number of real-time requests.
|
||||
2. **http_request_total**: number of total requests.
|
||||
3. **http_request_fail**: number of failed requets.
|
||||
4. **CPU Used**: CPU usage of taosAdapter.
|
||||
5. **Memory Used**: Memory usage of taosAdapter.
|
||||
|
||||
## Upgrade
|
||||
|
||||
|
@ -403,13 +371,6 @@ services:
|
|||
TDENGINE_API: ${TDENGINE_API}
|
||||
TDENGINE_USER: ${TDENGINE_USER}
|
||||
TDENGINE_PASS: ${TDENGINE_PASS}
|
||||
SMS_ACCESS_KEY_ID: ${SMS_ACCESS_KEY_ID}
|
||||
SMS_ACCESS_KEY_SECRET: ${SMS_ACCESS_KEY_SECRET}
|
||||
SMS_SIGN_NAME: ${SMS_SIGN_NAME}
|
||||
SMS_TEMPLATE_CODE: ${SMS_TEMPLATE_CODE}
|
||||
SMS_TEMPLATE_PARAM: '${SMS_TEMPLATE_PARAM}'
|
||||
SMS_PHONE_NUMBERS: $SMS_PHONE_NUMBERS
|
||||
SMS_LISTEN_ADDR: ${SMS_LISTEN_ADDR}
|
||||
ports:
|
||||
- 3000:3000
|
||||
volumes:
|
||||
|
|
|
@ -218,7 +218,7 @@ void Close()
|
|||
```sql
|
||||
DROP DATABASE IF EXISTS tmqdb;
|
||||
CREATE DATABASE tmqdb;
|
||||
CREATE TABLE tmqdb.stb (ts TIMESTAMP, c1 INT, c2 FLOAT, c3 VARCHAR(16) TAGS(t1 INT, t3 VARCHAR(16));
|
||||
CREATE TABLE tmqdb.stb (ts TIMESTAMP, c1 INT, c2 FLOAT, c3 VARCHAR(16)) TAGS(t1 INT, t3 VARCHAR(16));
|
||||
CREATE TABLE tmqdb.ctb0 USING tmqdb.stb TAGS(0, "subtable0");
|
||||
CREATE TABLE tmqdb.ctb1 USING tmqdb.stb TAGS(1, "subtable1");
|
||||
INSERT INTO tmqdb.ctb0 VALUES(now, 0, 0, 'a0')(now+1s, 0, 0, 'a00');
|
||||
|
|
|
@ -168,7 +168,7 @@ Query OK, 8 row(s) in set (0.001154s)
|
|||
|
||||
## 删除数据节点
|
||||
|
||||
先停止要删除的数据节点的 taosd 进程,然后启动 CLI 程序 taos,执行:
|
||||
启动 CLI 程序 taos,执行:
|
||||
|
||||
```sql
|
||||
DROP DNODE "fqdn:port";
|
||||
|
|
|
@ -104,7 +104,7 @@ SELECT location, groupid, current FROM d1001 LIMIT 2;
|
|||
|
||||
### 结果去重
|
||||
|
||||
`DISINTCT` 关键字可以对结果集中的一列或多列进行去重,去除的列既可以是标签列也可以是数据列。
|
||||
`DISTINCT` 关键字可以对结果集中的一列或多列进行去重,去除的列既可以是标签列也可以是数据列。
|
||||
|
||||
对标签列去重:
|
||||
|
||||
|
|
|
@ -6,7 +6,8 @@ description: TDengine 保留关键字的详细列表
|
|||
|
||||
## 保留关键字
|
||||
|
||||
目前 TDengine 有将近 200 个内部保留关键字,这些关键字无论大小写如果需要用作库名、表名、STable 名、数据列名及标签列名等,需要使用符号 `` ` `` 将关键字括起来使用,例如 \`ADD\`。
|
||||
目前 TDengine 有 200 多个内部保留关键字,这些关键字如果需要用作库名、表名、超级表名、子表名、数据列名及标签列名等,无论大小写,需要使用符号 `` ` `` 将关键字括起来使用,例如 \`ADD\`。
|
||||
|
||||
关键字列表如下:
|
||||
|
||||
### A
|
||||
|
@ -16,15 +17,20 @@ description: TDengine 保留关键字的详细列表
|
|||
- ACCOUNTS
|
||||
- ADD
|
||||
- AFTER
|
||||
- AGGREGATE
|
||||
- ALL
|
||||
- ALTER
|
||||
- ANALYZE
|
||||
- AND
|
||||
- APPS
|
||||
- AS
|
||||
- ASC
|
||||
- AT_ONCE
|
||||
- ATTACH
|
||||
|
||||
### B
|
||||
|
||||
- BALANCE
|
||||
- BEFORE
|
||||
- BEGIN
|
||||
- BETWEEN
|
||||
|
@ -34,19 +40,27 @@ description: TDengine 保留关键字的详细列表
|
|||
- BITNOT
|
||||
- BITOR
|
||||
- BLOCKS
|
||||
- BNODE
|
||||
- BNODES
|
||||
- BOOL
|
||||
- BUFFER
|
||||
- BUFSIZE
|
||||
- BY
|
||||
|
||||
### C
|
||||
|
||||
- CACHE
|
||||
- CACHELAST
|
||||
- CACHEMODEL
|
||||
- CACHESIZE
|
||||
- CASCADE
|
||||
- CAST
|
||||
- CHANGE
|
||||
- CLIENT_VERSION
|
||||
- CLUSTER
|
||||
- COLON
|
||||
- COLUMN
|
||||
- COMMA
|
||||
- COMMENT
|
||||
- COMP
|
||||
- COMPACT
|
||||
- CONCAT
|
||||
|
@ -54,15 +68,18 @@ description: TDengine 保留关键字的详细列表
|
|||
- CONNECTION
|
||||
- CONNECTIONS
|
||||
- CONNS
|
||||
- CONSUMER
|
||||
- CONSUMERS
|
||||
- CONTAINS
|
||||
- COPY
|
||||
- COUNT
|
||||
- CREATE
|
||||
- CTIME
|
||||
- CURRENT_USER
|
||||
|
||||
### D
|
||||
|
||||
- DATABASE
|
||||
- DATABASES
|
||||
- DAYS
|
||||
- DBS
|
||||
- DEFERRED
|
||||
- DELETE
|
||||
|
@ -71,18 +88,23 @@ description: TDengine 保留关键字的详细列表
|
|||
- DESCRIBE
|
||||
- DETACH
|
||||
- DISTINCT
|
||||
- DISTRIBUTED
|
||||
- DIVIDE
|
||||
- DNODE
|
||||
- DNODES
|
||||
- DOT
|
||||
- DOUBLE
|
||||
- DROP
|
||||
- DURATION
|
||||
|
||||
### E
|
||||
|
||||
- EACH
|
||||
- ENABLE
|
||||
- END
|
||||
- EQ
|
||||
- EVERY
|
||||
- EXISTS
|
||||
- EXPIRED
|
||||
- EXPLAIN
|
||||
|
||||
### F
|
||||
|
@ -90,18 +112,20 @@ description: TDengine 保留关键字的详细列表
|
|||
- FAIL
|
||||
- FILE
|
||||
- FILL
|
||||
- FIRST
|
||||
- FLOAT
|
||||
- FLUSH
|
||||
- FOR
|
||||
- FROM
|
||||
- FSYNC
|
||||
- FUNCTION
|
||||
- FUNCTIONS
|
||||
|
||||
### G
|
||||
|
||||
- GE
|
||||
- GLOB
|
||||
- GRANT
|
||||
- GRANTS
|
||||
- GROUP
|
||||
- GT
|
||||
|
||||
### H
|
||||
|
||||
|
@ -112,15 +136,18 @@ description: TDengine 保留关键字的详细列表
|
|||
- ID
|
||||
- IF
|
||||
- IGNORE
|
||||
- IMMEDIA
|
||||
- IMMEDIATE
|
||||
- IMPORT
|
||||
- IN
|
||||
- INITIAL
|
||||
- INDEX
|
||||
- INDEXES
|
||||
- INITIALLY
|
||||
- INNER
|
||||
- INSERT
|
||||
- INSTEAD
|
||||
- INT
|
||||
- INTEGER
|
||||
- INTERVA
|
||||
- INTERVAL
|
||||
- INTO
|
||||
- IS
|
||||
- ISNULL
|
||||
|
@ -128,6 +155,7 @@ description: TDengine 保留关键字的详细列表
|
|||
### J
|
||||
|
||||
- JOIN
|
||||
- JSON
|
||||
|
||||
### K
|
||||
|
||||
|
@ -137,46 +165,57 @@ description: TDengine 保留关键字的详细列表
|
|||
|
||||
### L
|
||||
|
||||
- LE
|
||||
- LAST
|
||||
- LAST_ROW
|
||||
- LICENCES
|
||||
- LIKE
|
||||
- LIMIT
|
||||
- LINEAR
|
||||
- LOCAL
|
||||
- LP
|
||||
- LSHIFT
|
||||
- LT
|
||||
|
||||
### M
|
||||
|
||||
- MATCH
|
||||
- MAX_DELAY
|
||||
- MAXROWS
|
||||
- MERGE
|
||||
- META
|
||||
- MINROWS
|
||||
- MINUS
|
||||
- MNODE
|
||||
- MNODES
|
||||
- MODIFY
|
||||
- MODULES
|
||||
|
||||
### N
|
||||
|
||||
- NE
|
||||
- NCHAR
|
||||
- NEXT
|
||||
- NMATCH
|
||||
- NONE
|
||||
- NOT
|
||||
- NOTNULL
|
||||
- NOW
|
||||
- NULL
|
||||
- NULLS
|
||||
|
||||
### O
|
||||
|
||||
- OF
|
||||
- OFFSET
|
||||
- ON
|
||||
- OR
|
||||
- ORDER
|
||||
- OUTPUTTYPE
|
||||
|
||||
### P
|
||||
|
||||
- PARTITION
|
||||
- PAGES
|
||||
- PAGESIZE
|
||||
- PARTITIONS
|
||||
- PASS
|
||||
- PLUS
|
||||
- PORT
|
||||
- PPS
|
||||
- PRECISION
|
||||
- PREV
|
||||
|
@ -184,47 +223,63 @@ description: TDengine 保留关键字的详细列表
|
|||
|
||||
### Q
|
||||
|
||||
- QNODE
|
||||
- QNODES
|
||||
- QTIME
|
||||
- QUERIE
|
||||
- QUERIES
|
||||
- QUERY
|
||||
- QUORUM
|
||||
|
||||
### R
|
||||
|
||||
- RAISE
|
||||
- REM
|
||||
- RANGE
|
||||
- RATIO
|
||||
- READ
|
||||
- REDISTRIBUTE
|
||||
- RENAME
|
||||
- REPLACE
|
||||
- REPLICA
|
||||
- RESET
|
||||
- RESTRIC
|
||||
- RESTRICT
|
||||
- RETENTIONS
|
||||
- REVOKE
|
||||
- ROLLUP
|
||||
- ROW
|
||||
- RP
|
||||
- RSHIFT
|
||||
|
||||
### S
|
||||
|
||||
- SCHEMALESS
|
||||
- SCORES
|
||||
- SELECT
|
||||
- SEMI
|
||||
- SERVER_STATUS
|
||||
- SERVER_VERSION
|
||||
- SESSION
|
||||
- SET
|
||||
- SHOW
|
||||
- SLASH
|
||||
- SINGLE_STABLE
|
||||
- SLIDING
|
||||
- SLIMIT
|
||||
- SMALLIN
|
||||
- SMA
|
||||
- SMALLINT
|
||||
- SNODE
|
||||
- SNODES
|
||||
- SOFFSET
|
||||
- STable
|
||||
- STableS
|
||||
- SPLIT
|
||||
- STABLE
|
||||
- STABLES
|
||||
- STAR
|
||||
- STATE
|
||||
- STATEMEN
|
||||
- STATE_WI
|
||||
- STATE_WINDOW
|
||||
- STATEMENT
|
||||
- STORAGE
|
||||
- STREAM
|
||||
- STREAMS
|
||||
- STRICT
|
||||
- STRING
|
||||
- SUBSCRIPTIONS
|
||||
- SYNCDB
|
||||
- SYSINFO
|
||||
|
||||
### T
|
||||
|
||||
|
@ -235,20 +290,24 @@ description: TDengine 保留关键字的详细列表
|
|||
- TBNAME
|
||||
- TIMES
|
||||
- TIMESTAMP
|
||||
- TIMEZONE
|
||||
- TINYINT
|
||||
- TO
|
||||
- TODAY
|
||||
- TOPIC
|
||||
- TOPICS
|
||||
- TRANSACTION
|
||||
- TRANSACTIONS
|
||||
- TRIGGER
|
||||
- TRIM
|
||||
- TSERIES
|
||||
- TTL
|
||||
|
||||
### U
|
||||
|
||||
- UMINUS
|
||||
- UNION
|
||||
- UNSIGNED
|
||||
- UPDATE
|
||||
- UPLUS
|
||||
- USE
|
||||
- USER
|
||||
- USERS
|
||||
|
@ -258,8 +317,11 @@ description: TDengine 保留关键字的详细列表
|
|||
|
||||
- VALUE
|
||||
- VALUES
|
||||
- VARCHAR
|
||||
- VARIABLE
|
||||
- VARIABLES
|
||||
- VERBOSE
|
||||
- VGROUP
|
||||
- VGROUPS
|
||||
- VIEW
|
||||
- VNODES
|
||||
|
@ -267,14 +329,25 @@ description: TDengine 保留关键字的详细列表
|
|||
### W
|
||||
|
||||
- WAL
|
||||
- WAL_FSYNC_PERIOD
|
||||
- WAL_LEVEL
|
||||
- WAL_RETENTION_PERIOD
|
||||
- WAL_RETENTION_SIZE
|
||||
- WAL_ROLL_PERIOD
|
||||
- WAL_SEGMENT_SIZE
|
||||
- WATERMARK
|
||||
- WHERE
|
||||
- WINDOW_CLOSE
|
||||
- WITH
|
||||
- WRITE
|
||||
|
||||
### \_
|
||||
|
||||
- \_C0
|
||||
- \_QSTART
|
||||
- \_QSTOP
|
||||
- \_QDURATION
|
||||
- \_WSTART
|
||||
- \_WSTOP
|
||||
- \_QEND
|
||||
- \_QSTART
|
||||
- \_ROWTS
|
||||
- \_WDURATION
|
||||
- \_WEND
|
||||
- \_WSTART
|
||||
|
|
|
@ -79,7 +79,7 @@ password = "taosdata"
|
|||
|
||||
# 需要被监控的 taosAdapter
|
||||
[taosAdapter]
|
||||
address = ["127.0.0.1:6041","192.168.1.95:6041"]
|
||||
address = ["127.0.0.1:6041"]
|
||||
|
||||
[metrics]
|
||||
# 监控指标前缀
|
||||
|
@ -92,7 +92,7 @@ cluster = "production"
|
|||
database = "log"
|
||||
|
||||
# 指定需要监控的普通表
|
||||
tables = ["normal_table"]
|
||||
tables = []
|
||||
```
|
||||
|
||||
### 获取监控指标
|
||||
|
@ -141,4 +141,4 @@ taos_cluster_info_dnodes_total{cluster_id="5981392874047724755"} 1
|
|||
# HELP taos_cluster_info_first_ep
|
||||
# TYPE taos_cluster_info_first_ep gauge
|
||||
taos_cluster_info_first_ep{cluster_id="5981392874047724755",value="hlb:6030"} 1
|
||||
```
|
||||
```
|
||||
|
|
|
@ -36,8 +36,13 @@ typedef struct STSRow2 STSRow2;
|
|||
typedef struct STSRowBuilder STSRowBuilder;
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
typedef struct SColData SColData;
|
||||
|
||||
// bitmap
|
||||
#define HAS_NONE ((uint8_t)0x1)
|
||||
#define HAS_NULL ((uint8_t)0x2)
|
||||
#define HAS_VALUE ((uint8_t)0x4)
|
||||
|
||||
// bitmap ================================
|
||||
const static uint8_t BIT2_MAP[4][4] = {{0b00000000, 0b00000001, 0b00000010, 0},
|
||||
{0b00000000, 0b00000100, 0b00001000, 2},
|
||||
{0b00000000, 0b00010000, 0b00100000, 4},
|
||||
|
@ -51,21 +56,21 @@ const static uint8_t BIT2_MAP[4][4] = {{0b00000000, 0b00000001, 0b00000010, 0},
|
|||
#define SET_BIT2(p, i, v) ((p)[(i) >> 2] = (p)[(i) >> 2] & N1(BIT2_MAP[(i)&3][3]) | BIT2_MAP[(i)&3][(v)])
|
||||
#define GET_BIT2(p, i) (((p)[(i) >> 2] >> BIT2_MAP[(i)&3][3]) & ((uint8_t)3))
|
||||
|
||||
// STSchema
|
||||
// STSchema ================================
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
|
||||
// SValue
|
||||
// SValue ================================
|
||||
int32_t tPutValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||
int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||
int tValueCmprFn(const SValue *pValue1, const SValue *pValue2, int8_t type);
|
||||
|
||||
// SColVal
|
||||
// SColVal ================================
|
||||
#define COL_VAL_NONE(CID, TYPE) ((SColVal){.cid = (CID), .type = (TYPE), .isNone = 1})
|
||||
#define COL_VAL_NULL(CID, TYPE) ((SColVal){.cid = (CID), .type = (TYPE), .isNull = 1})
|
||||
#define COL_VAL_VALUE(CID, TYPE, V) ((SColVal){.cid = (CID), .type = (TYPE), .value = (V)})
|
||||
|
||||
// STSRow2
|
||||
// STSRow2 ================================
|
||||
#define TSROW_LEN(PROW, V) tGetI32v((uint8_t *)(PROW)->data, (V) ? &(V) : NULL)
|
||||
#define TSROW_SVER(PROW, V) tGetI32v((PROW)->data + TSROW_LEN(PROW, NULL), (V) ? &(V) : NULL)
|
||||
|
||||
|
@ -77,7 +82,7 @@ int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray);
|
|||
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
|
||||
int32_t tGetTSRow(uint8_t *p, STSRow2 **ppRow);
|
||||
|
||||
// STSRowBuilder
|
||||
// STSRowBuilder ================================
|
||||
#define tsRowBuilderInit() ((STSRowBuilder){0})
|
||||
#define tsRowBuilderClear(B) \
|
||||
do { \
|
||||
|
@ -86,7 +91,7 @@ int32_t tGetTSRow(uint8_t *p, STSRow2 **ppRow);
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
// STag
|
||||
// STag ================================
|
||||
int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag);
|
||||
void tTagFree(STag *pTag);
|
||||
bool tTagIsJson(const void *pTag);
|
||||
|
@ -100,7 +105,16 @@ void tTagSetCid(const STag *pTag, int16_t iTag, int16_t cid);
|
|||
void debugPrintSTag(STag *pTag, const char *tag, int32_t ln); // TODO: remove
|
||||
int32_t parseJsontoTagData(const char *json, SArray *pTagVals, STag **ppTag, void *pMsgBuf);
|
||||
|
||||
// STRUCT =================
|
||||
// SColData ================================
|
||||
void tColDataDestroy(void *ph);
|
||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn);
|
||||
void tColDataClear(SColData *pColData);
|
||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal);
|
||||
uint8_t tColDataGetBitValue(SColData *pColData, int32_t iVal);
|
||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
||||
|
||||
// STRUCT ================================
|
||||
struct STColumn {
|
||||
col_id_t colId;
|
||||
int8_t type;
|
||||
|
@ -166,6 +180,18 @@ struct SColVal {
|
|||
SValue value;
|
||||
};
|
||||
|
||||
struct SColData {
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
int8_t smaOn;
|
||||
int32_t nVal;
|
||||
uint8_t flag;
|
||||
uint8_t *pBitMap;
|
||||
int32_t *aOffset;
|
||||
int32_t nData;
|
||||
uint8_t *pData;
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct STagVal {
|
||||
// char colName[TSDB_COL_NAME_LEN]; // only used for tmq_get_meta
|
||||
|
|
|
@ -151,6 +151,8 @@ typedef struct SVnodeModifyLogicNode {
|
|||
SArray* pDataBlocks;
|
||||
SVgDataBlocks* pVgDataBlocks;
|
||||
SNode* pAffectedRows; // SColumnNode
|
||||
SNode* pStartTs; // SColumnNode
|
||||
SNode* pEndTs; // SColumnNode
|
||||
uint64_t tableId;
|
||||
uint64_t stableId;
|
||||
int8_t tableType; // table type
|
||||
|
@ -525,6 +527,8 @@ typedef struct SDataDeleterNode {
|
|||
char tsColName[TSDB_COL_NAME_LEN];
|
||||
STimeWindow deleteTimeRange;
|
||||
SNode* pAffectedRows;
|
||||
SNode* pStartTs;
|
||||
SNode* pEndTs;
|
||||
} SDataDeleterNode;
|
||||
|
||||
typedef struct SSubplan {
|
||||
|
|
|
@ -315,6 +315,8 @@ typedef struct SDeleteStmt {
|
|||
SNode* pFromTable; // FROM clause
|
||||
SNode* pWhere; // WHERE clause
|
||||
SNode* pCountFunc; // count the number of rows affected
|
||||
SNode* pFirstFunc; // the start timestamp when the data was actually deleted
|
||||
SNode* pLastFunc; // the end timestamp when the data was actually deleted
|
||||
SNode* pTagCond; // pWhere divided into pTagCond and timeRange
|
||||
STimeWindow timeRange;
|
||||
uint8_t precision;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "tdataformat.h"
|
||||
#include "tRealloc.h"
|
||||
#include "tcoding.h"
|
||||
#include "tdatablock.h"
|
||||
#include "tlog.h"
|
||||
|
@ -680,7 +681,7 @@ int32_t tGetTSRow(uint8_t *p, STSRow2 **ppRow) {
|
|||
return n;
|
||||
}
|
||||
|
||||
// STSchema
|
||||
// STSchema ========================================
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t ncols, STSchema **ppTSchema) {
|
||||
*ppTSchema = (STSchema *)taosMemoryMalloc(sizeof(STSchema) + sizeof(STColumn) * ncols);
|
||||
if (*ppTSchema == NULL) {
|
||||
|
@ -720,9 +721,7 @@ void tTSchemaDestroy(STSchema *pTSchema) {
|
|||
if (pTSchema) taosMemoryFree(pTSchema);
|
||||
}
|
||||
|
||||
// STSRowBuilder
|
||||
|
||||
// STag
|
||||
// STag ========================================
|
||||
static int tTagValCmprFn(const void *p1, const void *p2) {
|
||||
if (((STagVal *)p1)->cid < ((STagVal *)p2)->cid) {
|
||||
return -1;
|
||||
|
@ -1172,4 +1171,495 @@ STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder) {
|
|||
return pSchema;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// SColData ========================================
|
||||
void tColDataDestroy(void *ph) {
|
||||
SColData *pColData = (SColData *)ph;
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
tFree((uint8_t *)pColData->aOffset);
|
||||
tFree(pColData->pData);
|
||||
}
|
||||
|
||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
|
||||
pColData->cid = cid;
|
||||
pColData->type = type;
|
||||
pColData->smaOn = smaOn;
|
||||
tColDataClear(pColData);
|
||||
}
|
||||
|
||||
void tColDataClear(SColData *pColData) {
|
||||
pColData->nVal = 0;
|
||||
pColData->flag = 0;
|
||||
pColData->nData = 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tColDataPutValue(SColData *pColData, SColVal *pColVal) {
|
||||
int32_t code = 0;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
code = tRealloc((uint8_t **)(&pColData->aOffset), sizeof(int32_t) * (pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
pColData->aOffset[pColData->nVal] = pColData->nData;
|
||||
|
||||
if (pColVal->value.nData) {
|
||||
code = tRealloc(&pColData->pData, pColData->nData + pColVal->value.nData);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColData->pData + pColData->nData, pColVal->value.pData, pColVal->value.nData);
|
||||
pColData->nData += pColVal->value.nData;
|
||||
}
|
||||
} else {
|
||||
ASSERT(pColData->nData == tDataTypes[pColData->type].bytes * pColData->nVal);
|
||||
code = tRealloc(&pColData->pData, pColData->nData + tDataTypes[pColData->type].bytes);
|
||||
if (code) goto _exit;
|
||||
pColData->nData += tPutValue(pColData->pData + pColData->nData, &pColVal->value, pColVal->type);
|
||||
}
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue0(SColData *pColData, SColVal *pColVal) { // 0
|
||||
int32_t code = 0;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
pColData->flag = HAS_NONE;
|
||||
} else if (pColVal->isNull) {
|
||||
pColData->flag = HAS_NULL;
|
||||
} else {
|
||||
pColData->flag = HAS_VALUE;
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue1(SColData *pColData, SColVal *pColVal) { // HAS_NONE
|
||||
int32_t code = 0;
|
||||
|
||||
if (!pColVal->isNone) {
|
||||
int32_t nBit = BIT1_SIZE(pColData->nVal + 1);
|
||||
|
||||
code = tRealloc(&pColData->pBitMap, nBit);
|
||||
if (code) goto _exit;
|
||||
|
||||
memset(pColData->pBitMap, 0, nBit);
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 1);
|
||||
|
||||
if (pColVal->isNull) {
|
||||
pColData->flag |= HAS_NULL;
|
||||
} else {
|
||||
pColData->flag |= HAS_VALUE;
|
||||
|
||||
if (pColData->nVal) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
int32_t nOffset = sizeof(int32_t) * pColData->nVal;
|
||||
code = tRealloc((uint8_t **)(&pColData->aOffset), nOffset);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->aOffset, 0, nOffset);
|
||||
} else {
|
||||
pColData->nData = tDataTypes[pColData->type].bytes * pColData->nVal;
|
||||
code = tRealloc(&pColData->pData, pColData->nData);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->pData, 0, pColData->nData);
|
||||
}
|
||||
}
|
||||
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
}
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue2(SColData *pColData, SColVal *pColVal) { // HAS_NULL
|
||||
int32_t code = 0;
|
||||
|
||||
if (!pColVal->isNull) {
|
||||
int32_t nBit = BIT1_SIZE(pColData->nVal + 1);
|
||||
code = tRealloc(&pColData->pBitMap, nBit);
|
||||
if (code) goto _exit;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
pColData->flag |= HAS_NONE;
|
||||
|
||||
memset(pColData->pBitMap, 255, nBit);
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else {
|
||||
pColData->flag |= HAS_VALUE;
|
||||
|
||||
memset(pColData->pBitMap, 0, nBit);
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 1);
|
||||
|
||||
if (pColData->nVal) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
int32_t nOffset = sizeof(int32_t) * pColData->nVal;
|
||||
code = tRealloc((uint8_t **)(&pColData->aOffset), nOffset);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->aOffset, 0, nOffset);
|
||||
} else {
|
||||
pColData->nData = tDataTypes[pColData->type].bytes * pColData->nVal;
|
||||
code = tRealloc(&pColData->pData, pColData->nData);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->pData, 0, pColData->nData);
|
||||
}
|
||||
}
|
||||
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
}
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue3(SColData *pColData, SColVal *pColVal) { // HAS_NULL|HAS_NONE
|
||||
int32_t code = 0;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else if (pColVal->isNull) {
|
||||
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 1);
|
||||
} else {
|
||||
pColData->flag |= HAS_VALUE;
|
||||
|
||||
uint8_t *pBitMap = NULL;
|
||||
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
for (int32_t iVal = 0; iVal < pColData->nVal; iVal++) {
|
||||
SET_BIT2(pBitMap, iVal, GET_BIT1(pColData->pBitMap, iVal));
|
||||
}
|
||||
SET_BIT2(pBitMap, pColData->nVal, 2);
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
pColData->pBitMap = pBitMap;
|
||||
|
||||
if (pColData->nVal) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
int32_t nOffset = sizeof(int32_t) * pColData->nVal;
|
||||
code = tRealloc((uint8_t **)(&pColData->aOffset), nOffset);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->aOffset, 0, nOffset);
|
||||
} else {
|
||||
pColData->nData = tDataTypes[pColData->type].bytes * pColData->nVal;
|
||||
code = tRealloc(&pColData->pData, pColData->nData);
|
||||
if (code) goto _exit;
|
||||
memset(pColData->pData, 0, pColData->nData);
|
||||
}
|
||||
}
|
||||
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue4(SColData *pColData, SColVal *pColVal) { // HAS_VALUE
|
||||
int32_t code = 0;
|
||||
|
||||
if (pColVal->isNone || pColVal->isNull) {
|
||||
if (pColVal->isNone) {
|
||||
pColData->flag |= HAS_NONE;
|
||||
} else {
|
||||
pColData->flag |= HAS_NULL;
|
||||
}
|
||||
|
||||
int32_t nBit = BIT1_SIZE(pColData->nVal + 1);
|
||||
code = tRealloc(&pColData->pBitMap, nBit);
|
||||
if (code) goto _exit;
|
||||
|
||||
memset(pColData->pBitMap, 255, nBit);
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 0);
|
||||
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
} else {
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue5(SColData *pColData, SColVal *pColVal) { // HAS_VALUE|HAS_NONE
|
||||
int32_t code = 0;
|
||||
|
||||
if (pColVal->isNull) {
|
||||
pColData->flag |= HAS_NULL;
|
||||
|
||||
uint8_t *pBitMap = NULL;
|
||||
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
for (int32_t iVal = 0; iVal < pColData->nVal; iVal++) {
|
||||
SET_BIT2(pBitMap, iVal, GET_BIT1(pColData->pBitMap, iVal) ? 2 : 0);
|
||||
}
|
||||
SET_BIT2(pBitMap, pColData->nVal, 1);
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
pColData->pBitMap = pBitMap;
|
||||
} else {
|
||||
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else {
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 1);
|
||||
}
|
||||
}
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue6(SColData *pColData, SColVal *pColVal) { // HAS_VALUE|HAS_NULL
|
||||
int32_t code = 0;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
pColData->flag |= HAS_NONE;
|
||||
|
||||
uint8_t *pBitMap = NULL;
|
||||
code = tRealloc(&pBitMap, BIT2_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
for (int32_t iVal = 0; iVal < pColData->nVal; iVal++) {
|
||||
SET_BIT2(pBitMap, iVal, GET_BIT1(pColData->pBitMap, iVal) ? 2 : 1);
|
||||
}
|
||||
SET_BIT2(pBitMap, pColData->nVal, 0);
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
pColData->pBitMap = pBitMap;
|
||||
} else {
|
||||
code = tRealloc(&pColData->pBitMap, BIT1_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
if (pColVal->isNull) {
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else {
|
||||
SET_BIT1(pColData->pBitMap, pColData->nVal, 1);
|
||||
}
|
||||
}
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static FORCE_INLINE int32_t tColDataAppendValue7(SColData *pColData,
|
||||
SColVal *pColVal) { // HAS_VALUE|HAS_NULL|HAS_NONE
|
||||
int32_t code = 0;
|
||||
|
||||
code = tRealloc(&pColData->pBitMap, BIT2_SIZE(pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
|
||||
if (pColVal->isNone) {
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else if (pColVal->isNull) {
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 1);
|
||||
} else {
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 2);
|
||||
}
|
||||
code = tColDataPutValue(pColData, pColVal);
|
||||
if (code) goto _exit;
|
||||
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
static int32_t (*tColDataAppendValueImpl[])(SColData *pColData, SColVal *pColVal) = {
|
||||
tColDataAppendValue0, // 0
|
||||
tColDataAppendValue1, // HAS_NONE
|
||||
tColDataAppendValue2, // HAS_NULL
|
||||
tColDataAppendValue3, // HAS_NULL|HAS_NONE
|
||||
tColDataAppendValue4, // HAS_VALUE
|
||||
tColDataAppendValue5, // HAS_VALUE|HAS_NONE
|
||||
tColDataAppendValue6, // HAS_VALUE|HAS_NULL
|
||||
tColDataAppendValue7 // HAS_VALUE|HAS_NULL|HAS_NONE
|
||||
};
|
||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal) {
|
||||
ASSERT(pColData->cid == pColVal->cid && pColData->type == pColVal->type);
|
||||
return tColDataAppendValueImpl[pColData->flag](pColData, pColVal);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void tColDataGetValue1(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_NONE
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue2(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_NULL
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue3(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_NULL|HAS_NONE
|
||||
switch (GET_BIT1(pColData->pBitMap, iVal)) {
|
||||
case 0:
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
break;
|
||||
case 1:
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue4(SColData *pColData, int32_t iVal, SColVal *pColVal) { // HAS_VALUE
|
||||
SValue value;
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
if (iVal + 1 < pColData->nVal) {
|
||||
value.nData = pColData->aOffset[iVal + 1] - pColData->aOffset[iVal];
|
||||
} else {
|
||||
value.nData = pColData->nData - pColData->aOffset[iVal];
|
||||
}
|
||||
value.pData = pColData->pData + pColData->aOffset[iVal];
|
||||
} else {
|
||||
tGetValue(pColData->pData + tDataTypes[pColData->type].bytes * iVal, &value, pColData->type);
|
||||
}
|
||||
*pColVal = COL_VAL_VALUE(pColData->cid, pColData->type, value);
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue5(SColData *pColData, int32_t iVal,
|
||||
SColVal *pColVal) { // HAS_VALUE|HAS_NONE
|
||||
switch (GET_BIT1(pColData->pBitMap, iVal)) {
|
||||
case 0:
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
break;
|
||||
case 1:
|
||||
tColDataGetValue4(pColData, iVal, pColVal);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue6(SColData *pColData, int32_t iVal,
|
||||
SColVal *pColVal) { // HAS_VALUE|HAS_NULL
|
||||
switch (GET_BIT1(pColData->pBitMap, iVal)) {
|
||||
case 0:
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
break;
|
||||
case 1:
|
||||
tColDataGetValue4(pColData, iVal, pColVal);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
static FORCE_INLINE void tColDataGetValue7(SColData *pColData, int32_t iVal,
|
||||
SColVal *pColVal) { // HAS_VALUE|HAS_NULL|HAS_NONE
|
||||
switch (GET_BIT2(pColData->pBitMap, iVal)) {
|
||||
case 0:
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
break;
|
||||
case 1:
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
break;
|
||||
case 2:
|
||||
tColDataGetValue4(pColData, iVal, pColVal);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
static void (*tColDataGetValueImpl[])(SColData *pColData, int32_t iVal, SColVal *pColVal) = {
|
||||
NULL, // 0
|
||||
tColDataGetValue1, // HAS_NONE
|
||||
tColDataGetValue2, // HAS_NULL
|
||||
tColDataGetValue3, // HAS_NULL | HAS_NONE
|
||||
tColDataGetValue4, // HAS_VALUE
|
||||
tColDataGetValue5, // HAS_VALUE | HAS_NONE
|
||||
tColDataGetValue6, // HAS_VALUE | HAS_NULL
|
||||
tColDataGetValue7 // HAS_VALUE | HAS_NULL | HAS_NONE
|
||||
};
|
||||
void tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
|
||||
ASSERT(iVal >= 0 && iVal < pColData->nVal && pColData->flag);
|
||||
tColDataGetValueImpl[pColData->flag](pColData, iVal, pColVal);
|
||||
}
|
||||
|
||||
uint8_t tColDataGetBitValue(SColData *pColData, int32_t iVal) {
|
||||
uint8_t v;
|
||||
switch (pColData->flag) {
|
||||
case HAS_NONE:
|
||||
v = 0;
|
||||
break;
|
||||
case HAS_NULL:
|
||||
v = 1;
|
||||
break;
|
||||
case (HAS_NULL | HAS_NONE):
|
||||
v = GET_BIT1(pColData->pBitMap, iVal);
|
||||
break;
|
||||
case HAS_VALUE:
|
||||
v = 2;
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NONE):
|
||||
v = GET_BIT1(pColData->pBitMap, iVal);
|
||||
if (v) v = 2;
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NULL):
|
||||
v = GET_BIT1(pColData->pBitMap, iVal) + 1;
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NULL | HAS_NONE):
|
||||
v = GET_BIT2(pColData->pBitMap, iVal);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
break;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
|
||||
int32_t code = 0;
|
||||
int32_t size;
|
||||
|
||||
ASSERT(pColDataSrc->nVal > 0);
|
||||
ASSERT(pColDataDest->cid = pColDataSrc->cid);
|
||||
ASSERT(pColDataDest->type = pColDataSrc->type);
|
||||
|
||||
pColDataDest->smaOn = pColDataSrc->smaOn;
|
||||
pColDataDest->nVal = pColDataSrc->nVal;
|
||||
pColDataDest->flag = pColDataSrc->flag;
|
||||
|
||||
// bitmap
|
||||
if (pColDataSrc->flag != HAS_NONE && pColDataSrc->flag != HAS_NULL && pColDataSrc->flag != HAS_VALUE) {
|
||||
size = BIT2_SIZE(pColDataSrc->nVal);
|
||||
code = tRealloc(&pColDataDest->pBitMap, size);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColDataDest->pBitMap, pColDataSrc->pBitMap, size);
|
||||
}
|
||||
|
||||
// offset
|
||||
if (IS_VAR_DATA_TYPE(pColDataDest->type)) {
|
||||
size = sizeof(int32_t) * pColDataSrc->nVal;
|
||||
|
||||
code = tRealloc((uint8_t **)&pColDataDest->aOffset, size);
|
||||
if (code) goto _exit;
|
||||
|
||||
memcpy(pColDataDest->aOffset, pColDataSrc->aOffset, size);
|
||||
}
|
||||
|
||||
// value
|
||||
pColDataDest->nData = pColDataSrc->nData;
|
||||
code = tRealloc(&pColDataDest->pData, pColDataSrc->nData);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColDataDest->pData, pColDataSrc->pData, pColDataDest->nData);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
|
@ -63,7 +63,7 @@ int32_t tsNumOfVnodeWriteThreads = 2;
|
|||
int32_t tsNumOfVnodeSyncThreads = 2;
|
||||
int32_t tsNumOfVnodeRsmaThreads = 2;
|
||||
int32_t tsNumOfQnodeQueryThreads = 4;
|
||||
int32_t tsNumOfQnodeFetchThreads = 4;
|
||||
int32_t tsNumOfQnodeFetchThreads = 1;
|
||||
int32_t tsNumOfSnodeSharedThreads = 2;
|
||||
int32_t tsNumOfSnodeUniqueThreads = 2;
|
||||
|
||||
|
@ -386,9 +386,9 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
tsNumOfQnodeQueryThreads = TMAX(tsNumOfQnodeQueryThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfQnodeQueryThreads", tsNumOfQnodeQueryThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
||||
tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfQnodeFetchThreads", tsNumOfQnodeFetchThreads, 1, 1024, 0) != 0) return -1;
|
||||
// tsNumOfQnodeFetchThreads = tsNumOfCores / 2;
|
||||
// tsNumOfQnodeFetchThreads = TMAX(tsNumOfQnodeFetchThreads, 4);
|
||||
// if (cfgAddInt32(pCfg, "numOfQnodeFetchThreads", tsNumOfQnodeFetchThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfSnodeSharedThreads = tsNumOfCores / 4;
|
||||
tsNumOfSnodeSharedThreads = TRANGE(tsNumOfSnodeSharedThreads, 2, 4);
|
||||
|
@ -529,6 +529,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
pItem->stype = stype;
|
||||
}
|
||||
|
||||
/*
|
||||
pItem = cfgGetItem(tsCfg, "numOfQnodeFetchThreads");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
tsNumOfQnodeFetchThreads = numOfCores / 2;
|
||||
|
@ -536,6 +537,7 @@ static int32_t taosUpdateServerCfg(SConfig *pCfg) {
|
|||
pItem->i32 = tsNumOfQnodeFetchThreads;
|
||||
pItem->stype = stype;
|
||||
}
|
||||
*/
|
||||
|
||||
pItem = cfgGetItem(tsCfg, "numOfSnodeSharedThreads");
|
||||
if (pItem != NULL && pItem->stype == CFG_STYPE_DEFAULT) {
|
||||
|
@ -693,7 +695,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsNumOfVnodeSyncThreads = cfgGetItem(pCfg, "numOfVnodeSyncThreads")->i32;
|
||||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||
tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32;
|
||||
// tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32;
|
||||
tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32;
|
||||
tsNumOfSnodeUniqueThreads = cfgGetItem(pCfg, "numOfSnodeUniqueThreads")->i32;
|
||||
tsRpcQueueMemoryAllowed = cfgGetItem(pCfg, "rpcQueueMemoryAllowed")->i64;
|
||||
|
@ -942,8 +944,10 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tsNumOfVnodeRsmaThreads = cfgGetItem(pCfg, "numOfVnodeRsmaThreads")->i32;
|
||||
} else if (strcasecmp("numOfQnodeQueryThreads", name) == 0) {
|
||||
tsNumOfQnodeQueryThreads = cfgGetItem(pCfg, "numOfQnodeQueryThreads")->i32;
|
||||
/*
|
||||
} else if (strcasecmp("numOfQnodeFetchThreads", name) == 0) {
|
||||
tsNumOfQnodeFetchThreads = cfgGetItem(pCfg, "numOfQnodeFetchThreads")->i32;
|
||||
*/
|
||||
} else if (strcasecmp("numOfSnodeSharedThreads", name) == 0) {
|
||||
tsNumOfSnodeSharedThreads = cfgGetItem(pCfg, "numOfSnodeSharedThreads")->i32;
|
||||
} else if (strcasecmp("numOfSnodeUniqueThreads", name) == 0) {
|
||||
|
|
|
@ -44,7 +44,6 @@ typedef struct SMapData SMapData;
|
|||
typedef struct SBlockIdx SBlockIdx;
|
||||
typedef struct SDataBlk SDataBlk;
|
||||
typedef struct SSttBlk SSttBlk;
|
||||
typedef struct SColData SColData;
|
||||
typedef struct SDiskDataHdr SDiskDataHdr;
|
||||
typedef struct SBlockData SBlockData;
|
||||
typedef struct SDelFile SDelFile;
|
||||
|
@ -71,10 +70,6 @@ typedef struct SLDataIter SLDataIter;
|
|||
#define TSDB_MAX_SUBBLOCKS 8
|
||||
#define TSDB_FHDR_SIZE 512
|
||||
|
||||
#define HAS_NONE ((int8_t)0x1)
|
||||
#define HAS_NULL ((int8_t)0x2)
|
||||
#define HAS_VALUE ((int8_t)0x4)
|
||||
|
||||
#define VERSION_MIN 0
|
||||
#define VERSION_MAX INT64_MAX
|
||||
|
||||
|
@ -148,15 +143,6 @@ int32_t tPutBlockIdx(uint8_t *p, void *ph);
|
|||
int32_t tGetBlockIdx(uint8_t *p, void *ph);
|
||||
int32_t tCmprBlockIdx(void const *lhs, void const *rhs);
|
||||
int32_t tCmprBlockL(void const *lhs, void const *rhs);
|
||||
// SColdata
|
||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn);
|
||||
void tColDataReset(SColData *pColData);
|
||||
void tColDataClear(void *ph);
|
||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal);
|
||||
int32_t tColDataGetValue(SColData *pColData, int32_t iRow, SColVal *pColVal);
|
||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest);
|
||||
int32_t tPutColData(uint8_t *p, SColData *pColData);
|
||||
int32_t tGetColData(uint8_t *p, SColData *pColData);
|
||||
// SBlockData
|
||||
#define tBlockDataFirstRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, 0)
|
||||
#define tBlockDataLastRow(PBLOCKDATA) tsdbRowFromBlockData(PBLOCKDATA, (PBLOCKDATA)->nRow - 1)
|
||||
|
@ -470,18 +456,6 @@ struct SSttBlk {
|
|||
SBlockInfo bInfo;
|
||||
};
|
||||
|
||||
struct SColData {
|
||||
int16_t cid;
|
||||
int8_t type;
|
||||
int8_t smaOn;
|
||||
int32_t nVal;
|
||||
uint8_t flag;
|
||||
uint8_t *pBitMap;
|
||||
int32_t *aOffset;
|
||||
int32_t nData;
|
||||
uint8_t *pData;
|
||||
};
|
||||
|
||||
// (SBlockData){.suid = 0, .uid = 0}: block data not initialized
|
||||
// (SBlockData){.suid = suid, .uid = uid}: block data for ONE child table int .data file
|
||||
// (SBlockData){.suid = suid, .uid = 0}: block data for N child tables int .last file
|
||||
|
|
|
@ -832,7 +832,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
|||
tDecoderClear(pCoder);
|
||||
|
||||
int32_t sz = taosArrayGetSize(pRes->uidList);
|
||||
if (sz == 0) {
|
||||
if (sz == 0 || pRes->affectedRows == 0) {
|
||||
taosArrayDestroy(pRes->uidList);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -903,7 +903,7 @@ static int32_t copyBlockDataToSDataBlock(STsdbReader* pReader, STableBlockScanIn
|
|||
// null value exists, check one-by-one
|
||||
if (pData->flag != HAS_VALUE) {
|
||||
for (int32_t j = pDumpInfo->rowIndex; rowIndex < remain; j += step, rowIndex++) {
|
||||
uint8_t v = GET_BIT2(pData->pBitMap, j);
|
||||
uint8_t v = tColDataGetBitValue(pData, j);
|
||||
if (v == 0 || v == 1) {
|
||||
colDataSetNull_f(pColData->nullbitmap, rowIndex);
|
||||
}
|
||||
|
@ -1362,15 +1362,10 @@ static void getBlockToLoadInfo(SDataBlockToLoadInfo* pInfo, SFileDataBlockInfo*
|
|||
pInfo->hasDupTs = (pBlock->nSubBlock == 1) ? pBlock->hasDup : true;
|
||||
pInfo->overlapWithDelInfo = overlapWithDelSkyline(pScanInfo, pBlock, pReader->order);
|
||||
|
||||
// todo here we need to each key in the last files to identify if it is really overlapped with last block
|
||||
// todo
|
||||
bool overlapWithlastBlock = false;
|
||||
#if 0
|
||||
if (taosArrayGetSize(pLastBlockReader->pSstBlk) > 0 && (pLastBlockReader->currentBlockIndex != -1)) {
|
||||
SSttBlk* pSstBlk = taosArrayGet(pLastBlockReader->pSstBlk, pLastBlockReader->currentBlockIndex);
|
||||
overlapWithlastBlock = !(pBlock->maxKey.ts < pSstBlk->minKey || pBlock->minKey.ts > pSstBlk->maxKey);
|
||||
if (hasDataInLastBlock(pLastBlockReader)) {
|
||||
int64_t tsLast = getCurrentKeyInLastBlock(pLastBlockReader);
|
||||
pInfo->overlapWithLastBlock = !(pBlock->maxKey.ts < tsLast || pBlock->minKey.ts > tsLast);
|
||||
}
|
||||
#endif
|
||||
|
||||
pInfo->moreThanCapcity = pBlock->nRow > pReader->capacity;
|
||||
pInfo->partiallyRequired = dataBlockPartiallyRequired(&pReader->window, &pReader->verRange, pBlock);
|
||||
|
@ -1896,151 +1891,6 @@ static int32_t doMergeMultiLevelRows(STsdbReader* pReader, STableBlockScanInfo*
|
|||
return code;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static int32_t doMergeThreeLevelRows(STsdbReader* pReader, STableBlockScanInfo* pBlockScanInfo, SBlockData* pBlockData) {
|
||||
SRowMerger merge = {0};
|
||||
STSRow* pTSRow = NULL;
|
||||
|
||||
SFileBlockDumpInfo* pDumpInfo = &pReader->status.fBlockDumpInfo;
|
||||
SArray* pDelList = pBlockScanInfo->delSkyline;
|
||||
|
||||
TSDBROW* pRow = getValidMemRow(&pBlockScanInfo->iter, pDelList, pReader);
|
||||
TSDBROW* piRow = getValidMemRow(&pBlockScanInfo->iiter, pDelList, pReader);
|
||||
ASSERT(pRow != NULL && piRow != NULL);
|
||||
|
||||
int64_t key = pBlockData->aTSKEY[pDumpInfo->rowIndex];
|
||||
bool freeTSRow = false;
|
||||
|
||||
uint64_t uid = pBlockScanInfo->uid;
|
||||
|
||||
TSDBKEY k = TSDBROW_KEY(pRow);
|
||||
TSDBKEY ik = TSDBROW_KEY(piRow);
|
||||
if (ASCENDING_TRAVERSE(pReader->order)) {
|
||||
// [1&2] key <= [k.ts && ik.ts]
|
||||
if (key <= k.ts && key <= ik.ts) {
|
||||
TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
|
||||
tRowMergerInit(&merge, &fRow, pReader->pSchema);
|
||||
|
||||
doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
|
||||
|
||||
if (ik.ts == key) {
|
||||
tRowMerge(&merge, piRow);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iiter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
}
|
||||
|
||||
if (k.ts == key) {
|
||||
tRowMerge(&merge, pRow);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
}
|
||||
|
||||
tRowMergerGetRow(&merge, &pTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else { // key > ik.ts || key > k.ts
|
||||
ASSERT(key != ik.ts);
|
||||
|
||||
// [3] ik.ts < key <= k.ts
|
||||
// [4] ik.ts < k.ts <= key
|
||||
if (ik.ts < k.ts) {
|
||||
doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, &pTSRow, pReader, &freeTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
if (freeTSRow) {
|
||||
taosMemoryFree(pTSRow);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// [5] k.ts < key <= ik.ts
|
||||
// [6] k.ts < ik.ts <= key
|
||||
if (k.ts < ik.ts) {
|
||||
doMergeMemTableMultiRows(pRow, uid, &pBlockScanInfo->iter, pDelList, &pTSRow, pReader, &freeTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
if (freeTSRow) {
|
||||
taosMemoryFree(pTSRow);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// [7] k.ts == ik.ts < key
|
||||
if (k.ts == ik.ts) {
|
||||
ASSERT(key > ik.ts && key > k.ts);
|
||||
|
||||
doMergeMemIMemRows(pRow, piRow, pBlockScanInfo, pReader, &pTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
taosMemoryFree(pTSRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
} else { // descending order scan
|
||||
// [1/2] k.ts >= ik.ts && k.ts >= key
|
||||
if (k.ts >= ik.ts && k.ts >= key) {
|
||||
STSchema* pSchema = doGetSchemaForTSRow(TSDBROW_SVERSION(pRow), pReader, pBlockScanInfo->uid);
|
||||
|
||||
tRowMergerInit(&merge, pRow, pSchema);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
|
||||
if (ik.ts == k.ts) {
|
||||
tRowMerge(&merge, piRow);
|
||||
doMergeRowsInBuf(&pBlockScanInfo->iiter, uid, key, pBlockScanInfo->delSkyline, &merge, pReader);
|
||||
}
|
||||
|
||||
if (k.ts == key) {
|
||||
TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
|
||||
tRowMerge(&merge, &fRow);
|
||||
doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
|
||||
}
|
||||
|
||||
tRowMergerGetRow(&merge, &pTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
} else {
|
||||
ASSERT(ik.ts != k.ts); // this case has been included in the previous if branch
|
||||
|
||||
// [3] ik.ts > k.ts >= Key
|
||||
// [4] ik.ts > key >= k.ts
|
||||
if (ik.ts > key) {
|
||||
doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, &pTSRow, pReader, &freeTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
if (freeTSRow) {
|
||||
taosMemoryFree(pTSRow);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
// [5] key > ik.ts > k.ts
|
||||
// [6] key > k.ts > ik.ts
|
||||
if (key > ik.ts) {
|
||||
TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
|
||||
tRowMergerInit(&merge, &fRow, pReader->pSchema);
|
||||
|
||||
doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
|
||||
tRowMergerGetRow(&merge, &pTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
taosMemoryFree(pTSRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
//[7] key = ik.ts > k.ts
|
||||
if (key == ik.ts) {
|
||||
doMergeMemTableMultiRows(piRow, uid, &pBlockScanInfo->iiter, pDelList, &pTSRow, pReader, &freeTSRow);
|
||||
|
||||
TSDBROW fRow = tsdbRowFromBlockData(pBlockData, pDumpInfo->rowIndex);
|
||||
tRowMerge(&merge, &fRow);
|
||||
doMergeRowsInFileBlocks(pBlockData, pBlockScanInfo, pReader, &merge);
|
||||
tRowMergerGetRow(&merge, &pTSRow);
|
||||
doAppendRowFromTSRow(pReader->pResBlock, pReader, pTSRow, uid);
|
||||
|
||||
taosMemoryFree(pTSRow);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT(0);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbReader* pReader) {
|
||||
if (pBlockScanInfo->iterInit) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -2257,9 +2107,7 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
SBlockData* pBlockData = &pReader->status.fileBlockData;
|
||||
int32_t step = ASCENDING_TRAVERSE(pReader->order) ? 1 : -1;
|
||||
|
||||
|
||||
while (1) {
|
||||
// todo check the validate of row in file block
|
||||
bool hasBlockData = false;
|
||||
{
|
||||
while (pBlockData->nRow > 0) { // find the first qualified row in data block
|
||||
|
@ -2620,7 +2468,7 @@ static int32_t doBuildDataBlock(STsdbReader* pReader) {
|
|||
code = buildComposedDataBlock(pReader);
|
||||
} else if (bufferDataInFileBlockGap(pReader->order, keyInBuf, pBlock)) {
|
||||
// data in memory that are earlier than current file block
|
||||
// todo rows in buffer should be less than the file block in asc, greater than file block in desc
|
||||
// rows in buffer should be less than the file block in asc, greater than file block in desc
|
||||
int64_t endKey = (ASCENDING_TRAVERSE(pReader->order)) ? pBlock->minKey.ts : pBlock->maxKey.ts;
|
||||
code = buildDataBlockFromBuf(pReader, pScanInfo, endKey);
|
||||
} else {
|
||||
|
@ -4081,4 +3929,4 @@ void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap) {
|
|||
}
|
||||
|
||||
tsdbTrace("vgId:%d, untake read snapshot", TD_VID(pTsdb->pVnode));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -909,248 +909,6 @@ int32_t tsdbBuildDeleteSkyline(SArray *aDelData, int32_t sidx, int32_t eidx, SAr
|
|||
return code;
|
||||
}
|
||||
|
||||
// SColData ========================================
|
||||
void tColDataInit(SColData *pColData, int16_t cid, int8_t type, int8_t smaOn) {
|
||||
pColData->cid = cid;
|
||||
pColData->type = type;
|
||||
pColData->smaOn = smaOn;
|
||||
tColDataReset(pColData);
|
||||
}
|
||||
|
||||
void tColDataReset(SColData *pColData) {
|
||||
pColData->nVal = 0;
|
||||
pColData->flag = 0;
|
||||
pColData->nData = 0;
|
||||
}
|
||||
|
||||
void tColDataClear(void *ph) {
|
||||
SColData *pColData = (SColData *)ph;
|
||||
|
||||
tFree(pColData->pBitMap);
|
||||
tFree((uint8_t *)pColData->aOffset);
|
||||
tFree(pColData->pData);
|
||||
}
|
||||
|
||||
int32_t tColDataAppendValue(SColData *pColData, SColVal *pColVal) {
|
||||
int32_t code = 0;
|
||||
int64_t size;
|
||||
SValue value = {0};
|
||||
SValue *pValue = &value;
|
||||
|
||||
ASSERT(pColVal->cid == pColData->cid);
|
||||
ASSERT(pColVal->type == pColData->type);
|
||||
|
||||
// realloc bitmap
|
||||
size = BIT2_SIZE(pColData->nVal + 1);
|
||||
code = tRealloc(&pColData->pBitMap, size);
|
||||
if (code) goto _exit;
|
||||
if ((pColData->nVal & 3) == 0) {
|
||||
pColData->pBitMap[pColData->nVal >> 2] = 0;
|
||||
}
|
||||
|
||||
// put value
|
||||
if (pColVal->isNone) {
|
||||
pColData->flag |= HAS_NONE;
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 0);
|
||||
} else if (pColVal->isNull) {
|
||||
pColData->flag |= HAS_NULL;
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 1);
|
||||
} else {
|
||||
pColData->flag |= HAS_VALUE;
|
||||
SET_BIT2(pColData->pBitMap, pColData->nVal, 2);
|
||||
pValue = &pColVal->value;
|
||||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
// offset
|
||||
code = tRealloc((uint8_t **)&pColData->aOffset, sizeof(int32_t) * (pColData->nVal + 1));
|
||||
if (code) goto _exit;
|
||||
pColData->aOffset[pColData->nVal] = pColData->nData;
|
||||
|
||||
// value
|
||||
if ((!pColVal->isNone) && (!pColVal->isNull)) {
|
||||
code = tRealloc(&pColData->pData, pColData->nData + pColVal->value.nData);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColData->pData + pColData->nData, pColVal->value.pData, pColVal->value.nData);
|
||||
pColData->nData += pColVal->value.nData;
|
||||
}
|
||||
} else {
|
||||
code = tRealloc(&pColData->pData, pColData->nData + tPutValue(NULL, pValue, pColVal->type));
|
||||
if (code) goto _exit;
|
||||
pColData->nData += tPutValue(pColData->pData + pColData->nData, pValue, pColVal->type);
|
||||
}
|
||||
|
||||
pColData->nVal++;
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tColDataCopy(SColData *pColDataSrc, SColData *pColDataDest) {
|
||||
int32_t code = 0;
|
||||
int32_t size;
|
||||
|
||||
ASSERT(pColDataSrc->nVal > 0);
|
||||
ASSERT(pColDataDest->cid = pColDataSrc->cid);
|
||||
ASSERT(pColDataDest->type = pColDataSrc->type);
|
||||
|
||||
pColDataDest->smaOn = pColDataSrc->smaOn;
|
||||
pColDataDest->nVal = pColDataSrc->nVal;
|
||||
pColDataDest->flag = pColDataSrc->flag;
|
||||
|
||||
// bitmap
|
||||
if (pColDataSrc->flag != HAS_NONE && pColDataSrc->flag != HAS_NULL && pColDataSrc->flag != HAS_VALUE) {
|
||||
size = BIT2_SIZE(pColDataSrc->nVal);
|
||||
code = tRealloc(&pColDataDest->pBitMap, size);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColDataDest->pBitMap, pColDataSrc->pBitMap, size);
|
||||
}
|
||||
|
||||
// offset
|
||||
if (IS_VAR_DATA_TYPE(pColDataDest->type)) {
|
||||
size = sizeof(int32_t) * pColDataSrc->nVal;
|
||||
|
||||
code = tRealloc((uint8_t **)&pColDataDest->aOffset, size);
|
||||
if (code) goto _exit;
|
||||
|
||||
memcpy(pColDataDest->aOffset, pColDataSrc->aOffset, size);
|
||||
}
|
||||
|
||||
// value
|
||||
pColDataDest->nData = pColDataSrc->nData;
|
||||
code = tRealloc(&pColDataDest->pData, pColDataSrc->nData);
|
||||
if (code) goto _exit;
|
||||
memcpy(pColDataDest->pData, pColDataSrc->pData, pColDataDest->nData);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tColDataGetValue(SColData *pColData, int32_t iVal, SColVal *pColVal) {
|
||||
int32_t code = 0;
|
||||
|
||||
ASSERT(iVal < pColData->nVal);
|
||||
ASSERT(pColData->flag);
|
||||
|
||||
if (pColData->flag == HAS_NONE) {
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
goto _exit;
|
||||
} else if (pColData->flag == HAS_NULL) {
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
goto _exit;
|
||||
} else if (pColData->flag != HAS_VALUE) {
|
||||
uint8_t v = GET_BIT2(pColData->pBitMap, iVal);
|
||||
if (v == 0) {
|
||||
*pColVal = COL_VAL_NONE(pColData->cid, pColData->type);
|
||||
goto _exit;
|
||||
} else if (v == 1) {
|
||||
*pColVal = COL_VAL_NULL(pColData->cid, pColData->type);
|
||||
goto _exit;
|
||||
}
|
||||
}
|
||||
|
||||
// get value
|
||||
SValue value;
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
if (iVal + 1 < pColData->nVal) {
|
||||
value.nData = pColData->aOffset[iVal + 1] - pColData->aOffset[iVal];
|
||||
} else {
|
||||
value.nData = pColData->nData - pColData->aOffset[iVal];
|
||||
}
|
||||
|
||||
value.pData = pColData->pData + pColData->aOffset[iVal];
|
||||
} else {
|
||||
tGetValue(pColData->pData + tDataTypes[pColData->type].bytes * iVal, &value, pColData->type);
|
||||
}
|
||||
*pColVal = COL_VAL_VALUE(pColData->cid, pColData->type, value);
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tPutColData(uint8_t *p, SColData *pColData) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tPutI16v(p ? p + n : p, pColData->cid);
|
||||
n += tPutI8(p ? p + n : p, pColData->type);
|
||||
n += tPutI8(p ? p + n : p, pColData->smaOn);
|
||||
n += tPutI32v(p ? p + n : p, pColData->nVal);
|
||||
n += tPutU8(p ? p + n : p, pColData->flag);
|
||||
|
||||
if (pColData->flag == HAS_NONE || pColData->flag == HAS_NULL) goto _exit;
|
||||
if (pColData->flag != HAS_VALUE) {
|
||||
// bitmap
|
||||
|
||||
int32_t size = BIT2_SIZE(pColData->nVal);
|
||||
if (p) {
|
||||
memcpy(p + n, pColData->pBitMap, size);
|
||||
}
|
||||
n += size;
|
||||
}
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
// offset
|
||||
|
||||
int32_t size = sizeof(int32_t) * pColData->nVal;
|
||||
if (p) {
|
||||
memcpy(p + n, pColData->aOffset, size);
|
||||
}
|
||||
n += size;
|
||||
}
|
||||
n += tPutI32v(p ? p + n : p, pColData->nData);
|
||||
if (p) {
|
||||
memcpy(p + n, pColData->pData, pColData->nData);
|
||||
}
|
||||
n += pColData->nData;
|
||||
|
||||
_exit:
|
||||
return n;
|
||||
}
|
||||
|
||||
int32_t tGetColData(uint8_t *p, SColData *pColData) {
|
||||
int32_t n = 0;
|
||||
|
||||
n += tGetI16v(p + n, &pColData->cid);
|
||||
n += tGetI8(p + n, &pColData->type);
|
||||
n += tGetI8(p + n, &pColData->smaOn);
|
||||
n += tGetI32v(p + n, &pColData->nVal);
|
||||
n += tGetU8(p + n, &pColData->flag);
|
||||
|
||||
if (pColData->flag == HAS_NONE || pColData->flag == HAS_NULL) goto _exit;
|
||||
if (pColData->flag != HAS_VALUE) {
|
||||
// bitmap
|
||||
|
||||
int32_t size = BIT2_SIZE(pColData->nVal);
|
||||
pColData->pBitMap = p + n;
|
||||
n += size;
|
||||
}
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
// offset
|
||||
|
||||
int32_t size = sizeof(int32_t) * pColData->nVal;
|
||||
pColData->aOffset = (int32_t *)(p + n);
|
||||
n += size;
|
||||
}
|
||||
n += tGetI32v(p + n, &pColData->nData);
|
||||
pColData->pData = p + n;
|
||||
n += pColData->nData;
|
||||
|
||||
_exit:
|
||||
return n;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tColDataCmprFn(const void *p1, const void *p2) {
|
||||
SColData *pColData1 = (SColData *)p1;
|
||||
SColData *pColData2 = (SColData *)p2;
|
||||
|
||||
if (pColData1->cid < pColData2->cid) {
|
||||
return -1;
|
||||
} else if (pColData1->cid > pColData2->cid) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// SBlockData ======================================================
|
||||
int32_t tBlockDataCreate(SBlockData *pBlockData) {
|
||||
int32_t code = 0;
|
||||
|
@ -1182,7 +940,7 @@ void tBlockDataDestroy(SBlockData *pBlockData, int8_t deepClear) {
|
|||
tFree((uint8_t *)pBlockData->aVersion);
|
||||
tFree((uint8_t *)pBlockData->aTSKEY);
|
||||
taosArrayDestroy(pBlockData->aIdx);
|
||||
taosArrayDestroyEx(pBlockData->aColData, deepClear ? tColDataClear : NULL);
|
||||
taosArrayDestroyEx(pBlockData->aColData, deepClear ? tColDataDestroy : NULL);
|
||||
pBlockData->aUid = NULL;
|
||||
pBlockData->aVersion = NULL;
|
||||
pBlockData->aTSKEY = NULL;
|
||||
|
@ -1251,7 +1009,7 @@ void tBlockDataClear(SBlockData *pBlockData) {
|
|||
pBlockData->nRow = 0;
|
||||
for (int32_t iColData = 0; iColData < taosArrayGetSize(pBlockData->aIdx); iColData++) {
|
||||
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, iColData);
|
||||
tColDataReset(pColData);
|
||||
tColDataClear(pColData);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1501,7 +1259,7 @@ void tBlockDataGetColData(SBlockData *pBlockData, int16_t cid, SColData **ppColD
|
|||
while (lidx <= ridx) {
|
||||
int32_t midx = (lidx + ridx) / 2;
|
||||
SColData *pColData = tBlockDataGetColDataByIdx(pBlockData, midx);
|
||||
int32_t c = tColDataCmprFn(pColData, &(SColData){.cid = cid});
|
||||
int32_t c = (pColData->cid == cid) ? 0 : ((pColData->cid > cid) ? 1 : -1);
|
||||
|
||||
if (c == 0) {
|
||||
*ppColData = pColData;
|
||||
|
@ -1986,47 +1744,16 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
|
|||
int32_t size = 0;
|
||||
// bitmap
|
||||
if (pColData->flag != HAS_VALUE) {
|
||||
uint8_t *pBitMap = pColData->pBitMap;
|
||||
int32_t szBitMap = BIT2_SIZE(pColData->nVal);
|
||||
|
||||
// BIT2 to BIT1
|
||||
if (pColData->flag != (HAS_VALUE | HAS_NULL | HAS_NONE)) {
|
||||
int32_t szBitMap;
|
||||
if (pColData->flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) {
|
||||
szBitMap = BIT2_SIZE(pColData->nVal);
|
||||
} else {
|
||||
szBitMap = BIT1_SIZE(pColData->nVal);
|
||||
pBitMap = taosMemoryCalloc(1, szBitMap);
|
||||
if (pBitMap == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t iVal = 0; iVal < pColData->nVal; iVal++) {
|
||||
uint8_t v = GET_BIT2(pColData->pBitMap, iVal);
|
||||
switch (pColData->flag) {
|
||||
case (HAS_NULL | HAS_NONE):
|
||||
SET_BIT1(pBitMap, iVal, v);
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NONE):
|
||||
if (v) {
|
||||
SET_BIT1(pBitMap, iVal, 1);
|
||||
} else {
|
||||
SET_BIT1(pBitMap, iVal, 0);
|
||||
}
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NULL):
|
||||
SET_BIT1(pBitMap, iVal, v - 1);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
code = tsdbCmprData(pBitMap, szBitMap, TSDB_DATA_TYPE_TINYINT, cmprAlg, ppOut, nOut + size, &pBlockCol->szBitmap,
|
||||
ppBuf);
|
||||
code = tsdbCmprData(pColData->pBitMap, szBitMap, TSDB_DATA_TYPE_TINYINT, cmprAlg, ppOut, nOut + size,
|
||||
&pBlockCol->szBitmap, ppBuf);
|
||||
if (code) goto _exit;
|
||||
|
||||
if (pColData->flag != (HAS_VALUE | HAS_NULL | HAS_NONE)) {
|
||||
taosMemoryFree(pBitMap);
|
||||
}
|
||||
}
|
||||
size += pBlockCol->szBitmap;
|
||||
|
||||
|
@ -2064,46 +1791,15 @@ int32_t tsdbDecmprColData(uint8_t *pIn, SBlockCol *pBlockCol, int8_t cmprAlg, in
|
|||
uint8_t *p = pIn;
|
||||
// bitmap
|
||||
if (pBlockCol->szBitmap) {
|
||||
if (pBlockCol->flag != (HAS_VALUE | HAS_NULL | HAS_NONE)) {
|
||||
uint8_t *pBitMap = NULL;
|
||||
code = tsdbDecmprData(p, pBlockCol->szBitmap, TSDB_DATA_TYPE_TINYINT, cmprAlg, &pBitMap,
|
||||
BIT1_SIZE(pColData->nVal), ppBuf);
|
||||
if (code) goto _exit;
|
||||
|
||||
code = tRealloc(&pColData->pBitMap, BIT2_SIZE(pColData->nVal));
|
||||
if (code) {
|
||||
tFree(pBitMap);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
// BIT1 to BIT2
|
||||
for (int32_t iVal = 0; iVal < nVal; iVal++) {
|
||||
uint8_t v = GET_BIT1(pBitMap, iVal);
|
||||
switch (pBlockCol->flag) {
|
||||
case (HAS_NULL | HAS_NONE):
|
||||
SET_BIT2(pColData->pBitMap, iVal, v);
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NONE):
|
||||
if (v) {
|
||||
SET_BIT2(pColData->pBitMap, iVal, 2);
|
||||
} else {
|
||||
SET_BIT2(pColData->pBitMap, iVal, 0);
|
||||
}
|
||||
break;
|
||||
case (HAS_VALUE | HAS_NULL):
|
||||
SET_BIT2(pColData->pBitMap, iVal, v + 1);
|
||||
break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
}
|
||||
|
||||
tFree(pBitMap);
|
||||
int32_t szBitMap;
|
||||
if (pColData->flag == (HAS_VALUE | HAS_NULL | HAS_NONE)) {
|
||||
szBitMap = BIT2_SIZE(pColData->nVal);
|
||||
} else {
|
||||
code = tsdbDecmprData(p, pBlockCol->szBitmap, TSDB_DATA_TYPE_TINYINT, cmprAlg, &pColData->pBitMap,
|
||||
BIT2_SIZE(pColData->nVal), ppBuf);
|
||||
if (code) goto _exit;
|
||||
szBitMap = BIT1_SIZE(pColData->nVal);
|
||||
}
|
||||
|
||||
code = tsdbDecmprData(p, pBlockCol->szBitmap, TSDB_DATA_TYPE_TINYINT, cmprAlg, &pColData->pBitMap, szBitMap, ppBuf);
|
||||
if (code) goto _exit;
|
||||
}
|
||||
p += pBlockCol->szBitmap;
|
||||
|
||||
|
|
|
@ -79,25 +79,33 @@ static void toDataCacheEntry(SDataDeleterHandle* pHandle, const SInputData* pInp
|
|||
pEntry->dataLen = sizeof(SDeleterRes);
|
||||
|
||||
ASSERT(1 == pEntry->numOfRows);
|
||||
ASSERT(1 == pEntry->numOfCols);
|
||||
ASSERT(3 == pEntry->numOfCols);
|
||||
|
||||
pBuf->useSize = sizeof(SDataCacheEntry);
|
||||
|
||||
SColumnInfoData* pColRes = (SColumnInfoData*)taosArrayGet(pInput->pData->pDataBlock, 0);
|
||||
SColumnInfoData* pColSKey = (SColumnInfoData*)taosArrayGet(pInput->pData->pDataBlock, 1);
|
||||
SColumnInfoData* pColEKey = (SColumnInfoData*)taosArrayGet(pInput->pData->pDataBlock, 2);
|
||||
|
||||
SDeleterRes* pRes = (SDeleterRes*)pEntry->data;
|
||||
pRes->suid = pHandle->pParam->suid;
|
||||
pRes->uidList = pHandle->pParam->pUidList;
|
||||
pRes->skey = pHandle->pDeleter->deleteTimeRange.skey;
|
||||
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
|
||||
strcpy(pRes->tableName, pHandle->pDeleter->tableFName);
|
||||
strcpy(pRes->tsColName, pHandle->pDeleter->tsColName);
|
||||
pRes->affectedRows = *(int64_t*)pColRes->pData;
|
||||
if (pRes->affectedRows) {
|
||||
pRes->skey = *(int64_t*)pColSKey->pData;
|
||||
pRes->ekey = *(int64_t*)pColEKey->pData;
|
||||
ASSERT(pRes->skey <= pRes->ekey);
|
||||
} else {
|
||||
pRes->skey = pHandle->pDeleter->deleteTimeRange.skey;
|
||||
pRes->ekey = pHandle->pDeleter->deleteTimeRange.ekey;
|
||||
}
|
||||
|
||||
pBuf->useSize += pEntry->dataLen;
|
||||
|
||||
atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen);
|
||||
atomic_add_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||
|
||||
atomic_add_fetch_64(&pHandle->cachedSize, pEntry->dataLen);
|
||||
atomic_add_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||
}
|
||||
|
||||
static bool allocBuf(SDataDeleterHandle* pDeleter, const SInputData* pInput, SDataDeleterBuf* pBuf) {
|
||||
|
@ -172,7 +180,8 @@ static void getDataLength(SDataSinkHandle* pHandle, int64_t* pLen, bool* pQueryE
|
|||
SDataCacheEntry* pEntry = (SDataCacheEntry*)pDeleter->nextOutput.pData;
|
||||
*pLen = pEntry->dataLen;
|
||||
*pQueryEnd = pDeleter->queryEnd;
|
||||
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen, ((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows);
|
||||
qDebug("got data len %" PRId64 ", row num %d in sink", *pLen,
|
||||
((SDataCacheEntry*)(pDeleter->nextOutput.pData))->numOfRows);
|
||||
}
|
||||
|
||||
static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
||||
|
@ -186,14 +195,14 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
SDataCacheEntry* pEntry = (SDataCacheEntry*)(pDeleter->nextOutput.pData);
|
||||
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
||||
memcpy(pOutput->pData, pEntry->data, pEntry->dataLen);
|
||||
pDeleter->pParam->pUidList = NULL;
|
||||
pOutput->numOfRows = pEntry->numOfRows;
|
||||
pOutput->numOfCols = pEntry->numOfCols;
|
||||
pOutput->compressed = pEntry->compressed;
|
||||
|
||||
atomic_sub_fetch_64(&pDeleter->cachedSize, pEntry->dataLen);
|
||||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||
atomic_sub_fetch_64(&pDeleter->cachedSize, pEntry->dataLen);
|
||||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pEntry->dataLen);
|
||||
|
||||
taosMemoryFreeClear(pDeleter->nextOutput.pData); // todo persistent
|
||||
pOutput->bufStatus = updateStatus(pDeleter);
|
||||
|
@ -202,7 +211,7 @@ static int32_t getDataBlock(SDataSinkHandle* pHandle, SOutputData* pOutput) {
|
|||
pOutput->useconds = pDeleter->useconds;
|
||||
pOutput->precision = pDeleter->pSchema->precision;
|
||||
taosThreadMutexUnlock(&pDeleter->mutex);
|
||||
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -211,7 +220,7 @@ static int32_t destroyDataSinker(SDataSinkHandle* pHandle) {
|
|||
atomic_sub_fetch_64(&gDataSinkStat.cachedSize, pDeleter->cachedSize);
|
||||
taosMemoryFreeClear(pDeleter->nextOutput.pData);
|
||||
taosArrayDestroy(pDeleter->pParam->pUidList);
|
||||
taosMemoryFree(pDeleter->pParam);
|
||||
taosMemoryFree(pDeleter->pParam);
|
||||
while (!taosQueueEmpty(pDeleter->pDataBlocks)) {
|
||||
SDataDeleterBuf* pBuf = NULL;
|
||||
taosReadQitem(pDeleter->pDataBlocks, (void**)&pBuf);
|
||||
|
@ -230,14 +239,15 @@ static int32_t getCacheSize(struct SDataSinkHandle* pHandle, uint64_t* size) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle, void *pParam) {
|
||||
int32_t createDataDeleter(SDataSinkManager* pManager, const SDataSinkNode* pDataSink, DataSinkHandle* pHandle,
|
||||
void* pParam) {
|
||||
SDataDeleterHandle* deleter = taosMemoryCalloc(1, sizeof(SDataDeleterHandle));
|
||||
if (NULL == deleter) {
|
||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
return TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
SDataDeleterNode* pDeleterNode = (SDataDeleterNode *)pDataSink;
|
||||
SDataDeleterNode* pDeleterNode = (SDataDeleterNode*)pDataSink;
|
||||
deleter->sink.fPut = putDataBlock;
|
||||
deleter->sink.fEndPut = endPut;
|
||||
deleter->sink.fGetLen = getDataLength;
|
||||
|
|
|
@ -4780,7 +4780,7 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
|
|||
colDataAppendNULL(pOutput, i);
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
appendSelectivityValue(pCtx, i, pCtx->offset + numOfElems - 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -4797,11 +4797,11 @@ int32_t stateDurationFunction(SqlFunctionCtx* pCtx) {
|
|||
} else {
|
||||
pInfo->durationStart = 0;
|
||||
}
|
||||
colDataAppend(pOutput, i, (char*)&output, false);
|
||||
colDataAppend(pOutput, pCtx->offset + numOfElems - 1, (char*)&output, false);
|
||||
|
||||
// handle selectivity
|
||||
if (pCtx->subsidiaries.num > 0) {
|
||||
appendSelectivityValue(pCtx, i, i);
|
||||
appendSelectivityValue(pCtx, i, pCtx->offset + numOfElems - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -399,6 +399,8 @@ static int32_t logicVnodeModifCopy(const SVnodeModifyLogicNode* pSrc, SVnodeModi
|
|||
COPY_SCALAR_FIELD(modifyType);
|
||||
COPY_SCALAR_FIELD(msgType);
|
||||
CLONE_NODE_FIELD(pAffectedRows);
|
||||
CLONE_NODE_FIELD(pStartTs);
|
||||
CLONE_NODE_FIELD(pEndTs);
|
||||
COPY_SCALAR_FIELD(tableId);
|
||||
COPY_SCALAR_FIELD(stableId);
|
||||
COPY_SCALAR_FIELD(tableType);
|
||||
|
|
|
@ -2431,6 +2431,8 @@ static const char* jkDeletePhysiPlanTsColName = "TsColName";
|
|||
static const char* jkDeletePhysiPlanDeleteTimeRangeStartKey = "DeleteTimeRangeStartKey";
|
||||
static const char* jkDeletePhysiPlanDeleteTimeRangeEndKey = "DeleteTimeRangeEndKey";
|
||||
static const char* jkDeletePhysiPlanAffectedRows = "AffectedRows";
|
||||
static const char* jkDeletePhysiPlanStartTs = "StartTs";
|
||||
static const char* jkDeletePhysiPlanEndTs = "EndTs";
|
||||
|
||||
static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) {
|
||||
const SDataDeleterNode* pNode = (const SDataDeleterNode*)pObj;
|
||||
|
@ -2457,6 +2459,12 @@ static int32_t physiDeleteNodeToJson(const void* pObj, SJson* pJson) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkDeletePhysiPlanAffectedRows, nodeToJson, pNode->pAffectedRows);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkDeletePhysiPlanStartTs, nodeToJson, pNode->pStartTs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tjsonAddObject(pJson, jkDeletePhysiPlanEndTs, nodeToJson, pNode->pEndTs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -2486,6 +2494,12 @@ static int32_t jsonToPhysiDeleteNode(const SJson* pJson, void* pObj) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkDeletePhysiPlanAffectedRows, &pNode->pAffectedRows);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkDeletePhysiPlanStartTs, &pNode->pStartTs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = jsonToNodeObject(pJson, jkDeletePhysiPlanEndTs, &pNode->pEndTs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -2665,7 +2665,9 @@ enum {
|
|||
PHY_DELETER_CODE_TABLE_FNAME,
|
||||
PHY_DELETER_CODE_TS_COL_NAME,
|
||||
PHY_DELETER_CODE_DELETE_TIME_RANGE,
|
||||
PHY_DELETER_CODE_AFFECTED_ROWS
|
||||
PHY_DELETER_CODE_AFFECTED_ROWS,
|
||||
PHY_DELETER_CODE_START_TS,
|
||||
PHY_DELETER_CODE_END_TS
|
||||
};
|
||||
|
||||
static int32_t physiDeleteNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
||||
|
@ -2690,6 +2692,12 @@ static int32_t physiDeleteNodeToMsg(const void* pObj, STlvEncoder* pEncoder) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_AFFECTED_ROWS, nodeToMsg, pNode->pAffectedRows);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_START_TS, nodeToMsg, pNode->pStartTs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = tlvEncodeObj(pEncoder, PHY_DELETER_CODE_END_TS, nodeToMsg, pNode->pEndTs);
|
||||
}
|
||||
|
||||
return code;
|
||||
}
|
||||
|
@ -2722,6 +2730,12 @@ static int32_t msgToPhysiDeleteNode(STlvDecoder* pDecoder, void* pObj) {
|
|||
case PHY_DELETER_CODE_AFFECTED_ROWS:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pAffectedRows);
|
||||
break;
|
||||
case PHY_DELETER_CODE_START_TS:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pStartTs);
|
||||
break;
|
||||
case PHY_DELETER_CODE_END_TS:
|
||||
code = msgToNodeFromTlv(pTlv, (void**)&pNode->pEndTs);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -727,6 +727,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
nodesDestroyNode(pStmt->pFromTable);
|
||||
nodesDestroyNode(pStmt->pWhere);
|
||||
nodesDestroyNode(pStmt->pCountFunc);
|
||||
nodesDestroyNode(pStmt->pFirstFunc);
|
||||
nodesDestroyNode(pStmt->pLastFunc);
|
||||
nodesDestroyNode(pStmt->pTagCond);
|
||||
break;
|
||||
}
|
||||
|
@ -791,6 +793,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
destroyVgDataBlockArray(pLogicNode->pDataBlocks);
|
||||
// pVgDataBlocks is weak reference
|
||||
nodesDestroyNode(pLogicNode->pAffectedRows);
|
||||
nodesDestroyNode(pLogicNode->pStartTs);
|
||||
nodesDestroyNode(pLogicNode->pEndTs);
|
||||
taosMemoryFreeClear(pLogicNode->pVgroupList);
|
||||
nodesDestroyList(pLogicNode->pInsertCols);
|
||||
break;
|
||||
|
@ -997,6 +1001,8 @@ void nodesDestroyNode(SNode* pNode) {
|
|||
SDataDeleterNode* pSink = (SDataDeleterNode*)pNode;
|
||||
destroyDataSinkNode((SDataSinkNode*)pSink);
|
||||
nodesDestroyNode(pSink->pAffectedRows);
|
||||
nodesDestroyNode(pSink->pStartTs);
|
||||
nodesDestroyNode(pSink->pEndTs);
|
||||
break;
|
||||
}
|
||||
case QUERY_NODE_PHYSICAL_SUBPLAN: {
|
||||
|
|
|
@ -1787,10 +1787,10 @@ SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDb
|
|||
return (SNode*)pStmt;
|
||||
}
|
||||
|
||||
SNode* createCountFuncForDelete(SAstCreateContext* pCxt) {
|
||||
SNode* createFuncForDelete(SAstCreateContext* pCxt, const char* pFuncName) {
|
||||
SFunctionNode* pFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION);
|
||||
CHECK_OUT_OF_MEM(pFunc);
|
||||
strcpy(pFunc->functionName, "count");
|
||||
strcpy(pFunc->functionName, pFuncName);
|
||||
if (TSDB_CODE_SUCCESS != nodesListMakeStrictAppend(&pFunc->pParameterList, createPrimaryKeyCol(pCxt, NULL))) {
|
||||
nodesDestroyNode((SNode*)pFunc);
|
||||
CHECK_OUT_OF_MEM(NULL);
|
||||
|
@ -1804,8 +1804,10 @@ SNode* createDeleteStmt(SAstCreateContext* pCxt, SNode* pTable, SNode* pWhere) {
|
|||
CHECK_OUT_OF_MEM(pStmt);
|
||||
pStmt->pFromTable = pTable;
|
||||
pStmt->pWhere = pWhere;
|
||||
pStmt->pCountFunc = createCountFuncForDelete(pCxt);
|
||||
if (NULL == pStmt->pCountFunc) {
|
||||
pStmt->pCountFunc = createFuncForDelete(pCxt, "count");
|
||||
pStmt->pFirstFunc = createFuncForDelete(pCxt, "first");
|
||||
pStmt->pLastFunc = createFuncForDelete(pCxt, "last");
|
||||
if (NULL == pStmt->pCountFunc || NULL == pStmt->pFirstFunc || NULL == pStmt->pLastFunc) {
|
||||
nodesDestroyNode((SNode*)pStmt);
|
||||
CHECK_OUT_OF_MEM(NULL);
|
||||
}
|
||||
|
|
|
@ -3347,10 +3347,16 @@ static int32_t translateDelete(STranslateContext* pCxt, SDeleteStmt* pDelete) {
|
|||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateDeleteWhere(pCxt, pDelete);
|
||||
}
|
||||
pCxt->currClause = SQL_CLAUSE_SELECT;
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pCxt->currClause = SQL_CLAUSE_SELECT;
|
||||
code = translateExpr(pCxt, &pDelete->pCountFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateExpr(pCxt, &pDelete->pFirstFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = translateExpr(pCxt, &pDelete->pLastFunc);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
|
|
|
@ -1372,9 +1372,21 @@ static int32_t createDeleteAggLogicNode(SLogicPlanContext* pCxt, SDeleteStmt* pD
|
|||
}
|
||||
|
||||
int32_t code = nodesListMakeStrictAppend(&pAgg->pAggFuncs, nodesCloneNode(pDelete->pCountFunc));
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pAgg->pAggFuncs, nodesCloneNode(pDelete->pFirstFunc));
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = nodesListStrictAppend(pAgg->pAggFuncs, nodesCloneNode(pDelete->pLastFunc));
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteExpr(pAgg->pAggFuncs, &pDelete->pCountFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteExpr(pAgg->pAggFuncs, &pDelete->pFirstFunc);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = rewriteExpr(pAgg->pAggFuncs, &pDelete->pLastFunc);
|
||||
}
|
||||
// set the output
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = createColumnByRewriteExprs(pAgg->pAggFuncs, &pAgg->node.pTargets);
|
||||
|
@ -1405,7 +1417,9 @@ static int32_t createVnodeModifLogicNodeByDelete(SLogicPlanContext* pCxt, SDelet
|
|||
strcpy(pModify->tsColName, pRealTable->pMeta->schema->name);
|
||||
pModify->deleteTimeRange = pDelete->timeRange;
|
||||
pModify->pAffectedRows = nodesCloneNode(pDelete->pCountFunc);
|
||||
if (NULL == pModify->pAffectedRows) {
|
||||
pModify->pStartTs = nodesCloneNode(pDelete->pFirstFunc);
|
||||
pModify->pEndTs = nodesCloneNode(pDelete->pLastFunc);
|
||||
if (NULL == pModify->pAffectedRows || NULL == pModify->pStartTs || NULL == pModify->pEndTs) {
|
||||
nodesDestroyNode((SNode*)pModify);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
|
|
@ -1323,9 +1323,9 @@ static int32_t createSortPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren
|
|||
|
||||
static int32_t createPartitionPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren,
|
||||
SPartitionLogicNode* pPartLogicNode, SPhysiNode** pPhyNode) {
|
||||
SPartitionPhysiNode* pPart =
|
||||
(SPartitionPhysiNode*)makePhysiNode(pCxt, (SLogicNode*)pPartLogicNode,
|
||||
pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION : QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
||||
SPartitionPhysiNode* pPart = (SPartitionPhysiNode*)makePhysiNode(
|
||||
pCxt, (SLogicNode*)pPartLogicNode,
|
||||
pCxt->pPlanCxt->streamQuery ? QUERY_NODE_PHYSICAL_PLAN_STREAM_PARTITION : QUERY_NODE_PHYSICAL_PLAN_PARTITION);
|
||||
if (NULL == pPart) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
@ -1670,6 +1670,12 @@ static int32_t createDataDeleter(SPhysiPlanContext* pCxt, SVnodeModifyLogicNode*
|
|||
|
||||
int32_t code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pAffectedRows,
|
||||
&pDeleter->pAffectedRows);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pStartTs, &pDeleter->pStartTs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
code = setNodeSlotId(pCxt, pRoot->pOutputDataBlockDesc->dataBlockId, -1, pModify->pEndTs, &pDeleter->pEndTs);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
pDeleter->sink.pInputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pRoot->pOutputDataBlockDesc);
|
||||
if (NULL == pDeleter->sink.pInputDataBlockDesc) {
|
||||
|
|
|
@ -283,8 +283,9 @@ typedef struct SSchJob {
|
|||
} SSchJob;
|
||||
|
||||
typedef struct SSchTaskCtx {
|
||||
int64_t jobRid;
|
||||
int64_t jobRid;
|
||||
SSchTask *pTask;
|
||||
bool asyncLaunch;
|
||||
} SSchTaskCtx;
|
||||
|
||||
extern SSchedulerMgmt schMgmt;
|
||||
|
|
|
@ -396,7 +396,7 @@ int32_t schHandleCallback(void *param, SDataBuf *pMsg, int32_t rspCode) {
|
|||
tstrerror(rspCode));
|
||||
|
||||
SCH_ERR_JRET(schProcessOnCbBegin(&pJob, &pTask, pParam->queryId, pParam->refId, pParam->taskId));
|
||||
|
||||
|
||||
code = schHandleResponseMsg(pJob, pTask, pParam->execId, pMsg, rspCode);
|
||||
pMsg->pData = NULL;
|
||||
|
||||
|
|
|
@ -138,12 +138,6 @@ int32_t schUpdateTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int3
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
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);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
SSchNodeInfo *nodeInfo = taosHashGet(pTask->execNodes, &execId, sizeof(execId));
|
||||
if (NULL == nodeInfo) { // ignore it
|
||||
SCH_TASK_DLOG("handle not updated since execId %d already not exist, current execId %d, waitRetry %d", execId,
|
||||
|
@ -162,11 +156,16 @@ int32_t schUpdateTaskHandle(SSchJob *pJob, SSchTask *pTask, bool dropExecNode, v
|
|||
if (dropExecNode) {
|
||||
SCH_RET(schDropTaskExecNode(pJob, pTask, handle, execId));
|
||||
}
|
||||
|
||||
SCH_SET_TASK_HANDLE(pTask, handle);
|
||||
|
||||
|
||||
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_ERR_RET(TSDB_CODE_SCH_IGNORE_ERROR);
|
||||
}
|
||||
|
||||
SCH_SET_TASK_HANDLE(pTask, handle);
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -352,7 +351,7 @@ int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32
|
|||
pTask->waitRetry = true;
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
taosHashClear(pTask->execNodes);
|
||||
SCH_ERR_JRET(schRemoveTaskFromExecList(pJob, pTask));
|
||||
schRemoveTaskFromExecList(pJob, pTask);
|
||||
schDeregisterTaskHb(pJob, pTask);
|
||||
atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||
taosMemoryFreeClear(pTask->msg);
|
||||
|
@ -599,7 +598,7 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo
|
|||
int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||
atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||
|
||||
SCH_ERR_RET(schRemoveTaskFromExecList(pJob, pTask));
|
||||
schRemoveTaskFromExecList(pJob, pTask);
|
||||
SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_INIT);
|
||||
|
||||
if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) {
|
||||
|
@ -746,8 +745,7 @@ _return:
|
|||
int32_t schRemoveTaskFromExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||
int32_t code = taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId));
|
||||
if (code) {
|
||||
SCH_TASK_ELOG("task failed to rm from execTask list, code:%x", code);
|
||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
||||
SCH_TASK_WLOG("task already not in execTask list, code:%x", code);
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -836,6 +834,11 @@ int32_t schLaunchTaskImpl(void *param) {
|
|||
}
|
||||
|
||||
SSchTask *pTask = pCtx->pTask;
|
||||
|
||||
if (pCtx->asyncLaunch) {
|
||||
SCH_LOCK_TASK(pTask);
|
||||
}
|
||||
|
||||
int8_t status = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -882,8 +885,6 @@ int32_t schLaunchTaskImpl(void *param) {
|
|||
|
||||
_return:
|
||||
|
||||
taosMemoryFree(param);
|
||||
|
||||
if (pJob->taskNum >= SCH_MIN_AYSNC_EXEC_NUM) {
|
||||
if (code) {
|
||||
code = schProcessOnTaskFailure(pJob, pTask, code);
|
||||
|
@ -893,8 +894,14 @@ _return:
|
|||
}
|
||||
}
|
||||
|
||||
if (pCtx->asyncLaunch) {
|
||||
SCH_UNLOCK_TASK(pTask);
|
||||
}
|
||||
|
||||
schReleaseJob(pJob->refId);
|
||||
|
||||
taosMemoryFree(param);
|
||||
|
||||
SCH_RET(code);
|
||||
}
|
||||
|
||||
|
@ -908,6 +915,7 @@ int32_t schAsyncLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) {
|
|||
param->pTask = pTask;
|
||||
|
||||
if (pJob->taskNum >= SCH_MIN_AYSNC_EXEC_NUM) {
|
||||
param->asyncLaunch = true;
|
||||
taosAsyncExec(schLaunchTaskImpl, param, NULL);
|
||||
} else {
|
||||
SCH_ERR_RET(schLaunchTaskImpl(param));
|
||||
|
|
|
@ -489,7 +489,7 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild, TXN
|
|||
}
|
||||
|
||||
// Copy the root page content to the child page
|
||||
tdbPageCopy(pRoot, pChild);
|
||||
tdbPageCopy(pRoot, pChild, 0);
|
||||
|
||||
// Reinitialize the root page
|
||||
zArg.flags = TDB_BTREE_ROOT;
|
||||
|
@ -742,7 +742,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
for (int i = 0; i < nOlds; i++) {
|
||||
tdbPageCreate(pOlds[0]->pageSize, &pOldsCopy[i], tdbDefaultMalloc, NULL);
|
||||
tdbBtreeInitPage(pOldsCopy[i], &iarg, 0);
|
||||
tdbPageCopy(pOlds[i], pOldsCopy[i]);
|
||||
tdbPageCopy(pOlds[i], pOldsCopy[i], 0);
|
||||
}
|
||||
iNew = 0;
|
||||
nNewCells = 0;
|
||||
|
@ -840,7 +840,7 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx, TXN *pTx
|
|||
i8 flags = TDB_BTREE_ROOT | TDB_BTREE_PAGE_IS_LEAF(pNews[0]);
|
||||
// copy content to the parent page
|
||||
tdbBtreeInitPage(pParent, &(SBtreeInitPageArg){.flags = flags, .pBt = pBt}, 0);
|
||||
tdbPageCopy(pNews[0], pParent);
|
||||
tdbPageCopy(pNews[0], pParent, 1);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
|
|
|
@ -229,7 +229,7 @@ int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void tdbPageCopy(SPage *pFromPage, SPage *pToPage) {
|
||||
void tdbPageCopy(SPage *pFromPage, SPage *pToPage, int deepCopyOvfl) {
|
||||
int delta, nFree;
|
||||
|
||||
pToPage->pFreeStart = pToPage->pPageHdr + (pFromPage->pFreeStart - pFromPage->pPageHdr);
|
||||
|
@ -250,8 +250,15 @@ void tdbPageCopy(SPage *pFromPage, SPage *pToPage) {
|
|||
|
||||
// Copy the overflow cells
|
||||
for (int iOvfl = 0; iOvfl < pFromPage->nOverflow; iOvfl++) {
|
||||
SCell *pNewCell = pFromPage->apOvfl[iOvfl];
|
||||
if (deepCopyOvfl) {
|
||||
int szCell = (*pFromPage->xCellSize)(pFromPage, pFromPage->apOvfl[iOvfl], 0, NULL, NULL);
|
||||
pNewCell = (SCell *)tdbOsMalloc(szCell);
|
||||
memcpy(pNewCell, pFromPage->apOvfl[iOvfl], szCell);
|
||||
}
|
||||
|
||||
pToPage->apOvfl[iOvfl] = pNewCell;
|
||||
pToPage->aiOvfl[iOvfl] = pFromPage->aiOvfl[iOvfl];
|
||||
pToPage->apOvfl[iOvfl] = pFromPage->apOvfl[iOvfl];
|
||||
}
|
||||
pToPage->nOverflow = pFromPage->nOverflow;
|
||||
}
|
||||
|
|
|
@ -333,7 +333,7 @@ void tdbPageInit(SPage *pPage, u8 szAmHdr, int (*xCellSize)(const SPage *, SCell
|
|||
int tdbPageInsertCell(SPage *pPage, int idx, SCell *pCell, int szCell, u8 asOvfl);
|
||||
int tdbPageDropCell(SPage *pPage, int idx, TXN *pTxn, SBTree *pBt);
|
||||
int tdbPageUpdateCell(SPage *pPage, int idx, SCell *pCell, int szCell, TXN *pTxn, SBTree *pBt);
|
||||
void tdbPageCopy(SPage *pFromPage, SPage *pToPage);
|
||||
void tdbPageCopy(SPage *pFromPage, SPage *pToPage, int copyOvflCells);
|
||||
int tdbPageCapacity(int pageSize, int amHdrSize);
|
||||
|
||||
static inline SCell *tdbPageGetCell(SPage *pPage, int idx) {
|
||||
|
|
|
@ -400,6 +400,9 @@ int tsem_init(tsem_t *psem, int flags, unsigned int count) {
|
|||
}
|
||||
|
||||
int tsem_destroy(tsem_t *psem) {
|
||||
if (psem == NULL || *psem == NULL) return -1;
|
||||
dispatch_release(*psem);
|
||||
*psem = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -421,13 +424,7 @@ int tsem_timewait(tsem_t *psem, int64_t nanosecs) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool taosCheckPthreadValid(TdThread thread) {
|
||||
int32_t ret = taosThreadKill(thread, 0);
|
||||
if (ret == ESRCH) return false;
|
||||
if (ret == EINVAL) return false;
|
||||
// alive
|
||||
return true;
|
||||
}
|
||||
bool taosCheckPthreadValid(TdThread thread) { return thread != 0; }
|
||||
|
||||
int64_t taosGetSelfPthreadId() {
|
||||
TdThread thread = taosThreadSelf();
|
||||
|
|
|
@ -344,30 +344,27 @@ int32_t taosGetCpuInfo(char *cpuModel, int32_t maxLen, float *numOfCores) {
|
|||
*numOfCores = si.dwNumberOfProcessors;
|
||||
return 0;
|
||||
#elif defined(_TD_DARWIN_64)
|
||||
char *line = NULL;
|
||||
size_t size = 0;
|
||||
char buf[16];
|
||||
int32_t done = 0;
|
||||
int32_t code = -1;
|
||||
|
||||
TdFilePtr pFile = taosOpenFile("/proc/cpuinfo", TD_FILE_READ | TD_FILE_STREAM);
|
||||
if (pFile == NULL) return false;
|
||||
|
||||
while (done != 3 && (size = taosGetLineFile(pFile, &line)) != -1) {
|
||||
line[size - 1] = '\0';
|
||||
if (((done & 1) == 0) && strncmp(line, "model name", 10) == 0) {
|
||||
const char *v = strchr(line, ':') + 2;
|
||||
tstrncpy(cpuModel, v, maxLen);
|
||||
code = 0;
|
||||
done |= 1;
|
||||
} else if (((done & 2) == 0) && strncmp(line, "cpu cores", 9) == 0) {
|
||||
const char *v = strchr(line, ':') + 2;
|
||||
*numOfCores = atof(v);
|
||||
done |= 2;
|
||||
}
|
||||
TdCmdPtr pCmd = taosOpenCmd("sysctl -n machdep.cpu.brand_string");
|
||||
if (pCmd == NULL) return code;
|
||||
if (taosGetsCmd(pCmd, maxLen, cpuModel) > 0) {
|
||||
code = 0;
|
||||
done |= 1;
|
||||
}
|
||||
taosCloseCmd(&pCmd);
|
||||
|
||||
if (line != NULL) taosMemoryFree(line);
|
||||
taosCloseFile(&pFile);
|
||||
pCmd = taosOpenCmd("sysctl -n machdep.cpu.core_count");
|
||||
if (pCmd == NULL) return code;
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if (taosGetsCmd(pCmd, maxLen, cpuModel) > 0) {
|
||||
code = 0;
|
||||
done |= 2;
|
||||
*numOfCores = atof(buf);
|
||||
}
|
||||
taosCloseCmd(&pCmd);
|
||||
|
||||
return code;
|
||||
#else
|
||||
|
|
|
@ -231,7 +231,7 @@ class TDTestCase:
|
|||
if platform.system().lower() == 'windows':
|
||||
os.system('ps -a | grep taos | awk \'{print $2}\' | xargs kill -9')
|
||||
else:
|
||||
os.system('pkill taos')
|
||||
os.system('pkill -9 taos')
|
||||
|
||||
def stop(self):
|
||||
tdSql.close()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from datetime import datetime
|
||||
from platform import platform
|
||||
import time
|
||||
|
||||
from typing import List, Any, Tuple
|
||||
|
@ -83,6 +84,8 @@ class TDTestCase:
|
|||
|
||||
def del_old_datadir(self, filename):
|
||||
cmd = f"sed -i '/^dataDir/d' {filename}"
|
||||
if platform.system().lower() == 'darwin':
|
||||
cmd = f"sed -i '' '/^dataDir/d' {filename}"
|
||||
if os.system(cmd) != 0:
|
||||
tdLog.exit(cmd)
|
||||
|
||||
|
|