Skip to content

Commit 252894a

Browse files
committed
example: merge C Session demos into client-cpp-example
Move tree_example.c and table_example.c into client-cpp-example, build them from the shared CMake entry, and update EN/ZH docs. Remove the standalone client-c-example module and drop it from the with-cpp profile.
1 parent 31438de commit 252894a

9 files changed

Lines changed: 26 additions & 232 deletions

File tree

example/client-c-example/README.md

Lines changed: 0 additions & 68 deletions
This file was deleted.

example/client-c-example/pom.xml

Lines changed: 0 additions & 156 deletions
This file was deleted.

example/client-cpp-example/README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ user `root` / `root`).
3636
| `AlignedTimeseriesSessionExample` | Aligned time series and templates |
3737
| `TableModelSessionExample` | Table (relational) model |
3838
| `MultiSvrNodeClient` | Multi-node insert/query loop |
39+
| `tree_example` | C Session API (tree model) |
40+
| `table_example` | C Session API (table model) |
3941

4042
## Which SDK zip to use
4143

@@ -92,7 +94,7 @@ the generator; on Windows with Visual Studio: `target/Release/`).
9294

9395
1. Build or download the SDK and unpack it so `client/include` and
9496
`client/lib` exist (see layout above).
95-
2. Copy `src/*.cpp` and `src/CMakeLists.txt` into one directory (or use
97+
2. Copy `src/*.{cpp,c}` and `src/CMakeLists.txt` into one directory (or use
9698
`src/` as the source tree and place `client/` beside it).
9799
3. Configure and build:
98100

@@ -248,7 +250,9 @@ client-cpp-example/
248250
├── SessionExample.cpp
249251
├── AlignedTimeseriesSessionExample.cpp
250252
├── TableModelSessionExample.cpp
251-
└── MultiSvrNodeClient.cpp
253+
├── MultiSvrNodeClient.cpp
254+
├── tree_example.c
255+
└── table_example.c
252256
```
253257

254258
After `mvn package`, the runnable tree is under `target/` (sources, `client/`,

example/client-cpp-example/README_zh.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
| `AlignedTimeseriesSessionExample` | 对齐时间序列与模板 |
3636
| `TableModelSessionExample` | 表模型(关系型) |
3737
| `MultiSvrNodeClient` | 多节点写入/查询循环 |
38+
| `tree_example` | C Session API(树模型) |
39+
| `table_example` | C Session API(表模型) |
3840

3941
## 选择哪个 SDK 压缩包
4042

@@ -89,7 +91,7 @@ Windows + Visual Studio 一般为 `target/Release/`)。
8991

9092
1. 自行编译或下载 SDK,解压后保证存在 `client/include``client/lib`(见
9193
上文目录结构)。
92-
2.`src/*.cpp``src/CMakeLists.txt` 放在同一目录(或保留 `src/`
94+
2.`src/*.{cpp,c}``src/CMakeLists.txt` 放在同一目录(或保留 `src/`
9395
结构,并在同级放置 `client/`)。
9496
3. 配置并编译:
9597

@@ -241,7 +243,9 @@ client-cpp-example/
241243
├── SessionExample.cpp
242244
├── AlignedTimeseriesSessionExample.cpp
243245
├── TableModelSessionExample.cpp
244-
└── MultiSvrNodeClient.cpp
246+
├── MultiSvrNodeClient.cpp
247+
├── tree_example.c
248+
└── table_example.c
245249
```
246250

247251
执行 `mvn package` 后,可在 `target/` 下找到源码、`client/` SDK 与 CMake

example/client-cpp-example/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@
6868
<sourceFile>${project.basedir}/src/MultiSvrNodeClient.cpp</sourceFile>
6969
<destinationFile>${project.build.directory}/MultiSvrNodeClient.cpp</destinationFile>
7070
</fileSet>
71+
<fileSet>
72+
<sourceFile>${project.basedir}/src/tree_example.c</sourceFile>
73+
<destinationFile>${project.build.directory}/tree_example.c</destinationFile>
74+
</fileSet>
75+
<fileSet>
76+
<sourceFile>${project.basedir}/src/table_example.c</sourceFile>
77+
<destinationFile>${project.build.directory}/table_example.c</destinationFile>
78+
</fileSet>
7179
<fileSet>
7280
<sourceFile>${project.basedir}/src/CMakeLists.txt</sourceFile>
7381
<destinationFile>${project.build.directory}/CMakeLists.txt</destinationFile>

example/client-cpp-example/src/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,16 @@ ADD_EXECUTABLE(SessionExample SessionExample.cpp)
7272
ADD_EXECUTABLE(AlignedTimeseriesSessionExample AlignedTimeseriesSessionExample.cpp)
7373
ADD_EXECUTABLE(TableModelSessionExample TableModelSessionExample.cpp)
7474
ADD_EXECUTABLE(MultiSvrNodeClient MultiSvrNodeClient.cpp)
75+
ADD_EXECUTABLE(tree_example tree_example.c)
76+
ADD_EXECUTABLE(table_example table_example.c)
7577

7678
set(_example_targets
7779
SessionExample
7880
AlignedTimeseriesSessionExample
7981
TableModelSessionExample
80-
MultiSvrNodeClient)
82+
MultiSvrNodeClient
83+
tree_example
84+
table_example)
8185

8286
foreach(_t IN LISTS _example_targets)
8387
IF(WITH_SSL)

example/client-c-example/src/table_example.c renamed to example/client-cpp-example/src/table_example.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ static void fail(const char* ctx, CTableSession* s) {
4646
}
4747

4848
int main(void) {
49-
/* Last arg: default database name; empty string leaves it unset (we USE "cdemo_db" via SQL below). */
5049
CTableSession* session = ts_table_session_new(HOST, PORT, USER, PASS, "");
5150
if (!session) {
5251
fprintf(stderr, "[table_example] ts_table_session_new returned NULL: %s\n", ts_get_last_error());

example/client-c-example/src/tree_example.c renamed to example/client-cpp-example/src/tree_example.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222
* Edit HOST / PORT / credentials below to match your IoTDB.
2323
*/
2424

25+
#include <stdbool.h>
2526
#include <stdio.h>
2627
#include <stdlib.h>
27-
#include <stdbool.h>
2828
#include <string.h>
2929

3030
#include "SessionC.h"

example/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
<id>with-cpp</id>
8686
<modules>
8787
<module>client-cpp-example</module>
88-
<module>client-c-example</module>
8988
</modules>
9089
</profile>
9190
</profiles>

0 commit comments

Comments
 (0)