Merge remote-tracking branch 'origin/3.0' into feat/TS-5992

This commit is contained in:
dapan1121 2025-03-13 15:32:26 +08:00
commit 90fcd168c9
93 changed files with 966 additions and 146 deletions

View File

@ -30,37 +30,48 @@ jobs:
id: parameters
run: |
set -euo pipefail
target_branch=${{ github.event.pull_request.base.ref }}
# target_branch=${{ github.event.pull_request.base.ref }}
# Check whether to run tdgpt test cases
cd ${{ env.WKC }}
changed_files_non_doc=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | grep -v "^docs/en/" | grep -v "^docs/zh/" | grep -v ".md$" | tr '\n' ' ' || :)
echo "changed files exclude doc: ${changed_files_non_doc}"
# # Fetch the latest code from the target branch
# cd ${{ env.WKC }}
# git reset --hard
# git clean -f
# git remote prune origin
# git fetch
# git checkout "$target_branch"
# git remote prune origin
# git pull >/dev/null
if [[ -n "$changed_files_non_doc" && "$changed_files_non_doc" =~ (forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt) ]]; then
run_tdgpt_test="true"
else
run_tdgpt_test="false"
fi
echo "run tdgpt test: ${run_tdgpt_test}"
# # Check whether to run tdgpt test cases
# changed_files_non_doc=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | grep -v "^docs/en/" | grep -v "^docs/zh/" | grep -v ".md$" | tr '\n' ' ' || :)
# echo "changed files exclude doc: ${changed_files_non_doc}"
# Check whether to run function test cases
changed_files_non_tdgpt=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | \
grep -v "^docs/en/" | \
grep -v "^docs/zh/" | \
grep -v ".md$" | \
grep -Ev "forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt" | \
tr '\n' ' ' || :)
echo "changed files exclude tdgpt: ${changed_files_non_tdgpt}"
# if [[ -n "$changed_files_non_doc" && "$changed_files_non_doc" =~ (forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt) ]]; then
# run_tdgpt_test="true"
# else
# run_tdgpt_test="false"
# fi
# echo "run tdgpt test: ${run_tdgpt_test}"
if [ -n "$changed_files_non_tdgpt" ]; then
run_function_test="true"
else
run_function_test="false"
fi
# # Check whether to run function test cases
# changed_files_non_tdgpt=$(git --no-pager diff --name-only FETCH_HEAD $(git merge-base FETCH_HEAD $target_branch) | \
# grep -v "^docs/en/" | \
# grep -v "^docs/zh/" | \
# grep -v ".md$" | \
# grep -Ev "forecastoperator\.c|anomalywindowoperator\.c|tanalytics\.h|tanalytics\.c|tdgpt_cases\.task|analytics|tdgpt" | \
# tr '\n' ' ' || :)
# echo "changed files exclude tdgpt: ${changed_files_non_tdgpt}"
echo "run function test: ${run_function_test}"
# if [ -n "$changed_files_non_tdgpt" ]; then
# run_function_test="true"
# else
# run_function_test="false"
# fi
# echo "run function test: ${run_function_test}"
run_tdgpt_test="true"
run_function_test="true"
# Output the results for GitHub Actions
echo "run_function_test=$run_function_test" >> $GITHUB_OUTPUT
echo "run_tdgpt_test=$run_tdgpt_test" >> $GITHUB_OUTPUT

View File

@ -21,19 +21,18 @@ include(${TD_SUPPORT_DIR}/cmake.version)
include(${TD_SUPPORT_DIR}/cmake.install)
set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES OFF)
add_library(api INTERFACE)
target_include_directories(api INTERFACE "include/client")
add_subdirectory(contrib)
add_subdirectory(source)
add_subdirectory(tools)
add_subdirectory(utils)
add_subdirectory(tests)
add_subdirectory(docs/doxgen)
if(${BUILD_TEST})
include(CTest)
enable_testing()
add_subdirectory(examples/c)
endif(${BUILD_TEST})
add_library(api INTERFACE)
target_include_directories(api INTERFACE "include/client")
add_subdirectory(source)
add_subdirectory(tools)
add_subdirectory(utils)
add_subdirectory(tests)
add_subdirectory(docs/doxgen)

View File

