Skip to content

Commit 604e0d6

Browse files
authored
Merge pull request #88 from eedalong/lz/1.0
支持1.0版本的IoTDB客户端
2 parents 937f263 + 57f7016 commit 604e0d6

55 files changed

Lines changed: 12070 additions & 2788 deletions

Some content is hidden

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

.github/workflows/e2e.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121

2222
- name: Set Docker & Run Test
2323
run: |
24-
docker-compose -f docker-compose.yml up --build --abort-on-container-exit --remove-orphans
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
2525
2626
- name: Clean IoTDB & Shut Down Docker
2727
run: |

docker-compose.yml

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ services:
1212
context: .
1313
dockerfile: samples/Apache.IoTDB.Samples/Dockerfile
1414
networks:
15-
- iotdb-network
15+
iotdb-network:
16+
ipv4_address: 172.18.0.2
1617

1718
iotdb:
18-
image: apache/iotdb:0.13.0-node
19+
image: apache/iotdb:1.0.0-datanode
1920
restart: always
20-
container_name: iotdb
21+
container_name: iotdb-dn-1
22+
depends_on:
23+
iotdb-confignode-1:
24+
condition: service_healthy
2125
healthcheck:
2226
test: ["CMD", "ls", "/iotdb/data"]
2327
interval: 3s
@@ -27,9 +31,31 @@ services:
2731
ports:
2832
- 6667:6667
2933
networks:
30-
- iotdb-network
34+
iotdb-network:
35+
ipv4_address: 172.18.0.3
36+
environment:
37+
- dn_rpc_address=iotdb
38+
- dn_internal_address=iotdb
39+
- dn_target_config_node_list=iotdb-confignode-1:22277
40+
41+
iotdb-confignode-1:
42+
image: apache/iotdb:1.0.0-confignode
43+
restart: always
44+
container_name: iotdb-cn-1
45+
healthcheck:
46+
test: ["CMD", "ls", "/iotdb/data"]
47+
interval: 3s
48+
timeout: 5s
49+
retries: 30
50+
start_period: 30s
51+
networks:
52+
iotdb-network:
53+
ipv4_address: 172.18.0.4
54+
environment:
55+
- cn_internal_address=iotdb-confignode-1
56+
- cn_target_config_node_list=iotdb-confignode-1:22277
3157

32-
networks:
33-
iotdb-network:
34-
driver: bridge
3558

59+
networks:
60+
iotdb-network:
61+
external: true

samples/Apache.IoTDB.Samples/SessionPoolTest.AlignedRecord.cs

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,52 @@ public async Task TestInsertAlignedRecord()
4444
await session_pool.Close();
4545
Console.WriteLine("TestInsertAlignedRecordAsync Passed");
4646
}
47+
public async Task TestInsertAlignedStringRecord()
48+
{
49+
var session_pool = new SessionPool(host, port, pool_size);
50+
var status = 0;
51+
await session_pool.Open(false);
52+
if (debug) session_pool.OpenDebugMode();
53+
54+
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
55+
await session_pool.DeleteStorageGroupAsync(test_group_name);
56+
57+
status = await session_pool.CreateAlignedTimeseriesAsync(
58+
string.Format("{0}.{1}", test_group_name, test_device),
59+
new List<string>() { test_measurements[0], test_measurements[1], test_measurements[2] },
60+
new List<TSDataType>() { TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT },
61+
new List<TSEncoding>() { TSEncoding.PLAIN, TSEncoding.PLAIN, TSEncoding.PLAIN },
62+
new List<Compressor>() { Compressor.UNCOMPRESSED, Compressor.UNCOMPRESSED, Compressor.UNCOMPRESSED });
63+
64+
System.Diagnostics.Debug.Assert(status == 0);
65+
var measurements = new List<string>
66+
{test_measurements[0], test_measurements[1], test_measurements[2]};
67+
var values = new List<string> { "test_text1", "test_text2", "test_text3" };
68+
var tasks = new List<Task<int>>();
69+
var start_ms = DateTime.Now.Ticks / 10000;
70+
for (var timestamp = 1; timestamp <= fetch_size * processed_size; timestamp++)
71+
{
72+
var task = session_pool.InsertAlignedStringRecordAsync(
73+
string.Format("{0}.{1}", test_group_name, test_device), measurements, values, timestamp);
74+
tasks.Add(task);
75+
}
76+
77+
Task.WaitAll(tasks.ToArray());
78+
var end_ms = DateTime.Now.Ticks / 10000;
79+
Console.WriteLine(string.Format("total insert aligned string record time is {0}", end_ms - start_ms));
80+
var res = await session_pool.ExecuteQueryStatementAsync("select * from " + string.Format("{0}.{1}", test_group_name, test_device));
81+
var res_cnt = 0;
82+
while (res.HasNext())
83+
{
84+
res.Next();
85+
res_cnt++;
86+
}
87+
Console.WriteLine(res_cnt + " " + fetch_size * processed_size);
88+
System.Diagnostics.Debug.Assert(res_cnt == fetch_size * processed_size);
89+
await session_pool.DeleteStorageGroupAsync(test_group_name);
90+
await session_pool.Close();
91+
Console.WriteLine("TestInsertAlignedStringRecordAsync Passed");
92+
}
4793
public async Task TestInsertAlignedRecords()
4894
{
4995
var session_pool = new SessionPool(host, port, pool_size);
@@ -165,6 +211,87 @@ public async Task TestInsertAlignedRecords()
165211
await session_pool.Close();
166212
Console.WriteLine("TestInsertAlignedRecords Passed!");
167213
}
214+
public async Task TestInsertAlignedStringRecords()
215+
{
216+
var session_pool = new SessionPool(host, port, pool_size);
217+
await session_pool.Open(false);
218+
if (debug) session_pool.OpenDebugMode();
219+
220+
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
221+
var status = 0;
222+
await session_pool.DeleteStorageGroupAsync(test_group_name);
223+
224+
string prefixPath = string.Format("{0}.{1}", test_group_name, test_device);
225+
var measurement_lst = new List<string>() { test_measurements[1], test_measurements[2] };
226+
var data_type_lst = new List<TSDataType>() { TSDataType.TEXT, TSDataType.TEXT };
227+
var encoding_lst = new List<TSEncoding>() { TSEncoding.PLAIN, TSEncoding.PLAIN };
228+
var compressor_lst = new List<Compressor>() { Compressor.SNAPPY, Compressor.SNAPPY };
229+
status = await session_pool.CreateAlignedTimeseriesAsync(prefixPath, measurement_lst, data_type_lst, encoding_lst,
230+
compressor_lst);
231+
System.Diagnostics.Debug.Assert(status == 0);
232+
233+
var device_id = new List<string>() { };
234+
for (var i = 0; i < 3; i++) device_id.Add(string.Format("{0}.{1}", test_group_name, test_device));
235+
var measurements_lst = new List<List<string>>() { };
236+
measurements_lst.Add(new List<string>() { test_measurements[1], test_measurements[2] });
237+
measurements_lst.Add(new List<string>() { test_measurements[1], test_measurements[2] });
238+
measurements_lst.Add(new List<string>() { test_measurements[1], test_measurements[2] });
239+
var values_lst = new List<List<string>>() { };
240+
values_lst.Add(new List<string>() { "test1", "test2" });
241+
values_lst.Add(new List<string>() { "test3", "test4" });
242+
values_lst.Add(new List<string>() { "test5", "test6" });
243+
List<long> timestamp_lst = new List<long>() { 1, 2, 3 };
244+
245+
status = await session_pool.InsertAlignedStringRecordsAsync(device_id, measurements_lst, values_lst, timestamp_lst);
246+
System.Diagnostics.Debug.Assert(status == 0);
247+
var res = await session_pool.ExecuteQueryStatementAsync(
248+
"select * from " + string.Format("{0}.{1}", test_group_name, test_device) + " where time<10");
249+
res.ShowTableNames();
250+
while (res.HasNext()) Console.WriteLine(res.Next());
251+
252+
await res.Close();
253+
254+
// large data test
255+
device_id = new List<string>() { };
256+
measurements_lst = new List<List<string>>() { };
257+
values_lst = new List<List<string>>() { };
258+
timestamp_lst = new List<long>() { };
259+
List<Task<int>> tasks = new List<Task<int>>();
260+
for (var timestamp = 4; timestamp <= fetch_size * processed_size; timestamp++)
261+
{
262+
device_id.Add(string.Format("{0}.{1}", test_group_name, test_device));
263+
measurements_lst.Add(new List<string>() { test_measurements[1], test_measurements[2] });
264+
values_lst.Add(new List<string>() { "test1", "test2" });
265+
timestamp_lst.Add(timestamp);
266+
if (timestamp % fetch_size == 0)
267+
{
268+
tasks.Add(session_pool.InsertAlignedStringRecordsAsync(device_id, measurements_lst, values_lst, timestamp_lst));
269+
device_id = new List<string>() { };
270+
measurements_lst = new List<List<string>>() { };
271+
values_lst = new List<List<string>>() { };
272+
timestamp_lst = new List<long>() { };
273+
}
274+
}
275+
276+
Task.WaitAll(tasks.ToArray());
277+
res = await session_pool.ExecuteQueryStatementAsync(
278+
"select * from " + string.Format("{0}.{1}", test_group_name, test_device));
279+
res.ShowTableNames();
280+
var res_count = 0;
281+
while (res.HasNext())
282+
{
283+
res.Next();
284+
res_count += 1;
285+
}
286+
287+
await res.Close();
288+
Console.WriteLine(res_count + " " + fetch_size * processed_size);
289+
System.Diagnostics.Debug.Assert(res_count == fetch_size * processed_size);
290+
status = await session_pool.DeleteStorageGroupAsync(test_group_name);
291+
System.Diagnostics.Debug.Assert(status == 0);
292+
await session_pool.Close();
293+
Console.WriteLine("TestInsertAlignedStringRecords Passed!");
294+
}
168295
public async Task TestInsertAlignedRecordsOfOneDevice()
169296
{
170297
var session_pool = new SessionPool(host, port, pool_size);
@@ -275,5 +402,79 @@ public async Task TestInsertAlignedRecordsOfOneDevice()
275402
await session_pool.Close();
276403
Console.WriteLine("TestInsertAlignedRecordsOfOneDevice Passed!");
277404
}
405+
public async Task TestInsertAlignedStringRecordsOfOneDevice()
406+
{
407+
var session_pool = new SessionPool(host, port, pool_size);
408+
await session_pool.Open(false);
409+
if (debug) session_pool.OpenDebugMode();
410+
411+
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
412+
var status = 0;
413+
await session_pool.DeleteStorageGroupAsync(test_group_name);
414+
var device_id = string.Format("{0}.{1}", test_group_name, test_device);
415+
var measurements = new List<string>() { test_measurements[0], test_measurements[1], test_measurements[2] };
416+
var data_type_lst = new List<TSDataType>() { TSDataType.TEXT, TSDataType.TEXT, TSDataType.TEXT };
417+
var encoding_lst = new List<TSEncoding>() { TSEncoding.PLAIN, TSEncoding.PLAIN, TSEncoding.PLAIN };
418+
var compressor_lst = new List<Compressor>() { Compressor.SNAPPY, Compressor.SNAPPY, Compressor.SNAPPY };
419+
status = await session_pool.CreateAlignedTimeseriesAsync(device_id, measurements, data_type_lst, encoding_lst, compressor_lst);
420+
System.Diagnostics.Debug.Assert(status == 0);
421+
422+
var measurements_lst = new List<List<string>>() { };
423+
measurements_lst.Add(new List<string>() { test_measurements[0], test_measurements[1], test_measurements[2] });
424+
measurements_lst.Add(new List<string>() { test_measurements[0], test_measurements[1], test_measurements[2] });
425+
measurements_lst.Add(new List<string>() { test_measurements[0], test_measurements[1], test_measurements[2] });
426+
427+
var values_lst = new List<List<string>>() { };
428+
values_lst.Add(new List<string>() { "test1", "test2", "test3" });
429+
values_lst.Add(new List<string>() { "test4", "test5", "test6" });
430+
values_lst.Add(new List<string>() { "test7", "test8", "test9" });
431+
432+
var timestamp_lst = new List<long>() { 1, 2, 3 };
433+
434+
status = await session_pool.InsertAlignedStringRecordsOfOneDeviceAsync(device_id, timestamp_lst, measurements_lst, values_lst);
435+
System.Diagnostics.Debug.Assert(status == 0);
436+
var res = await session_pool.ExecuteQueryStatementAsync(
437+
"select * from " + string.Format("{0}.{1}", test_group_name, test_device) + " where time<10");
438+
res.ShowTableNames();
439+
while (res.HasNext()) Console.WriteLine(res.Next());
440+
441+
await res.Close();
442+
// large data test
443+
values_lst = new List<List<string>>() { };
444+
var tasks = new List<Task<int>>();
445+
measurements_lst = new List<List<string>>() { };
446+
timestamp_lst = new List<long>() { };
447+
for (var timestamp = 4; timestamp <= fetch_size * processed_size; timestamp++)
448+
{
449+
values_lst.Add(new List<string>() { "test1", "test2" });
450+
measurements_lst.Add(new List<string>() { test_measurements[1], test_measurements[2] });
451+
timestamp_lst.Add(timestamp);
452+
if (timestamp % fetch_size == 0)
453+
{
454+
tasks.Add(session_pool.InsertAlignedStringRecordsOfOneDeviceAsync(device_id, timestamp_lst, measurements_lst, values_lst));
455+
values_lst = new List<List<string>>() { };
456+
measurements_lst = new List<List<string>>() { };
457+
timestamp_lst = new List<long>() { };
458+
}
459+
}
460+
461+
Task.WaitAll(tasks.ToArray());
462+
res = await session_pool.ExecuteQueryStatementAsync(
463+
"select * from " + string.Format("{0}.{1}", test_group_name, test_device));
464+
var res_count = 0;
465+
while (res.HasNext())
466+
{
467+
res.Next();
468+
res_count += 1;
469+
}
470+
471+
await res.Close();
472+
Console.WriteLine(res_count + " " + fetch_size * processed_size);
473+
System.Diagnostics.Debug.Assert(res_count == fetch_size * processed_size);
474+
status = await session_pool.DeleteStorageGroupAsync(test_group_name);
475+
System.Diagnostics.Debug.Assert(status == 0);
476+
await session_pool.Close();
477+
Console.WriteLine("TestInsertAlignedStringRecordsOfOneDevice Passed!");
478+
}
278479
}
279480
}

0 commit comments

Comments
 (0)