commit
a6016c6210
|
@ -201,7 +201,7 @@ The configuration parameters in the URL are as follows:
|
||||||
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
|
- httpConnectTimeout: REST connection timeout in milliseconds, the default value is 5000 ms.
|
||||||
- httpSocketTimeout: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when batchfetch is false.
|
- httpSocketTimeout: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when batchfetch is false.
|
||||||
- messageWaitTimeout: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when batchfetch is true.
|
- messageWaitTimeout: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when batchfetch is true.
|
||||||
- useSSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection.
|
- useSSL: connecting Securely Using SSL. true: using SSL connection, false: not using SSL connection.
|
||||||
|
|
||||||
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
|
**Note**: Some configuration items (e.g., locale, timezone) do not work in the REST connection.
|
||||||
|
|
||||||
|
@ -268,7 +268,7 @@ The configuration parameters in properties are as follows.
|
||||||
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
|
- TSDBDriver.HTTP_CONNECT_TIMEOUT: REST connection timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection.
|
||||||
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
|
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket timeout in milliseconds, the default value is 5000 ms. It only takes effect when using JDBC REST connection and batchfetch is false.
|
||||||
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
|
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: message transmission timeout in milliseconds, the default value is 3000 ms. It only takes effect when using JDBC REST connection and batchfetch is true.
|
||||||
- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL conneciton, false: not using SSL connection. It only takes effect when using JDBC REST connection.
|
- TSDBDriver.PROPERTY_KEY_USE_SSL: connecting Securely Using SSL. true: using SSL connection, false: not using SSL connection. It only takes effect when using JDBC REST connection.
|
||||||
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
|
For JDBC native connections, you can specify other parameters, such as log level, SQL length, etc., by specifying URL and Properties. For more detailed configuration, please refer to [Client Configuration](/reference/config/#Client-Only).
|
||||||
|
|
||||||
### Priority of configuration parameters
|
### Priority of configuration parameters
|
||||||
|
@ -824,7 +824,7 @@ Example usage is as follows.
|
||||||
//query or insert
|
//query or insert
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
connection.close(); // put back to conneciton pool
|
connection.close(); // put back to connection pool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -856,7 +856,7 @@ public static void main(String[] args) throws Exception {
|
||||||
//query or insert
|
//query or insert
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
connection.close(); // put back to conneciton pool
|
connection.close(); // put back to connection pool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -878,7 +878,9 @@ The source code of the sample application is under `TDengine/examples/JDBC`:
|
||||||
|
|
||||||
| taos-jdbcdriver version | major changes |
|
| taos-jdbcdriver version | major changes |
|
||||||
| :---------------------: | :--------------------------------------------: |
|
| :---------------------: | :--------------------------------------------: |
|
||||||
|
| 3.0.1 - 3.0.2 | fix the resultSet data is parsed incorrectly sometimes. 3.0.1 is compiled on JDK 11, you are advised to use 3.0.2 in the JDK 8 environment |
|
||||||
| 3.0.0 | Support for TDengine 3.0 |
|
| 3.0.0 | Support for TDengine 3.0 |
|
||||||
|
| 2.0.41 | fix decode method of username and password in REST connection |
|
||||||
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
|
| 2.0.39 - 2.0.40 | Add REST connection/request timeout parameters |
|
||||||
| 2.0.38 | JDBC REST connections add bulk pull function |
|
| 2.0.38 | JDBC REST connections add bulk pull function |
|
||||||
| 2.0.37 | Support json tags |
|
| 2.0.37 | Support json tags |
|
||||||
|
@ -910,6 +912,12 @@ The source code of the sample application is under `TDengine/examples/JDBC`:
|
||||||
|
|
||||||
**Solution**: Use taos-jdbcdriver 2.* with your TDengine 2.* deployment.
|
**Solution**: Use taos-jdbcdriver 2.* with your TDengine 2.* deployment.
|
||||||
|
|
||||||
|
5. java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer; ... taos-jdbcdriver-3.0.1.jar
|
||||||
|
|
||||||
|
**Cause**:taos-jdbcdriver 3.0.1 is compiled on JDK 11.
|
||||||
|
|
||||||
|
**Solution**: Use taos-jdbcdriver 3.0.2.
|
||||||
|
|
||||||
For additional troubleshooting, see [FAQ](../../../train-faq/faq).
|
For additional troubleshooting, see [FAQ](../../../train-faq/faq).
|
||||||
|
|
||||||
## API Reference
|
## API Reference
|
||||||
|
|
|
@ -36,10 +36,10 @@ int main() {
|
||||||
executeSQL(taos, "CREATE DATABASE power");
|
executeSQL(taos, "CREATE DATABASE power");
|
||||||
executeSQL(taos, "USE power");
|
executeSQL(taos, "USE power");
|
||||||
executeSQL(taos, "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
|
executeSQL(taos, "CREATE STABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT)");
|
||||||
executeSQL(taos, "INSERT INTO d1001 USING meters TAGS(California.SanFrancisco, 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)"
|
executeSQL(taos, "INSERT INTO d1001 USING meters TAGS('California.SanFrancisco', 2) VALUES ('2018-10-03 14:38:05.000', 10.30000, 219, 0.31000) ('2018-10-03 14:38:15.000', 12.60000, 218, 0.33000) ('2018-10-03 14:38:16.800', 12.30000, 221, 0.31000)"
|
||||||
"d1002 USING meters TAGS(California.SanFrancisco, 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)"
|
"d1002 USING meters TAGS('California.SanFrancisco', 3) VALUES ('2018-10-03 14:38:16.650', 10.30000, 218, 0.25000)"
|
||||||
"d1003 USING meters TAGS(California.LosAngeles, 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)"
|
"d1003 USING meters TAGS('California.LosAngeles', 2) VALUES ('2018-10-03 14:38:05.500', 11.80000, 221, 0.28000) ('2018-10-03 14:38:16.600', 13.40000, 223, 0.29000)"
|
||||||
"d1004 USING meters TAGS(California.LosAngeles, 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)");
|
"d1004 USING meters TAGS('California.LosAngeles', 3) VALUES ('2018-10-03 14:38:05.000', 10.80000, 223, 0.29000) ('2018-10-03 14:38:06.500', 11.50000, 221, 0.35000)");
|
||||||
taos_close(taos);
|
taos_close(taos);
|
||||||
taos_cleanup();
|
taos_cleanup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,38 +68,39 @@ TDengine 目前支持时间戳、数字、字符、布尔类型,与 Java 对
|
||||||
### 安装连接器
|
### 安装连接器
|
||||||
|
|
||||||
<Tabs defaultValue="maven">
|
<Tabs defaultValue="maven">
|
||||||
<TabItem value="maven" label="使用 Maven 安装">
|
<TabItem value="maven" label="使用 Maven 安装">
|
||||||
|
|
||||||
目前 taos-jdbcdriver 已经发布到 [Sonatype Repository](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver) 仓库,且各大仓库都已同步。
|
目前 taos-jdbcdriver 已经发布到 [Sonatype Repository](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver)
|
||||||
|
仓库,且各大仓库都已同步。
|
||||||
|
|
||||||
- [sonatype](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver)
|
- [sonatype](https://search.maven.org/artifact/com.taosdata.jdbc/taos-jdbcdriver)
|
||||||
- [mvnrepository](https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver)
|
- [mvnrepository](https://mvnrepository.com/artifact/com.taosdata.jdbc/taos-jdbcdriver)
|
||||||
- [maven.aliyun](https://maven.aliyun.com/mvn/search)
|
- [maven.aliyun](https://maven.aliyun.com/mvn/search)
|
||||||
|
|
||||||
Maven 项目中,在 pom.xml 中添加以下依赖:
|
Maven 项目中,在 pom.xml 中添加以下依赖:
|
||||||
|
|
||||||
```xml-dtd
|
```xml-dtd
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.taosdata.jdbc</groupId>
|
<groupId>com.taosdata.jdbc</groupId>
|
||||||
<artifactId>taos-jdbcdriver</artifactId>
|
<artifactId>taos-jdbcdriver</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
```
|
```
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="source" label="使用源码编译安装">
|
<TabItem value="source" label="使用源码编译安装">
|
||||||
|
|
||||||
可以通过下载 TDengine 的源码,自己编译最新版本的 Java connector
|
可以通过下载 TDengine 的源码,自己编译最新版本的 Java connector
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
git clone https://github.com/taosdata/taos-connector-jdbc.git
|
git clone https://github.com/taosdata/taos-connector-jdbc.git
|
||||||
cd taos-connector-jdbc
|
cd taos-connector-jdbc
|
||||||
mvn clean install -Dmaven.test.skip=true
|
mvn clean install -Dmaven.test.skip=true
|
||||||
```
|
```
|
||||||
|
|
||||||
编译后,在 target 目录下会产生 taos-jdbcdriver-3.0.*-dist.jar 的 jar 包,并自动将编译的 jar 文件放在本地的 Maven 仓库中。
|
编译后,在 target 目录下会产生 taos-jdbcdriver-3.0.*-dist.jar 的 jar 包,并自动将编译的 jar 文件放在本地的 Maven 仓库中。
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## 建立连接
|
## 建立连接
|
||||||
|
@ -110,39 +111,41 @@ TDengine 的 JDBC URL 规范格式为:
|
||||||
对于建立连接,原生连接与 REST 连接有细微不同。
|
对于建立连接,原生连接与 REST 连接有细微不同。
|
||||||
|
|
||||||
<Tabs defaultValue="rest">
|
<Tabs defaultValue="rest">
|
||||||
<TabItem value="native" label="原生连接">
|
<TabItem value="native" label="原生连接">
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata";
|
String jdbcUrl = "jdbc:TAOS://taosdemo.com:6030/test?user=root&password=taosdata";
|
||||||
Connection conn = DriverManager.getConnection(jdbcUrl);
|
Connection conn = DriverManager.getConnection(jdbcUrl);
|
||||||
```
|
```
|
||||||
|
|
||||||
以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。
|
以上示例,使用了 JDBC 原生连接的 TSDBDriver,建立了到 hostname 为 taosdemo.com,端口为 6030(TDengine 的默认端口),数据库名为 test 的连接。这个 URL
|
||||||
|
中指定用户名(user)为 root,密码(password)为 taosdata。
|
||||||
|
|
||||||
**注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll;macOS 下是 libtaos.dylib)。
|
**注意**:使用 JDBC 原生连接,taos-jdbcdriver 需要依赖客户端驱动(Linux 下是 libtaos.so;Windows 下是 taos.dll;macOS 下是 libtaos.dylib)。
|
||||||
|
|
||||||
url 中的配置参数如下:
|
url 中的配置参数如下:
|
||||||
|
|
||||||
- user:登录 TDengine 用户名,默认值 'root'。
|
- user:登录 TDengine 用户名,默认值 'root'。
|
||||||
- password:用户登录密码,默认值 'taosdata'。
|
- password:用户登录密码,默认值 'taosdata'。
|
||||||
- cfgdir:客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。
|
- cfgdir:客户端配置文件目录路径,Linux OS 上默认值 `/etc/taos`,Windows OS 上默认值 `C:/TDengine/cfg`。
|
||||||
- charset:客户端使用的字符集,默认值为系统字符集。
|
- charset:客户端使用的字符集,默认值为系统字符集。
|
||||||
- locale:客户端语言环境,默认值系统当前 locale。
|
- locale:客户端语言环境,默认值系统当前 locale。
|
||||||
- timezone:客户端使用的时区,默认值为系统当前时区。
|
- timezone:客户端使用的时区,默认值为系统当前时区。
|
||||||
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:true。开启批量拉取同时获取一批数据在查询数据量较大时批量拉取可以有效的提升查询性能。
|
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:true。开启批量拉取同时获取一批数据在查询数据量较大时批量拉取可以有效的提升查询性能。
|
||||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败将继续执行下面的 SQL。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败将继续执行下面的 SQL。false:不再执行失败 SQL
|
||||||
|
后的任何语句。默认值为:false。
|
||||||
|
|
||||||
JDBC 原生连接的使用请参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1955.html)。
|
JDBC 原生连接的使用请参见[视频教程](https://www.taosdata.com/blog/2020/11/11/1955.html)。
|
||||||
|
|
||||||
**使用 TDengine 客户端驱动配置文件建立连接 **
|
**使用 TDengine 客户端驱动配置文件建立连接 **
|
||||||
|
|
||||||
当使用 JDBC 原生连接连接 TDengine 集群时,可以使用 TDengine 客户端驱动配置文件,在配置文件中指定集群的 firstEp、secondEp 等参数。如下所示:
|
当使用 JDBC 原生连接连接 TDengine 集群时,可以使用 TDengine 客户端驱动配置文件,在配置文件中指定集群的 firstEp、secondEp 等参数。如下所示:
|
||||||
|
|
||||||
1. 在 Java 应用中不指定 hostname 和 port
|
1. 在 Java 应用中不指定 hostname 和 port
|
||||||
|
|
||||||
```java
|
```java
|
||||||
public Connection getConn() throws Exception{
|
public Connection getConn() throws Exception{
|
||||||
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
Class.forName("com.taosdata.jdbc.TSDBDriver");
|
||||||
String jdbcUrl = "jdbc:TAOS://:/test?user=root&password=taosdata";
|
String jdbcUrl = "jdbc:TAOS://:/test?user=root&password=taosdata";
|
||||||
Properties connProps = new Properties();
|
Properties connProps = new Properties();
|
||||||
|
@ -151,75 +154,82 @@ public Connection getConn() throws Exception{
|
||||||
connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
connProps.setProperty(TSDBDriver.PROPERTY_KEY_TIME_ZONE, "UTC-8");
|
||||||
Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
|
Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
|
||||||
return conn;
|
return conn;
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 在配置文件中指定 firstEp 和 secondEp
|
2. 在配置文件中指定 firstEp 和 secondEp
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
# first fully qualified domain name (FQDN) for TDengine system
|
# first fully qualified domain name (FQDN) for TDengine system
|
||||||
firstEp cluster_node1:6030
|
firstEp cluster_node1:6030
|
||||||
|
|
||||||
# second fully qualified domain name (FQDN) for TDengine system, for cluster only
|
# second fully qualified domain name (FQDN) for TDengine system, for cluster only
|
||||||
secondEp cluster_node2:6030
|
secondEp cluster_node2:6030
|
||||||
|
|
||||||
# default system charset
|
# default system charset
|
||||||
# charset UTF-8
|
# charset UTF-8
|
||||||
|
|
||||||
# system locale
|
# system locale
|
||||||
# locale en_US.UTF-8
|
# locale en_US.UTF-8
|
||||||
```
|
```
|
||||||
|
|
||||||
以上示例,jdbc 会使用客户端的配置文件,建立到 hostname 为 cluster_node1、端口为 6030、数据库名为 test 的连接。当集群中 firstEp 节点失效时,JDBC 会尝试使用 secondEp 连接集群。
|
以上示例,jdbc 会使用客户端的配置文件,建立到 hostname 为 cluster_node1、端口为 6030、数据库名为 test 的连接。当集群中 firstEp 节点失效时,JDBC 会尝试使用 secondEp
|
||||||
|
连接集群。
|
||||||
|
|
||||||
TDengine 中,只要保证 firstEp 和 secondEp 中一个节点有效,就可以正常建立到集群的连接。
|
TDengine 中,只要保证 firstEp 和 secondEp 中一个节点有效,就可以正常建立到集群的连接。
|
||||||
|
|
||||||
> **注意**:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值 C://TDengine/cfg/taos.cfg。
|
> **注意**:这里的配置文件指的是调用 JDBC Connector 的应用程序所在机器上的配置文件,Linux OS 上默认值 /etc/taos/taos.cfg ,Windows OS 上默认值
|
||||||
|
C://TDengine/cfg/taos.cfg。
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="rest" label="REST 连接">
|
<TabItem value="rest" label="REST 连接">
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
|
Class.forName("com.taosdata.jdbc.rs.RestfulDriver");
|
||||||
String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata";
|
String jdbcUrl = "jdbc:TAOS-RS://taosdemo.com:6041/test?user=root&password=taosdata";
|
||||||
Connection conn = DriverManager.getConnection(jdbcUrl);
|
Connection conn = DriverManager.getConnection(jdbcUrl);
|
||||||
```
|
```
|
||||||
|
|
||||||
以上示例,使用了 JDBC REST 连接的 RestfulDriver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为 root,密码(password)为 taosdata。
|
以上示例,使用了 JDBC REST 连接的 RestfulDriver,建立了到 hostname 为 taosdemo.com,端口为 6041,数据库名为 test 的连接。这个 URL 中指定用户名(user)为
|
||||||
|
root,密码(password)为 taosdata。
|
||||||
|
|
||||||
使用 JDBC REST 连接,不需要依赖客户端驱动。与 JDBC 原生连接相比,仅需要:
|
使用 JDBC REST 连接,不需要依赖客户端驱动。与 JDBC 原生连接相比,仅需要:
|
||||||
|
|
||||||
1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”;
|
1. driverClass 指定为“com.taosdata.jdbc.rs.RestfulDriver”;
|
||||||
2. jdbcUrl 以“jdbc:TAOS-RS://”开头;
|
2. jdbcUrl 以“jdbc:TAOS-RS://”开头;
|
||||||
3. 使用 6041 作为连接端口。
|
3. 使用 6041 作为连接端口。
|
||||||
|
|
||||||
url 中的配置参数如下:
|
url 中的配置参数如下:
|
||||||
|
|
||||||
- user:登录 TDengine 用户名,默认值 'root'。
|
- user:登录 TDengine 用户名,默认值 'root'。
|
||||||
- password:用户登录密码,默认值 'taosdata'。
|
- password:用户登录密码,默认值 'taosdata'。
|
||||||
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。JDBC REST 连接支持批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
- batchfetch: true:在执行查询时批量拉取结果集;false:逐行拉取结果集。默认值为:false。逐行拉取结果集使用 HTTP 方式进行数据传输。JDBC REST
|
||||||
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
连接支持批量拉取数据功能。taos-jdbcdriver 与 TDengine 之间通过 WebSocket 连接进行数据传输。相较于 HTTP,WebSocket 可以使 JDBC REST 连接支持大数据量查询,并提升查询性能。
|
||||||
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL 后的任何语句。默认值为:false。
|
- charset: 当开启批量拉取数据时,指定解析字符串数据的字符集。
|
||||||
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
- batchErrorIgnore:true:在执行 Statement 的 executeBatch 时,如果中间有一条 SQL 执行失败,继续执行下面的 SQL 了。false:不再执行失败 SQL
|
||||||
- httpSocketTimeout: socket 超时时间,单位 ms,默认值为 5000。仅在 batchfetch 设置为 false 时生效。
|
后的任何语句。默认值为:false。
|
||||||
- messageWaitTimeout: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 batchfetch 设置为 true 时生效。
|
- httpConnectTimeout: 连接超时时间,单位 ms, 默认值为 5000。
|
||||||
- useSSL: 连接中是否使用 SSL。
|
- httpSocketTimeout: socket 超时时间,单位 ms,默认值为 5000。仅在 batchfetch 设置为 false 时生效。
|
||||||
|
- messageWaitTimeout: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 batchfetch 设置为 true 时生效。
|
||||||
|
- useSSL: 连接中是否使用 SSL。
|
||||||
|
|
||||||
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
**注意**:部分配置项(比如:locale、timezone)在 REST 连接中不生效。
|
||||||
|
|
||||||
:::note
|
:::note
|
||||||
|
|
||||||
- 与原生连接方式不同,REST 接口是无状态的。在使用 JDBC REST 连接时,需要在 SQL 中指定表、超级表的数据库名称。例如:
|
- 与原生连接方式不同,REST 接口是无状态的。在使用 JDBC REST 连接时,需要在 SQL 中指定表、超级表的数据库名称。例如:
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFrancisco') VALUES(now, 24.6);
|
INSERT INTO test.t1 USING test.weather (ts, temperature) TAGS('California.SanFrancisco') VALUES(now, 24.6);
|
||||||
```
|
```
|
||||||
|
|
||||||
- 如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 restful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为 jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperature) tags('California.SanFrancisco') values(now, 24.6);
|
- 如果在 url 中指定了 dbname,那么,JDBC REST 连接会默认使用/rest/sql/dbname 作为 restful 请求的 url,在 SQL 中不需要指定 dbname。例如:url 为
|
||||||
|
jdbc:TAOS-RS://127.0.0.1:6041/test,那么,可以执行 sql:insert into t1 using weather(ts, temperature)
|
||||||
|
tags('California.SanFrancisco') values(now, 24.6);
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
</TabItem>
|
</TabItem>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
### 指定 URL 和 Properties 获取连接
|
### 指定 URL 和 Properties 获取连接
|
||||||
|
@ -271,7 +281,7 @@ properties 中的配置参数如下:
|
||||||
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket 超时时间,单位 ms,默认值为 5000。仅在 REST 连接且 batchfetch 设置为 false 时生效。
|
- TSDBDriver.HTTP_SOCKET_TIMEOUT: socket 超时时间,单位 ms,默认值为 5000。仅在 REST 连接且 batchfetch 设置为 false 时生效。
|
||||||
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 REST 连接且 batchfetch 设置为 true 时生效。
|
- TSDBDriver.PROPERTY_KEY_MESSAGE_WAIT_TIMEOUT: 消息超时时间, 单位 ms, 默认值为 3000。 仅在 REST 连接且 batchfetch 设置为 true 时生效。
|
||||||
- TSDBDriver.PROPERTY_KEY_USE_SSL: 连接中是否使用 SSL。仅在 REST 连接时生效。
|
- TSDBDriver.PROPERTY_KEY_USE_SSL: 连接中是否使用 SSL。仅在 REST 连接时生效。
|
||||||
此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
此外对 JDBC 原生连接,通过指定 URL 和 Properties 还可以指定其他参数,比如日志级别、SQL 长度等。更多详细配置请参考[客户端配置](/reference/config/#仅客户端适用)。
|
||||||
|
|
||||||
### 配置参数的优先级
|
### 配置参数的优先级
|
||||||
|
|
||||||
|
@ -826,7 +836,7 @@ public abstract class ConsumerLoop {
|
||||||
//query or insert
|
//query or insert
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
connection.close(); // put back to conneciton pool
|
connection.close(); // put back to connection pool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -858,7 +868,7 @@ public static void main(String[] args) throws Exception {
|
||||||
//query or insert
|
//query or insert
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
connection.close(); // put back to conneciton pool
|
connection.close(); // put back to connection pool
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -880,7 +890,9 @@ public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
| taos-jdbcdriver 版本 | 主要变化 |
|
| taos-jdbcdriver 版本 | 主要变化 |
|
||||||
| :------------------: | :----------------------------: |
|
| :------------------: | :----------------------------: |
|
||||||
|
| 3.0.1 - 3.0.2 | 修复一些情况下结果集数据解析错误的问题。3.0.1 在 JDK 11 环境编译,JDK 8 环境下建议使用 3.0.2 版本 |
|
||||||
| 3.0.0 | 支持 TDengine 3.0 |
|
| 3.0.0 | 支持 TDengine 3.0 |
|
||||||
|
| 2.0.41 | 修正 REST 连接中用户名和密码转码方式 |
|
||||||
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 |
|
| 2.0.39 - 2.0.40 | 增加 REST 连接/请求 超时设置 |
|
||||||
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
| 2.0.38 | JDBC REST 连接增加批量拉取功能 |
|
||||||
| 2.0.37 | 增加对 json tag 支持 |
|
| 2.0.37 | 增加对 json tag 支持 |
|
||||||
|
@ -890,27 +902,33 @@ public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
1. 使用 Statement 的 `addBatch()` 和 `executeBatch()` 来执行“批量写入/更新”,为什么没有带来性能上的提升?
|
1. 使用 Statement 的 `addBatch()` 和 `executeBatch()` 来执行“批量写入/更新”,为什么没有带来性能上的提升?
|
||||||
|
|
||||||
**原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。
|
**原因**:TDengine 的 JDBC 实现中,通过 `addBatch` 方法提交的 SQL 语句,会按照添加的顺序,依次执行,这种方式没有减少与服务端的交互次数,不会带来性能上的提升。
|
||||||
|
|
||||||
**解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式
|
**解决方法**:1. 在一条 insert 语句中拼接多个 values 值;2. 使用多线程的方式并发插入;3. 使用参数绑定的写入方式
|
||||||
|
|
||||||
2. java.lang.UnsatisfiedLinkError: no taos in java.library.path
|
2. java.lang.UnsatisfiedLinkError: no taos in java.library.path
|
||||||
|
|
||||||
**原因**:程序没有找到依赖的本地函数库 taos。
|
**原因**:程序没有找到依赖的本地函数库 taos。
|
||||||
|
|
||||||
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib`。
|
**解决方法**:Windows 下可以将 C:\TDengine\driver\taos.dll 拷贝到 C:\Windows\System32\ 目录下,Linux 下将建立如下软链 `ln -s /usr/local/taos/driver/libtaos.so.x.x.x.x /usr/lib/libtaos.so` 即可,macOS 下需要建立软链 `ln -s /usr/local/lib/libtaos.dylib`。
|
||||||
|
|
||||||
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
|
3. java.lang.UnsatisfiedLinkError: taos.dll Can't load AMD 64 bit on a IA 32-bit platform
|
||||||
|
|
||||||
**原因**:目前 TDengine 只支持 64 位 JDK。
|
**原因**:目前 TDengine 只支持 64 位 JDK。
|
||||||
|
|
||||||
**解决方法**:重新安装 64 位 JDK。
|
**解决方法**:重新安装 64 位 JDK。
|
||||||
|
|
||||||
4. java.lang.NoSuchMethodError: setByteArray
|
4. java.lang.NoSuchMethodError: setByteArray
|
||||||
|
|
||||||
**原因**:taos-jdbcdriver 3.* 版本仅支持 TDengine 3.0 及以上版本。
|
**原因**:taos-jdbcdriver 3.* 版本仅支持 TDengine 3.0 及以上版本。
|
||||||
|
|
||||||
**解决方法**: 使用 taos-jdbcdriver 2.* 版本连接 TDengine 2.* 版本。
|
**解决方法**: 使用 taos-jdbcdriver 2.* 版本连接 TDengine 2.* 版本。
|
||||||
|
|
||||||
|
5. java.lang.NoSuchMethodError: java.nio.ByteBuffer.position(I)Ljava/nio/ByteBuffer; ... taos-jdbcdriver-3.0.1.jar
|
||||||
|
|
||||||
|
**原因**:taos-jdbcdriver 3.0.1 版本需要在 JDK 11+ 环境使用。
|
||||||
|
|
||||||
|
**解决方法**: 更换 taos-jdbcdriver 3.0.2 版本。
|
||||||
|
|
||||||
其它问题请参考 [FAQ](../../../train-faq/faq)
|
其它问题请参考 [FAQ](../../../train-faq/faq)
|
||||||
|
|
||||||
|
|
|
@ -164,14 +164,6 @@ typedef enum EStreamType {
|
||||||
STREAM_FILL_OVER,
|
STREAM_FILL_OVER,
|
||||||
} EStreamType;
|
} EStreamType;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
SArray* pGroupList;
|
|
||||||
SArray* pTableList;
|
|
||||||
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
|
||||||
bool needSortTableByGroupId;
|
|
||||||
uint64_t suid;
|
|
||||||
} STableListInfo;
|
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
typedef struct SColumnDataAgg {
|
typedef struct SColumnDataAgg {
|
||||||
int16_t colId;
|
int16_t colId;
|
||||||
|
|
|
@ -269,6 +269,7 @@ enum {
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL) // no longer used
|
TD_DEF_MSG_TYPE(TDMT_SYNC_SET_VNODE_STANDBY, "set-vnode-standby", NULL, NULL) // no longer used
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT, "sync-heartbeat", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_HEARTBEAT_REPLY, "sync-heartbeat-reply", NULL, NULL)
|
||||||
|
TD_DEF_MSG_TYPE(TDMT_SYNC_LOCAL_CMD, "sync-local-cmd", NULL, NULL)
|
||||||
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
TD_DEF_MSG_TYPE(TDMT_SYNC_MAX_MSG, "sync-max", NULL, NULL)
|
||||||
|
|
||||||
#if defined(TD_MSG_NUMBER_)
|
#if defined(TD_MSG_NUMBER_)
|
||||||
|
|
|
@ -678,24 +678,61 @@ void syncReconfigFinishPrint2(char* s, const SyncReconfigFinish* pMsg);
|
||||||
void syncReconfigFinishLog(const SyncReconfigFinish* pMsg);
|
void syncReconfigFinishLog(const SyncReconfigFinish* pMsg);
|
||||||
void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg);
|
void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg);
|
||||||
|
|
||||||
// on message ----------------------
|
// ---------------------------------------------
|
||||||
int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg);
|
typedef enum {
|
||||||
int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
SYNC_LOCAL_CMD_STEP_DOWN = 100,
|
||||||
int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg);
|
} ESyncLocalCmd;
|
||||||
|
|
||||||
|
typedef struct SyncLocalCmd {
|
||||||
|
uint32_t bytes;
|
||||||
|
int32_t vgId;
|
||||||
|
uint32_t msgType;
|
||||||
|
SRaftId srcId;
|
||||||
|
SRaftId destId;
|
||||||
|
|
||||||
|
int32_t cmd;
|
||||||
|
SyncTerm sdNewTerm; // step down new term
|
||||||
|
|
||||||
|
} SyncLocalCmd;
|
||||||
|
|
||||||
|
SyncLocalCmd* syncLocalCmdBuild(int32_t vgId);
|
||||||
|
void syncLocalCmdDestroy(SyncLocalCmd* pMsg);
|
||||||
|
void syncLocalCmdSerialize(const SyncLocalCmd* pMsg, char* buf, uint32_t bufLen);
|
||||||
|
void syncLocalCmdDeserialize(const char* buf, uint32_t len, SyncLocalCmd* pMsg);
|
||||||
|
char* syncLocalCmdSerialize2(const SyncLocalCmd* pMsg, uint32_t* len);
|
||||||
|
SyncLocalCmd* syncLocalCmdDeserialize2(const char* buf, uint32_t len);
|
||||||
|
void syncLocalCmd2RpcMsg(const SyncLocalCmd* pMsg, SRpcMsg* pRpcMsg);
|
||||||
|
void syncLocalCmdFromRpcMsg(const SRpcMsg* pRpcMsg, SyncLocalCmd* pMsg);
|
||||||
|
SyncLocalCmd* syncLocalCmdFromRpcMsg2(const SRpcMsg* pRpcMsg);
|
||||||
|
cJSON* syncLocalCmd2Json(const SyncLocalCmd* pMsg);
|
||||||
|
char* syncLocalCmd2Str(const SyncLocalCmd* pMsg);
|
||||||
|
|
||||||
|
// for debug ----------------------
|
||||||
|
void syncLocalCmdPrint(const SyncLocalCmd* pMsg);
|
||||||
|
void syncLocalCmdPrint2(char* s, const SyncLocalCmd* pMsg);
|
||||||
|
void syncLocalCmdLog(const SyncLocalCmd* pMsg);
|
||||||
|
void syncLocalCmdLog2(char* s, const SyncLocalCmd* pMsg);
|
||||||
|
|
||||||
|
// on message ----------------------
|
||||||
|
int32_t syncNodeOnPing(SSyncNode* ths, SyncPing* pMsg);
|
||||||
|
int32_t syncNodeOnPingReply(SSyncNode* ths, SyncPingReply* pMsg);
|
||||||
|
|
||||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
|
||||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
|
||||||
int32_t syncNodeOnClientRequest(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
|
||||||
int32_t syncNodeOnRequestVote(SSyncNode* ths, SyncRequestVote* pMsg);
|
int32_t syncNodeOnRequestVote(SSyncNode* ths, SyncRequestVote* pMsg);
|
||||||
int32_t syncNodeOnRequestVoteReply(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
int32_t syncNodeOnRequestVoteReply(SSyncNode* ths, SyncRequestVoteReply* pMsg);
|
||||||
|
|
||||||
int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg);
|
int32_t syncNodeOnAppendEntries(SSyncNode* ths, SyncAppendEntries* pMsg);
|
||||||
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
int32_t syncNodeOnAppendEntriesReply(SSyncNode* ths, SyncAppendEntriesReply* pMsg);
|
||||||
|
|
||||||
int32_t syncNodeOnSnapshot(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
int32_t syncNodeOnSnapshot(SSyncNode* ths, SyncSnapshotSend* pMsg);
|
||||||
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
int32_t syncNodeOnSnapshotReply(SSyncNode* ths, SyncSnapshotRsp* pMsg);
|
||||||
|
|
||||||
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
int32_t syncNodeOnHeartbeat(SSyncNode* ths, SyncHeartbeat* pMsg);
|
||||||
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
int32_t syncNodeOnHeartbeatReply(SSyncNode* ths, SyncHeartbeatReply* pMsg);
|
||||||
|
|
||||||
|
int32_t syncNodeOnClientRequest(SSyncNode* ths, SyncClientRequest* pMsg, SyncIndex* pRetIndex);
|
||||||
|
int32_t syncNodeOnTimer(SSyncNode* ths, SyncTimeout* pMsg);
|
||||||
|
int32_t syncNodeOnLocalCmd(SSyncNode* ths, SyncLocalCmd* pMsg);
|
||||||
|
|
||||||
// -----------------------------------------
|
// -----------------------------------------
|
||||||
typedef int32_t (*FpOnPingCb)(SSyncNode* ths, SyncPing* pMsg);
|
typedef int32_t (*FpOnPingCb)(SSyncNode* ths, SyncPing* pMsg);
|
||||||
typedef int32_t (*FpOnPingReplyCb)(SSyncNode* ths, SyncPingReply* pMsg);
|
typedef int32_t (*FpOnPingReplyCb)(SSyncNode* ths, SyncPingReply* pMsg);
|
||||||
|
|
|
@ -360,7 +360,7 @@ typedef enum ELogicConditionType {
|
||||||
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF
|
||||||
#define TSDB_MIN_STT_TRIGGER 1
|
#define TSDB_MIN_STT_TRIGGER 1
|
||||||
#define TSDB_MAX_STT_TRIGGER 16
|
#define TSDB_MAX_STT_TRIGGER 16
|
||||||
#define TSDB_DEFAULT_SST_TRIGGER 8
|
#define TSDB_DEFAULT_SST_TRIGGER 1
|
||||||
#define TSDB_MIN_HASH_PREFIX 0
|
#define TSDB_MIN_HASH_PREFIX 0
|
||||||
#define TSDB_MAX_HASH_PREFIX 128
|
#define TSDB_MAX_HASH_PREFIX 128
|
||||||
#define TSDB_DEFAULT_HASH_PREFIX 0
|
#define TSDB_DEFAULT_HASH_PREFIX 0
|
||||||
|
|
|
@ -74,6 +74,12 @@ void tdSCellValPrint(SCellVal *pVal, int8_t colType) {
|
||||||
printf("NONE ");
|
printf("NONE ");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if(!pVal->val) {
|
||||||
|
ASSERT(0);
|
||||||
|
printf("BadVal ");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (colType) {
|
switch (colType) {
|
||||||
case TSDB_DATA_TYPE_BOOL:
|
case TSDB_DATA_TYPE_BOOL:
|
||||||
printf("%s ", (*(int8_t *)pVal->val) == 0 ? "false" : "true");
|
printf("%s ", (*(int8_t *)pVal->val) == 0 ? "false" : "true");
|
||||||
|
@ -678,6 +684,10 @@ int32_t tdAppendColValToRow(SRowBuilder *pBuilder, col_id_t colId, int8_t colTyp
|
||||||
}
|
}
|
||||||
// TS KEY is stored in STSRow.ts and not included in STSRow.data field.
|
// TS KEY is stored in STSRow.ts and not included in STSRow.data field.
|
||||||
if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
if (colId == PRIMARYKEY_TIMESTAMP_COL_ID) {
|
||||||
|
if (!val) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
return terrno;
|
||||||
|
}
|
||||||
TD_ROW_KEY(pRow) = *(TSKEY *)val;
|
TD_ROW_KEY(pRow) = *(TSKEY *)val;
|
||||||
// The primary TS key is Norm all the time, thus its valType is not stored in bitmap.
|
// The primary TS key is Norm all the time, thus its valType is not stored in bitmap.
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
|
|
@ -538,12 +538,12 @@ int32_t mndProcessSyncMsg(SRpcMsg *pMsg) {
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
||||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnPing(pSyncNode, pSyncMsg);
|
||||||
syncPingDestroy(pSyncMsg);
|
syncPingDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
||||||
code = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnPingReply(pSyncNode, pSyncMsg);
|
||||||
syncPingReplyDestroy(pSyncMsg);
|
syncPingReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||||
|
|
|
@ -152,26 +152,25 @@ typedef struct STsdbReader STsdbReader;
|
||||||
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
|
#define CACHESCAN_RETRIEVE_LAST_ROW 0x4
|
||||||
#define CACHESCAN_RETRIEVE_LAST 0x8
|
#define CACHESCAN_RETRIEVE_LAST 0x8
|
||||||
|
|
||||||
int32_t tsdbSetTableId(STsdbReader *pReader, int64_t uid);
|
int32_t tsdbSetTableList(STsdbReader *pReader, const void *pTableList, int32_t num);
|
||||||
int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, SArray *pTableList, STsdbReader **ppReader,
|
int32_t tsdbReaderOpen(SVnode *pVnode, SQueryTableDataCond *pCond, void *pTableList, int32_t numOfTables,
|
||||||
const char *idstr);
|
STsdbReader **ppReader, const char *idstr);
|
||||||
|
|
||||||
void tsdbReaderClose(STsdbReader *pReader);
|
void tsdbReaderClose(STsdbReader *pReader);
|
||||||
bool tsdbNextDataBlock(STsdbReader *pReader);
|
bool tsdbNextDataBlock(STsdbReader *pReader);
|
||||||
bool tsdbTableNextDataBlock(STsdbReader *pReader, int64_t uid);
|
bool tsdbTableNextDataBlock(STsdbReader *pReader, uint64_t uid);
|
||||||
void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo);
|
void tsdbRetrieveDataBlockInfo(STsdbReader *pReader, SDataBlockInfo *pDataBlockInfo);
|
||||||
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
int32_t tsdbRetrieveDatablockSMA(STsdbReader *pReader, SColumnDataAgg ***pBlockStatis, bool *allHave);
|
||||||
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
SArray *tsdbRetrieveDataBlock(STsdbReader *pTsdbReadHandle, SArray *pColumnIdList);
|
||||||
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
int32_t tsdbReaderReset(STsdbReader *pReader, SQueryTableDataCond *pCond);
|
||||||
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
int32_t tsdbGetFileBlocksDistInfo(STsdbReader *pReader, STableBlockDistInfo *pTableBlockInfo);
|
||||||
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
|
int64_t tsdbGetNumOfRowsInMemTable(STsdbReader *pHandle);
|
||||||
bool tsdbIsAscendingOrder(STsdbReader *pReader);
|
|
||||||
void *tsdbGetIdx(SMeta *pMeta);
|
void *tsdbGetIdx(SMeta *pMeta);
|
||||||
void *tsdbGetIvtIdx(SMeta *pMeta);
|
void *tsdbGetIvtIdx(SMeta *pMeta);
|
||||||
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
uint64_t getReaderMaxVersion(STsdbReader *pReader);
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, SArray *pTableIdList, int32_t numOfCols, uint64_t suid,
|
int32_t tsdbCacherowsReaderOpen(void *pVnode, int32_t type, void *pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
void **pReader);
|
uint64_t suid, void **pReader);
|
||||||
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
int32_t tsdbRetrieveCacheRows(void *pReader, SSDataBlock *pResBlock, const int32_t *slotIds, SArray *pTableUids);
|
||||||
void *tsdbCacherowsReaderClose(void *pReader);
|
void *tsdbCacherowsReaderClose(void *pReader);
|
||||||
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
int32_t tsdbGetTableSchema(SVnode *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid);
|
||||||
|
|
|
@ -716,7 +716,9 @@ typedef struct SCacheRowsReader {
|
||||||
int32_t numOfCols;
|
int32_t numOfCols;
|
||||||
int32_t type;
|
int32_t type;
|
||||||
int32_t tableIndex; // currently returned result tables
|
int32_t tableIndex; // currently returned result tables
|
||||||
SArray *pTableList; // table id list
|
|
||||||
|
STableKeyInfo *pTableList; // table id list
|
||||||
|
int32_t numOfTables;
|
||||||
SSttBlockLoadInfo *pLoadInfo;
|
SSttBlockLoadInfo *pLoadInfo;
|
||||||
STsdbReadSnap *pReadSnap;
|
STsdbReadSnap *pReadSnap;
|
||||||
SDataFReader *pDataFReader;
|
SDataFReader *pDataFReader;
|
||||||
|
|
|
@ -162,10 +162,7 @@ int tsdbInsertData(STsdb* pTsdb, int64_t version, SSubmitReq* pMsg, SSub
|
||||||
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
int32_t tsdbInsertTableData(STsdb* pTsdb, int64_t version, SSubmitMsgIter* pMsgIter, SSubmitBlk* pBlock,
|
||||||
SSubmitBlkRsp* pRsp);
|
SSubmitBlkRsp* pRsp);
|
||||||
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
int32_t tsdbDeleteTableData(STsdb* pTsdb, int64_t version, tb_uid_t suid, tb_uid_t uid, TSKEY sKey, TSKEY eKey);
|
||||||
STsdbReader tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableListInfo* tableList, uint64_t qId,
|
|
||||||
void* pMemRef);
|
|
||||||
int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
int32_t tsdbSetKeepCfg(STsdb* pTsdb, STsdbCfg* pCfg);
|
||||||
int32_t tsdbGetStbIdList(SMeta* pMeta, int64_t suid, SArray* list);
|
|
||||||
|
|
||||||
// tq
|
// tq
|
||||||
int tqInit();
|
int tqInit();
|
||||||
|
|
|
@ -701,25 +701,28 @@ static int32_t tdRSmaExecAndSubmitResult(SSma *pSma, qTaskInfo_t taskInfo, SRSma
|
||||||
#endif
|
#endif
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pResList); ++i) {
|
||||||
SSDataBlock *output = taosArrayGetP(pResList, i);
|
SSDataBlock *output = taosArrayGetP(pResList, i);
|
||||||
|
smaDebug("result block, uid:%"PRIu64", groupid:%"PRIu64", rows:%d", output->info.uid, output->info.groupId,
|
||||||
|
output->info.rows);
|
||||||
|
|
||||||
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
STsdb *sinkTsdb = (pItem->level == TSDB_RETENTION_L1 ? pSma->pRSmaTsdb[0] : pSma->pRSmaTsdb[1]);
|
||||||
SSubmitReq *pReq = NULL;
|
SSubmitReq *pReq = NULL;
|
||||||
|
|
||||||
// TODO: the schema update should be handled later(TD-17965)
|
// TODO: the schema update should be handled later(TD-17965)
|
||||||
if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) {
|
if (buildSubmitReqFromDataBlock(&pReq, output, pTSchema, SMA_VID(pSma), suid) < 0) {
|
||||||
smaError("vgId:%d, build submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s", SMA_VID(pSma),
|
smaError("vgId:%d, build submit req for rsma table suid:%" PRIu64 ", uid:%"PRIu64", level %" PRIi8 " failed since %s", SMA_VID(pSma),
|
||||||
suid, pItem->level, terrstr());
|
suid, output->info.groupId, pItem->level, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
|
if (pReq && tdProcessSubmitReq(sinkTsdb, output->info.version, pReq) < 0) {
|
||||||
taosMemoryFreeClear(pReq);
|
taosMemoryFreeClear(pReq);
|
||||||
smaError("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " failed since %s",
|
smaError("vgId:%d, process submit req for rsma suid:%"PRIu64", uid:%" PRIu64 " level %" PRIi8 " failed since %s",
|
||||||
SMA_VID(pSma), suid, pItem->level, terrstr());
|
SMA_VID(pSma), suid, output->info.groupId, pItem->level, terrstr());
|
||||||
goto _err;
|
goto _err;
|
||||||
}
|
}
|
||||||
|
|
||||||
smaDebug("vgId:%d, process submit req for rsma table %" PRIi64 " level %" PRIi8 " ver %" PRIi64 " len %" PRIu32,
|
smaDebug("vgId:%d, process submit req for rsma suid:%" PRIu64 ",uid:%"PRIu64", level %" PRIi8 " ver %" PRIi64 " len %" PRIu32,
|
||||||
SMA_VID(pSma), suid, pItem->level, output->info.version, htonl(pReq->header.contLen));
|
SMA_VID(pSma), suid, output->info.groupId, pItem->level, output->info.version, htonl(pReq->header.contLen));
|
||||||
|
|
||||||
taosMemoryFreeClear(pReq);
|
taosMemoryFreeClear(pReq);
|
||||||
}
|
}
|
||||||
|
|
|
@ -97,10 +97,9 @@ static void saveOneRow(SArray* pRow, SSDataBlock* pBlock, SCacheRowsReader* pRea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList, int32_t numOfCols, uint64_t suid,
|
int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, void* pTableIdList, int32_t numOfTables, int32_t numOfCols,
|
||||||
void** pReader) {
|
uint64_t suid, void** pReader) {
|
||||||
*pReader = NULL;
|
*pReader = NULL;
|
||||||
|
|
||||||
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
SCacheRowsReader* p = taosMemoryCalloc(1, sizeof(SCacheRowsReader));
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -111,14 +110,15 @@ int32_t tsdbCacherowsReaderOpen(void* pVnode, int32_t type, SArray* pTableIdList
|
||||||
p->numOfCols = numOfCols;
|
p->numOfCols = numOfCols;
|
||||||
p->suid = suid;
|
p->suid = suid;
|
||||||
|
|
||||||
if (taosArrayGetSize(pTableIdList) == 0) {
|
if (numOfTables == 0) {
|
||||||
*pReader = p;
|
*pReader = p;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pTableIdList, 0);
|
STableKeyInfo* pKeyInfo = &((STableKeyInfo*)pTableIdList)[0];
|
||||||
p->pSchema = metaGetTbTSchema(p->pVnode->pMeta, pKeyInfo->uid, -1, 1);
|
p->pSchema = metaGetTbTSchema(p->pVnode->pMeta, pKeyInfo->uid, -1, 1);
|
||||||
p->pTableList = pTableIdList;
|
p->pTableList = pTableIdList;
|
||||||
|
p->numOfTables = numOfTables;
|
||||||
|
|
||||||
p->transferBuf = taosMemoryCalloc(p->pSchema->numOfCols, POINTER_BYTES);
|
p->transferBuf = taosMemoryCalloc(p->pSchema->numOfCols, POINTER_BYTES);
|
||||||
if (p->transferBuf == NULL) {
|
if (p->transferBuf == NULL) {
|
||||||
|
@ -205,7 +205,6 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache;
|
SLRUCache* lruCache = pr->pVnode->pTsdb->lruCache;
|
||||||
LRUHandle* h = NULL;
|
LRUHandle* h = NULL;
|
||||||
SArray* pRow = NULL;
|
SArray* pRow = NULL;
|
||||||
size_t numOfTables = taosArrayGetSize(pr->pTableList);
|
|
||||||
bool hasRes = false;
|
bool hasRes = false;
|
||||||
SArray* pLastCols = NULL;
|
SArray* pLastCols = NULL;
|
||||||
|
|
||||||
|
@ -243,8 +242,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
|
|
||||||
// retrieve the only one last row of all tables in the uid list.
|
// retrieve the only one last row of all tables in the uid list.
|
||||||
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_SINGLE)) {
|
if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_SINGLE)) {
|
||||||
for (int32_t i = 0; i < numOfTables; ++i) {
|
for (int32_t i = 0; i < pr->numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pr->pTableList, i);
|
STableKeyInfo* pKeyInfo = &pr->pTableList[i];
|
||||||
|
|
||||||
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -308,8 +307,8 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
} else if (HASTYPE(pr->type, CACHESCAN_RETRIEVE_TYPE_ALL)) {
|
||||||
for (int32_t i = pr->tableIndex; i < numOfTables; ++i) {
|
for (int32_t i = pr->tableIndex; i < pr->numOfTables; ++i) {
|
||||||
STableKeyInfo* pKeyInfo = (STableKeyInfo*)taosArrayGet(pr->pTableList, i);
|
STableKeyInfo* pKeyInfo = &pr->pTableList[i];
|
||||||
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
code = doExtractCacheRow(pr, lruCache, pKeyInfo->uid, &pRow, &h);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
|
@ -334,7 +333,7 @@ int32_t tsdbRetrieveCacheRows(void* pReader, SSDataBlock* pResBlock, const int32
|
||||||
code = TSDB_CODE_INVALID_PARA;
|
code = TSDB_CODE_INVALID_PARA;
|
||||||
}
|
}
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
tsdbDataFReaderClose(&pr->pDataFReaderLast);
|
tsdbDataFReaderClose(&pr->pDataFReaderLast);
|
||||||
tsdbDataFReaderClose(&pr->pDataFReader);
|
tsdbDataFReaderClose(&pr->pDataFReader);
|
||||||
|
|
||||||
|
|
|
@ -270,10 +270,7 @@ static void resetDataBlockScanInfo(SHashObj* pTableMap, int64_t ts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
static void clearBlockScanInfo(STableBlockScanInfo* p) {
|
||||||
STableBlockScanInfo* p = NULL;
|
|
||||||
|
|
||||||
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
|
||||||
p->iterInit = false;
|
p->iterInit = false;
|
||||||
p->iiter.hasVal = false;
|
p->iiter.hasVal = false;
|
||||||
|
|
||||||
|
@ -288,6 +285,12 @@ static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
||||||
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
p->delSkyline = taosArrayDestroy(p->delSkyline);
|
||||||
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
p->pBlockList = taosArrayDestroy(p->pBlockList);
|
||||||
tMapDataClear(&p->mapData);
|
tMapDataClear(&p->mapData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void destroyBlockScanInfo(SHashObj* pTableMap) {
|
||||||
|
STableBlockScanInfo* p = NULL;
|
||||||
|
while ((p = taosHashIterate(pTableMap, p)) != NULL) {
|
||||||
|
clearBlockScanInfo(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosHashCleanup(pTableMap);
|
taosHashCleanup(pTableMap);
|
||||||
|
@ -3452,13 +3455,23 @@ int32_t buildDataBlockFromBufImpl(STableBlockScanInfo* pBlockScanInfo, int64_t e
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo refactor, use arraylist instead
|
// TODO refactor: with createDataBlockScanInfo
|
||||||
int32_t tsdbSetTableId(STsdbReader* pReader, int64_t uid) {
|
int32_t tsdbSetTableList(STsdbReader* pReader, const void* pTableList, int32_t num) {
|
||||||
ASSERT(pReader != NULL);
|
ASSERT(pReader != NULL);
|
||||||
|
|
||||||
|
STableBlockScanInfo* p = NULL;
|
||||||
|
while ((p = taosHashIterate(pReader->status.pTableMap, p)) != NULL) {
|
||||||
|
clearBlockScanInfo(p);
|
||||||
|
}
|
||||||
|
|
||||||
taosHashClear(pReader->status.pTableMap);
|
taosHashClear(pReader->status.pTableMap);
|
||||||
|
|
||||||
STableBlockScanInfo info = {.lastKey = 0, .uid = uid};
|
STableKeyInfo* pList = (STableKeyInfo*) pTableList;
|
||||||
|
for(int32_t i = 0; i < num; ++i) {
|
||||||
|
STableBlockScanInfo info = {.lastKey = 0, .uid = pList[i].uid};
|
||||||
taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
taosHashPut(pReader->status.pTableMap, &info.uid, sizeof(uint64_t), &info, sizeof(info));
|
||||||
|
}
|
||||||
|
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3483,6 +3496,7 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) {
|
||||||
|
|
||||||
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
initFilesetIterator(&pReader->status.fileIter, pReader->pReadSnap->fs.aDFileSet, pReader);
|
||||||
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
resetDataBlockIterator(&pReader->status.blockIter, pReader->order);
|
||||||
|
// resetDataBlockScanInfo(pReader->status.pTableMap, pReader->window.skey);
|
||||||
|
|
||||||
// no data in files, let's try buffer in memory
|
// no data in files, let's try buffer in memory
|
||||||
if (pReader->status.fileIter.numOfFiles == 0) {
|
if (pReader->status.fileIter.numOfFiles == 0) {
|
||||||
|
@ -3494,8 +3508,8 @@ static int32_t doOpenReaderImpl(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================================== EXPOSED APIs ======================================
|
// ====================================== EXPOSED APIs ======================================
|
||||||
int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTableList, STsdbReader** ppReader,
|
int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
|
||||||
const char* idstr) {
|
STsdbReader** ppReader, const char* idstr) {
|
||||||
STimeWindow window = pCond->twindows;
|
STimeWindow window = pCond->twindows;
|
||||||
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
if (pCond->type == TIMEWINDOW_RANGE_EXTERNAL) {
|
||||||
pCond->twindows.skey += 1;
|
pCond->twindows.skey += 1;
|
||||||
|
@ -3554,8 +3568,8 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
if (pReader->pSchema == NULL) {
|
if (pReader->pSchema == NULL) {
|
||||||
tsdbError("failed to get table schema, suid:%" PRIu64 ", ver:-1, %s", pReader->suid, pReader->idStr);
|
tsdbError("failed to get table schema, suid:%" PRIu64 ", ver:-1, %s", pReader->suid, pReader->idStr);
|
||||||
}
|
}
|
||||||
} else if (taosArrayGetSize(pTableList) > 0) {
|
} else if (numOfTables > 0) {
|
||||||
STableKeyInfo* pKey = taosArrayGet(pTableList, 0);
|
STableKeyInfo* pKey = pTableList;
|
||||||
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, -1, 1);
|
pReader->pSchema = metaGetTbTSchema(pReader->pTsdb->pVnode->pMeta, pKey->uid, -1, 1);
|
||||||
if (pReader->pSchema == NULL) {
|
if (pReader->pSchema == NULL) {
|
||||||
tsdbError("failed to get table schema, uid:%" PRIu64 ", ver:-1, %s", pKey->uid, pReader->idStr);
|
tsdbError("failed to get table schema, uid:%" PRIu64 ", ver:-1, %s", pKey->uid, pReader->idStr);
|
||||||
|
@ -3564,8 +3578,7 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
|
|
||||||
STsdbReader* p = pReader->innerReader[0] != NULL ? pReader->innerReader[0] : pReader;
|
STsdbReader* p = pReader->innerReader[0] != NULL ? pReader->innerReader[0] : pReader;
|
||||||
|
|
||||||
int32_t numOfTables = taosArrayGetSize(pTableList);
|
pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList, numOfTables);
|
||||||
pReader->status.pTableMap = createDataBlockScanInfo(p, pTableList->pData, numOfTables);
|
|
||||||
if (pReader->status.pTableMap == NULL) {
|
if (pReader->status.pTableMap == NULL) {
|
||||||
tsdbReaderClose(pReader);
|
tsdbReaderClose(pReader);
|
||||||
*ppReader = NULL;
|
*ppReader = NULL;
|
||||||
|
@ -3606,23 +3619,13 @@ int32_t tsdbReaderOpen(SVnode* pVnode, SQueryTableDataCond* pCond, SArray* pTabl
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
code = doOpenReaderImpl(pNextReader);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = doOpenReaderImpl(pReader);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
|
||||||
return code;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
tsdbDebug("%p total numOfTable:%d in this query %s", pReader, numOfTables, pReader->idStr);
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_err:
|
_err:
|
||||||
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
tsdbError("failed to create data reader, code:%s %s", tstrerror(code), idstr);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -3746,15 +3749,21 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
|
|
||||||
if (pReader->innerReader[0] != NULL && pReader->step == 0) {
|
if (pReader->innerReader[0] != NULL && pReader->step == 0) {
|
||||||
bool ret = doTsdbNextDataBlock(pReader->innerReader[0]);
|
bool ret = doTsdbNextDataBlock(pReader->innerReader[0]);
|
||||||
resetDataBlockScanInfo(pReader->innerReader[0]->status.pTableMap, pReader->innerReader[0]->window.ekey);
|
|
||||||
pReader->step = EXTERNAL_ROWS_PREV;
|
pReader->step = EXTERNAL_ROWS_PREV;
|
||||||
|
|
||||||
if (ret) {
|
if (ret) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
if (pReader->step == EXTERNAL_ROWS_PREV) {
|
||||||
|
// prepare for the main scan
|
||||||
|
int32_t code = doOpenReaderImpl(pReader);
|
||||||
|
resetDataBlockScanInfo(pReader->status.pTableMap, pReader->innerReader[0]->window.ekey);
|
||||||
|
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
pReader->step = EXTERNAL_ROWS_MAIN;
|
pReader->step = EXTERNAL_ROWS_MAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3764,7 +3773,13 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
if (pReader->innerReader[1] != NULL && pReader->step == EXTERNAL_ROWS_MAIN) {
|
||||||
|
// prepare for the next row scan
|
||||||
|
int32_t code = doOpenReaderImpl(pReader->innerReader[1]);
|
||||||
resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
|
resetDataBlockScanInfo(pReader->innerReader[1]->status.pTableMap, pReader->window.ekey);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]);
|
bool ret1 = doTsdbNextDataBlock(pReader->innerReader[1]);
|
||||||
pReader->step = EXTERNAL_ROWS_NEXT;
|
pReader->step = EXTERNAL_ROWS_NEXT;
|
||||||
if (ret1) {
|
if (ret1) {
|
||||||
|
@ -3775,7 +3790,7 @@ bool tsdbNextDataBlock(STsdbReader* pReader) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tsdbTableNextDataBlock(STsdbReader* pReader, int64_t uid) {
|
bool tsdbTableNextDataBlock(STsdbReader* pReader, uint64_t uid) {
|
||||||
STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid));
|
STableBlockScanInfo* pBlockScanInfo = taosHashGet(pReader->status.pTableMap, &uid, sizeof(uid));
|
||||||
if (pBlockScanInfo == NULL) { // no data block for the table of given uid
|
if (pBlockScanInfo == NULL) { // no data block for the table of given uid
|
||||||
return false;
|
return false;
|
||||||
|
@ -4155,7 +4170,7 @@ int32_t tsdbTakeReadSnap(STsdb* pTsdb, STsdbReadSnap** ppSnap, const char* idStr
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbTrace("vgId:%d, take read snapshot, %s", TD_VID(pTsdb->pVnode), idStr);
|
tsdbTrace("vgId:%d, take read snapshot, %s", TD_VID(pTsdb->pVnode), idStr);
|
||||||
_exit:
|
_exit:
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4174,4 +4189,3 @@ void tsdbUntakeReadSnap(STsdb* pTsdb, STsdbReadSnap* pSnap, const char* idStr) {
|
||||||
}
|
}
|
||||||
tsdbTrace("vgId:%d, untake read snapshot, %s", TD_VID(pTsdb->pVnode), idStr);
|
tsdbTrace("vgId:%d, untake read snapshot, %s", TD_VID(pTsdb->pVnode), idStr);
|
||||||
}
|
}
|
||||||
bool tsdbIsAscendingOrder(STsdbReader* pReader) { return ASCENDING_TRAVERSE(pReader->order); }
|
|
||||||
|
|
|
@ -301,13 +301,13 @@ int32_t vnodeProcessSyncMsg(SVnode *pVnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
} else if (pMsg->msgType == TDMT_SYNC_PING) {
|
||||||
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
SyncPing *pSyncMsg = syncPingFromRpcMsg2(pMsg);
|
||||||
ASSERT(pSyncMsg != NULL);
|
ASSERT(pSyncMsg != NULL);
|
||||||
code = syncNodeOnPingCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnPing(pSyncNode, pSyncMsg);
|
||||||
syncPingDestroy(pSyncMsg);
|
syncPingDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
} else if (pMsg->msgType == TDMT_SYNC_PING_REPLY) {
|
||||||
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pMsg);
|
||||||
ASSERT(pSyncMsg != NULL);
|
ASSERT(pSyncMsg != NULL);
|
||||||
code = syncNodeOnPingReplyCb(pSyncNode, pSyncMsg);
|
code = syncNodeOnPingReply(pSyncNode, pSyncMsg);
|
||||||
syncPingReplyDestroy(pSyncMsg);
|
syncPingReplyDestroy(pSyncMsg);
|
||||||
|
|
||||||
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
} else if (pMsg->msgType == TDMT_SYNC_CLIENT_REQUEST) {
|
||||||
|
|
|
@ -1114,6 +1114,7 @@ int32_t catalogGetCachedTableHashVgroup(SCatalog* pCtg, SRequestConnInfo* pConn,
|
||||||
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, exists));
|
CTG_API_LEAVE(ctgGetTbHashVgroup(pCtg, pConn, pTableName, pVgroup, exists));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp) {
|
int32_t catalogGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, SMetaData* pRsp) {
|
||||||
CTG_API_ENTER();
|
CTG_API_ENTER();
|
||||||
|
|
||||||
|
@ -1176,6 +1177,7 @@ _return:
|
||||||
|
|
||||||
CTG_API_LEAVE(code);
|
CTG_API_LEAVE(code);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp,
|
int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SCatalogReq* pReq, catalogCallback fp,
|
||||||
void* param, int64_t* jobId) {
|
void* param, int64_t* jobId) {
|
||||||
|
|
|
@ -63,6 +63,7 @@ enum {
|
||||||
CTGT_RSP_QNODELIST,
|
CTGT_RSP_QNODELIST,
|
||||||
CTGT_RSP_UDF,
|
CTGT_RSP_UDF,
|
||||||
CTGT_RSP_SVRVER,
|
CTGT_RSP_SVRVER,
|
||||||
|
CTGT_RSP_DNODElIST,
|
||||||
CTGT_RSP_TBMETA_NOT_EXIST,
|
CTGT_RSP_TBMETA_NOT_EXIST,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -702,6 +703,30 @@ void ctgTestRspSvrVer(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRs
|
||||||
pRsp->pCont = pReq;
|
pRsp->pCont = pReq;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctgTestRspDndeList(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
||||||
|
rpcFreeCont(pMsg->pCont);
|
||||||
|
|
||||||
|
SDnodeListRsp dRsp = {0};
|
||||||
|
dRsp.dnodeList = taosArrayInit(1, sizeof(SEpSet));
|
||||||
|
SEpSet epSet = {0};
|
||||||
|
epSet.numOfEps = 1;
|
||||||
|
tstrncpy(epSet.eps[0].fqdn, "localhost", TSDB_FQDN_LEN);
|
||||||
|
epSet.eps[0].port = 6030;
|
||||||
|
|
||||||
|
(void)taosArrayPush(dRsp.dnodeList, &epSet);
|
||||||
|
|
||||||
|
int32_t rspLen = tSerializeSDnodeListRsp(NULL, 0, &dRsp);
|
||||||
|
void *pReq = rpcMallocCont(rspLen);
|
||||||
|
tSerializeSDnodeListRsp(pReq, rspLen, &dRsp);
|
||||||
|
|
||||||
|
pRsp->code = 0;
|
||||||
|
pRsp->contLen = rspLen;
|
||||||
|
pRsp->pCont = pReq;
|
||||||
|
|
||||||
|
tFreeSDnodeListRsp(&dRsp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
|
||||||
switch (pMsg->msgType) {
|
switch (pMsg->msgType) {
|
||||||
|
@ -727,6 +752,9 @@ void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
|
||||||
case TDMT_MND_SERVER_VERSION:
|
case TDMT_MND_SERVER_VERSION:
|
||||||
ctgTestRspSvrVer(shandle, pEpSet, pMsg, pRsp);
|
ctgTestRspSvrVer(shandle, pEpSet, pMsg, pRsp);
|
||||||
break;
|
break;
|
||||||
|
case TDMT_MND_DNODE_LIST:
|
||||||
|
ctgTestRspDndeList(shandle, pEpSet, pMsg, pRsp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -779,6 +807,9 @@ void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp
|
||||||
case CTGT_RSP_SVRVER:
|
case CTGT_RSP_SVRVER:
|
||||||
ctgTestRspSvrVer(shandle, pEpSet, pMsg, pRsp);
|
ctgTestRspSvrVer(shandle, pEpSet, pMsg, pRsp);
|
||||||
break;
|
break;
|
||||||
|
case CTGT_RSP_DNODElIST:
|
||||||
|
ctgTestRspDndeList(shandle, pEpSet, pMsg, pRsp);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ctgTestRspAuto(shandle, pEpSet, pMsg, pRsp);
|
ctgTestRspAuto(shandle, pEpSet, pMsg, pRsp);
|
||||||
break;
|
break;
|
||||||
|
@ -2948,6 +2979,69 @@ TEST(apiTest, catalogGetServerVersion_test) {
|
||||||
catalogDestroy();
|
catalogDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(apiTest, catalogUpdateTableIndex_test) {
|
||||||
|
struct SCatalog *pCtg = NULL;
|
||||||
|
SRequestConnInfo connInfo = {0};
|
||||||
|
SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo;
|
||||||
|
|
||||||
|
ctgTestInitLogFile();
|
||||||
|
|
||||||
|
memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc));
|
||||||
|
ctgTestRspIdx = 0;
|
||||||
|
ctgTestRspFunc[0] = CTGT_RSP_SVRVER;
|
||||||
|
|
||||||
|
ctgTestSetRspByIdx();
|
||||||
|
|
||||||
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
|
int32_t code = catalogInit(NULL);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
STableIndexRsp rsp = {0};
|
||||||
|
strcpy(rsp.dbFName, ctgTestDbname);
|
||||||
|
strcpy(rsp.tbName, ctgTestSTablename);
|
||||||
|
rsp.suid = ctgTestSuid;
|
||||||
|
rsp.version = 1;
|
||||||
|
code = catalogUpdateTableIndex(pCtg, &rsp);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
catalogDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TEST(apiTest, catalogGetDnodeList_test) {
|
||||||
|
struct SCatalog *pCtg = NULL;
|
||||||
|
SRequestConnInfo connInfo = {0};
|
||||||
|
SRequestConnInfo *mockPointer = (SRequestConnInfo *)&connInfo;
|
||||||
|
|
||||||
|
ctgTestInitLogFile();
|
||||||
|
|
||||||
|
memset(ctgTestRspFunc, 0, sizeof(ctgTestRspFunc));
|
||||||
|
ctgTestRspIdx = 0;
|
||||||
|
ctgTestRspFunc[0] = CTGT_RSP_DNODElIST;
|
||||||
|
|
||||||
|
ctgTestSetRspByIdx();
|
||||||
|
|
||||||
|
initQueryModuleMsgHandle();
|
||||||
|
|
||||||
|
int32_t code = catalogInit(NULL);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
code = catalogGetHandle(ctgTestClusterId, &pCtg);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
|
||||||
|
SArray* pList = NULL;
|
||||||
|
code = catalogGetDnodeList(pCtg, mockPointer, &pList);
|
||||||
|
ASSERT_EQ(code, 0);
|
||||||
|
ASSERT_EQ(taosArrayGetSize(pList), 1);
|
||||||
|
|
||||||
|
taosArrayDestroy(pList);
|
||||||
|
|
||||||
|
catalogDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
do { \
|
do { \
|
||||||
ASSERT((_c) != -1); \
|
ASSERT((_c) != -1); \
|
||||||
longjmp((_obj), (_c)); \
|
longjmp((_obj), (_c)); \
|
||||||
} while (0);
|
} while (0)
|
||||||
|
|
||||||
#define SET_RES_WINDOW_KEY(_k, _ori, _len, _uid) \
|
#define SET_RES_WINDOW_KEY(_k, _ori, _len, _uid) \
|
||||||
do { \
|
do { \
|
||||||
|
@ -95,6 +95,25 @@ typedef struct SColMatchInfo {
|
||||||
int32_t matchType; // determinate the source according to col id or slot id
|
int32_t matchType; // determinate the source according to col id or slot id
|
||||||
} SColMatchInfo;
|
} SColMatchInfo;
|
||||||
|
|
||||||
|
// If the numOfOutputGroups is 1, the data blocks that belongs to different groups will be provided randomly
|
||||||
|
// The numOfOutputGroups is specified by physical plan. and will not be affect by numOfGroups
|
||||||
|
typedef struct STableListInfo {
|
||||||
|
bool oneTableForEachGroup;
|
||||||
|
int32_t numOfOuputGroups; // the data block will be generated one by one
|
||||||
|
int32_t* groupOffset; // keep the offset value for each group in the tableList
|
||||||
|
SArray* pTableList;
|
||||||
|
SHashObj* map; // speedup acquire the tableQueryInfo by table uid
|
||||||
|
uint64_t suid;
|
||||||
|
} STableListInfo;
|
||||||
|
|
||||||
|
void destroyTableList(STableListInfo* pTableList);
|
||||||
|
int32_t getNumOfOutputGroups(const STableListInfo* pTableList);
|
||||||
|
bool oneTableForEachGroup(const STableListInfo* pTableList);
|
||||||
|
uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid);
|
||||||
|
int32_t addTableIntoTableList(STableListInfo* pTableList, uint64_t uid, uint64_t gid);
|
||||||
|
int32_t getTablesOfGroup(const STableListInfo* pTableList, int32_t ordinalIndex, STableKeyInfo** pKeyInfo, int32_t* num);
|
||||||
|
uint64_t getTotalTables(const STableListInfo* pTableList);
|
||||||
|
|
||||||
struct SqlFunctionCtx;
|
struct SqlFunctionCtx;
|
||||||
|
|
||||||
size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
size_t getResultRowSize(struct SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
void copyUpdateDataBlock(SSDataBlock* pDest, SSDataBlock* pSource, int32_t tsColIndex);
|
||||||
|
|
||||||
bool groupbyTbname(SNodeList* pGroupList);
|
bool groupbyTbname(SNodeList* pGroupList);
|
||||||
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* groupKey);
|
int32_t setGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group, bool groupSort);
|
||||||
void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
void* destroySqlFunctionCtx(SqlFunctionCtx* pCtx, int32_t numOfOutput);
|
||||||
int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup,
|
int32_t buildDataBlockFromGroupRes(SOperatorInfo* pOperator, SStreamState* pState, SSDataBlock* pBlock, SExprSupp* pSup,
|
||||||
SGroupResInfo* pGroupResInfo);
|
SGroupResInfo* pGroupResInfo);
|
||||||
|
|
|
@ -48,6 +48,10 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
code =
|
code =
|
||||||
extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
extractColMatchInfo(pScanNode->scan.pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
removeRedundantTsCol(pScanNode, &pInfo->matchInfo);
|
removeRedundantTsCol(pScanNode, &pInfo->matchInfo);
|
||||||
|
|
||||||
code = extractCacheScanSlotId(pInfo->matchInfo.pList, pTaskInfo, &pInfo->pSlotIds);
|
code = extractCacheScanSlotId(pInfo->matchInfo.pList, pTaskInfo, &pInfo->pSlotIds);
|
||||||
|
@ -61,11 +65,15 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
blockDataEnsureCapacity(pInfo->pRes, pOperator->resultInfo.capacity);
|
||||||
pInfo->pUidList = taosArrayInit(4, sizeof(int64_t));
|
pInfo->pUidList = taosArrayInit(4, sizeof(int64_t));
|
||||||
|
|
||||||
// partition by tbname
|
// partition by tbname, todo opt perf
|
||||||
if (taosArrayGetSize(pTableList->pGroupList) == taosArrayGetSize(pTableList->pTableList)) {
|
if (oneTableForEachGroup(pTableList) || (getTotalTables(pTableList) == 1)) {
|
||||||
pInfo->retrieveType =
|
pInfo->retrieveType =
|
||||||
CACHESCAN_RETRIEVE_TYPE_ALL | (pScanNode->ignoreNull ? CACHESCAN_RETRIEVE_LAST : CACHESCAN_RETRIEVE_LAST_ROW);
|
CACHESCAN_RETRIEVE_TYPE_ALL | (pScanNode->ignoreNull ? CACHESCAN_RETRIEVE_LAST : CACHESCAN_RETRIEVE_LAST_ROW);
|
||||||
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pTableList->pTableList,
|
|
||||||
|
STableKeyInfo* pList = taosArrayGet(pTableList->pTableList, 0);
|
||||||
|
size_t num = taosArrayGetSize(pTableList->pTableList);
|
||||||
|
|
||||||
|
code = tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), pTableList->suid, &pInfo->pLastrowReader);
|
taosArrayGetSize(pInfo->matchInfo.pList), pTableList->suid, &pInfo->pLastrowReader);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -98,7 +106,7 @@ SOperatorInfo* createCacherowsScanOperator(SLastRowScanPhysiNode* pScanNode, SRe
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
destroyLastrowScanOperator(pInfo);
|
destroyLastrowScanOperator(pInfo);
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
|
@ -167,16 +175,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableList->map != NULL) {
|
pInfo->pRes->info.groupId = getTableGroupId(pTableList, pInfo->pRes->info.uid);
|
||||||
int64_t* groupId = taosHashGet(pTableList->map, &pInfo->pRes->info.uid, sizeof(int64_t));
|
|
||||||
if (groupId != NULL) {
|
|
||||||
pInfo->pRes->info.groupId = *groupId;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ASSERT(taosArrayGetSize(pTableList->pTableList) == 1);
|
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pTableList->pTableList, 0);
|
|
||||||
pInfo->pRes->info.groupId = pKeyInfo->groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
pInfo->indexOfBufferedRes += 1;
|
pInfo->indexOfBufferedRes += 1;
|
||||||
return pInfo->pRes;
|
return pInfo->pRes;
|
||||||
|
@ -185,18 +184,25 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
size_t totalGroups = taosArrayGetSize(pTableList->pGroupList);
|
size_t totalGroups = getNumOfOutputGroups(pTableList);
|
||||||
|
|
||||||
while (pInfo->currentGroupIndex < totalGroups) {
|
while (pInfo->currentGroupIndex < totalGroups) {
|
||||||
SArray* pGroupTableList = taosArrayGetP(pTableList->pGroupList, pInfo->currentGroupIndex);
|
|
||||||
|
|
||||||
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pGroupTableList,
|
STableKeyInfo* pList = NULL;
|
||||||
|
int32_t num = 0;
|
||||||
|
|
||||||
|
int32_t code = getTablesOfGroup(pTableList, pInfo->currentGroupIndex, &pList, &num);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbCacherowsReaderOpen(pInfo->readHandle.vnode, pInfo->retrieveType, pList, num,
|
||||||
taosArrayGetSize(pInfo->matchInfo.pList), pTableList->suid, &pInfo->pLastrowReader);
|
taosArrayGetSize(pInfo->matchInfo.pList), pTableList->suid, &pInfo->pLastrowReader);
|
||||||
taosArrayClear(pInfo->pUidList);
|
taosArrayClear(pInfo->pUidList);
|
||||||
|
|
||||||
int32_t code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
code = tsdbRetrieveCacheRows(pInfo->pLastrowReader, pInfo->pRes, pInfo->pSlotIds, pInfo->pUidList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
longjmp(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->currentGroupIndex += 1;
|
pInfo->currentGroupIndex += 1;
|
||||||
|
@ -206,7 +212,7 @@ SSDataBlock* doScanCache(SOperatorInfo* pOperator) {
|
||||||
if (pInfo->pseudoExprSup.numOfExprs > 0) {
|
if (pInfo->pseudoExprSup.numOfExprs > 0) {
|
||||||
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
SExprSupp* pSup = &pInfo->pseudoExprSup;
|
||||||
|
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pGroupTableList, 0);
|
STableKeyInfo* pKeyInfo = &((STableKeyInfo*)pTableList)[0];
|
||||||
pInfo->pRes->info.groupId = pKeyInfo->groupId;
|
pInfo->pRes->info.groupId = pKeyInfo->groupId;
|
||||||
|
|
||||||
if (taosArrayGetSize(pInfo->pUidList) > 0) {
|
if (taosArrayGetSize(pInfo->pUidList) > 0) {
|
||||||
|
|
|
@ -544,6 +544,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.index = 0;
|
ctx.index = 0;
|
||||||
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
|
ctx.cInfoList = taosArrayInit(4, sizeof(SColumnInfo));
|
||||||
if (ctx.cInfoList == NULL) {
|
if (ctx.cInfoList == NULL) {
|
||||||
|
@ -606,6 +607,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
} else {
|
} else {
|
||||||
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
|
void* tag = taosHashGet(tags, uid, sizeof(int64_t));
|
||||||
ASSERT(tag);
|
ASSERT(tag);
|
||||||
|
|
||||||
STagVal tagVal = {0};
|
STagVal tagVal = {0};
|
||||||
tagVal.cid = pColInfo->info.colId;
|
tagVal.cid = pColInfo->info.colId;
|
||||||
const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal);
|
const char* p = metaGetTableTagVal(tag, pColInfo->info.type, &tagVal);
|
||||||
|
@ -636,6 +638,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pResBlock->info.rows = rows;
|
pResBlock->info.rows = rows;
|
||||||
|
|
||||||
// int64_t st1 = taosGetTimestampUs();
|
// int64_t st1 = taosGetTimestampUs();
|
||||||
|
@ -661,10 +664,12 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
code = TSDB_CODE_OPS_NOT_SUPPORT;
|
code = TSDB_CODE_OPS_NOT_SUPPORT;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nodeType(pNode) == QUERY_NODE_COLUMN) {
|
if (nodeType(pNode) == QUERY_NODE_COLUMN) {
|
||||||
SColumnNode* pSColumnNode = (SColumnNode*)pNode;
|
SColumnNode* pSColumnNode = (SColumnNode*)pNode;
|
||||||
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, pSColumnNode->slotId);
|
SColumnInfoData* pColInfo = (SColumnInfoData*)taosArrayGet(pResBlock->pDataBlock, pSColumnNode->slotId);
|
||||||
|
@ -674,10 +679,12 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
} else {
|
} else {
|
||||||
code = scalarCalculate(pNode, pBlockList, &output);
|
code = scalarCalculate(pNode, pBlockList, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
releaseColInfoData(output.columnData);
|
releaseColInfoData(output.columnData);
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayPush(groupData, &output.columnData);
|
taosArrayPush(groupData, &output.columnData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -696,6 +703,7 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
code = TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < rows; i++) {
|
for (int i = 0; i < rows; i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
|
||||||
|
@ -733,7 +741,6 @@ int32_t getColInfoResultForGroupby(void* metaHandle, SNodeList* group, STableLis
|
||||||
|
|
||||||
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
int32_t len = (int32_t)(pStart - (char*)keyBuf);
|
||||||
info->groupId = calcGroupId(keyBuf, len);
|
info->groupId = calcGroupId(keyBuf, len);
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &info->groupId, sizeof(uint64_t));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// int64_t st2 = taosGetTimestampUs();
|
// int64_t st2 = taosGetTimestampUs();
|
||||||
|
@ -817,38 +824,86 @@ static int32_t removeInvalidTable(SArray* uids, SHashObj* tags) {
|
||||||
taosArrayDestroy(validUid);
|
taosArrayDestroy(validUid);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int32_t nameComparFn(const void* p1, const void* p2) {
|
||||||
|
const char* pName1 = *(const char**)p1;
|
||||||
|
const char* pName2 = *(const char**)p2;
|
||||||
|
|
||||||
|
int32_t ret = strcmp(pName1, pName2);
|
||||||
|
if (ret == 0) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return (ret > 0) ? 1 : -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static SArray* getTableNameList(const SNodeListNode* pList) {
|
||||||
|
int32_t len = LIST_LENGTH(pList->pNodeList);
|
||||||
|
SListCell* cell = pList->pNodeList->pHead;
|
||||||
|
|
||||||
|
SArray* pTbList = taosArrayInit(len, POINTER_BYTES);
|
||||||
|
for (int i = 0; i < pList->pNodeList->length; i++) {
|
||||||
|
SValueNode* valueNode = (SValueNode*)cell->pNode;
|
||||||
|
if (!IS_VAR_DATA_TYPE(valueNode->node.resType.type)) {
|
||||||
|
terrno = TSDB_CODE_INVALID_PARA;
|
||||||
|
taosArrayDestroy(pTbList);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* name = varDataVal(valueNode->datum.p);
|
||||||
|
taosArrayPush(pTbList, &name);
|
||||||
|
cell = cell->pNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t numOfTables = taosArrayGetSize(pTbList);
|
||||||
|
|
||||||
|
// order the name
|
||||||
|
taosArraySort(pTbList, nameComparFn);
|
||||||
|
|
||||||
|
// remove the duplicates
|
||||||
|
SArray* pNewList = taosArrayInit(taosArrayGetSize(pTbList), sizeof(void*));
|
||||||
|
taosArrayPush(pNewList, taosArrayGet(pTbList, 0));
|
||||||
|
|
||||||
|
for (int32_t i = 1; i < numOfTables; ++i) {
|
||||||
|
char** name = taosArrayGetLast(pNewList);
|
||||||
|
char** nameInOldList = taosArrayGet(pTbList, i);
|
||||||
|
if (strcmp(*name, *nameInOldList) == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayPush(pNewList, nameInOldList);
|
||||||
|
}
|
||||||
|
|
||||||
|
taosArrayDestroy(pTbList);
|
||||||
|
return pNewList;
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) {
|
static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray* list, SNode* pTagCond) {
|
||||||
if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) {
|
if (nodeType(pTagCond) != QUERY_NODE_OPERATOR) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
SOperatorNode* pNode = (SOperatorNode*)pTagCond;
|
SOperatorNode* pNode = (SOperatorNode*)pTagCond;
|
||||||
if (pNode->opType != OP_TYPE_IN) {
|
if (pNode->opType != OP_TYPE_IN) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((pNode->pLeft != NULL && nodeType(pNode->pLeft) == QUERY_NODE_COLUMN &&
|
if ((pNode->pLeft != NULL && nodeType(pNode->pLeft) == QUERY_NODE_COLUMN &&
|
||||||
((SColumnNode*)pNode->pLeft)->colType == COLUMN_TYPE_TBNAME) &&
|
((SColumnNode*)pNode->pLeft)->colType == COLUMN_TYPE_TBNAME) &&
|
||||||
(pNode->pRight != NULL && nodeType(pNode->pRight) == QUERY_NODE_NODE_LIST)) {
|
(pNode->pRight != NULL && nodeType(pNode->pRight) == QUERY_NODE_NODE_LIST)) {
|
||||||
SNodeListNode* pList = (SNodeListNode*)pNode->pRight;
|
SNodeListNode* pList = (SNodeListNode*)pNode->pRight;
|
||||||
|
|
||||||
int32_t len = LIST_LENGTH(pList->pNodeList);
|
int32_t len = LIST_LENGTH(pList->pNodeList);
|
||||||
if (len <= 0) return -1;
|
if (len <= 0) {
|
||||||
|
|
||||||
SListCell* cell = pList->pNodeList->pHead;
|
|
||||||
|
|
||||||
SArray* pTbList = taosArrayInit(len, sizeof(void*));
|
|
||||||
for (int i = 0; i < pList->pNodeList->length; i++) {
|
|
||||||
SValueNode* valueNode = (SValueNode*)cell->pNode;
|
|
||||||
if (!IS_VAR_DATA_TYPE(valueNode->node.resType.type)) {
|
|
||||||
taosArrayDestroy(pTbList);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
char* name = varDataVal(valueNode->datum.p);
|
|
||||||
taosArrayPush(pTbList, &name);
|
|
||||||
cell = cell->pNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < taosArrayGetSize(pTbList); i++) {
|
SArray* pTbList = getTableNameList(pList);
|
||||||
|
int32_t numOfTables = taosArrayGetSize(pTbList);
|
||||||
|
|
||||||
|
for (int i = 0; i < numOfTables; i++) {
|
||||||
char* name = taosArrayGetP(pTbList, i);
|
char* name = taosArrayGetP(pTbList, i);
|
||||||
|
|
||||||
uint64_t uid = 0;
|
uint64_t uid = 0;
|
||||||
if (metaGetTableUidByName(metaHandle, name, &uid) == 0) {
|
if (metaGetTableUidByName(metaHandle, name, &uid) == 0) {
|
||||||
ETableType tbType = TSDB_TABLE_MAX;
|
ETableType tbType = TSDB_TABLE_MAX;
|
||||||
|
@ -863,11 +918,14 @@ static int32_t optimizeTbnameInCondImpl(void* metaHandle, int64_t suid, SArray*
|
||||||
terrno = 0;
|
terrno = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pTbList);
|
taosArrayDestroy(pTbList);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond,
|
int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode, SNode* pTagCond, SNode* pTagIndexCond,
|
||||||
STableListInfo* pListInfo) {
|
STableListInfo* pListInfo) {
|
||||||
int32_t code = TSDB_CODE_SUCCESS;
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
@ -946,14 +1004,6 @@ int32_t getTableList(void* metaHandle, void* pVnode, SScanPhysiNode* pScanNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(res);
|
taosArrayDestroy(res);
|
||||||
|
|
||||||
pListInfo->pGroupList = taosArrayInit(4, POINTER_BYTES);
|
|
||||||
if (pListInfo->pGroupList == NULL) {
|
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
// put into list as default group, remove it if grouping sorting is required later
|
|
||||||
taosArrayPush(pListInfo->pGroupList, &pListInfo->pTableList);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1411,7 +1461,7 @@ void relocateColumnData(SSDataBlock* pBlock, const SArray* pColMatchInfo, SArray
|
||||||
while (i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
|
while (i < numOfSrcCols && j < taosArrayGetSize(pColMatchInfo)) {
|
||||||
SColumnInfoData* p = taosArrayGet(pCols, i);
|
SColumnInfoData* p = taosArrayGet(pCols, i);
|
||||||
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, j);
|
SColMatchItem* pmInfo = taosArrayGet(pColMatchInfo, j);
|
||||||
/* if (!outputEveryColumn && pmInfo->reserved) {
|
/* if (!outputEveryColumn && pmInfo->reserved) {
|
||||||
j++;
|
j++;
|
||||||
continue;
|
continue;
|
||||||
}*/
|
}*/
|
||||||
|
@ -1604,3 +1654,78 @@ void initLimitInfo(const SNode* pLimit, const SNode* pSLimit, SLimitInfo* pLimit
|
||||||
pLimitInfo->remainOffset = limit.offset;
|
pLimitInfo->remainOffset = limit.offset;
|
||||||
pLimitInfo->remainGroupOffset = slimit.offset;
|
pLimitInfo->remainGroupOffset = slimit.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t getTotalTables(const STableListInfo* pTableList) {
|
||||||
|
ASSERT(taosArrayGetSize(pTableList->pTableList) == taosHashGetSize(pTableList->map));
|
||||||
|
return taosArrayGetSize(pTableList->pTableList);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint64_t getTableGroupId(const STableListInfo* pTableList, uint64_t tableUid) {
|
||||||
|
int32_t* slot = taosHashGet(pTableList->map, &tableUid, sizeof(tableUid));
|
||||||
|
ASSERT(pTableList->map != NULL && slot != NULL);
|
||||||
|
|
||||||
|
STableKeyInfo* pKeyInfo = taosArrayGet(pTableList->pTableList, *slot);
|
||||||
|
ASSERT(pKeyInfo->uid == tableUid);
|
||||||
|
|
||||||
|
return pKeyInfo->groupId;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t addTableIntoTableList(STableListInfo* pTableList, uint64_t uid, uint64_t gid) {
|
||||||
|
if (pTableList->map == NULL) {
|
||||||
|
ASSERT(taosArrayGetSize(pTableList->pTableList) == 0);
|
||||||
|
pTableList->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
|
}
|
||||||
|
|
||||||
|
STableKeyInfo keyInfo = {.uid = uid, .groupId = gid};
|
||||||
|
taosArrayPush(pTableList->pTableList, &keyInfo);
|
||||||
|
|
||||||
|
int32_t slot = (int32_t)taosArrayGetSize(pTableList->pTableList) - 1;
|
||||||
|
taosHashPut(pTableList->map, &uid, sizeof(uid), &slot, sizeof(slot));
|
||||||
|
|
||||||
|
qDebug("uid:%" PRIu64 ", groupId:%" PRIu64 " added into table list, slot:%d, total:%d", uid, gid, slot, slot + 1);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getTablesOfGroup(const STableListInfo* pTableList, int32_t ordinalGroupIndex, STableKeyInfo** pKeyInfo,
|
||||||
|
int32_t* size) {
|
||||||
|
int32_t total = getNumOfOutputGroups(pTableList);
|
||||||
|
if (ordinalGroupIndex < 0 || ordinalGroupIndex >= total) {
|
||||||
|
return TSDB_CODE_INVALID_PARA;
|
||||||
|
}
|
||||||
|
|
||||||
|
// here handle two special cases:
|
||||||
|
// 1. only one group exists, and 2. one table exists for each group.
|
||||||
|
if (total == 1) {
|
||||||
|
*size = getTotalTables(pTableList);
|
||||||
|
*pKeyInfo = (*size == 0)? NULL:taosArrayGet(pTableList->pTableList, 0);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
} else if (total == getTotalTables(pTableList)) {
|
||||||
|
*size = 1;
|
||||||
|
*pKeyInfo = taosArrayGet(pTableList->pTableList, ordinalGroupIndex);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t offset = pTableList->groupOffset[ordinalGroupIndex];
|
||||||
|
if (ordinalGroupIndex < total - 1) {
|
||||||
|
*size = pTableList->groupOffset[offset + 1] - pTableList->groupOffset[offset];
|
||||||
|
} else {
|
||||||
|
*size = total - pTableList->groupOffset[offset] - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
*pKeyInfo = taosArrayGet(pTableList->pTableList, offset);
|
||||||
|
return TSDB_CODE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t getNumOfOutputGroups(const STableListInfo* pTableList) { return pTableList->numOfOuputGroups; }
|
||||||
|
|
||||||
|
bool oneTableForEachGroup(const STableListInfo* pTableList) { return pTableList->oneTableForEachGroup; }
|
||||||
|
|
||||||
|
void destroyTableList(STableListInfo* pTableqinfoList) {
|
||||||
|
pTableqinfoList->pTableList = taosArrayDestroy(pTableqinfoList->pTableList);
|
||||||
|
taosMemoryFreeClear(pTableqinfoList->groupOffset);
|
||||||
|
|
||||||
|
taosHashCleanup(pTableqinfoList->map);
|
||||||
|
|
||||||
|
pTableqinfoList->pTableList = NULL;
|
||||||
|
pTableqinfoList->map = NULL;
|
||||||
|
}
|
|
@ -293,9 +293,7 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), pTaskInfo->id.str);
|
qDebug("add %d tables id into query list, %s", (int32_t)taosArrayGetSize(tableIdList), pTaskInfo->id.str);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pListInfo->map == NULL) {
|
|
||||||
pListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
|
||||||
}
|
|
||||||
|
|
||||||
// traverse to the stream scanner node to add this table id
|
// traverse to the stream scanner node to add this table id
|
||||||
SOperatorInfo* pInfo = pTaskInfo->pRoot;
|
SOperatorInfo* pInfo = pTaskInfo->pRoot;
|
||||||
|
@ -307,8 +305,10 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
SStreamScanInfo* pScanInfo = pInfo->info;
|
SStreamScanInfo* pScanInfo = pInfo->info;
|
||||||
if (isAdd) { // add new table id
|
if (isAdd) { // add new table id
|
||||||
SArray* qa = filterUnqualifiedTables(pScanInfo, tableIdList, GET_TASKID(pTaskInfo));
|
SArray* qa = filterUnqualifiedTables(pScanInfo, tableIdList, GET_TASKID(pTaskInfo));
|
||||||
|
int32_t numOfQualifiedTables = taosArrayGetSize(qa);
|
||||||
|
|
||||||
|
qDebug(" %d qualified child tables added into stream scanner", numOfQualifiedTables);
|
||||||
|
|
||||||
qDebug(" %d qualified child tables added into stream scanner", (int32_t)taosArrayGetSize(qa));
|
|
||||||
code = tqReaderAddTbUidList(pScanInfo->tqReader, qa);
|
code = tqReaderAddTbUidList(pScanInfo->tqReader, qa);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
taosArrayDestroy(qa);
|
taosArrayDestroy(qa);
|
||||||
|
@ -328,7 +328,9 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(qa); ++i) {
|
STableListInfo* pTableListInfo = &pTaskInfo->tableqinfoList;
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < numOfQualifiedTables; ++i) {
|
||||||
uint64_t* uid = taosArrayGet(qa, i);
|
uint64_t* uid = taosArrayGet(qa, i);
|
||||||
STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0};
|
STableKeyInfo keyInfo = {.uid = *uid, .groupId = 0};
|
||||||
|
|
||||||
|
@ -358,8 +360,8 @@ int32_t qUpdateQualifiedTableId(qTaskInfo_t tinfo, const SArray* tableIdList, bo
|
||||||
|
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
#endif
|
#endif
|
||||||
taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &keyInfo);
|
|
||||||
taosHashPut(pTaskInfo->tableqinfoList.map, uid, sizeof(*uid), &keyInfo.groupId, sizeof(keyInfo.groupId));
|
addTableIntoTableList(pTableListInfo, keyInfo.uid, keyInfo.groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyBuf != NULL) {
|
if (keyBuf != NULL) {
|
||||||
|
@ -439,7 +441,7 @@ int32_t qCreateExecTask(SReadHandle* readHandle, int32_t vgId, uint64_t taskId,
|
||||||
|
|
||||||
qDebug("subplan task create completed, TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, pSubplan->id.queryId);
|
qDebug("subplan task create completed, TID:0x%" PRIx64 " QID:0x%" PRIx64, taskId, pSubplan->id.queryId);
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
// if failed to add ref for all tables in this query, abort current query
|
// if failed to add ref for all tables in this query, abort current query
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -935,7 +937,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
/*if (pTaskInfo->streamInfo.lastStatus.type != TMQ_OFFSET__SNAPSHOT_DATA ||*/
|
/*if (pTaskInfo->streamInfo.lastStatus.type != TMQ_OFFSET__SNAPSHOT_DATA ||*/
|
||||||
/*pTaskInfo->streamInfo.lastStatus.uid != uid || pTaskInfo->streamInfo.lastStatus.ts != ts) {*/
|
/*pTaskInfo->streamInfo.lastStatus.uid != uid || pTaskInfo->streamInfo.lastStatus.ts != ts) {*/
|
||||||
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
STableScanInfo* pTableScanInfo = pInfo->pTableScanOp->info;
|
||||||
int32_t tableSz = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList);
|
int32_t numOfTables = getTotalTables(&pTaskInfo->tableqinfoList);
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
qDebug("switch to next table %" PRId64 " (cursor %d), %" PRId64 " rows returned", uid,
|
qDebug("switch to next table %" PRId64 " (cursor %d), %" PRId64 " rows returned", uid,
|
||||||
|
@ -944,7 +946,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int32_t i = 0; i < tableSz; i++) {
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i);
|
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, i);
|
||||||
if (pTableInfo->uid == uid) {
|
if (pTableInfo->uid == uid) {
|
||||||
found = true;
|
found = true;
|
||||||
|
@ -957,14 +959,17 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
ASSERT(found);
|
ASSERT(found);
|
||||||
|
|
||||||
if (pTableScanInfo->dataReader == NULL) {
|
if (pTableScanInfo->dataReader == NULL) {
|
||||||
if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond,
|
STableKeyInfo* pList = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, 0);
|
||||||
pTaskInfo->tableqinfoList.pTableList, &pTableScanInfo->dataReader, NULL) < 0 ||
|
int32_t num = getTotalTables(&pTaskInfo->tableqinfoList);
|
||||||
pTableScanInfo->dataReader == NULL) {
|
|
||||||
|
if (tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &pTableScanInfo->cond, pList, num,
|
||||||
|
&pTableScanInfo->dataReader, NULL) < 0 || pTableScanInfo->dataReader == NULL) {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tsdbSetTableId(pTableScanInfo->dataReader, uid);
|
STableKeyInfo tki = {.uid = uid};
|
||||||
|
tsdbSetTableList(pTableScanInfo->dataReader, &tki, 1);
|
||||||
int64_t oldSkey = pTableScanInfo->cond.twindows.skey;
|
int64_t oldSkey = pTableScanInfo->cond.twindows.skey;
|
||||||
pTableScanInfo->cond.twindows.skey = ts + 1;
|
pTableScanInfo->cond.twindows.skey = ts + 1;
|
||||||
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
||||||
|
@ -972,7 +977,7 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
pTableScanInfo->scanTimes = 0;
|
pTableScanInfo->scanTimes = 0;
|
||||||
|
|
||||||
qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid,
|
qDebug("tsdb reader offset seek to uid %" PRId64 " ts %" PRId64 ", table cur set to %d , all table num %d", uid,
|
||||||
ts, pTableScanInfo->currentTable, tableSz);
|
ts, pTableScanInfo->currentTable, numOfTables);
|
||||||
/*}*/
|
/*}*/
|
||||||
} else {
|
} else {
|
||||||
ASSERT(0);
|
ASSERT(0);
|
||||||
|
@ -994,9 +999,15 @@ int32_t qStreamPrepareScan(qTaskInfo_t tinfo, STqOffsetVal* pOffset, int8_t subT
|
||||||
|
|
||||||
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
initQueryTableDataCondForTmq(&pTaskInfo->streamInfo.tableCond, sContext, &mtInfo);
|
||||||
pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts;
|
pTaskInfo->streamInfo.tableCond.twindows.skey = pOffset->ts;
|
||||||
pTaskInfo->tableqinfoList.pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
|
||||||
taosArrayPush(pTaskInfo->tableqinfoList.pTableList, &(STableKeyInfo){.uid = mtInfo.uid, .groupId = 0});
|
STableListInfo* pListInfo = &pTaskInfo->tableqinfoList;
|
||||||
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pTaskInfo->tableqinfoList.pTableList,
|
|
||||||
|
pListInfo->pTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
||||||
|
taosArrayPush(pListInfo->pTableList, &(STableKeyInfo){.uid = mtInfo.uid, .groupId = 0});
|
||||||
|
|
||||||
|
STableKeyInfo* pList = taosArrayGet(pListInfo->pTableList, 0);
|
||||||
|
|
||||||
|
tsdbReaderOpen(pInfo->vnode, &pTaskInfo->streamInfo.tableCond, pList, taosArrayGetSize(pListInfo->pTableList),
|
||||||
&pInfo->dataReader, NULL);
|
&pInfo->dataReader, NULL);
|
||||||
|
|
||||||
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
cleanupQueryTableDataCond(&pTaskInfo->streamInfo.tableCond);
|
||||||
|
|
|
@ -1739,8 +1739,6 @@ int32_t appendDownstream(SOperatorInfo* p, SOperatorInfo** pDownstream, int32_t
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doDestroyTableList(STableListInfo* pTableqinfoList);
|
|
||||||
|
|
||||||
typedef struct SFetchRspHandleWrapper {
|
typedef struct SFetchRspHandleWrapper {
|
||||||
uint32_t exchangeId;
|
uint32_t exchangeId;
|
||||||
int32_t sourceIndex;
|
int32_t sourceIndex;
|
||||||
|
@ -2030,7 +2028,7 @@ static void concurrentlyLoadRemoteDataImpl(SOperatorInfo* pOperator, SExchangeIn
|
||||||
sched_yield();
|
sched_yield();
|
||||||
}
|
}
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2305,7 +2303,7 @@ SOperatorInfo* createExchangeOperatorInfo(void* pTransporter, SExchangePhysiNode
|
||||||
createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, destroyExchangeOperatorInfo, NULL);
|
createOperatorFpSet(prepareLoadRemoteData, doLoadRemoteData, NULL, NULL, destroyExchangeOperatorInfo, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
doDestroyExchangeOperatorInfo(pInfo);
|
doDestroyExchangeOperatorInfo(pInfo);
|
||||||
}
|
}
|
||||||
|
@ -3042,7 +3040,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
destroyAggOperatorInfo(pInfo);
|
destroyAggOperatorInfo(pInfo);
|
||||||
}
|
}
|
||||||
|
@ -3258,7 +3256,7 @@ SOperatorInfo* createFillOperatorInfo(SOperatorInfo* downstream, SFillPhysiNode*
|
||||||
code = appendDownstream(pOperator, &downstream, 1);
|
code = appendDownstream(pOperator, &downstream, 1);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
destroyFillOperatorInfo(pInfo);
|
destroyFillOperatorInfo(pInfo);
|
||||||
}
|
}
|
||||||
|
@ -3366,62 +3364,115 @@ static void cleanupTableSchemaInfo(SSchemaInfo* pSchemaInfo) {
|
||||||
|
|
||||||
static void cleanupStreamInfo(SStreamTaskInfo* pStreamInfo) { tDeleteSSchemaWrapper(pStreamInfo->schema); }
|
static void cleanupStreamInfo(SStreamTaskInfo* pStreamInfo) { tDeleteSSchemaWrapper(pStreamInfo->schema); }
|
||||||
|
|
||||||
|
static int32_t orderbyGroupIdComparFn(const void* p1, const void* p2) {
|
||||||
|
STableKeyInfo* pInfo1 = (STableKeyInfo*) p1;
|
||||||
|
STableKeyInfo* pInfo2 = (STableKeyInfo*) p2;
|
||||||
|
|
||||||
|
if (pInfo1->groupId == pInfo2->groupId) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
return pInfo1->groupId < pInfo2->groupId? -1:1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
static int32_t sortTableGroup(STableListInfo* pTableListInfo) {
|
||||||
taosArrayClear(pTableListInfo->pGroupList);
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
|
int32_t size = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
|
||||||
|
SArray* pList = taosArrayInit(4, sizeof(int32_t));
|
||||||
|
|
||||||
|
STableKeyInfo* pInfo = taosArrayGet(pTableListInfo->pTableList, 0);
|
||||||
|
uint64_t gid = pInfo->groupId;
|
||||||
|
|
||||||
|
int32_t start = 0;
|
||||||
|
taosArrayPush(pList, &start);
|
||||||
|
|
||||||
|
for(int32_t i = 1; i < size; ++i) {
|
||||||
|
pInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
if (pInfo->groupId != gid) {
|
||||||
|
taosArrayPush(pList, &i);
|
||||||
|
gid = pInfo->groupId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pTableListInfo->numOfOuputGroups = taosArrayGetSize(pList);
|
||||||
|
pTableListInfo->groupOffset = taosMemoryMalloc(sizeof(int32_t) * pTableListInfo->numOfOuputGroups);
|
||||||
|
memcpy(pTableListInfo->groupOffset, taosArrayGet(pList, 0), sizeof(int32_t) * pTableListInfo->numOfOuputGroups);
|
||||||
|
taosArrayDestroy(pList);
|
||||||
|
|
||||||
|
# if 0
|
||||||
SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t));
|
SArray* sortSupport = taosArrayInit(16, sizeof(uint64_t));
|
||||||
if (sortSupport == NULL) return TSDB_CODE_OUT_OF_MEMORY;
|
if (sortSupport == NULL) {
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); i++) {
|
return TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t num = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
for (int32_t i = 0; i < num; i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t));
|
uint64_t* groupId = taosHashGet(pTableListInfo->map, &info->uid, sizeof(uint64_t));
|
||||||
|
|
||||||
int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ);
|
int32_t index = taosArraySearchIdx(sortSupport, groupId, compareUint64Val, TD_EQ);
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
void* p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT);
|
void* p = taosArraySearch(sortSupport, groupId, compareUint64Val, TD_GT);
|
||||||
|
|
||||||
SArray* tGroup = taosArrayInit(8, sizeof(STableKeyInfo));
|
SArray* tGroup = taosArrayInit(8, sizeof(STableKeyInfo));
|
||||||
if (tGroup == NULL) {
|
if (tGroup == NULL) {
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayPush(tGroup, info) == NULL) {
|
if (taosArrayPush(tGroup, info) == NULL) {
|
||||||
qError("taos push info array error");
|
qError("taos push info array error");
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
if (taosArrayPush(sortSupport, groupId) == NULL) {
|
if (taosArrayPush(sortSupport, groupId) == NULL) {
|
||||||
qError("taos push support array error");
|
qError("taos push support array error");
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayPush(pTableListInfo->pGroupList, &tGroup) == NULL) {
|
if (taosArrayPush(pTableListInfo->pGroupList, &tGroup) == NULL) {
|
||||||
qError("taos push group array error");
|
qError("taos push group array error");
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
goto _error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t pos = TARRAY_ELEM_IDX(sortSupport, p);
|
int32_t pos = TARRAY_ELEM_IDX(sortSupport, p);
|
||||||
if (taosArrayInsert(sortSupport, pos, groupId) == NULL) {
|
if (taosArrayInsert(sortSupport, pos, groupId) == NULL) {
|
||||||
qError("taos insert support array error");
|
qError("taos insert support array error");
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL) {
|
if (taosArrayInsert(pTableListInfo->pGroupList, pos, &tGroup) == NULL) {
|
||||||
qError("taos insert group array error");
|
qError("taos insert group array error");
|
||||||
taosArrayDestroy(sortSupport);
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
goto _error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index);
|
SArray* tGroup = (SArray*)taosArrayGetP(pTableListInfo->pGroupList, index);
|
||||||
if (taosArrayPush(tGroup, info) == NULL) {
|
if (taosArrayPush(tGroup, info) == NULL) {
|
||||||
qError("taos push uid array error");
|
qError("taos push uid array error");
|
||||||
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
taosArrayDestroy(sortSupport);
|
taosArrayDestroy(sortSupport);
|
||||||
return TSDB_CODE_QRY_APP_ERROR;
|
#endif
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taosArrayDestroy(sortSupport);
|
|
||||||
return TDB_CODE_SUCCESS;
|
return TDB_CODE_SUCCESS;
|
||||||
|
|
||||||
|
_error:
|
||||||
|
// taosArrayDestroy(sortSupport);
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool groupbyTbname(SNodeList* pGroupList) {
|
bool groupbyTbname(SNodeList* pGroupList) {
|
||||||
|
@ -3437,38 +3488,50 @@ bool groupbyTbname(SNodeList* pGroupList) {
|
||||||
return bytbname;
|
return bytbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t generateGroupIdMap(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group) {
|
int32_t setGroupIdMapForAllTables(STableListInfo* pTableListInfo, SReadHandle* pHandle, SNodeList* group, bool groupSort) {
|
||||||
if (group == NULL) {
|
int32_t code = TSDB_CODE_SUCCESS;
|
||||||
return TDB_CODE_SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
pTableListInfo->map = taosHashInit(32, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK);
|
||||||
if (pTableListInfo->map == NULL) {
|
if (pTableListInfo->map == NULL) {
|
||||||
return TSDB_CODE_OUT_OF_MEMORY;
|
code = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool assignUid = groupbyTbname(group);
|
bool groupByTbname = groupbyTbname(group);
|
||||||
|
|
||||||
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
size_t numOfTables = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
if (group == NULL || groupByTbname) {
|
||||||
if (assignUid) {
|
|
||||||
for (int32_t i = 0; i < numOfTables; i++) {
|
for (int32_t i = 0; i < numOfTables; i++) {
|
||||||
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* info = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
info->groupId = info->uid;
|
info->groupId = groupByTbname? info->uid:0;
|
||||||
taosHashPut(pTableListInfo->map, &(info->uid), sizeof(uint64_t), &info->groupId, sizeof(uint64_t));
|
}
|
||||||
|
|
||||||
|
pTableListInfo->oneTableForEachGroup = groupByTbname;
|
||||||
|
|
||||||
|
if (groupSort && groupByTbname) {
|
||||||
|
taosArraySort(pTableListInfo->pTableList, orderbyGroupIdComparFn);
|
||||||
|
pTableListInfo->numOfOuputGroups = numOfTables;
|
||||||
|
} else {
|
||||||
|
pTableListInfo->numOfOuputGroups = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int32_t code = getColInfoResultForGroupby(pHandle->meta, group, pTableListInfo);
|
code = getColInfoResultForGroupby(pHandle->meta, group, pTableListInfo);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (groupSort) {
|
||||||
|
code = sortTableGroup(pTableListInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableListInfo->needSortTableByGroupId) {
|
// add all table entry in the hash map
|
||||||
return sortTableGroup(pTableListInfo);
|
size_t size = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
for(int32_t i = 0; i < size; ++i) {
|
||||||
|
STableKeyInfo* p = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
|
taosHashPut(pTableListInfo->map, &p->uid, sizeof(uint64_t), &i, sizeof(int32_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return TDB_CODE_SUCCESS;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pCond) {
|
static int32_t initTableblockDistQueryCond(uint64_t uid, SQueryTableDataCond* pCond) {
|
||||||
|
@ -3505,6 +3568,12 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
if (QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN == type) {
|
||||||
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
STableScanPhysiNode* pTableScanNode = (STableScanPhysiNode*)pPhyNode;
|
||||||
|
|
||||||
|
// NOTE: this is an patch to fix the physical plan
|
||||||
|
// TODO remove it later
|
||||||
|
if (pTableScanNode->scan.node.pLimit != NULL) {
|
||||||
|
pTableScanNode->groupSort = true;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t code =
|
int32_t code =
|
||||||
createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle,
|
createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle,
|
||||||
pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||||
|
@ -3526,7 +3595,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN == type) {
|
||||||
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
STableMergeScanPhysiNode* pTableScanNode = (STableMergeScanPhysiNode*)pPhyNode;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, pTableScanNode->groupSort, pHandle,
|
createScanTableListInfo(&pTableScanNode->scan, pTableScanNode->pGroupTags, /*pTableScanNode->groupSort*/true, pHandle,
|
||||||
pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
pTableListInfo, pTagCond, pTagIndexCond, GET_TASKID(pTaskInfo));
|
||||||
if (code) {
|
if (code) {
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
|
@ -3561,9 +3630,11 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
int32_t sz = taosArrayGetSize(pTableListInfo->pTableList);
|
int32_t sz = taosArrayGetSize(pTableListInfo->pTableList);
|
||||||
|
qDebug("create stream task, total:%d", sz);
|
||||||
|
|
||||||
for (int32_t i = 0; i < sz; i++) {
|
for (int32_t i = 0; i < sz; i++) {
|
||||||
STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
STableKeyInfo* pKeyInfo = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
qDebug("creating stream task: add table %" PRId64, pKeyInfo->uid);
|
qDebug("add table uid:%" PRIu64", gid:%"PRIu64, pKeyInfo->uid, pKeyInfo->groupId);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -3586,26 +3657,40 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
} else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) {
|
} else if (QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN == type) {
|
||||||
SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode;
|
SBlockDistScanPhysiNode* pBlockNode = (SBlockDistScanPhysiNode*)pPhyNode;
|
||||||
pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo));
|
pTableListInfo->pTableList = taosArrayInit(4, sizeof(STableKeyInfo));
|
||||||
|
pTableListInfo->numOfOuputGroups = 1;
|
||||||
|
|
||||||
if (pBlockNode->tableType == TSDB_SUPER_TABLE) {
|
if (pBlockNode->tableType == TSDB_SUPER_TABLE) {
|
||||||
int32_t code = vnodeGetAllTableList(pHandle->vnode, pBlockNode->uid, pTableListInfo->pTableList);
|
SArray* pList = taosArrayInit(4, sizeof(STableKeyInfo));
|
||||||
|
int32_t code = vnodeGetAllTableList(pHandle->vnode, pBlockNode->uid, pList);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
pTaskInfo->code = terrno;
|
pTaskInfo->code = terrno;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(int32_t i = 0; i < taosArrayGetSize(pTableListInfo->pTableList); ++i) {
|
||||||
|
STableKeyInfo* p = taosArrayGet(pList, i);
|
||||||
|
addTableIntoTableList(pTableListInfo, p->uid, 0);
|
||||||
|
}
|
||||||
|
taosArrayDestroy(pList);
|
||||||
} else { // Create one table group.
|
} else { // Create one table group.
|
||||||
STableKeyInfo info = {.uid = pBlockNode->uid, .groupId = 0};
|
addTableIntoTableList(pTableListInfo, pBlockNode->uid, 0);
|
||||||
taosArrayPush(pTableListInfo->pTableList, &info);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SQueryTableDataCond cond = {0};
|
SQueryTableDataCond cond = {0};
|
||||||
|
|
||||||
int32_t code = initTableblockDistQueryCond(pBlockNode->suid, &cond);
|
int32_t code = initTableblockDistQueryCond(pBlockNode->suid, &cond);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t num = getTotalTables(pTableListInfo);
|
||||||
|
void* pList = NULL;
|
||||||
|
if (num > 0) {
|
||||||
|
pList = taosArrayGet(pTableListInfo->pTableList, 0);
|
||||||
|
}
|
||||||
|
|
||||||
STsdbReader* pReader = NULL;
|
STsdbReader* pReader = NULL;
|
||||||
tsdbReaderOpen(pHandle->vnode, &cond, pTableListInfo->pTableList, &pReader, "");
|
tsdbReaderOpen(pHandle->vnode, &cond, pList, num, &pReader, "");
|
||||||
cleanupQueryTableDataCond(&cond);
|
cleanupQueryTableDataCond(&cond);
|
||||||
|
|
||||||
pOperator = createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
pOperator = createDataBlockInfoScanOperator(pReader, pHandle, cond.suid, pBlockNode, pTaskInfo);
|
||||||
|
@ -3640,6 +3725,7 @@ SOperatorInfo* createOperatorTree(SPhysiNode* pPhyNode, SExecTaskInfo* pTaskInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t size = LIST_LENGTH(pPhyNode->pChildren);
|
size_t size = LIST_LENGTH(pPhyNode->pChildren);
|
||||||
|
|
||||||
SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES);
|
SOperatorInfo** ops = taosMemoryCalloc(size, POINTER_BYTES);
|
||||||
for (int32_t i = 0; i < size; ++i) {
|
for (int32_t i = 0; i < size; ++i) {
|
||||||
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i);
|
||||||
|
@ -3848,7 +3934,7 @@ int32_t encodeOperator(SOperatorInfo* ops, char** result, int32_t* length, int32
|
||||||
*length = *(int32_t*)(*result);
|
*length = *(int32_t*)(*result);
|
||||||
}
|
}
|
||||||
|
|
||||||
_downstream:
|
_downstream:
|
||||||
for (int32_t i = 0; i < ops->numOfDownstream; ++i) {
|
for (int32_t i = 0; i < ops->numOfDownstream; ++i) {
|
||||||
code = encodeOperator(ops->pDownstream[i], result, length, nOptrWithVal);
|
code = encodeOperator(ops->pDownstream[i], result, length, nOptrWithVal);
|
||||||
if (code != TDB_CODE_SUCCESS) {
|
if (code != TDB_CODE_SUCCESS) {
|
||||||
|
@ -3968,35 +4054,17 @@ int32_t createExecTaskInfoImpl(SSubplan* pPlan, SExecTaskInfo** pTaskInfo, SRead
|
||||||
|
|
||||||
return code;
|
return code;
|
||||||
|
|
||||||
_complete:
|
_complete:
|
||||||
taosMemoryFree(sql);
|
taosMemoryFree(sql);
|
||||||
doDestroyTask(*pTaskInfo);
|
doDestroyTask(*pTaskInfo);
|
||||||
terrno = code;
|
terrno = code;
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doDestroyTableList(STableListInfo* pTableqinfoList) {
|
|
||||||
taosArrayDestroy(pTableqinfoList->pTableList);
|
|
||||||
taosHashCleanup(pTableqinfoList->map);
|
|
||||||
if (pTableqinfoList->needSortTableByGroupId) {
|
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pTableqinfoList->pGroupList); i++) {
|
|
||||||
SArray* tmp = taosArrayGetP(pTableqinfoList->pGroupList, i);
|
|
||||||
if (tmp == pTableqinfoList->pTableList) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
taosArrayDestroy(tmp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
taosArrayDestroy(pTableqinfoList->pGroupList);
|
|
||||||
|
|
||||||
pTableqinfoList->pTableList = NULL;
|
|
||||||
pTableqinfoList->map = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
void doDestroyTask(SExecTaskInfo* pTaskInfo) {
|
||||||
qDebug("%s execTask is freed", GET_TASKID(pTaskInfo));
|
qDebug("%s execTask is freed", GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
doDestroyTableList(&pTaskInfo->tableqinfoList);
|
destroyTableList(&pTaskInfo->tableqinfoList);
|
||||||
destroyOperatorInfo(pTaskInfo->pRoot);
|
destroyOperatorInfo(pTaskInfo->pRoot);
|
||||||
cleanupTableSchemaInfo(&pTaskInfo->schemaInfo);
|
cleanupTableSchemaInfo(&pTaskInfo->schemaInfo);
|
||||||
cleanupStreamInfo(&pTaskInfo->streamInfo);
|
cleanupStreamInfo(&pTaskInfo->streamInfo);
|
||||||
|
|
|
@ -363,8 +363,7 @@ void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
|
||||||
if (pLimitInfo->remainOffset >= pBlock->info.rows) {
|
if (pLimitInfo->remainOffset >= pBlock->info.rows) {
|
||||||
pLimitInfo->remainOffset -= pBlock->info.rows;
|
pLimitInfo->remainOffset -= pBlock->info.rows;
|
||||||
pBlock->info.rows = 0;
|
pBlock->info.rows = 0;
|
||||||
qDebug("current block ignore due to offset, current:%" PRId64 ", %s", pLimitInfo->remainOffset,
|
qDebug("current block ignore due to offset, current:%"PRId64", %s", pLimitInfo->remainOffset, GET_TASKID(pTaskInfo));
|
||||||
GET_TASKID(pTaskInfo));
|
|
||||||
} else {
|
} else {
|
||||||
blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
|
blockDataTrimFirstNRows(pBlock, pLimitInfo->remainOffset);
|
||||||
pLimitInfo->remainOffset = 0;
|
pLimitInfo->remainOffset = 0;
|
||||||
|
@ -377,9 +376,7 @@ void applyLimitOffset(SLimitInfo* pLimitInfo, SSDataBlock* pBlock, SExecTaskInfo
|
||||||
int32_t keep = pBlock->info.rows - overflowRows;
|
int32_t keep = pBlock->info.rows - overflowRows;
|
||||||
|
|
||||||
blockDataKeepFirstNRows(pBlock, keep);
|
blockDataKeepFirstNRows(pBlock, keep);
|
||||||
qDebug("output limit %" PRId64 " has reached, %s", pLimit->limit, GET_TASKID(pTaskInfo));
|
qDebug("output limit %"PRId64" has reached, %s", pLimit->limit, GET_TASKID(pTaskInfo));
|
||||||
|
|
||||||
// setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
|
||||||
pOperator->status = OP_EXEC_DONE;
|
pOperator->status = OP_EXEC_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -624,12 +621,9 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo* pOperator) {
|
||||||
binfo.capacity = binfo.rows;
|
binfo.capacity = binfo.rows;
|
||||||
blockDataEnsureCapacity(pBlock, binfo.rows);
|
blockDataEnsureCapacity(pBlock, binfo.rows);
|
||||||
pBlock->info = binfo;
|
pBlock->info = binfo;
|
||||||
ASSERT(binfo.uid != 0);
|
|
||||||
|
|
||||||
uint64_t* groupId = taosHashGet(pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
ASSERT(binfo.uid != 0);
|
||||||
if (groupId) {
|
pBlock->info.groupId = getTableGroupId(&pTaskInfo->tableqinfoList, pBlock->info.uid);
|
||||||
pBlock->info.groupId = *groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
int32_t code = loadDataBlock(pOperator, pTableScanInfo, pBlock, &status);
|
||||||
|
@ -683,10 +677,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
|
||||||
if (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
|
if (pTableScanInfo->scanTimes < pTableScanInfo->scanInfo.numOfAsc) {
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
||||||
qDebug(
|
qDebug("start to repeat ascending order scan data blocks due to query func required, %s", GET_TASKID(pTaskInfo));
|
||||||
"%s start to repeat ascending order scan data SELECT last_row(*),hostname from cpu group by hostname;blocks "
|
|
||||||
"due to query func required",
|
|
||||||
GET_TASKID(pTaskInfo));
|
|
||||||
|
|
||||||
// do prepare for the next round table scan operation
|
// do prepare for the next round table scan operation
|
||||||
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
||||||
|
@ -713,8 +704,7 @@ static SSDataBlock* doTableScanGroup(SOperatorInfo* pOperator) {
|
||||||
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
setTaskStatus(pTaskInfo, TASK_NOT_COMPLETED);
|
||||||
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
pTableScanInfo->scanFlag = REPEAT_SCAN;
|
||||||
|
|
||||||
qDebug("%s start to repeat descending order scan data blocks due to query func required",
|
qDebug("%s start to repeat descending order scan data blocks", GET_TASKID(pTaskInfo));
|
||||||
GET_TASKID(pTaskInfo));
|
|
||||||
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
tsdbReaderReset(pTableScanInfo->dataReader, &pTableScanInfo->cond);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -727,7 +717,7 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
STableScanInfo* pInfo = pOperator->info;
|
STableScanInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
|
||||||
// if scan table by table
|
// scan table one by one sequentially
|
||||||
if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) {
|
if (pInfo->scanMode == TABLE_SCAN__TABLE_ORDER) {
|
||||||
int32_t numOfTables = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList);
|
int32_t numOfTables = taosArrayGetSize(pTaskInfo->tableqinfoList.pTableList);
|
||||||
|
|
||||||
|
@ -744,54 +734,64 @@ static SSDataBlock* doTableScan(SOperatorInfo* pOperator) {
|
||||||
}
|
}
|
||||||
|
|
||||||
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable);
|
STableKeyInfo* pTableInfo = taosArrayGet(pTaskInfo->tableqinfoList.pTableList, pInfo->currentTable);
|
||||||
tsdbSetTableId(pInfo->dataReader, pTableInfo->uid);
|
tsdbSetTableList(pInfo->dataReader, pTableInfo, 1);
|
||||||
qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables,
|
qDebug("set uid:%" PRIu64 " into scanner, total tables:%d, index:%d %s", pTableInfo->uid, numOfTables,
|
||||||
pInfo->currentTable, pTaskInfo->id.str);
|
pInfo->currentTable, pTaskInfo->id.str);
|
||||||
|
|
||||||
tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
|
tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
|
||||||
pInfo->scanTimes = 0;
|
pInfo->scanTimes = 0;
|
||||||
}
|
}
|
||||||
}
|
} else { // scan table group by group sequentially
|
||||||
|
|
||||||
if (pInfo->currentGroupId == -1) {
|
if (pInfo->currentGroupId == -1) {
|
||||||
pInfo->currentGroupId++;
|
if ((++pInfo->currentGroupId) >= getNumOfOutputGroups(&pTaskInfo->tableqinfoList)) {
|
||||||
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
doSetOperatorCompleted(pOperator);
|
||||||
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, pInfo->currentGroupId);
|
int32_t num = 0;
|
||||||
tsdbReaderClose(pInfo->dataReader);
|
STableKeyInfo* pList = NULL;
|
||||||
|
getTablesOfGroup(&pTaskInfo->tableqinfoList, pInfo->currentGroupId, &pList, &num);
|
||||||
|
ASSERT(pInfo->dataReader == NULL);
|
||||||
|
|
||||||
int32_t code = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, tableList, (STsdbReader**)&pInfo->dataReader,
|
int32_t code = tsdbReaderOpen(pInfo->readHandle.vnode, &pInfo->cond, pList, num, (STsdbReader**)&pInfo->dataReader,
|
||||||
GET_TASKID(pTaskInfo));
|
GET_TASKID(pTaskInfo));
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pTaskInfo->env, code);
|
T_LONG_JMP(pTaskInfo->env, code);
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SSDataBlock* result = doTableScanGroup(pOperator);
|
SSDataBlock* result = doTableScanGroup(pOperator);
|
||||||
if (result) {
|
if (result != NULL) {
|
||||||
|
ASSERT(result->info.uid != 0);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
pInfo->currentGroupId++;
|
if ((++pInfo->currentGroupId) >= getNumOfOutputGroups(&pTaskInfo->tableqinfoList)) {
|
||||||
if (pInfo->currentGroupId >= taosArrayGetSize(pTaskInfo->tableqinfoList.pGroupList)) {
|
doSetOperatorCompleted(pOperator);
|
||||||
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reset value for the next group data output
|
||||||
|
pOperator->status = OP_OPENED;
|
||||||
|
pInfo->limitInfo.numOfOutputRows = 0;
|
||||||
|
pInfo->limitInfo.remainOffset = pInfo->limitInfo.limit.offset;
|
||||||
|
|
||||||
|
int32_t num = 0;
|
||||||
|
STableKeyInfo* pList = NULL;
|
||||||
|
getTablesOfGroup(&pTaskInfo->tableqinfoList, pInfo->currentGroupId, &pList, &num);
|
||||||
|
|
||||||
|
tsdbSetTableList(pInfo->dataReader, pList, num);
|
||||||
tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
|
tsdbReaderReset(pInfo->dataReader, &pInfo->cond);
|
||||||
pInfo->scanTimes = 0;
|
pInfo->scanTimes = 0;
|
||||||
|
|
||||||
result = doTableScanGroup(pOperator);
|
result = doTableScanGroup(pOperator);
|
||||||
if (result) {
|
if (result != NULL) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
setTaskStatus(pTaskInfo, TASK_COMPLETED);
|
doSetOperatorCompleted(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
static int32_t getTableScannerExecInfo(struct SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) {
|
||||||
|
@ -837,7 +837,6 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
}
|
}
|
||||||
|
|
||||||
initLimitInfo(pTableScanNode->scan.node.pLimit, pTableScanNode->scan.node.pSlimit, &pInfo->limitInfo);
|
initLimitInfo(pTableScanNode->scan.node.pLimit, pTableScanNode->scan.node.pSlimit, &pInfo->limitInfo);
|
||||||
|
|
||||||
code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
code = initQueryTableDataCond(&pInfo->cond, pTableScanNode);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -885,7 +884,7 @@ SOperatorInfo* createTableScanOperatorInfo(STableScanPhysiNode* pTableScanNode,
|
||||||
pOperator->cost.openCost = 0;
|
pOperator->cost.openCost = 0;
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pInfo != NULL) {
|
if (pInfo != NULL) {
|
||||||
destroyTableScanOperatorInfo(pInfo);
|
destroyTableScanOperatorInfo(pInfo);
|
||||||
}
|
}
|
||||||
|
@ -1033,7 +1032,7 @@ SOperatorInfo* createDataBlockInfoScanOperator(void* dataReader, SReadHandle* re
|
||||||
createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, destroyBlockDistScanOperatorInfo, NULL);
|
createOperatorFpSet(operatorDummyOpenFn, doBlockInfoScan, NULL, NULL, destroyBlockDistScanOperatorInfo, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -1077,39 +1076,57 @@ void resetTableScanInfo(STableScanInfo* pTableScanInfo, STimeWindow* pWin) {
|
||||||
pTableScanInfo->cond.twindows = *pWin;
|
pTableScanInfo->cond.twindows = *pWin;
|
||||||
pTableScanInfo->scanTimes = 0;
|
pTableScanInfo->scanTimes = 0;
|
||||||
pTableScanInfo->currentGroupId = -1;
|
pTableScanInfo->currentGroupId = -1;
|
||||||
}
|
tsdbReaderClose(pTableScanInfo->dataReader);
|
||||||
|
pTableScanInfo->dataReader = NULL;
|
||||||
static void freeArray(void* array) { taosArrayDestroy(array); }
|
|
||||||
|
|
||||||
static void resetTableScanOperator(SOperatorInfo* pTableScanOp) {
|
|
||||||
STableScanInfo* pTableScanInfo = pTableScanOp->info;
|
|
||||||
pTableScanInfo->cond.startVersion = -1;
|
|
||||||
pTableScanInfo->cond.endVersion = -1;
|
|
||||||
SArray* gpTbls = pTableScanOp->pTaskInfo->tableqinfoList.pGroupList;
|
|
||||||
SArray* allTbls = pTableScanOp->pTaskInfo->tableqinfoList.pTableList;
|
|
||||||
taosArrayClearP(gpTbls, freeArray);
|
|
||||||
taosArrayPush(gpTbls, &allTbls);
|
|
||||||
STimeWindow win = {.skey = INT64_MIN, .ekey = INT64_MAX};
|
|
||||||
resetTableScanInfo(pTableScanOp->info, &win);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbUid, TSKEY startTs, TSKEY endTs,
|
static SSDataBlock* readPreVersionData(SOperatorInfo* pTableScanOp, uint64_t tbUid, TSKEY startTs, TSKEY endTs,
|
||||||
int64_t maxVersion) {
|
int64_t maxVersion) {
|
||||||
SArray* gpTbls = pTableScanOp->pTaskInfo->tableqinfoList.pGroupList;
|
|
||||||
taosArrayClear(gpTbls);
|
|
||||||
STableKeyInfo tblInfo = {.uid = tbUid, .groupId = 0};
|
STableKeyInfo tblInfo = {.uid = tbUid, .groupId = 0};
|
||||||
SArray* tbls = taosArrayInit(1, sizeof(STableKeyInfo));
|
|
||||||
taosArrayPush(tbls, &tblInfo);
|
|
||||||
taosArrayPush(gpTbls, &tbls);
|
|
||||||
|
|
||||||
STimeWindow win = {.skey = startTs, .ekey = endTs};
|
|
||||||
STableScanInfo* pTableScanInfo = pTableScanOp->info;
|
STableScanInfo* pTableScanInfo = pTableScanOp->info;
|
||||||
pTableScanInfo->cond.startVersion = -1;
|
SQueryTableDataCond cond = pTableScanInfo->cond;
|
||||||
pTableScanInfo->cond.endVersion = maxVersion;
|
|
||||||
resetTableScanInfo(pTableScanOp->info, &win);
|
cond.startVersion = -1;
|
||||||
SSDataBlock* pRes = doTableScan(pTableScanOp);
|
cond.endVersion = maxVersion;
|
||||||
resetTableScanOperator(pTableScanOp);
|
cond.twindows = (STimeWindow){.skey = startTs, .ekey = endTs};
|
||||||
return pRes;
|
|
||||||
|
SExecTaskInfo* pTaskInfo = pTableScanOp->pTaskInfo;
|
||||||
|
|
||||||
|
SSDataBlock* pBlock = pTableScanInfo->pResBlock;
|
||||||
|
blockDataCleanup(pBlock);
|
||||||
|
|
||||||
|
STsdbReader* pReader = NULL;
|
||||||
|
int32_t code = tsdbReaderOpen(pTableScanInfo->readHandle.vnode, &cond, &tblInfo, 1, (STsdbReader**)&pReader,
|
||||||
|
GET_TASKID(pTaskInfo));
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
terrno = code;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool hasBlock = tsdbNextDataBlock(pReader);
|
||||||
|
if (hasBlock) {
|
||||||
|
SDataBlockInfo binfo = {0};
|
||||||
|
tsdbRetrieveDataBlockInfo(pReader, &binfo);
|
||||||
|
|
||||||
|
SArray* pCols = tsdbRetrieveDataBlock(pReader, NULL);
|
||||||
|
blockDataEnsureCapacity(pBlock, binfo.rows);
|
||||||
|
|
||||||
|
pBlock->info.window = binfo.window;
|
||||||
|
pBlock->info.uid = binfo.uid;
|
||||||
|
pBlock->info.rows = binfo.rows;
|
||||||
|
|
||||||
|
relocateColumnData(pBlock, pTableScanInfo->matchInfo.pList, pCols, true);
|
||||||
|
doSetTagColumnData(pTableScanInfo, pBlock, pTaskInfo);
|
||||||
|
|
||||||
|
pBlock->info.groupId = getTableGroupId(&pTaskInfo->tableqinfoList, binfo.uid);
|
||||||
|
}
|
||||||
|
|
||||||
|
tsdbReaderClose(pReader);
|
||||||
|
qDebug("retrieve prev rows:%d, skey:%" PRId64 ", ekey:%" PRId64 " uid:%" PRIu64 ", max ver:%" PRId64
|
||||||
|
", suid:%" PRIu64, pBlock->info.rows, startTs, endTs, tbUid, maxVersion, cond.suid);
|
||||||
|
|
||||||
|
return pBlock->info.rows > 0 ? pBlock : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
||||||
|
@ -1122,12 +1139,13 @@ static uint64_t getGroupIdByCol(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts,
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
static uint64_t getGroupIdByUid(SStreamScanInfo* pInfo, uint64_t uid) {
|
||||||
SHashObj* map = pInfo->pTableScanOp->pTaskInfo->tableqinfoList.map;
|
return getTableGroupId(&pInfo->pTableScanOp->pTaskInfo->tableqinfoList, uid);
|
||||||
uint64_t* groupId = taosHashGet(map, &uid, sizeof(int64_t));
|
// SHashObj* map = pInfo->pTableScanOp->pTaskInfo->tableqinfoList.map;
|
||||||
if (groupId) {
|
// uint64_t* groupId = taosHashGet(map, &uid, sizeof(int64_t));
|
||||||
return *groupId;
|
// if (groupId) {
|
||||||
}
|
// return *groupId;
|
||||||
return 0;
|
// }
|
||||||
|
// return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
static uint64_t getGroupIdByData(SStreamScanInfo* pInfo, uint64_t uid, TSKEY ts, int64_t maxVersion) {
|
||||||
|
@ -1300,9 +1318,6 @@ static int32_t generateSessionScanRange(SStreamScanInfo* pInfo, SSDataBlock* pSr
|
||||||
SSessionKey startWin = {0};
|
SSessionKey startWin = {0};
|
||||||
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], endData[i], groupId, &startWin);
|
getCurSessionWindow(pInfo->windowSup.pStreamAggSup, startData[i], endData[i], groupId, &startWin);
|
||||||
if (IS_INVALID_SESSION_WIN_KEY(startWin)) {
|
if (IS_INVALID_SESSION_WIN_KEY(startWin)) {
|
||||||
// char* tmp = streamStateSessionDump(pInfo->windowSup.pStreamAggSup->pState);
|
|
||||||
// qInfo("%s", tmp);
|
|
||||||
// taosMemoryFree(tmp);
|
|
||||||
// window has been closed.
|
// window has been closed.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1549,12 +1564,7 @@ static int32_t setBlockIntoRes(SStreamScanInfo* pInfo, const SSDataBlock* pBlock
|
||||||
pInfo->pRes->info.type = STREAM_NORMAL;
|
pInfo->pRes->info.type = STREAM_NORMAL;
|
||||||
pInfo->pRes->info.version = pBlock->info.version;
|
pInfo->pRes->info.version = pBlock->info.version;
|
||||||
|
|
||||||
uint64_t* groupIdPre = taosHashGet(pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
pInfo->pRes->info.groupId = getTableGroupId(&pTaskInfo->tableqinfoList, pBlock->info.uid);
|
||||||
if (groupIdPre) {
|
|
||||||
pInfo->pRes->info.groupId = *groupIdPre;
|
|
||||||
} else {
|
|
||||||
pInfo->pRes->info.groupId = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// todo extract method
|
// todo extract method
|
||||||
for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
for (int32_t i = 0; i < taosArrayGetSize(pInfo->matchInfo.pList); ++i) {
|
||||||
|
@ -1847,7 +1857,7 @@ static SSDataBlock* doStreamScan(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
size_t total = taosArrayGetSize(pInfo->pBlockLists);
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
FETCH_NEXT_BLOCK:
|
FETCH_NEXT_BLOCK:
|
||||||
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
|
if (pInfo->blockType == STREAM_INPUT__DATA_BLOCK) {
|
||||||
if (pInfo->validBlockIndex >= total) {
|
if (pInfo->validBlockIndex >= total) {
|
||||||
doClearBufferedBlocks(pInfo);
|
doClearBufferedBlocks(pInfo);
|
||||||
|
@ -2229,7 +2239,7 @@ SOperatorInfo* createRawScanOperatorInfo(SReadHandle* pHandle, SExecTaskInfo* pT
|
||||||
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL);
|
pOperator->fpSet = createOperatorFpSet(NULL, doRawScan, NULL, NULL, destroyRawScanOperatorInfo, NULL);
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_end:
|
_end:
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
pTaskInfo->code = code;
|
pTaskInfo->code = code;
|
||||||
|
@ -2283,6 +2293,9 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
int32_t code =
|
int32_t code =
|
||||||
extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
extractColMatchInfo(pScanPhyNode->pScanCols, pDescNode, &numOfCols, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
int32_t numOfOutput = taosArrayGetSize(pInfo->matchInfo.pList);
|
||||||
SArray* pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
SArray* pColIds = taosArrayInit(numOfOutput, sizeof(int16_t));
|
||||||
|
@ -2335,12 +2348,16 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
pTSInfo->cond.endVersion = pHandle->version;
|
pTSInfo->cond.endVersion = pHandle->version;
|
||||||
}
|
}
|
||||||
|
|
||||||
SArray* tableList = taosArrayGetP(pTaskInfo->tableqinfoList.pGroupList, 0);
|
STableKeyInfo* pList = NULL;
|
||||||
|
int32_t num = 0;
|
||||||
|
getTablesOfGroup(&pTaskInfo->tableqinfoList, 0, &pList, &num);
|
||||||
|
|
||||||
if (pHandle->initTableReader) {
|
if (pHandle->initTableReader) {
|
||||||
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
pTSInfo->scanMode = TABLE_SCAN__TABLE_ORDER;
|
||||||
pTSInfo->dataReader = NULL;
|
pTSInfo->dataReader = NULL;
|
||||||
if (tsdbReaderOpen(pHandle->vnode, &pTSInfo->cond, tableList, &pTSInfo->dataReader, NULL) < 0) {
|
if (tsdbReaderOpen(pHandle->vnode, &pTSInfo->cond, pList, num, &pTSInfo->dataReader, NULL) < 0) {
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
destroyTableScanOperatorInfo(pTableScanOp);
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2367,7 +2384,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
// set the extract column id to streamHandle
|
// set the extract column id to streamHandle
|
||||||
tqReaderSetColIdList(pInfo->tqReader, pColIds);
|
tqReaderSetColIdList(pInfo->tqReader, pColIds);
|
||||||
SArray* tableIdList = extractTableIdList(&pTaskInfo->tableqinfoList);
|
SArray* tableIdList = extractTableIdList(&pTaskInfo->tableqinfoList);
|
||||||
int32_t code = tqReaderSetTbUidList(pInfo->tqReader, tableIdList);
|
code = tqReaderSetTbUidList(pInfo->tqReader, tableIdList);
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosArrayDestroy(tableIdList);
|
taosArrayDestroy(tableIdList);
|
||||||
goto _error;
|
goto _error;
|
||||||
|
@ -2411,7 +2428,7 @@ SOperatorInfo* createStreamScanOperatorInfo(SReadHandle* pHandle, STableScanPhys
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
if (pColIds != NULL) {
|
if (pColIds != NULL) {
|
||||||
taosArrayDestroy(pColIds);
|
taosArrayDestroy(pColIds);
|
||||||
}
|
}
|
||||||
|
@ -3316,6 +3333,7 @@ static int32_t optSysMergeRslt(SArray* mRslt, SArray* rslt) {
|
||||||
optSysIntersection(mRslt, rslt);
|
optSysIntersection(mRslt, rslt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t optSysSpecialColumn(SNode* cond) {
|
static int32_t optSysSpecialColumn(SNode* cond) {
|
||||||
SOperatorNode* pOper = (SOperatorNode*)cond;
|
SOperatorNode* pOper = (SOperatorNode*)cond;
|
||||||
SColumnNode* pCol = (SColumnNode*)pOper->pLeft;
|
SColumnNode* pCol = (SColumnNode*)pOper->pLeft;
|
||||||
|
@ -3326,6 +3344,7 @@ static int32_t optSysSpecialColumn(SNode* cond) {
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t optSysTabFilte(void* arg, SNode* cond, SArray* result) {
|
static int32_t optSysTabFilte(void* arg, SNode* cond, SArray* result) {
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
if (nodeType(cond) == QUERY_NODE_OPERATOR) {
|
if (nodeType(cond) == QUERY_NODE_OPERATOR) {
|
||||||
|
@ -3359,6 +3378,7 @@ static int32_t optSysTabFilte(void* arg, SNode* cond, SArray* result) {
|
||||||
if (cell == NULL) break;
|
if (cell == NULL) break;
|
||||||
|
|
||||||
SArray* aRslt = taosArrayInit(16, sizeof(int64_t));
|
SArray* aRslt = taosArrayInit(16, sizeof(int64_t));
|
||||||
|
|
||||||
ret = optSysTabFilteImpl(arg, cell->pNode, aRslt);
|
ret = optSysTabFilteImpl(arg, cell->pNode, aRslt);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
// has index
|
// has index
|
||||||
|
@ -3439,7 +3459,7 @@ static SSDataBlock* sysTableBuildUserTablesByUids(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
SMetaReader mr = {0};
|
SMetaReader mr = {0};
|
||||||
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
metaReaderInit(&mr, pInfo->readHandle.meta, 0);
|
||||||
int32_t ret = metaGetTableEntryByUid(&mr, *uid);
|
ret = metaGetTableEntryByUid(&mr, *uid);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
metaReaderClear(&mr);
|
metaReaderClear(&mr);
|
||||||
continue;
|
continue;
|
||||||
|
@ -4043,7 +4063,7 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* readHandle, SSystemTableScan
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
taosMemoryFreeClear(pInfo);
|
taosMemoryFreeClear(pInfo);
|
||||||
taosMemoryFreeClear(pOperator);
|
taosMemoryFreeClear(pOperator);
|
||||||
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_QRY_OUT_OF_MEMORY;
|
||||||
|
@ -4153,6 +4173,9 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs);
|
SExprInfo* pExprInfo = createExprInfo(pPhyNode->pScanPseudoCols, NULL, &numOfExprs);
|
||||||
int32_t code =
|
int32_t code =
|
||||||
extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
extractColMatchInfo(pPhyNode->pScanPseudoCols, pDescNode, &num, COL_MATCH_FROM_COL_ID, &pInfo->matchInfo);
|
||||||
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
goto _error;
|
||||||
|
}
|
||||||
|
|
||||||
code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs);
|
code = initExprSupp(&pOperator->exprSupp, pExprInfo, numOfExprs);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
|
@ -4179,7 +4202,7 @@ SOperatorInfo* createTagScanOperatorInfo(SReadHandle* pReadHandle, STagScanPhysi
|
||||||
|
|
||||||
return pOperator;
|
return pOperator;
|
||||||
|
|
||||||
_error:
|
_error:
|
||||||
taosMemoryFree(pInfo);
|
taosMemoryFree(pInfo);
|
||||||
taosMemoryFree(pOperator);
|
taosMemoryFree(pOperator);
|
||||||
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
terrno = TSDB_CODE_OUT_OF_MEMORY;
|
||||||
|
@ -4202,6 +4225,8 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pTableListInfo->numOfOuputGroups = 1;
|
||||||
|
|
||||||
int64_t st1 = taosGetTimestampUs();
|
int64_t st1 = taosGetTimestampUs();
|
||||||
qDebug("generate queried table list completed, elapsed time:%.2f ms %s", (st1 - st) / 1000.0, idStr);
|
qDebug("generate queried table list completed, elapsed time:%.2f ms %s", (st1 - st) / 1000.0, idStr);
|
||||||
|
|
||||||
|
@ -4210,8 +4235,7 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
pTableListInfo->needSortTableByGroupId = groupSort;
|
code = setGroupIdMapForAllTables(pTableListInfo, pHandle, pGroupTags, groupSort);
|
||||||
code = generateGroupIdMap(pTableListInfo, pHandle, pGroupTags);
|
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
@ -4225,14 +4249,10 @@ int32_t createScanTableListInfo(SScanPhysiNode* pScanNode, SNodeList* pGroupTags
|
||||||
int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, STableListInfo* pTableListInfo,
|
int32_t createMultipleDataReaders(SQueryTableDataCond* pQueryCond, SReadHandle* pHandle, STableListInfo* pTableListInfo,
|
||||||
int32_t tableStartIdx, int32_t tableEndIdx, SArray* arrayReader, const char* idstr) {
|
int32_t tableStartIdx, int32_t tableEndIdx, SArray* arrayReader, const char* idstr) {
|
||||||
for (int32_t i = tableStartIdx; i <= tableEndIdx; ++i) {
|
for (int32_t i = tableStartIdx; i <= tableEndIdx; ++i) {
|
||||||
SArray* subTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
STableKeyInfo* pList = taosArrayGet(pTableListInfo->pTableList, i);
|
||||||
taosArrayPush(subTableList, taosArrayGet(pTableListInfo->pTableList, i));
|
|
||||||
|
|
||||||
STsdbReader* pReader = NULL;
|
STsdbReader* pReader = NULL;
|
||||||
tsdbReaderOpen(pHandle->vnode, pQueryCond, subTableList, &pReader, idstr);
|
tsdbReaderOpen(pHandle->vnode, pQueryCond, pList, 1, &pReader, idstr);
|
||||||
taosArrayPush(arrayReader, &pReader);
|
taosArrayPush(arrayReader, &pReader);
|
||||||
|
|
||||||
taosArrayDestroy(subTableList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
|
@ -4242,15 +4262,14 @@ int32_t createMultipleDataReaders2(SQueryTableDataCond* pQueryCond, SReadHandle*
|
||||||
STableListInfo* pTableListInfo, int32_t tableStartIdx, int32_t tableEndIdx,
|
STableListInfo* pTableListInfo, int32_t tableStartIdx, int32_t tableEndIdx,
|
||||||
STsdbReader** ppReader, const char* idstr) {
|
STsdbReader** ppReader, const char* idstr) {
|
||||||
STsdbReader* pReader = NULL;
|
STsdbReader* pReader = NULL;
|
||||||
SArray* subTableList = taosArrayInit(1, sizeof(STableKeyInfo));
|
void* pStart = taosArrayGet(pTableListInfo->pTableList, tableStartIdx);
|
||||||
for (int32_t i = tableStartIdx; i <= tableEndIdx; ++i) {
|
int32_t num = tableEndIdx - tableStartIdx + 1;
|
||||||
taosArrayPush(subTableList, taosArrayGet(pTableListInfo->pTableList, i));
|
|
||||||
}
|
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, pStart, num, &pReader, idstr);
|
||||||
int32_t code = tsdbReaderOpen(pHandle->vnode, pQueryCond, subTableList, &pReader, idstr);
|
|
||||||
if (code != 0) {
|
if (code != 0) {
|
||||||
taosArrayDestroy(subTableList);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ppReader = pReader;
|
*ppReader = pReader;
|
||||||
return TSDB_CODE_SUCCESS;
|
return TSDB_CODE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -4405,8 +4424,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
||||||
|
|
||||||
bool allColumnsHaveAgg = true;
|
bool allColumnsHaveAgg = true;
|
||||||
SColumnDataAgg** pColAgg = NULL;
|
SColumnDataAgg** pColAgg = NULL;
|
||||||
STsdbReader* reader = taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
// STsdbReader* reader = pTableScanInfo->pReader; // taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
||||||
tsdbRetrieveDatablockSMA(reader, &pColAgg, &allColumnsHaveAgg);
|
|
||||||
|
|
||||||
if (allColumnsHaveAgg == true) {
|
if (allColumnsHaveAgg == true) {
|
||||||
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
int32_t numOfCols = taosArrayGetSize(pBlock->pDataBlock);
|
||||||
|
@ -4446,7 +4464,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
||||||
pCost->totalCheckedRows += pBlock->info.rows;
|
pCost->totalCheckedRows += pBlock->info.rows;
|
||||||
pCost->loadBlocks += 1;
|
pCost->loadBlocks += 1;
|
||||||
|
|
||||||
STsdbReader* reader = pTableScanInfo->pReader; // taosArrayGetP(pTableScanInfo->dataReaders, readerIdx);
|
STsdbReader* reader = pTableScanInfo->pReader;
|
||||||
SArray* pCols = tsdbRetrieveDataBlock(reader, NULL);
|
SArray* pCols = tsdbRetrieveDataBlock(reader, NULL);
|
||||||
if (pCols == NULL) {
|
if (pCols == NULL) {
|
||||||
return terrno;
|
return terrno;
|
||||||
|
@ -4485,7 +4503,7 @@ static int32_t loadDataBlockFromOneTable(SOperatorInfo* pOperator, STableMergeSc
|
||||||
typedef struct STableMergeScanSortSourceParam {
|
typedef struct STableMergeScanSortSourceParam {
|
||||||
SOperatorInfo* pOperator;
|
SOperatorInfo* pOperator;
|
||||||
int32_t readerIdx;
|
int32_t readerIdx;
|
||||||
int64_t uid;
|
uint64_t uid;
|
||||||
SSDataBlock* inputBlock;
|
SSDataBlock* inputBlock;
|
||||||
} STableMergeScanSortSourceParam;
|
} STableMergeScanSortSourceParam;
|
||||||
|
|
||||||
|
@ -4504,11 +4522,9 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
|
||||||
|
|
||||||
int64_t st = taosGetTimestampUs();
|
int64_t st = taosGetTimestampUs();
|
||||||
|
|
||||||
SArray* subTable = taosArrayInit(1, sizeof(STableKeyInfo));
|
void* p =taosArrayGet(pInfo->tableListInfo->pTableList, readIdx + pInfo->tableStartIndex);
|
||||||
taosArrayPush(subTable, taosArrayGet(pInfo->tableListInfo->pTableList, readIdx + pInfo->tableStartIndex));
|
|
||||||
SReadHandle* pHandle = &pInfo->readHandle;
|
SReadHandle* pHandle = &pInfo->readHandle;
|
||||||
tsdbReaderOpen(pHandle->vnode, pQueryCond, subTable, &pInfo->pReader, GET_TASKID(pTaskInfo));
|
tsdbReaderOpen(pHandle->vnode, pQueryCond, p, 1, &pInfo->pReader, GET_TASKID(pTaskInfo));
|
||||||
taosArrayDestroy(subTable);
|
|
||||||
|
|
||||||
STsdbReader* reader = pInfo->pReader;
|
STsdbReader* reader = pInfo->pReader;
|
||||||
while (tsdbNextDataBlock(reader)) {
|
while (tsdbNextDataBlock(reader)) {
|
||||||
|
@ -4532,7 +4548,7 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
|
||||||
pBlock->info.window = binfo.window;
|
pBlock->info.window = binfo.window;
|
||||||
pBlock->info.rows = binfo.rows;
|
pBlock->info.rows = binfo.rows;
|
||||||
|
|
||||||
if (tsdbIsAscendingOrder(pInfo->pReader)) {
|
if (pQueryCond->order == TSDB_ORDER_ASC) {
|
||||||
pQueryCond->twindows.skey = pBlock->info.window.ekey + 1;
|
pQueryCond->twindows.skey = pBlock->info.window.ekey + 1;
|
||||||
} else {
|
} else {
|
||||||
pQueryCond->twindows.ekey = pBlock->info.window.skey - 1;
|
pQueryCond->twindows.ekey = pBlock->info.window.skey - 1;
|
||||||
|
@ -4549,10 +4565,7 @@ static SSDataBlock* getTableDataBlockTemp(void* param) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
pBlock->info.groupId = getTableGroupId(&pOperator->pTaskInfo->tableqinfoList, pBlock->info.uid);
|
||||||
if (groupId) {
|
|
||||||
pBlock->info.groupId = *groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows += pBlock->info.rows; // pTableScanInfo->readRecorder.totalRows;
|
pOperator->resultInfo.totalRows += pBlock->info.rows; // pTableScanInfo->readRecorder.totalRows;
|
||||||
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
@ -4609,11 +4622,7 @@ static SSDataBlock* getTableDataBlock2(void* param) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
pBlock->info.groupId = getTableGroupId(&pOperator->pTaskInfo->tableqinfoList, pBlock->info.uid);
|
||||||
if (groupId) {
|
|
||||||
pBlock->info.groupId = *groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
||||||
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
|
||||||
|
@ -4657,6 +4666,7 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
|
|
||||||
uint32_t status = 0;
|
uint32_t status = 0;
|
||||||
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
int32_t code = loadDataBlockFromOneTable(pOperator, pTableScanInfo, readerIdx, pBlock, &status);
|
||||||
|
// int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status);
|
||||||
if (code != TSDB_CODE_SUCCESS) {
|
if (code != TSDB_CODE_SUCCESS) {
|
||||||
T_LONG_JMP(pOperator->pTaskInfo->env, code);
|
T_LONG_JMP(pOperator->pTaskInfo->env, code);
|
||||||
}
|
}
|
||||||
|
@ -4666,11 +4676,7 @@ static SSDataBlock* getTableDataBlock(void* param) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t* groupId = taosHashGet(pOperator->pTaskInfo->tableqinfoList.map, &pBlock->info.uid, sizeof(int64_t));
|
pBlock->info.groupId = getTableGroupId(&pOperator->pTaskInfo->tableqinfoList, pBlock->info.uid);
|
||||||
if (groupId) {
|
|
||||||
pBlock->info.groupId = *groupId;
|
|
||||||
}
|
|
||||||
|
|
||||||
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
pOperator->resultInfo.totalRows = pTableScanInfo->readRecorder.totalRows;
|
||||||
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
pTableScanInfo->readRecorder.elapsedTime += (taosGetTimestampUs() - st) / 1000.0;
|
||||||
|
|
||||||
|
@ -4707,6 +4713,7 @@ int32_t dumpSQueryTableCond(const SQueryTableDataCond* src, SQueryTableDataCond*
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
STableMergeScanInfo* pInfo = pOperator->info;
|
STableMergeScanInfo* pInfo = pOperator->info;
|
||||||
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
|
||||||
|
@ -4726,10 +4733,8 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
int32_t tableStartIdx = pInfo->tableStartIndex;
|
int32_t tableStartIdx = pInfo->tableStartIndex;
|
||||||
int32_t tableEndIdx = pInfo->tableEndIndex;
|
int32_t tableEndIdx = pInfo->tableEndIndex;
|
||||||
|
|
||||||
STableListInfo* tableListInfo = pInfo->tableListInfo;
|
|
||||||
|
|
||||||
// pInfo->dataReaders = taosArrayInit(64, POINTER_BYTES);
|
|
||||||
pInfo->pReader = NULL;
|
pInfo->pReader = NULL;
|
||||||
|
|
||||||
// todo the total available buffer should be determined by total capacity of buffer of this task.
|
// todo the total available buffer should be determined by total capacity of buffer of this task.
|
||||||
// the additional one is reserved for merge result
|
// the additional one is reserved for merge result
|
||||||
pInfo->sortBufSize = pInfo->bufPageSize * (tableEndIdx - tableStartIdx + 1 + 1);
|
pInfo->sortBufSize = pInfo->bufPageSize * (tableEndIdx - tableStartIdx + 1 + 1);
|
||||||
|
@ -4744,8 +4749,6 @@ int32_t startGroupTableMergeScan(SOperatorInfo* pOperator) {
|
||||||
pInfo->queryConds = taosArrayInit(numOfTable, sizeof(SQueryTableDataCond));
|
pInfo->queryConds = taosArrayInit(numOfTable, sizeof(SQueryTableDataCond));
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTable; ++i) {
|
for (int32_t i = 0; i < numOfTable; ++i) {
|
||||||
STableKeyInfo* tableKeyInfo = taosArrayGet(pInfo->tableListInfo->pTableList, i + tableStartIdx);
|
|
||||||
|
|
||||||
STableMergeScanSortSourceParam param = {0};
|
STableMergeScanSortSourceParam param = {0};
|
||||||
param.readerIdx = i;
|
param.readerIdx = i;
|
||||||
param.pOperator = pOperator;
|
param.pOperator = pOperator;
|
||||||
|
@ -4888,9 +4891,10 @@ void destroyTableMergeScanOperatorInfo(void* param) {
|
||||||
int32_t numOfTable = taosArrayGetSize(pTableScanInfo->queryConds);
|
int32_t numOfTable = taosArrayGetSize(pTableScanInfo->queryConds);
|
||||||
|
|
||||||
for (int32_t i = 0; i < numOfTable; i++) {
|
for (int32_t i = 0; i < numOfTable; i++) {
|
||||||
STableMergeScanSortSourceParam* param = taosArrayGet(pTableScanInfo->sortSourceParams, i);
|
STableMergeScanSortSourceParam* p = taosArrayGet(pTableScanInfo->sortSourceParams, i);
|
||||||
blockDataDestroy(param->inputBlock);
|
blockDataDestroy(p->inputBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pTableScanInfo->sortSourceParams);
|
taosArrayDestroy(pTableScanInfo->sortSourceParams);
|
||||||
|
|
||||||
tsdbReaderClose(pTableScanInfo->pReader);
|
tsdbReaderClose(pTableScanInfo->pReader);
|
||||||
|
@ -4955,10 +4959,6 @@ SOperatorInfo* createTableMergeScanOperatorInfo(STableScanPhysiNode* pTableScanN
|
||||||
goto _error;
|
goto _error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pTableScanNode->pGroupTags) {
|
|
||||||
taosArraySort(pTableListInfo->pTableList, compareTableKeyInfoByGid);
|
|
||||||
}
|
|
||||||
|
|
||||||
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
SDataBlockDescNode* pDescNode = pTableScanNode->scan.node.pOutputDataBlockDesc;
|
||||||
|
|
||||||
int32_t numOfCols = 0;
|
int32_t numOfCols = 0;
|
||||||
|
|
|
@ -5384,6 +5384,7 @@ static SSDataBlock* doStreamIntervalAgg(SOperatorInfo* pOperator) {
|
||||||
|
|
||||||
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
maxTs = TMAX(maxTs, pBlock->info.window.ekey);
|
||||||
minTs = TMIN(minTs, pBlock->info.window.skey);
|
minTs = TMIN(minTs, pBlock->info.window.skey);
|
||||||
|
|
||||||
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
|
doStreamIntervalAggImpl(pOperator, pBlock, pBlock->info.groupId, pUpdatedMap);
|
||||||
}
|
}
|
||||||
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
pInfo->twAggSup.maxTs = TMAX(pInfo->twAggSup.maxTs, maxTs);
|
||||||
|
|
|
@ -617,8 +617,6 @@ int tfileWriterPut(TFileWriter* tw, void* data, bool order) {
|
||||||
indexError("failed to write data: %s, offset: %d len: %d", v->colVal, v->offset,
|
indexError("failed to write data: %s, offset: %d len: %d", v->colVal, v->offset,
|
||||||
(int)taosArrayGetSize(v->tableId));
|
(int)taosArrayGetSize(v->tableId));
|
||||||
} else {
|
} else {
|
||||||
indexInfo("success to write data: %s, offset: %d len: %d", v->colVal, v->offset,
|
|
||||||
(int)taosArrayGetSize(v->tableId));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fstBuilderDestroy(tw->fb);
|
fstBuilderDestroy(tw->fb);
|
||||||
|
|
|
@ -31,10 +31,10 @@ extern "C" {
|
||||||
#define TIMER_MAX_MS 0x7FFFFFFF
|
#define TIMER_MAX_MS 0x7FFFFFFF
|
||||||
#define ENV_TICK_TIMER_MS 1000
|
#define ENV_TICK_TIMER_MS 1000
|
||||||
#define PING_TIMER_MS 5000
|
#define PING_TIMER_MS 5000
|
||||||
#define ELECT_TIMER_MS_MIN 5000
|
#define ELECT_TIMER_MS_MIN 2500
|
||||||
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
#define ELECT_TIMER_MS_MAX (ELECT_TIMER_MS_MIN * 2)
|
||||||
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
|
#define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN)
|
||||||
#define HEARTBEAT_TIMER_MS 900
|
#define HEARTBEAT_TIMER_MS 1000
|
||||||
|
|
||||||
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
|
#define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0})
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths);
|
||||||
static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId);
|
static void syncNodeEqPeerHeartbeatTimer(void* param, void* tmrId);
|
||||||
|
|
||||||
// process message ----
|
// process message ----
|
||||||
int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg);
|
int32_t syncNodeOnPing(SSyncNode* ths, SyncPing* pMsg);
|
||||||
int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg);
|
int32_t syncNodeOnPingReply(SSyncNode* ths, SyncPingReply* pMsg);
|
||||||
|
|
||||||
// ---------------------------------
|
// ---------------------------------
|
||||||
static void syncNodeFreeCb(void* param) {
|
static void syncNodeFreeCb(void* param) {
|
||||||
|
@ -1327,8 +1327,8 @@ SSyncNode* syncNodeOpen(SSyncInfo* pSyncInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// init callback
|
// init callback
|
||||||
pSyncNode->FpOnPing = syncNodeOnPingCb;
|
pSyncNode->FpOnPing = syncNodeOnPing;
|
||||||
pSyncNode->FpOnPingReply = syncNodeOnPingReplyCb;
|
pSyncNode->FpOnPingReply = syncNodeOnPingReply;
|
||||||
pSyncNode->FpOnClientRequest = syncNodeOnClientRequest;
|
pSyncNode->FpOnClientRequest = syncNodeOnClientRequest;
|
||||||
pSyncNode->FpOnTimeout = syncNodeOnTimer;
|
pSyncNode->FpOnTimeout = syncNodeOnTimer;
|
||||||
pSyncNode->FpOnSnapshot = syncNodeOnSnapshot;
|
pSyncNode->FpOnSnapshot = syncNodeOnSnapshot;
|
||||||
|
@ -3003,8 +3003,9 @@ static int32_t syncNodeAppendNoop(SSyncNode* ths) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// on message ----
|
// on message ----
|
||||||
int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
|
int32_t syncNodeOnPing(SSyncNode* ths, SyncPing* pMsg) {
|
||||||
// log state
|
sTrace("vgId:%d, recv sync-ping", ths->vgId);
|
||||||
|
|
||||||
SyncPingReply* pMsgReply = syncPingReplyBuild3(&ths->myRaftId, &pMsg->srcId, ths->vgId);
|
SyncPingReply* pMsgReply = syncPingReplyBuild3(&ths->myRaftId, &pMsg->srcId, ths->vgId);
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
syncPingReply2RpcMsg(pMsgReply, &rpcMsg);
|
syncPingReply2RpcMsg(pMsgReply, &rpcMsg);
|
||||||
|
@ -3014,7 +3015,7 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
|
||||||
SMsgHead* pHead = rpcMsg.pCont;
|
SMsgHead* pHead = rpcMsg.pCont;
|
||||||
pHead->contLen = htonl(pHead->contLen);
|
pHead->contLen = htonl(pHead->contLen);
|
||||||
pHead->vgId = htonl(pHead->vgId);
|
pHead->vgId = htonl(pHead->vgId);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
syncNodeSendMsgById(&pMsgReply->destId, ths, &rpcMsg);
|
syncNodeSendMsgById(&pMsgReply->destId, ths, &rpcMsg);
|
||||||
syncPingReplyDestroy(pMsgReply);
|
syncPingReplyDestroy(pMsgReply);
|
||||||
|
@ -3022,9 +3023,9 @@ int32_t syncNodeOnPingCb(SSyncNode* ths, SyncPing* pMsg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t syncNodeOnPingReplyCb(SSyncNode* ths, SyncPingReply* pMsg) {
|
int32_t syncNodeOnPingReply(SSyncNode* ths, SyncPingReply* pMsg) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
syncPingReplyLog2("==syncNodeOnPingReplyCb==", pMsg);
|
sTrace("vgId:%d, recv sync-ping-reply", ths->vgId);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3375,8 +3376,12 @@ int32_t syncNodeDoCommit(SSyncNode* ths, SyncIndex beginIndex, SyncIndex endInde
|
||||||
pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h);
|
pEntry = (SSyncRaftEntry*)taosLRUCacheValue(pCache, h);
|
||||||
} else {
|
} else {
|
||||||
code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry);
|
code = ths->pLogStore->syncLogGetEntry(ths->pLogStore, i, &pEntry);
|
||||||
ASSERT(code == 0);
|
// ASSERT(code == 0);
|
||||||
ASSERT(pEntry != NULL);
|
// ASSERT(pEntry != NULL);
|
||||||
|
if (code != 0 || pEntry == NULL) {
|
||||||
|
syncNodeErrorLog(ths, "get log entry error");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SRpcMsg rpcMsg;
|
SRpcMsg rpcMsg;
|
||||||
|
|
|
@ -3095,3 +3095,153 @@ void syncReconfigFinishLog2(char* s, const SyncReconfigFinish* pMsg) {
|
||||||
taosMemoryFree(serialized);
|
taosMemoryFree(serialized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------
|
||||||
|
SyncLocalCmd* syncLocalCmdBuild(int32_t vgId) {
|
||||||
|
uint32_t bytes = sizeof(SyncLocalCmd);
|
||||||
|
SyncLocalCmd* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
memset(pMsg, 0, bytes);
|
||||||
|
pMsg->bytes = bytes;
|
||||||
|
pMsg->vgId = vgId;
|
||||||
|
pMsg->msgType = TDMT_SYNC_LOCAL_CMD;
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdDestroy(SyncLocalCmd* pMsg) {
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
taosMemoryFree(pMsg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdSerialize(const SyncLocalCmd* pMsg, char* buf, uint32_t bufLen) {
|
||||||
|
ASSERT(pMsg->bytes <= bufLen);
|
||||||
|
memcpy(buf, pMsg, pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdDeserialize(const char* buf, uint32_t len, SyncLocalCmd* pMsg) {
|
||||||
|
memcpy(pMsg, buf, len);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncLocalCmdSerialize2(const SyncLocalCmd* pMsg, uint32_t* len) {
|
||||||
|
char* buf = taosMemoryMalloc(pMsg->bytes);
|
||||||
|
ASSERT(buf != NULL);
|
||||||
|
syncLocalCmdSerialize(pMsg, buf, pMsg->bytes);
|
||||||
|
if (len != NULL) {
|
||||||
|
*len = pMsg->bytes;
|
||||||
|
}
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncLocalCmd* syncLocalCmdDeserialize2(const char* buf, uint32_t len) {
|
||||||
|
uint32_t bytes = *((uint32_t*)buf);
|
||||||
|
SyncLocalCmd* pMsg = taosMemoryMalloc(bytes);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
syncLocalCmdDeserialize(buf, len, pMsg);
|
||||||
|
ASSERT(len == pMsg->bytes);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmd2RpcMsg(const SyncLocalCmd* pMsg, SRpcMsg* pRpcMsg) {
|
||||||
|
memset(pRpcMsg, 0, sizeof(*pRpcMsg));
|
||||||
|
pRpcMsg->msgType = pMsg->msgType;
|
||||||
|
pRpcMsg->contLen = pMsg->bytes;
|
||||||
|
pRpcMsg->pCont = rpcMallocCont(pRpcMsg->contLen);
|
||||||
|
syncLocalCmdSerialize(pMsg, pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdFromRpcMsg(const SRpcMsg* pRpcMsg, SyncLocalCmd* pMsg) {
|
||||||
|
syncLocalCmdDeserialize(pRpcMsg->pCont, pRpcMsg->contLen, pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncLocalCmd* syncLocalCmdFromRpcMsg2(const SRpcMsg* pRpcMsg) {
|
||||||
|
SyncLocalCmd* pMsg = syncLocalCmdDeserialize2(pRpcMsg->pCont, pRpcMsg->contLen);
|
||||||
|
ASSERT(pMsg != NULL);
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* syncLocalCmd2Json(const SyncLocalCmd* pMsg) {
|
||||||
|
char u64buf[128];
|
||||||
|
cJSON* pRoot = cJSON_CreateObject();
|
||||||
|
|
||||||
|
if (pMsg != NULL) {
|
||||||
|
cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "vgId", pMsg->vgId);
|
||||||
|
cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType);
|
||||||
|
|
||||||
|
cJSON* pSrcId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->srcId.addr);
|
||||||
|
cJSON_AddStringToObject(pSrcId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->srcId.addr;
|
||||||
|
cJSON* pTmp = pSrcId;
|
||||||
|
char host[128];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "srcId", pSrcId);
|
||||||
|
|
||||||
|
cJSON* pDestId = cJSON_CreateObject();
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->destId.addr);
|
||||||
|
cJSON_AddStringToObject(pDestId, "addr", u64buf);
|
||||||
|
{
|
||||||
|
uint64_t u64 = pMsg->destId.addr;
|
||||||
|
cJSON* pTmp = pDestId;
|
||||||
|
char host[128];
|
||||||
|
uint16_t port;
|
||||||
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
|
cJSON_AddStringToObject(pTmp, "addr_host", host);
|
||||||
|
cJSON_AddNumberToObject(pTmp, "addr_port", port);
|
||||||
|
}
|
||||||
|
cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId);
|
||||||
|
cJSON_AddItemToObject(pRoot, "destId", pDestId);
|
||||||
|
|
||||||
|
cJSON_AddNumberToObject(pRoot, "cmd", pMsg->cmd);
|
||||||
|
|
||||||
|
snprintf(u64buf, sizeof(u64buf), "%" PRIu64, pMsg->sdNewTerm);
|
||||||
|
cJSON_AddStringToObject(pRoot, "sd-new-term", u64buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
cJSON* pJson = cJSON_CreateObject();
|
||||||
|
cJSON_AddItemToObject(pJson, "SyncLocalCmd2Json", pRoot);
|
||||||
|
return pJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
char* syncLocalCmd2Str(const SyncLocalCmd* pMsg) {
|
||||||
|
cJSON* pJson = syncLocalCmd2Json(pMsg);
|
||||||
|
char* serialized = cJSON_Print(pJson);
|
||||||
|
cJSON_Delete(pJson);
|
||||||
|
return serialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
// for debug ----------------------
|
||||||
|
void syncLocalCmdPrint(const SyncLocalCmd* pMsg) {
|
||||||
|
char* serialized = syncLocalCmd2Str(pMsg);
|
||||||
|
printf("syncLocalCmdPrint | len:%d | %s \n", (int32_t)strlen(serialized), serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdPrint2(char* s, const SyncLocalCmd* pMsg) {
|
||||||
|
char* serialized = syncLocalCmd2Str(pMsg);
|
||||||
|
printf("syncLocalCmdPrint2 | len:%d | %s | %s \n", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
fflush(NULL);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdLog(const SyncLocalCmd* pMsg) {
|
||||||
|
char* serialized = syncLocalCmd2Str(pMsg);
|
||||||
|
sTrace("syncLocalCmdLog | len:%d | %s", (int32_t)strlen(serialized), serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
|
||||||
|
void syncLocalCmdLog2(char* s, const SyncLocalCmd* pMsg) {
|
||||||
|
if (gRaftDetailLog) {
|
||||||
|
char* serialized = syncLocalCmd2Str(pMsg);
|
||||||
|
sTrace("syncLocalCmdLog2 | len:%d | %s | %s", (int32_t)strlen(serialized), s, serialized);
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
}
|
||||||
|
}
|
|
@ -57,7 +57,7 @@ int32_t syncNodeReplicateOne(SSyncNode* pSyncNode, SRaftId* pDestId) {
|
||||||
SyncIndex logEndIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore);
|
SyncIndex logEndIndex = pSyncNode->pLogStore->syncLogEndIndex(pSyncNode->pLogStore);
|
||||||
if (nextIndex < logStartIndex || nextIndex - 1 > logEndIndex) {
|
if (nextIndex < logStartIndex || nextIndex - 1 > logEndIndex) {
|
||||||
char logBuf[128];
|
char logBuf[128];
|
||||||
snprintf(logBuf, sizeof(logBuf), "start snapshot for next-index:%" PRId64 ", start:%" PRId64 ", end:%" PRId64,
|
snprintf(logBuf, sizeof(logBuf), "maybe start snapshot for next-index:%" PRId64 ", start:%" PRId64 ", end:%" PRId64,
|
||||||
nextIndex, logStartIndex, logEndIndex);
|
nextIndex, logStartIndex, logEndIndex);
|
||||||
syncNodeEventLog(pSyncNode, logBuf);
|
syncNodeEventLog(pSyncNode, logBuf);
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ add_executable(syncRestoreFromSnapshot "")
|
||||||
add_executable(syncRaftCfgIndexTest "")
|
add_executable(syncRaftCfgIndexTest "")
|
||||||
add_executable(syncHeartbeatTest "")
|
add_executable(syncHeartbeatTest "")
|
||||||
add_executable(syncHeartbeatReplyTest "")
|
add_executable(syncHeartbeatReplyTest "")
|
||||||
|
add_executable(syncLocalCmdTest "")
|
||||||
|
|
||||||
|
|
||||||
target_sources(syncTest
|
target_sources(syncTest
|
||||||
|
@ -305,6 +306,10 @@ target_sources(syncHeartbeatReplyTest
|
||||||
PRIVATE
|
PRIVATE
|
||||||
"syncHeartbeatReplyTest.cpp"
|
"syncHeartbeatReplyTest.cpp"
|
||||||
)
|
)
|
||||||
|
target_sources(syncLocalCmdTest
|
||||||
|
PRIVATE
|
||||||
|
"syncLocalCmdTest.cpp"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
target_include_directories(syncTest
|
target_include_directories(syncTest
|
||||||
|
@ -612,6 +617,11 @@ target_include_directories(syncHeartbeatReplyTest
|
||||||
"${TD_SOURCE_DIR}/include/libs/sync"
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
)
|
)
|
||||||
|
target_include_directories(syncLocalCmdTest
|
||||||
|
PUBLIC
|
||||||
|
"${TD_SOURCE_DIR}/include/libs/sync"
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/../inc"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries(syncTest
|
target_link_libraries(syncTest
|
||||||
|
@ -858,6 +868,10 @@ target_link_libraries(syncHeartbeatReplyTest
|
||||||
sync
|
sync
|
||||||
gtest_main
|
gtest_main
|
||||||
)
|
)
|
||||||
|
target_link_libraries(syncLocalCmdTest
|
||||||
|
sync
|
||||||
|
gtest_main
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
|
@ -270,7 +270,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
|
||||||
pMsg->msgType = 9999;
|
pMsg->msgType = 9999;
|
||||||
pMsg->contLen = 256;
|
pMsg->contLen = 256;
|
||||||
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
||||||
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count,
|
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%" PRId64, myIndex, i, count,
|
||||||
taosGetTimestampMs());
|
taosGetTimestampMs());
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
|
||||||
pMsg->msgType = 9999;
|
pMsg->msgType = 9999;
|
||||||
pMsg->contLen = 256;
|
pMsg->contLen = 256;
|
||||||
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
||||||
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count,
|
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%" PRId64, myIndex, i, count,
|
||||||
taosGetTimestampMs());
|
taosGetTimestampMs());
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -186,7 +186,7 @@ int main(int argc, char **argv) {
|
||||||
int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, pEntry->index, &pEntry);
|
int32_t code = pSyncNode->pLogStore->syncLogGetEntry(pSyncNode->pLogStore, pEntry->index, &pEntry);
|
||||||
ASSERT(code == 0);
|
ASSERT(code == 0);
|
||||||
|
|
||||||
syncEntryLog2((char *)"==pEntry2==", pEntry2);
|
syncEntryLog2((char *)"==pEntry==", pEntry);
|
||||||
|
|
||||||
// step5
|
// step5
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
|
|
|
@ -13,7 +13,7 @@ void print(SHashObj *pNextIndex) {
|
||||||
|
|
||||||
SRaftId *pRaftId = (SRaftId *)key;
|
SRaftId *pRaftId = (SRaftId *)key;
|
||||||
|
|
||||||
printf("key:<" PRIu64 ", %d>, value:%" PRIu64 " \n", pRaftId->addr, pRaftId->vgId, *p);
|
printf("key:<%" PRIu64 ", %d>, value:%" PRIu64 " \n", pRaftId->addr, pRaftId->vgId, *p);
|
||||||
p = (uint64_t *)taosHashIterate(pNextIndex, p);
|
p = (uint64_t *)taosHashIterate(pNextIndex, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,100 @@
|
||||||
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include "syncIO.h"
|
||||||
|
#include "syncInt.h"
|
||||||
|
#include "syncMessage.h"
|
||||||
|
#include "syncUtil.h"
|
||||||
|
|
||||||
|
void logTest() {
|
||||||
|
sTrace("--- sync log test: trace");
|
||||||
|
sDebug("--- sync log test: debug");
|
||||||
|
sInfo("--- sync log test: info");
|
||||||
|
sWarn("--- sync log test: warn");
|
||||||
|
sError("--- sync log test: error");
|
||||||
|
sFatal("--- sync log test: fatal");
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncLocalCmd *createMsg() {
|
||||||
|
SyncLocalCmd *pMsg = syncLocalCmdBuild(1000);
|
||||||
|
pMsg->srcId.addr = syncUtilAddr2U64("127.0.0.1", 1234);
|
||||||
|
pMsg->srcId.vgId = 100;
|
||||||
|
pMsg->destId.addr = syncUtilAddr2U64("127.0.0.1", 5678);
|
||||||
|
pMsg->destId.vgId = 100;
|
||||||
|
pMsg->sdNewTerm = 123;
|
||||||
|
pMsg->cmd = SYNC_LOCAL_CMD_STEP_DOWN;
|
||||||
|
|
||||||
|
return pMsg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void test1() {
|
||||||
|
SyncLocalCmd *pMsg = createMsg();
|
||||||
|
syncLocalCmdLog2((char *)"test1:", pMsg);
|
||||||
|
syncLocalCmdDestroy(pMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test2() {
|
||||||
|
SyncLocalCmd *pMsg = createMsg();
|
||||||
|
uint32_t len = pMsg->bytes;
|
||||||
|
char *serialized = (char *)taosMemoryMalloc(len);
|
||||||
|
syncLocalCmdSerialize(pMsg, serialized, len);
|
||||||
|
SyncLocalCmd *pMsg2 = syncLocalCmdBuild(1000);
|
||||||
|
syncLocalCmdDeserialize(serialized, len, pMsg2);
|
||||||
|
syncLocalCmdLog2((char *)"test2: syncLocalCmdSerialize -> syncLocalCmdDeserialize ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncLocalCmdDestroy(pMsg);
|
||||||
|
syncLocalCmdDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test3() {
|
||||||
|
SyncLocalCmd *pMsg = createMsg();
|
||||||
|
uint32_t len;
|
||||||
|
char *serialized = syncLocalCmdSerialize2(pMsg, &len);
|
||||||
|
SyncLocalCmd *pMsg2 = syncLocalCmdDeserialize2(serialized, len);
|
||||||
|
syncLocalCmdLog2((char *)"test3: syncLocalCmdSerialize3 -> syncLocalCmdDeserialize2 ", pMsg2);
|
||||||
|
|
||||||
|
taosMemoryFree(serialized);
|
||||||
|
syncLocalCmdDestroy(pMsg);
|
||||||
|
syncLocalCmdDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test4() {
|
||||||
|
SyncLocalCmd *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncLocalCmd2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncLocalCmd *pMsg2 = (SyncLocalCmd *)taosMemoryMalloc(rpcMsg.contLen);
|
||||||
|
syncLocalCmdFromRpcMsg(&rpcMsg, pMsg2);
|
||||||
|
syncLocalCmdLog2((char *)"test4: syncLocalCmd2RpcMsg -> syncLocalCmdFromRpcMsg ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncLocalCmdDestroy(pMsg);
|
||||||
|
syncLocalCmdDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test5() {
|
||||||
|
SyncLocalCmd *pMsg = createMsg();
|
||||||
|
SRpcMsg rpcMsg;
|
||||||
|
syncLocalCmd2RpcMsg(pMsg, &rpcMsg);
|
||||||
|
SyncLocalCmd *pMsg2 = syncLocalCmdFromRpcMsg2(&rpcMsg);
|
||||||
|
syncLocalCmdLog2((char *)"test5: syncLocalCmd2RpcMsg -> syncLocalCmdFromRpcMsg2 ", pMsg2);
|
||||||
|
|
||||||
|
rpcFreeCont(rpcMsg.pCont);
|
||||||
|
syncLocalCmdDestroy(pMsg);
|
||||||
|
syncLocalCmdDestroy(pMsg2);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
gRaftDetailLog = true;
|
||||||
|
|
||||||
|
tsAsyncLog = 0;
|
||||||
|
sDebugFlag = DEBUG_TRACE + DEBUG_SCREEN + DEBUG_FILE;
|
||||||
|
logTest();
|
||||||
|
|
||||||
|
test1();
|
||||||
|
test2();
|
||||||
|
test3();
|
||||||
|
test4();
|
||||||
|
test5();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -15,7 +15,7 @@ int main(int argc, char** argv) {
|
||||||
char host[128];
|
char host[128];
|
||||||
uint16_t port;
|
uint16_t port;
|
||||||
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
syncUtilU642Addr(u64, host, sizeof(host), &port);
|
||||||
printf("" PRIu64 " -> %s:%d \n", u64, host, port);
|
printf("%" PRIu64 " -> %s:%d \n", u64, host, port);
|
||||||
|
|
||||||
} else if (argc == 3) {
|
} else if (argc == 3) {
|
||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
|
|
|
@ -97,8 +97,8 @@ void test1() {
|
||||||
sTrace("lastIndex: %" PRId64, lastIndex);
|
sTrace("lastIndex: %" PRId64, lastIndex);
|
||||||
sTrace("lastTerm: %" PRIu64, lastTerm);
|
sTrace("lastTerm: %" PRIu64, lastTerm);
|
||||||
sTrace("syncStartIndex: %" PRId64, syncStartIndex);
|
sTrace("syncStartIndex: %" PRId64, syncStartIndex);
|
||||||
sTrace("" PRId64 "'s preIndex: %" PRId64, testIndex, preIndex);
|
sTrace("testIndex: %" PRId64 " preIndex: %" PRId64, testIndex, preIndex);
|
||||||
sTrace("" PRId64 "'s preTerm: %" PRIu64, testIndex, preTerm);
|
sTrace("testIndex: %" PRId64 " preTerm: %" PRIu64, testIndex, preTerm);
|
||||||
|
|
||||||
if (gAssert) {
|
if (gAssert) {
|
||||||
assert(lastIndex == -1);
|
assert(lastIndex == -1);
|
||||||
|
@ -170,8 +170,8 @@ void test2() {
|
||||||
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
||||||
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
||||||
|
|
||||||
sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex);
|
sTrace("i: %" PRId64 " preIndex: %" PRId64, i, preIndex);
|
||||||
sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm);
|
sTrace("i: %" PRId64 " preTerm: %" PRIu64, i, preTerm);
|
||||||
|
|
||||||
if (gAssert) {
|
if (gAssert) {
|
||||||
SyncIndex preIndexArr[12] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
SyncIndex preIndexArr[12] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
|
||||||
|
@ -292,8 +292,8 @@ void test4() {
|
||||||
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
||||||
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
||||||
|
|
||||||
sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex);
|
sTrace("i: %" PRId64 " preIndex: %" PRId64, i, preIndex);
|
||||||
sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm);
|
sTrace("i: %" PRId64 " preTerm: %" PRIu64, i, preTerm);
|
||||||
}
|
}
|
||||||
|
|
||||||
logStoreDestory(pLogStore);
|
logStoreDestory(pLogStore);
|
||||||
|
@ -354,8 +354,8 @@ void test5() {
|
||||||
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
SyncIndex preIndex = syncNodeGetPreIndex(pSyncNode, i);
|
||||||
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
SyncTerm preTerm = syncNodeGetPreTerm(pSyncNode, i);
|
||||||
|
|
||||||
sTrace("" PRId64 "'s preIndex: %" PRId64, i, preIndex);
|
sTrace("i: %" PRId64 " preIndex: %" PRId64, i, preIndex);
|
||||||
sTrace("" PRId64 "'s preTerm: %" PRIu64, i, preTerm);
|
sTrace("i: %" PRId64 " preTerm: %" PRIu64, i, preTerm);
|
||||||
|
|
||||||
if (gAssert) {
|
if (gAssert) {
|
||||||
SyncIndex preIndexArr[12] = {9999, 9999, 9999, 9999, 9999, 9999, 5, 6, 7, 8, 9, 10};
|
SyncIndex preIndexArr[12] = {9999, 9999, 9999, 9999, 9999, 9999, 5, 6, 7, 8, 9, 10};
|
||||||
|
|
|
@ -145,7 +145,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
|
||||||
pMsg->msgType = 9999;
|
pMsg->msgType = 9999;
|
||||||
pMsg->contLen = 256;
|
pMsg->contLen = 256;
|
||||||
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
||||||
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count,
|
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%" PRId64, myIndex, i, count,
|
||||||
taosGetTimestampMs());
|
taosGetTimestampMs());
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,18 +58,18 @@ void syncRespMgrGetTest(uint64_t i) {
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
printStub(&stub);
|
printStub(&stub);
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
printf("" PRId64 " notFound \n", i);
|
printf("%" PRId64 " notFound \n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void syncRespMgrGetAndDelTest(uint64_t i) {
|
void syncRespMgrGetAndDelTest(uint64_t i) {
|
||||||
printf("------syncRespMgrGetAndDelTest-------" PRIu64 "-- \n", i);
|
printf("------syncRespMgrGetAndDelTest-------%" PRIu64 "-- \n", i);
|
||||||
SRespStub stub;
|
SRespStub stub;
|
||||||
int32_t ret = syncRespMgrGetAndDel(pMgr, i, &stub);
|
int32_t ret = syncRespMgrGetAndDel(pMgr, i, &stub);
|
||||||
if (ret == 1) {
|
if (ret == 1) {
|
||||||
printStub(&stub);
|
printStub(&stub);
|
||||||
} else if (ret == 0) {
|
} else if (ret == 0) {
|
||||||
printf("" PRId64 " notFound \n", i);
|
printf("%" PRId64 " notFound \n", i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ int32_t SnapshotDoWrite(struct SSyncFSM* pFsm, void* pWriter, void* pBuf, int32_
|
||||||
void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb== pFsm:%p", pFsm); }
|
void RestoreFinishCb(struct SSyncFSM* pFsm) { sTrace("==callback== ==RestoreFinishCb== pFsm:%p", pFsm); }
|
||||||
|
|
||||||
void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) {
|
void ReConfigCb(struct SSyncFSM* pFsm, const SRpcMsg* pMsg, SReConfigCbMeta* cbMeta) {
|
||||||
char* s = syncCfg2Str(&(cbMeta.newCfg));
|
char* s = syncCfg2Str(&(cbMeta->newCfg));
|
||||||
sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64
|
sTrace("==callback== ==ReConfigCb== flag:0x%lX, index:%" PRId64 ", code:%d, currentTerm:%" PRIu64 ", term:%" PRIu64
|
||||||
", newCfg:%s",
|
", newCfg:%s",
|
||||||
cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term, s);
|
cbMeta->flag, cbMeta->index, cbMeta->code, cbMeta->currentTerm, cbMeta->term, s);
|
||||||
|
@ -308,7 +308,7 @@ SRpcMsg* createRpcMsg(int i, int count, int myIndex) {
|
||||||
pMsg->msgType = TDMT_VND_SUBMIT;
|
pMsg->msgType = TDMT_VND_SUBMIT;
|
||||||
pMsg->contLen = 256;
|
pMsg->contLen = 256;
|
||||||
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
pMsg->pCont = rpcMallocCont(pMsg->contLen);
|
||||||
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-" PRId64, myIndex, i, count,
|
snprintf((char*)(pMsg->pCont), pMsg->contLen, "value-myIndex:%u-%d-%d-%" PRId64, myIndex, i, count,
|
||||||
taosGetTimestampMs());
|
taosGetTimestampMs());
|
||||||
return pMsg;
|
return pMsg;
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(TfsTest, 01_Open_Close) {
|
||||||
STfs *pTfs = tfsOpen(&dCfg, 1);
|
STfs *pTfs = tfsOpen(&dCfg, 1);
|
||||||
ASSERT_EQ(pTfs, nullptr);
|
ASSERT_EQ(pTfs, nullptr);
|
||||||
|
|
||||||
taosMkDir(root);
|
taosMulMkDir(root);
|
||||||
pTfs = tfsOpen(&dCfg, 1);
|
pTfs = tfsOpen(&dCfg, 1);
|
||||||
ASSERT_NE(pTfs, nullptr);
|
ASSERT_NE(pTfs, nullptr);
|
||||||
|
|
||||||
|
|
|
@ -655,7 +655,7 @@ void uvOnAcceptCb(uv_stream_t* stream, int status) {
|
||||||
uv_tcp_init(pObj->loop, cli);
|
uv_tcp_init(pObj->loop, cli);
|
||||||
|
|
||||||
if (uv_accept(stream, (uv_stream_t*)cli) == 0) {
|
if (uv_accept(stream, (uv_stream_t*)cli) == 0) {
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
if (pObj->numOfWorkerReady < pObj->numOfThreads) {
|
if (pObj->numOfWorkerReady < pObj->numOfThreads) {
|
||||||
tError("worker-threads are not ready for all, need %d instead of %d.", pObj->numOfThreads,
|
tError("worker-threads are not ready for all, need %d instead of %d.", pObj->numOfThreads,
|
||||||
pObj->numOfWorkerReady);
|
pObj->numOfWorkerReady);
|
||||||
|
@ -779,7 +779,7 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||||
#else
|
#else
|
||||||
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
uv_pipe_init(pThrd->loop, pThrd->pipe, 1);
|
||||||
|
@ -799,7 +799,7 @@ static bool addHandleToWorkloop(SWorkThrd* pThrd, char* pipeName) {
|
||||||
QUEUE_INIT(&pThrd->conn);
|
QUEUE_INIT(&pThrd->conn);
|
||||||
|
|
||||||
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 5, pThrd, uvWorkerAsyncCb);
|
pThrd->asyncPool = transAsyncPoolCreate(pThrd->loop, 5, pThrd, uvWorkerAsyncCb);
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb);
|
uv_pipe_connect(&pThrd->connect_req, pThrd->pipe, pipeName, uvOnPipeConnectionCb);
|
||||||
#else
|
#else
|
||||||
uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb);
|
uv_read_start((uv_stream_t*)pThrd->pipe, uvAllocConnBufferCb, uvOnConnectionCb);
|
||||||
|
@ -976,17 +976,18 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
uv_loop_init(srv->loop);
|
uv_loop_init(srv->loop);
|
||||||
|
|
||||||
char pipeName[PATH_MAX];
|
char pipeName[PATH_MAX];
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(DARWIN)
|
||||||
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
int ret = uv_pipe_init(srv->loop, &srv->pipeListen, 0);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
tError("failed to init pipe, errmsg: %s", uv_err_name(ret));
|
tError("failed to init pipe, errmsg: %s", uv_err_name(ret));
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
#if defined(WINDOWS)
|
||||||
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%d-%" PRIu64, taosSafeRand(), GetCurrentProcessId());
|
snprintf(pipeName, sizeof(pipeName), "\\\\?\\pipe\\trans.rpc.%d-%" PRIu64, taosSafeRand(), GetCurrentProcessId());
|
||||||
// char pipeName[PATH_MAX] = {0};
|
#elif defined(DARWIN)
|
||||||
// snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08d-%" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(),
|
snprintf(pipeName, sizeof(pipeName), "%s%spipe.trans.rpc.%08d-%" PRIu64, tsTempDir, TD_DIRSEP, taosSafeRand(),
|
||||||
// taosGetSelfPthreadId());
|
taosGetSelfPthreadId());
|
||||||
|
#endif
|
||||||
|
|
||||||
ret = uv_pipe_bind(&srv->pipeListen, pipeName);
|
ret = uv_pipe_bind(&srv->pipeListen, pipeName);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
|
@ -1036,7 +1037,7 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
srv->pThreadObj[i] = thrd;
|
srv->pThreadObj[i] = thrd;
|
||||||
|
|
||||||
uv_os_sock_t fds[2];
|
uv_os_sock_t fds[2];
|
||||||
if (uv_socketpair(AF_UNIX, SOCK_STREAM, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE) != 0) {
|
if (uv_socketpair(SOCK_STREAM, 0, fds, UV_NONBLOCK_PIPE, UV_NONBLOCK_PIPE) != 0) {
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1059,8 +1060,8 @@ void* transInitServer(uint32_t ip, uint32_t port, char* label, int numOfThreads,
|
||||||
goto End;
|
goto End;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
if (false == taosValidIpAndPort(srv->ip, srv->port)) {
|
||||||
terrno = TAOS_SYSTEM_ERROR(errno);
|
terrno = TAOS_SYSTEM_ERROR(errno);
|
||||||
tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr());
|
tError("invalid ip/port, %d:%d, reason:%s", srv->ip, srv->port, terrstr());
|
||||||
|
|
|
@ -46,7 +46,7 @@ class TDTestCase:
|
||||||
|
|
||||||
def init(self, conn, logSql):
|
def init(self, conn, logSql):
|
||||||
tdLog.debug(f"start to excute {__file__}")
|
tdLog.debug(f"start to excute {__file__}")
|
||||||
tdSql.init(conn.cursor(), False)
|
tdSql.init(conn.cursor(), True)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def create_databases_sql_err(self):
|
def create_databases_sql_err(self):
|
||||||
|
|
|
@ -86,8 +86,33 @@ ELSE ()
|
||||||
)
|
)
|
||||||
MESSAGE("CURRENT SOURCE DIR ${CMAKE_CURRENT_SOURCE_DIR}")
|
MESSAGE("CURRENT SOURCE DIR ${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
include(ExternalProject)
|
IF (TD_WINDOWS)
|
||||||
|
INCLUDE(ExternalProject)
|
||||||
|
ExternalProject_Add(taosadapter
|
||||||
|
PREFIX "taosadapter"
|
||||||
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
|
||||||
|
BUILD_ALWAYS off
|
||||||
|
DEPENDS taos
|
||||||
|
BUILD_IN_SOURCE 1
|
||||||
|
CONFIGURE_COMMAND cmake -E echo "taosadapter no need cmake to config"
|
||||||
|
PATCH_COMMAND
|
||||||
|
COMMAND git clean -f -d
|
||||||
|
BUILD_COMMAND
|
||||||
|
COMMAND set CGO_CFLAGS=-I${CMAKE_CURRENT_SOURCE_DIR}/../include/client
|
||||||
|
COMMAND set CGO_LDFLAGS=-L${CMAKE_BINARY_DIR}/build/lib
|
||||||
|
COMMAND go build -a -o taosadapter.exe -ldflags "-s -w -X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
|
||||||
|
COMMAND go build -a -o taosadapter-debug.exe -ldflags "-X github.com/taosdata/taosadapter/v3/version.Version=${taos_version} -X github.com/taosdata/taosadapter/v3/version.CommitID=${taosadapter_commit_sha1}"
|
||||||
|
|
||||||
|
INSTALL_COMMAND
|
||||||
|
COMMAND cmake -E time upx taosadapter ||:
|
||||||
|
COMMAND cmake -E copy taosadapter.exe ${CMAKE_BINARY_DIR}/build/bin
|
||||||
|
COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test/cfg/
|
||||||
|
COMMAND cmake -E copy ./example/config/taosadapter.toml ${CMAKE_BINARY_DIR}/test/cfg/
|
||||||
|
COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
|
||||||
|
COMMAND cmake -E copy taosadapter-debug.exe ${CMAKE_BINARY_DIR}/build/bin
|
||||||
|
)
|
||||||
|
ELSE (TD_WINDOWS)
|
||||||
|
INCLUDE(ExternalProject)
|
||||||
ExternalProject_Add(taosadapter
|
ExternalProject_Add(taosadapter
|
||||||
PREFIX "taosadapter"
|
PREFIX "taosadapter"
|
||||||
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
|
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/taosadapter
|
||||||
|
@ -108,4 +133,5 @@ ELSE ()
|
||||||
COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
|
COMMAND cmake -E copy ./taosadapter.service ${CMAKE_BINARY_DIR}/test/cfg/
|
||||||
COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
|
COMMAND cmake -E copy taosadapter-debug ${CMAKE_BINARY_DIR}/build/bin
|
||||||
)
|
)
|
||||||
|
ENDIF (TD_WINDOWS)
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
Loading…
Reference in New Issue