@ -112,16 +112,6 @@ def build_pre_docs(){
git fetch origin +refs/pull/${CHANGE_ID}/merge
git checkout -qf FETCH_HEAD
'''
sh '''
cd ${DOC_WKC}/${tools_repo}
git reset --hard
git clean -f
git fetch
git remote prune origin
git checkout ''' + env.CHANGE_TARGET + '''
git pull >/dev/null
'''
}
}

View File

@ -14,7 +14,7 @@ Power BI is a business analytics tool provided by Microsoft. By configuring the
## Configure Data Source
**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation).
**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation).
**Step 2**, Open Power BI and log in, click [Home] -> [Get Data] -> [Other] -> [ODBC] -> [Connect], add data source.

View File

@ -13,11 +13,11 @@ Prepare the following environment:
- TDengine 3.3.5.8 and above version is installed and running normally (both Enterprise and Community versions are available).
- taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/).
- Install and run Tableau Desktop (if not installed, please download and install Windows operating system 64-bit [Download Tableau Desktop](https://www.tableau.com/products/desktop/download)). Install Tableau please refer to [Tableau Desktop](https://www.tableau.com).
- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation).
- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation).
## Configure Data Source
**Step 1**, Search and open the "ODBC Data Source (64 bit)" management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation).
**Step 1**, Search and open the "ODBC Data Source (64 bit)" management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation).
:::tip
It should be noted that when configuring the ODBC data source for Tableau, the [Database] configuration item on the TDengine ODBC data source configuration page is required. You need to select a database that can be successfully connected.
@ -27,19 +27,19 @@ It should be noted that when configuring the ODBC data source for Tableau, the [
**Step 3**, Click the `DSN` radio button, then select the configured data source (MyTDengine), and click the `Connect` button. After the connection is successful, delete the content of the string attachment, and finally click the `Sign In` button.
![tableau-odbc](./tableau/tableau-odbc.jpg)
![tableau-odbc](./tableau/tableau-odbc.webp)
## Data Analysis
**Step 1**, In the workbook page, the connected data sources will be displayed. Clicking on the dropdown list of databases will display the databases that require data analysis. On this basis, click the search button in the table options to display all tables in the database. Then, drag the table to be analyzed to the right area to display the table structure.
![tableau-workbook](./tableau/tableau-table.jpg)
![tableau-workbook](./tableau/tableau-table.webp)
**Step 2**, Click the `Update Now` button below to display the data in the table.
![tableau-workbook](./tableau/tableau-data.jpg)
![tableau-workbook](./tableau/tableau-data.webp)
**Step 3**, Click on the "Worksheet" at the bottom of the window to pop up the data analysis window, which displays all the fields of the analysis table. Drag the fields to the rows and columns to display the chart.
![tableau-workbook](./tableau/tableau-analysis.jpg)
![tableau-workbook](./tableau/tableau-analysis.webp)

View File

@ -13,30 +13,30 @@ Prepare the following environment:
- TDengine 3.3.5.8 and above version is installed and running normally (both Enterprise and Community versions are available).
- taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/).
- Install and run Excel. If not installed, please download and install it. For specific instructions, please refer to Microsoft's official documentation.
- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation).
- Download the latest Windows operating system X64 client driver from the TDengine official website and install it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation).
## Configure Data Source
**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#Installation).
**Step 1**, Search and open the [ODBC Data Source (64 bit)] management tool in the Start menu of the Windows operating system and configure it, refer to [Install ODBC Driver](../../../tdengine-reference/client-libraries/odbc/#installation).
**Step 2**, Start Excel in the Windows system environment, then select [Data] -> [Get Data] -> [From Other Sources] -> [From ODBC].
![excel-odbc](./excel/odbc-menu.jpg)
![excel-odbc](./excel/odbc-menu.webp)
**Step 3**, In the pop-up window, select the data source you need to connect to from the drop-down list of [Data source name (DSN)], and then click the [OK] button.
![excel-odbc](./excel/odbc-select.jpg)
![excel-odbc](./excel/odbc-select.webp)
**Step 4**, Enter the username and password for TDengine.
![excel-odbc](./excel/odbc-config.jpg)
![excel-odbc](./excel/odbc-config.webp)
**Step 5**, In the pop-up [Navigator] dialog box, select the database tables you want to load, and then click [Load] to complete the data loading.
![excel-odbc](./excel/odbc-load.jpg)
![excel-odbc](./excel/odbc-load.webp)
## Data Analysis
Select the imported data. On the [Insert] tab, choose the column chart, and then configure the data fields in the [PivotChart Fields] pane on the right.
![excel-odbc](./excel/odbc-data.jpg)
![excel-odbc](./excel/odbc-data.webp)

View File

@ -0,0 +1,82 @@
---
sidebar_label: FineBI
title: Integration With FineBI
toc_max_heading_level: 4
---
Fanruan is a technology company specializing in the field of business intelligence and data analytics. With its self-developed core products, FineBI and FineReport, the company has established a leading position in the industry. Fanruan's BI tools are widely adopted by enterprises across various sectors, empowering users to achieve data visualization analysis, report generation, and data-driven decision support.
By using the TDengine Java connector, FineBI can quickly access the data in TDengine. Users can directly connect to the TDengine database in FineBI, obtain time-series data for analysis, and create visual reports, and the entire process does not require any code writing.
## Prerequisites
- TDengine 3.3.4.0 and above version is installed and running normally (both Enterprise and Community versions are available).
- taosAdapter is running normally, refer to [taosAdapter Reference](../../../tdengine-reference/components/taosadapter/).
- Install FineBI (if not installed, please download and install [Download FineBI](https://intl.finebi.com/download)).
- Download the fine_conf_entity plugin to support the addition of JDBC drivers, [Download link](https://market.fanruan.com/plugin/1052a471-0239-4cd8-b832-045d53182c5d).
- Install the JDBC driver. Download the `TDengine JDBC connector` file `taos-jdbcdriver-3.4.0-dist.jar` or a higher version from `maven.org`.
## Configure Data Source
**Step 1**, In the `db.script` configuration file of the FineBI server, find the `SystemConfig.driverUpload` configuration item and change its value to true.
- Windows system: The path of the configuration file is webapps/webroot/WEB-INF/embed/finedb/db.script under the installation directory.
- Linux/Mac system: The path of the configuration file is /usr/local/FineBI6.1/webapps/webroot/WEB-INF/embed/finedb/db.script.
**Step 2**, Start the FineBI service. Enter `http://ip:37799/webroot/decision` in the browser, where "ip" is the IP address of the FineBI server.
**Step 3**, After logging in to the FineBI Web page, click [System Management] -> [Plugin Management]. In the [Store App] on the right side, click [Install From Local] and select the downloaded `fine_conf_entity` plugin for installation.
![finebi-workbook](./finebi/plugin.webp)
**Step 4**, Click [System Management] -> [Data Connection] -> [Data Connection Management]. On the right-hand page, click the [Driver Management] button to open the configuration page. Then click the [New Driver] button, and in the pop-up window, enter a name (for example, `tdengine-websocket`) to configure the JDBC driver.
![finebi-workbook](./finebi/connect-manage.webp)
**Step 5**, On the driver configuration page, click the [Upload File] button. Select the downloaded TDengine Java Connector (e.g., `taos-jdbcdriver-3.4.0-dist.jar`) for uploading. After the upload is complete, select `com.taosdata.jdbc.ws.WebSocketDriver` from the drop-down list of [Driver], and then click [Save].
![finebi-workbook](./finebi/new-driver.webp)
**Step 6**, On the "Data Connection Management" page, click the [New Data Connection] button. Subsequently, click "Others", and then on the right-side page, click "Other JDBC" to perform the connection configuration.
![finebi-workbook](./finebi/jdbc-connect.webp)
**Step 7**, On the configuration page, first enter the name of the data connection. Then, select "Custom" in the [Driver] option and choose the configured driver from the drop-down list (e.g., `com.taosdata.jdbc.ws.WebSocketDriver (tdengine-websocket)`). After that, configure the "Data Connection URL" (e.g., `jdbc:TAOS-WS://localhost:6041/power?user=root&password=taosdata&fineBIDialect=mysql`). Once the settings are completed, click [Test Connection] in the top-right corner to test the connection. After the verification is successful, click [Save] to finish the configuration.
:::tip
`fineBIDialect=mysql` The meaning of this setting is to adopt the SQL dialect rules of the MySQL database. Simply put, it tells FineBI to parse and execute relevant queries and operations in the specific way that the MySQL database handles SQL statements.
:::
![finebi-workbook](./finebi/jdbc-config.webp)
## Data Analysis
### Data preparation
**Step 1**, Click [Public Data]. On the right - hand page, click [New Folder] to create a folder (e.g., TDengine). Then, click the [+] button on the right side of the folder to create a "Database Table" dataset or an "SQL Dataset".
![finebi-workbook](./finebi/common.webp)
**Step 2**, Click "Database Table" to open the database table selection page. In the "Data Connection" section on the left, select the previously created connection. Then, all the tables in the database of the current connection will be displayed on the right. Select the table you need to load (e.g., meters), and click [OK]. The data in the meters table will then be displayed.
![finebi-workbook](./finebi/select-table.webp)
![finebi-workbook](./finebi/table-data.webp)
**Step 3**, Click "SQL Dataset" to open the configuration page for the SQL dataset. First, enter the table name (used for display on the FineBI page). Then, select the previously created connection from the drop-down list of "Data from Data Connection". After that, enter the SQL statement and click "Preview" to view the query results. Finally, click [OK] to successfully create the SQL dataset.
![finebi-workbook](./finebi/sql-data-config.webp)
### Smart Meter Example
**Step 1**, Click [My Analysis]. On the right-hand page, click [New Folder] to create a folder (for example, `TDengine`). Then, click the [+] button on the right side of the folder to create an "Analysis Subject".
![finebi-workbook](./finebi/analysis-object.webp)
**Step 2**, On the analysis subject page, select the dataset (for example, `meters`) and then click the [OK] button to complete the association of the dataset.
![finebi-workbook](./finebi/load-data.webp)
**Step 3**, Click the [Component] tab at the bottom of the analysis subject page to open the chart configuration page. Drag the fields to the horizontal axis or the vertical axis, and then the chart will be displayed.
![finebi-workbook](./finebi/analysis-chart.webp)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 470 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 761 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 769 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 659 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 286 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 505 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 243 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 389 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 255 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 543 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 226 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 KiB

View File

@ -371,10 +371,14 @@ Specify the configuration parameters for tag and data columns in `super_tables`
### Query Parameters
In query scenarios, `filetype` must be set to `query`.
`filetype` must be set to `query`.
`query_mode` connect method:
- "taosc": Native.
- "rest" : RESTful.
`query_times` specifies the number of times to run the query, numeric type.
Query scenarios can control the execution of slow query statements by setting `kill_slow_query_threshold` and `kill_slow_query_interval` parameters, where threshold controls that queries exceeding the specified exec_usec time will be killed by taosBenchmark, in seconds; interval controls the sleep time to avoid continuous slow query CPU consumption, in seconds.
For other common parameters, see [General Configuration Parameters](#general-configuration-parameters)
@ -387,8 +391,21 @@ Configuration parameters for querying specified tables (can specify supertables,
The total number of queries(`General Query`) = the number of `sqls` * `query_times` * `threads`
`Mixed Query`:
All SQL statements in `sqls` are divided into `threads` groups, with each thread executing one group. Each SQL statement needs to execute `query_times` queries.
The total number of queries(`Mixed Query`) = the number of `sqls` * `query_times`
The total number of queries(`Mixed Query`) = the number of `sqls` * `query_times`.
- **batch_query** : Batch query power switch.
"yes": indicates that it is enabled.
"no": indicates that it is not enabled, and other values report errors.
Batch query refers to dividing all SQL statements in SQL into `threads` groups, with each thread executing one group.
Each SQL statement is queried only once before exiting, and the main thread waits for all threads to complete before determining if the `query_interval` parameter is set. If sleep is required for a specified time, each thread group is restarted and the previous process is repeated until the number of queries is exhausted.
Functional limitations:
- Only supports scenarios where `mixed_query` is set to 'yes'.
- Restful queries are not supported, meaning `query_made` cannot be 'rest'.
- **query_interval** : Query interval, in millisecond, default is 0.
When the 'batch_query' switch is turned on, it indicates the interval time after each batch query is completed, When closed, it indicates the interval time between each SQL query completion.
If the execution time of the query exceeds the interval time, it will no longer wait. If the execution time of the query is less than the interval time, it is necessary to wait to make up for the interval time.
- **threads** : Number of threads executing the SQL query, default is 1.
- **sqls**:
- **sql**: The SQL command to execute, required.

View File

@ -26,18 +26,18 @@ Tableau 是一款知名的商业智能工具,它支持多种数据源,可方
**第 3 步**,点击 `DSN` 单选框,接着选择已配置好的数据源(MyTDengine),然后点击`连接`按钮。待连接成功后,删除字符串附加部分的内容,最后点击`登录`按钮即可。
![tableau-odbc](./tableau/tableau-odbc.jpg)
![tableau-odbc](./tableau/tableau-odbc.webp)
## 数据分析
**第 1 步**,在工作簿页面中,选择已连接的数据源。点击数据库的下拉列表,会显示需要进行数据分析的数据库。在此基础上,点击表选项中的查找按钮,即可将该数据库下的所有表显示出来。然后,拖动需要分析的表到右侧区域,即可显示出表结构。
![tableau-workbook](./tableau/tableau-table.jpg)
![tableau-workbook](./tableau/tableau-table.webp)
**第 2 步**,点击下方的"立即更新"按钮,即可将表中的数据展示出来。
![tableau-workbook](./tableau/tableau-data.jpg)
![tableau-workbook](./tableau/tableau-data.webp)
**第 3 步**,点击窗口下方的"工作表",弹出数据分析窗口, 并展示分析表的所有字段,将字段拖动到行列即可展示出图表。
![tableau-workbook](./tableau/tableau-analysis.jpg)
![tableau-workbook](./tableau/tableau-analysis.webp)

View File

@ -19,22 +19,22 @@ title: 与 Excel 集成
**第 2 步**,在 Windows 系统环境下启动 Excel之后选择【数据】->【获取数据】->【自其他源】->【从ODBC】。
![excel-odbc](./excel/odbc-menu.jpg)
![excel-odbc](./excel/odbc-menu.webp)
**第 3 步**,在弹出窗口的【数据源名称(DSN)】下拉列表中选择需要连接的数据源后,点击【确定】按钮。
![excel-odbc](./excel/odbc-select.jpg)
![excel-odbc](./excel/odbc-select.webp)
**第 4 步**,输入 TDengine 的用户名密码。
![excel-odbc](./excel/odbc-config.jpg)
![excel-odbc](./excel/odbc-config.webp)
**第 5 步**,在弹出的【导航器】对话框中,选择要加载的库表, 并点击【加载】完成数据加载。
![excel-odbc](./excel/odbc-load.jpg)
![excel-odbc](./excel/odbc-load.webp)
## 数据分析
选中导入的数据,在【插入】选项卡中选择柱状图,并且在右侧的【数据透视图】中配置数据字段。
![excel-odbc](./excel/odbc-data.jpg)
![excel-odbc](./excel/odbc-data.webp)

View File

@ -0,0 +1,83 @@
---
sidebar_label: FineBI
title: 与 FineBI 集成
---
帆软是一家专注于商业智能与数据分析领域的科技企业,凭借自主研发的 FineBI 和 FineReport 两款核心产品在行业内占据重要地位。帆软的 BI 工具广泛应用于各类企业,帮助用户实现数据的可视化分析、报表生成和数据决策支持。
通过使用 `TDengine Java connector` 连接器FineBI 可以快速访问 TDengine 的数据。用户可以在 FineBI 中直接连接 TDengine 数据库,获取时序数据进行分析并制作可视化报表,整个过程不需要任何代码编写过程。
## 前置条件
准备以下环境:
- TDengine 3.3.4.0 以上版本集群已部署并正常运行(企业及社区版均可)。
- taosAdapter 能够正常运行,详细参考 [taosAdapter 参考手册](../../../reference/components/taosadapter)。
- FineBI 安装(如未安装,请下载并安装 [FineBI 下载](https://www.finebi.com/product/download))。
- 下载 `fine_conf_entity` 插件用于支持允许添加JDBC驱动, [下载地址](https://market.fanruan.com/plugin/1052a471-0239-4cd8-b832-045d53182c5d)。
- 安装 JDBC 驱动。从 `maven.org` 下载 `TDengine JDBC` 连接器文件 `taos-jdbcdriver-3.4.0-dist.jar` 或以上版本。
## 配置数据源
**第 1 步**,在 FineBI 服务端 `db.script` 配置文件中,找到 `SystemConfig.driverUpload` 配置项并将其修改为 `true`
- Windows 系统:配置文件路径是安装目录下 `webapps/webroot/WEB-INF/embed/finedb/db.script`
- Liunx/Mac 系统:配置文件路径是 `/usr/local/FineBI6.1/webapps/webroot/WEB-INF/embed/finedb/db.script`
**第 2 步**,启动 FineBI 服务,在浏览器中输入 `http://ip:37799/webroot/decision`, 其中 ip 是 FineBI 服务端 ip 地址。
**第 3 步** 打开 FineBI Web 页面登录后,点击【管理系统】->【插件管理】,在右侧的【应用商城】中点击【从本地安装】选择已下载的 `fine_conf_entity` 插件进行安装。
![finebi-workbook](./finebi/plugin.webp)
**第 4 步**,点击【管理系统】->【数据连接】->【数据连接管理】,在右侧页面中点击【驱动管理】按钮打开配置页面,点击【新建驱动】按钮并在弹出窗口中输入名称(比如 `tdengine-websocket`),进行 JDBC 驱动配置。
![finebi-workbook](./finebi/connect-manage.webp)
**第 5 步**,在驱动配置页面中点击【上传文件】按钮,选择已下载的 `TDengine Java Connector`(比如 `taos-jdbcdriver-3.4.0-dist.jar`)进行上传,上传完成后在【驱动】的下拉列表中选择 `com.taosdata.jdbc.ws.WebSocketDriver`,并点击【保存】。
![finebi-workbook](./finebi/new-driver.webp)
**第 6 步**,在 “数据连接管理” 页面中,点击【新建数据连接】按钮,随后点击 “其他” ,在右侧页面中点击 “其他JDBC” 进行连接配置。
![finebi-workbook](./finebi/jdbc-connect.webp)
**第 7 步**,在配置页面,先输入数据连接名称,接着在【驱动】选项中选择 “自定义”,并从下拉列表里选取已配置的驱动(例如 `com.taosdata.jdbc.ws.WebSocketDriver (tdengine-websocket)`),之后配置 “数据连接 URL”例如 `jdbc:TAOS-WS://localhost:6041/power?user=root&password=taosdata&fineBIDialect=mysql`)。设置完成后,点击右上角的【测试连接】进行连接测试,验证成功后点击【保存】即可完成配置。
:::tip
`fineBIDialect=mysql` 设置的含义是采用 MySQL 数据库的 SQL 方言规则。简单来说,就是告诉 FineBI 按照 MySQL 数据库处理 SQL 语句的特定方式来解析和执行相关的查询与操作。
:::
![finebi-workbook](./finebi/jdbc-config.webp)
## 数据分析
### 数据准备
**第 1 步**,点击【公共数据】在右侧页面中点击【新建文件夹】即可创建一个文件夹(比如 `TDengine` 接着在文件夹的右侧点击【+】按钮,可创建 “数据库表” 数据集或 “SQL数据集”。
![finebi-workbook](./finebi/common.webp)
**第 2 步**,点击 “数据库表”,打开数据库选表页面,在左侧 “数据连接” 中选择已创建的连接,则在右侧会显示当前连接的数据库中的所有表,选择需要加载的表(比如 `meters`),点击【确定】即可显示 `meters` 表中的数据。
![finebi-workbook](./finebi/select-table.webp)
![finebi-workbook](./finebi/table-data.webp)
**第 3 步**,点击 “SQL数据集”打开 SQL 数据集的配置页面,首先输入表名(用于在 FineBI 页面显示),接着在 “数据来自数据连接” 下拉列表中选择已创建的连接, 之后输入 SQL 语句并点击预览即可看到查询结果最后点击【确定】SQL 数据集即可创建成功。
![finebi-workbook](./finebi/sql-data-config.webp)
### 智能电表样例
**第 1 步**,点击【我的分析】在右侧页面中点击【新建文件夹】即可创建一个文件夹(比如 `TDengine` 接着在文件夹的右侧点击【+】按钮,可创建 “分析主题”。
![finebi-workbook](./finebi/analysis-object.webp)
**第 2 步**,在分析主题页面选择数据集(比如 `meters`)后点击【确定】按钮,即可完成数据集关联。
![finebi-workbook](./finebi/load-data.webp)
**第 3 步**,点击分析主题页面下方的【组件】标签,打开图表配置页面, 拖动字段到横轴或纵轴即可展示出图表。
![finebi-workbook](./finebi/analysis-chart.webp)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 481 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 753 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 338 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 643 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 492 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 235 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 398 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 238 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 514 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 610 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 102 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

View File

@ -280,27 +280,45 @@ taosBenchmark -f <json file>
### 查询配置参数
查询场景下 `filetype` 必须设置为 `query`
`query_mode` 查询连接方式,取值为:
- “taosc”: 通过 Native 连接方式查询。
- “rest” : 通过 restful 连接方式查询。
`query_times` 指定运行查询的次数,数值类型。
查询场景可以通过设置 `kill_slow_query_threshold``kill_slow_query_interval` 参数来控制杀掉慢查询语句的执行threshold 控制如果 exec_usec 超过指定时间的查询将被 taosBenchmark 杀掉,单位为秒。
interval 控制休眠时间,避免持续查询慢查询消耗 CPU单位为秒。
其它通用参数详见 [通用配置参数](#通用配置参数)
其它通用参数详见 [通用配置参数](#通用配置参数)。
#### 执行指定查询语句
查询指定表(可以指定超级表、子表或普通表)的配置参数在 `specified_table_query` 中设置。
- **mixed_query**:查询模式
“yes”`混合查询`
"no"(默认值)`普通查询`
`普通查询``sqls` 中每个 sql 启动 `threads` 个线程查询此 sql执行完 `query_times` 次查询后退出,执行此 sql 的所有线程都完成后进入下一个 sql
- **mixed_query**:混合查询开关。
“yes”: 开启 “混合查询”。
“no” : 关闭 “混合查询” ,即 “普通查询”。
- 普通查询:
`sqls` 中每个 sql 启动 `threads` 个线程查询此 sql, 执行完 `query_times` 次查询后退出,执行此 sql 的所有线程都完成后进入下一个 sql
`查询总次数` = `sqls` 个数 * `query_times` * `threads`
`混合查询``sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组,每个 sql 都需执行 `query_times` 次查询
- 混合查询:
`sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组, 每个 sql 都需执行 `query_times` 次查询
`查询总次数` = `sqls` 个数 * `query_times`
- **batch_query**:批查询功开关。
取值范围 “yes” 表示开启,"no" 不开启,其它值报错。
批查询是指 `sqls` 中所有 sql 分成 `threads` 个组,每个线程执行一组,每个 sql 只执行一次查询后退出,主线程等待所有线程都执行完,再判断是否设置有 `query_interval` 参数,如果有需要 sleep 指定时间,再启动各线程组重复前面的过程,直到查询次数耗尽为止。
功能限制条件:
- 只支持 `mixed_query` 为 "yes" 的场景。
- 不支持 restful 查询,即 `query_mode` 不能为 "rest"。
- **query_interval**查询时间间隔单位millisecond默认值为 0。
"batch_query" 开关打开时,表示是每批查询完间隔时间;关闭时,表示每个 sql 查询完间隔时间
如果执行查询的时间超过间隔时间,那么将不再等待,如果执行查询的时间不足间隔时间,需等待补足间隔时间
- **threads**:执行查询 SQL 的线程数,默认值为 1。

View File

@ -170,6 +170,8 @@ static void dmSetSignalHandle() {
#endif
}
extern bool generateNewMeta;
static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global.startTime = taosGetTimestampMs();
@ -208,6 +210,8 @@ static int32_t dmParseArgs(int32_t argc, char const *argv[]) {
global.dumpSdb = true;
} else if (strcmp(argv[i], "-dTxn") == 0) {
global.deleteTrans = true;
} else if (strcmp(argv[i], "-r") == 0) {
generateNewMeta = true;
} else if (strcmp(argv[i], "-E") == 0) {
if (i < argc - 1) {
if (strlen(argv[++i]) >= PATH_MAX) {

View File

@ -257,22 +257,185 @@ void vnodeGetMetaPath(SVnode *pVnode, const char *metaDir, char *fname) {
snprintf(fname + offset, TSDB_FILENAME_LEN - offset - 1, "%s%s", TD_DIRSEP, metaDir);
}
bool generateNewMeta = false;
static int32_t metaGenerateNewMeta(SMeta **ppMeta) {
SMeta *pNewMeta = NULL;
SMeta *pMeta = *ppMeta;
SVnode *pVnode = pMeta->pVnode;
metaInfo("vgId:%d start to generate new meta", TD_VID(pMeta->pVnode));
// Open a new meta for organization
int32_t code = metaOpenImpl(pMeta->pVnode, &pNewMeta, VNODE_META_TMP_DIR, false);
if (code) {
return code;
}
code = metaBegin(pNewMeta, META_BEGIN_HEAP_NIL);
if (code) {
return code;
}
// i == 0, scan super table
// i == 1, scan normal table and child table
for (int i = 0; i < 2; i++) {
TBC *uidCursor = NULL;
int32_t counter = 0;
code = tdbTbcOpen(pMeta->pUidIdx, &uidCursor, NULL);
if (code) {
metaError("vgId:%d failed to open uid index cursor, reason:%s", TD_VID(pVnode), tstrerror(code));
return code;
}
code = tdbTbcMoveToFirst(uidCursor);
if (code) {
metaError("vgId:%d failed to move to first, reason:%s", TD_VID(pVnode), tstrerror(code));
tdbTbcClose(uidCursor);
return code;
}
for (;;) {
const void *pKey;
int kLen;
const void *pVal;
int vLen;
if (tdbTbcGet(uidCursor, &pKey, &kLen, &pVal, &vLen) < 0) {
break;
}
tb_uid_t uid = *(tb_uid_t *)pKey;
SUidIdxVal *pUidIdxVal = (SUidIdxVal *)pVal;
if ((i == 0 && (pUidIdxVal->suid && pUidIdxVal->suid == uid)) // super table
|| (i == 1 && (pUidIdxVal->suid == 0 || pUidIdxVal->suid != uid)) // normal table and child table
) {
counter++;
if (i == 0) {
metaInfo("vgId:%d counter:%d new meta handle %s table uid:%" PRId64, TD_VID(pVnode), counter, "super", uid);
} else {
metaInfo("vgId:%d counter:%d new meta handle %s table uid:%" PRId64, TD_VID(pVnode), counter,
pUidIdxVal->suid == 0 ? "normal" : "child", uid);
}
// fetch table entry
void *value = NULL;
int valueSize = 0;
if (tdbTbGet(pMeta->pTbDb,
&(STbDbKey){
.version = pUidIdxVal->version,
.uid = uid,
},
sizeof(uid), &value, &valueSize) == 0) {
SDecoder dc = {0};
SMetaEntry me = {0};
tDecoderInit(&dc, value, valueSize);
if (metaDecodeEntry(&dc, &me) == 0) {
if (me.type == TSDB_CHILD_TABLE &&
tdbTbGet(pMeta->pUidIdx, &me.ctbEntry.suid, sizeof(me.ctbEntry.suid), NULL, NULL) != 0) {
metaError("vgId:%d failed to get super table uid:%" PRId64 " for child table uid:%" PRId64,
TD_VID(pVnode), me.ctbEntry.suid, uid);
} else if (metaHandleEntry2(pNewMeta, &me) != 0) {
metaError("vgId:%d failed to handle entry, uid:%" PRId64, TD_VID(pVnode), uid);
}
}
tDecoderClear(&dc);
}
tdbFree(value);
}
code = tdbTbcMoveToNext(uidCursor);
if (code) {
metaError("vgId:%d failed to move to next, reason:%s", TD_VID(pVnode), tstrerror(code));
return code;
}
}
tdbTbcClose(uidCursor);
}
code = metaCommit(pNewMeta, pNewMeta->txn);
if (code) {
metaError("vgId:%d failed to commit, reason:%s", TD_VID(pVnode), tstrerror(code));
return code;
}
code = metaFinishCommit(pNewMeta, pNewMeta->txn);
if (code) {
metaError("vgId:%d failed to finish commit, reason:%s", TD_VID(pVnode), tstrerror(code));
return code;
}
if ((code = metaBegin(pNewMeta, META_BEGIN_HEAP_NIL)) != 0) {
metaError("vgId:%d failed to begin new meta, reason:%s", TD_VID(pVnode), tstrerror(code));
}
metaClose(&pNewMeta);
metaInfo("vgId:%d finish to generate new meta", TD_VID(pVnode));
// Commit the new metadata
char metaDir[TSDB_FILENAME_LEN] = {0};
char metaTempDir[TSDB_FILENAME_LEN] = {0};
char metaBackupDir[TSDB_FILENAME_LEN] = {0};
vnodeGetMetaPath(pVnode, metaDir, VNODE_META_DIR);
vnodeGetMetaPath(pVnode, metaTempDir, VNODE_META_TMP_DIR);
vnodeGetMetaPath(pVnode, metaBackupDir, VNODE_META_BACKUP_DIR);
metaClose(ppMeta);
if (taosRenameFile(metaDir, metaBackupDir) != 0) {
metaError("vgId:%d failed to rename old meta to backup, reason:%s", TD_VID(pVnode), tstrerror(terrno));
return terrno;
}
// rename the new meta to old meta
if (taosRenameFile(metaTempDir, metaDir) != 0) {
metaError("vgId:%d failed to rename new meta to old meta, reason:%s", TD_VID(pVnode), tstrerror(terrno));
return terrno;
}
code = metaOpenImpl(pVnode, ppMeta, VNODE_META_DIR, false);
if (code) {
metaError("vgId:%d failed to open new meta, reason:%s", TD_VID(pVnode), tstrerror(code));
return code;
}
metaInfo("vgId:%d successfully opened new meta", TD_VID(pVnode));
return 0;
}
int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
int32_t code = TSDB_CODE_SUCCESS;
char metaDir[TSDB_FILENAME_LEN] = {0};
char metaBackupDir[TSDB_FILENAME_LEN] = {0};
char metaTempDir[TSDB_FILENAME_LEN] = {0};
vnodeGetMetaPath(pVnode, VNODE_META_DIR, metaDir);
vnodeGetMetaPath(pVnode, VNODE_META_BACKUP_DIR, metaBackupDir);
vnodeGetMetaPath(pVnode, VNODE_META_TMP_DIR, metaTempDir);
// Check file states
if (!taosCheckExistFile(metaDir) && taosCheckExistFile(metaTempDir)) {
bool metaExists = taosCheckExistFile(metaDir);
bool metaBackupExists = taosCheckExistFile(metaBackupDir);
bool metaTempExists = taosCheckExistFile(metaTempDir);
if ((!metaBackupExists && !metaExists && metaTempExists) //
|| (metaBackupExists && !metaExists && !metaTempExists) //
|| (metaBackupExists && metaExists && metaTempExists) //
) {
metaError("vgId:%d, invalid meta state, please check!", TD_VID(pVnode));
return TSDB_CODE_FAILED;
} else if (!metaBackupExists && metaExists && metaTempExists) {
taosRemoveDir(metaTempDir);
} else if (metaBackupExists && !metaExists && metaTempExists) {
code = taosRenameFile(metaTempDir, metaDir);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s: rename %s to %s failed", TD_VID(pVnode), __func__, __FILE__,
__LINE__, tstrerror(code), metaTempDir, metaDir);
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
return code;
}
taosRemoveDir(metaBackupDir);
} else if (metaBackupExists && metaExists && !metaTempExists) {
taosRemoveDir(metaBackupDir);
}
// Do open meta
@ -282,6 +445,14 @@ int32_t metaOpen(SVnode *pVnode, SMeta **ppMeta, int8_t rollback) {
return code;
}
if (generateNewMeta) {
code = metaGenerateNewMeta(ppMeta);
if (code) {
metaError("vgId:%d, %s failed at %s:%d since %s", TD_VID(pVnode), __func__, __FILE__, __LINE__, tstrerror(code));
return code;
}
}
return TSDB_CODE_SUCCESS;
}

View File

@ -57,7 +57,6 @@ void destroyStreamCountAggOperatorInfo(void* param) {
}
destroyStreamBasicInfo(&pInfo->basic);
cleanupExprSupp(&pInfo->scalarSupp);
clearGroupResInfo(&pInfo->groupResInfo);
taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos);

View File

@ -56,7 +56,6 @@ void destroyStreamEventOperatorInfo(void* param) {
}
destroyStreamBasicInfo(&pInfo->basic);
clearGroupResInfo(&pInfo->groupResInfo);
taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos);
pInfo->pUpdated = NULL;

View File

@ -2206,7 +2206,6 @@ void destroyStreamSessionAggOperatorInfo(void* param) {
}
destroyStreamBasicInfo(&pInfo->basic);
cleanupExprSupp(&pInfo->scalarSupp);
clearGroupResInfo(&pInfo->groupResInfo);
taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos);
@ -4445,7 +4444,6 @@ void destroyStreamStateOperatorInfo(void* param) {
}
destroyStreamBasicInfo(&pInfo->basic);
clearGroupResInfo(&pInfo->groupResInfo);
taosArrayDestroyP(pInfo->pUpdated, destroyFlusedPos);
pInfo->pUpdated = NULL;

View File

@ -2154,12 +2154,15 @@ static int32_t pdcDealProject(SOptimizeContext* pCxt, SProjectLogicNode* pProjec
if (NULL != pProject->node.pLimit || NULL != pProject->node.pSlimit) {
return TSDB_CODE_SUCCESS;
}
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0);
if(pChild->pLimit != NULL) {
return TSDB_CODE_SUCCESS;
}
int32_t code = TSDB_CODE_SUCCESS;
SNode* pProjCond = NULL;
code = rewriteProjectCondForPushDown(pCxt, pProject, &pProjCond);
if (TSDB_CODE_SUCCESS == code) {
SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pProject->node.pChildren, 0);
code = pdcPushDownCondToChild(pCxt, pChild, &pProjCond);
}

View File

@ -196,7 +196,7 @@ TEST(osFileTests, taosCopyFile) {
retsize = taosReadFromCFile(NULL, 0, 0, NULL);
EXPECT_EQ(retsize, 0);
taosRemoveFile(from);
taosRemoveFile(from);
}
TEST(osFileTests, taosCreateFile) {

View File

@ -389,7 +389,7 @@ TEST(osTest, osFile) {
(void)taosThreadJoin(thread2, NULL);
taosThreadClear(&thread2);
// int ret = taosRemoveFile(fname);
taosRemoveFile(fname);
// ASSERT_EQ(ret, 0);
// printf("remove file success");
}
@ -651,6 +651,8 @@ TEST(osTest, osFilePerformance) {
taosMemoryFree(writeBuffer);
taosMemoryFree(readBuffer);
taosRemoveFile(fname);
(void)printf("Test Write file %d times, cost: %" PRId64 "us\n", TESTTIMES, WriteFileCost);
(void)printf("Test Read file %d times, cost: %" PRId64 "us\n", TESTTIMES, ReadFileCost);
(void)printf("Test OpenForWrite & Close file %d times, cost: %" PRId64 "us\n", TESTTIMES, OpenForWriteCloseFileCost);

View File

@ -42,8 +42,8 @@ class TDTestCase(TBase):
tdSql.execute("insert into d0 file '%s'" % datafile)
tdSql.execute("CREATE TABLE `n1` (`ts` TIMESTAMP, `current` FLOAT, `voltage` INT, co NCHAR(10))")
tdSql.execute("insert into n1 values(now, 1, null, '23')")
tdSql.execute("insert into n1 values(now, null, 3, '23')")
tdSql.execute("insert into n1 values(now, 5, 3, '23')")
tdSql.execute("insert into n1 values(now+1a, null, 3, '23')")
tdSql.execute("insert into n1 values(now+2a, 5, 3, '23')")
def test_normal_query_new(self, testCase):
# read sql from .sql file and execute

View File

@ -0,0 +1,36 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "test",
"query_times": 5,
"query_mode": "taosc",
"specified_table_query": {
"concurrent": 5,
"query_interval": 0,
"mixed_query": "no",
"batch_query": "yes",
"sqls": [
{
"sql": "select last_row(*) from test.meters"
},
{
"sql": "select count(*) from test.meters"
},
{
"sql": "select * from test.d0",
"result": "./query_res1.txt"
},
{
"sql": "select count(*) from test.d1"
},
{
"sql": "select * from test.d2"
}
]
}
}

View File

@ -0,0 +1,36 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "test",
"query_times": 5,
"query_mode": "rest",
"specified_table_query": {
"concurrent": 5,
"query_interval": 1000,
"mixed_query": "yes",
"batch_query": "yes",
"sqls": [
{
"sql": "select last_row(*) from test.meters"
},
{
"sql": "select count(*) from test.meters"
},
{
"sql": "select * from test.d0",
"result": "./query_res1.txt"
},
{
"sql": "select count(*) from test.d1"
},
{
"sql": "select * from test.d2"
}
]
}
}

View File

@ -0,0 +1,36 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "test",
"query_times": 5,
"query_mode": "taosc",
"specified_table_query": {
"concurrent": 5,
"query_interval": 1000,
"mixed_query": "yes",
"batch_query": "yes",
"sqls": [
{
"sql": "select last_row(*) from test.meters"
},
{
"sql": "select count(*) from test.meters"
},
{
"sql": "select * from test.d0",
"result": "./query_res1.txt"
},
{
"sql": "select count(*) from test.d1"
},
{
"sql": "select * from test.d2"
}
]
}
}

View File

@ -0,0 +1,36 @@
{
"filetype": "query",
"cfgdir": "/etc/taos",
"host": "127.0.0.1",
"port": 6030,
"user": "root",
"password": "taosdata",
"confirm_parameter_prompt": "no",
"databases": "test",
"query_times": 5,
"query_mode": "taosc",
"specified_table_query": {
"concurrent": 5,
"query_interval": 100,
"mixed_query": "yes",
"batch_query": "no",
"sqls": [
{
"sql": "select last_row(*) from test.meters"
},
{
"sql": "select count(*) from test.meters"
},
{
"sql": "select * from test.d0",
"result": "./query_res1.txt"
},
{
"sql": "select count(*) from test.d1"
},
{
"sql": "select * from test.d2"
}
]
}
}

View File

@ -90,15 +90,15 @@ class TDTestCase(TBase):
fval = float(value)
# compare
if equal and fval != expect:
tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:{key} end:{end} output:\n{output}")
tdLog.exit(f"check not expect. expect:{expect} real:{fval}, key:'{key}' end:'{end}' output:\n{output}")
elif equal == False and fval <= expect:
tdLog.exit(f"failed because {fval} <= {expect}, key:{key} end:{end} output:\n{output}")
tdLog.exit(f"failed because {fval} <= {expect}, key:'{key}' end:'{end}' output:\n{output}")
else:
# succ
if equal:
tdLog.info(f"check successfully. key:{key} expect:{expect} real:{fval}")
tdLog.info(f"check successfully. key:'{key}' expect:{expect} real:{fval}")
else:
tdLog.info(f"check successfully. key:{key} {fval} > {expect}")
tdLog.info(f"check successfully. key:'{key}' {fval} > {expect}")
def checkAfterRun(self, benchmark, jsonFile, specMode, tbCnt):
@ -128,16 +128,24 @@ class TDTestCase(TBase):
sqls = data[label]["sqls"]
# mix
# batch_query
try:
batchQuery = data[label]["batch_query"]
except:
batchQuery = "no"
# mixed_query
try:
mixedQuery = data[label]["mixed_query"]
except:
mixedQuery = "no"
tdLog.info(f"queryTimes={queryTimes} concurrent={concurrent} mixedQuery={mixedQuery} len(sqls)={len(sqls)} label={label}\n")
tdLog.info(f"queryTimes={queryTimes} concurrent={concurrent} mixedQuery={mixedQuery} "
f"batchQuery={batchQuery} len(sqls)={len(sqls)} label={label}\n")
totalQueries = 0
totalQueries = 0
threadQueries = 0
QPS = 10
if continueIfFail.lower() == "yes":
allEnd = " "
@ -154,13 +162,20 @@ class TDTestCase(TBase):
minKey = "min:"
else:
# spec mixed or super
if specMode:
# spec
totalQueries = queryTimes * len(sqls)
# spec mixed
if batchQuery.lower() == "yes":
# batch
threadQueries = len(sqls)
QPS = 2
else:
threadQueries = totalQueries
else:
# super
totalQueries = queryTimes * len(sqls) * tbCnt
threadQueries = totalQueries
threadQueries = totalQueries
nSql = len(sqls)
if specMode and nSql < concurrent :
@ -182,7 +197,7 @@ class TDTestCase(TBase):
["p99: ", "s", 0, False],
["INFO: Spend ", " ", 0, False],
["completed total queries: ", ",", totalQueries, True],
["the QPS of all threads:", allEnd, 10 , False] # all qps need > 5
["the QPS of all threads:", allEnd, QPS , False] # all qps need > 5
]
# check
@ -196,6 +211,7 @@ class TDTestCase(TBase):
args = [
["./tools/benchmark/basic/json/queryModeSpec", True],
["./tools/benchmark/basic/json/queryModeSpecMix", True],
["./tools/benchmark/basic/json/queryModeSpecMixBatch", True],
["./tools/benchmark/basic/json/queryModeSuper", False]
]
@ -222,8 +238,9 @@ class TDTestCase(TBase):
self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBothSpecSuper.json")
# json format error
self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorFormat.json")
# batch query
self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBatchNoMix.json")
self.expectFailed(f"{benchmark} -f ./tools/benchmark/basic/json/queryErrorBatchRest.json")
def run(self):
tbCnt = 10

View File

@ -360,6 +360,18 @@ class TDTestCase:
tdSql.checkRows(0)
tdLog.info("check db1 vgroups 1 limit 1 offset 100 successfully!")
def ts6080(self):
tdLog.printNoPrefix("======== test case 6080: ")
tdSql.execute("create database db6080 vgroups 1;")
tdSql.execute("use db6080;")
tdSql.execute("create table db6080.st(ts timestamp, age int) tags(area int);")
tdSql.execute("create table db6080.t1 using db6080.st tags(1);")
tdSql.Execute("insert into db6080.t1 values(1537146000000, 1);")
tdSql.Execute("insert into db6080.t1 values(1537146000001, 2);")
tdSql.query("select ts, age from (select ts, age from db6080.t1 order by ts limit 1) where ts > 1537146000000;")
tdSql.checkRows(0)
def run(self):
# tdSql.prepare()
@ -370,6 +382,7 @@ class TDTestCase:
self.checkVGroups()
def stop(self):
tdSql.close()
tdLog.success(f"{__file__} successfully executed")

View File

@ -19,8 +19,7 @@ IF(TD_WEBSOCKET)
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND
COMMAND cargo update
COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release -p taos-ws-sys --features rustls
COMMAND RUSTFLAGS=-Ctarget-feature=-crt-static cargo build --release --locked -p taos-ws-sys --features rustls
INSTALL_COMMAND
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include
@ -38,8 +37,7 @@ IF(TD_WEBSOCKET)
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND
COMMAND cargo update
COMMAND cargo build --release -p taos-ws-sys --features rustls
COMMAND cargo build --release --locked -p taos-ws-sys --features rustls
INSTALL_COMMAND
COMMAND cp target/release/taosws.dll ${CMAKE_BINARY_DIR}/build/lib
COMMAND cp target/release/taosws.dll.lib ${CMAKE_BINARY_DIR}/build/lib/taosws.lib
@ -58,8 +56,7 @@ IF(TD_WEBSOCKET)
PATCH_COMMAND
COMMAND git clean -f -d
BUILD_COMMAND
COMMAND cargo update
COMMAND cargo build --release -p taos-ws-sys --features rustls
COMMAND cargo build --release --locked -p taos-ws-sys --features rustls
INSTALL_COMMAND
COMMAND cp target/release/${websocket_lib_file} ${CMAKE_BINARY_DIR}/build/lib
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/build/include

View File

@ -665,6 +665,7 @@ typedef struct SpecifiedQueryInfo_S {
TAOS_RES *res[MAX_QUERY_SQL_COUNT];
uint64_t totalQueried;
bool mixed_query;
bool batchQuery; // mixed query have batch and no batch query
// error rate
uint64_t totalFail;
} SpecifiedQueryInfo;

View File

@ -1860,6 +1860,23 @@ int32_t readSpecQueryJson(tools_cJSON * specifiedQuery) {
}
}
// batchQuery
tools_cJSON *batchQueryObj =
tools_cJSON_GetObjectItem(specifiedQuery, "batch_query");
if (tools_cJSON_IsString(batchQueryObj)) {
if (0 == strcasecmp(batchQueryObj->valuestring, "yes")) {
g_queryInfo.specifiedQueryInfo.batchQuery = true;
infoPrint("%s\n","batch_query is True");
} else if (0 == strcasecmp(batchQueryObj->valuestring, "no")) {
g_queryInfo.specifiedQueryInfo.batchQuery = false;
infoPrint("%s\n","batch_query is False");
} else {
errorPrint("Invalid batch_query value: %s\n",
batchQueryObj->valuestring);
return -1;
}
}
tools_cJSON *concurrent =
tools_cJSON_GetObjectItem(specifiedQuery, "concurrent");
if (tools_cJSON_IsNumber(concurrent)) {

View File

@ -47,7 +47,7 @@ void* benchCancelHandler(void* arg) {
}
#endif
void checkArgumentValid() {
int checkArgumentValid() {
// check prepared_rand valid
if(g_arguments->prepared_rand < g_arguments->reqPerReq) {
infoPrint("prepared_rand(%"PRIu64") < num_of_records_per_req(%d), so set num_of_records_per_req = prepared_rand\n",
@ -64,13 +64,32 @@ void checkArgumentValid() {
false,
1)) {
errorPrint("%s", "Failed to convert server address\n");
return;
return -1;
}
encodeAuthBase64();
g_arguments->rest_server_ver_major =
getServerVersionRest(g_arguments->port);
}
// check batch query
if (g_arguments->test_mode == QUERY_TEST) {
if (g_queryInfo.specifiedQueryInfo.batchQuery) {
// batch_query = yes
if (!g_queryInfo.specifiedQueryInfo.mixed_query) {
// mixed_query = no
errorPrint("%s\n", "batch_query = yes require mixed_query is yes");
return -1;
}
// rest not support
if (g_queryInfo.iface == REST_IFACE) {
errorPrint("%s\n", "batch_query = yes not support restful.");
return -1;
}
}
}
return 0;
}
int main(int argc, char* argv[]) {
@ -144,7 +163,11 @@ int main(int argc, char* argv[]) {
}
infoPrint("client version: %s\n", taos_get_client_info());
checkArgumentValid();
if (checkArgumentValid()) {
errorPrint("failed to readJsonConfig %s\n", g_arguments->metaFile);
exitLog();
return -1;
}
if (g_arguments->test_mode == INSERT_TEST) {
if (insertTestProcess()) {

View File

@ -80,10 +80,15 @@ int selectAndGetResult(qThreadInfo *pThreadInfo, char *command, bool record) {
}
// interlligent sleep
void autoSleep(uint64_t interval, uint64_t delay ) {
int32_t autoSleep(uint64_t interval, uint64_t delay ) {
int32_t msleep = 0;
if (delay < interval * 1000) {
toolsMsleep((int32_t)(interval * 1000 - delay)); // ms
msleep = (int32_t)((interval - delay/1000));
infoPrint("do sleep %dms ...\n", msleep);
toolsMsleep(msleep); // ms
debugPrint("%s\n","do sleep end");
}
return msleep;
}
// reset
@ -140,10 +145,13 @@ static void *specQueryMixThread(void *sarg) {
int64_t st = 0;
int64_t et = 0;
int64_t startTs = toolsGetTimestampMs();
int64_t lastPrintTime = startTs;
uint64_t queryTimes = g_queryInfo.specifiedQueryInfo.queryTimes;
uint64_t interval = g_queryInfo.specifiedQueryInfo.queryInterval;
int64_t startTs = toolsGetTimestampMs();
int64_t lastPrintTime = startTs;
// batchQuery
bool batchQuery = g_queryInfo.specifiedQueryInfo.batchQuery;
uint64_t queryTimes = batchQuery ? 1 : g_queryInfo.specifiedQueryInfo.queryTimes;
uint64_t interval = batchQuery ? 0 : g_queryInfo.specifiedQueryInfo.queryInterval;
pThreadInfo->query_delay_list = benchArrayInit(queryTimes, sizeof(int64_t));
for (int i = pThreadInfo->start_sql; i <= pThreadInfo->end_sql; ++i) {
SSQL * sql = benchArrayGet(g_queryInfo.specifiedQueryInfo.sqls, i);
@ -382,7 +390,7 @@ static void *stbQueryThread(void *sarg) {
// --------------------------------- firse level function ------------------------------
//
void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend) {
void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend, BArray *pDelays) {
// valid check
if (infos == NULL || threadCnt == 0) {
return ;
@ -444,9 +452,11 @@ void totalChildQuery(qThreadInfo* infos, int threadCnt, int64_t spend) {
(int32_t)(delay_list->size * 0.99)))/1E6,
*(int64_t *)(benchArrayGet(delay_list,
(int32_t)(delay_list->size - 1)))/1E6);
} else {
errorPrint("%s() LN%d, delay_list size: %"PRId64"\n",
__func__, __LINE__, (int64_t)delay_list->size);
}
// copy to another
if (pDelays) {
benchArrayAddBatch(pDelays, delay_list->pData, delay_list->size, false);
}
benchArrayDestroy(delay_list);
}
@ -547,7 +557,7 @@ static int stbQuery(uint16_t iface, char* dbName) {
}
// total show
totalChildQuery(threadInfos, threadCnt, end - start);
totalChildQuery(threadInfos, threadCnt, end - start, NULL);
ret = 0;
@ -825,7 +835,7 @@ static int specQueryMix(uint16_t iface, char* dbName) {
}
// statistic
totalChildQuery(infos, threadCnt, end - start);
totalChildQuery(infos, threadCnt, end - start, NULL);
ret = 0;
OVER:
@ -838,6 +848,206 @@ OVER:
return ret;
}
void totalBatchQuery(int32_t allSleep, BArray *pDelays) {
// sort
qsort(pDelays->pData, pDelays->size, pDelays->elemSize, compare);
// total delays
double totalDelays = 0;
for (size_t i = 0; i < pDelays->size; i++) {
int64_t *delay = benchArrayGet(pDelays, i);
totalDelays += *delay;
}
printf("\n");
// show sleep times
if (allSleep > 0) {
infoPrint("All sleep spend: %.3fs\n", (float)allSleep/1000);
}
// show P90 ...
if (pDelays->size) {
infoPrint(
"Total delay: "
"min delay: %.6fs, "
"avg delay: %.6fs, "
"p90: %.6fs, "
"p95: %.6fs, "
"p99: %.6fs, "
"max: %.6fs\n",
*(int64_t *)(benchArrayGet(pDelays, 0))/1E6,
(double)totalDelays/pDelays->size/1E6,
*(int64_t *)(benchArrayGet(pDelays,
(int32_t)(pDelays->size * 0.9)))/1E6,
*(int64_t *)(benchArrayGet(pDelays,
(int32_t)(pDelays->size * 0.95)))/1E6,
*(int64_t *)(benchArrayGet(pDelays,
(int32_t)(pDelays->size * 0.99)))/1E6,
*(int64_t *)(benchArrayGet(pDelays,
(int32_t)(pDelays->size - 1)))/1E6);
}
}
//
// specQuery Mix Batch
//
static int specQueryBatch(uint16_t iface, char* dbName) {
// init
BArray *pDelays = NULL;
int ret = -1;
int nConcurrent = g_queryInfo.specifiedQueryInfo.concurrent;
uint64_t interval = g_queryInfo.specifiedQueryInfo.queryInterval;
pthread_t * pids = benchCalloc(nConcurrent, sizeof(pthread_t), true);
qThreadInfo *infos = benchCalloc(nConcurrent, sizeof(qThreadInfo), true);
infoPrint("start batch query, sleep interval:%" PRIu64 "ms query times:%" PRIu64 " thread:%d \n",
interval, g_queryInfo.query_times, nConcurrent);
// concurent calc
int total_sql_num = g_queryInfo.specifiedQueryInfo.sqls->size;
int start_sql = 0;
int a = total_sql_num / nConcurrent;
if (a < 1) {
warnPrint("sqls num:%d < concurent:%d, set concurrent %d\n", total_sql_num, nConcurrent, nConcurrent);
nConcurrent = total_sql_num;
a = 1;
}
int b = 0;
if (nConcurrent != 0) {
b = total_sql_num % nConcurrent;
}
//
// connect
//
int connCnt = 0;
for (int i = 0; i < nConcurrent; ++i) {
qThreadInfo *pThreadInfo = infos + i;
// create conn
if (initQueryConn(pThreadInfo, iface)){
ret = -1;
goto OVER;
}
connCnt ++;
}
// reset total
g_queryInfo.specifiedQueryInfo.totalQueried = 0;
g_queryInfo.specifiedQueryInfo.totalFail = 0;
//
// running
//
int threadCnt = 0;
int allSleep = 0;
pDelays = benchArrayInit(10, sizeof(int64_t));
for (int m = 0; m < g_queryInfo.query_times; ++m) {
// reset
threadCnt = 0;
start_sql = 0;
// create thread
for (int i = 0; i < nConcurrent; ++i) {
qThreadInfo *pThreadInfo = infos + i;
pThreadInfo->threadID = i;
pThreadInfo->start_sql = start_sql;
pThreadInfo->end_sql = i < b ? start_sql + a : start_sql + a - 1;
start_sql = pThreadInfo->end_sql + 1;
pThreadInfo->total_delay = 0;
// total zero
pThreadInfo->nSucc = 0;
pThreadInfo->nFail = 0;
// main run
int code = pthread_create(pids + i, NULL, specQueryMixThread, pThreadInfo);
if (code != 0) {
errorPrint("failed specQueryBatchThread create. error code =%d \n", code);
break;
}
threadCnt ++;
}
bool needExit = false;
if (threadCnt != nConcurrent) {
// if failed, set termainte flag true like ctrl+c exit
needExit = true;
g_arguments->terminate = true;
}
// wait thread finished
int64_t start = toolsGetTimestampUs();
for (int i = 0; i < threadCnt; ++i) {
pthread_join(pids[i], NULL);
qThreadInfo *pThreadInfo = infos + i;
// total queries
g_queryInfo.specifiedQueryInfo.totalQueried += pThreadInfo->nSucc;
if (g_arguments->continueIfFail == YES_IF_FAILED) {
// yes need add failed count
g_queryInfo.specifiedQueryInfo.totalQueried += pThreadInfo->nFail;
g_queryInfo.specifiedQueryInfo.totalFail += pThreadInfo->nFail;
}
// destory
if (needExit) {
benchArrayDestroy(pThreadInfo->query_delay_list);
pThreadInfo->query_delay_list = NULL;
}
}
int64_t end = toolsGetTimestampUs();
// create
if (needExit) {
errorPrint("failed to create thread. expect nConcurrent=%d real threadCnt=%d, exit testing.\n", nConcurrent, threadCnt);
goto OVER;
}
// batch total
printf("\n");
totalChildQuery(infos, threadCnt, end - start, pDelays);
// show batch total
int64_t delay = end - start;
infoPrint("count:%d execute batch spend: %" PRId64 "ms\n", m + 1, delay/1000);
// sleep
if ( g_queryInfo.specifiedQueryInfo.batchQuery && interval > 0) {
allSleep += autoSleep(interval, delay);
}
// check cancel
if(g_arguments->terminate) {
break;
}
}
ret = 0;
// all total
totalBatchQuery(allSleep, pDelays);
OVER:
// close conn
for (int i = 0; i < connCnt; ++i) {
qThreadInfo *pThreadInfo = infos + i;
closeQueryConn(pThreadInfo, iface);
}
// free threads
tmfree(pids);
tmfree(infos);
// free sqls
freeSpecialQueryInfo();
// free delays
if (pDelays) {
benchArrayDestroy(pDelays);
}
return ret;
}
// total query for end
void totalQuery(int64_t spends) {
// total QPS
@ -903,14 +1113,19 @@ int queryTestProcess() {
// start running
//
uint64_t startTs = toolsGetTimestampMs();
if(g_queryInfo.specifiedQueryInfo.sqls && g_queryInfo.specifiedQueryInfo.sqls->size > 0) {
// specified table
if (g_queryInfo.specifiedQueryInfo.mixed_query) {
// mixed
if (specQueryMix(g_queryInfo.iface, g_queryInfo.dbName)) {
return -1;
if(g_queryInfo.specifiedQueryInfo.batchQuery) {
if (specQueryBatch(g_queryInfo.iface, g_queryInfo.dbName)) {
return -1;
}
} else {
if (specQueryMix(g_queryInfo.iface, g_queryInfo.dbName)) {
return -1;
}
}
} else {
// no mixied

View File

@ -1,15 +1,33 @@
#!/bin/bash
# Generate install package for all os system
# Generate install package for Linux Platform
set -e
# set -x
while getopts "e:v:" opt; do
case "$opt" in
e) edition="$OPTARG" ;; # -e enterprise/community
v) version="$OPTARG" ;; # -v version
*) echo "Usage: $0 -e edition -v version"; exit 1 ;;
esac
done
if [ -z "$edition" ] || [ -z "$version" ]; then
echo "Usage: $0 -e edition -v version"
exit 1
fi
if [ "$edition" == "enterprise" ]; then
productName="TDengine-enterprise-anode"
fi
if [ "$edition" == "community" ]; then
productName="TDengine-community-anode"
fi
echo start to build release package, edition: ${edition}, version: ${version}
curr_dir=$(pwd)
compile_dir=$1
version="1.0.1"
osType=
pagMode=
productName="TDengine-enterprise-anode"
script_dir="$(dirname $(readlink -f $0))"
top_dir="$(readlink -f ${script_dir}/..)"
@ -45,18 +63,17 @@ fi
# python files
mkdir -p ${install_dir}/bin && mkdir -p ${install_dir}/lib
# remove cache files generated by Python interpreter
TARGET_PATTERN="__pycache__"
find "${top_dir}/taosanalytics/" -type d -name "$TARGET_PATTERN" -exec rm -rf {} +
# script to control start/stop/uninstall process
rm -r ${top_dir}/taosanalytics/*.pyc || :
cp -r ${top_dir}/taosanalytics/ ${install_dir}/lib/ && chmod a+x ${install_dir}/lib/ || :
cp -r ${top_dir}/script/st*.sh ${install_dir}/bin/ && chmod a+x ${install_dir}/bin/* || :
cp -r ${top_dir}/script/uninstall.sh ${install_dir}/bin/ && chmod a+x ${install_dir}/bin/* || :
cd ${install_dir}
#if [ "$osType" != "Darwin" ]; then
# tar -zcv -f ${tarName} ./bin/* || :
# rm -rf ${install_dir}/bin || :
#else
tar -zcv -f ${tarName} ./lib/* || :
if [ ! -z "${install_dir}" ]; then