add pre check
This commit is contained in:
commit
66a3269c6b
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.1.4")
|
||||
SET(TD_VER_NUMBER "3.0.1.5")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 4d02980
|
||||
GIT_TAG cc973e0
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -116,7 +116,7 @@ Note: TDengine only supports Windows Server 2016/2019 and Windows 10/11 on the W
|
|||
|
||||
1. Download the macOS installation package.
|
||||
<PkgListV3 type={7}/>
|
||||
2. Run the downloaded package to install TDengine.
|
||||
2. Run the downloaded package to install TDengine. If the installation is blocked, you can right-click or ctrl-click on the installation package and select `Open`.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -179,12 +179,20 @@ The following `systemctl` commands can help you manage TDengine service:
|
|||
|
||||
:::
|
||||
|
||||
## Command Line Interface (CLI)
|
||||
|
||||
You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in terminal.
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows" value="windows">
|
||||
|
||||
After the installation is complete, run `C:\TDengine\taosd.exe` to start TDengine Server.
|
||||
|
||||
## Command Line Interface (CLI)
|
||||
|
||||
You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can run `taos.exe` in the `C:\TDengine` directory of the Windows terminal to start the TDengine command line.
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="macOS" value="macos">
|
||||
|
@ -206,12 +214,12 @@ The following `launchctl` commands can help you manage TDengine service:
|
|||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Command Line Interface (CLI)
|
||||
|
||||
You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in the Linux/macOS terminal where TDengine is installed, or you can run `taos.exe` in the `C:\TDengine` directory of the Windows terminal where TDengine is installed to start the TDengine command line.
|
||||
You can use the TDengine CLI to monitor your TDengine deployment and execute ad hoc queries. To open the CLI, you can execute `taos` in terminal.
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
taos
|
||||
|
|
|
@ -15,10 +15,12 @@ import ConnCSNative from "./_connect_cs.mdx";
|
|||
import ConnC from "./_connect_c.mdx";
|
||||
import ConnR from "./_connect_r.mdx";
|
||||
import ConnPHP from "./_connect_php.mdx";
|
||||
import InstallOnWindows from "../../14-reference/03-connector/_linux_install.mdx";
|
||||
import InstallOnLinux from "../../14-reference/03-connector/_windows_install.mdx";
|
||||
import InstallOnLinux from "../../14-reference/03-connector/_linux_install.mdx";
|
||||
import InstallOnWindows from "../../14-reference/03-connector/_windows_install.mdx";
|
||||
import InstallOnMacOS from "../../14-reference/03-connector/_macos_install.mdx";
|
||||
import VerifyLinux from "../../14-reference/03-connector/_verify_linux.mdx";
|
||||
import VerifyWindows from "../../14-reference/03-connector/_verify_windows.mdx";
|
||||
import VerifyMacOS from "../../14-reference/03-connector/_verify_macos.mdx";
|
||||
|
||||
Any application running on any platform can access TDengine through the REST API provided by TDengine. For information, see [REST API](/reference/rest-api/). Applications can also use the connectors for various programming languages, including C/C++, Java, Python, Go, Node.js, C#, and Rust, to access TDengine. These connectors support connecting to TDengine clusters using both native interfaces (taosc). Some connectors also support connecting over a REST interface. Community developers have also contributed several unofficial connectors, such as the ADO.NET connector, the Lua connector, and the PHP connector.
|
||||
|
||||
|
@ -44,10 +46,13 @@ If you are choosing to use the native connection and the the application is not
|
|||
|
||||
<Tabs defaultValue="linux" groupId="os">
|
||||
<TabItem value="linux" label="Linux">
|
||||
<InstallOnWindows />
|
||||
<InstallOnLinux />
|
||||
</TabItem>
|
||||
<TabItem value="windows" label="Windows">
|
||||
<InstallOnLinux />
|
||||
<InstallOnWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<InstallOnMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -62,6 +67,9 @@ After the above installation and configuration are done and making sure TDengine
|
|||
<TabItem value="windows" label="Windows">
|
||||
<VerifyWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<VerifyMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Install Connectors
|
||||
|
|
|
@ -863,6 +863,7 @@ INTERP(expr)
|
|||
|
||||
- `INTERP` is used to get the value that matches the specified time slice from a column. If no such value exists an interpolation value will be returned based on `FILL` parameter.
|
||||
- The input data of `INTERP` is the value of the specified column and a `where` clause can be used to filter the original data. If no `where` condition is specified then all original data is the input.
|
||||
- `INTERP` must be used along with `RANGE`, `EVERY`, `FILL` keywords.
|
||||
- The output time range of `INTERP` is specified by `RANGE(timestamp1,timestamp2)` parameter, with timestamp1<=timestamp2. timestamp1 is the starting point of the output time range and must be specified. timestamp2 is the ending point of the output time range and must be specified.
|
||||
- The number of rows in the result set of `INTERP` is determined by the parameter `EVERY`. Starting from timestamp1, one interpolation is performed for every time interval specified `EVERY` parameter. The parameter `EVERY` must be an integer, with no quotes, with a time unit of: b(nanosecond), u(microsecond), a(millisecond)), s(second), m(minute), h(hour), d(day), or w(week). For example, `EVERY(500a)` will interpolate every 500 milliseconds.
|
||||
- Interpolation is performed based on `FILL` parameter.
|
||||
|
@ -945,7 +946,7 @@ MIN(expr)
|
|||
MODE(expr)
|
||||
```
|
||||
|
||||
**Description**:The value which has the highest frequency of occurrence. NULL is returned if there are multiple values which have highest frequency of occurrence.
|
||||
**Description**:The value which has the highest frequency of occurrence. One random value is returned if there are multiple values which have highest frequency of occurrence.
|
||||
|
||||
**Return value type**: Same as the input data
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ title: TDengine Go Connector
|
|||
import Tabs from '@theme/Tabs';
|
||||
import TabItem from '@theme/TabItem';
|
||||
|
||||
import Preparition from "./_preparation.mdx"
|
||||
import GoInsert from "../../07-develop/03-insert-data/_go_sql.mdx"
|
||||
import GoInfluxLine from "../../07-develop/03-insert-data/_go_line.mdx"
|
||||
import GoOpenTSDBTelnet from "../../07-develop/03-insert-data/_go_opts_telnet.mdx"
|
||||
|
@ -176,6 +175,37 @@ func main() {
|
|||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="WebSocket" label="WebSocket connection">
|
||||
|
||||
_taosRestful_ implements Go's `database/sql/driver` interface via `http client`. You can use the [`database/sql`](https://golang.org/pkg/database/sql/) interface by simply introducing the driver (driver-go minimum version 3.0.2).
|
||||
|
||||
Use `taosWS` as `driverName` and use a correct [DSN](#DSN) as `dataSourceName` with the following parameters supported by the DSN.
|
||||
|
||||
* `writeTimeout` The timeout to send data via WebSocket.
|
||||
* `readTimeout` The timeout to receive response data via WebSocket.
|
||||
|
||||
For example:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/taosdata/driver-go/v3/taosWS"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var taosUri = "root:taosdata@ws(localhost:6041)/"
|
||||
taos, err := sql.Open("taosWS", taosUri)
|
||||
if err != nil {
|
||||
fmt.Println("failed to connect TDengine, err:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## Usage examples
|
||||
|
@ -331,7 +361,7 @@ Creates consumer group.
|
|||
|
||||
* `func (c *Consumer) Subscribe(topics []string) error`
|
||||
|
||||
Subscribes to a topic.
|
||||
Subscribes to topics.
|
||||
|
||||
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||
|
||||
|
@ -409,6 +439,30 @@ Close consumer.
|
|||
|
||||
Closes the parameter binding.
|
||||
|
||||
### Subscribe via WebSocket
|
||||
|
||||
* `func NewConsumer(config *Config) (*Consumer, error)`
|
||||
|
||||
Creates consumer group.
|
||||
|
||||
* `func (c *Consumer) Subscribe(topic []string) error`
|
||||
|
||||
Subscribes to topics.
|
||||
|
||||
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||
|
||||
Polling information.
|
||||
|
||||
* `func (c *Consumer) Commit(messageID uint64) error`
|
||||
|
||||
Commit information.
|
||||
|
||||
* `func (c *Consumer) Close() error`
|
||||
|
||||
Close consumer.
|
||||
|
||||
For a complete example see [GitHub sample file](https://github.com/taosdata/driver-go/blob/3.0/examples/tmqoverws/main.go)
|
||||
|
||||
## API Reference
|
||||
|
||||
Full API see [driver-go documentation](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import PkgListV3 from "/components/PkgListV3";
|
||||
|
||||
1. Download the client installation package
|
||||
|
||||
<PkgListV3 type={8} sys="macOS" />
|
||||
|
||||
[All Downloads](../../releases/tdengine)
|
||||
|
||||
2. Execute the installer, select the default value as prompted, and complete the installation. If the installation is blocked, you can right-click or ctrl-click on the installation package and select `Open`.
|
||||
3. configure taos.cfg
|
||||
|
||||
Edit `taos.cfg` file (full path is `/etc/taos/taos.cfg` by default), modify `firstEP` with actual TDengine server's End Point, for example `h1.tdengine.com:6030`
|
||||
|
||||
:::tip
|
||||
|
||||
1. If the computer does not run the TDengine service but installs the TDengine client driver, then you need to config `firstEP` in `taos.cfg` only, and there is no need to configure `FQDN`;
|
||||
2. If you encounter the "Unable to resolve FQDN" error, please make sure the FQDN in the `/etc/hosts` file of the current computer is correctly configured, or the DNS service is correctly configured.
|
||||
|
||||
:::
|
|
@ -0,0 +1,15 @@
|
|||
Execute TDengine CLI program `taos` directly from the macOS shell to connect to the TDengine service and enter the TDengine CLI interface, as shown in the following example.
|
||||
|
||||
```text
|
||||
$ taos
|
||||
|
||||
taos> show databases;
|
||||
name |
|
||||
=================================
|
||||
information_schema |
|
||||
performance_schema |
|
||||
db |
|
||||
Query OK, 3 rows in database (0.019154s)
|
||||
|
||||
taos>
|
||||
```
|
|
@ -10,12 +10,14 @@ import PkgListV3 from "/components/PkgListV3";
|
|||
|
||||
The default installation path is C:\TDengine, including the following files (directories).
|
||||
|
||||
- _taos.exe_ : TDengine CLI command-line program
|
||||
- _cfg_ : configuration file directory
|
||||
- _taos.exe_: TDengine CLI command-line program
|
||||
- _taosadapter.exe_: server-side executable that provides RESTful services and accepts writing requests from a variety of other softwares
|
||||
- _taosBenchmark.exe_: TDengine testing tool
|
||||
- _cfg_: configuration file directory
|
||||
- _driver_: client driver dynamic link library
|
||||
- _examples_: sample programs bash/C/C#/go/JDBC/Python/Node.js
|
||||
- _include_: header files
|
||||
- _log_ : log file
|
||||
- _log_: log file
|
||||
- _unins000.exe_: uninstaller
|
||||
|
||||
4. configure taos.cfg
|
||||
|
|
|
@ -74,10 +74,12 @@ The different database framework specifications for various programming language
|
|||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import InstallOnWindows from "./_linux_install.mdx";
|
||||
import InstallOnLinux from "./_windows_install.mdx";
|
||||
import InstallOnLinux from "./_linux_install.mdx";
|
||||
import InstallOnWindows from "./_windows_install.mdx";
|
||||
import InstallOnMacOS from "./_macos_install.mdx";
|
||||
import VerifyWindows from "./_verify_windows.mdx";
|
||||
import VerifyLinux from "./_verify_linux.mdx";
|
||||
import VerifyMacOS from "./_verify_macos.mdx";
|
||||
|
||||
## Install Client Driver
|
||||
|
||||
|
@ -90,10 +92,13 @@ The client driver needs to be installed if you use the native interface connecto
|
|||
|
||||
<Tabs defaultValue="linux" groupId="os">
|
||||
<TabItem value="linux" label="Linux">
|
||||
<InstallOnWindows />
|
||||
<InstallOnLinux />
|
||||
</TabItem>
|
||||
<TabItem value="windows" label="Windows">
|
||||
<InstallOnLinux />
|
||||
<InstallOnWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<InstallOnMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -108,5 +113,8 @@ After completing the above installation and configuration and you have confirmed
|
|||
<TabItem value="windows" label="Windows">
|
||||
<VerifyWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<VerifyMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ description: TDengine release history, Release Notes and download links.
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.5
|
||||
|
||||
<Release type="tdengine" version="3.0.1.5" />
|
||||
|
||||
## 3.0.1.4
|
||||
|
||||
<Release type="tdengine" version="3.0.1.4" />
|
||||
|
|
|
@ -6,6 +6,10 @@ description: taosTools release history, Release Notes, download links.
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.6
|
||||
|
||||
<Release type="tools" version="2.2.6" />
|
||||
|
||||
## 2.2.4
|
||||
|
||||
<Release type="tools" version="2.2.4" />
|
||||
|
|
|
@ -115,7 +115,7 @@ apt-get 方式只适用于 Debian 或 Ubuntu 系统。
|
|||
|
||||
1. 从列表中下载获得 pkg 安装程序;
|
||||
<PkgListV3 type={7}/>
|
||||
2. 运行可执行程序来安装 TDengine。
|
||||
2. 运行可执行程序来安装 TDengine。如果安装被阻止,可以右键或者按 Ctrl 点击安装包,选择 `打开`。
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -178,12 +178,20 @@ Active: inactive (dead)
|
|||
|
||||
:::
|
||||
|
||||
## TDengine 命令行(CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在终端执行 `taos` 即可。
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="Windows 系统" value="windows">
|
||||
|
||||
安装后,在 `C:\TDengine` 目录下,运行 `taosd.exe` 来启动 TDengine 服务进程。
|
||||
|
||||
## TDengine 命令行(CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在终端执行 `taos` 即可。
|
||||
|
||||
</TabItem>
|
||||
|
||||
<TabItem label="macOS 系统" value="macos">
|
||||
|
@ -205,12 +213,12 @@ Active: inactive (dead)
|
|||
|
||||
:::
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## TDengine 命令行(CLI)
|
||||
|
||||
为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在安装有 TDengine 的 Linux、macOS 终端执行 `taos` 即可,也可以在安装有 TDengine 的 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。
|
||||
为便于检查 TDengine 的状态,执行数据库(Database)的各种即席(Ad Hoc)查询,TDengine 提供一命令行应用程序(以下简称为 TDengine CLI)taos。要进入 TDengine 命令行,您只要在 Windows 终端的 C:\TDengine 目录下,运行 taos.exe 来启动 TDengine 命令行。
|
||||
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
```bash
|
||||
taos
|
||||
|
|
|
@ -14,9 +14,11 @@ import ConnCSNative from "./_connect_cs.mdx";
|
|||
import ConnC from "./_connect_c.mdx";
|
||||
import ConnR from "./_connect_r.mdx";
|
||||
import ConnPHP from "./_connect_php.mdx";
|
||||
import InstallOnWindows from "../../08-connector/_linux_install.mdx";
|
||||
import InstallOnLinux from "../../08-connector/_windows_install.mdx";
|
||||
import InstallOnLinux from "../../08-connector/_linux_install.mdx";
|
||||
import InstallOnWindows from "../../08-connector/_windows_install.mdx";
|
||||
import InstallOnMacOS from "../../08-connector/_macos_install.mdx";
|
||||
import VerifyLinux from "../../08-connector/_verify_linux.mdx";
|
||||
import VerifyMacOS from "../../08-connector/_verify_macos.mdx";
|
||||
import VerifyWindows from "../../08-connector/_verify_windows.mdx";
|
||||
|
||||
TDengine 提供了丰富的应用程序开发接口,为了便于用户快速开发自己的应用,TDengine 支持了多种编程语言的连接器,其中官方连接器包括支持 C/C++、Java、Python、Go、Node.js、C#、Rust、Lua(社区贡献)和 PHP (社区贡献)的连接器。这些连接器支持使用原生接口(taosc)和 REST 接口(部分语言暂不支持)连接 TDengine 集群。社区开发者也贡献了多个非官方连接器,例如 ADO.NET 连接器、Lua 连接器和 PHP 连接器。
|
||||
|
@ -43,10 +45,13 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
|
|||
|
||||
<Tabs defaultValue="linux" groupId="os">
|
||||
<TabItem value="linux" label="Linux">
|
||||
<InstallOnWindows />
|
||||
<InstallOnLinux />
|
||||
</TabItem>
|
||||
<TabItem value="windows" label="Windows">
|
||||
<InstallOnLinux />
|
||||
<InstallOnWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="macOS">
|
||||
<InstallOnMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -61,6 +66,9 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
|
|||
<TabItem value="windows" label="Windows">
|
||||
<VerifyWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="macOS">
|
||||
<VerifyMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 安装连接器
|
||||
|
|
|
@ -247,7 +247,7 @@ CREATE TOPIC topic_name as subquery
|
|||
|
||||
- 该类型 TOPIC 一旦创建则订阅数据的结构确定。
|
||||
- 被订阅或用于计算的列或标签不可被删除(`ALTER table DROP`)、修改(`ALTER table MODIFY`)。
|
||||
- 若发生表结构变更,新增的列不出现在结果中,若发生列删除则会报错。
|
||||
- 若发生表结构变更,新增的列不出现在结果中。
|
||||
|
||||
### 超级表订阅
|
||||
|
||||
|
@ -269,10 +269,10 @@ CREATE TOPIC topic_name AS STABLE stb_name
|
|||
语法:
|
||||
|
||||
```sql
|
||||
CREATE TOPIC topic_name [WITH META] AS DATABASE db_name;
|
||||
CREATE TOPIC topic_name AS DATABASE db_name;
|
||||
```
|
||||
|
||||
通过该语句可创建一个包含数据库所有表数据的订阅,`WITH META` 可选择将数据库结构变动信息加入到订阅消息流,TMQ 将消费当前数据库下所有表结构的变动,包括超级表的创建与删除,列添加、删除或修改,子表的创建、删除及 TAG 变动信息等等。消费者可通过 API 来判断具体的消息类型。这一点也是与 Kafka 不同的地方。
|
||||
通过该语句可创建一个包含数据库所有表数据的订阅
|
||||
|
||||
## 创建消费者 *consumer*
|
||||
|
||||
|
@ -282,16 +282,16 @@ CREATE TOPIC topic_name [WITH META] AS DATABASE db_name;
|
|||
| :----------------------------: | :-----: | -------------------------------------------------------- | ------------------------------------------- |
|
||||
| `td.connect.ip` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.user` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` |
|
||||
| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` |
|
||||
| `td.connect.pass` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `td.connect.port` | integer | 用于创建连接,同 `taos_connect` | |
|
||||
| `group.id` | string | 消费组 ID,同一消费组共享消费进度 | **必填项**。最大长度:192。 |
|
||||
| `client.id` | string | 客户端 ID | 最大长度:192。 |
|
||||
| `auto.offset.reset` | enum | 消费组订阅的初始位置 | 可选:`earliest`, `latest`, `none`(default) |
|
||||
| `enable.auto.commit` | boolean | 启用自动提交 | 合法值:`true`, `false`。 |
|
||||
| `auto.commit.interval.ms` | integer | 以毫秒为单位的自动提交时间间隔 |
|
||||
| `enable.heartbeat.background` | boolean | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | |
|
||||
| `experimental.snapshot.enable` | boolean | 从 WAL 开始消费,还是从 TSBS 开始消费 | |
|
||||
| `msg.with.table.name` | boolean | 是否允许从消息中解析表名 |
|
||||
| `auto.offset.reset` | enum | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` |
|
||||
| `enable.auto.commit` | boolean | 是否启用消费位点自动提交 | 合法值:`true`, `false`。 |
|
||||
| `auto.commit.interval.ms` | integer | 以毫秒为单位的消费记录自动提交消费位点时间间 | 默认 5000 m |
|
||||
| `enable.heartbeat.background` | boolean | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 默认开启 |
|
||||
| `experimental.snapshot.enable` | boolean | 是否允许从 TSDB 消费数据 | 实验功能,默认关闭 |
|
||||
| `msg.with.table.name` | boolean | 是否允许从消息中解析表名, 不适用于列订阅(列订阅时可将 tbname 作为列写入 subquery 语句) | |
|
||||
|
||||
对于不同编程语言,其设置方式如下:
|
||||
|
||||
|
@ -420,7 +420,18 @@ let mut consumer = tmq.build()?;
|
|||
|
||||
<TabItem value="Python" label="Python">
|
||||
|
||||
Python 使用以下配置项创建一个 Consumer 实例。
|
||||
Python 语言下引入 `taos` 库的 `TaosConsumer` 类,创建一个 Consumer 示例:
|
||||
|
||||
```python
|
||||
from taos.tmq import TaosConsumer
|
||||
|
||||
# Syntax: `consumer = TaosConsumer(*topics, **args)`
|
||||
#
|
||||
# Example:
|
||||
consumer = TaosConsumer('topic1', 'topic2', td_connect_ip = "127.0.0.1", group_id = "local")
|
||||
```
|
||||
|
||||
其中,元组类型参数被视为 *Topics*,字典类型参数用于以下订阅配置设置:
|
||||
|
||||
| 参数名称 | 类型 | 参数说明 | 备注 |
|
||||
| :----------------------------: | :----: | -------------------------------------------------------- | ------------------------------------------- |
|
||||
|
@ -430,13 +441,13 @@ Python 使用以下配置项创建一个 Consumer 实例。
|
|||
| `td_connect_port` | string | 用于创建连接,同 `taos_connect` | |
|
||||
| `group_id` | string | 消费组 ID,同一消费组共享消费进度 | **必填项**。最大长度:192。 |
|
||||
| `client_id` | string | 客户端 ID | 最大长度:192。 |
|
||||
| `auto_offset_reset` | string | 消费组订阅的初始位置 | 可选:`earliest`, `latest`, `none`(default) |
|
||||
| `enable_auto_commit` | string | 启用自动提交 | 合法值:`true`, `false`。 |
|
||||
| `auto_commit_interval_ms` | string | 以毫秒为单位的自动提交时间间隔 | |
|
||||
| `auto_offset_reset` | string | 消费组订阅的初始位置 | 可选:`earliest`(default), `latest`, `none` |
|
||||
| `enable_auto_commit` | string | 启用自动提交 | 合法值:`true`, `false`,默认为 true |
|
||||
| `auto_commit_interval_ms` | string | 以毫秒为单位的自动提交时间间隔 | 默认值:5000 ms |
|
||||
| `enable_heartbeat_background` | string | 启用后台心跳,启用后即使长时间不 poll 消息也不会造成离线 | 合法值:`true`, `false` |
|
||||
| `experimental_snapshot_enable` | string | 从 WAL 开始消费,还是从 TSBS 开始消费 | 合法值:`true`, `false` |
|
||||
| `msg_with_table_name` | string | 是否允许从消息中解析表名 | 合法值:`true`, `false` |
|
||||
| `timeout` | int | 消费者拉去的超时时间 | |
|
||||
| `experimental_snapshot_enable` | string | 是否允许从 TSDB 消费数据 | 合法值:`true`, `false` |
|
||||
| `msg_with_table_name` | string | 是否允许从消息中解析表名,不适用于列订阅 | 合法值:`true`, `false` |
|
||||
| `timeout` | int | 消费者拉取数据的超时时间 | |
|
||||
|
||||
</TabItem>
|
||||
|
||||
|
|
|
@ -177,6 +177,37 @@ func main() {
|
|||
}
|
||||
```
|
||||
</TabItem>
|
||||
<TabItem value="WebSocket" label="WebSocket 连接">
|
||||
|
||||
_taosWS_ 通过 `WebSocket` 实现了 Go 的 `database/sql/driver` 接口。只需要引入驱动(driver-go 最低版本 3.0.2)就可以使用[`database/sql`](https://golang.org/pkg/database/sql/)的接口。
|
||||
|
||||
使用 `taosWS` 作为 `driverName` 并且使用一个正确的 [DSN](#DSN) 作为 `dataSourceName`,DSN 支持的参数:
|
||||
|
||||
* `writeTimeout` 通过 WebSocket 发送数据的超时时间。
|
||||
* `readTimeout` 通过 WebSocket 接收响应数据的超时时间。
|
||||
|
||||
示例:
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
_ "github.com/taosdata/driver-go/v3/taosWS"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var taosUri = "root:taosdata@ws(localhost:6041)/"
|
||||
taos, err := sql.Open("taosWS", taosUri)
|
||||
if err != nil {
|
||||
fmt.Println("failed to connect TDengine, err:", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
```
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
## 使用示例
|
||||
|
@ -410,6 +441,30 @@ func main() {
|
|||
|
||||
结束参数绑定。
|
||||
|
||||
### 通过 WebSocket 订阅
|
||||
|
||||
* `func NewConsumer(config *Config) (*Consumer, error)`
|
||||
|
||||
创建消费者。
|
||||
|
||||
* `func (c *Consumer) Subscribe(topic []string) error`
|
||||
|
||||
订阅主题。
|
||||
|
||||
* `func (c *Consumer) Poll(timeout time.Duration) (*Result, error)`
|
||||
|
||||
轮询消息。
|
||||
|
||||
* `func (c *Consumer) Commit(messageID uint64) error`
|
||||
|
||||
提交消息。
|
||||
|
||||
* `func (c *Consumer) Close() error`
|
||||
|
||||
关闭消费者。
|
||||
|
||||
完整订阅示例参见 [GitHub 示例文件](https://github.com/taosdata/driver-go/blob/3.0/examples/tmqoverws/main.go)
|
||||
|
||||
## API 参考
|
||||
|
||||
全部 API 见 [driver-go 文档](https://pkg.go.dev/github.com/taosdata/driver-go/v3)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
import PkgListV3 from "/components/PkgListV3";
|
||||
|
||||
1. 下载客户端安装包
|
||||
|
||||
<PkgListV3 type={8} sys="macOS" />
|
||||
|
||||
[所有下载](../../releases/tdengine)
|
||||
|
||||
2. 执行安装程序,按提示选择默认值,完成安装。如果安装被阻止,可以右键或者按 Ctrl 点击安装包,选择 `打开`。
|
||||
3. 配置 taos.cfg
|
||||
|
||||
编辑 `taos.cfg` 文件(默认路径/etc/taos/taos.cfg),将 `firstEP` 修改为 TDengine 服务器的 End Point,例如:`h1.tdengine.com:6030`
|
||||
|
||||
:::tip
|
||||
|
||||
1. 如本机没有部署 TDengine 服务,仅安装了应用驱动,则 `taos.cfg` 中仅需配置 `firstEP`,无需在本机配置 `FQDN`。
|
||||
2. 为防止与服务器端连接时出现“Unable to resolve FQDN”错误,建议确认本机的 `/etc/hosts` 文件已经配置了服务器正确的 FQDN 值,或配置好了 DNS 服务。
|
||||
|
||||
:::
|
|
@ -0,0 +1,15 @@
|
|||
在 macOS shell 下直接执行 `taos` 连接到 TDengine 服务,进入到 TDengine CLI 界面,示例如下:
|
||||
|
||||
```text
|
||||
$ taos
|
||||
|
||||
taos> show databases;
|
||||
name |
|
||||
=================================
|
||||
information_schema |
|
||||
performance_schema |
|
||||
db |
|
||||
Query OK, 3 rows in database (0.019154s)
|
||||
|
||||
taos>
|
||||
```
|
|
@ -12,6 +12,8 @@ import PkgListV3 from "/components/PkgListV3";
|
|||
默认安装路径为:C:\TDengine,其中包括以下文件(目录):
|
||||
|
||||
- _taos.exe_:TDengine CLI 命令行程序
|
||||
- _taosadapter.exe_:提供 RESTful 服务和接受其他多种软件写入请求的服务端可执行文件
|
||||
- _taosBenchmark.exe_:TDengine 测试程序
|
||||
- _cfg_ : 配置文件目录
|
||||
- _driver_: 应用驱动动态链接库
|
||||
- _examples_: 示例程序 bash/C/C#/go/JDBC/Python/Node.js
|
||||
|
|
|
@ -74,10 +74,12 @@ TDengine 版本更新往往会增加新的功能特性,列表中的连接器
|
|||
|
||||
import Tabs from "@theme/Tabs";
|
||||
import TabItem from "@theme/TabItem";
|
||||
import InstallOnWindows from "./_linux_install.mdx";
|
||||
import InstallOnLinux from "./_windows_install.mdx";
|
||||
import InstallOnLinux from "./_linux_install.mdx";
|
||||
import InstallOnWindows from "./_windows_install.mdx";
|
||||
import InstallOnMacOS from "./_macos_install.mdx";
|
||||
import VerifyWindows from "./_verify_windows.mdx";
|
||||
import VerifyLinux from "./_verify_linux.mdx";
|
||||
import VerifyMacOS from "./_verify_macos.mdx";
|
||||
|
||||
## 安装客户端驱动
|
||||
|
||||
|
@ -90,10 +92,13 @@ import VerifyLinux from "./_verify_linux.mdx";
|
|||
|
||||
<Tabs defaultValue="linux" groupId="os">
|
||||
<TabItem value="linux" label="Linux">
|
||||
<InstallOnWindows />
|
||||
<InstallOnLinux />
|
||||
</TabItem>
|
||||
<TabItem value="windows" label="Windows">
|
||||
<InstallOnLinux />
|
||||
<InstallOnWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<InstallOnMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
@ -108,5 +113,8 @@ import VerifyLinux from "./_verify_linux.mdx";
|
|||
<TabItem value="windows" label="Windows">
|
||||
<VerifyWindows />
|
||||
</TabItem>
|
||||
<TabItem value="macos" label="MacOS">
|
||||
<VerifyMacOS />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
||||
|
|
|
@ -864,8 +864,9 @@ INTERP(expr)
|
|||
|
||||
- INTERP 用于在指定时间断面获取指定列的记录值,如果该时间断面不存在符合条件的行数据,那么会根据 FILL 参数的设定进行插值。
|
||||
- INTERP 的输入数据为指定列的数据,可以通过条件语句(where 子句)来对原始列数据进行过滤,如果没有指定过滤条件则输入为全部数据。
|
||||
- INTERP 需要同时与 RANGE,EVERY 和 FILL 关键字一起使用。
|
||||
- INTERP 的输出时间范围根据 RANGE(timestamp1,timestamp2)字段来指定,需满足 timestamp1<=timestamp2。其中 timestamp1(必选值)为输出时间范围的起始值,即如果 timestamp1 时刻符合插值条件则 timestamp1 为输出的第一条记录,timestamp2(必选值)为输出时间范围的结束值,即输出的最后一条记录的 timestamp 不能大于 timestamp2。
|
||||
- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。如果没有指定 EVERY,则默认窗口大小为无穷大,即从 timestamp1 开始只有一个窗口。
|
||||
- INTERP 根据 EVERY 字段来确定输出时间范围内的结果条数,即从 timestamp1 开始每隔固定长度的时间(EVERY 值)进行插值。
|
||||
- INTERP 根据 FILL 字段来决定在每个符合输出条件的时刻如何进行插值。
|
||||
- INTERP 只能在一个时间序列内进行插值,因此当作用于超级表时必须跟 partition by tbname 一起使用。
|
||||
- INTERP 可以与伪列 _irowts 一起使用,返回插值点所对应的时间戳(3.0.1.4版本以后支持)。
|
||||
|
@ -946,7 +947,7 @@ MIN(expr)
|
|||
MODE(expr)
|
||||
```
|
||||
|
||||
**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,输出NULL。
|
||||
**功能说明**:返回出现频率最高的值,若存在多个频率相同的最高值,则随机输出其中某个值。
|
||||
|
||||
**返回数据类型**:与输入数据类型一致。
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ dataDir /mnt/data6 2 0
|
|||
|
||||
## 数据查询
|
||||
|
||||
TDengine 提供了多种多样针对表和超级表的查询处理功能,除了常规的聚合查询之外,还提供针对时序数据的窗口查询、统计聚合等功能。TDengine 的查询处理需要客户端、vnode、qnode、mnode 节点协同完成,一个复杂的超级表聚合查询可能需要多个 vnode 和 qnode 节点公共分担查询和计算任务。
|
||||
TDengine 提供了多种多样针对表和超级表的查询处理功能,除了常规的聚合查询之外,还提供针对时序数据的窗口查询、统计聚合等功能。TDengine 的查询处理需要客户端、vnode、qnode、mnode 节点协同完成,一个复杂的超级表聚合查询可能需要多个 vnode 和 qnode 节点共同分担查询和计算任务。
|
||||
|
||||
### 查询基本流程
|
||||
|
||||
|
|
|
@ -6,6 +6,10 @@ description: TDengine 发布历史、Release Notes 及下载链接
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.5
|
||||
|
||||
<Release type="tdengine" version="3.0.1.5" />
|
||||
|
||||
## 3.0.1.4
|
||||
|
||||
<Release type="tdengine" version="3.0.1.4" />
|
||||
|
|
|
@ -6,6 +6,10 @@ description: taosTools 的发布历史、Release Notes 和下载链接
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.6
|
||||
|
||||
<Release type="tools" version="2.2.6" />
|
||||
|
||||
## 2.2.4
|
||||
|
||||
<Release type="tools" version="2.2.4" />
|
||||
|
|
|
@ -198,6 +198,7 @@ DLL_EXPORT const void *taos_get_raw_block(TAOS_RES *res);
|
|||
|
||||
DLL_EXPORT int taos_load_table_info(TAOS *taos, const char *tableNameList);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision);
|
||||
DLL_EXPORT TAOS_RES *taos_schemaless_insert_raw(TAOS* taos, char* lines, int len, int32_t *totalRows, int protocol, int precision);
|
||||
|
||||
/* --------------------------TMQ INTERFACE------------------------------- */
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ extern "C" {
|
|||
#define TSDB_INS_TABLE_MNODES "ins_mnodes"
|
||||
#define TSDB_INS_TABLE_MODULES "ins_modules"
|
||||
#define TSDB_INS_TABLE_QNODES "ins_qnodes"
|
||||
#define TSDB_INS_TABLE_BNODES "ins_bnodes"
|
||||
#define TSDB_INS_TABLE_BNODES "ins_bnodes" // no longer used
|
||||
#define TSDB_INS_TABLE_SNODES "ins_snodes"
|
||||
#define TSDB_INS_TABLE_CLUSTER "ins_cluster"
|
||||
#define TSDB_INS_TABLE_DATABASES "ins_databases"
|
||||
|
|
|
@ -44,12 +44,17 @@ enum {
|
|||
)
|
||||
// clang-format on
|
||||
|
||||
typedef struct {
|
||||
typedef struct SWinKey {
|
||||
uint64_t groupId;
|
||||
TSKEY ts;
|
||||
} SWinKey;
|
||||
|
||||
static inline int sWinKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
||||
typedef struct SSessionKey {
|
||||
STimeWindow win;
|
||||
uint64_t groupId;
|
||||
} SSessionKey;
|
||||
|
||||
static inline int winKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
||||
SWinKey* pWin1 = (SWinKey*)pKey1;
|
||||
SWinKey* pWin2 = (SWinKey*)pKey2;
|
||||
|
||||
|
@ -69,7 +74,7 @@ static inline int sWinKeyCmprImpl(const void* pKey1, const void* pKey2) {
|
|||
}
|
||||
|
||||
static inline int winKeyCmpr(const void* pKey1, int kLen1, const void* pKey2, int kLen2) {
|
||||
return sWinKeyCmprImpl(pKey1, pKey2);
|
||||
return winKeyCmprImpl(pKey1, pKey2);
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
|
|
@ -45,15 +45,6 @@ extern bool tsPrintAuth;
|
|||
extern int64_t tsTickPerMin[3];
|
||||
extern int32_t tsCountAlwaysReturnValue;
|
||||
|
||||
// multi-process
|
||||
extern int32_t tsMultiProcess;
|
||||
extern int32_t tsMnodeShmSize;
|
||||
extern int32_t tsVnodeShmSize;
|
||||
extern int32_t tsQnodeShmSize;
|
||||
extern int32_t tsSnodeShmSize;
|
||||
extern int32_t tsBnodeShmSize;
|
||||
extern int32_t tsNumOfShmThreads;
|
||||
|
||||
// queue & threads
|
||||
extern int32_t tsNumOfRpcThreads;
|
||||
extern int32_t tsNumOfCommitThreads;
|
||||
|
|
|
@ -95,7 +95,7 @@ typedef enum _mgmt_table {
|
|||
TSDB_MGMT_TABLE_MODULE,
|
||||
TSDB_MGMT_TABLE_QNODE,
|
||||
TSDB_MGMT_TABLE_SNODE,
|
||||
TSDB_MGMT_TABLE_BNODE,
|
||||
TSDB_MGMT_TABLE_BNODE, // no longer used
|
||||
TSDB_MGMT_TABLE_CLUSTER,
|
||||
TSDB_MGMT_TABLE_DB,
|
||||
TSDB_MGMT_TABLE_FUNC,
|
||||
|
@ -343,6 +343,8 @@ typedef struct {
|
|||
} SSchemaWrapper;
|
||||
|
||||
static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* pSchemaWrapper) {
|
||||
if (pSchemaWrapper->pSchema == NULL) return NULL;
|
||||
|
||||
SSchemaWrapper* pSW = (SSchemaWrapper*)taosMemoryMalloc(sizeof(SSchemaWrapper));
|
||||
if (pSW == NULL) return pSW;
|
||||
pSW->nCols = pSchemaWrapper->nCols;
|
||||
|
@ -352,6 +354,7 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
taosMemoryFree(pSW);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
return pSW;
|
||||
}
|
||||
|
@ -1485,11 +1488,10 @@ int32_t tDeserializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq
|
|||
typedef struct {
|
||||
int32_t dnodeId;
|
||||
} SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq, SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq,
|
||||
SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq, SMCreateBnodeReq, SMDropBnodeReq,
|
||||
SDCreateBnodeReq, SDDropBnodeReq;
|
||||
SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq;
|
||||
|
||||
int32_t tSerializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||
int32_t tDeserializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||
int32_t tSerializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||
int32_t tDeserializeSCreateDropMQSNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq);
|
||||
|
||||
typedef struct {
|
||||
int8_t replica;
|
||||
|
|
|
@ -34,6 +34,7 @@ typedef enum {
|
|||
WRITE_QUEUE,
|
||||
APPLY_QUEUE,
|
||||
SYNC_QUEUE,
|
||||
SYNC_CTRL_QUEUE,
|
||||
STREAM_QUEUE,
|
||||
QUEUE_MAX,
|
||||
} EQueueType;
|
||||
|
|
|
@ -74,8 +74,8 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_QNODE, "dnode-drop-qnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_SNODE, "dnode-create-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_SNODE, "dnode-drop-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_BNODE, "dnode-create-bnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_BNODE, "dnode-drop-bnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_BNODE, "dnode-create-bnode", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_BNODE, "dnode-drop-bnode", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_CREATE_VNODE, "create-vnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_DROP_VNODE, "drop-vnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_DND_SERVER_STATUS, "server-status", NULL, NULL)
|
||||
|
@ -107,9 +107,9 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_SNODE, "create-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_SNODE, "alter-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_SNODE, "drop-snode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_BNODE, "create-bnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_BNODE, "alter-bnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_BNODE, "drop-bnode", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_BNODE, "create-bnode", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_ALTER_BNODE, "alter-bnode", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_BNODE, "drop-bnode", NULL, NULL) // no longer used
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_CREATE_DB, "create-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_DROP_DB, "drop-db", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MND_USE_DB, "use-db", NULL, NULL)
|
||||
|
@ -239,14 +239,6 @@ enum {
|
|||
TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_MON_MSG)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_MM_INFO, "monitor-minfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_VM_INFO, "monitor-vinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_QM_INFO, "monitor-qinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_SM_INFO, "monitor-sinfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_BM_INFO, "monitor-binfo", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_VM_LOAD, "monitor-vload", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_MM_LOAD, "monitor-mload", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_QM_LOAD, "monitor-qload", NULL, NULL)
|
||||
TD_DEF_MSG_TYPE(TDMT_MON_MAX_MSG, "monitor-max", NULL, NULL)
|
||||
|
||||
TD_NEW_MSG_SEG(TDMT_SYNC_MSG)
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
typedef struct STSRow {
|
||||
TSKEY ts;
|
||||
union {
|
||||
uint32_t info;
|
||||
|
|
|
@ -337,21 +337,16 @@ typedef struct tDataTypeDescriptor {
|
|||
int32_t nBuf);
|
||||
int32_t (*decompFunc)(void *pIn, int32_t nIn, int32_t nEle, void *pOut, int32_t nOut, uint8_t cmprAlg, void *pBuf,
|
||||
int32_t nBuf);
|
||||
void (*statisFunc)(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numofrow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minindex, int16_t *maxindex, int16_t *numofnull);
|
||||
} tDataTypeDescriptor;
|
||||
|
||||
extern tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX];
|
||||
|
||||
bool isValidDataType(int32_t type);
|
||||
|
||||
void setVardataNull(void *val, int32_t type);
|
||||
void setNull(void *val, int32_t type, int32_t bytes);
|
||||
void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems);
|
||||
const void *getNullValue(int32_t type);
|
||||
|
||||
void setVardataNull(void *val, int32_t type);
|
||||
//void setNull(void *val, int32_t type, int32_t bytes);
|
||||
//void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems);
|
||||
void assignVal(char *val, const char *src, int32_t len, int32_t type);
|
||||
void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void *buf);
|
||||
void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type);
|
||||
void *getDataMin(int32_t type);
|
||||
void *getDataMax(int32_t type);
|
||||
|
|
|
@ -39,8 +39,6 @@ typedef struct SVariant {
|
|||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value);
|
||||
int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value);
|
||||
|
||||
bool taosVariantIsValid(SVariant *pVar);
|
||||
|
||||
void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uint32_t type);
|
||||
|
||||
void taosVariantDestroy(SVariant *pV);
|
||||
|
@ -49,15 +47,6 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc);
|
|||
|
||||
int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2);
|
||||
|
||||
int32_t taosVariantToString(SVariant *pVar, char *dst);
|
||||
|
||||
int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix);
|
||||
|
||||
#if 0
|
||||
int32_t taosVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted, char *extInfo);
|
||||
#endif
|
||||
|
||||
int32_t taosVariantTypeSetType(SVariant *pVariant, char type);
|
||||
char *taosVariantGet(SVariant *pVar, int32_t type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_BNODE_H_
|
||||
#define _TD_BNODE_H_
|
||||
|
||||
#include "tmsgcb.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ------------------------ TYPES EXPOSED ------------------------ */
|
||||
typedef struct SBnode SBnode;
|
||||
|
||||
typedef struct {
|
||||
#ifdef WINDOWS
|
||||
size_t avoidCompilationErrors;
|
||||
#endif
|
||||
} SBnodeLoad;
|
||||
|
||||
typedef struct {
|
||||
SMsgCb msgCb;
|
||||
} SBnodeOpt;
|
||||
|
||||
/* ------------------------ SBnode ------------------------ */
|
||||
/**
|
||||
* @brief Start one Bnode in Dnode.
|
||||
*
|
||||
* @param path Path of the bnode.
|
||||
* @param pOption Option of the bnode.
|
||||
* @return SBnode* The bnode object.
|
||||
*/
|
||||
SBnode *bndOpen(const char *path, const SBnodeOpt *pOption);
|
||||
|
||||
/**
|
||||
* @brief Stop Bnode in Dnode.
|
||||
*
|
||||
* @param pBnode The bnode object to close.
|
||||
*/
|
||||
void bndClose(SBnode *pBnode);
|
||||
|
||||
/**
|
||||
* @brief Get the statistical information of Bnode
|
||||
*
|
||||
* @param pBnode The bnode object.
|
||||
* @param pLoad Statistics of the bnode.
|
||||
* @return int32_t 0 for success, -1 for failure.
|
||||
*/
|
||||
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad);
|
||||
|
||||
/**
|
||||
* @brief Process a query message.
|
||||
*
|
||||
* @param pBnode The bnode object.
|
||||
* @param pMsgs The array of SRpcMsg
|
||||
* @return int32_t 0 for success, -1 for failure
|
||||
*/
|
||||
int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_BNODE_H_*/
|
|
@ -25,10 +25,9 @@ extern "C" {
|
|||
/**
|
||||
* @brief Initialize the dnode
|
||||
*
|
||||
* @param rtype for internal debug usage, default is 0
|
||||
* @return int32_t 0 for success and -1 for failure
|
||||
*/
|
||||
int32_t dmInit(int8_t rtype);
|
||||
int32_t dmInit();
|
||||
|
||||
/**
|
||||
* @brief Cleanup the dnode
|
||||
|
|
|
@ -80,7 +80,6 @@ typedef struct {
|
|||
int8_t has_mnode;
|
||||
int8_t has_qnode;
|
||||
int8_t has_snode;
|
||||
int8_t has_bnode;
|
||||
SMonDiskDesc logdir;
|
||||
SMonDiskDesc tempdir;
|
||||
} SMonDnodeInfo;
|
||||
|
|
|
@ -525,7 +525,7 @@ typedef struct SDataInserterNode {
|
|||
SDataSinkNode sink;
|
||||
int32_t numOfTables;
|
||||
uint32_t size;
|
||||
char* pData;
|
||||
void* pData;
|
||||
} SDataInserterNode;
|
||||
|
||||
typedef struct SQueryInserterNode {
|
||||
|
|
|
@ -356,7 +356,7 @@ typedef struct SVgDataBlocks {
|
|||
SVgroupInfo vg;
|
||||
int32_t numOfTables; // number of tables in current submit block
|
||||
uint32_t size;
|
||||
char* pData; // SMsgDesc + SSubmitReq + SSubmitBlk + ...
|
||||
void* pData; // SMsgDesc + SSubmitReq + SSubmitBlk + ...
|
||||
} SVgDataBlocks;
|
||||
|
||||
typedef struct SVnodeModifOpStmt {
|
||||
|
|
|
@ -25,6 +25,8 @@ extern "C" {
|
|||
|
||||
typedef struct SStreamTask SStreamTask;
|
||||
|
||||
typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2);
|
||||
|
||||
// incremental state storage
|
||||
typedef struct {
|
||||
SStreamTask* pOwner;
|
||||
|
@ -32,6 +34,7 @@ typedef struct {
|
|||
TTB* pStateDb;
|
||||
TTB* pFuncStateDb;
|
||||
TTB* pFillStateDb; // todo refactor
|
||||
TTB* pSessionStateDb;
|
||||
TXN txn;
|
||||
int32_t number;
|
||||
} SStreamState;
|
||||
|
@ -57,6 +60,19 @@ int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
|
|||
int32_t streamStateClear(SStreamState* pState);
|
||||
void streamStateSetNumber(SStreamState* pState, int32_t number);
|
||||
|
||||
int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, const void* value, int32_t vLen);
|
||||
int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateSessionDel(SStreamState* pState, const SSessionKey* key);
|
||||
int32_t streamStateSessionClear(SStreamState* pState);
|
||||
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, const void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
||||
|
||||
SStreamStateCur* streamStateSessionSeekKeyNext(SStreamState* pState, const SSessionKey* key);
|
||||
SStreamStateCur* streamStateSessionSeekKeyPrev(SStreamState* pState, const SSessionKey* key);
|
||||
SStreamStateCur* streamStateSessionGetCur(SStreamState* pState, const SSessionKey* key);
|
||||
|
||||
int32_t streamStateFillPut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
||||
int32_t streamStateFillGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateFillDel(SStreamState* pState, const SWinKey* key);
|
||||
|
|
|
@ -695,6 +695,9 @@ int32_t syncNodeOnAppendEntriesReplySnapshot2Cb(SSyncNode* ths, SyncAppendEntrie
|
|||
int32_t syncNodeOnSnapshotSendCb(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
||||
int32_t syncNodeOnSnapshotRspCb(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
||||
|
||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
||||
|
||||
// -----------------------------------------
|
||||
typedef int32_t (*FpOnPingCb)(SSyncNode* ths, SyncPing* pMsg);
|
||||
typedef int32_t (*FpOnPingReplyCb)(SSyncNode* ths, SyncPingReply* pMsg);
|
||||
|
|
|
@ -94,10 +94,8 @@ extern "C" {
|
|||
#include "osLz4.h"
|
||||
#include "osMath.h"
|
||||
#include "osMemory.h"
|
||||
#include "osProc.h"
|
||||
#include "osRand.h"
|
||||
#include "osSemaphore.h"
|
||||
#include "osShm.h"
|
||||
#include "osSignal.h"
|
||||
#include "osSleep.h"
|
||||
#include "osSocket.h"
|
||||
|
|
|
@ -60,6 +60,7 @@ bool osTempSpaceSufficient();
|
|||
|
||||
void osSetTimezone(const char *timezone);
|
||||
void osSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
void osSetProcPath(int32_t argc, char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_OS_PROC_H_
|
||||
#define _TD_OS_PROC_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t taosNewProc(char **args);
|
||||
void taosWaitProc(int32_t pid);
|
||||
void taosKillProc(int32_t pid);
|
||||
bool taosProcExist(int32_t pid);
|
||||
void taosSetProcName(int32_t argc, char **argv, const char *name);
|
||||
void taosSetProcPath(int32_t argc, char **argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_OS_PROC_H_*/
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_OS_SHM_H_
|
||||
#define _TD_OS_SHM_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
int32_t id;
|
||||
int32_t size;
|
||||
void *ptr;
|
||||
} SShm;
|
||||
|
||||
int32_t taosCreateShm(SShm *pShm, int32_t key, int32_t shmsize);
|
||||
void taosDropShm(SShm *pShm);
|
||||
int32_t taosAttachShm(SShm *pShm);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_OS_SHM_H_*/
|
|
@ -483,7 +483,6 @@ enum {
|
|||
#define QNODE_HANDLE -1
|
||||
#define SNODE_HANDLE -2
|
||||
#define VNODE_HANDLE -3
|
||||
#define BNODE_HANDLE -4
|
||||
#define CLIENT_HANDLE -5
|
||||
|
||||
#define TSDB_CONFIG_OPTION_LEN 32
|
||||
|
@ -498,6 +497,7 @@ enum {
|
|||
#define MAX_NUM_STR_SIZE 40
|
||||
|
||||
#define MAX_META_MSG_IN_BATCH 1048576
|
||||
#define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -83,6 +83,12 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
}
|
||||
}
|
||||
|
||||
#define TSDB_CHECK_CODE(CODE, LINO, LABEL) \
|
||||
if (CODE) { \
|
||||
LINO = __LINE__; \
|
||||
goto LABEL; \
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Label</key>
|
||||
<string>com.tdengine.taosadapter</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>/usr/local/bin/taosadapter</string>
|
||||
</array>
|
||||
<key>ProcessType</key>
|
||||
<string>Interactive</string>
|
||||
<key>Disabled</key>
|
||||
<false/>
|
||||
<key>RunAtLoad</key>
|
||||
<false/>
|
||||
<key>LaunchOnlyOnce</key>
|
||||
<false/>
|
||||
<key>SessionCreate</key>
|
||||
<true/>
|
||||
<key>ExitTimeOut</key>
|
||||
<integer>600</integer>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
<key>AfterInitialDemand</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<key>Program</key>
|
||||
<string>/usr/local/bin/taosadapter</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -69,7 +69,7 @@ prompt_force=0
|
|||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep systemd &>/dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &>/dev/null); then
|
||||
service_mod=1
|
||||
|
@ -575,11 +575,11 @@ function install_web() {
|
|||
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if pidof ${serverName} &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
${csudo}service ${serverName} stop || :
|
||||
fi
|
||||
|
||||
if pidof tarbitrator &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then
|
||||
${csudo}service tarbitratord stop || :
|
||||
fi
|
||||
|
||||
|
@ -759,7 +759,7 @@ function updateProduct() {
|
|||
|
||||
echo -e "${GREEN}Start to update ${productName}...${NC}"
|
||||
# Stop the service if running
|
||||
if pidof ${serverName} &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
if ((${service_mod} == 0)); then
|
||||
${csudo}systemctl stop ${serverName} || :
|
||||
elif ((${service_mod} == 1)); then
|
||||
|
|
|
@ -265,7 +265,7 @@ function update_TDengine() {
|
|||
tar -zxf ${tarName}
|
||||
echo -e "${GREEN}Start to update ${productName} client...${NC}"
|
||||
# Stop the client shell if running
|
||||
if pidof ${clientName} &> /dev/null; then
|
||||
if ps aux | grep -v grep | grep ${clientName} &> /dev/null; then
|
||||
kill_client
|
||||
sleep 1
|
||||
fi
|
||||
|
|
|
@ -2,4 +2,5 @@ TDengine is a high-efficient, scalable, high-available distributed time-series d
|
|||
|
||||
To configure TDengine : edit /etc/taos/taos.cfg
|
||||
To start service : launchctl start com.tdengine.taosd
|
||||
To start Taos Adapter : launchctl start com.tdengine.taosadapter
|
||||
To access TDengine : use taos in shell
|
|
@ -77,7 +77,7 @@ os_type=0
|
|||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
initd_mod=0
|
||||
if pidof systemd &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep systemd &>/dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &>/dev/null); then
|
||||
service_mod=1
|
||||
|
@ -130,7 +130,6 @@ function kill_taosadapter() {
|
|||
}
|
||||
|
||||
function kill_taosd() {
|
||||
ps -ef | grep ${serverName}
|
||||
pid=$(ps -ef | grep -w ${serverName} | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
|
@ -438,7 +437,7 @@ function install_web() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if pidof ${serverName} &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
${csudo}service ${serverName} stop || :
|
||||
fi
|
||||
|
||||
|
@ -535,6 +534,10 @@ function install_service_on_launchctl() {
|
|||
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
|
||||
${csudo}cp ${script_dir}/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist
|
||||
${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
|
||||
|
||||
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || :
|
||||
${csudo}cp ${script_dir}/com.taosdata.taosadapter.plist /Library/LaunchDaemons/com.taosdata.taosadapter.plist
|
||||
${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
function install_service() {
|
||||
|
@ -568,7 +571,7 @@ function update_TDengine() {
|
|||
echo -e "${GREEN}Start to update ${productName}...${NC}"
|
||||
# Stop the service if running
|
||||
|
||||
if pidof ${serverName} &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
if ((${service_mod} == 0)); then
|
||||
${csudo}systemctl stop ${serverName} || :
|
||||
elif ((${service_mod} == 1)); then
|
||||
|
@ -615,11 +618,12 @@ function update_TDengine() {
|
|||
else
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}"
|
||||
fi
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}"
|
||||
|
@ -666,11 +670,12 @@ function install_TDengine() {
|
|||
else
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}: ${serverName}${NC}"
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start service ${NC}: launchctl start com.tdengine.taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: launchctl start com.tdengine.taosadapter${NC}"
|
||||
fi
|
||||
[ -f ${installDir}/bin/taosadapter ] && \
|
||||
echo -e "${GREEN_DARK}To start Taos Adapter ${NC}: taosadapter &${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To access ${productName} ${NC}: use ${GREEN_UNDERLINE}${clientName}${NC} in shell${NC}"
|
||||
|
|
|
@ -75,7 +75,7 @@ fi
|
|||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
if ps aux | grep -v grep | grep systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
|
@ -421,7 +421,7 @@ function clean_service_on_sysvinit() {
|
|||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
if ps aux | grep -v grep | grep taosd &> /dev/null; then
|
||||
${csudo}service taosd stop || :
|
||||
fi
|
||||
|
||||
|
@ -512,6 +512,11 @@ function install_service_on_launchctl() {
|
|||
${csudo}cp ${install_main_dir}/service/com.taosdata.taosd.plist /Library/LaunchDaemons/com.taosdata.taosd.plist || :
|
||||
${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosd.plist || :
|
||||
fi
|
||||
if [ -f ${install_main_dir}/service/com.taosdata.taosadapter.plist ]; then
|
||||
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || :
|
||||
${csudo}cp ${install_main_dir}/service/com.taosdata.taosadapter.plist /Library/LaunchDaemons/com.taosdata.taosadapter.plist || :
|
||||
${csudouser}launchctl load -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_taosadapter_service() {
|
||||
|
|
|
@ -25,7 +25,7 @@ fi
|
|||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &> /dev/null; then
|
||||
if ps aux | grep -v grep | grep systemd &> /dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &> /dev/null); then
|
||||
service_mod=1
|
||||
|
@ -82,7 +82,7 @@ function clean_service_on_sysvinit() {
|
|||
#restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start"
|
||||
#${csudo}sed -i "\|${restart_config_str}|d" /etc/inittab || :
|
||||
|
||||
if pidof taosd &> /dev/null; then
|
||||
if ps aux | grep -v grep | grep taosd &> /dev/null; then
|
||||
echo "TDengine taosd is running, stopping it..."
|
||||
${csudo}service taosd stop || :
|
||||
fi
|
||||
|
|
|
@ -55,7 +55,7 @@ fi
|
|||
|
||||
initd_mod=0
|
||||
service_mod=2
|
||||
if pidof systemd &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep systemd &>/dev/null; then
|
||||
service_mod=0
|
||||
elif $(which service &>/dev/null); then
|
||||
service_mod=1
|
||||
|
@ -171,12 +171,12 @@ function clean_service_on_systemd() {
|
|||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if pidof ${serverName} &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
echo "${productName} ${serverName} is running, stopping it..."
|
||||
${csudo}service ${serverName} stop || :
|
||||
fi
|
||||
|
||||
if pidof tarbitrator &>/dev/null; then
|
||||
if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then
|
||||
echo "${productName} tarbitrator is running, stopping it..."
|
||||
${csudo}service tarbitratord stop || :
|
||||
fi
|
||||
|
@ -215,6 +215,8 @@ function clean_service_on_sysvinit() {
|
|||
function clean_service_on_launchctl() {
|
||||
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
|
||||
${csudo}rm /Library/LaunchDaemons/com.taosdata.taosd.plist > /dev/null 2>&1 || :
|
||||
${csudouser}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || :
|
||||
${csudo}rm /Library/LaunchDaemons/com.taosdata.taosadapter.plist > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
function clean_service() {
|
||||
|
|
|
@ -28,7 +28,7 @@ if command -v sudo > /dev/null; then
|
|||
fi
|
||||
|
||||
function kill_client() {
|
||||
if [ -n "$(pidof ${clientName})" ]; then
|
||||
if [ -n "$(ps aux | grep -v grep | grep ${clientName})" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -438,21 +438,18 @@ int taos_init() {
|
|||
}
|
||||
|
||||
int taos_options_imp(TSDB_OPTION option, const char *str) {
|
||||
if (option != TSDB_OPTION_CONFIGDIR) {
|
||||
taos_init(); // initialize global config
|
||||
} else {
|
||||
if (option == TSDB_OPTION_CONFIGDIR) {
|
||||
tstrncpy(configDir, str, PATH_MAX);
|
||||
tscInfo("set cfg:%s to %s", configDir, str);
|
||||
return 0;
|
||||
} else {
|
||||
taos_init(); // initialize global config
|
||||
}
|
||||
|
||||
SConfig *pCfg = taosGetCfg();
|
||||
SConfigItem *pItem = NULL;
|
||||
|
||||
switch (option) {
|
||||
case TSDB_OPTION_CONFIGDIR:
|
||||
pItem = cfgGetItem(pCfg, "configDir");
|
||||
break;
|
||||
case TSDB_OPTION_SHELL_ACTIVITY_TIMER:
|
||||
pItem = cfgGetItem(pCfg, "shellActivityTimer");
|
||||
break;
|
||||
|
|
|
@ -186,8 +186,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
STscObj* pTscObj = (*pRequest)->pTscObj;
|
||||
if (taosHashPut(pTscObj->pRequests, &(*pRequest)->self, sizeof((*pRequest)->self), &(*pRequest)->self,
|
||||
sizeof((*pRequest)->self))) {
|
||||
tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s", (*pRequest)->self,
|
||||
(*pRequest)->requestId, pTscObj->id, sql);
|
||||
tscError("%" PRIx64 " failed to add to request container, reqId:0x%" PRIu64 ", conn:%" PRIx64 ", %s",
|
||||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
|
||||
taosMemoryFree(param);
|
||||
destroyRequest(*pRequest);
|
||||
|
@ -199,9 +199,8 @@ int32_t buildRequest(uint64_t connId, const char* sql, int sqlLen, void* param,
|
|||
if (tsQueryUseNodeAllocator && !qIsInsertValuesSql((*pRequest)->sqlstr, (*pRequest)->sqlLen)) {
|
||||
if (TSDB_CODE_SUCCESS !=
|
||||
nodesCreateAllocator((*pRequest)->requestId, tsQueryNodeChunkSize, &((*pRequest)->allocatorRefId))) {
|
||||
tscError("%d failed to create node allocator, reqId:0x%" PRIx64 ", conn:%d, %s", (*pRequest)->self,
|
||||
(*pRequest)->requestId, pTscObj->id, sql);
|
||||
|
||||
tscError("%" PRId64 " failed to create node allocator, reqId:0x%" PRIx64 ", conn:%" PRId64 ", %s",
|
||||
(*pRequest)->self, (*pRequest)->requestId, pTscObj->id, sql);
|
||||
destroyRequest(*pRequest);
|
||||
*pRequest = NULL;
|
||||
return TSDB_CODE_TSC_OUT_OF_MEMORY;
|
||||
|
@ -955,7 +954,12 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
|||
switch (pQuery->execMode) {
|
||||
case QUERY_EXEC_MODE_LOCAL:
|
||||
if (!pRequest->validateOnly) {
|
||||
code = execLocalCmd(pRequest, pQuery);
|
||||
if (NULL == pQuery->pRoot) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
code = terrno;
|
||||
} else {
|
||||
code = execLocalCmd(pRequest, pQuery);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case QUERY_EXEC_MODE_RPC:
|
||||
|
@ -997,7 +1001,7 @@ SRequestObj* launchQueryImpl(SRequestObj* pRequest, SQuery* pQuery, bool keepQue
|
|||
|
||||
handleQueryExecRsp(pRequest);
|
||||
|
||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
pRequest->code = terrno;
|
||||
}
|
||||
|
||||
|
@ -1035,39 +1039,39 @@ static int32_t asyncExecSchQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaDat
|
|||
SSqlCallbackWrapper* pWrapper) {
|
||||
pRequest->type = pQuery->msgType;
|
||||
|
||||
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
||||
SArray* pMnodeList = taosArrayInit(4, sizeof(SQueryNodeLoad));
|
||||
|
||||
SPlanContext cxt = {.queryId = pRequest->requestId,
|
||||
.acctId = pRequest->pTscObj->acctId,
|
||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||
.pAstRoot = pQuery->pRoot,
|
||||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo,
|
||||
.allocatorId = pRequest->allocatorRefId};
|
||||
.acctId = pRequest->pTscObj->acctId,
|
||||
.mgmtEpSet = getEpSet_s(&pRequest->pTscObj->pAppInfo->mgmtEp),
|
||||
.pAstRoot = pQuery->pRoot,
|
||||
.showRewrite = pQuery->showRewrite,
|
||||
.pMsg = pRequest->msgBuf,
|
||||
.msgLen = ERROR_MSG_BUF_DEFAULT_SIZE,
|
||||
.pUser = pRequest->pTscObj->user,
|
||||
.sysInfo = pRequest->pTscObj->sysInfo,
|
||||
.allocatorId = pRequest->allocatorRefId};
|
||||
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
SQueryPlan* pDag = NULL;
|
||||
SAppInstInfo* pAppInfo = getAppInfo(pRequest);
|
||||
SQueryPlan* pDag = NULL;
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
int32_t code = qCreateQueryPlan(&cxt, &pDag, pMnodeList);
|
||||
if (code) {
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
pRequest->body.subplanNum = pDag->numOfSubplans;
|
||||
}
|
||||
if (code) {
|
||||
tscError("0x%" PRIx64 " failed to create query plan, code:%s 0x%" PRIx64, pRequest->self, tstrerror(code),
|
||||
pRequest->requestId);
|
||||
} else {
|
||||
pRequest->body.subplanNum = pDag->numOfSubplans;
|
||||
}
|
||||
|
||||
pRequest->metric.planEnd = taosGetTimestampUs();
|
||||
pRequest->metric.planEnd = taosGetTimestampUs();
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
tscDebug("0x%" PRIx64 " create query plan success, elapsed time:%.2f ms, 0x%" PRIx64, pRequest->self,
|
||||
(pRequest->metric.planEnd - st)/1000.0, pRequest->requestId);
|
||||
(pRequest->metric.planEnd - st) / 1000.0, pRequest->requestId);
|
||||
}
|
||||
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||
SArray* pNodeList = NULL;
|
||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||
if (TSDB_CODE_SUCCESS == code && !pRequest->validateOnly) {
|
||||
SArray* pNodeList = NULL;
|
||||
buildAsyncExecNodeList(pRequest, &pNodeList, pMnodeList, pResultMeta);
|
||||
|
||||
SRequestConnInfo conn = {.pTrans = getAppInfo(pRequest)->pTransporter,
|
||||
.requestId = pRequest->requestId,
|
||||
|
@ -1130,7 +1134,8 @@ void launchAsyncQuery(SRequestObj* pRequest, SQuery* pQuery, SMetaData* pResultM
|
|||
break;
|
||||
}
|
||||
|
||||
if (NULL != pRequest && TSDB_CODE_SUCCESS != code) {
|
||||
// TODO weired responding code?
|
||||
if (TSDB_CODE_SUCCESS != code) {
|
||||
pRequest->code = terrno;
|
||||
}
|
||||
}
|
||||
|
@ -2253,7 +2258,10 @@ void syncQueryFn(void* param, void* res, int32_t code) {
|
|||
void taosAsyncQueryImpl(uint64_t connId, const char* sql, __taos_async_fn_t fp, void* param, bool validateOnly) {
|
||||
if (sql == NULL || NULL == fp) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
fp(param, NULL, terrno);
|
||||
if (fp) {
|
||||
fp(param, NULL, terrno);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -944,7 +944,6 @@ void taos_fetch_rows_a(TAOS_RES *res, __taos_async_fn_t fp, void *param) {
|
|||
if (pResultInfo->completed) {
|
||||
// it is a local executed query, no need to do async fetch
|
||||
if (QUERY_EXEC_MODE_LOCAL == pRequest->body.execMode) {
|
||||
ASSERT(pResultInfo->numOfRows >= 0);
|
||||
if (pResultInfo->localResultFetched) {
|
||||
pResultInfo->numOfRows = 0;
|
||||
pResultInfo->current = 0;
|
||||
|
|
|
@ -194,6 +194,10 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
SUseDbRsp usedbRsp = {0};
|
||||
tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp);
|
||||
|
||||
if(strlen(usedbRsp.db) == 0){
|
||||
return TSDB_CODE_MND_DB_NOT_EXIST;
|
||||
}
|
||||
|
||||
SName name = {0};
|
||||
tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB);
|
||||
|
||||
|
@ -288,8 +292,10 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp);
|
||||
|
||||
struct SCatalog* pCatalog = NULL;
|
||||
catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||
int32_t code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
|
||||
if (TSDB_CODE_SUCCESS == code) {
|
||||
catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid);
|
||||
}
|
||||
}
|
||||
|
||||
taosMemoryFree(pMsg->pData);
|
||||
|
@ -393,6 +399,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
|
|||
size_t rspSize = sizeof(SRetrieveTableRsp) + blockGetEncodeSize(pBlock);
|
||||
*pRsp = taosMemoryCalloc(1, rspSize);
|
||||
if (NULL == *pRsp) {
|
||||
blockDataDestroy(pBlock);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@
|
|||
#define QUOTE '"'
|
||||
#define SLASH '\\'
|
||||
|
||||
#define JUMP_SPACE(sql) \
|
||||
while (*sql != '\0') { \
|
||||
#define JUMP_SPACE(sql, sqlEnd) \
|
||||
while (sql < sqlEnd) { \
|
||||
if (*sql == SPACE) \
|
||||
sql++; \
|
||||
else \
|
||||
|
@ -917,16 +917,17 @@ static int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
}
|
||||
|
||||
static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSmlMsgBuf *msg) {
|
||||
static int32_t smlParseInfluxString(const char *sql, const char *sqlEnd, SSmlLineInfo *elements, SSmlMsgBuf *msg) {
|
||||
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
||||
JUMP_SPACE(sql)
|
||||
JUMP_SPACE(sql, sqlEnd)
|
||||
if (*sql == COMMA) return TSDB_CODE_SML_INVALID_DATA;
|
||||
elements->measure = sql;
|
||||
|
||||
// parse measure
|
||||
while (*sql != '\0') {
|
||||
while (sql < sqlEnd) {
|
||||
if ((sql != elements->measure) && IS_SLASH_LETTER(sql)) {
|
||||
MOVE_FORWARD_ONE(sql, strlen(sql) + 1);
|
||||
MOVE_FORWARD_ONE(sql, sqlEnd - sql);
|
||||
sqlEnd--;
|
||||
continue;
|
||||
}
|
||||
if (IS_COMMA(sql)) {
|
||||
|
@ -950,7 +951,7 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
|||
} else {
|
||||
if (*sql == COMMA) sql++;
|
||||
elements->tags = sql;
|
||||
while (*sql != '\0') {
|
||||
while (sql < sqlEnd) {
|
||||
if (IS_SPACE(sql)) {
|
||||
break;
|
||||
}
|
||||
|
@ -961,10 +962,10 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
|||
elements->measureTagsLen = sql - elements->measure;
|
||||
|
||||
// parse cols
|
||||
JUMP_SPACE(sql)
|
||||
JUMP_SPACE(sql, sqlEnd)
|
||||
elements->cols = sql;
|
||||
bool isInQuote = false;
|
||||
while (*sql != '\0') {
|
||||
while (sql < sqlEnd) {
|
||||
if (IS_QUOTE(sql)) {
|
||||
isInQuote = !isInQuote;
|
||||
}
|
||||
|
@ -984,10 +985,10 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
|||
}
|
||||
|
||||
// parse timestamp
|
||||
JUMP_SPACE(sql)
|
||||
JUMP_SPACE(sql, sqlEnd)
|
||||
elements->timestamp = sql;
|
||||
while (*sql != '\0') {
|
||||
if (*sql == SPACE) {
|
||||
while (sql < sqlEnd) {
|
||||
if (isspace(*sql)) {
|
||||
break;
|
||||
}
|
||||
sql++;
|
||||
|
@ -997,8 +998,8 @@ static int32_t smlParseInfluxString(const char *sql, SSmlLineInfo *elements, SSm
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static void smlParseTelnetElement(const char **sql, const char **data, int32_t *len) {
|
||||
while (**sql != '\0') {
|
||||
static void smlParseTelnetElement(const char **sql, const char *sqlEnd, const char **data, int32_t *len) {
|
||||
while (*sql < sqlEnd) {
|
||||
if (**sql != SPACE && !(*data)) {
|
||||
*data = *sql;
|
||||
} else if (**sql == SPACE && *data) {
|
||||
|
@ -1009,20 +1010,20 @@ static void smlParseTelnetElement(const char **sql, const char **data, int32_t *
|
|||
}
|
||||
}
|
||||
|
||||
static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTableName, SHashObj *dumplicateKey,
|
||||
static int32_t smlParseTelnetTags(const char *data, const char *sqlEnd, SArray *cols, char *childTableName, SHashObj *dumplicateKey,
|
||||
SSmlMsgBuf *msg) {
|
||||
if(!cols) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
const char *sql = data;
|
||||
size_t childTableNameLen = strlen(tsSmlChildTableName);
|
||||
while (*sql != '\0') {
|
||||
JUMP_SPACE(sql)
|
||||
while (sql < sqlEnd) {
|
||||
JUMP_SPACE(sql, sqlEnd)
|
||||
if (*sql == '\0') break;
|
||||
|
||||
const char *key = sql;
|
||||
int32_t keyLen = 0;
|
||||
|
||||
// parse key
|
||||
while (*sql != '\0') {
|
||||
while (sql < sqlEnd) {
|
||||
if (*sql == SPACE) {
|
||||
smlBuildInvalidDataMsg(msg, "invalid data", sql);
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
|
@ -1047,7 +1048,7 @@ static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTab
|
|||
// parse value
|
||||
const char *value = sql;
|
||||
int32_t valueLen = 0;
|
||||
while (*sql != '\0') {
|
||||
while (sql < sqlEnd) {
|
||||
// parse value
|
||||
if (*sql == SPACE) {
|
||||
break;
|
||||
|
@ -1092,11 +1093,11 @@ static int32_t smlParseTelnetTags(const char *data, SArray *cols, char *childTab
|
|||
}
|
||||
|
||||
// format: <metric> <timestamp> <value> <tagk_1>=<tagv_1>[ <tagk_n>=<tagv_n>]
|
||||
static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTableInfo *tinfo, SArray *cols) {
|
||||
static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, const char *sqlEnd, SSmlTableInfo *tinfo, SArray *cols) {
|
||||
if (!sql) return TSDB_CODE_SML_INVALID_DATA;
|
||||
|
||||
// parse metric
|
||||
smlParseTelnetElement(&sql, &tinfo->sTableName, &tinfo->sTableNameLen);
|
||||
smlParseTelnetElement(&sql, sqlEnd, &tinfo->sTableName, &tinfo->sTableNameLen);
|
||||
if (!(tinfo->sTableName) || IS_INVALID_TABLE_LEN(tinfo->sTableNameLen)) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||
return TSDB_CODE_TSC_INVALID_TABLE_ID_LENGTH;
|
||||
|
@ -1105,7 +1106,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
|||
// parse timestamp
|
||||
const char *timestamp = NULL;
|
||||
int32_t tLen = 0;
|
||||
smlParseTelnetElement(&sql, ×tamp, &tLen);
|
||||
smlParseTelnetElement(&sql, sqlEnd, ×tamp, &tLen);
|
||||
if (!timestamp || tLen == 0) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid timestamp", sql);
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
|
@ -1120,7 +1121,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
|||
// parse value
|
||||
const char *value = NULL;
|
||||
int32_t valueLen = 0;
|
||||
smlParseTelnetElement(&sql, &value, &valueLen);
|
||||
smlParseTelnetElement(&sql, sqlEnd, &value, &valueLen);
|
||||
if (!value || valueLen == 0) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", sql);
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
|
@ -1138,7 +1139,7 @@ static int32_t smlParseTelnetString(SSmlHandle *info, const char *sql, SSmlTable
|
|||
}
|
||||
|
||||
// parse tags
|
||||
ret = smlParseTelnetTags(sql, tinfo->tags, tinfo->childTableName, info->dumplicateKey, &info->msgBuf);
|
||||
ret = smlParseTelnetTags(sql, sqlEnd, tinfo->tags, tinfo->childTableName, info->dumplicateKey, &info->msgBuf);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||
return ret;
|
||||
|
@ -1371,8 +1372,14 @@ static int32_t smlKvTimeArrayCompare(const void *key1, const void *key2) {
|
|||
static int32_t smlKvTimeHashCompare(const void *key1, const void *key2) {
|
||||
SHashObj *s1 = *(SHashObj **)key1;
|
||||
SHashObj *s2 = *(SHashObj **)key2;
|
||||
SSmlKv *kv1 = *(SSmlKv **)taosHashGet(s1, TS, TS_LEN);
|
||||
SSmlKv *kv2 = *(SSmlKv **)taosHashGet(s2, TS, TS_LEN);
|
||||
SSmlKv **kv1pp = (SSmlKv **)taosHashGet(s1, TS, TS_LEN);
|
||||
SSmlKv **kv2pp = (SSmlKv **)taosHashGet(s2, TS, TS_LEN);
|
||||
if(!kv1pp || !kv2pp){
|
||||
uError("smlKvTimeHashCompare kv is null");
|
||||
return -1;
|
||||
}
|
||||
SSmlKv *kv1 = *kv1pp;
|
||||
SSmlKv *kv2 = *kv2pp;
|
||||
if(!kv1 || kv1->type != TSDB_DATA_TYPE_TIMESTAMP){
|
||||
uError("smlKvTimeHashCompare kv1");
|
||||
return -1;
|
||||
|
@ -2073,11 +2080,11 @@ static int32_t smlParseJSONString(SSmlHandle *info, cJSON *root, SSmlTableInfo *
|
|||
}
|
||||
/************* TSDB_SML_JSON_PROTOCOL function end **************/
|
||||
|
||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
||||
static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql, const int len) {
|
||||
SSmlLineInfo elements = {0};
|
||||
uDebug("SML:0x%" PRIx64 " smlParseInfluxLine sql:%s, hello", info->id, sql);
|
||||
|
||||
int ret = smlParseInfluxString(sql, &elements, &info->msgBuf);
|
||||
int ret = smlParseInfluxString(sql, sql + len, &elements, &info->msgBuf);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlParseInfluxLine failed", info->id);
|
||||
return ret;
|
||||
|
@ -2184,7 +2191,7 @@ static int32_t smlParseInfluxLine(SSmlHandle *info, const char *sql) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) {
|
||||
static int32_t smlParseTelnetLine(SSmlHandle *info, void *data, const int len) {
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
SSmlTableInfo *tinfo = smlBuildTableInfo();
|
||||
if (!tinfo) {
|
||||
|
@ -2198,7 +2205,7 @@ static int32_t smlParseTelnetLine(SSmlHandle *info, void *data) {
|
|||
}
|
||||
|
||||
if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||
ret = smlParseTelnetString(info, (const char *)data, tinfo, cols);
|
||||
ret = smlParseTelnetString(info, (const char *)data, (char*)data + len, tinfo, cols);
|
||||
} else if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
||||
ret = smlParseJSONString(info, (cJSON *)data, tinfo, cols);
|
||||
} else {
|
||||
|
@ -2289,7 +2296,7 @@ static int32_t smlParseJSON(SSmlHandle *info, char *payload) {
|
|||
|
||||
for (int32_t i = 0; i < payloadNum; ++i) {
|
||||
cJSON *dataPoint = (payloadNum == 1 && cJSON_IsObject(root)) ? root : cJSON_GetArrayItem(root, i);
|
||||
ret = smlParseTelnetLine(info, dataPoint);
|
||||
ret = smlParseTelnetLine(info, dataPoint, -1);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " Invalid JSON Payload", info->id);
|
||||
goto end;
|
||||
|
@ -2378,10 +2385,14 @@ static void smlPrintStatisticInfo(SSmlHandle *info) {
|
|||
info->cost.endTime - info->cost.insertRpcTime, info->cost.endTime - info->cost.parseTime);
|
||||
}
|
||||
|
||||
static int32_t smlParseLine(SSmlHandle *info, char *lines[], int numLines) {
|
||||
static int32_t smlParseLine(SSmlHandle *info, char *lines[], char* rawLine, char* rawLineEnd, int numLines) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (info->protocol == TSDB_SML_JSON_PROTOCOL) {
|
||||
code = smlParseJSON(info, *lines);
|
||||
if(lines){
|
||||
code = smlParseJSON(info, *lines);
|
||||
}else if(rawLine){
|
||||
code = smlParseJSON(info, rawLine);
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlParseJSON failed:%s", info->id, *lines);
|
||||
return code;
|
||||
|
@ -2390,28 +2401,46 @@ static int32_t smlParseLine(SSmlHandle *info, char *lines[], int numLines) {
|
|||
}
|
||||
|
||||
for (int32_t i = 0; i < numLines; ++i) {
|
||||
char *tmp = NULL;
|
||||
int len = 0;
|
||||
if(lines){
|
||||
tmp = lines[i];
|
||||
len = strlen(tmp);
|
||||
}else if(rawLine){
|
||||
tmp = rawLine;
|
||||
while(rawLine < rawLineEnd){
|
||||
if(*(rawLine++) == '\n'){
|
||||
break;
|
||||
}
|
||||
len++;
|
||||
}
|
||||
if(info->protocol == TSDB_SML_LINE_PROTOCOL && tmp[0] == '#'){ // this line is comment
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (info->protocol == TSDB_SML_LINE_PROTOCOL) {
|
||||
code = smlParseInfluxLine(info, lines[i]);
|
||||
code = smlParseInfluxLine(info, tmp, len);
|
||||
} else if (info->protocol == TSDB_SML_TELNET_PROTOCOL) {
|
||||
code = smlParseTelnetLine(info, lines[i]);
|
||||
code = smlParseTelnetLine(info, tmp, len);
|
||||
} else {
|
||||
ASSERT(0);
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, lines[i]);
|
||||
uError("SML:0x%" PRIx64 " smlParseLine failed. line %d : %s", info->id, i, tmp);
|
||||
return code;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int smlProcess(SSmlHandle *info, char *lines[], int numLines) {
|
||||
static int smlProcess(SSmlHandle *info, char *lines[], char* rawLine, char* rawLineEnd, int numLines) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
int32_t retryNum = 0;
|
||||
|
||||
info->cost.parseTime = taosGetTimestampUs();
|
||||
|
||||
code = smlParseLine(info, lines, numLines);
|
||||
code = smlParseLine(info, lines, rawLine, rawLineEnd, numLines);
|
||||
if (code != 0) {
|
||||
uError("SML:0x%" PRIx64 " smlParseLine error : %s", info->id, tstrerror(code));
|
||||
return code;
|
||||
|
@ -2504,39 +2533,8 @@ static void smlInsertCallback(void *param, void *res, int32_t code) {
|
|||
smlDestroyInfo(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* taos_schemaless_insert() parse and insert data points into database according to
|
||||
* different protocol.
|
||||
*
|
||||
* @param $lines input array may contain multiple lines, each line indicates a data point.
|
||||
* If protocol=2 is used input array should contain single JSON
|
||||
* string(e.g. char *lines[] = {"$JSON_string"}). If need to insert
|
||||
* multiple data points in JSON format, should include them in $JSON_string
|
||||
* as a JSON array.
|
||||
* @param $numLines indicates how many data points in $lines.
|
||||
* If protocol = 2 is used this param will be ignored as $lines should
|
||||
* contain single JSON string.
|
||||
* @param $protocol indicates which protocol to use for parsing:
|
||||
* 0 - influxDB line protocol
|
||||
* 1 - OpenTSDB telnet line protocol
|
||||
* 2 - OpenTSDB JSON format protocol
|
||||
* @return return zero for successful insertion. Otherwise return none-zero error code of
|
||||
* failure reason.
|
||||
*
|
||||
*/
|
||||
|
||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_inner(SRequestObj *request, char *lines[], char *rawLine, char *rawLineEnd, int numLines, int protocol, int precision) {
|
||||
int batchs = 0;
|
||||
STscObj *pTscObj = request->pTscObj;
|
||||
|
||||
|
@ -2560,12 +2558,6 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
|||
goto end;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (protocol < TSDB_SML_LINE_PROTOCOL || protocol > TSDB_SML_JSON_PROTOCOL) {
|
||||
request->code = TSDB_CODE_SML_INVALID_PROTOCOL_TYPE;
|
||||
smlBuildInvalidDataMsg(&msg, "protocol invalidate", NULL);
|
||||
|
@ -2616,15 +2608,28 @@ TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int pr
|
|||
info->affectedRows = perBatch;
|
||||
info->pRequest->body.queryFp = smlInsertCallback;
|
||||
info->pRequest->body.param = info;
|
||||
int32_t code = smlProcess(info, lines, perBatch);
|
||||
lines += perBatch;
|
||||
int32_t code = smlProcess(info, lines, rawLine, rawLineEnd, perBatch);
|
||||
if(lines){
|
||||
lines += perBatch;
|
||||
}
|
||||
if(rawLine){
|
||||
int num = 0;
|
||||
while(rawLine < rawLineEnd){
|
||||
if(*(rawLine++) == '\n'){
|
||||
num++;
|
||||
}
|
||||
if(num == perBatch){
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
info->pRequest->body.queryFp(info, req, code);
|
||||
}
|
||||
}
|
||||
tsem_wait(¶ms.sem);
|
||||
|
||||
end:
|
||||
end:
|
||||
taosThreadSpinDestroy(¶ms.lock);
|
||||
tsem_destroy(¶ms.sem);
|
||||
// ((STscObj *)taos)->schemalessType = 0;
|
||||
|
@ -2632,3 +2637,80 @@ end:
|
|||
uDebug("resultend:%s", request->msgBuf);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
/**
|
||||
* taos_schemaless_insert() parse and insert data points into database according to
|
||||
* different protocol.
|
||||
*
|
||||
* @param $lines input array may contain multiple lines, each line indicates a data point.
|
||||
* If protocol=2 is used input array should contain single JSON
|
||||
* string(e.g. char *lines[] = {"$JSON_string"}). If need to insert
|
||||
* multiple data points in JSON format, should include them in $JSON_string
|
||||
* as a JSON array.
|
||||
* @param $numLines indicates how many data points in $lines.
|
||||
* If protocol = 2 is used this param will be ignored as $lines should
|
||||
* contain single JSON string.
|
||||
* @param $protocol indicates which protocol to use for parsing:
|
||||
* 0 - influxDB line protocol
|
||||
* 1 - OpenTSDB telnet line protocol
|
||||
* 2 - OpenTSDB JSON format protocol
|
||||
* @return return zero for successful insertion. Otherwise return none-zero error code of
|
||||
* failure reason.
|
||||
*
|
||||
*/
|
||||
|
||||
TAOS_RES *taos_schemaless_insert(TAOS *taos, char *lines[], int numLines, int protocol, int precision) {
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
return taos_schemaless_insert_inner(request, lines, NULL, NULL, numLines, protocol, precision);
|
||||
}
|
||||
|
||||
TAOS_RES *taos_schemaless_insert_raw(TAOS* taos, char* lines, int len, int32_t *totalRows, int protocol, int precision){
|
||||
if (NULL == taos) {
|
||||
terrno = TSDB_CODE_TSC_DISCONNECTED;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SRequestObj *request = (SRequestObj *)createRequest(*(int64_t *)taos, TSDB_SQL_INSERT);
|
||||
if (!request) {
|
||||
uError("SML:taos_schemaless_insert error request is null");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lines || len <= 0) {
|
||||
SSmlMsgBuf msg = {ERROR_MSG_BUF_DEFAULT_SIZE, request->msgBuf};
|
||||
request->code = TSDB_CODE_SML_INVALID_DATA;
|
||||
smlBuildInvalidDataMsg(&msg, "lines is null", NULL);
|
||||
return (TAOS_RES *)request;
|
||||
}
|
||||
|
||||
int numLines = 0;
|
||||
*totalRows = 0;
|
||||
char *tmp = lines;
|
||||
for(int i = 0; i < len; i++){
|
||||
if(lines[i] == '\n' || i == len - 1){
|
||||
numLines++;
|
||||
if(tmp[0] != '#' || protocol != TSDB_SML_LINE_PROTOCOL){ //ignore comment
|
||||
(*totalRows)++;
|
||||
}
|
||||
tmp = lines + i + 1;
|
||||
}
|
||||
}
|
||||
return taos_schemaless_insert_inner(request, NULL, lines, lines + len, numLines, protocol, precision);
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags,
|
|||
pStmt->bInfo.tbType = pTableMeta->tableType;
|
||||
pStmt->bInfo.boundTags = tags;
|
||||
pStmt->bInfo.tagsCached = false;
|
||||
strcpy(pStmt->bInfo.stbFName, sTableName);
|
||||
tstrncpy(pStmt->bInfo.stbFName, sTableName, sizeof(pStmt->bInfo.stbFName));
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
|
|
@ -210,6 +210,8 @@ typedef struct {
|
|||
typedef struct {
|
||||
SMqCommitCbParamSet* params;
|
||||
STqOffset* pOffset;
|
||||
/*char topicName[TSDB_TOPIC_FNAME_LEN];*/
|
||||
/*int32_t vgId;*/
|
||||
} SMqCommitCbParam;
|
||||
|
||||
tmq_conf_t* tmq_conf_new() {
|
||||
|
@ -407,6 +409,14 @@ int32_t tmqCommitDone(SMqCommitCbParamSet* pParamSet) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void tmqCommitRspCountDown(SMqCommitCbParamSet* pParamSet) {
|
||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||
ASSERT(waitingRspNum >= 0);
|
||||
if (waitingRspNum == 0) {
|
||||
tmqCommitDone(pParamSet);
|
||||
}
|
||||
}
|
||||
|
||||
int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) {
|
||||
SMqCommitCbParam* pParam = (SMqCommitCbParam*)param;
|
||||
SMqCommitCbParamSet* pParamSet = (SMqCommitCbParamSet*)pParam->params;
|
||||
|
@ -420,18 +430,13 @@ int32_t tmqCommitCb(void* param, SDataBuf* pBuf, int32_t code) {
|
|||
#endif
|
||||
|
||||
taosMemoryFree(pParam->pOffset);
|
||||
if (pBuf->pData) taosMemoryFree(pBuf->pData);
|
||||
taosMemoryFree(pBuf->pData);
|
||||
|
||||
/*tscDebug("receive offset commit cb of %s on vgId:%d, offset is %" PRId64, pParam->pOffset->subKey, pParam->->vgId,
|
||||
* pOffset->version);*/
|
||||
|
||||
// count down waiting rsp
|
||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||
ASSERT(waitingRspNum >= 0);
|
||||
tmqCommitRspCountDown(pParamSet);
|
||||
|
||||
if (waitingRspNum == 0) {
|
||||
tmqCommitDone(pParamSet);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -455,7 +460,10 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
return -1;
|
||||
}
|
||||
void* buf = taosMemoryCalloc(1, sizeof(SMsgHead) + len);
|
||||
if (buf == NULL) return -1;
|
||||
if (buf == NULL) {
|
||||
taosMemoryFree(pOffset);
|
||||
return -1;
|
||||
}
|
||||
((SMsgHead*)buf)->vgId = htonl(pVg->vgId);
|
||||
|
||||
void* abuf = POINTER_SHIFT(buf, sizeof(SMsgHead));
|
||||
|
@ -468,6 +476,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
// build param
|
||||
SMqCommitCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqCommitCbParam));
|
||||
if (pParam == NULL) {
|
||||
taosMemoryFree(pOffset);
|
||||
taosMemoryFree(buf);
|
||||
return -1;
|
||||
}
|
||||
|
@ -477,6 +486,7 @@ static int32_t tmqSendCommitReq(tmq_t* tmq, SMqClientVg* pVg, SMqClientTopic* pT
|
|||
// build send info
|
||||
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (pMsgSendInfo == NULL) {
|
||||
taosMemoryFree(pOffset);
|
||||
taosMemoryFree(buf);
|
||||
taosMemoryFree(pParam);
|
||||
return -1;
|
||||
|
@ -586,14 +596,10 @@ FAIL:
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
||||
void* userParam) {
|
||||
static int32_t tmqCommitConsumerImpl(tmq_t* tmq, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
||||
void* userParam) {
|
||||
int32_t code = -1;
|
||||
|
||||
if (msg != NULL) {
|
||||
return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam);
|
||||
}
|
||||
|
||||
SMqCommitCbParamSet* pParamSet = taosMemoryCalloc(1, sizeof(SMqCommitCbParamSet));
|
||||
if (pParamSet == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -641,33 +647,37 @@ int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t
|
|||
}
|
||||
}
|
||||
|
||||
// no request is sent
|
||||
if (pParamSet->totalRspNum == 0) {
|
||||
tsem_destroy(&pParamSet->rspSem);
|
||||
taosMemoryFree(pParamSet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t waitingRspNum = atomic_sub_fetch_32(&pParamSet->waitingRspNum, 1);
|
||||
ASSERT(waitingRspNum >= 0);
|
||||
if (waitingRspNum == 0) {
|
||||
tmqCommitDone(pParamSet);
|
||||
}
|
||||
// count down since waiting rsp num init as 1
|
||||
tmqCommitRspCountDown(pParamSet);
|
||||
|
||||
if (!async) {
|
||||
tsem_wait(&pParamSet->rspSem);
|
||||
code = pParamSet->rspErr;
|
||||
tsem_destroy(&pParamSet->rspSem);
|
||||
taosMemoryFree(pParamSet);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (!async) {
|
||||
taosArrayDestroyP(pParamSet->successfulOffsets, taosMemoryFree);
|
||||
taosArrayDestroyP(pParamSet->failedOffsets, taosMemoryFree);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return 0;
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tmqCommitInner(tmq_t* tmq, const TAOS_RES* msg, int8_t automatic, int8_t async, tmq_commit_cb* userCb,
|
||||
void* userParam) {
|
||||
if (msg) {
|
||||
return tmqCommitMsgImpl(tmq, msg, async, userCb, userParam);
|
||||
} else {
|
||||
return tmqCommitConsumerImpl(tmq, automatic, async, userCb, userParam);
|
||||
}
|
||||
}
|
||||
|
||||
void tmqAssignAskEpTask(void* param, void* tmrId) {
|
||||
|
|
|
@ -44,7 +44,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
char *tmp = "\\,st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ,32,c=3";
|
||||
char *sql = (char *)taosMemoryCalloc(256, 1);
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
int ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
int ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(elements.measure, sql);
|
||||
ASSERT_EQ(elements.measureLen, strlen(",st"));
|
||||
|
@ -63,14 +63,14 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
tmp = "st,t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_NE(ret, 0);
|
||||
|
||||
// case 3 false
|
||||
tmp = "st, t1=3,t2=4,t3=t3 c1=3i64,c3=\"passit hello,c1=2,c2=false,c4=4f64 1626006833639000000";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(elements.cols, sql + elements.measureTagsLen + 1);
|
||||
ASSERT_EQ(elements.colsLen, strlen("t1=3,t2=4,t3=t3"));
|
||||
|
@ -79,7 +79,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
tmp = "st, c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(elements.measure, sql);
|
||||
ASSERT_EQ(elements.measureLen, strlen("st"));
|
||||
|
@ -98,7 +98,7 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 1626006833639000000 ";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
ASSERT_EQ(elements.measure, sql + 1);
|
||||
ASSERT_EQ(elements.measureLen, strlen("st"));
|
||||
|
@ -116,21 +116,21 @@ TEST(testCase, smlParseInfluxString_Test) {
|
|||
tmp = " st c1=3i64,c3=\"passit hello,c1=2\",c2=false,c4=4f64 ";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// case 7
|
||||
tmp = " st , ";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_EQ(ret, 0);
|
||||
|
||||
// case 8 false
|
||||
tmp = ", st , ";
|
||||
memcpy(sql, tmp, strlen(tmp) + 1);
|
||||
memset(&elements, 0, sizeof(SSmlLineInfo));
|
||||
ret = smlParseInfluxString(sql, &elements, &msgBuf);
|
||||
ret = smlParseInfluxString(sql, sql + strlen(sql), &elements, &msgBuf);
|
||||
ASSERT_NE(ret, 0);
|
||||
taosMemoryFree(sql);
|
||||
}
|
||||
|
@ -542,7 +542,7 @@ TEST(testCase, smlParseTelnetLine_error_Test) {
|
|||
"sys.procs.running 1479496100 42 host= web01",
|
||||
};
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
int ret = smlParseTelnetLine(info, (void *)sql[i]);
|
||||
int ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||
ASSERT_NE(ret, 0);
|
||||
}
|
||||
|
||||
|
@ -561,7 +561,7 @@ TEST(testCase, smlParseTelnetLine_diff_type_Test) {
|
|||
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||
if (ret != TSDB_CODE_SUCCESS) break;
|
||||
}
|
||||
ASSERT_NE(ret, 0);
|
||||
|
@ -617,7 +617,7 @@ TEST(testCase, smlParseTelnetLine_json_error_Test) {
|
|||
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||
ASSERT_NE(ret, 0);
|
||||
}
|
||||
|
||||
|
@ -653,7 +653,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type1_Test) {
|
|||
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||
if (ret != TSDB_CODE_SUCCESS) break;
|
||||
}
|
||||
ASSERT_NE(ret, 0);
|
||||
|
@ -688,7 +688,7 @@ TEST(testCase, smlParseTelnetLine_diff_json_type2_Test) {
|
|||
};
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i]);
|
||||
ret = smlParseTelnetLine(info, (void *)sql[i], strlen(sql[i]));
|
||||
if (ret != TSDB_CODE_SUCCESS) break;
|
||||
}
|
||||
ASSERT_NE(ret, 0);
|
||||
|
@ -1002,7 +1002,7 @@ TEST(testCase, sml_col_4096_Test) {
|
|||
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < sizeof(sql) / sizeof(sql[0]); i++) {
|
||||
ret = smlParseInfluxLine(info, sql[i]);
|
||||
ret = smlParseInfluxLine(info, sql[i], strlen(sql[i]));
|
||||
if (ret != TSDB_CODE_SUCCESS) break;
|
||||
}
|
||||
ASSERT_NE(ret, 0);
|
||||
|
|
|
@ -62,12 +62,6 @@ static const SSysDbTableSchema snodesSchema[] = {
|
|||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema bnodesSchema[] = {
|
||||
{.name = "id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = true},
|
||||
{.name = "endpoint", .bytes = TSDB_EP_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
{.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = true},
|
||||
};
|
||||
|
||||
static const SSysDbTableSchema clusterSchema[] = {
|
||||
{.name = "id", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = true},
|
||||
{.name = "name", .bytes = TSDB_CLUSTER_ID_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
|
||||
|
@ -277,7 +271,6 @@ static const SSysTableMeta infosMeta[] = {
|
|||
{TSDB_INS_TABLE_MODULES, modulesSchema, tListLen(modulesSchema), true},
|
||||
{TSDB_INS_TABLE_QNODES, qnodesSchema, tListLen(qnodesSchema), true},
|
||||
// {TSDB_INS_TABLE_SNODES, snodesSchema, tListLen(snodesSchema)},
|
||||
// {TSDB_INS_TABLE_BNODES, bnodesSchema, tListLen(bnodesSchema)},
|
||||
{TSDB_INS_TABLE_CLUSTER, clusterSchema, tListLen(clusterSchema), true},
|
||||
{TSDB_INS_TABLE_DATABASES, userDBSchema, tListLen(userDBSchema), false},
|
||||
{TSDB_INS_TABLE_FUNCTIONS, userFuncSchema, tListLen(userFuncSchema), false},
|
||||
|
|
|
@ -1892,12 +1892,13 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
|
||||
for (int32_t k = 0; k < colNum; k++) {
|
||||
SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, k);
|
||||
void* var = POINTER_SHIFT(pColInfoData->pData, j * pColInfoData->info.bytes);
|
||||
if (colDataIsNull(pColInfoData, rows, j, NULL) || !pColInfoData->pData) {
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", "NULL");
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
continue;
|
||||
}
|
||||
|
||||
void* var = colDataGetData(pColInfoData, j);
|
||||
switch (pColInfoData->info.type) {
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
memset(pBuf, 0, sizeof(pBuf));
|
||||
|
@ -1926,8 +1927,8 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15lf |", *(double*)var);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
// len += snprintf(dumpBuf + len, size - len, " %15lf |", *(double*)var);
|
||||
// if (len >= size - 1) return dumpBuf;
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += snprintf(dumpBuf + len, size - len, " %15d |", *(bool*)var);
|
||||
|
|
|
@ -114,7 +114,7 @@ static void setBitMap(uint8_t *pb, uint8_t v, int32_t idx, uint8_t flags) {
|
|||
((uint32_t *)(p))[i] = (n); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#if 0
|
||||
int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, STSRow2 **ppRow) {
|
||||
int32_t code = 0;
|
||||
#if 0
|
||||
|
@ -432,7 +432,6 @@ void tTSRowFree(STSRow2 *pRow) {
|
|||
}
|
||||
|
||||
void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal) {
|
||||
#if 0
|
||||
uint8_t isTuple = ((pRow->flags & 0xf0) == 0) ? 1 : 0;
|
||||
STColumn *pTColumn = &pTSchema->columns[iCol];
|
||||
uint8_t flags = pRow->flags & (uint8_t)0xf;
|
||||
|
@ -577,12 +576,10 @@ _return_null:
|
|||
_return_value:
|
||||
*pColVal = COL_VAL_VALUE(pTColumn->colId, pTColumn->type, value);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray) {
|
||||
int32_t code = 0;
|
||||
#if 0
|
||||
SColVal cv;
|
||||
|
||||
(*ppArray) = taosArrayInit(pTSchema->numOfCols, sizeof(SColVal));
|
||||
|
@ -596,11 +593,11 @@ int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray) {
|
|||
taosArrayPush(*ppArray, &cv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
_exit:
|
||||
return code;
|
||||
}
|
||||
|
||||
#endif
|
||||
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow) {
|
||||
int32_t n = 0;
|
||||
|
||||
|
|
|
@ -40,15 +40,6 @@ int32_t tsMaxShellConns = 50000;
|
|||
int32_t tsShellActivityTimer = 3; // second
|
||||
bool tsPrintAuth = false;
|
||||
|
||||
// multi process
|
||||
int32_t tsMultiProcess = 0;
|
||||
int32_t tsMnodeShmSize = TSDB_MAX_MSG_SIZE * 2 + 1024;
|
||||
int32_t tsVnodeShmSize = TSDB_MAX_MSG_SIZE * 10 + 1024;
|
||||
int32_t tsQnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsSnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsBnodeShmSize = TSDB_MAX_MSG_SIZE * 4 + 1024;
|
||||
int32_t tsNumOfShmThreads = 1;
|
||||
|
||||
// queue & threads
|
||||
int32_t tsNumOfRpcThreads = 1;
|
||||
int32_t tsNumOfCommitThreads = 2;
|
||||
|
@ -353,14 +344,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) {
|
|||
if (cfgAddBool(pCfg, "printAuth", tsPrintAuth, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, 0) != 0) return -1;
|
||||
|
||||
if (cfgAddInt32(pCfg, "multiProcess", tsMultiProcess, 0, 2, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "mnodeShmSize", tsMnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "vnodeShmSize", tsVnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "qnodeShmSize", tsQnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "snodeShmSize", tsSnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "bnodeShmSize", tsBnodeShmSize, TSDB_MAX_MSG_SIZE * 2 + 1024, INT32_MAX, 0) != 0) return -1;
|
||||
if (cfgAddInt32(pCfg, "numOfShmThreads", tsNumOfShmThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
||||
tsNumOfRpcThreads = tsNumOfCores / 2;
|
||||
tsNumOfRpcThreads = TRANGE(tsNumOfRpcThreads, 1, 4);
|
||||
if (cfgAddInt32(pCfg, "numOfRpcThreads", tsNumOfRpcThreads, 1, 1024, 0) != 0) return -1;
|
||||
|
@ -700,15 +683,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) {
|
|||
tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32;
|
||||
tsPrintAuth = cfgGetItem(pCfg, "printAuth")->bval;
|
||||
|
||||
#if !defined(WINDOWS) && !defined(DARWIN)
|
||||
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||
#endif
|
||||
tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
|
||||
tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
|
||||
tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
|
||||
tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32;
|
||||
tsBnodeShmSize = cfgGetItem(pCfg, "bnodeShmSize")->i32;
|
||||
|
||||
tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32;
|
||||
tsNumOfCommitThreads = cfgGetItem(pCfg, "numOfCommitThreads")->i32;
|
||||
tsNumOfMnodeReadThreads = cfgGetItem(pCfg, "numOfMnodeReadThreads")->i32;
|
||||
|
@ -780,12 +754,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'b': {
|
||||
if (strcasecmp("bnodeShmSize", name) == 0) {
|
||||
tsBnodeShmSize = cfgGetItem(pCfg, "bnodeShmSize")->i32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'c': {
|
||||
if (strcasecmp("charset", name) == 0) {
|
||||
const char *locale = cfgGetItem(pCfg, "locale")->str;
|
||||
|
@ -912,12 +880,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 'n': {
|
||||
if (strcasecmp("mnodeShmSize", name) == 0) {
|
||||
tsMnodeShmSize = cfgGetItem(pCfg, "mnodeShmSize")->i32;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'o': {
|
||||
if (strcasecmp("monitor", name) == 0) {
|
||||
tsEnableMonitor = cfgGetItem(pCfg, "monitor")->bval;
|
||||
|
@ -941,11 +903,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
break;
|
||||
}
|
||||
case 'u': {
|
||||
if (strcasecmp("multiProcess", name) == 0) {
|
||||
#if !defined(WINDOWS) && !defined(DARWIN)
|
||||
tsMultiProcess = cfgGetItem(pCfg, "multiProcess")->bval;
|
||||
#endif
|
||||
} else if (strcasecmp("udfDebugFlag", name) == 0) {
|
||||
if (strcasecmp("udfDebugFlag", name) == 0) {
|
||||
udfDebugFlag = cfgGetItem(pCfg, "udfDebugFlag")->i32;
|
||||
}
|
||||
break;
|
||||
|
@ -1008,8 +966,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
if (tsQueryBufferSize >= 0) {
|
||||
tsQueryBufferSizeBytes = tsQueryBufferSize * 1048576UL;
|
||||
}
|
||||
} else if (strcasecmp("qnodeShmSize", name) == 0) {
|
||||
tsQnodeShmSize = cfgGetItem(pCfg, "qnodeShmSize")->i32;
|
||||
} else if (strcasecmp("qDebugFlag", name) == 0) {
|
||||
qDebugFlag = cfgGetItem(pCfg, "qDebugFlag")->i32;
|
||||
} else if (strcasecmp("queryPlannerTrace", name) == 0) {
|
||||
|
@ -1050,8 +1006,6 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
tsNumOfSupportVnodes = cfgGetItem(pCfg, "supportVnodes")->i32;
|
||||
} else if (strcasecmp("statusInterval", name) == 0) {
|
||||
tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32;
|
||||
} else if (strcasecmp("snodeShmSize", name) == 0) {
|
||||
tsSnodeShmSize = cfgGetItem(pCfg, "snodeShmSize")->i32;
|
||||
} else if (strcasecmp("serverPort", name) == 0) {
|
||||
tstrncpy(tsLocalFqdn, cfgGetItem(pCfg, "fqdn")->str, TSDB_FQDN_LEN);
|
||||
tsServerPort = (uint16_t)cfgGetItem(pCfg, "serverPort")->i32;
|
||||
|
@ -1119,9 +1073,7 @@ int32_t taosSetCfg(SConfig *pCfg, char *name) {
|
|||
break;
|
||||
}
|
||||
case 'v': {
|
||||
if (strcasecmp("vnodeShmSize", name) == 0) {
|
||||
tsVnodeShmSize = cfgGetItem(pCfg, "vnodeShmSize")->i32;
|
||||
} else if (strcasecmp("vDebugFlag", name) == 0) {
|
||||
if (strcasecmp("vDebugFlag", name) == 0) {
|
||||
vDebugFlag = cfgGetItem(pCfg, "vDebugFlag")->i32;
|
||||
}
|
||||
break;
|
||||
|
@ -1244,6 +1196,7 @@ int32_t taosInitCfg(const char *cfgDir, const char **envCmd, const char *envFile
|
|||
if (cfgLoadFromArray(tsCfg, pArgs) != 0) {
|
||||
uError("failed to load cfg from array since %s", terrstr());
|
||||
cfgCleanup(tsCfg);
|
||||
tsCfg = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1448,7 +1448,7 @@ void tFreeSGetUserAuthRsp(SGetUserAuthRsp *pRsp) {
|
|||
taosHashCleanup(pRsp->writeDbs);
|
||||
}
|
||||
|
||||
int32_t tSerializeSCreateDropMQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||
int32_t tSerializeSCreateDropMQSNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
|
||||
|
@ -1461,7 +1461,7 @@ int32_t tSerializeSCreateDropMQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnod
|
|||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSCreateDropMQSBNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||
int32_t tDeserializeSCreateDropMQSNodeReq(void *buf, int32_t bufLen, SMCreateQnodeReq *pReq) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, buf, bufLen);
|
||||
|
||||
|
|
|
@ -41,286 +41,6 @@ static bool tdSKvRowGetVal(STSRow *pRow, col_id_t colId, col_id_t colIdx, SCe
|
|||
static void tdSCellValPrint(SCellVal *pVal, int8_t colType);
|
||||
|
||||
// implementation
|
||||
/**
|
||||
* @brief Compress bitmap bytes comprised of 2-bits to counterpart of 1-bit.
|
||||
* e.g.
|
||||
* TD_VTYPE_NORM 0x00U(00000000) to 00000000 Normal
|
||||
* TD_VTYPE_NULL 0x01U(00000001) to 00000001 Null
|
||||
* TD_VTYPE_NONE 0x02U(00000010) to 00000001 Null
|
||||
*
|
||||
* 00000000 0x00 0x00
|
||||
* 01000000 0x40 0x08
|
||||
* 10000000 0x80 0x08
|
||||
* ...
|
||||
* @param byte
|
||||
* @return uint8_t
|
||||
*/
|
||||
static uint8_t tdGetMergedBitmapByte(uint8_t byte) {
|
||||
switch (byte) {
|
||||
case 0x00:
|
||||
return 0x00;
|
||||
case 0x40:
|
||||
return 0x08;
|
||||
case 0x80:
|
||||
return 0x08;
|
||||
case 0x10:
|
||||
return 0x04;
|
||||
case 0x50:
|
||||
return 0x0c;
|
||||
case 0x90:
|
||||
return 0x0c;
|
||||
case 0x20:
|
||||
return 0x04;
|
||||
case 0x60:
|
||||
return 0x0c;
|
||||
case 0xa0:
|
||||
return 0x0c;
|
||||
case 0x04:
|
||||
return 0x02;
|
||||
case 0x44:
|
||||
return 0x0a;
|
||||
case 0x84:
|
||||
return 0x0a;
|
||||
case 0x14:
|
||||
return 0x06;
|
||||
case 0x54:
|
||||
return 0x0e;
|
||||
case 0x94:
|
||||
return 0x0e;
|
||||
case 0x24:
|
||||
return 0x06;
|
||||
case 0x64:
|
||||
return 0x0e;
|
||||
case 0xa4:
|
||||
return 0x0e;
|
||||
case 0x08:
|
||||
return 0x02;
|
||||
case 0x48:
|
||||
return 0x0a;
|
||||
case 0x88:
|
||||
return 0x0a;
|
||||
case 0x18:
|
||||
return 0x06;
|
||||
case 0x58:
|
||||
return 0x0e;
|
||||
case 0x98:
|
||||
return 0x0e;
|
||||
case 0x28:
|
||||
return 0x06;
|
||||
case 0x68:
|
||||
return 0x0e;
|
||||
case 0xa8:
|
||||
return 0x0e;
|
||||
case 0x01:
|
||||
return 0x01;
|
||||
case 0x41:
|
||||
return 0x09;
|
||||
case 0x81:
|
||||
return 0x09;
|
||||
case 0x11:
|
||||
return 0x05;
|
||||
case 0x51:
|
||||
return 0x0d;
|
||||
case 0x91:
|
||||
return 0x0d;
|
||||
case 0x21:
|
||||
return 0x05;
|
||||
case 0x61:
|
||||
return 0x0d;
|
||||
case 0xa1:
|
||||
return 0x0d;
|
||||
case 0x05:
|
||||
return 0x03;
|
||||
case 0x45:
|
||||
return 0x0b;
|
||||
case 0x85:
|
||||
return 0x0b;
|
||||
case 0x15:
|
||||
return 0x07;
|
||||
case 0x55:
|
||||
return 0x0f;
|
||||
case 0x95:
|
||||
return 0x0f;
|
||||
case 0x25:
|
||||
return 0x07;
|
||||
case 0x65:
|
||||
return 0x0f;
|
||||
case 0xa5:
|
||||
return 0x0f;
|
||||
case 0x09:
|
||||
return 0x03;
|
||||
case 0x49:
|
||||
return 0x0b;
|
||||
case 0x89:
|
||||
return 0x0b;
|
||||
case 0x19:
|
||||
return 0x07;
|
||||
case 0x59:
|
||||
return 0x0f;
|
||||
case 0x99:
|
||||
return 0x0f;
|
||||
case 0x29:
|
||||
return 0x07;
|
||||
case 0x69:
|
||||
return 0x0f;
|
||||
case 0xa9:
|
||||
return 0x0f;
|
||||
case 0x02:
|
||||
return 0x01;
|
||||
case 0x42:
|
||||
return 0x09;
|
||||
case 0x82:
|
||||
return 0x09;
|
||||
case 0x12:
|
||||
return 0x05;
|
||||
case 0x52:
|
||||
return 0x0d;
|
||||
case 0x92:
|
||||
return 0x0d;
|
||||
case 0x22:
|
||||
return 0x05;
|
||||
case 0x62:
|
||||
return 0x0d;
|
||||
case 0xa2:
|
||||
return 0x0d;
|
||||
case 0x06:
|
||||
return 0x03;
|
||||
case 0x46:
|
||||
return 0x0b;
|
||||
case 0x86:
|
||||
return 0x0b;
|
||||
case 0x16:
|
||||
return 0x07;
|
||||
case 0x56:
|
||||
return 0x0f;
|
||||
case 0x96:
|
||||
return 0x0f;
|
||||
case 0x26:
|
||||
return 0x07;
|
||||
case 0x66:
|
||||
return 0x0f;
|
||||
case 0xa6:
|
||||
return 0x0f;
|
||||
case 0x0a:
|
||||
return 0x03;
|
||||
case 0x4a:
|
||||
return 0x0b;
|
||||
case 0x8a:
|
||||
return 0x0b;
|
||||
case 0x1a:
|
||||
return 0x07;
|
||||
case 0x5a:
|
||||
return 0x0f;
|
||||
case 0x9a:
|
||||
return 0x0f;
|
||||
case 0x2a:
|
||||
return 0x07;
|
||||
case 0x6a:
|
||||
return 0x0f;
|
||||
case 0xaa:
|
||||
return 0x0f;
|
||||
default:
|
||||
// make sure the bitmap area is set to 0 firstly
|
||||
ASSERT(0);
|
||||
return 0x0f; // return NULL bitmap for exception
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Merge bitmap from 2 bits to 1 bit, and the memory buffer should be guaranteed by the invoker.
|
||||
*
|
||||
* @param srcBitmap
|
||||
* @param nBits
|
||||
* @param dstBitmap
|
||||
*/
|
||||
void tdMergeBitmap(uint8_t *srcBitmap, int32_t nBits, uint8_t *dstBitmap) {
|
||||
int32_t i = 0, j = 0;
|
||||
int32_t nBytes = TD_BITMAP_BYTES(nBits);
|
||||
int32_t nRoundBytes = nBits / 4;
|
||||
int32_t nRemainderBits = nBits - nRoundBytes * 4;
|
||||
|
||||
switch (nRemainderBits) {
|
||||
case 0:
|
||||
// NOTHING TODO
|
||||
break;
|
||||
case 1: {
|
||||
void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
|
||||
*(uint8_t *)lastByte &= 0xC0;
|
||||
} break;
|
||||
case 2: {
|
||||
void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
|
||||
*(uint8_t *)lastByte &= 0xF0;
|
||||
} break;
|
||||
case 3: {
|
||||
void *lastByte = POINTER_SHIFT(srcBitmap, nRoundBytes);
|
||||
*(uint8_t *)lastByte &= 0xFC;
|
||||
} break;
|
||||
default:
|
||||
ASSERT(0);
|
||||
}
|
||||
|
||||
if (nBytes > 0) {
|
||||
dstBitmap[j] = (tdGetMergedBitmapByte(srcBitmap[i]) << 4);
|
||||
}
|
||||
|
||||
while ((++i) < nBytes) {
|
||||
if ((i & 1) == 0) {
|
||||
dstBitmap[j] = (tdGetMergedBitmapByte(srcBitmap[i]) << 4);
|
||||
} else {
|
||||
dstBitmap[j] |= tdGetMergedBitmapByte(srcBitmap[i]);
|
||||
++j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set bitmap area by byte preferentially and then by bit.
|
||||
*
|
||||
* @param pBitmap
|
||||
* @param nEle
|
||||
* @param valType
|
||||
* @param bitmapMode 0 for 2 bits, 1 for 1 bit
|
||||
* @return int32_t
|
||||
*/
|
||||
int32_t tdSetBitmapValTypeN(void *pBitmap, int16_t nEle, TDRowValT valType, int8_t bitmapMode) {
|
||||
TASSERT(valType < TD_VTYPE_MAX);
|
||||
int32_t nBytes = (bitmapMode == 0 ? nEle / TD_VTYPE_PARTS : nEle / TD_VTYPE_PARTS_I);
|
||||
uint8_t vTypeByte = tdVTypeByte[bitmapMode][valType];
|
||||
for (int i = 0; i < nBytes; ++i) {
|
||||
*(uint8_t *)pBitmap = vTypeByte;
|
||||
pBitmap = POINTER_SHIFT(pBitmap, 1);
|
||||
}
|
||||
|
||||
int32_t nLeft = nEle - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
|
||||
for (int j = 0; j < nLeft; ++j) {
|
||||
tdSetBitmapValType(pBitmap, j, valType, bitmapMode);
|
||||
}
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
bool tdIsBitmapBlkNorm(const void *pBitmap, int32_t numOfBits, int8_t bitmapMode) {
|
||||
int32_t nBytes = (bitmapMode == 0 ? numOfBits / TD_VTYPE_PARTS : numOfBits / TD_VTYPE_PARTS_I);
|
||||
uint8_t vTypeByte = tdVTypeByte[bitmapMode][TD_VTYPE_NORM];
|
||||
uint8_t *qBitmap = (uint8_t *)pBitmap;
|
||||
for (int i = 0; i < nBytes; ++i) {
|
||||
if (*qBitmap != vTypeByte) {
|
||||
return false;
|
||||
}
|
||||
qBitmap = (uint8_t *)POINTER_SHIFT(pBitmap, i);
|
||||
}
|
||||
|
||||
int32_t nLeft = numOfBits - nBytes * (bitmapMode == 0 ? TD_VTYPE_BITS : TD_VTYPE_BITS_I);
|
||||
|
||||
for (int j = 0; j < nLeft; ++j) {
|
||||
uint8_t vType;
|
||||
tdGetBitmapValType(qBitmap, j, &vType, bitmapMode);
|
||||
if (vType != TD_VTYPE_NORM) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
STSRow *tdRowDup(STSRow *row) {
|
||||
STSRow *trow = taosMemoryMalloc(TD_ROW_LEN(row));
|
||||
if (trow == NULL) return NULL;
|
||||
|
|
|
@ -37,394 +37,30 @@ const int32_t TYPE_BYTES[16] = {
|
|||
TSDB_MAX_JSON_TAG_LEN, // TSDB_DATA_TYPE_JSON
|
||||
};
|
||||
|
||||
#define DO_STATICS(__sum, __min, __max, __minIndex, __maxIndex, _list, _index) \
|
||||
do { \
|
||||
(__sum) += (_list)[(_index)]; \
|
||||
if ((__min) > (_list)[(_index)]) { \
|
||||
(__min) = (_list)[(_index)]; \
|
||||
(__minIndex) = (_index); \
|
||||
} \
|
||||
\
|
||||
if ((__max) < (_list)[(_index)]) { \
|
||||
(__max) = (_list)[(_index)]; \
|
||||
(__maxIndex) = (_index); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static void getStatics_bool(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int8_t *data = (int8_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (data[i] == TSDB_DATA_BOOL_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void getStatics_i8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int8_t *data = (int8_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint8_t)data[i]) == TSDB_DATA_TINYINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void getStatics_u8(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint8_t *data = (uint8_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
uint64_t _sum = 0;
|
||||
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint8_t)data[i]) == TSDB_DATA_UTINYINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
|
||||
*min = _min;
|
||||
*max = _max;
|
||||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int16_t *data = (int16_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint16_t)data[i]) == TSDB_DATA_SMALLINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void getStatics_u16(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint16_t *data = (uint16_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
uint64_t _sum = 0;
|
||||
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint16_t)data[i]) == TSDB_DATA_USMALLINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
|
||||
*min = _min;
|
||||
*max = _max;
|
||||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int32_t *data = (int32_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint32_t)data[i]) == TSDB_DATA_INT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void getStatics_u32(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint32_t *data = (uint32_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
uint64_t _sum = 0;
|
||||
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint32_t)data[i]) == TSDB_DATA_UINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
|
||||
*min = _min;
|
||||
*max = _max;
|
||||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_i64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
int64_t *data = (int64_t *)pData;
|
||||
*min = INT64_MAX;
|
||||
*max = INT64_MIN;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint64_t)data[i]) == TSDB_DATA_BIGINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(*sum, *min, *max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
}
|
||||
|
||||
static void getStatics_u64(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
uint64_t *data = (uint64_t *)pData;
|
||||
uint64_t _min = UINT64_MAX;
|
||||
uint64_t _max = 0;
|
||||
uint64_t _sum = 0;
|
||||
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (((uint64_t)data[i]) == TSDB_DATA_UBIGINT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
DO_STATICS(_sum, _min, _max, *minIndex, *maxIndex, data, i);
|
||||
}
|
||||
|
||||
*min = _min;
|
||||
*max = _max;
|
||||
*sum = _sum;
|
||||
}
|
||||
|
||||
static void getStatics_f(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
float *data = (float *)pData;
|
||||
float fmin = FLT_MAX;
|
||||
float fmax = -FLT_MAX;
|
||||
double dsum = 0;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if ((*(uint32_t *)&(data[i])) == TSDB_DATA_FLOAT_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
float fv = GET_FLOAT_VAL((const char *)&(data[i]));
|
||||
|
||||
dsum += fv;
|
||||
if (fmin > fv) {
|
||||
fmin = fv;
|
||||
*minIndex = i;
|
||||
}
|
||||
|
||||
if (fmax < fv) {
|
||||
fmax = fv;
|
||||
*maxIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
SET_DOUBLE_VAL(sum, dsum);
|
||||
SET_DOUBLE_VAL(max, fmax);
|
||||
SET_DOUBLE_VAL(min, fmin);
|
||||
}
|
||||
|
||||
static void getStatics_d(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
double *data = (double *)pData;
|
||||
double dmin = DBL_MAX;
|
||||
double dmax = -DBL_MAX;
|
||||
double dsum = 0;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if ((*(uint64_t *)&(data[i])) == TSDB_DATA_DOUBLE_NULL) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
double dv = 0;
|
||||
dv = GET_DOUBLE_VAL((const char *)&(data[i]));
|
||||
dsum += dv;
|
||||
if (dmin > dv) {
|
||||
dmin = dv;
|
||||
*minIndex = i;
|
||||
}
|
||||
|
||||
if (dmax < dv) {
|
||||
dmax = dv;
|
||||
*maxIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
SET_DOUBLE_PTR(sum, &dsum);
|
||||
SET_DOUBLE_PTR(max, &dmax);
|
||||
SET_DOUBLE_PTR(min, &dmin);
|
||||
}
|
||||
|
||||
static void getStatics_bin(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
const char *data = pData;
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (isNull(data, TSDB_DATA_TYPE_BINARY)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
}
|
||||
|
||||
data += varDataTLen(data);
|
||||
}
|
||||
|
||||
*sum = 0;
|
||||
*max = 0;
|
||||
*min = 0;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
}
|
||||
|
||||
static void getStatics_nchr(int8_t bitmapMode, const void *pBitmap, const void *pData, int32_t numOfRow, int64_t *min,
|
||||
int64_t *max, int64_t *sum, int16_t *minIndex, int16_t *maxIndex, int16_t *numOfNull) {
|
||||
const char *data = pData;
|
||||
assert(numOfRow <= INT16_MAX);
|
||||
|
||||
for (int32_t i = 0; i < numOfRow; ++i) {
|
||||
// if (isNull(data, TSDB_DATA_TYPE_NCHAR)) {
|
||||
if (!tdIsBitmapValTypeNorm(pBitmap, i, bitmapMode)) {
|
||||
(*numOfNull) += 1;
|
||||
}
|
||||
|
||||
data += varDataTLen(data);
|
||||
}
|
||||
|
||||
*sum = 0;
|
||||
*max = 0;
|
||||
*min = 0;
|
||||
*minIndex = 0;
|
||||
*maxIndex = 0;
|
||||
}
|
||||
|
||||
tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
|
||||
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL, NULL},
|
||||
{TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool, getStatics_bool},
|
||||
{TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint,
|
||||
getStatics_i8},
|
||||
{TSDB_DATA_TYPE_NULL, 6, 1, "NOTYPE", 0, 0, NULL, NULL},
|
||||
{TSDB_DATA_TYPE_BOOL, 4, CHAR_BYTES, "BOOL", false, true, tsCompressBool, tsDecompressBool},
|
||||
{TSDB_DATA_TYPE_TINYINT, 7, CHAR_BYTES, "TINYINT", INT8_MIN, INT8_MAX, tsCompressTinyint, tsDecompressTinyint},
|
||||
{TSDB_DATA_TYPE_SMALLINT, 8, SHORT_BYTES, "SMALLINT", INT16_MIN, INT16_MAX, tsCompressSmallint,
|
||||
tsDecompressSmallint, getStatics_i16},
|
||||
{TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", INT32_MIN, INT32_MAX, tsCompressInt, tsDecompressInt, getStatics_i32},
|
||||
{TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint, tsDecompressBigint,
|
||||
getStatics_i64},
|
||||
{TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat, getStatics_f},
|
||||
{TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble, getStatics_d},
|
||||
{TSDB_DATA_TYPE_VARCHAR, 6, 1, "VARCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_bin},
|
||||
tsDecompressSmallint},
|
||||
{TSDB_DATA_TYPE_INT, 3, INT_BYTES, "INT", INT32_MIN, INT32_MAX, tsCompressInt, tsDecompressInt},
|
||||
{TSDB_DATA_TYPE_BIGINT, 6, LONG_BYTES, "BIGINT", INT64_MIN, INT64_MAX, tsCompressBigint, tsDecompressBigint},
|
||||
{TSDB_DATA_TYPE_FLOAT, 5, FLOAT_BYTES, "FLOAT", 0, 0, tsCompressFloat, tsDecompressFloat},
|
||||
{TSDB_DATA_TYPE_DOUBLE, 6, DOUBLE_BYTES, "DOUBLE", 0, 0, tsCompressDouble, tsDecompressDouble},
|
||||
{TSDB_DATA_TYPE_VARCHAR, 6, 1, "VARCHAR", 0, 0, tsCompressString, tsDecompressString},
|
||||
{TSDB_DATA_TYPE_TIMESTAMP, 9, LONG_BYTES, "TIMESTAMP", INT64_MIN, INT64_MAX, tsCompressTimestamp,
|
||||
tsDecompressTimestamp, getStatics_i64},
|
||||
{TSDB_DATA_TYPE_NCHAR, 5, 1, "NCHAR", 0, 0, tsCompressString, tsDecompressString, getStatics_nchr},
|
||||
{TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint, tsDecompressTinyint,
|
||||
getStatics_u8},
|
||||
tsDecompressTimestamp},
|
||||
{TSDB_DATA_TYPE_NCHAR, 5, 1, "NCHAR", 0, 0, tsCompressString, tsDecompressString},
|
||||
{TSDB_DATA_TYPE_UTINYINT, 16, CHAR_BYTES, "TINYINT UNSIGNED", 0, UINT8_MAX, tsCompressTinyint, tsDecompressTinyint},
|
||||
{TSDB_DATA_TYPE_USMALLINT, 17, SHORT_BYTES, "SMALLINT UNSIGNED", 0, UINT16_MAX, tsCompressSmallint,
|
||||
tsDecompressSmallint, getStatics_u16},
|
||||
{TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt, getStatics_u32},
|
||||
{TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint,
|
||||
getStatics_u64},
|
||||
{TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString,
|
||||
getStatics_nchr},
|
||||
tsDecompressSmallint},
|
||||
{TSDB_DATA_TYPE_UINT, 12, INT_BYTES, "INT UNSIGNED", 0, UINT32_MAX, tsCompressInt, tsDecompressInt},
|
||||
{TSDB_DATA_TYPE_UBIGINT, 15, LONG_BYTES, "BIGINT UNSIGNED", 0, UINT64_MAX, tsCompressBigint, tsDecompressBigint},
|
||||
{TSDB_DATA_TYPE_JSON, 4, TSDB_MAX_JSON_TAG_LEN, "JSON", 0, 0, tsCompressString, tsDecompressString},
|
||||
};
|
||||
|
||||
char tTokenTypeSwitcher[13] = {
|
||||
TSDB_DATA_TYPE_NULL, // no type
|
||||
TSDB_DATA_TYPE_BINARY, // TK_ID
|
||||
TSDB_DATA_TYPE_BOOL, // TK_BOOL
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TINYINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_SMALLINT
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_INTEGER
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_BIGINT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_FLOAT
|
||||
TSDB_DATA_TYPE_DOUBLE, // TK_DOUBLE
|
||||
TSDB_DATA_TYPE_BINARY, // TK_STRING
|
||||
TSDB_DATA_TYPE_BIGINT, // TK_TIMESTAMP
|
||||
TSDB_DATA_TYPE_VARCHAR, // TK_BINARY
|
||||
TSDB_DATA_TYPE_NCHAR, // TK_NCHAR
|
||||
};
|
||||
|
||||
float floatMin = -FLT_MAX, floatMax = FLT_MAX;
|
||||
double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
|
||||
static float floatMin = -FLT_MAX, floatMax = FLT_MAX;
|
||||
static double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
|
||||
|
||||
FORCE_INLINE void *getDataMin(int32_t type) {
|
||||
switch (type) {
|
||||
|
@ -462,107 +98,8 @@ void setVardataNull(void *val, int32_t type) {
|
|||
}
|
||||
}
|
||||
|
||||
void setNull(void *val, int32_t type, int32_t bytes) { setNullN(val, type, bytes, 1); }
|
||||
|
||||
#define POINTER_SHIFT(p, b) ((void *)((char *)(p) + (b)))
|
||||
|
||||
void setNullN(void *val, int32_t type, int32_t bytes, int32_t numOfElems) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_BOOL_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_TINYINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint16_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_SMALLINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_INT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_BIGINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint8_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UTINYINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint16_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_USMALLINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_UBIGINT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_FLOAT_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint64_t *)(POINTER_SHIFT(val, i * tDataTypes[type].bytes)) = TSDB_DATA_DOUBLE_NULL;
|
||||
}
|
||||
break;
|
||||
case TSDB_DATA_TYPE_NCHAR:
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
setVardataNull(POINTER_SHIFT(val, i * bytes), type);
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
for (int32_t i = 0; i < numOfElems; ++i) {
|
||||
*(uint32_t *)(POINTER_SHIFT(val, i * tDataTypes[TSDB_DATA_TYPE_INT].bytes)) = TSDB_DATA_INT_NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint8_t nullBool = TSDB_DATA_BOOL_NULL;
|
||||
static uint8_t nullTinyInt = TSDB_DATA_TINYINT_NULL;
|
||||
static uint16_t nullSmallInt = TSDB_DATA_SMALLINT_NULL;
|
||||
static uint32_t nullInt = TSDB_DATA_INT_NULL;
|
||||
static uint64_t nullBigInt = TSDB_DATA_BIGINT_NULL;
|
||||
static uint32_t nullFloat = TSDB_DATA_FLOAT_NULL;
|
||||
static uint64_t nullDouble = TSDB_DATA_DOUBLE_NULL;
|
||||
static uint8_t nullTinyIntu = TSDB_DATA_UTINYINT_NULL;
|
||||
static uint16_t nullSmallIntu = TSDB_DATA_USMALLINT_NULL;
|
||||
static uint32_t nullIntu = TSDB_DATA_UINT_NULL;
|
||||
static uint64_t nullBigIntu = TSDB_DATA_UBIGINT_NULL;
|
||||
static SBinaryNullT nullBinary = {1, TSDB_DATA_BINARY_NULL};
|
||||
static SNCharNullT nullNchar = {4, TSDB_DATA_NCHAR_NULL};
|
||||
|
||||
static const void *nullValues[] = {
|
||||
&nullBool, &nullTinyInt, &nullSmallInt, &nullInt, &nullBigInt, &nullFloat, &nullDouble,
|
||||
&nullBinary, &nullBigInt, &nullNchar, &nullTinyIntu, &nullSmallIntu, &nullIntu, &nullBigIntu,
|
||||
};
|
||||
|
||||
const void *getNullValue(int32_t type) {
|
||||
assert(type >= TSDB_DATA_TYPE_BOOL && type <= TSDB_DATA_TYPE_UBIGINT); // TODO: extend the types
|
||||
return nullValues[type - 1];
|
||||
}
|
||||
|
||||
void assignVal(char *val, const char *src, int32_t len, int32_t type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
|
@ -648,48 +185,3 @@ void operateVal(void *dst, void *s1, void *s2, int32_t optr, int32_t type) {
|
|||
assert(0);
|
||||
}
|
||||
}
|
||||
|
||||
void tsDataSwap(void *pLeft, void *pRight, int32_t type, int32_t size, void *buf) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
TSWAP(*(int32_t *)(pLeft), *(int32_t *)(pRight));
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
TSWAP(*(int64_t *)(pLeft), *(int64_t *)(pRight));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
TSWAP(*(double *)(pLeft), *(double *)(pRight));
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
TSWAP(*(int16_t *)(pLeft), *(int16_t *)(pRight));
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
TSWAP(*(float *)(pLeft), *(float *)(pRight));
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
TSWAP(*(int8_t *)(pLeft), *(int8_t *)(pRight));
|
||||
break;
|
||||
}
|
||||
|
||||
default: {
|
||||
memcpy(buf, pLeft, size);
|
||||
memcpy(pLeft, pRight, size);
|
||||
memcpy(pRight, buf, size);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,22 +19,6 @@
|
|||
#include "ttokendef.h"
|
||||
#include "tvariant.h"
|
||||
|
||||
#define SET_EXT_INFO(converted, res, minv, maxv, exti) \
|
||||
do { \
|
||||
if (converted == NULL || exti == NULL || *converted == false) { \
|
||||
break; \
|
||||
} \
|
||||
if ((res) < (minv)) { \
|
||||
*exti = -1; \
|
||||
break; \
|
||||
} \
|
||||
if ((res) > (maxv)) { \
|
||||
*exti = 1; \
|
||||
break; \
|
||||
} \
|
||||
assert(0); \
|
||||
} while (0)
|
||||
|
||||
int32_t toInteger(const char *z, int32_t n, int32_t base, int64_t *value) {
|
||||
errno = 0;
|
||||
char *endPtr = NULL;
|
||||
|
@ -53,8 +37,8 @@ int32_t toUInteger(const char *z, int32_t n, int32_t base, uint64_t *value) {
|
|||
char *endPtr = NULL;
|
||||
|
||||
const char *p = z;
|
||||
while (*p != 0 && *p == ' ') p++;
|
||||
if (*p != 0 && *p == '-') {
|
||||
while (*p == ' ') p++;
|
||||
if (*p == '-') {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -176,11 +160,6 @@ void taosVariantDestroy(SVariant *pVar) {
|
|||
}
|
||||
}
|
||||
|
||||
bool taosVariantIsValid(SVariant *pVar) {
|
||||
assert(pVar != NULL);
|
||||
return isValidDataType(pVar->nType);
|
||||
}
|
||||
|
||||
void taosVariantAssign(SVariant *pDst, const SVariant *pSrc) {
|
||||
if (pSrc == NULL || pDst == NULL) return;
|
||||
|
||||
|
@ -265,702 +244,6 @@ int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2) {
|
|||
}
|
||||
}
|
||||
|
||||
int32_t taosVariantToString(SVariant *pVar, char *dst) {
|
||||
if (pVar == NULL || dst == NULL) return 0;
|
||||
|
||||
switch (pVar->nType) {
|
||||
case TSDB_DATA_TYPE_BINARY: {
|
||||
int32_t len = sprintf(dst, "\'%s\'", pVar->pz);
|
||||
assert(len <= pVar->nLen + sizeof("\'") * 2); // two more chars
|
||||
return len;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
dst[0] = '\'';
|
||||
taosUcs4ToMbs(pVar->ucs4, (taosUcs4len(pVar->ucs4) + 1) * TSDB_NCHAR_SIZE, dst + 1);
|
||||
int32_t len = (int32_t)strlen(dst);
|
||||
dst[len] = '\'';
|
||||
dst[len + 1] = 0;
|
||||
return len + 1;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
return sprintf(dst, "%d", (int32_t)pVar->i);
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
return sprintf(dst, "%" PRId64, pVar->i);
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
return sprintf(dst, "%" PRIu64, pVar->u);
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
return sprintf(dst, "%.9lf", pVar->d);
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t convertToBoolImpl(char *pStr, int32_t len) {
|
||||
if ((strncasecmp(pStr, "true", len) == 0) && (len == 4)) {
|
||||
return TSDB_TRUE;
|
||||
} else if ((strncasecmp(pStr, "false", len) == 0) && (len == 5)) {
|
||||
return TSDB_FALSE;
|
||||
} else if (strcasecmp(pStr, TSDB_DATA_NULL_STR_L) == 0) {
|
||||
return TSDB_DATA_BOOL_NULL;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t wcsconvertToBoolImpl(TdUcs4 *pstr, int32_t len) {
|
||||
if ((wcsncasecmp(pstr, L"true", len) == 0) && (len == 4)) {
|
||||
return TSDB_TRUE;
|
||||
} else if (wcsncasecmp(pstr, L"false", len) == 0 && (len == 5)) {
|
||||
return TSDB_FALSE;
|
||||
} else if (memcmp(pstr, L"null", wcslen(L"null")) == 0) {
|
||||
return TSDB_DATA_BOOL_NULL;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t toBinary(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||
const int32_t INITIAL_ALLOC_SIZE = 40;
|
||||
char *pBuf = NULL;
|
||||
|
||||
// it is a in-place convert type for SVariant, local buffer is needed
|
||||
if (*pDest == pVariant->pz) {
|
||||
pBuf = taosMemoryCalloc(1, INITIAL_ALLOC_SIZE);
|
||||
}
|
||||
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
size_t newSize = pVariant->nLen * TSDB_NCHAR_SIZE;
|
||||
if (pBuf != NULL) {
|
||||
if (newSize >= INITIAL_ALLOC_SIZE) {
|
||||
pBuf = taosMemoryRealloc(pBuf, newSize + 1);
|
||||
}
|
||||
|
||||
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, pBuf);
|
||||
taosMemoryFree(pVariant->ucs4);
|
||||
pBuf[newSize] = 0;
|
||||
} else {
|
||||
taosUcs4ToMbs(pVariant->ucs4, (int32_t)newSize, *pDest);
|
||||
}
|
||||
|
||||
} else {
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
sprintf(pBuf == NULL ? *pDest : pBuf, "%" PRId64, pVariant->i);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
||||
sprintf(pBuf == NULL ? *pDest : pBuf, "%lf", pVariant->d);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
|
||||
sprintf(pBuf == NULL ? *pDest : pBuf, "%s", (pVariant->i == TSDB_TRUE) ? "TRUE" : "FALSE");
|
||||
} else if (pVariant->nType == 0) { // null data
|
||||
setNull(pBuf == NULL ? *pDest : pBuf, TSDB_DATA_TYPE_BINARY, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (pBuf != NULL) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
*pDest = pBuf;
|
||||
}
|
||||
|
||||
*pDestSize = (int32_t)strlen(*pDest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t toNchar(SVariant *pVariant, char **pDest, int32_t *pDestSize) {
|
||||
char tmpBuf[40] = {0};
|
||||
|
||||
char *pDst = tmpBuf;
|
||||
int32_t nLen = 0;
|
||||
|
||||
// convert the number to string, than convert it to wchar string.
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
nLen = sprintf(pDst, "%" PRId64, pVariant->i);
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
nLen = sprintf(pDst, "%" PRIu64, pVariant->u);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_DOUBLE || pVariant->nType == TSDB_DATA_TYPE_FLOAT) {
|
||||
nLen = sprintf(pDst, "%lf", pVariant->d);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
pDst = pVariant->pz;
|
||||
nLen = pVariant->nLen;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
|
||||
nLen = sprintf(pDst, "%s", (pVariant->i == TSDB_TRUE) ? "TRUE" : "FALSE");
|
||||
}
|
||||
|
||||
if (*pDest == pVariant->pz) {
|
||||
TdUcs4 *pWStr = taosMemoryCalloc(1, (nLen + 1) * TSDB_NCHAR_SIZE);
|
||||
bool ret = taosMbsToUcs4(pDst, nLen, pWStr, (nLen + 1) * TSDB_NCHAR_SIZE, NULL);
|
||||
if (!ret) {
|
||||
taosMemoryFreeClear(pWStr);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// free the binary buffer in the first place
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
taosMemoryFree(pVariant->ucs4);
|
||||
}
|
||||
|
||||
pVariant->ucs4 = pWStr;
|
||||
*pDestSize = taosUcs4len(pVariant->ucs4);
|
||||
|
||||
// shrink the allocate memory, no need to check here.
|
||||
char *tmp = taosMemoryRealloc(pVariant->ucs4, (*pDestSize + 1) * TSDB_NCHAR_SIZE);
|
||||
assert(tmp != NULL);
|
||||
|
||||
pVariant->ucs4 = (TdUcs4 *)tmp;
|
||||
} else {
|
||||
int32_t output = 0;
|
||||
|
||||
bool ret = taosMbsToUcs4(pDst, nLen, (TdUcs4 *)*pDest, (nLen + 1) * TSDB_NCHAR_SIZE, &output);
|
||||
if (!ret) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pDestSize != NULL) {
|
||||
*pDestSize = output;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t convertToDouble(char *pStr, int32_t len, double *value) {
|
||||
// SToken stoken = {.z = pStr, .n = len};
|
||||
// if (TK_ILLEGAL == tGetNumericStringType(&stoken)) {
|
||||
// return -1;
|
||||
// }
|
||||
//
|
||||
// *value = taosStr2Double(pStr, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t convertToInteger(SVariant *pVariant, int64_t *result, int32_t type, bool issigned,
|
||||
bool releaseVariantPtr, bool *converted) {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
setNull((char *)result, type, tDataTypes[type].bytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) {
|
||||
*result = pVariant->i;
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
*result = pVariant->u;
|
||||
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
||||
*result = (int64_t)pVariant->d;
|
||||
} else {
|
||||
// TODO: handling var types
|
||||
}
|
||||
#if 0
|
||||
errno = 0;
|
||||
if (IS_SIGNED_NUMERIC_TYPE(pVariant->nType) || (pVariant->nType == TSDB_DATA_TYPE_BOOL)) {
|
||||
*result = pVariant->i;
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
*result = pVariant->u;
|
||||
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
||||
*result = (int64_t) pVariant->d;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
SToken token = {.z = pVariant->pz, .n = pVariant->nLen};
|
||||
/*int32_t n = */tGetToken(pVariant->pz, &token.type);
|
||||
|
||||
if (token.type == TK_NULL) {
|
||||
if (releaseVariantPtr) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->nLen = 0;
|
||||
}
|
||||
|
||||
setNull((char *)result, type, tDataTypes[type].bytes);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// decide if it is a valid number
|
||||
token.type = tGetNumericStringType(&token);
|
||||
if (token.type == TK_ILLEGAL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t res = 0;
|
||||
int32_t t = tStrToInteger(token.z, token.type, token.n, &res, issigned);
|
||||
if (t != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (releaseVariantPtr) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->nLen = 0;
|
||||
}
|
||||
|
||||
*result = res;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
errno = 0;
|
||||
TdUcs4 *endPtr = NULL;
|
||||
|
||||
SToken token = {0};
|
||||
token.n = tGetToken(pVariant->pz, &token.type);
|
||||
|
||||
if (token.type == TK_MINUS || token.type == TK_PLUS) {
|
||||
token.n = tGetToken(pVariant->pz + token.n, &token.type);
|
||||
}
|
||||
|
||||
if (token.type == TK_FLOAT) {
|
||||
double v = wcstod(pVariant->ucs4, &endPtr);
|
||||
if (releaseVariantPtr) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->nLen = 0;
|
||||
}
|
||||
|
||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*result = (int64_t)v;
|
||||
} else if (token.type == TK_NULL) {
|
||||
if (releaseVariantPtr) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->nLen = 0;
|
||||
}
|
||||
setNull((char *)result, type, tDataTypes[type].bytes);
|
||||
return 0;
|
||||
} else {
|
||||
int64_t val = wcstoll(pVariant->ucs4, &endPtr, 10);
|
||||
if (releaseVariantPtr) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->nLen = 0;
|
||||
}
|
||||
|
||||
if (errno == ERANGE) {
|
||||
return -1; // data overflow
|
||||
}
|
||||
|
||||
*result = val;
|
||||
}
|
||||
}
|
||||
|
||||
if (converted) {
|
||||
*converted = true;
|
||||
}
|
||||
|
||||
bool code = false;
|
||||
|
||||
uint64_t ui = 0;
|
||||
switch(type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
code = IS_VALID_TINYINT(*result); break;
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
code = IS_VALID_SMALLINT(*result); break;
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
code = IS_VALID_INT(*result); break;
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
code = IS_VALID_BIGINT(*result); break;
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
ui = *result;
|
||||
code = IS_VALID_UTINYINT(ui); break;
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
ui = *result;
|
||||
code = IS_VALID_USMALLINT(ui); break;
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
ui = *result;
|
||||
code = IS_VALID_UINT(ui); break;
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
ui = *result;
|
||||
code = IS_VALID_UBIGINT(ui); break;
|
||||
}
|
||||
|
||||
|
||||
return code? 0:-1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int32_t convertToBool(SVariant *pVariant, int64_t *pDest) {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BOOL) {
|
||||
*pDest = pVariant->i; // in order to be compatible to null of bool
|
||||
} else if (IS_NUMERIC_TYPE(pVariant->nType)) {
|
||||
*pDest = ((pVariant->i != 0) ? TSDB_TRUE : TSDB_FALSE);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_FLOAT || pVariant->nType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
*pDest = ((pVariant->d != 0) ? TSDB_TRUE : TSDB_FALSE);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
int32_t ret = 0;
|
||||
if ((ret = convertToBoolImpl(pVariant->pz, pVariant->nLen)) < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
*pDest = ret;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t ret = 0;
|
||||
if ((ret = wcsconvertToBoolImpl(pVariant->ucs4, pVariant->nLen)) < 0) {
|
||||
return ret;
|
||||
}
|
||||
*pDest = ret;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*pDest = TSDB_DATA_BOOL_NULL;
|
||||
}
|
||||
|
||||
assert(*pDest == TSDB_TRUE || *pDest == TSDB_FALSE || *pDest == TSDB_DATA_BOOL_NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType
|
||||
* to column type defined in schema
|
||||
*/
|
||||
int32_t tVariantDumpEx(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix, bool *converted,
|
||||
char *extInfo) {
|
||||
if (converted) {
|
||||
*converted = false;
|
||||
}
|
||||
|
||||
if (pVariant == NULL || (pVariant->nType != 0 && !isValidDataType(pVariant->nType))) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
errno = 0; // reset global error code
|
||||
int64_t result = 0;
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL: {
|
||||
if (convertToBool(pVariant, &result) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
*(int8_t *)payload = (int8_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_TINYINT: {
|
||||
if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, INT8_MIN + 1, INT8_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((int8_t *)payload) = (int8_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_UTINYINT: {
|
||||
if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, 0, UINT8_MAX - 1, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((uint8_t *)payload) = (uint8_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, INT16_MIN + 1, INT16_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((int16_t *)payload) = (int16_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_USMALLINT: {
|
||||
if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, 0, UINT16_MAX - 1, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((uint16_t *)payload) = (uint16_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_INT: {
|
||||
if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, INT32_MIN + 1, INT32_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((int32_t *)payload) = (int32_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_UINT: {
|
||||
if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, 0, UINT32_MAX - 1, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((uint32_t *)payload) = (uint32_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT: {
|
||||
if (convertToInteger(pVariant, &result, type, true, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, INT64_MIN + 1, INT64_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((int64_t *)payload) = (int64_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_UBIGINT: {
|
||||
if (convertToInteger(pVariant, &result, type, false, false, converted) < 0) {
|
||||
SET_EXT_INFO(converted, result, 0, UINT64_MAX - 1, extInfo);
|
||||
return -1;
|
||||
}
|
||||
*((uint64_t *)payload) = (uint64_t)result;
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
if (strncasecmp(TSDB_DATA_NULL_STR_L, pVariant->pz, pVariant->nLen) == 0 &&
|
||||
strlen(TSDB_DATA_NULL_STR_L) == pVariant->nLen) {
|
||||
*((int32_t *)payload) = TSDB_DATA_FLOAT_NULL;
|
||||
return 0;
|
||||
} else {
|
||||
double value = -1;
|
||||
int32_t ret = convertToDouble(pVariant->pz, pVariant->nLen, &value);
|
||||
if ((errno == ERANGE && (float)value == -1) || (ret != 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (converted) {
|
||||
*converted = true;
|
||||
}
|
||||
|
||||
if (value > FLT_MAX || value < -FLT_MAX) {
|
||||
SET_EXT_INFO(converted, value, -FLT_MAX, FLT_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
SET_FLOAT_VAL(payload, value);
|
||||
}
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) ||
|
||||
IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
if (converted) {
|
||||
*converted = true;
|
||||
}
|
||||
|
||||
if (pVariant->i > FLT_MAX || pVariant->i < -FLT_MAX) {
|
||||
SET_EXT_INFO(converted, pVariant->i, -FLT_MAX, FLT_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SET_FLOAT_VAL(payload, pVariant->i);
|
||||
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
||||
if (converted) {
|
||||
*converted = true;
|
||||
}
|
||||
|
||||
if (pVariant->d > FLT_MAX || pVariant->d < -FLT_MAX) {
|
||||
SET_EXT_INFO(converted, pVariant->d, -FLT_MAX, FLT_MAX, extInfo);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SET_FLOAT_VAL(payload, pVariant->d);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*((uint32_t *)payload) = TSDB_DATA_FLOAT_NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
float fv = GET_FLOAT_VAL(payload);
|
||||
if (isinf(fv) || isnan(fv) || fv > FLT_MAX || fv < -FLT_MAX) {
|
||||
return -1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
if (strncasecmp(TSDB_DATA_NULL_STR_L, pVariant->pz, pVariant->nLen) == 0 &&
|
||||
strlen(TSDB_DATA_NULL_STR_L) == pVariant->nLen) {
|
||||
*((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL;
|
||||
return 0;
|
||||
} else {
|
||||
double value = 0;
|
||||
int32_t ret;
|
||||
ret = convertToDouble(pVariant->pz, pVariant->nLen, &value);
|
||||
if ((errno == ERANGE && value == -1) || (ret != 0)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
SET_DOUBLE_VAL(payload, value);
|
||||
}
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_BOOL || IS_SIGNED_NUMERIC_TYPE(pVariant->nType) ||
|
||||
IS_UNSIGNED_NUMERIC_TYPE(pVariant->nType)) {
|
||||
SET_DOUBLE_VAL(payload, pVariant->i);
|
||||
} else if (IS_FLOAT_TYPE(pVariant->nType)) {
|
||||
SET_DOUBLE_VAL(payload, pVariant->d);
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*((int64_t *)payload) = TSDB_DATA_DOUBLE_NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
double dv = GET_DOUBLE_VAL(payload);
|
||||
if (errno == ERANGE || isinf(dv) || isnan(dv)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case TSDB_DATA_TYPE_BINARY: {
|
||||
if (!includeLengthPrefix) {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*(uint8_t *)payload = TSDB_DATA_BINARY_NULL;
|
||||
} else {
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
|
||||
toBinary(pVariant, &payload, &pVariant->nLen);
|
||||
} else {
|
||||
strncpy(payload, pVariant->pz, pVariant->nLen);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
setVardataNull(payload, TSDB_DATA_TYPE_BINARY);
|
||||
} else {
|
||||
char *p = varDataVal(payload);
|
||||
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
|
||||
toBinary(pVariant, &p, &pVariant->nLen);
|
||||
} else {
|
||||
strncpy(p, pVariant->pz, pVariant->nLen);
|
||||
}
|
||||
|
||||
varDataSetLen(payload, pVariant->nLen);
|
||||
assert(p == varDataVal(payload));
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_TIMESTAMP: {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*((int64_t *)payload) = TSDB_DATA_BIGINT_NULL;
|
||||
} else {
|
||||
*((int64_t *)payload) = pVariant->i;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
int32_t newlen = 0;
|
||||
if (!includeLengthPrefix) {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
*(uint32_t *)payload = TSDB_DATA_NCHAR_NULL;
|
||||
} else {
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
|
||||
if (toNchar(pVariant, &payload, &newlen) != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
tasoUcs4Copy((TdUcs4 *)payload, pVariant->ucs4, pVariant->nLen);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_NULL) {
|
||||
setVardataNull(payload, TSDB_DATA_TYPE_NCHAR);
|
||||
} else {
|
||||
char *p = varDataVal(payload);
|
||||
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
|
||||
if (toNchar(pVariant, &p, &newlen) != 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
memcpy(p, pVariant->ucs4, pVariant->nLen);
|
||||
newlen = pVariant->nLen;
|
||||
}
|
||||
|
||||
varDataSetLen(payload, newlen); // the length may be changed after toNchar function called
|
||||
assert(p == varDataVal(payload));
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* transfer data from variant serve as the implicit data conversion: from input sql string pVariant->nType
|
||||
* to column type defined in schema
|
||||
*/
|
||||
int32_t taosVariantDump(SVariant *pVariant, char *payload, int16_t type, bool includeLengthPrefix) {
|
||||
return tVariantDumpEx(pVariant, payload, type, includeLengthPrefix, NULL, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* In variant, bool/smallint/tinyint/int/bigint share the same attribution of
|
||||
* structure, also ignore the convert the type required
|
||||
*
|
||||
* It is actually the bigint/binary/bool/nchar type transfer
|
||||
*/
|
||||
int32_t taosVariantTypeSetType(SVariant *pVariant, char type) {
|
||||
if (pVariant == NULL || pVariant->nType == 0) { // value is not set
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL: { // bool
|
||||
if (convertToBool(pVariant, &pVariant->i) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
pVariant->nType = type;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
case TSDB_DATA_TYPE_SMALLINT: {
|
||||
convertToInteger(pVariant, &(pVariant->i), type, true, true, NULL);
|
||||
pVariant->nType = TSDB_DATA_TYPE_BIGINT;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
if (pVariant->nType == TSDB_DATA_TYPE_BINARY) {
|
||||
errno = 0;
|
||||
double v = taosStr2Double(pVariant->pz, NULL);
|
||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->d = v;
|
||||
} else if (pVariant->nType == TSDB_DATA_TYPE_NCHAR) {
|
||||
errno = 0;
|
||||
double v = wcstod(pVariant->ucs4, NULL);
|
||||
if ((errno == ERANGE && v == -1) || (isinf(v) || isnan(v))) {
|
||||
taosMemoryFree(pVariant->pz);
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosMemoryFree(pVariant->pz);
|
||||
pVariant->d = v;
|
||||
} else if (pVariant->nType >= TSDB_DATA_TYPE_BOOL && pVariant->nType <= TSDB_DATA_TYPE_BIGINT) {
|
||||
double tmp = (double)pVariant->i;
|
||||
pVariant->d = tmp;
|
||||
}
|
||||
|
||||
pVariant->nType = TSDB_DATA_TYPE_DOUBLE;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_BINARY: {
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_BINARY) {
|
||||
toBinary(pVariant, &pVariant->pz, &pVariant->nLen);
|
||||
}
|
||||
pVariant->nType = type;
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
if (pVariant->nType != TSDB_DATA_TYPE_NCHAR) {
|
||||
if (toNchar(pVariant, &pVariant->pz, &pVariant->nLen) != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
pVariant->nType = type;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *taosVariantGet(SVariant *pVar, int32_t type) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
|
|
|
@ -2,5 +2,4 @@ add_subdirectory(mnode)
|
|||
add_subdirectory(vnode)
|
||||
add_subdirectory(qnode)
|
||||
add_subdirectory(snode)
|
||||
add_subdirectory(bnode)
|
||||
add_subdirectory(mgmt)
|
|
@ -1,14 +0,0 @@
|
|||
aux_source_directory(src BNODE_SRC)
|
||||
add_library(bnode STATIC ${BNODE_SRC})
|
||||
target_include_directories(
|
||||
bnode
|
||||
PUBLIC "${TD_SOURCE_DIR}/include/dnode/bnode"
|
||||
private "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
bnode
|
||||
PRIVATE transport
|
||||
PRIVATE os
|
||||
PRIVATE common
|
||||
PRIVATE util
|
||||
)
|
|
@ -1,40 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_BNODE_INT_H_
|
||||
#define _TD_BNODE_INT_H_
|
||||
|
||||
#include "os.h"
|
||||
|
||||
#include "tarray.h"
|
||||
#include "tlog.h"
|
||||
#include "tmsg.h"
|
||||
#include "trpc.h"
|
||||
|
||||
#include "bnode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SBnode {
|
||||
SMsgCb msgCb;
|
||||
} SBnode;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_BNODE_INT_H_*/
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "bndInt.h"
|
||||
|
||||
SBnode *bndOpen(const char *path, const SBnodeOpt *pOption) {
|
||||
SBnode *pBnode = taosMemoryCalloc(1, sizeof(SBnode));
|
||||
pBnode->msgCb = pOption->msgCb;
|
||||
return pBnode;
|
||||
}
|
||||
|
||||
void bndClose(SBnode *pBnode) { taosMemoryFree(pBnode); }
|
||||
|
||||
int32_t bndGetLoad(SBnode *pBnode, SBnodeLoad *pLoad) { return 0; }
|
||||
|
||||
int32_t bndProcessWMsgs(SBnode *pBnode, SArray *pMsgs) { return 0; }
|
|
@ -1,6 +1,5 @@
|
|||
add_subdirectory(node_mgmt)
|
||||
add_subdirectory(node_util)
|
||||
add_subdirectory(mgmt_bnode)
|
||||
add_subdirectory(mgmt_mnode)
|
||||
add_subdirectory(mgmt_qnode)
|
||||
add_subdirectory(mgmt_snode)
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#define DM_SDB_INFO "Dump sdb info."
|
||||
#define DM_ENV_CMD "The env cmd variable string to use when configuring the server, such as: -e 'TAOS_FQDN=td1'."
|
||||
#define DM_ENV_FILE "The env variable file path to use when configuring the server, default is './.env', .env text can be 'TAOS_FQDN=td1'."
|
||||
#define DM_NODE_TYPE "Startup type of the node, default is 0."
|
||||
#define DM_MACHINE_CODE "Get machine code."
|
||||
#define DM_VERSION "Print program version."
|
||||
#define DM_EMAIL "<support@taosdata.com>"
|
||||
|
@ -44,7 +43,6 @@ static struct {
|
|||
char apolloUrl[PATH_MAX];
|
||||
const char **envCmd;
|
||||
SArray *pArgs; // SConfigPair
|
||||
EDndNodeType ntype;
|
||||
} global = {0};
|
||||
|
||||
static void dmStopDnode(int signum, void *info, void *ctx) { dmStop(); }
|
||||
|
@ -59,13 +57,6 @@ static void dmSetSignalHandle() {
|
|||
taosSetSignal(SIGTSTP, dmStopDnode);
|
||||
taosSetSignal(SIGQUIT, dmStopDnode);
|
||||
#endif
|
||||
|
||||
if (!tsMultiProcess) {
|
||||
} else if (global.ntype == DNODE || global.ntype == NODE_END) {
|
||||
taosIgnSignal(SIGCHLD);
|
||||
} else {
|
||||
taosKillChildOnParentStopped();
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
||||
|
@ -91,12 +82,6 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
|
|||
global.dumpSdb = true;
|
||||
} else if (strcmp(argv[i], "-E") == 0) {
|
||||
tstrncpy(global.envFile, argv[++i], PATH_MAX);
|
||||
} else if (strcmp(argv[i], "-n") == 0) {
|
||||
global.ntype = atoi(argv[++i]);
|
||||
if (global.ntype <= DNODE || global.ntype > NODE_END) {
|
||||
printf("'-n' range is [1 - %d], default is 0\n", NODE_END - 1);
|
||||
return -1;
|
||||
}
|
||||
} else if (strcmp(argv[i], "-k") == 0) {
|
||||
global.generateGrant = true;
|
||||
} else if (strcmp(argv[i], "-C") == 0) {
|
||||
|
@ -142,7 +127,6 @@ static void dmPrintHelp() {
|
|||
printf("%s%s%s%s\n", indent, "-C,", indent, DM_DMP_CFG);
|
||||
printf("%s%s%s%s\n", indent, "-e,", indent, DM_ENV_CMD);
|
||||
printf("%s%s%s%s\n", indent, "-E,", indent, DM_ENV_FILE);
|
||||
printf("%s%s%s%s\n", indent, "-n,", indent, DM_NODE_TYPE);
|
||||
printf("%s%s%s%s\n", indent, "-k,", indent, DM_MACHINE_CODE);
|
||||
printf("%s%s%s%s\n", indent, "-V,", indent, DM_VERSION);
|
||||
|
||||
|
@ -155,17 +139,7 @@ static void dmDumpCfg() {
|
|||
}
|
||||
|
||||
static int32_t dmInitLog() {
|
||||
char logName[12] = {0};
|
||||
snprintf(logName, sizeof(logName), "%slog", dmNodeLogName(global.ntype));
|
||||
return taosCreateLog(logName, 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0);
|
||||
}
|
||||
|
||||
static void dmSetProcInfo(int32_t argc, char **argv) {
|
||||
taosSetProcPath(argc, argv);
|
||||
if (global.ntype != DNODE && global.ntype != NODE_END) {
|
||||
const char *name = dmNodeProcName(global.ntype);
|
||||
taosSetProcName(argc, argv, name);
|
||||
}
|
||||
return taosCreateLog("taosdlog", 1, configDir, global.envCmd, global.envFile, global.apolloUrl, global.pArgs, 0);
|
||||
}
|
||||
|
||||
static void taosCleanupArgs() {
|
||||
|
@ -234,6 +208,7 @@ int mainWindows(int argc, char **argv) {
|
|||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
taosConvDestroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -242,13 +217,14 @@ int mainWindows(int argc, char **argv) {
|
|||
taosCleanupCfg();
|
||||
taosCloseLog();
|
||||
taosCleanupArgs();
|
||||
taosConvDestroy();
|
||||
return 0;
|
||||
}
|
||||
|
||||
dmSetProcInfo(argc, (char **)argv);
|
||||
osSetProcPath(argc, (char **)argv);
|
||||
taosCleanupArgs();
|
||||
|
||||
if (dmInit(global.ntype) != 0) {
|
||||
if (dmInit() != 0) {
|
||||
dError("failed to init dnode since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
aux_source_directory(src MGMT_BNODE)
|
||||
add_library(mgmt_bnode STATIC ${MGMT_BNODE})
|
||||
target_include_directories(
|
||||
mgmt_bnode
|
||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||
)
|
||||
target_link_libraries(
|
||||
mgmt_bnode node_util
|
||||
)
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef _TD_DND_BNODE_INT_H_
|
||||
#define _TD_DND_BNODE_INT_H_
|
||||
|
||||
#include "dmUtil.h"
|
||||
|
||||
#include "bnode.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SBnodeMgmt {
|
||||
SDnodeData *pData;
|
||||
SBnode *pBnode;
|
||||
SMsgCb msgCb;
|
||||
const char *path;
|
||||
const char *name;
|
||||
SMultiWorker writeWorker;
|
||||
SSingleWorker monitorWorker;
|
||||
} SBnodeMgmt;
|
||||
|
||||
// bmHandle.c
|
||||
SArray *bmGetMsgHandles();
|
||||
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// bmWorker.c
|
||||
int32_t bmStartWorker(SBnodeMgmt *pMgmt);
|
||||
void bmStopWorker(SBnodeMgmt *pMgmt);
|
||||
int32_t bmPutNodeMsgToWriteQueue(SBnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t bmPutNodeMsgToMonitorQueue(SBnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_DND_BNODE_INT_H_*/
|
|
@ -1,105 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http:www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "bmInt.h"
|
||||
|
||||
void bmGetMonitorInfo(SBnodeMgmt *pMgmt, SMonBmInfo *bmInfo) {}
|
||||
|
||||
int32_t bmProcessGetMonBmInfoReq(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonBmInfo bmInfo = {0};
|
||||
bmGetMonitorInfo(pMgmt, &bmInfo);
|
||||
dmGetMonitorSystemInfo(&bmInfo.sys);
|
||||
monGetLogs(&bmInfo.log);
|
||||
|
||||
int32_t rspLen = tSerializeSMonBmInfo(NULL, 0, &bmInfo);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonBmInfo(pRsp, rspLen, &bmInfo);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonBmInfo(&bmInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t bmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDCreateBnodeReq createReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pInput->pData->dnodeId != 0 && createReq.dnodeId != pInput->pData->dnodeId) {
|
||||
terrno = TSDB_CODE_INVALID_OPTION;
|
||||
dError("failed to create bnode since %s, input:%d cur:%d", terrstr(), createReq.dnodeId, pInput->pData->dnodeId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool deployed = true;
|
||||
if (dmWriteFile(pInput->path, pInput->name, deployed) != 0) {
|
||||
dError("failed to write bnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t bmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDDropBnodeReq dropReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pInput->pData->dnodeId != 0 && dropReq.dnodeId != pInput->pData->dnodeId) {
|
||||
terrno = TSDB_CODE_INVALID_OPTION;
|
||||
dError("failed to drop bnode since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool deployed = false;
|
||||
if (dmWriteFile(pInput->path, pInput->name, deployed) != 0) {
|
||||
dError("failed to write bnode file since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SArray *bmGetMsgHandles() {
|
||||
int32_t code = -1;
|
||||
SArray *pArray = taosArrayInit(2, sizeof(SMgmtHandle));
|
||||
if (pArray == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_BM_INFO, bmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
_OVER:
|
||||
if (code != 0) {
|
||||
taosArrayDestroy(pArray);
|
||||
return NULL;
|
||||
} else {
|
||||
return pArray;
|
||||
}
|
||||
}
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http:www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "bmInt.h"
|
||||
|
||||
static int32_t bmRequire(const SMgmtInputOpt *pInput, bool *required) {
|
||||
return dmReadFile(pInput->path, pInput->name, required);
|
||||
}
|
||||
|
||||
static void bmInitOption(SBnodeMgmt *pMgmt, SBnodeOpt *pOption) { pOption->msgCb = pMgmt->msgCb; }
|
||||
|
||||
static void bmClose(SBnodeMgmt *pMgmt) {
|
||||
if (pMgmt->pBnode != NULL) {
|
||||
bmStopWorker(pMgmt);
|
||||
bndClose(pMgmt->pBnode);
|
||||
pMgmt->pBnode = NULL;
|
||||
}
|
||||
|
||||
taosMemoryFree(pMgmt);
|
||||
}
|
||||
|
||||
int32_t bmOpen(SMgmtInputOpt *pInput, SMgmtOutputOpt *pOutput) {
|
||||
SBnodeMgmt *pMgmt = taosMemoryCalloc(1, sizeof(SBnodeMgmt));
|
||||
if (pMgmt == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
pMgmt->pData = pInput->pData;
|
||||
pMgmt->path = pInput->path;
|
||||
pMgmt->name = pInput->name;
|
||||
pMgmt->msgCb = pInput->msgCb;
|
||||
pMgmt->msgCb.mgmt = pMgmt;
|
||||
|
||||
SBnodeOpt option = {0};
|
||||
bmInitOption(pMgmt, &option);
|
||||
pMgmt->pBnode = bndOpen(pMgmt->path, &option);
|
||||
if (pMgmt->pBnode == NULL) {
|
||||
dError("failed to open bnode since %s", terrstr());
|
||||
bmClose(pMgmt);
|
||||
return -1;
|
||||
}
|
||||
tmsgReportStartup("bnode-impl", "initialized");
|
||||
|
||||
if (bmStartWorker(pMgmt) != 0) {
|
||||
dError("failed to start bnode worker since %s", terrstr());
|
||||
bmClose(pMgmt);
|
||||
return -1;
|
||||
}
|
||||
tmsgReportStartup("bnode-worker", "initialized");
|
||||
|
||||
pOutput->pMgmt = pMgmt;
|
||||
return 0;
|
||||
}
|
||||
|
||||
SMgmtFunc bmGetMgmtFunc() {
|
||||
SMgmtFunc mgmtFunc = {0};
|
||||
mgmtFunc.openFp = bmOpen;
|
||||
mgmtFunc.closeFp = (NodeCloseFp)bmClose;
|
||||
mgmtFunc.createFp = (NodeCreateFp)bmProcessCreateReq;
|
||||
mgmtFunc.dropFp = (NodeDropFp)bmProcessDropReq;
|
||||
mgmtFunc.requiredFp = bmRequire;
|
||||
mgmtFunc.getHandlesFp = bmGetMsgHandles;
|
||||
|
||||
return mgmtFunc;
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||
*
|
||||
* This program is free software: you can use, redistribute, and/or modify
|
||||
* it under the terms of the GNU Affero General Public License, version 3
|
||||
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http:www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#define _DEFAULT_SOURCE
|
||||
#include "bmInt.h"
|
||||
|
||||
static void bmSendErrorRsp(SRpcMsg *pMsg, int32_t code) {
|
||||
SRpcMsg rsp = {.code = code, .info = pMsg->info};
|
||||
tmsgSendRsp(&rsp);
|
||||
|
||||
dTrace("msg:%p, is freed", pMsg);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
||||
static void bmSendErrorRsps(STaosQall *qall, int32_t numOfMsgs, int32_t code) {
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
SRpcMsg *pMsg = NULL;
|
||||
taosGetQitem(qall, (void **)&pMsg);
|
||||
if (pMsg != NULL) {
|
||||
bmSendErrorRsp(pMsg, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void bmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
||||
SRpcMsg rsp = {
|
||||
.code = code,
|
||||
.pCont = pMsg->info.rsp,
|
||||
.contLen = pMsg->info.rspLen,
|
||||
.info = pMsg->info,
|
||||
};
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
||||
static void bmProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SBnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
dTrace("msg:%p, get from bnode-monitor queue", pMsg);
|
||||
|
||||
if (pMsg->msgType == TDMT_MON_BM_INFO) {
|
||||
code = bmProcessGetMonBmInfoReq(pMgmt, pMsg);
|
||||
} else {
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
}
|
||||
|
||||
if (IsReq(pMsg)) {
|
||||
if (code != 0 && terrno != 0) code = terrno;
|
||||
bmSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
||||
static void bmProcessWriteQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SBnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
|
||||
SArray *pArray = taosArrayInit(numOfMsgs, sizeof(SRpcMsg *));
|
||||
if (pArray == NULL) {
|
||||
bmSendErrorRsps(qall, numOfMsgs, TSDB_CODE_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
SRpcMsg *pMsg = NULL;
|
||||
taosGetQitem(qall, (void **)&pMsg);
|
||||
if (pMsg != NULL) {
|
||||
dTrace("msg:%p, get from bnode-write queue", pMsg);
|
||||
if (taosArrayPush(pArray, &pMsg) == NULL) {
|
||||
bmSendErrorRsp(pMsg, TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bndProcessWMsgs(pMgmt->pBnode, pArray);
|
||||
|
||||
for (size_t i = 0; i < numOfMsgs; i++) {
|
||||
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayGet(pArray, i);
|
||||
if (pMsg != NULL) {
|
||||
dTrace("msg:%p, is freed", pMsg);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
}
|
||||
taosArrayDestroy(pArray);
|
||||
}
|
||||
|
||||
int32_t bmPutNodeMsgToWriteQueue(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMultiWorker *pWorker = &pMgmt->writeWorker;
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t bmPutNodeMsgToMonitorQueue(SBnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
||||
|
||||
dTrace("msg:%p, put into worker:%s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t bmStartWorker(SBnodeMgmt *pMgmt) {
|
||||
SMultiWorkerCfg cfg = {
|
||||
.max = 1,
|
||||
.name = "bnode-write",
|
||||
.fp = (FItems)bmProcessWriteQueue,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tMultiWorkerInit(&pMgmt->writeWorker, &cfg) != 0) {
|
||||
dError("failed to start bnode-write worker since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
SSingleWorkerCfg mCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "bnode-monitor",
|
||||
.fp = (FItem)bmProcessMonitorQueue,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
||||
dError("failed to start bnode-monitor worker since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
dDebug("bnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bmStopWorker(SBnodeMgmt *pMgmt) {
|
||||
tSingleWorkerCleanup(&pMgmt->monitorWorker);
|
||||
tMultiWorkerCleanup(&pMgmt->writeWorker);
|
||||
dDebug("bnode workers are closed");
|
||||
}
|
|
@ -326,8 +326,6 @@ SArray *dmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SERVER_STATUS, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_SYSTABLE_RETRIEVE, dmPutNodeMsgToMgmtQueue, 0) == NULL) goto _OVER;
|
||||
|
|
|
@ -132,12 +132,6 @@ static void dmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
case TDMT_DND_DROP_SNODE:
|
||||
code = (*pMgmt->processDropNodeFp)(SNODE, pMsg);
|
||||
break;
|
||||
case TDMT_DND_CREATE_BNODE:
|
||||
code = (*pMgmt->processCreateNodeFp)(BNODE, pMsg);
|
||||
break;
|
||||
case TDMT_DND_DROP_BNODE:
|
||||
code = (*pMgmt->processDropNodeFp)(BNODE, pMsg);
|
||||
break;
|
||||
case TDMT_DND_SERVER_STATUS:
|
||||
code = dmProcessServerRunStatus(pMgmt, pMsg);
|
||||
break;
|
||||
|
|
|
@ -34,7 +34,6 @@ typedef struct SMnodeMgmt {
|
|||
SSingleWorker readWorker;
|
||||
SSingleWorker writeWorker;
|
||||
SSingleWorker syncWorker;
|
||||
SSingleWorker monitorWorker;
|
||||
bool stopped;
|
||||
int32_t refCount;
|
||||
TdThreadRwlock lock;
|
||||
|
@ -48,8 +47,6 @@ int32_t mmWriteFile(const char *path, const SMnodeOpt *pOption);
|
|||
SArray *mmGetMsgHandles();
|
||||
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// mmWorker.c
|
||||
int32_t mmStartWorker(SMnodeMgmt *pMgmt);
|
||||
|
@ -59,7 +56,6 @@ int32_t mmPutMsgToSyncQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|||
int32_t mmPutMsgToReadQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmPutMsgToQueryQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -20,58 +20,11 @@ void mmGetMonitorInfo(SMnodeMgmt *pMgmt, SMonMmInfo *pInfo) {
|
|||
mndGetMonitorInfo(pMgmt->pMnode, &pInfo->cluster, &pInfo->vgroup, &pInfo->stb, &pInfo->grant);
|
||||
}
|
||||
|
||||
int32_t mmProcessGetMonitorInfoReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonMmInfo mmInfo = {0};
|
||||
mmGetMonitorInfo(pMgmt, &mmInfo);
|
||||
dmGetMonitorSystemInfo(&mmInfo.sys);
|
||||
monGetLogs(&mmInfo.log);
|
||||
|
||||
int32_t rspLen = tSerializeSMonMmInfo(NULL, 0, &mmInfo);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonMmInfo(pRsp, rspLen, &mmInfo);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonMmInfo(&mmInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void mmGetMnodeLoads(SMnodeMgmt *pMgmt, SMonMloadInfo *pInfo) {
|
||||
pInfo->isMnode = 1;
|
||||
mndGetLoad(pMgmt->pMnode, &pInfo->load);
|
||||
}
|
||||
|
||||
int32_t mmProcessGetLoadsReq(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonMloadInfo mloads = {0};
|
||||
mmGetMnodeLoads(pMgmt, &mloads);
|
||||
|
||||
int32_t rspLen = tSerializeSMonMloadInfo(NULL, 0, &mloads);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonMloadInfo(pRsp, rspLen, &mloads);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
SDCreateMnodeReq createReq = {0};
|
||||
|
@ -105,7 +58,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
|||
int32_t mmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
SDDropMnodeReq dropReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
@ -136,8 +89,6 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_QNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_SNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_BNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CREATE_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_DROP_VNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_DND_CONFIG_DNODE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -163,8 +114,6 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_MND_DNODE_LIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_SNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_BNODE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MND_USE_DB, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -234,9 +183,6 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_HASHRANGE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_COMPACT_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_INFO, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_MM_LOAD, mmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_TIMEOUT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PING_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
|
|
|
@ -46,22 +46,12 @@ static inline void mmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
|||
|
||||
static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SMnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
pMsg->info.node = pMgmt->pMnode;
|
||||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
dGTrace("msg:%p, get from mnode queue", pMsg);
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_MON_MM_INFO:
|
||||
code = mmProcessGetMonitorInfoReq(pMgmt, pMsg);
|
||||
break;
|
||||
case TDMT_MON_MM_LOAD:
|
||||
code = mmProcessGetLoadsReq(pMgmt, pMsg);
|
||||
break;
|
||||
default:
|
||||
pMsg->info.node = pMgmt->pMnode;
|
||||
code = mndProcessRpcMsg(pMsg);
|
||||
}
|
||||
int32_t code = mndProcessRpcMsg(pMsg);
|
||||
|
||||
if (IsReq(pMsg) && pMsg->info.handle != NULL && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
if (code != 0 && terrno != 0) code = terrno;
|
||||
|
@ -136,10 +126,6 @@ int32_t mmPutMsgToFetchQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return mmPutMsgToWorker(pMgmt, &pMgmt->fetchWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutMsgToMonitorQueue(SMnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return mmPutMsgToWorker(pMgmt, &pMgmt->monitorWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t mmPutMsgToQueue(SMnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||
SSingleWorker *pWorker = NULL;
|
||||
switch (qtype) {
|
||||
|
@ -237,18 +223,6 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SSingleWorkerCfg mCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "mnode-monitor",
|
||||
.fp = (FItem)mmProcessRpcMsg,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
||||
dError("failed to start mnode mnode-monitor worker since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
dDebug("mnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
@ -256,7 +230,6 @@ int32_t mmStartWorker(SMnodeMgmt *pMgmt) {
|
|||
void mmStopWorker(SMnodeMgmt *pMgmt) {
|
||||
while (pMgmt->refCount > 0) taosMsleep(10);
|
||||
|
||||
tSingleWorkerCleanup(&pMgmt->monitorWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->fetchWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->readWorker);
|
||||
|
|
|
@ -32,14 +32,12 @@ typedef struct SQnodeMgmt {
|
|||
const char *name;
|
||||
SSingleWorker queryWorker;
|
||||
SSingleWorker fetchWorker;
|
||||
SSingleWorker monitorWorker;
|
||||
} SQnodeMgmt;
|
||||
|
||||
// qmHandle.c
|
||||
SArray *qmGetMsgHandles();
|
||||
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// qmWorker.c
|
||||
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pMsg);
|
||||
|
@ -49,7 +47,6 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt);
|
|||
void qmStopWorker(SQnodeMgmt *pMgmt);
|
||||
int32_t qmPutNodeMsgToQueryQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
int32_t qndPreprocessQueryMsg(SQnode *pQnode, SRpcMsg *pMsg);
|
||||
|
||||
|
|
|
@ -29,34 +29,9 @@ void qmGetQnodeLoads(SQnodeMgmt *pMgmt, SQnodeLoad *pInfo) {
|
|||
pInfo->dnodeId = pMgmt->pData->dnodeId;
|
||||
}
|
||||
|
||||
int32_t qmProcessGetMonitorInfoReq(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonQmInfo qmInfo = {0};
|
||||
qmGetMonitorInfo(pMgmt, &qmInfo);
|
||||
dmGetMonitorSystemInfo(&qmInfo.sys);
|
||||
monGetLogs(&qmInfo.log);
|
||||
|
||||
int32_t rspLen = tSerializeSMonQmInfo(NULL, 0, &qmInfo);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonQmInfo(pRsp, rspLen, &qmInfo);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonQmInfo(&qmInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDCreateQnodeReq createReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
@ -78,7 +53,7 @@ int32_t qmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t qmProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDDropQnodeReq dropReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
@ -103,8 +78,6 @@ SArray *qmGetMsgHandles() {
|
|||
SArray *pArray = taosArrayInit(16, sizeof(SMgmtHandle));
|
||||
if (pArray == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_QM_INFO, qmPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
// Requests handled by VNODE
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, qmPutNodeMsgToQueryQueue, 1) == NULL) goto _OVER;
|
||||
|
|
|
@ -28,18 +28,9 @@ static inline void qmSendRsp(SRpcMsg *pMsg, int32_t code) {
|
|||
|
||||
static void qmProcessQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SQnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
dTrace("msg:%p, get from qnode queue", pMsg);
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_MON_QM_INFO:
|
||||
code = qmProcessGetMonitorInfoReq(pMgmt, pMsg);
|
||||
break;
|
||||
default:
|
||||
code = qndProcessQueryMsg(pMgmt->pQnode, pInfo->timestamp, pMsg);
|
||||
break;
|
||||
}
|
||||
|
||||
int32_t code = qndProcessQueryMsg(pMgmt->pQnode, pInfo->timestamp, pMsg);
|
||||
if (IsReq(pMsg) && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
if (code != 0 && terrno != 0) code = terrno;
|
||||
qmSendRsp(pMsg, code);
|
||||
|
@ -66,10 +57,6 @@ int32_t qmPutNodeMsgToFetchQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return qmPutNodeMsgToWorker(&pMgmt->fetchWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t qmPutNodeMsgToMonitorQueue(SQnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return qmPutNodeMsgToWorker(&pMgmt->monitorWorker, pMsg);
|
||||
}
|
||||
|
||||
int32_t qmPutRpcMsgToQueue(SQnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
if (pMsg == NULL) return -1;
|
||||
|
@ -136,24 +123,11 @@ int32_t qmStartWorker(SQnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SSingleWorkerCfg mCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "qnode-monitor",
|
||||
.fp = (FItem)qmProcessQueue,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
||||
dError("failed to start qnode-monitor worker since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
dDebug("qnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void qmStopWorker(SQnodeMgmt *pMgmt) {
|
||||
tSingleWorkerCleanup(&pMgmt->monitorWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->queryWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->fetchWorker);
|
||||
dDebug("qnode workers are closed");
|
||||
|
|
|
@ -33,14 +33,12 @@ typedef struct SSnodeMgmt {
|
|||
int8_t uniqueWorkerInUse;
|
||||
SArray *uniqueWorkers; // SArray<SMultiWorker*>
|
||||
SSingleWorker sharedWorker;
|
||||
SSingleWorker monitorWorker;
|
||||
} SSnodeMgmt;
|
||||
|
||||
// smHandle.c
|
||||
SArray *smGetMsgHandles();
|
||||
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg);
|
||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// smWorker.c
|
||||
int32_t smStartWorker(SSnodeMgmt *pMgmt);
|
||||
|
@ -49,7 +47,6 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
|||
int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t smPutNodeMsgToSharedQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t smPutNodeMsgToExecQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t smPutNodeMsgToMonitorQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,34 +18,9 @@
|
|||
|
||||
void smGetMonitorInfo(SSnodeMgmt *pMgmt, SMonSmInfo *smInfo) {}
|
||||
|
||||
int32_t smProcessGetMonitorInfoReq(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonSmInfo smInfo = {0};
|
||||
smGetMonitorInfo(pMgmt, &smInfo);
|
||||
dmGetMonitorSystemInfo(&smInfo.sys);
|
||||
monGetLogs(&smInfo.log);
|
||||
|
||||
int32_t rspLen = tSerializeSMonSmInfo(NULL, 0, &smInfo);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonSmInfo(pRsp, rspLen, &smInfo);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonSmInfo(&smInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDCreateSnodeReq createReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &createReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
@ -67,7 +42,7 @@ int32_t smProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
|||
|
||||
int32_t smProcessDropReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) {
|
||||
SDDropSnodeReq dropReq = {0};
|
||||
if (tDeserializeSCreateDropMQSBNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
if (tDeserializeSCreateDropMQSNodeReq(pMsg->pCont, pMsg->contLen, &dropReq) != 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
@ -92,8 +67,6 @@ SArray *smGetMsgHandles() {
|
|||
SArray *pArray = taosArrayInit(4, sizeof(SMgmtHandle));
|
||||
if (pArray == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_SM_INFO, smPutNodeMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DEPLOY, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_DROP, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RUN, smPutNodeMsgToSharedQueue, 1) == NULL) goto _OVER;
|
||||
|
|
|
@ -26,27 +26,6 @@ static inline void smSendRsp(SRpcMsg *pMsg, int32_t code) {
|
|||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
|
||||
static void smProcessMonitorQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
||||
SSnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
int32_t code = -1;
|
||||
dTrace("msg:%p, get from snode-monitor queue", pMsg);
|
||||
|
||||
if (pMsg->msgType == TDMT_MON_SM_INFO) {
|
||||
code = smProcessGetMonitorInfoReq(pMgmt, pMsg);
|
||||
} else {
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
}
|
||||
|
||||
if (IsReq(pMsg)) {
|
||||
if (code != 0 && terrno != 0) code = terrno;
|
||||
smSendRsp(pMsg, code);
|
||||
}
|
||||
|
||||
dTrace("msg:%p, is freed, code:0x%x", pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
|
||||
static void smProcessUniqueQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SSnodeMgmt *pMgmt = pInfo->ahandle;
|
||||
|
||||
|
@ -123,24 +102,11 @@ int32_t smStartWorker(SSnodeMgmt *pMgmt) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
SSingleWorkerCfg mCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "snode-monitor",
|
||||
.fp = (FItem)smProcessMonitorQueue,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &mCfg) != 0) {
|
||||
dError("failed to start snode-monitor worker since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
dDebug("snode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void smStopWorker(SSnodeMgmt *pMgmt) {
|
||||
tSingleWorkerCleanup(&pMgmt->monitorWorker);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pMgmt->uniqueWorkers); i++) {
|
||||
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, i);
|
||||
tMultiWorkerCleanup(pWorker);
|
||||
|
@ -175,14 +141,6 @@ int32_t smPutNodeMsgToMgmtQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t smPutNodeMsgToMonitorQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SSingleWorker *pWorker = &pMgmt->monitorWorker;
|
||||
|
||||
dTrace("msg:%p, put into worker %s", pMsg, pWorker->name);
|
||||
taosWriteQitem(pWorker->queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t smPutNodeMsgToUniqueQueue(SSnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
int32_t index = smGetSWIdFromMsg(pMsg);
|
||||
SMultiWorker *pWorker = taosArrayGetP(pMgmt->uniqueWorkers, index);
|
||||
|
|
|
@ -34,10 +34,10 @@ typedef struct SVnodeMgmt {
|
|||
SQWorkerPool streamPool;
|
||||
SWWorkerPool fetchPool;
|
||||
SWWorkerPool syncPool;
|
||||
SWWorkerPool syncCtrlPool;
|
||||
SWWorkerPool writePool;
|
||||
SWWorkerPool applyPool;
|
||||
SSingleWorker mgmtWorker;
|
||||
SSingleWorker monitorWorker;
|
||||
SHashObj *hash;
|
||||
TdThreadRwlock lock;
|
||||
SVnodesStat state;
|
||||
|
@ -60,6 +60,7 @@ typedef struct {
|
|||
SVnode *pImpl;
|
||||
STaosQueue *pWriteQ;
|
||||
STaosQueue *pSyncQ;
|
||||
STaosQueue *pSyncCtrlQ;
|
||||
STaosQueue *pApplyQ;
|
||||
STaosQueue *pQueryQ;
|
||||
STaosQueue *pStreamQ;
|
||||
|
@ -87,8 +88,6 @@ void vmCloseVnode(SVnodeMgmt *pMgmt, SVnodeObj *pVnode);
|
|||
SArray *vmGetMsgHandles();
|
||||
int32_t vmProcessCreateVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmProcessDropVnodeReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
// vmFile.c
|
||||
int32_t vmGetVnodeListFromFile(SVnodeMgmt *pMgmt, SWrapperCfg **ppCfgs, int32_t *numOfVnodes);
|
||||
|
@ -106,12 +105,12 @@ int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc);
|
|||
|
||||
int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToFetchQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToStreamQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToMergeQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -83,54 +83,6 @@ void vmGetMonitorInfo(SVnodeMgmt *pMgmt, SMonVmInfo *pInfo) {
|
|||
taosArrayDestroy(pVloads);
|
||||
}
|
||||
|
||||
int32_t vmProcessGetMonitorInfoReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonVmInfo vmInfo = {0};
|
||||
vmGetMonitorInfo(pMgmt, &vmInfo);
|
||||
dmGetMonitorSystemInfo(&vmInfo.sys);
|
||||
monGetLogs(&vmInfo.log);
|
||||
|
||||
int32_t rspLen = tSerializeSMonVmInfo(NULL, 0, &vmInfo);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonVmInfo(pRsp, rspLen, &vmInfo);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonVmInfo(&vmInfo);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vmProcessGetLoadsReq(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
SMonVloadInfo vloads = {0};
|
||||
vmGetVnodeLoads(pMgmt, &vloads, false);
|
||||
|
||||
int32_t rspLen = tSerializeSMonVloadInfo(NULL, 0, &vloads);
|
||||
if (rspLen < 0) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *pRsp = rpcMallocCont(rspLen);
|
||||
if (pRsp == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
tSerializeSMonVloadInfo(pRsp, rspLen, &vloads);
|
||||
pMsg->info.rsp = pRsp;
|
||||
pMsg->info.rspLen = rspLen;
|
||||
tFreeSMonVloadInfo(&vloads);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
|
||||
memcpy(pCfg, &vnodeCfgDefault, sizeof(SVnodeCfg));
|
||||
|
||||
|
@ -348,9 +300,6 @@ SArray *vmGetMsgHandles() {
|
|||
SArray *pArray = taosArrayInit(32, sizeof(SMgmtHandle));
|
||||
if (pArray == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_VM_INFO, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_MON_VM_LOAD, vmPutMsgToMonitorQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_VND_SUBMIT, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SCH_MERGE_QUERY, vmPutMsgToQueryQueue, 0) == NULL) goto _OVER;
|
||||
|
@ -422,6 +371,8 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_SEND, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SNAPSHOT_RSP, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_SET_VNODE_STANDBY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
|
|
|
@ -217,17 +217,80 @@ static int32_t vmOpenVnodes(SVnodeMgmt *pMgmt) {
|
|||
}
|
||||
}
|
||||
|
||||
static void *vmCloseVnodeInThread(void *param) {
|
||||
SVnodeThread *pThread = param;
|
||||
SVnodeMgmt *pMgmt = pThread->pMgmt;
|
||||
|
||||
dInfo("thread:%d, start to close %d vnodes", pThread->threadIndex, pThread->vnodeNum);
|
||||
setThreadName("close-vnodes");
|
||||
|
||||
for (int32_t v = 0; v < pThread->vnodeNum; ++v) {
|
||||
SVnodeObj *pVnode = pThread->ppVnodes[v];
|
||||
|
||||
char stepDesc[TSDB_STEP_DESC_LEN] = {0};
|
||||
snprintf(stepDesc, TSDB_STEP_DESC_LEN, "vgId:%d, start to close, %d of %d have been closed", pVnode->vgId,
|
||||
pMgmt->state.openVnodes, pMgmt->state.totalVnodes);
|
||||
tmsgReportStartup("vnode-close", stepDesc);
|
||||
|
||||
vmCloseVnode(pMgmt, pVnode);
|
||||
}
|
||||
|
||||
dInfo("thread:%d, numOfVnodes:%d is closed", pThread->threadIndex, pThread->vnodeNum);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void vmCloseVnodes(SVnodeMgmt *pMgmt) {
|
||||
dInfo("start to close all vnodes");
|
||||
|
||||
int32_t numOfVnodes = 0;
|
||||
SVnodeObj **ppVnodes = vmGetVnodeListFromHash(pMgmt, &numOfVnodes);
|
||||
|
||||
for (int32_t i = 0; i < numOfVnodes; ++i) {
|
||||
if (ppVnodes == NULL || ppVnodes[i] == NULL) continue;
|
||||
vmCloseVnode(pMgmt, ppVnodes[i]);
|
||||
int32_t threadNum = tsNumOfCores / 2;
|
||||
if (threadNum < 1) threadNum = 1;
|
||||
int32_t vnodesPerThread = numOfVnodes / threadNum + 1;
|
||||
|
||||
SVnodeThread *threads = taosMemoryCalloc(threadNum, sizeof(SVnodeThread));
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
threads[t].threadIndex = t;
|
||||
threads[t].pMgmt = pMgmt;
|
||||
threads[t].ppVnodes = taosMemoryCalloc(vnodesPerThread, sizeof(SVnode *));
|
||||
}
|
||||
|
||||
for (int32_t v = 0; v < numOfVnodes; ++v) {
|
||||
int32_t t = v % threadNum;
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->ppVnodes != NULL && ppVnodes != NULL) {
|
||||
pThread->ppVnodes[pThread->vnodeNum++] = ppVnodes[v];
|
||||
}
|
||||
}
|
||||
|
||||
pMgmt->state.openVnodes = 0;
|
||||
dInfo("close %d vnodes with %d threads", numOfVnodes, threadNum);
|
||||
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->vnodeNum == 0) continue;
|
||||
|
||||
TdThreadAttr thAttr;
|
||||
taosThreadAttrInit(&thAttr);
|
||||
taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_JOINABLE);
|
||||
if (taosThreadCreate(&pThread->thread, &thAttr, vmCloseVnodeInThread, pThread) != 0) {
|
||||
dError("thread:%d, failed to create thread to close vnode since %s", pThread->threadIndex, strerror(errno));
|
||||
}
|
||||
|
||||
taosThreadAttrDestroy(&thAttr);
|
||||
}
|
||||
|
||||
for (int32_t t = 0; t < threadNum; ++t) {
|
||||
SVnodeThread *pThread = &threads[t];
|
||||
if (pThread->vnodeNum > 0 && taosCheckPthreadValid(pThread->thread)) {
|
||||
taosThreadJoin(pThread->thread, NULL);
|
||||
taosThreadClear(&pThread->thread);
|
||||
}
|
||||
taosMemoryFree(pThread->ppVnodes);
|
||||
}
|
||||
taosMemoryFree(threads);
|
||||
|
||||
if (ppVnodes != NULL) {
|
||||
taosMemoryFree(ppVnodes);
|
||||
}
|
||||
|
|
|
@ -34,12 +34,6 @@ static void vmProcessMgmtQueue(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
|
||||
dGTrace("msg:%p, get from vnode-mgmt queue", pMsg);
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_MON_VM_INFO:
|
||||
code = vmProcessGetMonitorInfoReq(pMgmt, pMsg);
|
||||
break;
|
||||
case TDMT_MON_VM_LOAD:
|
||||
code = vmProcessGetLoadsReq(pMgmt, pMsg);
|
||||
break;
|
||||
case TDMT_DND_CREATE_VNODE:
|
||||
code = vmProcessCreateVnodeReq(pMgmt, pMsg);
|
||||
break;
|
||||
|
@ -136,6 +130,22 @@ static void vmProcessSyncQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOf
|
|||
}
|
||||
}
|
||||
|
||||
static void vmProcessSyncCtrlQueue(SQueueInfo *pInfo, STaosQall *qall, int32_t numOfMsgs) {
|
||||
SVnodeObj *pVnode = pInfo->ahandle;
|
||||
SRpcMsg *pMsg = NULL;
|
||||
|
||||
for (int32_t i = 0; i < numOfMsgs; ++i) {
|
||||
if (taosGetQitem(qall, (void **)&pMsg) == 0) continue;
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
dGTrace("vgId:%d, msg:%p get from vnode-sync queue", pVnode->vgId, pMsg);
|
||||
|
||||
int32_t code = vnodeProcessSyncCtrlMsg(pVnode->pImpl, pMsg, NULL); // no response here
|
||||
dGTrace("vgId:%d, msg:%p is freed, code:0x%x", pVnode->vgId, pMsg, code);
|
||||
rpcFreeCont(pMsg->pCont);
|
||||
taosFreeQitem(pMsg);
|
||||
}
|
||||
}
|
||||
|
||||
static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtype) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
SMsgHead *pHead = pMsg->pCont;
|
||||
|
@ -203,6 +213,10 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
dGTrace("vgId:%d, msg:%p put into vnode-sync queue", pVnode->vgId, pMsg);
|
||||
taosWriteQitem(pVnode->pSyncQ, pMsg);
|
||||
break;
|
||||
case SYNC_CTRL_QUEUE:
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-sync-ctrl queue", pVnode->vgId, pMsg);
|
||||
taosWriteQitem(pVnode->pSyncCtrlQ, pMsg);
|
||||
break;
|
||||
case APPLY_QUEUE:
|
||||
dGTrace("vgId:%d, msg:%p put into vnode-apply queue", pVnode->vgId, pMsg);
|
||||
taosWriteQitem(pVnode->pApplyQ, pMsg);
|
||||
|
@ -219,6 +233,10 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
|
||||
int32_t vmPutMsgToSyncQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, SYNC_QUEUE); }
|
||||
|
||||
int32_t vmPutMsgToSyncCtrlQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
return vmPutMsgToQueue(pMgmt, pMsg, SYNC_CTRL_QUEUE);
|
||||
}
|
||||
|
||||
int32_t vmPutMsgToWriteQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, WRITE_QUEUE); }
|
||||
|
||||
int32_t vmPutMsgToQueryQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) { return vmPutMsgToQueue(pMgmt, pMsg, QUERY_QUEUE); }
|
||||
|
@ -234,13 +252,6 @@ int32_t vmPutMsgToMgmtQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t vmPutMsgToMonitorQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg) {
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
dGTrace("msg:%p, put into vnode-monitor queue", pMsg);
|
||||
taosWriteQitem(pMgmt->monitorWorker.queue, pMsg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t vmPutRpcMsgToQueue(SVnodeMgmt *pMgmt, EQueueType qtype, SRpcMsg *pRpc) {
|
||||
SRpcMsg *pMsg = taosAllocateQitem(sizeof(SRpcMsg), RPC_QITEM);
|
||||
if (pMsg == NULL) {
|
||||
|
@ -301,6 +312,7 @@ int32_t vmGetQueueSize(SVnodeMgmt *pMgmt, int32_t vgId, EQueueType qtype) {
|
|||
int32_t vmAllocQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
||||
pVnode->pWriteQ = tWWorkerAllocQueue(&pMgmt->writePool, pVnode->pImpl, (FItems)vnodeProposeWriteMsg);
|
||||
pVnode->pSyncQ = tWWorkerAllocQueue(&pMgmt->syncPool, pVnode, (FItems)vmProcessSyncQueue);
|
||||
pVnode->pSyncCtrlQ = tWWorkerAllocQueue(&pMgmt->syncCtrlPool, pVnode, (FItems)vmProcessSyncCtrlQueue);
|
||||
pVnode->pApplyQ = tWWorkerAllocQueue(&pMgmt->applyPool, pVnode->pImpl, (FItems)vnodeApplyWriteMsg);
|
||||
pVnode->pQueryQ = tQWorkerAllocQueue(&pMgmt->queryPool, pVnode, (FItem)vmProcessQueryQueue);
|
||||
pVnode->pStreamQ = tQWorkerAllocQueue(&pMgmt->streamPool, pVnode, (FItem)vmProcessStreamQueue);
|
||||
|
@ -325,6 +337,7 @@ void vmFreeQueue(SVnodeMgmt *pMgmt, SVnodeObj *pVnode) {
|
|||
tWWorkerFreeQueue(&pMgmt->writePool, pVnode->pWriteQ);
|
||||
tWWorkerFreeQueue(&pMgmt->applyPool, pVnode->pApplyQ);
|
||||
tWWorkerFreeQueue(&pMgmt->syncPool, pVnode->pSyncQ);
|
||||
tWWorkerFreeQueue(&pMgmt->syncCtrlPool, pVnode->pSyncCtrlQ);
|
||||
tQWorkerFreeQueue(&pMgmt->queryPool, pVnode->pQueryQ);
|
||||
tQWorkerFreeQueue(&pMgmt->streamPool, pVnode->pStreamQ);
|
||||
tWWorkerFreeQueue(&pMgmt->fetchPool, pVnode->pFetchQ);
|
||||
|
@ -370,6 +383,11 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
|||
pSPool->max = tsNumOfVnodeSyncThreads;
|
||||
if (tWWorkerInit(pSPool) != 0) return -1;
|
||||
|
||||
SWWorkerPool *pSCPool = &pMgmt->syncCtrlPool;
|
||||
pSCPool->name = "vnode-sync-ctrl";
|
||||
pSCPool->max = tsNumOfVnodeSyncThreads;
|
||||
if (tWWorkerInit(pSCPool) != 0) return -1;
|
||||
|
||||
SSingleWorkerCfg mgmtCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
|
@ -379,25 +397,16 @@ int32_t vmStartWorker(SVnodeMgmt *pMgmt) {
|
|||
};
|
||||
if (tSingleWorkerInit(&pMgmt->mgmtWorker, &mgmtCfg) != 0) return -1;
|
||||
|
||||
SSingleWorkerCfg monitorCfg = {
|
||||
.min = 1,
|
||||
.max = 1,
|
||||
.name = "vnode-monitor",
|
||||
.fp = (FItem)vmProcessMgmtQueue,
|
||||
.param = pMgmt,
|
||||
};
|
||||
if (tSingleWorkerInit(&pMgmt->monitorWorker, &monitorCfg) != 0) return -1;
|
||||
|
||||
dDebug("vnode workers are initialized");
|
||||
return 0;
|
||||
}
|
||||
|
||||
void vmStopWorker(SVnodeMgmt *pMgmt) {
|
||||
tSingleWorkerCleanup(&pMgmt->monitorWorker);
|
||||
tSingleWorkerCleanup(&pMgmt->mgmtWorker);
|
||||
tWWorkerCleanup(&pMgmt->writePool);
|
||||
tWWorkerCleanup(&pMgmt->applyPool);
|
||||
tWWorkerCleanup(&pMgmt->syncPool);
|
||||
tWWorkerCleanup(&pMgmt->syncCtrlPool);
|
||||
tQWorkerCleanup(&pMgmt->queryPool);
|
||||
tQWorkerCleanup(&pMgmt->streamPool);
|
||||
tWWorkerCleanup(&pMgmt->fetchPool);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
aux_source_directory(src IMPLEMENT_SRC)
|
||||
add_library(dnode STATIC ${IMPLEMENT_SRC})
|
||||
target_link_libraries(
|
||||
dnode mgmt_bnode mgmt_mnode mgmt_qnode mgmt_snode mgmt_vnode mgmt_dnode
|
||||
dnode mgmt_mnode mgmt_qnode mgmt_snode mgmt_vnode mgmt_dnode
|
||||
)
|
||||
target_include_directories(
|
||||
dnode
|
||||
|
|
|
@ -25,44 +25,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SMgmtWrapper SMgmtWrapper;
|
||||
|
||||
#define SINGLE_PROC 0
|
||||
#define CHILD_PROC 1
|
||||
#define PARENT_PROC 2
|
||||
#define TEST_PROC 3
|
||||
#define OnlyInSingleProc(wrapper) ((wrapper)->proc.ptype == SINGLE_PROC)
|
||||
#define OnlyInChildProc(wrapper) ((wrapper)->proc.ptype == CHILD_PROC)
|
||||
#define OnlyInParentProc(wrapper) ((wrapper)->proc.ptype == PARENT_PROC)
|
||||
#define InChildProc(wrapper) ((wrapper)->proc.ptype & CHILD_PROC)
|
||||
#define InParentProc(wrapper) ((wrapper)->proc.ptype & PARENT_PROC)
|
||||
|
||||
typedef struct {
|
||||
int32_t head;
|
||||
int32_t tail;
|
||||
int32_t total;
|
||||
int32_t avail;
|
||||
int32_t items;
|
||||
char name[8];
|
||||
TdThreadMutex mutex;
|
||||
tsem_t sem;
|
||||
char pBuffer[];
|
||||
} SProcQueue;
|
||||
|
||||
typedef struct {
|
||||
SMgmtWrapper *wrapper;
|
||||
const char *name;
|
||||
SHashObj *hash;
|
||||
SProcQueue *pqueue;
|
||||
SProcQueue *cqueue;
|
||||
TdThread pthread;
|
||||
TdThread cthread;
|
||||
SShm shm;
|
||||
int32_t pid;
|
||||
EDndProcType ptype;
|
||||
bool stop;
|
||||
} SProc;
|
||||
|
||||
typedef struct SMgmtWrapper {
|
||||
SMgmtFunc func;
|
||||
struct SDnode *pDnode;
|
||||
|
@ -74,7 +36,6 @@ typedef struct SMgmtWrapper {
|
|||
EDndNodeType ntype;
|
||||
bool deployed;
|
||||
bool required;
|
||||
SProc proc;
|
||||
NodeMsgFp msgFps[TDMT_MAX];
|
||||
} SMgmtWrapper;
|
||||
|
||||
|
@ -111,8 +72,6 @@ typedef struct SUdfdData {
|
|||
typedef struct SDnode {
|
||||
int8_t once;
|
||||
bool stop;
|
||||
EDndProcType ptype;
|
||||
EDndNodeType rtype;
|
||||
EDndRunStatus status;
|
||||
SStartupInfo startup;
|
||||
SDnodeTrans trans;
|
||||
|
@ -128,7 +87,7 @@ SDnode *dmInstance();
|
|||
void dmReportStartup(const char *pName, const char *pDesc);
|
||||
|
||||
// dmMgmt.c
|
||||
int32_t dmInitDnode(SDnode *pDnode, EDndNodeType rtype);
|
||||
int32_t dmInitDnode(SDnode *pDnode);
|
||||
void dmCleanupDnode(SDnode *pDnode);
|
||||
SMgmtWrapper *dmAcquireWrapper(SDnode *pDnode, EDndNodeType nType);
|
||||
int32_t dmMarkWrapper(SMgmtWrapper *pWrapper);
|
||||
|
@ -145,16 +104,6 @@ void dmStopNode(SMgmtWrapper *pWrapper);
|
|||
void dmCloseNode(SMgmtWrapper *pWrapper);
|
||||
int32_t dmRunDnode(SDnode *pDnode);
|
||||
|
||||
// dmProc.c
|
||||
int32_t dmInitProc(struct SMgmtWrapper *pWrapper);
|
||||
void dmCleanupProc(struct SMgmtWrapper *pWrapper);
|
||||
int32_t dmRunProc(SProc *proc);
|
||||
void dmStopProc(SProc *proc);
|
||||
void dmRemoveProcRpcHandle(SProc *proc, void *handle);
|
||||
void dmCloseProcRpcHandles(SProc *proc);
|
||||
int32_t dmPutToProcCQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
|
||||
void dmPutToProcPQueue(SProc *proc, SRpcMsg *pMsg, EProcFuncType ftype);
|
||||
|
||||
// dmTransport.c
|
||||
int32_t dmInitServer(SDnode *pDnode);
|
||||
void dmCleanupServer(SDnode *pDnode);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue