forked from apache/iotdb-client-csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSessionPoolTest.Template.cs
More file actions
104 lines (93 loc) · 5.11 KB
/
SessionPoolTest.Template.cs
File metadata and controls
104 lines (93 loc) · 5.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Apache.IoTDB.DataStructure;
namespace Apache.IoTDB.Samples
{
public partial class SessionPoolTest
{
public async Task TestCreateAndDropSchemaTemplate()
{
var session_pool = new SessionPool(host, port, poolSize);
await session_pool.Open(false);
if (debug) session_pool.OpenDebugMode();
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
var status = 0;
await session_pool.DropSchemaTemplateAsync(testTemplateName);
MeasurementNode node1 = new MeasurementNode(testMeasurements[1], TSDataType.INT32, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node2 = new MeasurementNode(testMeasurements[2], TSDataType.INT64, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node3 = new MeasurementNode(testMeasurements[3], TSDataType.DOUBLE, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node4 = new MeasurementNode(testMeasurements[4], TSDataType.FLOAT, TSEncoding.PLAIN, Compressor.SNAPPY);
Template template = new Template(testTemplateName);
template.addToTemplate(node1);
template.addToTemplate(node2);
template.addToTemplate(node3);
template.addToTemplate(node4);
status = await session_pool.CreateSchemaTemplateAsync(template);
System.Diagnostics.Debug.Assert(status == 0);
var templates = await session_pool.ShowAllTemplatesAsync();
foreach (var t in templates)
{
Console.WriteLine("template name :\t{0}", t);
}
status = await session_pool.DropSchemaTemplateAsync(testTemplateName);
System.Diagnostics.Debug.Assert(status == 0);
status = await session_pool.DeleteDatabaseAsync(testDatabaseName);
await session_pool.Close();
Console.WriteLine("TestCreateAndDropSchemaTemplate Passed!");
}
public async Task TestSetAndUnsetSchemaTemplate()
{
var session_pool = new SessionPool(host, port, poolSize);
await session_pool.Open(false);
if (debug) session_pool.OpenDebugMode();
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
var status = 0;
await session_pool.DeleteDatabaseAsync(testDatabaseName);
await session_pool.UnsetSchemaTemplateAsync(string.Format("{0}.{1}", testDatabaseName, testDevice), "template");
await session_pool.DropSchemaTemplateAsync(testTemplateName);
MeasurementNode node1 = new MeasurementNode(testMeasurements[1], TSDataType.INT32, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node2 = new MeasurementNode(testMeasurements[2], TSDataType.INT64, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node3 = new MeasurementNode(testMeasurements[3], TSDataType.DOUBLE, TSEncoding.PLAIN, Compressor.SNAPPY);
MeasurementNode node4 = new MeasurementNode(testMeasurements[4], TSDataType.FLOAT, TSEncoding.PLAIN, Compressor.SNAPPY);
Template template = new Template(testTemplateName);
template.addToTemplate(node1);
template.addToTemplate(node2);
template.addToTemplate(node3);
template.addToTemplate(node4);
status = await session_pool.CreateSchemaTemplateAsync(template);
System.Diagnostics.Debug.Assert(status == 0);
status = await session_pool.SetSchemaTemplateAsync(testTemplateName, string.Format("{0}.{1}", testDatabaseName, testDevice));
var paths = await session_pool.ShowPathsTemplateSetOnAsync(testTemplateName);
foreach (var p in paths)
{
Console.WriteLine("path :\t{0}", p);
}
status = await session_pool.UnsetSchemaTemplateAsync(string.Format("{0}.{1}", testDatabaseName, testDevice), testTemplateName);
status = await session_pool.DropSchemaTemplateAsync(testTemplateName);
System.Diagnostics.Debug.Assert(status == 0);
status = await session_pool.DeleteDatabaseAsync(testDatabaseName);
await session_pool.Close();
Console.WriteLine("TestSetAndUnsetSchemaTemplate Passed!");
}
}
}