|
14 | 14 | import java.io.ByteArrayOutputStream; |
15 | 15 | import java.io.IOException; |
16 | 16 | import java.io.PrintStream; |
| 17 | +import java.math.BigDecimal; |
17 | 18 | import java.text.SimpleDateFormat; |
18 | 19 | import java.time.*; |
19 | 20 | import java.time.format.DateTimeFormatter; |
@@ -1583,7 +1584,7 @@ public void test_insert_short() throws Exception { |
1583 | 1584 | "", "t1", false, false, null, 1, 1, |
1584 | 1585 | 1, "id"); |
1585 | 1586 | ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( (short)1, (short)1, (short)-1, (short)0, (short)-1); |
1586 | | - pErrorInfo=mutithreadTableWriter_.insert( null, (short)1, (short)1, (short)0, (short)1); |
| 1587 | + pErrorInfo = mutithreadTableWriter_.insert( null, (short)1, (short)1, (short)0, (short)1); |
1587 | 1588 | assertEquals("code= info=",pErrorInfo.toString()); |
1588 | 1589 | mutithreadTableWriter_.waitForThreadCompletion(); |
1589 | 1590 | BasicTable bt = (BasicTable) conn.run("select * from t1;"); |
@@ -2789,6 +2790,31 @@ public void test_insert_BasicType_in_java() throws Exception { |
2789 | 2790 | mutithreadTableWriter_.waitForThreadCompletion(); |
2790 | 2791 | } |
2791 | 2792 |
|
| 2793 | + //@Test(timeout = 120000) //AJ-822 |
| 2794 | + public void test_insert_arrayVector_insert_entity()throws Exception { |
| 2795 | + StringBuilder sb = new StringBuilder(); |
| 2796 | + sb.append("t = table(1000:0, `int`arrayv," + |
| 2797 | + "[INT,DECIMAL128(2)]);" + |
| 2798 | + "share t as t1;"); |
| 2799 | + int time=10240; |
| 2800 | + conn.run(sb.toString()); |
| 2801 | + mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456", |
| 2802 | + "", "t1", false, false,null,1, 1, |
| 2803 | + 1, "arrayv"); |
| 2804 | + for (short i=0;i<time;i++) { |
| 2805 | + ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( 1, new BigDecimal("1")); |
| 2806 | + assertEquals("code= info=",pErrorInfo.toString()); |
| 2807 | + } |
| 2808 | + mutithreadTableWriter_.waitForThreadCompletion(); |
| 2809 | + BasicTable bt= (BasicTable) conn.run("select * from t1;"); |
| 2810 | + System.out.println(bt.getString()); |
| 2811 | + assertEquals(time,bt.rows()); |
| 2812 | + for (int i=0;i<time;i++) { |
| 2813 | + assertEquals(0.0f, ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(0)).getNumber()); |
| 2814 | + assertEquals(Float.valueOf(i), ((Scalar)((BasicArrayVector)bt.getColumn("arrayv")).getVectorValue(i).get(1)).getNumber()); |
| 2815 | + } |
| 2816 | + } |
| 2817 | + |
2792 | 2818 | /** |
2793 | 2819 | * table types |
2794 | 2820 | * @throws Exception |
@@ -6907,146 +6933,114 @@ public void test_MultithreadedTableWriter_enableActualSendTime_not_support_setSt |
6907 | 6933 | conn.run("undef(`t1,SHARED)"); |
6908 | 6934 | } |
6909 | 6935 |
|
6910 | | - //@Test(timeout = 120000) |
| 6936 | + @Test(timeout = 120000) |
6911 | 6937 | public void test_MultithreadedTableWriter_allDataType_null() throws Exception { |
6912 | | - List<String> colNames = new ArrayList<String>(); |
6913 | | - colNames.add("boolv"); |
6914 | | - colNames.add("charv"); |
6915 | | - colNames.add("shortv"); |
6916 | | - colNames.add("intv"); |
6917 | | - colNames.add("longv"); |
6918 | | - colNames.add("doublev"); |
6919 | | - colNames.add("floatv"); |
6920 | | - colNames.add("datev"); |
6921 | | - colNames.add("monthv"); |
6922 | | - colNames.add("timev"); |
6923 | | - colNames.add("minutev"); |
6924 | | - colNames.add("secondv"); |
6925 | | - colNames.add("datetimev"); |
6926 | | - colNames.add("timestampv"); |
6927 | | - colNames.add("nanotimev"); |
6928 | | - colNames.add("nanotimestampv"); |
6929 | | - colNames.add("symbolv"); |
6930 | | - colNames.add("stringv"); |
6931 | | - colNames.add("uuidv"); |
6932 | | - colNames.add("datehourv"); |
6933 | | - colNames.add("ippaddrv"); |
6934 | | - colNames.add("int128v"); |
6935 | | - colNames.add("blobv"); |
6936 | | - colNames.add("complexv"); |
6937 | | - colNames.add("pointv"); |
6938 | | - colNames.add("decimal32v"); |
6939 | | - colNames.add("decimal64v"); |
6940 | | - colNames.add("decimal128V"); |
6941 | | - |
6942 | | - List<Vector> cols = new ArrayList<Vector>(); |
6943 | | - cols.add(new BasicBooleanVector(0)); |
6944 | | - cols.add(new BasicByteVector(0)); |
6945 | | - cols.add(new BasicShortVector(0)); |
6946 | | - cols.add(new BasicIntVector(0)); |
6947 | | - cols.add(new BasicLongVector(0)); |
6948 | | - cols.add(new BasicDoubleVector(0)); |
6949 | | - cols.add(new BasicFloatVector(0)); |
6950 | | - cols.add(new BasicDateVector(0)); |
6951 | | - cols.add(new BasicMonthVector(0)); |
6952 | | - cols.add(new BasicTimeVector(0)); |
6953 | | - cols.add(new BasicMinuteVector(0)); |
6954 | | - cols.add(new BasicSecondVector(0)); |
6955 | | - cols.add(new BasicDateTimeVector(0)); |
6956 | | - cols.add(new BasicTimestampVector(0)); |
6957 | | - cols.add(new BasicNanoTimeVector(0)); |
6958 | | - cols.add(new BasicNanoTimestampVector(0)); |
6959 | | - cols.add(new BasicSymbolVector(0)); |
6960 | | - cols.add(new BasicStringVector(0)); |
6961 | | - cols.add(new BasicUuidVector(0)); |
6962 | | - cols.add(new BasicDateHourVector(0)); |
6963 | | - cols.add(new BasicIPAddrVector(0)); |
6964 | | - cols.add(new BasicInt128Vector(0)); |
6965 | | - cols.add(new BasicStringVector(new String[0],true)); |
6966 | | - cols.add(new BasicComplexVector(0)); |
6967 | | - cols.add(new BasicPointVector(0)); |
6968 | | - cols.add(new BasicDecimal32Vector(0,0)); |
6969 | | - cols.add(new BasicDecimal64Vector(0,0)); |
6970 | | - cols.add(new BasicDecimal128Vector(0,0)); |
| 6938 | + BasicBoolean boolv = new BasicBoolean(true); |
| 6939 | + boolv.setNull(); |
| 6940 | + BasicByte charv = new BasicByte((byte)1); |
| 6941 | + charv.setNull(); |
| 6942 | + BasicShort shortv = new BasicShort((short)1); |
| 6943 | + shortv.setNull(); |
| 6944 | + BasicInt intv = new BasicInt(1); |
| 6945 | + intv.setNull(); |
| 6946 | + BasicLong longv = new BasicLong(1); |
| 6947 | + longv.setNull(); |
| 6948 | + BasicDouble doublev = new BasicDouble(1); |
| 6949 | + doublev.setNull(); |
| 6950 | + BasicFloat floatv = new BasicFloat(1); |
| 6951 | + floatv.setNull(); |
| 6952 | + BasicDate datev = new BasicDate(1); |
| 6953 | + datev.setNull(); |
| 6954 | + BasicMonth monthv = new BasicMonth(1); |
| 6955 | + monthv.setNull(); |
| 6956 | + BasicTime timev = new BasicTime(1); |
| 6957 | + timev.setNull(); |
| 6958 | + BasicMinute minutev = new BasicMinute(1); |
| 6959 | + minutev.setNull(); |
| 6960 | + BasicSecond secondv = new BasicSecond(1); |
| 6961 | + secondv.setNull(); |
| 6962 | + BasicDateTime datetimev = new BasicDateTime(1); |
| 6963 | + datetimev.setNull(); |
| 6964 | + BasicTimestamp timestampv = new BasicTimestamp(1); |
| 6965 | + timestampv.setNull(); |
| 6966 | + BasicNanoTime nanotimev = new BasicNanoTime(1); |
| 6967 | + nanotimev.setNull(); |
| 6968 | + BasicNanoTimestamp nanotimestampv = new BasicNanoTimestamp((byte)1); |
| 6969 | + nanotimestampv.setNull(); |
| 6970 | + BasicString symbolv = new BasicString("2"); |
| 6971 | + symbolv.setNull(); |
| 6972 | + BasicString stringv = new BasicString("1"); |
| 6973 | + stringv.setNull(); |
| 6974 | + BasicUuid uuidv = new BasicUuid(1,1); |
| 6975 | + uuidv.setNull(); |
| 6976 | + BasicDateHour datehourv = new BasicDateHour(1); |
| 6977 | + datehourv.setNull(); |
| 6978 | + BasicIPAddr ippaddrv = new BasicIPAddr(1,1); |
| 6979 | + ippaddrv.setNull(); |
| 6980 | + BasicInt128 int128v = new BasicInt128(1,1); |
| 6981 | + int128v.setNull(); |
| 6982 | + BasicString blobv = new BasicString("(byte)1",true); |
| 6983 | + blobv.setNull(); |
| 6984 | + BasicComplex complexv = new BasicComplex(1,1); |
| 6985 | + complexv.setNull(); |
| 6986 | + BasicPoint pointv = new BasicPoint(1,1); |
| 6987 | + pointv.setNull(); |
| 6988 | + BasicDecimal32 decimal32v = new BasicDecimal32("1.1",2); |
| 6989 | + decimal32v.setNull(); |
| 6990 | + BasicDecimal64 decimal64v = new BasicDecimal64("1.1",2); |
| 6991 | + decimal64v.setNull(); |
| 6992 | + BasicDecimal128 decimal128v = new BasicDecimal128("1.1",2); |
| 6993 | + decimal128v.setNull(); |
| 6994 | + |
6971 | 6995 | conn.run("dbPath = \"dfs://empty_table\";if(existsDatabase(dbPath)) dropDatabase(dbPath); \n" + |
6972 | 6996 | " db = database(dbPath, HASH,[STRING, 2],,\"TSDB\");\n " + |
6973 | 6997 | "t= table(100:0,`boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`symbolv`stringv`uuidv`datehourv`ippaddrv`int128v`blobv`complexv`pointv`decimal32v`decimal64v`decimal128v, " + |
6974 | 6998 | "[BOOL, CHAR, SHORT, INT, LONG, DOUBLE, FLOAT, DATE, MONTH, TIME, MINUTE, SECOND, DATETIME, TIMESTAMP, NANOTIME, NANOTIMESTAMP, SYMBOL, STRING, UUID, DATEHOUR, IPADDR, INT128, BLOB, complex, POINT, DECIMAL32(3), DECIMAL64(4),DECIMAL128(10) ]);\n" + |
6975 | 6999 | " pt=db.createPartitionedTable(t,`pt,`stringv,,`stringv);"); |
6976 | 7000 | mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456", "dfs://empty_table", "pt", false, false, null, 1, 1, 1, "stringv"); |
6977 | | - ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( cols); |
| 7001 | + ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,symbolv,stringv,uuidv,datehourv,ippaddrv,int128v,blobv,complexv,pointv,decimal32v,decimal64v,decimal128v); |
6978 | 7002 | assertEquals("code= info=",pErrorInfo.toString()); |
6979 | 7003 | mutithreadTableWriter_.waitForThreadCompletion(); |
6980 | 7004 | BasicTable bt = (BasicTable) conn.run("select * from loadTable(\"dfs://empty_table\",`pt);"); |
6981 | | - assertEquals(0, bt.rows()); |
| 7005 | + assertEquals(1, bt.rows()); |
| 7006 | + System.out.println(bt.getString()); |
6982 | 7007 | conn.close(); |
6983 | 7008 | } |
6984 | 7009 | //@Test(timeout = 120000) |
6985 | 7010 | public void test_MultithreadedTableWriter_allDataType_array_null() throws Exception { |
6986 | | - List<String> colNames = new ArrayList<String>(); |
6987 | | - colNames.add("boolv"); |
6988 | | - colNames.add("charv"); |
6989 | | - colNames.add("shortv"); |
6990 | | - colNames.add("intv"); |
6991 | | - colNames.add("longv"); |
6992 | | - colNames.add("doublev"); |
6993 | | - colNames.add("floatv"); |
6994 | | - colNames.add("datev"); |
6995 | | - colNames.add("monthv"); |
6996 | | - colNames.add("timev"); |
6997 | | - colNames.add("minutev"); |
6998 | | - colNames.add("secondv"); |
6999 | | - colNames.add("datetimev"); |
7000 | | - colNames.add("timestampv"); |
7001 | | - colNames.add("nanotimev"); |
7002 | | - colNames.add("nanotimestampv"); |
7003 | | - //colNames.add("symbolv"); |
7004 | | - //colNames.add("stringv"); |
7005 | | - colNames.add("uuidv"); |
7006 | | - colNames.add("datehourv"); |
7007 | | - colNames.add("ippaddrv"); |
7008 | | - colNames.add("int128v"); |
7009 | | - //colNames.add("blobv"); |
7010 | | - colNames.add("complexv"); |
7011 | | - colNames.add("pointv"); |
7012 | | - colNames.add("decimal32v"); |
7013 | | - colNames.add("decimal64v"); |
7014 | | - colNames.add("decimal128V"); |
7015 | | - |
7016 | | - List<Vector> cols = new ArrayList<Vector>(); |
7017 | | - cols.add(new BasicIntVector(0)); |
7018 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_BOOL_ARRAY,0)); |
7019 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_BYTE_ARRAY,0)); |
7020 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_SHORT_ARRAY,0)); |
7021 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_INT_ARRAY,0)); |
7022 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_LONG_ARRAY,0)); |
7023 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DOUBLE_ARRAY,0)); |
7024 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_FLOAT_ARRAY,0)); |
7025 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DATE_ARRAY,0)); |
7026 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_MONTH_ARRAY,0)); |
7027 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_TIME_ARRAY,0)); |
7028 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_MINUTE_ARRAY,0)); |
7029 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_SECOND_ARRAY,0)); |
7030 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DATETIME_ARRAY,0)); |
7031 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_TIMESTAMP_ARRAY,0)); |
7032 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_NANOTIME_ARRAY,0)); |
7033 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_NANOTIMESTAMP_ARRAY,0)); |
7034 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_UUID_ARRAY,0)); |
7035 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DATEHOUR_ARRAY,0)); |
7036 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_IPADDR_ARRAY,0)); |
7037 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_INT128_ARRAY,0)); |
7038 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_COMPLEX_ARRAY,0)); |
7039 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_POINT_ARRAY,0)); |
7040 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DECIMAL32_ARRAY,0,0)); |
7041 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DECIMAL64_ARRAY,0,0)); |
7042 | | - cols.add(new BasicArrayVector(Entity.DATA_TYPE.DT_DECIMAL128_ARRAY,0,0)); |
| 7011 | + BasicBooleanVector boolv = new BasicBooleanVector(0); |
| 7012 | + BasicByteVector charv = new BasicByteVector(0); |
| 7013 | + BasicShortVector shortv = new BasicShortVector(0); |
| 7014 | + BasicIntVector intv = new BasicIntVector(0); |
| 7015 | + BasicLongVector longv = new BasicLongVector(0); |
| 7016 | + BasicDoubleVector doublev = new BasicDoubleVector(0); |
| 7017 | + BasicFloatVector floatv = new BasicFloatVector(0); |
| 7018 | + BasicDateVector datev = new BasicDateVector(0); |
| 7019 | + BasicMonthVector monthv = new BasicMonthVector(0); |
| 7020 | + BasicTimeVector timev = new BasicTimeVector(0); |
| 7021 | + BasicMinuteVector minutev = new BasicMinuteVector(0); |
| 7022 | + BasicSecondVector secondv = new BasicSecondVector(0); |
| 7023 | + BasicDateTimeVector datetimev = new BasicDateTimeVector(0); |
| 7024 | + BasicTimestampVector timestampv = new BasicTimestampVector(0); |
| 7025 | + BasicNanoTimeVector nanotimev = new BasicNanoTimeVector(0); |
| 7026 | + BasicNanoTimestampVector nanotimestampv = new BasicNanoTimestampVector(0); |
| 7027 | + BasicUuidVector uuidv = new BasicUuidVector(0); |
| 7028 | + BasicDateHourVector datehourv = new BasicDateHourVector(0); |
| 7029 | + BasicIPAddrVector ippaddrv = new BasicIPAddrVector(0); |
| 7030 | + BasicInt128Vector int128v = new BasicInt128Vector(0); |
| 7031 | + BasicComplexVector complexv = new BasicComplexVector(0); |
| 7032 | + BasicPointVector pointv = new BasicPointVector(0); |
| 7033 | + BasicDecimal32Vector decimal32v = new BasicDecimal32Vector(0,0); |
| 7034 | + BasicDecimal64Vector decimal64v = new BasicDecimal64Vector(0,0); |
| 7035 | + BasicDecimal128Vector decimal128v = new BasicDecimal128Vector(0,0); |
| 7036 | + |
7043 | 7037 | conn.run("dbPath = \"dfs://empty_table\";if(existsDatabase(dbPath)) dropDatabase(dbPath); \n" + |
7044 | 7038 | " db = database(dbPath, HASH,[INT, 2],,\"TSDB\");\n " + |
7045 | 7039 | "t= table(100:0,`id`boolv`charv`shortv`intv`longv`doublev`floatv`datev`monthv`timev`minutev`secondv`datetimev`timestampv`nanotimev`nanotimestampv`uuidv`datehourv`ippaddrv`int128v`complexv`pointv`decimal32v`decimal64v`decimal128v, " + |
7046 | 7040 | "[INT, BOOL[], CHAR[], SHORT[], INT[], LONG[], DOUBLE[], FLOAT[], DATE[], MONTH[], TIME[], MINUTE[], SECOND[], DATETIME[], TIMESTAMP[], NANOTIME[], NANOTIMESTAMP[], UUID[], DATEHOUR[], IPADDR[], INT128[], COMPLEX[], POINT[], DECIMAL32(3)[], DECIMAL64(4)[],DECIMAL128(10)[] ]);\n" + |
7047 | 7041 | " pt=db.createPartitionedTable(t,`pt,`id,,`id);"); |
7048 | 7042 | mutithreadTableWriter_ = new MultithreadedTableWriter(HOST, PORT, "admin", "123456", "dfs://empty_table", "pt", false, false, null, 1, 1, 1, "id"); |
7049 | | - ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert( cols); |
| 7043 | + ErrorCodeInfo pErrorInfo = mutithreadTableWriter_.insert(null, boolv,charv,shortv,intv,longv,doublev,floatv,datev,monthv,timev,minutev,secondv,datetimev,timestampv,nanotimev,nanotimestampv,uuidv,datehourv,ippaddrv,int128v,complexv,pointv,decimal32v,decimal64v,decimal128v); |
7050 | 7044 | assertEquals("code= info=",pErrorInfo.toString()); |
7051 | 7045 | mutithreadTableWriter_.waitForThreadCompletion(); |
7052 | 7046 | BasicTable bt = (BasicTable) conn.run("select * from loadTable(\"dfs://empty_table\",`pt);"); |
@@ -7306,5 +7300,21 @@ public void test_MultithreadedTableWriter_table_any() throws Exception { |
7306 | 7300 | assertEquals(9, bt.rows()); |
7307 | 7301 | checkData(bt, bt1); |
7308 | 7302 | } |
| 7303 | + |
| 7304 | + //@Test(timeout = 120000)///这种情况有问题 |
| 7305 | + public void test_insert_array1() throws Exception { |
| 7306 | + DBConnection conn = new DBConnection(); |
| 7307 | + conn.connect("192.168.0.69",8848,"admin","123456"); |
| 7308 | + conn.run("share table(array(DECIMAL64(2)[]) as data) as tt"); |
| 7309 | + MultithreadedTableWriter writer = new MultithreadedTableWriter("192.168.0.69", 8848, "admin", "123456", "", "tt", |
| 7310 | + false, false, null, 1, 0.01f, 1, ""); |
| 7311 | + |
| 7312 | + ErrorCodeInfo re1 = writer.insert(new BasicDecimal64[]{new BasicDecimal64("1",2)}); |
| 7313 | + System.out.println(re1.toString()); |
| 7314 | + writer.waitForThreadCompletion(); |
| 7315 | + BasicTable rr=(BasicTable) conn.run("select * from tt"); |
| 7316 | + System.out.println(rr.getString()); |
| 7317 | + } |
| 7318 | + |
7309 | 7319 | } |
7310 | 7320 |
|
0 commit comments