Merge pull request #29311 from taosdata/merge/3.0tomain
merge: from 3.0 to main branch
|
@ -2,7 +2,7 @@
|
|||
# taosadapter
|
||||
ExternalProject_Add(taosadapter
|
||||
GIT_REPOSITORY https://github.com/taosdata/taosadapter.git
|
||||
GIT_TAG main
|
||||
GIT_TAG 3.0
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosadapter"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG main
|
||||
GIT_TAG 3.0
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taos-tools"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taosws-rs
|
||||
ExternalProject_Add(taosws-rs
|
||||
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"
|
||||
BINARY_DIR ""
|
||||
#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 的数据同步任务,回到**数据源列表**页面可查看任务执行情况。
|
|
@ -196,12 +196,16 @@ json 数据支持 JSONObject 或者 JSONArray,使用 json 解析器可以解
|
|||
|
||||
### 8. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||

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

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

|
||||

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

|
||||

|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
<AdvancedOptions/>
|
||||
|
||||
### 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 的数据同步任务,回到数据写入任务列表页面,可查看任务执行情况,也可以进行任务的“启动/停止”操作与“查看/编辑/删除/复制”操作。
|
||||
|
||||

|
||||
|
||||
### 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. 配置高级选项
|
||||
|
||||
**高级选项** 区域是默认折叠的,点击右侧 `>` 可以展开,如下图所示:
|
||||
import AdvancedOptions from './_02-advanced_options.mdx'
|
||||
|
||||
**最大读取并发数** 数据源连接数或读取线程数限制,当默认参数不满足需要或需要调整资源使用量时修改此参数。
|
||||
<AdvancedOptions/>
|
||||
|
||||
**批次大小** 单次发送的最大消息数或行数。默认是 10000。
|
||||
### 9. 异常处理策略
|
||||
|
||||

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

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

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

|
||||
import Contributing from './_03-exception-handling-strategy.mdx'
|
||||
|
||||
### 9. 创建完成
|
||||
<Contributing />
|
||||
|
||||
### 10. 创建完成
|
||||
|
||||
点击 **提交** 按钮,完成创建 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 时,与监控相关的配置才生效。
|
||||
|
||||
## 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 tsResolveFQDNRetryTime;
|
||||
extern bool tsStreamCoverage;
|
||||
extern int8_t tsS3EpNum;
|
||||
|
||||
extern bool tsExperimental;
|
||||
// #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);
|
||||
} else {
|
||||
int32_t dataLen = varDataTLen(pData);
|
||||
if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||
dataLen = 0;
|
||||
} else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
dataLen = varDataTLen(pData + sizeof(char));
|
||||
} else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
dataLen = sizeof(int64_t);
|
||||
} else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
dataLen = sizeof(char);
|
||||
}
|
||||
dataLen += sizeof(char);
|
||||
}
|
||||
// This is a piece of code to help users implement udf. It is only called during testing.
|
||||
// Currently, the json type is not supported and will not be called.
|
||||
// if (meta->type == TSDB_DATA_TYPE_JSON) {
|
||||
// if (*pData == TSDB_DATA_TYPE_NULL) {
|
||||
// dataLen = 0;
|
||||
// } else if (*pData == TSDB_DATA_TYPE_NCHAR) {
|
||||
// dataLen = varDataTLen(pData + sizeof(char));
|
||||
// } else if (*pData == TSDB_DATA_TYPE_BIGINT || *pData == TSDB_DATA_TYPE_DOUBLE) {
|
||||
// dataLen = sizeof(int64_t);
|
||||
// } else if (*pData == TSDB_DATA_TYPE_BOOL) {
|
||||
// dataLen = sizeof(char);
|
||||
// }
|
||||
// dataLen += sizeof(char);
|
||||
// }
|
||||
|
||||
if (data->varLenCol.payloadAllocLen < data->varLenCol.payloadLen + dataLen) {
|
||||
uint32_t newSize = data->varLenCol.payloadAllocLen;
|
||||
|
|
|
@ -276,6 +276,7 @@ TEST(testCase, smlParseCols_Test) {
|
|||
info->dataFormat = false;
|
||||
SSmlLineInfo elements = {0};
|
||||
info->msgBuf = msgBuf;
|
||||
ASSERT_EQ(smlInitHandle(NULL), TSDB_CODE_INVALID_PARA);
|
||||
|
||||
const char *data =
|
||||
"st,t=1 cb\\=in=\"pass\\,it "
|
||||
|
|
|
@ -11141,6 +11141,7 @@ void tOffsetCopy(STqOffsetVal *pLeft, const STqOffsetVal *pRight) {
|
|||
}
|
||||
|
||||
void tOffsetDestroy(void *param) {
|
||||
if (param == NULL) return;
|
||||
STqOffsetVal *pVal = (STqOffsetVal *)param;
|
||||
if (IS_VAR_DATA_TYPE(pVal->primaryKey.type)) {
|
||||
taosMemoryFreeClear(pVal->primaryKey.pData);
|
||||
|
@ -11148,6 +11149,7 @@ void tOffsetDestroy(void *param) {
|
|||
}
|
||||
|
||||
void tDeleteSTqOffset(void *param) {
|
||||
if (param == NULL) return;
|
||||
STqOffset *pVal = (STqOffset *)param;
|
||||
tOffsetDestroy(&pVal->val);
|
||||
}
|
||||
|
|
|
@ -348,6 +348,7 @@ static void *mndBuildKillCompactReq(SMnode *pMnode, SVgObj *pVgroup, int32_t *pC
|
|||
req.compactId = compactId;
|
||||
req.vgId = pVgroup->vgId;
|
||||
req.dnodeId = dnodeid;
|
||||
terrno = 0;
|
||||
|
||||
mInfo("vgId:%d, build compact vnode config req", pVgroup->vgId);
|
||||
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->vgId = htonl(pVgroup->vgId);
|
||||
|
||||
if ((contLen = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||
terrno = contLen;
|
||||
mTrace("vgId:%d, build compact vnode config req, contLen:%d", pVgroup->vgId, contLen);
|
||||
int32_t ret = 0;
|
||||
if ((ret = tSerializeSVKillCompactReq((char *)pReq + sizeof(SMsgHead), contLen, &req)) < 0) {
|
||||
terrno = ret;
|
||||
return NULL;
|
||||
}
|
||||
*pContLen = contLen;
|
||||
|
@ -401,6 +404,8 @@ static int32_t mndAddKillCompactAction(SMnode *pMnode, STrans *pTrans, SVgObj *p
|
|||
action.contLen = contLen;
|
||||
action.msgType = TDMT_VND_KILL_COMPACT;
|
||||
|
||||
mTrace("trans:%d, kill compact msg len:%d", pTrans->id, contLen);
|
||||
|
||||
if ((code = mndTransAppendRedoAction(pTrans, &action)) != 0) {
|
||||
taosMemoryFree(pReq);
|
||||
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 metaCreateTable2(SMeta* pMeta, int64_t version, SVCreateTbReq* pReq, STableMetaRsp** ppRsp);
|
||||
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);
|
||||
int metaTtlFindExpired(SMeta* pMeta, int64_t timePointMs, SArray* tbUids, int32_t ttlDropMaxCount);
|
||||
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);
|
||||
return code;
|
||||
}
|
||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
||||
TAOS_CHECK_RETURN(tsdbCacheNewSTableColumn(pTsdb, uids, cid, col_type));
|
||||
} else if (deltaCol == -1) {
|
||||
int16_t cid = -1;
|
||||
|
@ -1667,7 +1666,6 @@ static int32_t metaHandleSuperTableUpdate(SMeta *pMeta, const SMetaEntry *pEntry
|
|||
metaFetchEntryFree(&pOldEntry);
|
||||
return code;
|
||||
}
|
||||
// TAOS_CHECK_RETURN(metaGetSubtables(pMeta, pEntry->uid, uids));
|
||||
TAOS_CHECK_RETURN(tsdbCacheDropSTableColumn(pTsdb, uids, cid, hasPrimaryKey));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,11 +151,8 @@ void tqClose(STQ* pTq) {
|
|||
taosHashCleanup(pTq->pOffset);
|
||||
taosMemoryFree(pTq->path);
|
||||
tqMetaClose(pTq);
|
||||
|
||||
int32_t vgId = pTq->pStreamMeta->vgId;
|
||||
qDebug("vgId:%d end to close tq", pTq->pStreamMeta != NULL ? pTq->pStreamMeta->vgId : -1);
|
||||
streamMetaClose(pTq->pStreamMeta);
|
||||
|
||||
qDebug("vgId:%d end to close tq", vgId);
|
||||
taosMemoryFree(pTq);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,36 +17,41 @@
|
|||
#include "tq.h"
|
||||
|
||||
int32_t tqBuildFName(char** data, const char* path, char* name) {
|
||||
if (data == NULL || path == NULL || name == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
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;
|
||||
char* fname = taosMemoryCalloc(1, len);
|
||||
if(fname == NULL) {
|
||||
return terrno;
|
||||
}
|
||||
int32_t code = tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
if (code < 0){
|
||||
code = TAOS_SYSTEM_ERROR(errno);
|
||||
taosMemoryFree(fname);
|
||||
return code;
|
||||
}
|
||||
fname = taosMemoryCalloc(1, len);
|
||||
TSDB_CHECK_NULL(fname, code, lino, END, terrno);
|
||||
(void)tsnprintf(fname, len, "%s%s%s", path, TD_DIRSEP, name);
|
||||
|
||||
*data = fname;
|
||||
return TDB_CODE_SUCCESS;
|
||||
fname = NULL;
|
||||
|
||||
END:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(fname);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
||||
if (pTq == NULL || name == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = TDB_CODE_SUCCESS;
|
||||
void* pMemBuf = NULL;
|
||||
int32_t code = TDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
void* pMemBuf = NULL;
|
||||
TdFilePtr pFile = NULL;
|
||||
STqOffset *pOffset = NULL;
|
||||
void *pIter = NULL;
|
||||
|
||||
TdFilePtr pFile = taosOpenFile(name, TD_FILE_READ);
|
||||
if (pFile == NULL) {
|
||||
code = TDB_CODE_SUCCESS;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_NULL(pTq, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(name, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
pFile = taosOpenFile(name, TD_FILE_READ);
|
||||
TSDB_CHECK_NULL(pFile, code, lino, END, TDB_CODE_SUCCESS);
|
||||
|
||||
int64_t ret = 0;
|
||||
int32_t size = 0;
|
||||
|
@ -60,48 +65,41 @@ int32_t tqOffsetRestoreFromFile(STQ* pTq, char* name) {
|
|||
}
|
||||
total += INT_BYTES;
|
||||
size = htonl(size);
|
||||
if (size <= 0) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto END;
|
||||
}
|
||||
pMemBuf = taosMemoryCalloc(1, size);
|
||||
if (pMemBuf == NULL) {
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(size > 0, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
if (taosReadFile(pFile, pMemBuf, size) != size) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto END;
|
||||
}
|
||||
pMemBuf = taosMemoryCalloc(1, size);
|
||||
TSDB_CHECK_NULL(pMemBuf, code, lino, END, terrno);
|
||||
TSDB_CHECK_CONDITION(taosReadFile(pFile, pMemBuf, size) == size, code, lino, END, TSDB_CODE_INVALID_MSG);
|
||||
|
||||
total += size;
|
||||
STqOffset offset = {0};
|
||||
TQ_ERR_GO_TO_END(tqMetaDecodeOffsetInfo(&offset, pMemBuf, size));
|
||||
code = taosHashPut(pTq->pOffset, offset.subKey, strlen(offset.subKey), &offset, sizeof(STqOffset));
|
||||
if (code != TDB_CODE_SUCCESS) {
|
||||
tDeleteSTqOffset(&offset);
|
||||
goto END;
|
||||
}
|
||||
code = tqMetaDecodeOffsetInfo(&offset, pMemBuf, size);
|
||||
TSDB_CHECK_CODE(code, lino, END);
|
||||
pOffset = &offset;
|
||||
code = taosHashPut(pTq->pOffset, pOffset->subKey, strlen(pOffset->subKey), pOffset, sizeof(STqOffset));
|
||||
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);
|
||||
taosMemoryFree(pMemBuf);
|
||||
pMemBuf = NULL;
|
||||
}
|
||||
|
||||
void *pIter = NULL;
|
||||
while ((pIter = taosHashIterate(pTq->pOffset, pIter))) {
|
||||
STqOffset* pOffset = (STqOffset*)pIter;
|
||||
code = tqMetaSaveOffset(pTq, pOffset);
|
||||
if(code != 0){
|
||||
taosHashCancelIterate(pTq->pOffset, pIter);
|
||||
goto END;
|
||||
}
|
||||
STqOffset* offset = (STqOffset*)pIter;
|
||||
code = tqMetaSaveOffset(pTq, offset);
|
||||
TSDB_CHECK_CODE(code, lino, END);
|
||||
}
|
||||
|
||||
END:
|
||||
taosCloseFile(&pFile);
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
(void)taosCloseFile(&pFile);
|
||||
taosMemoryFree(pMemBuf);
|
||||
|
||||
tDeleteSTqOffset(pOffset);
|
||||
taosHashCancelIterate(pTq->pOffset, pIter);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -27,18 +27,16 @@ struct STqSnapReader {
|
|||
};
|
||||
|
||||
int32_t tqSnapReaderOpen(STQ* pTq, int64_t sver, int64_t ever, int8_t type, STqSnapReader** ppReader) {
|
||||
if (pTq == NULL || ppReader == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
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
|
||||
pReader = (STqSnapReader*)taosMemoryCalloc(1, sizeof(STqSnapReader));
|
||||
if (pReader == NULL) {
|
||||
code = terrno;
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(pReader, code, lino, end, terrno);
|
||||
|
||||
pReader->pTq = pTq;
|
||||
pReader->sver = sver;
|
||||
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;
|
||||
} else {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
goto _err;
|
||||
goto end;
|
||||
}
|
||||
code = tdbTbcOpen(pTb, &pReader->pCur, NULL);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
code = tdbTbcMoveToFirst(pReader->pCur);
|
||||
if (code) {
|
||||
taosMemoryFree(pReader);
|
||||
goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq snapshot reader opene success", TD_VID(pTq->pVnode));
|
||||
*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;
|
||||
}
|
||||
|
||||
|
@ -84,45 +75,37 @@ void tqSnapReaderClose(STqSnapReader** ppReader) {
|
|||
return;
|
||||
}
|
||||
tdbTbcClose((*ppReader)->pCur);
|
||||
taosMemoryFree(*ppReader);
|
||||
*ppReader = NULL;
|
||||
taosMemoryFreeClear(*ppReader);
|
||||
}
|
||||
|
||||
int32_t tqSnapRead(STqSnapReader* pReader, uint8_t** ppData) {
|
||||
if (pReader == NULL || ppData == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int32_t kLen = 0;
|
||||
int32_t vLen = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
void* pKey = NULL;
|
||||
void* pVal = NULL;
|
||||
int32_t kLen = 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)) {
|
||||
goto _exit;
|
||||
}
|
||||
code = tdbTbcNext(pReader->pCur, &pKey, &kLen, &pVal, &vLen);
|
||||
TSDB_CHECK_CONDITION(code == 0, code, lino, end, TDB_CODE_SUCCESS);
|
||||
|
||||
*ppData = taosMemoryMalloc(sizeof(SSnapDataHdr) + vLen);
|
||||
if (*ppData == NULL) {
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(*ppData, code, lino, end, terrno);
|
||||
|
||||
SSnapDataHdr* pHdr = (SSnapDataHdr*)(*ppData);
|
||||
pHdr->type = pReader->type;
|
||||
pHdr->size = 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(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;
|
||||
}
|
||||
|
||||
|
@ -135,135 +118,148 @@ struct STqSnapWriter {
|
|||
};
|
||||
|
||||
int32_t tqSnapWriterOpen(STQ* pTq, int64_t sver, int64_t ever, STqSnapWriter** ppWriter) {
|
||||
if (pTq == NULL || ppWriter == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
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
|
||||
pWriter = (STqSnapWriter*)taosMemoryCalloc(1, sizeof(*pWriter));
|
||||
if (pWriter == NULL) {
|
||||
code = TAOS_GET_TERRNO(TSDB_CODE_OUT_OF_MEMORY);
|
||||
;
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_NULL(pWriter, code, lino, end, terrno);
|
||||
pWriter->pTq = pTq;
|
||||
pWriter->sver = sver;
|
||||
pWriter->ever = ever;
|
||||
|
||||
code = tdbBegin(pTq->pMetaDB, &pWriter->txn, tdbDefaultMalloc, tdbDefaultFree, NULL, 0);
|
||||
if (code < 0) {
|
||||
taosMemoryFree(pWriter);
|
||||
goto _err;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, tq snapshot writer opene success", TD_VID(pTq->pVnode));
|
||||
*ppWriter = pWriter;
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, tq snapshot writer open failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
*ppWriter = NULL;
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d tq snapshot writer open failed since %s", __func__, lino, tstrerror(code));
|
||||
taosMemoryFreeClear(pWriter);
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapWriterClose(STqSnapWriter** ppWriter, int8_t rollback) {
|
||||
if (ppWriter == NULL || *ppWriter == NULL) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
STqSnapWriter* pWriter = *ppWriter;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
STqSnapWriter* pWriter = NULL;
|
||||
|
||||
TSDB_CHECK_NULL(ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
TSDB_CHECK_NULL(*ppWriter, code, lino, end, TSDB_CODE_INVALID_MSG);
|
||||
pWriter = *ppWriter;
|
||||
|
||||
if (rollback) {
|
||||
tdbAbort(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
} else {
|
||||
code = tdbCommit(pWriter->pTq->pMetaDB, pWriter->txn);
|
||||
if (code) goto _err;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
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);
|
||||
*ppWriter = NULL;
|
||||
|
||||
return code;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, tq snapshot writer close failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, tq snapshot writer close failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
static int32_t tqWriteCheck(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData){
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
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;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
return code;
|
||||
}
|
||||
int32_t tqSnapHandleWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SDecoder decoder = {0};
|
||||
SDecoder* pDecoder = &decoder;
|
||||
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));
|
||||
code = tDecodeSTqHandle(pDecoder, &handle);
|
||||
if (code) goto end;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
taosWLockLatch(&pTq->lock);
|
||||
code = tqMetaSaveInfo(pTq, pTq->pExecStore, handle.subKey, strlen(handle.subKey), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
taosWUnLockLatch(&pTq->lock);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
tqInfo("vgId:%d, vnode tq snapshot write success", TD_VID(pTq->pVnode));
|
||||
|
||||
end:
|
||||
tDecoderClear(pDecoder);
|
||||
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;
|
||||
}
|
||||
|
||||
int32_t tqSnapCheckInfoWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
||||
code = tqWriteCheck(pWriter, pData, nData);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
STQ* pTq = pWriter->pTq;
|
||||
STqCheckInfo info = {0};
|
||||
code = tqMetaDecodeCheckInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
if (code != 0) {
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
code = tqMetaSaveInfo(pTq, pTq->pCheckStore, &info.topic, strlen(info.topic), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
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;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq check info write failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t tqSnapOffsetWrite(STqSnapWriter* pWriter, uint8_t* pData, uint32_t nData) {
|
||||
if (pWriter == NULL || pData == NULL || nData < sizeof(SSnapDataHdr)) {
|
||||
return TSDB_CODE_INVALID_MSG;
|
||||
}
|
||||
int32_t code = 0;
|
||||
STQ* pTq = pWriter->pTq;
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
code = tqWriteCheck(pWriter, pData, nData);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
STQ* pTq = pWriter->pTq;
|
||||
STqOffset info = {0};
|
||||
code = tqMetaDecodeOffsetInfo(&info, pData + sizeof(SSnapDataHdr), nData - sizeof(SSnapDataHdr));
|
||||
if (code != 0) {
|
||||
goto _err;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
code = tqMetaSaveInfo(pTq, pTq->pOffsetStore, info.subKey, strlen(info.subKey), pData + sizeof(SSnapDataHdr),
|
||||
nData - sizeof(SSnapDataHdr));
|
||||
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;
|
||||
|
||||
_err:
|
||||
tqError("vgId:%d, vnode check info tq write failed since %s", TD_VID(pTq->pVnode), tstrerror(code));
|
||||
end:
|
||||
if (code != 0){
|
||||
tqError("%s failed at %d, vnode tq offset write failed since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -5791,7 +5791,6 @@ int32_t tsdbReaderSuspend2(STsdbReader* pReader) {
|
|||
|
||||
// make sure only release once
|
||||
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)) {
|
||||
tsdbUntakeReadSnap2(pReader, p, false);
|
||||
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
|
||||
", conn.applyTerm:%" PRId64,
|
||||
", conn.applyTerm:%" PRId64 ", contLen:%d",
|
||||
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)) {
|
||||
return terrno = TSDB_CODE_INTERNAL_ERROR;
|
||||
|
@ -843,7 +843,7 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) {
|
|||
SReadHandle handle = {.vnode = pVnode, .pMsgCb = &pVnode->msgCb, .pWorkerCb = pInfo->workerCb};
|
||||
initStorageAPI(&handle.api);
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
bool redirected = false;
|
||||
bool redirected = false;
|
||||
|
||||
switch (pMsg->msgType) {
|
||||
case TDMT_SCH_QUERY:
|
||||
|
@ -2145,7 +2145,7 @@ static int32_t vnodeConsolidateAlterHashRange(SVnode *pVnode, int64_t ver) {
|
|||
pVnode->config.hashBegin, pVnode->config.hashEnd, ver);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
|
|
@ -1,29 +1,27 @@
|
|||
MESSAGE(STATUS "vnode unit test")
|
||||
MESSAGE(STATUS "tq unit test")
|
||||
|
||||
# GoogleTest requires at least C++11
|
||||
SET(CMAKE_CXX_STANDARD 11)
|
||||
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCE_LIST)
|
||||
|
||||
# add_executable(tqTest "")
|
||||
# target_sources(tqTest
|
||||
# PRIVATE
|
||||
# "tqMetaTest.cpp"
|
||||
# )
|
||||
# target_include_directories(tqTest
|
||||
# PUBLIC
|
||||
# "${TD_SOURCE_DIR}/include/server/vnode/tq"
|
||||
# "${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
# )
|
||||
IF(NOT TD_WINDOWS)
|
||||
add_executable(tqTest tqTest.cpp)
|
||||
target_include_directories(tqTest
|
||||
PUBLIC
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||
)
|
||||
|
||||
# target_link_libraries(tqTest
|
||||
# tq
|
||||
# gtest_main
|
||||
# )
|
||||
# enable_testing()
|
||||
# add_test(
|
||||
# NAME tq_test
|
||||
# COMMAND tqTest
|
||||
# )
|
||||
TARGET_LINK_LIBRARIES(
|
||||
tqTest
|
||||
PUBLIC os util common vnode gtest_main
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
add_test(
|
||||
NAME tq_test
|
||||
COMMAND tqTest
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
# ADD_EXECUTABLE(tsdbSmaTest tsdbSmaTest.cpp)
|
||||
# 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
|
||||
)
|
||||
|
||||
#if(${BUILD_TEST})
|
||||
# ADD_SUBDIRECTORY(test)
|
||||
#endif(${BUILD_TEST})
|
||||
if(${BUILD_TEST} AND NOT ${TD_WINDOWS})
|
||||
ADD_SUBDIRECTORY(test)
|
||||
endif()
|
||||
|
|
|
@ -424,6 +424,7 @@ int32_t ctgGetTbCfg(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName,
|
|||
CTG_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t ctgGetTbTag(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pRes) {
|
||||
SVgroupInfo vgroupInfo = {0};
|
||||
STableCfg* pCfg = NULL;
|
||||
|
@ -474,6 +475,7 @@ _return:
|
|||
|
||||
CTG_RET(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t ctgGetTbDistVgInfo(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** pVgList) {
|
||||
STableMeta* tbMeta = NULL;
|
||||
|
@ -1695,6 +1697,7 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t catalogGetTableTag(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1709,6 +1712,7 @@ _return:
|
|||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t catalogRefreshGetTableCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableCfg** pCfg) {
|
||||
CTG_API_ENTER();
|
||||
|
@ -1845,7 +1849,7 @@ _return:
|
|||
CTG_API_LEAVE(code);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
int32_t catalogAsyncUpdateViewMeta(SCatalog* pCtg, SViewMetaRsp* pMsg) {
|
||||
CTG_API_ENTER();
|
||||
|
||||
|
@ -1860,6 +1864,7 @@ _return:
|
|||
|
||||
CTG_API_LEAVE(code);
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pViewName, STableMeta** pTableMeta) {
|
||||
CTG_API_ENTER();
|
||||
|
|
|
@ -2992,6 +2992,7 @@ TEST(apiTest, catalogGetTableIndex_test) {
|
|||
catalogDestroy();
|
||||
}
|
||||
|
||||
|
||||
TEST(apiTest, catalogGetDBCfg_test) {
|
||||
struct SCatalog *pCtg = NULL;
|
||||
SRequestConnInfo connInfo = {0};
|
||||
|
|
|
@ -83,6 +83,8 @@ int32_t hInnerJoinDo(struct SOperatorInfo* pOperator) {
|
|||
return code;
|
||||
}
|
||||
|
||||
#ifdef HASH_JOIN_FULL
|
||||
|
||||
int32_t hLeftJoinHandleSeqRowRemains(struct SOperatorInfo* pOperator, SHJoinOperatorInfo* pJoin, bool* loopCont) {
|
||||
bool allFetched = false;
|
||||
SHJoinCtx* pCtx = &pJoin->ctx;
|
||||
|
@ -346,4 +348,5 @@ int32_t hLeftJoinDo(struct SOperatorInfo* pOperator) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ int32_t hJoinSetImplFp(SHJoinOperatorInfo* pJoin) {
|
|||
case JOIN_TYPE_RIGHT: {
|
||||
switch (pJoin->subType) {
|
||||
case JOIN_STYPE_OUTER:
|
||||
pJoin->joinFp = hLeftJoinDo;
|
||||
//pJoin->joinFp = hLeftJoinDo; TOOPEN
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -44,3 +44,15 @@ TARGET_INCLUDE_DIRECTORIES(
|
|||
PUBLIC "${TD_SOURCE_DIR}/include/common"
|
||||
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 "stub.h"
|
||||
#include "querytask.h"
|
||||
#include "hashjoin.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
@ -3766,6 +3767,21 @@ TEST(leftWinJoin, noCondProjectionTest) {
|
|||
|
||||
#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) {
|
||||
|
|
|
@ -142,6 +142,50 @@ target_link_libraries(
|
|||
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)
|
||||
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);
|
||||
}
|
||||
|
||||
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[]) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
|
|
@ -20,40 +20,32 @@
|
|||
|
||||
int32_t qCreateSName(SName* pName, const char* pTableName, int32_t acctId, char* dbName, char* msgBuf,
|
||||
int32_t msgBufLen) {
|
||||
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||
SToken sToken;
|
||||
int32_t code = 0;
|
||||
char* tbName = NULL;
|
||||
SMsgBuf msg = {.buf = msgBuf, .len = msgBufLen};
|
||||
SToken sToken = {0};
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
||||
NEXT_TOKEN(pTableName, sToken);
|
||||
|
||||
if (sToken.n == 0) {
|
||||
return buildInvalidOperationMsg(&msg, "empty table name");
|
||||
}
|
||||
|
||||
TSDB_CHECK_CONDITION(sToken.n != 0, code, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
code = insCreateSName(pName, &sToken, acctId, dbName, &msg);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
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, "table name format is wrong");
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
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));
|
||||
if (NULL == pUseCols) {
|
||||
return terrno;
|
||||
}
|
||||
|
||||
TSDB_CHECK_NULL(pUseCols, code, lino, end, terrno);
|
||||
pBoundInfo->numOfBound = 0;
|
||||
int16_t lastColIdx = -1; // last column found
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
||||
for (int i = 0; i < taosArrayGetSize(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);
|
||||
}
|
||||
|
||||
if (index < 0) {
|
||||
uError("smlBoundColumnData. index:%d", index);
|
||||
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;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(index >= 0, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
TSDB_CHECK_CONDITION(!pUseCols[index], code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
|
||||
lastColIdx = index;
|
||||
pUseCols[index] = true;
|
||||
pBoundInfo->pColIndex[pBoundInfo->numOfBound] = index;
|
||||
|
@ -82,11 +67,30 @@ static int32_t smlBoundColumnData(SArray* cols, SBoundColInfo* pBoundInfo, SSche
|
|||
}
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
taosMemoryFree(pUseCols);
|
||||
|
||||
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
|
||||
*
|
||||
|
@ -99,75 +103,39 @@ end:
|
|||
*/
|
||||
static int32_t smlBuildTagRow(SArray* cols, SBoundColInfo* tags, SSchema* pSchema, STag** ppTag, SArray** tagName,
|
||||
SMsgBuf* msg, void* charsetCxt) {
|
||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||
if (!pTagArray) {
|
||||
return terrno;
|
||||
}
|
||||
int code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SArray* pTagArray = taosArrayInit(tags->numOfBound, sizeof(STagVal));
|
||||
TSDB_CHECK_NULL(pTagArray, code, lino, end, terrno);
|
||||
*tagName = taosArrayInit(8, TSDB_COL_NAME_LEN);
|
||||
if (!*tagName) {
|
||||
return terrno;
|
||||
}
|
||||
TSDB_CHECK_NULL(*tagName, code, lino, end, terrno);
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
for (int i = 0; i < tags->numOfBound; ++i) {
|
||||
SSchema* pTagSchema = &pSchema[tags->pColIndex[i]];
|
||||
SSmlKv* kv = taosArrayGet(cols, i);
|
||||
if (kv == NULL){
|
||||
code = terrno;
|
||||
uError("SML smlBuildTagRow error kv is null");
|
||||
goto end;
|
||||
}
|
||||
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;
|
||||
}
|
||||
TSDB_CHECK_NULL(kv, code, lino, end, terrno);
|
||||
bool cond = (kv->keyLen == strlen(pTagSchema->name) && memcmp(kv->key, pTagSchema->name, kv->keyLen) == 0 && kv->type == pTagSchema->type);
|
||||
TSDB_CHECK_CONDITION(cond, code, lino, end, TSDB_CODE_SML_INVALID_DATA);
|
||||
TSDB_CHECK_NULL(taosArrayPush(*tagName, pTagSchema->name), code, lino, end, terrno);
|
||||
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 ||
|
||||
pTagSchema->type == TSDB_DATA_TYPE_GEOMETRY) {
|
||||
val.pData = (uint8_t*)kv->value;
|
||||
val.nData = kv->length;
|
||||
} else if (pTagSchema->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t output = 0;
|
||||
void* p = taosMemoryCalloc(1, kv->length * TSDB_NCHAR_SIZE);
|
||||
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;
|
||||
code = smlMbsToUcs4(kv->value, kv->length, (void**)&val.pData, (int32_t*)&val.nData, kv->length * TSDB_NCHAR_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
} else {
|
||||
(void)memcpy(&val.i64, &(kv->value), kv->length);
|
||||
}
|
||||
if (taosArrayPush(pTagArray, &val) == NULL){
|
||||
code = terrno;
|
||||
uError("SML smlBuildTagRow error push tag array");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(taosArrayPush(pTagArray, &val), code, lino, end, terrno);
|
||||
}
|
||||
|
||||
code = tTagNew(pTagArray, 1, false, ppTag);
|
||||
|
||||
end:
|
||||
if (code != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
for (int i = 0; i < taosArrayGetSize(pTagArray); ++i) {
|
||||
STagVal* p = (STagVal*)taosArrayGet(pTagArray, i);
|
||||
if (p->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
|
@ -179,18 +147,20 @@ end:
|
|||
}
|
||||
|
||||
int32_t smlInitTableDataCtx(SQuery* query, STableMeta* pTableMeta, STableDataCxt** cxt) {
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
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);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
ret = initTableColSubmitData(*cxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
return ret;
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
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) {
|
||||
|
@ -207,78 +177,51 @@ void clearColValArraySml(SArray* pCols) {
|
|||
}
|
||||
|
||||
int32_t smlBuildRow(STableDataCxt* pTableCxt) {
|
||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||
if (pRow == NULL){
|
||||
return terrno;
|
||||
}
|
||||
int ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
return ret;
|
||||
}
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SRow** pRow = taosArrayReserve(pTableCxt->pData->aRowP, 1);
|
||||
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
SRowKey key;
|
||||
tRowGetKey(*pRow, &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) {
|
||||
int ret = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
SSchema* pColSchema = schema + index;
|
||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, index);
|
||||
if (pVal == NULL) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal, ret, lino, end, TSDB_CODE_SUCCESS);
|
||||
SSmlKv* kv = (SSmlKv*)data;
|
||||
if (kv->keyLen != strlen(pColSchema->name) || memcmp(kv->key, pColSchema->name, kv->keyLen) != 0 ||
|
||||
kv->type != pColSchema->type) {
|
||||
ret = TSDB_CODE_SML_INVALID_DATA;
|
||||
char* tmp = taosMemoryCalloc(kv->keyLen + 1, 1);
|
||||
if (tmp) {
|
||||
(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,
|
||||
pColSchema->name, tDataTypes[pColSchema->type].name);
|
||||
taosMemoryFree(tmp);
|
||||
} else {
|
||||
uError("SML smlBuildCol out of memory");
|
||||
ret = terrno;
|
||||
}
|
||||
TSDB_CHECK_NULL(tmp, ret, lino, end, terrno);
|
||||
(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,
|
||||
pColSchema->name, tDataTypes[pColSchema->type].name);
|
||||
taosMemoryFree(tmp);
|
||||
goto end;
|
||||
}
|
||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = 0;
|
||||
int64_t size = pColSchema->bytes - VARSTR_HEADER_SIZE;
|
||||
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;
|
||||
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, &pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = (uint8_t*)kv->value;
|
||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||
if (!pVal->value.pData) {
|
||||
ret = terrno;
|
||||
uError("SML smlBuildCol malloc failed %s:%d, err: %s", __func__, __LINE__, tstrerror(ret));
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||
|
||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||
} else {
|
||||
(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;
|
||||
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
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,
|
||||
char* msgBuf, int32_t msgBufLen, void* charsetCxt) {
|
||||
int32_t lino = 0;
|
||||
int32_t ret = 0;
|
||||
SMsgBuf pBuf = {.buf = msgBuf, .len = msgBufLen};
|
||||
|
||||
SSchema* pTagsSchema = getTableTagSchema(pTableMeta);
|
||||
|
@ -299,50 +247,32 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
SVCreateTbReq* pCreateTblReq = NULL;
|
||||
SArray* tagName = NULL;
|
||||
|
||||
int ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "init bound cols error");
|
||||
goto end;
|
||||
}
|
||||
ret = insInitBoundColsInfo(getNumOfTags(pTableMeta), &bindTags);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
ret = smlBoundColumnData(tags, &bindTags, pTagsSchema, true);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound tags error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
STag* pTag = NULL;
|
||||
|
||||
ret = smlBuildTagRow(tags, &bindTags, pTagsSchema, &pTag, &tagName, &pBuf, charsetCxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
pCreateTblReq = taosMemoryCalloc(1, sizeof(SVCreateTbReq));
|
||||
if (NULL == pCreateTblReq) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pCreateTblReq, ret, lino, end, terrno);
|
||||
|
||||
ret = insBuildCreateTbReq(pCreateTblReq, tableName, pTag, pTableMeta->suid, NULL, tagName,
|
||||
pTableMeta->tableInfo.numOfTags, ttl);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
pCreateTblReq->ctb.stbName = taosMemoryCalloc(1, sTableNameLen + 1);
|
||||
if (pCreateTblReq->ctb.stbName == NULL){
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pCreateTblReq->ctb.stbName, ret, lino, end, terrno);
|
||||
|
||||
(void)memcpy(pCreateTblReq->ctb.stbName, sTableName, sTableNameLen);
|
||||
|
||||
if (dataFormat) {
|
||||
STableDataCxt** pTableCxt = (STableDataCxt**)taosHashGet(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj,
|
||||
&pTableMeta->uid, sizeof(pTableMeta->uid));
|
||||
if (NULL == pTableCxt) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "dataformat true. get tableDataCtx error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pTableCxt, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
(*pTableCxt)->pData->flags |= SUBMIT_REQ_AUTO_CREATE_TABLE;
|
||||
(*pTableCxt)->pData->pCreateTbReq = pCreateTblReq;
|
||||
(*pTableCxt)->pMeta->uid = pTableMeta->uid;
|
||||
|
@ -354,86 +284,47 @@ int32_t smlBindData(SQuery* query, bool dataFormat, SArray* tags, SArray* colsSc
|
|||
STableDataCxt* pTableCxt = NULL;
|
||||
ret = insGetTableDataCxt(((SVnodeModifyOpStmt*)(query->pRoot))->pTableBlockHashObj, &pTableMeta->uid,
|
||||
sizeof(pTableMeta->uid), pTableMeta, &pCreateTblReq, &pTableCxt, false, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "insGetTableDataCxt error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
SSchema* pSchema = getTableColumnSchema(pTableMeta);
|
||||
ret = smlBoundColumnData(colsSchema, &pTableCxt->boundColsInfo, pSchema, false);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "bound cols error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
ret = initTableColSubmitData(pTableCxt);
|
||||
if (ret != TSDB_CODE_SUCCESS) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "initTableColSubmitData error");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
|
||||
int32_t rowNum = taosArrayGetSize(cols);
|
||||
if (rowNum <= 0) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "cols size <= 0");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(rowNum > 0, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
for (int32_t r = 0; r < rowNum; ++r) {
|
||||
void* rowData = taosArrayGetP(cols, r);
|
||||
if (rowData == NULL) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(rowData, ret, lino, end, terrno);
|
||||
|
||||
// 1. set the parsed value from sql string
|
||||
for (int c = 0; c < pTableCxt->boundColsInfo.numOfBound; ++c) {
|
||||
SSchema* pColSchema = &pSchema[pTableCxt->boundColsInfo.pColIndex[c]];
|
||||
SColVal* pVal = taosArrayGet(pTableCxt->pValues, pTableCxt->boundColsInfo.pColIndex[c]);
|
||||
if (pVal == NULL) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal, ret, lino, end, terrno);
|
||||
void** p = taosHashGet(rowData, pColSchema->name, strlen(pColSchema->name));
|
||||
if (p == NULL) {
|
||||
continue;
|
||||
}
|
||||
SSmlKv* kv = *(SSmlKv**)p;
|
||||
if (kv->type != pColSchema->type) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "kv type not equal to col type");
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_CONDITION(kv->type == pColSchema->type, ret, lino, end, TSDB_CODE_TSC_INVALID_OPERATION);
|
||||
|
||||
if (pColSchema->type == TSDB_DATA_TYPE_TIMESTAMP) {
|
||||
kv->i = convertTimePrecision(kv->i, TSDB_TIME_PRECISION_NANO, pTableMeta->tableInfo.precision);
|
||||
}
|
||||
if (kv->type == TSDB_DATA_TYPE_NCHAR) {
|
||||
int32_t len = 0;
|
||||
char* pUcs4 = taosMemoryCalloc(1, pColSchema->bytes - VARSTR_HEADER_SIZE);
|
||||
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;
|
||||
ret = smlMbsToUcs4(kv->value, kv->length, (void**)&pVal->value.pData, (int32_t*)&pVal->value.nData, pColSchema->bytes - VARSTR_HEADER_SIZE, charsetCxt);
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
} else if (kv->type == TSDB_DATA_TYPE_BINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = (uint8_t*)kv->value;
|
||||
} else if (kv->type == TSDB_DATA_TYPE_GEOMETRY || kv->type == TSDB_DATA_TYPE_VARBINARY) {
|
||||
pVal->value.nData = kv->length;
|
||||
pVal->value.pData = taosMemoryMalloc(kv->length);
|
||||
if (NULL == pVal->value.pData) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pVal->value.pData, ret, lino, end, terrno);
|
||||
(void)memcpy(pVal->value.pData, (uint8_t*)kv->value, kv->length);
|
||||
} else {
|
||||
(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);
|
||||
if (NULL == pRow) {
|
||||
ret = terrno;
|
||||
goto end;
|
||||
}
|
||||
TSDB_CHECK_NULL(pRow, ret, lino, end, terrno);
|
||||
ret = tRowBuild(pTableCxt->pValues, pTableCxt->pSchema, pRow);
|
||||
if (TSDB_CODE_SUCCESS != ret) {
|
||||
ret = buildInvalidOperationMsg(&pBuf, "tRowBuild error");
|
||||
goto end;
|
||||
}
|
||||
SRowKey key;
|
||||
TSDB_CHECK_CODE(ret, lino, end);
|
||||
SRowKey key = {0};
|
||||
tRowGetKey(*pRow, &key);
|
||||
insCheckTableDataOrder(pTableCxt, &key);
|
||||
clearColValArraySml(pTableCxt->pValues);
|
||||
}
|
||||
|
||||
end:
|
||||
if (ret != 0){
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(ret));
|
||||
ret = buildInvalidOperationMsg(&pBuf, tstrerror(ret));
|
||||
}
|
||||
insDestroyBoundColInfo(&bindTags);
|
||||
tdDestroySVCreateTbReq(pCreateTblReq);
|
||||
taosMemoryFree(pCreateTblReq);
|
||||
|
@ -466,29 +355,22 @@ end:
|
|||
}
|
||||
|
||||
int32_t smlInitHandle(SQuery** query) {
|
||||
*query = NULL;
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
SQuery* pQuery = NULL;
|
||||
SVnodeModifyOpStmt* stmt = NULL;
|
||||
TSDB_CHECK_NULL(query, code, lino, end, TSDB_CODE_INVALID_PARA);
|
||||
|
||||
int32_t code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
if (code != 0) {
|
||||
uError("SML create pQuery error");
|
||||
goto END;
|
||||
}
|
||||
*query = NULL;
|
||||
code = nodesMakeNode(QUERY_NODE_QUERY, (SNode**)&pQuery);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
pQuery->execMode = QUERY_EXEC_MODE_SCHEDULE;
|
||||
pQuery->haveResultSet = false;
|
||||
pQuery->msgType = TDMT_VND_SUBMIT;
|
||||
code = nodesMakeNode(QUERY_NODE_VNODE_MODIFY_STMT, (SNode**)&stmt);
|
||||
if (code != 0) {
|
||||
uError("SML create SVnodeModifyOpStmt error");
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
stmt->pTableBlockHashObj = taosHashInit(16, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK);
|
||||
if (stmt->pTableBlockHashObj == NULL){
|
||||
uError("SML create pTableBlockHashObj error");
|
||||
code = terrno;
|
||||
goto END;
|
||||
}
|
||||
TSDB_CHECK_NULL(stmt->pTableBlockHashObj, code, lino, end, terrno);
|
||||
stmt->freeHashFunc = insDestroyTableDataCxtHashMap;
|
||||
stmt->freeArrayFunc = insDestroyVgroupDataCxtList;
|
||||
|
||||
|
@ -496,24 +378,28 @@ int32_t smlInitHandle(SQuery** query) {
|
|||
*query = pQuery;
|
||||
return code;
|
||||
|
||||
END:
|
||||
end:
|
||||
if (code != 0) {
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
nodesDestroyNode((SNode*)stmt);
|
||||
qDestroyQuery(pQuery);
|
||||
return code;
|
||||
}
|
||||
|
||||
int32_t smlBuildOutput(SQuery* handle, SHashObj* pVgHash) {
|
||||
int32_t lino = 0;
|
||||
int32_t code = 0;
|
||||
|
||||
SVnodeModifyOpStmt* pStmt = (SVnodeModifyOpStmt*)(handle)->pRoot;
|
||||
// merge according to vgId
|
||||
int32_t code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("insMergeTableDataCxt failed");
|
||||
return code;
|
||||
}
|
||||
code = insMergeTableDataCxt(pStmt->pTableBlockHashObj, &pStmt->pVgDataBlocks, true);
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
code = insBuildVgDataBlocks(pVgHash, pStmt->pVgDataBlocks, &pStmt->pDataBlocks, false);
|
||||
if (code != TSDB_CODE_SUCCESS) {
|
||||
uError("insBuildVgDataBlocks failed");
|
||||
return code;
|
||||
TSDB_CHECK_CODE(code, lino, end);
|
||||
|
||||
end:
|
||||
if (code != 0) {
|
||||
uError("%s failed at %d since %s", __func__, lino, tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -6060,11 +6060,22 @@ static int32_t stbJoinOptCreateTagScanNode(SLogicNode* pJoin, SNodeList** ppList
|
|||
}
|
||||
|
||||
SNode* pNode = NULL;
|
||||
SName* pPrev = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
code = stbJoinOptRewriteToTagScan(pJoin, pNode);
|
||||
if (code) {
|
||||
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) {
|
||||
|
@ -6156,6 +6167,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
}
|
||||
|
||||
int32_t i = 0;
|
||||
SName* pPrev = NULL;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pList) {
|
||||
SScanLogicNode* pScan = (SScanLogicNode*)pNode;
|
||||
|
@ -6173,6 +6185,16 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL
|
|||
*(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1;
|
||||
|
||||
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;
|
||||
|
|
|
@ -55,16 +55,10 @@ int32_t validateQueryPlanNode(SValidatePlanContext* pCxt, SQueryPlan* pPlan) {
|
|||
SNode* pSubNode = NULL;
|
||||
SNodeListNode* pSubplans = (SNodeListNode*)pNode;
|
||||
FOREACH(pSubNode, pSubplans->pNodeList) {
|
||||
if (QUERY_NODE_PHYSICAL_SUBPLAN != nodeType(pNode)) {
|
||||
code = TSDB_CODE_PLAN_INTERNAL_ERROR;
|
||||
break;
|
||||
}
|
||||
|
||||
code = doValidatePhysiNode(pCxt, pSubNode);
|
||||
if (code) {
|
||||
break;
|
||||
}
|
||||
if (code) break;
|
||||
}
|
||||
if (code) break;
|
||||
}
|
||||
|
||||
return code;
|
||||
|
@ -142,24 +136,7 @@ int32_t validateQueryPlan(SPlanContext* pCxt, SQueryPlan* pPlan) {
|
|||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SNode* pNode = NULL;
|
||||
FOREACH(pNode, pPlan->pSubplans) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
code = validateQueryPlanNode(&cxt, pPlan);
|
||||
|
||||
destoryValidatePlanContext(&cxt);
|
||||
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 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) {
|
||||
SDataInserterNode* insert = (SDataInserterNode*)pSubplan->pDataSink;
|
||||
*pLen = insert->size;
|
||||
|
|
|
@ -137,6 +137,8 @@ static void processTaskQueue(SQueueInfo *pInfo, SSchedMsg *pSchedMsg) {
|
|||
}
|
||||
|
||||
int32_t initTaskQueue() {
|
||||
memset(&taskQueue, 0, sizeof(taskQueue));
|
||||
|
||||
taskQueue.wrokrerPool.name = "taskWorkPool";
|
||||
taskQueue.wrokrerPool.min = tsNumOfTaskQueueThreads;
|
||||
taskQueue.wrokrerPool.max = tsNumOfTaskQueueThreads;
|
||||
|
|
|
@ -477,6 +477,8 @@ extern SQueryMgmt gQueryMgmt;
|
|||
} \
|
||||
} while (0)
|
||||
|
||||
|
||||
#if 0
|
||||
#define QW_UNLOCK(type, _lock) \
|
||||
do { \
|
||||
if (QW_READ == (type)) { \
|
||||
|
@ -505,6 +507,16 @@ extern SQueryMgmt gQueryMgmt;
|
|||
} \
|
||||
} \
|
||||
} while (0)
|
||||
#else
|
||||
#define QW_UNLOCK(type, _lock) \
|
||||
do { \
|
||||
if (QW_READ == (type)) { \
|
||||
taosRUnLockLatch(_lock); \
|
||||
} else { \
|
||||
taosWUnLockLatch(_lock); \
|
||||
} \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
extern SQWorkerMgmt gQwMgmt;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "qwInt.h"
|
||||
#include "qworker.h"
|
||||
|
||||
#if 0
|
||||
void qwSetConcurrentTaskNumCb(int32_t taskNum) {
|
||||
int32_t finTaskNum = TMIN(taskNum, tsNumOfQueryThreads * QW_DEFAULT_THREAD_TASK_NUM);
|
||||
|
||||
|
@ -33,6 +34,7 @@ void qwIncConcurrentTaskNumCb(void) {
|
|||
|
||||
//TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t qwInitJobInfo(QW_FPARAMS_DEF, SQWJobInfo* pJob) {
|
||||
pJob->pSessions= taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||
|
|
|
@ -2985,279 +2985,93 @@ 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])));
|
||||
|
||||
int32_t numOfRows = TMAX(pInput[0].numOfRows, pInput[1].numOfRows);
|
||||
if (pInput[0].numOfRows == pInput[1].numOfRows) {
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
if (colDataIsNull_s(pInputData[0], i) || colDataIsNull_s(pInputData[1], i) || hasNullType) {
|
||||
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[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], (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[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;
|
||||
}
|
||||
}
|
||||
for (int32_t i = 0; i < numOfRows; ++i) {
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
} 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)) {
|
||||
double in2;
|
||||
GET_TYPED_DATA(in2, double, GET_PARAM_TYPE(&pInput[1]), colDataGetData(pInputData[1], colIdx2));
|
||||
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[colIdx1], in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
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 {
|
||||
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)) {
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float *in = (float *)pInputData[0]->pData;
|
||||
float *out = (float *)pOutputData->pData;
|
||||
float result = f1(in[colIdx1], (float)in2);
|
||||
if (isinf(result) || isnan(result)) {
|
||||
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;
|
||||
}
|
||||
} 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[colIdx1], 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[colIdx1], 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[colIdx1], 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[colIdx1], 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[colIdx1], 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[colIdx1], 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[colIdx1], 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[colIdx1], in2);
|
||||
out[i] = result;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,19 +121,6 @@ _return:
|
|||
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);
|
||||
|
||||
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)) {
|
||||
code = vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
SCL_ERR_RET(vectorConvertSingleCol(param1, paramOut1, type, startIndex, numOfRows));
|
||||
}
|
||||
|
||||
if (type != GET_PARAM_TYPE(param2)) {
|
||||
code = vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows);
|
||||
if (code) {
|
||||
return code;
|
||||
}
|
||||
SCL_ERR_RET(vectorConvertSingleCol(param2, paramOut2, type, startIndex, numOfRows));
|
||||
}
|
||||
|
||||
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) {
|
||||
SScalarParam output = {0};
|
||||
SColumnInfoData *pCol = pInput->columnData;
|
||||
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
*pOutputCol = NULL;
|
||||
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;
|
||||
SCL_ERR_RET(code);
|
||||
}
|
||||
|
||||
SCL_ERR_RET(vectorConvertSingleCol(pInput, &output, TSDB_DATA_TYPE_DOUBLE, -1, -1));
|
||||
*converted = VECTOR_DO_CONVERT;
|
||||
|
||||
*pOutputCol = output.columnData;
|
||||
SCL_RET(code);
|
||||
}
|
||||
|
||||
*converted = VECTOR_UN_CONVERT;
|
||||
|
||||
*pOutputCol = pInput->columnData;
|
||||
SCL_RET(TSDB_CODE_SUCCESS);
|
||||
}
|
||||
|
@ -1616,68 +1591,25 @@ int32_t vectorMathRemainder(SScalarParam *pLeft, SScalarParam *pRight, SScalarPa
|
|||
|
||||
double *output = (double *)pOutputCol->pData;
|
||||
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
double lx = 0;
|
||||
double rx = 0;
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, i, &lx));
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, i, &rx));
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
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);
|
||||
continue;
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnLeft(LEFT_COL, leftidx, &lx));
|
||||
SCL_ERR_JRET(getVectorDoubleValueFnRight(RIGHT_COL, rightidx, &rx));
|
||||
if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue;
|
||||
}
|
||||
|
||||
*output = lx - ((int64_t)(lx / rx)) * rx;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -1739,33 +1671,6 @@ int32_t vectorAssign(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
|||
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) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
|
@ -1786,22 +1691,19 @@ int32_t vectorBitAnd(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pO
|
|||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
||||
*output = leftRes & rightRes;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
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);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
} 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));
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||
*output = leftRes & rightRes;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
@ -1810,33 +1712,6 @@ _return:
|
|||
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) {
|
||||
SColumnInfoData *pOutputCol = pOut->columnData;
|
||||
pOut->numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
|
@ -1857,22 +1732,20 @@ int32_t vectorBitOr(SScalarParam *pLeft, SScalarParam *pRight, SScalarParam *pOu
|
|||
SCL_ERR_JRET(getVectorBigintValueFn(pRightCol->info.type, &getVectorBigintValueFnRight));
|
||||
|
||||
int64_t *output = (int64_t *)pOutputCol->pData;
|
||||
if (pLeft->numOfRows == pRight->numOfRows) {
|
||||
for (; i < pRight->numOfRows && i >= 0; i += step, output += 1) {
|
||||
if (IS_NULL) {
|
||||
colDataSetNULL(pOutputCol, i);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, i, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, i, &rightRes));
|
||||
*output = leftRes | rightRes;
|
||||
int32_t numOfRows = TMAX(pLeft->numOfRows, pRight->numOfRows);
|
||||
for (; i < numOfRows && i >= 0; i += step, output += 1) {
|
||||
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);
|
||||
continue; // TODO set null or ignore
|
||||
}
|
||||
} 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));
|
||||
|
||||
int64_t leftRes = 0;
|
||||
int64_t rightRes = 0;
|
||||
SCL_ERR_JRET(getVectorBigintValueFnLeft(LEFT_COL, leftidx, &leftRes));
|
||||
SCL_ERR_JRET(getVectorBigintValueFnRight(RIGHT_COL, rightidx, &rightRes));
|
||||
*output = leftRes | rightRes;
|
||||
}
|
||||
|
||||
_return:
|
||||
|
|
|
@ -391,6 +391,26 @@ TEST(constantTest, bigint_add_bigint) {
|
|||
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) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -431,6 +451,66 @@ TEST(constantTest, tinyint_and_smallint) {
|
|||
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) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
|
@ -494,6 +574,53 @@ TEST(constantTest, int_greater_double) {
|
|||
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) {
|
||||
SNode *pLeft = NULL, *pRight = NULL, *opNode = NULL, *res = NULL;
|
||||
char binaryStr[64] = {0};
|
||||
|
|
|
@ -149,11 +149,11 @@ typedef struct SSchedulerMgmt {
|
|||
bool exit;
|
||||
int32_t jobRef;
|
||||
int32_t jobNum;
|
||||
SSchStat stat;
|
||||
void *timer;
|
||||
SRWLatch hbLock;
|
||||
SHashObj *hbConnections;
|
||||
void *queryMgmt;
|
||||
SSchStat stat;
|
||||
} SSchedulerMgmt;
|
||||
|
||||
typedef struct SSchCallbackParamHeader {
|
||||
|
|
|
@ -50,11 +50,6 @@ int32_t schChkJobNeedFlowCtrl(SSchJob *pJob, SSchLevel *pLevel) {
|
|||
int32_t taskNum = taosArrayGetSize(pJob->dataSrcTasks);
|
||||
for (int32_t i = 0; i < taskNum; ++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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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",
|
||||
pParam->queryId, pParam->seriousId, pParam->clientId, pParam->taskId, code);
|
||||
if (pMsg) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFreeClear(pMsg->pData);
|
||||
taosMemoryFreeClear(pMsg->pEpSet);
|
||||
}
|
||||
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);
|
||||
|
||||
if (head->isHbParam) {
|
||||
taosMemoryFree(pMsg->pData);
|
||||
taosMemoryFree(pMsg->pEpSet);
|
||||
taosMemoryFreeClear(pMsg->pData);
|
||||
taosMemoryFreeClear(pMsg->pEpSet);
|
||||
|
||||
SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param;
|
||||
SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL, .pHandleId = 0};
|
||||
|
@ -1293,6 +1293,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
}
|
||||
break;
|
||||
}
|
||||
/*
|
||||
case TDMT_SCH_QUERY_HEARTBEAT: {
|
||||
SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &rpcCtx));
|
||||
|
||||
|
@ -1320,6 +1321,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr,
|
|||
persistHandle = true;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
case TDMT_SCH_TASK_NOTIFY: {
|
||||
ETaskNotifyType* pType = param;
|
||||
STaskNotifyReq qMsg;
|
||||
|
|
|
@ -189,7 +189,6 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode)
|
|||
}
|
||||
|
||||
pTask->failedExecId = pTask->execId;
|
||||
pTask->failedSeriousId = pTask->seriousId;
|
||||
|
||||
int8_t jobStatus = 0;
|
||||
if (schJobNeedToStop(pJob, &jobStatus)) {
|
||||
|
@ -274,18 +273,18 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) {
|
|||
if (taskDone < pTask->level->taskNum) {
|
||||
SCH_TASK_DLOG("wait all tasks, done:%d, all:%d", taskDone, pTask->level->taskNum);
|
||||
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) {
|
||||
SCH_RET(schHandleJobFailure(pJob, pJob->errCode));
|
||||
} else {
|
||||
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||
}
|
||||
} else {
|
||||
pJob->resNode = pTask->succeedAddr;
|
||||
|
||||
SCH_RET(schSwitchJobStatus(pJob, JOB_TASK_STATUS_PART_SUCC, NULL));
|
||||
}
|
||||
|
||||
pJob->resNode = pTask->succeedAddr;
|
||||
|
||||
pJob->fetchTask = pTask;
|
||||
|
||||
|
@ -438,7 +437,7 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
pTask->waitRetry = true;
|
||||
|
||||
if (pTask->delayTimer) {
|
||||
taosTmrStop(pTask->delayTimer);
|
||||
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||
}
|
||||
|
||||
schDropTaskOnExecNode(pJob, pTask);
|
||||
|
@ -452,6 +451,8 @@ void schResetTaskForRetry(SSchJob *pJob, SSchTask *pTask) {
|
|||
TAOS_MEMSET(&pTask->succeedAddr, 0, sizeof(pTask->succeedAddr));
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
int32_t schDoTaskRedirect(SSchJob *pJob, SSchTask *pTask, SDataBuf *pData, int32_t rspCode) {
|
||||
int32_t code = 0;
|
||||
|
||||
|
@ -593,17 +594,18 @@ _return:
|
|||
|
||||
SCH_RET(schProcessOnTaskFailure(pJob, pTask, code));
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) {
|
||||
int32_t code = taosHashPut(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId), &pTask, POINTER_BYTES);
|
||||
if (0 != 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;
|
||||
}
|
||||
|
||||
SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:0x%x", errno);
|
||||
SCH_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
SCH_TASK_ELOG("taosHashPut task to execTask list failed, code:0x%x", code);
|
||||
SCH_ERR_RET(code);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
if (pTask->delayTimer) {
|
||||
taosTmrStop(pTask->delayTimer);
|
||||
UNUSED(taosTmrStop(pTask->delayTimer));
|
||||
}
|
||||
|
||||
(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) {
|
||||
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;
|
||||
|
||||
if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) {
|
||||
|
@ -869,6 +866,7 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
#if 0
|
||||
int32_t schUpdateTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask, SEpSet *pEpSet) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
if (NULL == pTask->candidateAddrs || 1 != taosArrayGetSize(pTask->candidateAddrs)) {
|
||||
|
@ -900,6 +898,7 @@ _return:
|
|||
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t schSwitchTaskCandidateAddr(SSchJob *pJob, SSchTask *pTask) {
|
||||
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) {
|
||||
SSchTask *pTask = taosArrayGet(level->subTasks, i);
|
||||
pTask->failedSeriousId = pJob->seriousId - 1;
|
||||
pTask->seriousId = pJob->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,
|
||||
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 queryJobRefId = 0;
|
||||
|
@ -316,7 +332,7 @@ void schtBuildQueryFlowCtrlDag(SQueryPlan *dag) {
|
|||
|
||||
scanPlan->execNode.nodeId = 1 + i;
|
||||
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, "ep1", 6030);
|
||||
addEpIntoEpSet(&scanPlan->execNode.epSet, "ep2", 6030);
|
||||
|
@ -982,8 +998,159 @@ TEST(queryTest, normalCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(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) {
|
||||
void *mockPointer = (void *)0x1;
|
||||
char *clusterId = "cluster1";
|
||||
|
@ -1097,6 +1264,7 @@ TEST(queryTest, readyFirstCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(queryTest, flowCtrlCase) {
|
||||
|
@ -1196,6 +1364,9 @@ TEST(queryTest, flowCtrlCase) {
|
|||
schedulerFreeJob(&job, 0);
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
|
||||
cleanupTaskQueue();
|
||||
}
|
||||
|
||||
TEST(insertTest, normalCase) {
|
||||
|
@ -1260,6 +1431,7 @@ TEST(insertTest, normalCase) {
|
|||
schedulerDestroy();
|
||||
|
||||
(void)taosThreadJoin(thread1, NULL);
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(multiThread, forceFree) {
|
||||
|
@ -1282,9 +1454,11 @@ TEST(multiThread, forceFree) {
|
|||
|
||||
schtTestStop = true;
|
||||
// taosSsleep(3);
|
||||
|
||||
schMgmt.jobRef = -1;
|
||||
}
|
||||
|
||||
TEST(otherTest, otherCase) {
|
||||
TEST(otherTest, function) {
|
||||
// excpet test
|
||||
(void)schReleaseJob(0);
|
||||
schFreeRpcCtx(NULL);
|
||||
|
@ -1293,6 +1467,296 @@ TEST(otherTest, otherCase) {
|
|||
ASSERT_EQ(schDumpEpSet(NULL, &ep), TSDB_CODE_SUCCESS);
|
||||
ASSERT_EQ(strcmp(schGetOpStr(SCH_OP_NULL), "NULL"), 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) {
|
||||
|
@ -1302,7 +1766,17 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
taosSeedRand(taosGetTimestampSec());
|
||||
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
|
||||
|
|
|
@ -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 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
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ static int32_t streamTaskUploadCheckpoint(const char* id, const char* path, int6
|
|||
#ifdef BUILD_NO_CALL
|
||||
static int32_t deleteCheckpoint(const char* id);
|
||||
#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 appendCheckpointIntoInputQ(SStreamTask* pTask, int32_t checkpointType, int64_t checkpointId,
|
||||
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 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 code = TSDB_CODE_SUCCESS;
|
||||
int32_t lino = 0;
|
||||
|
@ -135,6 +136,7 @@ _end:
|
|||
}
|
||||
return code;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t getHashSortNextRow(SStreamFileState* pFileState, const SWinKey* pKey, SWinKey* pResKey, void** ppVal,
|
||||
int32_t* pVLen, int32_t* pWinCode) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "tstream.h"
|
||||
#include "streamInt.h"
|
||||
#include "tcs.h"
|
||||
#include "tglobal.h"
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wwrite-strings"
|
||||
|
@ -217,6 +219,10 @@ TEST(StreamTaskAlreadySendTriggerTest, AlreadySendTrigger) {
|
|||
taosArrayDestroy(array);
|
||||
}
|
||||
|
||||
int32_t sendReq1111(const SEpSet *pEpSet, SRpcMsg *pMsg) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
||||
SStreamTask* pTask = NULL;
|
||||
int64_t uid = 2222222222222;
|
||||
|
@ -239,6 +245,11 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
|||
pTask->chkInfo.pActiveInfo->transId = 4561111;
|
||||
pTask->chkInfo.startTs = 11111;
|
||||
|
||||
SStreamTask upTask;
|
||||
upTask = *pTask;
|
||||
streamTaskSetUpstreamInfo(pTask, &upTask);
|
||||
|
||||
|
||||
streamTaskSetStatusReady(pTask);
|
||||
code = streamTaskHandleEvent(pTask->status.pSM, TASK_EVENT_GEN_CHECKPOINT);
|
||||
ASSERT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -254,7 +265,21 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
|||
|
||||
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;
|
||||
|
||||
SMsgCb msgCb = {0};
|
||||
msgCb.sendReqFp = sendReq1111;
|
||||
msgCb.mgmt = (SMgmtWrapper*)(&msgCb); // hack
|
||||
tmsgSetDefault(&msgCb);
|
||||
|
||||
SArray* array1 = NULL;
|
||||
code = chkptTriggerRecvMonitorHelper(pTask, NULL, &array1);
|
||||
EXPECT_EQ(code, TSDB_CODE_SUCCESS);
|
||||
|
@ -268,3 +293,106 @@ TEST(ChkptTriggerRecvMonitorHelperTest, chkptTriggerRecvMonitorHelper) {
|
|||
taosArrayDestroy(array);
|
||||
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 outLeft = ucs4_max_len;
|
||||
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);
|
||||
taosReleaseConv(idx, conv, M2C, charsetCxt);
|
||||
return false;
|
||||
|
|
|
@ -454,7 +454,8 @@ struct tm *taosGmTimeR(const time_t *timep, struct tm *result) {
|
|||
return NULL;
|
||||
}
|
||||
#ifdef WINDOWS
|
||||
return gmtime_s(result, timep);
|
||||
errno_t code = gmtime_s(result, timep);
|
||||
return (code == 0) ? result : NULL;
|
||||
#else
|
||||
return gmtime_r(timep, result);
|
||||
#endif
|
||||
|
|
|
@ -94,6 +94,35 @@ TEST(osTimeTests, taosLocalTime) {
|
|||
#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) {
|
||||
void *retp = NULL;
|
||||
int32_t reti = 0;
|
||||
|
|
|
@ -22,7 +22,7 @@ char tsSIMDEnable = 0;
|
|||
#endif
|
||||
|
||||
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);
|
||||
|
||||
// Selector value: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
||||
|
@ -53,183 +53,79 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
|||
int32_t gRemainder = (nelements - _pos);
|
||||
int32_t num = (gRemainder > elems) ? elems : gRemainder;
|
||||
|
||||
int32_t batch = 0;
|
||||
int32_t remain = 0;
|
||||
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
|
||||
}
|
||||
int32_t batch = num >> 3;
|
||||
int32_t remain = num & 0x07;
|
||||
|
||||
if (selector == 0 || selector == 1) {
|
||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
||||
#ifdef __AVX512F__
|
||||
for (int32_t i = 0; i < batch; ++i) {
|
||||
__m512i prev = _mm512_set1_epi64(prevValue);
|
||||
_mm512_storeu_si512((__m512i *)&p[_pos], prev);
|
||||
_pos += 8; // handle 64bit x 8 = 512bit
|
||||
}
|
||||
for (int32_t i = 0; i < remain; ++i) {
|
||||
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;
|
||||
}
|
||||
for (int32_t i = 0; i < batch; ++i) {
|
||||
__m512i prev = _mm512_set1_epi64(prevValue);
|
||||
_mm512_storeu_si512((__m512i *)&p[_pos], prev);
|
||||
_pos += 8; // handle 64bit x 8 = 512bit
|
||||
}
|
||||
for (int32_t i = 0; i < remain; ++i) {
|
||||
p[_pos++] = prevValue;
|
||||
}
|
||||
} else {
|
||||
if (tsSIMDEnable && tsAVX512Supported && tsAVX512Enable) {
|
||||
#ifdef __AVX512F__
|
||||
__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_mask3 = _mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3);
|
||||
__m512i base = _mm512_set1_epi64(w);
|
||||
__m512i maskVal = _mm512_set1_epi64(mask);
|
||||
__m512i shiftBits = _mm512_set_epi64(bit * 7 + 4, bit * 6 + 4, bit * 5 + 4, bit * 4 + 4, bit * 3 + 4,
|
||||
bit * 2 + 4, bit + 4, 4);
|
||||
__m512i inc = _mm512_set1_epi64(bit << 3);
|
||||
__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_mask3 = _mm512_set_epi64(3, 3, 3, 3, 3, 3, 3, 3);
|
||||
__m512i base = _mm512_set1_epi64(w);
|
||||
__m512i maskVal = _mm512_set1_epi64(mask);
|
||||
__m512i shiftBits = _mm512_set_epi64(bit * 7 + 4, bit * 6 + 4, bit * 5 + 4, bit * 4 + 4, bit * 3 + 4,
|
||||
bit * 2 + 4, bit + 4, 4);
|
||||
__m512i inc = _mm512_set1_epi64(bit << 3);
|
||||
|
||||
for (int32_t i = 0; i < batch; ++i) {
|
||||
__m512i after = _mm512_srlv_epi64(base, shiftBits);
|
||||
__m512i zigzagVal = _mm512_and_si512(after, maskVal);
|
||||
for (int32_t i = 0; i < batch; ++i) {
|
||||
__m512i after = _mm512_srlv_epi64(base, shiftBits);
|
||||
__m512i zigzagVal = _mm512_and_si512(after, maskVal);
|
||||
|
||||
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
|
||||
__m512i signmask = _mm512_and_si512(_mm512_set1_epi64(1), zigzagVal);
|
||||
signmask = _mm512_sub_epi64(_mm512_setzero_si512(), signmask);
|
||||
__m512i delta = _mm512_xor_si512(_mm512_srli_epi64(zigzagVal, 1), signmask);
|
||||
// ZIGZAG_DECODE(T, v) (((v) >> 1) ^ -((T)((v)&1)))
|
||||
__m512i signmask = _mm512_and_si512(_mm512_set1_epi64(1), zigzagVal);
|
||||
signmask = _mm512_sub_epi64(_mm512_setzero_si512(), signmask);
|
||||
__m512i delta = _mm512_xor_si512(_mm512_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]
|
||||
// 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]
|
||||
|
||||
// 7 6 5 4 3 2 1
|
||||
// 0 D7 D6 D5 D4 D3 D2 D1
|
||||
// D0 D6 0 D4 0 D2 0 D0
|
||||
// 0 D7+D6 D6 D5+D4 D4 D3+D2 D2
|
||||
// D1+D0 D0 13 6 9 4 5 2
|
||||
// 1 0
|
||||
__m512i prev = _mm512_set1_epi64(prevValue);
|
||||
__m512i cum_sum = _mm512_add_epi64(delta, _mm512_maskz_permutexvar_epi64(0xaa, sum_mask1, delta));
|
||||
cum_sum = _mm512_add_epi64(cum_sum, _mm512_maskz_permutexvar_epi64(0xcc, sum_mask2, cum_sum));
|
||||
cum_sum = _mm512_add_epi64(cum_sum, _mm512_maskz_permutexvar_epi64(0xf0, sum_mask3, cum_sum));
|
||||
// 7 6 5 4 3 2 1
|
||||
// 0 D7 D6 D5 D4 D3 D2 D1
|
||||
// D0 D6 0 D4 0 D2 0 D0
|
||||
// 0 D7+D6 D6 D5+D4 D4 D3+D2 D2
|
||||
// D1+D0 D0 13 6 9 4 5 2
|
||||
// 1 0
|
||||
__m512i prev = _mm512_set1_epi64(prevValue);
|
||||
__m512i cum_sum = _mm512_add_epi64(delta, _mm512_maskz_permutexvar_epi64(0xaa, sum_mask1, delta));
|
||||
cum_sum = _mm512_add_epi64(cum_sum, _mm512_maskz_permutexvar_epi64(0xcc, sum_mask2, cum_sum));
|
||||
cum_sum = _mm512_add_epi64(cum_sum, _mm512_maskz_permutexvar_epi64(0xf0, sum_mask3, cum_sum));
|
||||
|
||||
// 13 6 9 4 5 2 1
|
||||
// 0 D7,D6 D6 D5,D4 D4 D3,D2 D2
|
||||
// D1,D0 D0 +D5,D4 D5,D4, 0 0 D1,D0 D1,D0
|
||||
// 0 0 D7~D4 D6~D4 D5~D4 D4 D3~D0 D2~D0
|
||||
// D1~D0 D0 22 15 9 4 6 3
|
||||
// 1 0
|
||||
//
|
||||
// D3~D0 D3~D0 D3~D0 D3~D0 0 0 0
|
||||
// 0 28 21 15 10 6 3 1
|
||||
// 0
|
||||
// 13 6 9 4 5 2 1
|
||||
// 0 D7,D6 D6 D5,D4 D4 D3,D2 D2
|
||||
// D1,D0 D0 +D5,D4 D5,D4, 0 0 D1,D0 D1,D0
|
||||
// 0 0 D7~D4 D6~D4 D5~D4 D4 D3~D0 D2~D0
|
||||
// D1~D0 D0 22 15 9 4 6 3
|
||||
// 1 0
|
||||
//
|
||||
// D3~D0 D3~D0 D3~D0 D3~D0 0 0 0
|
||||
// 0 28 21 15 10 6 3 1
|
||||
// 0
|
||||
|
||||
cum_sum = _mm512_add_epi64(cum_sum, prev);
|
||||
_mm512_storeu_si512((__m512i *)&p[_pos], cum_sum);
|
||||
cum_sum = _mm512_add_epi64(cum_sum, prev);
|
||||
_mm512_storeu_si512((__m512i *)&p[_pos], cum_sum);
|
||||
|
||||
shiftBits = _mm512_add_epi64(shiftBits, inc);
|
||||
prevValue = p[_pos + 7];
|
||||
_pos += 8;
|
||||
}
|
||||
// handle the remain value
|
||||
for (int32_t i = 0; i < remain; i++) {
|
||||
zigzag_value = ((w >> (v + (batch * bit * 8))) & mask);
|
||||
prevValue += ZIGZAG_DECODE(int64_t, zigzag_value);
|
||||
shiftBits = _mm512_add_epi64(shiftBits, inc);
|
||||
prevValue = p[_pos + 7];
|
||||
_pos += 8;
|
||||
}
|
||||
// handle the remain value
|
||||
for (int32_t i = 0; i < remain; i++) {
|
||||
zigzag_value = ((w >> (v + (batch * bit * 8))) & mask);
|
||||
prevValue += ZIGZAG_DECODE(int64_t, zigzag_value);
|
||||
|
||||
p[_pos++] = prevValue;
|
||||
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;
|
||||
}
|
||||
p[_pos++] = prevValue;
|
||||
v += bit;
|
||||
}
|
||||
}
|
||||
} break;
|
||||
|
@ -292,7 +188,7 @@ int32_t tsDecompressIntImpl_Hw(const char *const input, const int32_t nelements,
|
|||
|
||||
return nelements * word_length;
|
||||
#else
|
||||
uError("unable run %s without avx2 instructions", __func__);
|
||||
uError("unable run %s without avx512 instructions", __func__);
|
||||
return -1;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -823,6 +823,8 @@ bool tQueryAutoQWorkerTryRecycleWorker(SQueryAutoQWorkerPool *pPool, SQueryAutoQ
|
|||
int32_t tQueryAutoQWorkerInit(SQueryAutoQWorkerPool *pool) {
|
||||
int32_t code;
|
||||
|
||||
pool->exit = false;
|
||||
|
||||
(void)taosThreadMutexInit(&pool->poolLock, NULL);
|
||||
(void)taosThreadMutexInit(&pool->backupLock, NULL);
|
||||
(void)taosThreadMutexInit(&pool->waitingAfterBlockLock, NULL);
|
||||
|
|
|
@ -138,6 +138,10 @@ add_test(
|
|||
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")
|
||||
target_link_libraries(decompressTest os util common gtest_main)
|
||||
add_test(
|
||||
|
@ -145,6 +149,16 @@ add_test(
|
|||
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})
|
||||
# terrorTest
|
||||
add_executable(terrorTest "terrorTest.cpp")
|
||||
|
|
|
@ -2048,7 +2048,252 @@ TEST(DisablePoolFuncTest, MultiThreadTest) {
|
|||
}
|
||||
#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
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include "tarray.h"
|
||||
#include "tcompare.h"
|
||||
#include "tdatablock.h"
|
||||
|
||||
namespace {
|
||||
} // namespace
|
||||
|
@ -474,3 +475,67 @@ TEST(tsma, reverse_unit) {
|
|||
ASSERT_FALSE(tsmaIntervalCheck(12, '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 |
|
||||
|
||||
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 |
|
||||
|
||||
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 |
|
||||
|
||||
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 |
|
||||
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))
|
||||
sign(abs(10)) |
|
||||
========================
|
||||
|
@ -213,6 +313,34 @@ taos> select sign(current) from ts_4893.meters order by ts limit 10
|
|||
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)
|
||||
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空 |
|
||||
|
||||
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
|
||||
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 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 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 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 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(sqrt(voltage), 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);
|