Merge pull request #29311 from taosdata/merge/3.0tomain
merge: from 3.0 to main branch
|
@ -2,7 +2,7 @@
|
||||||
# taosadapter
|
# taosadapter
|
||||||
ExternalProject_Add(taosadapter
|
ExternalProject_Add(taosadapter
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taos-tools
|
# taos-tools
|
||||||
ExternalProject_Add(taos-tools
|
ExternalProject_Add(taos-tools
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# taosws-rs
|
# taosws-rs
|
||||||
ExternalProject_Add(taosws-rs
|
ExternalProject_Add(taosws-rs
|
||||||
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
GIT_REPOSITORY https://github.com/taosdata/taos-connector-rust.git
|
||||||
GIT_TAG main
|
GIT_TAG 3.0
|
||||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||||
BINARY_DIR ""
|
BINARY_DIR ""
|
||||||
#BUILD_IN_SOURCE TRUE
|
#BUILD_IN_SOURCE TRUE
|
||||||
|
|
|
@ -166,6 +166,12 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 8. 创建完成
|
### 8. 异常处理策略
|
||||||
|
|
||||||
|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
|
<Contributing />
|
||||||
|
|
||||||
|
### 9. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 MQTT 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 MQTT 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -196,12 +196,16 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
||||||
|
|
||||||
### 8. 配置高级选项
|
### 8. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||

|
<AdvancedOptions/>
|
||||||
|
|
||||||

|
### 9. 异常处理策略
|
||||||
|
|
||||||
### 9. 创建完成
|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
|
<Contributing />
|
||||||
|
|
||||||
|
### 10. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 Kafka 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 Kafka 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -75,9 +75,9 @@ InfluxDB 是一种流行的开源时间序列数据库,它针对处理大量
|
||||||
|
|
||||||
### 6. 配置高级选项
|
### 6. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||

|
|
||||||

|
<AdvancedOptions/>
|
||||||
|
|
||||||
### 7. 创建完成
|
### 7. 创建完成
|
||||||
|
|
|
@ -58,9 +58,9 @@ OpenTSDB 是一个架构在 HBase 系统之上的实时监控信息收集和展
|
||||||
|
|
||||||
### 5. 配置高级选项
|
### 5. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||

|
|
||||||

|
<AdvancedOptions/>
|
||||||
|
|
||||||
### 6. 创建完成
|
### 6. 创建完成
|
||||||
|
|
|
@ -107,13 +107,25 @@ sidebar_label: "CSV"
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 5. 创建完成
|
### 5. 配置高级选项
|
||||||
|
|
||||||
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
|
<AdvancedOptions/>
|
||||||
|
|
||||||
|
### 6. 异常处理策略
|
||||||
|
|
||||||
|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
|
<Contributing />
|
||||||
|
|
||||||
|
### 7. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 CSV 到 TDengine 的数据同步任务,回到数据写入任务列表页面,可查看任务执行情况,也可以进行任务的“启动/停止”操作与“查看/编辑/删除/复制”操作。
|
点击 **提交** 按钮,完成创建 CSV 到 TDengine 的数据同步任务,回到数据写入任务列表页面,可查看任务执行情况,也可以进行任务的“启动/停止”操作与“查看/编辑/删除/复制”操作。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 6. 查看运行指标
|
### 8. 查看运行指标
|
||||||
|
|
||||||
点击 **查看** 按钮,查看任务的运行指标,同时也可以查看任务中所有文件的处理情况。
|
点击 **查看** 按钮,查看任务的运行指标,同时也可以查看任务中所有文件的处理情况。
|
||||||
|
|
|
@ -134,6 +134,12 @@ split 提取器,seperator 填写分割符 `,`, number 填写 2。
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
### 7. 创建完成
|
### 7. 异常处理策略
|
||||||
|
|
||||||
|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
|
<Contributing />
|
||||||
|
|
||||||
|
### 8. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建任务。提交任务后,回到**数据写入**页面可以查看任务状态。
|
点击 **提交** 按钮,完成创建任务。提交任务后,回到**数据写入**页面可以查看任务状态。
|
|
@ -98,14 +98,16 @@ MySQL 是最流行的关系型数据库之一。很多系统都曾经或正在
|
||||||
|
|
||||||
### 8. 配置高级选项
|
### 8. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
<AdvancedOptions/>
|
||||||
|
|
||||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
### 9. 异常处理策略
|
||||||
|
|
||||||

|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
### 9. 创建完成
|
<Contributing />
|
||||||
|
|
||||||
|
### 10. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 MySQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 MySQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -99,14 +99,16 @@ TDengine 可以高效地从 PostgreSQL 读取数据并将其写入 TDengine,
|
||||||
|
|
||||||
### 8. 配置高级选项
|
### 8. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
<AdvancedOptions/>
|
||||||
|
|
||||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
### 9. 异常处理策略
|
||||||
|
|
||||||

|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
### 9. 创建完成
|
<Contributing />
|
||||||
|
|
||||||
|
### 10. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 PostgreSQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 PostgreSQL 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -91,14 +91,16 @@ TDengine 可以高效地从 Oracle 读取数据并将其写入 TDengine,以实
|
||||||
|
|
||||||
### 7. 配置高级选项
|
### 7. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
<AdvancedOptions/>
|
||||||
|
|
||||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
### 8. 异常处理策略
|
||||||
|
|
||||||

|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
### 8. 创建完成
|
<Contributing />
|
||||||
|
|
||||||
|
### 9. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 Oracle 到 TDengine 的数据同步任务,回到**数据源列表****页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 Oracle 到 TDengine 的数据同步任务,回到**数据源列表****页面可查看任务执行情况。
|
|
@ -105,14 +105,16 @@ Microsoft SQL Server 是最流行的关系型数据库之一。很多系统都
|
||||||
|
|
||||||
### 8. 配置高级选项
|
### 8. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
<AdvancedOptions/>
|
||||||
|
|
||||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
### 9. 异常处理策略
|
||||||
|
|
||||||

|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
### 9. 创建完成
|
<Contributing />
|
||||||
|
|
||||||
|
### 10. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 Microsoft SQL Server 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 Microsoft SQL Server 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -122,14 +122,16 @@ MongoDB 是一个介于关系型数据库与非关系型数据库之间的产品
|
||||||
|
|
||||||
### 8. 配置高级选项
|
### 8. 配置高级选项
|
||||||
|
|
||||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||||
|
|
||||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
<AdvancedOptions/>
|
||||||
|
|
||||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
### 9. 异常处理策略
|
||||||
|
|
||||||

|
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||||
|
|
||||||
### 9. 创建完成
|
<Contributing />
|
||||||
|
|
||||||
|
### 10. 创建完成
|
||||||
|
|
||||||
点击 **提交** 按钮,完成创建 MongoDB 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
点击 **提交** 按钮,完成创建 MongoDB 到 TDengine 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -0,0 +1,7 @@
|
||||||
|
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||||
|
|
||||||
|
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||||
|
|
||||||
|
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||||
|
|
||||||
|

|
|
@ -0,0 +1,23 @@
|
||||||
|
异常处理策略区域是对数据异常时的处理策略进行配置,默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
各异常项说明及相应可选处理策略如下:
|
||||||
|
|
||||||
|
> 通用处理策略说明:
|
||||||
|
> 归档:将异常数据写入归档文件(默认路径为 `${data_dir}/tasks/_id/.datetime`),不写入目标库
|
||||||
|
> 丢弃:将异常数据忽略,不写入目标库
|
||||||
|
> 报错:任务报错
|
||||||
|
|
||||||
|
- **主键时间戳溢出** 检查数据中第一列时间戳是否在正确的时间范围内(now - keep1, now + 100y),可选处理策略:归档、丢弃、报错
|
||||||
|
- **主键时间戳空** 检查数据中第一列时间戳是否为空,可选处理策略:归档、丢弃、报错、使用当前时间
|
||||||
|
> 使用当前时间:使用当前时间填充到空的时间戳字段中
|
||||||
|
- **表名长度溢出** 检查子表表名的长度是否超出限制(最大 192 字符),可选处理策略:归档、丢弃、报错、截断、截断且归档
|
||||||
|
> 截断:截取原始表名的前 192 个字符作为新的表名
|
||||||
|
> 截断且归档:截取原始表名的前 192 个字符作为新的表名,并且将此行记录写入归档文件
|
||||||
|
- **表名非法字符** 检查子表表名中是否包含特殊字符(符号 `.` 等),可选处理策略:归档、丢弃、报错、非法字符替换为指定字符串
|
||||||
|
> 非法字符替换为指定字符串:将原始表名中的特殊字符替换为后方输入框中的指定字符串,例如 `a.b` 替换为 `a_b`
|
||||||
|
- **表名模板变量空值** 检查子表表名模板中的变量是否为空,可选处理策略:丢弃、留空、变量替换为指定字符串
|
||||||
|
> 留空:变量位置不做任何特殊处理,例如 `a_{x}` 转换为 `a_`
|
||||||
|
> 变量替换为指定字符串:变量位置使用后方输入框中的指定字符串,例如 `a_{x}` 转换为 `a_b`
|
||||||
|
- **列名长度溢出** 检查列名的长度是否超出限制(最大 64 字符),可选处理策略:归档、丢弃、报错
|
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 97 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 31 KiB |
|
@ -145,3 +145,47 @@ toasX 的配置文件(默认 /etc/taos/taosx.toml) 中与 monitor 相关的配
|
||||||
#### 限制
|
#### 限制
|
||||||
|
|
||||||
只有在以 server 模式运行 taosX 时,与监控相关的配置才生效。
|
只有在以 server 模式运行 taosX 时,与监控相关的配置才生效。
|
||||||
|
|
||||||
|
## explorer 集成监控面板
|
||||||
|
|
||||||
|
explorer 支持集成已有的 grafana dashboard。
|
||||||
|
|
||||||
|
### 配置 grafana
|
||||||
|
|
||||||
|
编辑 grafana.ini, 修改以下配置项。配置 root_url, 可能对现有的 grafana 使用习惯有所影响,为了集成到 explorer 是需要如此配置的, 方便通过 explorer 做服务代理。
|
||||||
|
|
||||||
|
``` toml
|
||||||
|
[server]
|
||||||
|
# If you use reverse proxy and sub path specify full url (with sub path)
|
||||||
|
root_url = http://ip:3000/grafana
|
||||||
|
# Serve Grafana from subpath specified in `root_url` setting. By default it is set to `false` for compatibility reasons.
|
||||||
|
serve_from_sub_path = true
|
||||||
|
|
||||||
|
[security]
|
||||||
|
# set to true if you want to allow browsers to render Grafana in a <frame>, <iframe>, <embed> or <object>. default is false.
|
||||||
|
allow_embedding = true
|
||||||
|
```
|
||||||
|
|
||||||
|
### 配置 Explorer
|
||||||
|
|
||||||
|
修改 explorer.toml, 其中 dashboard 配置的 url 中的 ip, 应该配置为可以通过 explorer 服务器能够访问到的 grafana 服务的内网地址。
|
||||||
|
|
||||||
|
``` toml
|
||||||
|
[grafana]
|
||||||
|
# The token of the Grafana server, which is used to access the Grafana server.
|
||||||
|
token = ""
|
||||||
|
|
||||||
|
# The URL of the Grafana dashboard, which is used to display the monitoring data of the TDengine cluster.
|
||||||
|
# You can configure multiple Grafana dashboards.
|
||||||
|
[grafana.dashboards]
|
||||||
|
TDengine3 = "http://ip:3000/d/000000001/tdengine3?theme=light&kiosk=tv"
|
||||||
|
taosX = "http://ip:3000/d/000000002/taosx?theme=light&kiosk=tv"
|
||||||
|
```
|
||||||
|
|
||||||
|
如下图(grafana V-8.5.27),获取 api key, 请注意添加只读权限的 apikey, 否则有安全风险。
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
如下图(grafana V-8.5.27),获取 dashboard url, 获取的 url 请额外加上参数:theme=light&kiosk=tv.
|
||||||
|
|
||||||
|

|
||||||
|
|
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 109 KiB |
|
@ -293,6 +293,7 @@ extern int32_t tsMaxStreamBackendCache;
|
||||||
extern int32_t tsPQSortMemThreshold;
|
extern int32_t tsPQSortMemThreshold;
|
||||||
extern int32_t tsResolveFQDNRetryTime;
|
extern int32_t tsResolveFQDNRetryTime;
|
||||||
extern bool tsStreamCoverage;
|
extern bool tsStreamCoverage;
|
||||||
|
extern int8_t tsS3EpNum;
|
||||||
|
|
||||||
extern bool tsExperimental;
|
extern bool tsExperimental;
|
||||||
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
// #define NEEDTO_COMPRESSS_MSG(size) (tsCompressMsgSize != -1 && (size) > tsCompressMsgSize)
|
||||||
|
|
|
@ -237,18 +237,20 @@ static FORCE_INLINE int32_t udfColDataSet(SUdfColumn *pColumn, uint32_t currentR
|
||||||
(void)memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
(void)memcpy(data->fixLenCol.data + meta->bytes * currentRow, pData, meta->bytes);
|
||||||
} else {
|
} else {
|
||||||
int32_t dataLen = varDataTLen(pData);
|
int32_t dataLen = varDataTLen(pData);
|
||||||
if (meta->type == TSDB_DATA_TYPE_JSON) {
|
// This is a piece of code to help users implement udf. It is only called during testing.
|
||||||
if (*pData == TSDB_DATA_TYPE_NULL) {
|
// Currently, the json type is not supported and will not be called.
|
||||||
dataLen = 0;
|
// if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
// if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||||
dataLen = varDataTLen(pData + sizeof(char));
|
// dataLen = 0;
|
||||||
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
// } else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||||
dataLen = sizeof(int64_t);
|
// dataLen = varDataTLen(pData + sizeof(char));
|
||||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
// } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||||
dataLen = sizeof(char);
|
// dataLen = sizeof(int64_t);
|
||||||
}
|
// } else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||||
dataLen += sizeof(char);
|
// dataLen = sizeof(char);
|
||||||
}
|
// }
|
||||||
|
// dataLen += sizeof(char);
|
||||||
|
// }
|
||||||
|
|
||||||
if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) {
|
if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) {
|
||||||
uint32_t newSize = data->varLenCol.payloadAllocLen;
|
uint32_t newSize = data->varLenCol.payloadAllocLen;
|
||||||
|
|
|
@ -276,6 +276,7 @@ TEST(testCase, smlParseCols_Test) {
|
||||||
info->dataFormat = false;
|
info->dataFormat = false;
|
||||||
SSmlLineInfo elements = {0};
|
SSmlLineInfo elements = {0};
|
||||||
info->msgBuf = msgBuf;
|
info->msgBuf = msgBuf;
|
||||||
|
ASSERT_EQ(smlInitHandle(NULL), TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
const char *data =
|
const char *data =
|
||||||
"st,t=1 cb\\=in=\"pass\\,it "
|
"st,t=1 cb\\=in=\"pass\\,it "
|
||||||
|
|
|
@ -11141,6 +11141,7 @@ void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tOffsetDestroy(void *param) {
|
void tOffsetDestroy(void *param) {
|
||||||
|
if (param == NULL) return;
|
||||||
STqOffsetVal *pVal = (STqOffsetVal *)param;
|
STqOffsetVal *pVal = (STqOffsetVal *)param;
|
||||||
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
||||||
taosMemoryFreeClear(pVal->primaryKey.pData);
|
taosMemoryFreeClear(pVal->primaryKey.pData);
|
||||||
|
@ -11148,6 +11149,7 @@ void tOffsetDestroy(void *param) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void tDeleteSTqOffset(void *param) {
|
void tDeleteSTqOffset(void *param) {
|
||||||
|
if (param == NULL) return;
|
||||||
STqOffset *pVal = (STqOffset *)param;
|
STqOffset *pVal = (STqOffset *)param;
|
||||||
tOffsetDestroy(&pVal->val);
|
tOffsetDestroy(&pVal->val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,6 +348,7 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
||||||
req.compactId = compactId;
|
req.compactId = compactId;
|
||||||
req.vgId = pVgroup->vgId;
|
req.vgId = pVgroup->vgId;
|
||||||
req.dnodeId = dnodeid;
|
req.dnodeId = dnodeid;
|
||||||
|
terrno = 0;
|
||||||
|
|
||||||
mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId);
|
mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId);
|
||||||
int32_t contLen = tSerializeSVKillCompactReq(NULL, 0, &req);
|
int32_t contLen = tSerializeSVKillCompactReq(NULL, 0, &req);
|
||||||
|
@ -367,8 +368,10 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
||||||
pHead->contLen = htonl(contLen);
|
pHead->contLen = htonl(contLen);
|
||||||
pHead->vgId = htonl(pVgroup->vgId);
|
pHead->vgId = htonl(pVgroup->vgId);
|
||||||
|
|
||||||
if ((contLen = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
mTrace("vgId:%d, build compact vnode config req, contLen:%d", pVgroup->vgId, contLen);
|
||||||
terrno = contLen;
|
int32_t ret = 0;
|
||||||
|
if ((ret = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||||
|
terrno = ret;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
*pContLen = contLen;
|
*pContLen = contLen;
|
||||||
|
@ -401,6 +404,8 @@ static int32_t mndAddKillCompactAction(SMnode *pMnode, STrans *pTrans, SVgObj *p
|
||||||
action.contLen = contLen;
|
action.contLen = contLen;
|
||||||
action.msgType = TDMT_VND_KILL_COMPACT;
|
action.msgType = TDMT_VND_KILL_COMPACT;
|
||||||
|
|
||||||
|
mTrace("trans:%d, kill compact msg len:%d", pTrans->id, contLen);
|
||||||
|
|
||||||
if ((code = mndTransAppendRedoAction(pTrans, &action)) != 0) {
|
if ((code = mndTransAppendRedoAction(pTrans, &action)) != 0) {
|
||||||
taosMemoryFree(pReq);
|
taosMemoryFree(pReq);
|
||||||
TAOS_RETURN(code);
|
TAOS_RETURN(code);
|
||||||
|
|
|
@ -160,7 +160,7 @@ int32_t metaAlterSuperTable(SMeta* pMeta, int64_t version, SVCreateStbRe
|
||||||
int32_t metaDropSuperTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
int32_t metaDropSuperTable(SMeta* pMeta, int64_t verison, SVDropStbReq* pReq);
|
||||||
int32_t metaCreateTable2(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** ppRsp);
|
int32_t metaCreateTable2(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** ppRsp);
|
||||||
int32_t metaDropTable2(SMeta* pMeta, int64_t version, SVDropTbReq* pReq);
|
int32_t metaDropTable2(SMeta* pMeta, int64_t version, SVDropTbReq* pReq);
|
||||||
int32_t metaTrimTables(SMeta* pMeta);
|
int32_t metaTrimTables(SMeta* pMeta, int64_t version);
|
||||||
int32_t metaDropMultipleTables(SMeta* pMeta, int64_t version, SArray* tbUids);
|
int32_t metaDropMultipleTables(SMeta* pMeta, int64_t version, SArray* tbUids);
|
||||||
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
||||||
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
|
int metaAlterTable(SMeta* pMeta, int64_t version, SVAlterTbReq* pReq, STableMetaRsp* pMetaRsp);
|
||||||
|
|
|
@ -1645,7 +1645,6 @@ static int32_t metaHandleSuperTableUpdate(SMeta *pMeta, const SMetaEntry *pEntry
|
||||||
metaFetchEntryFree(&pOldEntry);
|
metaFetchEntryFree(&pOldEntry);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
|
||||||
TAOS_CHECK_RETURN(tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type));
|
TAOS_CHECK_RETURN(tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type));
|
||||||
} else if (deltaCol == -1) {
|
} else if (deltaCol == -1) {
|
||||||
int16_t cid = -1;
|
int16_t cid = -1;
|
||||||
|
@ -1667,7 +1666,6 @@ static int32_t metaHandleSuperTableUpdate(SMeta *pMeta, const SMetaEntry *pEntry
|
||||||
metaFetchEntryFree(&pOldEntry);
|
metaFetchEntryFree(&pOldEntry);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
|
||||||
TAOS_CHECK_RETURN(tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey));
|
TAOS_CHECK_RETURN(tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,11 +151,8 @@ void tqClose(STQ* pTq) {
|
||||||
taosHashCleanup(pTq->pOffset);
|
taosHashCleanup(pTq->pOffset);
|
||||||
taosMemoryFree(pTq->path);
|
taosMemoryFree(pTq->path);
|
||||||
tqMetaClose(pTq);
|
tqMetaClose(pTq);
|
||||||
|
qDebug("vgId:%d end to close tq", pTq->pStreamMeta != NULL ? pTq->pStreamMeta->vgId : -1);
|
||||||
int32_t vgId = pTq->pStreamMeta->vgId;
|
|
||||||
streamMetaClose(pTq->pStreamMeta);
|
streamMetaClose(pTq->pStreamMeta);
|
||||||
|
|
||||||
qDebug("vgId:%d end to close tq", vgId);
|
|
||||||
taosMemoryFree(pTq);
|
taosMemoryFree(pTq);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,36 +17,41 @@
|
||||||
#include "tq.h"
|
#include "tq.h"
|
||||||
|
|
||||||
int32_t tqBuildFName(char** data, const char* path, char* name) {
|
int32_t tqBuildFName(char** data, const char* path, char* name) {
|
||||||
if (data == NULL || path == NULL || name == NULL) {
|
int32_t code = 0;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
char* fname = NULL;
|
||||||
|
TSDB_CHECK_NULL(data, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(path, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(name, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
int32_t len = strlen(path) + strlen(name) + 2;
|
int32_t len = strlen(path) + strlen(name) + 2;
|
||||||
char* fname = taosMemoryCalloc(1, len);
|
fname = taosMemoryCalloc(1, len);
|
||||||
if(fname == NULL) {
|
TSDB_CHECK_NULL(fname, code, lino, END, terrno);
|
||||||
return terrno;
|
(void)tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||||
|
|
||||||
|
*data = fname;
|
||||||
|
fname = NULL;
|
||||||
|
|
||||||
|
END:
|
||||||
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
|
||||||
if (code < 0){
|
|
||||||
code = TAOS_SYSTEM_ERROR(errno);
|
|
||||||
taosMemoryFree(fname);
|
taosMemoryFree(fname);
|
||||||
return code;
|
return code;
|
||||||
}
|
|
||||||
*data = fname;
|
|
||||||
return TDB_CODE_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
||||||
if (pTq == NULL || name == NULL) {
|
|
||||||
return TSDB_CODE_INVALID_MSG;
|
|
||||||
}
|
|
||||||
int32_t code = TDB_CODE_SUCCESS;
|
int32_t code = TDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
void* pMemBuf = NULL;
|
void* pMemBuf = NULL;
|
||||||
|
TdFilePtr pFile = NULL;
|
||||||
|
STqOffset *pOffset = NULL;
|
||||||
|
void *pIter = NULL;
|
||||||
|
|
||||||
TdFilePtr pFile = taosOpenFile(name, TD_FILE_READ);
|
TSDB_CHECK_NULL(pTq, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
if (pFile == NULL) {
|
TSDB_CHECK_NULL(name, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
code = TDB_CODE_SUCCESS;
|
|
||||||
goto END;
|
pFile = taosOpenFile(name, TD_FILE_READ);
|
||||||
}
|
TSDB_CHECK_NULL(pFile, code, lino, END, TDB_CODE_SUCCESS);
|
||||||
|
|
||||||
int64_t ret = 0;
|
int64_t ret = 0;
|
||||||
int32_t size = 0;
|
int32_t size = 0;
|
||||||
|
@ -60,48 +65,41 @@ int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
||||||
}
|
}
|
||||||
total += INT_BYTES;
|
total += INT_BYTES;
|
||||||
size = htonl(size);
|
size = htonl(size);
|
||||||
if (size <= 0) {
|
TSDB_CHECK_CONDITION(size > 0, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
pMemBuf = taosMemoryCalloc(1, size);
|
|
||||||
if (pMemBuf == NULL) {
|
|
||||||
code = terrno;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosReadFile(pFile, pMemBuf, size) != size) {
|
pMemBuf = taosMemoryCalloc(1, size);
|
||||||
terrno = TSDB_CODE_INVALID_MSG;
|
TSDB_CHECK_NULL(pMemBuf, code, lino, END, terrno);
|
||||||
goto END;
|
TSDB_CHECK_CONDITION(taosReadFile(pFile, pMemBuf, size) == size, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||||
}
|
|
||||||
|
|
||||||
total += size;
|
total += size;
|
||||||
STqOffset offset = {0};
|
STqOffset offset = {0};
|
||||||
TQ_ERR_GO_TO_END(tqMetaDecodeOffsetInfo(&offset, pMemBuf, size));
|
code = tqMetaDecodeOffsetInfo(&offset, pMemBuf, size);
|
||||||
code = taosHashPut(pTq->pOffset, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset));
|
TSDB_CHECK_CODE(code, lino, END);
|
||||||
if (code != TDB_CODE_SUCCESS) {
|
pOffset = &offset;
|
||||||
tDeleteSTqOffset(&offset);
|
code = taosHashPut(pTq->pOffset, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
||||||
goto END;
|
TSDB_CHECK_CODE(code, lino, END);
|
||||||
}
|
pOffset = NULL;
|
||||||
|
|
||||||
tqInfo("tq: offset restore from file to tdb, size:%d, hash size:%d subkey:%s", total, taosHashGetSize(pTq->pOffset), offset.subKey);
|
tqInfo("tq: offset restore from file to tdb, size:%d, hash size:%d subkey:%s", total, taosHashGetSize(pTq->pOffset), offset.subKey);
|
||||||
taosMemoryFree(pMemBuf);
|
taosMemoryFree(pMemBuf);
|
||||||
pMemBuf = NULL;
|
pMemBuf = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *pIter = NULL;
|
|
||||||
while ((pIter = taosHashIterate(pTq->pOffset, pIter))) {
|
while ((pIter = taosHashIterate(pTq->pOffset, pIter))) {
|
||||||
STqOffset* pOffset = (STqOffset*)pIter;
|
STqOffset* offset = (STqOffset*)pIter;
|
||||||
code = tqMetaSaveOffset(pTq, pOffset);
|
code = tqMetaSaveOffset(pTq, offset);
|
||||||
if(code != 0){
|
TSDB_CHECK_CODE(code, lino, END);
|
||||||
taosHashCancelIterate(pTq->pOffset, pIter);
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
END:
|
END:
|
||||||
taosCloseFile(&pFile);
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
(void)taosCloseFile(&pFile);
|
||||||
taosMemoryFree(pMemBuf);
|
taosMemoryFree(pMemBuf);
|
||||||
|
|
||||||
|
tDeleteSTqOffset(pOffset);
|
||||||
|
taosHashCancelIterate(pTq->pOffset, pIter);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,18 +27,16 @@ struct STqSnapReader {
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader) {
|
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader) {
|
||||||
if (pTq == NULL || ppReader == NULL) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
|
||||||
int32_t code = 0;
|
|
||||||
STqSnapReader* pReader = NULL;
|
STqSnapReader* pReader = NULL;
|
||||||
|
TSDB_CHECK_NULL(pTq, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(ppReader, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
||||||
if (pReader == NULL) {
|
TSDB_CHECK_NULL(pReader, code, lino, end, terrno);
|
||||||
code = terrno;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
pReader->pTq = pTq;
|
pReader->pTq = pTq;
|
||||||
pReader->sver = sver;
|
pReader->sver = sver;
|
||||||
pReader->ever = ever;
|
pReader->ever = ever;
|
||||||
|
@ -54,28 +52,21 @@ int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqS
|
||||||
pTb = pTq->pOffsetStore;
|
pTb = pTq->pOffsetStore;
|
||||||
} else {
|
} else {
|
||||||
code = TSDB_CODE_INVALID_MSG;
|
code = TSDB_CODE_INVALID_MSG;
|
||||||
goto _err;
|
goto end;
|
||||||
}
|
}
|
||||||
code = tdbTbcOpen(pTb, &pReader->pCur, NULL);
|
code = tdbTbcOpen(pTb, &pReader->pCur, NULL);
|
||||||
if (code) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
taosMemoryFree(pReader);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tdbTbcMoveToFirst(pReader->pCur);
|
code = tdbTbcMoveToFirst(pReader->pCur);
|
||||||
if (code) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
taosMemoryFree(pReader);
|
tqInfo("vgId:%d, vnode tq snapshot reader opene success", TD_VID(pTq->pVnode));
|
||||||
goto _err;
|
*ppReader = pReader;
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d, vnode tq snapshot reader open failed since %s", __func__, lino, tstrerror(code));
|
||||||
|
taosMemoryFreeClear(pReader);
|
||||||
}
|
}
|
||||||
|
|
||||||
tqInfo("vgId:%d, vnode snapshot tq reader opened", TD_VID(pTq->pVnode));
|
|
||||||
|
|
||||||
*ppReader = pReader;
|
|
||||||
return code;
|
|
||||||
|
|
||||||
_err:
|
|
||||||
tqError("vgId:%d, vnode snapshot tq reader open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
|
||||||
*ppReader = NULL;
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,45 +75,37 @@ void tqSnapReaderClose(STqSnapReader** ppReader) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tdbTbcClose((*ppReader)->pCur);
|
tdbTbcClose((*ppReader)->pCur);
|
||||||
taosMemoryFree(*ppReader);
|
taosMemoryFreeClear(*ppReader);
|
||||||
*ppReader = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||||
if (pReader == NULL || ppData == NULL) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
|
||||||
int32_t code = 0;
|
|
||||||
void* pKey = NULL;
|
void* pKey = NULL;
|
||||||
void* pVal = NULL;
|
void* pVal = NULL;
|
||||||
int32_t kLen = 0;
|
int32_t kLen = 0;
|
||||||
int32_t vLen = 0;
|
int32_t vLen = 0;
|
||||||
|
TSDB_CHECK_NULL(pReader, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(ppData, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
|
||||||
if (tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen)) {
|
code = tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||||
goto _exit;
|
TSDB_CHECK_CONDITION(code == 0, code, lino, end, TDB_CODE_SUCCESS);
|
||||||
}
|
|
||||||
|
|
||||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||||
if (*ppData == NULL) {
|
TSDB_CHECK_NULL(*ppData, code, lino, end, terrno);
|
||||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||||
pHdr->type = pReader->type;
|
pHdr->type = pReader->type;
|
||||||
pHdr->size = vLen;
|
pHdr->size = vLen;
|
||||||
(void)memcpy(pHdr->data, pVal, vLen);
|
(void)memcpy(pHdr->data, pVal, vLen);
|
||||||
|
tqInfo("vgId:%d, vnode tq snapshot read data, vLen:%d", TD_VID(pReader->pTq->pVnode), vLen);
|
||||||
|
|
||||||
_exit:
|
end:
|
||||||
|
if (code != 0) {
|
||||||
|
tqError("%s failed at %d, vnode tq snapshot read data failed since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
tdbFree(pKey);
|
tdbFree(pKey);
|
||||||
tdbFree(pVal);
|
tdbFree(pVal);
|
||||||
tqInfo("vgId:%d, vnode snapshot tq read data, vLen:%d", TD_VID(pReader->pTq->pVnode), vLen);
|
|
||||||
return code;
|
|
||||||
|
|
||||||
_err:
|
|
||||||
tdbFree(pKey);
|
|
||||||
tdbFree(pVal);
|
|
||||||
tqError("vgId:%d, vnode snapshot tq read data failed since %s", TD_VID(pReader->pTq->pVnode), tstrerror(code));
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,135 +118,148 @@ struct STqSnapWriter {
|
||||||
};
|
};
|
||||||
|
|
||||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||||
if (pTq == NULL || ppWriter == NULL) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
|
||||||
int32_t code = 0;
|
|
||||||
STqSnapWriter* pWriter = NULL;
|
STqSnapWriter* pWriter = NULL;
|
||||||
|
|
||||||
|
TSDB_CHECK_NULL(pTq, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
|
||||||
// alloc
|
// alloc
|
||||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||||
if (pWriter == NULL) {
|
TSDB_CHECK_NULL(pWriter, code, lino, end, terrno);
|
||||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
|
||||||
;
|
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
pWriter->pTq = pTq;
|
pWriter->pTq = pTq;
|
||||||
pWriter->sver = sver;
|
pWriter->sver = sver;
|
||||||
pWriter->ever = ever;
|
pWriter->ever = ever;
|
||||||
|
|
||||||
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
||||||
if (code < 0) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
taosMemoryFree(pWriter);
|
tqInfo("vgId:%d, tq snapshot writer opene success", TD_VID(pTq->pVnode));
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
*ppWriter = pWriter;
|
*ppWriter = pWriter;
|
||||||
return code;
|
|
||||||
|
|
||||||
_err:
|
end:
|
||||||
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
if (code != 0){
|
||||||
*ppWriter = NULL;
|
tqError("%s failed at %d tq snapshot writer open failed since %s", __func__, lino, tstrerror(code));
|
||||||
|
taosMemoryFreeClear(pWriter);
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||||
if (ppWriter == NULL || *ppWriter == NULL) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
STqSnapWriter* pWriter = NULL;
|
||||||
int32_t code = 0;
|
|
||||||
STqSnapWriter* pWriter = *ppWriter;
|
TSDB_CHECK_NULL(ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
STQ* pTq = pWriter->pTq;
|
TSDB_CHECK_NULL(*ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
pWriter = *ppWriter;
|
||||||
|
|
||||||
if (rollback) {
|
if (rollback) {
|
||||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
} else {
|
} else {
|
||||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
|
||||||
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
code = tdbPostCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
}
|
}
|
||||||
|
tqInfo("vgId:%d, tq snapshot writer close success", TD_VID(pWriter->pTq->pVnode));
|
||||||
|
taosMemoryFreeClear(*ppWriter);
|
||||||
|
|
||||||
taosMemoryFree(pWriter);
|
end:
|
||||||
*ppWriter = NULL;
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d, tq snapshot writer close failed since %s", __func__, lino, tstrerror(code));
|
||||||
return code;
|
}
|
||||||
|
|
||||||
_err:
|
|
||||||
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
static int32_t tqWriteCheck(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData){
|
||||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
|
TSDB_CHECK_NULL(pWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_NULL(pData, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
TSDB_CHECK_CONDITION(nData >= sizeof(SSnapDataHdr), code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||||
|
end:
|
||||||
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d failed since %s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
int32_t code = 0;
|
return code;
|
||||||
STQ* pTq = pWriter->pTq;
|
}
|
||||||
|
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
|
int code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
SDecoder decoder = {0};
|
SDecoder decoder = {0};
|
||||||
SDecoder* pDecoder = &decoder;
|
SDecoder* pDecoder = &decoder;
|
||||||
STqHandle handle = {0};
|
STqHandle handle = {0};
|
||||||
|
code = tqWriteCheck(pWriter, pData, nData);
|
||||||
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
|
||||||
|
STQ* pTq = pWriter->pTq;
|
||||||
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
tDecoderInit(pDecoder, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||||
if (code) goto end;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
|
||||||
taosWLockLatch(&pTq->lock);
|
taosWLockLatch(&pTq->lock);
|
||||||
code = tqMetaSaveInfo(pTq, pTq->pExecStore, handle.subKey, strlen(handle.subKey), pData + sizeof(SSnapDataHdr),
|
code = tqMetaSaveInfo(pTq, pTq->pExecStore, handle.subKey, strlen(handle.subKey), pData + sizeof(SSnapDataHdr),
|
||||||
nData - sizeof(SSnapDataHdr));
|
nData - sizeof(SSnapDataHdr));
|
||||||
taosWUnLockLatch(&pTq->lock);
|
taosWUnLockLatch(&pTq->lock);
|
||||||
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
tqInfo("vgId:%d, vnode tq snapshot write success", TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
end:
|
end:
|
||||||
tDecoderClear(pDecoder);
|
tDecoderClear(pDecoder);
|
||||||
tqDestroyTqHandle(&handle);
|
tqDestroyTqHandle(&handle);
|
||||||
tqInfo("vgId:%d, vnode snapshot tq write result:%d", TD_VID(pTq->pVnode), code);
|
if (code != 0){
|
||||||
|
tqError("%s failed at %d, vnode tq snapshot write failed since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
|
||||||
int32_t code = 0;
|
code = tqWriteCheck(pWriter, pData, nData);
|
||||||
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
|
||||||
STQ* pTq = pWriter->pTq;
|
STQ* pTq = pWriter->pTq;
|
||||||
STqCheckInfo info = {0};
|
STqCheckInfo info = {0};
|
||||||
code = tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
code = tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
if (code != 0) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tqMetaSaveInfo(pTq, pTq->pCheckStore, &info.topic, strlen(info.topic), pData + sizeof(SSnapDataHdr),
|
code = tqMetaSaveInfo(pTq, pTq->pCheckStore, &info.topic, strlen(info.topic), pData + sizeof(SSnapDataHdr),
|
||||||
nData - sizeof(SSnapDataHdr));
|
nData - sizeof(SSnapDataHdr));
|
||||||
tDeleteSTqCheckInfo(&info);
|
tDeleteSTqCheckInfo(&info);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
tqInfo("vgId:%d, vnode tq check info write success", TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
return code;
|
end:
|
||||||
|
if (code != 0){
|
||||||
_err:
|
tqError("%s failed at %d, vnode tq check info write failed since %s", __func__, lino, tstrerror(code));
|
||||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
int code = TSDB_CODE_SUCCESS;
|
||||||
return TSDB_CODE_INVALID_MSG;
|
int32_t lino = 0;
|
||||||
}
|
code = tqWriteCheck(pWriter, pData, nData);
|
||||||
int32_t code = 0;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
STQ* pTq = pWriter->pTq;
|
|
||||||
|
|
||||||
|
STQ* pTq = pWriter->pTq;
|
||||||
STqOffset info = {0};
|
STqOffset info = {0};
|
||||||
code = tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
code = tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||||
if (code != 0) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
goto _err;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = tqMetaSaveInfo(pTq, pTq->pOffsetStore, info.subKey, strlen(info.subKey), pData + sizeof(SSnapDataHdr),
|
code = tqMetaSaveInfo(pTq, pTq->pOffsetStore, info.subKey, strlen(info.subKey), pData + sizeof(SSnapDataHdr),
|
||||||
nData - sizeof(SSnapDataHdr));
|
nData - sizeof(SSnapDataHdr));
|
||||||
tDeleteSTqOffset(&info);
|
tDeleteSTqOffset(&info);
|
||||||
if (code) goto _err;
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
|
tqInfo("vgId:%d, vnode tq offset write success", TD_VID(pTq->pVnode));
|
||||||
|
|
||||||
return code;
|
end:
|
||||||
|
if (code != 0){
|
||||||
_err:
|
tqError("%s failed at %d, vnode tq offset write failed since %s", __func__, lino, tstrerror(code));
|
||||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5791,7 +5791,6 @@ int32_t tsdbReaderSuspend2(STsdbReader* pReader) {
|
||||||
|
|
||||||
// make sure only release once
|
// make sure only release once
|
||||||
void* p = pReader->pReadSnap;
|
void* p = pReader->pReadSnap;
|
||||||
TSDB_CHECK_NULL(p, code, lino, _end, TSDB_CODE_INVALID_PARA);
|
|
||||||
if ((p == atomic_val_compare_exchange_ptr((void**)&pReader->pReadSnap, p, NULL)) && (p != NULL)) {
|
if ((p == atomic_val_compare_exchange_ptr((void**)&pReader->pReadSnap, p, NULL)) && (p != NULL)) {
|
||||||
tsdbUntakeReadSnap2(pReader, p, false);
|
tsdbUntakeReadSnap2(pReader, p, false);
|
||||||
pReader->pReadSnap = NULL;
|
pReader->pReadSnap = NULL;
|
||||||
|
|
|
@ -607,9 +607,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg
|
||||||
}
|
}
|
||||||
|
|
||||||
vDebug("vgId:%d, start to process write request %s, index:%" PRId64 ", applied:%" PRId64 ", state.applyTerm:%" PRId64
|
vDebug("vgId:%d, start to process write request %s, index:%" PRId64 ", applied:%" PRId64 ", state.applyTerm:%" PRId64
|
||||||
", conn.applyTerm:%" PRId64,
|
", conn.applyTerm:%" PRId64 ", contLen:%d",
|
||||||
TD_VID(pVnode), TMSG_INFO(pMsg->msgType), ver, pVnode->state.applied, pVnode->state.applyTerm,
|
TD_VID(pVnode), TMSG_INFO(pMsg->msgType), ver, pVnode->state.applied, pVnode->state.applyTerm,
|
||||||
pMsg->info.conn.applyTerm);
|
pMsg->info.conn.applyTerm, pMsg->contLen);
|
||||||
|
|
||||||
if (!(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm)) {
|
if (!(pVnode->state.applyTerm <= pMsg->info.conn.applyTerm)) {
|
||||||
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
||||||
|
@ -2145,7 +2145,7 @@ static int32_t vnodeConsolidateAlterHashRange(SVnode *pVnode, int64_t ver) {
|
||||||
pVnode->config.hashBegin, pVnode->config.hashEnd, ver);
|
pVnode->config.hashBegin, pVnode->config.hashEnd, ver);
|
||||||
|
|
||||||
// TODO: trim meta of tables from TDB per hash range [pVnode->config.hashBegin, pVnode->config.hashEnd]
|
// TODO: trim meta of tables from TDB per hash range [pVnode->config.hashBegin, pVnode->config.hashEnd]
|
||||||
code = metaTrimTables(pVnode->pMeta);
|
code = metaTrimTables(pVnode->pMeta, ver);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,29 +1,27 @@
|
||||||
MESSAGE(STATUS "vnode unit test")
|
MESSAGE(STATUS "tq unit test")
|
||||||
|
|
||||||
# GoogleTest requires at least C++11
|
# GoogleTest requires at least C++11
|
||||||
SET(CMAKE_CXX_STANDARD 11)
|
SET(CMAKE_CXX_STANDARD 11)
|
||||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
|
||||||
|
|
||||||
# add_executable(tqTest "")
|
IF(NOT TD_WINDOWS)
|
||||||
# target_sources(tqTest
|
add_executable(tqTest tqTest.cpp)
|
||||||
# PRIVATE
|
target_include_directories(tqTest
|
||||||
# "tqMetaTest.cpp"
|
PUBLIC
|
||||||
# )
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
# target_include_directories(tqTest
|
)
|
||||||
# PUBLIC
|
|
||||||
# "${TD_SOURCE_DIR}/include/server/vnode/tq"
|
|
||||||
# "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
|
||||||
# )
|
|
||||||
|
|
||||||
# target_link_libraries(tqTest
|
TARGET_LINK_LIBRARIES(
|
||||||
# tq
|
tqTest
|
||||||
# gtest_main
|
PUBLIC os util common vnode gtest_main
|
||||||
# )
|
)
|
||||||
# enable_testing()
|
|
||||||
# add_test(
|
enable_testing()
|
||||||
# NAME tq_test
|
|
||||||
# COMMAND tqTest
|
add_test(
|
||||||
# )
|
NAME tq_test
|
||||||
|
COMMAND tqTest
|
||||||
|
)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# ADD_EXECUTABLE(tsdbSmaTest tsdbSmaTest.cpp)
|
# ADD_EXECUTABLE(tsdbSmaTest tsdbSmaTest.cpp)
|
||||||
# TARGET_LINK_LIBRARIES(
|
# TARGET_LINK_LIBRARIES(
|
||||||
|
|
|
@ -0,0 +1,79 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <vnodeInt.h>
|
||||||
|
|
||||||
|
#include <taoserror.h>
|
||||||
|
#include <tglobal.h>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <tmsg.h>
|
||||||
|
#include <vnodeInt.h>
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
|
||||||
|
SDmNotifyHandle dmNotifyHdl = {.state = 0};
|
||||||
|
|
||||||
|
#include "tq.h"
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
testing::InitGoogleTest(&argc, argv);
|
||||||
|
return RUN_ALL_TESTS();
|
||||||
|
}
|
||||||
|
|
||||||
|
void tqWriteOffset() {
|
||||||
|
TdFilePtr pFile = taosOpenFile(TQ_OFFSET_NAME, TD_FILE_CREATE | TD_FILE_WRITE | TD_FILE_APPEND);
|
||||||
|
|
||||||
|
STqOffset offset = {.val = {.type = TMQ_OFFSET__LOG, .version = 8923}};
|
||||||
|
strcpy(offset.subKey, "testtest");
|
||||||
|
int32_t bodyLen;
|
||||||
|
int32_t code;
|
||||||
|
tEncodeSize(tEncodeSTqOffset, &offset, bodyLen, code);
|
||||||
|
int32_t totLen = INT_BYTES + bodyLen;
|
||||||
|
void* buf = taosMemoryCalloc(1, totLen);
|
||||||
|
void* abuf = POINTER_SHIFT(buf, INT_BYTES);
|
||||||
|
|
||||||
|
*(int32_t*)buf = htonl(bodyLen);
|
||||||
|
SEncoder encoder;
|
||||||
|
tEncoderInit(&encoder, (uint8_t*)abuf, bodyLen);
|
||||||
|
tEncodeSTqOffset(&encoder, &offset);
|
||||||
|
taosWriteFile(pFile, buf, totLen);
|
||||||
|
|
||||||
|
taosMemoryFree(buf);
|
||||||
|
|
||||||
|
taosCloseFile(&pFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(testCase, tqOffsetTest) {
|
||||||
|
STQ* pTq = (STQ*)taosMemoryCalloc(1, sizeof(STQ));
|
||||||
|
pTq->path = taosStrdup("./");
|
||||||
|
|
||||||
|
pTq->pOffset = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_VARCHAR), true, HASH_ENTRY_LOCK);
|
||||||
|
taosHashSetFreeFp(pTq->pOffset, (FDelete)tDeleteSTqOffset);
|
||||||
|
|
||||||
|
tdbOpen(pTq->path, 16 * 1024, 1, &pTq->pMetaDB, 0, 0, NULL);
|
||||||
|
tdbTbOpen("tq.offset.db", -1, -1, NULL, pTq->pMetaDB, &pTq->pOffsetStore, 0);
|
||||||
|
|
||||||
|
tqWriteOffset();
|
||||||
|
tqOffsetRestoreFromFile(pTq, TQ_OFFSET_NAME);
|
||||||
|
taosRemoveFile(TQ_OFFSET_NAME);
|
||||||
|
tqClose(pTq);
|
||||||
|
}
|
||||||
|
|
||||||
|
#pragma GCC diagnostic pop
|
|
@ -11,6 +11,6 @@ target_link_libraries(
|
||||||
PRIVATE os util transport qcom nodes
|
PRIVATE os util transport qcom nodes
|
||||||
)
|
)
|
||||||
|
|
||||||
#if(${BUILD_TEST})
|
if(${BUILD_TEST} AND NOT ${TD_WINDOWS})
|
||||||
# ADD_SUBDIRECTORY(test)
|
ADD_SUBDIRECTORY(test)
|
||||||
#endif(${BUILD_TEST})
|
endif()
|
||||||
|
|
|
@ -424,6 +424,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
|
||||||
CTG_RET(TSDB_CODE_SUCCESS);
|
CTG_RET(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) {
|
int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) {
|
||||||
SVgroupInfo vgroupInfo = {0};
|
SVgroupInfo vgroupInfo = {0};
|
||||||
STableCfg* pCfg = NULL;
|
STableCfg* pCfg = NULL;
|
||||||
|
@ -474,6 +475,7 @@ _return:
|
||||||
|
|
||||||
CTG_RET(code);
|
CTG_RET(code);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) {
|
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) {
|
||||||
STableMeta* tbMeta = NULL;
|
STableMeta* tbMeta = NULL;
|
||||||
|
@ -1695,6 +1697,7 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) {
|
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -1709,6 +1712,7 @@ _return:
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) {
|
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
@ -1845,7 +1849,7 @@ _return:
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) {
|
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -1860,6 +1864,7 @@ _return:
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta) {
|
int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
|
@ -2992,6 +2992,7 @@ TEST(apiTest, catalogGetTableIndex_test) {
|
||||||
catalogDestroy();
|
catalogDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(apiTest, catalogGetDBCfg_test) {
|
TEST(apiTest, catalogGetDBCfg_test) {
|
||||||
struct SCatalog *pCtg = NULL;
|
struct SCatalog *pCtg = NULL;
|
||||||
SRequestConnInfo connInfo = {0};
|
SRequestConnInfo connInfo = {0};
|
||||||
|
|
|
@ -83,6 +83,8 @@ int32_t hInnerJoinDo(struct SOperatorInfo* pOperator) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HASH_JOIN_FULL
|
||||||
|
|
||||||
int32_t hLeftJoinHandleSeqRowRemains(struct SOperatorInfo* pOperator, SHJoinOperatorInfo* pJoin, bool* loopCont) {
|
int32_t hLeftJoinHandleSeqRowRemains(struct SOperatorInfo* pOperator, SHJoinOperatorInfo* pJoin, bool* loopCont) {
|
||||||
bool allFetched = false;
|
bool allFetched = false;
|
||||||
SHJoinCtx* pCtx = &pJoin->ctx;
|
SHJoinCtx* pCtx = &pJoin->ctx;
|
||||||
|
@ -346,4 +348,5 @@ int32_t hLeftJoinDo(struct SOperatorInfo* pOperator) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ int32_t hJoinSetImplFp(SHJoinOperatorInfo* pJoin) {
|
||||||
case JOIN_TYPE_RIGHT: {
|
case JOIN_TYPE_RIGHT: {
|
||||||
switch (pJoin->subType) {
|
switch (pJoin->subType) {
|
||||||
case JOIN_STYPE_OUTER:
|
case JOIN_STYPE_OUTER:
|
||||||
pJoin->joinFp = hLeftJoinDo;
|
//pJoin->joinFp = hLeftJoinDo; TOOPEN
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -44,3 +44,15 @@ TARGET_INCLUDE_DIRECTORIES(
|
||||||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||||
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ADD_EXECUTABLE(execUtilTests execUtilTests.cpp)
|
||||||
|
TARGET_LINK_LIBRARIES(
|
||||||
|
execUtilTests
|
||||||
|
PRIVATE os util common executor gtest_main qcom function planner scalar nodes vnode
|
||||||
|
)
|
||||||
|
|
||||||
|
TARGET_INCLUDE_DIRECTORIES(
|
||||||
|
execUtilTests
|
||||||
|
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
#include "gtest/gtest.h"
|
||||||
|
|
||||||
|
#include "executil.h"
|
||||||
|
|
||||||
|
TEST(execUtilTest, resRowTest) {
|
||||||
|
SDiskbasedBuf *pBuf = nullptr;
|
||||||
|
int32_t pageSize = 32;
|
||||||
|
int32_t numPages = 3;
|
||||||
|
int32_t code = createDiskbasedBuf(&pBuf, pageSize, pageSize * numPages, "test_buf", "/");
|
||||||
|
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
std::vector<void *> pages(numPages);
|
||||||
|
std::vector<int32_t> pageIds(numPages);
|
||||||
|
for (int32_t i = 0; i < numPages; ++i) {
|
||||||
|
pages[i] = getNewBufPage(pBuf, &pageIds[i]);
|
||||||
|
EXPECT_NE(pages[i], nullptr);
|
||||||
|
EXPECT_EQ(pageIds[i], i);
|
||||||
|
}
|
||||||
|
|
||||||
|
EXPECT_EQ(getNewBufPage(pBuf, nullptr), nullptr);
|
||||||
|
|
||||||
|
SResultRowPosition pos;
|
||||||
|
pos.offset = 0;
|
||||||
|
for (int32_t i = 0; i < numPages; ++i) {
|
||||||
|
pos.pageId = pageIds[i];
|
||||||
|
bool forUpdate = i & 0x1;
|
||||||
|
SResultRow *row = getResultRowByPos(pBuf, &pos, forUpdate);
|
||||||
|
EXPECT_EQ((void *)row, pages[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
pos.pageId = numPages + 1;
|
||||||
|
EXPECT_EQ(getResultRowByPos(pBuf, &pos, true), nullptr);
|
||||||
|
|
||||||
|
destroyDiskbasedBuf(pBuf);
|
||||||
|
}
|
|
@ -41,6 +41,7 @@
|
||||||
#include "tvariant.h"
|
#include "tvariant.h"
|
||||||
#include "stub.h"
|
#include "stub.h"
|
||||||
#include "querytask.h"
|
#include "querytask.h"
|
||||||
|
#include "hashjoin.h"
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -3766,6 +3767,21 @@ TEST(leftWinJoin, noCondProjectionTest) {
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
TEST(functionsTest, branch) {
|
||||||
|
struct SOperatorInfo op = {0};
|
||||||
|
SHJoinOperatorInfo join;
|
||||||
|
SBufRowInfo bufrow = {0};
|
||||||
|
SSDataBlock blk = {0};
|
||||||
|
|
||||||
|
op.info = &join;
|
||||||
|
memset(&join, 0, sizeof(join));
|
||||||
|
join.ctx.pBuildRow = &bufrow;
|
||||||
|
blk.info.rows = 1;
|
||||||
|
join.finBlk = &blk;
|
||||||
|
hInnerJoinDo(&op);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
|
@ -142,6 +142,50 @@ target_link_libraries(
|
||||||
udf2_dup PUBLIC os ${LINK_JEMALLOC}
|
udf2_dup PUBLIC os ${LINK_JEMALLOC}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(TARGET_NAMES
|
||||||
|
change_udf_normal
|
||||||
|
change_udf_no_init
|
||||||
|
change_udf_no_process
|
||||||
|
change_udf_no_destroy
|
||||||
|
change_udf_init_failed
|
||||||
|
change_udf_process_failed
|
||||||
|
change_udf_destory_failed
|
||||||
|
)
|
||||||
|
|
||||||
|
set(COMPILE_DEFINITIONS
|
||||||
|
CHANGE_UDF_NORMAL
|
||||||
|
CHANGE_UDF_NO_INIT
|
||||||
|
CHANGE_UDF_NO_PROCESS
|
||||||
|
CHANGE_UDF_NO_DESTROY
|
||||||
|
CHANGE_UDF_INIT_FAILED
|
||||||
|
CHANGE_UDF_PROCESS_FAILED
|
||||||
|
CHANGE_UDF_DESTORY_FAILED
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(index RANGE 0 6)
|
||||||
|
list(GET TARGET_NAMES ${index} target_name)
|
||||||
|
list(GET COMPILE_DEFINITIONS ${index} compile_def)
|
||||||
|
|
||||||
|
add_library(${target_name} STATIC MODULE test/change_udf.c)
|
||||||
|
target_include_directories(
|
||||||
|
${target_name}
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/function"
|
||||||
|
"${TD_SOURCE_DIR}/include/util"
|
||||||
|
"${TD_SOURCE_DIR}/include/common"
|
||||||
|
"${TD_SOURCE_DIR}/include/client"
|
||||||
|
"${TD_SOURCE_DIR}/include/os"
|
||||||
|
PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/inc"
|
||||||
|
)
|
||||||
|
target_compile_definitions(${target_name} PRIVATE ${compile_def})
|
||||||
|
IF(TD_LINUX_64 AND JEMALLOC_ENABLED)
|
||||||
|
ADD_DEPENDENCIES(${target_name} jemalloc)
|
||||||
|
ENDIF()
|
||||||
|
target_link_libraries(
|
||||||
|
${target_name} PUBLIC os ${LINK_JEMALLOC}
|
||||||
|
)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
# SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
# SET(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/bin)
|
||||||
add_executable(udfd src/udfd.c)
|
add_executable(udfd src/udfd.c)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,172 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#ifdef LINUX
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#include "taosudf.h"
|
||||||
|
|
||||||
|
// rename function name
|
||||||
|
#ifdef CHANGE_UDF_NORMAL
|
||||||
|
#define UDFNAME change_udf_normal
|
||||||
|
#define UDFNAMEINIT change_udf_normal_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_normal_destroy
|
||||||
|
#elif defined(CHANGE_UDF_NO_INIT)
|
||||||
|
#define UDFNAME change_udf_no_init
|
||||||
|
#define UDFNAMEINIT change_udf_no_init_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_no_init_destroy
|
||||||
|
#elif defined(CHANGE_UDF_NO_PROCESS)
|
||||||
|
#define UDFNAME change_udf_no_process
|
||||||
|
#define UDFNAMEINIT change_udf_no_process_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_no_process_destroy
|
||||||
|
#elif defined(CHANGE_UDF_NO_DESTROY)
|
||||||
|
#define UDFNAME change_udf_no_destroy
|
||||||
|
#define UDFNAMEINIT change_udf_no_destroy_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_no_destroy_destroy
|
||||||
|
#elif defined(CHANGE_UDF_INIT_FAILED)
|
||||||
|
#define UDFNAME change_udf_init_failed
|
||||||
|
#define UDFNAMEINIT change_udf_init_failed_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_init_failed_destroy
|
||||||
|
#elif defined(CHANGE_UDF_PROCESS_FAILED)
|
||||||
|
#define UDFNAME change_udf_process_failed
|
||||||
|
#define UDFNAMEINIT change_udf_process_failed_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_process_failed_destroy
|
||||||
|
#elif defined(CHANGE_UDF_DESTORY_FAILED)
|
||||||
|
#define UDFNAME change_udf_destory_failed
|
||||||
|
#define UDFNAMEINIT change_udf_destory_failed_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_destory_failed_destroy
|
||||||
|
#else
|
||||||
|
#define UDFNAME change_udf_normal
|
||||||
|
#define UDFNAMEINIT change_udf_normal_init
|
||||||
|
#define UDFNAMEDESTROY change_udf_normal_destroy
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef CHANGE_UDF_NO_INIT
|
||||||
|
#else
|
||||||
|
DLL_EXPORT int32_t UDFNAMEINIT() {
|
||||||
|
#ifdef CHANGE_UDF_INIT_FAILED
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif // ifdef CHANGE_UDF_INIT_FAILED
|
||||||
|
}
|
||||||
|
#endif // ifdef CHANGE_UDF_NO_INIT
|
||||||
|
|
||||||
|
#ifdef CHANGE_UDF_NO_DESTROY
|
||||||
|
#else
|
||||||
|
DLL_EXPORT int32_t UDFNAMEDESTROY() {
|
||||||
|
#ifdef CHANGE_UDF_DESTORY_FAILED
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif // ifdef CHANGE_UDF_DESTORY_FAILED
|
||||||
|
}
|
||||||
|
#endif // ifdef CHANGE_UDF_NO_DESTROY
|
||||||
|
|
||||||
|
#ifdef CHANGE_UDF_NO_PROCESS
|
||||||
|
#else
|
||||||
|
DLL_EXPORT int32_t UDFNAME(SUdfDataBlock *block, SUdfColumn *resultCol) {
|
||||||
|
#ifdef CHANGE_UDF_PROCESS_FAILED
|
||||||
|
return -1;
|
||||||
|
#else
|
||||||
|
int32_t code = 0;
|
||||||
|
SUdfColumnData *resultData = &resultCol->colData;
|
||||||
|
for (int32_t i = 0; i < block->numOfRows; ++i) {
|
||||||
|
int j = 0;
|
||||||
|
for (; j < block->numOfCols; ++j) {
|
||||||
|
if (udfColDataIsNull(block->udfCols[j], i)) {
|
||||||
|
code = udfColDataSetNull(resultCol, i);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (j == block->numOfCols) {
|
||||||
|
int32_t luckyNum = 1;
|
||||||
|
code = udfColDataSet(resultCol, i, (char *)&luckyNum, false);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// to simulate actual processing delay by udf
|
||||||
|
#ifdef LINUX
|
||||||
|
usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second)
|
||||||
|
#endif // ifdef LINUX
|
||||||
|
#ifdef WINDOWS
|
||||||
|
Sleep(1);
|
||||||
|
#endif // ifdef WINDOWS
|
||||||
|
resultData->numOfRows = block->numOfRows;
|
||||||
|
return 0;
|
||||||
|
#endif // ifdef CHANGE_UDF_PROCESS_FAILED
|
||||||
|
}
|
||||||
|
#endif // ifdef CHANGE_UDF_NO_PROCESS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/********************************************************************************************************************/
|
||||||
|
// udf revert functions
|
||||||
|
/********************************************************************************************************************/
|
||||||
|
DLL_EXPORT int32_t udf_reverse_init() { return 0; }
|
||||||
|
|
||||||
|
DLL_EXPORT int32_t udf_reverse_destroy() { return 0; }
|
||||||
|
|
||||||
|
static void reverse_data(char* data, size_t len) {
|
||||||
|
size_t i, j;
|
||||||
|
char temp;
|
||||||
|
for (i = 0, j = len - 1; i < j; i++, j--) {
|
||||||
|
temp = data[i];
|
||||||
|
data[i] = data[j];
|
||||||
|
data[j] = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DLL_EXPORT int32_t udf_reverse(SUdfDataBlock *block, SUdfColumn *resultCol) {
|
||||||
|
int32_t code = 0;
|
||||||
|
SUdfColumnData *resultData = &resultCol->colData;
|
||||||
|
for (int32_t i = 0; i < block->numOfRows; ++i) {
|
||||||
|
int j = 0;
|
||||||
|
for (; j < block->numOfCols; ++j) {
|
||||||
|
if (udfColDataIsNull(block->udfCols[j], i)) {
|
||||||
|
code = udfColDataSetNull(resultCol, i);
|
||||||
|
if (code != 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
int32_t oldLen = udfColDataGetDataLen(block->udfCols[j], i);
|
||||||
|
char *pOldData = udfColDataGetData(block->udfCols[j], i);
|
||||||
|
|
||||||
|
|
||||||
|
char *buff = malloc(sizeof(VarDataLenT) + oldLen);
|
||||||
|
if (buff == NULL) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
((VarDataLenT *)buff)[0] = (VarDataLenT)oldLen;
|
||||||
|
memcpy(buff, pOldData, oldLen + sizeof(VarDataLenT));
|
||||||
|
reverse_data(buff + sizeof(VarDataLenT), oldLen);
|
||||||
|
code = udfColDataSet(resultCol, i, buff, false);
|
||||||
|
if (code != 0) {
|
||||||
|
free(buff);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// to simulate actual processing delay by udf
|
||||||
|
#ifdef LINUX
|
||||||
|
usleep(1 * 1000); // usleep takes sleep time in us (1 millionth of a second)
|
||||||
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
|
Sleep(1);
|
||||||
|
#endif
|
||||||
|
resultData->numOfRows = block->numOfRows;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -128,6 +128,86 @@ TEST(NodesTest, sort) {
|
||||||
nodesDestroyList(l);
|
nodesDestroyList(l);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(NodesTest, match) {
|
||||||
|
SNode* pOperator = NULL;
|
||||||
|
int32_t code = nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pOperator);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
SOperatorNode* pOp = (SOperatorNode*)pOperator;
|
||||||
|
SOperatorNode* pLeft = NULL;
|
||||||
|
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_OPERATOR, (SNode**)&pLeft));
|
||||||
|
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pLeft));
|
||||||
|
((SValueNode*)(pLeft->pLeft))->literal = taosStrdup("10");
|
||||||
|
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pLeft->pRight));
|
||||||
|
((SValueNode*)(pLeft->pRight))->literal = taosStrdup("5");
|
||||||
|
pOp->pLeft = (SNode*)pLeft;
|
||||||
|
ASSERT_EQ(TSDB_CODE_SUCCESS, nodesMakeNode(QUERY_NODE_VALUE, &pOp->pRight));
|
||||||
|
((SValueNode*)(pOp->pRight))->literal = taosStrdup("3");
|
||||||
|
pOp->opType = OP_TYPE_GREATER_THAN;
|
||||||
|
|
||||||
|
SNode* pOperatorClone = NULL;
|
||||||
|
code = nodesCloneNode(pOperator, &pOperatorClone);
|
||||||
|
ASSERT_TRUE(nodesMatchNode(pOperator, pOperatorClone));
|
||||||
|
|
||||||
|
SNode* pValue = NULL;
|
||||||
|
code = nodesMakeNode(QUERY_NODE_VALUE, (SNode**)&pValue);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
((SValueNode*)pValue)->literal = taosStrdup("10");
|
||||||
|
ASSERT_FALSE(nodesMatchNode(pOperator, pValue));
|
||||||
|
|
||||||
|
SNode* pValueClone = NULL;
|
||||||
|
code = nodesCloneNode(pValue, &pValueClone);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(nodesMatchNode(pValue, pValueClone));
|
||||||
|
nodesDestroyNode(pValue);
|
||||||
|
nodesDestroyNode(pValueClone);
|
||||||
|
|
||||||
|
SNode* pColumn = NULL, *pColumnClone = NULL;
|
||||||
|
code = nodesMakeNode(QUERY_NODE_COLUMN, &pColumn);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
strcpy(((SColumnNode*)pColumn)->colName, "column");
|
||||||
|
strcpy(((SColumnNode*)pColumn)->tableName, "table");
|
||||||
|
strcpy(((SColumnNode*)pColumn)->dbName, "db");
|
||||||
|
strcpy(((SColumnNode*)pColumn)->node.aliasName, "column");
|
||||||
|
ASSERT_FALSE(nodesMatchNode(pOperator, pColumn));
|
||||||
|
code = nodesCloneNode(pColumn, &pColumnClone);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(nodesMatchNode(pColumn, pColumnClone));
|
||||||
|
nodesDestroyNode(pColumn);
|
||||||
|
nodesDestroyNode(pColumnClone);
|
||||||
|
|
||||||
|
SNode* pFunction = NULL, *pFunctionClone = NULL;
|
||||||
|
code = nodesMakeNode(QUERY_NODE_FUNCTION, (SNode**)&pFunction);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
((SFunctionNode*)pFunction)->funcId = 1;
|
||||||
|
strcpy(((SFunctionNode*)pFunction)->functionName, "now");
|
||||||
|
ASSERT_FALSE(nodesMatchNode(pOperator, pFunction));
|
||||||
|
code = nodesCloneNode(pFunction, &pFunctionClone);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(nodesMatchNode(pFunction, pFunctionClone));
|
||||||
|
nodesDestroyNode(pFunctionClone);
|
||||||
|
nodesDestroyNode(pFunction);
|
||||||
|
|
||||||
|
SNode* pLogicCondition = NULL, *pLogicConditionClone = NULL;
|
||||||
|
code = nodesMakeNode(QUERY_NODE_LOGIC_CONDITION, (SNode**)&pLogicCondition);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
((SLogicConditionNode*)pLogicCondition)->condType = LOGIC_COND_TYPE_AND;
|
||||||
|
((SLogicConditionNode*)pLogicCondition)->pParameterList = NULL;
|
||||||
|
code = nodesMakeList(&((SLogicConditionNode*)pLogicCondition)->pParameterList);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = nodesListAppend((SNodeList*)((SLogicConditionNode*)pLogicCondition)->pParameterList, pOperator);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = nodesListAppend(((SLogicConditionNode*)pLogicCondition)->pParameterList, pOperatorClone);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = nodesCloneNode(pLogicCondition, &pLogicConditionClone);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(nodesMatchNode(pLogicCondition, pLogicConditionClone));
|
||||||
|
ASSERT_FALSE(nodesMatchNode(pLogicCondition, pFunctionClone));
|
||||||
|
|
||||||
|
nodesDestroyNode(pLogicCondition);
|
||||||
|
nodesDestroyNode(pLogicConditionClone);
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
return RUN_ALL_TESTS();
|
||||||
|
|
|
@ -21,39 +21,31 @@
|
||||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||||
int32_t msgBufLen) {
|
int32_t msgBufLen) {
|
||||||
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||||
SToken sToken;
|
SToken sToken = {0};
|
||||||
int32_t code = 0;
|
int code = TSDB_CODE_SUCCESS;
|
||||||
char* tbName = NULL;
|
int32_t lino = 0;
|
||||||
|
|
||||||
NEXT_TOKEN(pTableName, sToken);
|
NEXT_TOKEN(pTableName, sToken);
|
||||||
|
TSDB_CHECK_CONDITION(sToken.n != 0, code, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||||
if (sToken.n == 0) {
|
|
||||||
return buildInvalidOperationMsg(&msg, "empty table name");
|
|
||||||
}
|
|
||||||
|
|
||||||
code = insCreateSName(pName, &sToken, acctId, dbName, &msg);
|
code = insCreateSName(pName, &sToken, acctId, dbName, &msg);
|
||||||
if (code) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
NEXT_TOKEN(pTableName, sToken);
|
NEXT_TOKEN(pTableName, sToken);
|
||||||
|
TSDB_CHECK_CONDITION(sToken.n <= 0, code, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||||
|
|
||||||
if (sToken.n > 0) {
|
end:
|
||||||
return buildInvalidOperationMsg(&msg, "table name format is wrong");
|
if (code != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) {
|
static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSchema* pSchema, bool isTag) {
|
||||||
|
int code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool));
|
bool* pUseCols = taosMemoryCalloc(pBoundInfo->numOfCols, sizeof(bool));
|
||||||
if (NULL == pUseCols) {
|
TSDB_CHECK_NULL(pUseCols, code, lino, end, terrno);
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBoundInfo->numOfBound = 0;
|
pBoundInfo->numOfBound = 0;
|
||||||
int16_t lastColIdx = -1; // last column found
|
int16_t lastColIdx = -1; // last column found
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(cols); ++i) {
|
for (int i = 0; i < taosArrayGetSize(cols); ++i) {
|
||||||
SSmlKv* kv = taosArrayGet(cols, i);
|
SSmlKv* kv = taosArrayGet(cols, i);
|
||||||
|
@ -65,16 +57,9 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche
|
||||||
index = insFindCol(&sToken, 0, t, pSchema);
|
index = insFindCol(&sToken, 0, t, pSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 0) {
|
TSDB_CHECK_CONDITION(index >= 0, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||||
uError("smlBoundColumnData. index:%d", index);
|
TSDB_CHECK_CONDITION(!pUseCols[index], code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||||
code = TSDB_CODE_SML_INVALID_DATA;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (pUseCols[index]) {
|
|
||||||
uError("smlBoundColumnData. already set. index:%d", index);
|
|
||||||
code = TSDB_CODE_SML_INVALID_DATA;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
lastColIdx = index;
|
lastColIdx = index;
|
||||||
pUseCols[index] = true;
|
pUseCols[index] = true;
|
||||||
pBoundInfo->pColIndex[pBoundInfo->numOfBound] = index;
|
pBoundInfo->pColIndex[pBoundInfo->numOfBound] = index;
|
||||||
|
@ -82,11 +67,30 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (code != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
taosMemoryFree(pUseCols);
|
taosMemoryFree(pUseCols);
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t smlMbsToUcs4(const char* mbs, size_t mbsLen, void** result, int32_t* resultLen, int32_t maxLen, void* charsetCxt){
|
||||||
|
int code = TSDB_CODE_SUCCESS;
|
||||||
|
void* pUcs4 = NULL;
|
||||||
|
int32_t lino = 0;
|
||||||
|
pUcs4 = taosMemoryCalloc(1, maxLen);
|
||||||
|
TSDB_CHECK_NULL(pUcs4, code, lino, end, terrno);
|
||||||
|
TSDB_CHECK_CONDITION(taosMbsToUcs4(mbs, mbsLen, (TdUcs4*)pUcs4, maxLen, resultLen, charsetCxt), code, lino, end, terrno);
|
||||||
|
*result = pUcs4;
|
||||||
|
pUcs4 = NULL;
|
||||||
|
|
||||||
|
end:
|
||||||
|
if (code != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
|
taosMemoryFree(pUcs4);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* @brief No json tag for schemaless
|
* @brief No json tag for schemaless
|
||||||
*
|
*
|
||||||
|
@ -99,75 +103,39 @@ end:
|
||||||
*/
|
*/
|
||||||
static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName,
|
static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName,
|
||||||
SMsgBuf* msg, void* charsetCxt) {
|
SMsgBuf* msg, void* charsetCxt) {
|
||||||
|
int code = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||||
if (!pTagArray) {
|
TSDB_CHECK_NULL(pTagArray, code, lino, end, terrno);
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||||
if (!*tagName) {
|
TSDB_CHECK_NULL(*tagName, code, lino, end, terrno);
|
||||||
return terrno;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
|
||||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||||
SSchema* pTagSchema = &pSchema[tags->pColIndex[i]];
|
SSchema* pTagSchema = &pSchema[tags->pColIndex[i]];
|
||||||
SSmlKv* kv = taosArrayGet(cols, i);
|
SSmlKv* kv = taosArrayGet(cols, i);
|
||||||
if (kv == NULL){
|
TSDB_CHECK_NULL(kv, code, lino, end, terrno);
|
||||||
code = terrno;
|
bool cond = (kv->keyLen == strlen(pTagSchema->name) && memcmp(kv->key, pTagSchema->name, kv->keyLen) == 0 && kv->type == pTagSchema->type);
|
||||||
uError("SML smlBuildTagRow error kv is null");
|
TSDB_CHECK_CONDITION(cond, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||||
goto end;
|
TSDB_CHECK_NULL(taosArrayPush(*tagName, pTagSchema->name), code, lino, end, terrno);
|
||||||
}
|
|
||||||
if (kv->keyLen != strlen(pTagSchema->name) || memcmp(kv->key, pTagSchema->name, kv->keyLen) != 0 ||
|
|
||||||
kv->type != pTagSchema->type) {
|
|
||||||
code = TSDB_CODE_SML_INVALID_DATA;
|
|
||||||
uError("SML smlBuildTagRow error col not same %s", pTagSchema->name);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (taosArrayPush(*tagName, pTagSchema->name) == NULL){
|
|
||||||
code = terrno;
|
|
||||||
uError("SML smlBuildTagRow error push tag name");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
STagVal val = {.cid = pTagSchema->colId, .type = pTagSchema->type};
|
||||||
// strcpy(val.colName, pTagSchema->name);
|
|
||||||
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY || pTagSchema->type == TSDB_DATA_TYPE_VARBINARY ||
|
if (pTagSchema->type == TSDB_DATA_TYPE_BINARY || pTagSchema->type == TSDB_DATA_TYPE_VARBINARY ||
|
||||||
pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) {
|
pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||||
val.pData = (uint8_t*)kv->value;
|
val.pData = (uint8_t*)kv->value;
|
||||||
val.nData = kv->length;
|
val.nData = kv->length;
|
||||||
} else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
} else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t output = 0;
|
code = smlMbsToUcs4(kv->value, kv->length, (void**)&val.pData, (int32_t*)&val.nData, kv->length * TSDB_NCHAR_SIZE, charsetCxt);
|
||||||
void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE);
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
if (p == NULL) {
|
|
||||||
code = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)(p), kv->length * TSDB_NCHAR_SIZE, &output, charsetCxt)) {
|
|
||||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
|
||||||
taosMemoryFree(p);
|
|
||||||
code = generateSyntaxErrMsg(msg, TSDB_CODE_PAR_VALUE_TOO_LONG, pTagSchema->name);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
char buf[512] = {0};
|
|
||||||
(void)snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s", strerror(terrno));
|
|
||||||
taosMemoryFree(p);
|
|
||||||
code = buildSyntaxErrMsg(msg, buf, kv->value);
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
val.pData = p;
|
|
||||||
val.nData = output;
|
|
||||||
} else {
|
} else {
|
||||||
(void)memcpy(&val.i64, &(kv->value), kv->length);
|
(void)memcpy(&val.i64, &(kv->value), kv->length);
|
||||||
}
|
}
|
||||||
if (taosArrayPush(pTagArray, &val) == NULL){
|
TSDB_CHECK_NULL(taosArrayPush(pTagArray, &val), code, lino, end, terrno);
|
||||||
code = terrno;
|
|
||||||
uError("SML smlBuildTagRow error push tag array");
|
|
||||||
goto end;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
code = tTagNew(pTagArray, 1, false, ppTag);
|
code = tTagNew(pTagArray, 1, false, ppTag);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (code != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
||||||
STagVal* p = (STagVal*)taosArrayGet(pTagArray, i);
|
STagVal* p = (STagVal*)taosArrayGet(pTagArray, i);
|
||||||
if (p->type == TSDB_DATA_TYPE_NCHAR) {
|
if (p->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
|
@ -179,18 +147,20 @@ end:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta, STableDataCxt** cxt) {
|
int32_t smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta, STableDataCxt** cxt) {
|
||||||
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
SVCreateTbReq* pCreateTbReq = NULL;
|
SVCreateTbReq* pCreateTbReq = NULL;
|
||||||
int ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTbReq, cxt, false, false);
|
sizeof(pTableMeta->uid), pTableMeta, &pCreateTbReq, cxt, false, false);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = initTableColSubmitData(*cxt);
|
ret = initTableColSubmitData(*cxt);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
return ret;
|
|
||||||
|
end:
|
||||||
|
if (ret != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearColValArraySml(SArray* pCols) {
|
void clearColValArraySml(SArray* pCols) {
|
||||||
|
@ -207,78 +177,51 @@ void clearColValArraySml(SArray* pCols) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBuildRow(STableDataCxt* pTableCxt) {
|
int32_t smlBuildRow(STableDataCxt* pTableCxt) {
|
||||||
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||||
if (pRow == NULL){
|
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||||
return terrno;
|
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||||
}
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
int ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
|
||||||
if (TSDB_CODE_SUCCESS != ret) {
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
SRowKey key;
|
SRowKey key;
|
||||||
tRowGetKey(*pRow, &key);
|
tRowGetKey(*pRow, &key);
|
||||||
insCheckTableDataOrder(pTableCxt, &key);
|
insCheckTableDataOrder(pTableCxt, &key);
|
||||||
return TSDB_CODE_SUCCESS;
|
end:
|
||||||
|
if (ret != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32_t index, void* charsetCxt) {
|
int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32_t index, void* charsetCxt) {
|
||||||
int ret = TSDB_CODE_SUCCESS;
|
int ret = TSDB_CODE_SUCCESS;
|
||||||
|
int32_t lino = 0;
|
||||||
SSchema* pColSchema = schema + index;
|
SSchema* pColSchema = schema + index;
|
||||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, index);
|
SColVal* pVal = taosArrayGet(pTableCxt->pValues, index);
|
||||||
if (pVal == NULL) {
|
TSDB_CHECK_NULL(pVal, ret, lino, end, TSDB_CODE_SUCCESS);
|
||||||
return TSDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
SSmlKv* kv = (SSmlKv*)data;
|
SSmlKv* kv = (SSmlKv*)data;
|
||||||
if (kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0 ||
|
if (kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0 ||
|
||||||
kv->type != pColSchema->type) {
|
kv->type != pColSchema->type) {
|
||||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
ret = TSDB_CODE_SML_INVALID_DATA;
|
||||||
char* tmp = taosMemoryCalloc(kv->keyLen + 1, 1);
|
char* tmp = taosMemoryCalloc(kv->keyLen + 1, 1);
|
||||||
if (tmp) {
|
TSDB_CHECK_NULL(tmp, ret, lino, end, terrno);
|
||||||
(void)memcpy(tmp, kv->key, kv->keyLen);
|
(void)memcpy(tmp, kv->key, kv->keyLen);
|
||||||
uInfo("SML data(name:%s type:%s) is not same like the db data(name:%s type:%s)", tmp, tDataTypes[kv->type].name,
|
uInfo("SML data(name:%s type:%s) is not same like the db data(name:%s type:%s)", tmp, tDataTypes[kv->type].name,
|
||||||
pColSchema->name, tDataTypes[pColSchema->type].name);
|
pColSchema->name, tDataTypes[pColSchema->type].name);
|
||||||
taosMemoryFree(tmp);
|
taosMemoryFree(tmp);
|
||||||
} else {
|
|
||||||
uError("SML smlBuildCol out of memory");
|
|
||||||
ret = terrno;
|
|
||||||
}
|
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t len = 0;
|
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, &pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||||
int64_t size = pColSchema->bytes - VARSTR_HEADER_SIZE;
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
if (size <= 0) {
|
|
||||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
char* pUcs4 = taosMemoryCalloc(1, size);
|
|
||||||
if (NULL == pUcs4) {
|
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, size, &len, charsetCxt)) {
|
|
||||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
|
||||||
taosMemoryFree(pUcs4);
|
|
||||||
ret = TSDB_CODE_PAR_VALUE_TOO_LONG;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
taosMemoryFree(pUcs4);
|
|
||||||
ret = TSDB_CODE_TSC_INVALID_VALUE;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
pVal->value.pData = pUcs4;
|
|
||||||
pVal->value.nData = len;
|
|
||||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||||
pVal->value.nData = kv->length;
|
pVal->value.nData = kv->length;
|
||||||
pVal->value.pData = (uint8_t*)kv->value;
|
pVal->value.pData = (uint8_t*)kv->value;
|
||||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
pVal->value.nData = kv->length;
|
pVal->value.nData = kv->length;
|
||||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||||
if (!pVal->value.pData) {
|
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
uError("SML smlBuildCol malloc failed %s:%d, err: %s", __func__, __LINE__, tstrerror(ret));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||||
} else {
|
} else {
|
||||||
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
||||||
|
@ -286,12 +229,17 @@ int32_t smlBuildCol(STableDataCxt* pTableCxt, SSchema* schema, void* data, int32
|
||||||
pVal->flag = CV_FLAG_VALUE;
|
pVal->flag = CV_FLAG_VALUE;
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (ret != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||||
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols,
|
int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSchema, SArray* cols,
|
||||||
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
STableMeta* pTableMeta, char* tableName, const char* sTableName, int32_t sTableNameLen, int32_t ttl,
|
||||||
char* msgBuf, int32_t msgBufLen, void* charsetCxt) {
|
char* msgBuf, int32_t msgBufLen, void* charsetCxt) {
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t ret = 0;
|
||||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||||
|
|
||||||
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
||||||
|
@ -299,50 +247,32 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
||||||
SVCreateTbReq* pCreateTblReq = NULL;
|
SVCreateTbReq* pCreateTblReq = NULL;
|
||||||
SArray* tagName = NULL;
|
SArray* tagName = NULL;
|
||||||
|
|
||||||
int ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "init bound cols error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = smlBoundColumnData(tags, &bindTags, pTagsSchema, true);
|
ret = smlBoundColumnData(tags, &bindTags, pTagsSchema, true);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "bound tags error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
STag* pTag = NULL;
|
STag* pTag = NULL;
|
||||||
|
|
||||||
ret = smlBuildTagRow(tags, &bindTags, pTagsSchema, &pTag, &tagName, &pBuf, charsetCxt);
|
ret = smlBuildTagRow(tags, &bindTags, pTagsSchema, &pTag, &tagName, &pBuf, charsetCxt);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||||
if (NULL == pCreateTblReq) {
|
TSDB_CHECK_NULL(pCreateTblReq, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
ret = insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName,
|
ret = insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName,
|
||||||
pTableMeta->tableInfo.numOfTags, ttl);
|
pTableMeta->tableInfo.numOfTags, ttl);
|
||||||
if (TSDB_CODE_SUCCESS != ret) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1);
|
pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1);
|
||||||
if (pCreateTblReq->ctb.stbName == NULL){
|
TSDB_CHECK_NULL(pCreateTblReq->ctb.stbName, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
(void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen);
|
(void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen);
|
||||||
|
|
||||||
if (dataFormat) {
|
if (dataFormat) {
|
||||||
STableDataCxt** pTableCxt = (STableDataCxt**)taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj,
|
STableDataCxt** pTableCxt = (STableDataCxt**)taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj,
|
||||||
&pTableMeta->uid, sizeof(pTableMeta->uid));
|
&pTableMeta->uid, sizeof(pTableMeta->uid));
|
||||||
if (NULL == pTableCxt) {
|
TSDB_CHECK_NULL(pTableCxt, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "dataformat true. get tableDataCtx error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
(*pTableCxt)->pData->flags |= SUBMIT_REQ_AUTO_CREATE_TABLE;
|
(*pTableCxt)->pData->flags |= SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||||
(*pTableCxt)->pData->pCreateTbReq = pCreateTblReq;
|
(*pTableCxt)->pData->pCreateTbReq = pCreateTblReq;
|
||||||
(*pTableCxt)->pMeta->uid = pTableMeta->uid;
|
(*pTableCxt)->pMeta->uid = pTableMeta->uid;
|
||||||
|
@ -354,86 +284,47 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
||||||
STableDataCxt* pTableCxt = NULL;
|
STableDataCxt* pTableCxt = NULL;
|
||||||
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false);
|
sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
||||||
ret = smlBoundColumnData(colsSchema, &pTableCxt->boundColsInfo, pSchema, false);
|
ret = smlBoundColumnData(colsSchema, &pTableCxt->boundColsInfo, pSchema, false);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "bound cols error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = initTableColSubmitData(pTableCxt);
|
ret = initTableColSubmitData(pTableCxt);
|
||||||
if (ret != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "initTableColSubmitData error");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t rowNum = taosArrayGetSize(cols);
|
int32_t rowNum = taosArrayGetSize(cols);
|
||||||
if (rowNum <= 0) {
|
TSDB_CHECK_CONDITION(rowNum > 0, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "cols size <= 0");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t r = 0; r < rowNum; ++r) {
|
for (int32_t r = 0; r < rowNum; ++r) {
|
||||||
void* rowData = taosArrayGetP(cols, r);
|
void* rowData = taosArrayGetP(cols, r);
|
||||||
if (rowData == NULL) {
|
TSDB_CHECK_NULL(rowData, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
// 1. set the parsed value from sql string
|
// 1. set the parsed value from sql string
|
||||||
for (int c = 0; c < pTableCxt->boundColsInfo.numOfBound; ++c) {
|
for (int c = 0; c < pTableCxt->boundColsInfo.numOfBound; ++c) {
|
||||||
SSchema* pColSchema = &pSchema[pTableCxt->boundColsInfo.pColIndex[c]];
|
SSchema* pColSchema = &pSchema[pTableCxt->boundColsInfo.pColIndex[c]];
|
||||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, pTableCxt->boundColsInfo.pColIndex[c]);
|
SColVal* pVal = taosArrayGet(pTableCxt->pValues, pTableCxt->boundColsInfo.pColIndex[c]);
|
||||||
if (pVal == NULL) {
|
TSDB_CHECK_NULL(pVal, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
SSmlKv* kv = *(SSmlKv**)p;
|
SSmlKv* kv = *(SSmlKv**)p;
|
||||||
if (kv->type != pColSchema->type) {
|
TSDB_CHECK_CONDITION(kv->type == pColSchema->type, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "kv type not equal to col type");
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||||
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
||||||
}
|
}
|
||||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||||
int32_t len = 0;
|
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, (int32_t*)&pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||||
char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE);
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
if (NULL == pUcs4) {
|
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
if (!taosMbsToUcs4(kv->value, kv->length, (TdUcs4*)pUcs4, pColSchema->bytes - VARSTR_HEADER_SIZE, &len, charsetCxt)) {
|
|
||||||
if (terrno == TAOS_SYSTEM_ERROR(E2BIG)) {
|
|
||||||
uError("sml bind taosMbsToUcs4 error, kv length:%d, bytes:%d, kv->value:%s", (int)kv->length,
|
|
||||||
pColSchema->bytes, kv->value);
|
|
||||||
(void)buildInvalidOperationMsg(&pBuf, "value too long");
|
|
||||||
ret = TSDB_CODE_PAR_VALUE_TOO_LONG;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
ret = buildInvalidOperationMsg(&pBuf, strerror(terrno));
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
pVal->value.pData = pUcs4;
|
|
||||||
pVal->value.nData = len;
|
|
||||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||||
pVal->value.nData = kv->length;
|
pVal->value.nData = kv->length;
|
||||||
pVal->value.pData = (uint8_t*)kv->value;
|
pVal->value.pData = (uint8_t*)kv->value;
|
||||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||||
pVal->value.nData = kv->length;
|
pVal->value.nData = kv->length;
|
||||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||||
if (NULL == pVal->value.pData) {
|
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||||
} else {
|
} else {
|
||||||
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
(void)memcpy(&pVal->value.val, &(kv->value), kv->length);
|
||||||
|
@ -442,22 +333,20 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
||||||
}
|
}
|
||||||
|
|
||||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||||
if (NULL == pRow) {
|
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||||
ret = terrno;
|
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||||
if (TSDB_CODE_SUCCESS != ret) {
|
TSDB_CHECK_CODE(ret, lino, end);
|
||||||
ret = buildInvalidOperationMsg(&pBuf, "tRowBuild error");
|
SRowKey key = {0};
|
||||||
goto end;
|
|
||||||
}
|
|
||||||
SRowKey key;
|
|
||||||
tRowGetKey(*pRow, &key);
|
tRowGetKey(*pRow, &key);
|
||||||
insCheckTableDataOrder(pTableCxt, &key);
|
insCheckTableDataOrder(pTableCxt, &key);
|
||||||
clearColValArraySml(pTableCxt->pValues);
|
clearColValArraySml(pTableCxt->pValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
if (ret != 0){
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||||
|
ret = buildInvalidOperationMsg(&pBuf, tstrerror(ret));
|
||||||
|
}
|
||||||
insDestroyBoundColInfo(&bindTags);
|
insDestroyBoundColInfo(&bindTags);
|
||||||
tdDestroySVCreateTbReq(pCreateTblReq);
|
tdDestroySVCreateTbReq(pCreateTblReq);
|
||||||
taosMemoryFree(pCreateTblReq);
|
taosMemoryFree(pCreateTblReq);
|
||||||
|
@ -466,29 +355,22 @@ end:
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlInitHandle(SQuery** query) {
|
int32_t smlInitHandle(SQuery** query) {
|
||||||
*query = NULL;
|
int32_t lino = 0;
|
||||||
|
int32_t code = 0;
|
||||||
SQuery* pQuery = NULL;
|
SQuery* pQuery = NULL;
|
||||||
SVnodeModifyOpStmt* stmt = NULL;
|
SVnodeModifyOpStmt* stmt = NULL;
|
||||||
|
TSDB_CHECK_NULL(query, code, lino, end, TSDB_CODE_INVALID_PARA);
|
||||||
|
|
||||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
*query = NULL;
|
||||||
if (code != 0) {
|
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||||
uError("SML create pQuery error");
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||||
pQuery->haveResultSet = false;
|
pQuery->haveResultSet = false;
|
||||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||||
code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&stmt);
|
code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&stmt);
|
||||||
if (code != 0) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
uError("SML create SVnodeModifyOpStmt error");
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
stmt->pTableBlockHashObj = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
stmt->pTableBlockHashObj = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||||
if (stmt->pTableBlockHashObj == NULL){
|
TSDB_CHECK_NULL(stmt->pTableBlockHashObj, code, lino, end, terrno);
|
||||||
uError("SML create pTableBlockHashObj error");
|
|
||||||
code = terrno;
|
|
||||||
goto END;
|
|
||||||
}
|
|
||||||
stmt->freeHashFunc = insDestroyTableDataCxtHashMap;
|
stmt->freeHashFunc = insDestroyTableDataCxtHashMap;
|
||||||
stmt->freeArrayFunc = insDestroyVgroupDataCxtList;
|
stmt->freeArrayFunc = insDestroyVgroupDataCxtList;
|
||||||
|
|
||||||
|
@ -496,24 +378,28 @@ int32_t smlInitHandle(SQuery** query) {
|
||||||
*query = pQuery;
|
*query = pQuery;
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
END:
|
end:
|
||||||
|
if (code != 0) {
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
|
}
|
||||||
nodesDestroyNode((SNode*)stmt);
|
nodesDestroyNode((SNode*)stmt);
|
||||||
qDestroyQuery(pQuery);
|
qDestroyQuery(pQuery);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash) {
|
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash) {
|
||||||
|
int32_t lino = 0;
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)(handle)->pRoot;
|
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)(handle)->pRoot;
|
||||||
// merge according to vgId
|
code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
||||||
int32_t code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
uError("insMergeTableDataCxt failed");
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
code = insBuildVgDataBlocks(pVgHash, pStmt->pVgDataBlocks, &pStmt->pDataBlocks, false);
|
code = insBuildVgDataBlocks(pVgHash, pStmt->pVgDataBlocks, &pStmt->pDataBlocks, false);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
TSDB_CHECK_CODE(code, lino, end);
|
||||||
uError("insBuildVgDataBlocks failed");
|
|
||||||
return code;
|
end:
|
||||||
|
if (code != 0) {
|
||||||
|
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6060,11 +6060,22 @@ static int32_t stbJoinOptCreateTagScanNode(SLogicNode* pJoin, SNodeList** ppList
|
||||||
}
|
}
|
||||||
|
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
|
SName* pPrev = NULL;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
code = stbJoinOptRewriteToTagScan(pJoin, pNode);
|
code = stbJoinOptRewriteToTagScan(pJoin, pNode);
|
||||||
if (code) {
|
if (code) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||||
|
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||||
|
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||||
|
pPrev = &pScan->tableName;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pScan->needSplit = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (TSDB_CODE_SUCCESS == code) {
|
if (TSDB_CODE_SUCCESS == code) {
|
||||||
|
@ -6156,6 +6167,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t i = 0;
|
int32_t i = 0;
|
||||||
|
SName* pPrev = NULL;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pList) {
|
FOREACH(pNode, pList) {
|
||||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||||
|
@ -6173,6 +6185,16 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
||||||
*(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1;
|
*(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1;
|
||||||
|
|
||||||
pScan->scanType = SCAN_TYPE_TABLE;
|
pScan->scanType = SCAN_TYPE_TABLE;
|
||||||
|
|
||||||
|
if (pScan->pVgroupList && 1 == pScan->pVgroupList->numOfVgroups) {
|
||||||
|
if (NULL == pPrev || 0 == strcmp(pPrev->dbname, pScan->tableName.dbname)) {
|
||||||
|
pPrev = &pScan->tableName;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pScan->needSplit = true;
|
||||||
|
*(srcScan + i - 1) = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppList = pList;
|
*ppList = pList;
|
||||||
|
|
|
@ -55,16 +55,10 @@ int32_t validateQueryPlanNode(SValidatePlanContext* pCxt, SQueryPlan* pPlan) {
|
||||||
SNode* pSubNode = NULL;
|
SNode* pSubNode = NULL;
|
||||||
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
||||||
FOREACH(pSubNode, pSubplans->pNodeList) {
|
FOREACH(pSubNode, pSubplans->pNodeList) {
|
||||||
if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pNode)) {
|
|
||||||
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = doValidatePhysiNode(pCxt, pSubNode);
|
code = doValidatePhysiNode(pCxt, pSubNode);
|
||||||
if (code) {
|
if (code) break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (code) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
@ -142,24 +136,7 @@ int32_t validateQueryPlan(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
||||||
|
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
SNode* pNode = NULL;
|
SNode* pNode = NULL;
|
||||||
FOREACH(pNode, pPlan->pSubplans) {
|
code = validateQueryPlanNode(&cxt, pPlan);
|
||||||
if (QUERY_NODE_NODE_LIST != nodeType(pNode)) {
|
|
||||||
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
SNode* pSubNode = NULL;
|
|
||||||
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
|
||||||
FOREACH(pSubNode, pSubplans->pNodeList) {
|
|
||||||
code = doValidatePhysiNode(&cxt, pSubNode);
|
|
||||||
if (code) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (code) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
destoryValidatePlanContext(&cxt);
|
destoryValidatePlanContext(&cxt);
|
||||||
return code;
|
return code;
|
||||||
|
|
|
@ -161,6 +161,10 @@ int32_t qSubPlanToString(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
||||||
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesStringToNode(pStr, (SNode**)pSubplan); }
|
int32_t qStringToSubplan(const char* pStr, SSubplan** pSubplan) { return nodesStringToNode(pStr, (SNode**)pSubplan); }
|
||||||
|
|
||||||
int32_t qSubPlanToMsg(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
int32_t qSubPlanToMsg(const SSubplan* pSubplan, char** pStr, int32_t* pLen) {
|
||||||
|
if (NULL == pSubplan) {
|
||||||
|
return terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) {
|
if (SUBPLAN_TYPE_MODIFY == pSubplan->subplanType && NULL == pSubplan->pNode) {
|
||||||
SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink;
|
SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink;
|
||||||
*pLen = insert->size;
|
*pLen = insert->size;
|
||||||
|
|
|
@ -137,6 +137,8 @@ static void processTaskQueue(SQueueInfo *pInfo, SSchedMsg *pSchedMsg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t initTaskQueue() {
|
int32_t initTaskQueue() {
|
||||||
|
memset(&taskQueue, 0, sizeof(taskQueue));
|
||||||
|
|
||||||
taskQueue.wrokrerPool.name = "taskWorkPool";
|
taskQueue.wrokrerPool.name = "taskWorkPool";
|
||||||
taskQueue.wrokrerPool.min = tsNumOfTaskQueueThreads;
|
taskQueue.wrokrerPool.min = tsNumOfTaskQueueThreads;
|
||||||
taskQueue.wrokrerPool.max = tsNumOfTaskQueueThreads;
|
taskQueue.wrokrerPool.max = tsNumOfTaskQueueThreads;
|
||||||
|
|
|
@ -477,6 +477,8 @@ extern SQueryMgmt gQueryMgmt;
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
|
||||||
|
#if 0
|
||||||
#define QW_UNLOCK(type, _lock) \
|
#define QW_UNLOCK(type, _lock) \
|
||||||
do { \
|
do { \
|
||||||
if (QW_READ == (type)) { \
|
if (QW_READ == (type)) { \
|
||||||
|
@ -505,6 +507,16 @@ extern SQueryMgmt gQueryMgmt;
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
#else
|
||||||
|
#define QW_UNLOCK(type, _lock) \
|
||||||
|
do { \
|
||||||
|
if (QW_READ == (type)) { \
|
||||||
|
taosRUnLockLatch(_lock); \
|
||||||
|
} else { \
|
||||||
|
taosWUnLockLatch(_lock); \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
#endif
|
||||||
|
|
||||||
extern SQWorkerMgmt gQwMgmt;
|
extern SQWorkerMgmt gQwMgmt;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "qwInt.h"
|
#include "qwInt.h"
|
||||||
#include "qworker.h"
|
#include "qworker.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
void qwSetConcurrentTaskNumCb(int32_t taskNum) {
|
void qwSetConcurrentTaskNumCb(int32_t taskNum) {
|
||||||
int32_t finTaskNum = TMIN(taskNum, tsNumOfQueryThreads * QW_DEFAULT_THREAD_TASK_NUM);
|
int32_t finTaskNum = TMIN(taskNum, tsNumOfQueryThreads * QW_DEFAULT_THREAD_TASK_NUM);
|
||||||
|
|
||||||
|
@ -33,6 +34,7 @@ void qwIncConcurrentTaskNumCb(void) {
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t qwInitJobInfo(QW_FPARAMS_DEF, SQWJobInfo* pJob) {
|
int32_t qwInitJobInfo(QW_FPARAMS_DEF, SQWJobInfo* pJob) {
|
||||||
pJob->pSessions= taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
pJob->pSessions= taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
|
|
|
@ -2985,19 +2985,20 @@ static int32_t doScalarFunction2(SScalarParam *pInput, int32_t inputNum, SScalar
|
||||||
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
bool hasNullType = (IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[0])) || IS_NULL_TYPE(GET_PARAM_TYPE(&pInput[1])));
|
||||||
|
|
||||||
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||||
if (pInput[0].numOfRows == pInput[1].numOfRows) {
|
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||||
if (colDataIsNull_s(pInputData[0], i) || colDataIsNull_s(pInputData[1], i) || hasNullType) {
|
int32_t colIdx1 = (pInput[0].numOfRows == 1) ? 0 : i;
|
||||||
|
int32_t colIdx2 = (pInput[1].numOfRows == 1) ? 0 : i;
|
||||||
|
if (colDataIsNull_s(pInputData[0], colIdx1) || colDataIsNull_s(pInputData[1], colIdx2) || hasNullType) {
|
||||||
colDataSetNULL(pOutputData, i);
|
colDataSetNULL(pOutputData, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double in2;
|
double in2;
|
||||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], i));
|
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], colIdx2));
|
||||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
switch (GET_PARAM_TYPE(&pInput[0])) {
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
case TSDB_DATA_TYPE_DOUBLE: {
|
||||||
double *in = (double *)pInputData[0]->pData;
|
double *in = (double *)pInputData[0]->pData;
|
||||||
double *out = (double *)pOutputData->pData;
|
double *out = (double *)pOutputData->pData;
|
||||||
double result = d1(in[i], in2);
|
double result = d1(in[colIdx1], in2);
|
||||||
if (isinf(result) || isnan(result)) {
|
if (isinf(result) || isnan(result)) {
|
||||||
colDataSetNULL(pOutputData, i);
|
colDataSetNULL(pOutputData, i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3008,7 +3009,7 @@ static int32_t doScalarFunction2(SScalarParam *pInput, int32_t inputNum, SScalar
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
case TSDB_DATA_TYPE_FLOAT: {
|
||||||
float *in = (float *)pInputData[0]->pData;
|
float *in = (float *)pInputData[0]->pData;
|
||||||
float *out = (float *)pOutputData->pData;
|
float *out = (float *)pOutputData->pData;
|
||||||
float result = f1(in[i], (float)in2);
|
float result = f1(in[colIdx1], (float)in2);
|
||||||
if (isinf(result) || isnan(result)) {
|
if (isinf(result) || isnan(result)) {
|
||||||
colDataSetNULL(pOutputData, i);
|
colDataSetNULL(pOutputData, i);
|
||||||
} else {
|
} else {
|
||||||
|
@ -3019,248 +3020,61 @@ static int32_t doScalarFunction2(SScalarParam *pInput, int32_t inputNum, SScalar
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
case TSDB_DATA_TYPE_TINYINT: {
|
||||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
int8_t *in = (int8_t *)pInputData[0]->pData;
|
||||||
int8_t *out = (int8_t *)pOutputData->pData;
|
int8_t *out = (int8_t *)pOutputData->pData;
|
||||||
int8_t result = (int8_t)d1((double)in[i], in2);
|
int8_t result = (int8_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
case TSDB_DATA_TYPE_SMALLINT: {
|
||||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
int16_t *in = (int16_t *)pInputData[0]->pData;
|
||||||
int16_t *out = (int16_t *)pOutputData->pData;
|
int16_t *out = (int16_t *)pOutputData->pData;
|
||||||
int16_t result = (int16_t)d1((double)in[i], in2);
|
int16_t result = (int16_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
int32_t *in = (int32_t *)pInputData[0]->pData;
|
||||||
int32_t *out = (int32_t *)pOutputData->pData;
|
int32_t *out = (int32_t *)pOutputData->pData;
|
||||||
int32_t result = (int32_t)d1((double)in[i], in2);
|
int32_t result = (int32_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
case TSDB_DATA_TYPE_BIGINT: {
|
||||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
int64_t *in = (int64_t *)pInputData[0]->pData;
|
||||||
int64_t *out = (int64_t *)pOutputData->pData;
|
int64_t *out = (int64_t *)pOutputData->pData;
|
||||||
int64_t result = (int64_t)d1((double)in[i], in2);
|
int64_t result = (int64_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
case TSDB_DATA_TYPE_UTINYINT: {
|
||||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
||||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
uint8_t *out = (uint8_t *)pOutputData->pData;
|
||||||
uint8_t result = (uint8_t)d1((double)in[i], in2);
|
uint8_t result = (uint8_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
case TSDB_DATA_TYPE_USMALLINT: {
|
||||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
||||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
uint16_t *out = (uint16_t *)pOutputData->pData;
|
||||||
uint16_t result = (uint16_t)d1((double)in[i], in2);
|
uint16_t result = (uint16_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
case TSDB_DATA_TYPE_UINT: {
|
||||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
||||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
uint32_t *out = (uint32_t *)pOutputData->pData;
|
||||||
uint32_t result = (uint32_t)d1((double)in[i], in2);
|
uint32_t result = (uint32_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
case TSDB_DATA_TYPE_UBIGINT: {
|
||||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
||||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
uint64_t *out = (uint64_t *)pOutputData->pData;
|
||||||
uint64_t result = (uint64_t)d1((double)in[i], in2);
|
uint64_t result = (uint64_t)d1((double)in[colIdx1], in2);
|
||||||
out[i] = result;
|
out[i] = result;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (pInput[0].numOfRows == 1) { // left operand is constant
|
|
||||||
if (colDataIsNull_s(pInputData[0], 0) || hasNullType) {
|
|
||||||
colDataSetNNULL(pOutputData, 0, pInput[1].numOfRows);
|
|
||||||
} else {
|
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
|
||||||
if (colDataIsNull_s(pInputData[1], i)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double in2;
|
|
||||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], i));
|
|
||||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
|
||||||
double *in = (double *)pInputData[0]->pData;
|
|
||||||
double *out = (double *)pOutputData->pData;
|
|
||||||
double result = d1(in[0], in2);
|
|
||||||
if (isinf(result) || isnan(result)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
} else {
|
|
||||||
out[i] = result;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
|
||||||
float *in = (float *)pInputData[0]->pData;
|
|
||||||
float *out = (float *)pOutputData->pData;
|
|
||||||
float result = f1(in[0], (float)in2);
|
|
||||||
if (isinf(result) || isnan(result)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
} else {
|
|
||||||
out[i] = result;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
|
||||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
|
||||||
int8_t *out = (int8_t *)pOutputData->pData;
|
|
||||||
int8_t result = (int8_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
|
||||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
|
||||||
int16_t *out = (int16_t *)pOutputData->pData;
|
|
||||||
int16_t result = (int16_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
|
||||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
|
||||||
int32_t *out = (int32_t *)pOutputData->pData;
|
|
||||||
int32_t result = (int32_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
|
||||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
|
||||||
int64_t *out = (int64_t *)pOutputData->pData;
|
|
||||||
int64_t result = (int64_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
|
||||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
|
||||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
|
||||||
uint8_t result = (uint8_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
|
||||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
|
||||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
|
||||||
uint16_t result = (uint16_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
|
||||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
|
||||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
|
||||||
uint32_t result = (uint32_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
|
||||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
|
||||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
|
||||||
uint64_t result = (uint64_t)d1((double)in[0], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (pInput[1].numOfRows == 1) {
|
|
||||||
if (colDataIsNull_s(pInputData[1], 0) || hasNullType) {
|
|
||||||
colDataSetNNULL(pOutputData, 0, pInput[0].numOfRows);
|
|
||||||
} else {
|
|
||||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
|
||||||
if (colDataIsNull_s(pInputData[0], i)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double in2;
|
|
||||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], 0));
|
|
||||||
switch (GET_PARAM_TYPE(&pInput[0])) {
|
|
||||||
case TSDB_DATA_TYPE_DOUBLE: {
|
|
||||||
double *in = (double *)pInputData[0]->pData;
|
|
||||||
double *out = (double *)pOutputData->pData;
|
|
||||||
double result = d1(in[i], in2);
|
|
||||||
if (isinf(result) || isnan(result)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
} else {
|
|
||||||
out[i] = result;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_FLOAT: {
|
|
||||||
float *in = (float *)pInputData[0]->pData;
|
|
||||||
float *out = (float *)pOutputData->pData;
|
|
||||||
float result = f1(in[i], in2);
|
|
||||||
if (isinf(result) || isnan(result)) {
|
|
||||||
colDataSetNULL(pOutputData, i);
|
|
||||||
} else {
|
|
||||||
out[i] = result;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_TINYINT: {
|
|
||||||
int8_t *in = (int8_t *)pInputData[0]->pData;
|
|
||||||
int8_t *out = (int8_t *)pOutputData->pData;
|
|
||||||
int8_t result = (int8_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_SMALLINT: {
|
|
||||||
int16_t *in = (int16_t *)pInputData[0]->pData;
|
|
||||||
int16_t *out = (int16_t *)pOutputData->pData;
|
|
||||||
int16_t result = (int16_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_INT: {
|
|
||||||
int32_t *in = (int32_t *)pInputData[0]->pData;
|
|
||||||
int32_t *out = (int32_t *)pOutputData->pData;
|
|
||||||
int32_t result = (int32_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_BIGINT: {
|
|
||||||
int64_t *in = (int64_t *)pInputData[0]->pData;
|
|
||||||
int64_t *out = (int64_t *)pOutputData->pData;
|
|
||||||
int64_t result = (int64_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UTINYINT: {
|
|
||||||
uint8_t *in = (uint8_t *)pInputData[0]->pData;
|
|
||||||
uint8_t *out = (uint8_t *)pOutputData->pData;
|
|
||||||
uint8_t result = (uint8_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_USMALLINT: {
|
|
||||||
uint16_t *in = (uint16_t *)pInputData[0]->pData;
|
|
||||||
uint16_t *out = (uint16_t *)pOutputData->pData;
|
|
||||||
uint16_t result = (uint16_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UINT: {
|
|
||||||
uint32_t *in = (uint32_t *)pInputData[0]->pData;
|
|
||||||
uint32_t *out = (uint32_t *)pOutputData->pData;
|
|
||||||
uint32_t result = (uint32_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TSDB_DATA_TYPE_UBIGINT: {
|
|
||||||
uint64_t *in = (uint64_t *)pInputData[0]->pData;
|
|
||||||
uint64_t *out = (uint64_t *)pOutputData->pData;
|
|
||||||
uint64_t result = (uint64_t)d1((double)in[i], in2);
|
|
||||||
out[i] = result;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pOutput->numOfRows = numOfRows;
|
pOutput->numOfRows = numOfRows;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -121,19 +121,6 @@ _return:
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t convertBinaryToDouble(const void *inData, void *outData) {
|
|
||||||
char *tmp = taosMemoryCalloc(1, varDataTLen(inData));
|
|
||||||
if (tmp == NULL) {
|
|
||||||
*((double *)outData) = 0.;
|
|
||||||
SCL_ERR_RET(terrno);
|
|
||||||
}
|
|
||||||
(void)memcpy(tmp, varDataVal(inData), varDataLen(inData));
|
|
||||||
double ret = taosStr2Double(tmp, NULL);
|
|
||||||
taosMemoryFree(tmp);
|
|
||||||
*((double *)outData) = ret;
|
|
||||||
SCL_RET(TSDB_CODE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef int32_t (*_getBigintValue_fn_t)(void *src, int32_t index, int64_t *res);
|
typedef int32_t (*_getBigintValue_fn_t)(void *src, int32_t index, int64_t *res);
|
||||||
|
|
||||||
int32_t getVectorBigintValue_TINYINT(void *src, int32_t index, int64_t *res) {
|
int32_t getVectorBigintValue_TINYINT(void *src, int32_t index, int64_t *res) {
|
||||||
|
@ -1129,17 +1116,11 @@ int32_t vectorConvertCols(SScalarParam *pLeft, SScalarParam *pRight, SScalarPara
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != GET_PARAM_TYPE(param1)) {
|
if (type != GET_PARAM_TYPE(param1)) {
|
||||||
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
SCL_ERR_RET(vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows));
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != GET_PARAM_TYPE(param2)) {
|
if (type != GET_PARAM_TYPE(param2)) {
|
||||||
code = vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows);
|
SCL_ERR_RET(vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows));
|
||||||
if (code) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -1208,22 +1189,16 @@ static int32_t vectorMathTsAddHelper(SColumnInfoData *pLeftCol, SColumnInfoData
|
||||||
static int32_t vectorConvertVarToDouble(SScalarParam *pInput, int32_t *converted, SColumnInfoData **pOutputCol) {
|
static int32_t vectorConvertVarToDouble(SScalarParam *pInput, int32_t *converted, SColumnInfoData **pOutputCol) {
|
||||||
SScalarParam output = {0};
|
SScalarParam output = {0};
|
||||||
SColumnInfoData *pCol = pInput->columnData;
|
SColumnInfoData *pCol = pInput->columnData;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON && pCol->info.type != TSDB_DATA_TYPE_VARBINARY) {
|
|
||||||
int32_t code = vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
*pOutputCol = NULL;
|
*pOutputCol = NULL;
|
||||||
SCL_ERR_RET(code);
|
if (IS_VAR_DATA_TYPE(pCol->info.type) && pCol->info.type != TSDB_DATA_TYPE_JSON && pCol->info.type != TSDB_DATA_TYPE_VARBINARY) {
|
||||||
}
|
SCL_ERR_RET(vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1));
|
||||||
|
|
||||||
*converted = VECTOR_DO_CONVERT;
|
*converted = VECTOR_DO_CONVERT;
|
||||||
|
|
||||||
*pOutputCol = output.columnData;
|
*pOutputCol = output.columnData;
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
*converted = VECTOR_UN_CONVERT;
|
*converted = VECTOR_UN_CONVERT;
|
||||||
|
|
||||||
*pOutputCol = pInput->columnData;
|
*pOutputCol = pInput->columnData;
|
||||||
SCL_RET(TSDB_CODE_SUCCESS);
|
SCL_RET(TSDB_CODE_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -1616,17 +1591,19 @@ int32_t vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
|
||||||
|
|
||||||
double *output = (double *)pOutputCol->pData;
|
double *output = (double *)pOutputCol->pData;
|
||||||
|
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (IS_NULL) {
|
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||||
|
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||||
|
if (IS_HELPER_NULL(pLeftCol, leftidx) || IS_HELPER_NULL(pRightCol, rightidx)) {
|
||||||
colDataSetNULL(pOutputCol, i);
|
colDataSetNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
double lx = 0;
|
double lx = 0;
|
||||||
double rx = 0;
|
double rx = 0;
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, i, &lx));
|
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, leftidx, &lx));
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, i, &rx));
|
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, rightidx, &rx));
|
||||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||||
colDataSetNULL(pOutputCol, i);
|
colDataSetNULL(pOutputCol, i);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1634,51 +1611,6 @@ int32_t vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
|
||||||
|
|
||||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
|
||||||
double lx = 0;
|
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, 0, &lx));
|
|
||||||
if (IS_HELPER_NULL(pLeftCol, 0)) { // Set pLeft->numOfRows NULL value
|
|
||||||
colDataSetNNULL(pOutputCol, 0, pRight->numOfRows);
|
|
||||||
} else {
|
|
||||||
for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) {
|
|
||||||
if (IS_HELPER_NULL(pRightCol, i)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
double rx = 0;
|
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, i, &rx));
|
|
||||||
if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (pRight->numOfRows == 1) {
|
|
||||||
double rx = 0;
|
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, 0, &rx));
|
|
||||||
if (IS_HELPER_NULL(pRightCol, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value
|
|
||||||
colDataSetNNULL(pOutputCol, 0, pLeft->numOfRows);
|
|
||||||
} else {
|
|
||||||
for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) {
|
|
||||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
double lx = 0;
|
|
||||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, i, &lx));
|
|
||||||
if (isnan(lx) || isinf(lx)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
doReleaseVec(pLeftCol, leftConvert);
|
doReleaseVec(pLeftCol, leftConvert);
|
||||||
|
@ -1739,33 +1671,6 @@ int32_t vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vectorBitAndHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
|
||||||
int32_t numOfRows, int32_t step, int32_t i) {
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft;
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight;
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
|
||||||
|
|
||||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
|
||||||
|
|
||||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
|
||||||
colDataSetNNULL(pOutputCol, 0, numOfRows);
|
|
||||||
} else {
|
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
|
||||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue; // TODO set null or ignore
|
|
||||||
}
|
|
||||||
int64_t leftRes = 0;
|
|
||||||
int64_t rightRes = 0;
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFnRight(RIGHT_COL, 0, &rightRes));
|
|
||||||
*output = leftRes & rightRes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SCL_RET(TSDB_CODE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
|
@ -1786,23 +1691,20 @@ int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
||||||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||||
|
|
||||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (IS_NULL) {
|
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||||
|
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||||
|
if (IS_HELPER_NULL(pRightCol, rightidx) || IS_HELPER_NULL(pLeftCol, leftidx)) {
|
||||||
colDataSetNULL(pOutputCol, i);
|
colDataSetNULL(pOutputCol, i);
|
||||||
continue; // TODO set null or ignore
|
continue; // TODO set null or ignore
|
||||||
}
|
}
|
||||||
int64_t leftRes = 0;
|
int64_t leftRes = 0;
|
||||||
int64_t rightRes = 0;
|
int64_t rightRes = 0;
|
||||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||||
*output = leftRes & rightRes;
|
*output = leftRes & rightRes;
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
|
||||||
SCL_ERR_JRET(vectorBitAndHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i));
|
|
||||||
} else if (pRight->numOfRows == 1) {
|
|
||||||
SCL_ERR_JRET(vectorBitAndHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
doReleaseVec(pLeftCol, leftConvert);
|
doReleaseVec(pLeftCol, leftConvert);
|
||||||
|
@ -1810,33 +1712,6 @@ _return:
|
||||||
SCL_RET(code);
|
SCL_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t vectorBitOrHelper(SColumnInfoData *pLeftCol, SColumnInfoData *pRightCol, SColumnInfoData *pOutputCol,
|
|
||||||
int32_t numOfRows, int32_t step, int32_t i) {
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnLeft;
|
|
||||||
_getBigintValue_fn_t getVectorBigintValueFnRight;
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFn(pLeftCol->info.type, &getVectorBigintValueFnLeft));
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
|
||||||
|
|
||||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
|
||||||
|
|
||||||
if (IS_HELPER_NULL(pRightCol, 0)) { // Set pLeft->numOfRows NULL value
|
|
||||||
colDataSetNNULL(pOutputCol, 0, numOfRows);
|
|
||||||
} else {
|
|
||||||
int64_t rx = 0;
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFnRight(RIGHT_COL, 0, &rx));
|
|
||||||
for (; i >= 0 && i < numOfRows; i += step, output += 1) {
|
|
||||||
if (IS_HELPER_NULL(pLeftCol, i)) {
|
|
||||||
colDataSetNULL(pOutputCol, i);
|
|
||||||
continue; // TODO set null or ignore
|
|
||||||
}
|
|
||||||
int64_t lx = 0;
|
|
||||||
SCL_ERR_RET(getVectorBigintValueFnLeft(LEFT_COL, i, &lx));
|
|
||||||
*output = lx | rx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SCL_RET(TSDB_CODE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOut, int32_t _ord) {
|
||||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
|
@ -1857,23 +1732,21 @@ int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOu
|
||||||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||||
|
|
||||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||||
if (IS_NULL) {
|
int32_t leftidx = pLeft->numOfRows == 1 ? 0 : i;
|
||||||
|
int32_t rightidx = pRight->numOfRows == 1 ? 0 : i;
|
||||||
|
if (IS_HELPER_NULL(pRightCol, leftidx) || IS_HELPER_NULL(pLeftCol, rightidx)) {
|
||||||
colDataSetNULL(pOutputCol, i);
|
colDataSetNULL(pOutputCol, i);
|
||||||
continue; // TODO set null or ignore
|
continue; // TODO set null or ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t leftRes = 0;
|
int64_t leftRes = 0;
|
||||||
int64_t rightRes = 0;
|
int64_t rightRes = 0;
|
||||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||||
*output = leftRes | rightRes;
|
*output = leftRes | rightRes;
|
||||||
}
|
}
|
||||||
} else if (pLeft->numOfRows == 1) {
|
|
||||||
SCL_ERR_JRET(vectorBitOrHelper(pRightCol, pLeftCol, pOutputCol, pRight->numOfRows, step, i));
|
|
||||||
} else if (pRight->numOfRows == 1) {
|
|
||||||
SCL_ERR_JRET(vectorBitOrHelper(pLeftCol, pRightCol, pOutputCol, pLeft->numOfRows, step, i));
|
|
||||||
}
|
|
||||||
|
|
||||||
_return:
|
_return:
|
||||||
doReleaseVec(pLeftCol, leftConvert);
|
doReleaseVec(pLeftCol, leftConvert);
|
||||||
|
|
|
@ -391,6 +391,26 @@ TEST(constantTest, bigint_add_bigint) {
|
||||||
nodesDestroyNode(res);
|
nodesDestroyNode(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, ubigint_add_ubigint) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UBIGINT, &scltLeftV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UBIGINT, &scltRightV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_ADD, TSDB_DATA_TYPE_UBIGINT, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_UBIGINT);
|
||||||
|
ASSERT_FLOAT_EQ(v->datum.d, (scltLeftV + scltRightV));
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(constantTest, double_sub_bigint) {
|
TEST(constantTest, double_sub_bigint) {
|
||||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -431,6 +451,66 @@ TEST(constantTest, tinyint_and_smallint) {
|
||||||
nodesDestroyNode(res);
|
nodesDestroyNode(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, utinyint_and_usmallint) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UTINYINT, &scltLeftV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_USMALLINT, &scltRightV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, uint_and_usmallint) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UINT, &scltLeftV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_USMALLINT, &scltRightV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, ubigint_and_uint) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_UBIGINT, &scltLeftV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_UINT, &scltRightV);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_BIT_AND, TSDB_DATA_TYPE_BIGINT, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BIGINT);
|
||||||
|
ASSERT_EQ(v->datum.i, (int64_t)scltLeftV & (int64_t)scltRightV);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(constantTest, bigint_or_double) {
|
TEST(constantTest, bigint_or_double) {
|
||||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -494,6 +574,53 @@ TEST(constantTest, int_greater_double) {
|
||||||
nodesDestroyNode(res);
|
nodesDestroyNode(res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, binary_greater_equal_varbinary) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
char binaryStr[64] = {0};
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
(void)sprintf(&binaryStr[2], "%d", scltRightV);
|
||||||
|
varDataSetLen(binaryStr, strlen(&binaryStr[2]));
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_VARBINARY, binaryStr);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, binaryStr);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_GREATER_THAN, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(v->datum.b, scltLeftV < scltRightVd);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(constantTest, binary_equal_geo) {
|
||||||
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
|
char geoRawStr[64] = "POLYGON((30 10, 40 40, 20 40, 10 20, 30 10))";
|
||||||
|
char geoStr[64] = {0};
|
||||||
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
(void)sprintf(&geoStr[2], "%s", geoRawStr);
|
||||||
|
varDataSetLen(geoStr, strlen(&geoStr[2]));
|
||||||
|
code = scltMakeValueNode(&pLeft, TSDB_DATA_TYPE_GEOMETRY, geoStr);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeValueNode(&pRight, TSDB_DATA_TYPE_BINARY, geoStr);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
code = scltMakeOpNode(&opNode, OP_TYPE_EQUAL, TSDB_DATA_TYPE_BOOL, pLeft, pRight);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = scalarCalculateConstants(opNode, &res);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
ASSERT_TRUE(res);
|
||||||
|
ASSERT_EQ(nodeType(res), QUERY_NODE_VALUE);
|
||||||
|
SValueNode *v = (SValueNode *)res;
|
||||||
|
ASSERT_EQ(v->node.resType.type, TSDB_DATA_TYPE_BOOL);
|
||||||
|
ASSERT_EQ(v->datum.b, scltLeftV < scltRightVd);
|
||||||
|
nodesDestroyNode(res);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(constantTest, int_greater_equal_binary) {
|
TEST(constantTest, int_greater_equal_binary) {
|
||||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||||
char binaryStr[64] = {0};
|
char binaryStr[64] = {0};
|
||||||
|
|
|
@ -149,11 +149,11 @@ typedef struct SSchedulerMgmt {
|
||||||
bool exit;
|
bool exit;
|
||||||
int32_t jobRef;
|
int32_t jobRef;
|
||||||
int32_t jobNum;
|
int32_t jobNum;
|
||||||
SSchStat stat;
|
|
||||||
void *timer;
|
void *timer;
|
||||||
SRWLatch hbLock;
|
SRWLatch hbLock;
|
||||||
SHashObj *hbConnections;
|
SHashObj *hbConnections;
|
||||||
void *queryMgmt;
|
void *queryMgmt;
|
||||||
|
SSchStat stat;
|
||||||
} SSchedulerMgmt;
|
} SSchedulerMgmt;
|
||||||
|
|
||||||
typedef struct SSchCallbackParamHeader {
|
typedef struct SSchCallbackParamHeader {
|
||||||
|
|
|
@ -50,11 +50,6 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
||||||
int32_t taskNum = taosArrayGetSize(pJob->dataSrcTasks);
|
int32_t taskNum = taosArrayGetSize(pJob->dataSrcTasks);
|
||||||
for (int32_t i = 0; i < taskNum; ++i) {
|
for (int32_t i = 0; i < taskNum; ++i) {
|
||||||
SSchTask *pTask = *(SSchTask **)taosArrayGet(pJob->dataSrcTasks, i);
|
SSchTask *pTask = *(SSchTask **)taosArrayGet(pJob->dataSrcTasks, i);
|
||||||
if (NULL == pTask) {
|
|
||||||
SCH_JOB_DLOG("fail to get the %dth task", i);
|
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
sum += pTask->plan->execNodeStat.tableNum;
|
sum += pTask->plan->execNodeStat.tableNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -531,8 +531,8 @@ int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
qDebug("QID:0x%" PRIx64 ",SID:0x%" PRIx64 ",CID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x",
|
qDebug("QID:0x%" PRIx64 ",SID:0x%" PRIx64 ",CID:0x%" PRIx64 ",TID:0x%" PRIx64 " task notify rsp received, code:0x%x",
|
||||||
pParam->queryId, pParam->seriousId, pParam->clientId, pParam->taskId, code);
|
pParam->queryId, pParam->seriousId, pParam->clientId, pParam->taskId, code);
|
||||||
if (pMsg) {
|
if (pMsg) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFreeClear(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFreeClear(pMsg->pEpSet);
|
||||||
}
|
}
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -545,8 +545,8 @@ int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code) {
|
||||||
qDebug("handle %p is broken", pMsg->handle);
|
qDebug("handle %p is broken", pMsg->handle);
|
||||||
|
|
||||||
if (head->isHbParam) {
|
if (head->isHbParam) {
|
||||||
taosMemoryFree(pMsg->pData);
|
taosMemoryFreeClear(pMsg->pData);
|
||||||
taosMemoryFree(pMsg->pEpSet);
|
taosMemoryFreeClear(pMsg->pEpSet);
|
||||||
|
|
||||||
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
||||||
SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL, .pHandleId = 0};
|
SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL, .pHandleId = 0};
|
||||||
|
@ -1293,6 +1293,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
case TDMT_SCH_QUERY_HEARTBEAT: {
|
case TDMT_SCH_QUERY_HEARTBEAT: {
|
||||||
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
||||||
|
|
||||||
|
@ -1320,6 +1321,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
||||||
persistHandle = true;
|
persistHandle = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
case TDMT_SCH_TASK_NOTIFY: {
|
case TDMT_SCH_TASK_NOTIFY: {
|
||||||
ETaskNotifyType* pType = param;
|
ETaskNotifyType* pType = param;
|
||||||
STaskNotifyReq qMsg;
|
STaskNotifyReq qMsg;
|
||||||
|
|
|
@ -189,7 +189,6 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
pTask->failedExecId = pTask->execId;
|
pTask->failedExecId = pTask->execId;
|
||||||
pTask->failedSeriousId = pTask->seriousId;
|
|
||||||
|
|
||||||
int8_t jobStatus = 0;
|
int8_t jobStatus = 0;
|
||||||
if (schJobNeedToStop(pJob, &jobStatus)) {
|
if (schJobNeedToStop(pJob, &jobStatus)) {
|
||||||
|
@ -274,18 +273,18 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
||||||
if (taskDone < pTask->level->taskNum) {
|
if (taskDone < pTask->level->taskNum) {
|
||||||
SCH_TASK_DLOG("wait all tasks, done:%d, all:%d", taskDone, pTask->level->taskNum);
|
SCH_TASK_DLOG("wait all tasks, done:%d, all:%d", taskDone, pTask->level->taskNum);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
} else if (taskDone > pTask->level->taskNum) {
|
|
||||||
SCH_TASK_ELOG("taskDone number invalid, done:%d, total:%d", taskDone, pTask->level->taskNum);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCH_TASK_DLOG("taskDone number reach level task number, done:%d, total:%d", taskDone, pTask->level->taskNum);
|
||||||
|
|
||||||
if (pTask->level->taskFailed > 0) {
|
if (pTask->level->taskFailed > 0) {
|
||||||
SCH_RET(schHandleJobFailure(pJob, pJob->errCode));
|
SCH_RET(schHandleJobFailure(pJob, pJob->errCode));
|
||||||
} else {
|
}
|
||||||
|
|
||||||
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
pJob->resNode = pTask->succeedAddr;
|
pJob->resNode = pTask->succeedAddr;
|
||||||
}
|
|
||||||
|
|
||||||
pJob->fetchTask = pTask;
|
pJob->fetchTask = pTask;
|
||||||
|
|
||||||
|
@ -438,7 +437,7 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
pTask->waitRetry = true;
|
pTask->waitRetry = true;
|
||||||
|
|
||||||
if (pTask->delayTimer) {
|
if (pTask->delayTimer) {
|
||||||
taosTmrStop(pTask->delayTimer);
|
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||||
}
|
}
|
||||||
|
|
||||||
schDropTaskOnExecNode(pJob, pTask);
|
schDropTaskOnExecNode(pJob, pTask);
|
||||||
|
@ -452,6 +451,8 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
TAOS_MEMSET(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
TAOS_MEMSET(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
|
||||||
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
|
|
||||||
|
@ -593,17 +594,18 @@ _return:
|
||||||
|
|
||||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||||
if (0 != code) {
|
if (0 != code) {
|
||||||
if (HASH_NODE_EXIST(code)) {
|
if (HASH_NODE_EXIST(code)) {
|
||||||
SCH_TASK_DLOG("task already in execTask list, code:%x", code);
|
SCH_TASK_DLOG("task already in execTask list, code:0x%x", code);
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:0x%x", errno);
|
SCH_TASK_ELOG("taosHashPut task to execTask list failed, code:0x%x", code);
|
||||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
SCH_ERR_RET(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
SCH_TASK_DLOG("task added to execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks));
|
SCH_TASK_DLOG("task added to execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks));
|
||||||
|
@ -759,7 +761,7 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) {
|
||||||
(void)atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
(void)atomic_sub_fetch_32(&pTask->level->taskLaunchedNum, 1);
|
||||||
|
|
||||||
if (pTask->delayTimer) {
|
if (pTask->delayTimer) {
|
||||||
taosTmrStop(pTask->delayTimer);
|
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)schRemoveTaskFromExecList(pJob, pTask); // ignore error
|
(void)schRemoveTaskFromExecList(pJob, pTask); // ignore error
|
||||||
|
@ -798,11 +800,6 @@ int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < nodeNum; ++i) {
|
for (int32_t i = 0; i < nodeNum; ++i) {
|
||||||
SQueryNodeLoad *nload = taosArrayGet(pJob->nodeList, i);
|
SQueryNodeLoad *nload = taosArrayGet(pJob->nodeList, i);
|
||||||
if (NULL == nload) {
|
|
||||||
SCH_TASK_ELOG("fail to get the %dth node in nodeList, nodeNum:%d", i, nodeNum);
|
|
||||||
SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
SQueryNodeAddr *naddr = &nload->addr;
|
SQueryNodeAddr *naddr = &nload->addr;
|
||||||
|
|
||||||
if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) {
|
if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) {
|
||||||
|
@ -869,6 +866,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) {
|
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) {
|
if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) {
|
||||||
|
@ -900,6 +898,7 @@ _return:
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
|
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
|
||||||
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs);
|
||||||
|
@ -1376,6 +1375,7 @@ int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) {
|
||||||
|
|
||||||
for (int32_t i = 0; i < level->taskNum; ++i) {
|
for (int32_t i = 0; i < level->taskNum; ++i) {
|
||||||
SSchTask *pTask = taosArrayGet(level->subTasks, i);
|
SSchTask *pTask = taosArrayGet(level->subTasks, i);
|
||||||
|
pTask->failedSeriousId = pJob->seriousId - 1;
|
||||||
pTask->seriousId = pJob->seriousId;
|
pTask->seriousId = pJob->seriousId;
|
||||||
|
|
||||||
SCH_TASK_DLOG("task seriousId set to 0x%" PRIx64, pTask->seriousId);
|
SCH_TASK_DLOG("task seriousId set to 0x%" PRIx64, pTask->seriousId);
|
||||||
|
|
|
@ -57,6 +57,22 @@ namespace {
|
||||||
extern "C" int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, uint64_t sId, int32_t execId, SDataBuf *pMsg,
|
extern "C" int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, uint64_t sId, int32_t execId, SDataBuf *pMsg,
|
||||||
int32_t rspCode);
|
int32_t rspCode);
|
||||||
extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t rspCode);
|
extern "C" int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t rspCode);
|
||||||
|
extern "C" int32_t schHandleNotifyCallback(void *param, SDataBuf *pMsg, int32_t code);
|
||||||
|
extern "C" int32_t schHandleLinkBrokenCallback(void *param, SDataBuf *pMsg, int32_t code);
|
||||||
|
extern "C" int32_t schRescheduleTask(SSchJob *pJob, SSchTask *pTask);
|
||||||
|
extern "C" int32_t schValidateRspMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType);
|
||||||
|
//extern "C" int32_t schProcessFetchRsp(SSchJob *pJob, SSchTask *pTask, char *msg, int32_t rspCode);
|
||||||
|
extern "C" int32_t schProcessResponseMsg(SSchJob *pJob, SSchTask *pTask, SDataBuf *pMsg, int32_t rspCode);
|
||||||
|
extern "C" void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel);
|
||||||
|
extern "C" int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask);
|
||||||
|
extern "C" int32_t schDropTaskExecNode(SSchJob *pJob, SSchTask *pTask, void *handle, int32_t execId);
|
||||||
|
extern "C" int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask);
|
||||||
|
extern "C" int32_t schSetAddrsFromNodeList(SSchJob *pJob, SSchTask *pTask);
|
||||||
|
extern "C" int32_t schNotifyTaskOnExecNode(SSchJob *pJob, SSchTask *pTask, ETaskNotifyType type);
|
||||||
|
extern "C" int32_t schLaunchRemoteTask(SSchJob *pJob, SSchTask *pTask);
|
||||||
|
extern "C" int32_t schLaunchTaskImpl(void *param);
|
||||||
|
extern "C" void schHandleTimerEvent(void *param, void *tmrId);
|
||||||
|
|
||||||
|
|
||||||
int64_t insertJobRefId = 0;
|
int64_t insertJobRefId = 0;
|
||||||
int64_t queryJobRefId = 0;
|
int64_t queryJobRefId = 0;
|
||||||
|
@ -316,7 +332,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
||||||
|
|
||||||
scanPlan->execNode.nodeId = 1 + i;
|
scanPlan->execNode.nodeId = 1 + i;
|
||||||
scanPlan->execNode.epSet.inUse = 0;
|
scanPlan->execNode.epSet.inUse = 0;
|
||||||
scanPlan->execNodeStat.tableNum = taosRand() % 30;
|
scanPlan->execNodeStat.tableNum = taosRand() % 100;
|
||||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep0", 6030);
|
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep0", 6030);
|
||||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep1", 6030);
|
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep1", 6030);
|
||||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep2", 6030);
|
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep2", 6030);
|
||||||
|
@ -982,8 +998,159 @@ TEST(queryTest, normalCase) {
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
(void)taosThreadJoin(thread1, NULL);
|
(void)taosThreadJoin(thread1, NULL);
|
||||||
|
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(queryTest, rescheduleCase) {
|
||||||
|
void *mockPointer = (void *)0x1;
|
||||||
|
char *clusterId = "cluster1";
|
||||||
|
char *dbname = "1.db1";
|
||||||
|
char *tablename = "table1";
|
||||||
|
SVgroupInfo vgInfo = {0};
|
||||||
|
int64_t job = 0;
|
||||||
|
SQueryPlan *dag = NULL;
|
||||||
|
int32_t code = nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN, (SNode**)&dag);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SArray *qnodeList = taosArrayInit(1, sizeof(SQueryNodeLoad));
|
||||||
|
|
||||||
|
SQueryNodeLoad load = {0};
|
||||||
|
load.addr.epSet.numOfEps = 1;
|
||||||
|
TAOS_STRCPY(load.addr.epSet.eps[0].fqdn, "qnode0.ep");
|
||||||
|
load.addr.epSet.eps[0].port = 6031;
|
||||||
|
assert(taosArrayPush(qnodeList, &load) != NULL);
|
||||||
|
|
||||||
|
TAOS_STRCPY(load.addr.epSet.eps[0].fqdn, "qnode1.ep");
|
||||||
|
assert(taosArrayPush(qnodeList, &load) != NULL);
|
||||||
|
|
||||||
|
code = schedulerInit();
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
schtBuildQueryDag(dag);
|
||||||
|
|
||||||
|
schtSetPlanToString();
|
||||||
|
schtSetExecNode();
|
||||||
|
schtSetAsyncSendMsgToServer();
|
||||||
|
|
||||||
|
int32_t queryDone = 0;
|
||||||
|
|
||||||
|
SRequestConnInfo conn = {0};
|
||||||
|
conn.pTrans = mockPointer;
|
||||||
|
SSchedulerReq req = {0};
|
||||||
|
req.pConn = &conn;
|
||||||
|
req.pNodeList = qnodeList;
|
||||||
|
req.pDag = dag;
|
||||||
|
req.sql = "select * from tb";
|
||||||
|
req.execFp = schtQueryCb;
|
||||||
|
req.cbParam = &queryDone;
|
||||||
|
|
||||||
|
code = schedulerExecJob(&req, &job);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
SSchJob *pJob = NULL;
|
||||||
|
code = schAcquireJob(job, &pJob);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
schedulerEnableReSchedule(true);
|
||||||
|
|
||||||
|
void *pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
task->timeoutUsec = -1;
|
||||||
|
|
||||||
|
code = schRescheduleTask(pJob, task);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
task->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
|
||||||
|
SDataBuf msg = {0};
|
||||||
|
void *rmsg = NULL;
|
||||||
|
assert(0 == schtBuildQueryRspMsg(&msg.len, &rmsg));
|
||||||
|
msg.msgType = TDMT_SCH_QUERY_RSP;
|
||||||
|
msg.pData = rmsg;
|
||||||
|
|
||||||
|
code = schHandleResponseMsg(pJob, task, task->seriousId, task->execId, &msg, 0);
|
||||||
|
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
task->timeoutUsec = -1;
|
||||||
|
|
||||||
|
code = schRescheduleTask(pJob, task);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
task->timeoutUsec = SCH_DEFAULT_TASK_TIMEOUT_USEC;
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, NULL);
|
||||||
|
while (pIter) {
|
||||||
|
SSchTask *task = *(SSchTask **)pIter;
|
||||||
|
if (JOB_TASK_STATUS_EXEC == task->status) {
|
||||||
|
SDataBuf msg = {0};
|
||||||
|
void *rmsg = NULL;
|
||||||
|
assert(0 == schtBuildQueryRspMsg(&msg.len, &rmsg));
|
||||||
|
msg.msgType = TDMT_SCH_QUERY_RSP;
|
||||||
|
msg.pData = rmsg;
|
||||||
|
|
||||||
|
code = schHandleResponseMsg(pJob, task, task->seriousId, task->execId, &msg, 0);
|
||||||
|
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
pIter = taosHashIterate(pJob->execTasks, pIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (queryDone) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosUsleep(10000);
|
||||||
|
}
|
||||||
|
|
||||||
|
TdThreadAttr thattr;
|
||||||
|
assert(0 == taosThreadAttrInit(&thattr));
|
||||||
|
|
||||||
|
TdThread thread1;
|
||||||
|
assert(0 == taosThreadCreate(&(thread1), &thattr, schtCreateFetchRspThread, &job));
|
||||||
|
|
||||||
|
void *data = NULL;
|
||||||
|
req.syncReq = true;
|
||||||
|
req.pFetchRes = &data;
|
||||||
|
|
||||||
|
code = schedulerFetchRows(job, &req);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
SRetrieveTableRsp *pRsp = (SRetrieveTableRsp *)data;
|
||||||
|
ASSERT_EQ(pRsp->completed, 1);
|
||||||
|
ASSERT_EQ(pRsp->numOfRows, 10);
|
||||||
|
taosMemoryFreeClear(data);
|
||||||
|
|
||||||
|
(void)schReleaseJob(job);
|
||||||
|
|
||||||
|
schedulerDestroy();
|
||||||
|
|
||||||
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
|
(void)taosThreadJoin(thread1, NULL);
|
||||||
|
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
TEST(queryTest, readyFirstCase) {
|
TEST(queryTest, readyFirstCase) {
|
||||||
void *mockPointer = (void *)0x1;
|
void *mockPointer = (void *)0x1;
|
||||||
char *clusterId = "cluster1";
|
char *clusterId = "cluster1";
|
||||||
|
@ -1097,6 +1264,7 @@ TEST(queryTest, readyFirstCase) {
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
(void)taosThreadJoin(thread1, NULL);
|
(void)taosThreadJoin(thread1, NULL);
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(queryTest, flowCtrlCase) {
|
TEST(queryTest, flowCtrlCase) {
|
||||||
|
@ -1196,6 +1364,9 @@ TEST(queryTest, flowCtrlCase) {
|
||||||
schedulerFreeJob(&job, 0);
|
schedulerFreeJob(&job, 0);
|
||||||
|
|
||||||
(void)taosThreadJoin(thread1, NULL);
|
(void)taosThreadJoin(thread1, NULL);
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
|
|
||||||
|
cleanupTaskQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(insertTest, normalCase) {
|
TEST(insertTest, normalCase) {
|
||||||
|
@ -1260,6 +1431,7 @@ TEST(insertTest, normalCase) {
|
||||||
schedulerDestroy();
|
schedulerDestroy();
|
||||||
|
|
||||||
(void)taosThreadJoin(thread1, NULL);
|
(void)taosThreadJoin(thread1, NULL);
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(multiThread, forceFree) {
|
TEST(multiThread, forceFree) {
|
||||||
|
@ -1282,9 +1454,11 @@ TEST(multiThread, forceFree) {
|
||||||
|
|
||||||
schtTestStop = true;
|
schtTestStop = true;
|
||||||
// taosSsleep(3);
|
// taosSsleep(3);
|
||||||
|
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(otherTest, otherCase) {
|
TEST(otherTest, function) {
|
||||||
// excpet test
|
// excpet test
|
||||||
(void)schReleaseJob(0);
|
(void)schReleaseJob(0);
|
||||||
schFreeRpcCtx(NULL);
|
schFreeRpcCtx(NULL);
|
||||||
|
@ -1293,6 +1467,296 @@ TEST(otherTest, otherCase) {
|
||||||
ASSERT_EQ(schDumpEpSet(NULL, &ep), TSDB_CODE_SUCCESS);
|
ASSERT_EQ(schDumpEpSet(NULL, &ep), TSDB_CODE_SUCCESS);
|
||||||
ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 0);
|
ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 0);
|
||||||
ASSERT_EQ(strcmp(schGetOpStr((SCH_OP_TYPE)100), "UNKNOWN"), 0);
|
ASSERT_EQ(strcmp(schGetOpStr((SCH_OP_TYPE)100), "UNKNOWN"), 0);
|
||||||
|
|
||||||
|
SSchTaskCallbackParam param = {0};
|
||||||
|
SDataBuf dataBuf = {0};
|
||||||
|
dataBuf.pData = taosMemoryMalloc(1);
|
||||||
|
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||||
|
ASSERT_EQ(schHandleNotifyCallback(¶m, &dataBuf, TSDB_CODE_SUCCESS), TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SSchCallbackParamHeader param2 = {0};
|
||||||
|
dataBuf.pData = taosMemoryMalloc(1);
|
||||||
|
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||||
|
schHandleLinkBrokenCallback(¶m2, &dataBuf, TSDB_CODE_SUCCESS);
|
||||||
|
param2.isHbParam = true;
|
||||||
|
dataBuf.pData = taosMemoryMalloc(1);
|
||||||
|
dataBuf.pEpSet = (SEpSet*)taosMemoryMalloc(sizeof(*dataBuf.pEpSet));
|
||||||
|
schHandleLinkBrokenCallback(¶m2, &dataBuf, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(otherTest, branch) {
|
||||||
|
SSchJob job = {0};
|
||||||
|
SSchTask task = {0};
|
||||||
|
memset(&schMgmt, 0, sizeof(schMgmt));
|
||||||
|
|
||||||
|
schValidateRspMsgType(&job, &task, TDMT_SCH_MERGE_FETCH_RSP);
|
||||||
|
|
||||||
|
task.lastMsgType = TDMT_SCH_MERGE_FETCH_RSP - 1;
|
||||||
|
schValidateRspMsgType(&job, &task, TDMT_SCH_MERGE_FETCH_RSP);
|
||||||
|
|
||||||
|
schValidateRspMsgType(&job, &task, 0);
|
||||||
|
|
||||||
|
schValidateRspMsgType(&job, &task, TDMT_SCH_QUERY_RSP);
|
||||||
|
|
||||||
|
task.lastMsgType = TDMT_SCH_QUERY_RSP - 1;
|
||||||
|
schValidateRspMsgType(&job, &task, TDMT_SCH_QUERY_RSP);
|
||||||
|
|
||||||
|
schProcessFetchRsp(&job, &task, NULL, -1);
|
||||||
|
schProcessFetchRsp(&job, &task, NULL, 0);
|
||||||
|
|
||||||
|
job.fetchRes = (void*)0x1;
|
||||||
|
schProcessFetchRsp(&job, &task, (char*)taosMemoryMalloc(0), 0);
|
||||||
|
job.fetchRes = NULL;
|
||||||
|
|
||||||
|
SDataBuf databuf = {0};
|
||||||
|
databuf.msgType = TDMT_VND_ALTER_TABLE_RSP;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_VND_SUBMIT_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_VND_DELETE_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_QUERY_RSP;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_QUERY_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
job.status = 0;
|
||||||
|
|
||||||
|
job.attr.explainMode = EXPLAIN_MODE_ANALYZE;
|
||||||
|
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
job.fetchRes = (void*)0x1;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
job.fetchRes = NULL;
|
||||||
|
|
||||||
|
job.attr.explainMode = EXPLAIN_MODE_ANALYZE;
|
||||||
|
databuf.msgType = TDMT_SCH_EXPLAIN_RSP;
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_DROP_TASK_RSP;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = TDMT_SCH_LINK_BROKEN;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.msgType = 0;
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessResponseMsg(&job, &task, &databuf, 0);
|
||||||
|
|
||||||
|
databuf.pData = taosMemoryMalloc(0);
|
||||||
|
schHandleHbCallback(NULL, &databuf, 0);
|
||||||
|
|
||||||
|
__async_send_cb_fn_t fp = NULL;
|
||||||
|
schGetCallbackFp(TDMT_SCH_TASK_NOTIFY, &fp);
|
||||||
|
schGetCallbackFp(0, &fp);
|
||||||
|
|
||||||
|
SQueryNodeEpId ep = {0};
|
||||||
|
schBuildAndSendHbMsg(&ep, NULL);
|
||||||
|
|
||||||
|
schBuildAndSendMsg(&job, &task, NULL, 0, NULL);
|
||||||
|
|
||||||
|
SSchLevel level = {0};
|
||||||
|
SSubplan subplan;
|
||||||
|
memset(&subplan, 0, sizeof(subplan));
|
||||||
|
job.attr.queryJob = true;
|
||||||
|
schMgmt.cfg.schPolicy = SCH_ALL;
|
||||||
|
task.plan = &subplan;
|
||||||
|
schInitTaskRetryTimes(&job, &task, &level);
|
||||||
|
job.attr.queryJob = false;
|
||||||
|
memset(&schMgmt.cfg, 0, sizeof(schMgmt.cfg));
|
||||||
|
memset(&level, 0, sizeof(level));
|
||||||
|
|
||||||
|
schRecordTaskSucceedNode(&job, &task);
|
||||||
|
|
||||||
|
schDropTaskExecNode(&job, &task, NULL, 0);
|
||||||
|
|
||||||
|
task.execNodes = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK);
|
||||||
|
schDropTaskExecNode(&job, &task, NULL, 0);
|
||||||
|
|
||||||
|
int32_t execId = 0;
|
||||||
|
task.execId = 1;
|
||||||
|
(void)taosHashPut(task.execNodes, &execId, sizeof(execId), &execId, sizeof(execId));
|
||||||
|
schDropTaskExecNode(&job, &task, NULL, execId);
|
||||||
|
task.execId = 0;
|
||||||
|
taosHashCleanup(task.execNodes);
|
||||||
|
task.execNodes = NULL;
|
||||||
|
|
||||||
|
job.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessOnTaskFailure(&job, &task, 0);
|
||||||
|
job.status = 0;
|
||||||
|
|
||||||
|
task.status = JOB_TASK_STATUS_FAIL;
|
||||||
|
schProcessOnTaskFailure(&job, &task, 0);
|
||||||
|
task.status = 0;
|
||||||
|
|
||||||
|
task.level = &level;
|
||||||
|
schProcessOnTaskFailure(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR);
|
||||||
|
memset(&level, 0, sizeof(level));
|
||||||
|
task.level = NULL;
|
||||||
|
|
||||||
|
subplan.subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
|
task.plan = &subplan;
|
||||||
|
SEpSet epset = {0};
|
||||||
|
epset.numOfEps = 127;
|
||||||
|
schChkUpdateRedirectCtx(&job, &task, &epset, 0);
|
||||||
|
|
||||||
|
schChkUpdateRedirectCtx(&job, &task, NULL, 0);
|
||||||
|
task.plan = NULL;
|
||||||
|
|
||||||
|
schPushTaskToExecList(&job, &task);
|
||||||
|
|
||||||
|
job.execTasks = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
|
||||||
|
taosHashPut(job.execTasks, &task.taskId, sizeof(task.taskId), &task, POINTER_BYTES);
|
||||||
|
schPushTaskToExecList(&job, &task);
|
||||||
|
taosHashCleanup(job.execTasks);
|
||||||
|
job.execTasks = NULL;
|
||||||
|
|
||||||
|
bool needRetry = false;
|
||||||
|
task.timeoutUsec = SCH_MAX_TASK_TIMEOUT_USEC / 2 + 1;
|
||||||
|
task.retryTimes = 0;
|
||||||
|
task.maxRetryTimes = 0;
|
||||||
|
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||||
|
|
||||||
|
task.execId = 0;
|
||||||
|
task.retryTimes = 0;
|
||||||
|
task.maxRetryTimes = 100;
|
||||||
|
task.maxExecTimes = 1;
|
||||||
|
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||||
|
|
||||||
|
|
||||||
|
task.execId = 0;
|
||||||
|
task.retryTimes = 0;
|
||||||
|
task.maxRetryTimes = 100;
|
||||||
|
task.maxExecTimes = 100;
|
||||||
|
task.lastMsgType = TDMT_SCH_LINK_BROKEN;
|
||||||
|
schTaskCheckSetRetry(&job, &task, TSDB_CODE_SCH_TIMEOUT_ERROR, &needRetry);
|
||||||
|
|
||||||
|
schSetAddrsFromNodeList(&job, &task);
|
||||||
|
|
||||||
|
schSwitchTaskCandidateAddr(&job, &task);
|
||||||
|
|
||||||
|
|
||||||
|
task.candidateAddrs = taosArrayInit(SCHEDULE_DEFAULT_MAX_NODE_NUM, sizeof(SQueryNodeAddr));
|
||||||
|
SQueryNodeAddr addr = {0};
|
||||||
|
taosArrayPush(task.candidateAddrs, &addr);
|
||||||
|
taosArrayPush(task.candidateAddrs, &addr);
|
||||||
|
schMgmt.cfg.schPolicy = SCH_LOAD_SEQ;
|
||||||
|
task.candidateIdx = 1;
|
||||||
|
schSwitchTaskCandidateAddr(&job, &task);
|
||||||
|
|
||||||
|
schMgmt.cfg.schPolicy = SCH_RANDOM;
|
||||||
|
schSwitchTaskCandidateAddr(&job, &task);
|
||||||
|
taosArrayDestroy(task.candidateAddrs);
|
||||||
|
task.candidateAddrs = NULL;
|
||||||
|
memset(&schMgmt.cfg, 0, sizeof(schMgmt.cfg));
|
||||||
|
task.candidateIdx = 0;
|
||||||
|
|
||||||
|
schDropTaskOnExecNode(&job, &task);
|
||||||
|
|
||||||
|
schNotifyTaskOnExecNode(&job, &task, TASK_NOTIFY_FINISHED);
|
||||||
|
|
||||||
|
schLaunchRemoteTask(&job, &task);
|
||||||
|
|
||||||
|
SSchTaskCtx* pCtx = (SSchTaskCtx*)taosMemoryCalloc(1, sizeof(SSchTaskCtx));
|
||||||
|
pCtx->jobRid = -1;
|
||||||
|
schLaunchTaskImpl((void*)pCtx);
|
||||||
|
|
||||||
|
task.plan = &subplan;
|
||||||
|
subplan.subplanType = SUBPLAN_TYPE_SCAN;
|
||||||
|
job.attr.needFlowCtrl = true;
|
||||||
|
level.taskNum = 1000;
|
||||||
|
task.level = &level;
|
||||||
|
schLaunchTask(&job, &task);
|
||||||
|
task.plan = NULL;
|
||||||
|
task.level = NULL;
|
||||||
|
job.attr.needFlowCtrl = false;
|
||||||
|
|
||||||
|
SSchTimerParam param = {0};
|
||||||
|
param.rId = -1;
|
||||||
|
schHandleTimerEvent(¶m, NULL);
|
||||||
|
|
||||||
|
job.execTasks = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK);
|
||||||
|
task.delayExecMs = 1;
|
||||||
|
schMgmt.timer = NULL;
|
||||||
|
schDelayLaunchTask(&job, &task);
|
||||||
|
task.delayExecMs = 0;
|
||||||
|
taosHashCleanup(job.execTasks);
|
||||||
|
job.execTasks = NULL;
|
||||||
|
|
||||||
|
job.fetchRes = (void*)0x1;
|
||||||
|
schLaunchFetchTask(&job);
|
||||||
|
job.fetchRes = NULL;
|
||||||
|
|
||||||
|
job.fetchTask = &task;
|
||||||
|
job.attr.localExec = true;
|
||||||
|
job.attr.queryJob = true;
|
||||||
|
subplan.subplanType = SUBPLAN_TYPE_MERGE;
|
||||||
|
task.plan = &subplan;
|
||||||
|
void* p = taosMemoryCalloc(1, 1024);
|
||||||
|
schMgmt.queryMgmt = p;
|
||||||
|
schLaunchFetchTask(&job);
|
||||||
|
memset(&job, 0, sizeof(job));
|
||||||
|
memset(&subplan, 0, sizeof(subplan));
|
||||||
|
task.plan = NULL;
|
||||||
|
taosMemoryFreeClear(schMgmt.queryMgmt);
|
||||||
|
|
||||||
|
// flow ctrl
|
||||||
|
|
||||||
|
job.flowCtrl = taosHashInit(1, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
|
SEp sep = {0};
|
||||||
|
SSchFlowControl nctrl = {0};
|
||||||
|
nctrl.taskList = taosArrayInit(1, POINTER_BYTES);
|
||||||
|
taosHashPut(job.flowCtrl, &sep, sizeof(SEp), &nctrl, sizeof(nctrl));
|
||||||
|
schFreeFlowCtrl(&job);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
schMgmt.jobRef = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void schtReset() {
|
||||||
|
insertJobRefId = 0;
|
||||||
|
queryJobRefId = 0;
|
||||||
|
|
||||||
|
schtJobDone = false;
|
||||||
|
schtMergeTemplateId = 0x4;
|
||||||
|
schtFetchTaskId = 0;
|
||||||
|
schtQueryId = 1;
|
||||||
|
|
||||||
|
schtTestStop = false;
|
||||||
|
schtTestDeadLoop = false;
|
||||||
|
schtTestMTRunSec = 1;
|
||||||
|
schtTestPrintNum = 1000;
|
||||||
|
schtStartFetch = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
@ -1302,7 +1766,17 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
taosSeedRand(taosGetTimestampSec());
|
taosSeedRand(taosGetTimestampSec());
|
||||||
testing::InitGoogleTest(&argc, argv);
|
testing::InitGoogleTest(&argc, argv);
|
||||||
return RUN_ALL_TESTS();
|
|
||||||
|
int code = 0;
|
||||||
|
for (int32_t i = 0; i < 10; ++i) {
|
||||||
|
schtReset();
|
||||||
|
code = RUN_ALL_TESTS();
|
||||||
|
if (code) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma GCC diagnostic pop
|
#pragma GCC diagnostic pop
|
||||||
|
|
|
@ -252,6 +252,8 @@ void chkptFailedByRetrieveReqToSource(SStreamTask* pTask, int64_t checkpointId);
|
||||||
|
|
||||||
int32_t uploadCheckpointData(SStreamTask* pTask, int64_t checkpointId, int64_t dbRefId, ECHECKPOINT_BACKUP_TYPE type);
|
int32_t uploadCheckpointData(SStreamTask* pTask, int64_t checkpointId, int64_t dbRefId, ECHECKPOINT_BACKUP_TYPE type);
|
||||||
int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, void* param, SArray** ppNotSendList);
|
int32_t chkptTriggerRecvMonitorHelper(SStreamTask* pTask, void* param, SArray** ppNotSendList);
|
||||||
|
int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char* dstName);
|
||||||
|
int32_t uploadCheckpointToS3(const char* id, const char* path);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,6 @@ static int32_t streamTaskUploadCheckpoint(const char* id, const char* path, int6
|
||||||
#ifdef BUILD_NO_CALL
|
#ifdef BUILD_NO_CALL
|
||||||
static int32_t deleteCheckpoint(const char* id);
|
static int32_t deleteCheckpoint(const char* id);
|
||||||
#endif
|
#endif
|
||||||
static int32_t downloadCheckpointByNameS3(const char* id, const char* fname, const char* dstName);
|
|
||||||
static int32_t continueDispatchCheckpointTriggerBlock(SStreamDataBlock* pBlock, SStreamTask* pTask);
|
static int32_t continueDispatchCheckpointTriggerBlock(SStreamDataBlock* pBlock, SStreamTask* pTask);
|
||||||
static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
static int32_t appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
||||||
int32_t transId, int32_t srcTaskId);
|
int32_t transId, int32_t srcTaskId);
|
||||||
|
@ -1355,7 +1354,7 @@ void streamTaskSetTriggerDispatchConfirmed(SStreamTask* pTask, int32_t vgId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
int32_t uploadCheckpointToS3(const char* id, const char* path) {
|
||||||
int32_t code = 0;
|
int32_t code = 0;
|
||||||
int32_t nBytes = 0;
|
int32_t nBytes = 0;
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -112,6 +112,7 @@ void clearSearchBuff(SStreamFileState* pFileState) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef BUILD_NO_CALL
|
||||||
int32_t getStateFromRocksdbByCur(SStreamFileState* pFileState, SStreamStateCur* pCur, SWinKey* pResKey, SRowBuffPos** ppPos, int32_t* pVLen, int32_t* pWinCode) {
|
int32_t getStateFromRocksdbByCur(SStreamFileState* pFileState, SStreamStateCur* pCur, SWinKey* pResKey, SRowBuffPos** ppPos, int32_t* pVLen, int32_t* pWinCode) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
int32_t lino = 0;
|
int32_t lino = 0;
|
||||||
|
@ -135,6 +136,7 @@ _end:
|
||||||
}
|
}
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t getHashSortNextRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** ppVal,
|
int32_t getHashSortNextRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** ppVal,
|
||||||
int32_t* pVLen, int32_t* pWinCode) {
|
int32_t* pVLen, int32_t* pWinCode) {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
#include "tstream.h"
|
#include "tstream.h"
|
||||||
#include "streamInt.h"
|
#include "streamInt.h"
|
||||||
|
#include "tcs.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
|
||||||
#pragma GCC diagnostic push
|
#pragma GCC diagnostic push
|
||||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
@ -217,6 +219,10 @@ TEST(StreamTaskAlreadySendTriggerTest, AlreadySendTrigger) {
|
||||||
taosArrayDestroy(array);
|
taosArrayDestroy(array);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t sendReq1111(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
||||||
SStreamTask* pTask = NULL;
|
SStreamTask* pTask = NULL;
|
||||||
int64_t uid = 2222222222222;
|
int64_t uid = 2222222222222;
|
||||||
|
@ -239,6 +245,11 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
||||||
pTask->chkInfo.pActiveInfo->transId = 4561111;
|
pTask->chkInfo.pActiveInfo->transId = 4561111;
|
||||||
pTask->chkInfo.startTs = 11111;
|
pTask->chkInfo.startTs = 11111;
|
||||||
|
|
||||||
|
SStreamTask upTask;
|
||||||
|
upTask = *pTask;
|
||||||
|
streamTaskSetUpstreamInfo(pTask, &upTask);
|
||||||
|
|
||||||
|
|
||||||
streamTaskSetStatusReady(pTask);
|
streamTaskSetStatusReady(pTask);
|
||||||
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT);
|
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT);
|
||||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
@ -254,7 +265,21 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
||||||
|
|
||||||
taosArrayPush(pTask->chkInfo.pActiveInfo->pDispatchTriggerList, &triggerInfo);
|
taosArrayPush(pTask->chkInfo.pActiveInfo->pDispatchTriggerList, &triggerInfo);
|
||||||
|
|
||||||
|
STaskCheckpointReadyInfo readyInfo;
|
||||||
|
readyInfo.upstreamNodeId = 789111;
|
||||||
|
void* pBuf = rpcMallocCont(sizeof(SMsgHead) + 1);
|
||||||
|
|
||||||
|
initRpcMsg(&readyInfo.msg, 0, pBuf, sizeof(SMsgHead) + 1);
|
||||||
|
taosArrayPush(pTask->chkInfo.pActiveInfo->pReadyMsgList, &readyInfo);
|
||||||
|
|
||||||
|
|
||||||
pTask->chkInfo.pActiveInfo->dispatchTrigger = true;
|
pTask->chkInfo.pActiveInfo->dispatchTrigger = true;
|
||||||
|
|
||||||
|
SMsgCb msgCb = {0};
|
||||||
|
msgCb.sendReqFp = sendReq1111;
|
||||||
|
msgCb.mgmt = (SMgmtWrapper*)(&msgCb); // hack
|
||||||
|
tmsgSetDefault(&msgCb);
|
||||||
|
|
||||||
SArray* array1 = NULL;
|
SArray* array1 = NULL;
|
||||||
code = chkptTriggerRecvMonitorHelper(pTask, NULL, &array1);
|
code = chkptTriggerRecvMonitorHelper(pTask, NULL, &array1);
|
||||||
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
@ -268,3 +293,106 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
||||||
taosArrayDestroy(array);
|
taosArrayDestroy(array);
|
||||||
taosArrayDestroy(array1);
|
taosArrayDestroy(array1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(StreamTaskSendCheckpointTriggerMsgTest, SendCheckpointTriggerMsgSuccessTest) {
|
||||||
|
SStreamTask* pTask = NULL;
|
||||||
|
int64_t uid = 2222222222222;
|
||||||
|
SArray* array = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
int32_t code = tNewStreamTask(uid, TASK_LEVEL__SINK, NULL, false, 0, 0, array,
|
||||||
|
false, 1, &pTask);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
initTaskLock(pTask);
|
||||||
|
|
||||||
|
const char *path = "/tmp/SendCheckpointTriggerMsgSuccessTest/stream";
|
||||||
|
code = streamMetaOpen((path), NULL, NULL, NULL, 0, 0, NULL, &pTask->pMeta);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = streamTaskCreateActiveChkptInfo(&pTask->chkInfo.pActiveInfo);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SRpcHandleInfo rpcInfo;
|
||||||
|
|
||||||
|
int32_t ret = streamTaskSendCheckpointTriggerMsg(pTask, 123, 456, &rpcInfo, code);
|
||||||
|
|
||||||
|
EXPECT_EQ(ret, TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(streamTaskBuildCheckpointTest, streamTaskBuildCheckpointFnTest) {
|
||||||
|
SStreamTask* pTask = NULL;
|
||||||
|
int64_t uid = 2222222222222;
|
||||||
|
SArray* array = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
int32_t code = tNewStreamTask(uid, TASK_LEVEL__SINK, NULL, false, 0, 0, array,
|
||||||
|
false, 1, &pTask);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
initTaskLock(pTask);
|
||||||
|
|
||||||
|
const char *path = "/tmp/streamTaskBuildCheckpoinTest/stream";
|
||||||
|
code = streamMetaOpen((path), NULL, NULL, NULL, 0, 0, NULL, &pTask->pMeta);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SStreamState *pState = streamStateOpen((char *)path, pTask, 0, 0);
|
||||||
|
ASSERT(pState != NULL);
|
||||||
|
|
||||||
|
pTask->pBackend = pState->pTdbState->pOwner->pBackend;
|
||||||
|
|
||||||
|
code = streamTaskCreateActiveChkptInfo(&pTask->chkInfo.pActiveInfo);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
char a[] = "localhost";
|
||||||
|
memcpy(tsSnodeAddress, a, sizeof(a));
|
||||||
|
|
||||||
|
int32_t ret = streamTaskBuildCheckpoint(pTask);
|
||||||
|
|
||||||
|
EXPECT_NE(ret, TSDB_CODE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t s3GetObjectToFileTest(const char *object_name, const char *fileName) {
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(sstreamTaskGetTriggerRecvStatusTest, streamTaskGetTriggerRecvStatusFnTest) {
|
||||||
|
SStreamTask* pTask = NULL;
|
||||||
|
int64_t uid = 2222222222222;
|
||||||
|
SArray* array = taosArrayInit(4, POINTER_BYTES);
|
||||||
|
int32_t code = tNewStreamTask(uid, TASK_LEVEL__SINK, NULL, false, 0, 0, array,
|
||||||
|
false, 1, &pTask);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
initTaskLock(pTask);
|
||||||
|
|
||||||
|
SStreamTask upTask;
|
||||||
|
upTask = *pTask;
|
||||||
|
code = streamTaskSetUpstreamInfo(pTask, &upTask);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = streamTaskSetUpstreamInfo(pTask, &upTask);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = streamTaskCreateActiveChkptInfo(&pTask->chkInfo.pActiveInfo);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
int32_t recv = 0;
|
||||||
|
int32_t total = 0;
|
||||||
|
pTask->info.taskLevel = TASK_LEVEL__SOURCE;
|
||||||
|
streamTaskGetTriggerRecvStatus(pTask, &recv, &total);
|
||||||
|
EXPECT_EQ(total, 1);
|
||||||
|
|
||||||
|
pTask->info.taskLevel = TASK_LEVEL__AGG;
|
||||||
|
streamTaskGetTriggerRecvStatus(pTask, &recv, &total);
|
||||||
|
EXPECT_EQ(total, 2);
|
||||||
|
|
||||||
|
code = streamTaskDownloadCheckpointData("123", "/root/download", 123);
|
||||||
|
EXPECT_NE(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
tcsInit();
|
||||||
|
extern int8_t tsS3EpNum;
|
||||||
|
tsS3EpNum = 1;
|
||||||
|
|
||||||
|
code = uploadCheckpointToS3("123", "/tmp/backend5/stream");
|
||||||
|
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
code = downloadCheckpointByNameS3("123", "/root/download", "");
|
||||||
|
EXPECT_NE(code, TSDB_CODE_OUT_OF_RANGE);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include "tstream.h"
|
||||||
|
#include "streamInt.h"
|
||||||
|
#include "tcs.h"
|
||||||
|
#include "tglobal.h"
|
||||||
|
#include "streamState.h"
|
||||||
|
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wsign-compare"
|
||||||
|
#pragma GCC diagnostic ignored "-Wformat"
|
||||||
|
#pragma GCC diagnostic ignored "-Wint-to-pointer-cast"
|
||||||
|
#pragma GCC diagnostic ignored "-Wpointer-arith"
|
||||||
|
|
||||||
|
|
||||||
|
SStreamState *stateCreate2(const char *path) {
|
||||||
|
SStreamTask *pTask = (SStreamTask *)taosMemoryCalloc(1, sizeof(SStreamTask));
|
||||||
|
pTask->ver = 1024;
|
||||||
|
pTask->id.streamId = 1023;
|
||||||
|
pTask->id.taskId = 1111111;
|
||||||
|
SStreamMeta *pMeta = NULL;
|
||||||
|
|
||||||
|
int32_t code = streamMetaOpen((path), NULL, NULL, NULL, 0, 0, NULL, &pMeta);
|
||||||
|
pTask->pMeta = pMeta;
|
||||||
|
|
||||||
|
SStreamState *p = streamStateOpen((char *)path, pTask, 0, 0);
|
||||||
|
ASSERT(p != NULL);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
void *backendOpen2() {
|
||||||
|
streamMetaInit();
|
||||||
|
const char *path = "/tmp/streamslicestate/";
|
||||||
|
SStreamState *p = stateCreate2(path);
|
||||||
|
ASSERT(p != NULL);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
TSKEY compareTs1(void* pKey) {
|
||||||
|
SWinKey* pWinKey = (SWinKey*)pKey;
|
||||||
|
return pWinKey->ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(getHashSortNextRowFn, getHashSortNextRowTest) {
|
||||||
|
void *pState = backendOpen2();
|
||||||
|
SStreamFileState *pFileState = NULL;
|
||||||
|
int32_t code = streamFileStateInit(1024, sizeof(SWinKey), 10, 0, compareTs1, pState, INT64_MAX, "aaa", 123,
|
||||||
|
STREAM_STATE_BUFF_HASH, &pFileState);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SWinKey key1;
|
||||||
|
key1.groupId = 123;
|
||||||
|
key1.ts = 456;
|
||||||
|
char str[] = "abc";
|
||||||
|
code = streamStateFillPut_rocksdb((SStreamState*)pState, &key1, str, sizeof(str));
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SWinKey key2;
|
||||||
|
key2.groupId = 123;
|
||||||
|
key2.ts = 460;
|
||||||
|
code = streamStateFillPut_rocksdb((SStreamState*)pState, &key2, str, sizeof(str));
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
SWinKey key3;
|
||||||
|
key3.groupId = 123;
|
||||||
|
void* pVal = NULL;
|
||||||
|
int32_t len = 0;
|
||||||
|
int32_t wincode = 0;
|
||||||
|
code = getHashSortNextRow(pFileState, &key1, &key3, &pVal, &len, &wincode);
|
||||||
|
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||||
|
|
||||||
|
ASSERT_EQ(key3.ts, key2.ts);
|
||||||
|
}
|
|
@ -405,8 +405,6 @@ bool taosMbsToUcs4(const char *mbs, size_t mbsLength, TdUcs4 *ucs4, int32_t ucs4
|
||||||
size_t ucs4_input_len = mbsLength;
|
size_t ucs4_input_len = mbsLength;
|
||||||
size_t outLeft = ucs4_max_len;
|
size_t outLeft = ucs4_max_len;
|
||||||
if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) {
|
if (iconv(conv, (char **)&mbs, &ucs4_input_len, (char **)&ucs4, &outLeft) == -1) {
|
||||||
char buf[512] = {0};
|
|
||||||
snprintf(buf, tListLen(buf), " taosMbsToUcs4 error:%s %d %d", strerror(terrno), errno, EILSEQ);
|
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
taosReleaseConv(idx, conv, M2C, charsetCxt);
|
taosReleaseConv(idx, conv, M2C, charsetCxt);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -454,7 +454,8 @@ struct tm *taosGmTimeR(const time_t *timep, struct tm *result) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
return gmtime_s(result, timep);
|
errno_t code = gmtime_s(result, timep);
|
||||||
|
return (code == 0) ? result : NULL;
|
||||||
#else
|
#else
|
||||||
return gmtime_r(timep, result);
|
return gmtime_r(timep, result);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -94,6 +94,35 @@ TEST(osTimeTests, taosLocalTime) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(osTimeTests, taosGmTimeR) {
|
||||||
|
// Test 1: Test when both timep and result are not NULL
|
||||||
|
time_t timep = 1617531000; // 2021-04-04 18:10:00
|
||||||
|
struct tm tmInfo;
|
||||||
|
ASSERT_NE(taosGmTimeR(&timep, &tmInfo), nullptr);
|
||||||
|
|
||||||
|
char buf[128];
|
||||||
|
taosStrfTime(buf, sizeof(buf), "%Y-%m-%dT%H:%M:%S", &tmInfo);
|
||||||
|
ASSERT_STREQ(buf, "2021-04-04T10:10:00");
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(osTimeTests, taosTimeGm) {
|
||||||
|
char *timestr= "2021-04-04T18:10:00";
|
||||||
|
struct tm tm = {0};
|
||||||
|
|
||||||
|
taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
|
||||||
|
int64_t seconds = taosTimeGm(&tm);
|
||||||
|
ASSERT_EQ(seconds, 1617559800);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(osTimeTests, taosMktime) {
|
||||||
|
char *timestr= "2021-04-04T18:10:00";
|
||||||
|
struct tm tm = {0};
|
||||||
|
|
||||||
|
taosStrpTime(timestr, "%Y-%m-%dT%H:%M:%S", &tm);
|
||||||
|
time_t seconds = taosMktime(&tm, NULL);
|
||||||
|
ASSERT_EQ(seconds, 1617531000);
|
||||||
|
}
|
||||||
|
|
||||||
TEST(osTimeTests, invalidParameter) {
|
TEST(osTimeTests, invalidParameter) {
|
||||||
void *retp = NULL;
|
void *retp = NULL;
|
||||||
int32_t reti = 0;
|
int32_t reti = 0;
|
||||||
|
|
|
@ -22,7 +22,7 @@ char tsSIMDEnable = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type) {
|
int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements, char *const output, const char type) {
|
||||||
#ifdef __AVX2__
|
#ifdef __AVX512F__
|
||||||
int32_t word_length = getWordLength(type);
|
int32_t word_length = getWordLength(type);
|
||||||
|
|
||||||
// Selector value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
// Selector value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||||
|
@ -53,23 +53,10 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
||||||
int32_t gRemainder = (nelements - _pos);
|
int32_t gRemainder = (nelements - _pos);
|
||||||
int32_t num = (gRemainder > elems) ? elems : gRemainder;
|
int32_t num = (gRemainder > elems) ? elems : gRemainder;
|
||||||
|
|
||||||
int32_t batch = 0;
|
int32_t batch = num >> 3;
|
||||||
int32_t remain = 0;
|
int32_t remain = num & 0x07;
|
||||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
|
||||||
#ifdef __AVX512F__
|
|
||||||
batch = num >> 3;
|
|
||||||
remain = num & 0x07;
|
|
||||||
#endif
|
|
||||||
} else if (tsSIMDEnable && tsAVX2Supported) {
|
|
||||||
#ifdef __AVX2__
|
|
||||||
batch = num >> 2;
|
|
||||||
remain = num & 0x03;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selector == 0 || selector == 1) {
|
if (selector == 0 || selector == 1) {
|
||||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
|
||||||
#ifdef __AVX512F__
|
|
||||||
for (int32_t i = 0; i < batch; ++i) {
|
for (int32_t i = 0; i < batch; ++i) {
|
||||||
__m512i prev = _mm512_set1_epi64(prevValue);
|
__m512i prev = _mm512_set1_epi64(prevValue);
|
||||||
_mm512_storeu_si512((__m512i *)&p[_pos], prev);
|
_mm512_storeu_si512((__m512i *)&p[_pos], prev);
|
||||||
|
@ -78,27 +65,7 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
||||||
for (int32_t i = 0; i < remain; ++i) {
|
for (int32_t i = 0; i < remain; ++i) {
|
||||||
p[_pos++] = prevValue;
|
p[_pos++] = prevValue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else if (tsSIMDEnable && tsAVX2Supported) {
|
|
||||||
for (int32_t i = 0; i < batch; ++i) {
|
|
||||||
__m256i prev = _mm256_set1_epi64x(prevValue);
|
|
||||||
_mm256_storeu_si256((__m256i *)&p[_pos], prev);
|
|
||||||
_pos += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < remain; ++i) {
|
|
||||||
p[_pos++] = prevValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else { // alternative implementation without SIMD instructions.
|
|
||||||
for (int32_t i = 0; i < elems && count < nelements; i++, count++) {
|
|
||||||
p[_pos++] = prevValue;
|
|
||||||
v += bit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
|
||||||
#ifdef __AVX512F__
|
|
||||||
__m512i sum_mask1 = _mm512_set_epi64(6, 6, 4, 4, 2, 2, 0, 0);
|
__m512i sum_mask1 = _mm512_set_epi64(6, 6, 4, 4, 2, 2, 0, 0);
|
||||||
__m512i sum_mask2 = _mm512_set_epi64(5, 5, 5, 5, 1, 1, 1, 1);
|
__m512i sum_mask2 = _mm512_set_epi64(5, 5, 5, 5, 1, 1, 1, 1);
|
||||||
__m512i sum_mask3 = _mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3);
|
__m512i sum_mask3 = _mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3);
|
||||||
|
@ -160,77 +127,6 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
||||||
p[_pos++] = prevValue;
|
p[_pos++] = prevValue;
|
||||||
v += bit;
|
v += bit;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
} else if (tsSIMDEnable && tsAVX2Supported) {
|
|
||||||
__m256i base = _mm256_set1_epi64x(w);
|
|
||||||
__m256i maskVal = _mm256_set1_epi64x(mask);
|
|
||||||
|
|
||||||
__m256i shiftBits = _mm256_set_epi64x(bit * 3 + 4, bit * 2 + 4, bit + 4, 4);
|
|
||||||
__m256i inc = _mm256_set1_epi64x(bit << 2);
|
|
||||||
|
|
||||||
for (int32_t i = 0; i < batch; ++i) {
|
|
||||||
__m256i after = _mm256_srlv_epi64(base, shiftBits);
|
|
||||||
__m256i zigzagVal = _mm256_and_si256(after, maskVal);
|
|
||||||
|
|
||||||
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
|
|
||||||
__m256i signmask = _mm256_and_si256(_mm256_set1_epi64x(1), zigzagVal);
|
|
||||||
signmask = _mm256_sub_epi64(_mm256_setzero_si256(), signmask);
|
|
||||||
|
|
||||||
// get four zigzag values here
|
|
||||||
__m256i delta = _mm256_xor_si256(_mm256_srli_epi64(zigzagVal, 1), signmask);
|
|
||||||
|
|
||||||
// calculate the cumulative sum (prefix sum) for each number
|
|
||||||
// decode[0] = prevValue + final[0]
|
|
||||||
// decode[1] = decode[0] + final[1] -----> prevValue + final[0] + final[1]
|
|
||||||
// decode[2] = decode[1] + final[2] -----> prevValue + final[0] + final[1] + final[2]
|
|
||||||
// decode[3] = decode[2] + final[3] -----> prevValue + final[0] + final[1] + final[2] + final[3]
|
|
||||||
|
|
||||||
// 1, 2, 3, 4
|
|
||||||
//+ 0, 1, 0, 3
|
|
||||||
// 1, 3, 3, 7
|
|
||||||
// shift and add for the first round
|
|
||||||
__m128i prev = _mm_set1_epi64x(prevValue);
|
|
||||||
__m256i x = _mm256_slli_si256(delta, 8);
|
|
||||||
|
|
||||||
delta = _mm256_add_epi64(delta, x);
|
|
||||||
_mm256_storeu_si256((__m256i *)&p[_pos], delta);
|
|
||||||
|
|
||||||
// 1, 3, 3, 7
|
|
||||||
//+ 0, 0, 3, 3
|
|
||||||
// 1, 3, 6, 10
|
|
||||||
// shift and add operation for the second round
|
|
||||||
__m128i firstPart = _mm_loadu_si128((__m128i *)&p[_pos]);
|
|
||||||
__m128i secondItem = _mm_set1_epi64x(p[_pos + 1]);
|
|
||||||
__m128i secPart = _mm_add_epi64(_mm_loadu_si128((__m128i *)&p[_pos + 2]), secondItem);
|
|
||||||
firstPart = _mm_add_epi64(firstPart, prev);
|
|
||||||
secPart = _mm_add_epi64(secPart, prev);
|
|
||||||
|
|
||||||
// save it in the memory
|
|
||||||
_mm_storeu_si128((__m128i *)&p[_pos], firstPart);
|
|
||||||
_mm_storeu_si128((__m128i *)&p[_pos + 2], secPart);
|
|
||||||
|
|
||||||
shiftBits = _mm256_add_epi64(shiftBits, inc);
|
|
||||||
prevValue = p[_pos + 3];
|
|
||||||
_pos += 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
// handle the remain value
|
|
||||||
for (int32_t i = 0; i < remain; i++) {
|
|
||||||
zigzag_value = ((w >> (v + (batch * bit * 4))) & mask);
|
|
||||||
prevValue += ZIGZAG_DECODE(int64_t, zigzag_value);
|
|
||||||
|
|
||||||
p[_pos++] = prevValue;
|
|
||||||
v += bit;
|
|
||||||
}
|
|
||||||
} else { // alternative implementation without SIMD instructions.
|
|
||||||
for (int32_t i = 0; i < elems && count < nelements; i++, count++) {
|
|
||||||
zigzag_value = ((w >> v) & mask);
|
|
||||||
prevValue += ZIGZAG_DECODE(int64_t, zigzag_value);
|
|
||||||
|
|
||||||
p[_pos++] = prevValue;
|
|
||||||
v += bit;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case TSDB_DATA_TYPE_INT: {
|
case TSDB_DATA_TYPE_INT: {
|
||||||
|
@ -292,7 +188,7 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
||||||
|
|
||||||
return nelements * word_length;
|
return nelements * word_length;
|
||||||
#else
|
#else
|
||||||
uError("unable run %s without avx2 instructions", __func__);
|
uError("unable run %s without avx512 instructions", __func__);
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -823,6 +823,8 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ
|
||||||
int32_t tQueryAutoQWorkerInit(SQueryAutoQWorkerPool *pool) {
|
int32_t tQueryAutoQWorkerInit(SQueryAutoQWorkerPool *pool) {
|
||||||
int32_t code;
|
int32_t code;
|
||||||
|
|
||||||
|
pool->exit = false;
|
||||||
|
|
||||||
(void)taosThreadMutexInit(&pool->poolLock, NULL);
|
(void)taosThreadMutexInit(&pool->poolLock, NULL);
|
||||||
(void)taosThreadMutexInit(&pool->backupLock, NULL);
|
(void)taosThreadMutexInit(&pool->backupLock, NULL);
|
||||||
(void)taosThreadMutexInit(&pool->waitingAfterBlockLock, NULL);
|
(void)taosThreadMutexInit(&pool->waitingAfterBlockLock, NULL);
|
||||||
|
|
|
@ -138,6 +138,10 @@ add_test(
|
||||||
COMMAND logTest
|
COMMAND logTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(COMPILER_SUPPORT_AVX2)
|
||||||
|
MESSAGE(STATUS "AVX2 instructions is ACTIVATED")
|
||||||
|
set_source_files_properties(decompressTest.cpp PROPERTIES COMPILE_FLAGS -mavx2)
|
||||||
|
ENDIF()
|
||||||
add_executable(decompressTest "decompressTest.cpp")
|
add_executable(decompressTest "decompressTest.cpp")
|
||||||
target_link_libraries(decompressTest os util common gtest_main)
|
target_link_libraries(decompressTest os util common gtest_main)
|
||||||
add_test(
|
add_test(
|
||||||
|
@ -145,6 +149,16 @@ add_test(
|
||||||
COMMAND decompressTest
|
COMMAND decompressTest
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
IF($TD_LINUX)
|
||||||
|
add_executable(utilTests "utilTests.cpp")
|
||||||
|
target_link_libraries(utilTests os util common gtest_main)
|
||||||
|
add_test(
|
||||||
|
NAME utilTests
|
||||||
|
COMMAND utilTests
|
||||||
|
)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
if(${TD_LINUX})
|
if(${TD_LINUX})
|
||||||
# terrorTest
|
# terrorTest
|
||||||
add_executable(terrorTest "terrorTest.cpp")
|
add_executable(terrorTest "terrorTest.cpp")
|
||||||
|
|
|
@ -2048,7 +2048,252 @@ TEST(DisablePoolFuncTest, MultiThreadTest) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if 1
|
||||||
|
TEST(functionsTest, internalFunc) {
|
||||||
|
char* caseName = "functionsTest:internalFunc";
|
||||||
|
int32_t code = 0;
|
||||||
|
|
||||||
|
int64_t msize = 10;
|
||||||
|
void* pSession = NULL;
|
||||||
|
void* pJob = NULL;
|
||||||
|
|
||||||
|
mptInitPool();
|
||||||
|
|
||||||
|
memset(mptCtx.jobCtxs, 0, sizeof(*mptCtx.jobCtxs));
|
||||||
|
|
||||||
|
assert(0 == taosMemPoolCallocJob(0, 0, (void**)&pJob));
|
||||||
|
assert(0 == taosMemPoolInitSession(gMemPoolHandle, &pSession, pJob, "id"));
|
||||||
|
|
||||||
|
int32_t loopTimes = 1;
|
||||||
|
int64_t st = 0;
|
||||||
|
void **addrList = (void**)taosMemCalloc(loopTimes, POINTER_BYTES);
|
||||||
|
|
||||||
|
|
||||||
|
// MALLOC
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMalloc(msize);
|
||||||
|
}
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMalloc(msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMalloc(msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
// CALLOC
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryCalloc(1, msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryCalloc(1, msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryCalloc(1, msize);
|
||||||
|
}
|
||||||
|
//mptFreeAddrList(addrList, loopTimes); NO FREE FOR REALLOC
|
||||||
|
|
||||||
|
// REALLOC
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryRealloc(addrList[i], msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryRealloc(addrList[i], msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryRealloc(addrList[i], msize);
|
||||||
|
}
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
// STRDUP
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrdup("abc");
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrdup("abc");
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrdup("abc");
|
||||||
|
}
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
// STRNDUP
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrndup("abc", 3);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrndup("abc", 3);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptStrndup("abc", 3);
|
||||||
|
}
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
// ALIGNALLOC
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMallocAlign(8, msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMallocAlign(8, msize);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
mptFreeAddrList(addrList, loopTimes);
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMallocAlign(8, msize);
|
||||||
|
}
|
||||||
|
//mptFreeAddrList(addrList, loopTimes); NO FREE FOR GETSIZE
|
||||||
|
|
||||||
|
|
||||||
|
// GETSIZE
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemorySize(addrList[i]);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemorySize(addrList[i]);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemorySize(addrList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FREE
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemoryFree(addrList[i]);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMalloc(msize);
|
||||||
|
}
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemoryFree(addrList[i]);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
addrList[i] = (char*)mptMemoryMalloc(msize);
|
||||||
|
}
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemoryFree(addrList[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TRIM
|
||||||
|
|
||||||
|
bool trimed = false;
|
||||||
|
tsMemPoolFullFunc = 0;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemoryTrim(0, NULL);
|
||||||
|
mptMemoryTrim(0, &trimed);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
tsMemPoolFullFunc = 1;
|
||||||
|
mptEnableMemoryPoolUsage(gMemPoolHandle, pSession);
|
||||||
|
for (int32_t i = 0; i < loopTimes; ++i) {
|
||||||
|
mptMemoryTrim(0, NULL);
|
||||||
|
mptMemoryTrim(0, &trimed);
|
||||||
|
}
|
||||||
|
mptDisableMemoryPoolUsage();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "tarray.h"
|
#include "tarray.h"
|
||||||
#include "tcompare.h"
|
#include "tcompare.h"
|
||||||
|
#include "tdatablock.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -474,3 +475,67 @@ TEST(tsma, reverse_unit) {
|
||||||
ASSERT_FALSE(tsmaIntervalCheck(12, 'n', 1, 'y', TSDB_TIME_PRECISION_NANO));
|
ASSERT_FALSE(tsmaIntervalCheck(12, 'n', 1, 'y', TSDB_TIME_PRECISION_NANO));
|
||||||
ASSERT_TRUE(tsmaIntervalCheck(3, 'n', 1, 'y', TSDB_TIME_PRECISION_NANO));
|
ASSERT_TRUE(tsmaIntervalCheck(3, 'n', 1, 'y', TSDB_TIME_PRECISION_NANO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <int16_t type, typename ValType, typename F>
|
||||||
|
void dataBlockNullTest(const F& setValFunc) {
|
||||||
|
int32_t totalRows = 16;
|
||||||
|
SColumnInfoData columnInfoData = createColumnInfoData(type, tDataTypes[type].bytes, 0);
|
||||||
|
SColumnDataAgg columnDataAgg = {.numOfNull = 0};
|
||||||
|
|
||||||
|
auto checkNull = [totalRows, &columnInfoData, &columnDataAgg](uint32_t row, bool expected) {
|
||||||
|
EXPECT_EQ(colDataIsNull_s(&columnInfoData, row), expected);
|
||||||
|
EXPECT_EQ(colDataIsNull_t(&columnInfoData, row, IS_VAR_DATA_TYPE(columnInfoData.info.type)), expected);
|
||||||
|
EXPECT_EQ(colDataIsNull(&columnInfoData, totalRows, row, NULL), expected);
|
||||||
|
columnDataAgg.numOfNull = totalRows;
|
||||||
|
EXPECT_EQ(colDataIsNull(&columnInfoData, totalRows, row, &columnDataAgg), columnInfoData.hasNull);
|
||||||
|
columnDataAgg.numOfNull = 0;
|
||||||
|
EXPECT_EQ(colDataIsNull(&columnInfoData, totalRows, row, &columnDataAgg), false);
|
||||||
|
};
|
||||||
|
|
||||||
|
columnInfoData.hasNull = false;
|
||||||
|
checkNull(0, false);
|
||||||
|
checkNull(1, false);
|
||||||
|
checkNull(2, false);
|
||||||
|
checkNull(totalRows - 2, false);
|
||||||
|
checkNull(totalRows - 1, false);
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
columnInfoData.varmeta.offset = (int32_t*)taosMemoryCalloc(totalRows, sizeof(int32_t));
|
||||||
|
} else {
|
||||||
|
columnInfoData.pData = (char*)taosMemoryCalloc(totalRows, tDataTypes[type].bytes);
|
||||||
|
columnInfoData.nullbitmap = (char*)taosMemoryCalloc(((totalRows - 1) >> NBIT) + 1, 1);
|
||||||
|
ValType val = 1;
|
||||||
|
setValFunc(&columnInfoData, 1, &val);
|
||||||
|
val = 2;
|
||||||
|
setValFunc(&columnInfoData, 2, &val);
|
||||||
|
}
|
||||||
|
colDataSetNULL(&columnInfoData, 0);
|
||||||
|
colDataSetNNULL(&columnInfoData, 3, totalRows - 3);
|
||||||
|
checkNull(0, true);
|
||||||
|
checkNull(1, false);
|
||||||
|
checkNull(2, false);
|
||||||
|
checkNull(totalRows - 2, true);
|
||||||
|
checkNull(totalRows - 1, true);
|
||||||
|
|
||||||
|
if (IS_VAR_DATA_TYPE(type)) {
|
||||||
|
taosMemoryFreeClear(columnInfoData.varmeta.offset);
|
||||||
|
} else {
|
||||||
|
taosMemoryFreeClear(columnInfoData.pData);
|
||||||
|
taosMemoryFreeClear(columnInfoData.nullbitmap);
|
||||||
|
checkNull(0, false);
|
||||||
|
checkNull(1, false);
|
||||||
|
checkNull(2, false);
|
||||||
|
checkNull(totalRows - 2, false);
|
||||||
|
checkNull(totalRows - 1, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(utilTest, tdatablockTestNull) {
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_TINYINT, int8_t>(colDataSetInt8);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_SMALLINT, int16_t>(colDataSetInt16);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_INT, int32_t>(colDataSetInt32);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_BIGINT, int64_t>(colDataSetInt64);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_FLOAT, float>(colDataSetFloat);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_DOUBLE, double>(colDataSetDouble);
|
||||||
|
dataBlockNullTest<TSDB_DATA_TYPE_VARCHAR, int64_t>(colDataSetInt64);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
import taos
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import subprocess
|
||||||
|
import glob
|
||||||
|
import shutil
|
||||||
|
import time
|
||||||
|
|
||||||
|
from frame.log import *
|
||||||
|
from frame.cases import *
|
||||||
|
from frame.sql import *
|
||||||
|
from frame.srvCtl import *
|
||||||
|
from frame.caseBase import *
|
||||||
|
from frame import *
|
||||||
|
from frame.autogen import *
|
||||||
|
from frame import epath
|
||||||
|
# from frame.server.dnodes import *
|
||||||
|
# from frame.server.cluster import *
|
||||||
|
|
||||||
|
|
||||||
|
class TDTestCase(TBase):
|
||||||
|
|
||||||
|
def init(self, conn, logSql, replicaVar=1):
|
||||||
|
updatecfgDict = {'dDebugFlag':131}
|
||||||
|
super(TDTestCase, self).init(conn, logSql, replicaVar=1, checkColName="c1")
|
||||||
|
|
||||||
|
self.valgrind = 0
|
||||||
|
self.db = "test"
|
||||||
|
self.stb = "meters"
|
||||||
|
self.childtable_count = 10
|
||||||
|
tdSql.init(conn.cursor(), logSql)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
tdSql.execute('CREATE DATABASE db vgroups 1 replica 2;')
|
||||||
|
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
|
||||||
|
while count < 100:
|
||||||
|
tdSql.query("show arbgroups;")
|
||||||
|
|
||||||
|
if tdSql.getData(0, 4) == 1:
|
||||||
|
break
|
||||||
|
|
||||||
|
tdLog.info("wait 1 seconds for is sync")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
|
||||||
|
tdSql.query("show db.vgroups;")
|
||||||
|
|
||||||
|
if(tdSql.getData(0, 4) == "follower") and (tdSql.getData(0, 6) == "leader"):
|
||||||
|
tdLog.info("stop dnode2")
|
||||||
|
sc.dnodeStop(2)
|
||||||
|
|
||||||
|
if(tdSql.getData(0, 6) == "follower") and (tdSql.getData(0, 4) == "leader"):
|
||||||
|
tdLog.info("stop dnode 3")
|
||||||
|
sc.dnodeStop(3)
|
||||||
|
|
||||||
|
|
||||||
|
count = 0
|
||||||
|
while count < 100:
|
||||||
|
tdSql.query("show db.vgroups;")
|
||||||
|
|
||||||
|
if(tdSql.getData(0, 4) == "assigned ") or (tdSql.getData(0, 6) == "assigned "):
|
||||||
|
break
|
||||||
|
|
||||||
|
tdLog.info("wait 1 seconds for set assigned")
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
count += 1
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
tdSql.close()
|
||||||
|
tdLog.success(f"{__file__} successfully executed")
|
||||||
|
|
||||||
|
|
||||||
|
tdCases.addLinux(__file__, TDTestCase())
|
||||||
|
tdCases.addWindows(__file__, TDTestCase())
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
taos> select leastsquares(1, 1, 1)
|
||||||
|
leastsquares(1, 1, 1) |
|
||||||
|
=================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(1.1 as float), 1, 1)
|
||||||
|
leastsquares(cast(1.1 as float), 1, 1) |
|
||||||
|
=========================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(1.1 as double), 1, 1)
|
||||||
|
leastsquares(cast(1.1 as double), 1, 1) |
|
||||||
|
==========================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(1 as tinyint), 1, 1)
|
||||||
|
leastsquares(cast(1 as tinyint), 1, 1) |
|
||||||
|
=========================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(100 as smallint), 1, 1)
|
||||||
|
leastsquares(cast(100 as smallint), 1, 1) |
|
||||||
|
============================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(100000 as int), 1, 1)
|
||||||
|
leastsquares(cast(100000 as int), 1, 1) |
|
||||||
|
==========================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(10000000000 as bigint), 1, 1)
|
||||||
|
leastsquares(cast(10000000000 as bigint), 1, 1) |
|
||||||
|
==================================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(1 as tinyint unsigned), 1, 1)
|
||||||
|
leastsquares(cast(1 as tinyint unsigned), 1, 1) |
|
||||||
|
==================================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(100 as smallint unsigned), 1, 1)
|
||||||
|
leastsquares(cast(100 as smallint unsigned), 1, 1) |
|
||||||
|
=====================================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(100000 as int unsigned), 1, 1)
|
||||||
|
leastsquares(cast(100000 as int unsigned), 1, 1) |
|
||||||
|
===================================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
||||||
|
taos> select leastsquares(cast(10000000000 as bigint unsigned), 1, 1)
|
||||||
|
leastsquares(cast(10000000000 as bigint unsigned), 1, 1) |
|
||||||
|
===========================================================
|
||||||
|
{slop:-nan, intercept:-nan} |
|
||||||
|
|
|
|
@ -603,3 +603,58 @@ taos> select location, max(current) from ts_4893.meters group by location order
|
||||||
============================================
|
============================================
|
||||||
beijing | 11.9989996 |
|
beijing | 11.9989996 |
|
||||||
|
|
||||||
|
taos> select max(1)
|
||||||
|
max(1) |
|
||||||
|
========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select max(cast(1 as tinyint))
|
||||||
|
max(cast(1 as tinyint)) |
|
||||||
|
==========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select max(cast(100 as smallint))
|
||||||
|
max(cast(100 as smallint)) |
|
||||||
|
=============================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select max(cast(100000 as int))
|
||||||
|
max(cast(100000 as int)) |
|
||||||
|
===========================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select max(cast(10000000000 as bigint))
|
||||||
|
max(cast(10000000000 as bigint)) |
|
||||||
|
===================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select max(cast(1 as tinyint unsigned))
|
||||||
|
max(cast(1 as tinyint unsigned)) |
|
||||||
|
===================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select max(cast(100 as smallint unsigned))
|
||||||
|
max(cast(100 as smallint unsigned)) |
|
||||||
|
======================================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select max(cast(100000 as int unsigned))
|
||||||
|
max(cast(100000 as int unsigned)) |
|
||||||
|
====================================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select max(cast(10000000000 as bigint unsigned))
|
||||||
|
max(cast(10000000000 as bigint unsigned)) |
|
||||||
|
============================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select max(cast(1.1 as float))
|
||||||
|
max(cast(1.1 as float)) |
|
||||||
|
==========================
|
||||||
|
1.1000000e+00 |
|
||||||
|
|
||||||
|
taos> select max(cast(1.1 as double))
|
||||||
|
max(cast(1.1 as double)) |
|
||||||
|
============================
|
||||||
|
1.100000000000000 |
|
||||||
|
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 576.
|
|
@ -603,3 +603,58 @@ taos> select location, min(id) from ts_4893.meters group by location order by lo
|
||||||
===================================
|
===================================
|
||||||
beijing | 0 |
|
beijing | 0 |
|
||||||
|
|
||||||
|
taos> select min(1)
|
||||||
|
min(1) |
|
||||||
|
========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select min(cast(1 as tinyint))
|
||||||
|
min(cast(1 as tinyint)) |
|
||||||
|
==========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select min(cast(100 as smallint))
|
||||||
|
min(cast(100 as smallint)) |
|
||||||
|
=============================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select min(cast(100000 as int))
|
||||||
|
min(cast(100000 as int)) |
|
||||||
|
===========================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select min(cast(10000000000 as bigint))
|
||||||
|
min(cast(10000000000 as bigint)) |
|
||||||
|
===================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select min(cast(1 as tinyint unsigned))
|
||||||
|
min(cast(1 as tinyint unsigned)) |
|
||||||
|
===================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select min(cast(100 as smallint unsigned))
|
||||||
|
min(cast(100 as smallint unsigned)) |
|
||||||
|
======================================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select min(cast(100000 as int unsigned))
|
||||||
|
min(cast(100000 as int unsigned)) |
|
||||||
|
====================================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select min(cast(10000000000 as bigint unsigned))
|
||||||
|
min(cast(10000000000 as bigint unsigned)) |
|
||||||
|
============================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select min(cast(1.1 as float))
|
||||||
|
min(cast(1.1 as float)) |
|
||||||
|
==========================
|
||||||
|
1.1000000e+00 |
|
||||||
|
|
||||||
|
taos> select min(cast(1.1 as double))
|
||||||
|
min(cast(1.1 as double)) |
|
||||||
|
============================
|
||||||
|
1.100000000000000 |
|
||||||
|
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 576.
|
|
@ -308,3 +308,53 @@ taos> select round(log(current), 2) from ts_4893.meters limit 1
|
||||||
============================
|
============================
|
||||||
2.370000000000000 |
|
2.370000000000000 |
|
||||||
|
|
||||||
|
taos> select round(cast(1.0e+400 as float), 0);
|
||||||
|
round(cast(1.0e+400 as float), 0) |
|
||||||
|
====================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select round(cast(1.0e+400 as double), 0);
|
||||||
|
round(cast(1.0e+400 as double), 0) |
|
||||||
|
=====================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select round(cast(5 as tinyint), 1);
|
||||||
|
round(cast(5 as tinyint), 1) |
|
||||||
|
===============================
|
||||||
|
5 |
|
||||||
|
|
||||||
|
taos> select round(cast(50 as smallint), 1);
|
||||||
|
round(cast(50 as smallint), 1) |
|
||||||
|
=================================
|
||||||
|
50 |
|
||||||
|
|
||||||
|
taos> select round(cast(500 as int), 1);
|
||||||
|
round(cast(500 as int), 1) |
|
||||||
|
=============================
|
||||||
|
500 |
|
||||||
|
|
||||||
|
taos> select round(cast(50000 as bigint), 1);
|
||||||
|
round(cast(50000 as bigint), 1) |
|
||||||
|
==================================
|
||||||
|
50000 |
|
||||||
|
|
||||||
|
taos> select round(cast(5 as TINYINT UNSIGNED), 1);
|
||||||
|
round(cast(5 as tinyint unsigned), 1) |
|
||||||
|
========================================
|
||||||
|
5 |
|
||||||
|
|
||||||
|
taos> select round(cast(50 as smallint unsigned), 1);
|
||||||
|
round(cast(50 as smallint unsigned), 1) |
|
||||||
|
==========================================
|
||||||
|
50 |
|
||||||
|
|
||||||
|
taos> select round(cast(500 as int unsigned), 1);
|
||||||
|
round(cast(500 as int unsigned), 1) |
|
||||||
|
======================================
|
||||||
|
500 |
|
||||||
|
|
||||||
|
taos> select round(cast(50000 as bigint unsigned), 1)
|
||||||
|
round(cast(50000 as bigint unsigned), 1) |
|
||||||
|
===========================================
|
||||||
|
50000 |
|
||||||
|
|
||||||
|
|
|
|
@ -121,6 +121,106 @@ taos> select SIGN(id) + id from ts_4893.meters order by ts limit 5
|
||||||
4.000000000000000 |
|
4.000000000000000 |
|
||||||
5.000000000000000 |
|
5.000000000000000 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as tinyint))
|
||||||
|
sign(cast(1 as tinyint)) |
|
||||||
|
===========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as smallint))
|
||||||
|
sign(cast(1 as smallint)) |
|
||||||
|
============================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as int))
|
||||||
|
sign(cast(1 as int)) |
|
||||||
|
=======================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as bigint))
|
||||||
|
sign(cast(1 as bigint)) |
|
||||||
|
==========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as tinyint unsigned))
|
||||||
|
sign(cast(1 as tinyint unsigned)) |
|
||||||
|
====================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as smallint unsigned))
|
||||||
|
sign(cast(1 as smallint unsigned)) |
|
||||||
|
=====================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as int unsigned))
|
||||||
|
sign(cast(1 as int unsigned)) |
|
||||||
|
================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as bigint unsigned))
|
||||||
|
sign(cast(1 as bigint unsigned)) |
|
||||||
|
===================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as float))
|
||||||
|
sign(cast(1 as float)) |
|
||||||
|
=========================
|
||||||
|
1.0000000e+00 |
|
||||||
|
|
||||||
|
taos> select sign(cast(1 as double))
|
||||||
|
sign(cast(1 as double)) |
|
||||||
|
============================
|
||||||
|
1.000000000000000 |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as tinyint))
|
||||||
|
sign(cast(null as tinyint)) |
|
||||||
|
==============================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as smallint))
|
||||||
|
sign(cast(null as smallint)) |
|
||||||
|
===============================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as int))
|
||||||
|
sign(cast(null as int)) |
|
||||||
|
==========================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as bigint))
|
||||||
|
sign(cast(null as bigint)) |
|
||||||
|
=============================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as tinyint unsigned))
|
||||||
|
sign(cast(null as tinyint unsigned)) |
|
||||||
|
=======================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as smallint unsigned))
|
||||||
|
sign(cast(null as smallint unsigned)) |
|
||||||
|
========================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as int unsigned))
|
||||||
|
sign(cast(null as int unsigned)) |
|
||||||
|
===================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as bigint unsigned))
|
||||||
|
sign(cast(null as bigint unsigned)) |
|
||||||
|
======================================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as float))
|
||||||
|
sign(cast(null as float)) |
|
||||||
|
============================
|
||||||
|
NULL |
|
||||||
|
|
||||||
|
taos> select sign(cast(NULL as double))
|
||||||
|
sign(cast(null as double)) |
|
||||||
|
=============================
|
||||||
|
NULL |
|
||||||
|
|
||||||
taos> select SIGN(abs(10))
|
taos> select SIGN(abs(10))
|
||||||
sign(abs(10)) |
|
sign(abs(10)) |
|
||||||
========================
|
========================
|
||||||
|
@ -213,6 +313,34 @@ taos> select sign(current) from ts_4893.meters order by ts limit 10
|
||||||
1.0000000 |
|
1.0000000 |
|
||||||
1.0000000 |
|
1.0000000 |
|
||||||
|
|
||||||
|
taos> select sign(cast(current as float)) from ts_4893.d0 order by ts limit 10
|
||||||
|
sign(cast(current as float)) |
|
||||||
|
===============================
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
|
||||||
|
taos> select sign(cast(current as float)) from ts_4893.meters order by ts limit 10
|
||||||
|
sign(cast(current as float)) |
|
||||||
|
===============================
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
1.0000000e+00 |
|
||||||
|
|
||||||
taos> select sign(null)
|
taos> select sign(null)
|
||||||
sign(null) |
|
sign(null) |
|
||||||
========================
|
========================
|
||||||
|
|
Can't render this file because it has a wrong number of fields in line 139.
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
taos> select statecount(1, 'GT', 1)
|
||||||
|
statecount(1, 'GT', 1) |
|
||||||
|
=========================
|
||||||
|
-1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(1 as tinyint), 'GT', 1)
|
||||||
|
statecount(cast(1 as tinyint), 'GT', 1) |
|
||||||
|
==========================================
|
||||||
|
-1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(100 as smallint), 'GT', 1)
|
||||||
|
statecount(cast(100 as smallint), 'GT', 1) |
|
||||||
|
=============================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(100000 as int), 'GT', 1)
|
||||||
|
statecount(cast(100000 as int), 'GT', 1) |
|
||||||
|
===========================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(10000000000 as bigint), 'GT', 1)
|
||||||
|
statecount(cast(10000000000 as bigint), 'GT', 1) |
|
||||||
|
===================================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(1 as tinyint unsigned), 'GT', 1)
|
||||||
|
statecount(cast(1 as tinyint unsigned), 'GT', 1) |
|
||||||
|
===================================================
|
||||||
|
-1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(100 as smallint unsigned), 'GT', 1)
|
||||||
|
statecount(cast(100 as smallint unsigned), 'GT', 1) |
|
||||||
|
======================================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(100000 as int unsigned), 'GT', 1)
|
||||||
|
statecount(cast(100000 as int unsigned), 'GT', 1) |
|
||||||
|
====================================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(10000000000 as bigint unsigned), 'GT', 1)
|
||||||
|
statecount(cast(10000000000 as bigint unsigned), 'GT', 1) |
|
||||||
|
============================================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(1.1 as float), 'GT', 1)
|
||||||
|
statecount(cast(1.1 as float), 'GT', 1) |
|
||||||
|
==========================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select statecount(cast(1.1 as double), 'GT', 1)
|
||||||
|
statecount(cast(1.1 as double), 'GT', 1) |
|
||||||
|
===========================================
|
||||||
|
1 |
|
||||||
|
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
|
||||||
|
taos> select sum(1)
|
||||||
|
sum(1) |
|
||||||
|
========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sum(cast(1 as tinyint))
|
||||||
|
sum(cast(1 as tinyint)) |
|
||||||
|
==========================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sum(cast(100 as smallint))
|
||||||
|
sum(cast(100 as smallint)) |
|
||||||
|
=============================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select sum(cast(100000 as int))
|
||||||
|
sum(cast(100000 as int)) |
|
||||||
|
===========================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select sum(cast(10000000000 as bigint))
|
||||||
|
sum(cast(10000000000 as bigint)) |
|
||||||
|
===================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select sum(cast(1 as tinyint unsigned))
|
||||||
|
sum(cast(1 as tinyint unsigned)) |
|
||||||
|
===================================
|
||||||
|
1 |
|
||||||
|
|
||||||
|
taos> select sum(cast(100 as smallint unsigned))
|
||||||
|
sum(cast(100 as smallint unsigned)) |
|
||||||
|
======================================
|
||||||
|
100 |
|
||||||
|
|
||||||
|
taos> select sum(cast(100000 as int unsigned))
|
||||||
|
sum(cast(100000 as int unsigned)) |
|
||||||
|
====================================
|
||||||
|
100000 |
|
||||||
|
|
||||||
|
taos> select sum(cast(10000000000 as bigint unsigned))
|
||||||
|
sum(cast(10000000000 as bigint unsigned)) |
|
||||||
|
============================================
|
||||||
|
10000000000 |
|
||||||
|
|
||||||
|
taos> select sum(cast(1.1 as float))
|
||||||
|
sum(cast(1.1 as float)) |
|
||||||
|
============================
|
||||||
|
1.100000023841858 |
|
||||||
|
|
||||||
|
taos> select sum(cast(1.1 as double))
|
||||||
|
sum(cast(1.1 as double)) |
|
||||||
|
============================
|
||||||
|
1.100000000000000 |
|
||||||
|
|
|
|
@ -179,6 +179,33 @@ taos> select trim(trailing '空格blank' from '空格blank空格中Tes空格blan
|
||||||
===================================================================
|
===================================================================
|
||||||
空格blank空格中Tes空格blank空 |
|
空格blank空格中Tes空格blank空 |
|
||||||
|
|
||||||
|
taos> select trim(both from nch1) from ts_4893.meters order by ts limit 5
|
||||||
|
trim(both from nch1) |
|
||||||
|
=================================
|
||||||
|
novel |
|
||||||
|
一二三四五六七八九十 |
|
||||||
|
update |
|
||||||
|
prision |
|
||||||
|
novel |
|
||||||
|
|
||||||
|
taos> select trim(leading from nch1) from ts_4893.meters order by ts limit 5
|
||||||
|
trim(leading from nch1) |
|
||||||
|
=================================
|
||||||
|
novel |
|
||||||
|
一二三四五六七八九十 |
|
||||||
|
update |
|
||||||
|
prision |
|
||||||
|
novel |
|
||||||
|
|
||||||
|
taos> select trim(trailing from nch1) from ts_4893.meters order by ts limit 5
|
||||||
|
trim(trailing from nch1) |
|
||||||
|
=================================
|
||||||
|
novel |
|
||||||
|
一二三四五六七八九十 |
|
||||||
|
update |
|
||||||
|
prision |
|
||||||
|
novel |
|
||||||
|
|
||||||
taos> select trim(nch2 from nch1) from ts_4893.meters where position(nch2 in nch1) != 0 order by ts limit 5
|
taos> select trim(nch2 from nch1) from ts_4893.meters where position(nch2 in nch1) != 0 order by ts limit 5
|
||||||
trim(nch2 from nch1) |
|
trim(nch2 from nch1) |
|
||||||
=================================
|
=================================
|
||||||
|
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
select avg(1)
|
||||||
|
select avg(cast(1 as tinyint))
|
||||||
|
select avg(cast(100 as smallint))
|
||||||
|
select avg(cast(100000 as int))
|
||||||
|
select avg(cast(10000000000 as bigint))
|
||||||
|
select avg(cast(1 as tinyint unsigned))
|
||||||
|
select avg(cast(100 as smallint unsigned))
|
||||||
|
select avg(cast(100000 as int unsigned))
|
||||||
|
select avg(cast(10000000000 as bigint unsigned))
|
||||||
|
select avg(cast(1.1 as float))
|
||||||
|
select avg(cast(1.1 as double))
|
|
@ -0,0 +1,11 @@
|
||||||
|
select leastsquares(1, 1, 1)
|
||||||
|
select leastsquares(cast(1.1 as float), 1, 1)
|
||||||
|
select leastsquares(cast(1.1 as double), 1, 1)
|
||||||
|
select leastsquares(cast(1 as tinyint), 1, 1)
|
||||||
|
select leastsquares(cast(100 as smallint), 1, 1)
|
||||||
|
select leastsquares(cast(100000 as int), 1, 1)
|
||||||
|
select leastsquares(cast(10000000000 as bigint), 1, 1)
|
||||||
|
select leastsquares(cast(1 as tinyint unsigned), 1, 1)
|
||||||
|
select leastsquares(cast(100 as smallint unsigned), 1, 1)
|
||||||
|
select leastsquares(cast(100000 as int unsigned), 1, 1)
|
||||||
|
select leastsquares(cast(10000000000 as bigint unsigned), 1, 1)
|
|
@ -26,3 +26,14 @@ select log(max(voltage) + 1) from ts_4893.meters
|
||||||
select groupid, max(voltage) from ts_4893.meters group by groupid order by groupid
|
select groupid, max(voltage) from ts_4893.meters group by groupid order by groupid
|
||||||
select location, max(id) from ts_4893.meters group by location order by location
|
select location, max(id) from ts_4893.meters group by location order by location
|
||||||
select location, max(current) from ts_4893.meters group by location order by location
|
select location, max(current) from ts_4893.meters group by location order by location
|
||||||
|
select max(1)
|
||||||
|
select max(cast(1 as tinyint))
|
||||||
|
select max(cast(100 as smallint))
|
||||||
|
select max(cast(100000 as int))
|
||||||
|
select max(cast(10000000000 as bigint))
|
||||||
|
select max(cast(1 as tinyint unsigned))
|
||||||
|
select max(cast(100 as smallint unsigned))
|
||||||
|
select max(cast(100000 as int unsigned))
|
||||||
|
select max(cast(10000000000 as bigint unsigned))
|
||||||
|
select max(cast(1.1 as float))
|
||||||
|
select max(cast(1.1 as double))
|
||||||
|
|
|
@ -26,3 +26,14 @@ select log(min(voltage) + 1) from ts_4893.meters
|
||||||
select groupid, min(voltage) from ts_4893.meters group by groupid order by groupid
|
select groupid, min(voltage) from ts_4893.meters group by groupid order by groupid
|
||||||
select location, min(current) from ts_4893.meters group by location order by location
|
select location, min(current) from ts_4893.meters group by location order by location
|
||||||
select location, min(id) from ts_4893.meters group by location order by location
|
select location, min(id) from ts_4893.meters group by location order by location
|
||||||
|
select min(1)
|
||||||
|
select min(cast(1 as tinyint))
|
||||||
|
select min(cast(100 as smallint))
|
||||||
|
select min(cast(100000 as int))
|
||||||
|
select min(cast(10000000000 as bigint))
|
||||||
|
select min(cast(1 as tinyint unsigned))
|
||||||
|
select min(cast(100 as smallint unsigned))
|
||||||
|
select min(cast(100000 as int unsigned))
|
||||||
|
select min(cast(10000000000 as bigint unsigned))
|
||||||
|
select min(cast(1.1 as float))
|
||||||
|
select min(cast(1.1 as double))
|
||||||
|
|
|
@ -47,3 +47,13 @@ select round(abs(voltage), 2) from ts_4893.meters limit 1
|
||||||
select round(pi() * phase, 3) from ts_4893.meters limit 1
|
select round(pi() * phase, 3) from ts_4893.meters limit 1
|
||||||
select round(sqrt(voltage), 2) from ts_4893.meters limit 1
|
select round(sqrt(voltage), 2) from ts_4893.meters limit 1
|
||||||
select round(log(current), 2) from ts_4893.meters limit 1
|
select round(log(current), 2) from ts_4893.meters limit 1
|
||||||
|
select round(cast(1.0e+400 as float), 0);
|
||||||
|
select round(cast(1.0e+400 as double), 0);
|
||||||
|
select round(cast(5 as tinyint), 1);
|
||||||
|
select round(cast(50 as smallint), 1);
|
||||||
|
select round(cast(500 as int), 1);
|
||||||
|
select round(cast(50000 as bigint), 1);
|
||||||
|
select round(cast(5 as TINYINT UNSIGNED), 1);
|
||||||
|
select round(cast(50 as smallint unsigned), 1);
|
||||||
|
select round(cast(500 as int unsigned), 1);
|
||||||
|
select round(cast(50000 as bigint unsigned), 1);
|