Skip to content

Commit 7a400b3

Browse files
authored
Merge pull request #1 from lausannel/main
Add the original repository
2 parents 66bcfa2 + 2de6cc0 commit 7a400b3

File tree

140 files changed

+51900
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

140 files changed

+51900
-0
lines changed

.dockerignore

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
**/.classpath
2+
**/.dockerignore
3+
**/.env
4+
**/.git
5+
**/.gitignore
6+
**/.project
7+
**/.settings
8+
**/.toolstarget
9+
**/.vs
10+
**/.vscode
11+
**/*.*proj.user
12+
**/*.dbmdl
13+
**/*.jfm
14+
**/azds.yaml
15+
**/bin
16+
**/charts
17+
**/docker-compose*
18+
**/Dockerfile*
19+
**/node_modules
20+
**/npm-debug.log
21+
**/obj
22+
**/secrets.dev.yaml
23+
**/values.dev.yaml
24+
LICENSE
25+
README.md

.github/workflows/dotnet.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: .NET
2+
3+
on:
4+
push:
5+
branches: [ main, dev/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Setup .NET
17+
uses: actions/setup-dotnet@v1
18+
with:
19+
dotnet-version: 6.0.x
20+
- name: Restore dependencies
21+
run: dotnet restore "src/Apache.IoTDB/Apache.IoTDB.csproj"
22+
- name: Build
23+
run: dotnet build --no-restore "src/Apache.IoTDB/Apache.IoTDB.csproj"
24+
- name: Test
25+
run: dotnet test --no-build --verbosity normal "tests/Apache.IoTDB.Tests/Apache.IoTDB.Tests.csproj"

.github/workflows/e2e.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: E2E Tests
2+
3+
on:
4+
push:
5+
branches: [ main, dev/* ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
11+
build:
12+
name: e2e test
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest]
17+
steps:
18+
19+
- name: Check out code into the CSharp module directory
20+
uses: actions/checkout@v2
21+
22+
- name: Set Docker & Run Test
23+
run: |
24+
docker network create --subnet 172.18.0.0/24 iotdb-network && docker-compose -f docker-compose.yml up --build --abort-on-container-exit --remove-orphans
25+
26+
- name: Clean IoTDB & Shut Down Docker
27+
run: |
28+
docker-compose -f docker-compose.yml down

.gitignore

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# User-specific files
2+
*.rsuser
3+
*.suo
4+
*.user
5+
*.userosscache
6+
*.sln.docstates
7+
**/tmp
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
[Rr]eleases/
14+
x64/
15+
x86/
16+
[Ww][Ii][Nn]32/
17+
[Aa][Rr][Mm]/
18+
[Aa][Rr][Mm]64/
19+
bld/
20+
[Bb]in/
21+
[Oo]bj/
22+
[Ll]og/
23+
[Ll]ogs/
24+
25+
# MSTest test Results
26+
[Tt]est[Rr]esult*/
27+
[Bb]uild[Ll]og.*
28+
29+
# NUnit
30+
*.VisualState.xml
31+
TestResult.xml
32+
nunit-*.xml
33+
34+
# Build Results of an ATL Project
35+
[Dd]ebugPS/
36+
[Rr]eleasePS/
37+
dlldata.c
38+
39+
# .NET Core
40+
project.lock.json
41+
project.fragment.lock.json
42+
artifacts/
43+
44+
# StyleCop
45+
StyleCopReport.xml
46+
47+
48+
# ReSharper is a .NET coding add-in
49+
_ReSharper*/
50+
*.[Rr]e[Ss]harper
51+
*.DotSettings.user
52+
53+
# DotCover is a Code Coverage Tool
54+
*.dotCove
55+
56+
# Click-Once directory
57+
publish/
58+
59+
### VisualStudioCode ###
60+
.vscode/*
61+
!.vscode/settings.json
62+
!.vscode/tasks.json
63+
!.vscode/launch.json
64+
!.vscode/extensions.json
65+
*.code-workspace
66+
67+
68+
### Rider ###
69+
.idea
70+
/.vs/Apache.IoTDB/FileContentIndex
71+
/.vs/ProjectEvaluation
72+
/.vs/Apache.IoTDB
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net7.0</TargetFramework>
6+
<RootNamespace>Apache_IoTDB_Client_CSharp_UserCase</RootNamespace>
7+
<LangVersion>latest</LangVersion>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Apache.IoTDB" Version="1.0.0.3" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Threading;
4+
using System.Threading.Tasks;
5+
using Apache.IoTDB;
6+
using Apache.IoTDB.DataStructure;
7+
8+
namespace Apache.IoTDB.UserCase
9+
{
10+
class Program
11+
{
12+
static string host = "localhost";
13+
static int port = 6667;
14+
static int pool_size = 2;
15+
16+
17+
static async Task OpenAndCloseSessionPool()
18+
{
19+
var session_pool = new SessionPool(host, port, pool_size);
20+
await session_pool.Open(false);
21+
if (session_pool.IsOpen())
22+
{
23+
Console.WriteLine("SessionPool open success");
24+
}
25+
else
26+
{
27+
Console.WriteLine("SessionPool open failed");
28+
}
29+
await session_pool.Close();
30+
}
31+
32+
static async Task CreateTimeseries()
33+
{
34+
var session_pool = new SessionPool(host, port, pool_size);
35+
await session_pool.Open(false);
36+
37+
await session_pool.DeleteStorageGroupAsync("root.ln.wf01.wt01");
38+
var status = await session_pool.CreateTimeSeries("root.ln.wf01.wt01.status", TSDataType.BOOLEAN, TSEncoding.PLAIN, Compressor.SNAPPY);
39+
status = await session_pool.CreateTimeSeries("root.ln.wf01.wt01.temperature", TSDataType.DOUBLE, TSEncoding.PLAIN, Compressor.SNAPPY);
40+
status = await session_pool.CreateTimeSeries("root.ln.wf01.wt01.hardware", TSDataType.TEXT, TSEncoding.PLAIN, Compressor.SNAPPY);
41+
42+
await session_pool.Close();
43+
}
44+
45+
static async Task InsertRecord()
46+
{
47+
var session_pool = new SessionPool(host, port, pool_size);
48+
await session_pool.Open(false);
49+
long timestamp = 1;
50+
var values = new List<object> { true, (double)1.1, "test" };
51+
var measures = new List<string> { "status", "temperature", "hardware" };
52+
var rowRecord = new RowRecord(timestamp, values, measures);
53+
var status = await session_pool.InsertRecordAsync("root.ln.wf01.wt01", rowRecord);
54+
55+
await session_pool.Close();
56+
}
57+
58+
static async Task InsertTablet()
59+
{
60+
var session_pool = new SessionPool(host, port, pool_size);
61+
await session_pool.Open(false);
62+
var device_id = "root.ln.wf01.wt01";
63+
var measurement_lst = new List<string> { "status", "temperature", "hardware" };
64+
var value_lst = new List<List<object>>
65+
{
66+
new() {true, (double)1.1, "test"},
67+
new() {false, (double)2.2, "test2"},
68+
new() {true, (double)3.3, "test3"}
69+
};
70+
var timestamp_lst = new List<long> { 1, 2, 3 };
71+
var datatype_lst = new List<TSDataType> { TSDataType.BOOLEAN, TSDataType.DOUBLE, TSDataType.TEXT };
72+
var tablet = new Tablet(device_id, measurement_lst, datatype_lst, value_lst, timestamp_lst);
73+
var status = await session_pool.InsertTabletAsync(tablet);
74+
await session_pool.Close();
75+
}
76+
77+
static async Task ExecuteQueryStatement()
78+
{
79+
var session_pool = new SessionPool(host, port, pool_size);
80+
await session_pool.Open(false);
81+
var res = await session_pool.ExecuteQueryStatementAsync("select * from root.ln.wf01.wt01");
82+
res.ShowTableNames();
83+
while (res.HasNext())
84+
{
85+
Console.WriteLine(res.Next());
86+
}
87+
await res.Close();
88+
await session_pool.Close();
89+
}
90+
91+
static async Task Main(string[] args)
92+
{
93+
await OpenAndCloseSessionPool();
94+
await CreateTimeseries();
95+
await InsertRecord();
96+
await InsertTablet();
97+
await ExecuteQueryStatement();
98+
}
99+
}
100+
101+
}
102+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Apache-IoTDB-Client-CSharp-UseCase
2+
Use case for csharp client of Apache IoTDB
3+
4+
5+
# Run this use case
6+
7+
After cloning this project, you need to install Apache.IoTDB first.
8+
9+
```shell
10+
dotnet add package Apache.IoTDB
11+
```
12+
13+
Then you can run this project to test.
14+
```shell
15+
dotnet run
16+
```

0 commit comments

Comments
 (0)