@@ -1201,7 +1201,150 @@ public void test_SimpleDBConnectionPool_insert_into_memoryTable_arrayVector_all_
1201
1201
}
1202
1202
pool .close ();
1203
1203
}
1204
-
1204
+ @ Test
1205
+ public void test_SimpleDBConnectionPool_insert_into_dfs_arrayVector_all_dateType () throws IOException , InterruptedException {
1206
+ config .setInitialPoolSize (100 );
1207
+ pool = new SimpleDBConnectionPool (config );
1208
+ String script = "login(`admin, `123456); \n " +
1209
+ "if(existsDatabase('dfs://test_append_type_tsdb1'))" +
1210
+ "{ dropDatabase('dfs://test_append_type_tsdb1')} \n " +
1211
+ "colNames=\" col\" +string(1..26);\n " +
1212
+ "colTypes=[INT,BOOL[],CHAR[],SHORT[],INT[],LONG[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],FLOAT[],DOUBLE[],UUID[],DATEHOUR[],IPADDR[],INT128[],COMPLEX[],POINT[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(19)[]];\n " +
1213
+ "t1 = table(1:0,colNames,colTypes) ;\n " +
1214
+ "db=database('dfs://test_append_type_tsdb1', RANGE, 0 5 11,,'TSDB') \n " +
1215
+ "db.createPartitionedTable(t1, `pt, `col1,,`col1)\n " ;
1216
+ DBConnection poolEntry = pool .getConnection ();
1217
+ poolEntry .run (script );
1218
+ poolEntry .close ();
1219
+ DBConnection poolEntry1 = pool .getConnection ();
1220
+ String script1 = "col1 = 1..10;\n " +
1221
+ "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], 1000), 100))\n " +
1222
+ "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), 1000), 100))\n " +
1223
+ "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), 1000), 100))\n " +
1224
+ "cint = array(INT[]).append!(cut(take(-100..100 join NULL, 1000), 100))\n " +
1225
+ "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), 1000), 100))\n " +
1226
+ "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, 1000) + 0.254, 100))\n " +
1227
+ "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, 1000) + 0.254f, 100))\n " +
1228
+ "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, 1000), 100))\n " +
1229
+ "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, 1000), 100))\n " +
1230
+ "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, 1000), 100))\n " +
1231
+ "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, 1000), 100))\n " +
1232
+ "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, 1000), 100))\n " +
1233
+ "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, 1000), 100))\n " +
1234
+ "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, 1000), 100))\n " +
1235
+ "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, 1000), 100))\n " +
1236
+ "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, 1000), 100))\n " +
1237
+ "cuuid = array(UUID[]).append!(cut(take(uuid([\" 5d212a78-cc48-e3b1-4235-b4d91473ee87\" , \" 5d212a78-cc48-e3b1-4235-b4d91473ee88\" , \" 5d212a78-cc48-e3b1-4235-b4d91473ee89\" , \" \" ]), 1000), 100))\n " +
1238
+ "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), 1000), 100))\n " +
1239
+ "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\" 192.168.100.10\" , \" 192.168.100.11\" , \" 192.168.100.14\" , \" \" ]), 1000), 100))\n " +
1240
+ "cint128 = array(INT128[]).append!(cut(take(int128([\" e1671797c52e15f763380b45e841ec32\" , \" e1671797c52e15f763380b45e841ec33\" , \" e1671797c52e15f763380b45e841ec35\" , \" \" ]), 1000), 100))\n " +
1241
+ "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, 1000), 100))\n " +
1242
+ "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, 1000), 100))\n " +
1243
+ "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, 1000) + 0.254, 3), 100))\n " +
1244
+ "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, 1000) + 0.25467, 4), 100))\n " +
1245
+ "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, 1000) + 0.25467, 5), 100))\n " +
1246
+ "share table(col1, cbool, cchar, cshort, cint, clong, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cfloat, cdouble, cuuid, cdatehour,cipaddr, cint128, ccomplex,cpoint,cdecimal32,cdecimal64,cdecimal128) as data;\n " +
1247
+ "pt = loadTable(\" dfs://test_append_type_tsdb1\" ,`pt)\n " +
1248
+ "pt.append!(data)\n " ;
1249
+ poolEntry1 .run (script1 );
1250
+ poolEntry1 .close ();
1251
+ Thread [] threads = new Thread [100 ];
1252
+ for (int i = 0 ; i < 100 ; ++i ) {
1253
+ threads [i ] = new Thread (() -> {
1254
+ DBConnection poolEntry2 = pool .getConnection ();
1255
+ try {
1256
+ BasicTable re1 = (BasicTable )poolEntry2 .run ("select count(*) from loadTable(\" dfs://test_append_type_tsdb1\" ,`pt);" );
1257
+ assertEquals ("10" ,re1 .getColumn (0 ).get (0 ).toString ());
1258
+ BasicTable re2 = (BasicTable )poolEntry2 .run ("select * from loadTable(\" dfs://test_append_type_tsdb1\" ,`pt);" );
1259
+ for (int j =0 ; j <10 ; j ++){
1260
+ assertEquals (String .valueOf (j +1 ),re2 .getColumn (0 ).get (j ).toString ());
1261
+ }
1262
+ } catch (IOException e ) {
1263
+ throw new RuntimeException (e );
1264
+ }
1265
+ poolEntry2 .close ();
1266
+ });
1267
+ }
1268
+ for (int i = 0 ; i < 100 ; i ++) {
1269
+ threads [i ].start ();
1270
+ }
1271
+ for (int i = 0 ; i < 100 ; i ++){
1272
+ threads [i ].join ();
1273
+ }
1274
+ pool .close ();
1275
+ }
1276
+ @ Test
1277
+ public void test_SimpleDBConnectionPool_insert_into_DimensionTable_arrayVector_all_dateType () throws IOException , InterruptedException {
1278
+ config .setInitialPoolSize (100 );
1279
+ pool = new SimpleDBConnectionPool (config );
1280
+ String script = "login(`admin, `123456); \n " +
1281
+ "if(existsDatabase('dfs://test_append_type_tsdb1'))" +
1282
+ "{ dropDatabase('dfs://test_append_type_tsdb1')} \n " +
1283
+ "colNames=\" col\" +string(1..26);\n " +
1284
+ "colTypes=[INT,BOOL[],CHAR[],SHORT[],INT[],LONG[],DATE[],MONTH[],TIME[],MINUTE[],SECOND[],DATETIME[],TIMESTAMP[],NANOTIME[],NANOTIMESTAMP[],FLOAT[],DOUBLE[],UUID[],DATEHOUR[],IPADDR[],INT128[],COMPLEX[],POINT[],DECIMAL32(2)[],DECIMAL64(7)[],DECIMAL128(19)[]];\n " +
1285
+ "t1 = table(1:0,colNames,colTypes) ;\n " +
1286
+ "db=database('dfs://test_append_type_tsdb1', RANGE, 0 5 11,,'TSDB') \n " +
1287
+ "db.createTable(t1, `pt,,`col1)\n " ;
1288
+ DBConnection poolEntry = pool .getConnection ();
1289
+ poolEntry .run (script );
1290
+ poolEntry .close ();
1291
+ DBConnection poolEntry1 = pool .getConnection ();
1292
+ String script1 = "col1 = 1..10;\n " +
1293
+ "cbool = array(BOOL[]).append!(cut(take([true, false, NULL], 1000), 100))\n " +
1294
+ "cchar = array(CHAR[]).append!(cut(take(char(-100..100 join NULL), 1000), 100))\n " +
1295
+ "cshort = array(SHORT[]).append!(cut(take(short(-100..100 join NULL), 1000), 100))\n " +
1296
+ "cint = array(INT[]).append!(cut(take(-100..100 join NULL, 1000), 100))\n " +
1297
+ "clong = array(LONG[]).append!(cut(take(long(-100..100 join NULL), 1000), 100))\n " +
1298
+ "cdouble = array(DOUBLE[]).append!(cut(take(-100..100 join NULL, 1000) + 0.254, 100))\n " +
1299
+ "cfloat = array(FLOAT[]).append!(cut(take(-100..100 join NULL, 1000) + 0.254f, 100))\n " +
1300
+ "cdate = array(DATE[]).append!(cut(take(2012.01.01..2012.02.29, 1000), 100))\n " +
1301
+ "cmonth = array(MONTH[]).append!(cut(take(2012.01M..2013.12M, 1000), 100))\n " +
1302
+ "ctime = array(TIME[]).append!(cut(take(09:00:00.000 + 0..99 * 1000, 1000), 100))\n " +
1303
+ "cminute = array(MINUTE[]).append!(cut(take(09:00m..15:59m, 1000), 100))\n " +
1304
+ "csecond = array(SECOND[]).append!(cut(take(09:00:00 + 0..999, 1000), 100))\n " +
1305
+ "cdatetime = array(DATETIME[]).append!(cut(take(2012.01.01T09:00:00 + 0..999, 1000), 100))\n " +
1306
+ "ctimestamp = array(TIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000 + 0..999 * 1000, 1000), 100))\n " +
1307
+ "cnanotime =array(NANOTIME[]).append!(cut(take(09:00:00.000000000 + 0..999 * 1000000000, 1000), 100))\n " +
1308
+ "cnanotimestamp = array(NANOTIMESTAMP[]).append!(cut(take(2012.01.01T09:00:00.000000000 + 0..999 * 1000000000, 1000), 100))\n " +
1309
+ "cuuid = array(UUID[]).append!(cut(take(uuid([\" 5d212a78-cc48-e3b1-4235-b4d91473ee87\" , \" 5d212a78-cc48-e3b1-4235-b4d91473ee88\" , \" 5d212a78-cc48-e3b1-4235-b4d91473ee89\" , \" \" ]), 1000), 100))\n " +
1310
+ "cdatehour = array(DATEHOUR[]).append!(cut(take(datehour(1..10 join NULL), 1000), 100))\n " +
1311
+ "cipaddr = array(IPADDR[]).append!(cut(take(ipaddr([\" 192.168.100.10\" , \" 192.168.100.11\" , \" 192.168.100.14\" , \" \" ]), 1000), 100))\n " +
1312
+ "cint128 = array(INT128[]).append!(cut(take(int128([\" e1671797c52e15f763380b45e841ec32\" , \" e1671797c52e15f763380b45e841ec33\" , \" e1671797c52e15f763380b45e841ec35\" , \" \" ]), 1000), 100))\n " +
1313
+ "ccomplex = array( COMPLEX[]).append!(cut(rand(complex(rand(100, 1000), rand(100, 1000)) join NULL, 1000), 100))\n " +
1314
+ "cpoint = array(POINT[]).append!(cut(rand(point(rand(100, 1000), rand(100, 1000)) join NULL, 1000), 100))\n " +
1315
+ "cdecimal32 = array(DECIMAL32(2)[]).append!(cut(decimal32(take(-100..100 join NULL, 1000) + 0.254, 3), 100))\n " +
1316
+ "cdecimal64 = array(DECIMAL64(7)[]).append!(cut(decimal64(take(-100..100 join NULL, 1000) + 0.25467, 4), 100))\n " +
1317
+ "cdecimal128 = array(DECIMAL128(19)[]).append!(cut(decimal128(take(-100..100 join NULL, 1000) + 0.25467, 5), 100))\n " +
1318
+ "share table(col1, cbool, cchar, cshort, cint, clong, cdate, cmonth, ctime, cminute, csecond, cdatetime, ctimestamp, cnanotime, cnanotimestamp, cfloat, cdouble, cuuid, cdatehour,cipaddr, cint128, ccomplex,cpoint,cdecimal32,cdecimal64,cdecimal128) as data;\n " +
1319
+ "pt = loadTable(\" dfs://test_append_type_tsdb1\" ,`pt)\n " +
1320
+ "pt.append!(data)\n " ;
1321
+ poolEntry1 .run (script1 );
1322
+ poolEntry1 .close ();
1323
+ Thread [] threads = new Thread [100 ];
1324
+ for (int i = 0 ; i < 100 ; ++i ) {
1325
+ threads [i ] = new Thread (() -> {
1326
+ DBConnection poolEntry2 = pool .getConnection ();
1327
+ try {
1328
+ BasicTable re1 = (BasicTable )poolEntry2 .run ("select count(*) from loadTable(\" dfs://test_append_type_tsdb1\" ,`pt);" );
1329
+ assertEquals ("10" ,re1 .getColumn (0 ).get (0 ).toString ());
1330
+ BasicTable re2 = (BasicTable )poolEntry2 .run ("select * from loadTable(\" dfs://test_append_type_tsdb1\" ,`pt);" );
1331
+ for (int j =0 ; j <10 ; j ++){
1332
+ assertEquals (String .valueOf (j +1 ),re2 .getColumn (0 ).get (j ).toString ());
1333
+ }
1334
+ } catch (IOException e ) {
1335
+ throw new RuntimeException (e );
1336
+ }
1337
+ poolEntry2 .close ();
1338
+ });
1339
+ }
1340
+ for (int i = 0 ; i < 100 ; i ++) {
1341
+ threads [i ].start ();
1342
+ }
1343
+ for (int i = 0 ; i < 100 ; i ++){
1344
+ threads [i ].join ();
1345
+ }
1346
+ pool .close ();
1347
+ }
1205
1348
@ Test
1206
1349
public void test_SimpleDBConnectionPool_insert_into_dfs_all_dateType () throws IOException , InterruptedException {
1207
1350
config .setInitialPoolSize (100 );
0 commit comments