Skip to content

Commit b0483bb

Browse files
committed
remove add measurements in template interface and test
1 parent ef66b9d commit b0483bb

2 files changed

Lines changed: 3 additions & 164 deletions

File tree

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

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -81,74 +81,6 @@ public async Task TestSetAndUnsetSchemaTemplate()
8181
await session_pool.Close();
8282
Console.WriteLine("TestSetAndUnsetSchemaTemplate Passed!");
8383
}
84-
public async Task TestAddAlignedMeasurements()
85-
{
86-
var session_pool = new SessionPool(host, port, pool_size);
87-
await session_pool.Open(false);
88-
if (debug) session_pool.OpenDebugMode();
89-
90-
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
91-
var status = 0;
92-
await session_pool.DeleteStorageGroupAsync(test_group_name);
93-
await session_pool.DropSchemaTemplateAsync(test_template_name);
94-
95-
MeasurementNode node1 = new MeasurementNode(test_measurements[1], TSDataType.INT32, TSEncoding.PLAIN, Compressor.SNAPPY);
96-
MeasurementNode node2 = new MeasurementNode(test_measurements[2], TSDataType.INT64, TSEncoding.PLAIN, Compressor.SNAPPY);
97-
MeasurementNode node3 = new MeasurementNode(test_measurements[3], TSDataType.DOUBLE, TSEncoding.PLAIN, Compressor.SNAPPY);
98-
MeasurementNode node4 = new MeasurementNode(test_measurements[4], TSDataType.FLOAT, TSEncoding.PLAIN, Compressor.SNAPPY);
99-
var measurements = new List<MeasurementNode>() { node3, node4 };
100-
101-
Template template = new Template(test_template_name, true);
102-
template.addToTemplate(node1);
103-
template.addToTemplate(node2);
104-
status = await session_pool.CreateSchemaTemplateAsync(template);
105-
System.Diagnostics.Debug.Assert(status == 0);
106-
status = await session_pool.AddAlignedMeasurementsInTemplateAsync(test_template_name, measurements);
107-
System.Diagnostics.Debug.Assert(status == 0);
108-
var measurements_count = await session_pool.CountMeasurementsInTemplateAsync(test_template_name);
109-
System.Diagnostics.Debug.Assert(measurements_count == 4);
110-
foreach (var m in measurements)
111-
{
112-
System.Diagnostics.Debug.Assert(await session_pool.IsMeasurementInTemplateAsync(test_template_name, m.Name));
113-
}
114-
status = await session_pool.DropSchemaTemplateAsync(test_template_name);
115-
System.Diagnostics.Debug.Assert(status == 0);
116-
await session_pool.Close();
117-
Console.WriteLine("TestAddAlignedMeasurements Passed!");
118-
}
119-
public async Task TestAddUnalignedMeasurements()
120-
{
121-
var session_pool = new SessionPool(host, port, pool_size);
122-
await session_pool.Open(false);
123-
if (debug) session_pool.OpenDebugMode();
124-
125-
System.Diagnostics.Debug.Assert(session_pool.IsOpen());
126-
var status = 0;
127-
await session_pool.DeleteStorageGroupAsync(test_group_name);
128-
await session_pool.DropSchemaTemplateAsync(test_template_name);
129-
130-
MeasurementNode node1 = new MeasurementNode(test_measurements[1], TSDataType.INT32, TSEncoding.PLAIN, Compressor.SNAPPY);
131-
MeasurementNode node2 = new MeasurementNode(test_measurements[2], TSDataType.INT64, TSEncoding.PLAIN, Compressor.SNAPPY);
132-
MeasurementNode node3 = new MeasurementNode(test_measurements[3], TSDataType.DOUBLE, TSEncoding.PLAIN, Compressor.SNAPPY);
133-
MeasurementNode node4 = new MeasurementNode(test_measurements[4], TSDataType.FLOAT, TSEncoding.PLAIN, Compressor.SNAPPY);
134-
var measurements = new List<MeasurementNode>() { node1, node2, node3, node4 };
135-
136-
Template template = new Template(test_template_name);
137-
status = await session_pool.CreateSchemaTemplateAsync(template);
138-
System.Diagnostics.Debug.Assert(status == 0);
139-
status = await session_pool.AddUnalignedMeasurementsInTemplateAsync(test_template_name, measurements);
140-
System.Diagnostics.Debug.Assert(status == 0);
141-
var measurements_count = await session_pool.CountMeasurementsInTemplateAsync(test_template_name);
142-
System.Diagnostics.Debug.Assert(measurements_count == 4);
143-
foreach (var m in measurements)
144-
{
145-
System.Diagnostics.Debug.Assert(await session_pool.IsPathExistInTemplate(test_template_name, m.Name));
146-
}
147-
status = await session_pool.DropSchemaTemplateAsync(test_template_name);
148-
System.Diagnostics.Debug.Assert(status == 0);
149-
await session_pool.Close();
150-
Console.WriteLine("TestAddUnalignedMeasurements Passed!");
151-
}
15284
public async Task TestDeleteNodeInTemplate()
15385
{
15486
var session_pool = new SessionPool(host, port, pool_size);

src/Apache.IoTDB/SessionPool.cs

Lines changed: 3 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public async Task<int> SetStorageGroup(string groupName)
266266
{
267267
_logger.LogInformation("set storage group {0} successfully, server message is {1}", groupName, status.Message);
268268
}
269-
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
269+
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
270270
}
271271
catch (TException ex)
272272
{
@@ -1739,7 +1739,8 @@ public async Task<SessionDataSet> ExecuteQueryStatementAsync(string sql)
17391739

17401740
return sessionDataset;
17411741
}
1742-
public async Task<SessionDataSet> ExecuteStatementAsync(string sql){
1742+
public async Task<SessionDataSet> ExecuteStatementAsync(string sql)
1743+
{
17431744
TSExecuteStatementResp resp;
17441745
TSStatus status;
17451746
var client = _clients.Take();
@@ -2114,101 +2115,7 @@ public async Task<int> UnsetSchemaTemplateAsync(string prefixPath, string templa
21142115
_clients.Add(client);
21152116
}
21162117
}
2117-
public async Task<int> AddAlignedMeasurementsInTemplateAsync(string templateName, List<MeasurementNode> measurementNodes)
2118-
{
2119-
var client = _clients.Take();
2120-
var measurements = measurementNodes.ConvertAll(m => m.Name);
2121-
var dataTypes = measurementNodes.ConvertAll(m => (int)m.DataType);
2122-
var encodings = measurementNodes.ConvertAll(m => (int)m.Encoding);
2123-
var compressors = measurementNodes.ConvertAll(m => (int)m.Compressor);
2124-
var req = new TSAppendSchemaTemplateReq(client.SessionId, templateName, true, measurements, dataTypes, encodings, compressors);
2125-
try
2126-
{
2127-
var status = await client.ServiceClient.appendSchemaTemplateAsync(req);
2128-
2129-
if (_debugMode)
2130-
{
2131-
_logger.LogInformation("add aligned measurements in template {0} message: {1}", templateName, status.Message);
2132-
}
2133-
2134-
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
2135-
2136-
}
2137-
catch (TException e)
2138-
{
2139-
await Open(_enableRpcCompression);
2140-
client = _clients.Take();
2141-
req.SessionId = client.SessionId;
2142-
try
2143-
{
2144-
var status = await client.ServiceClient.appendSchemaTemplateAsync(req);
2145-
2146-
if (_debugMode)
2147-
{
2148-
_logger.LogInformation("add aligned measurements in template {0} message: {1}", templateName, status.Message);
2149-
}
21502118

2151-
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
2152-
2153-
}
2154-
catch (TException ex)
2155-
{
2156-
throw new TException("Error occurs when adding aligned measurements in template", ex);
2157-
}
2158-
}
2159-
finally
2160-
{
2161-
_clients.Add(client);
2162-
}
2163-
}
2164-
2165-
public async Task<int> AddUnalignedMeasurementsInTemplateAsync(string templateName, List<MeasurementNode> measurementNodes)
2166-
{
2167-
var client = _clients.Take();
2168-
var measurements = measurementNodes.ConvertAll(m => m.Name);
2169-
var dataTypes = measurementNodes.ConvertAll(m => (int)m.DataType);
2170-
var encodings = measurementNodes.ConvertAll(m => (int)m.Encoding);
2171-
var compressors = measurementNodes.ConvertAll(m => (int)m.Compressor);
2172-
var req = new TSAppendSchemaTemplateReq(client.SessionId, templateName, false, measurements, dataTypes, encodings, compressors);
2173-
try
2174-
{
2175-
var status = await client.ServiceClient.appendSchemaTemplateAsync(req);
2176-
2177-
if (_debugMode)
2178-
{
2179-
_logger.LogInformation("add unaligned measurements in template {0} message: {1}", templateName, status.Message);
2180-
}
2181-
2182-
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
2183-
2184-
}
2185-
catch (TException e)
2186-
{
2187-
await Open(_enableRpcCompression);
2188-
client = _clients.Take();
2189-
req.SessionId = client.SessionId;
2190-
try
2191-
{
2192-
var status = await client.ServiceClient.appendSchemaTemplateAsync(req);
2193-
2194-
if (_debugMode)
2195-
{
2196-
_logger.LogInformation("add unaligned measurements in template {0} message: {1}", templateName, status.Message);
2197-
}
2198-
2199-
return _utilFunctions.VerifySuccess(status, SuccessCode, RedirectRecommendCode);
2200-
2201-
}
2202-
catch (TException ex)
2203-
{
2204-
throw new TException("Error occurs when adding unaligned measurements in template", ex);
2205-
}
2206-
}
2207-
finally
2208-
{
2209-
_clients.Add(client);
2210-
}
2211-
}
22122119
public async Task<int> DeleteNodeInTemplateAsync(string templateName, string path)
22132120
{
22142121
var client = _clients.Take();

0 commit comments

Comments
 (0)