@@ -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