Merge branch '3.0' of https://github.com/taosdata/TDengine into fix/TD-30837
This commit is contained in:
commit
b5f432bd50
|
@ -401,7 +401,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('linux test') {
|
||||
agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || slave1_59 || slave1_63 || worker03 || slave215 || slave217 || slave219 "}
|
||||
agent{label "slave1_47 || slave1_48 || slave1_49 || slave1_50 || slave1_52 || slave1_59 || slave1_63 || worker03 || slave215 || slave217 || slave219 "}
|
||||
options { skipDefaultCheckout() }
|
||||
when {
|
||||
changeRequest()
|
||||
|
@ -416,7 +416,7 @@ pipeline {
|
|||
echo "${WKDIR}/restore.sh -p ${BRANCH_NAME} -n ${BUILD_ID} -c {container name}"
|
||||
}
|
||||
catchError(buildResult: 'FAILURE', stageResult: 'FAILURE') {
|
||||
timeout(time: 150, unit: 'MINUTES'){
|
||||
timeout(time: 200, unit: 'MINUTES'){
|
||||
pre_test()
|
||||
script {
|
||||
sh '''
|
||||
|
@ -454,7 +454,7 @@ pipeline {
|
|||
cd ${WKC}/tests/parallel_test
|
||||
export DEFAULT_RETRY_TIME=2
|
||||
date
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 900 ''' + extra_param + '''
|
||||
''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 1200 ''' + extra_param + '''
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,7 @@ table_option: {
|
|||
7. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive.
|
||||
For example \`aBc\` and \`abc\` are different table names but `abc` and `aBc` are same table names because they are both converted to `abc` internally.
|
||||
Only ASCII visible characters can be used with escape character.
|
||||
8. For the details of using `ENCODE` and `COMPRESS`, please refer to [Encode and Compress for Column](../compress).
|
||||
|
||||
**Parameter description**
|
||||
|
||||
|
|
|
@ -13,17 +13,29 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
||||
table_option: {
|
||||
COMMENT 'string_value'
|
||||
| SMA(col_name [, col_name] ...)
|
||||
| TTL value
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
**More explanations**
|
||||
- Each supertable can have a maximum of 4096 columns, including tags. The minimum number of columns is 3: a timestamp column used as the key, one tag column, and one data column.
|
||||
- The TAGS keyword defines the tag columns for the supertable. The following restrictions apply to tag columns:
|
||||
1. Each supertable can have a maximum of 4096 columns, including tags. The minimum number of columns is 3: a timestamp column used as the key, one tag column, and one data column.
|
||||
2. Since version 3.3.0.0, besides the timestamp, you can specify another column as primary key using `PRIMARY KEY` keyword, the column specified using `primary key` must be type of integer or varchar.
|
||||
2. The TAGS keyword defines the tag columns for the supertable. The following restrictions apply to tag columns:
|
||||
- A tag column can use the TIMESTAMP data type, but the values in the column must be fixed numbers. Timestamps including formulae, such as "now + 10s", cannot be stored in a tag column.
|
||||
- The name of a tag column cannot be the same as the name of any other column.
|
||||
- The name of a tag column cannot be a reserved keyword.
|
||||
- Each supertable must contain between 1 and 128 tags. The total length of the TAGS keyword cannot exceed 16 KB.
|
||||
- For more information about table parameters, see Create a Table.
|
||||
3. Regarding how to use `ENCODE` and `COMPRESS`, please refer to [Encode and Compress for Column](../compress).
|
||||
3. For more information about table parameters, see [Create a Table](../table).
|
||||
|
||||
## View a Supertable
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ select _wstart, tbname, avg(voltage) from meters partition by tbname interval(10
|
|||
|
||||
## Windowed Queries
|
||||
|
||||
Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window. Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are four kinds of windows: time window, status window, session window, and event window. There are two kinds of time windows: sliding window and flip time/tumbling window. The syntax of window clause is as follows:
|
||||
Aggregation by time window is supported in TDengine. For example, in the case where temperature sensors report the temperature every seconds, the average temperature for every 10 minutes can be retrieved by performing a query with a time window. Window related clauses are used to divide the data set to be queried into subsets and then aggregation is performed across the subsets. There are five kinds of windows: time window, status window, session window, event window, and count window. There are two kinds of time windows: sliding window and flip time/tumbling window. The syntax of window clause is as follows:
|
||||
|
||||
```sql
|
||||
window_clause: {
|
||||
|
|
|
@ -729,6 +729,57 @@ The charset that takes effect is UTF-8.
|
|||
| Value Range | -1: none message is compressed; 0: all messages are compressed; N (N>0): messages exceeding N bytes are compressed |
|
||||
| Default | -1 |
|
||||
|
||||
### fPrecision
|
||||
|
||||
| Attribute | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| Application | Server Only |
|
||||
| Meaning | Compression precision for float data type |
|
||||
| Value Range | 0.1 ~ 0.00000001 |
|
||||
| Default | 0.00000001 |
|
||||
| Note | The floating value below this setting will be cut off |
|
||||
|
||||
### dPrecision
|
||||
|
||||
| Attribute | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| Applicable | Server Only |
|
||||
| Meaning | Compression precision for double data type |
|
||||
| Value Range | 0.1 ~ 0.0000000000000001 |
|
||||
| Default | 0.0000000000000001 |
|
||||
| Note | The floating value below this setting will be cut off |
|
||||
|
||||
### lossyColumn
|
||||
|
||||
| Attribute | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| Applicable | Server Only |
|
||||
| Meaning | Enable TSZ lossy compression for float and/or double |
|
||||
| Value Range | float, double |
|
||||
| Default | none: disable TSZ lossy compression |
|
||||
|
||||
**补充说明**
|
||||
1. It's only available since 3.2.0.0 version, and can't downgrade to previous version once upgrading to 3.2.0.0 and enabling this parameter
|
||||
2. TSZ compression algorithm compresses data based on data prediction technique, so it's more suitable for data with specific pattern
|
||||
3. TSZ compression algorithm may take longer time but it has better compression ratio, so it's suitable when you have enough CPU resources and are more sensitive to disk occupation
|
||||
4. Example: enable TSZ for both float and double
|
||||
```shell
|
||||
lossyColumns float|double
|
||||
```
|
||||
5. After configuring, taosd service needs to restarted. After restarting, if you see the following output in taosd logfile, it means the function has been enabled
|
||||
```sql
|
||||
02/22 10:49:27.607990 00002933 UTL lossyColumns float|double
|
||||
```
|
||||
|
||||
### ifAdtFse
|
||||
|
||||
| Attribute | Description |
|
||||
| -------- | -------------------------------- |
|
||||
| Applicable | Server Only |
|
||||
| Meaning | Replace HUFFMAN with FSE in TSZ, FSE is faster when compressing but slower when uncompressing |
|
||||
| Value Range | 0: Use HUFFMAN, 1: Use FSE |
|
||||
| Default | 0: Use HUFFMAN |
|
||||
|
||||
|
||||
## Other Parameters
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ table_option: {
|
|||
6. 使用数据类型 BINARY/NCHAR/GEOMETRY,需指定其最长的字节数,如 BINARY(20),表示 20 字节。
|
||||
7. 为了兼容支持更多形式的表名,TDengine 引入新的转义符 "\`",可以让表名与关键词不冲突,同时不受限于上述表名称合法性约束检查。但是同样具有长度限制要求。使用转义字符以后,不再对转义字符中的内容进行大小写统一,
|
||||
例如:\`aBc\` 和 \`abc\` 是不同的表名,但是 abc 和 aBc 是相同的表名。
|
||||
8. 关于 `ENCODE` 和 `COMPRESS` 的使用,请参考[按列压缩](../compress)
|
||||
|
||||
**参数说明**
|
||||
|
||||
|
|
|
@ -13,17 +13,28 @@ create_definition:
|
|||
col_name column_definition
|
||||
|
||||
column_definition:
|
||||
type_name
|
||||
type_name [comment 'string_value'] [PRIMARY KEY] [ENCODE 'encode_type'] [COMPRESS 'compress_type'] [LEVEL 'level_type']
|
||||
|
||||
table_options:
|
||||
table_option ...
|
||||
|
||||
table_option: {
|
||||
COMMENT 'string_value'
|
||||
| SMA(col_name [, col_name] ...)
|
||||
| TTL value
|
||||
}
|
||||
```
|
||||
|
||||
**使用说明**
|
||||
- 超级表中列的最大个数为 4096,需要注意,这里的 4096 是包含 TAG 列在内的,最小个数为 3,包含一个时间戳主键、一个 TAG 列和一个数据列。
|
||||
- TAGS语法指定超级表的标签列,标签列需要遵循以下约定:
|
||||
1. 超级表中列的最大个数为 4096,需要注意,这里的 4096 是包含 TAG 列在内的,最小个数为 3,包含一个时间戳主键、一个 TAG 列和一个数据列。
|
||||
2. 除时间戳主键列之外,还可以通过 PRIMARY KEY 关键字指定第二列为额外的主键列。被指定为主键列的第二列必须为整型或字符串类型(varchar)
|
||||
3. TAGS语法指定超级表的标签列,标签列需要遵循以下约定:
|
||||
- TAGS 中的 TIMESTAMP 列写入数据时需要提供给定值,而暂不支持四则运算,例如 NOW + 10s 这类表达式。
|
||||
- TAGS 列名不能与其他列名相同。
|
||||
- TAGS 列名不能为预留关键字。
|
||||
- TAGS 最多允许 128 个,至少 1 个,总长度不超过 16 KB。
|
||||
- 关于表参数的详细说明,参见 CREATE TABLE 中的介绍。
|
||||
4. 关于 `ENCODE` 和 `COMPRESS` 的使用,请参考 [按列压缩](../compress)
|
||||
5. 关于 table_option 中的参数说明,请参考 [建表 SQL 说明](../table)
|
||||
|
||||
## 查看超级表
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ select _wstart, tbname, avg(voltage) from meters partition by tbname interval(10
|
|||
|
||||
## 窗口切分查询
|
||||
|
||||
TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)、事件窗口(event window)四种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。
|
||||
TDengine 支持按时间窗口切分方式进行聚合结果查询,比如温度传感器每秒采集一次数据,但需查询每隔 10 分钟的温度平均值。这种场景下可以使用窗口子句来获得需要的查询结果。窗口子句用于针对查询的数据集合按照窗口切分成为查询子集并进行聚合,窗口包含时间窗口(time window)、状态窗口(status window)、会话窗口(session window)、事件窗口(event window)、计数窗口(count window)五种窗口。其中时间窗口又可划分为滑动时间窗口和翻转时间窗口。
|
||||
|
||||
窗口子句语法如下:
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
---
|
||||
title: 可配置压缩算法
|
||||
sidebar_label: 可配置压缩
|
||||
description: 可配置压缩算法
|
||||
---
|
||||
|
|
@ -784,6 +784,57 @@ charset 的有效值是 UTF-8。
|
|||
| 取值范围 | -1: 所有消息都不压缩; 0: 所有消息都压缩; N (N>0): 只有大于 N 个字节的消息才压缩 |
|
||||
| 缺省值 | -1 |
|
||||
|
||||
### fPrecision
|
||||
FLOAT 类型压缩精度控制:
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 设置 float 类型浮点数压缩精度 |
|
||||
| 取值范围 | 0.1 ~ 0.00000001 |
|
||||
| 缺省值 | 0.00000001 |
|
||||
| 补充说明 | 小于此值的浮点数尾数部分将被截取 |
|
||||
|
||||
### dPrecision
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 设置 double 类型浮点数压缩精度 |
|
||||
| 取值范围 | 0.1 ~ 0.0000000000000001 |
|
||||
| 缺省值 | 0.0000000000000001 |
|
||||
| 补充说明 | 小于此值的浮点数尾数部分将被截取 |
|
||||
|
||||
### lossyColumn
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 对 float 和/或 double 类型启用 TSZ 有损压缩 |
|
||||
| 取值范围 | float, double |
|
||||
| 缺省值 | none:表示关闭无损压缩 |
|
||||
|
||||
**补充说明**
|
||||
1. 在 3.2.0.0 ~ 3.3.0.0(不包含)版本生效,启用该参数后不能回退到升级前的版本
|
||||
2. TSZ 压缩算法是通过数据预测技术完成的压缩,所以更适合有规律变化的数据
|
||||
3. TSZ 压缩时间会更长一些,如果您的服务器 CPU 空闲多,存储空间小的情况下适合选用
|
||||
4. 示例:对 float 和 double 类型都启用有损压缩
|
||||
```shell
|
||||
lossyColumns float|double
|
||||
```
|
||||
5. 配置需重启服务生效,重启如果在 taosd 日志中看到以下内容,表明配置已生效:
|
||||
```sql
|
||||
02/22 10:49:27.607990 00002933 UTL lossyColumns float|double
|
||||
```
|
||||
|
||||
### ifAdtFse
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 在启用 TSZ 有损压缩时,使用 FSE 算法替换 HUFFMAN 算法, FSE 算法压缩速度更快,但解压稍慢,追求压缩速度可选用此算法 |
|
||||
| 取值范围 | 0:关闭 1:打开 |
|
||||
| 缺省值 | 0:关闭 |
|
||||
|
||||
## 3.0 中有效的配置参数列表
|
||||
|
||||
| # | **参数** | **适用于 2.X ** | **适用于 3.0 ** | 3.0 版本的当前行为 |
|
||||
|
@ -922,8 +973,5 @@ charset 的有效值是 UTF-8。
|
|||
| 73 | probeSeconds | 是 | 否 | 3.0 行为未知 |
|
||||
| 74 | probeKillSeconds | 是 | 否 | 3.0 行为未知 |
|
||||
| 75 | probeInterval | 是 | 否 | 3.0 行为未知 |
|
||||
| 76 | lossyColumns | 是 | 否 | 3.0 行为未知 |
|
||||
| 77 | fPrecision | 是 | 否 | 3.0 行为未知 |
|
||||
| 78 | dPrecision | 是 | 否 | 3.0 行为未知 |
|
||||
| 79 | maxRange | 是 | 否 | 3.0 行为未知 |
|
||||
| 80 | range | 是 | 否 | 3.0 行为未知 |
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
---
|
||||
title: TSZ 压缩算法
|
||||
description: TDengine 对浮点数进行高效压缩的算法
|
||||
---
|
||||
|
||||
TSZ 压缩算法是 TDengine 为浮点数据类型提供的可选压缩算法,可以实现浮点数有损至无损全状态压缩,相比默认压缩算法, TSZ 压缩算法压缩率更高,即使切至无损状态,压缩率也会比默认压缩高一倍。
|
||||
|
||||
## 适合场景
|
||||
|
||||
- TSZ 压缩算法是通过数据预测技术完成的压缩,所以更适合有规律变化的数据
|
||||
- TSZ 压缩时间会更长一些,如果您的服务器 CPU 空闲多,存储空间小的情况下适合选用
|
||||
|
||||
## 使用步骤
|
||||
- TDengine 支持版本为 3.2.0.0 或以上
|
||||
- 开启选项
|
||||
在 taos.cfg 配置中增加以下内容,即可开启 TSZ 压缩算法,功能打开后,会替换默认算法。
|
||||
以下表示字段类型是 float 及 double 类型都使用此压缩算法,也可以单独只配置一个
|
||||
|
||||
```sql
|
||||
lossyColumns float|double
|
||||
```
|
||||
|
||||
- 配置需重启服务生效
|
||||
- Taosd 日志输出以下内容,表明功能已生效:
|
||||
|
||||
```sql
|
||||
02/22 10:49:27.607990 00002933 UTL lossyColumns float|double
|
||||
```
|
||||
|
||||
## 配置参数
|
||||
|
||||
### fPrecision
|
||||
FLOAT 类型精度控制:
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 设置 float 类型浮点数压缩精度 |
|
||||
| 取值范围 | 0.1 ~ 0.00000001 |
|
||||
| 缺省值 | 0.00000001 |
|
||||
| 补充说明 | 小于此值的浮点数尾数部分将被截取 |
|
||||
|
||||
|
||||
|
||||
### dPrecision
|
||||
DOUBLE 类型精度控制:
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 设置 double 类型浮点数压缩精度 |
|
||||
| 取值范围 | 0.1 ~ 0.0000000000000001 |
|
||||
| 缺省值 | 0.0000000000000001 |
|
||||
| 补充说明 | 小于此值的浮点数尾数部分将被截取 |
|
||||
|
||||
|
||||
### ifAdtFse
|
||||
TSZ 压缩中可选择的算法 FSE,默认为 HUFFMAN:
|
||||
|
||||
| 属性 | 说明 |
|
||||
| -------- | -------------------------------- |
|
||||
| 适用范围 | 服务器端 |
|
||||
| 含义 | 使用 FSE 算法替换 HUFFMAN 算法, FSE 算法压缩速度更快,但解压稍慢,追求压缩速度可选用此算法 |
|
||||
| 取值范围 | 0:关闭 1:打开 |
|
||||
| 缺省值 | 0:关闭 |
|
||||
|
||||
|
||||
## 注意事项
|
||||
- 打开 TSZ 后生成的存储数据格式,回退至 3.2.0.0 之前的版本,数据将不能被识别
|
|
@ -3,9 +3,51 @@ title: 3.3.2.0 版本说明
|
|||
sidebar_label: 3.3.2.0
|
||||
description: 3.3.2.0 版本说明
|
||||
---
|
||||
|
||||
### 新特性
|
||||
|
||||
### 优化
|
||||
|
||||
### 新特性/优化
|
||||
1. alter table add column支持ENCODE/COMPRESS
|
||||
2. 改进stt_trigger=1下compact对读写的影响
|
||||
3. 调整SupportVnodes默认值=5+2*CPU cores
|
||||
4. 取消lossyColumns参数
|
||||
5. alter table修改多项参数仅一项生效
|
||||
6. SupportVnodes支持热更新
|
||||
7. 支持CentOS Stream
|
||||
### 新特性/优化(企业版)
|
||||
1. 对指定db进行balance vgroup leader
|
||||
2. 多级存储新增配置项disable_create_new_file
|
||||
3. 多级存储跨级迁移数据增加限速设置
|
||||
4. IP白名单启停支持热更新
|
||||
5. 普通用户取消建库权限
|
||||
6. 数据库加密改进密钥配置
|
||||
7. TDengine 2.0/3.0数据压缩的支持
|
||||
8. Oracle数据源支持
|
||||
9. 支持Microsoft SQL Server数据源
|
||||
10. OPC类型任务可动态获取新增点位
|
||||
11. PI backfill支持断点续传功能
|
||||
12. PI backfill类型的任务支持 Transformer
|
||||
13. PI数据接入性能优化
|
||||
14. taos-explorer支持GEOMETRY/VARBINARY数据类型
|
||||
15. taos-explorer支持用户及权限信息的导入导出
|
||||
16. PI数据源支持新增数据点位/数据元素属性同步到TDengine
|
||||
17. taosX写入端支持原生连接
|
||||
18. Kafka支持GSSAPI
|
||||
19. MQTT类型任务可从数据源拉取示例数据
|
||||
20. 支持Object数组类型的数据
|
||||
21. 支持通过自定义脚本解析数据
|
||||
22. 支持通过插件的形式对数据动态筛选
|
||||
### 修复问题
|
||||
1. 修改子表中缺少修改TTL和COMMENT的命令说明
|
||||
2. 查询first/last+interval+fill导致taosd异常退出
|
||||
3. tmq删除topicA消费组导致topicB同消费组消费失败
|
||||
4. 参数绑定column index越界导致taosd异常退出
|
||||
5. 查询cast函数导致taosd异常退出
|
||||
6. 多次resetlog后taosdlog消失
|
||||
7. insert 插入带有常量字段的select子查询数据失败
|
||||
8. event_window查询导致taosd异常退出
|
||||
9. 查询interp+partition by column+fill导致taosd异常退出
|
||||
10. 查询last返回值与预期不符
|
||||
11. event_window+having过滤条件未生效
|
||||
12. taosX同步遇首列空值导致taosd异常退出(仅企业版)
|
||||
13. 升级至3.3.0.0开启cachemodel后查询last+group by返回行数不正确
|
||||
14. taos-explorer导航栏未显示所有超级表名(仅企业版)
|
||||
15. 复合主键VARCHAR长度超125遇查询导致taosd异常退出
|
||||
16. taos CLI和taosAdapter占用CPU过高
|
||||
|
|
|
@ -60,8 +60,8 @@ typedef struct {
|
|||
} SCheckpoint;
|
||||
|
||||
int32_t cos_cp_open(char const* cp_path, SCheckpoint* checkpoint);
|
||||
void cos_cp_close(TdFilePtr fd);
|
||||
void cos_cp_remove(char const* filepath);
|
||||
int32_t cos_cp_close(TdFilePtr fd);
|
||||
int32_t cos_cp_remove(char const* filepath);
|
||||
|
||||
int32_t cos_cp_load(char const* filepath, SCheckpoint* checkpoint);
|
||||
int32_t cos_cp_dump(SCheckpoint* checkpoint);
|
||||
|
|
|
@ -12,7 +12,7 @@ extern "C" {
|
|||
#include "tarray.h"
|
||||
|
||||
void stopRsync();
|
||||
void startRsync();
|
||||
int32_t startRsync();
|
||||
int32_t uploadByRsync(const char* id, const char* path);
|
||||
int32_t downloadRsync(const char* id, const char* path);
|
||||
int32_t deleteRsync(const char* id);
|
||||
|
|
|
@ -32,8 +32,8 @@ typedef struct SBlockOrderInfo {
|
|||
SColumnInfoData* pColData;
|
||||
} SBlockOrderInfo;
|
||||
|
||||
#define BLOCK_VERSION_1 1
|
||||
#define BLOCK_VERSION_2 2
|
||||
#define BLOCK_VERSION_1 1
|
||||
#define BLOCK_VERSION_2 2
|
||||
|
||||
#define NBIT (3u)
|
||||
#define BitPos(_n) ((_n) & ((1 << NBIT) - 1))
|
||||
|
@ -46,10 +46,10 @@ typedef struct SBlockOrderInfo {
|
|||
BMCharPos(bm_, r_) |= (1u << (7u - BitPos(r_))); \
|
||||
} while (0)
|
||||
|
||||
#define colDataSetNull_f_s(c_, r_) \
|
||||
do { \
|
||||
colDataSetNull_f((c_)->nullbitmap, r_); \
|
||||
memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
#define colDataSetNull_f_s(c_, r_) \
|
||||
do { \
|
||||
colDataSetNull_f((c_)->nullbitmap, r_); \
|
||||
(void)memset(((char*)(c_)->pData) + (c_)->info.bytes * (r_), 0, (c_)->info.bytes); \
|
||||
} while (0)
|
||||
|
||||
#define colDataClearNull_f(bm_, r_) \
|
||||
|
@ -143,7 +143,7 @@ static FORCE_INLINE void colDataSetNNULL(SColumnInfoData* pColumnInfoData, uint3
|
|||
for (int32_t i = start; i < start + nRows; ++i) {
|
||||
colDataSetNull_f(pColumnInfoData->nullbitmap, i);
|
||||
}
|
||||
memset(pColumnInfoData->pData + start * pColumnInfoData->info.bytes, 0, pColumnInfoData->info.bytes * nRows);
|
||||
(void)memset(pColumnInfoData->pData + start * pColumnInfoData->info.bytes, 0, pColumnInfoData->info.bytes * nRows);
|
||||
}
|
||||
|
||||
pColumnInfoData->hasNull = true;
|
||||
|
@ -192,15 +192,17 @@ int32_t getJsonValueLen(const char* data);
|
|||
|
||||
int32_t colDataSetVal(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, bool isNull);
|
||||
int32_t colDataReassignVal(SColumnInfoData* pColumnInfoData, uint32_t dstRowIdx, uint32_t srcRowIdx, const char* pData);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows, bool trimValue);
|
||||
void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, uint32_t numOfRows);
|
||||
int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData,
|
||||
uint32_t numOfRows, bool isNull);
|
||||
int32_t colDataSetNItems(SColumnInfoData* pColumnInfoData, uint32_t rowIndex, const char* pData, uint32_t numOfRows,
|
||||
bool trimValue);
|
||||
void colDataSetNItemsNull(SColumnInfoData* pColumnInfoData, uint32_t currentRow, uint32_t numOfRows);
|
||||
int32_t colDataCopyNItems(SColumnInfoData* pColumnInfoData, uint32_t currentRow, const char* pData, uint32_t numOfRows,
|
||||
bool isNull);
|
||||
int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, int32_t numOfRow1, int32_t* capacity,
|
||||
const SColumnInfoData* pSource, int32_t numOfRow2);
|
||||
int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* pSource, int32_t numOfRows,
|
||||
const SDataBlockInfo* pBlockInfo);
|
||||
int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx, int32_t numOfRows);
|
||||
int32_t colDataAssignNRows(SColumnInfoData* pDst, int32_t dstIdx, const SColumnInfoData* pSrc, int32_t srcIdx,
|
||||
int32_t numOfRows);
|
||||
int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex);
|
||||
int32_t blockDataUpdatePkRange(SSDataBlock* pDataBlock, int32_t pkColumnIndex, bool asc);
|
||||
|
||||
|
@ -214,7 +216,7 @@ size_t blockDataGetNumOfRows(const SSDataBlock* pBlock);
|
|||
|
||||
int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc);
|
||||
int32_t blockDataMergeNRows(SSDataBlock* pDest, const SSDataBlock* pSrc, int32_t srcIdx, int32_t numOfRows);
|
||||
void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows);
|
||||
void blockDataShrinkNRows(SSDataBlock* pBlock, int32_t numOfRows);
|
||||
int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex,
|
||||
int32_t pageSize);
|
||||
int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock);
|
||||
|
@ -237,23 +239,23 @@ int32_t blockDataGetSortedRows(SSDataBlock* pDataBlock, SArray* pOrderInfo);
|
|||
int32_t colInfoDataEnsureCapacity(SColumnInfoData* pColumn, uint32_t numOfRows, bool clearPayload);
|
||||
int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows);
|
||||
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
void blockDataReset(SSDataBlock* pDataBlock);
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock);
|
||||
void colInfoDataCleanup(SColumnInfoData* pColumn, uint32_t numOfRows);
|
||||
void blockDataCleanup(SSDataBlock* pDataBlock);
|
||||
void blockDataReset(SSDataBlock* pDataBlock);
|
||||
void blockDataEmpty(SSDataBlock* pDataBlock);
|
||||
int32_t doEnsureCapacity(SColumnInfoData* pColumn, const SDataBlockInfo* pBlockInfo, uint32_t numOfRows,
|
||||
bool clearPayload);
|
||||
bool clearPayload);
|
||||
|
||||
size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize, int32_t extraSize);
|
||||
|
||||
int32_t blockDataTrimFirstRows(SSDataBlock* pBlock, size_t n);
|
||||
int32_t blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n);
|
||||
void blockDataKeepFirstNRows(SSDataBlock* pBlock, size_t n);
|
||||
|
||||
int32_t assignOneDataBlock(SSDataBlock* dst, const SSDataBlock* src);
|
||||
int32_t copyDataBlock(SSDataBlock* pDst, const SSDataBlock* pSrc);
|
||||
|
||||
SSDataBlock* createDataBlock();
|
||||
void* blockDataDestroy(SSDataBlock* pBlock);
|
||||
void blockDataDestroy(SSDataBlock* pBlock);
|
||||
void blockDataFreeRes(SSDataBlock* pBlock);
|
||||
SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData);
|
||||
SSDataBlock* createSpecialDataBlock(EStreamType type);
|
||||
|
@ -264,20 +266,20 @@ int32_t blockDataAppendColInfo(SSDataBlock* pBlock, SColumnInfoData* pColIn
|
|||
SColumnInfoData createColumnInfoData(int16_t type, int32_t bytes, int16_t colId);
|
||||
SColumnInfoData* bdGetColumnInfoData(const SSDataBlock* pBlock, int32_t index);
|
||||
|
||||
int32_t blockGetEncodeSize(const SSDataBlock* pBlock);
|
||||
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols);
|
||||
int32_t blockGetEncodeSize(const SSDataBlock* pBlock);
|
||||
int32_t blockEncode(const SSDataBlock* pBlock, char* data, int32_t numOfCols);
|
||||
const char* blockDecode(SSDataBlock* pBlock, const char* pData);
|
||||
|
||||
// for debug
|
||||
char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** dumpBuf, const char* taskIdStr);
|
||||
|
||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pDataBlocks, const STSchema* pTSchema, int64_t uid, int32_t vgId,
|
||||
tb_uid_t suid);
|
||||
int32_t buildSubmitReqFromDataBlock(SSubmitReq2** pReq, const SSDataBlock* pDataBlocks, const STSchema* pTSchema,
|
||||
int64_t uid, int32_t vgId, tb_uid_t suid);
|
||||
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||
bool alreadyAddGroupId(char* ctbName, int64_t groupId);
|
||||
bool isAutoTableName(char* ctbName);
|
||||
void buildCtbNameAddGroupId(const char* stbName, char* ctbName, uint64_t groupId);
|
||||
char* buildCtbNameByGroupId(const char* stbName, uint64_t groupId);
|
||||
int32_t buildCtbNameByGroupIdImpl(const char* stbName, uint64_t groupId, char* pBuf);
|
||||
|
||||
void trimDataBlock(SSDataBlock* pBlock, int32_t totalRows, const bool* pBoolList);
|
||||
|
|
|
@ -136,7 +136,7 @@ int32_t tRowMerge(SArray *aRowP, STSchema *pTSchema, int8_t flag);
|
|||
int32_t tRowUpsertColData(SRow *pRow, STSchema *pTSchema, SColData *aColData, int32_t nColData, int32_t flag);
|
||||
void tRowGetPrimaryKey(SRow *pRow, SRowKey *key);
|
||||
int32_t tRowKeyCompare(const SRowKey *key1, const SRowKey *key2);
|
||||
int32_t tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
||||
void tRowKeyAssign(SRowKey *pDst, SRowKey *pSrc);
|
||||
|
||||
// SRowIter ================================
|
||||
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
||||
|
@ -315,7 +315,7 @@ struct STag {
|
|||
do { \
|
||||
VarDataLenT __len = (VarDataLenT)strlen(str); \
|
||||
*(VarDataLenT *)(x) = __len; \
|
||||
memcpy(varDataVal(x), (str), __len); \
|
||||
(void)memcpy(varDataVal(x), (str), __len); \
|
||||
} while (0);
|
||||
|
||||
#define STR_WITH_MAXSIZE_TO_VARSTR(x, str, _maxs) \
|
||||
|
@ -324,10 +324,10 @@ struct STag {
|
|||
varDataSetLen(x, (_e - (x)-VARSTR_HEADER_SIZE)); \
|
||||
} while (0)
|
||||
|
||||
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) \
|
||||
do { \
|
||||
*(VarDataLenT *)(x) = (VarDataLenT)(_size); \
|
||||
memcpy(varDataVal(x), (str), (_size)); \
|
||||
#define STR_WITH_SIZE_TO_VARSTR(x, str, _size) \
|
||||
do { \
|
||||
*(VarDataLenT *)(x) = (VarDataLenT)(_size); \
|
||||
(void)memcpy(varDataVal(x), (str), (_size)); \
|
||||
} while (0);
|
||||
|
||||
// STSchema ================================
|
||||
|
|
|
@ -68,7 +68,7 @@ int32_t generateEncryptCode(const char *key, const char *machineId, char **encry
|
|||
int64_t grantRemain(EGrantType grant);
|
||||
int32_t grantCheck(EGrantType grant);
|
||||
int32_t grantCheckExpire(EGrantType grant);
|
||||
char *tGetMachineId();
|
||||
int32_t tGetMachineId(char **result);
|
||||
|
||||
// #ifndef GRANTS_CFG
|
||||
#ifdef TD_ENTERPRISE
|
||||
|
|
|
@ -31,7 +31,7 @@ typedef struct SCorEpSet {
|
|||
|
||||
int32_t epsetToStr(const SEpSet* pEpSet, char* pBuf, int32_t len);
|
||||
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp);
|
||||
void addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port);
|
||||
int32_t addEpIntoEpSet(SEpSet* pEpSet, const char* fqdn, uint16_t port);
|
||||
|
||||
bool isEpsetEqual(const SEpSet* s1, const SEpSet* s2);
|
||||
void epsetAssign(SEpSet* dst, const SEpSet* pSrc);
|
||||
|
|
|
@ -692,7 +692,7 @@ static FORCE_INLINE SColCmprWrapper* tCloneSColCmprWrapper(const SColCmprWrapper
|
|||
|
||||
int32_t size = sizeof(SColCmpr) * pDstWrapper->nCols;
|
||||
pDstWrapper->pColCmpr = (SColCmpr*)taosMemoryCalloc(1, size);
|
||||
memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
|
||||
(void)memcpy(pDstWrapper->pColCmpr, pSrcWrapper->pColCmpr, size);
|
||||
|
||||
return pDstWrapper;
|
||||
}
|
||||
|
@ -733,7 +733,7 @@ static FORCE_INLINE SSchemaWrapper* tCloneSSchemaWrapper(const SSchemaWrapper* p
|
|||
return NULL;
|
||||
}
|
||||
|
||||
memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
(void)memcpy(pSW->pSchema, pSchemaWrapper->pSchema, pSW->nCols * sizeof(SSchema));
|
||||
return pSW;
|
||||
}
|
||||
|
||||
|
@ -2829,19 +2829,24 @@ static FORCE_INLINE int32_t tSerializeSCMSubscribeReq(void** buf, const SCMSubsc
|
|||
return tlen;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||
static FORCE_INLINE int32_t tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq* pReq) {
|
||||
buf = taosDecodeFixedI64(buf, &pReq->consumerId);
|
||||
buf = taosDecodeStringTo(buf, pReq->cgroup);
|
||||
buf = taosDecodeStringTo(buf, pReq->clientId);
|
||||
|
||||
int32_t topicNum;
|
||||
int32_t topicNum = 0;
|
||||
buf = taosDecodeFixedI32(buf, &topicNum);
|
||||
|
||||
pReq->topicNames = taosArrayInit(topicNum, sizeof(void*));
|
||||
if (pReq->topicNames == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
for (int32_t i = 0; i < topicNum; i++) {
|
||||
char* name;
|
||||
char* name = NULL;
|
||||
buf = taosDecodeString(buf, &name);
|
||||
taosArrayPush(pReq->topicNames, &name);
|
||||
if (taosArrayPush(pReq->topicNames, &name) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
buf = taosDecodeFixedI8(buf, &pReq->withTbName);
|
||||
|
@ -2850,7 +2855,7 @@ static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq
|
|||
buf = taosDecodeFixedI8(buf, &pReq->resetOffsetCfg);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->enableReplay);
|
||||
buf = taosDecodeFixedI8(buf, &pReq->enableBatchMeta);
|
||||
return buf;
|
||||
return 0;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
|
@ -3613,6 +3618,7 @@ typedef struct {
|
|||
|
||||
int32_t tEncodeSTqOffset(SEncoder* pEncoder, const STqOffset* pOffset);
|
||||
int32_t tDecodeSTqOffset(SDecoder* pDecoder, STqOffset* pOffset);
|
||||
void tDeleteSTqOffset(void* val);
|
||||
|
||||
typedef struct SMqVgOffset {
|
||||
int64_t consumerId;
|
||||
|
@ -4036,7 +4042,9 @@ static FORCE_INLINE void* tDecodeSMqAskEpRsp(void* buf, SMqAskEpRsp* pRsp) {
|
|||
for (int32_t i = 0; i < sz; i++) {
|
||||
SMqSubTopicEp topicEp;
|
||||
buf = tDecodeMqSubTopicEp(buf, &topicEp);
|
||||
taosArrayPush(pRsp->topics, &topicEp);
|
||||
if (taosArrayPush(pRsp->topics, &topicEp) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@
|
|||
#define _TD_COMMON_MSG_CB_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SRpcMsg SRpcMsg;
|
||||
typedef struct SEpSet SEpSet;
|
||||
typedef struct SMgmtWrapper SMgmtWrapper;
|
||||
typedef struct SRpcHandleInfo SRpcHandleInfo;
|
||||
|
||||
|
@ -46,7 +46,7 @@ typedef int32_t (*PutToQueueFp)(void* pMgmt, EQueueType qtype, SRpcMsg* pMsg);
|
|||
typedef int32_t (*GetQueueSizeFp)(void* pMgmt, int32_t vgId, EQueueType qtype);
|
||||
typedef int32_t (*SendReqFp)(const SEpSet* pEpSet, SRpcMsg* pMsg);
|
||||
typedef void (*SendRspFp)(SRpcMsg* pMsg);
|
||||
typedef void (*RegisterBrokenLinkArgFp)(SRpcMsg* pMsg);
|
||||
typedef void (*RegisterBrokenLinkArgFp)(struct SRpcMsg* pMsg);
|
||||
typedef void (*ReleaseHandleFp)(SRpcHandleInfo* pHandle, int8_t type);
|
||||
typedef void (*ReportStartup)(const char* name, const char* desc);
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ typedef struct {
|
|||
// uint64_t uid; // child table uid, may be useful
|
||||
} RandTableName;
|
||||
|
||||
void buildChildTableName(RandTableName* rName);
|
||||
int32_t buildChildTableName(RandTableName* rName);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ void deltaToUtcInitOnce();
|
|||
char getPrecisionUnit(int32_t precision);
|
||||
|
||||
int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision);
|
||||
int64_t convertTimeFromPrecisionToUnit(int64_t ts, int32_t fromPrecision, char toUnit);
|
||||
int32_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit, int64_t* pRes);
|
||||
int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal);
|
||||
int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision);
|
||||
|
||||
void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||
int32_t taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision);
|
||||
|
||||
struct STm {
|
||||
struct tm tm;
|
||||
|
@ -117,7 +117,7 @@ int32_t taosTs2Char(const char* format, SArray** formats, int64_t ts, int32_t pr
|
|||
int32_t taosChar2Ts(const char* format, SArray** formats, const char* tsStr, int64_t* ts, int32_t precision, char* errMsg,
|
||||
int32_t errMsgLen);
|
||||
|
||||
void TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen);
|
||||
int32_t TEST_ts2char(const char* format, int64_t ts, int32_t precision, char* out, int32_t outLen);
|
||||
int32_t TEST_char2ts(const char* format, int64_t* ts, int32_t precision, const char* tsStr);
|
||||
|
||||
/// @brief get offset seconds from zero timezone to input timezone
|
||||
|
|
|
@ -132,16 +132,16 @@
|
|||
#define TK_TABLE 114
|
||||
#define TK_NK_LP 115
|
||||
#define TK_NK_RP 116
|
||||
#define TK_STABLE 117
|
||||
#define TK_COLUMN 118
|
||||
#define TK_MODIFY 119
|
||||
#define TK_RENAME 120
|
||||
#define TK_TAG 121
|
||||
#define TK_SET 122
|
||||
#define TK_NK_EQ 123
|
||||
#define TK_USING 124
|
||||
#define TK_TAGS 125
|
||||
#define TK_FILE 126
|
||||
#define TK_USING 117
|
||||
#define TK_FILE 118
|
||||
#define TK_STABLE 119
|
||||
#define TK_COLUMN 120
|
||||
#define TK_MODIFY 121
|
||||
#define TK_RENAME 122
|
||||
#define TK_TAG 123
|
||||
#define TK_SET 124
|
||||
#define TK_NK_EQ 125
|
||||
#define TK_TAGS 126
|
||||
#define TK_BOOL 127
|
||||
#define TK_TINYINT 128
|
||||
#define TK_SMALLINT 129
|
||||
|
|
|
@ -1,147 +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_COMMON_TTSZIP_H_
|
||||
#define _TD_COMMON_TTSZIP_H_
|
||||
|
||||
#include "os.h"
|
||||
#include "tdef.h"
|
||||
#include "tvariant.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MEM_BUF_SIZE (1 << 20)
|
||||
#define TS_COMP_FILE_MAGIC 0x87F5EC4C
|
||||
#define TS_COMP_FILE_GROUP_MAX 512
|
||||
|
||||
typedef struct STSList {
|
||||
char* rawBuf;
|
||||
int32_t allocSize;
|
||||
int32_t threshold;
|
||||
int32_t len;
|
||||
} STSList;
|
||||
|
||||
typedef struct STSElem {
|
||||
TSKEY ts;
|
||||
SVariant* tag;
|
||||
int32_t id;
|
||||
} STSElem;
|
||||
|
||||
typedef struct STSCursor {
|
||||
int32_t vgroupIndex;
|
||||
int32_t blockIndex;
|
||||
int32_t tsIndex;
|
||||
uint32_t order;
|
||||
} STSCursor;
|
||||
|
||||
typedef struct STSBlock {
|
||||
SVariant tag; // tag value
|
||||
int32_t numOfElem; // number of elements
|
||||
int32_t compLen; // size after compressed
|
||||
int32_t padding; // 0xFFFFFFFF by default, after the payload
|
||||
char* payload; // actual data that is compressed
|
||||
} STSBlock;
|
||||
|
||||
/*
|
||||
* The size of buffer file should not be greater than 2G,
|
||||
* and the offset of int32_t type is enough
|
||||
*/
|
||||
typedef struct STSGroupBlockInfo {
|
||||
int32_t id; // group id
|
||||
int32_t offset; // offset set value in file
|
||||
int32_t numOfBlocks; // number of total blocks
|
||||
int32_t compLen; // compressed size
|
||||
} STSGroupBlockInfo;
|
||||
|
||||
typedef struct STSGroupBlockInfoEx {
|
||||
STSGroupBlockInfo info;
|
||||
int32_t len; // length before compress
|
||||
} STSGroupBlockInfoEx;
|
||||
|
||||
typedef struct STSBuf {
|
||||
TdFilePtr pFile;
|
||||
char path[PATH_MAX];
|
||||
uint32_t fileSize;
|
||||
|
||||
// todo use array
|
||||
STSGroupBlockInfoEx* pData;
|
||||
uint32_t numOfAlloc;
|
||||
uint32_t numOfGroups;
|
||||
|
||||
char* assistBuf;
|
||||
int32_t bufSize;
|
||||
STSBlock block;
|
||||
STSList tsData; // uncompressed raw ts data
|
||||
uint64_t numOfTotal;
|
||||
bool autoDelete;
|
||||
bool remainOpen;
|
||||
int32_t tsOrder; // order of timestamp in ts comp buffer
|
||||
STSCursor cur;
|
||||
} STSBuf;
|
||||
|
||||
typedef struct STSBufFileHeader {
|
||||
uint32_t magic; // file magic number
|
||||
uint32_t numOfGroup; // number of group stored in current file
|
||||
int32_t tsOrder; // timestamp order in current file
|
||||
} STSBufFileHeader;
|
||||
|
||||
STSBuf* tsBufCreate(bool autoDelete, int32_t order);
|
||||
STSBuf* tsBufCreateFromFile(const char* path, bool autoDelete);
|
||||
STSBuf* tsBufCreateFromCompBlocks(const char* pData, int32_t numOfBlocks, int32_t len, int32_t tsOrder, int32_t id);
|
||||
|
||||
void* tsBufDestroy(STSBuf* pTSBuf);
|
||||
|
||||
void tsBufAppend(STSBuf* pTSBuf, int32_t id, SVariant* tag, const char* pData, int32_t len);
|
||||
int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf);
|
||||
|
||||
STSBuf* tsBufClone(STSBuf* pTSBuf);
|
||||
|
||||
STSGroupBlockInfo* tsBufGetGroupBlockInfo(STSBuf* pTSBuf, int32_t id);
|
||||
|
||||
void tsBufFlush(STSBuf* pTSBuf);
|
||||
void tsBufResetPos(STSBuf* pTSBuf);
|
||||
bool tsBufNextPos(STSBuf* pTSBuf);
|
||||
|
||||
STSElem tsBufGetElem(STSBuf* pTSBuf);
|
||||
STSElem tsBufGetElemStartPos(STSBuf* pTSBuf, int32_t id, SVariant* tag);
|
||||
|
||||
STSCursor tsBufGetCursor(STSBuf* pTSBuf);
|
||||
void tsBufSetTraverseOrder(STSBuf* pTSBuf, int32_t order);
|
||||
|
||||
void tsBufSetCursor(STSBuf* pTSBuf, STSCursor* pCur);
|
||||
|
||||
/**
|
||||
* display all data in comp block file, for debug purpose only
|
||||
* @param pTSBuf
|
||||
*/
|
||||
void tsBufDisplay(STSBuf* pTSBuf);
|
||||
|
||||
int32_t tsBufGetNumOfGroup(STSBuf* pTSBuf);
|
||||
|
||||
void tsBufGetGroupIdList(STSBuf* pTSBuf, int32_t* num, int32_t** id);
|
||||
|
||||
int32_t dumpFileBlockByGroupId(STSBuf* pTSBuf, int32_t id, void* buf, int32_t* len, int32_t* numOfBlocks);
|
||||
|
||||
STSElem tsBufFindElemStartPosByTag(STSBuf* pTSBuf, SVariant* pTag);
|
||||
|
||||
bool tsBufIsValidElem(STSElem* pElem);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*_TD_COMMON_TTSZIP_H_*/
|
|
@ -46,7 +46,7 @@ typedef struct {
|
|||
#pragma pack(pop)
|
||||
|
||||
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
|
||||
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataCopy(dst, v) (void)memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
|
||||
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
|
||||
|
||||
|
|
|
@ -34,9 +34,10 @@ typedef struct {
|
|||
* @brief Start one Qnode in Dnode.
|
||||
*
|
||||
* @param pOption Option of the qnode.
|
||||
* @return SQnode* The qnode object.
|
||||
* @param pQnode The qnode object.
|
||||
* @return int32_t The error code.
|
||||
*/
|
||||
SQnode *qndOpen(const SQnodeOpt *pOption);
|
||||
int32_t qndOpen(const SQnodeOpt *pOption, SQnode **pQnode);
|
||||
|
||||
/**
|
||||
* @brief Stop Qnode in Dnode.
|
||||
|
|
|
@ -50,7 +50,7 @@ typedef struct {
|
|||
|
||||
int32_t auditInit(const SAuditCfg *pCfg);
|
||||
void auditCleanup();
|
||||
void auditSend(SJson *pJson);
|
||||
int32_t auditSend(SJson *pJson);
|
||||
void auditRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||
char *detail, int32_t len);
|
||||
void auditAddRecord(SRpcMsg *pReq, int64_t clusterId, char *operation, char *target1, char *target2,
|
||||
|
|
|
@ -152,7 +152,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
|||
* @return
|
||||
*/
|
||||
int32_t qGetQueryTableSchemaVersion(qTaskInfo_t tinfo, char* dbName, char* tableName, int32_t* sversion,
|
||||
int32_t* tversion, int32_t idx);
|
||||
int32_t* tversion, int32_t idx, bool* tbGet);
|
||||
|
||||
/**
|
||||
* The main task execution function, including query on both table and multiple tables,
|
||||
|
|
|
@ -79,7 +79,7 @@ typedef struct SMetaEntry {
|
|||
} smaEntry;
|
||||
};
|
||||
|
||||
uint8_t* pBuf;
|
||||
uint8_t* pBuf;
|
||||
|
||||
SColCmprWrapper colCmpr; // col compress alg
|
||||
} SMetaEntry;
|
||||
|
@ -106,15 +106,15 @@ typedef struct SMTbCursor {
|
|||
} SMTbCursor;
|
||||
|
||||
typedef struct SMCtbCursor {
|
||||
SMeta* pMeta;
|
||||
void* pCur;
|
||||
tb_uid_t suid;
|
||||
void* pKey;
|
||||
void* pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
int8_t paused;
|
||||
int lock;
|
||||
struct SMeta* pMeta;
|
||||
void* pCur;
|
||||
tb_uid_t suid;
|
||||
void* pKey;
|
||||
void* pVal;
|
||||
int kLen;
|
||||
int vLen;
|
||||
int8_t paused;
|
||||
int lock;
|
||||
} SMCtbCursor;
|
||||
|
||||
typedef struct SRowBuffPos {
|
||||
|
@ -135,18 +135,18 @@ typedef struct SMetaTableInfo {
|
|||
} SMetaTableInfo;
|
||||
|
||||
typedef struct SSnapContext {
|
||||
SMeta* pMeta;
|
||||
int64_t snapVersion;
|
||||
void* pCur;
|
||||
int64_t suid;
|
||||
int8_t subType;
|
||||
SHashObj* idVersion;
|
||||
SHashObj* suidInfo;
|
||||
SArray* idList;
|
||||
int32_t index;
|
||||
int8_t withMeta;
|
||||
int8_t queryMeta; // true-get meta, false-get data
|
||||
bool hasPrimaryKey;
|
||||
struct SMeta* pMeta;
|
||||
int64_t snapVersion;
|
||||
void* pCur;
|
||||
int64_t suid;
|
||||
int8_t subType;
|
||||
SHashObj* idVersion;
|
||||
SHashObj* suidInfo;
|
||||
SArray* idList;
|
||||
int32_t index;
|
||||
int8_t withMeta;
|
||||
int8_t queryMeta; // true-get meta, false-get data
|
||||
bool hasPrimaryKey;
|
||||
} SSnapContext;
|
||||
|
||||
typedef struct {
|
||||
|
@ -179,7 +179,7 @@ typedef struct TsdReader {
|
|||
int32_t (*tsdNextDataBlock)();
|
||||
|
||||
int32_t (*tsdReaderRetrieveBlockSMAInfo)();
|
||||
SSDataBlock *(*tsdReaderRetrieveDataBlock)();
|
||||
int32_t (*tsdReaderRetrieveDataBlock)();
|
||||
|
||||
void (*tsdReaderReleaseDataBlock)();
|
||||
|
||||
|
@ -196,7 +196,7 @@ typedef struct SStoreCacheReader {
|
|||
int32_t (*openReader)(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||
SArray *pCidList, int32_t *pSlotIds, uint64_t suid, void **pReader, const char *idstr,
|
||||
SArray *pFuncTypeList, SColumnInfo* pPkCol, int32_t numOfPks);
|
||||
void *(*closeReader)(void *pReader);
|
||||
void (*closeReader)(void *pReader);
|
||||
int32_t (*retrieveRows)(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, const int32_t *dstSlotIds,
|
||||
SArray *pTableUidList);
|
||||
int32_t (*reuseReader)(void *pReader, void *pTableIdList, int32_t numOfTables);
|
||||
|
@ -230,15 +230,15 @@ typedef struct SStoreTqReader {
|
|||
bool (*tqReaderCurrentBlockConsumed)();
|
||||
|
||||
struct SWalReader* (*tqReaderGetWalReader)(); // todo remove it
|
||||
// int32_t (*tqReaderRetrieveTaosXBlock)(); // todo remove it
|
||||
// int32_t (*tqReaderRetrieveTaosXBlock)(); // todo remove it
|
||||
|
||||
int32_t (*tqReaderSetSubmitMsg)(); // todo remove it
|
||||
// bool (*tqReaderNextBlockFilterOut)();
|
||||
// bool (*tqReaderNextBlockFilterOut)();
|
||||
} SStoreTqReader;
|
||||
|
||||
typedef struct SStoreSnapshotFn {
|
||||
bool (*taosXGetTablePrimaryKey)(SSnapContext *ctx);
|
||||
void (*taosXSetTablePrimaryKey)(SSnapContext *ctx, int64_t uid);
|
||||
bool (*taosXGetTablePrimaryKey)(SSnapContext* ctx);
|
||||
void (*taosXSetTablePrimaryKey)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*setForSnapShot)(SSnapContext* ctx, int64_t uid);
|
||||
int32_t (*destroySnapshot)(SSnapContext* ctx);
|
||||
SMetaTableInfo (*getMetaTableInfoFromSnapshot)(SSnapContext* ctx);
|
||||
|
@ -271,7 +271,7 @@ typedef struct SStoreMeta {
|
|||
int32_t (*putCachedTableList)(void* pVnode, uint64_t suid, const void* pKey, int32_t keyLen, void* pPayload,
|
||||
int32_t payloadLen, double selectivityRatio);
|
||||
|
||||
void* (*storeGetIndexInfo)(void *pVnode);
|
||||
void* (*storeGetIndexInfo)(void* pVnode);
|
||||
void* (*getInvertIndex)(void* pVnode);
|
||||
// support filter and non-filter cases. [vnodeGetCtbIdList & vnodeGetCtbIdListByFilter]
|
||||
int32_t (*getChildTableList)(void* pVnode, int64_t suid, SArray* list);
|
||||
|
@ -330,31 +330,35 @@ typedef struct {
|
|||
|
||||
typedef struct SStateStore {
|
||||
int32_t (*streamStatePutParName)(SStreamState* pState, int64_t groupId, const char* tbname);
|
||||
int32_t (*streamStateGetParName)(SStreamState* pState, int64_t groupId, void** pVal, bool onlyCache);
|
||||
int32_t (*streamStateGetParName)(SStreamState* pState, int64_t groupId, void** pVal, bool onlyCache,
|
||||
int32_t* pWinCode);
|
||||
|
||||
int32_t (*streamStateAddIfNotExist)(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t (*streamStateReleaseBuf)(SStreamState* pState, void* pVal, bool used);
|
||||
int32_t (*streamStateClearBuff)(SStreamState* pState, void* pVal);
|
||||
int32_t (*streamStateAddIfNotExist)(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
void (*streamStateReleaseBuf)(SStreamState* pState, void* pVal, bool used);
|
||||
void (*streamStateClearBuff)(SStreamState* pState, void* pVal);
|
||||
void (*streamStateFreeVal)(void* val);
|
||||
|
||||
int32_t (*streamStatePut)(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
||||
int32_t (*streamStateGet)(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t (*streamStateGet)(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
bool (*streamStateCheck)(SStreamState* pState, const SWinKey* key);
|
||||
int32_t (*streamStateGetByPos)(SStreamState* pState, void* pos, void** pVal);
|
||||
int32_t (*streamStateDel)(SStreamState* pState, const SWinKey* key);
|
||||
int32_t (*streamStateClear)(SStreamState* pState);
|
||||
void (*streamStateDel)(SStreamState* pState, const SWinKey* key);
|
||||
void (*streamStateClear)(SStreamState* pState);
|
||||
void (*streamStateSetNumber)(SStreamState* pState, int32_t number, int32_t tsIdex);
|
||||
int32_t (*streamStateSaveInfo)(SStreamState* pState, void* pKey, int32_t keyLen, void* pVal, int32_t vLen);
|
||||
void (*streamStateSaveInfo)(SStreamState* pState, void* pKey, int32_t keyLen, void* pVal, int32_t vLen);
|
||||
int32_t (*streamStateGetInfo)(SStreamState* pState, void* pKey, int32_t keyLen, void** pVal, int32_t* pLen);
|
||||
|
||||
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);
|
||||
int32_t (*streamStateFillGetNext)(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
int32_t (*streamStateFillGetPrev)(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
void (*streamStateFillDel)(SStreamState* pState, const SWinKey* key);
|
||||
int32_t (*streamStateFillGetNext)(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
int32_t (*streamStateFillGetPrev)(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
|
||||
int32_t (*streamStateCurNext)(SStreamState* pState, SStreamStateCur* pCur);
|
||||
int32_t (*streamStateCurPrev)(SStreamState* pState, SStreamStateCur* pCur);
|
||||
void (*streamStateCurNext)(SStreamState* pState, SStreamStateCur* pCur);
|
||||
void (*streamStateCurPrev)(SStreamState* pState, SStreamStateCur* pCur);
|
||||
|
||||
SStreamStateCur* (*streamStateGetAndCheckCur)(SStreamState* pState, SWinKey* key);
|
||||
SStreamStateCur* (*streamStateSeekKeyNext)(SStreamState* pState, const SWinKey* key);
|
||||
|
@ -366,38 +370,42 @@ typedef struct SStateStore {
|
|||
int32_t (*streamStateGetKVByCur)(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||
|
||||
int32_t (*streamStateSessionAddIfNotExist)(SStreamState* pState, SSessionKey* key, TSKEY gap, void** pVal,
|
||||
int32_t* pVLen);
|
||||
int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t (*streamStateSessionPut)(SStreamState* pState, const SSessionKey* key, 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 (*streamStateSessionReset)(SStreamState* pState, void* pVal);
|
||||
int32_t (*streamStateSessionClear)(SStreamState* pState);
|
||||
int32_t (*streamStateSessionGet)(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
void (*streamStateSessionDel)(SStreamState* pState, const SSessionKey* key);
|
||||
void (*streamStateSessionReset)(SStreamState* pState, void* pVal);
|
||||
void (*streamStateSessionClear)(SStreamState* pState);
|
||||
int32_t (*streamStateSessionGetKVByCur)(SStreamStateCur* pCur, SSessionKey* pKey, 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);
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t (*streamStateSessionGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||
int32_t (*streamStateCountGetKeyByRange)(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||
int32_t (*streamStateSessionAllocWinBuffByNextPosition)(SStreamState* pState, SStreamStateCur* pCur,
|
||||
const SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
int32_t (*streamStateCountWinAddIfNotExist)(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount,
|
||||
void** ppVal, int32_t* pVLen);
|
||||
void** ppVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t (*streamStateCountWinAdd)(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
SUpdateInfo* (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen);
|
||||
TSKEY (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol, int32_t primaryKeyCol);
|
||||
int32_t (*updateInfoInit)(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType,
|
||||
int32_t pkLen, SUpdateInfo** ppInfo);
|
||||
int32_t (*updateInfoFillBlockData)(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol,
|
||||
int32_t primaryKeyCol, TSKEY* pMaxResTs);
|
||||
bool (*updateInfoIsUpdated)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
bool (*updateInfoIsTableInserted)(SUpdateInfo* pInfo, int64_t tbUid);
|
||||
bool (*isIncrementalTimeStamp)(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
|
||||
void (*updateInfoDestroy)(SUpdateInfo* pInfo);
|
||||
void (*windowSBfDelete)(SUpdateInfo* pInfo, uint64_t count);
|
||||
void (*windowSBfAdd)(SUpdateInfo* pInfo, uint64_t count);
|
||||
int32_t (*windowSBfAdd)(SUpdateInfo* pInfo, uint64_t count);
|
||||
|
||||
SUpdateInfo* (*updateInfoInitP)(SInterval* pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen);
|
||||
int32_t (*updateInfoInitP)(SInterval* pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen,
|
||||
SUpdateInfo** ppInfo);
|
||||
void (*updateInfoAddCloseWindowSBF)(SUpdateInfo* pInfo);
|
||||
void (*updateInfoDestoryColseWinSBF)(SUpdateInfo* pInfo);
|
||||
int32_t (*updateInfoSerialize)(void* buf, int32_t bufLen, const SUpdateInfo* pInfo);
|
||||
int32_t (*updateInfoSerialize)(void* buf, int32_t bufLen, const SUpdateInfo* pInfo, int32_t* pLen);
|
||||
int32_t (*updateInfoDeserialize)(void* buf, int32_t bufLen, SUpdateInfo* pInfo);
|
||||
|
||||
SStreamStateCur* (*streamStateSessionSeekKeyNext)(SStreamState* pState, const SSessionKey* key);
|
||||
|
@ -416,7 +424,7 @@ typedef struct SStateStore {
|
|||
SStreamState* (*streamStateOpen)(const char* path, void* pTask, int64_t streamId, int32_t taskId);
|
||||
void (*streamStateClose)(SStreamState* pState, bool remove);
|
||||
int32_t (*streamStateBegin)(SStreamState* pState);
|
||||
int32_t (*streamStateCommit)(SStreamState* pState);
|
||||
void (*streamStateCommit)(SStreamState* pState);
|
||||
void (*streamStateDestroy)(SStreamState* pState, bool remove);
|
||||
int32_t (*streamStateDeleteCheckPoint)(SStreamState* pState, TSKEY mark);
|
||||
void (*streamStateReloadInfo)(SStreamState* pState, TSKEY ts);
|
||||
|
|
|
@ -36,7 +36,7 @@ typedef struct SFuncExecEnv {
|
|||
} SFuncExecEnv;
|
||||
|
||||
typedef bool (*FExecGetEnv)(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
|
||||
typedef bool (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
typedef int32_t (*FExecInit)(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
typedef int32_t (*FExecProcess)(struct SqlFunctionCtx *pCtx);
|
||||
typedef int32_t (*FExecFinalize)(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
||||
typedef int32_t (*FScalarExecProcess)(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput);
|
||||
|
@ -294,7 +294,7 @@ typedef struct SPoint {
|
|||
void *val;
|
||||
} SPoint;
|
||||
|
||||
int32_t taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint *point1, SPoint *point2,
|
||||
void taosGetLinearInterpolationVal(SPoint *point, int32_t outputType, SPoint *point1, SPoint *point2,
|
||||
int32_t inputType);
|
||||
|
||||
#define LEASTSQUARES_DOUBLE_ITEM_LENGTH 25
|
||||
|
|
|
@ -138,6 +138,7 @@ typedef enum EFunctionType {
|
|||
FUNCTION_TYPE_CACHE_LAST_ROW,
|
||||
FUNCTION_TYPE_CACHE_LAST,
|
||||
FUNCTION_TYPE_TABLE_COUNT,
|
||||
FUNCTION_TYPE_GROUP_CONST_VALUE,
|
||||
|
||||
// distributed splitting functions
|
||||
FUNCTION_TYPE_APERCENTILE_PARTIAL = 4000,
|
||||
|
@ -256,9 +257,10 @@ bool fmIsConstantResFunc(SFunctionNode* pFunc);
|
|||
bool fmIsSkipScanCheckFunc(int32_t funcId);
|
||||
bool fmIsPrimaryKeyFunc(int32_t funcId);
|
||||
bool fmIsProcessByRowFunc(int32_t funcId);
|
||||
bool fmisSelectGroupConstValueFunc(int32_t funcId);
|
||||
|
||||
void getLastCacheDataType(SDataType* pType, int32_t pkBytes);
|
||||
SFunctionNode* createFunction(const char* pName, SNodeList* pParameterList);
|
||||
int32_t createFunction(const char* pName, SNodeList* pParameterList, SFunctionNode** pFunc);
|
||||
|
||||
int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMidFunc, SFunctionNode** pMergeFunc);
|
||||
|
||||
|
@ -271,7 +273,7 @@ typedef enum EFuncDataRequired {
|
|||
} EFuncDataRequired;
|
||||
|
||||
EFuncDataRequired fmFuncDataRequired(SFunctionNode* pFunc, STimeWindow* pTimeWindow);
|
||||
EFuncDataRequired fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo);
|
||||
int32_t fmFuncDynDataRequired(int32_t funcId, void* pRes, SDataBlockInfo* pBlockInfo, int32_t *reqStatus);
|
||||
|
||||
int32_t fmGetFuncExecFuncs(int32_t funcId, SFuncExecFuncs* pFpSet);
|
||||
int32_t fmGetScalarFuncExecFuncs(int32_t funcId, SScalarFuncExecFuncs* pFpSet);
|
||||
|
|
|
@ -105,12 +105,14 @@ typedef uint16_t VarDataLenT; // maxVarDataLen: 65535
|
|||
#define varDataLen(v) ((VarDataLenT *)(v))[0]
|
||||
#define varDataVal(v) ((char *)(v) + VARSTR_HEADER_SIZE)
|
||||
#define varDataTLen(v) (sizeof(VarDataLenT) + varDataLen(v))
|
||||
#define varDataCopy(dst, v) memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataCopy(dst, v) (void)memcpy((dst), (void *)(v), varDataTLen(v))
|
||||
#define varDataLenByData(v) (*(VarDataLenT *)(((char *)(v)) - VARSTR_HEADER_SIZE))
|
||||
#define varDataSetLen(v, _len) (((VarDataLenT *)(v))[0] = (VarDataLenT)(_len))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || ((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) (((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
#define IS_VAR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR) || \
|
||||
((t) == TSDB_DATA_TYPE_JSON) || ((t) == TSDB_DATA_TYPE_GEOMETRY))
|
||||
#define IS_STR_DATA_TYPE(t) \
|
||||
(((t) == TSDB_DATA_TYPE_VARCHAR) || ((t) == TSDB_DATA_TYPE_VARBINARY) || ((t) == TSDB_DATA_TYPE_NCHAR))
|
||||
|
||||
static FORCE_INLINE char *udfColDataGetData(const SUdfColumn *pColumn, int32_t row) {
|
||||
if (IS_VAR_DATA_TYPE(pColumn->colMeta.type)) {
|
||||
|
@ -158,7 +160,7 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
|
|||
}
|
||||
data->varLenCol.varOffsets = (int32_t *)tmp;
|
||||
data->varLenCol.varOffsetsLen = sizeof(int32_t) * allocCapacity;
|
||||
memset(&data->varLenCol.varOffsets[existedRows], 0, sizeof(int32_t) * (allocCapacity - existedRows));
|
||||
(void)memset(&data->varLenCol.varOffsets[existedRows], 0, sizeof(int32_t) * (allocCapacity - existedRows));
|
||||
// for payload, add data in udfColDataAppend
|
||||
} else {
|
||||
char *tmp = (char *)realloc(data->fixLenCol.nullBitmap, BitmapLen(allocCapacity));
|
||||
|
@ -166,11 +168,11 @@ static FORCE_INLINE int32_t udfColEnsureCapacity(SUdfColumn *pColumn, int32_t ne
|
|||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
uint32_t extend = BitmapLen(allocCapacity) - BitmapLen(data->rowsAlloc);
|
||||
memset(tmp + BitmapLen(data->rowsAlloc), 0, extend);
|
||||
(void)memset(tmp + BitmapLen(data->rowsAlloc), 0, extend);
|
||||
data->fixLenCol.nullBitmap = tmp;
|
||||
data->fixLenCol.nullBitmapLen = BitmapLen(allocCapacity);
|
||||
int32_t oldLen = BitmapLen(existedRows);
|
||||
memset(&data->fixLenCol.nullBitmap[oldLen], 0, BitmapLen(allocCapacity) - oldLen);
|
||||
(void)memset(&data->fixLenCol.nullBitmap[oldLen], 0, BitmapLen(allocCapacity) - oldLen);
|
||||
|
||||
if (meta->type == TSDB_DATA_TYPE_NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
|
@ -198,7 +200,8 @@ static FORCE_INLINE void udfColDataSetNull(SUdfColumn *pColumn, int32_t row) {
|
|||
udfColDataSetNull_f(pColumn, row);
|
||||
}
|
||||
pColumn->hasNull = true;
|
||||
pColumn->colData.numOfRows = ((int32_t)(row + 1) > pColumn->colData.numOfRows) ? (int32_t)(row + 1) : pColumn->colData.numOfRows;
|
||||
pColumn->colData.numOfRows =
|
||||
((int32_t)(row + 1) > pColumn->colData.numOfRows) ? (int32_t)(row + 1) : pColumn->colData.numOfRows;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentRow, const char *pData, bool isNull) {
|
||||
|
@ -211,7 +214,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
|||
} else {
|
||||
if (!isVarCol) {
|
||||
udfColDataSetNotNull_f(pColumn, currentRow);
|
||||
memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||
(void)memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||
} else {
|
||||
int32_t dataLen = varDataTLen(pData);
|
||||
if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
|
@ -249,7 +252,7 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
|||
uint32_t len = data->varLenCol.payloadLen;
|
||||
data->varLenCol.varOffsets[currentRow] = len;
|
||||
|
||||
memcpy(data->varLenCol.payload + len, pData, dataLen);
|
||||
(void)memcpy(data->varLenCol.payload + len, pData, dataLen);
|
||||
data->varLenCol.payloadLen += dataLen;
|
||||
}
|
||||
}
|
||||
|
@ -278,8 +281,8 @@ typedef enum EUdfFuncType { UDF_FUNC_TYPE_SCALAR = 1, UDF_FUNC_TYPE_AGG = 2 } EU
|
|||
|
||||
typedef struct SScriptUdfInfo {
|
||||
const char *name;
|
||||
int32_t version;
|
||||
int64_t createdTime;
|
||||
int32_t version;
|
||||
int64_t createdTime;
|
||||
|
||||
EUdfFuncType funcType;
|
||||
int8_t scriptType;
|
||||
|
|
|
@ -77,7 +77,7 @@ void freeUdfInterBuf(SUdfInterBuf *buf);
|
|||
|
||||
// high level APIs
|
||||
bool udfAggGetEnv(struct SFunctionNode *pFunc, SFuncExecEnv *pEnv);
|
||||
bool udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
int32_t udfAggInit(struct SqlFunctionCtx *pCtx, struct SResultRowEntryInfo *pResultCellInfo);
|
||||
int32_t udfAggProcess(struct SqlFunctionCtx *pCtx);
|
||||
int32_t udfAggFinalize(struct SqlFunctionCtx *pCtx, SSDataBlock *pBlock);
|
||||
|
||||
|
|
|
@ -221,9 +221,6 @@ typedef struct SCreateSubTableFromFileClause {
|
|||
bool ignoreExists;
|
||||
SNodeList* pSpecificTags;
|
||||
char filePath[PATH_MAX];
|
||||
TdFilePtr fp;
|
||||
SArray* aCreateTbData;
|
||||
SArray* aTagIndexs;
|
||||
} SCreateSubTableFromFileClause;
|
||||
|
||||
typedef struct SCreateMultiTablesStmt {
|
||||
|
|
|
@ -233,7 +233,7 @@ typedef struct SViewNode {
|
|||
#define IS_WINDOW_JOIN(_stype) ((_stype) == JOIN_STYPE_WIN)
|
||||
#define IS_ASOF_JOIN(_stype) ((_stype) == JOIN_STYPE_ASOF)
|
||||
|
||||
typedef enum EJoinType {
|
||||
typedef enum EJoinType {
|
||||
JOIN_TYPE_INNER = 0,
|
||||
JOIN_TYPE_LEFT,
|
||||
JOIN_TYPE_RIGHT,
|
||||
|
@ -251,7 +251,7 @@ typedef enum EJoinSubType {
|
|||
JOIN_STYPE_MAX_VALUE
|
||||
} EJoinSubType;
|
||||
|
||||
typedef enum EJoinAlgorithm {
|
||||
typedef enum EJoinAlgorithm {
|
||||
JOIN_ALGO_UNKNOWN = 0,
|
||||
JOIN_ALGO_MERGE,
|
||||
JOIN_ALGO_HASH,
|
||||
|
@ -454,7 +454,7 @@ typedef struct SSetOperator {
|
|||
SNode* pLimit;
|
||||
char stmtName[TSDB_TABLE_NAME_LEN];
|
||||
uint8_t precision;
|
||||
ETimeLineMode timeLineResMode;
|
||||
ETimeLineMode timeLineResMode;
|
||||
bool timeLineFromOrderBy;
|
||||
bool joinContains;
|
||||
} SSetOperator;
|
||||
|
@ -504,6 +504,10 @@ typedef void (*FFreeTableBlockHash)(SHashObj*);
|
|||
typedef void (*FFreeVgourpBlockArray)(SArray*);
|
||||
struct SStbRowsDataContext;
|
||||
typedef void (*FFreeStbRowsDataContext)(struct SStbRowsDataContext*);
|
||||
struct SCreateTbInfo;
|
||||
struct SParseFileContext;
|
||||
typedef void (*FDestroyParseFileContext)(struct SParseFileContext**);
|
||||
|
||||
typedef struct SVnodeModifyOpStmt {
|
||||
ENodeType nodeType;
|
||||
ENodeType sqlNodeType;
|
||||
|
@ -524,7 +528,7 @@ typedef struct SVnodeModifyOpStmt {
|
|||
SHashObj* pTableNameHashObj; // set of table names for refreshing meta, sync mode
|
||||
SHashObj* pDbFNameHashObj; // set of db names for refreshing meta, sync mode
|
||||
SHashObj* pTableCxtHashObj; // temp SHashObj<tuid, STableDataCxt*> for single request
|
||||
SArray* pVgDataBlocks; // SArray<SVgroupDataCxt*>
|
||||
SArray* pVgDataBlocks; // SArray<SVgroupDataCxt*>
|
||||
SVCreateTbReq* pCreateTblReq;
|
||||
TdFilePtr fp;
|
||||
FFreeTableBlockHash freeHashFunc;
|
||||
|
@ -532,9 +536,13 @@ typedef struct SVnodeModifyOpStmt {
|
|||
bool usingTableProcessing;
|
||||
bool fileProcessing;
|
||||
|
||||
bool stbSyntax;
|
||||
struct SStbRowsDataContext* pStbRowsCxt;
|
||||
bool stbSyntax;
|
||||
struct SStbRowsDataContext* pStbRowsCxt;
|
||||
FFreeStbRowsDataContext freeStbRowsCxtFunc;
|
||||
|
||||
struct SCreateTbInfo* pCreateTbInfo;
|
||||
struct SParseFileContext* pParFileCxt;
|
||||
FDestroyParseFileContext destroyParseFileCxt;
|
||||
} SVnodeModifyOpStmt;
|
||||
|
||||
typedef struct SExplainOptions {
|
||||
|
@ -602,7 +610,7 @@ typedef enum ECollectColType { COLLECT_COL_TYPE_COL = 1, COLLECT_COL_TYPE_TAG, C
|
|||
int32_t nodesCollectColumns(SSelectStmt* pSelect, ESqlClause clause, const char* pTableAlias, ECollectColType type,
|
||||
SNodeList** pCols);
|
||||
int32_t nodesCollectColumnsExt(SSelectStmt* pSelect, ESqlClause clause, SSHashObj* pMultiTableAlias, ECollectColType type,
|
||||
SNodeList** pCols);
|
||||
SNodeList** pCols);
|
||||
int32_t nodesCollectColumnsFromNode(SNode* node, const char* pTableAlias, ECollectColType type, SNodeList** pCols);
|
||||
|
||||
typedef bool (*FFuncClassifier)(int32_t funcId);
|
||||
|
@ -618,6 +626,7 @@ bool nodesIsArithmeticOp(const SOperatorNode* pOp);
|
|||
bool nodesIsComparisonOp(const SOperatorNode* pOp);
|
||||
bool nodesIsJsonOp(const SOperatorNode* pOp);
|
||||
bool nodesIsRegularOp(const SOperatorNode* pOp);
|
||||
bool nodesIsMatchRegularOp(const SOperatorNode* pOp);
|
||||
bool nodesIsBitwiseOp(const SOperatorNode* pOp);
|
||||
|
||||
bool nodesExprHasColumn(SNode* pNode);
|
||||
|
|
|
@ -149,10 +149,10 @@ int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char*
|
|||
|
||||
void qDestroyBoundColInfo(void* pInfo);
|
||||
|
||||
SQuery* smlInitHandle();
|
||||
int32_t smlInitHandle(SQuery** query);
|
||||
int32_t smlBuildRow(STableDataCxt* pTableCxt);
|
||||
int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* kv, int32_t index);
|
||||
STableDataCxt* smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta);
|
||||
int32_t smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta, STableDataCxt** cxt);
|
||||
|
||||
void clearColValArraySml(SArray* pCols);
|
||||
int32_t smlBindData(SQuery* handle, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols,
|
||||
|
@ -163,8 +163,8 @@ int rawBlockBindData(SQuery *query, STableMeta* pTableMeta, void* data, SVCr
|
|||
int numFields, bool needChangeLength, char* errstr, int32_t errstrLen);
|
||||
|
||||
int32_t rewriteToVnodeModifyOpStmt(SQuery* pQuery, SArray* pBufArray);
|
||||
SArray* serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap);
|
||||
SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap);
|
||||
int32_t serializeVgroupsCreateTableBatch(SHashObj* pVgroupHashmap, SArray** pOut);
|
||||
int32_t serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap, SArray** pOut);
|
||||
void destoryCatalogReq(SCatalogReq *pCatalogReq);
|
||||
bool isPrimaryKeyImpl(SNode* pExpr);
|
||||
int32_t insAppendStmtTableDataCxt(SHashObj* pAllVgHash, STableColsData* pTbData, STableDataCxt* pTbCtx, SStbInterlaceInfo* pBuildInfo);
|
||||
|
|
|
@ -192,6 +192,7 @@ typedef struct SBoundColInfo {
|
|||
int16_t* pColIndex; // bound index => schema index
|
||||
int32_t numOfCols;
|
||||
int32_t numOfBound;
|
||||
bool hasBoundCols;
|
||||
} SBoundColInfo;
|
||||
|
||||
typedef struct STableColsData {
|
||||
|
@ -334,7 +335,7 @@ SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* nam
|
|||
|
||||
void destroyQueryExecRes(SExecResult* pRes);
|
||||
int32_t dataConverToStr(char* str, int type, void* buf, int32_t bufSize, int32_t* len);
|
||||
char* parseTagDatatoJson(void* p);
|
||||
void parseTagDatatoJson(void* p, char** jsonStr);
|
||||
int32_t cloneTableMeta(STableMeta* pSrc, STableMeta** pDst);
|
||||
void getColumnTypeFromMeta(STableMeta* pMeta, char* pName, ETableColumnType* pType);
|
||||
int32_t cloneDbVgInfo(SDBVgInfo* pSrc, SDBVgInfo** pDst);
|
||||
|
|
|
@ -58,12 +58,13 @@ extern int32_t filterGetTimeRange(SNode *pNode, STimeWindow *win, bool *isStrict
|
|||
extern int32_t filterConverNcharColumns(SFilterInfo *pFilterInfo, int32_t rows, bool *gotNchar);
|
||||
extern int32_t filterFreeNcharColumns(SFilterInfo *pFilterInfo);
|
||||
extern void filterFreeInfo(SFilterInfo *info);
|
||||
extern bool filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pColsAgg, int32_t numOfCols, int32_t numOfRows);
|
||||
extern int32_t filterRangeExecute(SFilterInfo *info, SColumnDataAgg *pDataStatis, int32_t numOfCols, int32_t numOfRows,
|
||||
bool *keep);
|
||||
|
||||
/* condition split interface */
|
||||
int32_t filterPartitionCond(SNode **pCondition, SNode **pPrimaryKeyCond, SNode **pTagIndexCond, SNode **pTagCond,
|
||||
SNode **pOtherCond);
|
||||
bool filterIsMultiTableColsCond(SNode *pCond);
|
||||
int32_t filterIsMultiTableColsCond(SNode *pCond, bool *res);
|
||||
EConditionType filterClassifyCondition(SNode *pNode);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -23,8 +23,6 @@ extern "C" {
|
|||
#include "catalog.h"
|
||||
#include "planner.h"
|
||||
|
||||
extern tsem_t schdRspSem;
|
||||
|
||||
typedef struct SQueryProfileSummary {
|
||||
int64_t startTs; // Object created and added into the message queue
|
||||
int64_t endTs; // the timestamp when the task is completed
|
||||
|
@ -101,8 +99,6 @@ void schedulerFreeJob(int64_t* job, int32_t errCode);
|
|||
|
||||
void schedulerDestroy(void);
|
||||
|
||||
void schdExecCallback(SExecResult* pResult, void* param, int32_t code);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -32,7 +32,7 @@ extern "C" {
|
|||
SStreamState* streamStateOpen(const char* path, void* pTask, int64_t streamId, int32_t taskId);
|
||||
void streamStateClose(SStreamState* pState, bool remove);
|
||||
int32_t streamStateBegin(SStreamState* pState);
|
||||
int32_t streamStateCommit(SStreamState* pState);
|
||||
void streamStateCommit(SStreamState* pState);
|
||||
void streamStateDestroy(SStreamState* pState, bool remove);
|
||||
int32_t streamStateDeleteCheckPoint(SStreamState* pState, TSKEY mark);
|
||||
int32_t streamStateDelTaskDb(SStreamState* pState);
|
||||
|
@ -41,22 +41,23 @@ int32_t streamStateFuncPut(SStreamState* pState, const SWinKey* key, const void*
|
|||
int32_t streamStateFuncGet(SStreamState* pState, const SWinKey* key, void** ppVal, int32_t* pVLen);
|
||||
|
||||
int32_t streamStatePut(SStreamState* pState, const SWinKey* key, const void* value, int32_t vLen);
|
||||
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateGet(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
bool streamStateCheck(SStreamState* pState, const SWinKey* key);
|
||||
int32_t streamStateGetByPos(SStreamState* pState, void* pos, void** pVal);
|
||||
int32_t streamStateDel(SStreamState* pState, const SWinKey* key);
|
||||
int32_t streamStateClear(SStreamState* pState);
|
||||
void streamStateDel(SStreamState* pState, const SWinKey* key);
|
||||
void streamStateClear(SStreamState* pState);
|
||||
void streamStateSetNumber(SStreamState* pState, int32_t number, int32_t tsIdex);
|
||||
int32_t streamStateSaveInfo(SStreamState* pState, void* pKey, int32_t keyLen, void* pVal, int32_t vLen);
|
||||
void streamStateSaveInfo(SStreamState* pState, void* pKey, int32_t keyLen, void* pVal, int32_t vLen);
|
||||
int32_t streamStateGetInfo(SStreamState* pState, void* pKey, int32_t keyLen, void** pVal, int32_t* pLen);
|
||||
|
||||
// session window
|
||||
int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, TSKEY gap, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateSessionAddIfNotExist(SStreamState* pState, SSessionKey* key, TSKEY gap, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
int32_t streamStateSessionPut(SStreamState* pState, const SSessionKey* key, 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 streamStateSessionReset(SStreamState* pState, void* pVal);
|
||||
int32_t streamStateSessionClear(SStreamState* pState);
|
||||
int32_t streamStateSessionGet(SStreamState* pState, SSessionKey* key, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
void streamStateSessionDel(SStreamState* pState, const SSessionKey* key);
|
||||
void streamStateSessionReset(SStreamState* pState, void* pVal);
|
||||
void streamStateSessionClear(SStreamState* pState);
|
||||
int32_t streamStateSessionGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateSessionGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||
int32_t streamStateCountGetKeyByRange(SStreamState* pState, const SSessionKey* range, SSessionKey* curKey);
|
||||
|
@ -70,23 +71,26 @@ SStreamStateCur* streamStateSessionSeekKeyCurrentNext(SStreamState* pState, cons
|
|||
|
||||
// state window
|
||||
int32_t streamStateStateAddIfNotExist(SStreamState* pState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
|
||||
// fill
|
||||
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);
|
||||
int32_t streamStateFillGetNext(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateFillGetPrev(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
void streamStateFillDel(SStreamState* pState, const SWinKey* key);
|
||||
int32_t streamStateFillGetNext(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
int32_t streamStateFillGetPrev(SStreamState* pState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
|
||||
int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateReleaseBuf(SStreamState* pState, void* pVal, bool used);
|
||||
int32_t streamStateClearBuff(SStreamState* pState, void* pVal);
|
||||
int32_t streamStateAddIfNotExist(SStreamState* pState, const SWinKey* key, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
void streamStateReleaseBuf(SStreamState* pState, void* pVal, bool used);
|
||||
void streamStateClearBuff(SStreamState* pState, void* pVal);
|
||||
void streamStateFreeVal(void* val);
|
||||
|
||||
// count window
|
||||
int32_t streamStateCountWinAddIfNotExist(SStreamState* pState, SSessionKey* pKey, COUNT_TYPE winCount, void** ppVal,
|
||||
int32_t* pVLen);
|
||||
int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t streamStateCountWinAdd(SStreamState* pState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
SStreamStateCur* streamStateGetAndCheckCur(SStreamState* pState, SWinKey* key);
|
||||
|
@ -99,11 +103,11 @@ void streamStateResetCur(SStreamStateCur* pCur);
|
|||
int32_t streamStateGetGroupKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||
int32_t streamStateGetKVByCur(SStreamStateCur* pCur, SWinKey* pKey, const void** pVal, int32_t* pVLen);
|
||||
|
||||
int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur);
|
||||
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur);
|
||||
void streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur);
|
||||
void streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur);
|
||||
|
||||
int32_t streamStatePutParName(SStreamState* pState, int64_t groupId, const char* tbname);
|
||||
int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal, bool onlyCache);
|
||||
int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal, bool onlyCache, int32_t* pWinCode);
|
||||
|
||||
void streamStateReloadInfo(SStreamState* pState, TSKEY ts);
|
||||
|
||||
|
|
|
@ -59,8 +59,6 @@ extern "C" {
|
|||
#define STREAM_EXEC_T_STOP_ALL_TASKS (-5)
|
||||
#define STREAM_EXEC_T_RESUME_TASK (-6)
|
||||
#define STREAM_EXEC_T_ADD_FAILED_TASK (-7)
|
||||
// the load and start stream task should be executed after snode has started successfully, since the load of stream
|
||||
// tasks may incur the download of checkpoint data from remote, which may consume significant network and CPU resources.
|
||||
|
||||
typedef struct SStreamTask SStreamTask;
|
||||
typedef struct SStreamQueue SStreamQueue;
|
||||
|
@ -190,8 +188,8 @@ typedef struct {
|
|||
SSDataBlock* pBlock;
|
||||
} SStreamRefDataBlock;
|
||||
|
||||
SStreamDataSubmit* streamDataSubmitNew(SPackedData* pData, int32_t type);
|
||||
void streamDataSubmitDestroy(SStreamDataSubmit* pDataSubmit);
|
||||
int32_t streamDataSubmitNew(SPackedData* pData, int32_t type, SStreamDataSubmit** pSubmit);
|
||||
void streamDataSubmitDestroy(SStreamDataSubmit* pDataSubmit);
|
||||
|
||||
typedef struct {
|
||||
char* qmsg;
|
||||
|
@ -237,6 +235,8 @@ typedef struct {
|
|||
int64_t stbUid;
|
||||
char stbFullName[TSDB_TABLE_FNAME_LEN];
|
||||
SSchemaWrapper* pSchemaWrapper;
|
||||
SSchemaWrapper* pTagSchema;
|
||||
bool autoCreateCtb;
|
||||
void* vnode; // not available to encoder and decoder
|
||||
FTbSink* tbSinkFunc;
|
||||
STSchema* pTSchema;
|
||||
|
@ -528,13 +528,13 @@ typedef struct STaskUpdateEntry {
|
|||
|
||||
typedef int32_t (*__state_trans_user_fn)(SStreamTask*, void* param);
|
||||
|
||||
SStreamTask* tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam,
|
||||
SArray* pTaskList, bool hasFillhistory, int8_t subtableWithoutMd5);
|
||||
void tFreeStreamTask(SStreamTask* pTask);
|
||||
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
||||
int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, int64_t ver);
|
||||
void streamFreeTaskState(SStreamTask* pTask, ETaskStatus status);
|
||||
int32_t tNewStreamTask(int64_t streamId, int8_t taskLevel, SEpSet* pEpset, bool fillHistory, int64_t triggerParam,
|
||||
SArray* pTaskList, bool hasFillhistory, int8_t subtableWithoutMd5, SStreamTask** pTask);
|
||||
void tFreeStreamTask(SStreamTask* pTask);
|
||||
int32_t tEncodeStreamTask(SEncoder* pEncoder, const SStreamTask* pTask);
|
||||
int32_t tDecodeStreamTask(SDecoder* pDecoder, SStreamTask* pTask);
|
||||
int32_t streamTaskInit(SStreamTask* pTask, SStreamMeta* pMeta, SMsgCb* pMsgCb, int64_t ver);
|
||||
void streamFreeTaskState(SStreamTask* pTask, ETaskStatus status);
|
||||
|
||||
int32_t tDecodeStreamTaskChkInfo(SDecoder* pDecoder, SCheckpointInfo* pChkpInfo);
|
||||
int32_t tDecodeStreamTaskId(SDecoder* pDecoder, STaskId* pTaskId);
|
||||
|
@ -629,8 +629,10 @@ int32_t streamSetupScheduleTrigger(SStreamTask* pTask);
|
|||
int32_t streamProcessDispatchMsg(SStreamTask* pTask, SStreamDispatchReq* pReq, SRpcMsg* pMsg);
|
||||
int32_t streamProcessDispatchRsp(SStreamTask* pTask, SStreamDispatchRsp* pRsp, int32_t code);
|
||||
|
||||
SStreamUpstreamEpInfo* streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t taskId);
|
||||
SEpSet* streamTaskGetDownstreamEpInfo(SStreamTask* pTask, int32_t taskId);
|
||||
void streamTaskGetUpstreamTaskEpInfo(SStreamTask* pTask, int32_t taskId, SStreamUpstreamEpInfo** pEpInfo);
|
||||
#if 0
|
||||
SEpSet* streamTaskGetDownstreamEpInfo(SStreamTask* pTask, int32_t taskId);
|
||||
#endif
|
||||
|
||||
void streamTaskInputFail(SStreamTask* pTask);
|
||||
|
||||
|
@ -639,8 +641,8 @@ bool streamTaskShouldPause(const SStreamTask* pStatus);
|
|||
bool streamTaskIsIdle(const SStreamTask* pTask);
|
||||
bool streamTaskReadyToRun(const SStreamTask* pTask, char** pStatus);
|
||||
|
||||
char* createStreamTaskIdStr(int64_t streamId, int32_t taskId);
|
||||
SStreamTaskState* streamTaskGetStatus(const SStreamTask* pTask);
|
||||
int32_t createStreamTaskIdStr(int64_t streamId, int32_t taskId, const char** pId);
|
||||
SStreamTaskState streamTaskGetStatus(const SStreamTask* pTask);
|
||||
const char* streamTaskGetStatusStr(ETaskStatus status);
|
||||
void streamTaskResetStatus(SStreamTask* pTask);
|
||||
void streamTaskSetStatusReady(SStreamTask* pTask);
|
||||
|
@ -657,10 +659,10 @@ int8_t streamTaskSetSchedStatusInactive(SStreamTask* pTask);
|
|||
int32_t streamTaskClearHTaskAttr(SStreamTask* pTask, int32_t clearRelHalt);
|
||||
|
||||
int32_t streamExecTask(SStreamTask* pTask);
|
||||
int32_t streamResumeTask(SStreamTask* pTask);
|
||||
void streamResumeTask(SStreamTask* pTask);
|
||||
int32_t streamTrySchedExec(SStreamTask* pTask);
|
||||
int32_t streamTaskSchedTask(SMsgCb* pMsgCb, int32_t vgId, int64_t streamId, int32_t taskId, int32_t execType);
|
||||
int32_t streamTaskResumeInFuture(SStreamTask* pTask);
|
||||
void streamTaskResumeInFuture(SStreamTask* pTask);
|
||||
void streamTaskClearSchedIdleInfo(SStreamTask* pTask);
|
||||
void streamTaskSetIdleInfo(SStreamTask* pTask, int32_t idleTime);
|
||||
|
||||
|
@ -673,8 +675,8 @@ int32_t streamTaskSendCheckRsp(const SStreamMeta* pMeta, int32_t vgId, SStreamTa
|
|||
int32_t streamTaskProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp);
|
||||
|
||||
// check downstream status
|
||||
int32_t streamTaskStartMonitorCheckRsp(SStreamTask* pTask);
|
||||
int32_t streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id);
|
||||
void streamTaskStartMonitorCheckRsp(SStreamTask* pTask);
|
||||
void streamTaskStopMonitorCheckRsp(STaskCheckInfo* pInfo, const char* id);
|
||||
void streamTaskCleanupCheckInfo(STaskCheckInfo* pInfo);
|
||||
|
||||
// fill-history task
|
||||
|
@ -684,7 +686,7 @@ int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration);
|
|||
bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer);
|
||||
|
||||
// checkpoint related
|
||||
int32_t streamTaskGetActiveCheckpointInfo(const SStreamTask* pTask, int32_t* pTransId, int64_t* pCheckpointId);
|
||||
void streamTaskGetActiveCheckpointInfo(const SStreamTask* pTask, int32_t* pTransId, int64_t* pCheckpointId);
|
||||
int32_t streamTaskSetActiveCheckpointInfo(SStreamTask* pTask, int64_t activeCheckpointId);
|
||||
int32_t streamTaskSetFailedChkptInfo(SStreamTask* pTask, int32_t transId, int64_t checkpointId);
|
||||
bool streamTaskAlreadySendTrigger(SStreamTask* pTask, int32_t downstreamNodeId);
|
||||
|
@ -722,43 +724,43 @@ int32_t streamSetParamForStreamScannerStep2(SStreamTask* pTask, SVersionRange* p
|
|||
SScanhistoryDataInfo streamScanHistoryData(SStreamTask* pTask, int64_t st);
|
||||
|
||||
// stream task meta
|
||||
void streamMetaInit();
|
||||
void streamMetaCleanup();
|
||||
SStreamMeta* streamMetaOpen(const char* path, void* ahandle, FTaskBuild expandFunc, FTaskExpand expandTaskFn,
|
||||
int32_t vgId, int64_t stage, startComplete_fn_t fn);
|
||||
void streamMetaClose(SStreamMeta* streamMeta);
|
||||
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask); // save to stream meta store
|
||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey);
|
||||
int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask, bool* pAdded);
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta);
|
||||
SStreamTask* streamMetaAcquireTaskNoLock(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
SStreamTask* streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||
SStreamTask* streamMetaAcquireOneTask(SStreamTask* pTask);
|
||||
void streamMetaClear(SStreamMeta* pMeta);
|
||||
void streamMetaInitBackend(SStreamMeta* pMeta);
|
||||
int32_t streamMetaCommit(SStreamMeta* pMeta);
|
||||
int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta);
|
||||
void streamMetaNotifyClose(SStreamMeta* pMeta);
|
||||
void streamMetaStartHb(SStreamMeta* pMeta);
|
||||
bool streamMetaTaskInTimer(SStreamMeta* pMeta);
|
||||
int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, int64_t startTs,
|
||||
int64_t endTs, bool ready);
|
||||
int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta);
|
||||
int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs);
|
||||
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
|
||||
int64_t startTs);
|
||||
void streamMetaClearUpdateTaskList(SStreamMeta* pMeta);
|
||||
void streamMetaInitUpdateTaskList(SStreamMeta* pMeta, int32_t transId);
|
||||
void streamMetaInit();
|
||||
void streamMetaCleanup();
|
||||
int32_t streamMetaOpen(const char* path, void* ahandle, FTaskBuild expandFunc, FTaskExpand expandTaskFn, int32_t vgId,
|
||||
int64_t stage, startComplete_fn_t fn, SStreamMeta** pMeta);
|
||||
void streamMetaClose(SStreamMeta* streamMeta);
|
||||
int32_t streamMetaSaveTask(SStreamMeta* pMeta, SStreamTask* pTask); // save to stream meta store
|
||||
int32_t streamMetaRemoveTask(SStreamMeta* pMeta, STaskId* pKey);
|
||||
int32_t streamMetaRegisterTask(SStreamMeta* pMeta, int64_t ver, SStreamTask* pTask, bool* pAdded);
|
||||
int32_t streamMetaUnregisterTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
int32_t streamMetaGetNumOfTasks(SStreamMeta* pMeta);
|
||||
int32_t streamMetaAcquireTaskNoLock(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, SStreamTask** pTask);
|
||||
int32_t streamMetaAcquireTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, SStreamTask** pTask);
|
||||
void streamMetaReleaseTask(SStreamMeta* pMeta, SStreamTask* pTask);
|
||||
void streamMetaAcquireOneTask(SStreamTask* pTask);
|
||||
void streamMetaClear(SStreamMeta* pMeta);
|
||||
void streamMetaInitBackend(SStreamMeta* pMeta);
|
||||
int32_t streamMetaCommit(SStreamMeta* pMeta);
|
||||
int64_t streamMetaGetLatestCheckpointId(SStreamMeta* pMeta);
|
||||
void streamMetaNotifyClose(SStreamMeta* pMeta);
|
||||
void streamMetaStartHb(SStreamMeta* pMeta);
|
||||
bool streamMetaTaskInTimer(SStreamMeta* pMeta);
|
||||
int32_t streamMetaAddTaskLaunchResult(SStreamMeta* pMeta, int64_t streamId, int32_t taskId, int64_t startTs,
|
||||
int64_t endTs, bool ready);
|
||||
int32_t streamMetaResetTaskStatus(SStreamMeta* pMeta);
|
||||
int32_t streamMetaAddFailedTask(SStreamMeta* pMeta, int64_t streamId, int32_t taskId);
|
||||
void streamMetaAddFailedTaskSelf(SStreamTask* pTask, int64_t failedTs);
|
||||
void streamMetaAddIntoUpdateTaskList(SStreamMeta* pMeta, SStreamTask* pTask, SStreamTask* pHTask, int32_t transId,
|
||||
int64_t startTs);
|
||||
void streamMetaClearUpdateTaskList(SStreamMeta* pMeta);
|
||||
void streamMetaInitUpdateTaskList(SStreamMeta* pMeta, int32_t transId);
|
||||
|
||||
void streamMetaRLock(SStreamMeta* pMeta);
|
||||
void streamMetaRUnLock(SStreamMeta* pMeta);
|
||||
void streamMetaWLock(SStreamMeta* pMeta);
|
||||
void streamMetaWUnLock(SStreamMeta* pMeta);
|
||||
void streamMetaResetStartInfo(STaskStartInfo* pMeta, int32_t vgId);
|
||||
SArray* streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta);
|
||||
int32_t streamMetaSendMsgBeforeCloseTasks(SStreamMeta* pMeta, SArray** pTaskList);
|
||||
void streamMetaUpdateStageRole(SStreamMeta* pMeta, int64_t stage, bool isLeader);
|
||||
void streamMetaLoadAllTasks(SStreamMeta* pMeta);
|
||||
int32_t streamMetaStartAllTasks(SStreamMeta* pMeta);
|
||||
|
@ -768,7 +770,9 @@ bool streamMetaAllTasksReady(const SStreamMeta* pMeta);
|
|||
int32_t streamTaskSendRestoreChkptMsg(SStreamTask* pTask);
|
||||
|
||||
// timer
|
||||
tmr_h streamTimerGetInstance();
|
||||
int32_t streamTimerGetInstance(tmr_h* pTmr);
|
||||
void streamTmrReset(TAOS_TMR_CALLBACK fp, int32_t mseconds, void* param, void* handle, tmr_h* pTmrId, int32_t vgId,
|
||||
const char* pMsg);
|
||||
|
||||
// checkpoint
|
||||
int32_t streamProcessCheckpointSourceReq(SStreamTask* pTask, SStreamCheckpointSourceReq* pReq);
|
||||
|
@ -785,14 +789,14 @@ int32_t streamTaskBuildCheckpointSourceRsp(SStreamCheckpointSourceReq* pReq, SRp
|
|||
int32_t setCode);
|
||||
int32_t streamSendChkptReportMsg(SStreamTask* pTask, SCheckpointInfo* pCheckpointInfo, int8_t dropRelHTask);
|
||||
int32_t streamTaskUpdateTaskCheckpointInfo(SStreamTask* pTask, bool restored, SVUpdateCheckpointInfoReq* pReq);
|
||||
SActiveCheckpointInfo* streamTaskCreateActiveChkptInfo();
|
||||
int32_t streamTaskCreateActiveChkptInfo(SActiveCheckpointInfo** pRes);
|
||||
|
||||
// stream task state machine, and event handling
|
||||
SStreamTaskSM* streamCreateStateMachine(SStreamTask* pTask);
|
||||
void* streamDestroyStateMachine(SStreamTaskSM* pSM);
|
||||
int32_t streamTaskHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event);
|
||||
int32_t streamTaskHandleEventAsync(SStreamTaskSM* pSM, EStreamTaskEvent event, __state_trans_user_fn callbackFn,
|
||||
void* param);
|
||||
int32_t streamCreateStateMachine(SStreamTask* pTask);
|
||||
void streamDestroyStateMachine(SStreamTaskSM* pSM);
|
||||
int32_t streamTaskHandleEvent(SStreamTaskSM* pSM, EStreamTaskEvent event);
|
||||
int32_t streamTaskHandleEventAsync(SStreamTaskSM* pSM, EStreamTaskEvent event, __state_trans_user_fn callbackFn,
|
||||
void* param);
|
||||
int32_t streamTaskOnHandleEventSuccess(SStreamTaskSM* pSM, EStreamTaskEvent event, __state_trans_user_fn callbackFn,
|
||||
void* param);
|
||||
int32_t streamTaskRestoreStatus(SStreamTask* pTask);
|
||||
|
@ -803,8 +807,11 @@ int32_t streamTaskBroadcastRetrieveReq(SStreamTask* pTask, SStreamRetrieveReq* r
|
|||
void streamTaskSendRetrieveRsp(SStreamRetrieveReq* pReq, SRpcMsg* pRsp);
|
||||
|
||||
int32_t streamProcessHeartbeatRsp(SStreamMeta* pMeta, SMStreamHbRspMsg* pRsp);
|
||||
int32_t streamTaskSendPreparedCheckpointsourceRsp(SStreamTask* pTask);
|
||||
int32_t streamTaskSendCheckpointsourceRsp(SStreamTask* pTask);
|
||||
|
||||
void streamMutexLock(TdThreadMutex *pMutex);
|
||||
void streamMutexUnlock(TdThreadMutex *pMutex);
|
||||
void streamMutexDestroy(TdThreadMutex *pMutex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -18,10 +18,10 @@
|
|||
|
||||
#include "os.h"
|
||||
|
||||
#include "storageapi.h"
|
||||
#include "tarray.h"
|
||||
#include "tdef.h"
|
||||
#include "tlist.h"
|
||||
#include "storageapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -30,66 +30,70 @@ extern "C" {
|
|||
typedef struct SStreamFileState SStreamFileState;
|
||||
typedef SList SStreamSnapshot;
|
||||
|
||||
typedef void* (*_state_buff_get_fn)(void* pRowBuff, const void* pKey, size_t keyLen);
|
||||
typedef void* (*_state_buff_get_fn)(void* pRowBuff, const void* pKey, size_t keyLen);
|
||||
typedef int32_t (*_state_buff_remove_fn)(void* pRowBuff, const void* pKey, size_t keyLen);
|
||||
typedef int32_t (*_state_buff_remove_by_pos_fn)(SStreamFileState* pState, SRowBuffPos* pPos);
|
||||
typedef void (*_state_buff_cleanup_fn)(void* pRowBuff);
|
||||
typedef void* (*_state_buff_create_statekey_fn)(SRowBuffPos* pPos, int64_t num);
|
||||
typedef void (*_state_buff_remove_by_pos_fn)(SStreamFileState* pState, SRowBuffPos* pPos);
|
||||
typedef void (*_state_buff_cleanup_fn)(void* pRowBuff);
|
||||
typedef void* (*_state_buff_create_statekey_fn)(SRowBuffPos* pPos, int64_t num);
|
||||
|
||||
typedef int32_t (*_state_file_remove_fn)(SStreamFileState* pFileState, const void* pKey);
|
||||
typedef int32_t (*_state_file_get_fn)(SStreamFileState* pFileState, void* pKey, void** data, int32_t* pDataLen);
|
||||
typedef int32_t (*_state_file_clear_fn)(SStreamState* pState);
|
||||
|
||||
typedef int32_t (*_state_fun_get_fn) (SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen);
|
||||
typedef int32_t (*_state_fun_get_fn)(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal,
|
||||
int32_t* pVLen, int32_t* pWinCode);
|
||||
|
||||
typedef int32_t (*range_cmpr_fn)(const SSessionKey* pWin1, const SSessionKey* pWin2);
|
||||
|
||||
typedef int (*__session_compare_fn_t)(const void* pWin, const void* pDatas, int pos);
|
||||
|
||||
SStreamFileState* streamFileStateInit(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
|
||||
GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId,
|
||||
int64_t checkpointId, int8_t type);
|
||||
GetTsFun fp, void* pFile, TSKEY delMark, const char* taskId, int64_t checkpointId,
|
||||
int8_t type);
|
||||
void streamFileStateDestroy(SStreamFileState* pFileState);
|
||||
void streamFileStateClear(SStreamFileState* pFileState);
|
||||
bool needClearDiskBuff(SStreamFileState* pFileState);
|
||||
void streamFileStateReleaseBuff(SStreamFileState* pFileState, SRowBuffPos* pPos, bool used);
|
||||
int32_t streamFileStateClearBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
void streamFileStateClearBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
|
||||
int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen);
|
||||
int32_t deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen);
|
||||
int32_t getRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
void deleteRowBuff(SStreamFileState* pFileState, const void* pKey, int32_t keyLen);
|
||||
int32_t getRowBuffByPos(SStreamFileState* pFileState, SRowBuffPos* pPos, void** pVal);
|
||||
bool hasRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen);
|
||||
void putFreeBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
int32_t putFreeBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
|
||||
SStreamSnapshot* getSnapshot(SStreamFileState* pFileState);
|
||||
int32_t flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot, bool flushState);
|
||||
int32_t recoverSnapshot(SStreamFileState* pFileState, int64_t ckId);
|
||||
void flushSnapshot(SStreamFileState* pFileState, SStreamSnapshot* pSnapshot, bool flushState);
|
||||
void recoverSnapshot(SStreamFileState* pFileState, int64_t ckId);
|
||||
|
||||
int32_t getSnapshotIdList(SStreamFileState* pFileState, SArray* list);
|
||||
int32_t deleteExpiredCheckPoint(SStreamFileState* pFileState, TSKEY mark);
|
||||
int32_t streamFileStateGetSelectRowSize(SStreamFileState* pFileState);
|
||||
void streamFileStateReloadInfo(SStreamFileState* pFileState, TSKEY ts);
|
||||
|
||||
void* getRowStateBuff(SStreamFileState* pFileState);
|
||||
void* getSearchBuff(SStreamFileState* pFileState);
|
||||
void* getStateFileStore(SStreamFileState* pFileState);
|
||||
bool isDeteled(SStreamFileState* pFileState, TSKEY ts);
|
||||
bool isFlushedState(SStreamFileState* pFileState, TSKEY ts, TSKEY gap);
|
||||
TSKEY getFlushMark(SStreamFileState* pFileState);
|
||||
void* getRowStateBuff(SStreamFileState* pFileState);
|
||||
void* getSearchBuff(SStreamFileState* pFileState);
|
||||
void* getStateFileStore(SStreamFileState* pFileState);
|
||||
bool isDeteled(SStreamFileState* pFileState, TSKEY ts);
|
||||
bool isFlushedState(SStreamFileState* pFileState, TSKEY ts, TSKEY gap);
|
||||
TSKEY getFlushMark(SStreamFileState* pFileState);
|
||||
SRowBuffPos* getNewRowPosForWrite(SStreamFileState* pFileState);
|
||||
int32_t getRowStateRowSize(SStreamFileState* pFileState);
|
||||
int32_t getRowStateRowSize(SStreamFileState* pFileState);
|
||||
|
||||
// session window
|
||||
int32_t getSessionWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, TSKEY gap, void** pVal, int32_t* pVLen);
|
||||
int32_t getSessionWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, TSKEY gap, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
int32_t putSessionWinResultBuff(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
int32_t getSessionFlushedBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
int32_t getSessionFlushedBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
int32_t deleteSessionWinStateBuffFn(void* pBuff, const void* key, size_t keyLen);
|
||||
int32_t deleteSessionWinStateBuffByPosFn(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
void deleteSessionWinStateBuffByPosFn(SStreamFileState* pFileState, SRowBuffPos* pPos);
|
||||
int32_t allocSessioncWinBuffByNextPosition(SStreamFileState* pFileState, SStreamStateCur* pCur,
|
||||
const SSessionKey* pWinKey, void** ppVal, int32_t* pVLen);
|
||||
|
||||
SRowBuffPos* createSessionWinBuff(SStreamFileState* pFileState, SSessionKey* pKey, void* p, int32_t* pVLen);
|
||||
int32_t recoverSesssion(SStreamFileState* pFileState, int64_t ckId);
|
||||
void recoverSesssion(SStreamFileState* pFileState, int64_t ckId);
|
||||
|
||||
void sessionWinStateClear(SStreamFileState* pFileState);
|
||||
void sessionWinStateCleanup(void* pBuff);
|
||||
|
@ -98,31 +102,36 @@ SStreamStateCur* sessionWinStateSeekKeyCurrentPrev(SStreamFileState* pFileState,
|
|||
SStreamStateCur* sessionWinStateSeekKeyCurrentNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
||||
SStreamStateCur* sessionWinStateSeekKeyNext(SStreamFileState* pFileState, const SSessionKey* pWinKey);
|
||||
SStreamStateCur* countWinStateSeekKeyPrev(SStreamFileState* pFileState, const SSessionKey* pWinKey, COUNT_TYPE count);
|
||||
int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
int32_t sessionWinStateMoveToNext(SStreamStateCur* pCur);
|
||||
int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey, range_cmpr_fn cmpFn);
|
||||
int32_t sessionWinStateGetKVByCur(SStreamStateCur* pCur, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
void sessionWinStateMoveToNext(SStreamStateCur* pCur);
|
||||
int32_t sessionWinStateGetKeyByRange(SStreamFileState* pFileState, const SSessionKey* key, SSessionKey* curKey,
|
||||
range_cmpr_fn cmpFn);
|
||||
|
||||
int32_t binarySearch(void* keyList, int num, const void* key, __session_compare_fn_t cmpFn);
|
||||
|
||||
// state window
|
||||
int32_t getStateWinResultBuff(SStreamFileState* pFileState, SSessionKey* key, char* pKeyData, int32_t keyDataLen,
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen);
|
||||
state_key_cmpr_fn fn, void** pVal, int32_t* pVLen, int32_t* pWinCode);
|
||||
|
||||
// count window
|
||||
int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal, int32_t* pVLen);
|
||||
int32_t getCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, COUNT_TYPE winCount, void** pVal,
|
||||
int32_t* pVLen, int32_t* pWinCode);
|
||||
int32_t createCountWinResultBuff(SStreamFileState* pFileState, SSessionKey* pKey, void** pVal, int32_t* pVLen);
|
||||
|
||||
//function
|
||||
int32_t getSessionRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen);
|
||||
// function
|
||||
int32_t getSessionRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen,
|
||||
int32_t* pWinCode);
|
||||
int32_t getFunctionRowBuff(SStreamFileState* pFileState, void* pKey, int32_t keyLen, void** pVal, int32_t* pVLen);
|
||||
|
||||
//fill
|
||||
// fill
|
||||
int32_t getHashSortRowBuff(SStreamFileState* pFileState, const SWinKey* pKey, void** pVal, int32_t* pVLen);
|
||||
int32_t hashSortFileGetFn(SStreamFileState* pFileState, void* pKey, void** data, int32_t* pDataLen);
|
||||
int32_t hashSortFileRemoveFn(SStreamFileState* pFileState, const void* pKey);
|
||||
void clearSearchBuff(SStreamFileState* pFileState);
|
||||
int32_t getHashSortNextRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
int32_t getHashSortPrevRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** pVal, int32_t* pVLen);
|
||||
int32_t getHashSortNextRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
int32_t getHashSortPrevRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** pVal,
|
||||
int32_t* pVLen);
|
||||
int32_t recoverFillSnapshot(SStreamFileState* pFileState, int64_t ckId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -15,29 +15,32 @@
|
|||
#ifndef _TSTREAMUPDATE_H_
|
||||
#define _TSTREAMUPDATE_H_
|
||||
|
||||
#include "storageapi.h"
|
||||
#include "taosdef.h"
|
||||
#include "tarray.h"
|
||||
#include "tcommon.h"
|
||||
#include "tmsg.h"
|
||||
#include "storageapi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen);
|
||||
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen);
|
||||
TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol, int32_t primaryKeyCol);
|
||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid);
|
||||
void updateInfoDestroy(SUpdateInfo *pInfo);
|
||||
void updateInfoAddCloseWindowSBF(SUpdateInfo *pInfo);
|
||||
void updateInfoDestoryColseWinSBF(SUpdateInfo *pInfo);
|
||||
int32_t updateInfoSerialize(void *buf, int32_t bufLen, const SUpdateInfo *pInfo);
|
||||
int32_t updateInfoDeserialize(void *buf, int32_t bufLen, SUpdateInfo *pInfo);
|
||||
void windowSBfDelete(SUpdateInfo *pInfo, uint64_t count);
|
||||
void windowSBfAdd(SUpdateInfo *pInfo, uint64_t count);
|
||||
bool isIncrementalTimeStamp(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
int32_t updateInfoInitP(SInterval* pInterval, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen,
|
||||
SUpdateInfo** ppInfo);
|
||||
int32_t updateInfoInit(int64_t interval, int32_t precision, int64_t watermark, bool igUp, int8_t pkType, int32_t pkLen,
|
||||
SUpdateInfo** ppInfo);
|
||||
int32_t updateInfoFillBlockData(SUpdateInfo* pInfo, SSDataBlock* pBlock, int32_t primaryTsCol, int32_t primaryKeyCol,
|
||||
TSKEY* pMaxResTs);
|
||||
bool updateInfoIsUpdated(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
bool updateInfoIsTableInserted(SUpdateInfo* pInfo, int64_t tbUid);
|
||||
void updateInfoDestroy(SUpdateInfo* pInfo);
|
||||
void updateInfoAddCloseWindowSBF(SUpdateInfo* pInfo);
|
||||
void updateInfoDestoryColseWinSBF(SUpdateInfo* pInfo);
|
||||
int32_t updateInfoSerialize(void* buf, int32_t bufLen, const SUpdateInfo* pInfo, int32_t* pLen);
|
||||
int32_t updateInfoDeserialize(void* buf, int32_t bufLen, SUpdateInfo* pInfo);
|
||||
void windowSBfDelete(SUpdateInfo* pInfo, uint64_t count);
|
||||
int32_t windowSBfAdd(SUpdateInfo* pInfo, uint64_t count);
|
||||
bool isIncrementalTimeStamp(SUpdateInfo* pInfo, uint64_t tableId, TSKEY ts, void* pPkVal, int32_t len);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -70,7 +70,6 @@ typedef int64_t SyncIndex;
|
|||
typedef int64_t SyncTerm;
|
||||
|
||||
typedef struct SSyncNode SSyncNode;
|
||||
typedef struct SWal SWal;
|
||||
typedef struct SSyncRaftEntry SSyncRaftEntry;
|
||||
|
||||
typedef enum {
|
||||
|
@ -238,7 +237,7 @@ typedef struct SSyncInfo {
|
|||
int32_t batchSize;
|
||||
SSyncCfg syncCfg;
|
||||
char path[TSDB_FILENAME_LEN];
|
||||
SWal* pWal;
|
||||
struct SWal* pWal;
|
||||
SSyncFSM* pFsm;
|
||||
SMsgCb* msgcb;
|
||||
int32_t pingMs;
|
||||
|
|
|
@ -44,9 +44,9 @@ typedef struct {
|
|||
*
|
||||
* @param pCfg Config of the fs.
|
||||
* @param ndisk Length of the config.
|
||||
* @return STfs* The fs object.
|
||||
* @param ppTfs The fs object.
|
||||
*/
|
||||
STfs *tfsOpen(SDiskCfg *pCfg, int32_t ndisk);
|
||||
int32_t tfsOpen(SDiskCfg *pCfg, int32_t ndisk, STfs **ppTfs);
|
||||
|
||||
/**
|
||||
* @brief Close a fs.
|
||||
|
@ -275,7 +275,7 @@ int32_t tfsCopyFile(const STfsFile *pFile1, const STfsFile *pFile2);
|
|||
* @param rname The rel name of file.
|
||||
* @return STfsDir* The dir object.
|
||||
*/
|
||||
STfsDir *tfsOpendir(STfs *pTfs, const char *rname);
|
||||
int32_t tfsOpendir(STfs *pTfs, const char *rname, STfsDir **ppDir);
|
||||
|
||||
/**
|
||||
* @brief Get a file from dir and move to next pos.
|
||||
|
|
|
@ -28,6 +28,11 @@ typedef enum { HTTP_GZIP, HTTP_FLAT } EHttpCompFlag;
|
|||
int32_t taosSendHttpReport(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||
EHttpCompFlag flag);
|
||||
|
||||
int64_t taosInitHttpChan();
|
||||
int32_t taosSendHttpReportByChan(const char* server, const char* uri, uint16_t port, char* pCont, int32_t contLen,
|
||||
EHttpCompFlag flag, int64_t chanId);
|
||||
void taosDestroyHttpChan(int64_t chanId);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
* 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_WAL_H_
|
||||
#define _TD_WAL_H_
|
||||
|
||||
|
@ -20,19 +21,11 @@
|
|||
#include "tdef.h"
|
||||
#include "tlog.h"
|
||||
#include "tmsg.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
#define wFatal(...) { if (wDebugFlag & DEBUG_FATAL) { taosPrintLog("WAL FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
|
||||
#define wError(...) { if (wDebugFlag & DEBUG_ERROR) { taosPrintLog("WAL ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
|
||||
#define wWarn(...) { if (wDebugFlag & DEBUG_WARN) { taosPrintLog("WAL WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
|
||||
#define wInfo(...) { if (wDebugFlag & DEBUG_INFO) { taosPrintLog("WAL ", DEBUG_INFO, 255, __VA_ARGS__); }}
|
||||
#define wDebug(...) { if (wDebugFlag & DEBUG_DEBUG) { taosPrintLog("WAL ", DEBUG_DEBUG, wDebugFlag, __VA_ARGS__); }}
|
||||
#define wTrace(...) { if (wDebugFlag & DEBUG_TRACE) { taosPrintLog("WAL ", DEBUG_TRACE, wDebugFlag, __VA_ARGS__); }}
|
||||
// clang-format on
|
||||
|
||||
#define WAL_PROTO_VER 0
|
||||
#define WAL_NOSUFFIX_LEN 20
|
||||
#define WAL_SUFFIX_AT (WAL_NOSUFFIX_LEN + 1)
|
||||
|
@ -131,8 +124,7 @@ typedef struct SWal {
|
|||
typedef struct {
|
||||
int64_t refId;
|
||||
int64_t refVer;
|
||||
// int64_t refFile;
|
||||
SWal *pWal;
|
||||
SWal *pWal;
|
||||
} SWalRef;
|
||||
|
||||
typedef struct {
|
||||
|
@ -143,10 +135,8 @@ typedef struct {
|
|||
int8_t enableRef;
|
||||
} SWalFilterCond;
|
||||
|
||||
typedef struct SWalReader SWalReader;
|
||||
|
||||
// todo hide this struct
|
||||
struct SWalReader {
|
||||
typedef struct SWalReader {
|
||||
SWal *pWal;
|
||||
int64_t readerId;
|
||||
TdFilePtr pLogFile;
|
||||
|
@ -159,7 +149,7 @@ struct SWalReader {
|
|||
TdThreadMutex mutex;
|
||||
SWalFilterCond cond;
|
||||
SWalCkHead *pHead;
|
||||
};
|
||||
} SWalReader;
|
||||
|
||||
// module initialization
|
||||
int32_t walInit();
|
||||
|
@ -172,17 +162,9 @@ int32_t walPersist(SWal *);
|
|||
void walClose(SWal *);
|
||||
|
||||
// write interfaces
|
||||
|
||||
// By assigning index by the caller, wal gurantees linearizability
|
||||
int32_t walWrite(SWal *, int64_t index, tmsg_t msgType, const void *body, int32_t bodyLen);
|
||||
int32_t walWriteWithSyncInfo(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body,
|
||||
int32_t bodyLen);
|
||||
|
||||
// Assign version automatically and return to caller,
|
||||
// -1 will be returned for failed writes
|
||||
int64_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen);
|
||||
|
||||
void walFsync(SWal *, bool force);
|
||||
int32_t walAppendLog(SWal *, int64_t index, tmsg_t msgType, SWalSyncInfo syncMeta, const void *body, int32_t bodyLen);
|
||||
int32_t walFsync(SWal *, bool force);
|
||||
|
||||
// apis for lifecycle management
|
||||
int32_t walCommit(SWal *, int64_t ver);
|
||||
|
@ -191,17 +173,13 @@ int32_t walRollback(SWal *, int64_t ver);
|
|||
int32_t walBeginSnapshot(SWal *, int64_t ver, int64_t logRetention);
|
||||
int32_t walEndSnapshot(SWal *);
|
||||
int32_t walRestoreFromSnapshot(SWal *, int64_t ver);
|
||||
// for tq
|
||||
int32_t walApplyVer(SWal *, int64_t ver);
|
||||
|
||||
// int32_t walDataCorrupted(SWal*);
|
||||
|
||||
// wal reader
|
||||
SWalReader *walOpenReader(SWal *, SWalFilterCond *pCond, int64_t id);
|
||||
void walCloseReader(SWalReader *pRead);
|
||||
void walReadReset(SWalReader *pReader);
|
||||
int32_t walReadVer(SWalReader *pRead, int64_t ver);
|
||||
void decryptBody(SWalCfg *cfg, SWalCkHead *pHead, int32_t plainBodyLen, const char *func);
|
||||
int32_t walReaderSeekVer(SWalReader *pRead, int64_t ver);
|
||||
int32_t walNextValidMsg(SWalReader *pRead);
|
||||
int64_t walReaderGetCurrentVer(const SWalReader *pReader);
|
||||
|
@ -216,12 +194,11 @@ int32_t walFetchHead(SWalReader *pRead, int64_t ver);
|
|||
int32_t walFetchBody(SWalReader *pRead);
|
||||
int32_t walSkipFetchBody(SWalReader *pRead);
|
||||
|
||||
void walRefFirstVer(SWal *, SWalRef *);
|
||||
void walRefLastVer(SWal *, SWalRef *);
|
||||
|
||||
SWalRef *walOpenRef(SWal *);
|
||||
void walCloseRef(SWal *pWal, int64_t refId);
|
||||
int32_t walSetRefVer(SWalRef *, int64_t ver);
|
||||
void walRefFirstVer(SWal *, SWalRef *);
|
||||
void walRefLastVer(SWal *, SWalRef *);
|
||||
|
||||
// helper function for raft
|
||||
bool walLogExist(SWal *, int64_t ver);
|
||||
|
|
|
@ -97,6 +97,7 @@ extern "C" {
|
|||
#include <nmmintrin.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "osThread.h"
|
||||
|
||||
#include "osAtomic.h"
|
||||
|
|
|
@ -220,7 +220,7 @@ void syslog(int unused, const char *format, ...);
|
|||
// Linux, length of name must <= 16 (the last '\0' included)
|
||||
#define setThreadName(name) \
|
||||
do { \
|
||||
prctl(PR_SET_NAME, (name)); \
|
||||
(void)prctl(PR_SET_NAME, (name)); \
|
||||
} while (0)
|
||||
#define getThreadName(name) \
|
||||
do { \
|
||||
|
|
|
@ -54,7 +54,7 @@ extern SDiskSpace tsDataSpace;
|
|||
extern SDiskSpace tsLogSpace;
|
||||
extern SDiskSpace tsTempSpace;
|
||||
|
||||
void osDefaultInit();
|
||||
int32_t osDefaultInit();
|
||||
void osUpdate();
|
||||
void osCleanup();
|
||||
|
||||
|
@ -66,7 +66,7 @@ bool osLogSpaceSufficient();
|
|||
bool osDataSpaceSufficient();
|
||||
bool osTempSpaceSufficient();
|
||||
|
||||
void osSetTimezone(const char *timezone);
|
||||
int32_t osSetTimezone(const char *timezone);
|
||||
void osSetSystemLocale(const char *inLocale, const char *inCharSet);
|
||||
void osSetProcPath(int32_t argc, char **argv);
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@ extern "C" {
|
|||
#define TSWAP(a, b) \
|
||||
do { \
|
||||
char *__tmp = (char*)alloca(sizeof(a)); \
|
||||
memcpy(__tmp, &(a), sizeof(a)); \
|
||||
memcpy(&(a), &(b), sizeof(a)); \
|
||||
memcpy(&(b), __tmp, sizeof(a)); \
|
||||
(void)memcpy(__tmp, &(a), sizeof(a)); \
|
||||
(void)memcpy(&(a), &(b), sizeof(a)); \
|
||||
(void)memcpy(&(b), __tmp, sizeof(a)); \
|
||||
} while (0)
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
|
|
@ -53,6 +53,10 @@ void taosPrintBackTrace();
|
|||
void taosMemoryTrim(int32_t size);
|
||||
void *taosMemoryMallocAlign(uint32_t alignment, int64_t size);
|
||||
|
||||
#define TAOS_MEMSET(_s, _c, _n) ((void)memset(_s, _c, _n))
|
||||
#define TAOS_MEMCPY(_d, _s, _n) ((void)memcpy(_d, _s, _n))
|
||||
#define TAOS_MEMMOVE(_d, _s, _n) ((void)memmove(_d, _s, _n))
|
||||
|
||||
#define taosMemoryFreeClear(ptr) \
|
||||
do { \
|
||||
if (ptr) { \
|
||||
|
@ -61,6 +65,16 @@ void *taosMemoryMallocAlign(uint32_t alignment, int64_t size);
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_MEMORY_REALLOC(ptr, len) \
|
||||
do { \
|
||||
void *tmp = taosMemoryRealloc(ptr, (len)); \
|
||||
if (tmp) { \
|
||||
(ptr) = tmp; \
|
||||
} else { \
|
||||
taosMemoryFreeClear(ptr); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -55,10 +55,14 @@ typedef enum { M2C = 0, C2M } ConvType;
|
|||
|
||||
#define tstrncpy(dst, src, size) \
|
||||
do { \
|
||||
strncpy((dst), (src), (size)); \
|
||||
(void)strncpy((dst), (src), (size)); \
|
||||
(dst)[(size)-1] = 0; \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_STRCPY(_dst, _src) ((void)strcpy(_dst, _src))
|
||||
#define TAOS_STRNCPY(_dst, _src, _size) ((void)strncpy(_dst, _src, _size))
|
||||
#define TAOS_STRCAT(_dst, _src) ((void)strcat(_dst, _src))
|
||||
|
||||
char *tstrdup(const char *src);
|
||||
int32_t taosUcs4len(TdUcs4 *ucs4);
|
||||
int64_t taosStr2int64(const char *str);
|
||||
|
|
|
@ -65,28 +65,28 @@ int32_t taosGetTimestampSec();
|
|||
//@return timestamp in millisecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampMs() {
|
||||
struct timeval systemTime;
|
||||
taosGetTimeOfDay(&systemTime);
|
||||
(void)taosGetTimeOfDay(&systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_usec / 1000;
|
||||
}
|
||||
|
||||
//@return timestamp in microsecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampUs() {
|
||||
struct timeval systemTime;
|
||||
taosGetTimeOfDay(&systemTime);
|
||||
(void)taosGetTimeOfDay(&systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000LL + (int64_t)systemTime.tv_usec;
|
||||
}
|
||||
|
||||
//@return timestamp in nanosecond
|
||||
static FORCE_INLINE int64_t taosGetTimestampNs() {
|
||||
struct timespec systemTime = {0};
|
||||
taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||
(void)taosClockGetTime(CLOCK_REALTIME, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000000000LL + (int64_t)systemTime.tv_nsec;
|
||||
}
|
||||
|
||||
//@return timestamp of monotonic clock in millisecond
|
||||
static FORCE_INLINE int64_t taosGetMonoTimestampMs() {
|
||||
struct timespec systemTime = {0};
|
||||
taosClockGetTime(CLOCK_MONOTONIC, &systemTime);
|
||||
(void)taosClockGetTime(CLOCK_MONOTONIC, &systemTime);
|
||||
return (int64_t)systemTime.tv_sec * 1000LL + (int64_t)systemTime.tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ enum TdTimezone {
|
|||
};
|
||||
|
||||
void taosGetSystemTimezone(char *outTimezone, enum TdTimezone *tsTimezone);
|
||||
void taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone);
|
||||
int32_t taosSetSystemTimezone(const char *inTimezone, char *outTimezone, int8_t *outDaylight, enum TdTimezone *tsTimezone);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ static FORCE_INLINE int32_t tRealloc(uint8_t **ppBuf, int64_t size) {
|
|||
|
||||
pBuf = (uint8_t *)taosMemoryRealloc(pBuf, bsize + sizeof(int64_t));
|
||||
if (pBuf == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
code = terrno;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ typedef int32_t (*__ext_compar_fn_t)(const void *p1, const void *p2, const void
|
|||
* @param param
|
||||
* @param comparFn
|
||||
*/
|
||||
void taosqsort(void *src, int64_t numOfElem, int64_t size, const void *param, __ext_compar_fn_t comparFn);
|
||||
int32_t taosqsort(void *src, int64_t numOfElem, int64_t size, const void *param, __ext_compar_fn_t comparFn);
|
||||
|
||||
/**
|
||||
* Non-recursive quick sort.
|
||||
|
@ -98,8 +98,8 @@ void *taosbsearch(const void *key, const void *base, int32_t nmemb, int32_t size
|
|||
* @param maxroot: if heap is max root heap
|
||||
* @return
|
||||
*/
|
||||
void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const void *parcompar,
|
||||
__ext_compar_fn_t compar, char *buf, bool maxroot);
|
||||
int32_t taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const void *parcompar,
|
||||
__ext_compar_fn_t compar, char *buf, bool maxroot);
|
||||
|
||||
/**
|
||||
* sort heap to make sure it is a max/min root heap
|
||||
|
@ -114,7 +114,8 @@ void taosheapadjust(void *base, int32_t size, int32_t start, int32_t end, const
|
|||
* @param maxroot: if heap is max root heap
|
||||
* @return
|
||||
*/
|
||||
void taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, __ext_compar_fn_t compar, bool maxroot);
|
||||
int32_t taosheapsort(void *base, int32_t size, int32_t len, const void *parcompar, __ext_compar_fn_t compar,
|
||||
bool maxroot);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ int32_t taosGetErrSize();
|
|||
#define terrln (*taosGetErrln())
|
||||
|
||||
#define SET_ERROR_MSG(MSG, ...) \
|
||||
snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
|
||||
(void)snprintf(terrMsg, ERR_MSG_LEN, MSG, ##__VA_ARGS__)
|
||||
|
||||
#define TSDB_CODE_SUCCESS 0
|
||||
#define TSDB_CODE_FAILED -1 // unknown or needn't tell detail error
|
||||
|
@ -89,6 +89,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_RPC_MAX_SESSIONS TAOS_DEF_ERROR_CODE(0, 0x0022) //
|
||||
#define TSDB_CODE_RPC_NETWORK_ERROR TAOS_DEF_ERROR_CODE(0, 0x0023)
|
||||
#define TSDB_CODE_RPC_NETWORK_BUSY TAOS_DEF_ERROR_CODE(0, 0x0024)
|
||||
#define TSDB_CODE_HTTP_MODULE_QUIT TAOS_DEF_ERROR_CODE(0, 0x0025)
|
||||
|
||||
|
||||
|
||||
|
@ -223,6 +224,7 @@ int32_t taosGetErrSize();
|
|||
// #define TSDB_CODE_MND_FAILED_TO_INIT_STEP TAOS_DEF_ERROR_CODE(0, 0x0314) // 2.x
|
||||
#define TSDB_CODE_MND_USER_DISABLED TAOS_DEF_ERROR_CODE(0, 0x0315)
|
||||
#define TSDB_CODE_MND_INVALID_PLATFORM TAOS_DEF_ERROR_CODE(0, 0x0316)
|
||||
#define TSDB_CODE_MND_RETURN_VALUE_NULL TAOS_DEF_ERROR_CODE(0, 0x0317)
|
||||
|
||||
// mnode-sdb
|
||||
#define TSDB_CODE_SDB_OBJ_ALREADY_THERE TAOS_DEF_ERROR_CODE(0, 0x0320) // internal
|
||||
|
@ -554,6 +556,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||
#define TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE TAOS_DEF_ERROR_CODE(0, 0x061D)
|
||||
#define TSDB_CODE_TDB_INCONSISTENT_DB_ID TAOS_DEF_ERROR_CODE(0, 0x061E)
|
||||
|
||||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
|
@ -595,6 +598,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_QRY_GEO_NOT_SUPPORT_ERROR TAOS_DEF_ERROR_CODE(0, 0x0731)
|
||||
#define TSDB_CODE_QRY_EXECUTOR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x0732)
|
||||
#define TSDB_CODE_QRY_INVALID_JOIN_CONDITION TAOS_DEF_ERROR_CODE(0, 0x0733)
|
||||
#define TSDB_CODE_QRY_FILTER_NOT_SUPPORT_TYPE TAOS_DEF_ERROR_CODE(0, 0x0734)
|
||||
|
||||
// grant
|
||||
#define TSDB_CODE_GRANT_EXPIRED TAOS_DEF_ERROR_CODE(0, 0x0800)
|
||||
|
@ -836,6 +840,7 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_PAR_TBNAME_DUPLICATED TAOS_DEF_ERROR_CODE(0, 0x267E)
|
||||
#define TSDB_CODE_PAR_TAG_NAME_DUPLICATED TAOS_DEF_ERROR_CODE(0, 0x267F)
|
||||
#define TSDB_CODE_PAR_NOT_ALLOWED_DIFFERENT_BY_ROW_FUNC TAOS_DEF_ERROR_CODE(0, 0x2680)
|
||||
#define TSDB_CODE_PAR_REGULAR_EXPRESSION_ERROR TAOS_DEF_ERROR_CODE(0, 0x2681)
|
||||
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
|
||||
|
||||
//planner
|
||||
|
@ -855,6 +860,11 @@ int32_t taosGetErrSize();
|
|||
#define TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_TS_ERR TAOS_DEF_ERROR_CODE(0, 0x2807)
|
||||
#define TSDB_CODE_FUNC_TO_TIMESTAMP_FAILED_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2808)
|
||||
#define TSDB_CODE_FUNC_TO_CHAR_NOT_SUPPORTED TAOS_DEF_ERROR_CODE(0, 0x2809)
|
||||
#define TSDB_CODE_FUNC_TIME_UNIT_INVALID TAOS_DEF_ERROR_CODE(0, 0x280A)
|
||||
#define TSDB_CODE_FUNC_TIME_UNIT_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x280B)
|
||||
#define TSDB_CODE_FUNC_INVALID_VALUE_RANGE TAOS_DEF_ERROR_CODE(0, 0x280C)
|
||||
#define TSDB_CODE_FUNC_SETUP_ERROR TAOS_DEF_ERROR_CODE(0, 0x280D)
|
||||
|
||||
|
||||
//udf
|
||||
#define TSDB_CODE_UDF_STOPPING TAOS_DEF_ERROR_CODE(0, 0x2901)
|
||||
|
@ -940,6 +950,11 @@ int32_t taosGetErrSize();
|
|||
// UTIL
|
||||
#define TSDB_CODE_UTIL_QUEUE_OUT_OF_MEMORY TAOS_DEF_ERROR_CODE(0, 0x6000)
|
||||
|
||||
// AUDIT
|
||||
#define TSDB_CODE_AUDIT_NOT_FORMAT_TO_JSON TAOS_DEF_ERROR_CODE(0, 0x6100)
|
||||
#define TSDB_CODE_AUDIT_FAIL_SEND_AUDIT_RECORD TAOS_DEF_ERROR_CODE(0, 0x6101)
|
||||
#define TSDB_CODE_AUDIT_FAIL_GENERATE_JSON TAOS_DEF_ERROR_CODE(0, 0x6102)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -205,7 +205,7 @@ void taosArrayClearEx(SArray* pArray, void (*fp)(void*));
|
|||
|
||||
void taosArrayClearP(SArray* pArray, void (*fp)(void*));
|
||||
|
||||
void* taosArrayDestroy(SArray* pArray);
|
||||
void taosArrayDestroy(SArray* pArray);
|
||||
|
||||
void taosArrayDestroyP(SArray* pArray, FDelete fp);
|
||||
|
||||
|
@ -251,7 +251,7 @@ int32_t taosArraySearchIdx(const SArray* pArray, const void* key, __compar_fn_t
|
|||
* @return
|
||||
*/
|
||||
|
||||
void taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void* param);
|
||||
int32_t taosArraySortPWithExt(SArray* pArray, __ext_compar_fn_t fn, const void* param);
|
||||
|
||||
int32_t taosEncodeArray(void** buf, const SArray* pArray, FEncode encode);
|
||||
void* taosDecodeArray(const void* buf, SArray** pArray, FDecode decode, int32_t dataSz, int8_t sver);
|
||||
|
|
|
@ -55,7 +55,7 @@ static FORCE_INLINE int32_t tarray2_make_room(void *arr, int32_t expSize, int32_
|
|||
capacity <<= 1;
|
||||
}
|
||||
void *p = taosMemoryRealloc(a->data, capacity * eleSize);
|
||||
if (p == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
||||
if (p == NULL) return terrno;
|
||||
a->capacity = capacity;
|
||||
a->data = p;
|
||||
return 0;
|
||||
|
@ -71,9 +71,9 @@ static FORCE_INLINE int32_t tarray2InsertBatch(void *arr, int32_t idx, const voi
|
|||
}
|
||||
if (ret == 0) {
|
||||
if (idx < a->size) {
|
||||
memmove(a->data + (idx + numEle) * eleSize, a->data + idx * eleSize, (a->size - idx) * eleSize);
|
||||
(void)memmove(a->data + (idx + numEle) * eleSize, a->data + idx * eleSize, (a->size - idx) * eleSize);
|
||||
}
|
||||
memcpy(a->data + idx * eleSize, elePtr, numEle * eleSize);
|
||||
(void)memcpy(a->data + idx * eleSize, elePtr, numEle * eleSize);
|
||||
a->size += numEle;
|
||||
}
|
||||
return ret;
|
||||
|
@ -145,18 +145,18 @@ static FORCE_INLINE int32_t tarray2SortInsert(void *arr, const void *elePtr, int
|
|||
#define TARRAY2_SORT_INSERT(a, e, cmp) tarray2SortInsert(a, &(e), sizeof(((a)->data[0])), (__compar_fn_t)cmp)
|
||||
#define TARRAY2_SORT_INSERT_P(a, ep, cmp) tarray2SortInsert(a, ep, sizeof(((a)->data[0])), (__compar_fn_t)cmp)
|
||||
|
||||
#define TARRAY2_REMOVE(a, idx, cb) \
|
||||
do { \
|
||||
if ((idx) < (a)->size) { \
|
||||
if (cb) { \
|
||||
TArray2Cb cb_ = (TArray2Cb)(cb); \
|
||||
cb_((a)->data + (idx)); \
|
||||
} \
|
||||
if ((idx) < (a)->size - 1) { \
|
||||
memmove((a)->data + (idx), (a)->data + (idx) + 1, sizeof((*(a)->data)) * ((a)->size - (idx)-1)); \
|
||||
} \
|
||||
(a)->size--; \
|
||||
} \
|
||||
#define TARRAY2_REMOVE(a, idx, cb) \
|
||||
do { \
|
||||
if ((idx) < (a)->size) { \
|
||||
if (cb) { \
|
||||
TArray2Cb cb_ = (TArray2Cb)(cb); \
|
||||
cb_((a)->data + (idx)); \
|
||||
} \
|
||||
if ((idx) < (a)->size - 1) { \
|
||||
(void)memmove((a)->data + (idx), (a)->data + (idx) + 1, sizeof((*(a)->data)) * ((a)->size - (idx)-1)); \
|
||||
} \
|
||||
(a)->size--; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TARRAY2_FOREACH(a, e) for (int32_t __i = 0; __i < (a)->size && ((e) = (a)->data[__i], 1); __i++)
|
||||
|
|
|
@ -25,8 +25,8 @@ extern "C" {
|
|||
#define TBASE_MAX_ILEN 4096
|
||||
#define TBASE_MAX_OLEN 5653
|
||||
|
||||
uint8_t *base58_decode(const char *value, size_t inlen, int32_t *outlen);
|
||||
char *base58_encode(const uint8_t *value, int32_t vlen);
|
||||
int32_t base58_decode(const char *value, size_t inlen, int32_t *outlen, uint8_t **result);
|
||||
int32_t base58_encode(const uint8_t *value, int32_t vlen, char **result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
uint8_t *base64_decode(const char *value, int32_t inlen, int32_t *outlen);
|
||||
char *base64_encode(const uint8_t *value, int32_t vlen);
|
||||
int32_t base64_decode(const char *value, int32_t inlen, int32_t *outlen, uint8_t **result);
|
||||
int32_t base64_encode(const uint8_t *value, int32_t vlen, char **result);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
#include "os.h"
|
||||
#include "tencode.h"
|
||||
#include "thash.h"
|
||||
#include "tlog.h"
|
||||
#include "tutil.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -35,19 +37,19 @@ typedef struct SBloomFilter {
|
|||
uint64_t size;
|
||||
_hash_fn_t hashFn1;
|
||||
_hash_fn_t hashFn2;
|
||||
void *buffer;
|
||||
void* buffer;
|
||||
double errorRate;
|
||||
} SBloomFilter;
|
||||
|
||||
SBloomFilter *tBloomFilterInit(uint64_t expectedEntries, double errorRate);
|
||||
int32_t tBloomFilterPutHash(SBloomFilter *pBF, uint64_t hash1, uint64_t hash2);
|
||||
int32_t tBloomFilterPut(SBloomFilter *pBF, const void *keyBuf, uint32_t len);
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter *pBF, uint64_t h1, uint64_t h2);
|
||||
void tBloomFilterDestroy(SBloomFilter *pBF);
|
||||
void tBloomFilterDump(const SBloomFilter *pBF);
|
||||
bool tBloomFilterIsFull(const SBloomFilter *pBF);
|
||||
int32_t tBloomFilterEncode(const SBloomFilter *pBF, SEncoder *pEncoder);
|
||||
SBloomFilter *tBloomFilterDecode(SDecoder *pDecoder);
|
||||
int32_t tBloomFilterInit(uint64_t expectedEntries, double errorRate, SBloomFilter** ppBF);
|
||||
int32_t tBloomFilterPutHash(SBloomFilter* pBF, uint64_t hash1, uint64_t hash2);
|
||||
int32_t tBloomFilterPut(SBloomFilter* pBF, const void* keyBuf, uint32_t len);
|
||||
int32_t tBloomFilterNoContain(const SBloomFilter* pBF, uint64_t h1, uint64_t h2);
|
||||
void tBloomFilterDestroy(SBloomFilter* pBF);
|
||||
void tBloomFilterDump(const SBloomFilter* pBF);
|
||||
bool tBloomFilterIsFull(const SBloomFilter* pBF);
|
||||
int32_t tBloomFilterEncode(const SBloomFilter* pBF, SEncoder* pEncoder);
|
||||
int32_t tBloomFilterDecode(SDecoder* pDecoder, SBloomFilter** ppBF);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "taoserror.h"
|
||||
#include "tcoding.h"
|
||||
#include "tutil.h"
|
||||
|
||||
struct SBuffer {
|
||||
uint32_t size;
|
||||
|
@ -67,8 +68,7 @@ static FORCE_INLINE int32_t tBufferEnsureCapacity(SBuffer *buffer, uint32_t capa
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tBufferPut(SBuffer *buffer, const void *data, uint32_t size) {
|
||||
int32_t code = tBufferEnsureCapacity(buffer, buffer->size + size);
|
||||
if (code) return code;
|
||||
TAOS_CHECK_RETURN(tBufferEnsureCapacity(buffer, buffer->size + size));
|
||||
memcpy((char *)buffer->data + buffer->size, data, size);
|
||||
buffer->size += size;
|
||||
return 0;
|
||||
|
@ -119,10 +119,8 @@ static FORCE_INLINE int32_t tBufferPutU16v(SBuffer *buffer, uint16_t value) { re
|
|||
static FORCE_INLINE int32_t tBufferPutU32v(SBuffer *buffer, uint32_t value) { return tBufferPutU64v(buffer, value); }
|
||||
|
||||
static FORCE_INLINE int32_t tBufferPutU64v(SBuffer *buffer, uint64_t value) {
|
||||
int32_t code;
|
||||
while (value >= 0x80) {
|
||||
code = tBufferPutU8(buffer, (value & 0x7F) | 0x80);
|
||||
if (code) return code;
|
||||
TAOS_CHECK_RETURN(tBufferPutU8(buffer, (value & 0x7F) | 0x80));
|
||||
value >>= 7;
|
||||
}
|
||||
return tBufferPutU8(buffer, value);
|
||||
|
@ -141,8 +139,7 @@ static FORCE_INLINE int32_t tBufferPutI64v(SBuffer *buffer, int64_t value) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tBufferPutBinary(SBuffer *buffer, const void *data, uint32_t size) {
|
||||
int32_t code = tBufferPutU32v(buffer, size);
|
||||
if (code) return code;
|
||||
TAOS_CHECK_RETURN(tBufferPutU32v(buffer, size));
|
||||
return tBufferPut(buffer, data, size);
|
||||
}
|
||||
|
||||
|
@ -324,8 +321,7 @@ static int32_t tBufferGetF32(SBufferReader *reader, float *value) {
|
|||
float f;
|
||||
uint32_t u;
|
||||
} u;
|
||||
int32_t code = tBufferGetU32(reader, &u.u);
|
||||
if (code) return code;
|
||||
TAOS_CHECK_RETURN(tBufferGetU32(reader, &u.u));
|
||||
if (value) {
|
||||
*value = u.f;
|
||||
}
|
||||
|
@ -337,8 +333,7 @@ static int32_t tBufferGetF64(SBufferReader *reader, double *value) {
|
|||
double f;
|
||||
uint64_t u;
|
||||
} u;
|
||||
int32_t code = tBufferGetU64(reader, &u.u);
|
||||
if (code) return code;
|
||||
TAOS_CHECK_RETURN(tBufferGetU64(reader, &u.u));
|
||||
if (value) {
|
||||
*value = u.f;
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ static FORCE_INLINE void *taosDecodeFixedBool(const void *buf, bool *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU16(void **buf, uint16_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -92,7 +92,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU16(void **buf, uint16_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU16(const void *buf, uint16_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[1] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[0] = ((uint8_t *)buf)[1];
|
||||
|
@ -117,7 +117,7 @@ static FORCE_INLINE void *taosDecodeFixedI16(const void *buf, int16_t *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU32(void **buf, uint32_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -132,7 +132,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU32(void **buf, uint32_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU32(const void *buf, uint32_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[3] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[2] = ((uint8_t *)buf)[1];
|
||||
|
@ -159,7 +159,7 @@ static FORCE_INLINE void *taosDecodeFixedI32(const void *buf, int32_t *value) {
|
|||
static FORCE_INLINE int32_t taosEncodeFixedU64(void **buf, uint64_t value) {
|
||||
if (buf != NULL) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(*buf, &value, sizeof(value));
|
||||
TAOS_MEMCPY(*buf, &value, sizeof(value));
|
||||
} else {
|
||||
((uint8_t *)(*buf))[0] = value & 0xff;
|
||||
((uint8_t *)(*buf))[1] = (value >> 8) & 0xff;
|
||||
|
@ -179,7 +179,7 @@ static FORCE_INLINE int32_t taosEncodeFixedU64(void **buf, uint64_t value) {
|
|||
|
||||
static FORCE_INLINE void *taosDecodeFixedU64(const void *buf, uint64_t *value) {
|
||||
if (IS_LITTLE_ENDIAN()) {
|
||||
memcpy(value, buf, sizeof(*value));
|
||||
TAOS_MEMCPY(value, buf, sizeof(*value));
|
||||
} else {
|
||||
((uint8_t *)value)[7] = ((uint8_t *)buf)[0];
|
||||
((uint8_t *)value)[6] = ((uint8_t *)buf)[1];
|
||||
|
@ -357,7 +357,7 @@ static FORCE_INLINE int32_t taosEncodeString(void **buf, const char *value) {
|
|||
|
||||
tlen += taosEncodeVariantU64(buf, size);
|
||||
if (buf != NULL) {
|
||||
memcpy(*buf, value, size);
|
||||
TAOS_MEMCPY(*buf, value, size);
|
||||
*buf = POINTER_SHIFT(*buf, size);
|
||||
}
|
||||
tlen += (int32_t)size;
|
||||
|
@ -372,7 +372,7 @@ static FORCE_INLINE void *taosDecodeString(const void *buf, char **value) {
|
|||
*value = (char *)taosMemoryMalloc((size_t)size + 1);
|
||||
|
||||
if (*value == NULL) return NULL;
|
||||
memcpy(*value, buf, (size_t)size);
|
||||
TAOS_MEMCPY(*value, buf, (size_t)size);
|
||||
|
||||
(*value)[size] = '\0';
|
||||
|
||||
|
@ -383,7 +383,7 @@ static FORCE_INLINE void *taosDecodeStringTo(const void *buf, char *value) {
|
|||
uint64_t size = 0;
|
||||
|
||||
buf = taosDecodeVariantU64(buf, &size);
|
||||
memcpy(value, buf, (size_t)size);
|
||||
TAOS_MEMCPY(value, buf, (size_t)size);
|
||||
|
||||
value[size] = '\0';
|
||||
|
||||
|
@ -395,7 +395,7 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
|
|||
int32_t tlen = 0;
|
||||
|
||||
if (buf != NULL) {
|
||||
memcpy(*buf, value, valueLen);
|
||||
TAOS_MEMCPY(*buf, value, valueLen);
|
||||
*buf = POINTER_SHIFT(*buf, valueLen);
|
||||
}
|
||||
tlen += (int32_t)valueLen;
|
||||
|
@ -406,13 +406,13 @@ static FORCE_INLINE int32_t taosEncodeBinary(void **buf, const void *value, int3
|
|||
static FORCE_INLINE void *taosDecodeBinary(const void *buf, void **value, int32_t valueLen) {
|
||||
*value = taosMemoryMalloc((size_t)valueLen);
|
||||
if (*value == NULL) return NULL;
|
||||
memcpy(*value, buf, (size_t)valueLen);
|
||||
TAOS_MEMCPY(*value, buf, (size_t)valueLen);
|
||||
|
||||
return POINTER_SHIFT(buf, valueLen);
|
||||
}
|
||||
|
||||
static FORCE_INLINE void *taosDecodeBinaryTo(const void *buf, void *value, int32_t valueLen) {
|
||||
memcpy(value, buf, (size_t)valueLen);
|
||||
TAOS_MEMCPY(value, buf, (size_t)valueLen);
|
||||
return POINTER_SHIFT(buf, valueLen);
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,10 @@ typedef struct SPatternCompareInfo {
|
|||
TdUcs4 umatchOne; // unicode version matchOne
|
||||
} SPatternCompareInfo;
|
||||
|
||||
int32_t InitRegexCache();
|
||||
void DestroyRegexCache();
|
||||
int32_t patternMatch(const char *pattern, size_t psize, const char *str, size_t ssize, const SPatternCompareInfo *pInfo);
|
||||
int32_t checkRegexPattern(const char *pPattern);
|
||||
|
||||
int32_t wcsPatternMatch(const TdUcs4 *pattern, size_t psize, const TdUcs4 *str, size_t ssize, const SPatternCompareInfo *pInfo);
|
||||
|
||||
|
@ -83,7 +86,6 @@ int32_t compareLenBinaryVal(const void *pLeft, const void *pRight);
|
|||
|
||||
int32_t comparestrRegexMatch(const void *pLeft, const void *pRight);
|
||||
int32_t comparestrRegexNMatch(const void *pLeft, const void *pRight);
|
||||
void DestoryThreadLocalRegComp();
|
||||
|
||||
int32_t comparewcsRegexMatch(const void *pLeft, const void *pRight);
|
||||
int32_t comparewcsRegexNMatch(const void *pLeft, const void *pRight);
|
||||
|
|
|
@ -101,7 +101,7 @@ typedef struct {
|
|||
typedef struct SConfig SConfig;
|
||||
typedef struct SConfigIter SConfigIter;
|
||||
|
||||
SConfig *cfgInit();
|
||||
int32_t cfgInit(SConfig **ppCfg);
|
||||
int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const void *sourceStr);
|
||||
int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair
|
||||
void cfgCleanup(SConfig *pCfg);
|
||||
|
@ -110,7 +110,7 @@ SConfigItem *cfgGetItem(SConfig *pCfg, const char *pName);
|
|||
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype, bool lock);
|
||||
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer);
|
||||
|
||||
SConfigIter *cfgCreateIter(SConfig *pConf);
|
||||
int32_t cfgCreateIter(SConfig *pConf, SConfigIter **ppIter);
|
||||
SConfigItem *cfgNextIter(SConfigIter *pIter);
|
||||
void cfgDestroyIter(SConfigIter *pIter);
|
||||
void cfgLock(SConfig *pCfg);
|
||||
|
@ -131,8 +131,8 @@ int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal,
|
|||
const char *cfgStypeStr(ECfgSrcType type);
|
||||
const char *cfgDtypeStr(ECfgDataType type);
|
||||
|
||||
void cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
void cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
int32_t cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
|
||||
|
||||
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
|
||||
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump);
|
||||
|
|
|
@ -131,10 +131,10 @@ static const int64_t TICK_PER_SECOND[] = {
|
|||
: ((precision) == TSDB_TIME_PRECISION_MICRO ? 1000000LL : 1000000000LL)))
|
||||
|
||||
#define T_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
|
||||
#define T_APPEND_MEMBER(dst, ptr, type, member) \
|
||||
do { \
|
||||
memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member)); \
|
||||
dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member)); \
|
||||
#define T_APPEND_MEMBER(dst, ptr, type, member) \
|
||||
do { \
|
||||
(void)memcpy((void *)(dst), (void *)(&((ptr)->member)), T_MEMBER_SIZE(type, member)); \
|
||||
dst = (void *)((char *)(dst) + T_MEMBER_SIZE(type, member)); \
|
||||
} while (0)
|
||||
#define T_READ_MEMBER(src, type, target) \
|
||||
do { \
|
||||
|
@ -556,7 +556,8 @@ typedef struct {
|
|||
char name[TSDB_LOG_VAR_LEN];
|
||||
} SLogVar;
|
||||
|
||||
#define TMQ_SEPARATOR ':'
|
||||
#define TMQ_SEPARATOR ":"
|
||||
#define TMQ_SEPARATOR_CHAR ':'
|
||||
|
||||
enum {
|
||||
SND_WORKER_TYPE__SHARED = 1,
|
||||
|
|
|
@ -64,10 +64,10 @@ typedef struct TDigest {
|
|||
} TDigest;
|
||||
|
||||
TDigest *tdigestNewFrom(void *pBuf, int32_t compression);
|
||||
void tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
void tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
int32_t tdigestAdd(TDigest *t, double x, int64_t w);
|
||||
int32_t tdigestMerge(TDigest *t1, TDigest *t2);
|
||||
double tdigestQuantile(TDigest *t, double q);
|
||||
void tdigestCompress(TDigest *t);
|
||||
int32_t tdigestCompress(TDigest *t);
|
||||
void tdigestFreeFrom(TDigest *t);
|
||||
void tdigestAutoFill(TDigest *t, int32_t compression);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "tcoding.h"
|
||||
#include "tlist.h"
|
||||
#include "tutil.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -46,38 +47,8 @@ typedef struct {
|
|||
SDecoderNode* dStack;
|
||||
} SDecoder;
|
||||
|
||||
#define tPut(TYPE, BUF, VAL) ((TYPE*)(BUF))[0] = (VAL)
|
||||
#define tGet(TYPE, BUF, VAL) (VAL) = ((TYPE*)(BUF))[0]
|
||||
|
||||
#define tRPut16(PDEST, PSRC) \
|
||||
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[1]; \
|
||||
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[0];
|
||||
|
||||
#define tRPut32(PDEST, PSRC) \
|
||||
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[3]; \
|
||||
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[2]; \
|
||||
((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[1]; \
|
||||
((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[0];
|
||||
|
||||
#define tRPut64(PDEST, PSRC) \
|
||||
((uint8_t*)(PDEST))[0] = ((uint8_t*)(PSRC))[7]; \
|
||||
((uint8_t*)(PDEST))[1] = ((uint8_t*)(PSRC))[6]; \
|
||||
((uint8_t*)(PDEST))[2] = ((uint8_t*)(PSRC))[5]; \
|
||||
((uint8_t*)(PDEST))[3] = ((uint8_t*)(PSRC))[4]; \
|
||||
((uint8_t*)(PDEST))[4] = ((uint8_t*)(PSRC))[3]; \
|
||||
((uint8_t*)(PDEST))[5] = ((uint8_t*)(PSRC))[2]; \
|
||||
((uint8_t*)(PDEST))[6] = ((uint8_t*)(PSRC))[1]; \
|
||||
((uint8_t*)(PDEST))[7] = ((uint8_t*)(PSRC))[0];
|
||||
|
||||
#define tRGet16 tRPut16
|
||||
#define tRGet32 tRPut32
|
||||
#define tRGet64 tRPut64
|
||||
|
||||
#define TD_CODER_POS(CODER) ((CODER)->pos)
|
||||
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
||||
#define TD_CODER_MOVE_POS(CODER, MOVE) ((CODER)->pos += (MOVE))
|
||||
#define TD_CODER_CHECK_CAPACITY_FAILED(CODER, EXPSIZE) (((CODER)->size - (CODER)->pos) < (EXPSIZE))
|
||||
#define TD_CODER_REMAIN_CAPACITY(CODER) ((CODER)->size - (CODER)->pos)
|
||||
#define TD_CODER_CURRENT(CODER) ((CODER)->data + (CODER)->pos)
|
||||
#define TD_CODER_REMAIN_CAPACITY(CODER) ((CODER)->size - (CODER)->pos)
|
||||
|
||||
#define tEncodeSize(E, S, SIZE, RET) \
|
||||
do { \
|
||||
|
@ -100,6 +71,7 @@ void tEncoderInit(SEncoder* pCoder, uint8_t* data, uint32_t size);
|
|||
void tEncoderClear(SEncoder* pCoder);
|
||||
int32_t tStartEncode(SEncoder* pCoder);
|
||||
void tEndEncode(SEncoder* pCoder);
|
||||
static int32_t tEncodeFixed(SEncoder* pCoder, const void* val, uint32_t size);
|
||||
static int32_t tEncodeU8(SEncoder* pCoder, uint8_t val);
|
||||
static int32_t tEncodeI8(SEncoder* pCoder, int8_t val);
|
||||
static int32_t tEncodeU16(SEncoder* pCoder, uint16_t val);
|
||||
|
@ -127,6 +99,7 @@ void tDecoderClear(SDecoder* SDecoder);
|
|||
int32_t tStartDecode(SDecoder* pCoder);
|
||||
void tEndDecode(SDecoder* pCoder);
|
||||
static bool tDecodeIsEnd(SDecoder* pCoder);
|
||||
static int32_t tDecodeFixed(SDecoder* pCoder, void* val, uint32_t size);
|
||||
static int32_t tDecodeU8(SDecoder* pCoder, uint8_t* val);
|
||||
static int32_t tDecodeI8(SDecoder* pCoder, int8_t* val);
|
||||
static int32_t tDecodeU16(SDecoder* pCoder, uint16_t* val);
|
||||
|
@ -149,97 +122,65 @@ static int32_t tDecodeCStr(SDecoder* pCoder, char** val);
|
|||
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val);
|
||||
|
||||
/* ------------------------ IMPL ------------------------ */
|
||||
#define TD_ENCODE_MACRO(CODER, VAL, TYPE, BITS) \
|
||||
if ((CODER)->data) { \
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(VAL))) return -1; \
|
||||
tPut(TYPE, TD_CODER_CURRENT(CODER), (VAL)); \
|
||||
} \
|
||||
TD_CODER_MOVE_POS(CODER, sizeof(VAL)); \
|
||||
return 0;
|
||||
|
||||
#define TD_ENCODE_VARIANT_MACRO(CODER, VAL) \
|
||||
while ((VAL) >= ENCODE_LIMIT) { \
|
||||
if ((CODER)->data) { \
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, 1)) return -1; \
|
||||
TD_CODER_CURRENT(CODER)[0] = ((VAL) | ENCODE_LIMIT) & 0xff; \
|
||||
} \
|
||||
\
|
||||
(VAL) >>= 7; \
|
||||
TD_CODER_MOVE_POS(CODER, 1); \
|
||||
} \
|
||||
\
|
||||
if ((CODER)->data) { \
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, 1)) return -1; \
|
||||
TD_CODER_CURRENT(CODER)[0] = (uint8_t)(VAL); \
|
||||
} \
|
||||
TD_CODER_MOVE_POS(CODER, 1); \
|
||||
return 0;
|
||||
|
||||
#define TD_DECODE_MACRO(CODER, PVAL, TYPE, BITS) \
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, sizeof(*(PVAL)))) return -1; \
|
||||
tGet(TYPE, TD_CODER_CURRENT(CODER), *(PVAL)); \
|
||||
TD_CODER_MOVE_POS(CODER, sizeof(*(PVAL))); \
|
||||
return 0;
|
||||
|
||||
#define TD_DECODE_VARIANT_MACRO(CODER, PVAL, TYPE) \
|
||||
int32_t i = 0; \
|
||||
*(PVAL) = 0; \
|
||||
for (;;) { \
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(CODER, 1)) return -1; \
|
||||
TYPE tval = TD_CODER_CURRENT(CODER)[0]; \
|
||||
if (tval < ENCODE_LIMIT) { \
|
||||
*(PVAL) |= (tval << (7 * i)); \
|
||||
TD_CODER_MOVE_POS(pCoder, 1); \
|
||||
break; \
|
||||
} else { \
|
||||
*(PVAL) |= (((tval) & (ENCODE_LIMIT - 1)) << (7 * i)); \
|
||||
i++; \
|
||||
TD_CODER_MOVE_POS(pCoder, 1); \
|
||||
} \
|
||||
} \
|
||||
\
|
||||
return 0;
|
||||
|
||||
// 8
|
||||
static FORCE_INLINE int32_t tEncodeU8(SEncoder* pCoder, uint8_t val) {
|
||||
static FORCE_INLINE int32_t tEncodeFixed(SEncoder* pCoder, const void* val, uint32_t size) {
|
||||
if (pCoder->data) {
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(val))) return -1;
|
||||
tPut(uint8_t, TD_CODER_CURRENT(pCoder), val);
|
||||
if (pCoder->pos + size > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
TAOS_MEMCPY(pCoder->data + pCoder->pos, val, size);
|
||||
}
|
||||
TD_CODER_MOVE_POS(pCoder, sizeof(val));
|
||||
|
||||
pCoder->pos += size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeI8(SEncoder* pCoder, int8_t val) {
|
||||
if (pCoder->data) {
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(val))) return -1;
|
||||
tPut(int8_t, TD_CODER_CURRENT(pCoder), val);
|
||||
}
|
||||
TD_CODER_MOVE_POS(pCoder, sizeof(val));
|
||||
return 0;
|
||||
static FORCE_INLINE int32_t tEncodeU8(SEncoder* pCoder, uint8_t val) { return tEncodeFixed(pCoder, &val, sizeof(val)); }
|
||||
static FORCE_INLINE int32_t tEncodeI8(SEncoder* pCoder, int8_t val) { return tEncodeFixed(pCoder, &val, sizeof(val)); }
|
||||
static FORCE_INLINE int32_t tEncodeU16(SEncoder* pCoder, uint16_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeI16(SEncoder* pCoder, int16_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeU32(SEncoder* pCoder, uint32_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeI32(SEncoder* pCoder, int32_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeU64(SEncoder* pCoder, uint64_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeI64(SEncoder* pCoder, int64_t val) {
|
||||
return tEncodeFixed(pCoder, &val, sizeof(val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeU16v(SEncoder* pCoder, uint16_t val) {
|
||||
while (val >= ENCODE_LIMIT) {
|
||||
TAOS_CHECK_RETURN(tEncodeU8(pCoder, (val | ENCODE_LIMIT) & 0xff));
|
||||
val >>= 7;
|
||||
}
|
||||
return tEncodeU8(pCoder, val);
|
||||
}
|
||||
|
||||
// 16
|
||||
static FORCE_INLINE int32_t tEncodeU16(SEncoder* pCoder, uint16_t val) { TD_ENCODE_MACRO(pCoder, val, uint16_t, 16); }
|
||||
static FORCE_INLINE int32_t tEncodeI16(SEncoder* pCoder, int16_t val) { TD_ENCODE_MACRO(pCoder, val, int16_t, 16); }
|
||||
// 32
|
||||
static FORCE_INLINE int32_t tEncodeU32(SEncoder* pCoder, uint32_t val) { TD_ENCODE_MACRO(pCoder, val, uint32_t, 32); }
|
||||
static FORCE_INLINE int32_t tEncodeI32(SEncoder* pCoder, int32_t val) { TD_ENCODE_MACRO(pCoder, val, int32_t, 32); }
|
||||
// 64
|
||||
static FORCE_INLINE int32_t tEncodeU64(SEncoder* pCoder, uint64_t val) { TD_ENCODE_MACRO(pCoder, val, uint64_t, 64); }
|
||||
static FORCE_INLINE int32_t tEncodeI64(SEncoder* pCoder, int64_t val) { TD_ENCODE_MACRO(pCoder, val, int64_t, 64); }
|
||||
// 16v
|
||||
static FORCE_INLINE int32_t tEncodeU16v(SEncoder* pCoder, uint16_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||
static FORCE_INLINE int32_t tEncodeI16v(SEncoder* pCoder, int16_t val) {
|
||||
return tEncodeU16v(pCoder, ZIGZAGE(int16_t, val));
|
||||
}
|
||||
// 32v
|
||||
static FORCE_INLINE int32_t tEncodeU32v(SEncoder* pCoder, uint32_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||
static FORCE_INLINE int32_t tEncodeU32v(SEncoder* pCoder, uint32_t val) {
|
||||
while (val >= ENCODE_LIMIT) {
|
||||
TAOS_CHECK_RETURN(tEncodeU8(pCoder, (val | ENCODE_LIMIT) & 0xff));
|
||||
val >>= 7;
|
||||
}
|
||||
return tEncodeU8(pCoder, val);
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeI32v(SEncoder* pCoder, int32_t val) {
|
||||
return tEncodeU32v(pCoder, ZIGZAGE(int32_t, val));
|
||||
}
|
||||
// 64v
|
||||
static FORCE_INLINE int32_t tEncodeU64v(SEncoder* pCoder, uint64_t val) { TD_ENCODE_VARIANT_MACRO(pCoder, val); }
|
||||
static FORCE_INLINE int32_t tEncodeU64v(SEncoder* pCoder, uint64_t val) {
|
||||
while (val >= ENCODE_LIMIT) {
|
||||
TAOS_CHECK_RETURN(tEncodeU8(pCoder, (val | ENCODE_LIMIT) & 0xff));
|
||||
val >>= 7;
|
||||
}
|
||||
return tEncodeU8(pCoder, val);
|
||||
}
|
||||
static FORCE_INLINE int32_t tEncodeI64v(SEncoder* pCoder, int64_t val) {
|
||||
return tEncodeU64v(pCoder, ZIGZAGE(int64_t, val));
|
||||
}
|
||||
|
@ -265,14 +206,16 @@ static FORCE_INLINE int32_t tEncodeDouble(SEncoder* pCoder, double val) {
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len) {
|
||||
if (tEncodeU32v(pCoder, len) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tEncodeU32v(pCoder, len));
|
||||
if (len) {
|
||||
if (pCoder->data) {
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, len)) return -1;
|
||||
memcpy(TD_CODER_CURRENT(pCoder), val, len);
|
||||
if (pCoder->pos + len > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
TAOS_MEMCPY(pCoder->data + pCoder->pos, val, len);
|
||||
}
|
||||
|
||||
TD_CODER_MOVE_POS(pCoder, len);
|
||||
pCoder->pos += len;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -286,70 +229,137 @@ static FORCE_INLINE int32_t tEncodeCStr(SEncoder* pCoder, const char* val) {
|
|||
}
|
||||
|
||||
/* ------------------------ FOR DECODER ------------------------ */
|
||||
// 8
|
||||
static FORCE_INLINE int32_t tDecodeU8(SDecoder* pCoder, uint8_t* val) {
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(*val))) return -1;
|
||||
tGet(uint8_t, TD_CODER_CURRENT(pCoder), *val);
|
||||
TD_CODER_MOVE_POS(pCoder, sizeof(*val));
|
||||
static int32_t tDecodeFixed(SDecoder* pCoder, void* val, uint32_t size) {
|
||||
if (pCoder->pos + size > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
} else if (val) {
|
||||
TAOS_MEMCPY(val, pCoder->data + pCoder->pos, size);
|
||||
}
|
||||
pCoder->pos += size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeI8(SDecoder* pCoder, int8_t* val) {
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, sizeof(*val))) return -1;
|
||||
tGet(int8_t, TD_CODER_CURRENT(pCoder), *val);
|
||||
TD_CODER_MOVE_POS(pCoder, sizeof(*val));
|
||||
return 0;
|
||||
static FORCE_INLINE int32_t tDecodeU8(SDecoder* pCoder, uint8_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeI8(SDecoder* pCoder, int8_t* val) { return tDecodeFixed(pCoder, val, sizeof(*val)); }
|
||||
|
||||
// 16
|
||||
static FORCE_INLINE int32_t tDecodeU16(SDecoder* pCoder, uint16_t* val) { TD_DECODE_MACRO(pCoder, val, uint16_t, 16); }
|
||||
static FORCE_INLINE int32_t tDecodeI16(SDecoder* pCoder, int16_t* val) { TD_DECODE_MACRO(pCoder, val, int16_t, 16); }
|
||||
static FORCE_INLINE int32_t tDecodeU16(SDecoder* pCoder, uint16_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tDecodeI16(SDecoder* pCoder, int16_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
// 32
|
||||
static FORCE_INLINE int32_t tDecodeU32(SDecoder* pCoder, uint32_t* val) { TD_DECODE_MACRO(pCoder, val, uint32_t, 32); }
|
||||
static FORCE_INLINE int32_t tDecodeI32(SDecoder* pCoder, int32_t* val) { TD_DECODE_MACRO(pCoder, val, int32_t, 32); }
|
||||
static FORCE_INLINE int32_t tDecodeU32(SDecoder* pCoder, uint32_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tDecodeI32(SDecoder* pCoder, int32_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
// 64
|
||||
static FORCE_INLINE int32_t tDecodeU64(SDecoder* pCoder, uint64_t* val) { TD_DECODE_MACRO(pCoder, val, uint64_t, 64); }
|
||||
static FORCE_INLINE int32_t tDecodeI64(SDecoder* pCoder, int64_t* val) { TD_DECODE_MACRO(pCoder, val, int64_t, 64); }
|
||||
static FORCE_INLINE int32_t tDecodeU64(SDecoder* pCoder, uint64_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
static FORCE_INLINE int32_t tDecodeI64(SDecoder* pCoder, int64_t* val) {
|
||||
return tDecodeFixed(pCoder, val, sizeof(*val));
|
||||
}
|
||||
|
||||
// 16v
|
||||
static FORCE_INLINE int32_t tDecodeU16v(SDecoder* pCoder, uint16_t* val) {
|
||||
TD_DECODE_VARIANT_MACRO(pCoder, val, uint16_t);
|
||||
uint8_t byte;
|
||||
uint16_t tval = 0;
|
||||
for (int32_t i = 0;; i++) {
|
||||
TAOS_CHECK_RETURN(tDecodeU8(pCoder, &byte));
|
||||
if (byte < ENCODE_LIMIT) {
|
||||
tval |= (((uint16_t)byte) << (7 * i));
|
||||
break;
|
||||
} else {
|
||||
tval |= ((((uint16_t)byte) & (ENCODE_LIMIT - 1)) << (7 * i));
|
||||
}
|
||||
}
|
||||
|
||||
if (val) {
|
||||
*val = tval;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeI16v(SDecoder* pCoder, int16_t* val) {
|
||||
uint16_t tval;
|
||||
if (tDecodeU16v(pCoder, &tval) < 0) {
|
||||
return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeU16v(pCoder, &tval));
|
||||
|
||||
if (val) {
|
||||
*val = ZIGZAGD(int16_t, tval);
|
||||
}
|
||||
if (val) *val = ZIGZAGD(int16_t, tval);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 32v
|
||||
static FORCE_INLINE int32_t tDecodeU32v(SDecoder* pCoder, uint32_t* val) {
|
||||
TD_DECODE_VARIANT_MACRO(pCoder, val, uint32_t);
|
||||
uint8_t byte;
|
||||
uint32_t tval = 0;
|
||||
for (int32_t i = 0;; i++) {
|
||||
TAOS_CHECK_RETURN(tDecodeU8(pCoder, &byte));
|
||||
if (byte < ENCODE_LIMIT) {
|
||||
tval |= (((uint32_t)byte) << (7 * i));
|
||||
break;
|
||||
} else {
|
||||
tval |= ((((uint32_t)byte) & (ENCODE_LIMIT - 1)) << (7 * i));
|
||||
}
|
||||
}
|
||||
|
||||
if (val) {
|
||||
*val = tval;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeI32v(SDecoder* pCoder, int32_t* val) {
|
||||
uint32_t tval;
|
||||
if (tDecodeU32v(pCoder, &tval) < 0) {
|
||||
return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeU32v(pCoder, &tval));
|
||||
|
||||
if (val) {
|
||||
*val = ZIGZAGD(int32_t, tval);
|
||||
}
|
||||
if (val) *val = ZIGZAGD(int32_t, tval);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 64v
|
||||
static FORCE_INLINE int32_t tDecodeU64v(SDecoder* pCoder, uint64_t* val) {
|
||||
TD_DECODE_VARIANT_MACRO(pCoder, val, uint64_t);
|
||||
uint8_t byte;
|
||||
uint64_t tval = 0;
|
||||
for (int32_t i = 0;; i++) {
|
||||
TAOS_CHECK_RETURN(tDecodeU8(pCoder, &byte));
|
||||
if (byte < ENCODE_LIMIT) {
|
||||
tval |= (((uint64_t)byte) << (7 * i));
|
||||
break;
|
||||
} else {
|
||||
tval |= ((((uint64_t)byte) & (ENCODE_LIMIT - 1)) << (7 * i));
|
||||
}
|
||||
}
|
||||
|
||||
if (val) {
|
||||
*val = tval;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val) {
|
||||
uint64_t tval;
|
||||
if (tDecodeU64v(pCoder, &tval) < 0) {
|
||||
return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeU64v(pCoder, &tval));
|
||||
|
||||
if (val) {
|
||||
*val = ZIGZAGD(int64_t, tval);
|
||||
}
|
||||
if (val) *val = ZIGZAGD(int64_t, tval);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -359,11 +369,11 @@ static FORCE_INLINE int32_t tDecodeFloat(SDecoder* pCoder, float* val) {
|
|||
float f;
|
||||
} v;
|
||||
|
||||
if (tDecodeU32(pCoder, &(v.ui)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDecodeU32(pCoder, &(v.ui)));
|
||||
|
||||
*val = v.f;
|
||||
if (val) {
|
||||
*val = v.f;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -373,30 +383,36 @@ static FORCE_INLINE int32_t tDecodeDouble(SDecoder* pCoder, double* val) {
|
|||
double d;
|
||||
} v;
|
||||
|
||||
if (tDecodeU64(pCoder, &(v.ui)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
TAOS_CHECK_RETURN(tDecodeU64(pCoder, &(v.ui)));
|
||||
|
||||
*val = v.d;
|
||||
if (val) {
|
||||
*val = v.d;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint32_t* len) {
|
||||
uint32_t length = 0;
|
||||
if (tDecodeU32v(pCoder, &length) < 0) return -1;
|
||||
if (len) *len = length;
|
||||
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, length)) return -1;
|
||||
if (val) {
|
||||
*val = (uint8_t*)TD_CODER_CURRENT(pCoder);
|
||||
TAOS_CHECK_RETURN(tDecodeU32v(pCoder, &length));
|
||||
if (len) {
|
||||
*len = length;
|
||||
}
|
||||
|
||||
TD_CODER_MOVE_POS(pCoder, length);
|
||||
if (pCoder->pos + length > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
if (val) {
|
||||
*val = pCoder->data + pCoder->pos;
|
||||
}
|
||||
|
||||
pCoder->pos += length;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len) {
|
||||
if (tDecodeBinary(pCoder, (uint8_t**)val, len) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeBinary(pCoder, (uint8_t**)val, len));
|
||||
(*len) -= 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -409,24 +425,30 @@ static FORCE_INLINE int32_t tDecodeCStr(SDecoder* pCoder, char** val) {
|
|||
static int32_t tDecodeCStrTo(SDecoder* pCoder, char* val) {
|
||||
char* pStr;
|
||||
uint32_t len;
|
||||
if (tDecodeCStrAndLen(pCoder, &pStr, &len) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeCStrAndLen(pCoder, &pStr, &len));
|
||||
|
||||
memcpy(val, pStr, len + 1);
|
||||
TAOS_MEMCPY(val, pStr, len + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeBinaryAlloc(SDecoder* pCoder, void** val, uint64_t* len) {
|
||||
uint64_t length = 0;
|
||||
if (tDecodeU64v(pCoder, &length) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeU64v(pCoder, &length));
|
||||
if (length) {
|
||||
if (len) *len = length;
|
||||
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, length)) return -1;
|
||||
*val = taosMemoryMalloc(length);
|
||||
if (*val == NULL) return -1;
|
||||
memcpy(*val, TD_CODER_CURRENT(pCoder), length);
|
||||
if (pCoder->pos + length > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
|
||||
TD_CODER_MOVE_POS(pCoder, length);
|
||||
*val = taosMemoryMalloc(length);
|
||||
if (*val == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
TAOS_MEMCPY(*val, pCoder->data + pCoder->pos, length);
|
||||
|
||||
pCoder->pos += length;
|
||||
} else {
|
||||
*val = NULL;
|
||||
}
|
||||
|
@ -435,16 +457,20 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc(SDecoder* pCoder, void** val, uin
|
|||
|
||||
static FORCE_INLINE int32_t tDecodeBinaryAlloc32(SDecoder* pCoder, void** val, uint32_t* len) {
|
||||
uint32_t length = 0;
|
||||
if (tDecodeU32v(pCoder, &length) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeU32v(pCoder, &length));
|
||||
if (length) {
|
||||
if (len) *len = length;
|
||||
|
||||
if (TD_CODER_CHECK_CAPACITY_FAILED(pCoder, length)) return -1;
|
||||
if (pCoder->pos + length > pCoder->size) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_RANGE);
|
||||
}
|
||||
*val = taosMemoryMalloc(length);
|
||||
if (*val == NULL) return -1;
|
||||
memcpy(*val, TD_CODER_CURRENT(pCoder), length);
|
||||
if (*val == NULL) {
|
||||
TAOS_RETURN(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
TAOS_MEMCPY(*val, pCoder->data + pCoder->pos, length);
|
||||
|
||||
TD_CODER_MOVE_POS(pCoder, length);
|
||||
pCoder->pos += length;
|
||||
} else {
|
||||
*val = NULL;
|
||||
}
|
||||
|
@ -452,7 +478,7 @@ static FORCE_INLINE int32_t tDecodeBinaryAlloc32(SDecoder* pCoder, void** val, u
|
|||
}
|
||||
|
||||
static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SDecoder* pCoder, char** val, uint64_t* len) {
|
||||
if (tDecodeBinaryAlloc(pCoder, (void**)val, len) < 0) return -1;
|
||||
TAOS_CHECK_RETURN(tDecodeBinaryAlloc(pCoder, (void**)val, len));
|
||||
(*len) -= 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -731,7 +757,7 @@ static FORCE_INLINE int32_t tPutBinary(uint8_t* p, uint8_t* pData, uint32_t nDat
|
|||
int n = 0;
|
||||
|
||||
n += tPutU32v(p ? p + n : p, nData);
|
||||
if (p) memcpy(p + n, pData, nData);
|
||||
if (p) TAOS_MEMCPY(p + n, pData, nData);
|
||||
n += nData;
|
||||
|
||||
return n;
|
||||
|
|
|
@ -28,8 +28,7 @@ typedef int32_t (*_equal_fn_t)(const void *, const void *, size_t len);
|
|||
typedef void (*_hash_before_fn_t)(void *);
|
||||
typedef void (*_hash_free_fn_t)(void *);
|
||||
|
||||
#define HASH_KEY_ALREADY_EXISTS (-2)
|
||||
#define HASH_NODE_EXIST(code) (code == HASH_KEY_ALREADY_EXISTS)
|
||||
#define HASH_NODE_EXIST(code) (code == TSDB_CODE_DUP_KEY)
|
||||
|
||||
/**
|
||||
* murmur hash algorithm
|
||||
|
|
|
@ -224,7 +224,7 @@ void tdListInit(SList *list, int32_t eleSize);
|
|||
void tdListEmpty(SList *list);
|
||||
SList *tdListNew(int32_t eleSize);
|
||||
void *tdListFree(SList *list);
|
||||
void *tdListFreeP(SList *list, FDelete fp);
|
||||
void tdListFreeP(SList *list, FDelete fp);
|
||||
void tdListPrependNode(SList *list, SListNode *node);
|
||||
void tdListAppendNode(SList *list, SListNode *node);
|
||||
int32_t tdListPrepend(SList *list, void *data);
|
||||
|
|
|
@ -73,36 +73,36 @@ struct STaosQnode {
|
|||
char item[];
|
||||
};
|
||||
|
||||
STaosQueue *taosOpenQueue();
|
||||
void taosCloseQueue(STaosQueue *queue);
|
||||
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
||||
void *taosAllocateQitem(int32_t size, EQItype itype, int64_t dataSize);
|
||||
void taosFreeQitem(void *pItem);
|
||||
int32_t taosWriteQitem(STaosQueue *queue, void *pItem);
|
||||
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
||||
bool taosQueueEmpty(STaosQueue *queue);
|
||||
void taosUpdateItemSize(STaosQueue *queue, int32_t items);
|
||||
int32_t taosQueueItemSize(STaosQueue *queue);
|
||||
int64_t taosQueueMemorySize(STaosQueue *queue);
|
||||
void taosSetQueueCapacity(STaosQueue *queue, int64_t size);
|
||||
void taosSetQueueMemoryCapacity(STaosQueue *queue, int64_t mem);
|
||||
int32_t taosOpenQueue(STaosQueue **queue);
|
||||
void taosCloseQueue(STaosQueue *queue);
|
||||
void taosSetQueueFp(STaosQueue *queue, FItem itemFp, FItems itemsFp);
|
||||
int32_t taosAllocateQitem(int32_t size, EQItype itype, int64_t dataSize, void **item);
|
||||
void taosFreeQitem(void *pItem);
|
||||
int32_t taosWriteQitem(STaosQueue *queue, void *pItem);
|
||||
int32_t taosReadQitem(STaosQueue *queue, void **ppItem);
|
||||
bool taosQueueEmpty(STaosQueue *queue);
|
||||
void taosUpdateItemSize(STaosQueue *queue, int32_t items);
|
||||
int32_t taosQueueItemSize(STaosQueue *queue);
|
||||
int64_t taosQueueMemorySize(STaosQueue *queue);
|
||||
void taosSetQueueCapacity(STaosQueue *queue, int64_t size);
|
||||
void taosSetQueueMemoryCapacity(STaosQueue *queue, int64_t mem);
|
||||
|
||||
STaosQall *taosAllocateQall();
|
||||
void taosFreeQall(STaosQall *qall);
|
||||
int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall);
|
||||
int32_t taosGetQitem(STaosQall *qall, void **ppItem);
|
||||
void taosResetQitems(STaosQall *qall);
|
||||
int32_t taosQallItemSize(STaosQall *qall);
|
||||
int64_t taosQallMemSize(STaosQall *qll);
|
||||
int64_t taosQallUnAccessedItemSize(STaosQall *qall);
|
||||
int64_t taosQallUnAccessedMemSize(STaosQall *qall);
|
||||
int32_t taosAllocateQall(STaosQall **qall);
|
||||
void taosFreeQall(STaosQall *qall);
|
||||
int32_t taosReadAllQitems(STaosQueue *queue, STaosQall *qall);
|
||||
int32_t taosGetQitem(STaosQall *qall, void **ppItem);
|
||||
void taosResetQitems(STaosQall *qall);
|
||||
int32_t taosQallItemSize(STaosQall *qall);
|
||||
int64_t taosQallMemSize(STaosQall *qll);
|
||||
int64_t taosQallUnAccessedItemSize(STaosQall *qall);
|
||||
int64_t taosQallUnAccessedMemSize(STaosQall *qall);
|
||||
|
||||
STaosQset *taosOpenQset();
|
||||
void taosCloseQset(STaosQset *qset);
|
||||
void taosQsetThreadResume(STaosQset *qset);
|
||||
int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle);
|
||||
void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue);
|
||||
int32_t taosGetQueueNumber(STaosQset *qset);
|
||||
int32_t taosOpenQset(STaosQset **qset);
|
||||
void taosCloseQset(STaosQset *qset);
|
||||
void taosQsetThreadResume(STaosQset *qset);
|
||||
int32_t taosAddIntoQset(STaosQset *qset, STaosQueue *queue, void *ahandle);
|
||||
void taosRemoveFromQset(STaosQset *qset, STaosQueue *queue);
|
||||
int32_t taosGetQueueNumber(STaosQset *qset);
|
||||
|
||||
int32_t taosReadQitemFromQset(STaosQset *qset, void **ppItem, SQueueInfo *qinfo);
|
||||
int32_t taosReadAllQitemsFromQset(STaosQset *qset, STaosQall *qall, SQueueInfo *qinfo);
|
||||
|
|
|
@ -23,22 +23,22 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
typedef struct SScalableBf {
|
||||
SArray *bfArray; // array of bloom filters
|
||||
uint32_t growth;
|
||||
uint64_t numBits;
|
||||
uint32_t maxBloomFilters;
|
||||
int8_t status;
|
||||
SArray* bfArray; // array of bloom filters
|
||||
uint32_t growth;
|
||||
uint64_t numBits;
|
||||
uint32_t maxBloomFilters;
|
||||
int8_t status;
|
||||
_hash_fn_t hashFn1;
|
||||
_hash_fn_t hashFn2;
|
||||
} SScalableBf;
|
||||
|
||||
SScalableBf *tScalableBfInit(uint64_t expectedEntries, double errorRate);
|
||||
int32_t tScalableBfPutNoCheck(SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||
int32_t tScalableBfPut(SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||
int32_t tScalableBfNoContain(const SScalableBf *pSBf, const void *keyBuf, uint32_t len);
|
||||
void tScalableBfDestroy(SScalableBf *pSBf);
|
||||
int32_t tScalableBfEncode(const SScalableBf *pSBf, SEncoder *pEncoder);
|
||||
SScalableBf *tScalableBfDecode(SDecoder *pDecoder);
|
||||
int32_t tScalableBfInit(uint64_t expectedEntries, double errorRate, SScalableBf** ppSBf);
|
||||
int32_t tScalableBfPutNoCheck(SScalableBf* pSBf, const void* keyBuf, uint32_t len);
|
||||
int32_t tScalableBfPut(SScalableBf* pSBf, const void* keyBuf, uint32_t len, int32_t* winRes);
|
||||
int32_t tScalableBfNoContain(const SScalableBf* pSBf, const void* keyBuf, uint32_t len);
|
||||
void tScalableBfDestroy(SScalableBf* pSBf);
|
||||
int32_t tScalableBfEncode(const SScalableBf* pSBf, SEncoder* pEncoder);
|
||||
int32_t tScalableBfDecode(SDecoder* pDecoder, SScalableBf** ppSBf);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "tdef.h"
|
||||
#include "thash.h"
|
||||
#include "tmd5.h"
|
||||
#include "tutil.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -56,14 +57,14 @@ void taosIpPort2String(uint32_t ip, uint16_t port, char *str);
|
|||
|
||||
void *tmemmem(const char *haystack, int hlen, const char *needle, int nlen);
|
||||
|
||||
int32_t parseCfgReal(const char* str, double* out);
|
||||
int32_t parseCfgReal(const char *str, double *out);
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) {
|
||||
T_MD5_CTX context;
|
||||
tMD5Init(&context);
|
||||
tMD5Update(&context, inBuf, (uint32_t)inLen);
|
||||
tMD5Final(&context);
|
||||
memcpy(target, context.digest, tListLen(context.digest));
|
||||
(void)memcpy(target, context.digest, tListLen(context.digest));
|
||||
}
|
||||
|
||||
static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *target) {
|
||||
|
@ -78,15 +79,15 @@ static FORCE_INLINE void taosEncryptPass_c(uint8_t *inBuf, size_t len, char *tar
|
|||
context.digest[2], context.digest[3], context.digest[4], context.digest[5], context.digest[6],
|
||||
context.digest[7], context.digest[8], context.digest[9], context.digest[10], context.digest[11],
|
||||
context.digest[12], context.digest[13], context.digest[14], context.digest[15]);
|
||||
memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||
(void)memcpy(target, buf, TSDB_PASSWORD_LEN);
|
||||
}
|
||||
|
||||
static FORCE_INLINE int32_t taosCreateMD5Hash(char *pBuf, int32_t len) {
|
||||
T_MD5_CTX ctx;
|
||||
tMD5Init(&ctx);
|
||||
tMD5Update(&ctx, (uint8_t*)pBuf, len);
|
||||
tMD5Update(&ctx, (uint8_t *)pBuf, len);
|
||||
tMD5Final(&ctx);
|
||||
char* p = pBuf;
|
||||
char *p = pBuf;
|
||||
int32_t resLen = 0;
|
||||
for (uint8_t i = 0; i < tListLen(ctx.digest); ++i) {
|
||||
resLen += snprintf(p, 3, "%02x", ctx.digest[i]);
|
||||
|
@ -134,6 +135,8 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
#define QUERY_CHECK_CODE TSDB_CHECK_CODE
|
||||
|
||||
#define TSDB_CHECK_NULL(ptr, CODE, LINO, LABEL, ERRNO) \
|
||||
if ((ptr) == NULL) { \
|
||||
(CODE) = (ERRNO); \
|
||||
|
@ -141,12 +144,49 @@ static FORCE_INLINE int32_t taosGetTbHashVal(const char *tbname, int32_t tblen,
|
|||
goto LABEL; \
|
||||
}
|
||||
|
||||
#define QUERY_CHECK_NULL TSDB_CHECK_NULL
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
|
||||
|
||||
#define VND_CHECK_CODE(CODE, LINO, LABEL) TSDB_CHECK_CODE(CODE, LINO, LABEL)
|
||||
|
||||
#define TCONTAINER_OF(ptr, type, member) ((type *)((char *)(ptr)-offsetof(type, member)))
|
||||
|
||||
#define TAOS_RETURN(CODE) \
|
||||
do { \
|
||||
return (terrno = (CODE)); \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_RETURN(CMD) \
|
||||
do { \
|
||||
int32_t code = (CMD); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
TAOS_RETURN(code); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_GOTO(CMD, LINO, LABEL) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
if (code != TSDB_CODE_SUCCESS) { \
|
||||
if (LINO) { \
|
||||
*((int32_t *)(LINO)) = __LINE__; \
|
||||
} \
|
||||
goto LABEL; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_CHECK_EXIT(CMD) \
|
||||
do { \
|
||||
code = (CMD); \
|
||||
if (code < TSDB_CODE_SUCCESS) { \
|
||||
lino = __LINE__; \
|
||||
goto _exit; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define TAOS_UNUSED(expr) (void)(expr)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -38,7 +38,7 @@ static FORCE_INLINE float taos_align_get_float(const char *pBuf) {
|
|||
assert(sizeof(float) == sizeof(uint32_t));
|
||||
#endif
|
||||
float fv = 0;
|
||||
memcpy(&fv, pBuf, sizeof(fv)); // in ARM, return *((const float*)(pBuf)) may cause problem
|
||||
(void)memcpy(&fv, pBuf, sizeof(fv)); // in ARM, return *((const float*)(pBuf)) may cause problem
|
||||
return fv;
|
||||
}
|
||||
|
||||
|
@ -49,7 +49,7 @@ static FORCE_INLINE double taos_align_get_double(const char *pBuf) {
|
|||
assert(sizeof(double) == sizeof(uint64_t));
|
||||
#endif
|
||||
double dv = 0;
|
||||
memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem
|
||||
(void)memcpy(&dv, pBuf, sizeof(dv)); // in ARM, return *((const double*)(pBuf)) may cause problem
|
||||
return dv;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ if command -v sudo > /dev/null; then
|
|||
csudo="sudo "
|
||||
fi
|
||||
|
||||
${csudo}mkdir -p ${insmetaPath}
|
||||
${csudo}chmod -R 744 ${insmetaPath}
|
||||
cd ${insmetaPath}
|
||||
${csudo}./post.sh
|
||||
|
|
|
@ -20,6 +20,7 @@ if [ -f ${insmetaPath}/preun.sh ]; then
|
|||
else
|
||||
bin_link_dir="/usr/bin"
|
||||
lib_link_dir="/usr/lib"
|
||||
lib64_link_dir="/usr/lib64"
|
||||
inc_link_dir="/usr/include"
|
||||
|
||||
data_link_dir="/usr/local/taos/data"
|
||||
|
@ -33,15 +34,18 @@ else
|
|||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${bin_link_dir}/taos-explorer || :
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/tdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.so ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
|
||||
${csudo}rm -f ${log_link_dir} || :
|
||||
${csudo}rm -f ${data_link_dir} || :
|
||||
|
|
|
@ -76,11 +76,11 @@ if [ -f "${compile_dir}/test/cfg/taosadapter.service" ]; then
|
|||
cp ${compile_dir}/test/cfg/taosadapter.service ${pkg_dir}${install_home_path}/cfg || :
|
||||
fi
|
||||
|
||||
if [ -f "%{_compiledir}/../../../explorer/target/taos-explorer.service" ]; then
|
||||
cp %{_compiledir}/../../../explorer/target/taos-explorer.service ${pkg_dir}${install_home_path}/cfg || :
|
||||
if [ -f "${compile_dir}/../../../explorer/target/taos-explorer.service" ]; then
|
||||
cp ${compile_dir}/../../../explorer/target/taos-explorer.service ${pkg_dir}${install_home_path}/cfg || :
|
||||
fi
|
||||
if [ -f "%{_compiledir}/../../../explorer/server/example/explorer.toml" ]; then
|
||||
cp %{_compiledir}/../../../explorer/server/example/explorer.toml ${pkg_dir}${install_home_path}/cfg || :
|
||||
if [ -f "${compile_dir}/../../../explorer/server/example/explorer.toml" ]; then
|
||||
cp ${compile_dir}/../../../explorer/server/example/explorer.toml ${pkg_dir}${install_home_path}/cfg || :
|
||||
fi
|
||||
|
||||
cp ${taoskeeper_binary} ${pkg_dir}${install_home_path}/bin
|
||||
|
@ -90,6 +90,11 @@ cp ${compile_dir}/../packaging/tools/preun.sh ${pkg_dir}${install_home_pat
|
|||
cp ${compile_dir}/../packaging/tools/startPre.sh ${pkg_dir}${install_home_path}/bin
|
||||
cp ${compile_dir}/../packaging/tools/set_core.sh ${pkg_dir}${install_home_path}/bin
|
||||
cp ${compile_dir}/../packaging/tools/taosd-dump-cfg.gdb ${pkg_dir}${install_home_path}/bin
|
||||
cp ${top_dir}/../enterprise/packaging/start-all.sh ${pkg_dir}${install_home_path}/bin
|
||||
cp ${top_dir}/../enterprise/packaging/stop-all.sh ${pkg_dir}${install_home_path}/bin
|
||||
sed -i "s/versionType=\"enterprise\"/versionType=\"community\"/g" ${pkg_dir}${install_home_path}/bin/start-all.sh
|
||||
sed -i "s/versionType=\"enterprise\"/versionType=\"community\"/g" ${pkg_dir}${install_home_path}/bin/stop-all.sh
|
||||
|
||||
|
||||
cp ${compile_dir}/build/bin/taosd ${pkg_dir}${install_home_path}/bin
|
||||
cp ${compile_dir}/build/bin/udfd ${pkg_dir}${install_home_path}/bin
|
||||
|
|
|
@ -70,8 +70,8 @@ else
|
|||
fi
|
||||
|
||||
cd ${top_dir}
|
||||
echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper"
|
||||
taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper`
|
||||
echo "${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r ${arch} -e taoskeeper -t ver-${tdengine_ver}"
|
||||
taoskeeper_binary=`${top_dir}/../enterprise/packaging/build_taoskeeper.sh -r $arch -e taoskeeper -t ver-${tdengine_ver}`
|
||||
echo "taoskeeper_binary: ${taoskeeper_binary}"
|
||||
cd ${package_dir}
|
||||
|
||||
|
|
|
@ -56,6 +56,10 @@ mkdir -p %{buildroot}%{homepath}/include
|
|||
#mkdir -p %{buildroot}%{homepath}/init.d
|
||||
mkdir -p %{buildroot}%{homepath}/script
|
||||
|
||||
if [ -f %{_compiledir}/../packaging/cfg/taosd.service ]; then
|
||||
cp %{_compiledir}/../packaging/cfg/taosd.service %{buildroot}%{homepath}/cfg
|
||||
fi
|
||||
|
||||
cp %{_compiledir}/../packaging/cfg/taos.cfg %{buildroot}%{homepath}/cfg
|
||||
if [ -f %{_compiledir}/test/cfg/taosadapter.toml ]; then
|
||||
cp %{_compiledir}/test/cfg/taosadapter.toml %{buildroot}%{homepath}/cfg
|
||||
|
@ -91,6 +95,10 @@ cp %{_compiledir}/build/bin/taosd %{buildroot}%{homepath}/bin
|
|||
cp %{_compiledir}/build/bin/udfd %{buildroot}%{homepath}/bin
|
||||
cp %{_compiledir}/build/bin/taosBenchmark %{buildroot}%{homepath}/bin
|
||||
cp %{_compiledir}/build/bin/taosdump %{buildroot}%{homepath}/bin
|
||||
cp %{_compiledir}/../../enterprise/packaging/start-all.sh %{buildroot}%{homepath}/bin
|
||||
cp %{_compiledir}/../../enterprise/packaging/stop-all.sh %{buildroot}%{homepath}/bin
|
||||
sed -i "s/versionType=\"enterprise\"/versionType=\"community\"/g" %{buildroot}%{homepath}/bin/start-all.sh
|
||||
sed -i "s/versionType=\"enterprise\"/versionType=\"community\"/g" %{buildroot}%{homepath}/bin/stop-all.sh
|
||||
|
||||
if [ -f %{_compiledir}/../../../explorer/target/release/taos-explorer ]; then
|
||||
cp %{_compiledir}/../../../explorer/target/release/taos-explorer %{buildroot}%{homepath}/bin
|
||||
|
@ -215,6 +223,7 @@ if [ $1 -eq 0 ];then
|
|||
else
|
||||
bin_link_dir="/usr/bin"
|
||||
lib_link_dir="/usr/lib"
|
||||
lib64_link_dir="/usr/lib64"
|
||||
inc_link_dir="/usr/include"
|
||||
|
||||
data_link_dir="/usr/local/taos/data"
|
||||
|
@ -227,13 +236,18 @@ if [ $1 -eq 0 ];then
|
|||
${csudo}rm -f ${bin_link_dir}/udfd || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdump || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/tdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taows.h || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.so || :
|
||||
${csudo}rm -f ${lib_link_dir}/libtaosws.so || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaosws.so || :
|
||||
|
||||
${csudo}rm -f ${log_link_dir} || :
|
||||
${csudo}rm -f ${data_link_dir} || :
|
||||
|
|
|
@ -156,7 +156,7 @@ done
|
|||
|
||||
#echo "verType=${verType} interactiveFqdn=${interactiveFqdn}"
|
||||
|
||||
tools=(${clientName} ${benchmarkName} ${dumpName} ${demoName} remove.sh udfd set_core.sh TDinsight.sh start_pre.sh)
|
||||
tools=(${clientName} ${benchmarkName} ${dumpName} ${demoName} remove.sh udfd set_core.sh TDinsight.sh start_pre.sh start-all.sh stop-all.sh)
|
||||
if [ "${verMode}" == "cluster" ]; then
|
||||
services=(${serverName} ${adapterName} ${xname} ${explorerName} ${keeperName})
|
||||
elif [ "${verMode}" == "edge" ]; then
|
||||
|
@ -221,6 +221,8 @@ function install_bin() {
|
|||
${csudo}cp -r ${script_dir}/bin/remove.sh ${install_main_dir}/bin
|
||||
else
|
||||
${csudo}cp -r ${script_dir}/bin/* ${install_main_dir}/bin
|
||||
${csudo}cp ${script_dir}/start-all.sh ${install_main_dir}/bin
|
||||
${csudo}cp ${script_dir}/stop-all.sh ${install_main_dir}/bin
|
||||
fi
|
||||
|
||||
if [[ "${verMode}" == "cluster" && "${verType}" != "client" ]]; then
|
||||
|
@ -576,7 +578,9 @@ function install_taosd_config() {
|
|||
${csudo}sed -i -r "s/#*\s*(fqdn\s*).*/\1$serverFqdn/" ${script_dir}/cfg/${configFile}
|
||||
${csudo}echo "monitor 1" >>${script_dir}/cfg/${configFile}
|
||||
${csudo}echo "monitorFQDN ${serverFqdn}" >>${script_dir}/cfg/${configFile}
|
||||
${csudo}echo "audit 1" >>${script_dir}/cfg/${configFile}
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
${csudo}echo "audit 1" >>${script_dir}/cfg/${configFile}
|
||||
fi
|
||||
|
||||
if [ -f "${configDir}/${configFile}" ]; then
|
||||
${csudo}cp ${fileName} ${configDir}/${configFile}.new
|
||||
|
@ -594,6 +598,7 @@ function install_config() {
|
|||
[ ! -z $1 ] && return 0 || : # only install client
|
||||
|
||||
if ((${update_flag} == 1)); then
|
||||
install_taosd_config
|
||||
return 0
|
||||
fi
|
||||
|
||||
|
@ -651,9 +656,7 @@ function install_data() {
|
|||
|
||||
function install_connector() {
|
||||
if [ -d "${script_dir}/connector/" ]; then
|
||||
${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector"
|
||||
${csudo}cp ${script_dir}/start-all.sh ${install_main_dir}/ || echo "failed to copy start-all.sh"
|
||||
${csudo}cp ${script_dir}/stop-all.sh ${install_main_dir}/ || echo "failed to copy stop-all.sh"
|
||||
${csudo}cp -rf ${script_dir}/connector/ ${install_main_dir}/ || echo "failed to copy connector"
|
||||
${csudo}cp ${script_dir}/README.md ${install_main_dir}/ || echo "failed to copy README.md"
|
||||
fi
|
||||
}
|
||||
|
@ -910,39 +913,36 @@ function updateProduct() {
|
|||
echo
|
||||
echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}"
|
||||
[ -f ${configDir}/${adapterName}.toml ] && [ -f ${installDir}/bin/${adapterName} ] &&
|
||||
echo -e "${GREEN_DARK}To configure ${adapterName} ${NC}\t: edit ${configDir}/${adapterName}.toml"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "${GREEN_DARK}To configure ${explorerName} ${NC}\t: edit ${configDir}/explorer.toml"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}To configure ${adapterName} ${NC}\t: edit ${configDir}/${adapterName}.toml"
|
||||
echo -e "${GREEN_DARK}To configure ${explorerName} ${NC}\t: edit ${configDir}/explorer.toml"
|
||||
if ((${service_mod} == 0)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ${csudo}systemctl start ${serverName}${NC}"
|
||||
[ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}"
|
||||
elif ((${service_mod} == 1)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ${csudo}service ${serverName} start${NC}"
|
||||
[ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ./${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ./${serverName}${NC}"
|
||||
[ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName}keeper ${NC}\t\t: sudo systemctl start ${clientName}keeper ${NC}"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}"
|
||||
|
||||
echo
|
||||
echo "${productName} is updated successfully!"
|
||||
echo
|
||||
|
||||
echo -e "\033[44;32;1mTo start all the components : sudo start-all.sh${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Commnd Line Interface : ${clientName} -h $serverFqdn${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Graphic User Interface : http://$serverFqdn:6060${NC}"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "\033[44;32;1mTo start all the components : ./start-all.sh${NC}"
|
||||
fi
|
||||
echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}"
|
||||
echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs${NC}"
|
||||
fi
|
||||
else
|
||||
|
@ -1007,39 +1007,36 @@ function installProduct() {
|
|||
echo -e "${GREEN_DARK}To configure ${productName} ${NC}\t\t: edit ${configDir}/${configFile}"
|
||||
[ -f ${configDir}/${clientName}adapter.toml ] && [ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To configure ${clientName}Adapter ${NC}\t: edit ${configDir}/${clientName}adapter.toml"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "${GREEN_DARK}To configure ${clientName}-explorer ${NC}\t: edit ${configDir}/explorer.toml"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}To configure ${clientName}-explorer ${NC}\t: edit ${configDir}/explorer.toml"
|
||||
if ((${service_mod} == 0)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}systemctl start ${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ${csudo}systemctl start ${serverName}${NC}"
|
||||
[ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}systemctl start ${clientName}adapter ${NC}"
|
||||
elif ((${service_mod} == 1)); then
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${csudo}service ${serverName} start${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ${csudo}service ${serverName} start${NC}"
|
||||
[ -f ${service_config_dir}/${clientName}adapter.service ] && [ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${csudo}service ${clientName}adapter start${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start ${productName} ${NC}\t\t: ${serverName}${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${productName} server ${NC}\t: ${serverName}${NC}"
|
||||
[ -f ${installDir}/bin/${clientName}adapter ] &&
|
||||
echo -e "${GREEN_DARK}To start ${clientName}Adapter ${NC}\t\t: ${clientName}adapter ${NC}"
|
||||
fi
|
||||
|
||||
echo -e "${GREEN_DARK}To enable ${clientName}keeper ${NC}\t\t: sudo systemctl enable ${clientName}keeper ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName}keeper ${NC}\t\t: sudo systemctl start ${clientName}keeper ${NC}"
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "${GREEN_DARK}To start ${clientName}x ${NC}\t\t\t: sudo systemctl start ${clientName}x ${NC}"
|
||||
echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}To start ${clientName}-explorer ${NC}\t\t: sudo systemctl start ${clientName}-explorer ${NC}"
|
||||
|
||||
echo
|
||||
echo "${productName} is installed successfully!"
|
||||
echo
|
||||
|
||||
echo -e "\033[44;32;1mTo start all the components : sudo start-all.sh${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Commnd Line Interface : ${clientName} -h $serverFqdn${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Graphic User Interface : http://$serverFqdn:6060${NC}"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "\033[44;32;1mTo start all the components : sudo ./start-all.sh${NC}"
|
||||
fi
|
||||
echo -e "\033[44;32;1mTo access ${productName} : ${clientName} -h $serverFqdn${NC}"
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
echo -e "\033[44;32;1mTo access the management system : http://$serverFqdn:6060${NC}"
|
||||
echo -e "\033[44;32;1mTo read the user manual : http://$serverFqdn:6060/docs-en${NC}"
|
||||
fi
|
||||
echo
|
||||
|
|
|
@ -232,7 +232,7 @@ fi
|
|||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
sed 's/verMode=edge/verMode=cluster/g' ${install_dir}/bin/remove.sh >>remove_temp.sh
|
||||
sed -i "s/PREFIX=\"taos\"/PREFIX=\"${serverName2}\"/g" remove_temp.sh
|
||||
sed -i "s/PREFIX=\"taos\"/PREFIX=\"${clientName2}\"/g" remove_temp.sh
|
||||
sed -i "s/productName=\"TDengine\"/productName=\"${productName2}\"/g" remove_temp.sh
|
||||
mv remove_temp.sh ${install_dir}/bin/remove.sh
|
||||
fi
|
||||
|
|
|
@ -104,6 +104,8 @@ fi
|
|||
|
||||
function log_print(){
|
||||
now=$(date +"%D %T")
|
||||
${csudo}mkdir -p ${log_dir} && ${csudo}chmod 777 ${log_dir}
|
||||
${csudo} touch ${install_log_path}
|
||||
echo "$now $1" >> ${install_log_path}
|
||||
}
|
||||
|
||||
|
@ -235,11 +237,14 @@ function install_bin() {
|
|||
${csudo}rm -f ${bin_link_dir}/taosadapter || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosBenchmark || :
|
||||
${csudo}rm -f ${bin_link_dir}/taoskeeper || :
|
||||
${csudo}rm -f ${bin_link_dir}/taos-explorer || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdemo || :
|
||||
${csudo}rm -f ${bin_link_dir}/taosdump || :
|
||||
${csudo}rm -f ${bin_link_dir}/rmtaos || :
|
||||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||
${csudo}rm -f ${bin_link_dir}/*explorer || :
|
||||
${csudo}rm -f ${bin_link_dir}/start-all.sh || :
|
||||
${csudo}rm -f ${bin_link_dir}/stop-all.sh || :
|
||||
|
||||
${csudo}chmod 0555 ${bin_dir}/*
|
||||
|
||||
|
@ -275,8 +280,14 @@ function install_bin() {
|
|||
if [ -x ${bin_dir}/taoskeeper ]; then
|
||||
${csudo}ln -sf ${bin_dir}/taoskeeper ${bin_link_dir}/taoskeeper 2>>${install_log_path} || return 1
|
||||
fi
|
||||
if [ -x ${bin_dir}/*explorer ]; then
|
||||
${csudo}ln -s ${bin_dir}/*explorer ${bin_link_dir}/*explorer 2>>${install_log_path} || return 1
|
||||
if [ -x ${bin_dir}/taos-explorer ]; then
|
||||
${csudo}ln -s ${bin_dir}/taos-explorer ${bin_link_dir}/taos-explorer 2>>${install_log_path} || return 1
|
||||
fi
|
||||
if [ -x ${bin_dir}/start-all.sh ]; then
|
||||
${csudo}ln -s ${bin_dir}/start-all.sh ${bin_link_dir}/start-all.sh 2>>${install_log_path} || return 1
|
||||
fi
|
||||
if [ -x ${bin_dir}/stop-all.sh ]; then
|
||||
${csudo}ln -s ${bin_dir}/stop-all.sh ${bin_link_dir}/stop-all.sh 2>>${install_log_path} || return 1
|
||||
fi
|
||||
log_print "install bin success"
|
||||
}
|
||||
|
@ -474,6 +485,22 @@ function install_taoskeeper_config() {
|
|||
${csudo}ln -s ${cfg_install_dir}/taoskeeper.toml ${cfg_dir}
|
||||
}
|
||||
|
||||
function install_taos-explorer_config() {
|
||||
if [ ! -f "${cfg_install_dir}/explorer.toml" ]; then
|
||||
[ ! -d ${cfg_install_dir} ] &&
|
||||
${csudo}${csudo}mkdir -p ${cfg_install_dir}
|
||||
[ -f ${cfg_dir}/explorer.toml ] && ${csudo}cp ${cfg_dir}/explorer.toml ${cfg_install_dir}
|
||||
[ -f ${cfg_install_dir}/explorer.toml ] &&
|
||||
${csudo}chmod 644 ${cfg_install_dir}/explorer.toml
|
||||
fi
|
||||
|
||||
[ -f ${cfg_dir}/explorer.toml ] &&
|
||||
${csudo}mv ${cfg_dir}/explorer.toml ${cfg_dir}/explorer.toml.new
|
||||
|
||||
[ -f ${cfg_install_dir}/explorer.toml ] &&
|
||||
${csudo}ln -s ${cfg_install_dir}/explorer.toml ${cfg_dir}
|
||||
}
|
||||
|
||||
function install_config() {
|
||||
log_print "start install config from ${cfg_dir} to ${cfg_install_dir}"
|
||||
if [ ! -f "${cfg_install_dir}/taos.cfg" ]; then
|
||||
|
@ -609,30 +636,12 @@ function clean_service_on_systemd() {
|
|||
|
||||
function install_service_on_systemd() {
|
||||
clean_service_on_systemd
|
||||
|
||||
[ -f ${script_dir}/../cfg/taosd.service ] &&\
|
||||
${csudo}cp ${script_dir}/../cfg/taosd.service \
|
||||
${service_config_dir}/ || :
|
||||
|
||||
taosd_service_config="${service_config_dir}/taosd.service"
|
||||
|
||||
${csudo}bash -c "echo '[Unit]' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'Description=TDengine server service' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'After=network-online.target' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'Wants=network-online.target' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo '[Service]' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'Type=simple' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'ExecStart=/usr/bin/taosd' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'ExecStartPre=/usr/local/taos/bin/startPre.sh' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'TimeoutStopSec=1000000s' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'LimitNOFILE=infinity' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'LimitNPROC=infinity' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'LimitCORE=infinity' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'TimeoutStartSec=0' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'StandardOutput=null' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'Restart=always' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'StartLimitBurst=3' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'StartLimitInterval=60s' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo '[Install]' >> ${taosd_service_config}"
|
||||
${csudo}bash -c "echo 'WantedBy=multi-user.target' >> ${taosd_service_config}"
|
||||
${csudo}systemctl daemon-reload
|
||||
${csudo}systemctl enable taosd
|
||||
}
|
||||
|
||||
|
@ -652,6 +661,11 @@ function install_service_on_launchctl() {
|
|||
${csudo}cp ${install_main_dir}/service/com.taosdata.taoskeeper.plist /Library/LaunchDaemons/com.taosdata.taoskeeper.plist || :
|
||||
${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taoskeeper.plist || :
|
||||
fi
|
||||
if [ -f ${install_main_dir}/service/com.taosdata.taos-explorer.plist ]; then
|
||||
${csudo}launchctl unload -w /Library/LaunchDaemons/com.taosdata.taos-explorer.plist > /dev/null 2>&1 || :
|
||||
${csudo}cp ${install_main_dir}/service/com.taosdata.taos-explorer.plist /Library/LaunchDaemons/com.taosdata.taos-explorer.plist || :
|
||||
${csudo}launchctl load -w /Library/LaunchDaemons/com.taosdata.taos-explorer.plist || :
|
||||
fi
|
||||
}
|
||||
|
||||
function install_taosadapter_service() {
|
||||
|
@ -672,6 +686,15 @@ function install_taoskeeper_service() {
|
|||
fi
|
||||
}
|
||||
|
||||
function install_taos-explorer_service() {
|
||||
if ((${service_mod}==0)); then
|
||||
[ -f ${script_dir}/../cfg/taos-explorer.service ] &&\
|
||||
${csudo}cp ${script_dir}/../cfg/taos-explorer.service \
|
||||
${service_config_dir}/ || :
|
||||
${csudo}systemctl daemon-reload
|
||||
fi
|
||||
}
|
||||
|
||||
function install_service() {
|
||||
log_print "start install service"
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
|
@ -748,8 +771,10 @@ function install_TDengine() {
|
|||
install_config
|
||||
install_taosadapter_config
|
||||
install_taoskeeper_config
|
||||
install_taos-explorer_config
|
||||
install_taosadapter_service
|
||||
install_taoskeeper_service
|
||||
install_taos-explorer_service
|
||||
install_service
|
||||
install_app
|
||||
|
||||
|
@ -757,40 +782,38 @@ function install_TDengine() {
|
|||
#echo
|
||||
#echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
|
||||
echo
|
||||
echo -e "${GREEN_DARK}To configure TDengine ${NC}: edit /etc/taos/taos.cfg"
|
||||
echo -e "${GREEN_DARK}To configure TDengine ${NC}\t: edit /etc/taos/taos.cfg"
|
||||
echo -e "${GREEN_DARK}To configure taosAdapter ${NC}\t: edit /etc/taos/taosadapter.toml"
|
||||
echo -e "${GREEN_DARK}To configure taos-explorer ${NC}\t: edit /etc/taos/explorer.toml"
|
||||
if ((${service_mod}==0)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}systemctl start taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start TDengine server ${NC}\t: ${csudo}systemctl start taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start taosAdapter ${NC}\t: ${csudo}systemctl start taosadapter${NC}"
|
||||
echo -e "${GREEN_DARK}To start taoskeeper ${NC}\t: ${csudo}systemctl start taoskeeper${NC}"
|
||||
echo -e "${GREEN_DARK}To start taos-explorer ${NC}\t: ${csudo}systemctl start taos-explorer${NC}"
|
||||
elif ((${service_mod}==1)); then
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ${csudo}update-rc.d taosd default ${RED} for the first time${NC}"
|
||||
echo -e "${GREEN_DARK}To start TDengine server ${NC}\t: ${csudo}update-rc.d taosd default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo}service taosd start ${RED} after${NC}"
|
||||
echo -e "${GREEN_DARK}To start taosAdapter ${NC}\t: ${csudo}update-rc.d taosadapter default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo}service taosd taosadapter ${RED} after${NC}"
|
||||
echo -e "${GREEN_DARK}To start taoskeeper ${NC}\t: ${csudo}update-rc.d taoskeeper default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo}service taosd taoskeeper ${RED} after${NC}"
|
||||
echo -e "${GREEN_DARK}To start taos-explorer ${NC}\t: ${csudo}update-rc.d taos-explorer default ${RED} for the first time${NC}"
|
||||
echo -e " : ${csudo}service taosd taos-explorer ${RED} after${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To start TDengine ${NC}: ./taosd${NC}"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
if [ ! -z "$firstEp" ]; then
|
||||
tmpFqdn=${firstEp%%:*}
|
||||
substr=":"
|
||||
if [[ $firstEp =~ $substr ]];then
|
||||
tmpPort=${firstEp#*:}
|
||||
else
|
||||
tmpPort=""
|
||||
fi
|
||||
if [[ "$tmpPort" != "" ]];then
|
||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn -P $tmpPort${GREEN_DARK} to login into cluster, then${NC}"
|
||||
else
|
||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $tmpFqdn${GREEN_DARK} to login into cluster, then${NC}"
|
||||
fi
|
||||
echo -e "${GREEN_DARK}execute ${NC}: create dnode 'newDnodeFQDN:port'; ${GREEN_DARK}to add this new node${NC}"
|
||||
echo
|
||||
elif [ ! -z "$serverFqdn" ]; then
|
||||
echo -e "${GREEN_DARK}To access TDengine ${NC}: taos -h $serverFqdn${GREEN_DARK} to login into TDengine server${NC}"
|
||||
echo
|
||||
echo -e "${GREEN_DARK}To start TDengine server ${NC}\t: ./taosd${NC}"
|
||||
echo -e "${GREEN_DARK}To start taosAdapter ${NC}\t: ./taosadapter${NC}"
|
||||
echo -e "${GREEN_DARK}To start taoskeeper ${NC}\t: ./taoskeeper${NC}"
|
||||
echo -e "${GREEN_DARK}To start taos-explorer ${NC}\t: ./taos-explorer${NC}"
|
||||
fi
|
||||
|
||||
log_print "install TDengine successfully!"
|
||||
echo
|
||||
echo -e "\033[44;32;1mTDengine is installed successfully!${NC}"
|
||||
echo "TDengine is installed successfully!"
|
||||
echo
|
||||
echo -e "\033[44;32;1mTo start all the components : sudo start-all.sh${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Commnd Line Interface : taos -h $serverFqdn${NC}"
|
||||
echo -e "\033[44;32;1mTo access ${productName} Graphic User Interface : http://$serverFqdn:6060${NC}"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ RED='\033[0;31m'
|
|||
GREEN='\033[1;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
PREFIX="taos"
|
||||
|
||||
if [ "$osType" != "Darwin" ]; then
|
||||
installDir="/usr/local/taos"
|
||||
bin_link_dir="/usr/bin"
|
||||
|
@ -31,41 +33,31 @@ else
|
|||
lib64_link_dir="/usr/local/lib"
|
||||
inc_link_dir="/usr/local/include"
|
||||
fi
|
||||
serverName="taosd"
|
||||
clientName="taos"
|
||||
uninstallScript="rmtaos"
|
||||
|
||||
serverName="${PREFIX}d"
|
||||
clientName="${PREFIX}"
|
||||
uninstallScript="rm${PREFIX}"
|
||||
adapterName="${PREFIX}adapter"
|
||||
demoName="${PREFIX}demo"
|
||||
benchmarkName="${PREFIX}Benchmark"
|
||||
dumpName="${PREFIX}dump"
|
||||
keeperName="${PREFIX}keeper"
|
||||
xName="${PREFIX}x"
|
||||
explorerName="${PREFIX}-explorer"
|
||||
tarbitratorName="tarbitratord"
|
||||
productName="TDengine"
|
||||
|
||||
serverName2="taosd"
|
||||
clientName2="taos"
|
||||
productName2="TDengine"
|
||||
|
||||
adapterName2="${clientName2}adapter"
|
||||
demoName2="${clientName2}demo"
|
||||
benchmarkName2="${clientName2}Benchmark"
|
||||
dumpName2="${clientName2}dump"
|
||||
keeperName2="${clientName2}keeper"
|
||||
xName2="${clientName2}x"
|
||||
explorerName2="${clientName2}-explorer"
|
||||
uninstallScript2="rm${clientName2}"
|
||||
|
||||
installDir="/usr/local/${clientName2}"
|
||||
|
||||
#install main path
|
||||
install_main_dir=${installDir}
|
||||
data_link_dir=${installDir}/data
|
||||
log_link_dir=${installDir}/log
|
||||
cfg_link_dir=${installDir}/cfg
|
||||
local_bin_link_dir="/usr/local/bin"
|
||||
|
||||
|
||||
service_config_dir="/etc/systemd/system"
|
||||
taos_service_name=${serverName2}
|
||||
taosadapter_service_name="${clientName2}adapter"
|
||||
tarbitrator_service_name="tarbitratord"
|
||||
|
||||
config_dir="/etc/${clientName2}"
|
||||
config_dir="/etc/${PREFIX}"
|
||||
|
||||
services=(${PREFIX}"d" ${PREFIX}"adapter" ${PREFIX}"x" ${PREFIX}"-explorer" ${PREFIX}"keeper")
|
||||
tools=(${PREFIX} ${PREFIX}"Benchmark" ${PREFIX}"dump" ${PREFIX}"demo" udfd set_core.sh TDinsight.sh $uninstallScript start-all.sh stop-all.sh)
|
||||
|
||||
csudo=""
|
||||
if command -v sudo >/dev/null; then
|
||||
|
@ -92,215 +84,26 @@ else
|
|||
service_mod=2
|
||||
fi
|
||||
|
||||
function kill_taosadapter() {
|
||||
pid=$(ps -ef | grep "${adapterName2}" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_taosd() {
|
||||
pid=$(ps -ef | grep ${serverName2} | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function kill_tarbitrator() {
|
||||
pid=$(ps -ef | grep "tarbitrator" | grep -v "grep" | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_bin() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${bin_link_dir}/${clientName} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${serverName} || :
|
||||
echo "${serverName} is removed successfully"
|
||||
${csudo}rm -f ${bin_link_dir}/udfd || :
|
||||
${csudo}rm -f ${bin_link_dir}/${adapterName2} || :
|
||||
echo "${adapterName2} is removed successfully"
|
||||
${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${demoName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${uninstallScript} || :
|
||||
${csudo}rm -f ${bin_link_dir}/tarbitrator || :
|
||||
${csudo}rm -f ${bin_link_dir}/set_core || :
|
||||
${csudo}rm -f ${bin_link_dir}/TDinsight.sh || :
|
||||
${csudo}rm -f ${bin_link_dir}/${keeperName2} || :
|
||||
|
||||
|
||||
if [ "$verMode" == "cluster" ] && [ "$clientName" != "$clientName2" ]; then
|
||||
${csudo}rm -f ${bin_link_dir}/${xName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${explorerName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${clientName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${benchmarkName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${dumpName2} || :
|
||||
${csudo}rm -f ${bin_link_dir}/${uninstallScript2} || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_local_bin() {
|
||||
${csudo}rm -f ${local_bin_link_dir}/${benchmarkName2} || :
|
||||
${csudo}rm -f ${local_bin_link_dir}/${demoName2} || :
|
||||
}
|
||||
|
||||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
|
||||
}
|
||||
|
||||
function clean_header() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/tdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
}
|
||||
|
||||
function clean_config() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
}
|
||||
|
||||
function clean_log() {
|
||||
# Remove link
|
||||
${csudo}rm -rf ${log_link_dir} || :
|
||||
}
|
||||
|
||||
function clean_service_on_systemd() {
|
||||
taosd_service_config="${service_config_dir}/${taos_service_name}.service"
|
||||
if systemctl is-active --quiet ${taos_service_name}; then
|
||||
echo "${taos_service_name} is running, stopping it..."
|
||||
${csudo}systemctl stop ${taos_service_name} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${taos_service_name} &>/dev/null || echo &>/dev/null
|
||||
${csudo}rm -f ${taosd_service_config}
|
||||
|
||||
taosadapter_service_config="${service_config_dir}/${clientName2}adapter.service"
|
||||
if systemctl is-active --quiet ${taosadapter_service_name}; then
|
||||
echo "${clientName2}Adapter is running, stopping it..."
|
||||
${csudo}systemctl stop ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${taosadapter_service_name} &>/dev/null || echo &>/dev/null
|
||||
[ -f ${taosadapter_service_config} ] && ${csudo}rm -f ${taosadapter_service_config}
|
||||
|
||||
tarbitratord_service_config="${service_config_dir}/${tarbitrator_service_name}.service"
|
||||
if systemctl is-active --quiet ${tarbitrator_service_name}; then
|
||||
echo "${productName2} tarbitrator is running, stopping it..."
|
||||
${csudo}systemctl stop ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${tarbitrator_service_name} &>/dev/null || echo &>/dev/null
|
||||
|
||||
}
|
||||
|
||||
function clean_service_on_sysvinit() {
|
||||
if ps aux | grep -v grep | grep ${serverName} &>/dev/null; then
|
||||
echo "${serverName2} is running, stopping it..."
|
||||
${csudo}service ${serverName} stop || :
|
||||
fi
|
||||
|
||||
if ps aux | grep -v grep | grep tarbitrator &>/dev/null; then
|
||||
echo "${productName2} tarbitrator is running, stopping it..."
|
||||
${csudo}service tarbitratord stop || :
|
||||
fi
|
||||
|
||||
if ((${initd_mod} == 1)); then
|
||||
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||
${csudo}chkconfig --del ${serverName} || :
|
||||
fi
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo}chkconfig --del tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod} == 2)); then
|
||||
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||
${csudo}insserv -r ${serverName} || :
|
||||
fi
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo}insserv -r tarbitratord || :
|
||||
fi
|
||||
elif ((${initd_mod} == 3)); then
|
||||
if [ -e ${service_config_dir}/${serverName} ]; then
|
||||
${csudo}update-rc.d -f ${serverName} remove || :
|
||||
fi
|
||||
if [ -e ${service_config_dir}/tarbitratord ]; then
|
||||
${csudo}update-rc.d -f tarbitratord remove || :
|
||||
fi
|
||||
fi
|
||||
|
||||
${csudo}rm -f ${service_config_dir}/${serverName} || :
|
||||
${csudo}rm -f ${service_config_dir}/tarbitratord || :
|
||||
|
||||
if $(which init &>/dev/null); then
|
||||
${csudo}init q || :
|
||||
fi
|
||||
}
|
||||
|
||||
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.${clientName2}adapter.plist > /dev/null 2>&1 || :
|
||||
${csudo}rm /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
function clean_service() {
|
||||
if ((${service_mod} == 0)); then
|
||||
clean_service_on_systemd
|
||||
elif ((${service_mod} == 1)); then
|
||||
clean_service_on_sysvinit
|
||||
else
|
||||
if [ "$osType" = "Darwin" ]; then
|
||||
clean_service_on_launchctl
|
||||
fi
|
||||
kill_taosadapter
|
||||
kill_taosd
|
||||
kill_tarbitrator
|
||||
fi
|
||||
}
|
||||
|
||||
function remove_data_and_config() {
|
||||
data_dir=`grep dataDir /etc/taos/taos.cfg | grep -v '#' | tail -n 1 | awk {'print $2'}`
|
||||
if [ X"$data_dir" == X"" ]; then
|
||||
data_dir="/var/lib/taos"
|
||||
fi
|
||||
log_dir=`grep logDir /etc/taos/taos.cfg | grep -v '#' | tail -n 1 | awk {'print $2'}`
|
||||
if [ X"$log_dir" == X"" ]; then
|
||||
log_dir="/var/log/taos"
|
||||
fi
|
||||
[ -d "${config_dir}" ] && ${csudo}rm -rf ${config_dir}/*
|
||||
[ -d "${data_dir}" ] && ${csudo}rm -rf ${data_dir}/*
|
||||
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}/*
|
||||
}
|
||||
|
||||
_kill_service_of() {
|
||||
kill_service_of() {
|
||||
_service=$1
|
||||
pid=$(ps -ef | grep "$_service" | grep -v "grep" | awk '{print $2}')
|
||||
pid=$(ps -ef | grep $_service | grep -v grep | grep -v $uninstallScript | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
_clean_service_on_systemd_of() {
|
||||
clean_service_on_systemd_of() {
|
||||
_service=$1
|
||||
_service_config="${service_config_dir}/${_service}.service"
|
||||
if systemctl is-active --quiet ${_service}; then
|
||||
echo "taoskeeper is running, stopping it..."
|
||||
echo "${_service} is running, stopping it..."
|
||||
${csudo}systemctl stop ${_service} &>/dev/null || echo &>/dev/null
|
||||
fi
|
||||
${csudo}systemctl disable ${_service} &>/dev/null || echo &>/dev/null
|
||||
${csudo}rm -f ${_service_config}
|
||||
}
|
||||
_clean_service_on_sysvinit_of() {
|
||||
|
||||
clean_service_on_sysvinit_of() {
|
||||
_service=$1
|
||||
if pidof ${_service} &>/dev/null; then
|
||||
echo "${_service} is running, stopping it..."
|
||||
|
@ -327,45 +130,99 @@ _clean_service_on_sysvinit_of() {
|
|||
fi
|
||||
}
|
||||
|
||||
_clean_service_of() {
|
||||
clean_service_of() {
|
||||
_service=$1
|
||||
if ((${service_mod} == 0)); then
|
||||
_clean_service_on_systemd_of $_service
|
||||
clean_service_on_systemd_of $_service
|
||||
elif ((${service_mod} == 1)); then
|
||||
_clean_service_on_sysvinit_of $_service
|
||||
clean_service_on_sysvinit_of $_service
|
||||
else
|
||||
_kill_service_of $_service
|
||||
kill_service_of $_service
|
||||
fi
|
||||
}
|
||||
|
||||
remove_taoskeeper() {
|
||||
# remove taoskeeper bin
|
||||
_clean_service_of taoskeeper
|
||||
[ -e "${bin_link_dir}/taoskeeper" ] && ${csudo}rm -rf ${bin_link_dir}/taoskeeper
|
||||
[ -e "${installDir}/taoskeeper" ] && ${csudo}rm -rf ${installDir}/taoskeeper
|
||||
[ -e "${cfg_link_dir}/metrics.toml" ] || ${csudo}rm -rf ${cfg_link_dir}/metrics.toml
|
||||
echo "taosKeeper is removed successfully!"
|
||||
}
|
||||
|
||||
function uninstall_taosx() {
|
||||
if [ -f ${installDir}/uninstall.sh ]; then
|
||||
cd ${installDir}
|
||||
bash uninstall.sh
|
||||
remove_service_of() {
|
||||
_service=$1
|
||||
clean_service_of ${_service}
|
||||
if [[ -e "${bin_link_dir}/${_service}" || -e "${installDir}/bin/${_service}" || -e "${local_bin_link_dir}/${_service}" ]]; then
|
||||
${csudo}rm -rf ${bin_link_dir}/${_service}
|
||||
${csudo}rm -rf ${installDir}/bin/${_service}
|
||||
${csudo}rm -rf ${local_bin_link_dir}/${_service}
|
||||
echo "${_service} is removed successfully!"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "$verMode" == "cluster" ]; then
|
||||
uninstall_taosx
|
||||
fi
|
||||
remove_tools_of() {
|
||||
_tool=$1
|
||||
kill_service_of ${_tool}
|
||||
[ -e "${bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${bin_link_dir}/${_tool} || :
|
||||
[ -e "${installDir}/bin/${_tool}" ] && ${csudo}rm -rf ${installDir}/bin/${_tool} || :
|
||||
[ -e "${local_bin_link_dir}/${_tool}" ] && ${csudo}rm -rf ${local_bin_link_dir}/${_tool} || :
|
||||
}
|
||||
|
||||
remove_taoskeeper
|
||||
# Stop service and disable booting start.
|
||||
clean_service
|
||||
# Remove binary file and links
|
||||
clean_bin
|
||||
# Remove links of local bin
|
||||
clean_local_bin
|
||||
# Remove header file.
|
||||
remove_bin() {
|
||||
for _service in "${services[@]}"; do
|
||||
remove_service_of ${_service}
|
||||
done
|
||||
|
||||
for _tool in "${tools[@]}"; do
|
||||
remove_tools_of ${_tool}
|
||||
done
|
||||
}
|
||||
|
||||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
}
|
||||
|
||||
function clean_header() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${inc_link_dir}/taos.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/tdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
|
||||
[ -f ${inc_link_dir}/taosws.h ] && ${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
}
|
||||
|
||||
function clean_config() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${cfg_link_dir}/* || :
|
||||
}
|
||||
|
||||
function clean_log() {
|
||||
# Remove link
|
||||
${csudo}rm -rf ${log_link_dir} || :
|
||||
}
|
||||
|
||||
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.${clientName2}adapter.plist > /dev/null 2>&1 || :
|
||||
${csudo}rm /Library/LaunchDaemons/com.taosdata.${clientName2}adapter.plist > /dev/null 2>&1 || :
|
||||
}
|
||||
|
||||
function remove_data_and_config() {
|
||||
data_dir=`grep dataDir /etc/taos/taos.cfg | grep -v '#' | tail -n 1 | awk {'print $2'}`
|
||||
if [ X"$data_dir" == X"" ]; then
|
||||
data_dir="/var/lib/${PREFIX}"
|
||||
fi
|
||||
log_dir=`grep logDir /etc/taos/taos.cfg | grep -v '#' | tail -n 1 | awk {'print $2'}`
|
||||
if [ X"$log_dir" == X"" ]; then
|
||||
log_dir="/var/log/${PREFIX}"
|
||||
fi
|
||||
[ -d "${config_dir}" ] && ${csudo}rm -rf ${config_dir}
|
||||
[ -d "${data_dir}" ] && ${csudo}rm -rf ${data_dir}
|
||||
[ -d "${log_dir}" ] && ${csudo}rm -rf ${log_dir}
|
||||
}
|
||||
|
||||
remove_bin
|
||||
clean_header
|
||||
# Remove lib file
|
||||
clean_lib
|
||||
|
@ -375,8 +232,7 @@ clean_log
|
|||
clean_config
|
||||
# Remove data link directory
|
||||
${csudo}rm -rf ${data_link_dir} || :
|
||||
|
||||
${csudo}rm -rf ${install_main_dir}
|
||||
${csudo}rm -rf ${install_main_dir} || :
|
||||
if [[ -e /etc/os-release ]]; then
|
||||
osinfo=$(awk -F= '/^NAME/{print $2}' /etc/os-release)
|
||||
else
|
||||
|
@ -394,6 +250,7 @@ elif echo $osinfo | grep -qwi "centos"; then
|
|||
${csudo}rpm -e --noscripts tdengine >/dev/null 2>&1 || :
|
||||
fi
|
||||
if [ "$osType" = "Darwin" ]; then
|
||||
clean_service_on_launchctl
|
||||
${csudo}rm -rf /Applications/TDengine.app
|
||||
fi
|
||||
|
||||
|
@ -411,6 +268,7 @@ if [ X$answer == X"y" ] || [ X$answer == X"Y" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
command -v systemctl >/dev/null 2>&1 && ${csudo}systemctl daemon-reload >/dev/null 2>&1 || true
|
||||
echo
|
||||
echo "${productName2} is removed successfully!"
|
||||
echo "${productName} is removed successfully!"
|
||||
echo
|
||||
|
|
|
@ -38,9 +38,10 @@ if command -v sudo > /dev/null; then
|
|||
fi
|
||||
|
||||
function kill_client() {
|
||||
if [ -n "$(ps aux | grep -v grep | grep ${clientName})" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
pid=$(ps -ef | grep ${clientName2} | grep -v grep | grep -v $uninstallScript2 | awk '{print $2}')
|
||||
if [ -n "$pid" ]; then
|
||||
${csudo}kill -9 $pid || :
|
||||
fi
|
||||
}
|
||||
|
||||
function clean_bin() {
|
||||
|
@ -62,10 +63,13 @@ function clean_bin() {
|
|||
}
|
||||
|
||||
function clean_lib() {
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
# Remove link
|
||||
${csudo}rm -f ${lib_link_dir}/libtaos.* || :
|
||||
[ -f ${lib_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib_link_dir}/libtaosws.* || :
|
||||
|
||||
${csudo}rm -f ${lib64_link_dir}/libtaos.* || :
|
||||
[ -f ${lib64_link_dir}/libtaosws.* ] && ${csudo}rm -f ${lib64_link_dir}/libtaosws.* || :
|
||||
#${csudo}rm -rf ${v15_java_app_dir} || :
|
||||
}
|
||||
|
||||
function clean_header() {
|
||||
|
@ -75,6 +79,7 @@ function clean_header() {
|
|||
${csudo}rm -f ${inc_link_dir}/taoserror.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/tdef.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosudf.h || :
|
||||
${csudo}rm -f ${inc_link_dir}/taosws.h || :
|
||||
}
|
||||
|
||||
function clean_config() {
|
||||
|
|
|
@ -332,8 +332,7 @@ static FORCE_INLINE SReqResultInfo* tmqGetCurResInfo(TAOS_RES* res) {
|
|||
return (SReqResultInfo*)&msg->common.resInfo;
|
||||
}
|
||||
|
||||
SReqResultInfo* tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4);
|
||||
|
||||
int32_t tmqGetNextResInfo(TAOS_RES* res, bool convertUcs4, SReqResultInfo** pResInfo);
|
||||
static FORCE_INLINE SReqResultInfo* tscGetCurResInfo(TAOS_RES* res) {
|
||||
if (TD_RES_QUERY(res)) return &(((SRequestObj*)res)->body.resInfo);
|
||||
return tmqGetCurResInfo(res);
|
||||
|
|
|
@ -82,7 +82,7 @@ extern "C" {
|
|||
#define IS_SLASH_LETTER_IN_MEASUREMENT(sql) \
|
||||
(*((sql)-1) == SLASH && (*(sql) == COMMA || *(sql) == SPACE || *(sql) == SLASH))
|
||||
|
||||
#define MOVE_FORWARD_ONE(sql, len) (memmove((void *)((sql)-1), (sql), len))
|
||||
#define MOVE_FORWARD_ONE(sql, len) ((void)memmove((void *)((sql)-1), (sql), len))
|
||||
|
||||
#define PROCESS_SLASH_IN_MEASUREMENT(key, keyLen) \
|
||||
for (int i = 1; i < keyLen; ++i) { \
|
||||
|
@ -211,19 +211,19 @@ extern int64_t smlFactorS[];
|
|||
|
||||
typedef int32_t (*_equal_fn_sml)(const void *, const void *);
|
||||
|
||||
SSmlHandle *smlBuildSmlInfo(TAOS *taos);
|
||||
int32_t smlBuildSmlInfo(TAOS *taos, SSmlHandle **handle);
|
||||
void smlDestroyInfo(SSmlHandle *info);
|
||||
int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset);
|
||||
int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset);
|
||||
bool smlParseNumberOld(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
||||
int32_t smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2);
|
||||
bool smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
||||
void smlBuildInvalidDataMsg(SSmlMsgBuf *pBuf, const char *msg1, const char *msg2);
|
||||
int32_t smlParseNumber(SSmlKv *kvVal, SSmlMsgBuf *msg);
|
||||
int64_t smlGetTimeValue(const char *value, int32_t len, uint8_t fromPrecision, uint8_t toPrecision);
|
||||
SSmlTableInfo* smlBuildTableInfo(int numRows, const char* measure, int32_t measureLen);
|
||||
SSmlSTableMeta* smlBuildSTableMeta(bool isDataFormat);
|
||||
int32_t smlBuildTableInfo(int numRows, const char* measure, int32_t measureLen, SSmlTableInfo** tInfo);
|
||||
int32_t smlBuildSTableMeta(bool isDataFormat, SSmlSTableMeta** sMeta);
|
||||
int32_t smlSetCTableName(SSmlTableInfo *oneTable);
|
||||
void getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tinfo);
|
||||
STableMeta* smlGetMeta(SSmlHandle *info, const void* measure, int32_t measureLen);
|
||||
int32_t getTableUid(SSmlHandle *info, SSmlLineInfo *currElement, SSmlTableInfo *tinfo);
|
||||
int32_t smlGetMeta(SSmlHandle *info, const void* measure, int32_t measureLen, STableMeta **pTableMeta);
|
||||
int32_t is_same_child_table_telnet(const void *a, const void *b);
|
||||
int64_t smlParseOpenTsdbTime(SSmlHandle *info, const char *data, int32_t len);
|
||||
int32_t smlClearForRerun(SSmlHandle *info);
|
||||
|
@ -236,7 +236,7 @@ int32_t smlParseInfluxString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLine
|
|||
int32_t smlParseTelnetString(SSmlHandle *info, char *sql, char *sqlEnd, SSmlLineInfo *elements);
|
||||
int32_t smlParseJSON(SSmlHandle *info, char *payload);
|
||||
|
||||
SSmlSTableMeta* smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement);
|
||||
int32_t smlBuildSuperTableInfo(SSmlHandle *info, SSmlLineInfo *currElement, SSmlSTableMeta** sMeta);
|
||||
bool isSmlTagAligned(SSmlHandle *info, int cnt, SSmlKv *kv);
|
||||
bool isSmlColAligned(SSmlHandle *info, int cnt, SSmlKv *kv);
|
||||
int32_t smlProcessChildTable(SSmlHandle *info, SSmlLineInfo *elements);
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "tsched.h"
|
||||
#include "ttime.h"
|
||||
#include "tversion.h"
|
||||
#include "tcompare.h"
|
||||
|
||||
#if defined(CUS_NAME) || defined(CUS_PROMPT) || defined(CUS_EMAIL)
|
||||
#include "cus_name.h"
|
||||
|
@ -127,7 +128,7 @@ static void generateWriteSlowLog(STscObj *pTscObj, SRequestObj *pRequest, int32_
|
|||
cJSON_AddItemToObject(json, "error_info", cJSON_CreateString(tstrerror(pRequest->code)));
|
||||
cJSON_AddItemToObject(json, "type", cJSON_CreateNumber(reqType));
|
||||
cJSON_AddItemToObject(json, "rows_num", cJSON_CreateNumber(pRequest->body.resInfo.numOfRows + pRequest->body.resInfo.totalRows));
|
||||
if(strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen){
|
||||
if(pRequest->sqlstr != NULL && strlen(pRequest->sqlstr) > pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen){
|
||||
char tmp = pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen];
|
||||
pRequest->sqlstr[pTscObj->pAppInfo->monitorParas.tsSlowLogMaxLen] = '\0';
|
||||
cJSON_AddItemToObject(json, "sql", cJSON_CreateString(pRequest->sqlstr));
|
||||
|
@ -875,6 +876,12 @@ void taos_init_imp(void) {
|
|||
}
|
||||
rpcInit();
|
||||
|
||||
if (InitRegexCache() != 0) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init regex cache");
|
||||
return;
|
||||
}
|
||||
|
||||
SCatalogCfg cfg = {.maxDBCacheNum = 100, .maxTblCacheNum = 100};
|
||||
catalogInit(&cfg);
|
||||
|
||||
|
@ -885,8 +892,16 @@ void taos_init_imp(void) {
|
|||
taosSetCoreDump(true);
|
||||
#endif
|
||||
|
||||
initTaskQueue();
|
||||
fmFuncMgtInit();
|
||||
if (initTaskQueue() != 0){
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init task queue");
|
||||
return;
|
||||
}
|
||||
if (fmFuncMgtInit() != TSDB_CODE_SUCCESS) {
|
||||
tscInitRes = -1;
|
||||
tscError("failed to init function manager");
|
||||
return;
|
||||
}
|
||||
nodesInitAllocatorSet();
|
||||
|
||||
clientConnRefPool = taosOpenRef(200, destroyTscObj);
|
||||
|
|
|
@ -744,7 +744,7 @@ static int32_t hbGetUserAuthInfo(SClientHbKey *connKey, SHbParam *param, SClient
|
|||
req->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK);
|
||||
}
|
||||
|
||||
if (taosHashPut(req->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv)) < 0) {
|
||||
if (taosHashPut(req->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv)) != 0) {
|
||||
taosMemoryFree(user);
|
||||
code = terrno ? terrno : TSDB_CODE_APP_ERROR;
|
||||
goto _return;
|
||||
|
@ -1398,7 +1398,8 @@ void hbMgrCleanUp() {
|
|||
|
||||
taosThreadMutexLock(&clientHbMgr.lock);
|
||||
appHbMgrCleanup();
|
||||
clientHbMgr.appHbMgrs = taosArrayDestroy(clientHbMgr.appHbMgrs);
|
||||
taosArrayDestroy(clientHbMgr.appHbMgrs);
|
||||
clientHbMgr.appHbMgrs = NULL;
|
||||
taosThreadMutexUnlock(&clientHbMgr.lock);
|
||||
}
|
||||
|
||||
|
|
|
@ -2007,7 +2007,8 @@ static int32_t doConvertJson(SReqResultInfo* pResultInfo, int32_t numOfCols, int
|
|||
sprintf(varDataVal(dst), "%s", TSDB_DATA_NULL_STR_L);
|
||||
varDataSetLen(dst, strlen(varDataVal(dst)));
|
||||
} else if (tTagIsJson(data)) {
|
||||
char* jsonString = parseTagDatatoJson(data);
|
||||
char* jsonString = NULL;
|
||||
parseTagDatatoJson(data, &jsonString);
|
||||
STR_TO_VARSTR(dst, jsonString);
|
||||
taosMemoryFree(jsonString);
|
||||
} else if (jsonInnerType == TSDB_DATA_TYPE_NCHAR) { // value -> "value"
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "tref.h"
|
||||
#include "trpc.h"
|
||||
#include "version.h"
|
||||
#include "tcompare.h"
|
||||
|
||||
#define TSC_VAR_NOT_RELEASE 1
|
||||
#define TSC_VAR_RELEASED 0
|
||||
|
@ -78,6 +79,7 @@ void taos_cleanup(void) {
|
|||
clientConnRefPool = -1;
|
||||
taosCloseRef(id);
|
||||
|
||||
DestroyRegexCache();
|
||||
rpcCleanup();
|
||||
tscDebug("rpc cleanup");
|
||||
|
||||
|
@ -424,9 +426,11 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
return doAsyncFetchRows(pRequest, true, true);
|
||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SMqRspObj *msg = ((SMqRspObj *)res);
|
||||
SReqResultInfo *pResultInfo;
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
if (msg->common.resIter == -1) {
|
||||
pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if(tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
pResultInfo = tmqGetCurResInfo(res);
|
||||
}
|
||||
|
@ -436,8 +440,7 @@ TAOS_ROW taos_fetch_row(TAOS_RES *res) {
|
|||
pResultInfo->current += 1;
|
||||
return pResultInfo->row;
|
||||
} else {
|
||||
pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if (pResultInfo == NULL) {
|
||||
if (tmqGetNextResInfo(res, true, &pResultInfo) != 0){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -752,8 +755,9 @@ int taos_fetch_block_s(TAOS_RES *res, int *numOfRows, TAOS_ROW *rows) {
|
|||
(*numOfRows) = pResultInfo->numOfRows;
|
||||
return pRequest->code;
|
||||
} else if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, true);
|
||||
if (pResultInfo == NULL) return -1;
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
int32_t code = tmqGetNextResInfo(res, true, &pResultInfo);
|
||||
if (code != 0) return code;
|
||||
|
||||
pResultInfo->current = pResultInfo->numOfRows;
|
||||
(*rows) = pResultInfo->row;
|
||||
|
@ -774,8 +778,9 @@ int taos_fetch_raw_block(TAOS_RES *res, int *numOfRows, void **pData) {
|
|||
}
|
||||
|
||||
if (TD_RES_TMQ(res) || TD_RES_TMQ_METADATA(res)) {
|
||||
SReqResultInfo *pResultInfo = tmqGetNextResInfo(res, false);
|
||||
if (pResultInfo == NULL) {
|
||||
SReqResultInfo *pResultInfo = NULL;
|
||||
int32_t code = tmqGetNextResInfo(res, false, &pResultInfo);
|
||||
if (code != 0) {
|
||||
(*numOfRows) = 0;
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#include "clientMonitor.h"
|
||||
#include "clientLog.h"
|
||||
#include "os.h"
|
||||
#include "tmisce.h"
|
||||
#include "ttime.h"
|
||||
#include "ttimer.h"
|
||||
#include "tglobal.h"
|
||||
#include "tqueue.h"
|
||||
#include "cJSON.h"
|
||||
#include "clientInt.h"
|
||||
#include "clientLog.h"
|
||||
#include "os.h"
|
||||
#include "tglobal.h"
|
||||
#include "tmisce.h"
|
||||
#include "tqueue.h"
|
||||
#include "ttime.h"
|
||||
#include "ttimer.h"
|
||||
|
||||
SRWLatch monitorLock;
|
||||
void* monitorTimer;
|
||||
|
@ -20,41 +20,41 @@ STaosQueue* monitorQueue;
|
|||
SHashObj* monitorSlowLogHash;
|
||||
char tmpSlowLogPath[PATH_MAX] = {0};
|
||||
|
||||
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size){
|
||||
static int32_t getSlowLogTmpDir(char* tmpPath, int32_t size) {
|
||||
if (tsTempDir == NULL) {
|
||||
return -1;
|
||||
}
|
||||
int ret = snprintf(tmpPath, size, "%s/tdengine_slow_log/", tsTempDir);
|
||||
if (ret < 0){
|
||||
if (ret < 0) {
|
||||
tscError("failed to get tmp path ret:%d", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void processFileInTheEnd(TdFilePtr pFile, char* path){
|
||||
if(pFile == NULL){
|
||||
static void processFileInTheEnd(TdFilePtr pFile, char* path) {
|
||||
if (pFile == NULL) {
|
||||
return;
|
||||
}
|
||||
if(taosFtruncateFile(pFile, 0) != 0){
|
||||
if (taosFtruncateFile(pFile, 0) != 0) {
|
||||
tscError("failed to truncate file:%s, errno:%d", path, errno);
|
||||
return;
|
||||
}
|
||||
if(taosUnLockFile(pFile) != 0){
|
||||
if (taosUnLockFile(pFile) != 0) {
|
||||
tscError("failed to unlock file:%s, errno:%d", path, errno);
|
||||
return;
|
||||
}
|
||||
if(taosCloseFile(&(pFile)) != 0){
|
||||
if (taosCloseFile(&(pFile)) != 0) {
|
||||
tscError("failed to close file:%s, errno:%d", path, errno);
|
||||
return;
|
||||
}
|
||||
if(taosRemoveFile(path) != 0){
|
||||
if (taosRemoveFile(path) != 0) {
|
||||
tscError("failed to remove file:%s, errno:%d", path, errno);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void destroySlowLogClient(void* data){
|
||||
static void destroySlowLogClient(void* data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
|
@ -63,40 +63,40 @@ static void destroySlowLogClient(void* data){
|
|||
taosMemoryFree(slowLogClient);
|
||||
}
|
||||
|
||||
static void destroyMonitorClient(void* data){
|
||||
static void destroyMonitorClient(void* data) {
|
||||
if (data == NULL) {
|
||||
return;
|
||||
}
|
||||
MonitorClient* pMonitor = *(MonitorClient**)data;
|
||||
if(pMonitor == NULL){
|
||||
if (pMonitor == NULL) {
|
||||
return;
|
||||
}
|
||||
taosTmrStopA(&pMonitor->timer);
|
||||
taosHashCleanup(pMonitor->counters);
|
||||
taos_collector_registry_destroy(pMonitor->registry);
|
||||
// taos_collector_destroy(pMonitor->colector);
|
||||
// taos_collector_destroy(pMonitor->colector);
|
||||
taosMemoryFree(pMonitor);
|
||||
}
|
||||
|
||||
static void monitorFreeSlowLogData(void *paras) {
|
||||
static void monitorFreeSlowLogData(void* paras) {
|
||||
MonitorSlowLogData* pData = (MonitorSlowLogData*)paras;
|
||||
if (pData == NULL) {
|
||||
return;
|
||||
}
|
||||
taosMemoryFreeClear(pData->data);
|
||||
if (pData->type == SLOW_LOG_READ_BEGINNIG){
|
||||
if (pData->type == SLOW_LOG_READ_BEGINNIG) {
|
||||
taosMemoryFree(pData->fileName);
|
||||
}
|
||||
}
|
||||
|
||||
static void monitorFreeSlowLogDataEx(void *paras) {
|
||||
static void monitorFreeSlowLogDataEx(void* paras) {
|
||||
monitorFreeSlowLogData(paras);
|
||||
taosMemoryFree(paras);
|
||||
}
|
||||
|
||||
static SAppInstInfo* getAppInstByClusterId(int64_t clusterId) {
|
||||
void *p = taosHashGet(appInfo.pInstMapByClusterId, &clusterId, LONG_BYTES);
|
||||
if(p == NULL){
|
||||
void* p = taosHashGet(appInfo.pInstMapByClusterId, &clusterId, LONG_BYTES);
|
||||
if (p == NULL) {
|
||||
tscError("failed to get app inst, clusterId:%" PRIx64, clusterId);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -111,21 +111,25 @@ static int32_t monitorReportAsyncCB(void* param, SDataBuf* pMsg, int32_t code) {
|
|||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
}
|
||||
if(param != NULL){
|
||||
if (param != NULL) {
|
||||
MonitorSlowLogData* p = (MonitorSlowLogData*)param;
|
||||
if(code != 0){
|
||||
if (code != 0) {
|
||||
tscError("failed to send slow log:%s, clusterId:%" PRIx64, p->data, p->clusterId);
|
||||
}
|
||||
MonitorSlowLogData tmp = {.clusterId = p->clusterId, .type = p->type, .fileName = p->fileName,
|
||||
.pFile= p->pFile, .offset = p->offset, .data = NULL};
|
||||
if(monitorPutData2MonitorQueue(tmp) == 0){
|
||||
MonitorSlowLogData tmp = {.clusterId = p->clusterId,
|
||||
.type = p->type,
|
||||
.fileName = p->fileName,
|
||||
.pFile = p->pFile,
|
||||
.offset = p->offset,
|
||||
.data = NULL};
|
||||
if (monitorPutData2MonitorQueue(tmp) == 0) {
|
||||
p->fileName = NULL;
|
||||
}
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
static int32_t sendReport(void* pTransporter, SEpSet *epSet, char* pCont, MONITOR_TYPE type, void* param) {
|
||||
static int32_t sendReport(void* pTransporter, SEpSet* epSet, char* pCont, MONITOR_TYPE type, void* param) {
|
||||
SStatisReq sStatisReq;
|
||||
sStatisReq.pCont = pCont;
|
||||
sStatisReq.contLen = strlen(pCont);
|
||||
|
@ -167,11 +171,11 @@ FAILED:
|
|||
return -1;
|
||||
}
|
||||
|
||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet *epSet) {
|
||||
static void generateClusterReport(taos_collector_registry_t* registry, void* pTransporter, SEpSet* epSet) {
|
||||
char ts[50] = {0};
|
||||
sprintf(ts, "%" PRId64, taosGetTimestamp(TSDB_TIME_PRECISION_MILLI));
|
||||
char* pCont = (char*)taos_collector_registry_bridge_new(registry, ts, "%" PRId64, NULL);
|
||||
if(NULL == pCont) {
|
||||
if (NULL == pCont) {
|
||||
tscError("generateClusterReport failed, get null content.");
|
||||
return;
|
||||
}
|
||||
|
@ -190,8 +194,8 @@ static void reportSendProcess(void* param, void* tmrId) {
|
|||
}
|
||||
|
||||
MonitorClient* pMonitor = (MonitorClient*)param;
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(pMonitor->clusterId);
|
||||
if(pInst == NULL){
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(pMonitor->clusterId);
|
||||
if (pInst == NULL) {
|
||||
taosRUnLockLatch(&monitorLock);
|
||||
return;
|
||||
}
|
||||
|
@ -202,15 +206,15 @@ static void reportSendProcess(void* param, void* tmrId) {
|
|||
taosRUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
static void sendAllCounter(){
|
||||
static void sendAllCounter() {
|
||||
MonitorClient** ppMonitor = NULL;
|
||||
while ((ppMonitor = taosHashIterate(monitorSlowLogHash, ppMonitor))) {
|
||||
MonitorClient* pMonitor = *ppMonitor;
|
||||
if (pMonitor == NULL){
|
||||
if (pMonitor == NULL) {
|
||||
continue;
|
||||
}
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(pMonitor->clusterId);
|
||||
if(pInst == NULL){
|
||||
if (pInst == NULL) {
|
||||
taosHashCancelIterate(monitorCounterHash, ppMonitor);
|
||||
break;
|
||||
}
|
||||
|
@ -231,46 +235,48 @@ void monitorCreateClient(int64_t clusterId) {
|
|||
}
|
||||
pMonitor->clusterId = clusterId;
|
||||
char clusterKey[32] = {0};
|
||||
if(snprintf(clusterKey, sizeof(clusterKey), "%"PRId64, clusterId) < 0){
|
||||
if (snprintf(clusterKey, sizeof(clusterKey), "%" PRId64, clusterId) < 0) {
|
||||
tscError("failed to create cluster key");
|
||||
goto fail;
|
||||
}
|
||||
pMonitor->registry = taos_collector_registry_new(clusterKey);
|
||||
if(pMonitor->registry == NULL){
|
||||
if (pMonitor->registry == NULL) {
|
||||
tscError("failed to create registry");
|
||||
goto fail;
|
||||
}
|
||||
pMonitor->colector = taos_collector_new(clusterKey);
|
||||
if(pMonitor->colector == NULL){
|
||||
if (pMonitor->colector == NULL) {
|
||||
tscError("failed to create collector");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
taos_collector_registry_register_collector(pMonitor->registry, pMonitor->colector);
|
||||
pMonitor->counters = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
pMonitor->counters =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK);
|
||||
if (pMonitor->counters == NULL) {
|
||||
tscError("failed to create monitor counters");
|
||||
goto fail;
|
||||
}
|
||||
// taosHashSetFreeFp(pMonitor->counters, destroyCounter);
|
||||
// taosHashSetFreeFp(pMonitor->counters, destroyCounter);
|
||||
|
||||
if(taosHashPut(monitorCounterHash, &clusterId, LONG_BYTES, &pMonitor, POINTER_BYTES) != 0){
|
||||
if (taosHashPut(monitorCounterHash, &clusterId, LONG_BYTES, &pMonitor, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put monitor client to hash");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
||||
if(pInst == NULL){
|
||||
if (pInst == NULL) {
|
||||
tscError("failed to get app instance by cluster id");
|
||||
pMonitor = NULL;
|
||||
goto fail;
|
||||
}
|
||||
pMonitor->timer = taosTmrStart(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, (void*)pMonitor, monitorTimer);
|
||||
if(pMonitor->timer == NULL){
|
||||
pMonitor->timer =
|
||||
taosTmrStart(reportSendProcess, pInst->monitorParas.tsMonitorInterval * 1000, (void*)pMonitor, monitorTimer);
|
||||
if (pMonitor->timer == NULL) {
|
||||
tscError("failed to start timer");
|
||||
goto fail;
|
||||
}
|
||||
tscInfo("[monitor] monitorCreateClient for %"PRIx64 "finished %p.", clusterId, pMonitor);
|
||||
tscInfo("[monitor] monitorCreateClient for %" PRIx64 "finished %p.", clusterId, pMonitor);
|
||||
}
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
if (-1 != atomic_val_compare_exchange_32(&monitorFlag, -1, 0)) {
|
||||
|
@ -283,7 +289,8 @@ fail:
|
|||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* help, size_t label_key_count, const char** label_keys) {
|
||||
void monitorCreateClientCounter(int64_t clusterId, const char* name, const char* help, size_t label_key_count,
|
||||
const char** label_keys) {
|
||||
taosWLockLatch(&monitorLock);
|
||||
MonitorClient** ppMonitor = (MonitorClient**)taosHashGet(monitorCounterHash, &clusterId, LONG_BYTES);
|
||||
if (ppMonitor == NULL || *ppMonitor == NULL) {
|
||||
|
@ -291,16 +298,16 @@ void monitorCreateClientCounter(int64_t clusterId, const char* name, const char*
|
|||
goto end;
|
||||
}
|
||||
taos_counter_t* newCounter = taos_counter_new(name, help, label_key_count, label_keys);
|
||||
if (newCounter == NULL)
|
||||
return;
|
||||
MonitorClient* pMonitor = *ppMonitor;
|
||||
if (newCounter == NULL) return;
|
||||
MonitorClient* pMonitor = *ppMonitor;
|
||||
taos_collector_add_metric(pMonitor->colector, newCounter);
|
||||
if(taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0){
|
||||
if (taosHashPut(pMonitor->counters, name, strlen(name), &newCounter, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put counter to monitor");
|
||||
taos_counter_destroy(newCounter);
|
||||
goto end;
|
||||
}
|
||||
tscInfo("[monitor] monitorCreateClientCounter %"PRIx64"(%p):%s : %p.", pMonitor->clusterId, pMonitor, name, newCounter);
|
||||
tscInfo("[monitor] monitorCreateClientCounter %" PRIx64 "(%p):%s : %p.", pMonitor->clusterId, pMonitor, name,
|
||||
newCounter);
|
||||
|
||||
end:
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
|
@ -315,18 +322,18 @@ void monitorCounterInc(int64_t clusterId, const char* counterName, const char**
|
|||
|
||||
MonitorClient** ppMonitor = (MonitorClient**)taosHashGet(monitorCounterHash, &clusterId, LONG_BYTES);
|
||||
if (ppMonitor == NULL || *ppMonitor == NULL) {
|
||||
tscError("monitorCounterInc not found pMonitor %"PRId64, clusterId);
|
||||
tscError("monitorCounterInc not found pMonitor %" PRId64, clusterId);
|
||||
goto end;
|
||||
}
|
||||
|
||||
MonitorClient* pMonitor = *ppMonitor;
|
||||
taos_counter_t** ppCounter = (taos_counter_t**)taosHashGet(pMonitor->counters, counterName, strlen(counterName));
|
||||
if (ppCounter == NULL || *ppCounter == NULL) {
|
||||
tscError("monitorCounterInc not found pCounter %"PRIx64":%s.", clusterId, counterName);
|
||||
tscError("monitorCounterInc not found pCounter %" PRIx64 ":%s.", clusterId, counterName);
|
||||
goto end;
|
||||
}
|
||||
taos_counter_inc(*ppCounter, label_values);
|
||||
tscDebug("[monitor] monitorCounterInc %"PRIx64"(%p):%s", pMonitor->clusterId, pMonitor, counterName);
|
||||
tscDebug("[monitor] monitorCounterInc %" PRIx64 "(%p):%s", pMonitor->clusterId, pMonitor, counterName);
|
||||
|
||||
end:
|
||||
taosWUnLockLatch(&monitorLock);
|
||||
|
@ -339,13 +346,13 @@ const char* monitorResultStr(SQL_RESULT_CODE code) {
|
|||
|
||||
static void monitorThreadFuncUnexpectedStopped(void) { atomic_store_32(&slowLogFlag, -1); }
|
||||
|
||||
static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpPath){
|
||||
static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char* tmpPath) {
|
||||
TdFilePtr pFile = NULL;
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES);
|
||||
if (tmp == NULL){
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES);
|
||||
if (tmp == NULL) {
|
||||
char path[PATH_MAX] = {0};
|
||||
char clusterId[32] = {0};
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRIx64, slowLogData->clusterId) < 0){
|
||||
if (snprintf(clusterId, sizeof(clusterId), "%" PRIx64, slowLogData->clusterId) < 0) {
|
||||
tscError("failed to generate clusterId:%" PRIx64, slowLogData->clusterId);
|
||||
return;
|
||||
}
|
||||
|
@ -358,8 +365,8 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpP
|
|||
return;
|
||||
}
|
||||
|
||||
SlowLogClient *pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
|
||||
if (pClient == NULL){
|
||||
SlowLogClient* pClient = taosMemoryCalloc(1, sizeof(SlowLogClient));
|
||||
if (pClient == NULL) {
|
||||
tscError("failed to allocate memory for slow log client");
|
||||
taosCloseFile(&pFile);
|
||||
return;
|
||||
|
@ -368,58 +375,58 @@ static void monitorWriteSlowLog2File(MonitorSlowLogData* slowLogData, char *tmpP
|
|||
strcpy(pClient->path, path);
|
||||
pClient->offset = 0;
|
||||
pClient->pFile = pFile;
|
||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0){
|
||||
if (taosHashPut(monitorSlowLogHash, &slowLogData->clusterId, LONG_BYTES, &pClient, POINTER_BYTES) != 0) {
|
||||
tscError("failed to put clusterId:%" PRId64 " to hash table", slowLogData->clusterId);
|
||||
taosCloseFile(&pFile);
|
||||
taosMemoryFree(pClient);
|
||||
return;
|
||||
}
|
||||
|
||||
if(taosLockFile(pFile) < 0){
|
||||
if (taosLockFile(pFile) < 0) {
|
||||
tscError("failed to lock file:%p since %s", pFile, terrstr());
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
pFile = (*(SlowLogClient**)tmp)->pFile;
|
||||
}
|
||||
|
||||
if(taosLSeekFile(pFile, 0, SEEK_END) < 0){
|
||||
if (taosLSeekFile(pFile, 0, SEEK_END) < 0) {
|
||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
||||
return;
|
||||
}
|
||||
if (taosWriteFile(pFile, slowLogData->data, strlen(slowLogData->data) + 1) < 0){
|
||||
if (taosWriteFile(pFile, slowLogData->data, strlen(slowLogData->data) + 1) < 0) {
|
||||
tscError("failed to write len to file:%p since %s", pFile, terrstr());
|
||||
}
|
||||
tscDebug("[monitor] write slow log to file:%p, clusterId:%"PRIx64, pFile, slowLogData->clusterId);
|
||||
tscDebug("[monitor] write slow log to file:%p, clusterId:%" PRIx64, pFile, slowLogData->clusterId);
|
||||
}
|
||||
|
||||
static char* readFile(TdFilePtr pFile, int64_t *offset, int64_t size){
|
||||
tscDebug("[monitor] readFile slow begin pFile:%p, offset:%"PRId64 ", size:%"PRId64, pFile, *offset, size);
|
||||
if(taosLSeekFile(pFile, *offset, SEEK_SET) < 0){
|
||||
static char* readFile(TdFilePtr pFile, int64_t* offset, int64_t size) {
|
||||
tscDebug("[monitor] readFile slow begin pFile:%p, offset:%" PRId64 ", size:%" PRId64, pFile, *offset, size);
|
||||
if (taosLSeekFile(pFile, *offset, SEEK_SET) < 0) {
|
||||
tscError("failed to seek file:%p code: %d", pFile, errno);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ASSERT(size > *offset);
|
||||
char* pCont = NULL;
|
||||
char* pCont = NULL;
|
||||
int64_t totalSize = 0;
|
||||
if (size - *offset >= SLOW_LOG_SEND_SIZE_MAX) {
|
||||
pCont = taosMemoryCalloc(1, 4 + SLOW_LOG_SEND_SIZE_MAX); //4 reserved for []
|
||||
pCont = taosMemoryCalloc(1, 4 + SLOW_LOG_SEND_SIZE_MAX); // 4 reserved for []
|
||||
totalSize = 4 + SLOW_LOG_SEND_SIZE_MAX;
|
||||
}else{
|
||||
} else {
|
||||
pCont = taosMemoryCalloc(1, 4 + (size - *offset));
|
||||
totalSize = 4 + (size - *offset);
|
||||
}
|
||||
|
||||
if(pCont == NULL){
|
||||
if (pCont == NULL) {
|
||||
tscError("failed to allocate memory for slow log, size:%" PRId64, totalSize);
|
||||
return NULL;
|
||||
}
|
||||
char* buf = pCont;
|
||||
char* buf = pCont;
|
||||
strcat(buf++, "[");
|
||||
int64_t readSize = taosReadFile(pFile, buf, SLOW_LOG_SEND_SIZE_MAX);
|
||||
if (readSize <= 0) {
|
||||
if (readSize < 0){
|
||||
if (readSize < 0) {
|
||||
tscError("failed to read len from file:%p since %s", pFile, terrstr());
|
||||
}
|
||||
taosMemoryFree(pCont);
|
||||
|
@ -427,24 +434,24 @@ static char* readFile(TdFilePtr pFile, int64_t *offset, int64_t size){
|
|||
}
|
||||
|
||||
totalSize = 0;
|
||||
while(1){
|
||||
while (1) {
|
||||
size_t len = strlen(buf);
|
||||
totalSize += (len+1);
|
||||
totalSize += (len + 1);
|
||||
if (totalSize > readSize || len == 0) {
|
||||
*(buf-1) = ']';
|
||||
*(buf - 1) = ']';
|
||||
*buf = '\0';
|
||||
break;
|
||||
}
|
||||
buf[len] = ','; // replace '\0' with ','
|
||||
buf[len] = ','; // replace '\0' with ','
|
||||
buf += (len + 1);
|
||||
*offset += (len+1);
|
||||
*offset += (len + 1);
|
||||
}
|
||||
|
||||
tscDebug("[monitor] readFile slow log end, data:%s, offset:%"PRId64, pCont, *offset);
|
||||
tscDebug("[monitor] readFile slow log end, data:%s, offset:%" PRId64, pCont, *offset);
|
||||
return pCont;
|
||||
}
|
||||
|
||||
static int64_t getFileSize(char* path){
|
||||
static int64_t getFileSize(char* path) {
|
||||
int64_t fileSize = 0;
|
||||
if (taosStatFile(path, &fileSize, NULL, NULL) < 0) {
|
||||
return -1;
|
||||
|
@ -453,13 +460,14 @@ static int64_t getFileSize(char* path){
|
|||
return fileSize;
|
||||
}
|
||||
|
||||
static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64_t offset, SLOW_LOG_QUEUE_TYPE type, char* fileName, void* pTransporter, SEpSet *epSet){
|
||||
if (data == NULL){
|
||||
static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64_t offset, SLOW_LOG_QUEUE_TYPE type,
|
||||
char* fileName, void* pTransporter, SEpSet* epSet) {
|
||||
if (data == NULL) {
|
||||
taosMemoryFree(fileName);
|
||||
return -1;
|
||||
}
|
||||
MonitorSlowLogData* pParam = taosMemoryMalloc(sizeof(MonitorSlowLogData));
|
||||
if(pParam == NULL){
|
||||
if (pParam == NULL) {
|
||||
taosMemoryFree(data);
|
||||
taosMemoryFree(fileName);
|
||||
return -1;
|
||||
|
@ -473,121 +481,124 @@ static int32_t sendSlowLog(int64_t clusterId, char* data, TdFilePtr pFile, int64
|
|||
return sendReport(pTransporter, epSet, data, MONITOR_TYPE_SLOW_LOG, pParam);
|
||||
}
|
||||
|
||||
static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offset, int64_t size, SLOW_LOG_QUEUE_TYPE type, char* fileName){
|
||||
static int32_t monitorReadSend(int64_t clusterId, TdFilePtr pFile, int64_t* offset, int64_t size,
|
||||
SLOW_LOG_QUEUE_TYPE type, char* fileName) {
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(clusterId);
|
||||
if(pInst == NULL){
|
||||
if (pInst == NULL) {
|
||||
tscError("failed to get app instance by clusterId:%" PRId64, clusterId);
|
||||
return -1;
|
||||
}
|
||||
SEpSet ep = getEpSet_s(&pInst->mgmtEp);
|
||||
char* data = readFile(pFile, offset, size);
|
||||
return sendSlowLog(clusterId, data, (type == SLOW_LOG_READ_BEGINNIG ? pFile : NULL), *offset, type, fileName, pInst->pTransporter, &ep);
|
||||
char* data = readFile(pFile, offset, size);
|
||||
return sendSlowLog(clusterId, data, (type == SLOW_LOG_READ_BEGINNIG ? pFile : NULL), *offset, type, fileName,
|
||||
pInst->pTransporter, &ep);
|
||||
}
|
||||
|
||||
static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, TdFilePtr pFile, int64_t offset){
|
||||
int64_t size = getFileSize(*fileName);
|
||||
if(size <= offset){
|
||||
static void monitorSendSlowLogAtBeginning(int64_t clusterId, char** fileName, TdFilePtr pFile, int64_t offset) {
|
||||
int64_t size = getFileSize(*fileName);
|
||||
if (size <= offset) {
|
||||
processFileInTheEnd(pFile, *fileName);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning delete file:%s", *fileName);
|
||||
}else{
|
||||
} else {
|
||||
int32_t code = monitorReadSend(clusterId, pFile, &offset, size, SLOW_LOG_READ_BEGINNIG, *fileName);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log clusterId:%"PRId64",ret:%d", clusterId, code);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtBeginning send slow log clusterId:%" PRId64 ",ret:%d", clusterId, code);
|
||||
*fileName = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void monitorSendSlowLogAtRunning(int64_t clusterId){
|
||||
static void monitorSendSlowLogAtRunning(int64_t clusterId) {
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &clusterId, LONG_BYTES);
|
||||
if (tmp == NULL){
|
||||
if (tmp == NULL) {
|
||||
return;
|
||||
}
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)tmp);
|
||||
if (pClient == NULL){
|
||||
if (pClient == NULL) {
|
||||
return;
|
||||
}
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if(size <= pClient->offset){
|
||||
if(taosFtruncateFile(pClient->pFile, 0) < 0){
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if (size <= pClient->offset) {
|
||||
if (taosFtruncateFile(pClient->pFile, 0) < 0) {
|
||||
tscError("failed to truncate file:%p code: %d", pClient->pFile, errno);
|
||||
}
|
||||
tscDebug("[monitor] monitorSendSlowLogAtRunning truncate file to 0 file:%p", pClient->pFile);
|
||||
pClient->offset = 0;
|
||||
}else{
|
||||
} else {
|
||||
int32_t code = monitorReadSend(clusterId, pClient->pFile, &pClient->offset, size, SLOW_LOG_READ_RUNNING, NULL);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtRunning send slow log clusterId:%"PRId64",ret:%d", clusterId, code);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtRunning send slow log clusterId:%" PRId64 ",ret:%d", clusterId, code);
|
||||
}
|
||||
}
|
||||
|
||||
static bool monitorSendSlowLogAtQuit(int64_t clusterId) {
|
||||
void* tmp = taosHashGet(monitorSlowLogHash, &clusterId, LONG_BYTES);
|
||||
if (tmp == NULL){
|
||||
if (tmp == NULL) {
|
||||
return true;
|
||||
}
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)tmp);
|
||||
if (pClient == NULL){
|
||||
if (pClient == NULL) {
|
||||
return true;
|
||||
}
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if(size <= pClient->offset){
|
||||
if (size <= pClient->offset) {
|
||||
processFileInTheEnd(pClient->pFile, pClient->path);
|
||||
pClient->pFile = NULL;
|
||||
tscInfo("[monitor] monitorSendSlowLogAtQuit remove file:%s", pClient->path);
|
||||
if((--quitCnt) == 0){
|
||||
if ((--quitCnt) == 0) {
|
||||
return true;
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
int32_t code = monitorReadSend(clusterId, pClient->pFile, &pClient->offset, size, SLOW_LOG_READ_QUIT, NULL);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtQuit send slow log clusterId:%"PRId64",ret:%d", clusterId, code);
|
||||
tscDebug("[monitor] monitorSendSlowLogAtQuit send slow log clusterId:%" PRId64 ",ret:%d", clusterId, code);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
static void monitorSendAllSlowLogAtQuit(){
|
||||
static void monitorSendAllSlowLogAtQuit() {
|
||||
void* pIter = NULL;
|
||||
while ((pIter = taosHashIterate(monitorSlowLogHash, pIter))) {
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)pIter);
|
||||
if(pClient == NULL) {
|
||||
if (pClient == NULL) {
|
||||
continue;
|
||||
}
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if(size <= pClient->offset){
|
||||
if (size <= pClient->offset) {
|
||||
processFileInTheEnd(pClient->pFile, pClient->path);
|
||||
pClient->pFile = NULL;
|
||||
}else if(pClient->offset == 0){
|
||||
} else if (pClient->offset == 0) {
|
||||
int64_t* clusterId = (int64_t*)taosHashGetKey(pIter, NULL);
|
||||
int32_t code = monitorReadSend(*clusterId, pClient->pFile, &pClient->offset, size, SLOW_LOG_READ_QUIT, NULL);
|
||||
tscDebug("[monitor] monitorSendAllSlowLogAtQuit send slow log clusterId:%"PRId64",ret:%d", *clusterId, code);
|
||||
if (code == 0){
|
||||
quitCnt ++;
|
||||
int32_t code = monitorReadSend(*clusterId, pClient->pFile, &pClient->offset, size, SLOW_LOG_READ_QUIT, NULL);
|
||||
tscDebug("[monitor] monitorSendAllSlowLogAtQuit send slow log clusterId:%" PRId64 ",ret:%d", *clusterId, code);
|
||||
if (code == 0) {
|
||||
quitCnt++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void processFileRemoved(SlowLogClient* pClient){
|
||||
static void processFileRemoved(SlowLogClient* pClient) {
|
||||
taosUnLockFile(pClient->pFile);
|
||||
taosCloseFile(&(pClient->pFile));
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
TdFilePtr pFile =
|
||||
taosOpenFile(pClient->path, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND | TD_FILE_READ | TD_FILE_TRUNC);
|
||||
if (pFile == NULL) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("failed to open file:%s since %s", pClient->path, terrstr());
|
||||
}else{
|
||||
} else {
|
||||
pClient->pFile = pFile;
|
||||
}
|
||||
}
|
||||
|
||||
static void monitorSendAllSlowLog(){
|
||||
static void monitorSendAllSlowLog() {
|
||||
int64_t t = taosGetMonoTimestampMs();
|
||||
void* pIter = NULL;
|
||||
void* pIter = NULL;
|
||||
while ((pIter = taosHashIterate(monitorSlowLogHash, pIter))) {
|
||||
int64_t* clusterId = (int64_t*)taosHashGetKey(pIter, NULL);
|
||||
SAppInstInfo* pInst = getAppInstByClusterId(*clusterId);
|
||||
SlowLogClient* pClient = (*(SlowLogClient**)pIter);
|
||||
if (pClient == NULL){
|
||||
if (pClient == NULL) {
|
||||
taosHashCancelIterate(monitorSlowLogHash, pIter);
|
||||
return;
|
||||
}
|
||||
if (t - pClient->lastCheckTime > pInst->monitorParas.tsMonitorInterval * 1000){
|
||||
if (t - pClient->lastCheckTime > pInst->monitorParas.tsMonitorInterval * 1000) {
|
||||
pClient->lastCheckTime = t;
|
||||
} else {
|
||||
continue;
|
||||
|
@ -595,35 +606,35 @@ static void monitorSendAllSlowLog(){
|
|||
|
||||
if (pInst != NULL && pClient->offset == 0) {
|
||||
int64_t size = getFileSize(pClient->path);
|
||||
if(size <= 0){
|
||||
if(size < 0){
|
||||
if (size <= 0) {
|
||||
if (size < 0) {
|
||||
tscError("[monitor] monitorSendAllSlowLog failed to get file size:%s, err:%d", pClient->path, errno);
|
||||
if(errno == ENOENT){
|
||||
if (errno == ENOENT) {
|
||||
processFileRemoved(pClient);
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
int32_t code = monitorReadSend(*clusterId, pClient->pFile, &pClient->offset, size, SLOW_LOG_READ_RUNNING, NULL);
|
||||
tscDebug("[monitor] monitorSendAllSlowLog send slow log clusterId:%"PRId64",ret:%d", *clusterId, code);
|
||||
tscDebug("[monitor] monitorSendAllSlowLog send slow log clusterId:%" PRId64 ",ret:%d", *clusterId, code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void monitorSendAllSlowLogFromTempDir(int64_t clusterId){
|
||||
static void monitorSendAllSlowLogFromTempDir(int64_t clusterId) {
|
||||
SAppInstInfo* pInst = getAppInstByClusterId((int64_t)clusterId);
|
||||
|
||||
if(pInst == NULL || !pInst->monitorParas.tsEnableMonitor){
|
||||
if (pInst == NULL || !pInst->monitorParas.tsEnableMonitor) {
|
||||
tscInfo("[monitor] monitor is disabled, skip send slow log");
|
||||
return;
|
||||
}
|
||||
char namePrefix[PATH_MAX] = {0};
|
||||
if (snprintf(namePrefix, sizeof(namePrefix), "%s%"PRIx64, TD_TMP_FILE_PREFIX, clusterId) < 0) {
|
||||
if (snprintf(namePrefix, sizeof(namePrefix), "%s%" PRIx64, TD_TMP_FILE_PREFIX, clusterId) < 0) {
|
||||
tscError("failed to generate slow log file name prefix");
|
||||
return;
|
||||
}
|
||||
|
||||
char tmpPath[PATH_MAX] = {0};
|
||||
char tmpPath[PATH_MAX] = {0};
|
||||
if (getSlowLogTmpDir(tmpPath, sizeof(tmpPath)) < 0) {
|
||||
return;
|
||||
}
|
||||
|
@ -639,11 +650,9 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId){
|
|||
continue;
|
||||
}
|
||||
|
||||
char *name = taosGetDirEntryName(de);
|
||||
if (strcmp(name, ".") == 0 ||
|
||||
strcmp(name, "..") == 0 ||
|
||||
strstr(name, namePrefix) == NULL) {
|
||||
tscInfo("skip file:%s, for cluster id:%"PRIx64, name, clusterId);
|
||||
char* name = taosGetDirEntryName(de);
|
||||
if (strcmp(name, ".") == 0 || strcmp(name, "..") == 0 || strstr(name, namePrefix) == NULL) {
|
||||
tscInfo("skip file:%s, for cluster id:%" PRIx64, name, clusterId);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -659,7 +668,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId){
|
|||
taosCloseFile(&pFile);
|
||||
continue;
|
||||
}
|
||||
char *tmp = taosStrdup(filename);
|
||||
char* tmp = taosStrdup(filename);
|
||||
monitorSendSlowLogAtBeginning(clusterId, &tmp, pFile, 0);
|
||||
taosMemoryFree(tmp);
|
||||
}
|
||||
|
@ -667,7 +676,7 @@ static void monitorSendAllSlowLogFromTempDir(int64_t clusterId){
|
|||
taosCloseDir(&pDir);
|
||||
}
|
||||
|
||||
static void* monitorThreadFunc(void *param){
|
||||
static void* monitorThreadFunc(void* param) {
|
||||
setThreadName("client-monitor-slowlog");
|
||||
|
||||
#ifdef WINDOWS
|
||||
|
@ -680,18 +689,18 @@ static void* monitorThreadFunc(void *param){
|
|||
return NULL;
|
||||
}
|
||||
tscDebug("monitorThreadFunc start");
|
||||
int64_t quitTime = 0;
|
||||
int64_t quitTime = 0;
|
||||
while (1) {
|
||||
if (atomic_load_32(&slowLogFlag) > 0 > 0) {
|
||||
if(quitCnt == 0){
|
||||
if (atomic_load_32(&slowLogFlag) > 0) {
|
||||
if (quitCnt == 0) {
|
||||
monitorSendAllSlowLogAtQuit();
|
||||
if(quitCnt == 0){
|
||||
if (quitCnt == 0) {
|
||||
tscInfo("monitorThreadFunc quit since no slow log to send");
|
||||
break;
|
||||
}
|
||||
quitTime = taosGetMonoTimestampMs();
|
||||
}
|
||||
if(taosGetMonoTimestampMs() - quitTime > 500){ //quit at most 500ms
|
||||
if (taosGetMonoTimestampMs() - quitTime > 500) { // quit at most 500ms
|
||||
tscInfo("monitorThreadFunc quit since timeout");
|
||||
break;
|
||||
}
|
||||
|
@ -700,18 +709,19 @@ static void* monitorThreadFunc(void *param){
|
|||
MonitorSlowLogData* slowLogData = NULL;
|
||||
taosReadQitem(monitorQueue, (void**)&slowLogData);
|
||||
if (slowLogData != NULL) {
|
||||
if (slowLogData->type == SLOW_LOG_READ_BEGINNIG){
|
||||
if(slowLogData->pFile != NULL){
|
||||
monitorSendSlowLogAtBeginning(slowLogData->clusterId, &(slowLogData->fileName), slowLogData->pFile, slowLogData->offset);
|
||||
}else{
|
||||
if (slowLogData->type == SLOW_LOG_READ_BEGINNIG) {
|
||||
if (slowLogData->pFile != NULL) {
|
||||
monitorSendSlowLogAtBeginning(slowLogData->clusterId, &(slowLogData->fileName), slowLogData->pFile,
|
||||
slowLogData->offset);
|
||||
} else {
|
||||
monitorSendAllSlowLogFromTempDir(slowLogData->clusterId);
|
||||
}
|
||||
} else if(slowLogData->type == SLOW_LOG_WRITE){
|
||||
} else if (slowLogData->type == SLOW_LOG_WRITE) {
|
||||
monitorWriteSlowLog2File(slowLogData, tmpSlowLogPath);
|
||||
} else if(slowLogData->type == SLOW_LOG_READ_RUNNING){
|
||||
} else if (slowLogData->type == SLOW_LOG_READ_RUNNING) {
|
||||
monitorSendSlowLogAtRunning(slowLogData->clusterId);
|
||||
} else if(slowLogData->type == SLOW_LOG_READ_QUIT){
|
||||
if(monitorSendSlowLogAtQuit(slowLogData->clusterId)){
|
||||
} else if (slowLogData->type == SLOW_LOG_READ_QUIT) {
|
||||
if (monitorSendSlowLogAtQuit(slowLogData->clusterId)) {
|
||||
tscInfo("monitorThreadFunc quit since all slow log sended");
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
|
@ -757,8 +767,11 @@ static void tscMonitorStop() {
|
|||
}
|
||||
|
||||
int32_t monitorInit() {
|
||||
int32_t code;
|
||||
|
||||
tscInfo("[monitor] tscMonitor init");
|
||||
monitorCounterHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
monitorCounterHash =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorCounterHash == NULL) {
|
||||
tscError("failed to create monitorCounterHash");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -766,7 +779,8 @@ int32_t monitorInit() {
|
|||
}
|
||||
taosHashSetFreeFp(monitorCounterHash, destroyMonitorClient);
|
||||
|
||||
monitorSlowLogHash = (SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
monitorSlowLogHash =
|
||||
(SHashObj*)taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_ENTRY_LOCK);
|
||||
if (monitorSlowLogHash == NULL) {
|
||||
tscError("failed to create monitorSlowLogHash");
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -781,15 +795,14 @@ int32_t monitorInit() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath)) < 0){
|
||||
if (getSlowLogTmpDir(tmpSlowLogPath, sizeof(tmpSlowLogPath)) < 0) {
|
||||
terrno = TSDB_CODE_TSC_INTERNAL_ERROR;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (taosMulModeMkDir(tmpSlowLogPath, 0777, true) != 0) {
|
||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||
tscError("failed to create dir:%s since %s", tmpSlowLogPath, terrstr());
|
||||
return -1;
|
||||
return terrno;
|
||||
}
|
||||
|
||||
if (tsem2_init(&monitorSem, 0, 0) != 0) {
|
||||
|
@ -798,14 +811,15 @@ int32_t monitorInit() {
|
|||
return -1;
|
||||
}
|
||||
|
||||
monitorQueue = taosOpenQueue();
|
||||
if(monitorQueue == NULL){
|
||||
code = taosOpenQueue(&monitorQueue);
|
||||
if (code) {
|
||||
terrno = code;
|
||||
tscError("open queue error since %s", terrstr());
|
||||
return -1;
|
||||
}
|
||||
|
||||
taosInitRWLatch(&monitorLock);
|
||||
if (tscMonitortInit() != 0){
|
||||
if (tscMonitortInit() != 0) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
@ -828,21 +842,26 @@ void monitorClose() {
|
|||
taosWUnLockLatch(&monitorLock);
|
||||
}
|
||||
|
||||
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data){
|
||||
int32_t monitorPutData2MonitorQueue(MonitorSlowLogData data) {
|
||||
int32_t code;
|
||||
MonitorSlowLogData* slowLogData;
|
||||
|
||||
if (atomic_load_32(&slowLogFlag) == -2) {
|
||||
tscError("[monitor] slow log thread is exiting");
|
||||
return -1;
|
||||
}
|
||||
MonitorSlowLogData* slowLogData = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0);
|
||||
if (slowLogData == NULL) {
|
||||
|
||||
code = taosAllocateQitem(sizeof(MonitorSlowLogData), DEF_QITEM, 0, (void**)&slowLogData);
|
||||
if (code) {
|
||||
tscError("[monitor] failed to allocate slow log data");
|
||||
return -1;
|
||||
return terrno = code;
|
||||
}
|
||||
*slowLogData = data;
|
||||
tscDebug("[monitor] write slow log to queue, clusterId:%"PRIx64 " type:%s, data:%s", slowLogData->clusterId, queueTypeStr[slowLogData->type], slowLogData->data);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0){
|
||||
tscDebug("[monitor] write slow log to queue, clusterId:%" PRIx64 " type:%s, data:%s", slowLogData->clusterId,
|
||||
queueTypeStr[slowLogData->type], slowLogData->data);
|
||||
if (taosWriteQitem(monitorQueue, slowLogData) == 0) {
|
||||
tsem2_post(&monitorSem);
|
||||
}else{
|
||||
} else {
|
||||
monitorFreeSlowLogData(slowLogData);
|
||||
taosFreeQitem(slowLogData);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -29,29 +29,29 @@
|
|||
(start)++; \
|
||||
}
|
||||
|
||||
static char *smlJsonGetObj(char *payload) {
|
||||
static int32_t smlJsonGetObj(char **payload) {
|
||||
int leftBracketCnt = 0;
|
||||
bool isInQuote = false;
|
||||
while (*payload) {
|
||||
if (*payload == '"' && *(payload - 1) != '\\') {
|
||||
while (**payload) {
|
||||
if (**payload == '"' && *((*payload) - 1) != '\\') {
|
||||
isInQuote = !isInQuote;
|
||||
} else if (!isInQuote && unlikely(*payload == '{')) {
|
||||
} else if (!isInQuote && unlikely(**payload == '{')) {
|
||||
leftBracketCnt++;
|
||||
payload++;
|
||||
(*payload)++;
|
||||
continue;
|
||||
} else if (!isInQuote && unlikely(*payload == '}')) {
|
||||
} else if (!isInQuote && unlikely(**payload == '}')) {
|
||||
leftBracketCnt--;
|
||||
payload++;
|
||||
(*payload)++;
|
||||
if (leftBracketCnt == 0) {
|
||||
return payload;
|
||||
return 0;
|
||||
} else if (leftBracketCnt < 0) {
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
payload++;
|
||||
(*payload)++;
|
||||
}
|
||||
return NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset) {
|
||||
|
@ -99,8 +99,9 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
offset[index++] = *start - sTmp;
|
||||
element->timestamp = (*start);
|
||||
if (*(*start) == '{') {
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->timestampLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -127,8 +128,9 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
offset[index++] = *start - sTmp;
|
||||
element->cols = (*start);
|
||||
if (*(*start) == '{') {
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->colsLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -153,8 +155,9 @@ int smlJsonParseObjFirst(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
JUMP_JSON_SPACE((*start))
|
||||
offset[index++] = *start - sTmp;
|
||||
element->tags = (*start);
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->tagsLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -209,8 +212,9 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
(*start) += offset[index++];
|
||||
element->timestamp = *start;
|
||||
if (*(*start) == '{') {
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->timestampLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -227,8 +231,9 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
(*start) += offset[index++];
|
||||
element->cols = *start;
|
||||
if (*(*start) == '{') {
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->colsLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -244,8 +249,9 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
} else if ((*start)[1] == 't' && (*start)[2] == 'a') {
|
||||
(*start) += offset[index++];
|
||||
element->tags = (*start);
|
||||
char *tmp = smlJsonGetObj((*start));
|
||||
if (tmp) {
|
||||
char *tmp = *start;
|
||||
int32_t code = smlJsonGetObj(&tmp);
|
||||
if (code == 0) {
|
||||
element->tagsLen = tmp - (*start);
|
||||
*start = tmp;
|
||||
}
|
||||
|
@ -261,7 +267,7 @@ int smlJsonParseObj(char **start, SSmlLineInfo *element, int8_t *offset) {
|
|||
uError("elements != %d", OTD_JSON_FIELDS_NUM);
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static inline int32_t smlParseMetricFromJSON(SSmlHandle *info, cJSON *metric, SSmlLineInfo *elements) {
|
||||
|
@ -466,7 +472,11 @@ static int32_t smlParseValueFromJSON(cJSON *root, SSmlKv *kv) {
|
|||
break;
|
||||
}
|
||||
case cJSON_String: {
|
||||
smlConvertJSONString(kv, "binary", root);
|
||||
int32_t ret = smlConvertJSONString(kv, "binary", root);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
uError("OTD:Failed to parse binary value from JSON Obj");
|
||||
return ret;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case cJSON_Object: {
|
||||
|
@ -492,20 +502,17 @@ static int32_t smlProcessTagJson(SSmlHandle *info, cJSON *tags){
|
|||
int32_t tagNum = cJSON_GetArraySize(tags);
|
||||
if (unlikely(tagNum == 0)) {
|
||||
uError("SML:Tag should not be empty");
|
||||
terrno = TSDB_CODE_TSC_INVALID_JSON;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
for (int32_t i = 0; i < tagNum; ++i) {
|
||||
cJSON *tag = cJSON_GetArrayItem(tags, i);
|
||||
if (unlikely(tag == NULL)) {
|
||||
terrno = TSDB_CODE_TSC_INVALID_JSON;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
size_t keyLen = strlen(tag->string);
|
||||
if (unlikely(IS_INVALID_COL_LEN(keyLen))) {
|
||||
uError("OTD:Tag key length is 0 or too large than 64");
|
||||
terrno = TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
}
|
||||
|
||||
// add kv to SSmlKv
|
||||
|
@ -516,19 +523,19 @@ static int32_t smlProcessTagJson(SSmlHandle *info, cJSON *tags){
|
|||
// value
|
||||
int32_t ret = smlParseValueFromJSON(tag, &kv);
|
||||
if (unlikely(ret != TSDB_CODE_SUCCESS)) {
|
||||
terrno = ret;
|
||||
return -1;
|
||||
return ret;
|
||||
}
|
||||
if (taosArrayPush(preLineKV, &kv) == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosArrayPush(preLineKV, &kv);
|
||||
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo *elements) {
|
||||
|
@ -536,12 +543,18 @@ static int32_t smlParseTagsFromJSON(SSmlHandle *info, cJSON *tags, SSmlLineInfo
|
|||
if(info->dataFormat){
|
||||
ret = smlProcessSuperTable(info, elements);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if(info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
ret = smlProcessTagJson(info, tags);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if(info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
ret = smlJoinMeasureTag(elements);
|
||||
if(ret != 0){
|
||||
|
@ -703,6 +716,9 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
|
|||
// Parse tags
|
||||
bool needFree = info->dataFormat;
|
||||
elements->tags = cJSON_PrintUnformatted(tagsJson);
|
||||
if (elements->tags == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
elements->tagsLen = strlen(elements->tags);
|
||||
if (is_same_child_table_telnet(elements, &info->preLine) != 0) {
|
||||
ret = smlParseTagsFromJSON(info, tagsJson, elements);
|
||||
|
@ -729,7 +745,8 @@ static int32_t smlParseJSONStringExt(SSmlHandle *info, cJSON *root, SSmlLineInfo
|
|||
// notice!!! put ts back to tag to ensure get meta->precision
|
||||
int64_t ts = smlParseTSFromJSON(info, tsJson);
|
||||
if (unlikely(ts < 0)) {
|
||||
uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload", info->id);
|
||||
char* tmp = cJSON_PrintUnformatted(tsJson);
|
||||
uError("OTD:0x%" PRIx64 " Unable to parse timestamp from JSON payload %s %s %" PRId64, info->id, info->msgBuf.buf,tmp, ts);
|
||||
return TSDB_CODE_INVALID_TIMESTAMP;
|
||||
}
|
||||
SSmlKv kvTs = {0};
|
||||
|
@ -823,7 +840,7 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
|
|||
}
|
||||
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (unlikely(**start == '\0' && elements->measure == NULL)) return TSDB_CODE_SUCCESS;
|
||||
|
@ -844,18 +861,23 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
|
|||
cJSON *valueJson = cJSON_Parse(elements->cols);
|
||||
if (unlikely(valueJson == NULL)) {
|
||||
uError("SML:0x%" PRIx64 " parse json cols failed:%s", info->id, elements->cols);
|
||||
elements->cols[elements->colsLen] = tmp;
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
taosArrayPush(info->tagJsonArray, &valueJson);
|
||||
if (taosArrayPush(info->tagJsonArray, &valueJson) == NULL){
|
||||
cJSON_Delete(valueJson);
|
||||
elements->cols[elements->colsLen] = tmp;
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
ret = smlParseValueFromJSONObj(valueJson, &kv);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:Failed to parse value from JSON Obj:%s", elements->cols);
|
||||
uError("SML:0x%" PRIx64 " Failed to parse value from JSON Obj:%s", info->id, elements->cols);
|
||||
elements->cols[elements->colsLen] = tmp;
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
}
|
||||
elements->cols[elements->colsLen] = tmp;
|
||||
} else if (smlParseValue(&kv, &info->msgBuf) != TSDB_CODE_SUCCESS) {
|
||||
uError("SML:cols invalidate:%s", elements->cols);
|
||||
uError("SML:0x%" PRIx64 " cols invalidate:%s", info->id, elements->cols);
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
@ -870,7 +892,11 @@ static int32_t smlParseJSONString(SSmlHandle *info, char **start, SSmlLineInfo *
|
|||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
|
||||
taosArrayPush(info->tagJsonArray, &tagsJson);
|
||||
if (taosArrayPush(info->tagJsonArray, &tagsJson) == NULL){
|
||||
cJSON_Delete(tagsJson);
|
||||
uError("SML:0x%" PRIx64 " taosArrayPush failed", info->id);
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
ret = smlParseTagsFromJSON(info, tagsJson, elements);
|
||||
if (unlikely(ret)) {
|
||||
uError("OTD:0x%" PRIx64 " Unable to parse tags from JSON payload", info->id);
|
||||
|
@ -937,7 +963,7 @@ int32_t smlParseJSON(SSmlHandle *info, char *payload) {
|
|||
return ret;
|
||||
}
|
||||
info->lines = (SSmlLineInfo *)tmp;
|
||||
memset(info->lines + cnt, 0, (payloadNum - cnt) * sizeof(SSmlLineInfo));
|
||||
(void)memset(info->lines + cnt, 0, (payloadNum - cnt) * sizeof(SSmlLineInfo));
|
||||
}
|
||||
ret = smlParseJSONString(info, &dataPointStart, info->lines + cnt);
|
||||
if ((info->lines + cnt)->measure == NULL) break;
|
||||
|
|
|
@ -103,7 +103,10 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
return code;
|
||||
}
|
||||
char* tmp = taosMemoryCalloc(pVal->length, 1);
|
||||
memcpy(tmp, pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(tmp, pVal->value + NCHAR_ADD_LEN - 1, pVal->length - NCHAR_ADD_LEN);
|
||||
code = doGeomFromText(tmp, (unsigned char **)&pVal->value, &pVal->length);
|
||||
taosMemoryFree(tmp);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
|
@ -149,7 +152,7 @@ int32_t smlParseValue(SSmlKv *pVal, SSmlMsgBuf *msg) {
|
|||
if(data == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
memcpy(data, pVal->value + (NCHAR_ADD_LEN - 1), pVal->length);
|
||||
(void)memcpy(data, pVal->value + (NCHAR_ADD_LEN - 1), pVal->length);
|
||||
pVal->value = data;
|
||||
}
|
||||
|
||||
|
@ -212,8 +215,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
while (*sql < sqlEnd) {
|
||||
if (unlikely(IS_SPACE(*sql,escapeChar) || IS_COMMA(*sql,escapeChar))) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", *sql);
|
||||
terrno = TSDB_CODE_SML_INVALID_DATA;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
if (unlikely(IS_EQUAL(*sql,escapeChar))) {
|
||||
keyLen = *sql - key;
|
||||
|
@ -230,8 +232,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
|
||||
if (unlikely(IS_INVALID_COL_LEN(keyLen - keyLenEscaped))) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid key or key is too long than 64", key);
|
||||
terrno = TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
}
|
||||
|
||||
// parse value
|
||||
|
@ -245,8 +246,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
break;
|
||||
} else if (unlikely(IS_EQUAL(*sql,escapeChar))) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", *sql);
|
||||
terrno = TSDB_CODE_SML_INVALID_DATA;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (IS_SLASH_LETTER_IN_TAG_FIELD_KEY(*sql)) {
|
||||
|
@ -261,24 +261,28 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
|
||||
if (unlikely(valueLen == 0)) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", value);
|
||||
terrno = TSDB_CODE_SML_INVALID_DATA;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
|
||||
if (unlikely(valueLen - valueLenEscaped > (TSDB_MAX_NCHAR_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)) {
|
||||
terrno = TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
return -1;
|
||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
}
|
||||
|
||||
if (keyEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(keyLen);
|
||||
memcpy(tmp, key, keyLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(tmp, key, keyLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, keyLen);
|
||||
key = tmp;
|
||||
}
|
||||
if (valueEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(valueLen);
|
||||
memcpy(tmp, value, valueLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(tmp, value, valueLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, valueLen);
|
||||
value = tmp;
|
||||
}
|
||||
|
@ -289,11 +293,12 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
.length = valueLen,
|
||||
.keyEscaped = keyEscaped,
|
||||
.valueEscaped = valueEscaped};
|
||||
taosArrayPush(preLineKV, &kv);
|
||||
if(taosArrayPush(preLineKV, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_JSON;
|
||||
}
|
||||
|
||||
cnt++;
|
||||
|
@ -302,7 +307,7 @@ static int32_t smlProcessTagLine(SSmlHandle *info, char **sql, char *sqlEnd){
|
|||
}
|
||||
(*sql)++;
|
||||
}
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlParseTagLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlLineInfo *elements) {
|
||||
|
@ -315,13 +320,19 @@ static int32_t smlParseTagLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
if(info->dataFormat){
|
||||
ret = smlProcessSuperTable(info, elements);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if(info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = smlProcessTagLine(info, sql, sqlEnd);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if (info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return smlProcessChildTable(info, elements);
|
||||
|
@ -410,7 +421,10 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
|
||||
if (keyEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(kv.keyLen);
|
||||
memcpy(tmp, key, kv.keyLen);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(tmp, key, kv.keyLen);
|
||||
PROCESS_SLASH_IN_TAG_FIELD_KEY(tmp, kv.keyLen);
|
||||
kv.key = tmp;
|
||||
kv.keyEscaped = keyEscaped;
|
||||
|
@ -418,7 +432,10 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
|
||||
if (valueEscaped) {
|
||||
char *tmp = (char *)taosMemoryMalloc(kv.length);
|
||||
memcpy(tmp, kv.value, kv.length);
|
||||
if (tmp == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
(void)memcpy(tmp, kv.value, kv.length);
|
||||
PROCESS_SLASH_IN_FIELD_VALUE(tmp, kv.length);
|
||||
ASSERT(kv.type != TSDB_DATA_TYPE_GEOMETRY);
|
||||
if(kv.type == TSDB_DATA_TYPE_VARBINARY){
|
||||
|
@ -437,8 +454,13 @@ static int32_t smlParseColLine(SSmlHandle *info, char **sql, char *sqlEnd, SSmlL
|
|||
} else {
|
||||
if (currElement->colArray == NULL) {
|
||||
currElement->colArray = taosArrayInit_s(sizeof(SSmlKv), 1);
|
||||
if (currElement->colArray == NULL) {
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
}
|
||||
if (taosArrayPush(currElement->colArray, &kv) == NULL){ // reserve for timestamp
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
taosArrayPush(currElement->colArray, &kv); // reserve for timestamp
|
||||
}
|
||||
|
||||
cnt++;
|
||||
|
|
|
@ -84,8 +84,7 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
while (sql < sqlEnd) {
|
||||
if (unlikely(*sql == SPACE)) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||
terrno = TSDB_CODE_SML_INVALID_DATA;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
if (unlikely(*sql == EQUAL)) {
|
||||
keyLen = sql - key;
|
||||
|
@ -97,8 +96,7 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
|
||||
if (unlikely(IS_INVALID_COL_LEN(keyLen))) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid key or key is too long than 64", key);
|
||||
terrno = TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_COLUMN_LENGTH;
|
||||
}
|
||||
|
||||
// parse value
|
||||
|
@ -111,8 +109,7 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
}
|
||||
if (unlikely(*sql == EQUAL)) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid data", sql);
|
||||
terrno = TSDB_CODE_SML_INVALID_DATA;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
sql++;
|
||||
}
|
||||
|
@ -120,13 +117,11 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
|
||||
if (unlikely(valueLen == 0)) {
|
||||
smlBuildInvalidDataMsg(&info->msgBuf, "invalid value", value);
|
||||
terrno = TSDB_CODE_TSC_INVALID_VALUE;
|
||||
return -1;
|
||||
return TSDB_CODE_TSC_INVALID_VALUE;
|
||||
}
|
||||
|
||||
if (unlikely(valueLen > (TSDB_MAX_TAGS_LEN - VARSTR_HEADER_SIZE) / TSDB_NCHAR_SIZE)) {
|
||||
terrno = TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
return -1;
|
||||
return TSDB_CODE_PAR_INVALID_VAR_COLUMN_LEN;
|
||||
}
|
||||
|
||||
SSmlKv kv = {.key = key,
|
||||
|
@ -136,14 +131,15 @@ static int32_t smlProcessTagTelnet(SSmlHandle *info, char *data, char *sqlEnd){
|
|||
.length = valueLen,
|
||||
.keyEscaped = false,
|
||||
.valueEscaped = false};
|
||||
taosArrayPush(preLineKV, &kv);
|
||||
if (taosArrayPush(preLineKV, &kv) == NULL){
|
||||
return TSDB_CODE_OUT_OF_MEMORY;
|
||||
}
|
||||
if (info->dataFormat && !isSmlTagAligned(info, cnt, &kv)) {
|
||||
terrno = TSDB_CODE_SUCCESS;
|
||||
return -1;
|
||||
return TSDB_CODE_SML_INVALID_DATA;
|
||||
}
|
||||
cnt++;
|
||||
}
|
||||
return 0;
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SSmlLineInfo *elements) {
|
||||
|
@ -156,13 +152,19 @@ static int32_t smlParseTelnetTags(SSmlHandle *info, char *data, char *sqlEnd, SS
|
|||
if(info->dataFormat){
|
||||
ret = smlProcessSuperTable(info, elements);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if(info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
ret = smlProcessTagTelnet(info, data, sqlEnd);
|
||||
if(ret != 0){
|
||||
return terrno;
|
||||
if (info->reRun){
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = smlJoinMeasureTag(elements);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue