Merge branch 3.0 to FIX/TD-19334-3.0
This commit is contained in:
commit
68f8ebac9d
|
@ -101,6 +101,7 @@ tests/examples/JDBC/JDBCDemo/.settings/
|
|||
source/libs/parser/inc/sql.*
|
||||
tests/script/tmqResult.txt
|
||||
tests/tmqResult.txt
|
||||
tests/script/jenkins/basic.txt
|
||||
|
||||
# Emacs
|
||||
# -*- mode: gitignore; -*-
|
||||
|
|
|
@ -7,25 +7,18 @@
|
|||
- 任何用户都可以通过 **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)** 向我们报告错误。请您对所遇到的问题进行**详细描述**,最好提供重现错误的详细步骤。
|
||||
- 欢迎提供包含由 Bug 生成的日志文件的附录。
|
||||
|
||||
## 需要强调的代码提交规则
|
||||
## 代码提交规则
|
||||
|
||||
- 在提交代码之前,需要**同意贡献者许可协议(CLA)**。点击 [TaosData CLA](https://cla-assistant.io/taosdata/TDengine) 阅读并签署协议。如果您不接受该协议,请停止提交。
|
||||
- 请在 [GitHub issue tracker](https://github.com/taosdata/TDengine/issues) 中解决问题或添加注册功能。
|
||||
- 如果在 [GitHub issue tracker](https://github.com/taosdata/TDengine/issues) 中没有找到相应的问题或功能,请**创建一个新的 issue**。
|
||||
- 将代码提交到我们的存储库时,请创建**包含问题编号的 PR**。
|
||||
1. 在提交代码之前,需要**同意贡献者许可协议(CLA)**。点击 [TaosData CLA](https://cla-assistant.io/taosdata/TDengine) 阅读并签署协议。如果您不接受该协议,请停止提交。
|
||||
2. 请在 [GitHub issue tracker](https://github.com/taosdata/TDengine/issues) 中解决问题或添加注册功能。
|
||||
如果在 [GitHub issue tracker](https://github.com/taosdata/TDengine/issues) 中没有找到相应的问题或功能,请**创建一个新的 issue**。
|
||||
将代码提交到我们的存储库时,请创建**包含问题编号的 PR**。
|
||||
3. 将TDengine仓库库fork到自己的账户中并创建分支(branch)。
|
||||
注意:默认分支`main`不能直接接受PR,请基于开发分支`3.0`创建自己的分支。
|
||||
注意:修改文档的分支要以`docs/`为开头,以免进行不必要的测试。
|
||||
4. 创建pull request,将自己的分支合并到开发分支`3.0`,我们开发团队将尽快审核。
|
||||
|
||||
## 贡献指南
|
||||
|
||||
1. 请用友好的语气书写。
|
||||
|
||||
2. **主动语态**总体上优于被动语态。主动语态中的句子会突出执行动作的人,而不是被动语态突出动作的接受者。
|
||||
|
||||
3. 文档写作建议
|
||||
|
||||
- 正确拼写产品名称 “TDengine”。 “TD” 用大写字母,“TD” 和 “engine” 之间没有空格 **(正确拼写:TDengine)**。
|
||||
- 在句号或其他标点符号后只留一个空格。
|
||||
|
||||
4. 尽量**使用简单句**,而不是复杂句。
|
||||
如遇任何问题,请添加官方微信TDengineECO。我们的团队会帮忙解决。
|
||||
|
||||
## 给贡献者的礼品
|
||||
|
||||
|
|
|
@ -1,40 +1,36 @@
|
|||
# Contributing
|
||||
# Contributing to TDengine
|
||||
|
||||
We appreciate contributions from all developers. Feel free to follow us, fork the repository, report bugs, and even submit your code on GitHub. However, we would like developers to follow the guidelines in this document to ensure effective cooperation.
|
||||
TDengine Community Edition is free, open-source software. Its development is led by the TDengine Team, but we welcome contributions from all community members and open-source developers. This document describes how you can contribute, no matter whether you're a user or a developer yourself.
|
||||
|
||||
## Reporting a bug
|
||||
## Bug reports
|
||||
|
||||
- Any users can report bugs to us through the **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)**. We would appreciate if you could provide **a detailed description** of the problem you encountered, including steps to reproduce it.
|
||||
All users can report bugs to us through the **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)**. To ensure that the development team can locate and resolve the issue that you experienced, please include the following in your bug report:
|
||||
|
||||
- Attaching log files caused by the bug is really appreciated.
|
||||
- A detailed description of the issue, including the steps to reproduce it.
|
||||
- Any log files that may be relevant to the issue.
|
||||
|
||||
## Guidelines for committing code
|
||||
## Code contributions
|
||||
|
||||
- You must agree to the **Contributor License Agreement(CLA) before submitting your code patch**. Follow the **[TAOSData CLA](https://cla-assistant.io/taosdata/TDengine)** link to read through and sign the agreement. If you do not accept the agreement, your contributions cannot be accepted.
|
||||
Developers are encouraged to submit patches to the project, and all contributions, from minor documentation changes to bug fixes, are appreciated by our team. To ensure that your code can be merged successfully and improve the experience for other community members, we ask that you go through the following procedure before submitting a pull request:
|
||||
|
||||
- Please solve an issue or add a feature registered in the **[GitHub issue tracker](https://github.com/taosdata/TDengine/issues)**.
|
||||
- If no corresponding issue or feature is found in the issue tracker, please **create one**.
|
||||
- When submitting your code to our repository, please create a pull request with the **issue number** included.
|
||||
1. Read and accept the terms of the TAOS Data Contributor License Agreement (CLA) located at [https://cla-assistant.io/taosdata/TDengine](https://cla-assistant.io/taosdata/TDengine).
|
||||
|
||||
## Guidelines for communicating
|
||||
2. For bug fixes, search the [GitHub issue tracker](https://github.com/taosdata/TDengine/issues) to check whether the bug has already been filed.
|
||||
- If the bug that you want to fix already exists in the issue tracker, review the previous discussion before submitting your patch.
|
||||
- If the bug that you want to fix does not exist in the issue tracker, click **New issue** and file a report.
|
||||
- Ensure that you note the issue number in your pull request when you submit your patch.
|
||||
|
||||
3. Fork our repository to your GitHub account and create a branch for your patch.
|
||||
**Important:** The `main` branch is for stable versions and cannot accept patches directly. For all code and documentation changes, create your own branch from the development branch `3.0` and not from `main`.
|
||||
Note: For a documentation change, ensure that the branch name starts with `docs/` so that the change can be merged without running tests.
|
||||
|
||||
4. Create a pull request to merge your changes into the development branch `3.0`, and our team members will review the request as soon as possible.
|
||||
|
||||
1. Please be **nice and polite** in the description.
|
||||
2. **Active voice is better than passive voice in general**. Sentences in the active voice will highlight who is performing the action rather than the recipient of the action highlighted by the passive voice.
|
||||
3. Documentation writing advice
|
||||
If you encounter any difficulties or problems in contributing your code, you can join our [Discord server](https://discord.com/invite/VZdSuUg4pS) and receive assistance from members of the TDengine Team.
|
||||
|
||||
- Spell the product name "TDengine" correctly. "TD" is written in capital letters, and there is no space between "TD" and "engine" (**Correct spelling: TDengine**).
|
||||
- Please **capitalize the first letter** of every sentence.
|
||||
- Leave **only one space** after periods or other punctuation marks.
|
||||
- Use **American spelling**.
|
||||
- When possible, **use second person** rather than first person (e.g.“You are recommended to use a reverse proxy such as Nginx.” rather than “We recommend to use a reverse proxy such as Nginx.”).
|
||||
## Expressing our thanks
|
||||
|
||||
5. Use **simple sentences**, rather than complex sentences.
|
||||
|
||||
## Gifts for the contributors
|
||||
|
||||
Developers, as long as you contribute to TDengine, whether it's code contributions to fix bugs or feature requests, or documentation changes, **you are eligible for a very special Contributor Souvenir Gift!**
|
||||
|
||||
**You can choose one of the following gifts:**
|
||||
To thank community members for your support, we are offering a free gift to any developer who submits at least one contribution. You can choose one of the following items:
|
||||
|
||||
<p align="left">
|
||||
<img
|
||||
|
@ -53,12 +49,10 @@ Developers, as long as you contribute to TDengine, whether it's code contributio
|
|||
width="200"
|
||||
/>
|
||||
|
||||
The TDengine community is committed to making TDengine accepted and used by more developers.
|
||||
If you would like to claim your gift, send an email to [developer@tdengine.com](mailto:developer@tdengine.com?subject=Claiming&20my%20developer%20gift) including the following information:
|
||||
|
||||
Just fill out the **Contributor Submission Form** to choose your desired gift.
|
||||
- Your GitHub account name
|
||||
- Your name and mailing address
|
||||
- Your preferred gift
|
||||
|
||||
- [Contributor Submission Form](https://page.ma.scrmtech.com/form/index?pf_uid=27715_2095&id=12100)
|
||||
|
||||
## Contact us
|
||||
|
||||
If you have any problems or questions that need help from us, please feel free to add our WeChat account: TDengineECO.
|
||||
Note: Limit one per person.
|
|
@ -303,7 +303,7 @@ def pre_test_build_win() {
|
|||
set CL=/MP8
|
||||
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> cmake"
|
||||
time /t
|
||||
cmake .. -G "NMake Makefiles JOM" -DBUILD_TEST=true || exit 7
|
||||
cmake .. -G "NMake Makefiles JOM" -DBUILD_TEST=true -DBUILD_TOOLS=true || exit 7
|
||||
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> jom -j 6"
|
||||
time /t
|
||||
jom -j 6 || exit 8
|
||||
|
@ -361,7 +361,7 @@ pipeline {
|
|||
}
|
||||
parallel {
|
||||
stage('check docs') {
|
||||
agent{label " worker03 || slave215 || slave217 || slave219 || Mac_catalina "}
|
||||
agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_52 || worker03 || slave215 || slave217 || slave219 || Mac_catalina "}
|
||||
steps {
|
||||
check_docs()
|
||||
}
|
||||
|
@ -407,7 +407,7 @@ pipeline {
|
|||
}
|
||||
}
|
||||
stage('linux test') {
|
||||
agent{label " worker03 || slave215 || slave217 || slave219 "}
|
||||
agent{label " slave1_47 || slave1_48 || slave1_49 || slave1_52 || worker03 || slave215 || slave217 || slave219 "}
|
||||
options { skipDefaultCheckout() }
|
||||
when {
|
||||
changeRequest()
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
IF (DEFINED VERNUMBER)
|
||||
SET(TD_VER_NUMBER ${VERNUMBER})
|
||||
ELSE ()
|
||||
SET(TD_VER_NUMBER "3.0.1.6")
|
||||
SET(TD_VER_NUMBER "3.0.1.7")
|
||||
ENDIF ()
|
||||
|
||||
IF (DEFINED VERCOMPATIBLE)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# taos-tools
|
||||
ExternalProject_Add(taos-tools
|
||||
GIT_REPOSITORY https://github.com/taosdata/taos-tools.git
|
||||
GIT_TAG 23e2b73
|
||||
GIT_TAG fab042d
|
||||
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 9843872
|
||||
GIT_TAG f406d51
|
||||
SOURCE_DIR "${TD_SOURCE_DIR}/tools/taosws-rs"
|
||||
BINARY_DIR ""
|
||||
#BUILD_IN_SOURCE TRUE
|
||||
|
|
|
@ -8,6 +8,7 @@ import DiscordSVG from './discord.svg'
|
|||
import TwitterSVG from './twitter.svg'
|
||||
import YouTubeSVG from './youtube.svg'
|
||||
import LinkedInSVG from './linkedin.svg'
|
||||
import StackOverflowSVG from './stackoverflow.svg'
|
||||
|
||||
You can install and run TDengine on Linux/Windows/macOS machines as well as Docker containers. You can also deploy TDengine as a managed service with TDengine Cloud.
|
||||
|
||||
|
@ -20,14 +21,34 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
||||
```
|
||||
|
||||
### Join TDengine Community
|
||||
## Study TDengine Knowledge Map
|
||||
|
||||
The TDengine Knowledge Map covers the various knowledge points of TDengine, revealing the invocation relationships and data flow between various conceptual entities. Learning and understanding the TDengine Knowledge Map will help you quickly master the TDengine knowledge system.
|
||||
|
||||
<figure>
|
||||
<center>
|
||||
<a href="pathname:///img/tdengine-map.svg" target="_blank"><img src="/img/tdengine-map.svg" width="80%" /></a>
|
||||
<figcaption>Diagram 1. TDengine Knowledge Map</figcaption>
|
||||
</center>
|
||||
</figure>
|
||||
|
||||
## Join TDengine Community
|
||||
|
||||
<table width="100%">
|
||||
<tr align="center" style={{border:0}}>
|
||||
<td width="20%" style={{border:0}}><a href="https://github.com/taosdata/TDengine" target="_blank"><GitHubSVG /><p>Star GitHub</p></a></td>
|
||||
<td width="20%" style={{border:0}}><a href="https://discord.com/invite/VZdSuUg4pS" target="_blank"><DiscordSVG /><p>Join Discord</p></a></td>
|
||||
<td width="20%" style={{border:0}}><a href="https://twitter.com/TDengineDB" target="_blank"><TwitterSVG /><p>Follow Twitter</p></a></td>
|
||||
<td width="20%" style={{border:0}}><a href="https://www.youtube.com/@tdengine" target="_blank"><YouTubeSVG /><p>Subscribe YouTube</p></a></td>
|
||||
<td width="20%" style={{border:0}}><a href="https://www.linkedin.com/company/tdengine" target="_blank"><LinkedInSVG /><p>Follow LinkedIn</p></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://github.com/taosdata/TDengine" target="_blank"><GitHubSVG /></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://discord.com/invite/VZdSuUg4pS" target="_blank"><DiscordSVG /></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://twitter.com/TDengineDB" target="_blank"><TwitterSVG /></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://www.youtube.com/@tdengine" target="_blank"><YouTubeSVG /></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://www.linkedin.com/company/tdengine" target="_blank"><LinkedInSVG /></a></td>
|
||||
<td width="16%" style={{border:0}}><a href="https://stackoverflow.com/questions/tagged/tdengine" target="_blank"><StackOverflowSVG /></a></td>
|
||||
</tr>
|
||||
<tr align="center" style={{border:0,backgroundColor:'transparent'}}>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://github.com/taosdata/TDengine" target="_blank">Star GitHub</a></td>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://discord.com/invite/VZdSuUg4pS" target="_blank">Join Discord</a></td>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://twitter.com/TDengineDB" target="_blank">Follow Twitter</a></td>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://www.youtube.com/@tdengine" target="_blank">Subscribe YouTube</a></td>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://www.linkedin.com/company/tdengine" target="_blank">Follow LinkedIn</a></td>
|
||||
<td width="16%" style={{border:0,padding:0}}><a href="https://stackoverflow.com/questions/tagged/tdengine" target="_blank">Ask StackOverflow</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="-8 0 48 48" width="50" height="50">
|
||||
<path d="M26 41v-9h4v13H0V32h4v9h22z" fill="#BCBBBB" />
|
||||
<path
|
||||
d="M23 34l.8-3-16.1-3.3L7 31l16 3zM9.2 23.2l15 7 1.4-3-15-7-1.4 3zm4.2-7.4L26 26.4l2.1-2.5-12.7-10.6-2.1 2.5zM21.5 8l-2.7 2 9.9 13.3 2.7-2L21.5 8zM7 38h16v-3H7v3z"
|
||||
fill="#F48024"
|
||||
/>
|
||||
</svg>
|
After Width: | Height: | Size: 350 B |
|
@ -205,13 +205,13 @@ Additional functions are defined in `taosudf.h` to make it easier to work with t
|
|||
|
||||
To use your user-defined function in TDengine, first compile it to a dynamically linked library (DLL).
|
||||
|
||||
For example, the sample UDF `add_one.c` can be compiled into a DLL as follows:
|
||||
For example, the sample UDF `bit_and.c` can be compiled into a DLL as follows:
|
||||
|
||||
```bash
|
||||
gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
|
||||
gcc -g -O0 -fPIC -shared bit_and.c -o libbitand.so
|
||||
```
|
||||
|
||||
The generated DLL file `add_one.so` can now be used to implement your function. Note: GCC 7.5 or later is required.
|
||||
The generated DLL file `libbitand.so` can now be used to implement your function. Note: GCC 7.5 or later is required.
|
||||
|
||||
## Manage and Use User-Defined Functions
|
||||
After compiling your function into a DLL, you add it to TDengine. For more information, see [User-Defined Functions](../12-taos-sql/26-udf.md).
|
||||
|
|
|
@ -301,7 +301,7 @@ SELECT TIMEZONE();
|
|||
### Syntax
|
||||
|
||||
```txt
|
||||
WHERE (column|tbname) **match/MATCH/nmatch/NMATCH** _regex_
|
||||
WHERE (column|tbname) match/MATCH/nmatch/NMATCH _regex_
|
||||
```
|
||||
|
||||
### Specification
|
||||
|
|
|
@ -23,7 +23,7 @@ The following characters cannot occur in a password: single quotation marks ('),
|
|||
|
||||
## General Limits
|
||||
|
||||
- Maximum length of database name is 32 bytes
|
||||
- Maximum length of database name is 64 bytes
|
||||
- Maximum length of table name is 192 bytes, excluding the database name prefix and the separator.
|
||||
- Maximum length of each data row is 48K bytes. Note that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type.
|
||||
- The maximum length of a column name is 64 bytes.
|
||||
|
@ -35,7 +35,7 @@ The following characters cannot occur in a password: single quotation marks ('),
|
|||
- Maximum numbers of databases, STables, tables are dependent only on the system resources.
|
||||
- The number of replicas can only be 1 or 3.
|
||||
- The maximum length of a username is 23 bytes.
|
||||
- The maximum length of a password is 15 bytes.
|
||||
- The maximum length of a password is 128 bytes.
|
||||
- The maximum number of rows depends on system resources.
|
||||
- The maximum number of vnodes in a database is 1024.
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ SHOW FUNCTIONS;
|
|||
|
||||
The function name specified when creating UDF can be used directly in SQL statements, just like builtin functions. For example:
|
||||
```sql
|
||||
SELECT X(c1,c2) FROM table/stable;
|
||||
SELECT bit_and(c1,c2) FROM table;
|
||||
```
|
||||
|
||||
The above SQL statement invokes function X for column c1 and c2. You can use query keywords like WHERE with user-defined functions.
|
||||
The above SQL statement invokes function X for column c1 and c2 on table. You can use query keywords like WHERE with user-defined functions.
|
||||
|
|
|
@ -26,14 +26,13 @@ Using REST connection can support a broader range of operating systems as it doe
|
|||
|
||||
TDengine version updates often add new features, and the connector versions in the list are the best-fit versions of the connector.
|
||||
|
||||
| **TDengine Versions** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** |
|
||||
| --------------------- | -------- | ---------- | ------------ | ------------- | --------------- | -------- |
|
||||
| **3.0.0.0 and later** | 3.0.0 | current version | 3.0 branch | 3.0.0 | 3.0.0 | current version |
|
||||
| **2.4.0.14 and up** | 2.0.38 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
|
||||
| **2.4.0.6 and up** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
|
||||
| **2.4.0.4 - 2.4.0.5** | 2.0.37 | current version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
|
||||
| **2.2.x.x ** | 2.0.36 | current version | master branch | n/a | 2.0.7 - 2.0.9 | current version |
|
||||
| **2.0.x.x ** | 2.0.34 | current version | master branch | n/a | 2.0.1 - 2.0.6 | current version |
|
||||
| **TDengine Versions** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** |
|
||||
| --------------------------- | -------------- | -------------- | -------------- | ------------- | --------------- | --------------- |
|
||||
| **3.0.0.0 and later** | 3.0.2 + | latest version | 3.0 branch | 3.0.0 | 3.0.0 | current version |
|
||||
| **2.4.0.14 and up ** | 2.0.38 | latest version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
|
||||
| **2.4.0.4 - 2.4.0.13 ** | 2.0.37 | latest version | develop branch | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | current version |
|
||||
| **2.2.x.x ** | 2.0.36 | latest version | master branch | n/a | 2.0.7 - 2.0.9 | current version |
|
||||
| **2.0.x.x ** | 2.0.34 | latest version | master branch | n/a | 2.0.1 - 2.0.6 | current version |
|
||||
|
||||
## Functional Features
|
||||
|
||||
|
|
|
@ -10,6 +10,10 @@ For TDengine 2.x installation packages by version, please visit [here](https://w
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.7
|
||||
|
||||
<Release type="tdengine" version="3.0.1.7" />
|
||||
|
||||
## 3.0.1.6
|
||||
|
||||
<Release type="tdengine" version="3.0.1.6" />
|
||||
|
|
|
@ -10,6 +10,10 @@ For other historical version installers, please visit [here](https://www.taosdat
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.9
|
||||
|
||||
<Release type="tools" version="2.2.9" />
|
||||
|
||||
## 2.2.7
|
||||
|
||||
<Release type="tools" version="2.2.7" />
|
||||
|
|
|
@ -4,6 +4,7 @@ from taos.tmq import *
|
|||
conn = taos.connect()
|
||||
|
||||
print("init")
|
||||
conn.execute("drop topic if exists topic_ctb_column")
|
||||
conn.execute("drop database if exists py_tmq")
|
||||
conn.execute("create database if not exists py_tmq vgroups 2")
|
||||
conn.select_db("py_tmq")
|
||||
|
@ -15,7 +16,6 @@ conn.execute("create table if not exists tb2 using stb1 tags(2)")
|
|||
conn.execute("create table if not exists tb3 using stb1 tags(3)")
|
||||
|
||||
print("create topic")
|
||||
conn.execute("drop topic if exists topic_ctb_column")
|
||||
conn.execute(
|
||||
"create topic if not exists topic_ctb_column as select ts, c1, c2, c3 from stb1"
|
||||
)
|
||||
|
|
|
@ -10,4 +10,4 @@ chrono = "0.4"
|
|||
serde = { version = "1", features = ["derive"] }
|
||||
tokio = { version = "1", features = ["rt", "macros", "rt-multi-thread"] }
|
||||
|
||||
taos = { version = "0.*" }
|
||||
taos = { version = "0.4.8" }
|
||||
|
|
|
@ -12,7 +12,10 @@ async fn main() -> anyhow::Result<()> {
|
|||
// bind table name and tags
|
||||
stmt.set_tbname_tags(
|
||||
"d1001",
|
||||
&[Value::VarChar("California.SanFransico".into()), Value::Int(2)],
|
||||
&[
|
||||
Value::VarChar("California.SanFransico".into()),
|
||||
Value::Int(2),
|
||||
],
|
||||
)?;
|
||||
// bind values.
|
||||
let values = vec![
|
||||
|
@ -30,9 +33,9 @@ async fn main() -> anyhow::Result<()> {
|
|||
ColumnView::from_floats(vec![0.33]),
|
||||
];
|
||||
stmt.bind(&values2)?;
|
||||
|
||||
|
||||
stmt.add_batch()?;
|
||||
|
||||
|
||||
// execute.
|
||||
let rows = stmt.execute()?;
|
||||
assert_eq!(rows, 2);
|
||||
|
|
|
@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> {
|
|||
// create super table
|
||||
format!("CREATE TABLE `meters` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, `phase` FLOAT) TAGS (`groupid` INT, `location` BINARY(24))"),
|
||||
// create topic for subscription
|
||||
format!("CREATE TOPIC tmq_meters with META AS DATABASE {db}")
|
||||
format!("CREATE TOPIC tmq_meters AS SELECT * FROM `meters`")
|
||||
])
|
||||
.await?;
|
||||
|
||||
|
@ -64,13 +64,9 @@ async fn main() -> anyhow::Result<()> {
|
|||
let mut consumer = tmq.build()?;
|
||||
consumer.subscribe(["tmq_meters"]).await?;
|
||||
|
||||
{
|
||||
let mut stream = consumer.stream();
|
||||
|
||||
while let Some((offset, message)) = stream.try_next().await? {
|
||||
// get information from offset
|
||||
|
||||
// the topic
|
||||
consumer
|
||||
.stream()
|
||||
.try_for_each(|(offset, message)| async {
|
||||
let topic = offset.topic();
|
||||
// the vgroup id, like partition id in kafka.
|
||||
let vgroup_id = offset.vgroup_id();
|
||||
|
@ -78,20 +74,14 @@ async fn main() -> anyhow::Result<()> {
|
|||
|
||||
if let Some(data) = message.into_data() {
|
||||
while let Some(block) = data.fetch_raw_block().await? {
|
||||
// one block for one table, get table name if needed
|
||||
let name = block.table_name();
|
||||
let records: Vec<Record> = block.deserialize().try_collect()?;
|
||||
println!(
|
||||
"** table: {}, got {} records: {:#?}\n",
|
||||
name.unwrap(),
|
||||
records.len(),
|
||||
records
|
||||
);
|
||||
println!("** read {} records: {:#?}\n", records.len(), records);
|
||||
}
|
||||
}
|
||||
consumer.commit(offset).await?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.await?;
|
||||
|
||||
consumer.unsubscribe().await;
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ async fn main() -> anyhow::Result<()> {
|
|||
let dsn = "ws://";
|
||||
let taos = TaosBuilder::from_dsn(dsn)?.build()?;
|
||||
|
||||
|
||||
taos.exec_many([
|
||||
"DROP DATABASE IF EXISTS power",
|
||||
"CREATE DATABASE power",
|
||||
|
|
|
@ -18,7 +18,18 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
||||
```
|
||||
|
||||
### 加入 TDengine 官方社区
|
||||
## 学习 TDengine 知识地图
|
||||
|
||||
TDengine 知识地图中涵盖了 TDengine 的各种知识点,揭示了各概念实体之间的调用关系和数据流向。学习和了解 TDengine 知识地图有助于你快速掌握 TDengine 的知识体系。
|
||||
|
||||
<figure>
|
||||
<center>
|
||||
<a href="pathname:///img/tdengine-map.svg" target="_blank"><img src="/img/tdengine-map.svg" width="80%" /></a>
|
||||
<figcaption>图 1. TDengine 知识地图</figcaption>
|
||||
</center>
|
||||
</figure>
|
||||
|
||||
## 加入 TDengine 官方社区
|
||||
|
||||
微信扫描以下二维码,学习了解 TDengine 的最新技术,与大家共同交流物联网大数据技术应用、TDengine 使用问题和技巧等话题。
|
||||
|
||||
|
|
|
@ -205,13 +205,13 @@ typedef struct SUdfInterBuf {
|
|||
|
||||
用户定义函数的 C 语言源代码无法直接被 TDengine 系统使用,而是需要先编译为 动态链接库,之后才能载入 TDengine 系统。
|
||||
|
||||
例如,按照上一章节描述的规则准备好了用户定义函数的源代码 add_one.c,以 Linux 为例可以执行如下指令编译得到动态链接库文件:
|
||||
例如,按照上一章节描述的规则准备好了用户定义函数的源代码 bit_and.c,以 Linux 为例可以执行如下指令编译得到动态链接库文件:
|
||||
|
||||
```bash
|
||||
gcc -g -O0 -fPIC -shared add_one.c -o add_one.so
|
||||
gcc -g -O0 -fPIC -shared bit_and.c -o libbitand.so
|
||||
```
|
||||
|
||||
这样就准备好了动态链接库 add_one.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。
|
||||
这样就准备好了动态链接库 libbitand.so 文件,可以供后文创建 UDF 时使用了。为了保证可靠的系统运行,编译器 GCC 推荐使用 7.5 及以上版本。
|
||||
|
||||
## 管理和使用UDF
|
||||
编译好的UDF,还需要将其加入到系统才能被正常的SQL调用。关于如何管理和使用UDF,参见[UDF使用说明](../12-taos-sql/26-udf.md)
|
||||
|
|
|
@ -73,7 +73,95 @@ TDengine 客户端驱动的安装请参考 [安装指南](../#安装步骤)
|
|||
```c
|
||||
{{#include examples/c/demo.c}}
|
||||
```
|
||||
格式化输出不同类型字段函数 taos_print_row
|
||||
```c
|
||||
int taos_print_row(char *str, TAOS_ROW row, TAOS_FIELD *fields, int num_fields) {
|
||||
int32_t len = 0;
|
||||
for (int i = 0; i < num_fields; ++i) {
|
||||
if (i > 0) {
|
||||
str[len++] = ' ';
|
||||
}
|
||||
|
||||
if (row[i] == NULL) {
|
||||
len += sprintf(str + len, "%s", TSDB_DATA_NULL_STR);
|
||||
continue;
|
||||
}
|
||||
|
||||
switch (fields[i].type) {
|
||||
case TSDB_DATA_TYPE_TINYINT:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UTINYINT:
|
||||
len += sprintf(str + len, "%u", *((uint8_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_SMALLINT:
|
||||
len += sprintf(str + len, "%d", *((int16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_USMALLINT:
|
||||
len += sprintf(str + len, "%u", *((uint16_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_INT:
|
||||
len += sprintf(str + len, "%d", *((int32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UINT:
|
||||
len += sprintf(str + len, "%u", *((uint32_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BIGINT:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
len += sprintf(str + len, "%" PRIu64, *((uint64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
float fv = 0;
|
||||
fv = GET_FLOAT_VAL(row[i]);
|
||||
len += sprintf(str + len, "%f", fv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_DOUBLE: {
|
||||
double dv = 0;
|
||||
dv = GET_DOUBLE_VAL(row[i]);
|
||||
len += sprintf(str + len, "%lf", dv);
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_NCHAR: {
|
||||
int32_t charLen = varDataLen((char *)row[i] - VARSTR_HEADER_SIZE);
|
||||
if (fields[i].type == TSDB_DATA_TYPE_BINARY) {
|
||||
assert(charLen <= fields[i].bytes && charLen >= 0);
|
||||
} else {
|
||||
assert(charLen <= fields[i].bytes * TSDB_NCHAR_SIZE && charLen >= 0);
|
||||
}
|
||||
|
||||
memcpy(str + len, row[i], charLen);
|
||||
len += charLen;
|
||||
} break;
|
||||
|
||||
case TSDB_DATA_TYPE_TIMESTAMP:
|
||||
len += sprintf(str + len, "%" PRId64, *((int64_t *)row[i]));
|
||||
break;
|
||||
|
||||
case TSDB_DATA_TYPE_BOOL:
|
||||
len += sprintf(str + len, "%d", *((int8_t *)row[i]));
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
str[len] = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
### 异步查询示例
|
||||
|
|
|
@ -26,14 +26,13 @@ TDengine 提供了丰富的应用程序开发接口,为了便于用户快速
|
|||
|
||||
TDengine 版本更新往往会增加新的功能特性,列表中的连接器版本为连接器最佳适配版本。
|
||||
|
||||
| **TDengine 版本** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** |
|
||||
| --------------------- | -------- | ---------- | ------------ | ------------- | --------------- | -------- |
|
||||
| **3.0.0.0 及以上** | 3.0.0 | 当前版本 | 3.0 分支 | 3.0.0 | 3.0.0 | 当前版本 |
|
||||
| **2.4.0.14 及以上** | 2.0.38 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 |
|
||||
| **2.4.0.6 及以上** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 |
|
||||
| **2.4.0.4 - 2.4.0.5** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 |
|
||||
| **2.2.x.x ** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 |
|
||||
| **2.0.x.x ** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 |
|
||||
| **TDengine 版本** | **Java** | **Python** | **Go** | **C#** | **Node.js** | **Rust** |
|
||||
| ---------------------- | --------- | ---------- | ------------ | ------------- | --------------- | -------- |
|
||||
| **3.0.0.0 及以上** | 3.0.2以上 | 当前版本 | 3.0 分支 | 3.0.0 | 3.0.0 | 当前版本 |
|
||||
| **2.4.0.14 及以上** | 2.0.38 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 |
|
||||
| **2.4.0.4 - 2.4.0.13** | 2.0.37 | 当前版本 | develop 分支 | 1.0.2 - 1.0.6 | 2.0.10 - 2.0.12 | 当前版本 |
|
||||
| **2.2.x.x ** | 2.0.36 | 当前版本 | master 分支 | n/a | 2.0.7 - 2.0.9 | 当前版本 |
|
||||
| **2.0.x.x ** | 2.0.34 | 当前版本 | master 分支 | n/a | 2.0.1 - 2.0.6 | 当前版本 |
|
||||
|
||||
## 功能特性
|
||||
|
||||
|
|
|
@ -302,7 +302,7 @@ SELECT TIMEZONE();
|
|||
### 语法
|
||||
|
||||
```txt
|
||||
WHERE (column|tbname) **match/MATCH/nmatch/NMATCH** _regex_
|
||||
WHERE (column|tbname) match/MATCH/nmatch/NMATCH _regex_
|
||||
```
|
||||
|
||||
### 正则表达式规范
|
||||
|
|
|
@ -24,19 +24,19 @@ description: 合法字符集和命名中的限制规则
|
|||
|
||||
## 一般限制
|
||||
|
||||
- 数据库名最大长度为 32
|
||||
- 表名最大长度为 192,不包括数据库名前缀和分隔符
|
||||
- 数据库名最大长度为 64 字节
|
||||
- 表名最大长度为 192 字节,不包括数据库名前缀和分隔符
|
||||
- 每行数据最大长度 48KB (注意:数据行内每个 BINARY/NCHAR 类型的列还会额外占用 2 个字节的存储位置)
|
||||
- 列名最大长度为 64
|
||||
- 列名最大长度为 64 字节
|
||||
- 最多允许 4096 列,最少需要 2 列,第一列必须是时间戳。
|
||||
- 标签名最大长度为 64
|
||||
- 标签名最大长度为 64 字节
|
||||
- 最多允许 128 个,至少要有 1 个标签,一个表中标签值的总长度不超过 16KB
|
||||
- SQL 语句最大长度 1048576 个字符
|
||||
- SELECT 语句的查询结果,最多允许返回 4096 列(语句中的函数调用可能也会占用一些列空间),超限时需要显式指定较少的返回数据列,以避免语句执行报错
|
||||
- 库的数目,超级表的数目、表的数目,系统不做限制,仅受系统资源限制
|
||||
- 数据库的副本数只能设置为 1 或 3
|
||||
- 用户名的最大长度是 23 个字节
|
||||
- 用户密码的最大长度是 15 个字节
|
||||
- 用户名的最大长度是 23 字节
|
||||
- 用户密码的最大长度是 128 字节
|
||||
- 总数据行数取决于可用资源
|
||||
- 单个数据库的虚拟结点数上限为 1024
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ SHOW FUNCTIONS;
|
|||
|
||||
在 SQL 指令中,可以直接以在系统中创建 UDF 时赋予的函数名来调用用户定义函数。例如:
|
||||
```sql
|
||||
SELECT X(c1,c2) FROM table/stable;
|
||||
SELECT bit_and(c1,c2) FROM table;
|
||||
```
|
||||
|
||||
表示对名为 c1, c2 的数据列调用名为 X 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
|
||||
表示对表 table 上名为 c1, c2 的数据列调用名为 bit_and 的用户定义函数。SQL 指令中用户定义函数可以配合 WHERE 等查询特性来使用。
|
||||
|
|
|
@ -10,6 +10,10 @@ TDengine 2.x 各版本安装包请访问[这里](https://www.taosdata.com/all-do
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 3.0.1.7
|
||||
|
||||
<Release type="tdengine" version="3.0.1.7" />
|
||||
|
||||
## 3.0.1.6
|
||||
|
||||
<Release type="tdengine" version="3.0.1.6" />
|
||||
|
|
|
@ -10,6 +10,10 @@ taosTools 各版本安装包下载链接如下:
|
|||
|
||||
import Release from "/components/ReleaseV3";
|
||||
|
||||
## 2.2.9
|
||||
|
||||
<Release type="tools" version="2.2.9" />
|
||||
|
||||
## 2.2.7
|
||||
|
||||
<Release type="tools" version="2.2.7" />
|
||||
|
|
|
@ -90,6 +90,33 @@ static FORCE_INLINE bool colDataIsNull_s(const SColumnInfoData* pColumnInfoData,
|
|||
}
|
||||
}
|
||||
|
||||
static FORCE_INLINE bool colDataIsNNull_s(const SColumnInfoData* pColumnInfoData, int32_t startIndex,
|
||||
uint32_t nRows) {
|
||||
if (!pColumnInfoData->hasNull) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||
for (int32_t i = startIndex; i < nRows; ++i) {
|
||||
if (!colDataIsNull_var(pColumnInfoData, i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (pColumnInfoData->nullbitmap == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int32_t i = startIndex; i < nRows; ++i) {
|
||||
if (!colDataIsNull_f(pColumnInfoData->nullbitmap, i)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static FORCE_INLINE bool colDataIsNull(const SColumnInfoData* pColumnInfoData, uint32_t totalRows, uint32_t row,
|
||||
SColumnDataAgg* pColAgg) {
|
||||
if (!pColumnInfoData->hasNull) {
|
||||
|
|
|
@ -27,17 +27,17 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct SBuffer SBuffer;
|
||||
typedef struct SSchema SSchema;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
typedef struct SValue SValue;
|
||||
typedef struct SColVal SColVal;
|
||||
typedef struct STSRow2 STSRow2;
|
||||
typedef struct STSRowBuilder STSRowBuilder;
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
typedef struct SColData SColData;
|
||||
typedef struct SBuffer SBuffer;
|
||||
typedef struct SSchema SSchema;
|
||||
typedef struct STColumn STColumn;
|
||||
typedef struct STSchema STSchema;
|
||||
typedef struct SValue SValue;
|
||||
typedef struct SColVal SColVal;
|
||||
typedef struct SRow SRow;
|
||||
typedef struct SRowIter SRowIter;
|
||||
typedef struct STagVal STagVal;
|
||||
typedef struct STag STag;
|
||||
typedef struct SColData SColData;
|
||||
|
||||
#define HAS_NONE ((uint8_t)0x1)
|
||||
#define HAS_NULL ((uint8_t)0x2)
|
||||
|
@ -68,13 +68,10 @@ struct SBuffer {
|
|||
void tBufferDestroy(SBuffer *pBuffer);
|
||||
int32_t tBufferInit(SBuffer *pBuffer, int64_t size);
|
||||
int32_t tBufferPut(SBuffer *pBuffer, const void *pData, int64_t nData);
|
||||
int32_t tBufferReserve(SBuffer *pBuffer, int64_t nData, void **ppData);
|
||||
|
||||
// STSchema ================================
|
||||
int32_t tTSchemaCreate(int32_t sver, SSchema *pSchema, int32_t nCols, STSchema **ppTSchema);
|
||||
void tTSchemaDestroy(STSchema *pTSchema);
|
||||
|
||||
// SValue ================================
|
||||
static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
|
||||
void tDestroyTSchema(STSchema *pTSchema);
|
||||
|
||||
// SColVal ================================
|
||||
#define CV_FLAG_VALUE ((int8_t)0x0)
|
||||
|
@ -89,26 +86,14 @@ static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type);
|
|||
#define COL_VAL_IS_NULL(CV) ((CV)->flag == CV_FLAG_NULL)
|
||||
#define COL_VAL_IS_VALUE(CV) ((CV)->flag == CV_FLAG_VALUE)
|
||||
|
||||
// STSRow2 ================================
|
||||
#define TSROW_LEN(PROW, V) tGetI32v((uint8_t *)(PROW)->data, (V) ? &(V) : NULL)
|
||||
#define TSROW_SVER(PROW, V) tGetI32v((PROW)->data + TSROW_LEN(PROW, NULL), (V) ? &(V) : NULL)
|
||||
// SRow ================================
|
||||
int32_t tRowBuild(SArray *aColVal, STSchema *pTSchema, SBuffer *pBuffer);
|
||||
void tRowGet(SRow *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||
|
||||
int32_t tTSRowNew(STSRowBuilder *pBuilder, SArray *pArray, STSchema *pTSchema, STSRow2 **ppRow);
|
||||
int32_t tTSRowClone(const STSRow2 *pRow, STSRow2 **ppRow);
|
||||
void tTSRowFree(STSRow2 *pRow);
|
||||
void tTSRowGet(STSRow2 *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||
int32_t tTSRowToArray(STSRow2 *pRow, STSchema *pTSchema, SArray **ppArray);
|
||||
int32_t tPutTSRow(uint8_t *p, STSRow2 *pRow);
|
||||
int32_t tGetTSRow(uint8_t *p, STSRow2 **ppRow);
|
||||
|
||||
// STSRowBuilder ================================
|
||||
#define tsRowBuilderInit() ((STSRowBuilder){0})
|
||||
#define tsRowBuilderClear(B) \
|
||||
do { \
|
||||
if ((B)->pBuf) { \
|
||||
taosMemoryFree((B)->pBuf); \
|
||||
} \
|
||||
} while (0)
|
||||
// SRowIter ================================
|
||||
int32_t tRowIterOpen(SRow *pRow, STSchema *pTSchema, SRowIter **ppIter);
|
||||
void tRowIterClose(SRowIter **ppIter);
|
||||
SColVal *tRowIterNext(SRowIter *pIter);
|
||||
|
||||
// STag ================================
|
||||
int32_t tTagNew(SArray *pArray, int32_t version, int8_t isJson, STag **ppTag);
|
||||
|
@ -147,29 +132,17 @@ struct STSchema {
|
|||
int32_t numOfCols;
|
||||
int32_t version;
|
||||
int32_t flen;
|
||||
int32_t vlen;
|
||||
int32_t tlen;
|
||||
STColumn columns[];
|
||||
};
|
||||
|
||||
#define TSROW_HAS_NONE ((uint8_t)0x1)
|
||||
#define TSROW_HAS_NULL ((uint8_t)0x2U)
|
||||
#define TSROW_HAS_VAL ((uint8_t)0x4U)
|
||||
#define TSROW_KV_SMALL ((uint8_t)0x10U)
|
||||
#define TSROW_KV_MID ((uint8_t)0x20U)
|
||||
#define TSROW_KV_BIG ((uint8_t)0x40U)
|
||||
#pragma pack(push, 1)
|
||||
struct STSRow2 {
|
||||
TSKEY ts;
|
||||
uint8_t flags;
|
||||
uint8_t data[];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct STSRowBuilder {
|
||||
// STSRow2 tsRow;
|
||||
int32_t szBuf;
|
||||
uint8_t *pBuf;
|
||||
struct SRow {
|
||||
uint8_t flag;
|
||||
uint8_t rsv;
|
||||
uint16_t sver;
|
||||
uint32_t len;
|
||||
TSKEY ts;
|
||||
uint8_t data[];
|
||||
};
|
||||
|
||||
struct SValue {
|
||||
|
@ -258,37 +231,17 @@ typedef struct {
|
|||
int32_t nCols;
|
||||
schema_ver_t version;
|
||||
uint16_t flen;
|
||||
int32_t vlen;
|
||||
int32_t tlen;
|
||||
STColumn *columns;
|
||||
} STSchemaBuilder;
|
||||
|
||||
// use 2 bits for bitmap(default: STSRow/sub block)
|
||||
#define TD_VTYPE_BITS 2
|
||||
#define TD_VTYPE_PARTS 4 // PARTITIONS: 1 byte / 2 bits
|
||||
#define TD_VTYPE_OPTR 3 // OPERATOR: 4 - 1, utilize to get remainder
|
||||
#define TD_BITMAP_BYTES(cnt) (((cnt) + TD_VTYPE_OPTR) >> 2)
|
||||
|
||||
// use 1 bit for bitmap(super block)
|
||||
#define TD_VTYPE_BITS_I 1
|
||||
#define TD_VTYPE_PARTS_I 8 // PARTITIONS: 1 byte / 1 bit
|
||||
#define TD_VTYPE_OPTR_I 7 // OPERATOR: 8 - 1, utilize to get remainder
|
||||
#define TD_BITMAP_BYTES_I(cnt) (((cnt) + TD_VTYPE_OPTR_I) >> 3)
|
||||
|
||||
int32_t tdInitTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||
void tdDestroyTSchemaBuilder(STSchemaBuilder *pBuilder);
|
||||
void tdResetTSchemaBuilder(STSchemaBuilder *pBuilder, schema_ver_t version);
|
||||
int32_t tdAddColToSchema(STSchemaBuilder *pBuilder, int8_t type, int8_t flags, col_id_t colId, col_bytes_t bytes);
|
||||
STSchema *tdGetSchemaFromBuilder(STSchemaBuilder *pBuilder);
|
||||
|
||||
static FORCE_INLINE int32_t tGetValue(uint8_t *p, SValue *pValue, int8_t type) {
|
||||
if (IS_VAR_DATA_TYPE(type)) {
|
||||
return tGetBinary(p, &pValue->pData, pValue ? &pValue->nData : NULL);
|
||||
} else {
|
||||
memcpy(&pValue->val, p, tDataTypes[type].bytes);
|
||||
return tDataTypes[type].bytes;
|
||||
}
|
||||
}
|
||||
STSchema *tBuildTSchema(SSchema *aSchema, int32_t numOfCols, int32_t version);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1615,15 +1615,20 @@ typedef struct SSubQueryMsg {
|
|||
uint64_t taskId;
|
||||
int64_t refId;
|
||||
int32_t execId;
|
||||
int32_t msgMask;
|
||||
int8_t taskType;
|
||||
int8_t explain;
|
||||
int8_t needFetch;
|
||||
uint32_t sqlLen; // the query sql,
|
||||
uint32_t phyLen;
|
||||
int32_t msgMask;
|
||||
char msg[];
|
||||
uint32_t sqlLen;
|
||||
char *sql;
|
||||
uint32_t msgLen;
|
||||
char *msg;
|
||||
} SSubQueryMsg;
|
||||
|
||||
int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq);
|
||||
int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq);
|
||||
void tFreeSSubQueryMsg(SSubQueryMsg *pReq);
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
uint64_t sId;
|
||||
|
@ -1661,6 +1666,10 @@ typedef struct {
|
|||
int32_t execId;
|
||||
} SResFetchReq;
|
||||
|
||||
int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq);
|
||||
int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq);
|
||||
|
||||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
uint64_t sId;
|
||||
|
@ -1732,6 +1741,13 @@ typedef struct {
|
|||
int32_t execId;
|
||||
} STaskDropReq;
|
||||
|
||||
int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq);
|
||||
int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq);
|
||||
|
||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
||||
int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp);
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32_t code;
|
||||
} STaskDropRsp;
|
||||
|
@ -2935,6 +2951,10 @@ typedef struct {
|
|||
STqOffsetVal reqOffset;
|
||||
} SMqPollReq;
|
||||
|
||||
int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq);
|
||||
int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq);
|
||||
|
||||
|
||||
typedef struct {
|
||||
int32_t vgId;
|
||||
int64_t offset;
|
||||
|
@ -3169,8 +3189,7 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
SMsgHead header;
|
||||
int32_t msgNum;
|
||||
SBatchMsg msg[];
|
||||
SArray* pMsgs; //SArray<SBatchMsg>
|
||||
} SBatchReq;
|
||||
|
||||
typedef struct {
|
||||
|
@ -3179,17 +3198,40 @@ typedef struct {
|
|||
int32_t msgLen;
|
||||
int32_t rspCode;
|
||||
void* msg;
|
||||
} SBatchRspMsg;
|
||||
|
||||
typedef struct {
|
||||
SArray* pRsps; //SArray<SBatchRspMsg>
|
||||
} SBatchRsp;
|
||||
|
||||
static FORCE_INLINE void tFreeSBatchRsp(void* p) {
|
||||
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq);
|
||||
int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq);
|
||||
static FORCE_INLINE void tFreeSBatchReqMsg(void* msg) {
|
||||
if (NULL == msg) {
|
||||
return;
|
||||
}
|
||||
SBatchMsg* pMsg = (SBatchMsg*)msg;
|
||||
taosMemoryFree(pMsg->msg);
|
||||
}
|
||||
|
||||
int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);
|
||||
int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp);
|
||||
|
||||
static FORCE_INLINE void tFreeSBatchRspMsg(void* p) {
|
||||
if (NULL == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
SBatchRsp* pRsp = (SBatchRsp*)p;
|
||||
SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
|
||||
taosMemoryFree(pRsp->msg);
|
||||
}
|
||||
|
||||
int32_t tSerializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq);
|
||||
int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq);
|
||||
int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq);
|
||||
int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq);
|
||||
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -55,6 +55,14 @@ typedef struct STSRow {
|
|||
#define TD_ROW_TP 0x0U // default
|
||||
#define TD_ROW_KV 0x01U
|
||||
|
||||
#define TD_VTYPE_PARTS 4 // PARTITIONS: 1 byte / 2 bits
|
||||
#define TD_VTYPE_OPTR 3 // OPERATOR: 4 - 1, utilize to get remainder
|
||||
#define TD_BITMAP_BYTES(cnt) (((cnt) + TD_VTYPE_OPTR) >> 2)
|
||||
|
||||
#define TD_VTYPE_PARTS_I 8 // PARTITIONS: 1 byte / 1 bit
|
||||
#define TD_VTYPE_OPTR_I 7 // OPERATOR: 8 - 1, utilize to get remainder
|
||||
#define TD_BITMAP_BYTES_I(cnt) (((cnt) + TD_VTYPE_OPTR_I) >> 3)
|
||||
|
||||
/**
|
||||
* @brief value type
|
||||
* - for data from client input and STSRow in memory, 3 types of value none/null/norm available
|
||||
|
@ -244,7 +252,7 @@ int32_t tdGetBitmapValTypeI(const void *pBitmap, int16_t colIdx, TDRowValT *pVal
|
|||
*/
|
||||
static FORCE_INLINE void *tdGetBitmapAddrTp(STSRow *pRow, uint32_t flen) {
|
||||
// The primary TS key is stored separatedly.
|
||||
return POINTER_SHIFT(TD_ROW_DATA(pRow), flen - sizeof(TSKEY));
|
||||
return POINTER_SHIFT(TD_ROW_DATA(pRow), flen);
|
||||
// return POINTER_SHIFT(pRow->ts, flen);
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ typedef struct SVariant {
|
|||
int64_t i;
|
||||
uint64_t u;
|
||||
double d;
|
||||
float f;
|
||||
char *pz;
|
||||
TdUcs4 *ucs4;
|
||||
SArray *arr; // only for 'in' query to hold value list, not value for a field
|
||||
|
@ -47,7 +48,7 @@ void taosVariantAssign(SVariant *pDst, const SVariant *pSrc);
|
|||
|
||||
int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2);
|
||||
|
||||
char *taosVariantGet(SVariant *pVar, int32_t type);
|
||||
char *taosVariantGet(SVariant *pVar, int32_t type);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -171,6 +171,7 @@ typedef struct SExchangeLogicNode {
|
|||
SLogicNode node;
|
||||
int32_t srcStartGroupId;
|
||||
int32_t srcEndGroupId;
|
||||
bool seqRecvData;
|
||||
} SExchangeLogicNode;
|
||||
|
||||
typedef struct SMergeLogicNode {
|
||||
|
@ -416,6 +417,7 @@ typedef struct SExchangePhysiNode {
|
|||
int32_t srcEndGroupId;
|
||||
bool singleChannel;
|
||||
SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode
|
||||
bool seqRecvData;
|
||||
} SExchangePhysiNode;
|
||||
|
||||
typedef struct SMergePhysiNode {
|
||||
|
|
|
@ -351,7 +351,7 @@ typedef struct SVgDataBlocks {
|
|||
SVgroupInfo vg;
|
||||
int32_t numOfTables; // number of tables in current submit block
|
||||
uint32_t size;
|
||||
void* pData; // SMsgDesc + SSubmitReq + SSubmitBlk + ...
|
||||
void* pData; // SSubmitReq + SSubmitBlk + ...
|
||||
} SVgDataBlocks;
|
||||
|
||||
typedef void (*FFreeDataBlockHash)(SHashObj*);
|
||||
|
|
|
@ -27,16 +27,21 @@ typedef struct SStreamTask SStreamTask;
|
|||
|
||||
typedef bool (*state_key_cmpr_fn)(void* pKey1, void* pKey2);
|
||||
|
||||
// incremental state storage
|
||||
typedef struct {
|
||||
typedef struct STdbState {
|
||||
SStreamTask* pOwner;
|
||||
TDB* db;
|
||||
TTB* pStateDb;
|
||||
TTB* pFuncStateDb;
|
||||
TTB* pFillStateDb; // todo refactor
|
||||
TTB* pSessionStateDb;
|
||||
TTB* pParNameDb;
|
||||
TXN txn;
|
||||
int32_t number;
|
||||
} STdbState;
|
||||
|
||||
// incremental state storage
|
||||
typedef struct {
|
||||
STdbState* pTdbState;
|
||||
int32_t number;
|
||||
} SStreamState;
|
||||
|
||||
SStreamState* streamStateOpen(char* path, SStreamTask* pTask, bool specPath, int32_t szPage, int32_t pages);
|
||||
|
@ -44,6 +49,7 @@ void streamStateClose(SStreamState* pState);
|
|||
int32_t streamStateBegin(SStreamState* pState);
|
||||
int32_t streamStateCommit(SStreamState* pState);
|
||||
int32_t streamStateAbort(SStreamState* pState);
|
||||
void streamStateDestroy(SStreamState* pState);
|
||||
|
||||
typedef struct {
|
||||
TBC* pCur;
|
||||
|
@ -99,6 +105,9 @@ int32_t streamStateSeekLast(SStreamState* pState, SStreamStateCur* pCur);
|
|||
int32_t streamStateCurNext(SStreamState* pState, SStreamStateCur* pCur);
|
||||
int32_t streamStateCurPrev(SStreamState* pState, SStreamStateCur* pCur);
|
||||
|
||||
int32_t streamStatePutParName(SStreamState* pState, int64_t groupId, const char* tbname);
|
||||
int32_t streamStateGetParName(SStreamState* pState, int64_t groupId, void** pVal);
|
||||
|
||||
#if 0
|
||||
char* streamStateSessionDump(SStreamState* pState);
|
||||
#endif
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef struct SUpdateInfo {
|
|||
|
||||
SUpdateInfo *updateInfoInitP(SInterval *pInterval, int64_t watermark);
|
||||
SUpdateInfo *updateInfoInit(int64_t interval, int32_t precision, int64_t watermark);
|
||||
void updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol);
|
||||
TSKEY updateInfoFillBlockData(SUpdateInfo *pInfo, SSDataBlock *pBlock, int32_t primaryTsCol);
|
||||
bool updateInfoIsUpdated(SUpdateInfo *pInfo, uint64_t tableId, TSKEY ts);
|
||||
bool updateInfoIsTableInserted(SUpdateInfo *pInfo, int64_t tbUid);
|
||||
void updateInfoSetScanRange(SUpdateInfo *pInfo, STimeWindow *pWin, uint64_t groupId, uint64_t version);
|
||||
|
|
|
@ -36,13 +36,14 @@ extern "C" {
|
|||
#define SYNC_DEL_WAL_MS (1000 * 60)
|
||||
#define SYNC_ADD_QUORUM_COUNT 3
|
||||
#define SYNC_MNODE_LOG_RETENTION 10000
|
||||
#define SYNC_VNODE_LOG_RETENTION 100
|
||||
#define SYNC_VNODE_LOG_RETENTION 20
|
||||
#define SNAPSHOT_MAX_CLOCK_SKEW_MS 1000 * 10
|
||||
#define SNAPSHOT_WAIT_MS 1000 * 30
|
||||
|
||||
#define SYNC_MAX_RETRY_BACKOFF 5
|
||||
#define SYNC_LOG_REPL_RETRY_WAIT_MS 100
|
||||
#define SYNC_APPEND_ENTRIES_TIMEOUT_MS 10000
|
||||
#define SYNC_HEART_TIMEOUT_MS 1000 * 8
|
||||
|
||||
#define SYNC_MAX_BATCH_SIZE 1
|
||||
#define SYNC_INDEX_BEGIN 0
|
||||
|
|
|
@ -352,6 +352,7 @@ int32_t* taosGetErrno();
|
|||
#define TSDB_CODE_TDB_STB_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x061A)
|
||||
#define TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER TAOS_DEF_ERROR_CODE(0, 0x061B)
|
||||
#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x061C)
|
||||
#define TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE TAOS_DEF_ERROR_CODE(0, 0x061D)
|
||||
|
||||
// query
|
||||
#define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700)
|
||||
|
|
|
@ -490,6 +490,9 @@ enum {
|
|||
#define MAX_META_MSG_IN_BATCH 1048576
|
||||
#define MAX_META_BATCH_RSP_SIZE (1 * 1048576 * 1024)
|
||||
|
||||
// sort page size by default
|
||||
#define DEFAULT_PAGESIZE 4096
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -40,27 +40,32 @@ pipeline {
|
|||
choice(
|
||||
name: 'sourcePath',
|
||||
choices: ['nas','web'],
|
||||
description: 'choice which way to download the installation pacakge;web is Office Web and nas means taos nas server '
|
||||
description: 'Choice which way to download the installation pacakge;web is Office Web and nas means taos nas server '
|
||||
)
|
||||
choice(
|
||||
name: 'verMode',
|
||||
choices: ['all','community','enterprise'],
|
||||
description: 'Choice which types of package you want do check '
|
||||
)
|
||||
string (
|
||||
name:'version',
|
||||
defaultValue:'3.0.1.6',
|
||||
description: 'release version number,eg: 3.0.0.1 or 3.0.0.'
|
||||
defaultValue:'3.0.1.7',
|
||||
description: 'Release version number,eg: 3.0.0.1 or 3.0.0.'
|
||||
)
|
||||
string (
|
||||
name:'baseVersion',
|
||||
defaultValue:'3.0.1.6',
|
||||
description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1'
|
||||
defaultValue:'3.0.1.7',
|
||||
description: 'The number of baseVerison is generally not modified.Now it is 3.0.0.1'
|
||||
)
|
||||
string (
|
||||
name:'toolsVersion',
|
||||
defaultValue:'2.2.7',
|
||||
description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1'
|
||||
description: 'Release version number,eg:2.2.0'
|
||||
)
|
||||
string (
|
||||
name:'toolsBaseVersion',
|
||||
defaultValue:'2.1.2',
|
||||
description: 'This number of baseVerison is generally not modified.Now it is 3.0.0.1'
|
||||
description: 'The number of baseVerison is generally not modified.Now it is 2.1.2'
|
||||
)
|
||||
}
|
||||
environment{
|
||||
|
@ -68,10 +73,10 @@ pipeline {
|
|||
TDINTERNAL_ROOT_DIR = '/var/lib/jenkins/workspace/TDinternal'
|
||||
TDENGINE_ROOT_DIR = '/var/lib/jenkins/workspace/TDinternal/community'
|
||||
BRANCH_NAME = '3.0'
|
||||
|
||||
TD_SERVER_TAR = "TDengine-server-${version}-Linux-x64.tar.gz"
|
||||
|
||||
TD_SERVER_TAR = "${preServerPackag}-${version}-Linux-x64.tar.gz"
|
||||
BASE_TD_SERVER_TAR = "TDengine-server-${baseVersion}-Linux-x64.tar.gz"
|
||||
|
||||
|
||||
TD_SERVER_ARM_TAR = "TDengine-server-${version}-Linux-arm64.tar.gz"
|
||||
BASE_TD_SERVER_ARM_TAR = "TDengine-server-${baseVersion}-Linux-arm64.tar.gz"
|
||||
|
||||
|
@ -108,19 +113,28 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
bash testpackage.sh -f server -m community -f server -l true -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
bash testpackage.sh -f server -m community -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t deb
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
@ -131,22 +145,30 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_DEB} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
dpkg -r tdengine
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m community -f server -l true -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m community -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t deb
|
||||
python3 checkPackageRuning.py
|
||||
dpkg -r tdengine
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -156,19 +178,28 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m community -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m community -f server -l true -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
bash testpackage.sh -f server -m community -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t rpm
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
@ -179,21 +210,30 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_TAR} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_LITE_TAR} ${version} ${BASE_TD_SERVER_LITE_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
bash testpackage.sh -f server -m community -f server -l true -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
'''
|
||||
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_RPM} ${version} ${BASE_TD_SERVER_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
bash testpackage.sh -f server -m community -f server -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t rpm
|
||||
python3 checkPackageRuning.py
|
||||
sudo rpm -e tdengine
|
||||
'''
|
||||
'''
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -203,9 +243,16 @@ pipeline {
|
|||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sync_source("${BRANCH_NAME}")
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_SERVER_ARM_TAR} ${version} ${BASE_TD_SERVER_ARM_TAR} ${baseVersion} server ${sourcePath}
|
||||
python3 checkPackageRuning.py
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f server -l false -c arm64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
@ -219,8 +266,16 @@ pipeline {
|
|||
steps {
|
||||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_TAR} ${version} ${BASE_TD_CLIENT_TAR} ${baseVersion} client ${sourcePath}
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f client -l false -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
python3 checkPackageRuning.py 192.168.0.21
|
||||
'''
|
||||
}
|
||||
|
@ -231,8 +286,10 @@ pipeline {
|
|||
steps {
|
||||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sh '''
|
||||
verModeList=community
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_LITE_TAR} ${version} ${BASE_TD_CLIENT_LITE_TAR} ${baseVersion} client ${sourcePath}
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f client -l true -c x64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
python3 checkPackageRuning.py 192.168.0.24
|
||||
'''
|
||||
}
|
||||
|
@ -245,8 +302,16 @@ pipeline {
|
|||
steps {
|
||||
timeout(time: 30, unit: 'MINUTES'){
|
||||
sh '''
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh ${TD_CLIENT_ARM_TAR} ${version} ${BASE_TD_CLIENT_ARM_TAR} ${baseVersion} client ${sourcePath}
|
||||
if [ "${verMode}" = "all" ];then
|
||||
verMode="community enterprise"
|
||||
fi
|
||||
verModeList=${verMode}
|
||||
for verModeSin in ${verModeList}
|
||||
do
|
||||
cd ${TDENGINE_ROOT_DIR}/packaging
|
||||
bash testpackage.sh -f server -m ${verModeSin} -f client -l false -c arm64 -v ${version} -o ${baseVersion} -s ${sourcePath} -t tar
|
||||
python3 checkPackageRuning.py
|
||||
done
|
||||
python3 checkPackageRuning.py 192.168.0.21
|
||||
'''
|
||||
}
|
||||
|
|
|
@ -73,10 +73,10 @@
|
|||
# compressColData -1
|
||||
|
||||
# system time zone
|
||||
# timezone Asia/Shanghai (CST, +0800)
|
||||
# timezone UTC-8
|
||||
|
||||
# system time zone (for windows 10)
|
||||
# timezone UTC-8
|
||||
# timezone Asia/Shanghai (CST, +0800)
|
||||
|
||||
# system locale
|
||||
# locale en_US.UTF-8
|
||||
|
@ -179,4 +179,4 @@
|
|||
# metaDebugFlag 131
|
||||
|
||||
# generate core file when service crash
|
||||
# enableCoreFile 1
|
||||
# enableCoreFile 1
|
||||
|
|
|
@ -7,6 +7,9 @@ ARG dirName
|
|||
ARG cpuType
|
||||
RUN echo ${pkgFile} && echo ${dirName}
|
||||
|
||||
RUN apt update
|
||||
RUN apt install -y curl
|
||||
|
||||
COPY ${pkgFile} /root/
|
||||
ENV TINI_VERSION v0.19.0
|
||||
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${cpuType} /tini
|
||||
|
|
|
@ -1,16 +1,161 @@
|
|||
#!/bin/bash
|
||||
|
||||
TAOS_RUN_TAOSBENCHMARK_TEST_ONCE=0
|
||||
#ADMIN_URL=${ADMIN_URL:-http://172.26.10.84:10001}
|
||||
TAOSD_STARTUP_TIMEOUT_SECOND=${TAOSD_STARTUP_TIMEOUT_SECOND:-160}
|
||||
TAOS_TIMEOUT_SECOND=${TAOS_TIMEOUT_SECOND:-5}
|
||||
BACKUP_CORE_FOLDER=/var/log/corefile
|
||||
ALERT_URL=app/system/alert/add
|
||||
|
||||
echo "ADMIN_URL: ${ADMIN_URL}"
|
||||
echo "TAOS_TIMEOUT_SECOND: ${TAOS_TIMEOUT_SECOND}"
|
||||
|
||||
function set_service_state() {
|
||||
#echo "set service state: $1, $2"
|
||||
service_state="$1"
|
||||
service_msg="$2"
|
||||
}
|
||||
set_service_state "init" "ok"
|
||||
app_name=`hostname |cut -d\- -f1`
|
||||
|
||||
function check_taosd() {
|
||||
timeout $TAOS_TIMEOUT_SECOND taos -s "show databases;" >/dev/null
|
||||
local ret=$?
|
||||
if [ $ret -ne 0 ]; then
|
||||
echo "`date` check taosd error $ret"
|
||||
if [ "x$1" != "xignore" ]; then
|
||||
set_service_state "error" "taos check failed $ret"
|
||||
fi
|
||||
else
|
||||
set_service_state "ready" "ok"
|
||||
fi
|
||||
}
|
||||
function post_error_msg() {
|
||||
if [ ! -z "${ADMIN_URL}" ]; then
|
||||
taos_version=`taos --version`
|
||||
echo "app_name: ${app_name}"
|
||||
echo "service_state: ${service_state}"
|
||||
echo "`date` service_msg: ${service_msg}"
|
||||
echo "${taos_version}"
|
||||
curl --connect-timeout 10 --max-time 20 -X POST -H "Content-Type: application/json" \
|
||||
-d"{\"appName\":\"${app_name}\",\
|
||||
\"alertLevel\":\"${service_state}\",\
|
||||
\"taosVersion\":\"${taos_version}\",\
|
||||
\"alertMsg\":\"${service_msg}\"}" \
|
||||
${ADMIN_URL}/${ALERT_URL}
|
||||
fi
|
||||
}
|
||||
function check_taosd_exit_type() {
|
||||
local core_pattern=`cat /proc/sys/kernel/core_pattern`
|
||||
echo "$core_pattern" | grep -q "^/"
|
||||
if [ $? -eq 0 ]; then
|
||||
core_folder=`dirname $core_pattern`
|
||||
core_prefix=`basename $core_pattern | sed "s/%.*//"`
|
||||
else
|
||||
core_folder=`pwd`
|
||||
core_prefix="$core_pattern"
|
||||
fi
|
||||
local core_files=`ls $core_folder | grep "^${core_prefix}"`
|
||||
if [ ! -z "$core_files" ]; then
|
||||
# move core files to another folder
|
||||
mkdir -p ${BACKUP_CORE_FOLDER}
|
||||
cp ${core_folder}/${core_prefix}* ${BACKUP_CORE_FOLDER}/
|
||||
rm -f ${core_folder}/${core_prefix}*
|
||||
set_service_state "error" "taosd exit with core file"
|
||||
else
|
||||
set_service_state "error" "taosd exit without core file"
|
||||
fi
|
||||
}
|
||||
disk_usage_level=(60 80 99)
|
||||
current_disk_level=0
|
||||
disk_state="ok"
|
||||
disk_msg="ok"
|
||||
get_usage_ok="yes"
|
||||
function post_disk_error_msg() {
|
||||
if [ ! -z "${ADMIN_URL}" ]; then
|
||||
taos_version=`taos --version`
|
||||
echo "app_name: ${app_name}"
|
||||
echo "disk_state: ${disk_state}"
|
||||
echo "`date` disk_msg: ${disk_msg}"
|
||||
echo "${taos_version}"
|
||||
curl --connect-timeout 10 --max-time 20 -X POST -H "Content-Type: application/json" \
|
||||
-d"{\"appName\":\"${app_name}\",\
|
||||
\"alertLevel\":\"${disk_state}\",\
|
||||
\"taosVersion\":\"${taos_version}\",\
|
||||
\"alertMsg\":\"${disk_msg}\"}" \
|
||||
${ADMIN_URL}/${ALERT_URL}
|
||||
fi
|
||||
}
|
||||
function check_disk() {
|
||||
local folder=`cat /etc/taos/taos.cfg|grep -v "^#"|grep dataDir|awk '{print $NF}'`
|
||||
if [ -z "$folder" ]; then
|
||||
folder="/var/lib/taos"
|
||||
fi
|
||||
local mount_point="$folder"
|
||||
local usage=""
|
||||
while [ -z "$usage" ]; do
|
||||
usage=`df -h|grep -w "${mount_point}"|awk '{print $5}'|grep -v Use|sed "s/%$//"`
|
||||
if [ "x${mount_point}" = "x/" ]; then
|
||||
break
|
||||
fi
|
||||
mount_point=`dirname ${mount_point}`
|
||||
done
|
||||
if [ -z "$usage" ]; then
|
||||
disk_state="error"
|
||||
disk_msg="cannot get disk usage"
|
||||
if [ "$get_usage_ok" = "yes" ]; then
|
||||
post_disk_error_msg
|
||||
get_usage_ok="no"
|
||||
fi
|
||||
else
|
||||
get_usage_ok="yes"
|
||||
local current_level=0
|
||||
for level in ${disk_usage_level[*]}; do
|
||||
if [ ${usage} -ge ${level} ]; then
|
||||
disk_state="error"
|
||||
disk_msg="disk usage over ${level}%"
|
||||
current_level=${level}
|
||||
fi
|
||||
done
|
||||
if [ ${current_level} -gt ${current_disk_level} ]; then
|
||||
post_disk_error_msg
|
||||
elif [ ${current_level} -lt ${current_disk_level} ]; then
|
||||
echo "disk usage reduced from ${current_disk_level} to ${current_level}"
|
||||
fi
|
||||
current_disk_level=${current_level}
|
||||
fi
|
||||
}
|
||||
function run_taosd() {
|
||||
taosd
|
||||
set_service_state "error" "taosd exit"
|
||||
# post error msg
|
||||
# check crash or OOM
|
||||
check_taosd_exit_type
|
||||
post_error_msg
|
||||
}
|
||||
function print_service_state_change() {
|
||||
if [ "x$1" != "x${service_state}" ]; then
|
||||
echo "`date` service state: ${service_state}, ${service_msg}"
|
||||
fi
|
||||
}
|
||||
taosd_start_time=`date +%s`
|
||||
while ((1))
|
||||
do
|
||||
check_disk
|
||||
# echo "outer loop: $a"
|
||||
sleep 10
|
||||
output=`taos -k`
|
||||
status=${output:0:1}
|
||||
output=`timeout $TAOS_TIMEOUT_SECOND taos -k`
|
||||
if [ -z "${output}" ]; then
|
||||
echo "`date` taos -k error"
|
||||
status=""
|
||||
else
|
||||
status=${output:0:1}
|
||||
fi
|
||||
# echo $output
|
||||
# echo $status
|
||||
if [ "$status"x = "0"x ]
|
||||
then
|
||||
taosd &
|
||||
# taosd_start_time=`date +%s`
|
||||
run_taosd &
|
||||
fi
|
||||
# echo "$status"x "$TAOS_RUN_TAOSBENCHMARK_TEST"x "$TAOS_RUN_TAOSBENCHMARK_TEST_ONCE"x
|
||||
if [ "$status"x = "2"x ] && [ "$TAOS_RUN_TAOSBENCHMARK_TEST"x = "1"x ] && [ "$TAOS_RUN_TAOSBENCHMARK_TEST_ONCE"x = "0"x ]
|
||||
|
@ -24,13 +169,37 @@ do
|
|||
taos -s "select stable_name from information_schema.ins_stables where db_name = 'test';"|grep -q -w meters
|
||||
if [ $? -ne 0 ]; then
|
||||
taosBenchmark -y -t 1000 -n 1000 -S 900000
|
||||
taos -s "create user admin_user pass 'NDS65R6t' sysinfo 0;"
|
||||
taos -s "GRANT ALL on test.* to admin_user;"
|
||||
taos -s "create user admin_user pass 'NDS65R6t' sysinfo 0;"
|
||||
taos -s "GRANT ALL on test.* to admin_user;"
|
||||
fi
|
||||
fi
|
||||
# check taosd status
|
||||
if [ "$service_state" = "ready" ]; then
|
||||
# check taosd status
|
||||
check_taosd
|
||||
print_service_state_change "ready"
|
||||
if [ "$service_state" = "error" ]; then
|
||||
post_error_msg
|
||||
fi
|
||||
elif [ "$service_state" = "init" ]; then
|
||||
check_taosd "ignore"
|
||||
# check timeout
|
||||
current_time=`date +%s`
|
||||
time_elapsed=$(( current_time - taosd_start_time ))
|
||||
if [ ${time_elapsed} -gt ${TAOSD_STARTUP_TIMEOUT_SECOND} ]; then
|
||||
set_service_state "error" "taosd startup timeout"
|
||||
post_error_msg
|
||||
fi
|
||||
print_service_state_change "init"
|
||||
elif [ "$service_state" = "error" ]; then
|
||||
# check taosd status
|
||||
check_taosd
|
||||
print_service_state_change "error"
|
||||
fi
|
||||
# check taosadapter
|
||||
nc -z localhost 6041
|
||||
if [ $? -ne 0 ]; then
|
||||
taosadapter &
|
||||
taosadapter &
|
||||
fi
|
||||
sleep 10
|
||||
done
|
||||
|
|
|
@ -221,12 +221,12 @@ if [[ "$cpuType" == "x64" ]] || [[ "$cpuType" == "aarch64" ]] || [[ "$cpuType" =
|
|||
# community-version compile
|
||||
cmake ../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DPAGMODE=${pagMode} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||
elif [ "$verMode" == "cloud" ]; then
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_CLOUD=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DBUILD_CLOUD=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||
elif [ "$verMode" == "cluster" ]; then
|
||||
if [[ "$dbName" != "taos" ]]; then
|
||||
replace_enterprise_$dbName
|
||||
fi
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||
cmake ../../ -DCPUTYPE=${cpuType} -DWEBSOCKET=true -DBUILD_TAOSX=true -DOSTYPE=${osType} -DSOMODE=${soMode} -DDBNAME=${dbName} -DVERTYPE=${verType} -DVERDATE="${build_time}" -DGITINFO=${gitinfo} -DGITINFOI=${gitinfoOfInternal} -DVERNUMBER=${verNumber} -DVERCOMPATIBLE=${verNumberComp} -DBUILD_HTTP=${BUILD_HTTP} -DBUILD_TOOLS=${BUILD_TOOLS} ${allocator_macro}
|
||||
fi
|
||||
else
|
||||
echo "input cpuType=${cpuType} error!!!"
|
||||
|
|
|
@ -1,15 +1,72 @@
|
|||
#!/bin/sh
|
||||
|
||||
|
||||
function usage() {
|
||||
echo "$0"
|
||||
echo -e "\t -f test file type,server/client/tools/"
|
||||
echo -e "\t -m pacakage version Type,community/enterprise"
|
||||
echo -e "\t -l package type,lite or not"
|
||||
echo -e "\t -c operation type,x64/arm64"
|
||||
echo -e "\t -v pacakage version,3.0.1.7"
|
||||
echo -e "\t -o pacakage version,3.0.1.7"
|
||||
echo -e "\t -s source Path,web/nas"
|
||||
echo -e "\t -t package Type,tar/rpm/deb"
|
||||
echo -e "\t -h help"
|
||||
}
|
||||
|
||||
|
||||
#parameter
|
||||
scriptDir=$(dirname $(readlink -f $0))
|
||||
packgeName=$1
|
||||
version=$2
|
||||
originPackageName=$3
|
||||
originversion=$4
|
||||
testFile=$5
|
||||
# sourcePath:web/nas
|
||||
sourcePath=$6
|
||||
version="3.0.1.7"
|
||||
originversion="3.0.1.7"
|
||||
testFile="server"
|
||||
verMode="communtity"
|
||||
sourcePath="nas"
|
||||
cpuType="x64"
|
||||
lite="true"
|
||||
packageType="tar"
|
||||
subFile="taos.tar.gz"
|
||||
while getopts "m:c:f:l:s:o:t:v:h" opt; do
|
||||
case $opt in
|
||||
m)
|
||||
verMode=$OPTARG
|
||||
;;
|
||||
v)
|
||||
version=$OPTARG
|
||||
;;
|
||||
f)
|
||||
testFile=$OPTARG
|
||||
;;
|
||||
l)
|
||||
lite=$OPTARG
|
||||
;;
|
||||
s)
|
||||
sourcePath=$OPTARG
|
||||
;;
|
||||
o)
|
||||
originversion=$OPTARG
|
||||
;;
|
||||
c)
|
||||
cpuType=$OPTARG
|
||||
;;
|
||||
t)
|
||||
packageType=$OPTARG
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
?)
|
||||
echo "Invalid option: -$OPTARG"
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
|
||||
echo "testFile:${testFile},verMode:${verMode},lite:${lite},cpuType:${cpuType},packageType:${packageType},version-${version},originversion:${originversion},sourcePath:${sourcePath}"
|
||||
# Color setting
|
||||
RED='\033[41;30m'
|
||||
GREEN='\033[1;32m'
|
||||
|
@ -21,20 +78,40 @@ BLUE_DARK='\033[0;34m'
|
|||
GREEN_UNDERLINE='\033[4;32m'
|
||||
NC='\033[0m'
|
||||
|
||||
if [ ${testFile} = "server" ];then
|
||||
tdPath="TDengine-server-${version}"
|
||||
originTdpPath="TDengine-server-${originversion}"
|
||||
if [[ ${verMode} = "enterprise" ]];then
|
||||
prePackag="TDengine-enterprise-${testFile}"
|
||||
elif [ ${verMode} = "community" ];then
|
||||
prePackag="TDengine-${testFile}"
|
||||
fi
|
||||
if [ ${lite} = "true" ];then
|
||||
packageLite="-Lite"
|
||||
elif [ ${lite} = "false" ];then
|
||||
packageLite=""
|
||||
fi
|
||||
if [[ "$packageType" = "tar" ]] ;then
|
||||
packageType="tar.gz"
|
||||
fi
|
||||
|
||||
tdPath="${prePackag}-${version}"
|
||||
originTdpPath="${prePackag}-${originversion}"
|
||||
|
||||
packgeName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}"
|
||||
originPackageName="${originTdpPath}-Linux-${cpuType}${packageLite}.${packageType}"
|
||||
|
||||
if [ "$testFile" == "server" ] ;then
|
||||
installCmd="install.sh"
|
||||
elif [ ${testFile} = "client" ];then
|
||||
tdPath="TDengine-client-${version}"
|
||||
originTdpPath="TDengine-client-${originversion}"
|
||||
installCmd="install_client.sh"
|
||||
elif [ ${testFile} = "tools" ];then
|
||||
tdPath="taosTools-${version}"
|
||||
originTdpPath="taosTools-${originversion}"
|
||||
packgeName="${tdPath}-Linux-${cpuType}${packageLite}.${packageType}"
|
||||
originPackageName="${originTdpPath}-Linux-${cpuType}${packageLite}.${packageType}"
|
||||
installCmd="install-taostools.sh"
|
||||
fi
|
||||
|
||||
|
||||
echo "tdPath:${tdPath},originTdpPath:${originTdpPath},packgeName:${packgeName},originPackageName:${originPackageName}"
|
||||
function cmdInstall {
|
||||
command=$1
|
||||
if command -v ${command} ;then
|
||||
|
@ -76,16 +153,16 @@ file=$1
|
|||
versionPath=$2
|
||||
sourceP=$3
|
||||
nasServerIP="192.168.1.131"
|
||||
packagePath="/nas/TDengine/v${versionPath}/community"
|
||||
packagePath="/nas/TDengine/v${versionPath}/${verMode}"
|
||||
if [ -f ${file} ];then
|
||||
echoColor YD "${file} already exists ,it will delete it and download it again "
|
||||
rm -rf ${file}
|
||||
fi
|
||||
|
||||
if [ ${sourceP} = 'web' ];then
|
||||
if [[ ${sourceP} = 'web' ]];then
|
||||
echoColor BD "====download====:wget https://www.taosdata.com/assets-download/3.0/${file}"
|
||||
wget https://www.taosdata.com/assets-download/3.0/${file}
|
||||
elif [ ${sourceP} = 'nas' ];then
|
||||
elif [[ ${sourceP} = 'nas' ]];then
|
||||
echoColor BD "====download====:scp root@${nasServerIP}:${packagePath}/${file} ."
|
||||
scp root@${nasServerIP}:${packagePath}/${file} .
|
||||
fi
|
||||
|
|
|
@ -213,7 +213,7 @@ function install_bin() {
|
|||
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${demoName} || :
|
||||
[ -x ${install_main_dir}/bin/${benchmarkName} ] && ${csudo}ln -s ${install_main_dir}/bin/${benchmarkName} ${bin_link_dir}/${benchmarkName} || :
|
||||
[ -x ${install_main_dir}/bin/${dumpName} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${dumpName} || :
|
||||
[ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -s ${install_main_dir}/bin/${dumpName} ${bin_link_dir}/${xname} || :
|
||||
[ -x ${install_main_dir}/bin/${xname} ] && ${csudo}ln -s ${install_main_dir}/bin/${xname} ${bin_link_dir}/${xname} || :
|
||||
[ -x ${install_main_dir}/bin/TDinsight.sh ] && ${csudo}ln -s ${install_main_dir}/bin/TDinsight.sh ${bin_link_dir}/TDinsight.sh || :
|
||||
[ -x ${install_main_dir}/bin/remove.sh ] && ${csudo}ln -s ${install_main_dir}/bin/remove.sh ${bin_link_dir}/${uninstallScript} || :
|
||||
[ -x ${install_main_dir}/bin/set_core.sh ] && ${csudo}ln -s ${install_main_dir}/bin/set_core.sh ${bin_link_dir}/set_core || :
|
||||
|
|
|
@ -63,7 +63,7 @@ Source: {#MyAppSourceDir}{#MyAppTaosdemoExeName}; DestDir: "{app}"; Flags: igNor
|
|||
|
||||
[run]
|
||||
Filename: {sys}\sc.exe; Parameters: "create taosd start= DEMAND binPath= ""C:\\TDengine\\taosd.exe --win_service""" ; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe --win_service""" ; Flags: runhidden
|
||||
Filename: {sys}\sc.exe; Parameters: "create taosadapter start= DEMAND binPath= ""C:\\TDengine\\taosadapter.exe""" ; Flags: runhidden
|
||||
|
||||
[UninstallRun]
|
||||
RunOnceId: "stoptaosd"; Filename: {sys}\sc.exe; Parameters: "stop taosd" ; Flags: runhidden
|
||||
|
|
|
@ -1106,6 +1106,8 @@ int taos_get_table_vgId(TAOS *taos, const char *db, const char *table, int *vgId
|
|||
return terrno;
|
||||
}
|
||||
|
||||
pRequest->syncQuery = true;
|
||||
|
||||
STscObj *pTscObj = pRequest->pTscObj;
|
||||
SCatalog *pCtg = NULL;
|
||||
code = catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCtg);
|
||||
|
|
|
@ -1275,6 +1275,7 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
nVar++;
|
||||
}
|
||||
}
|
||||
fLen -= sizeof(TSKEY);
|
||||
|
||||
int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) +
|
||||
(int32_t)TD_BITMAP_BYTES(numOfCols - 1);
|
||||
|
@ -1333,7 +1334,9 @@ int taos_write_raw_block(TAOS* taos, int rows, char* pData, const char* tbname)
|
|||
}
|
||||
}
|
||||
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
if (pColumn->colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
}
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
|
@ -1503,6 +1506,7 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
nVar++;
|
||||
}
|
||||
}
|
||||
fLen -= sizeof(TSKEY);
|
||||
|
||||
int32_t rows = rspObj.resInfo.numOfRows;
|
||||
int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) +
|
||||
|
@ -1585,8 +1589,9 @@ static int32_t tmqWriteRawDataImpl(TAOS* taos, void* data, int32_t dataLen) {
|
|||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, offset, k);
|
||||
}
|
||||
}
|
||||
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
if (pColumn->colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
}
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
|
@ -1803,6 +1808,7 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
nVar++;
|
||||
}
|
||||
}
|
||||
fLen -= sizeof(TSKEY);
|
||||
|
||||
int32_t rows = rspObj.resInfo.numOfRows;
|
||||
int32_t extendedRowSize = rowSize + TD_ROW_HEAD_LEN - sizeof(TSKEY) + nVar * sizeof(VarDataOffsetT) +
|
||||
|
@ -1888,8 +1894,9 @@ static int32_t tmqWriteRawMetaDataImpl(TAOS* taos, void* data, int32_t dataLen)
|
|||
tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, colData, true, offset, k);
|
||||
}
|
||||
}
|
||||
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
if (pColumn->colId != PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
offset += TYPE_BYTES[pColumn->type];
|
||||
}
|
||||
}
|
||||
tdSRowEnd(&rb);
|
||||
int32_t rowLen = TD_ROW_LEN(rowData);
|
||||
|
|
|
@ -152,13 +152,13 @@ int32_t stmtRestoreQueryFields(STscStmt* pStmt) {
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, const char* sTableName) {
|
||||
int32_t stmtUpdateBindInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char* tbFName, const char* sTableName, bool autoCreateTbl) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
strncpy(pStmt->bInfo.tbFName, tbFName, sizeof(pStmt->bInfo.tbFName) - 1);
|
||||
pStmt->bInfo.tbFName[sizeof(pStmt->bInfo.tbFName) - 1] = 0;
|
||||
|
||||
pStmt->bInfo.tbUid = pTableMeta->uid;
|
||||
pStmt->bInfo.tbUid = autoCreateTbl ? 0 : pTableMeta->uid;
|
||||
pStmt->bInfo.tbSuid = pTableMeta->suid;
|
||||
pStmt->bInfo.tbType = pTableMeta->tableType;
|
||||
pStmt->bInfo.boundTags = tags;
|
||||
|
@ -182,7 +182,7 @@ int32_t stmtUpdateInfo(TAOS_STMT* stmt, STableMeta* pTableMeta, void* tags, char
|
|||
SHashObj* pVgHash, SHashObj* pBlockHash, const char* sTableName) {
|
||||
STscStmt* pStmt = (STscStmt*)stmt;
|
||||
|
||||
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName, sTableName));
|
||||
STMT_ERR_RET(stmtUpdateBindInfo(stmt, pTableMeta, tags, tbFName, sTableName, autoCreateTbl));
|
||||
STMT_ERR_RET(stmtUpdateExecInfo(stmt, pVgHash, pBlockHash, autoCreateTbl));
|
||||
|
||||
pStmt->sql.autoCreateTbl = autoCreateTbl;
|
||||
|
@ -623,6 +623,8 @@ int stmtSetTbTags(TAOS_STMT* stmt, TAOS_MULTI_BIND* tags) {
|
|||
pStmt->bInfo.sname.tname, tags, pStmt->exec.pRequest->msgBuf,
|
||||
pStmt->exec.pRequest->msgBufLen));
|
||||
|
||||
pStmt->exec.autoCreateTbl = true;
|
||||
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -771,10 +773,6 @@ int stmtAddBatch(TAOS_STMT* stmt) {
|
|||
int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
||||
tscDebug("stmt start to update tbUid, blockNum: %d", pRsp->nBlocks);
|
||||
|
||||
if (pRsp->nBlocks <= 0) {
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
size_t keyLen = 0;
|
||||
STableDataBlocks** pIter = taosHashIterate(pStmt->exec.pBlockHash, NULL);
|
||||
while (pIter) {
|
||||
|
@ -809,8 +807,30 @@ int stmtUpdateTableUid(STscStmt* pStmt, SSubmitRsp* pRsp) {
|
|||
pMeta->uid = blkRsp->uid;
|
||||
pStmt->bInfo.tbUid = blkRsp->uid;
|
||||
} else {
|
||||
tscError("table %s not found in submit rsp", pStmt->bInfo.tbFName);
|
||||
STMT_ERR_RET(TSDB_CODE_TSC_APP_ERROR);
|
||||
tscDebug("table %s not found in submit rsp, will update from catalog", pStmt->bInfo.tbFName);
|
||||
if (NULL == pStmt->pCatalog) {
|
||||
STMT_ERR_RET(catalogGetHandle(pStmt->taos->pAppInfo->clusterId, &pStmt->pCatalog));
|
||||
}
|
||||
|
||||
STMT_ERR_RET(stmtCreateRequest(pStmt));
|
||||
|
||||
STableMeta* pTableMeta = NULL;
|
||||
SRequestConnInfo conn = {.pTrans = pStmt->taos->pAppInfo->pTransporter,
|
||||
.requestId = pStmt->exec.pRequest->requestId,
|
||||
.requestObjRefId = pStmt->exec.pRequest->self,
|
||||
.mgmtEps = getEpSet_s(&pStmt->taos->pAppInfo->mgmtEp)};
|
||||
int32_t code = catalogGetTableMeta(pStmt->pCatalog, &conn, &pStmt->bInfo.sname, &pTableMeta);
|
||||
|
||||
taos_free_result(pStmt->exec.pRequest);
|
||||
pStmt->exec.pRequest = NULL;
|
||||
|
||||
if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) {
|
||||
tscDebug("tb %s not exist", pStmt->bInfo.tbFName);
|
||||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
pMeta->uid = pTableMeta->uid;
|
||||
pStmt->bInfo.tbUid = pTableMeta->uid;
|
||||
}
|
||||
|
||||
pIter = taosHashIterate(pStmt->exec.pBlockHash, pIter);
|
||||
|
|
|
@ -728,12 +728,26 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
taosMemoryFree(param);
|
||||
return;
|
||||
}
|
||||
int64_t consumerId = tmq->consumerId;
|
||||
int32_t epoch = tmq->epoch;
|
||||
SMqHbReq* pReq = taosMemoryMalloc(sizeof(SMqHbReq));
|
||||
if (pReq == NULL) goto OVER;
|
||||
pReq->consumerId = htobe64(consumerId);
|
||||
pReq->epoch = epoch;
|
||||
|
||||
SMqHbReq req = {0};
|
||||
req.consumerId = tmq->consumerId;
|
||||
req.epoch = tmq->epoch;
|
||||
|
||||
int32_t tlen = tSerializeSMqHbReq(NULL, 0, &req);
|
||||
if (tlen < 0) {
|
||||
tscError("tSerializeSMqHbReq failed");
|
||||
return;
|
||||
}
|
||||
void *pReq = taosMemoryCalloc(1, tlen);
|
||||
if (tlen < 0) {
|
||||
tscError("failed to malloc MqHbReq msg, size:%d", tlen);
|
||||
return;
|
||||
}
|
||||
if (tSerializeSMqHbReq(pReq, tlen, &req) < 0) {
|
||||
tscError("tSerializeSMqHbReq %d failed", tlen);
|
||||
taosMemoryFree(pReq);
|
||||
return;
|
||||
}
|
||||
|
||||
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) {
|
||||
|
@ -742,7 +756,7 @@ void tmqSendHbReq(void* param, void* tmrId) {
|
|||
}
|
||||
sendInfo->msgInfo = (SDataBuf){
|
||||
.pData = pReq,
|
||||
.len = sizeof(SMqHbReq),
|
||||
.len = tlen,
|
||||
.handle = NULL,
|
||||
};
|
||||
|
||||
|
@ -1378,21 +1392,31 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
|||
}
|
||||
atomic_store_32(&tmq->epSkipCnt, 0);
|
||||
#endif
|
||||
int32_t tlen = sizeof(SMqAskEpReq);
|
||||
SMqAskEpReq* req = taosMemoryCalloc(1, tlen);
|
||||
if (req == NULL) {
|
||||
tscError("failed to malloc get subscribe ep buf");
|
||||
/*atomic_store_8(&tmq->epStatus, 0);*/
|
||||
SMqAskEpReq req = {0};
|
||||
req.consumerId = tmq->consumerId;
|
||||
req.epoch = tmq->epoch;
|
||||
strcpy(req.cgroup, tmq->groupId);
|
||||
|
||||
int32_t tlen = tSerializeSMqAskEpReq(NULL, 0, &req);
|
||||
if (tlen < 0) {
|
||||
tscError("tSerializeSMqAskEpReq failed");
|
||||
return -1;
|
||||
}
|
||||
void *pReq = taosMemoryCalloc(1, tlen);
|
||||
if (tlen < 0) {
|
||||
tscError("failed to malloc askEpReq msg, size:%d", tlen);
|
||||
return -1;
|
||||
}
|
||||
if (tSerializeSMqAskEpReq(pReq, tlen, &req) < 0) {
|
||||
tscError("tSerializeSMqAskEpReq %d failed", tlen);
|
||||
taosMemoryFree(pReq);
|
||||
return -1;
|
||||
}
|
||||
req->consumerId = htobe64(tmq->consumerId);
|
||||
req->epoch = htonl(tmq->epoch);
|
||||
strcpy(req->cgroup, tmq->groupId);
|
||||
|
||||
SMqAskEpCbParam* pParam = taosMemoryCalloc(1, sizeof(SMqAskEpCbParam));
|
||||
if (pParam == NULL) {
|
||||
tscError("failed to malloc subscribe param");
|
||||
taosMemoryFree(req);
|
||||
taosMemoryFree(pReq);
|
||||
/*atomic_store_8(&tmq->epStatus, 0);*/
|
||||
return -1;
|
||||
}
|
||||
|
@ -1405,13 +1429,13 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
|||
if (sendInfo == NULL) {
|
||||
tsem_destroy(&pParam->rspSem);
|
||||
taosMemoryFree(pParam);
|
||||
taosMemoryFree(req);
|
||||
taosMemoryFree(pReq);
|
||||
/*atomic_store_8(&tmq->epStatus, 0);*/
|
||||
return -1;
|
||||
}
|
||||
|
||||
sendInfo->msgInfo = (SDataBuf){
|
||||
.pData = req,
|
||||
.pData = pReq,
|
||||
.len = tlen,
|
||||
.handle = NULL,
|
||||
};
|
||||
|
@ -1437,12 +1461,7 @@ int32_t tmqAskEp(tmq_t* tmq, bool async) {
|
|||
return code;
|
||||
}
|
||||
|
||||
SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic* pTopic, SMqClientVg* pVg) {
|
||||
SMqPollReq* pReq = taosMemoryCalloc(1, sizeof(SMqPollReq));
|
||||
if (pReq == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void tmqBuildConsumeReqImpl(SMqPollReq *pReq, tmq_t* tmq, int64_t timeout, SMqClientTopic* pTopic, SMqClientVg* pVg) {
|
||||
/*strcpy(pReq->topic, pTopic->topicName);*/
|
||||
/*strcpy(pReq->cgroup, tmq->groupId);*/
|
||||
|
||||
|
@ -1461,9 +1480,7 @@ SMqPollReq* tmqBuildConsumeReqImpl(tmq_t* tmq, int64_t timeout, SMqClientTopic*
|
|||
|
||||
pReq->useSnapshot = tmq->useSnapshot;
|
||||
|
||||
pReq->head.vgId = htonl(pVg->vgId);
|
||||
pReq->head.contLen = htonl(sizeof(SMqPollReq));
|
||||
return pReq;
|
||||
pReq->head.vgId = pVg->vgId;
|
||||
}
|
||||
|
||||
SMqMetaRspObj* tmqBuildMetaRspFromWrapper(SMqPollRspWrapper* pWrapper) {
|
||||
|
@ -1535,15 +1552,32 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
#endif
|
||||
}
|
||||
atomic_store_32(&pVg->vgSkipCnt, 0);
|
||||
SMqPollReq* pReq = tmqBuildConsumeReqImpl(tmq, timeout, pTopic, pVg);
|
||||
if (pReq == NULL) {
|
||||
|
||||
SMqPollReq req = {0};
|
||||
tmqBuildConsumeReqImpl(&req, tmq, timeout, pTopic, pVg);
|
||||
int32_t msgSize = tSerializeSMqPollReq(NULL, 0, &req);
|
||||
if (msgSize < 0) {
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
tsem_post(&tmq->rspSem);
|
||||
return -1;
|
||||
}
|
||||
char *msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == msg) {
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
tsem_post(&tmq->rspSem);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (tSerializeSMqPollReq(msg, msgSize, &req) < 0) {
|
||||
taosMemoryFree(msg);
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
tsem_post(&tmq->rspSem);
|
||||
return -1;
|
||||
}
|
||||
|
||||
SMqPollCbParam* pParam = taosMemoryMalloc(sizeof(SMqPollCbParam));
|
||||
if (pParam == NULL) {
|
||||
taosMemoryFree(pReq);
|
||||
taosMemoryFree(msg);
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
tsem_post(&tmq->rspSem);
|
||||
return -1;
|
||||
|
@ -1557,7 +1591,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
|
||||
SMsgSendInfo* sendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
|
||||
if (sendInfo == NULL) {
|
||||
taosMemoryFree(pReq);
|
||||
taosMemoryFree(msg);
|
||||
taosMemoryFree(pParam);
|
||||
atomic_store_32(&pVg->vgStatus, TMQ_VG_STATUS__IDLE);
|
||||
tsem_post(&tmq->rspSem);
|
||||
|
@ -1565,11 +1599,11 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
}
|
||||
|
||||
sendInfo->msgInfo = (SDataBuf){
|
||||
.pData = pReq,
|
||||
.len = sizeof(SMqPollReq),
|
||||
.pData = msg,
|
||||
.len = msgSize,
|
||||
.handle = NULL,
|
||||
};
|
||||
sendInfo->requestId = pReq->reqId;
|
||||
sendInfo->requestId = req.reqId;
|
||||
sendInfo->requestObjRefId = 0;
|
||||
sendInfo->param = pParam;
|
||||
sendInfo->fp = tmqPollCb;
|
||||
|
@ -1581,7 +1615,7 @@ int32_t tmqPollImpl(tmq_t* tmq, int64_t timeout) {
|
|||
char offsetFormatBuf[80];
|
||||
tFormatOffset(offsetFormatBuf, 80, &pVg->currentOffset);
|
||||
tscDebug("consumer:%" PRId64 ", send poll to %s vgId:%d, epoch %d, req offset:%s, reqId:%" PRIu64,
|
||||
tmq->consumerId, pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, pReq->reqId);
|
||||
tmq->consumerId, pTopic->topicName, pVg->vgId, tmq->epoch, offsetFormatBuf, req.reqId);
|
||||
/*printf("send vgId:%d %" PRId64 "\n", pVg->vgId, pVg->currentOffset);*/
|
||||
asyncSendMsgToServer(tmq->pTscObj->pAppInfo->pTransporter, &pVg->epSet, &transporterId, sendInfo);
|
||||
pVg->pollCnt++;
|
||||
|
|
|
@ -692,7 +692,6 @@ TEST(testCase, insert_test) {
|
|||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(testCase, projection_query_tables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
|
@ -752,9 +751,6 @@ TEST(testCase, projection_query_tables) {
|
|||
taos_close(pConn);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
TEST(testCase, tsbs_perf_test) {
|
||||
TdThread qid[20] = {0};
|
||||
|
||||
|
@ -764,15 +760,16 @@ TEST(testCase, tsbs_perf_test) {
|
|||
getchar();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
TEST(testCase, projection_query_stables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
||||
TAOS_RES* pRes = taos_query(pConn, "use abc1");
|
||||
TAOS_RES* pRes = taos_query(pConn, "use test");
|
||||
taos_free_result(pRes);
|
||||
|
||||
pRes = taos_query(pConn, "select ts from st1");
|
||||
pRes = taos_query(pConn, "select * from meters limit 50000000");
|
||||
if (taos_errno(pRes) != 0) {
|
||||
printf("failed to select from table, reason:%s\n", taos_errstr(pRes));
|
||||
taos_free_result(pRes);
|
||||
|
@ -785,14 +782,15 @@ TEST(testCase, projection_query_stables) {
|
|||
|
||||
char str[512] = {0};
|
||||
while ((pRow = taos_fetch_row(pRes)) != NULL) {
|
||||
int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
printf("%s\n", str);
|
||||
// int32_t code = taos_print_row(str, pRow, pFields, numOfFields);
|
||||
// printf("%s\n", str);
|
||||
}
|
||||
|
||||
taos_free_result(pRes);
|
||||
taos_close(pConn);
|
||||
}
|
||||
|
||||
#if 0
|
||||
TEST(testCase, agg_query_tables) {
|
||||
TAOS* pConn = taos_connect("localhost", "root", "taosdata", NULL, 0);
|
||||
ASSERT_NE(pConn, nullptr);
|
||||
|
|
|
@ -36,7 +36,7 @@ int32_t colDataGetFullLength(const SColumnInfoData* pColumnInfoData, int32_t num
|
|||
if (IS_VAR_DATA_TYPE(pColumnInfoData->info.type)) {
|
||||
return pColumnInfoData->varmeta.length + sizeof(int32_t) * numOfRows;
|
||||
} else {
|
||||
return pColumnInfoData->info.bytes * numOfRows + BitmapLen(numOfRows);
|
||||
return ((pColumnInfoData->info.type == TSDB_DATA_TYPE_NULL) ? 0 : pColumnInfoData->info.bytes * numOfRows) + BitmapLen(numOfRows);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -652,7 +652,10 @@ int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity)
|
|||
ASSERT(pCol->varmeta.length <= pCol->varmeta.allocLen);
|
||||
}
|
||||
|
||||
memcpy(pCol->pData, pStart, colLength);
|
||||
if (!colDataIsNNull_s(pCol, 0, pBlock->info.rows)) {
|
||||
memcpy(pCol->pData, pStart, colLength);
|
||||
}
|
||||
|
||||
pStart += pCol->info.bytes * capacity;
|
||||
}
|
||||
|
||||
|
@ -1084,8 +1087,6 @@ int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
int32_t varColSort(SColumnInfoData* pColumnInfoData, SBlockOrderInfo* pOrder) { return 0; }
|
||||
|
||||
int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) {
|
||||
// Allocate the additional buffer.
|
||||
int64_t p0 = taosGetTimestampUs();
|
||||
|
@ -1403,6 +1404,7 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock, bool copyData) {
|
|||
pBlock->info = pDataBlock->info;
|
||||
pBlock->info.rows = 0;
|
||||
pBlock->info.capacity = 0;
|
||||
pBlock->info.rowSize = 0;
|
||||
|
||||
size_t numOfCols = taosArrayGetSize(pDataBlock->pDataBlock);
|
||||
for (int32_t i = 0; i < numOfCols; ++i) {
|
||||
|
@ -1961,6 +1963,7 @@ char* dumpBlockData(SSDataBlock* pDataBlock, const char* flag, char** pDataBuf)
|
|||
memset(pBuf, 0, sizeof(pBuf));
|
||||
char* pData = colDataGetVarData(pColInfoData, j);
|
||||
int32_t dataSize = TMIN(sizeof(pBuf), varDataLen(pData));
|
||||
dataSize = TMIN(dataSize, 50);
|
||||
memcpy(pBuf, varDataVal(pData), dataSize);
|
||||
len += snprintf(dumpBuf + len, size - len, " %15s |", pBuf);
|
||||
if (len >= size - 1) return dumpBuf;
|
||||
|
@ -2052,6 +2055,7 @@ int32_t buildSubmitReqFromDataBlock(SSubmitReq** pReq, const SSDataBlock* pDataB
|
|||
isStartKey = true;
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NORM, var, true,
|
||||
offset, k);
|
||||
continue; // offset should keep 0 for next column
|
||||
|
||||
} else if (colDataIsNull_s(pColInfoData, j)) {
|
||||
tdAppendColValToRow(&rb, PRIMARYKEY_TIMESTAMP_COL_ID + k, TSDB_DATA_TYPE_TIMESTAMP, TD_VTYPE_NULL, NULL,
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -277,7 +277,9 @@ static int32_t taosAddServerLogCfg(SConfig *pCfg) {
|
|||
static int32_t taosAddClientCfg(SConfig *pCfg) {
|
||||
char defaultFqdn[TSDB_FQDN_LEN] = {0};
|
||||
int32_t defaultServerPort = 6030;
|
||||
if (taosGetFqdn(defaultFqdn) != 0) return -1;
|
||||
if (taosGetFqdn(defaultFqdn) != 0) {
|
||||
strcpy(defaultFqdn, "localhost");
|
||||
}
|
||||
|
||||
if (cfgAddString(pCfg, "firstEp", "", 1) != 0) return -1;
|
||||
if (cfgAddString(pCfg, "secondEp", "", 1) != 0) return -1;
|
||||
|
|
|
@ -4446,6 +4446,509 @@ void tFreeSExplainRsp(SExplainRsp *pRsp) {
|
|||
taosMemoryFreeClear(pRsp->subplanInfo);
|
||||
}
|
||||
|
||||
int32_t tSerializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
int32_t num = taosArrayGetSize(pReq->pMsgs);
|
||||
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchMsg *pMsg = taosArrayGet(pReq->pMsgs, i);
|
||||
if (tEncodeI32(&encoder, pMsg->msgIdx) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pMsg->msgType) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pMsg->msgLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, pMsg->msg, pMsg->msgLen) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->header.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSBatchReq(void *buf, int32_t bufLen, SBatchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SMsgHead *pHead = buf;
|
||||
pHead->vgId = pReq->header.vgId;
|
||||
pHead->contLen = pReq->header.contLen;
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
int32_t num = 0;
|
||||
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||
if (num <= 0) {
|
||||
pReq->pMsgs = NULL;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pReq->pMsgs = taosArrayInit(num, sizeof(SBatchMsg));
|
||||
if (NULL == pReq->pMsgs) return -1;
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchMsg msg = {0};
|
||||
if (tDecodeI32(&decoder, &msg.msgIdx) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &msg.msgType) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &msg.msgLen) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1;
|
||||
if (NULL == taosArrayPush(pReq->pMsgs, &msg)) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
int32_t num = taosArrayGetSize(pRsp->pRsps);
|
||||
if (tEncodeI32(&encoder, num) < 0) return -1;
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchRspMsg *pMsg = taosArrayGet(pRsp->pRsps, i);
|
||||
if (tEncodeI32(&encoder, pMsg->reqType) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pMsg->msgIdx) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pMsg->msgLen) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pMsg->rspCode) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, pMsg->msg, pMsg->msgLen) < 0) return -1;
|
||||
}
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSBatchRsp(void *buf, int32_t bufLen, SBatchRsp *pRsp) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf, bufLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
int32_t num = 0;
|
||||
if (tDecodeI32(&decoder, &num) < 0) return -1;
|
||||
if (num <= 0) {
|
||||
pRsp->pRsps = NULL;
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pRsp->pRsps = taosArrayInit(num, sizeof(SBatchRspMsg));
|
||||
if (NULL == pRsp->pRsps) return -1;
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchRspMsg msg = {0};
|
||||
if (tDecodeI32(&decoder, &msg.reqType) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &msg.msgIdx) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &msg.msgLen) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &msg.rspCode) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, &msg.msg, NULL) < 0) return -1;
|
||||
if (NULL == taosArrayPush(pRsp->pRsps, &msg)) return -1;
|
||||
}
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->epoch) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pReq->cgroup) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSMqAskEpReq(void *buf, int32_t bufLen, SMqAskEpReq *pReq) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf, bufLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pReq->cgroup) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->epoch) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSMqHbReq(void *buf, int32_t bufLen, SMqHbReq *pReq) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf, bufLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeU64(&encoder, pReq->sId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->refId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->execId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->msgMask) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->taskType) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->explain) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->needFetch) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pReq->sqlLen) < 0) return -1;
|
||||
if (tEncodeCStrWithLen(&encoder, pReq->sql, pReq->sqlLen) < 0) return -1;
|
||||
if (tEncodeU32(&encoder, pReq->msgLen) < 0) return -1;
|
||||
if (tEncodeBinary(&encoder, (uint8_t*)pReq->msg, pReq->msgLen) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->header.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSSubQueryMsg(void *buf, int32_t bufLen, SSubQueryMsg *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SMsgHead *pHead = buf;
|
||||
pHead->vgId = pReq->header.vgId;
|
||||
pHead->contLen = pReq->header.contLen;
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->msgMask) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->taskType) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->explain) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->needFetch) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pReq->sqlLen) < 0) return -1;
|
||||
if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1;
|
||||
if (tDecodeU32(&decoder, &pReq->msgLen) < 0) return -1;
|
||||
if (tDecodeBinaryAlloc(&decoder, (void**)&pReq->msg, NULL) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void tFreeSSubQueryMsg(SSubQueryMsg *pReq) {
|
||||
if (NULL == pReq) {
|
||||
return;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(pReq->sql);
|
||||
taosMemoryFreeClear(pReq->msg);
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeU64(&encoder, pReq->sId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->execId) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->header.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSResFetchReq(void *buf, int32_t bufLen, SResFetchReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SMsgHead *pHead = buf;
|
||||
pHead->vgId = pReq->header.vgId;
|
||||
pHead->contLen = pReq->header.contLen;
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSTqOffsetVal(SEncoder *pEncoder, STqOffsetVal *pOffset) {
|
||||
if (tEncodeI8(pEncoder, pOffset->type) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pOffset->uid) < 0) return -1;
|
||||
if (tEncodeI64(pEncoder, pOffset->ts) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tDerializeSTqOffsetVal(SDecoder *pDecoder, STqOffsetVal *pOffset) {
|
||||
if (tDecodeI8(pDecoder, &pOffset->type) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pOffset->uid) < 0) return -1;
|
||||
if (tDecodeI64(pDecoder, &pOffset->ts) < 0) return -1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeCStr(&encoder, pReq->subKey) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->withTbName) < 0) return -1;
|
||||
if (tEncodeI8(&encoder, pReq->useSnapshot) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->epoch) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->reqId) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->consumerId) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->timeout) < 0) return -1;
|
||||
if (tSerializeSTqOffsetVal(&encoder, &pReq->reqOffset) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->head.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSMqPollReq(void *buf, int32_t bufLen, SMqPollReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SMsgHead *pHead = buf;
|
||||
pHead->vgId = pReq->head.vgId;
|
||||
pHead->contLen = pReq->head.contLen;
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeCStrTo(&decoder, pReq->subKey) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->withTbName) < 0) return -1;
|
||||
if (tDecodeI8(&decoder, &pReq->useSnapshot) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->epoch) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->reqId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->consumerId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->timeout) < 0) return -1;
|
||||
if (tDerializeSTqOffsetVal(&decoder, &pReq->reqOffset) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
buf = (char *)buf + headLen;
|
||||
bufLen -= headLen;
|
||||
}
|
||||
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeU64(&encoder, pReq->sId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->queryId) < 0) return -1;
|
||||
if (tEncodeU64(&encoder, pReq->taskId) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pReq->refId) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pReq->execId) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
if (buf != NULL) {
|
||||
SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen);
|
||||
pHead->vgId = htonl(pReq->header.vgId);
|
||||
pHead->contLen = htonl(tlen + headLen);
|
||||
}
|
||||
|
||||
return tlen + headLen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSTaskDropReq(void *buf, int32_t bufLen, STaskDropReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
|
||||
SMsgHead *pHead = buf;
|
||||
pHead->vgId = pReq->header.vgId;
|
||||
pHead->contLen = pReq->header.contLen;
|
||||
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf + headLen, bufLen - headLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeU64(&decoder, &pReq->sId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->queryId) < 0) return -1;
|
||||
if (tDecodeU64(&decoder, &pReq->taskId) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pReq->refId) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pReq->execId) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t tSerializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp) {
|
||||
SEncoder encoder = {0};
|
||||
tEncoderInit(&encoder, buf, bufLen);
|
||||
if (tStartEncode(&encoder) < 0) return -1;
|
||||
|
||||
if (tEncodeI32(&encoder, pRsp->code) < 0) return -1;
|
||||
if (tEncodeCStr(&encoder, pRsp->tbFName) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->sversion) < 0) return -1;
|
||||
if (tEncodeI32(&encoder, pRsp->tversion) < 0) return -1;
|
||||
if (tEncodeI64(&encoder, pRsp->affectedRows) < 0) return -1;
|
||||
|
||||
tEndEncode(&encoder);
|
||||
|
||||
int32_t tlen = encoder.pos;
|
||||
tEncoderClear(&encoder);
|
||||
|
||||
return tlen;
|
||||
}
|
||||
|
||||
int32_t tDeserializeSQueryTableRsp(void *buf, int32_t bufLen, SQueryTableRsp *pRsp) {
|
||||
SDecoder decoder = {0};
|
||||
tDecoderInit(&decoder, (char *)buf, bufLen);
|
||||
|
||||
if (tStartDecode(&decoder) < 0) return -1;
|
||||
|
||||
if (tDecodeI32(&decoder, &pRsp->code) < 0) return -1;
|
||||
if (tDecodeCStrTo(&decoder, pRsp->tbFName) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->sversion) < 0) return -1;
|
||||
if (tDecodeI32(&decoder, &pRsp->tversion) < 0) return -1;
|
||||
if (tDecodeI64(&decoder, &pRsp->affectedRows) < 0) return -1;
|
||||
|
||||
tEndDecode(&decoder);
|
||||
|
||||
tDecoderClear(&decoder);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq) {
|
||||
int32_t headLen = sizeof(SMsgHead);
|
||||
if (buf != NULL) {
|
||||
|
|
|
@ -192,7 +192,7 @@ bool tdSTpRowGetVal(STSRow *pRow, col_id_t colId, col_type_t colType, int32_t fl
|
|||
return true;
|
||||
}
|
||||
void *pBitmap = tdGetBitmapAddrTp(pRow, flen);
|
||||
tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset - sizeof(TSKEY), colIdx);
|
||||
tdGetTpRowValOfCol(pVal, pRow, pBitmap, colType, offset, colIdx);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ bool tdSTSRowIterFetch(STSRowIter *pIter, col_id_t colId, col_type_t colType, SC
|
|||
return false;
|
||||
}
|
||||
}
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal);
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
++pIter->colIdx;
|
||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||
return tdSTSRowIterGetKvVal(pIter, colId, &pIter->kvIdx, pVal);
|
||||
|
@ -244,7 +244,7 @@ bool tdSTSRowIterNext(STSRowIter *pIter, SCellVal *pVal) {
|
|||
}
|
||||
|
||||
if (TD_IS_TP_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset - sizeof(TSKEY), pVal);
|
||||
tdSTSRowIterGetTpVal(pIter, pCol->type, pCol->offset, pVal);
|
||||
} else if (TD_IS_KV_ROW(pIter->pRow)) {
|
||||
tdSTSRowIterGetKvVal(pIter, pCol->colId, &pIter->kvIdx, pVal);
|
||||
} else {
|
||||
|
@ -412,7 +412,9 @@ int32_t tdSTSRowNew(SArray *pArray, STSchema *pTSchema, STSRow **ppRow) {
|
|||
valType = TD_VTYPE_NULL;
|
||||
} else if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
varDataSetLen(varBuf, pColVal->value.nData);
|
||||
memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
if (pColVal->value.nData != 0) {
|
||||
memcpy(varDataVal(varBuf), pColVal->value.pData, pColVal->value.nData);
|
||||
}
|
||||
val = varBuf;
|
||||
} else {
|
||||
val = (const void *)&pColVal->value.val;
|
||||
|
@ -467,7 +469,7 @@ bool tdSTSRowGetVal(STSRowIter *pIter, col_id_t colId, col_type_t colType, SCell
|
|||
#ifdef TD_SUPPORT_BITMAP
|
||||
colIdx = POINTER_DISTANCE(pCol, pSchema->columns) / sizeof(STColumn);
|
||||
#endif
|
||||
tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset - sizeof(TSKEY), colIdx - 1);
|
||||
tdGetTpRowValOfCol(pVal, pRow, pIter->pBitmap, pCol->type, pCol->offset, colIdx - 1);
|
||||
} else if (TD_IS_KV_ROW(pRow)) {
|
||||
SKvRowIdx *pIdx = (SKvRowIdx *)taosbsearch(&colId, TD_ROW_COL_IDX(pRow), tdRowGetNCols(pRow), sizeof(SKvRowIdx),
|
||||
compareKvRowColId, TD_EQ);
|
||||
|
@ -755,11 +757,10 @@ int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowValT valType, const vo
|
|||
|
||||
int32_t tdAppendColValToTpRow(SRowBuilder *pBuilder, TDRowValT valType, const void *val, bool isCopyVarData,
|
||||
int8_t colType, int16_t colIdx, int32_t offset) {
|
||||
if ((offset < (int32_t)sizeof(TSKEY)) || (colIdx < 1)) {
|
||||
if (colIdx < 1) {
|
||||
terrno = TSDB_CODE_INVALID_PARA;
|
||||
return terrno;
|
||||
}
|
||||
offset -= sizeof(TSKEY);
|
||||
--colIdx;
|
||||
|
||||
#ifdef TD_SUPPORT_BITMAP
|
||||
|
@ -851,7 +852,7 @@ int32_t tdSRowResetBuf(SRowBuilder *pBuilder, void *pBuf) {
|
|||
memset(pBuilder->pBitmap, TD_VTYPE_NONE_BYTE_II, pBuilder->nBitmaps);
|
||||
#endif
|
||||
// the primary TS key is stored separatedly
|
||||
len = TD_ROW_HEAD_LEN + pBuilder->flen - sizeof(TSKEY) + pBuilder->nBitmaps;
|
||||
len = TD_ROW_HEAD_LEN + pBuilder->flen + pBuilder->nBitmaps;
|
||||
TD_ROW_SET_LEN(pBuilder->pBuf, len);
|
||||
TD_ROW_SET_SVER(pBuilder->pBuf, pBuilder->sver);
|
||||
break;
|
||||
|
@ -1094,4 +1095,4 @@ void tTSRowGetVal(STSRow *pRow, STSchema *pTSchema, int16_t iCol, SColVal *pColV
|
|||
memcpy(&pColVal->value.val, cv.val, tDataTypes[pTColumn->type].bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -436,21 +436,24 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
|
|||
ASSERT(toPrecision == TSDB_TIME_PRECISION_MILLI || toPrecision == TSDB_TIME_PRECISION_MICRO ||
|
||||
toPrecision == TSDB_TIME_PRECISION_NANO);
|
||||
|
||||
double tempResult = (double)utime;
|
||||
|
||||
switch (fromPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI: {
|
||||
switch (toPrecision) {
|
||||
case TSDB_TIME_PRECISION_MILLI:
|
||||
return utime;
|
||||
case TSDB_TIME_PRECISION_MICRO:
|
||||
tempResult *= 1000;
|
||||
utime *= 1000;
|
||||
goto end_;
|
||||
if (utime > INT64_MAX / 1000) {
|
||||
return INT64_MAX;
|
||||
}
|
||||
return utime * 1000;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
tempResult *= 1000000;
|
||||
utime *= 1000000;
|
||||
goto end_;
|
||||
if (utime > INT64_MAX / 1000000) {
|
||||
return INT64_MAX;
|
||||
}
|
||||
return utime * 1000000;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return utime;
|
||||
}
|
||||
} // end from milli
|
||||
case TSDB_TIME_PRECISION_MICRO: {
|
||||
|
@ -460,9 +463,13 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
|
|||
case TSDB_TIME_PRECISION_MICRO:
|
||||
return utime;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
tempResult *= 1000;
|
||||
utime *= 1000;
|
||||
goto end_;
|
||||
if (utime > INT64_MAX / 1000) {
|
||||
return INT64_MAX;
|
||||
}
|
||||
return utime * 1000;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return utime;
|
||||
}
|
||||
} // end from micro
|
||||
case TSDB_TIME_PRECISION_NANO: {
|
||||
|
@ -473,17 +480,17 @@ int64_t convertTimePrecision(int64_t utime, int32_t fromPrecision, int32_t toPre
|
|||
return utime / 1000;
|
||||
case TSDB_TIME_PRECISION_NANO:
|
||||
return utime;
|
||||
default:
|
||||
ASSERT(0);
|
||||
return utime;
|
||||
}
|
||||
} // end from nano
|
||||
default: {
|
||||
assert(0);
|
||||
ASSERT(0);
|
||||
return utime; // only to pass windows compilation
|
||||
}
|
||||
} // end switch fromPrecision
|
||||
|
||||
end_:
|
||||
if (tempResult >= (double)INT64_MAX) return INT64_MAX;
|
||||
if (tempResult <= (double)INT64_MIN) return INT64_MIN; // INT64_MIN means NULL
|
||||
return utime;
|
||||
}
|
||||
|
||||
|
@ -599,18 +606,33 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec
|
|||
static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) {
|
||||
switch (unit) {
|
||||
case 's':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_SECOND) {
|
||||
return -1;
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_SECOND, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'm':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||
return -1;
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_MINUTE, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'h':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_MINUTE) {
|
||||
return -1;
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_HOUR, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'd':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_DAY) {
|
||||
return -1;
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_DAY, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'w':
|
||||
if (val > INT64_MAX / MILLISECOND_PER_WEEK) {
|
||||
return -1;
|
||||
}
|
||||
(*result) = convertTimePrecision(val * MILLISECOND_PER_WEEK, TSDB_TIME_PRECISION_MILLI, timePrecision);
|
||||
break;
|
||||
case 'a':
|
||||
|
@ -650,7 +672,7 @@ int32_t parseAbsoluteDuration(const char* token, int32_t tokenlen, int64_t* dura
|
|||
|
||||
/* get the basic numeric value */
|
||||
int64_t timestamp = taosStr2Int64(token, &endPtr, 10);
|
||||
if (errno != 0) {
|
||||
if (timestamp < 0 || errno != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -668,7 +690,7 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati
|
|||
|
||||
/* get the basic numeric value */
|
||||
*duration = taosStr2Int64(token, NULL, 10);
|
||||
if (errno != 0) {
|
||||
if (*duration < 0 || errno != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ tDataTypeDescriptor tDataTypes[TSDB_DATA_TYPE_MAX] = {
|
|||
static float floatMin = -FLT_MAX, floatMax = FLT_MAX;
|
||||
static double doubleMin = -DBL_MAX, doubleMax = DBL_MAX;
|
||||
|
||||
FORCE_INLINE void *getDataMin(int32_t type, void* value) {
|
||||
FORCE_INLINE void *getDataMin(int32_t type, void *value) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
*(float *)value = floatMin;
|
||||
|
@ -77,7 +77,7 @@ FORCE_INLINE void *getDataMin(int32_t type, void* value) {
|
|||
return value;
|
||||
}
|
||||
|
||||
FORCE_INLINE void *getDataMax(int32_t type, void* value) {
|
||||
FORCE_INLINE void *getDataMax(int32_t type, void *value) {
|
||||
switch (type) {
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
*(float *)value = floatMax;
|
||||
|
|
|
@ -109,7 +109,7 @@ void taosVariantCreateFromBinary(SVariant *pVar, const char *pz, size_t len, uin
|
|||
}
|
||||
case TSDB_DATA_TYPE_FLOAT: {
|
||||
pVar->nLen = tDataTypes[type].bytes;
|
||||
pVar->d = GET_FLOAT_VAL(pz);
|
||||
pVar->f = GET_FLOAT_VAL(pz);
|
||||
break;
|
||||
}
|
||||
case TSDB_DATA_TYPE_NCHAR: { // here we get the nchar length from raw binary bits length
|
||||
|
@ -223,12 +223,18 @@ int32_t taosVariantCompare(const SVariant *p1, const SVariant *p2) {
|
|||
} else {
|
||||
return p1->nLen > p2->nLen ? 1 : -1;
|
||||
}
|
||||
} else if (p1->nType == TSDB_DATA_TYPE_FLOAT || p1->nType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
} else if (p1->nType == TSDB_DATA_TYPE_DOUBLE) {
|
||||
if (p1->d == p2->d) {
|
||||
return 0;
|
||||
} else {
|
||||
return p1->d > p2->d ? 1 : -1;
|
||||
}
|
||||
} else if (p1->nType == TSDB_DATA_TYPE_FLOAT) {
|
||||
if (p1->f == p2->f) {
|
||||
return 0;
|
||||
} else {
|
||||
return p1->f > p2->f ? 1 : -1;
|
||||
}
|
||||
} else if (IS_UNSIGNED_NUMERIC_TYPE(p1->nType)) {
|
||||
if (p1->u == p2->u) {
|
||||
return 0;
|
||||
|
@ -259,8 +265,9 @@ char *taosVariantGet(SVariant *pVar, int32_t type) {
|
|||
case TSDB_DATA_TYPE_UBIGINT:
|
||||
return (char *)&pVar->u;
|
||||
case TSDB_DATA_TYPE_DOUBLE:
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
return (char *)&pVar->d;
|
||||
case TSDB_DATA_TYPE_FLOAT:
|
||||
return (char *)&pVar->f;
|
||||
case TSDB_DATA_TYPE_BINARY:
|
||||
case TSDB_DATA_TYPE_JSON:
|
||||
return (char *)pVar->pz;
|
||||
|
|
|
@ -196,7 +196,7 @@ SArray *mmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncCtrlQueue, 1) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, mmPutMsgToSyncQueue, 1) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
|
|
|
@ -56,6 +56,9 @@ static void mmProcessRpcMsg(SQueueInfo *pInfo, SRpcMsg *pMsg) {
|
|||
if (IsReq(pMsg) && pMsg->info.handle != NULL && code != TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
if (code != 0 && terrno != 0) code = terrno;
|
||||
mmSendRsp(pMsg, code);
|
||||
} else {
|
||||
rpcFreeCont(pMsg->info.rsp);
|
||||
pMsg->info.rsp = NULL;
|
||||
}
|
||||
|
||||
if (code == TSDB_CODE_RPC_REDIRECT) {
|
||||
|
|
|
@ -464,7 +464,7 @@ SArray *vmGetMsgHandles() {
|
|||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_PRE_SNAPSHOT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncCtrlQueue, 0) == NULL) goto _OVER;
|
||||
if (dmSetMgmtHandle(pArray, TDMT_SYNC_HEARTBEAT_REPLY, vmPutMsgToSyncQueue, 0) == NULL) goto _OVER;
|
||||
|
||||
code = 0;
|
||||
|
||||
|
|
|
@ -148,8 +148,8 @@ static int32_t vmPutMsgToQueue(SVnodeMgmt *pMgmt, SRpcMsg *pMsg, EQueueType qtyp
|
|||
|
||||
SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId);
|
||||
if (pVnode == NULL) {
|
||||
dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d", pHead->vgId, pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), qtype);
|
||||
dGError("vgId:%d, msg:%p failed to put into vnode queue since %s, type:%s qtype:%d contLen:%d", pHead->vgId, pMsg, terrstr(),
|
||||
TMSG_INFO(pMsg->msgType), qtype, pHead->contLen);
|
||||
return terrno != 0 ? terrno : -1;
|
||||
}
|
||||
|
||||
|
|
|
@ -325,9 +325,14 @@ static int32_t mndProcessMqTimerMsg(SRpcMsg *pMsg) {
|
|||
|
||||
static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
SMqHbReq *pReq = (SMqHbReq *)pMsg->pCont;
|
||||
int64_t consumerId = be64toh(pReq->consumerId);
|
||||
SMqHbReq req = {0};
|
||||
|
||||
if (tDeserializeSMqHbReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t consumerId = req.consumerId;
|
||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
||||
if (pConsumer == NULL) {
|
||||
mError("consumer %" PRId64 " not exist", consumerId);
|
||||
|
@ -359,10 +364,16 @@ static int32_t mndProcessMqHbReq(SRpcMsg *pMsg) {
|
|||
|
||||
static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
SMqAskEpReq *pReq = (SMqAskEpReq *)pMsg->pCont;
|
||||
SMqAskEpReq req = {0};
|
||||
SMqAskEpRsp rsp = {0};
|
||||
int64_t consumerId = be64toh(pReq->consumerId);
|
||||
int32_t epoch = ntohl(pReq->epoch);
|
||||
|
||||
if (tDeserializeSMqAskEpReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t consumerId = req.consumerId;
|
||||
int32_t epoch = req.epoch;
|
||||
|
||||
SMqConsumerObj *pConsumer = mndAcquireConsumer(pMnode, consumerId);
|
||||
if (pConsumer == NULL) {
|
||||
|
@ -370,7 +381,7 @@ static int32_t mndProcessAskEpReq(SRpcMsg *pMsg) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
ASSERT(strcmp(pReq->cgroup, pConsumer->cgroup) == 0);
|
||||
ASSERT(strcmp(req.cgroup, pConsumer->cgroup) == 0);
|
||||
|
||||
atomic_store_32(&pConsumer->hbStatus, 0);
|
||||
|
||||
|
|
|
@ -577,9 +577,9 @@ static int32_t mndCheckMnodeState(SRpcMsg *pMsg) {
|
|||
|
||||
int32_t contLen = tSerializeSEpSet(NULL, 0, &epSet);
|
||||
pMsg->info.rsp = rpcMallocCont(contLen);
|
||||
pMsg->info.hasEpSet = 1;
|
||||
if (pMsg->info.rsp != NULL) {
|
||||
tSerializeSEpSet(pMsg->info.rsp, contLen, &epSet);
|
||||
pMsg->info.hasEpSet = 1;
|
||||
pMsg->info.rspLen = contLen;
|
||||
terrno = TSDB_CODE_RPC_REDIRECT;
|
||||
} else {
|
||||
|
|
|
@ -63,81 +63,60 @@ int32_t mndProcessQueryMsg(SRpcMsg *pMsg) {
|
|||
return code;
|
||||
}
|
||||
|
||||
|
||||
static FORCE_INLINE void mnodeFreeSBatchRspMsg(void* p) {
|
||||
if (NULL == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
|
||||
rpcFreeCont(pRsp->msg);
|
||||
}
|
||||
|
||||
int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
||||
int32_t code = 0;
|
||||
int32_t offset = 0;
|
||||
int32_t rspSize = 0;
|
||||
SBatchReq *batchReq = (SBatchReq *)pMsg->pCont;
|
||||
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||
offset += sizeof(SBatchReq);
|
||||
SBatchReq batchReq = {0};
|
||||
SBatchMsg req = {0};
|
||||
SBatchRsp rsp = {0};
|
||||
SBatchRspMsg rsp = {0};
|
||||
SBatchRsp batchRsp = {0};
|
||||
SRpcMsg reqMsg = *pMsg;
|
||||
SRpcMsg rspMsg = {0};
|
||||
void *pRsp = NULL;
|
||||
SMnode *pMnode = pMsg->info.node;
|
||||
|
||||
if (tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
mError("tDeserializeSBatchReq failed");
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
|
||||
if (msgNum >= MAX_META_MSG_IN_BATCH) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
mError("too many msgs %d in mnode batch meta req", msgNum);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
SArray *batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||
if (NULL == batchRsp) {
|
||||
batchRsp.pRsps = taosArrayInit(msgNum, sizeof(SBatchRspMsg));
|
||||
if (NULL == batchRsp.pRsps) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
SBatchMsg* req = taosArrayGet(batchReq.pMsgs, i);
|
||||
|
||||
req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgIdx);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgLen);
|
||||
if (offset >= pMsg->contLen) {
|
||||
mError("offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msg = (char *)pMsg->pCont + offset;
|
||||
offset += req.msgLen;
|
||||
|
||||
reqMsg.msgType = req.msgType;
|
||||
reqMsg.pCont = req.msg;
|
||||
reqMsg.contLen = req.msgLen;
|
||||
reqMsg.msgType = req->msgType;
|
||||
reqMsg.pCont = req->msg;
|
||||
reqMsg.contLen = req->msgLen;
|
||||
reqMsg.info.rsp = NULL;
|
||||
reqMsg.info.rspLen = 0;
|
||||
|
||||
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(req.msgType)];
|
||||
MndMsgFp fp = pMnode->msgFp[TMSG_INDEX(req->msgType)];
|
||||
if (fp == NULL) {
|
||||
mError("msg:%p, failed to get msg handle, app:%p type:%s", pMsg, pMsg->info.ahandle, TMSG_INFO(pMsg->msgType));
|
||||
terrno = TSDB_CODE_MSG_NOT_PROCESSED;
|
||||
taosArrayDestroy(batchRsp);
|
||||
taosArrayDestroy(batchRsp.pRsps);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -146,49 +125,29 @@ int32_t mndProcessBatchMetaMsg(SRpcMsg *pMsg) {
|
|||
} else {
|
||||
rsp.rspCode = 0;
|
||||
}
|
||||
rsp.msgIdx = req.msgIdx;
|
||||
rsp.msgIdx = req->msgIdx;
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.info.rspLen;
|
||||
rsp.msg = reqMsg.info.rsp;
|
||||
|
||||
taosArrayPush(batchRsp, &rsp);
|
||||
|
||||
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||
taosArrayPush(batchRsp.pRsps, &rsp);
|
||||
}
|
||||
|
||||
rspSize += sizeof(int32_t);
|
||||
offset = 0;
|
||||
|
||||
rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp);
|
||||
if (rspSize < 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(msgNum);
|
||||
offset += sizeof(msgNum);
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx);
|
||||
offset += sizeof(p->msgIdx);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode);
|
||||
offset += sizeof(p->rspCode);
|
||||
if (p->msg != NULL) {
|
||||
memcpy((char *)pRsp + offset, p->msg, p->msgLen);
|
||||
offset += p->msgLen;
|
||||
}
|
||||
|
||||
rpcFreeCont(p->msg);
|
||||
if (tSerializeSBatchRsp(pRsp, rspSize, &batchRsp) < 0) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
taosArrayDestroy(batchRsp);
|
||||
batchRsp = NULL;
|
||||
|
||||
_exit:
|
||||
|
||||
pMsg->info.rsp = pRsp;
|
||||
|
@ -198,7 +157,8 @@ _exit:
|
|||
mError("mnd get batch meta failed cause of %s", tstrerror(code));
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||
taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
|
||||
taosArrayDestroyEx(batchRsp.pRsps, mnodeFreeSBatchRspMsg);
|
||||
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
ASSERT(taosArrayGetSize(pStream->tasks) == 1);
|
||||
|
||||
while (1) {
|
||||
SVgObj* pVgroup;
|
||||
SVgObj* pVgroup = NULL;
|
||||
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup);
|
||||
if (pIter == NULL) break;
|
||||
if (!mndVgroupInDb(pVgroup, pStream->targetDbUid)) {
|
||||
|
@ -258,6 +258,7 @@ int32_t mndAddShuffleSinkTasksToStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
pTask->tbSink.pSchemaWrapper = tCloneSSchemaWrapper(&pStream->outputSchema);
|
||||
ASSERT(pTask->tbSink.pSchemaWrapper);
|
||||
}
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -382,6 +383,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
qDestroyQueryPlan(pPlan);
|
||||
return -1;
|
||||
}
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
} else {
|
||||
if (mndAssignTaskToSnode(pMnode, pInnerTask, plan, pSnode) < 0) {
|
||||
sdbRelease(pSdb, pSnode);
|
||||
|
@ -396,6 +398,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
qDestroyQueryPlan(pPlan);
|
||||
return -1;
|
||||
}
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -459,6 +462,7 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) {
|
|||
pEpInfo->nodeId = pTask->nodeId;
|
||||
pEpInfo->taskId = pTask->taskId;
|
||||
taosArrayPush(pInnerTask->childEpInfo, &pEpInfo);
|
||||
sdbRelease(pSdb, pVgroup);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1187,11 +1187,11 @@ static int32_t mndCheckAlterColForTopic(SMnode *pMnode, const char *stbFullName,
|
|||
goto NEXT;
|
||||
}
|
||||
if (pCol->colId > 0 && pCol->colId == colId) {
|
||||
sdbRelease(pSdb, pTopic);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TOPIC;
|
||||
mError("topic:%s, check colId:%d conflicted", pTopic->name, pCol->colId);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
sdbRelease(pSdb, pTopic);
|
||||
return -1;
|
||||
}
|
||||
mInfo("topic:%s, check colId:%d passed", pTopic->name, pCol->colId);
|
||||
|
@ -1230,11 +1230,11 @@ static int32_t mndCheckAlterColForStream(SMnode *pMnode, const char *stbFullName
|
|||
goto NEXT;
|
||||
}
|
||||
if (pCol->colId > 0 && pCol->colId == colId) {
|
||||
sdbRelease(pSdb, pStream);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
terrno = TSDB_CODE_MND_STREAM_MUST_BE_DELETED;
|
||||
mError("stream:%s, check colId:%d conflicted", pStream->name, pCol->colId);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
sdbRelease(pSdb, pStream);
|
||||
return -1;
|
||||
}
|
||||
mInfo("stream:%s, check colId:%d passed", pStream->name, pCol->colId);
|
||||
|
@ -1279,11 +1279,11 @@ static int32_t mndCheckAlterColForTSma(SMnode *pMnode, const char *stbFullName,
|
|||
goto NEXT;
|
||||
}
|
||||
if ((pCol->colId) > 0 && (pCol->colId == colId)) {
|
||||
sdbRelease(pSdb, pSma);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
terrno = TSDB_CODE_MND_FIELD_CONFLICT_WITH_TSMA;
|
||||
mError("tsma:%s, check colId:%d conflicted", pSma->name, pCol->colId);
|
||||
nodesDestroyNode(pAst);
|
||||
nodesDestroyList(pNodeList);
|
||||
sdbRelease(pSdb, pSma);
|
||||
return -1;
|
||||
}
|
||||
mInfo("tsma:%s, check colId:%d passed", pSma->name, pCol->colId);
|
||||
|
|
|
@ -1277,9 +1277,11 @@ static int32_t mndTransExecuteRedoActionsSerial(SMnode *pMnode, STrans *pTrans)
|
|||
pAction->id);
|
||||
code = mndTransSync(pMnode, pTrans);
|
||||
if (code != 0) {
|
||||
pTrans->redoActionPos--;
|
||||
pTrans->code = terrno;
|
||||
mError("trans:%d, %s:%d is executed and failed to sync to other mnodes since %s", pTrans->id,
|
||||
mndTransStr(pAction->stage), pAction->id, terrstr());
|
||||
break;
|
||||
}
|
||||
} else if (code == TSDB_CODE_ACTION_IN_PROGRESS) {
|
||||
mInfo("trans:%d, %s:%d is in progress and wait it finish", pTrans->id, mndTransStr(pAction->stage), pAction->id);
|
||||
|
|
|
@ -1739,6 +1739,7 @@ static int32_t mndSplitVgroup(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, SVgObj
|
|||
code = 0;
|
||||
|
||||
_OVER:
|
||||
taosArrayDestroy(pArray);
|
||||
mndTransDrop(pTrans);
|
||||
sdbFreeRaw(pRaw);
|
||||
return code;
|
||||
|
@ -1907,6 +1908,7 @@ static int32_t mndBalanceVgroup(SMnode *pMnode, SRpcMsg *pReq, SArray *pArray) {
|
|||
}
|
||||
|
||||
_OVER:
|
||||
taosHashCleanup(pBalancedVgroups);
|
||||
mndTransDrop(pTrans);
|
||||
return code;
|
||||
}
|
||||
|
|
|
@ -239,6 +239,7 @@ int32_t tqReaderSetDataMsg(STqReader *pReader, const SSubmitReq *pMsg, int64_t v
|
|||
bool tqNextDataBlock(STqReader *pReader);
|
||||
bool tqNextDataBlockFilterOut(STqReader *pReader, SHashObj *filterOutUids);
|
||||
int32_t tqRetrieveDataBlock(SSDataBlock *pBlock, STqReader *pReader);
|
||||
int32_t tqRetrieveTaosxBlock(STqReader *pReader, SArray *blocks, SArray *schemas);
|
||||
|
||||
int32_t vnodeEnqueueStreamMsg(SVnode *pVnode, SRpcMsg *pMsg);
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ typedef struct SDataFWriter SDataFWriter;
|
|||
typedef struct SDataFReader SDataFReader;
|
||||
typedef struct SDelFWriter SDelFWriter;
|
||||
typedef struct SDelFReader SDelFReader;
|
||||
typedef struct SRowIter SRowIter;
|
||||
typedef struct STSDBRowIter STSDBRowIter;
|
||||
typedef struct STsdbFS STsdbFS;
|
||||
typedef struct SRowMerger SRowMerger;
|
||||
typedef struct STsdbReadSnap STsdbReadSnap;
|
||||
|
@ -111,9 +111,9 @@ static FORCE_INLINE int64_t tsdbLogicToFileSize(int64_t lSize, int32_t szPage) {
|
|||
void tsdbRowGetColVal(TSDBROW *pRow, STSchema *pTSchema, int32_t iCol, SColVal *pColVal);
|
||||
// int32_t tPutTSDBRow(uint8_t *p, TSDBROW *pRow);
|
||||
int32_t tsdbRowCmprFn(const void *p1, const void *p2);
|
||||
// SRowIter
|
||||
void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
||||
SColVal *tRowIterNext(SRowIter *pIter);
|
||||
// STSDBRowIter
|
||||
void tsdbRowIterInit(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema);
|
||||
SColVal *tsdbRowIterNext(STSDBRowIter *pIter);
|
||||
// SRowMerger
|
||||
int32_t tRowMergerInit2(SRowMerger *pMerger, STSchema *pResTSchema, TSDBROW *pRow, STSchema *pTSchema);
|
||||
int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema);
|
||||
|
@ -562,7 +562,7 @@ struct SDFileSet {
|
|||
SSttFile *aSttF[TSDB_MAX_STT_TRIGGER];
|
||||
};
|
||||
|
||||
struct SRowIter {
|
||||
struct STSDBRowIter {
|
||||
TSDBROW *pRow;
|
||||
STSchema *pTSchema;
|
||||
SColVal colVal;
|
||||
|
|
|
@ -403,6 +403,11 @@ int metaCreateTable(SMeta *pMeta, int64_t version, SVCreateTbReq *pReq, STableMe
|
|||
// validate req
|
||||
metaReaderInit(&mr, pMeta, 0);
|
||||
if (metaGetTableEntryByName(&mr, pReq->name) == 0) {
|
||||
if (pReq->type == TSDB_CHILD_TABLE && pReq->ctb.suid != mr.me.ctbEntry.suid) {
|
||||
terrno = TSDB_CODE_TDB_TABLE_IN_OTHER_STABLE;
|
||||
metaReaderClear(&mr);
|
||||
return -1;
|
||||
}
|
||||
pReq->uid = mr.me.uid;
|
||||
if (pReq->type == TSDB_CHILD_TABLE) {
|
||||
pReq->ctb.suid = mr.me.ctbEntry.suid;
|
||||
|
@ -976,6 +981,11 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA
|
|||
|
||||
/* get stbEntry*/
|
||||
tdbTbGet(pMeta->pUidIdx, &ctbEntry.ctbEntry.suid, sizeof(tb_uid_t), &pVal, &nVal);
|
||||
if (!pVal) {
|
||||
terrno = TSDB_CODE_INVALID_MSG;
|
||||
goto _err;
|
||||
}
|
||||
|
||||
tdbTbGet(pMeta->pTbDb, &((STbDbKey){.uid = ctbEntry.ctbEntry.suid, .version = ((SUidIdxVal *)pVal)[0].version}),
|
||||
sizeof(STbDbKey), (void **)&stbEntry.pBuf, &nVal);
|
||||
tdbFree(pVal);
|
||||
|
|
|
@ -203,10 +203,13 @@ static int32_t tdProcessTSmaInsertImpl(SSma *pSma, int64_t indexUid, const char
|
|||
goto _err;
|
||||
}
|
||||
|
||||
SBatchDeleteReq deleteReq;
|
||||
SBatchDeleteReq deleteReq = {0};
|
||||
SSubmitReq *pSubmitReq =
|
||||
tqBlockToSubmit(pSma->pVnode, (const SArray *)msg, pTsmaStat->pTSchema, &pTsmaStat->pTSma->schemaTag, true,
|
||||
pTsmaStat->pTSma->dstTbUid, pTsmaStat->pTSma->dstTbName, &deleteReq);
|
||||
// TODO deleteReq
|
||||
taosArrayDestroy(deleteReq.deleteReqs);
|
||||
|
||||
|
||||
if (!pSubmitReq) {
|
||||
smaError("vgId:%d, failed to gen submit blk while tsma insert for smaIndex %" PRIi64 " since %s", SMA_VID(pSma),
|
||||
|
|
|
@ -458,20 +458,26 @@ static int32_t tqInitTaosxRsp(STaosxRsp* pRsp, const SMqPollReq* pReq) {
|
|||
}
|
||||
|
||||
int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
||||
SMqPollReq* pReq = pMsg->pCont;
|
||||
int64_t consumerId = pReq->consumerId;
|
||||
int32_t reqEpoch = pReq->epoch;
|
||||
SMqPollReq req = {0};
|
||||
int32_t code = 0;
|
||||
STqOffsetVal reqOffset = pReq->reqOffset;
|
||||
STqOffsetVal fetchOffsetNew;
|
||||
SWalCkHead* pCkHead = NULL;
|
||||
|
||||
if (tDeserializeSMqPollReq(pMsg->pCont, pMsg->contLen, &req) < 0) {
|
||||
tqError("tDeserializeSMqPollReq %d failed", pMsg->contLen);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int64_t consumerId = req.consumerId;
|
||||
int32_t reqEpoch = req.epoch;
|
||||
STqOffsetVal reqOffset = req.reqOffset;
|
||||
|
||||
// 1.find handle
|
||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, pReq->subKey, strlen(pReq->subKey));
|
||||
STqHandle* pHandle = taosHashGet(pTq->pHandle, req.subKey, strlen(req.subKey));
|
||||
/*ASSERT(pHandle);*/
|
||||
if (pHandle == NULL) {
|
||||
tqError("tmq poll: no consumer handle for consumer:%" PRId64 ", in vgId:%d, subkey %s", consumerId,
|
||||
TD_VID(pTq->pVnode), pReq->subKey);
|
||||
TD_VID(pTq->pVnode), req.subKey);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -479,7 +485,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
if (pHandle->consumerId != consumerId) {
|
||||
tqError("tmq poll: consumer handle mismatch for consumer:%" PRId64
|
||||
", in vgId:%d, subkey %s, handle consumer id %" PRId64,
|
||||
consumerId, TD_VID(pTq->pVnode), pReq->subKey, pHandle->consumerId);
|
||||
consumerId, TD_VID(pTq->pVnode), req.subKey, pHandle->consumerId);
|
||||
terrno = TSDB_CODE_TMQ_CONSUMER_MISMATCH;
|
||||
return -1;
|
||||
}
|
||||
|
@ -493,13 +499,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
char buf[80];
|
||||
tFormatOffset(buf, 80, &reqOffset);
|
||||
tqDebug("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, recv poll req in vg %d, req offset %s", consumerId,
|
||||
pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf);
|
||||
req.epoch, pHandle->subKey, TD_VID(pTq->pVnode), buf);
|
||||
|
||||
// 2.reset offset if needed
|
||||
if (reqOffset.type > 0) {
|
||||
fetchOffsetNew = reqOffset;
|
||||
} else {
|
||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, pReq->subKey);
|
||||
STqOffset* pOffset = tqOffsetRead(pTq->pOffsetStore, req.subKey);
|
||||
if (pOffset != NULL) {
|
||||
fetchOffsetNew = pOffset->val;
|
||||
char formatBuf[80];
|
||||
|
@ -508,7 +514,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
TD_VID(pTq->pVnode), formatBuf);
|
||||
} else {
|
||||
if (reqOffset.type == TMQ_OFFSET__RESET_EARLIEAST) {
|
||||
if (pReq->useSnapshot) {
|
||||
if (req.useSnapshot) {
|
||||
if (pHandle->fetchMeta) {
|
||||
tqOffsetResetToMeta(&fetchOffsetNew, 0);
|
||||
} else {
|
||||
|
@ -520,21 +526,21 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
} else if (reqOffset.type == TMQ_OFFSET__RESET_LATEST) {
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
|
||||
tqInitDataRsp(&dataRsp, &req, pHandle->execHandle.subType);
|
||||
|
||||
tqOffsetResetToLog(&dataRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal));
|
||||
tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, offset reset to %" PRId64, consumerId,
|
||||
pHandle->subKey, TD_VID(pTq->pVnode), dataRsp.rspOffset.version);
|
||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||
if (tqSendDataRsp(pTq, pMsg, &req, &dataRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tDeleteSMqDataRsp(&dataRsp);
|
||||
return code;
|
||||
} else {
|
||||
STaosxRsp taosxRsp = {0};
|
||||
tqInitTaosxRsp(&taosxRsp, pReq);
|
||||
tqInitTaosxRsp(&taosxRsp, &req);
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, walGetLastVer(pTq->pVnode->pWal));
|
||||
if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) {
|
||||
if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
|
@ -543,7 +549,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
} else if (reqOffset.type == TMQ_OFFSET__RESET_NONE) {
|
||||
tqError("tmq poll: subkey %s, no offset committed for consumer %" PRId64
|
||||
" in vg %d, subkey %s, reset none failed",
|
||||
pHandle->subKey, consumerId, TD_VID(pTq->pVnode), pReq->subKey);
|
||||
pHandle->subKey, consumerId, TD_VID(pTq->pVnode), req.subKey);
|
||||
terrno = TSDB_CODE_TQ_NO_COMMITTED_OFFSET;
|
||||
return -1;
|
||||
}
|
||||
|
@ -552,7 +558,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
|
||||
if (pHandle->execHandle.subType == TOPIC_SUB_TYPE__COLUMN) {
|
||||
SMqDataRsp dataRsp = {0};
|
||||
tqInitDataRsp(&dataRsp, pReq, pHandle->execHandle.subType);
|
||||
tqInitDataRsp(&dataRsp, &req, pHandle->execHandle.subType);
|
||||
// lock
|
||||
taosWLockLatch(&pTq->pushLock);
|
||||
tqScanData(pTq, pHandle, &dataRsp, &fetchOffsetNew);
|
||||
|
@ -580,7 +586,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
#endif
|
||||
taosWUnLockLatch(&pTq->pushLock);
|
||||
|
||||
if (tqSendDataRsp(pTq, pMsg, pReq, &dataRsp) < 0) {
|
||||
if (tqSendDataRsp(pTq, pMsg, &req, &dataRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
|
||||
|
@ -599,13 +605,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SMqMetaRsp metaRsp = {0};
|
||||
|
||||
STaosxRsp taosxRsp = {0};
|
||||
tqInitTaosxRsp(&taosxRsp, pReq);
|
||||
tqInitTaosxRsp(&taosxRsp, &req);
|
||||
|
||||
if (fetchOffsetNew.type != TMQ_OFFSET__LOG) {
|
||||
tqScanTaosx(pTq, pHandle, &taosxRsp, &metaRsp, &fetchOffsetNew);
|
||||
|
||||
if (metaRsp.metaRspLen > 0) {
|
||||
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
|
||||
if (tqSendMetaPollRsp(pTq, pMsg, &req, &metaRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tqDebug("tmq poll: consumer %" PRId64 ", subkey %s, vg %d, send meta offset type:%d,uid:%" PRId64
|
||||
|
@ -618,7 +624,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
}
|
||||
|
||||
if (taosxRsp.blockNum > 0) {
|
||||
if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) {
|
||||
if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
|
@ -648,13 +654,13 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
if (consumerEpoch > reqEpoch) {
|
||||
tqWarn("tmq poll: consumer %" PRId64 " (epoch %d), subkey %s, vg %d offset %" PRId64
|
||||
", found new consumer epoch %d, discard req epoch %d",
|
||||
consumerId, pReq->epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch);
|
||||
consumerId, req.epoch, pHandle->subKey, TD_VID(pTq->pVnode), fetchVer, consumerEpoch, reqEpoch);
|
||||
break;
|
||||
}
|
||||
|
||||
if (tqFetchLog(pTq, pHandle, &fetchVer, &pCkHead) < 0) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) {
|
||||
if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
|
@ -665,17 +671,16 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
SWalCont* pHead = &pCkHead->head;
|
||||
|
||||
tqDebug("tmq poll: consumer:%" PRId64 ", (epoch %d) iter log, vgId:%d offset %" PRId64 " msgType %d", consumerId,
|
||||
pReq->epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
||||
req.epoch, TD_VID(pTq->pVnode), fetchVer, pHead->msgType);
|
||||
|
||||
if (pHead->msgType == TDMT_VND_SUBMIT) {
|
||||
SSubmitReq* pCont = (SSubmitReq*)&pHead->body;
|
||||
|
||||
if (tqTaosxScanLog(pTq, pHandle, pCont, &taosxRsp) < 0) {
|
||||
/*ASSERT(0);*/
|
||||
}
|
||||
if (taosxRsp.blockNum > 0 /* threshold */) {
|
||||
tqOffsetResetToLog(&taosxRsp.rspOffset, fetchVer);
|
||||
if (tqSendTaosxRsp(pTq, pMsg, pReq, &taosxRsp) < 0) {
|
||||
if (tqSendTaosxRsp(pTq, pMsg, &req, &taosxRsp) < 0) {
|
||||
code = -1;
|
||||
}
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
|
@ -693,7 +698,7 @@ int32_t tqProcessPollReq(STQ* pTq, SRpcMsg* pMsg) {
|
|||
metaRsp.resMsgType = pHead->msgType;
|
||||
metaRsp.metaRspLen = pHead->bodyLen;
|
||||
metaRsp.metaRsp = pHead->body;
|
||||
if (tqSendMetaPollRsp(pTq, pMsg, pReq, &metaRsp) < 0) {
|
||||
if (tqSendMetaPollRsp(pTq, pMsg, &req, &metaRsp) < 0) {
|
||||
code = -1;
|
||||
taosMemoryFreeClear(pCkHead);
|
||||
tDeleteSTaosxRsp(&taosxRsp);
|
||||
|
@ -1270,6 +1275,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
|||
if (streamTaskInput(pTask, (SStreamQueueItem*)pRefBlock) < 0) {
|
||||
qError("stream task input del failed, task id %d", pTask->taskId);
|
||||
|
||||
atomic_sub_fetch_32(pRef, 1);
|
||||
taosFreeQitem(pRefBlock);
|
||||
continue;
|
||||
}
|
||||
|
@ -1287,7 +1293,7 @@ int32_t tqProcessDelReq(STQ* pTq, void* pReq, int32_t len, int64_t ver) {
|
|||
int32_t ref = atomic_sub_fetch_32(pRef, 1);
|
||||
ASSERT(ref >= 0);
|
||||
if (ref == 0) {
|
||||
taosMemoryFree(pDelBlock);
|
||||
blockDataDestroy(pDelBlock);
|
||||
taosMemoryFree(pRef);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ static int32_t tqAddBlockSchemaToRsp(const STqExecHandle* pExec, SMqDataRsp* pRs
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
||||
static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp, int32_t n) {
|
||||
SMetaReader mr = {0};
|
||||
metaReaderInit(&mr, pTq->pVnode->pMeta, 0);
|
||||
// TODO add reference to gurantee success
|
||||
|
@ -52,8 +52,10 @@ static int32_t tqAddTbNameToRsp(const STQ* pTq, int64_t uid, SMqDataRsp* pRsp) {
|
|||
metaReaderClear(&mr);
|
||||
return -1;
|
||||
}
|
||||
char* tbName = strdup(mr.me.name);
|
||||
taosArrayPush(pRsp->blockTbName, &tbName);
|
||||
for (int32_t i = 0; i < n; i++) {
|
||||
char* tbName = strdup(mr.me.name);
|
||||
taosArrayPush(pRsp->blockTbName, &tbName);
|
||||
}
|
||||
metaReaderClear(&mr);
|
||||
return 0;
|
||||
}
|
||||
|
@ -111,7 +113,7 @@ int32_t tqScanData(STQ* pTq, const STqHandle* pHandle, SMqDataRsp* pRsp, STqOffs
|
|||
if (pRsp->withTbName) {
|
||||
if (pRsp->rspOffset.type == TMQ_OFFSET__LOG) {
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
tqAddTbNameToRsp(pTq, uid, pRsp);
|
||||
tqAddTbNameToRsp(pTq, uid, pRsp, 1);
|
||||
} else {
|
||||
pRsp->withTbName = false;
|
||||
}
|
||||
|
@ -155,7 +157,7 @@ int32_t tqScanTaosx(STQ* pTq, const STqHandle* pHandle, STaosxRsp* pRsp, SMqMeta
|
|||
int64_t uid = 0;
|
||||
if (pOffset->type == TMQ_OFFSET__LOG) {
|
||||
uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) {
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, 1) < 0) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -225,18 +227,30 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp
|
|||
STqExecHandle* pExec = &pHandle->execHandle;
|
||||
ASSERT(pExec->subType != TOPIC_SUB_TYPE__COLUMN);
|
||||
|
||||
SArray* pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||
SArray* pSchemas = taosArrayInit(0, sizeof(void*));
|
||||
|
||||
if (pExec->subType == TOPIC_SUB_TYPE__TABLE) {
|
||||
STqReader* pReader = pExec->pExecReader;
|
||||
tqReaderSetDataMsg(pReader, pReq, 0);
|
||||
while (tqNextDataBlock(pReader)) {
|
||||
SSDataBlock block = {0};
|
||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||
/*SSDataBlock block = {0};*/
|
||||
/*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/
|
||||
/*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/
|
||||
/*}*/
|
||||
|
||||
taosArrayClear(pBlocks);
|
||||
taosArrayClear(pSchemas);
|
||||
if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas) < 0) {
|
||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
}
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) {
|
||||
blockDataFreeRes(&block);
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
||||
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
|
||||
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSSchemaWrapper);
|
||||
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||
pSchemas = taosArrayInit(0, sizeof(void*));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -255,25 +269,37 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp
|
|||
pRsp->createTableNum++;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision);
|
||||
blockDataFreeRes(&block);
|
||||
tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);
|
||||
pRsp->blockNum++;
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
|
||||
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
||||
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision);
|
||||
blockDataFreeRes(pBlock);
|
||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
}
|
||||
} else if (pExec->subType == TOPIC_SUB_TYPE__DB) {
|
||||
STqReader* pReader = pExec->pExecReader;
|
||||
tqReaderSetDataMsg(pReader, pReq, 0);
|
||||
while (tqNextDataBlockFilterOut(pReader, pExec->execDb.pFilterOutTbUid)) {
|
||||
SSDataBlock block = {0};
|
||||
if (tqRetrieveDataBlock(&block, pReader) < 0) {
|
||||
/*SSDataBlock block = {0};*/
|
||||
/*if (tqRetrieveDataBlock(&block, pReader) < 0) {*/
|
||||
/*if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;*/
|
||||
/*}*/
|
||||
taosArrayClear(pBlocks);
|
||||
taosArrayClear(pSchemas);
|
||||
if (tqRetrieveTaosxBlock(pReader, pBlocks, pSchemas) < 0) {
|
||||
if (terrno == TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND) continue;
|
||||
}
|
||||
if (pRsp->withTbName) {
|
||||
int64_t uid = pExec->pExecReader->msgIter.uid;
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp) < 0) {
|
||||
blockDataFreeRes(&block);
|
||||
continue;
|
||||
if (tqAddTbNameToRsp(pTq, uid, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlocks)) < 0) {
|
||||
taosArrayDestroyEx(pBlocks, (FDelete)blockDataFreeRes);
|
||||
taosArrayDestroyP(pSchemas, (FDelete)tDeleteSSchemaWrapper);
|
||||
pBlocks = taosArrayInit(0, sizeof(SSDataBlock));
|
||||
pSchemas = taosArrayInit(0, sizeof(void*));
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (pHandle->fetchMeta) {
|
||||
|
@ -291,14 +317,26 @@ int32_t tqTaosxScanLog(STQ* pTq, STqHandle* pHandle, SSubmitReq* pReq, STaosxRsp
|
|||
pRsp->createTableNum++;
|
||||
}
|
||||
}
|
||||
tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision);
|
||||
blockDataFreeRes(&block);
|
||||
tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);
|
||||
pRsp->blockNum++;
|
||||
/*tqAddBlockDataToRsp(&block, (SMqDataRsp*)pRsp, taosArrayGetSize(block.pDataBlock),*/
|
||||
/*pTq->pVnode->config.tsdbCfg.precision);*/
|
||||
/*blockDataFreeRes(&block);*/
|
||||
/*tqAddBlockSchemaToRsp(pExec, (SMqDataRsp*)pRsp);*/
|
||||
/*pRsp->blockNum++;*/
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pBlocks); i++) {
|
||||
SSDataBlock* pBlock = taosArrayGet(pBlocks, i);
|
||||
tqAddBlockDataToRsp(pBlock, (SMqDataRsp*)pRsp, taosArrayGetSize(pBlock->pDataBlock),
|
||||
pTq->pVnode->config.tsdbCfg.precision);
|
||||
blockDataFreeRes(pBlock);
|
||||
SSchemaWrapper* pSW = taosArrayGetP(pSchemas, i);
|
||||
taosArrayPush(pRsp->blockSchema, &pSW);
|
||||
pRsp->blockNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
taosArrayDestroy(pBlocks);
|
||||
taosArrayDestroy(pSchemas);
|
||||
|
||||
if (pRsp->blockNum == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -308,9 +308,8 @@ int tqPushMsg(STQ* pTq, void* msg, int32_t msgLen, tmsg_t msgType, int64_t ver)
|
|||
}
|
||||
|
||||
if (vnodeIsRoleLeader(pTq->pVnode)) {
|
||||
if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
|
||||
if (msgType == TDMT_VND_SUBMIT) {
|
||||
if (taosHashGetSize(pTq->pStreamMeta->pTasks) == 0) return 0;
|
||||
|
||||
void* data = taosMemoryMalloc(msgLen);
|
||||
if (data == NULL) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
|
|
@ -398,6 +398,35 @@ bool tqNextDataBlock(STqReader* pReader) {
|
|||
return false;
|
||||
}
|
||||
|
||||
int32_t tqMaskBlock(SSchemaWrapper* pDst, SSDataBlock* pBlock, const SSchemaWrapper* pSrc, char* mask) {
|
||||
int32_t code;
|
||||
|
||||
int32_t cnt = 0;
|
||||
for (int32_t i = 0; i < pSrc->nCols; i++) {
|
||||
cnt += mask[i];
|
||||
}
|
||||
|
||||
pDst->nCols = cnt;
|
||||
pDst->pSchema = taosMemoryCalloc(cnt, sizeof(SSchema));
|
||||
if (pDst->pSchema == NULL) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
int32_t j = 0;
|
||||
for (int32_t i = 0; i < pSrc->nCols; i++) {
|
||||
if (mask[i]) {
|
||||
pDst->pSchema[j++] = pSrc->pSchema[i];
|
||||
SColumnInfoData colInfo =
|
||||
createColumnInfoData(pSrc->pSchema[i].type, pSrc->pSchema[i].bytes, pSrc->pSchema[i].colId);
|
||||
code = blockDataAppendColInfo(pBlock, &colInfo);
|
||||
if (code != 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool tqNextDataBlockFilterOut(STqReader* pHandle, SHashObj* filterOutUids) {
|
||||
while (1) {
|
||||
if (tGetSubmitMsgNext(&pHandle->msgIter, &pHandle->pBlock) < 0) {
|
||||
|
@ -527,6 +556,141 @@ FAIL:
|
|||
return -1;
|
||||
}
|
||||
|
||||
int32_t tqRetrieveTaosxBlock(STqReader* pReader, SArray* blocks, SArray* schemas) {
|
||||
int32_t sversion = htonl(pReader->pBlock->sversion);
|
||||
|
||||
if (pReader->cachedSchemaSuid == 0 || pReader->cachedSchemaVer != sversion ||
|
||||
pReader->cachedSchemaSuid != pReader->msgIter.suid) {
|
||||
if (pReader->pSchema) taosMemoryFree(pReader->pSchema);
|
||||
pReader->pSchema = metaGetTbTSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1);
|
||||
if (pReader->pSchema == NULL) {
|
||||
tqWarn("cannot found tsschema for table: uid:%" PRId64 " (suid:%" PRId64 "), version %d, possibly dropped table",
|
||||
pReader->msgIter.uid, pReader->msgIter.suid, pReader->cachedSchemaVer);
|
||||
/*ASSERT(0);*/
|
||||
pReader->cachedSchemaSuid = 0;
|
||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (pReader->pSchemaWrapper) tDeleteSSchemaWrapper(pReader->pSchemaWrapper);
|
||||
pReader->pSchemaWrapper = metaGetTableSchema(pReader->pVnodeMeta, pReader->msgIter.uid, sversion, 1);
|
||||
if (pReader->pSchemaWrapper == NULL) {
|
||||
tqWarn("cannot found schema wrapper for table: suid:%" PRId64 ", version %d, possibly dropped table",
|
||||
pReader->msgIter.uid, pReader->cachedSchemaVer);
|
||||
/*ASSERT(0);*/
|
||||
pReader->cachedSchemaSuid = 0;
|
||||
terrno = TSDB_CODE_TQ_TABLE_SCHEMA_NOT_FOUND;
|
||||
return -1;
|
||||
}
|
||||
pReader->cachedSchemaVer = sversion;
|
||||
pReader->cachedSchemaSuid = pReader->msgIter.suid;
|
||||
}
|
||||
|
||||
STSchema* pTschema = pReader->pSchema;
|
||||
SSchemaWrapper* pSchemaWrapper = pReader->pSchemaWrapper;
|
||||
|
||||
int32_t colAtMost = pSchemaWrapper->nCols;
|
||||
|
||||
int32_t curRow = 0;
|
||||
int32_t lastRow = 0;
|
||||
|
||||
char* assigned = taosMemoryCalloc(1, pSchemaWrapper->nCols);
|
||||
if (assigned == NULL) return -1;
|
||||
|
||||
tInitSubmitBlkIter(&pReader->msgIter, pReader->pBlock, &pReader->blkIter);
|
||||
STSRowIter iter = {0};
|
||||
tdSTSRowIterInit(&iter, pTschema);
|
||||
STSRow* row;
|
||||
|
||||
while ((row = tGetSubmitBlkNext(&pReader->blkIter)) != NULL) {
|
||||
bool buildNew = false;
|
||||
tdSTSRowIterReset(&iter, row);
|
||||
|
||||
tqDebug("vgId:%d, row of block %d", pReader->pWalReader->pWal->cfg.vgId, curRow);
|
||||
for (int32_t i = 0; i < colAtMost; i++) {
|
||||
SCellVal sVal = {0};
|
||||
if (!tdSTSRowIterFetch(&iter, pSchemaWrapper->pSchema[i].colId, pSchemaWrapper->pSchema[i].type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
tqDebug("vgId:%d, %d col, type %d", pReader->pWalReader->pWal->cfg.vgId, i, sVal.valType);
|
||||
if (curRow == 0) {
|
||||
assigned[i] = sVal.valType != TD_VTYPE_NONE;
|
||||
buildNew = true;
|
||||
} else {
|
||||
bool currentRowAssigned = sVal.valType != TD_VTYPE_NONE;
|
||||
if (currentRowAssigned != assigned[i]) {
|
||||
assigned[i] = currentRowAssigned;
|
||||
buildNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (buildNew) {
|
||||
if (taosArrayGetSize(blocks) > 0) {
|
||||
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
||||
pLastBlock->info.rows = curRow - lastRow;
|
||||
lastRow = curRow;
|
||||
}
|
||||
SSDataBlock* pBlock = createDataBlock();
|
||||
SSchemaWrapper* pSW = taosMemoryCalloc(1, sizeof(SSchemaWrapper));
|
||||
if (tqMaskBlock(pSW, pBlock, pSchemaWrapper, assigned) < 0) {
|
||||
blockDataDestroy(pBlock);
|
||||
goto FAIL;
|
||||
}
|
||||
SSDataBlock block = {0};
|
||||
assignOneDataBlock(&block, pBlock);
|
||||
blockDataDestroy(pBlock);
|
||||
|
||||
tqDebug("vgId:%d, build new block, col %d", pReader->pWalReader->pWal->cfg.vgId,
|
||||
(int32_t)taosArrayGetSize(block.pDataBlock));
|
||||
|
||||
taosArrayPush(blocks, &block);
|
||||
taosArrayPush(schemas, &pSW);
|
||||
}
|
||||
|
||||
SSDataBlock* pBlock = taosArrayGetLast(blocks);
|
||||
pBlock->info.uid = pReader->msgIter.uid;
|
||||
pBlock->info.rows = 0;
|
||||
pBlock->info.version = pReader->pMsg->version;
|
||||
|
||||
tqDebug("vgId:%d, taosx scan, block num: %d", pReader->pWalReader->pWal->cfg.vgId,
|
||||
(int32_t)taosArrayGetSize(blocks));
|
||||
|
||||
if (blockDataEnsureCapacity(pBlock, pReader->msgIter.numOfRows - curRow) < 0) {
|
||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto FAIL;
|
||||
}
|
||||
|
||||
tdSTSRowIterReset(&iter, row);
|
||||
for (int32_t i = 0; i < taosArrayGetSize(pBlock->pDataBlock); i++) {
|
||||
SColumnInfoData* pColData = taosArrayGet(pBlock->pDataBlock, i);
|
||||
SCellVal sVal = {0};
|
||||
|
||||
if (!tdSTSRowIterFetch(&iter, pColData->info.colId, pColData->info.type, &sVal)) {
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT(sVal.valType != TD_VTYPE_NONE);
|
||||
|
||||
if (colDataAppend(pColData, curRow, sVal.val, sVal.valType == TD_VTYPE_NULL) < 0) {
|
||||
goto FAIL;
|
||||
}
|
||||
tqDebug("vgId:%d, row %d col %d append %d", pReader->pWalReader->pWal->cfg.vgId, curRow, i,
|
||||
sVal.valType == TD_VTYPE_NULL);
|
||||
}
|
||||
curRow++;
|
||||
}
|
||||
SSDataBlock* pLastBlock = taosArrayGetLast(blocks);
|
||||
pLastBlock->info.rows = curRow - lastRow;
|
||||
|
||||
taosMemoryFree(assigned);
|
||||
return 0;
|
||||
|
||||
FAIL:
|
||||
taosMemoryFree(assigned);
|
||||
return -1;
|
||||
}
|
||||
|
||||
void tqReaderSetColIdList(STqReader* pReader, SArray* pColIdList) { pReader->pColIdList = pColIdList; }
|
||||
|
||||
int tqReaderSetTbUidList(STqReader* pReader, const SArray* tbUidList) {
|
||||
|
|
|
@ -236,6 +236,7 @@ SSubmitReq* tqBlockToSubmit(SVnode* pVnode, const SArray* pBlocks, const STSchem
|
|||
SSDataBlock* pDataBlock = taosArrayGet(pBlocks, i);
|
||||
if (pDataBlock->info.type == STREAM_DELETE_RESULT) {
|
||||
pDeleteReq->suid = suid;
|
||||
pDeleteReq->deleteReqs = taosArrayInit(0, sizeof(SSingleDeleteReq));
|
||||
tqBuildDeleteReq(pVnode, stbFullName, pDataBlock, pDeleteReq);
|
||||
continue;
|
||||
}
|
||||
|
@ -349,7 +350,6 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
|||
.contLen = len + sizeof(SMsgHead),
|
||||
};
|
||||
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
||||
rpcFreeCont(serializedDeleteReq);
|
||||
tqDebug("failed to put delete req into write-queue since %s", terrstr());
|
||||
}
|
||||
} else {
|
||||
|
@ -476,12 +476,12 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
|||
|
||||
cap += sizeof(SSubmitBlk) + schemaLen + rows * maxLen;
|
||||
|
||||
SSubmitReq* ret = rpcMallocCont(cap);
|
||||
ret->header.vgId = pVnode->config.vgId;
|
||||
ret->length = sizeof(SSubmitReq);
|
||||
ret->numOfBlocks = htonl(1);
|
||||
SSubmitReq* pSubmit = rpcMallocCont(cap);
|
||||
pSubmit->header.vgId = pVnode->config.vgId;
|
||||
pSubmit->length = sizeof(SSubmitReq);
|
||||
pSubmit->numOfBlocks = htonl(1);
|
||||
|
||||
SSubmitBlk* blkHead = POINTER_SHIFT(ret, sizeof(SSubmitReq));
|
||||
SSubmitBlk* blkHead = POINTER_SHIFT(pSubmit, sizeof(SSubmitReq));
|
||||
|
||||
blkHead->numOfRows = htonl(pDataBlock->info.rows);
|
||||
blkHead->sversion = htonl(pTSchema->version);
|
||||
|
@ -531,17 +531,16 @@ void tqSinkToTablePipeline(SStreamTask* pTask, void* vnode, int64_t ver, void* d
|
|||
}
|
||||
blkHead->dataLen = htonl(dataLen);
|
||||
|
||||
ret->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
ret->length = htonl(ret->length);
|
||||
pSubmit->length += sizeof(SSubmitBlk) + schemaLen + dataLen;
|
||||
pSubmit->length = htonl(pSubmit->length);
|
||||
|
||||
SRpcMsg msg = {
|
||||
.msgType = TDMT_VND_SUBMIT,
|
||||
.pCont = ret,
|
||||
.contLen = ntohl(ret->length),
|
||||
.pCont = pSubmit,
|
||||
.contLen = ntohl(pSubmit->length),
|
||||
};
|
||||
|
||||
if (tmsgPutToQueue(&pVnode->msgCb, WRITE_QUEUE, &msg) != 0) {
|
||||
rpcFreeCont(ret);
|
||||
tqDebug("failed to put into write-queue since %s", terrstr());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -287,12 +287,17 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
|||
hasRes = true;
|
||||
p->ts = pColVal->ts;
|
||||
|
||||
uint8_t* px = p->colVal.value.pData;
|
||||
p->colVal = pColVal->colVal;
|
||||
if (!IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||
p->colVal = pColVal->colVal;
|
||||
} else {
|
||||
if (COL_VAL_IS_VALUE(&pColVal->colVal)) {
|
||||
memcpy(p->colVal.value.pData, pColVal->colVal.value.pData, pColVal->colVal.value.nData);
|
||||
}
|
||||
|
||||
if (COL_VAL_IS_VALUE(&pColVal->colVal) && IS_VAR_DATA_TYPE(pColVal->colVal.type)) {
|
||||
p->colVal.value.pData = px;
|
||||
memcpy(px, pColVal->colVal.value.pData, pColVal->colVal.value.nData);
|
||||
p->colVal.value.nData = pColVal->colVal.value.nData;
|
||||
p->colVal.type = pColVal->colVal.type;
|
||||
p->colVal.flag = pColVal->colVal.flag;
|
||||
p->colVal.cid = pColVal->colVal.cid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,7 +341,7 @@ int32_t tsdbUpdateTableSchema(SMeta *pMeta, int64_t suid, int64_t uid, SSkmInfo
|
|||
|
||||
pSkmInfo->suid = suid;
|
||||
pSkmInfo->uid = uid;
|
||||
tTSchemaDestroy(pSkmInfo->pTSchema);
|
||||
tDestroyTSchema(pSkmInfo->pTSchema);
|
||||
code = metaGetTbTSchemaEx(pMeta, suid, uid, -1, &pSkmInfo->pTSchema);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -365,7 +365,7 @@ static int32_t tsdbCommitterUpdateRowSchema(SCommitter *pCommitter, int64_t suid
|
|||
|
||||
pCommitter->skmRow.suid = suid;
|
||||
pCommitter->skmRow.uid = uid;
|
||||
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmRow.pTSchema);
|
||||
code = metaGetTbTSchemaEx(pCommitter->pTsdb->pVnode->pMeta, suid, uid, sver, &pCommitter->skmRow.pTSchema);
|
||||
TSDB_CHECK_CODE(code, lino, _exit);
|
||||
|
||||
|
@ -498,7 +498,7 @@ static int32_t tsdbCommitFileDataStart(SCommitter *pCommitter) {
|
|||
#if 0
|
||||
ASSERT(pCommitter->minKey <= pCommitter->nextKey && pCommitter->maxKey >= pCommitter->nextKey);
|
||||
#endif
|
||||
|
||||
|
||||
pCommitter->nextKey = TSKEY_MAX;
|
||||
|
||||
// Reader
|
||||
|
@ -623,7 +623,8 @@ int32_t tsdbWriteDataBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SMapDa
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -666,7 +667,8 @@ int32_t tsdbWriteSttBlock(SDataFWriter *pWriter, SBlockData *pBlockData, SArray
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -706,7 +708,8 @@ static int32_t tsdbCommitSttBlk(SDataFWriter *pWriter, SDiskDataBuilder *pBuilde
|
|||
|
||||
_exit:
|
||||
if (code) {
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino, tstrerror(code));
|
||||
tsdbError("vgId:%d, %s failed at line %d since %s", TD_VID(pWriter->pTsdb->pVnode), __func__, lino,
|
||||
tstrerror(code));
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
@ -919,8 +922,8 @@ static void tsdbCommitDataEnd(SCommitter *pCommitter) {
|
|||
#else
|
||||
tBlockDataDestroy(&pCommitter->dWriter.bDatal, 1);
|
||||
#endif
|
||||
tTSchemaDestroy(pCommitter->skmTable.pTSchema);
|
||||
tTSchemaDestroy(pCommitter->skmRow.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmTable.pTSchema);
|
||||
tDestroyTSchema(pCommitter->skmRow.pTSchema);
|
||||
}
|
||||
|
||||
static int32_t tsdbCommitData(SCommitter *pCommitter) {
|
||||
|
|
|
@ -595,21 +595,21 @@ int32_t tDiskDataAddRow(SDiskDataBuilder *pBuilder, TSDBROW *pRow, STSchema *pTS
|
|||
if (pBuilder->bi.minKey > kRow.ts) pBuilder->bi.minKey = kRow.ts;
|
||||
if (pBuilder->bi.maxKey < kRow.ts) pBuilder->bi.maxKey = kRow.ts;
|
||||
|
||||
SRowIter iter = {0};
|
||||
tRowIterInit(&iter, pRow, pTSchema);
|
||||
STSDBRowIter iter = {0};
|
||||
tsdbRowIterInit(&iter, pRow, pTSchema);
|
||||
|
||||
SColVal *pColVal = tRowIterNext(&iter);
|
||||
SColVal *pColVal = tsdbRowIterNext(&iter);
|
||||
for (int32_t iBuilder = 0; iBuilder < pBuilder->nBuilder; iBuilder++) {
|
||||
SDiskColBuilder *pDCBuilder = (SDiskColBuilder *)taosArrayGet(pBuilder->aBuilder, iBuilder);
|
||||
|
||||
while (pColVal && pColVal->cid < pDCBuilder->cid) {
|
||||
pColVal = tRowIterNext(&iter);
|
||||
pColVal = tsdbRowIterNext(&iter);
|
||||
}
|
||||
|
||||
if (pColVal && pColVal->cid == pDCBuilder->cid) {
|
||||
code = tDiskColAddVal(pDCBuilder, pColVal);
|
||||
if (code) return code;
|
||||
pColVal = tRowIterNext(&iter);
|
||||
pColVal = tsdbRowIterNext(&iter);
|
||||
} else {
|
||||
code = tDiskColAddVal(pDCBuilder, &COL_VAL_NONE(pDCBuilder->cid, pDCBuilder->type));
|
||||
if (code) return code;
|
||||
|
|
|
@ -49,7 +49,7 @@ int tsdbOpen(SVnode *pVnode, STsdb **ppTsdb, const char *dir, STsdbKeepCfg *pKee
|
|||
|
||||
pTsdb->path = (char *)&pTsdb[1];
|
||||
snprintf(pTsdb->path, TD_PATH_MAX, "%s%s%s", pVnode->path, TD_DIRSEP, dir);
|
||||
taosRealPath(pTsdb->path, NULL, slen);
|
||||
// taosRealPath(pTsdb->path, NULL, slen);
|
||||
pTsdb->pVnode = pVnode;
|
||||
taosThreadRwlockInit(&pTsdb->rwLock, NULL);
|
||||
if (!pKeepCfg) {
|
||||
|
|
|
@ -305,7 +305,7 @@ static void* getPosInBlockInfoBuf(SBlockInfoBuf* pBuf, int32_t index) {
|
|||
}
|
||||
|
||||
// NOTE: speedup the whole processing by preparing the buffer for STableBlockScanInfo in batch model
|
||||
static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableKeyInfo* idList, int32_t numOfTables) {
|
||||
static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, SBlockInfoBuf* pBuf, const STableKeyInfo* idList, int32_t numOfTables) {
|
||||
// allocate buffer in order to load data blocks from file
|
||||
// todo use simple hash instead, optimize the memory consumption
|
||||
SHashObj* pTableMap =
|
||||
|
@ -315,10 +315,10 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
}
|
||||
|
||||
int64_t st = taosGetTimestampUs();
|
||||
initBlockScanInfoBuf(&pTsdbReader->blockInfoBuf, numOfTables);
|
||||
initBlockScanInfoBuf(pBuf, numOfTables);
|
||||
|
||||
for (int32_t j = 0; j < numOfTables; ++j) {
|
||||
STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(&pTsdbReader->blockInfoBuf, j);
|
||||
STableBlockScanInfo* pScanInfo = getPosInBlockInfoBuf(pBuf, j);
|
||||
pScanInfo->uid = idList[j].uid;
|
||||
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
|
||||
int64_t skey = pTsdbReader->window.skey;
|
||||
|
@ -329,20 +329,6 @@ static SHashObj* createDataBlockScanInfo(STsdbReader* pTsdbReader, const STableK
|
|||
}
|
||||
|
||||
taosHashPut(pTableMap, &pScanInfo->uid, sizeof(uint64_t), &pScanInfo, POINTER_BYTES);
|
||||
|
||||
#if 0
|
||||
// STableBlockScanInfo info = {.lastKey = 0, .uid = idList[j].uid};
|
||||
if (ASCENDING_TRAVERSE(pTsdbReader->order)) {
|
||||
int64_t skey = pTsdbReader->window.skey;
|
||||
info.lastKey = (skey > INT64_MIN) ? (skey - 1) : skey;
|
||||
} else {
|
||||
int64_t ekey = pTsdbReader->window.ekey;
|
||||
info.lastKey = (ekey < INT64_MAX) ? (ekey + 1) : ekey;
|
||||
}
|
||||
|
||||
taosHashPut(pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
||||
#endif
|
||||
|
||||
tsdbTrace("%p check table uid:%" PRId64 " from lastKey:%" PRId64 " %s", pTsdbReader, pScanInfo->uid,
|
||||
pScanInfo->lastKey, pTsdbReader->idStr);
|
||||
}
|
||||
|
@ -361,11 +347,17 @@ static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
|||
STableBlockScanInfo* pInfo = *(STableBlockScanInfo**)p;
|
||||
|
||||
pInfo->iterInit = false;
|
||||
pInfo->iter.hasVal = false;
|
||||
pInfo->iiter.hasVal = false;
|
||||
|
||||
if (pInfo->iter.iter != NULL) {
|
||||
pInfo->iter.iter = tsdbTbDataIterDestroy(pInfo->iter.iter);
|
||||
}
|
||||
|
||||
if (pInfo->iiter.iter != NULL) {
|
||||
pInfo->iiter.iter = tsdbTbDataIterDestroy(pInfo->iiter.iter);
|
||||
}
|
||||
|
||||
pInfo->delSkyline = taosArrayDestroy(pInfo->delSkyline);
|
||||
pInfo->lastKey = ts;
|
||||
}
|
||||
|
@ -373,6 +365,8 @@ static void resetAllDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
|||
|
||||
static void clearBlockScanInfo(STableBlockScanInfo* p) {
|
||||
p->iterInit = false;
|
||||
|
||||
p->iter.hasVal = false;
|
||||
p->iiter.hasVal = false;
|
||||
|
||||
if (p->iter.iter != NULL) {
|
||||
|
@ -388,9 +382,9 @@ static void clearBlockScanInfo(STableBlockScanInfo* p) {
|
|||
tMapDataClear(&p->mapData);
|
||||
}
|
||||
|
||||
static void destroyAllBlockScanInfo(SHashObj* pTableMap, bool clearEntry) {
|
||||
static void destroyAllBlockScanInfo(SHashObj* pTableMap) {
|
||||
void* p = NULL;
|
||||
while (clearEntry && ((p = taosHashIterate(pTableMap, p)) != NULL)) {
|
||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||
clearBlockScanInfo(*(STableBlockScanInfo**)p);
|
||||
}
|
||||
|
||||
|
@ -2226,6 +2220,7 @@ static int32_t initMemDataIterator(STableBlockScanInfo* pBlockScanInfo, STsdbRea
|
|||
if (pReader->pReadSnap->pMem != NULL) {
|
||||
d = tsdbGetTbDataFromMemTable(pReader->pReadSnap->pMem, pReader->suid, pBlockScanInfo->uid);
|
||||
if (d != NULL) {
|
||||
ASSERT(pBlockScanInfo->iter.iter == NULL);
|
||||
code = tsdbTbDataIterCreate(d, &startKey, backward, &pBlockScanInfo->iter.iter);
|
||||
if (code == TSDB_CODE_SUCCESS) {
|
||||
pBlockScanInfo->iter.hasVal = (tsdbTbDataIterGet(pBlockScanInfo->iter.iter) != NULL);
|
||||
|
@ -2437,7 +2432,8 @@ static int32_t buildComposedDataBlock(STsdbReader* pReader) {
|
|||
TSDBKEY keyInBuf = getCurrentKeyInBuf(pBlockScanInfo, pReader);
|
||||
|
||||
// it is a clean block, load it directly
|
||||
if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader)) {
|
||||
if (isCleanFileDataBlock(pReader, pBlockInfo, pBlock, pBlockScanInfo, keyInBuf, pLastBlockReader) &&
|
||||
pBlock->nRow <= pReader->capacity) {
|
||||
if (asc || ((!asc) && (!hasDataInLastBlock(pLastBlockReader)))) {
|
||||
copyBlockDataToSDataBlock(pReader, pBlockScanInfo);
|
||||
|
||||
|
@ -3789,11 +3785,10 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableL
|
|||
updateBlockSMAInfo(pReader->pSchema, &pReader->suppInfo);
|
||||
}
|
||||
|
||||
STsdbReader* p = pReader->innerReader[0] != NULL ? pReader->innerReader[0] : pReader;
|
||||
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList, numOfTables);
|
||||
STsdbReader* p = (pReader->innerReader[0] != NULL)? pReader->innerReader[0]:pReader;
|
||||
pReader->status.pTableMap = createDataBlockScanInfo(p, &pReader->blockInfoBuf, pTableList, numOfTables);
|
||||
if (pReader->status.pTableMap == NULL) {
|
||||
tsdbReaderClose(pReader);
|
||||
tsdbReaderClose(p);
|
||||
*ppReader = NULL;
|
||||
|
||||
code = TSDB_CODE_TDB_OUT_OF_MEMORY;
|
||||
|
@ -3849,7 +3844,7 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
}
|
||||
|
||||
{
|
||||
if (pReader->innerReader[0] != NULL) {
|
||||
if (pReader->innerReader[0] != NULL || pReader->innerReader[1] != NULL) {
|
||||
STsdbReader* p = pReader->innerReader[0];
|
||||
|
||||
p->status.pTableMap = NULL;
|
||||
|
@ -3887,9 +3882,12 @@ void tsdbReaderClose(STsdbReader* pReader) {
|
|||
cleanupDataBlockIterator(&pReader->status.blockIter);
|
||||
|
||||
size_t numOfTables = taosHashGetSize(pReader->status.pTableMap);
|
||||
destroyAllBlockScanInfo(pReader->status.pTableMap, (pReader->innerReader[0] == NULL) ? true : false);
|
||||
if (pReader->status.pTableMap != NULL) {
|
||||
destroyAllBlockScanInfo(pReader->status.pTableMap);
|
||||
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||
}
|
||||
|
||||
blockDataDestroy(pReader->pResBlock);
|
||||
clearBlockScanInfoBuf(&pReader->blockInfoBuf);
|
||||
|
||||
if (pReader->pFileReader != NULL) {
|
||||
tsdbDataFReaderClose(&pReader->pFileReader);
|
||||
|
@ -4118,9 +4116,13 @@ int32_t tsdbRetrieveDatablockSMA(STsdbReader* pReader, SColumnDataAgg*** pBlockS
|
|||
} else if (pAgg->colId < pSup->colIds[j]) {
|
||||
i += 1;
|
||||
} else if (pSup->colIds[j] < pAgg->colId) {
|
||||
if (pSup->colIds[j] == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||
taosArrayPush(pNewAggList, &pSup->tsColAgg);
|
||||
} else {
|
||||
// all date in this block are null
|
||||
SColumnDataAgg nullColAgg = {.colId = pSup->colIds[j], .numOfNull = pBlock->nRow};
|
||||
taosArrayPush(pNewAggList, &nullColAgg);
|
||||
SColumnDataAgg nullColAgg = {.colId = pSup->colIds[j], .numOfNull = pBlock->nRow};
|
||||
taosArrayPush(pNewAggList, &nullColAgg);
|
||||
}
|
||||
j += 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -555,7 +555,7 @@ int32_t tsdbSnapReaderClose(STsdbSnapReader** ppReader) {
|
|||
}
|
||||
|
||||
tBlockDataDestroy(&pReader->bData, 1);
|
||||
tTSchemaDestroy(pReader->skmTable.pTSchema);
|
||||
tDestroyTSchema(pReader->skmTable.pTSchema);
|
||||
|
||||
// del
|
||||
if (pReader->pDelFReader) tsdbDelFReaderClose(&pReader->pDelFReader);
|
||||
|
@ -1416,7 +1416,7 @@ int32_t tsdbSnapWriterClose(STsdbSnapWriter** ppWriter, int8_t rollback) {
|
|||
taosArrayDestroy(pWriter->dReader.aBlockIdx);
|
||||
|
||||
tBlockDataDestroy(&pWriter->bData, 1);
|
||||
tTSchemaDestroy(pWriter->skmTable.pTSchema);
|
||||
tDestroyTSchema(pWriter->skmTable.pTSchema);
|
||||
|
||||
for (int32_t iBuf = 0; iBuf < sizeof(pWriter->aBuf) / sizeof(uint8_t*); iBuf++) {
|
||||
tFree(pWriter->aBuf[iBuf]);
|
||||
|
|
|
@ -579,8 +579,8 @@ int32_t tsdbRowCmprFn(const void *p1, const void *p2) {
|
|||
return tsdbKeyCmprFn(&TSDBROW_KEY((TSDBROW *)p1), &TSDBROW_KEY((TSDBROW *)p2));
|
||||
}
|
||||
|
||||
// SRowIter ======================================================
|
||||
void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
||||
// STSDBRowIter ======================================================
|
||||
void tsdbRowIterInit(STSDBRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
||||
pIter->pRow = pRow;
|
||||
if (pRow->type == 0) {
|
||||
ASSERT(pTSchema);
|
||||
|
@ -594,7 +594,7 @@ void tRowIterInit(SRowIter *pIter, TSDBROW *pRow, STSchema *pTSchema) {
|
|||
}
|
||||
}
|
||||
|
||||
SColVal *tRowIterNext(SRowIter *pIter) {
|
||||
SColVal *tsdbRowIterNext(STSDBRowIter *pIter) {
|
||||
if (pIter->pRow->type == 0) {
|
||||
if (pIter->i < pIter->pTSchema->numOfCols) {
|
||||
tTSRowGetVal(pIter->pRow->pTSRow, pIter->pTSchema, pIter->i, &pIter->colVal);
|
||||
|
@ -704,8 +704,7 @@ int32_t tRowMergerAdd(SRowMerger *pMerger, TSDBROW *pRow, STSchema *pTSchema) {
|
|||
taosArraySet(pMerger->pArray, iCol, pColVal);
|
||||
}
|
||||
} else {
|
||||
// ASSERT(0);
|
||||
tsdbError("dup key accounted: key version:%" PRId64 ", merger version:%" PRId64, key.version, pMerger->version);
|
||||
ASSERT(0 && "dup versions not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1084,11 +1083,11 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
|
|||
cv.flag = CV_FLAG_VALUE;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
void *pData = (char *)pRow + *(int32_t *)(pRow->data + pTColumn->offset - sizeof(TSKEY));
|
||||
void *pData = (char *)pRow + *(int32_t *)(pRow->data + pTColumn->offset);
|
||||
cv.value.nData = varDataLen(pData);
|
||||
cv.value.pData = varDataVal(pData);
|
||||
} else {
|
||||
memcpy(&cv.value.val, pRow->data + pTColumn->offset - sizeof(TSKEY), pTColumn->bytes);
|
||||
memcpy(&cv.value.val, pRow->data + pTColumn->offset, pTColumn->bytes);
|
||||
}
|
||||
|
||||
code = tColDataAppendValue(pColData, &cv);
|
||||
|
@ -1106,11 +1105,11 @@ static int32_t tBlockDataAppendTPRow(SBlockData *pBlockData, STSRow *pRow, STSch
|
|||
cv.flag = CV_FLAG_VALUE;
|
||||
|
||||
if (IS_VAR_DATA_TYPE(pTColumn->type)) {
|
||||
void *pData = (char *)pRow + *(int32_t *)(pRow->data + pTColumn->offset - sizeof(TSKEY));
|
||||
void *pData = (char *)pRow + *(int32_t *)(pRow->data + pTColumn->offset);
|
||||
cv.value.nData = varDataLen(pData);
|
||||
cv.value.pData = varDataVal(pData);
|
||||
} else {
|
||||
memcpy(&cv.value.val, pRow->data + pTColumn->offset - sizeof(TSKEY), pTColumn->bytes);
|
||||
memcpy(&cv.value.val, pRow->data + pTColumn->offset, pTColumn->bytes);
|
||||
}
|
||||
|
||||
code = tColDataAppendValue(pColData, &cv);
|
||||
|
@ -1698,7 +1697,7 @@ int32_t tsdbCmprColData(SColData *pColData, int8_t cmprAlg, SBlockCol *pBlockCol
|
|||
size += pBlockCol->szBitmap;
|
||||
|
||||
// offset
|
||||
if (IS_VAR_DATA_TYPE(pColData->type)) {
|
||||
if (IS_VAR_DATA_TYPE(pColData->type) && pColData->flag != (HAS_NULL | HAS_NONE)) {
|
||||
code = tsdbCmprData((uint8_t *)pColData->aOffset, sizeof(int32_t) * pColData->nVal, TSDB_DATA_TYPE_INT, cmprAlg,
|
||||
ppOut, nOut + size, &pBlockCol->szOffset, ppBuf);
|
||||
if (code) goto _exit;
|
||||
|
|
|
@ -264,77 +264,55 @@ _exit:
|
|||
return TSDB_CODE_SUCCESS;
|
||||
}
|
||||
|
||||
static FORCE_INLINE void vnodeFreeSBatchRspMsg(void* p) {
|
||||
if (NULL == p) {
|
||||
return;
|
||||
}
|
||||
|
||||
SBatchRspMsg* pRsp = (SBatchRspMsg*)p;
|
||||
rpcFreeCont(pRsp->msg);
|
||||
}
|
||||
|
||||
|
||||
int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
||||
int32_t code = 0;
|
||||
int32_t offset = 0;
|
||||
int32_t rspSize = 0;
|
||||
SBatchReq *batchReq = (SBatchReq *)pMsg->pCont;
|
||||
int32_t msgNum = ntohl(batchReq->msgNum);
|
||||
offset += sizeof(SBatchReq);
|
||||
SBatchMsg req = {0};
|
||||
SBatchRsp rsp = {0};
|
||||
SBatchReq batchReq = {0};
|
||||
SBatchMsg *req = NULL;
|
||||
SBatchRspMsg rsp = {0};
|
||||
SBatchRsp batchRsp = {0};
|
||||
SRpcMsg reqMsg = *pMsg;
|
||||
SRpcMsg rspMsg = {0};
|
||||
void *pRsp = NULL;
|
||||
|
||||
if (tDeserializeSBatchReq(pMsg->pCont, pMsg->contLen, &batchReq)) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
qError("tDeserializeSBatchReq failed");
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
int32_t msgNum = taosArrayGetSize(batchReq.pMsgs);
|
||||
if (msgNum >= MAX_META_MSG_IN_BATCH) {
|
||||
code = TSDB_CODE_INVALID_MSG;
|
||||
qError("too many msgs %d in vnode batch meta req", msgNum);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
SArray *batchRsp = taosArrayInit(msgNum, sizeof(SBatchRsp));
|
||||
if (NULL == batchRsp) {
|
||||
batchRsp.pRsps = taosArrayInit(msgNum, sizeof(SBatchRspMsg));
|
||||
if (NULL == batchRsp.pRsps) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
qError("taosArrayInit %d SBatchRspMsg failed", msgNum);
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
req = taosArrayGet(batchReq.pMsgs, i);
|
||||
|
||||
req.msgIdx = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgIdx);
|
||||
reqMsg.msgType = req->msgType;
|
||||
reqMsg.pCont = req->msg;
|
||||
reqMsg.contLen = req->msgLen;
|
||||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msgType = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgType);
|
||||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msgLen = ntohl(*(int32_t *)((char *)pMsg->pCont + offset));
|
||||
offset += sizeof(req.msgLen);
|
||||
|
||||
if (offset >= pMsg->contLen) {
|
||||
qError("vnode offset %d is bigger than contLen %d", offset, pMsg->contLen);
|
||||
terrno = TSDB_CODE_INVALID_MSG_LEN;
|
||||
taosArrayDestroy(batchRsp);
|
||||
return -1;
|
||||
}
|
||||
|
||||
req.msg = (char *)pMsg->pCont + offset;
|
||||
offset += req.msgLen;
|
||||
|
||||
reqMsg.msgType = req.msgType;
|
||||
reqMsg.pCont = req.msg;
|
||||
reqMsg.contLen = req.msgLen;
|
||||
|
||||
switch (req.msgType) {
|
||||
switch (req->msgType) {
|
||||
case TDMT_VND_TABLE_META:
|
||||
vnodeGetTableMeta(pVnode, &reqMsg, false);
|
||||
break;
|
||||
|
@ -342,62 +320,39 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) {
|
|||
vnodeGetTableCfg(pVnode, &reqMsg, false);
|
||||
break;
|
||||
default:
|
||||
qError("invalid req msgType %d", req.msgType);
|
||||
qError("invalid req msgType %d", req->msgType);
|
||||
reqMsg.code = TSDB_CODE_INVALID_MSG;
|
||||
reqMsg.pCont = NULL;
|
||||
reqMsg.contLen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
rsp.msgIdx = req.msgIdx;
|
||||
rsp.msgIdx = req->msgIdx;
|
||||
rsp.reqType = reqMsg.msgType;
|
||||
rsp.msgLen = reqMsg.contLen;
|
||||
rsp.rspCode = reqMsg.code;
|
||||
rsp.msg = reqMsg.pCont;
|
||||
|
||||
taosArrayPush(batchRsp, &rsp);
|
||||
|
||||
rspSize += sizeof(rsp) + rsp.msgLen - POINTER_BYTES;
|
||||
taosArrayPush(batchRsp.pRsps, &rsp);
|
||||
}
|
||||
|
||||
rspSize += sizeof(int32_t);
|
||||
offset = 0;
|
||||
|
||||
if (rspSize > MAX_META_BATCH_RSP_SIZE) {
|
||||
qError("rspSize:%d overload", rspSize);
|
||||
code = TSDB_CODE_INVALID_MSG_LEN;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
rspSize = tSerializeSBatchRsp(NULL, 0, &batchRsp);
|
||||
if (rspSize < 0) {
|
||||
qError("tSerializeSBatchRsp failed");
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(msgNum);
|
||||
offset += sizeof(msgNum);
|
||||
for (int32_t i = 0; i < msgNum; ++i) {
|
||||
SBatchRsp *p = taosArrayGet(batchRsp, i);
|
||||
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->reqType);
|
||||
offset += sizeof(p->reqType);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgIdx);
|
||||
offset += sizeof(p->msgIdx);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->msgLen);
|
||||
offset += sizeof(p->msgLen);
|
||||
*(int32_t *)((char *)pRsp + offset) = htonl(p->rspCode);
|
||||
offset += sizeof(p->rspCode);
|
||||
if (p->msg) {
|
||||
memcpy((char *)pRsp + offset, p->msg, p->msgLen);
|
||||
offset += p->msgLen;
|
||||
}
|
||||
|
||||
taosMemoryFreeClear(p->msg);
|
||||
pRsp = rpcMallocCont(rspSize);
|
||||
if (pRsp == NULL) {
|
||||
qError("rpcMallocCont %d failed", rspSize);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
if (tSerializeSBatchRsp(pRsp, rspSize, &batchRsp) < 0) {
|
||||
qError("tSerializeSBatchRsp %d failed", rspSize);
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
goto _exit;
|
||||
}
|
||||
|
||||
taosArrayDestroy(batchRsp);
|
||||
batchRsp = NULL;
|
||||
|
||||
_exit:
|
||||
|
||||
|
@ -411,7 +366,8 @@ _exit:
|
|||
qError("vnd get batch meta failed cause of %s", tstrerror(code));
|
||||
}
|
||||
|
||||
taosArrayDestroyEx(batchRsp, tFreeSBatchRsp);
|
||||
taosArrayDestroyEx(batchReq.pMsgs, tFreeSBatchReqMsg);
|
||||
taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
|
||||
|
||||
tmsgSendRsp(&rspMsg);
|
||||
|
||||
|
|
|
@ -616,6 +616,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
|||
_exit:
|
||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||
pCreateReq = req.pReqs + iReq;
|
||||
taosMemoryFree(pCreateReq->comment);
|
||||
taosArrayDestroy(pCreateReq->ctb.tagName);
|
||||
}
|
||||
taosArrayDestroyEx(rsp.pArray, tFreeSVCreateTbRsp);
|
||||
|
|
|
@ -298,35 +298,24 @@ static int32_t vnodeSyncGetSnapshot(const SSyncFSM *pFsm, SSnapshot *pSnapshot)
|
|||
static void vnodeSyncApplyMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
|
||||
if (pMeta->code == 0) {
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||
rpcMsg.info = pMsg->info;
|
||||
rpcMsg.info.conn.applyIndex = pMeta->index;
|
||||
rpcMsg.info.conn.applyTerm = pMeta->term;
|
||||
SRpcMsg rpcMsg = {.msgType = pMsg->msgType, .contLen = pMsg->contLen};
|
||||
rpcMsg.pCont = rpcMallocCont(rpcMsg.contLen);
|
||||
memcpy(rpcMsg.pCont, pMsg->pCont, pMsg->contLen);
|
||||
rpcMsg.info = pMsg->info;
|
||||
rpcMsg.info.conn.applyIndex = pMeta->index;
|
||||
rpcMsg.info.conn.applyTerm = pMeta->term;
|
||||
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak,
|
||||
pMeta->code, pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||
const STraceId *trace = &pMsg->info.traceId;
|
||||
vGTrace("vgId:%d, commit-cb is excuted, fsm:%p, index:%" PRId64 ", term:%" PRIu64 ", msg-index:%" PRId64
|
||||
", weak:%d, code:%d, state:%d %s, type:%s",
|
||||
pVnode->config.vgId, pFsm, pMeta->index, pMeta->term, rpcMsg.info.conn.applyIndex, pMeta->isWeak, pMeta->code,
|
||||
pMeta->state, syncStr(pMeta->state), TMSG_INFO(pMsg->msgType));
|
||||
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
} else {
|
||||
SRpcMsg rsp = {.code = pMeta->code, .info = pMsg->info};
|
||||
vError("vgId:%d, commit-cb execute error, type:%s, index:%" PRId64 ", error:0x%x %s", pVnode->config.vgId,
|
||||
TMSG_INFO(pMsg->msgType), pMeta->index, pMeta->code, tstrerror(pMeta->code));
|
||||
if (rsp.info.handle != NULL) {
|
||||
tmsgSendRsp(&rsp);
|
||||
}
|
||||
}
|
||||
tmsgPutToQueue(&pVnode->msgCb, APPLY_QUEUE, &rpcMsg);
|
||||
}
|
||||
|
||||
static void vnodeSyncCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
if (pMeta->isWeak == 0) {
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
vnodeSyncApplyMsg(pFsm, pMsg, pMeta);
|
||||
}
|
||||
|
||||
static void vnodeSyncPreCommitMsg(const SSyncFSM *pFsm, const SRpcMsg *pMsg, const SFsmCbMeta *pMeta) {
|
||||
|
@ -420,7 +409,7 @@ static void vnodeRestoreFinish(const SSyncFSM *pFsm) {
|
|||
|
||||
static void vnodeBecomeFollower(const SSyncFSM *pFsm) {
|
||||
SVnode *pVnode = pFsm->data;
|
||||
vDebug("vgId:%d, become follower", pVnode->config.vgId);
|
||||
vInfo("vgId:%d, become follower", pVnode->config.vgId);
|
||||
|
||||
taosThreadMutexLock(&pVnode->lock);
|
||||
if (pVnode->blocked) {
|
||||
|
|
|
@ -234,7 +234,6 @@ typedef struct SCatalog {
|
|||
typedef struct SCtgBatch {
|
||||
int32_t batchId;
|
||||
int32_t msgType;
|
||||
int32_t msgSize;
|
||||
SArray* pMsgs;
|
||||
SRequestConnInfo conn;
|
||||
char dbFName[TSDB_DB_FNAME_LEN];
|
||||
|
|
|
@ -26,19 +26,29 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
SCatalog* pCtg = pJob->pCtg;
|
||||
int32_t taskNum = taosArrayGetSize(cbParam->taskId);
|
||||
SDataBuf taskMsg = *pMsg;
|
||||
int32_t offset = 0;
|
||||
int32_t msgNum = (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) ? ntohl(*(int32_t*)pMsg->pData) : 0;
|
||||
int32_t msgNum = 0;
|
||||
SBatchRsp batchRsp = {0};
|
||||
SBatchRspMsg rsp = {0};
|
||||
SBatchRspMsg *pRsp = NULL;
|
||||
|
||||
if (TSDB_CODE_SUCCESS == rspCode && pMsg->pData && (pMsg->len > 0)) {
|
||||
if (tDeserializeSBatchRsp(pMsg->pData, pMsg->len, &batchRsp) < 0) {
|
||||
ctgError("tDeserializeSBatchRsp failed, msgLen:%d", pMsg->len);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
msgNum = taosArrayGetSize(batchRsp.pRsps);
|
||||
}
|
||||
|
||||
ASSERT(taskNum == msgNum || 0 == msgNum);
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg got batch %d rsp %s", pJob->queryId, cbParam->batchId,
|
||||
TMSG_INFO(cbParam->reqType + 1));
|
||||
|
||||
offset += sizeof(msgNum);
|
||||
SBatchRsp rsp = {0};
|
||||
SHashObj* pBatchs = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK);
|
||||
if (NULL == pBatchs) {
|
||||
ctgError("taosHashInit %d batch failed", taskNum);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
for (int32_t i = 0; i < taskNum; ++i) {
|
||||
|
@ -46,25 +56,18 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
int32_t* msgIdx = taosArrayGet(cbParam->msgIdx, i);
|
||||
SCtgTask* pTask = taosArrayGet(pJob->pTasks, *taskId);
|
||||
if (msgNum > 0) {
|
||||
rsp.reqType = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.reqType);
|
||||
rsp.msgIdx = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.msgIdx);
|
||||
rsp.msgLen = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.msgLen);
|
||||
rsp.rspCode = ntohl(*(int32_t*)((char*)pMsg->pData + offset));
|
||||
offset += sizeof(rsp.rspCode);
|
||||
rsp.msg = ((char*)pMsg->pData) + offset;
|
||||
offset += rsp.msgLen;
|
||||
pRsp = taosArrayGet(batchRsp.pRsps, i);
|
||||
|
||||
taskMsg.msgType = rsp.reqType;
|
||||
taskMsg.pData = rsp.msg;
|
||||
taskMsg.len = rsp.msgLen;
|
||||
taskMsg.msgType = pRsp->reqType;
|
||||
taskMsg.pData = pRsp->msg;
|
||||
taskMsg.len = pRsp->msgLen;
|
||||
|
||||
ASSERT(rsp.msgIdx == *msgIdx);
|
||||
ASSERT(pRsp->msgIdx == *msgIdx);
|
||||
} else {
|
||||
rsp.msgIdx = *msgIdx;
|
||||
rsp.reqType = -1;
|
||||
pRsp = &rsp;
|
||||
pRsp->msgIdx = *msgIdx;
|
||||
pRsp->reqType = -1;
|
||||
pRsp->rspCode = 0;
|
||||
taskMsg.msgType = -1;
|
||||
taskMsg.pData = NULL;
|
||||
taskMsg.len = 0;
|
||||
|
@ -72,20 +75,22 @@ int32_t ctgHandleBatchRsp(SCtgJob* pJob, SCtgTaskCallbackParam* cbParam, SDataBu
|
|||
|
||||
SCtgTaskReq tReq;
|
||||
tReq.pTask = pTask;
|
||||
tReq.msgIdx = rsp.msgIdx;
|
||||
tReq.msgIdx = pRsp->msgIdx;
|
||||
SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq.msgIdx);
|
||||
pMsgCtx->pBatchs = pBatchs;
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg task %d idx %d start to handle rsp %s, pBatchs: %p", pJob->queryId, pTask->taskId,
|
||||
rsp.msgIdx, TMSG_INFO(taskMsg.msgType + 1), pBatchs);
|
||||
pRsp->msgIdx, TMSG_INFO(taskMsg.msgType + 1), pBatchs);
|
||||
|
||||
(*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, rsp.reqType, &taskMsg, (rsp.rspCode ? rsp.rspCode : rspCode));
|
||||
(*gCtgAsyncFps[pTask->type].handleRspFp)(&tReq, pRsp->reqType, &taskMsg, (pRsp->rspCode ? pRsp->rspCode : rspCode));
|
||||
}
|
||||
|
||||
CTG_ERR_JRET(ctgLaunchBatchs(pJob->pCtg, pJob, pBatchs));
|
||||
|
||||
_return:
|
||||
|
||||
taosArrayDestroyEx(batchRsp.pRsps, tFreeSBatchRspMsg);
|
||||
|
||||
ctgFreeBatchs(pBatchs);
|
||||
CTG_RET(code);
|
||||
}
|
||||
|
@ -481,7 +486,6 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
if (NULL == taosArrayPush(newBatch.pMsgIdxs, &req.msgIdx)) {
|
||||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
newBatch.msgSize = sizeof(SBatchReq) + sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
SName* pName = NULL;
|
||||
|
@ -533,8 +537,6 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT
|
|||
CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
pBatch->msgSize += sizeof(req) + msgSize - POINTER_BYTES;
|
||||
|
||||
if (vgId > 0) {
|
||||
SName* pName = NULL;
|
||||
if (TDMT_VND_TABLE_CFG == msgType) {
|
||||
|
@ -570,38 +572,35 @@ _return:
|
|||
return code;
|
||||
}
|
||||
|
||||
int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg) {
|
||||
*msg = taosMemoryCalloc(1, pBatch->msgSize);
|
||||
if (NULL == (*msg)) {
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
int32_t offset = 0;
|
||||
int32_t ctgBuildBatchReqMsg(SCtgBatch* pBatch, int32_t vgId, void** msg, int32_t *pSize) {
|
||||
int32_t num = taosArrayGetSize(pBatch->pMsgs);
|
||||
SBatchReq* pBatchReq = (SBatchReq*)(*msg);
|
||||
|
||||
if (num >= CTG_MAX_REQ_IN_BATCH) {
|
||||
qError("too many msgs %d in one batch request", num);
|
||||
CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT);
|
||||
}
|
||||
|
||||
pBatchReq->header.vgId = htonl(vgId);
|
||||
pBatchReq->msgNum = htonl(num);
|
||||
offset += sizeof(SBatchReq);
|
||||
SBatchReq batchReq = {0};
|
||||
|
||||
for (int32_t i = 0; i < num; ++i) {
|
||||
SBatchMsg* pReq = taosArrayGet(pBatch->pMsgs, i);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgIdx);
|
||||
offset += sizeof(pReq->msgIdx);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgType);
|
||||
offset += sizeof(pReq->msgType);
|
||||
*(int32_t*)((char*)(*msg) + offset) = htonl(pReq->msgLen);
|
||||
offset += sizeof(pReq->msgLen);
|
||||
memcpy((char*)(*msg) + offset, pReq->msg, pReq->msgLen);
|
||||
offset += pReq->msgLen;
|
||||
batchReq.header.vgId = vgId;
|
||||
batchReq.pMsgs = pBatch->pMsgs;
|
||||
|
||||
int32_t msgSize = tSerializeSBatchReq(NULL, 0, &batchReq);
|
||||
if (msgSize < 0) {
|
||||
qError("tSerializeSBatchReq failed");
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
*msg = taosMemoryCalloc(1, msgSize);
|
||||
if (NULL == (*msg)) {
|
||||
qError("calloc batchReq msg failed, size:%d", msgSize);
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
if (tSerializeSBatchReq(*msg, msgSize, &batchReq) < 0) {
|
||||
qError("tSerializeSBatchReq failed");
|
||||
CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY);
|
||||
}
|
||||
|
||||
ASSERT(pBatch->msgSize == offset);
|
||||
*pSize = msgSize;
|
||||
|
||||
qDebug("batch req %d to vg %d msg built with %d meta reqs", pBatch->batchId, vgId, num);
|
||||
|
||||
|
@ -616,12 +615,13 @@ int32_t ctgLaunchBatchs(SCatalog* pCtg, SCtgJob* pJob, SHashObj* pBatchs) {
|
|||
size_t len = 0;
|
||||
int32_t* vgId = taosHashGetKey(p, &len);
|
||||
SCtgBatch* pBatch = (SCtgBatch*)p;
|
||||
int32_t msgSize = 0;
|
||||
|
||||
ctgDebug("QID:0x%" PRIx64 " ctg start to launch batch %d", pJob->queryId, pBatch->batchId);
|
||||
|
||||
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg));
|
||||
CTG_ERR_JRET(ctgBuildBatchReqMsg(pBatch, *vgId, &msg, &msgSize));
|
||||
code = ctgAsyncSendMsg(pCtg, &pBatch->conn, pJob, pBatch->pTaskIds, pBatch->batchId, pBatch->pMsgIdxs,
|
||||
pBatch->dbFName, *vgId, pBatch->msgType, msg, pBatch->msgSize);
|
||||
pBatch->dbFName, *vgId, pBatch->msgType, msg, msgSize);
|
||||
pBatch->pTaskIds = NULL;
|
||||
CTG_ERR_JRET(code);
|
||||
|
||||
|
|
|
@ -2,10 +2,6 @@ aux_source_directory(src EXECUTOR_SRC)
|
|||
#add_library(executor ${EXECUTOR_SRC})
|
||||
|
||||
add_library(executor STATIC ${EXECUTOR_SRC})
|
||||
#set_target_properties(executor PROPERTIES
|
||||
# IMPORTED_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}/libexecutor.a"
|
||||
# INTERFACE_INCLUDE_DIRECTORIES "${TD_SOURCE_DIR}/include/libs/executor"
|
||||
# )
|
||||
|
||||
target_link_libraries(executor
|
||||
PRIVATE os util common function parser planner qcom vnode scalar nodes index stream
|
||||
|
|
|
@ -163,7 +163,7 @@ typedef struct {
|
|||
SArray* pStopInfo;
|
||||
} STaskStopInfo;
|
||||
|
||||
typedef struct SExecTaskInfo {
|
||||
struct SExecTaskInfo {
|
||||
STaskIdInfo id;
|
||||
uint32_t status;
|
||||
STimeWindow window;
|
||||
|
@ -182,7 +182,7 @@ typedef struct SExecTaskInfo {
|
|||
struct SOperatorInfo* pRoot;
|
||||
SLocalFetch localFetch;
|
||||
STaskStopInfo stopInfo;
|
||||
} SExecTaskInfo;
|
||||
};
|
||||
|
||||
enum {
|
||||
OP_NOT_OPENED = 0x0,
|
||||
|
@ -235,15 +235,6 @@ typedef enum {
|
|||
#define COL_MATCH_FROM_COL_ID 0x1
|
||||
#define COL_MATCH_FROM_SLOT_ID 0x2
|
||||
|
||||
typedef struct SSourceDataInfo {
|
||||
int32_t index;
|
||||
SRetrieveTableRsp* pRsp;
|
||||
uint64_t totalRows;
|
||||
int32_t code;
|
||||
EX_SOURCE_STATUS status;
|
||||
const char* taskId;
|
||||
} SSourceDataInfo;
|
||||
|
||||
typedef struct SLoadRemoteDataInfo {
|
||||
uint64_t totalSize; // total load bytes from remote
|
||||
uint64_t totalRows; // total number of rows
|
||||
|
@ -315,37 +306,39 @@ typedef struct STableMetaCacheInfo {
|
|||
uint64_t cacheHit;
|
||||
} STableMetaCacheInfo;
|
||||
|
||||
typedef struct STableScanInfo {
|
||||
typedef struct STableScanBase {
|
||||
STsdbReader* dataReader;
|
||||
SReadHandle readHandle;
|
||||
SLimitInfo limitInfo;
|
||||
SFileBlockLoadRecorder readRecorder;
|
||||
SQueryTableDataCond cond;
|
||||
SAggOptrPushDownInfo pdInfo;
|
||||
SColMatchInfo matchInfo;
|
||||
SReadHandle readHandle;
|
||||
SExprSupp pseudoSup;
|
||||
STableMetaCacheInfo metaCache;
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
SLimitInfo limitInfo;
|
||||
} STableScanBase;
|
||||
|
||||
typedef struct STableScanInfo {
|
||||
STableScanBase base;
|
||||
SScanInfo scanInfo;
|
||||
int32_t scanTimes;
|
||||
SSDataBlock* pResBlock;
|
||||
SColMatchInfo matchInfo;
|
||||
SExprSupp pseudoSup;
|
||||
SQueryTableDataCond cond;
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
SSampleExecInfo sample; // sample execution info
|
||||
int32_t currentGroupId;
|
||||
int32_t currentTable;
|
||||
int8_t scanMode;
|
||||
SAggOptrPushDownInfo pdInfo;
|
||||
int8_t assignBlockUid;
|
||||
STableMetaCacheInfo metaCache;
|
||||
} STableScanInfo;
|
||||
|
||||
typedef struct STableMergeScanInfo {
|
||||
STableListInfo* tableListInfo;
|
||||
int32_t tableStartIndex;
|
||||
int32_t tableEndIndex;
|
||||
bool hasGroupId;
|
||||
uint64_t groupId;
|
||||
SArray* queryConds; // array of queryTableDataCond
|
||||
STsdbReader* pReader;
|
||||
SReadHandle readHandle;
|
||||
STableScanBase base;
|
||||
int32_t bufPageSize;
|
||||
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||
SArray* pSortInfo;
|
||||
|
@ -354,27 +347,12 @@ typedef struct STableMergeScanInfo {
|
|||
int64_t startTs; // sort start time
|
||||
SArray* sortSourceParams;
|
||||
SLimitInfo limitInfo;
|
||||
SFileBlockLoadRecorder readRecorder;
|
||||
int64_t numOfRows;
|
||||
SScanInfo scanInfo;
|
||||
int32_t scanTimes;
|
||||
SqlFunctionCtx* pCtx; // which belongs to the direct upstream operator operator query context
|
||||
SResultRowInfo* pResultRowInfo;
|
||||
int32_t* rowEntryInfoOffset;
|
||||
SExprInfo* pExpr;
|
||||
SSDataBlock* pResBlock;
|
||||
SColMatchInfo matchInfo;
|
||||
int32_t numOfOutput;
|
||||
SExprSupp pseudoSup;
|
||||
SQueryTableDataCond cond;
|
||||
int32_t scanFlag; // table scan flag to denote if it is a repeat/reverse/main scan
|
||||
int32_t dataBlockLoadFlag;
|
||||
|
||||
// if the upstream is an interval operator, the interval info is also kept here to get the time
|
||||
// window to check if current data block needs to be loaded.
|
||||
SInterval interval;
|
||||
SSampleExecInfo sample; // sample execution info
|
||||
SSortExecInfo sortExecInfo;
|
||||
SSampleExecInfo sample; // sample execution info
|
||||
SSortExecInfo sortExecInfo;
|
||||
} STableMergeScanInfo;
|
||||
|
||||
typedef struct STagScanInfo {
|
||||
|
@ -383,23 +361,8 @@ typedef struct STagScanInfo {
|
|||
SColMatchInfo matchInfo;
|
||||
int32_t curPos;
|
||||
SReadHandle readHandle;
|
||||
STableListInfo* pTableList;
|
||||
} STagScanInfo;
|
||||
|
||||
typedef struct SLastrowScanInfo {
|
||||
SSDataBlock* pRes;
|
||||
SReadHandle readHandle;
|
||||
void* pLastrowReader;
|
||||
SColMatchInfo matchInfo;
|
||||
int32_t* pSlotIds;
|
||||
SExprSupp pseudoExprSup;
|
||||
int32_t retrieveType;
|
||||
int32_t currentGroupIndex;
|
||||
SSDataBlock* pBufferredRes;
|
||||
SArray* pUidList;
|
||||
int32_t indexOfBufferedRes;
|
||||
} SLastrowScanInfo;
|
||||
|
||||
typedef enum EStreamScanMode {
|
||||
STREAM_SCAN_FROM_READERHANDLE = 1,
|
||||
STREAM_SCAN_FROM_RES,
|
||||
|
@ -414,13 +377,6 @@ enum {
|
|||
PROJECT_RETRIEVE_DONE = 0x2,
|
||||
};
|
||||
|
||||
typedef struct SCatchSupporter {
|
||||
SHashObj* pWindowHashTable; // quick locate the window object for each window
|
||||
SDiskbasedBuf* pDataBuf; // buffer based on blocked-wised disk file
|
||||
int32_t keySize;
|
||||
int64_t* pKeyBuf;
|
||||
} SCatchSupporter;
|
||||
|
||||
typedef struct SStreamAggSupporter {
|
||||
int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row
|
||||
SSDataBlock* pScanBlock;
|
||||
|
@ -504,7 +460,6 @@ typedef struct SStreamScanInfo {
|
|||
STimeWindow updateWin;
|
||||
STimeWindowAggSupp twAggSup;
|
||||
SSDataBlock* pUpdateDataRes;
|
||||
SHashObj* pGroupIdTbNameMap;
|
||||
// status for tmq
|
||||
SNodeList* pGroupTags;
|
||||
SNode* pTagCond;
|
||||
|
@ -524,40 +479,6 @@ typedef struct {
|
|||
SSnapContext* sContext;
|
||||
} SStreamRawScanInfo;
|
||||
|
||||
typedef struct SSysTableIndex {
|
||||
int8_t init;
|
||||
SArray* uids;
|
||||
int32_t lastIdx;
|
||||
} SSysTableIndex;
|
||||
|
||||
typedef struct SSysTableScanInfo {
|
||||
SRetrieveMetaTableRsp* pRsp;
|
||||
SRetrieveTableReq req;
|
||||
SEpSet epSet;
|
||||
tsem_t ready;
|
||||
SReadHandle readHandle;
|
||||
int32_t accountId;
|
||||
const char* pUser;
|
||||
bool sysInfo;
|
||||
bool showRewrite;
|
||||
SNode* pCondition; // db_name filter condition, to discard data that are not in current database
|
||||
SMTbCursor* pCur; // cursor for iterate the local table meta store.
|
||||
SSysTableIndex* pIdx; // idx for local table meta
|
||||
SColMatchInfo matchInfo;
|
||||
SName name;
|
||||
SSDataBlock* pRes;
|
||||
int64_t numOfBlocks; // extract basic running information.
|
||||
SLoadRemoteDataInfo loadInfo;
|
||||
} SSysTableScanInfo;
|
||||
|
||||
typedef struct SBlockDistInfo {
|
||||
SSDataBlock* pResBlock;
|
||||
STsdbReader* pHandle;
|
||||
SReadHandle readHandle;
|
||||
uint64_t uid; // table uid
|
||||
} SBlockDistInfo;
|
||||
|
||||
// todo remove this
|
||||
typedef struct SOptrBasicInfo {
|
||||
SResultRowInfo resultRowInfo;
|
||||
SSDataBlock* pRes;
|
||||
|
@ -612,7 +533,6 @@ typedef struct SStreamIntervalOperatorInfo {
|
|||
SArray* pChildren;
|
||||
SStreamState* pState;
|
||||
SWinKey delKey;
|
||||
SHashObj* pGroupIdTbNameMap; // uint64_t -> char[TSDB_TABLE_NAME_LEN]
|
||||
} SStreamIntervalOperatorInfo;
|
||||
|
||||
typedef struct SAggOperatorInfo {
|
||||
|
@ -624,24 +544,6 @@ typedef struct SAggOperatorInfo {
|
|||
SExprSupp scalarExprSup;
|
||||
} SAggOperatorInfo;
|
||||
|
||||
typedef struct SProjectOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SAggSupporter aggSup;
|
||||
SArray* pPseudoColInfo;
|
||||
SLimitInfo limitInfo;
|
||||
bool mergeDataBlocks;
|
||||
SSDataBlock* pFinalRes;
|
||||
} SProjectOperatorInfo;
|
||||
|
||||
typedef struct SIndefOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SAggSupporter aggSup;
|
||||
SArray* pPseudoColInfo;
|
||||
SExprSupp scalarSup;
|
||||
uint64_t groupId;
|
||||
SSDataBlock* pNextGroupRes;
|
||||
} SIndefOperatorInfo;
|
||||
|
||||
typedef struct SFillOperatorInfo {
|
||||
struct SFillInfo* pFillInfo;
|
||||
SSDataBlock* pRes;
|
||||
|
@ -659,42 +561,12 @@ typedef struct SFillOperatorInfo {
|
|||
SExprSupp noFillExprSupp;
|
||||
} SFillOperatorInfo;
|
||||
|
||||
typedef struct SGroupbyOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SAggSupporter aggSup;
|
||||
SArray* pGroupCols; // group by columns, SArray<SColumn>
|
||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
||||
bool isInit; // denote if current val is initialized or not
|
||||
char* keyBuf; // group by keys for hash
|
||||
int32_t groupKeyLen; // total group by column width
|
||||
SGroupResInfo groupResInfo;
|
||||
SExprSupp scalarSup;
|
||||
} SGroupbyOperatorInfo;
|
||||
|
||||
typedef struct SDataGroupInfo {
|
||||
uint64_t groupId;
|
||||
int64_t numOfRows;
|
||||
SArray* pPageList;
|
||||
} SDataGroupInfo;
|
||||
|
||||
// The sort in partition may be needed later.
|
||||
typedef struct SPartitionOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
SArray* pGroupCols;
|
||||
SArray* pGroupColVals; // current group column values, SArray<SGroupKeys>
|
||||
char* keyBuf; // group by keys for hash
|
||||
int32_t groupKeyLen; // total group by column width
|
||||
SHashObj* pGroupSet; // quick locate the window object for each result
|
||||
|
||||
SDiskbasedBuf* pBuf; // query result buffer based on blocked-wised disk file
|
||||
int32_t rowCapacity; // maximum number of rows for each buffer page
|
||||
int32_t* columnOffset; // start position for each column data
|
||||
SArray* sortedGroupArray; // SDataGroupInfo sorted by group id
|
||||
int32_t groupIndex; // group index
|
||||
int32_t pageIndex; // page index of current group
|
||||
SExprSupp scalarSup;
|
||||
} SPartitionOperatorInfo;
|
||||
|
||||
typedef struct SWindowRowsSup {
|
||||
STimeWindow win;
|
||||
TSKEY prevTs;
|
||||
|
@ -745,7 +617,6 @@ typedef struct SStreamSessionAggOperatorInfo {
|
|||
SPhysiNode* pPhyNode; // create new child
|
||||
bool isFinal;
|
||||
bool ignoreExpiredData;
|
||||
SHashObj* pGroupIdTbNameMap;
|
||||
} SStreamSessionAggOperatorInfo;
|
||||
|
||||
typedef struct SStreamStateAggOperatorInfo {
|
||||
|
@ -761,7 +632,6 @@ typedef struct SStreamStateAggOperatorInfo {
|
|||
void* pDelIterator;
|
||||
SArray* pChildren; // cache for children's result;
|
||||
bool ignoreExpiredData;
|
||||
SHashObj* pGroupIdTbNameMap;
|
||||
} SStreamStateAggOperatorInfo;
|
||||
|
||||
typedef struct SStreamPartitionOperatorInfo {
|
||||
|
@ -777,6 +647,23 @@ typedef struct SStreamPartitionOperatorInfo {
|
|||
SSDataBlock* pDelRes;
|
||||
} SStreamPartitionOperatorInfo;
|
||||
|
||||
typedef struct SStreamFillSupporter {
|
||||
int32_t type; // fill type
|
||||
SInterval interval;
|
||||
SResultRowData prev;
|
||||
SResultRowData cur;
|
||||
SResultRowData next;
|
||||
SResultRowData nextNext;
|
||||
SFillColInfo* pAllColInfo; // fill exprs and not fill exprs
|
||||
SExprSupp notFillExprSup;
|
||||
int32_t numOfAllCols; // number of all exprs, including the tags columns
|
||||
int32_t numOfFillCols;
|
||||
int32_t numOfNotFillCols;
|
||||
int32_t rowSize;
|
||||
SSHashObj* pResMap;
|
||||
bool hasDelete;
|
||||
} SStreamFillSupporter;
|
||||
|
||||
typedef struct SStreamFillOperatorInfo {
|
||||
SStreamFillSupporter* pFillSup;
|
||||
SSDataBlock* pRes;
|
||||
|
@ -800,7 +687,6 @@ typedef struct STimeSliceOperatorInfo {
|
|||
SArray* pPrevRow; // SArray<SGroupValue>
|
||||
SArray* pNextRow; // SArray<SGroupValue>
|
||||
SArray* pLinearInfo; // SArray<SFillLinearInfo>
|
||||
bool fillLastPoint;
|
||||
bool isPrevRowSet;
|
||||
bool isNextRowSet;
|
||||
int32_t fillType; // fill type
|
||||
|
@ -824,33 +710,6 @@ typedef struct SStateWindowOperatorInfo {
|
|||
STimeWindowAggSupp twAggSup;
|
||||
} SStateWindowOperatorInfo;
|
||||
|
||||
typedef struct SSortOperatorInfo {
|
||||
SOptrBasicInfo binfo;
|
||||
uint32_t sortBufSize; // max buffer size for in-memory sort
|
||||
SArray* pSortInfo;
|
||||
SSortHandle* pSortHandle;
|
||||
SColMatchInfo matchInfo;
|
||||
int32_t bufPageSize;
|
||||
int64_t startTs; // sort start time
|
||||
uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included.
|
||||
SLimitInfo limitInfo;
|
||||
} SSortOperatorInfo;
|
||||
|
||||
typedef struct SJoinOperatorInfo {
|
||||
SSDataBlock* pRes;
|
||||
int32_t joinType;
|
||||
int32_t inputOrder;
|
||||
|
||||
SSDataBlock* pLeft;
|
||||
int32_t leftPos;
|
||||
SColumnInfo leftCol;
|
||||
|
||||
SSDataBlock* pRight;
|
||||
int32_t rightPos;
|
||||
SColumnInfo rightCol;
|
||||
SNode* pCondAfterMerge;
|
||||
} SJoinOperatorInfo;
|
||||
|
||||
#define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED)
|
||||
#define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED)
|
||||
|
||||
|
@ -874,7 +733,6 @@ void doBuildStreamResBlock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGr
|
|||
void doBuildResultDatablock(SOperatorInfo* pOperator, SOptrBasicInfo* pbInfo, SGroupResInfo* pGroupResInfo,
|
||||
SDiskbasedBuf* pBuf);
|
||||
|
||||
int32_t handleLimitOffset(SOperatorInfo* pOperator, SLimitInfo* pLimitInfo, SSDataBlock* pBlock, bool holdDataInBuf);
|
||||
bool hasLimitOffsetInfo(SLimitInfo* pLimitInfo);
|
||||
void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimitInfo);
|
||||
void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo, SOperatorInfo* pOperator);
|
||||
|
@ -904,9 +762,6 @@ void cleanupAggSup(SAggSupporter* pAggSup);
|
|||
void appendOneRowToDataBlock(SSDataBlock* pBlock, STupleHandle* pTupleHandle);
|
||||
void setTbNameColData(const SSDataBlock* pBlock, SColumnInfoData* pColInfoData, int32_t functionId, const char* name);
|
||||
|
||||
int32_t doPrepareScan(SOperatorInfo* pOperator, uint64_t uid, int64_t ts);
|
||||
int32_t doGetScanStatus(SOperatorInfo* pOperator, uint64_t* uid, int64_t* ts);
|
||||
|
||||
SSDataBlock* loadNextDataBlock(void* param);
|
||||
|
||||
void setResultRowInitCtx(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowEntryInfoOffset);
|
||||
|
@ -989,9 +844,8 @@ void setInputDataBlock(SExprSupp* pExprSupp, SSDataBlock* pBlock, int32_t order,
|
|||
bool isTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||
int32_t checkForQueryBuf(size_t numOfTables);
|
||||
|
||||
void setTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||
void queryCostStatis(SExecTaskInfo* pTaskInfo);
|
||||
|
||||
void setTaskKilled(SExecTaskInfo* pTaskInfo);
|
||||
void queryCostStatis(SExecTaskInfo* pTaskInfo);
|
||||
void doDestroyTask(SExecTaskInfo* pTaskInfo);
|
||||
void destroyOperatorInfo(SOperatorInfo* pOperator);
|
||||
int32_t getMaximumIdleDurationSec();
|
||||
|
@ -1019,9 +873,6 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
|||
int32_t createDataSinkParam(SDataSinkNode* pNode, void** pParam, qTaskInfo_t* pTaskInfo, SReadHandle* readHandle);
|
||||
int32_t getOperatorExplainExecInfo(SOperatorInfo* operatorInfo, SArray* pExecInfoList);
|
||||
|
||||
int32_t aggDecodeResultRow(SOperatorInfo* pOperator, char* result);
|
||||
int32_t aggEncodeResultRow(SOperatorInfo* pOperator, char** result, int32_t* length);
|
||||
|
||||
STimeWindow getActiveTimeWindow(SDiskbasedBuf* pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval,
|
||||
int32_t order);
|
||||
int32_t getNumOfRowsInTimeWindow(SDataBlockInfo* pDataBlockInfo, TSKEY* pPrimaryColumn, int32_t startPos, TSKEY ekey,
|
||||
|
@ -1046,8 +897,8 @@ int32_t finalizeResultRows(SDiskbasedBuf* pBuf, SResultRowPosition* resultRowPos
|
|||
|
||||
SOperatorInfo* createGroupSortOperatorInfo(SOperatorInfo* downstream, SGroupSortPhysiNode* pSortPhyNode,
|
||||
SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, STableListInfo* pTableListInfo,
|
||||
SReadHandle* readHandle, SExecTaskInfo* pTaskInfo);
|
||||
SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanNode, SReadHandle* readHandle,
|
||||
SExecTaskInfo* pTaskInfo);
|
||||
|
||||
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
||||
|
||||
|
|
|
@ -36,7 +36,8 @@ typedef struct SFillColInfo {
|
|||
typedef struct SFillLinearInfo {
|
||||
SPoint start;
|
||||
SPoint end;
|
||||
bool hasNull;
|
||||
bool isStartSet;
|
||||
bool isEndSet;
|
||||
int16_t type;
|
||||
int32_t bytes;
|
||||
} SFillLinearInfo;
|
||||
|
@ -110,22 +111,6 @@ typedef struct SStreamFillInfo {
|
|||
int32_t delIndex;
|
||||
} SStreamFillInfo;
|
||||
|
||||
typedef struct SStreamFillSupporter {
|
||||
int32_t type; // fill type
|
||||
SInterval interval;
|
||||
SResultRowData prev;
|
||||
SResultRowData cur;
|
||||
SResultRowData next;
|
||||
SResultRowData nextNext;
|
||||
SFillColInfo* pAllColInfo; // fill exprs and not fill exprs
|
||||
int32_t numOfAllCols; // number of all exprs, including the tags columns
|
||||
int32_t numOfFillCols;
|
||||
int32_t numOfNotFillCols;
|
||||
int32_t rowSize;
|
||||
SSHashObj* pResMap;
|
||||
bool hasDelete;
|
||||
} SStreamFillSupporter;
|
||||
|
||||
int64_t getNumOfResultsAfterFillGap(SFillInfo* pFillInfo, int64_t ekey, int32_t maxNumOfRows);
|
||||
|
||||
void taosFillSetStartInfo(struct SFillInfo* pFillInfo, int32_t numOfRows, TSKEY endKey);
|
||||
|
|
|
@ -36,12 +36,13 @@ typedef struct SMultiMergeSource {
|
|||
|
||||
typedef struct SSortSource {
|
||||
SMultiMergeSource src;
|
||||
union {
|
||||
struct {
|
||||
SArray* pageIdList;
|
||||
int32_t pageIndex;
|
||||
};
|
||||
struct {
|
||||
SArray* pageIdList;
|
||||
int32_t pageIndex;
|
||||
};
|
||||
struct {
|
||||
void* param;
|
||||
bool onlyRef;
|
||||
};
|
||||
|
||||
} SSortSource;
|
||||
|
@ -163,9 +164,10 @@ SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle);
|
|||
/**
|
||||
* get proper sort buffer pages according to the row size
|
||||
* @param rowSize
|
||||
* @param numOfCols columns count that be put into page
|
||||
* @return
|
||||
*/
|
||||
int32_t getProperSortPageSize(size_t rowSize);
|
||||
int32_t getProperSortPageSize(size_t rowSize, uint32_t numOfCols);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -25,15 +25,29 @@
|
|||
#include "thash.h"
|
||||
#include "ttypes.h"
|
||||
|
||||
typedef struct SCacheRowsScanInfo {
|
||||
SSDataBlock* pRes;
|
||||
SReadHandle readHandle;
|
||||
void* pLastrowReader;
|
||||
SColMatchInfo matchInfo;
|
||||
int32_t* pSlotIds;
|
||||
SExprSupp pseudoExprSup;
|
||||
int32_t retrieveType;
|
||||
int32_t currentGroupIndex;
|
||||
SSDataBlock* pBufferredRes;
|
||||
SArray* pUidList;
|
||||
int32_t indexOfBufferedRes;
|
||||
} SCacheRowsScanInfo;
|
||||
|
||||
static SSDataBlock* doScanCache(SOperatorInfo* pOperator);
|
||||
static void destroyLastrowScanOperator(void* param);
|
||||
static void destroyCacheScanOperator(void* param);
|
||||
static int32_t extractCacheScanSlotId(const SArray* pColMatchInfo, SExecTaskInfo* pTaskInfo, int32_t** pSlotIds);
|
||||
static int32_t removeRedundantTsCol(SLastRowScanPhysiNode* pScanNode, SColMatchInfo* pColMatchInfo);
|
||||
|
||||
SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SReadHandle* readHandle,
|
||||
SExecTaskInfo* pTaskInfo) {
|
||||
int32_t code = TSDB_CODE_SUCCESS;
|
||||
SLastrowScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SLastrowScanInfo));
|
||||
SCacheRowsScanInfo* pInfo = taosMemoryCalloc(1, sizeof(SCacheRowsScanInfo));
|
||||
SOperatorInfo* pOperator = taosMemoryCalloc(1, sizeof(SOperatorInfo));
|
||||
if (pInfo == NULL || pOperator == NULL) {
|
||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||
|
@ -97,14 +111,14 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
|||
pOperator->exprSupp.numOfExprs = taosArrayGetSize(pInfo->pRes->pDataBlock);
|
||||
|
||||
pOperator->fpSet =
|
||||
createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, destroyLastrowScanOperator, NULL);
|
||||
createOperatorFpSet(operatorDummyOpenFn, doScanCache, NULL, destroyCacheScanOperator, NULL);
|
||||
|
||||
pOperator->cost.openCost = 0;
|
||||
return pOperator;
|
||||
|
||||
_error:
|
||||
pTaskInfo->code = code;
|
||||
destroyLastrowScanOperator(pInfo);
|
||||
destroyCacheScanOperator(pInfo);
|
||||
taosMemoryFree(pOperator);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -114,7 +128,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
SLastrowScanInfo* pInfo = pOperator->info;
|
||||
SCacheRowsScanInfo* pInfo = pOperator->info;
|
||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||
STableListInfo* pTableList = pTaskInfo->pTableInfoList;
|
||||
|
||||
|
@ -157,9 +171,12 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
SColumnInfoData* pSrc = taosArrayGet(pInfo->pBufferredRes->pDataBlock, slotId);
|
||||
SColumnInfoData* pDst = taosArrayGet(pRes->pDataBlock, slotId);
|
||||
|
||||
char* p = colDataGetData(pSrc, pInfo->indexOfBufferedRes);
|
||||
bool isNull = colDataIsNull_s(pSrc, pInfo->indexOfBufferedRes);
|
||||
colDataAppend(pDst, 0, p, isNull);
|
||||
if (colDataIsNull_s(pSrc, pInfo->indexOfBufferedRes)) {
|
||||
colDataAppendNULL(pDst, 0);
|
||||
} else {
|
||||
char* p = colDataGetData(pSrc, pInfo->indexOfBufferedRes);
|
||||
colDataAppend(pDst, 0, p, false);
|
||||
}
|
||||
}
|
||||
|
||||
pRes->info.uid = *(tb_uid_t*)taosArrayGet(pInfo->pUidList, pInfo->indexOfBufferedRes);
|
||||
|
@ -226,6 +243,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
|
||||
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
|
||||
return pInfo->pRes;
|
||||
} else {
|
||||
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -234,8 +253,8 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
|||
}
|
||||
}
|
||||
|
||||
void destroyLastrowScanOperator(void* param) {
|
||||
SLastrowScanInfo* pInfo = (SLastrowScanInfo*)param;
|
||||
void destroyCacheScanOperator(void* param) {
|
||||
SCacheRowsScanInfo* pInfo = (SCacheRowsScanInfo*)param;
|
||||
blockDataDestroy(pInfo->pRes);
|
||||
blockDataDestroy(pInfo->pBufferredRes);
|
||||
taosMemoryFree(pInfo->pSlotIds);
|
||||
|
@ -246,6 +265,7 @@ void destroyLastrowScanOperator(void* param) {
|
|||
pInfo->pLastrowReader = tsdbCacherowsReaderClose(pInfo->pLastrowReader);
|
||||
}
|
||||
|
||||
cleanupExprSupp(&pInfo->pseudoExprSup);
|
||||
taosMemoryFreeClear(param);
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue