|
11 | 11 | import java.nio.ByteBuffer; |
12 | 12 | import java.util.*; |
13 | 13 |
|
| 14 | +import static com.xxdb.data.Entity.DATA_TYPE.*; |
| 15 | +import static java.sql.JDBCType.NULL; |
14 | 16 | import static org.junit.Assert.*; |
15 | 17 |
|
16 | 18 | public class BasicAnyVectorTest { |
@@ -334,7 +336,7 @@ public void test_BasicAnyVector_table() throws Exception { |
334 | 336 | "m [tom,dickh,arry,jack] [blue,green,blue,blue]\n",re.getString()); |
335 | 337 | } |
336 | 338 |
|
337 | | - @Test |
| 339 | + //@Test |
338 | 340 | public void test_BasicAnyVector_performence() throws IOException, InterruptedException { |
339 | 341 | List<String> colNames = new ArrayList<>(); |
340 | 342 | colNames.add("cbool"); |
@@ -394,7 +396,9 @@ public void test_BasicAnyVector_performence() throws IOException, InterruptedExc |
394 | 396 | DBConnection conn = new DBConnection(); |
395 | 397 | conn.connect(HOST,PORT,"admin","123456"); |
396 | 398 | //Preparedata_array(500000,10); |
397 | | - String pre_data = "def createDataTableTuple(n,num){\n" + |
| 399 | + String pre_data = "try{undef(`data,SHARED)}catch(ex){}\n" + |
| 400 | + "try{undef(`data1,SHARED)}catch(ex){}\n" + |
| 401 | + "def createDataTableTuple(n,num){\n" + |
398 | 402 | " boolv = bool(rand([true, false, NULL], n))\n" + |
399 | 403 | " cbool = cut(take([true, false, NULL], n*num), num)\n" + |
400 | 404 | " cchar = cut(take(char(-100..100 join NULL), n*num), num)\n" + |
@@ -452,4 +456,64 @@ public void test_BasicAnyVector_performence() throws IOException, InterruptedExc |
452 | 456 | System.out.println(testCases.get(ii) + "上传花费时间:" + (end - start) / 10000000); |
453 | 457 | } |
454 | 458 | } |
| 459 | + |
| 460 | + @Test |
| 461 | + public void test_BasicAnyVector_set_dict() throws Exception { |
| 462 | + BasicAnyVector bbb = new BasicAnyVector(1); |
| 463 | + BasicDictionary dictionary3 = new BasicDictionary(DT_STRING, DT_ANY); |
| 464 | + BasicDictionary dictionaryAAA = new BasicDictionary(DT_STRING, DT_STRING); |
| 465 | + dictionaryAAA.put(new BasicString("p1"), new BasicString("1")); |
| 466 | + dictionaryAAA.put(new BasicString("p2"), new BasicString("2")); |
| 467 | + |
| 468 | + BasicDictionary dictionaryBBB = new BasicDictionary(DT_STRING, DT_STRING); |
| 469 | + dictionaryBBB.put(new BasicString("p1"), new BasicString("100")); |
| 470 | + dictionaryBBB.put(new BasicString("p2"), new BasicString("200")); |
| 471 | + |
| 472 | + dictionary3.put(new BasicString("aaa"), dictionaryAAA); |
| 473 | + dictionary3.put(new BasicString("bbb"), dictionaryBBB); |
| 474 | + bbb.set(0, dictionary3); |
| 475 | + System.out.println(bbb.getString()); |
| 476 | + DBConnection conn = new DBConnection(); |
| 477 | + conn.connect(HOST,PORT,"admin","123456"); |
| 478 | + BasicAnyVector re = (BasicAnyVector)conn.run("any1=array(ANY,0).append!(dict(`aaa`bbb, [dict(`p1`p2, `1`2), dict(`p1`p2, `100`200)]));any1;"); |
| 479 | + System.out.println(re.getString()); |
| 480 | + assertEquals(bbb.getString(),re.getString()); |
| 481 | + } |
| 482 | + |
| 483 | + @Test |
| 484 | + public void test_BasicAnyVector_set_dict1() throws Exception { |
| 485 | + DBConnection conn = new DBConnection(); |
| 486 | + conn.connect(HOST, PORT, "admin", "123456"); |
| 487 | + String script= |
| 488 | + "try{undef(`st,SHARED)}catch(ex){}\n" + |
| 489 | + "share table(1000:0, `c1`c2,[STRING,ANY]) as st;\n" ; |
| 490 | + conn.run(script); |
| 491 | + Entity RE22 = conn.run("st"); |
| 492 | + BasicAnyVector anyVector = new BasicAnyVector(1); |
| 493 | + BasicDictionary dict = new BasicDictionary(DT_STRING, DT_ANY); |
| 494 | + BasicDictionary dictionaryAAA = new BasicDictionary(DT_STRING, DT_STRING); |
| 495 | + dictionaryAAA.put(new BasicString("p1"), new BasicString("1")); |
| 496 | + dictionaryAAA.put(new BasicString("p2"), new BasicString("2")); |
| 497 | + BasicDictionary dictionaryBBB = new BasicDictionary(DT_STRING, DT_STRING); |
| 498 | + dictionaryBBB.put(new BasicString("p1"), new BasicString("100")); |
| 499 | + dictionaryBBB.put(new BasicString("p2"), new BasicString("200")); |
| 500 | + dict.put(new BasicString("aaa"), dictionaryAAA); |
| 501 | + dict.put(new BasicString("bbb"), dictionaryBBB); |
| 502 | + anyVector.set(0, dict); |
| 503 | + System.out.println(anyVector.getString()); |
| 504 | + List<String> colNames = new ArrayList<>(); |
| 505 | + colNames.add("c1"); |
| 506 | + colNames.add("c2"); |
| 507 | + List<Vector> colVectors = new ArrayList<>(); |
| 508 | + BasicStringVector stringVector = new BasicStringVector(0); |
| 509 | + stringVector.add("test!"); |
| 510 | + colVectors.add(stringVector); |
| 511 | + colVectors.add(anyVector); |
| 512 | + |
| 513 | + BasicTable table = new BasicTable(colNames, colVectors); |
| 514 | + List<Entity> arguments = Arrays.asList(table); |
| 515 | + conn.run("tableInsert{st}", arguments); |
| 516 | + BasicTable bt = (BasicTable)conn.run("select * from st"); |
| 517 | + assertEquals(bt.getColumn(1).getString(), anyVector.getString()); |
| 518 | + } |
455 | 519 | } |
0 commit comments